Kaydet (Commit) e9e57c61 authored tarafından Marco Cecchetti's avatar Marco Cecchetti Kaydeden (comit) Marco Cecchetti

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: 's avatarMarco Cecchetti <mrcekets@gmail.com>
üst f6727831
......@@ -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;
......
......@@ -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;
......
......@@ -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() ||
......
......@@ -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
......
......@@ -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();
}
......
......@@ -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
......
......@@ -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() )
......
......@@ -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())
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment