Commits

Anonymous committed 102887c

#i12587# Inserting/editing arbitrary text objects in chart

Comments (0)

Files changed (3)

chart2/source/model/main/ChartModel.cxx

 #include <com/sun/star/awt/XWindow.hpp>
 #include <com/sun/star/awt/PosSize.hpp>
 #include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
 
 #include <map>
 #include <algorithm>
 	}
 }
 
+void ChartModel::impl_adjustAdditionalShapesPositionAndSize( const awt::Size& aVisualAreaSize )
+{
+    uno::Reference< beans::XPropertySet > xProperties( static_cast< ::cppu::OWeakObject* >( this ), uno::UNO_QUERY );
+    if ( xProperties.is() )
+    {
+        uno::Reference< drawing::XShapes > xShapes;
+        xProperties->getPropertyValue( C2U( "AdditionalShapes" ) ) >>= xShapes;
+        if ( xShapes.is() )
+        {
+            sal_Int32 nCount = xShapes->getCount();
+            for ( sal_Int32 i = 0; i < nCount; ++i )
+            {
+                Reference< drawing::XShape > xShape;
+                if ( xShapes->getByIndex( i ) >>= xShape )
+                {
+                    if ( xShape.is() )
+                    {
+                        awt::Point aPos( xShape->getPosition() );
+                        awt::Size aSize( xShape->getSize() );
+
+                        double fWidth = static_cast< double >( aVisualAreaSize.Width ) / m_aVisualAreaSize.Width;
+                        double fHeight = static_cast< double >( aVisualAreaSize.Height ) / m_aVisualAreaSize.Height;
+
+                        aPos.X = static_cast< long >( aPos.X * fWidth );
+                        aPos.Y = static_cast< long >( aPos.Y * fHeight );
+                        aSize.Width = static_cast< long >( aSize.Width * fWidth );
+                        aSize.Height = static_cast< long >( aSize.Height * fHeight );
+
+                        xShape->setPosition( aPos );
+                        xShape->setSize( aSize );
+                    }
+                }
+            }
+        }
+    }
+}
+
 //-----------------------------------------------------------------
 // lang::XServiceInfo
 //-----------------------------------------------------------------
         bool bChanged =
             (m_aVisualAreaSize.Width != aSize.Width ||
              m_aVisualAreaSize.Height != aSize.Height);
+
+        // #i12587# support for shapes in chart
+        if ( bChanged )
+        {
+            impl_adjustAdditionalShapesPositionAndSize( aSize );
+        }
+
         m_aVisualAreaSize = aSize;
         if( bChanged )
             setModified( sal_True );

chart2/source/model/main/ChartModel.hxx

         impl_createFilter( const ::com::sun::star::uno::Sequence<
                       ::com::sun::star::beans::PropertyValue > & rMediaDescriptor );
 
+    void impl_adjustAdditionalShapesPositionAndSize(
+        const ::com::sun::star::awt::Size& aVisualAreaSize );
+
 public:
 	//no default constructor
 	ChartModel(::com::sun::star::uno::Reference<

chart2/source/view/main/ChartView.cxx

     {
         // /--
         ::vos::OGuard aSolarGuard( Application::GetSolarMutex());
+        // #i12587# support for shapes in chart
+        m_pDrawModelWrapper->getSdrModel().EnableUndo( FALSE );
         m_pDrawModelWrapper->clearMainDrawPage();
         // \--
     }
         lcl_removeEmptyGroupShapes( xPageShapes );
     }
 
+    // #i12587# support for shapes in chart
+    if ( m_pDrawModelWrapper )
+    {
+        ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+        m_pDrawModelWrapper->getSdrModel().EnableUndo( TRUE );
+    }
+
 #if OSL_DEBUG_LEVEL > 0
     clock_t nEnd = clock();
     double fDuration =(double(nEnd-nStart)*1000.0)/double(CLOCKS_PER_SEC);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.