Anonymous avatar Anonymous committed bbe01ee Merge

ooxml11: merge with DEV300 m82

Comments (0)

Files changed (495)

 e4a9ffc6a905e83572d34b47ffb9d1253c149af6 DEV300_m78
 4c02d2669043bd6f16d57ecbd21061d15745a613 DEV300_m79
 9f08556668b1565f293d735949e3b16d96e78651 DEV300_m80
+d3a11d2d353c2bf49d279018f2a59774484e9b38 DEV300_m81
+a5fb3c4091cbac8324a98bf080c08ef626b32258 DEV300_m82
Add a comment to this file

basic/source/runtime/methods.cxx

File contents unchanged.

chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx

 #include "chartview/ExplicitValueProvider.hxx"
 #include "chartview/DrawModelWrapper.hxx"
 #include "AxisHelper.hxx"
+#include "DiagramHelper.hxx"
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::chart2;
     return ChartModelHelper::findDiagram( this->getChartModel() );
 }
 
-ExplicitValueProvider* Chart2ModelContact::getExplicitValueProvider() const
+uno::Reference< lang::XUnoTunnel > Chart2ModelContact::getChartView() const
 {
     if(!m_xChartView.is())
     {
 	    if( xFact.is() )
             m_xChartView = Reference< lang::XUnoTunnel >( xFact->createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
     }
+    return m_xChartView;
+}
 
+ExplicitValueProvider* Chart2ModelContact::getExplicitValueProvider() const
+{
+    getChartView();
     if(!m_xChartView.is())
         return 0;
 
     return ChartModelHelper::getPageSize(m_xChartModel);
 }
 
-awt::Rectangle Chart2ModelContact::GetDiagramRectangleInclusive() const
+awt::Rectangle Chart2ModelContact::SubstractAxisTitleSizes( const awt::Rectangle& rPositionRect )
 {
-    awt::Rectangle aRect;
+    awt::Rectangle aRect = ExplicitValueProvider::substractAxisTitleSizes(
+        m_xChartModel, getChartView(), rPositionRect );
+    return aRect;
+}
 
-    ExplicitValueProvider* pProvider( getExplicitValueProvider() );
-    if( pProvider )
-    {
-        aRect = pProvider->getRectangleOfObject( lcl_getCIDForDiagram( m_xChartModel ) );
-    }
+awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingTitle() const
+{
+    awt::Rectangle aRect( GetDiagramRectangleIncludingAxes() );
+
     //add axis title sizes to the diagram size
-    aRect = ExplicitValueProvider::calculateDiagramPositionAndSizeInclusiveTitle(
-        m_xChartModel, m_xChartView, aRect );
+    aRect = ExplicitValueProvider::addAxisTitleSizes(
+        m_xChartModel, getChartView(), aRect );
 
     return aRect;
 }
 
-awt::Size Chart2ModelContact::GetDiagramSizeInclusive() const
+awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingAxes() const
 {
-    return ToSize( this->GetDiagramRectangleInclusive() );
+    awt::Rectangle aRect(0,0,0,0);
+    uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) );
+    
+    if( DiagramPositioningMode_INCLUDING == DiagramHelper::getDiagramPositioningMode( xDiagram ) )
+        aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel);
+    else
+    {
+        ExplicitValueProvider* pProvider( getExplicitValueProvider() );
+        if( pProvider )
+            aRect = pProvider->getRectangleOfObject( C2U("PlotAreaIncludingAxes") );
+    }
+    return aRect;
 }
 
-awt::Point Chart2ModelContact::GetDiagramPositionInclusive() const
+awt::Rectangle Chart2ModelContact::GetDiagramRectangleExcludingAxes() const
 {
-    return ToPoint( this->GetDiagramRectangleInclusive() );
+    awt::Rectangle aRect(0,0,0,0);
+    uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) );
+
+    if( DiagramPositioningMode_EXCLUDING == DiagramHelper::getDiagramPositioningMode( xDiagram ) )
+        aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel);
+    else
+    {
+        ExplicitValueProvider* pProvider( getExplicitValueProvider() );
+        if( pProvider )
+            aRect = pProvider->getDiagramRectangleExcludingAxes();
+    }
+    return aRect;
 }
 
 awt::Size Chart2ModelContact::GetLegendSize() const

chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx

      */
     ::com::sun::star::awt::Size GetPageSize() const;
 
-    /** Returns the size of the diagram object in logic coordinates inclusive
-        the space reserved for axis titles.
+    /** calculates the current axes title sizes and substract that space them from the given recangle
      */
-    ::com::sun::star::awt::Size GetDiagramSizeInclusive() const;
+    ::com::sun::star::awt::Rectangle SubstractAxisTitleSizes( const ::com::sun::star::awt::Rectangle& rPositionRect );
 
-    /** Returns the position of the diagram in logic coordinates inclusive
-        the space reserved for axis titles.
+    /** Returns the position and size of the diagram in logic coordinates (100th mm) including
+        the space used for axes including axes titles.
      */
-    ::com::sun::star::awt::Point GetDiagramPositionInclusive() const;
+    ::com::sun::star::awt::Rectangle GetDiagramRectangleIncludingTitle() const;
+
+    /** Returns the position and size of the diagram in logic coordinates (100th mm) including
+        the space used for axes excluding axes titles.
+     */
+    ::com::sun::star::awt::Rectangle GetDiagramRectangleIncludingAxes() const;
+
+    /** Returns the position and size of the diagram in logic coordinates (100th mm) excluding
+        the space used for axes (inner plot area).
+     */
+    ::com::sun::star::awt::Rectangle GetDiagramRectangleExcludingAxes() const;
 
     /** Returns the size of the object in logic coordinates.
      */
 
 private: //methods
     ExplicitValueProvider* getExplicitValueProvider() const;
-    ::com::sun::star::awt::Rectangle GetDiagramRectangleInclusive() const;
+    ::com::sun::star::uno::Reference<
+        ::com::sun::star::lang::XUnoTunnel > getChartView() const;
 
 public: //member
     ::com::sun::star::uno::Reference<

chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx

 #include "DisposeHelper.hxx"
 #include <comphelper/InlineContainer.hxx>
 #include "WrappedAutomaticPositionProperties.hxx"
+#include "CommonConverters.hxx"
 
 #include <com/sun/star/beans/PropertyAttribute.hpp>
 #include <com/sun/star/chart2/XTitled.hpp>
 awt::Point SAL_CALL DiagramWrapper::getPosition()
     throw (uno::RuntimeException)
 {
-    awt::Point aPosition;
-
-    Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() );
-    if( xProp.is() )
-    {
-        bool bSet = false;
-        chart2::RelativePosition aRelativePosition;
-        uno::Any aAPosition( xProp->getPropertyValue( C2U( "RelativePosition" ) ) );
-        if( aAPosition >>= aRelativePosition  )
-        {
-            awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() );
-            aPosition.X = static_cast<sal_Int32>(aRelativePosition.Primary*aPageSize.Width);
-            aPosition.Y = static_cast<sal_Int32>(aRelativePosition.Secondary*aPageSize.Height);
-
-            aPosition = RelativePositionHelper::getUpperLeftCornerOfAnchoredObject(
-                aPosition, DiagramWrapper::getSize(), aRelativePosition.Anchor );
-            
-            bSet = true;
-        }
-        if(!bSet)
-            aPosition =  m_spChart2ModelContact->GetDiagramPositionInclusive();
-    }
-
+    awt::Point aPosition = ToPoint( m_spChart2ModelContact->GetDiagramRectangleIncludingAxes() );
     return aPosition;
 }
 
 void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition )
     throw (uno::RuntimeException)
 {
+    ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
     Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() );
     if( xProp.is() )
     {
-        if( aPosition.X < 0 || aPosition.Y < 0 )
+        if( aPosition.X < 0 || aPosition.Y < 0 || aPosition.X > 1 || aPosition.Y > 1 )
         {
-            if( !TitleHelper::getTitle( TitleHelper::X_AXIS_TITLE, m_spChart2ModelContact->getChartModel() ).is() &&
-                !TitleHelper::getTitle( TitleHelper::Y_AXIS_TITLE, m_spChart2ModelContact->getChartModel() ).is() )
-            {
-                DBG_ERROR("DiagramWrapper::setPosition called with negative position -> automatic values are taken instead" );
-                uno::Any aEmpty;
-                xProp->setPropertyValue( C2U( "RelativePosition" ), aEmpty );
-                return;
-            }
-            //else: The saved didagram size does include the axis title sizes thus the position and size could be negative
+            DBG_ERROR("DiagramWrapper::setPosition called with a position out of range -> automatic values are taken instead" );
+            uno::Any aEmpty;
+            xProp->setPropertyValue( C2U( "RelativePosition" ), aEmpty );
+            return;
         }
 
         awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() );
         aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width);
         aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height);
         xProp->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) );
+        xProp->setPropertyValue( C2U( "PosSizeExcludeAxes" ), uno::makeAny(false) );
     }
 }
 
 awt::Size SAL_CALL DiagramWrapper::getSize()
     throw (uno::RuntimeException)
 {
-    awt::Size aSize;
-
-    Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() );
-    if( xProp.is() )
-    {
-        bool bSet = false;
-        chart2::RelativeSize aRelativeSize;
-        uno::Any aASize( xProp->getPropertyValue( C2U( "RelativeSize" ) ) );
-        if(aASize>>=aRelativeSize)
-        {
-            awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() );
-            aSize.Width = static_cast<sal_Int32>(aRelativeSize.Primary*aPageSize.Width);
-            aSize.Height = static_cast<sal_Int32>(aRelativeSize.Secondary*aPageSize.Height);
-            bSet = true;
-        }
-        if(!bSet)
-            aSize = m_spChart2ModelContact->GetDiagramSizeInclusive();
-    }
-        
+    awt::Size aSize = ToSize( m_spChart2ModelContact->GetDiagramRectangleIncludingAxes() );
     return aSize;
 }
 
     throw (beans::PropertyVetoException,
            uno::RuntimeException)
 {
+    ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
     Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() );
     if( xProp.is() )
     {
 
         if( aRelativeSize.Primary > 1 || aRelativeSize.Secondary > 1 )
         {
-            if( !TitleHelper::getTitle( TitleHelper::X_AXIS_TITLE, m_spChart2ModelContact->getChartModel() ).is() &&
-                !TitleHelper::getTitle( TitleHelper::Y_AXIS_TITLE, m_spChart2ModelContact->getChartModel() ).is() )
-            {
-                DBG_ERROR("DiagramWrapper::setSize called with sizes bigger than page -> automatic values are taken instead" );
-                uno::Any aEmpty;
-                xProp->setPropertyValue( C2U( "RelativeSize" ), aEmpty );
-                return;
-            }
-            //else: The saved didagram size does include the axis title sizes thus the position and size could be out of range
+            DBG_ERROR("DiagramWrapper::setSize called with sizes bigger than page -> automatic values are taken instead" );
+            uno::Any aEmpty;
+            xProp->setPropertyValue( C2U( "RelativeSize" ), aEmpty );
+            return;
         }
 
         xProp->setPropertyValue( C2U( "RelativeSize" ), uno::makeAny(aRelativeSize) );
+        xProp->setPropertyValue( C2U( "PosSizeExcludeAxes" ), uno::makeAny(false) );
     }
 }
 
 	return C2U( "com.sun.star.chart.Diagram" );
 }
 
+// ____ XDiagramPositioning ____
+
+void SAL_CALL DiagramWrapper::setAutomaticDiagramPositioning() throw (uno::RuntimeException)
+{
+    ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
+    uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY );
+    if( xDiaProps.is() )
+    {
+        xDiaProps->setPropertyValue( C2U( "RelativeSize" ), Any() );
+        xDiaProps->setPropertyValue( C2U( "RelativePosition" ), Any() );
+    }
+}
+::sal_Bool SAL_CALL DiagramWrapper::isAutomaticDiagramPositioning(  ) throw (uno::RuntimeException)
+{
+    uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY );
+    if( xDiaProps.is() )
+    {
+        Any aRelativeSize( xDiaProps->getPropertyValue( C2U( "RelativeSize" ) ) );
+        Any aRelativePosition( xDiaProps->getPropertyValue( C2U( "RelativePosition" ) ) );
+        if( aRelativeSize.hasValue() && aRelativePosition.hasValue() )
+            return false;
+    }
+    return true;
+}
+void SAL_CALL DiagramWrapper::setDiagramPositionExcludingAxes( const awt::Rectangle& rPositionRect ) throw (uno::RuntimeException)
+{
+    ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
+    DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getChartModel(), rPositionRect );
+    uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY );
+    if( xDiaProps.is() )
+        xDiaProps->setPropertyValue(C2U("PosSizeExcludeAxes"), uno::makeAny(true) );
+}
+::sal_Bool SAL_CALL DiagramWrapper::isExcludingDiagramPositioning() throw (uno::RuntimeException)
+{
+    uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY );
+    if( xDiaProps.is() )
+    {
+        Any aRelativeSize( xDiaProps->getPropertyValue( C2U( "RelativeSize" ) ) );
+        Any aRelativePosition( xDiaProps->getPropertyValue( C2U( "RelativePosition" ) ) );
+        if( aRelativeSize.hasValue() && aRelativePosition.hasValue() )
+        {
+            sal_Bool bPosSizeExcludeAxes = false;
+            xDiaProps->getPropertyValue( C2U( "PosSizeExcludeAxes" ) ) >>= bPosSizeExcludeAxes;
+            return bPosSizeExcludeAxes;
+        }
+    }
+    return false;
+}
+awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionExcludingAxes(  ) throw (uno::RuntimeException)
+{
+    return m_spChart2ModelContact->GetDiagramRectangleExcludingAxes();
+}
+void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxes( const awt::Rectangle& rPositionRect ) throw (uno::RuntimeException)
+{
+    ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
+    DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getChartModel(), rPositionRect );
+    uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY );
+    if( xDiaProps.is() )
+        xDiaProps->setPropertyValue(C2U("PosSizeExcludeAxes"), uno::makeAny(false) );
+}
+awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxes(  ) throw (uno::RuntimeException)
+{
+    return m_spChart2ModelContact->GetDiagramRectangleIncludingAxes();
+}
+void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxesAndAxisTitles( const awt::Rectangle& rPositionRect ) throw (uno::RuntimeException)
+{
+    ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
+    awt::Rectangle aRect( m_spChart2ModelContact->SubstractAxisTitleSizes(rPositionRect) );
+    DiagramWrapper::setDiagramPositionIncludingAxes( aRect );
+}
+::com::sun::star::awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxesAndAxisTitles(  ) throw (::com::sun::star::uno::RuntimeException)
+{
+    return m_spChart2ModelContact->GetDiagramRectangleIncludingTitle();
+}
+
 // ____ XAxisZSupplier ____
 Reference<
     drawing::XShape > SAL_CALL DiagramWrapper::getZAxisTitle()

chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx

 #include "WrappedPropertySet.hxx"
 #include "ServiceMacros.hxx"
 #include "DiagramHelper.hxx"
-#include <cppuhelper/implbase11.hxx>
+#include <cppuhelper/implbase12.hxx>
 #include <comphelper/uno3.hxx>
 #include <cppuhelper/interfacecontainer.hxx>
 #include <com/sun/star/chart2/XChartDocument.hpp>
 #include <com/sun/star/chart2/XDiagram.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/chart/XDiagramPositioning.hpp>
 #include <com/sun/star/chart2/XDiagramProvider.hpp>
 #include <com/sun/star/chart2/XChartTypeTemplate.hpp>
 #include <com/sun/star/chart2/XChartTypeManager.hpp>
 
 class Chart2ModelContact;
 
-class DiagramWrapper : public ::cppu::ImplInheritanceHelper11<
+class DiagramWrapper : public ::cppu::ImplInheritanceHelper12<
                       WrappedPropertySet
                      , ::com::sun::star::chart::XDiagram
                      , ::com::sun::star::chart::XAxisZSupplier
 	                 , ::com::sun::star::lang::XServiceInfo
    	                 , ::com::sun::star::lang::XComponent
 //                      , ::com::sun::star::lang::XEventListener
+                     , ::com::sun::star::chart::XDiagramPositioning
                      , ::com::sun::star::chart2::XDiagramProvider
                      , ::com::sun::star::chart::XSecondAxisTitleSupplier
                     >
 //     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
 //         throw (::com::sun::star::uno::RuntimeException);
 
+    // ____ XDiagramPositioning ____
+
+    virtual void SAL_CALL setAutomaticDiagramPositioning(  ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::sal_Bool SAL_CALL isAutomaticDiagramPositioning(  ) throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setDiagramPositionExcludingAxes( const ::com::sun::star::awt::Rectangle& PositionRect ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::sal_Bool SAL_CALL isExcludingDiagramPositioning(  ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::com::sun::star::awt::Rectangle SAL_CALL calculateDiagramPositionExcludingAxes(  ) throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setDiagramPositionIncludingAxes( const ::com::sun::star::awt::Rectangle& PositionRect ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::com::sun::star::awt::Rectangle SAL_CALL calculateDiagramPositionIncludingAxes(  ) throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setDiagramPositionIncludingAxesAndAxisTitles( const ::com::sun::star::awt::Rectangle& PositionRect ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::com::sun::star::awt::Rectangle SAL_CALL calculateDiagramPositionIncludingAxesAndAxisTitles(  ) throw (::com::sun::star::uno::RuntimeException);
+
     // ____ XDiagramProvider ____
     virtual ::com::sun::star::uno::Reference<
             ::com::sun::star::chart2::XDiagram > SAL_CALL getDiagram()
Add a comment to this file

chart2/source/controller/dialogs/ResourceIds.hrc

File contents unchanged.

Add a comment to this file

chart2/source/controller/dialogs/Strings.src

File contents unchanged.

chart2/source/controller/dialogs/TabPages.hrc

 ////#define RBT_DOWNUP 3
 ////#define RBT_AUTOORDER 4
 
-//#define TP_STAT                   905
 #define FL_TEXTBREAK                3
 #define CBX_TEXTBREAK               2
 #define CBX_TEXTOVERLAP             4
Add a comment to this file

chart2/source/controller/dialogs/dlg_ObjectProperties.cxx

File contents unchanged.

Add a comment to this file

chart2/source/controller/dialogs/makefile.mk

File contents unchanged.

chart2/source/controller/drawinglayer/DrawViewWrapper.cxx

 #include "DrawViewWrapper.hxx"
 #include "chartview/DrawModelWrapper.hxx"
 #include "ConfigurationAccess.hxx"
+#include "macros.hxx"
 
 #include <unotools/lingucfg.hxx>
 #include <editeng/langitem.hxx>
 
     if( pRet )
     {
+        //ignore some special shapes
+        rtl::OUString aShapeName = pRet->GetName(); 
+        if( aShapeName.match(C2U("PlotAreaIncludingAxes")) || aShapeName.match(C2U("PlotAreaExcludingAxes")) )
+        {
+            pRet->SetMarkProtect( true );
+            return getHitObject( rPnt );
+        }
+
         //3d objects need a special treatment
         //because the simple PickObj method is not accurate in this case for performance reasons
         E3dObject* pE3d = dynamic_cast< E3dObject* >(pRet);

chart2/source/controller/inc/PositionAndSizeHelper.hxx

     static bool moveObject( const rtl::OUString& rObjectCID
             , const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel
             , const ::com::sun::star::awt::Rectangle& rNewPositionAndSize
-            , const ::com::sun::star::awt::Rectangle& rPageRectangle
-            , ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xChartView );
+            , const ::com::sun::star::awt::Rectangle& rPageRectangle );
 };
 
 //.............................................................................

chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx

     0
 };
 
-const USHORT nChartWhichPairs[] =
-{
-	SCHATTR_STYLE_START,SCHATTR_STYLE_END,			//    59 -    68  sch/schattr.hxx
-	0
-};
-
-const USHORT nDiagramAreaWhichPairs[] =
-{
-	XATTR_LINE_FIRST, XATTR_LINE_LAST,				//  1000 -  1016  svx/xdef.hxx
-	XATTR_FILL_FIRST, XATTR_FILL_LAST,				//  1018 -  1046  svx/xdef.hxx
-	0
-};
-
-const USHORT nAreaAndChartWhichPairs[] =   // pairs for chart AND area
-{
-	XATTR_LINE_FIRST, XATTR_LINE_LAST,				//  1000 -  1016  svx/xdef.hxx
-	XATTR_FILL_FIRST, XATTR_FILL_LAST,				//  1018 -  1046  svx/xdef.hxx
-	SCHATTR_STYLE_START,SCHATTR_STYLE_END,			//    59 -    68  sch/schattr.hxx
-	0
-};
-
 const USHORT nLegendWhichPairs[] =
 {
 	XATTR_LINE_FIRST, XATTR_LINE_LAST,				//  1000 -  1016  svx/xdef.hxx
Add a comment to this file

chart2/source/controller/itemsetwrapper/makefile.mk

File contents unchanged.

chart2/source/controller/main/ChartController.hxx

     void impl_SetMousePointer( const MouseEvent & rEvent );
 
     void impl_ClearSelection();
+
+    void impl_switchDiagramPositioningToExcludingPositioning();
 };
 
 //.............................................................................

chart2/source/controller/main/ChartController_Position.cxx

                 bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID()
                             , m_aModel->getModel()
                             , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight())
-                            , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight())
-                            , m_xChartView );
+                            , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) );
                 if( bChanged )
                     aUndoGuard.commitAction();
             }
Add a comment to this file

chart2/source/controller/main/ChartController_Properties.cxx

File contents unchanged.

chart2/source/controller/main/ChartController_Tools.cxx

 #include "RegressionCurveHelper.hxx"
 #include "ShapeController.hxx"
 #include "DiagramHelper.hxx"
+#include "ObjectNameProvider.hxx"
 
 #include <com/sun/star/chart2/DataPointLabel.hpp>
 #include <com/sun/star/beans/XPropertyState.hpp>
             Reference< beans::XPropertyState > xState( xDiagram, uno::UNO_QUERY_THROW );
             xState->setPropertyToDefault( C2U("RelativeSize"));
             xState->setPropertyToDefault( C2U("RelativePosition"));
+            xState->setPropertyToDefault( C2U("PosSizeExcludeAxes"));
 
             // 3d rotation
             ThreeDHelper::set3DSettingsToDefault( uno::Reference< beans::XPropertySet >( xDiagram, uno::UNO_QUERY ) );
             m_aSelection.applySelection( m_pDrawViewWrapper );
 
             m_pDrawViewWrapper->EndUndo();
+
+            impl_switchDiagramPositioningToExcludingPositioning();
         }
     }
 }
                     m_pDrawViewWrapper->BegUndo( SVX_RESSTR( RID_SVX_3D_UNDO_EXCHANGE_PASTE ) );
                     m_pDrawViewWrapper->AddUndo( new SdrUndoInsertObj( *pObj ) );
                     m_pDrawViewWrapper->EndUndo();
+
+                    impl_switchDiagramPositioningToExcludingPositioning();
                 }
             }
             catch ( const uno::Exception& ex )
     }
 }
 
+void ChartController::impl_switchDiagramPositioningToExcludingPositioning()
+{
+    UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription(
+        ActionDescriptionProvider::POS_SIZE,
+        ObjectNameProvider::getName( OBJECTTYPE_DIAGRAM)),
+        m_xUndoManager, m_aModel->getModel() );
+    if( DiagramHelper::switchDiagramPositioningToExcludingPositioning( m_aModel->getModel(), true, true ) )
+        aUndoGuard.commitAction();
+}
+
 } //  namespace chart

chart2/source/controller/main/ChartController_Window.cxx

         if ( m_eDrawMode == CHARTDRAW_INSERT && pDrawViewWrapper->IsCreateObj() )
         {
             pDrawViewWrapper->EndCreateObj( SDRCREATE_FORCEEND );
+            impl_switchDiagramPositioningToExcludingPositioning();
             if ( pDrawViewWrapper->AreObjectsMarked() )
             {
                 if ( pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_TEXT )
                         bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID()
                                         , m_aModel->getModel()
                                         , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight())
-                                        , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight())
-                                        , m_xChartView );
+                                        , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) );
                         if( bChanged )
                         {
                             bDraggingDone = true;

chart2/source/controller/main/PositionAndSizeHelper.cxx

     {
         //@todo decide wether x is primary or secondary
 
-        //xChartView
-
         //set position:
         chart2::RelativePosition aRelativePosition;
         aRelativePosition.Anchor = drawing::Alignment_CENTER;
                 , const uno::Reference< frame::XModel >& xChartModel
                 , const awt::Rectangle& rNewPositionAndSize
                 , const awt::Rectangle& rPageRectangle
-                , uno::Reference< uno::XInterface > xChartView
                 )
 {
     ControllerLockGuard aLockedControllers( xChartModel );
         xObjectProp = uno::Reference< beans::XPropertySet >( ObjectIdentifier::getDiagramForCID( rObjectCID, xChartModel ), uno::UNO_QUERY );
         if(!xObjectProp.is())
             return false;
-
-        //add axis title sizes to the diagram size
-        aNewPositionAndSize = ExplicitValueProvider::calculateDiagramPositionAndSizeInclusiveTitle(
-            xChartModel, xChartView, rNewPositionAndSize );
     }
     return moveObject( eObjectType, xObjectProp, aNewPositionAndSize, rPageRectangle );
 }

chart2/source/inc/DiagramHelper.hxx

 namespace chart
 {
 
+enum DiagramPositioningMode
+{
+    DiagramPositioningMode_AUTO,
+    DiagramPositioningMode_EXCLUDING,
+    DiagramPositioningMode_INCLUDING
+};
+
 class OOO_DLLPUBLIC_CHARTTOOLS DiagramHelper
 {
 public:
             const ::com::sun::star::uno::Reference<
                 ::com::sun::star::chart2::XChartType >& xChartType );
 
+    static DiagramPositioningMode getDiagramPositioningMode( const ::com::sun::star::uno::Reference<
+                ::com::sun::star::chart2::XDiagram > & xDiagram );
+
+    static bool setDiagramPositioning( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel,
+        const ::com::sun::star::awt::Rectangle& rPosRect /*100th mm*/ );
+
+    static ::com::sun::star::awt::Rectangle getDiagramRectangleFromModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel );
+
+    static bool switchDiagramPositioningToExcludingPositioning( const ::com::sun::star::uno::Reference<
+        ::com::sun::star::frame::XModel >& xChartModel
+        , bool bResetModifiedState //set model back to unchanged if it was unchanged before
+        , bool bConvertAlsoFromAutoPositioning );
+
 private:
     // not implemented
     DiagramHelper();
Add a comment to this file

chart2/source/inc/ObjectIdentifier.hxx

File contents unchanged.

Add a comment to this file

chart2/source/inc/Strings.hrc

File contents unchanged.

Add a comment to this file

chart2/source/inc/chartview/ChartSfxItemIds.hxx

File contents unchanged.

chart2/source/inc/chartview/ExplicitValueProvider.hxx

     virtual ::com::sun::star::awt::Rectangle
         getRectangleOfObject( const rtl::OUString& rObjectCID, bool bSnapRect=false )=0;
 
+    virtual ::com::sun::star::awt::Rectangle getDiagramRectangleExcludingAxes()=0;
+
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
         getShapeForCID( const rtl::OUString& rObjectCID )=0;
 
     static ExplicitValueProvider* getExplicitValueProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xChartView );
 
     static ::com::sun::star::awt::Rectangle
-        calculateDiagramPositionAndSizeInclusiveTitle(
+        addAxisTitleSizes(
             const ::com::sun::star::uno::Reference<
                 ::com::sun::star::frame::XModel >& xChartModel
             , const ::com::sun::star::uno::Reference<
                 ::com::sun::star::uno::XInterface >& xChartView
-            , const ::com::sun::star::awt::Rectangle& rExclusivePositionAndSize );
+            , const ::com::sun::star::awt::Rectangle& rExcludingPositionAndSize );
+
+    static ::com::sun::star::awt::Rectangle
+        substractAxisTitleSizes(
+            const ::com::sun::star::uno::Reference<
+                ::com::sun::star::frame::XModel >& xChartModel
+            , const ::com::sun::star::uno::Reference<
+                ::com::sun::star::uno::XInterface >& xChartView
+            , const ::com::sun::star::awt::Rectangle& rPositionAndSizeIncludingTitles );
 
     static sal_Int32 getExplicitNumberFormatKeyForAxis(
               const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis

chart2/source/model/main/Diagram.cxx

 {
     PROP_DIAGRAM_REL_POS,
     PROP_DIAGRAM_REL_SIZE,
+    PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS,
     PROP_DIAGRAM_SORT_BY_X_VALUES,
     PROP_DIAGRAM_CONNECT_BARS,
     PROP_DIAGRAM_GROUP_BARS_PER_AXIS,
                   | beans::PropertyAttribute::MAYBEVOID ));
 
     rOutProperties.push_back(
+        Property( C2U( "PosSizeExcludeAxes" ),
+                  PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS,
+                  ::getBooleanCppuType(),
+                  beans::PropertyAttribute::BOUND
+                  | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+    rOutProperties.push_back(
         Property( C2U( "SortByXValues" ),
                   PROP_DIAGRAM_SORT_BY_X_VALUES,
                   ::getBooleanCppuType(),
 void lcl_AddDefaultsToMap(
     ::chart::tPropertyValueMap & rOutMap )
 {
+    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, true );
     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false );
     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_CONNECT_BARS, false );
     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true );

chart2/source/tools/DiagramHelper.cxx

 #include "CommonConverters.hxx"
 #include "ExplicitCategoriesProvider.hxx"
 #include "servicenames_charttypes.hxx"
+#include "ChartModelHelper.hxx"
+#include "RelativePositionHelper.hxx"
+#include "ControllerLockGuard.hxx"
 
 #include <com/sun/star/chart/MissingValueTreatment.hpp>
+#include <com/sun/star/chart/XChartDocument.hpp>
+#include <com/sun/star/chart/XDiagramPositioning.hpp>
 #include <com/sun/star/chart2/XTitled.hpp>
 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
 #include <com/sun/star/chart2/XChartTypeTemplate.hpp>
 #include <com/sun/star/chart2/InterpretedData.hpp>
 #include <com/sun/star/chart2/AxisType.hpp>
 #include <com/sun/star/chart2/DataPointGeometry3D.hpp>
-#include <com/sun/star/drawing/ShadeMode.hpp>
+#include <com/sun/star/chart2/RelativePosition.hpp>
+#include <com/sun/star/chart2/RelativeSize.hpp>
 
+#include <unotools/saveopt.hxx>
 #include <rtl/math.hxx>
 
+#include <com/sun/star/util/XModifiable.hpp>
+
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::chart2;
 using namespace ::std;
     return nResult;
 }
 
+//static
+DiagramPositioningMode DiagramHelper::getDiagramPositioningMode( const uno::Reference<
+                chart2::XDiagram > & xDiagram )
+{
+    DiagramPositioningMode eMode = DiagramPositioningMode_AUTO;
+    uno::Reference< beans::XPropertySet > xDiaProps( xDiagram, uno::UNO_QUERY );
+    if( xDiaProps.is() )
+    {
+        RelativePosition aRelPos;
+        RelativeSize aRelSize;
+        if( (xDiaProps->getPropertyValue(C2U("RelativePosition")) >>= aRelPos ) &&
+            (xDiaProps->getPropertyValue(C2U("RelativeSize")) >>= aRelSize ) )
+        {
+            bool bPosSizeExcludeAxes=false;
+            xDiaProps->getPropertyValue(C2U("PosSizeExcludeAxes")) >>= bPosSizeExcludeAxes;
+            if( bPosSizeExcludeAxes )
+                eMode = DiagramPositioningMode_EXCLUDING;
+            else
+                eMode = DiagramPositioningMode_INCLUDING;
+        }
+    }
+    return eMode;
+}
+
+void lcl_ensureRange0to1( double& rValue )
+{
+    if(rValue<0.0)
+        rValue=0.0;
+    if(rValue>1.0)
+        rValue=1.0;
+}
+
+//static
+bool DiagramHelper::setDiagramPositioning( const uno::Reference< frame::XModel >& xChartModel,
+        const awt::Rectangle& rPosRect /*100th mm*/ )
+{
+    ControllerLockGuard aCtrlLockGuard( xChartModel );
+
+    bool bChanged = false;
+    awt::Size aPageSize( ChartModelHelper::getPageSize(xChartModel) );
+    uno::Reference< beans::XPropertySet > xDiaProps( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY );
+    if( !xDiaProps.is() )
+        return bChanged;
+
+    RelativePosition aOldPos;
+    RelativeSize aOldSize;
+    xDiaProps->getPropertyValue(C2U("RelativePosition") ) >>= aOldPos;
+    xDiaProps->getPropertyValue(C2U("RelativeSize") ) >>= aOldSize;
+
+    RelativePosition aNewPos;
+    aNewPos.Anchor = drawing::Alignment_TOP_LEFT;
+    aNewPos.Primary = double(rPosRect.X)/double(aPageSize.Width);
+    aNewPos.Secondary = double(rPosRect.Y)/double(aPageSize.Height);
+    
+    chart2::RelativeSize aNewSize;
+    aNewSize.Primary = double(rPosRect.Width)/double(aPageSize.Width);
+    aNewSize.Secondary = double(rPosRect.Height)/double(aPageSize.Height);
+
+    lcl_ensureRange0to1( aNewPos.Primary );
+    lcl_ensureRange0to1( aNewPos.Secondary );
+    lcl_ensureRange0to1( aNewSize.Primary );
+    lcl_ensureRange0to1( aNewSize.Secondary );
+    if( (aNewPos.Primary + aNewSize.Primary) > 1.0 )
+        aNewPos.Primary = 1.0 - aNewSize.Primary;
+    if( (aNewPos.Secondary + aNewSize.Secondary) > 1.0 )
+        aNewPos.Secondary = 1.0 - aNewSize.Secondary;
+    
+    xDiaProps->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aNewPos) );
+    xDiaProps->setPropertyValue( C2U( "RelativeSize" ), uno::makeAny(aNewSize) );
+
+    bChanged = (aOldPos.Anchor!=aNewPos.Anchor) ||
+        (aOldPos.Primary!=aNewPos.Primary) ||
+        (aOldPos.Secondary!=aNewPos.Secondary) ||
+        (aOldSize.Primary!=aNewSize.Primary) ||
+        (aOldSize.Secondary!=aNewSize.Secondary);
+    return bChanged;
+}
+
+//static
+awt::Rectangle DiagramHelper::getDiagramRectangleFromModel( const uno::Reference< frame::XModel >& xChartModel )
+{
+    awt::Rectangle aRet(-1,-1,-1,-1);
+
+    uno::Reference< beans::XPropertySet > xDiaProps( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY );
+    if( !xDiaProps.is() )
+        return aRet;
+
+    awt::Size aPageSize( ChartModelHelper::getPageSize(xChartModel) );
+
+    RelativePosition aRelPos;
+    RelativeSize aRelSize;
+    xDiaProps->getPropertyValue(C2U("RelativePosition") ) >>= aRelPos;
+    xDiaProps->getPropertyValue(C2U("RelativeSize") ) >>= aRelSize;
+
+    awt::Size aAbsSize(
+        aRelSize.Primary * aPageSize.Width,
+        aRelSize.Secondary * aPageSize.Height );
+    
+    awt::Point aAbsPos(
+        static_cast< sal_Int32 >( aRelPos.Primary * aPageSize.Width ),
+        static_cast< sal_Int32 >( aRelPos.Secondary * aPageSize.Height ));
+
+    awt::Point aAbsPosLeftTop = RelativePositionHelper::getUpperLeftCornerOfAnchoredObject( aAbsPos, aAbsSize, aRelPos.Anchor );
+
+    aRet = awt::Rectangle(aAbsPosLeftTop.X, aAbsPosLeftTop.Y, aAbsSize.Width, aAbsSize.Height );
+    
+    return aRet;
+}
+
+//static
+bool DiagramHelper::switchDiagramPositioningToExcludingPositioning(
+    const uno::Reference< frame::XModel >& xChartModel
+    , bool bResetModifiedState, bool bConvertAlsoFromAutoPositioning )
+{
+    //return true if something was changed
+    const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
+    if( nCurrentODFVersion == SvtSaveOptions::ODFVER_LATEST )//#i100778# todo: change this dependent on fileformat evolution
+    {
+        uno::Reference< ::com::sun::star::chart::XChartDocument > xOldDoc( xChartModel, uno::UNO_QUERY ) ;
+        if( xOldDoc.is() )
+        {
+            uno::Reference< ::com::sun::star::chart::XDiagramPositioning > xDiagramPositioning( xOldDoc->getDiagram(), uno::UNO_QUERY );
+            if( xDiagramPositioning.is() && ( bConvertAlsoFromAutoPositioning || !xDiagramPositioning->isAutomaticDiagramPositioning() )
+                && !xDiagramPositioning->isExcludingDiagramPositioning() )
+            {
+                ControllerLockGuard aCtrlLockGuard( xChartModel );
+                uno::Reference< util::XModifiable > xModifiable( xChartModel, uno::UNO_QUERY );
+                bool bModelWasModified = xModifiable.is() && xModifiable->isModified();
+                xDiagramPositioning->setDiagramPositionExcludingAxes( xDiagramPositioning->calculateDiagramPositionExcludingAxes() );
+                if(bResetModifiedState && !bModelWasModified && xModifiable.is() )
+                    xModifiable->setModified(sal_False);
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
 } //  namespace chart

chart2/source/view/charttypes/PieChart.cxx

 //-----------------------------------------------------------------------------
 
 PieChart::PieChart( const uno::Reference<XChartType>& xChartTypeModel
-                   , sal_Int32 nDimensionCount )
+                   , sal_Int32 nDimensionCount
+                   , bool bExcludingPositioning )
         : VSeriesPlotter( xChartTypeModel, nDimensionCount )
         , m_pPosHelper( new PiePositionHelper( NormalAxis_Z, (m_nDimension==3)?0.0:90.0 ) )
         , m_bUseRings(false)
+        , m_bSizeExcludesLabelsAndExplodedSegments(bExcludingPositioning)
 {
     ::rtl::math::setNan(&m_fMaxOffset);
 
     return true;
 }
 
+bool PieChart::shouldSnapRectToUsedArea()
+{
+    return true;
+}
+
 //-----------------------------------------------------------------
 // lang::XServiceInfo
 //-----------------------------------------------------------------
     if(fExplodePercentage>m_fMaxOffset)
         m_fMaxOffset=fExplodePercentage;
 
-    uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
-    if( xSeriesProp->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aAttributedDataPointIndexList )
+    if(!m_bSizeExcludesLabelsAndExplodedSegments)
     {
-        for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
+        uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
+        if( xSeriesProp->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aAttributedDataPointIndexList )
         {
-            uno::Reference< beans::XPropertySet > xPointProp( pSeries->getPropertiesOfPoint(aAttributedDataPointIndexList[nN]) );
-            if(xPointProp.is())
+            for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
             {
-                fExplodePercentage=0.0;
-                xPointProp->getPropertyValue( C2U( "Offset" )) >>= fExplodePercentage;
-                if(fExplodePercentage>m_fMaxOffset)
-                    m_fMaxOffset=fExplodePercentage;
+                uno::Reference< beans::XPropertySet > xPointProp( pSeries->getPropertiesOfPoint(aAttributedDataPointIndexList[nN]) );
+                if(xPointProp.is())
+                {
+                    fExplodePercentage=0.0;
+                    xPointProp->getPropertyValue( C2U( "Offset" )) >>= fExplodePercentage;
+                    if(fExplodePercentage>m_fMaxOffset)
+                        m_fMaxOffset=fExplodePercentage;
+                }
             }
         }
     }
         for( nPointIndex = 0; nPointIndex < nPointCount; nPointIndex++ )
         {
             double fLogicInnerRadius, fLogicOuterRadius;
-            bool bIsVisible = m_pPosHelper->getInnerAndOuterRadius( fSlotX+1.0, fLogicInnerRadius, fLogicOuterRadius, m_bUseRings, getMaxOffset() );
+            double fOffset = getMaxOffset();
+            bool bIsVisible = m_pPosHelper->getInnerAndOuterRadius( fSlotX+1.0, fLogicInnerRadius, fLogicOuterRadius, m_bUseRings, fOffset );
             if( !bIsVisible )
                 continue;
 

chart2/source/view/charttypes/PieChart.hxx

 public:
     PieChart( const ::com::sun::star::uno::Reference<
             ::com::sun::star::chart2::XChartType >& xChartTypeModel
-            , sal_Int32 nDimensionCount );
+            , sal_Int32 nDimensionCount, bool bExcludingPositioning );
 	virtual ~PieChart();
 
 	//-------------------------------------------------------------------------
 
     virtual void SAL_CALL createShapes();
     virtual void rearrangeLabelToAvoidOverlapIfRequested( const ::com::sun::star::awt::Size& rPageSize );
-
+    
     virtual void SAL_CALL setScales(
           const ::com::sun::star::uno::Sequence<
             ::com::sun::star::chart2::ExplicitScaleData >& rScales
     //-------------------
     virtual ::com::sun::star::drawing::Direction3D  getPreferredDiagramAspectRatio() const;
     virtual bool keepAspectRatio() const;
+    virtual bool shouldSnapRectToUsedArea();
 
     //MinimumAndMaximumSupplier
     virtual double getMinimumX();
 private: //member
     PiePositionHelper*    m_pPosHelper;
     bool                  m_bUseRings;
+    bool                  m_bSizeExcludesLabelsAndExplodedSegments;
 
     struct PieLabelInfo
     {

chart2/source/view/charttypes/VSeriesPlotter.cxx

     return ChartTypeHelper::isSeriesInFrontOfAxisLine( m_xChartTypeModel );
 }
 
+bool VSeriesPlotter::shouldSnapRectToUsedArea()
+{
+    if( m_nDimension == 3 )
+        return false;
+    return true;
+}
+
 Sequence< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntries(
               LegendExpansion eLegendExpansion
             , const Reference< beans::XPropertySet >& xTextProperties
 //static
 VSeriesPlotter* VSeriesPlotter::createSeriesPlotter(
     const uno::Reference<XChartType>& xChartTypeModel
-    , sal_Int32 nDimensionCount )
+    , sal_Int32 nDimensionCount
+    , bool bExcludingPositioning )
 {
     rtl::OUString aChartType = xChartTypeModel->getChartType();
 
     else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
         pRet = new BubbleChart(xChartTypeModel,nDimensionCount);
     else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
-        pRet = new PieChart(xChartTypeModel,nDimensionCount);
+        pRet = new PieChart(xChartTypeModel,nDimensionCount, bExcludingPositioning );
     else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
         pRet = new AreaChart(xChartTypeModel,nDimensionCount,true,true,new PolarPlottingPositionHelper(),true,false,1,drawing::Direction3D(1,1,1) );
     else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )

chart2/source/view/diagram/VDiagram.cxx

 #include <com/sun/star/lang/XTypeProvider.hpp>
 // header for class SvxShape
 #include <svx/unoshape.hxx>
+// header for GetSdrObjectFromXShape
+#include <svx/unoapi.hxx>
 // header for class E3dScene
 #include <svx/scene3d.hxx>
 #include <rtl/math.hxx>
     uno::Reference< drawing::XShapes > xOuterGroup_Shapes = m_pShapeFactory->createGroup2D(m_xLogicTarget);
     m_xOuterGroupShape = uno::Reference<drawing::XShape>( xOuterGroup_Shapes, uno::UNO_QUERY );
 
+    uno::Reference< drawing::XShapes > xGroupForWall( m_pShapeFactory->createGroup2D(xOuterGroup_Shapes,C2U("PlotAreaExcludingAxes")) );
+
     //create independent group shape as container for datapoints and such things
     {
         uno::Reference< drawing::XShapes > xShapes = m_pShapeFactory->createGroup2D(xOuterGroup_Shapes,C2U("testonly;CooContainer=XXX_CID"));
             "com.sun.star.drawing.RectangleShape" ) ), uno::UNO_QUERY );
         //m_xWall2D->setPosition(m_aAvailablePosIncludingAxes);
         //m_xWall2D->setSize(m_aAvailableSizeIncludingAxes);
-        uno::Reference< drawing::XShapes > xShapes( m_xCoordinateRegionShape, uno::UNO_QUERY );
-        xShapes->add(m_xWall2D);
+        xGroupForWall->add(m_xWall2D);
         uno::Reference< beans::XPropertySet > xProp( m_xWall2D, uno::UNO_QUERY );
         if( xProp.is())
 	    {
     m_xOuterGroupShape = uno::Reference< drawing::XShape >(
 			m_xShapeFactory->createInstance( C2U(
             "com.sun.star.drawing.Shape3DSceneObject" ) ), uno::UNO_QUERY );
+    ShapeFactory::setShapeName( m_xOuterGroupShape, C2U("PlotAreaExcludingAxes") );
     m_xLogicTarget->add(m_xOuterGroupShape);
-
+    
     uno::Reference< drawing::XShapes > xOuterGroup_Shapes =
             uno::Reference<drawing::XShapes>( m_xOuterGroupShape, uno::UNO_QUERY );
 

chart2/source/view/inc/VSeriesPlotter.hxx

 
     static VSeriesPlotter* createSeriesPlotter( const ::com::sun::star::uno::Reference<
                                 ::com::sun::star::chart2::XChartType >& xChartTypeModel
-                                , sal_Int32 nDimensionCount );
+                                , sal_Int32 nDimensionCount
+                                , bool bExcludingPositioning = false /*for pie and donut charts labels and exploded segments are excluded from the given size*/);
 
     sal_Int32 getPointCount() const;
 
     virtual void rearrangeLabelToAvoidOverlapIfRequested( const ::com::sun::star::awt::Size& rPageSize );
 
     bool WantToPlotInFrontOfAxisLine();
+    virtual bool shouldSnapRectToUsedArea();
 
     //-------------------------------------------------------------------------
     //-------------------------------------------------------------------------

chart2/source/view/main/ChartItemPool.cxx

 #include <editeng/brshitem.hxx>
 #include <editeng/sizeitem.hxx>
 #include <svl/stritem.hxx>
+#include <svl/rectitem.hxx>
 #include <svl/ilstitem.hxx>
 #define _SVSTDARR_ULONGS
 #include <svl/svstdarr.hxx>

chart2/source/view/main/ChartView.cxx

     , m_nScaleYNumerator(1)
     , m_nScaleYDenominator(1)
     , m_bSdrViewIsInEditMode(sal_False)
+    , m_aResultingDiagramRectangleExcludingAxes(0,0,0,0)
 {
 }
 
     if( ! (bHighContrastMetaFile || aFlavor.MimeType.equals(lcl_aGDIMetaFileMIMEType)) )
         return aRet;
 
-    impl_updateView();
+    update();
 
     SvMemoryStream aStream( 1024, 1024 );
     utl::OStreamWrapper* pStreamWrapper = new utl::OStreamWrapper( aStream );
             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 );
 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
 } //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)
         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) );
     }
 
     //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 ) ));
                 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
         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( !bIs