Commits

tbe  committed 05daf0b

#i12587# Inserting/editing arbitrary text objects in chart

  • Participants
  • Parent commits 2427c5b

Comments (0)

Files changed (8)

File chart2/source/controller/accessibility/AccessibleBase.cxx

     Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier );
     if ( xSelSupp.is() )
     {
-        uno::Any aSelection;
-        AccessibleUniqueId aId = GetId();
-        if ( aId.isAutoGeneratedObject() )
-        {
-            aSelection = uno::makeAny( aId.getObjectCID() );
-        }
-        else if ( aId.isAdditionalShape() )
-        {
-            aSelection = uno::makeAny( aId.getAdditionalShape() );
-        }
-        xSelSupp->select( aSelection );
+        xSelSupp->select( GetId().getAny() );
     }
 }
 

File chart2/source/controller/dialogs/Strings.src

 	Text [ en-US ] = "Chart Floor" ;
 };
 
+String STR_OBJECT_SHAPE
+{
+	Text [ en-US ] = "Drawing Object" ;
+};
+
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------

File chart2/source/controller/main/ChartController_Window.cxx

             uno::Any aNewSelection;
             if ( aNewOID.isValid() && !ObjectHierarchy::isRootNode( aNewOID ) )
             {
-                if ( aNewOID.isAutoGeneratedObject() )
-                {
-                    aNewSelection <<= aNewOID.getObjectCID();
-                }
-                else if ( aNewOID.isAdditionalShape() )
-                {
-                    aNewSelection <<= aNewOID.getAdditionalShape();
-                }
+                aNewSelection = aNewOID.getAny();
             }
             if ( m_eDragMode == SDRDRAG_ROTATE && !SelectionHelper::isRotateableObject( aNewOID.getObjectCID(), m_aModel->getModel() ) )
             {

File chart2/source/controller/main/ElementSelector.cxx

 #include "ObjectHierarchy.hxx"
 #include "servicenames.hxx"
 #include <chartview/ExplicitValueProvider.hxx>
+#include "DrawViewWrapper.hxx"
+#include "ResId.hxx"
+#include "Strings.hrc"
 
 #include <toolkit/helper/vclunohelper.hxx>
 #include <vos/mutex.hxx>
         ObjectHierarchy::tOID aOID = *aIt;
         ::rtl::OUString aCID = aOID.getObjectCID();
         ListBoxEntryData aEntry;
-        aEntry.CID = aCID;
+        aEntry.OID = aOID;
         aEntry.UIName += ObjectNameProvider::getNameForCID( aCID, xChartDoc );
         aEntry.nHierarchyDepth = nHierarchyDepth;
         rEntries.push_back(aEntry);
         }
                 
         Reference< chart2::XChartDocument > xChartDoc( xChartController->getModel(), uno::UNO_QUERY );
-        ObjectType eType( ObjectIdentifier::getObjectType( aSelectedCID ));
+        ObjectType eType( aSelectedOID.getObjectType() );
         bool bAddSelectionToList = false;
-        if( eType == OBJECTTYPE_DATA_POINT || eType == OBJECTTYPE_DATA_LABEL )
+        if ( eType == OBJECTTYPE_DATA_POINT || eType == OBJECTTYPE_DATA_LABEL || eType == OBJECTTYPE_SHAPE )
             bAddSelectionToList = true;
 
         Reference< uno::XInterface > xChartView;
         std::vector< ListBoxEntryData >::iterator aIt( m_aEntries.begin() );
         if( bAddSelectionToList )
         {
-            rtl::OUString aSeriesCID = ObjectIdentifier::createClassifiedIdentifierForParticle( ObjectIdentifier::getSeriesParticleFromCID( aSelectedCID ) );
-            for( aIt = m_aEntries.begin(); aIt != m_aEntries.end(); ++aIt )
+            if ( aSelectedOID.isAutoGeneratedObject() )
             {
-                if( aIt->CID.match( aSeriesCID ) )
+                rtl::OUString aSeriesCID = ObjectIdentifier::createClassifiedIdentifierForParticle( ObjectIdentifier::getSeriesParticleFromCID( aSelectedCID ) );
+                for( aIt = m_aEntries.begin(); aIt != m_aEntries.end(); ++aIt )
                 {
-                    ListBoxEntryData aEntry;
-                    aEntry.UIName = ObjectNameProvider::getNameForCID( aSelectedCID, xChartDoc );
-                    aEntry.CID = aSelectedCID;
-                    ++aIt;
-                    if( aIt != m_aEntries.end() )
-                        m_aEntries.insert(aIt, aEntry);
-                    else
-                        m_aEntries.push_back( aEntry );
-                    break;
+                    if( aIt->OID.getObjectCID().match( aSeriesCID ) )
+                    {
+                        ListBoxEntryData aEntry;
+                        aEntry.UIName = ObjectNameProvider::getNameForCID( aSelectedCID, xChartDoc );
+                        aEntry.OID = aSelectedOID;
+                        ++aIt;
+                        if( aIt != m_aEntries.end() )
+                            m_aEntries.insert(aIt, aEntry);
+                        else
+                            m_aEntries.push_back( aEntry );
+                        break;
+                    }
                 }
             }
+            else if ( aSelectedOID.isAdditionalShape() )
+            {
+                ListBoxEntryData aEntry;
+                SdrObject* pSelectedObj = DrawViewWrapper::getSdrObject( aSelectedOID.getAdditionalShape() );
+                ::rtl::OUString aName( pSelectedObj ? pSelectedObj->GetName() : ::rtl::OUString() );
+                aEntry.UIName = ( aName.getLength() > 0 ? aName : ::rtl::OUString( String( SchResId( STR_OBJECT_SHAPE ) ) ) );
+                aEntry.OID = aSelectedOID;
+                m_aEntries.push_back( aEntry );
+            }
         }
 
         USHORT nEntryPosToSelect = 0; bool bSelectionFound = false;
         for( USHORT nN=0; aIt != m_aEntries.end(); ++aIt, ++nN )
         {
             InsertEntry( aIt->UIName );
-            if( !bSelectionFound && aSelectedCID.equals( aIt->CID ) )
+            if ( !bSelectionFound && aSelectedOID == aIt->OID )
             {
                 nEntryPosToSelect = nN;
                 bSelectionFound = true;
         USHORT nPos = GetSelectEntryPos();
         if( nPos < m_aEntries.size() )
         {
-            rtl::OUString aCID = m_aEntries[nPos].CID;
-            uno::Any aASelection( uno::makeAny(aCID) );
+            ObjectHierarchy::tOID aOID = m_aEntries[nPos].OID;
             Reference< view::XSelectionSupplier > xSelectionSupplier( m_xChartController.get(), uno::UNO_QUERY );
             if( xSelectionSupplier.is() )
-                xSelectionSupplier->select(aASelection);
+                xSelectionSupplier->select( aOID.getAny() );
         }
         ReleaseFocus_Impl();
     }

File chart2/source/controller/main/ElementSelector.hxx

 #define _CHART_ELEMENTSELECTOR_HXX
 
 #include "ServiceMacros.hxx"
+#include "ObjectHierarchy.hxx"
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <cppuhelper/implbase1.hxx>
 #include <svtools/toolboxcontroller.hxx>
 struct ListBoxEntryData
 {
     rtl::OUString UIName;
-    rtl::OUString CID;
+    ObjectHierarchy::tOID OID;
     sal_Int32 nHierarchyDepth;
 
     ListBoxEntryData() : nHierarchyDepth(0)

File chart2/source/inc/ObjectIdentifier.hxx

     bool isAdditionalShape() const;
     ::rtl::OUString getObjectCID() const;
     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > getAdditionalShape() const;
+    ::com::sun::star::uno::Any getAny() const;
 
 private:
     // #i12587# support for shapes in chart

File chart2/source/inc/Strings.hrc

 // this includes no link dependency
 #include <svtools/solar.hrc>
 
-//next free is 290
+//next free is 291
 //single free is: 134
 
 //#define RID_APP_START 30000
 #define STR_OBJECT_CURVE_EQUATION           (RID_APP_START + 268)
 #define STR_STATISTICS_IN_LEGEND			(RID_APP_START + 180)
 
+#define STR_OBJECT_SHAPE                    (RID_APP_START + 290)
+
 //-----------------------------------------------------------------------------
 //Titles for tabpages and dialogs
 

File chart2/source/tools/ObjectIdentifier.cxx

     return m_xAdditionalShape;
 }
 
+Any ObjectIdentifier::getAny() const
+{
+    Any aAny;
+    if ( isAutoGeneratedObject() )
+    {
+        aAny = uno::makeAny( getObjectCID() );
+    }
+    else if ( isAdditionalShape() )
+    {
+        aAny = uno::makeAny( getAdditionalShape() );
+    }
+    return aAny;
+}
+
 //.............................................................................
 } //namespace chart
 //.............................................................................