[Libreoffice-commits] core.git: chart2/source svx/source

Marco Cecchetti (via logerrit) logerrit at kemper.freedesktop.org
Mon May 20 08:35:41 UTC 2019


 chart2/source/controller/inc/ChartController.hxx         |    4 +
 chart2/source/controller/inc/SelectionHelper.hxx         |    6 +-
 chart2/source/controller/main/ChartController_Tools.cxx  |   17 +++++++
 chart2/source/controller/main/ChartController_Window.cxx |   11 ++++
 chart2/source/controller/main/SelectionHelper.cxx        |    6 +-
 chart2/source/inc/ObjectIdentifier.hxx                   |    4 -
 chart2/source/tools/ObjectIdentifier.cxx                 |    4 -
 svx/source/svdraw/svdmrkv.cxx                            |   34 +++++++++++++++
 8 files changed, 76 insertions(+), 10 deletions(-)

New commits:
commit e9e57c61a747f0f5859b579ff4f2bcaa53eacd79
Author:     Marco Cecchetti <marco.cecchetti at collabora.com>
AuthorDate: Wed Apr 10 21:04:51 2019 +0200
Commit:     Marco Cecchetti <mrcekets at gmail.com>
CommitDate: Mon May 20 10:34:48 2019 +0200

    lok: chart: informing the client about selection handling properties
    
    We hijack the chart CID protocol (CID:/classification/ObjectID) by
    inserting information about selection handling properties (draggable,
    resizable, rotatable) btw the classification section and the ObjectID
    section.
    This new section has the form: /Draggable=?:Resizable=?:Rotatable=?
    where in place of '?' there is 0 or 1.
    The hijacking occurs at the ChartController.getSelection method which
    is available through the XSelectionSupplier interface.
    
    Change-Id: Iaf920fe68e59c2595000e43d3fc1f976632cef18
    Reviewed-on: https://gerrit.libreoffice.org/70567
    Tested-by: Jenkins
    Reviewed-by: Marco Cecchetti <mrcekets at gmail.com>

diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx
index a14224e24c73..98225c96dd49 100644
--- a/chart2/source/controller/inc/ChartController.hxx
+++ b/chart2/source/controller/inc/ChartController.hxx
@@ -320,6 +320,10 @@ public:
 
     static bool isObjectDeleteable( const css::uno::Any& rSelection );
 
+    bool isSelectedObjectDraggable() const;
+    bool isSelectedObjectResizable() const;
+    bool isSelectedObjectRotatable() const;
+
     void setDrawMode( ChartDrawMode eMode ) { m_eDrawMode = eMode; }
 
     bool isShapeContext() const;
diff --git a/chart2/source/controller/inc/SelectionHelper.hxx b/chart2/source/controller/inc/SelectionHelper.hxx
index b9fe3fc20377..19a40c9a5af2 100644
--- a/chart2/source/controller/inc/SelectionHelper.hxx
+++ b/chart2/source/controller/inc/SelectionHelper.hxx
@@ -38,9 +38,9 @@ public: //methods
     css::uno::Reference< css::drawing::XShape > const & getSelectedAdditionalShape();
     const ObjectIdentifier& getSelectedOID() const { return m_aSelectedOID;}
 
-    bool isResizeableObjectSelected();
-    bool isRotateableObjectSelected( const css::uno::Reference< css::frame::XModel >& xChartModel );
-    bool isDragableObjectSelected();
+    bool isResizeableObjectSelected() const;
+    bool isRotateableObjectSelected( const css::uno::Reference< css::frame::XModel >& xChartModel ) const;
+    bool isDragableObjectSelected() const;
 
     bool isAdditionalShapeSelected() const;
 
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index c55d0a004134..799b4b6b48f7 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -565,6 +565,23 @@ bool ChartController::isObjectDeleteable( const uno::Any& rSelection )
     return false;
 }
 
+bool ChartController::isSelectedObjectDraggable() const
+{
+    return m_aSelection.isDragableObjectSelected();
+}
+
+bool ChartController::isSelectedObjectResizable() const
+{
+    return m_aSelection.isResizeableObjectSelected();
+}
+
+bool ChartController::isSelectedObjectRotatable() const
+{
+    const ChartController* pThis = this;
+    const uno::Reference< frame::XModel >& xChartModel = const_cast<ChartController*>(pThis)->getModel();
+    return m_aSelection.isRotateableObjectSelected(xChartModel);
+}
+
 bool ChartController::isShapeContext() const
 {
     return m_aSelection.isAdditionalShapeSelected() ||
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index c928be0e3a17..8907ed5ca203 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -1670,6 +1670,17 @@ uno::Any SAL_CALL ChartController::getSelection()
         OUString aCID( m_aSelection.getSelectedCID() );
         if ( !aCID.isEmpty() )
         {
+            if ( comphelper::LibreOfficeKit::isActive() )
+            {
+                sal_Int32 nPos = aCID.lastIndexOf('/');
+                OUString sFirst = aCID.copy(0, nPos);
+                OUString sSecond = aCID.copy(nPos);
+                aCID = sFirst;
+                aCID += "/Draggable=" + OUString::number(static_cast<int>(isSelectedObjectDraggable()));
+                aCID += ":Resizable=" + OUString::number(static_cast<int>(isSelectedObjectResizable()));
+                aCID += ":Rotatable=" + OUString::number(static_cast<int>(isSelectedObjectRotatable()));
+                aCID += sSecond;
+            }
             aReturn <<= aCID;
         }
         else
diff --git a/chart2/source/controller/main/SelectionHelper.cxx b/chart2/source/controller/main/SelectionHelper.cxx
index 11370bb480a7..e950f292d238 100644
--- a/chart2/source/controller/main/SelectionHelper.cxx
+++ b/chart2/source/controller/main/SelectionHelper.cxx
@@ -286,7 +286,7 @@ void Selection::adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper
     }
 }
 
-bool Selection::isResizeableObjectSelected()
+bool Selection::isResizeableObjectSelected() const
 {
     ObjectType eObjectType = m_aSelectedOID.getObjectType();
     switch( eObjectType )
@@ -301,12 +301,12 @@ bool Selection::isResizeableObjectSelected()
     }
 }
 
-bool Selection::isRotateableObjectSelected( const uno::Reference< frame::XModel >& xChartModel )
+bool Selection::isRotateableObjectSelected( const uno::Reference< frame::XModel >& xChartModel ) const
 {
     return SelectionHelper::isRotateableObject( m_aSelectedOID.getObjectCID(), xChartModel );
 }
 
-bool Selection::isDragableObjectSelected()
+bool Selection::isDragableObjectSelected() const
 {
     return m_aSelectedOID.isDragableObject();
 }
diff --git a/chart2/source/inc/ObjectIdentifier.hxx b/chart2/source/inc/ObjectIdentifier.hxx
index 79fb15232c81..87fb5723e3fc 100644
--- a/chart2/source/inc/ObjectIdentifier.hxx
+++ b/chart2/source/inc/ObjectIdentifier.hxx
@@ -164,7 +164,7 @@ public:
     static OUString getDragMethodServiceName( const OUString& rClassifiedIdentifier );
     static OUString getDragParameterString( const OUString& rCID );
     static bool isDragableObject( const OUString& rClassifiedIdentifier );
-    bool isDragableObject();
+    bool isDragableObject() const;
     static bool isRotateableObject( const OUString& rClassifiedIdentifier );
     static bool isMultiClickObject( const OUString& rClassifiedIdentifier );
     static bool areSiblings( const OUString& rCID1, const OUString& rCID2 );//identical object is no sibling
@@ -172,7 +172,7 @@ public:
 
     static OUString getStringForType( ObjectType eObjectType );
     static ObjectType    getObjectType( const OUString& rCID );
-    ObjectType getObjectType();
+    ObjectType getObjectType() const;
 
     static OUString createSeriesSubObjectStub( ObjectType eSubObjectType
                     , const OUString& rSeriesParticle
diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx
index 40c7380d3c23..0b29437546dd 100644
--- a/chart2/source/tools/ObjectIdentifier.cxx
+++ b/chart2/source/tools/ObjectIdentifier.cxx
@@ -811,7 +811,7 @@ bool ObjectIdentifier::isDragableObject( const OUString& rClassifiedIdentifier )
     return bReturn;
 }
 
-bool ObjectIdentifier::isDragableObject()
+bool ObjectIdentifier::isDragableObject() const
 {
     bool bReturn = false;
     if ( isAutoGeneratedObject() )
@@ -1056,7 +1056,7 @@ ObjectType ObjectIdentifier::getObjectType( const OUString& rCID )
     return eRet;
 }
 
-ObjectType ObjectIdentifier::getObjectType()
+ObjectType ObjectIdentifier::getObjectType() const
 {
     ObjectType eObjectType( OBJECTTYPE_UNKNOWN );
     if ( isAutoGeneratedObject() )
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 3bbf3b4a72ed..8a41e521d480 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -30,6 +30,7 @@
 #include <svdibrow.hxx>
 #endif
 
+#include <osl/thread.h>
 #include <svx/svdoole2.hxx>
 #include <svx/xgrad.hxx>
 #include <svx/xflgrit.hxx>
@@ -56,8 +57,11 @@
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <comphelper/lok.hxx>
 #include <sfx2/lokhelper.hxx>
+#include <sfx2/lokcharthelper.hxx>
 #include <sfx2/viewsh.hxx>
 
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+
 using namespace com::sun::star;
 
 // Migrate Marking of Objects, Points and GluePoints
@@ -734,6 +738,7 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
     tools::Rectangle aRect(GetMarkedObjRect());
     tools::Rectangle aSelection(aRect);
 
+    bool bIsChart = false;
     if (bTiledRendering && !aRect.IsEmpty())
     {
         sal_uInt32 nTotalPaintWindows = this->PaintWindowCount();
@@ -742,6 +747,7 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
             const vcl::Window* pWin = dynamic_cast<const vcl::Window*>(this->GetFirstOutputDevice());
             if (pWin && pWin->IsChart())
             {
+                bIsChart = true;
                 const vcl::Window* pViewShellWindow = GetSfxViewShell()->GetEditWindowForActiveOLEObj();
                 if (pViewShellWindow && pViewShellWindow->IsAncestorOf(*pWin))
                 {
@@ -799,6 +805,34 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
                 {
                     sProperties = "{ WriterGraphic=true }";
                 }
+                else if (bIsChart)
+                {
+                    LokChartHelper aChartHelper(pViewShell);
+                    css::uno::Reference<css::frame::XController>& xChartController = aChartHelper.GetXController();
+                    css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier( xChartController, uno::UNO_QUERY);
+                    if (xSelectionSupplier.is())
+                    {
+                        uno::Any aSel = xSelectionSupplier->getSelection();
+                        OUString aValue;
+                        if (aSel >>= aValue)
+                        {
+                            OString aObjectCID(aValue.getStr(), aValue.getLength(), osl_getThreadTextEncoding());
+                            sProperties += "{ ";
+                            const std::vector<OString> aProps{"Draggable=", "Resizable=", "Rotatable="};
+                            for (const auto& rProp: aProps)
+                            {
+                                sal_Int32 nPos = aObjectCID.indexOf(rProp);
+                                if (nPos == -1) continue;
+                                nPos += rProp.getLength();
+                                if (sProperties.getLength() > 2)
+                                    sProperties += ", ";
+                                sProperties += rProp;
+                                sProperties += OString::boolean(aObjectCID[nPos] == '1');
+                            }
+                            sProperties += " }";
+                        }
+                    }
+                }
 
                 if (!sProperties.isEmpty())
                 {


More information about the Libreoffice-commits mailing list