summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2022-01-06 10:54:49 +0530
committerAndras Timar <andras.timar@collabora.com>2022-01-11 11:18:09 +0100
commit284068c7eb473bafd5cafeb30a78daab4538cff6 (patch)
tree170a2b16f0a2dee74cb991e98c494ac2cecaa834
parentlokCalcRTL: negate mouse event X for chart and controls (diff)
downloadcore-284068c7eb473bafd5cafeb30a78daab4538cff6.tar.gz
core-284068c7eb473bafd5cafeb30a78daab4538cff6.zip
lokCalcRTL: fix rendering of charts in edit mode
Inform Sfx2InPlaceClient and LokChartHelper when negated X coordinates are used. Ensure that invalidation rectangles have positive coordinates in all cases. Change-Id: I8f5440718e288d8f0d379c8da5f49a29e51f6940
-rw-r--r--include/sfx2/ipclient.hxx4
-rw-r--r--include/sfx2/lokcharthelper.hxx3
-rw-r--r--sc/source/ui/unoobj/docuno.cxx3
-rw-r--r--sc/source/ui/view/gridwin4.cxx7
-rw-r--r--sc/source/ui/view/tabvwshb.cxx14
-rw-r--r--sfx2/source/view/ipclient.cxx26
-rw-r--r--sfx2/source/view/lokcharthelper.cxx6
7 files changed, 55 insertions, 8 deletions
diff --git a/include/sfx2/ipclient.hxx b/include/sfx2/ipclient.hxx
index d3fead566486..208a1bf82e56 100644
--- a/include/sfx2/ipclient.hxx
+++ b/include/sfx2/ipclient.hxx
@@ -86,6 +86,10 @@ public:
void ResetObject();
bool IsUIActive() const;
+ /// To indicate that negated document X coordinates are used
+ void SetNegativeX(bool bSet);
+ bool IsNegativeX() const;
+
virtual void FormatChanged(); // object format was changed (used for StarMath formulas aligning)
};
diff --git a/include/sfx2/lokcharthelper.hxx b/include/sfx2/lokcharthelper.hxx
index 020abad111f0..aa7cfb5867ac 100644
--- a/include/sfx2/lokcharthelper.hxx
+++ b/include/sfx2/lokcharthelper.hxx
@@ -47,7 +47,8 @@ public:
static void PaintAllChartsOnTile(VirtualDevice& rDevice,
int nOutputWidth, int nOutputHeight,
int nTilePosX, int nTilePosY,
- tools::Long nTileWidth, tools::Long nTileHeight);
+ tools::Long nTileWidth, tools::Long nTileHeight,
+ bool bNegativeX = false);
bool postMouseEvent(int nType, int nX, int nY,
int nCount, int nButtons, int nModifier,
double fScaleX = 1.0, double fScaleY = 1.0);
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 3af00c03a404..f18793734baf 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -568,9 +568,6 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
pGridWindow->PaintTile( rDevice, nOutputWidth, nOutputHeight,
nTilePosX, nTilePosY, nTileWidth, nTileHeight );
- LokChartHelper::PaintAllChartsOnTile(rDevice, nOutputWidth, nOutputHeight,
- nTilePosX, nTilePosY, nTileWidth, nTileHeight);
-
// Draw Form controls
ScDrawLayer* pDrawLayer = pDocShell->GetDocument().GetDrawLayer();
SdrPage* pPage = pDrawLayer->GetPage(sal_uInt16(pViewData->GetTabNo()));
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 9de8604f2bfd..cb085fcc6e64 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -33,6 +33,7 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <comphelper/lok.hxx>
#include <sfx2/lokhelper.hxx>
+#include <sfx2/lokcharthelper.hxx>
#include <svx/svdview.hxx>
#include <svx/svdpagv.hxx>
@@ -1581,6 +1582,12 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
DrawContent(rDevice, aTabInfo, aOutputData, true);
rDevice.SetMapMode(aOriginalMode);
+ // Paint the chart(s) in edit mode.
+ LokChartHelper::PaintAllChartsOnTile(rDevice, nOutputWidth, nOutputHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight, bLayoutRTL);
+
+ rDevice.SetMapMode(aOriginalMode);
+
// Flag drawn formula cells "unchanged".
rDoc.ResetChanged(ScRange(nTopLeftTileCol, nTopLeftTileRow, nTab, nBottomRightTileCol, nBottomRightTileRow, nTab));
rDoc.PrepareFormulaCalc();
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index d0006564d53e..a62770067796 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -80,6 +80,13 @@ void ScTabViewShell::ConnectObject( const SdrOle2Obj* pObj )
return;
pClient = new ScClient( this, pWin, GetScDrawView()->GetModel(), pObj );
+ ScViewData& rViewData = GetViewData();
+ ScDocShell* pDocSh = rViewData.GetDocShell();
+ ScDocument& rDoc = pDocSh->GetDocument();
+ bool bNegativeX = comphelper::LibreOfficeKit::isActive() && rDoc.IsNegativePage(rViewData.GetTabNo());
+ if (bNegativeX)
+ pClient->SetNegativeX(true);
+
tools::Rectangle aRect = pObj->GetLogicRect();
Size aDrawSize = aRect.GetSize();
@@ -153,10 +160,17 @@ void ScTabViewShell::ActivateObject( SdrOle2Obj* pObj, tools::Long nVerb )
bool bErrorShown = false;
{
+ ScViewData& rViewData = GetViewData();
+ ScDocShell* pDocSh = rViewData.GetDocShell();
+ ScDocument& rDoc = pDocSh->GetDocument();
+ bool bNegativeX = comphelper::LibreOfficeKit::isActive() && rDoc.IsNegativePage(rViewData.GetTabNo());
SfxInPlaceClient* pClient = FindIPClient( xObj, pWin );
if ( !pClient )
pClient = new ScClient( this, pWin, GetScDrawView()->GetModel(), pObj );
+ if (bNegativeX)
+ pClient->SetNegativeX(true);
+
if ( (sal_uInt32(nErr) & ERRCODE_ERROR_MASK) == 0 && xObj.is() )
{
tools::Rectangle aRect = pObj->GetLogicRect();
diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx
index fc594ff2e658..141e7f954e19 100644
--- a/sfx2/source/view/ipclient.cxx
+++ b/sfx2/source/view/ipclient.cxx
@@ -90,6 +90,15 @@ public:
}
};
+tools::Rectangle lcl_negateRectX(const tools::Rectangle& rRect)
+{
+ return tools::Rectangle(
+ std::max(0l, -rRect.Right()),
+ rRect.Top(),
+ std::max(0l, -rRect.Left()),
+ rRect.Bottom());
+}
+
}
// SfxInPlaceClient_Impl
@@ -111,6 +120,7 @@ public:
bool m_bStoreObject;
bool m_bUIActive; // set and cleared when notification for UI (de)activation is sent
bool m_bResizeNoScale;
+ bool m_bNegativeX;
uno::Reference < embed::XEmbeddedObject > m_xObject;
@@ -121,6 +131,7 @@ public:
, m_bStoreObject( true )
, m_bUIActive( false )
, m_bResizeNoScale( false )
+ , m_bNegativeX( false )
{}
void SizeHasChanged();
@@ -345,7 +356,7 @@ void SAL_CALL SfxInPlaceClient_Impl::activatingInplace()
aRect = OutputDevice::LogicToLogic(aRect, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
}
- OString str = aRect.toString() + ", \"INPLACE\"";
+ OString str = (m_bNegativeX ? lcl_negateRectX(aRect) : aRect).toString() + ", \"INPLACE\"";
pViewShell->libreOfficeKitViewCallback( LOK_CALLBACK_GRAPHIC_SELECTION, str.getStr() );
}
}
@@ -823,7 +834,8 @@ void SfxInPlaceClient::Invalidate()
tools::Rectangle aRealObjArea( m_xImp->m_aObjArea );
aRealObjArea.SetSize( Size( tools::Long( aRealObjArea.GetWidth() * m_xImp->m_aScaleWidth ),
tools::Long( aRealObjArea.GetHeight() * m_xImp->m_aScaleHeight ) ) );
- m_pEditWin->Invalidate( aRealObjArea );
+
+ m_pEditWin->Invalidate( IsNegativeX() ? lcl_negateRectX(aRealObjArea) : aRealObjArea );
ViewChanged();
}
@@ -1120,4 +1132,14 @@ bool SfxInPlaceClient::IsUIActive() const
return m_xImp->m_bUIActive;
}
+void SfxInPlaceClient::SetNegativeX(bool bSet)
+{
+ m_xImp->m_bNegativeX = bSet;
+}
+
+bool SfxInPlaceClient::IsNegativeX() const
+{
+ return m_xImp->m_bNegativeX;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/view/lokcharthelper.cxx b/sfx2/source/view/lokcharthelper.cxx
index d5995e33ba8d..b0b71aaa0353 100644
--- a/sfx2/source/view/lokcharthelper.cxx
+++ b/sfx2/source/view/lokcharthelper.cxx
@@ -236,7 +236,8 @@ void LokChartHelper::PaintTile(VirtualDevice& rRenderContext, const tools::Recta
void LokChartHelper::PaintAllChartsOnTile(VirtualDevice& rDevice,
int nOutputWidth, int nOutputHeight,
int nTilePosX, int nTilePosY,
- tools::Long nTileWidth, tools::Long nTileHeight)
+ tools::Long nTileWidth, tools::Long nTileHeight,
+ bool bNegativeX)
{
if (comphelper::LibreOfficeKit::isTiledAnnotations())
return;
@@ -257,7 +258,8 @@ void LokChartHelper::PaintAllChartsOnTile(VirtualDevice& rDevice,
SfxViewShell* pCurView = SfxViewShell::Current();
int nPartForCurView = pCurView ? pCurView->getPart() : -1;
- tools::Rectangle aTileRect(Point(nTilePosX, nTilePosY), Size(nTileWidth, nTileHeight));
+ tools::Long nTileRectLeft = bNegativeX ? -nTilePosX - nTileWidth : nTilePosX;
+ tools::Rectangle aTileRect(Point(nTileRectLeft, nTilePosY), Size(nTileWidth, nTileHeight));
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{