diff options
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/view/viewsh.cxx | 29 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 89 |
2 files changed, 115 insertions, 3 deletions
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 8a79a0896b60..2a2d46c95c39 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -25,6 +25,7 @@ #include <svx/srchdlg.hxx> #include <svx/svdobj.hxx> #include <sfx2/viewsh.hxx> +#include <sfx2/ipclient.hxx> #include <drawdoc.hxx> #include <swwait.hxx> #include <swmodule.hxx> @@ -1885,10 +1886,12 @@ void SwViewShell::PaintTile(VirtualDevice &rDevice, int contextWidth, int contex rDevice.SetMapMode(aMapMode); // Update scaling of SwEditWin and its sub-widgets, needed for comments. + sal_uInt16 nOldZoomValue = 0; if (GetWin() && GetWin()->GetMapMode().GetScaleX() != scaleX) { double fScale = scaleX; SwViewOption aOption(*GetViewOptions()); + nOldZoomValue = aOption.GetZoom(); aOption.SetZoom(fScale * 100); ApplyViewOptions(aOption); // Make sure the map mode (disabled in SwXTextDocument::initializeForTiledRendering()) is still disabled. @@ -1918,6 +1921,32 @@ void SwViewShell::PaintTile(VirtualDevice &rDevice, int contextWidth, int contex pPostItMgr->PaintTile(rDevice); // SwViewShell's output device tear down + + // A view shell can get a PaintTile call for a tile at a zoom level + // different from the one, the related client really is. + // In such a case it is better to reset the current scale value to + // the original one, since such a value should be in synchronous with + // the zoom level in the client (see setClientZoom). + // At present the zoom value returned by GetViewOptions()->GetZoom() is + // used in SwXTextDocument methods (postMouseEvent and setGraphicSelection) + // for passing the correct mouse position to an edited chart (if any). + if (nOldZoomValue !=0) + { + SwViewOption aOption(*GetViewOptions()); + aOption.SetZoom(nOldZoomValue); + ApplyViewOptions(aOption); + + // Changing the zoom value doesn't always trigger the updating of + // the client ole object area, so we call it directly. + SfxInPlaceClient* pIPClient = GetSfxViewShell()->GetIPClient(); + if (pIPClient) + { + pIPClient->VisAreaChanged(); + } + // Make sure the map mode (disabled in SwXTextDocument::initializeForTiledRendering()) is still disabled. + GetWin()->EnableMapMode(false); + } + mpOut = pSaveOut; comphelper::LibreOfficeKit::setTiledPainting(false); } diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index aca79a13c678..1e2473fdc6f8 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -37,6 +37,8 @@ #include <toolkit/helper/vclunohelper.hxx> #include <toolkit/awt/vclxdevice.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <sfx2/lokcharthelper.hxx> +#include <sfx2/ipclient.hxx> #include <editeng/svxacorr.hxx> #include <editeng/acorrcfg.hxx> #include <cmdid.h> @@ -166,6 +168,8 @@ #include <comphelper/servicehelper.hxx> #include <memory> +#define TWIPS_PER_PIXEL 15 + using namespace ::com::sun::star; using namespace ::com::sun::star::text; using namespace ::com::sun::star::i18n; @@ -3078,6 +3082,9 @@ void SwXTextDocument::paintTile( VirtualDevice &rDevice, SwViewShell* pViewShell = pDocShell->GetWrtShell(); pViewShell->PaintTile(rDevice, nOutputWidth, nOutputHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); + + LokChartHelper::PaintAllChartsOnTile(rDevice, nOutputWidth, nOutputHeight, + nTilePosX, nTilePosY, nTileWidth, nTileHeight); } Size SwXTextDocument::getDocumentSize() @@ -3158,6 +3165,34 @@ void SwXTextDocument::setClientVisibleArea(const tools::Rectangle& rRectangle) pView->ForcePageUpDownOffset(2 * rRectangle.GetHeight() / 3); } +void SwXTextDocument::setClientZoom(int nTilePixelWidth_, int /*nTilePixelHeight_*/, + int nTileTwipWidth_, int /*nTileTwipHeight_*/) +{ + // Here we set the zoom value as it has been set by the user in the client. + // This value is used in postMouseEvent and setGraphicSelection methods + // for in place chart editing. We assume that x and y scale is rougly + // the same. + // Indeed we could set mnTilePixelWidth, mnTilePixelHeight, mnTileTwipWidth, + // mnTileTwipHeight data members of this class but they are not very useful + // since we need to be able to retrieve the zoom value for each view shell. + SfxInPlaceClient* pIPClient = pDocShell->GetView()->GetIPClient(); + if (pIPClient) + { + SwViewShell* pWrtViewShell = pDocShell->GetWrtShell(); + double fScale = nTilePixelWidth_ * TWIPS_PER_PIXEL / (nTileTwipWidth_ * 1.0); + SwViewOption aOption(*(pWrtViewShell->GetViewOptions())); + if (aOption.GetZoom() != fScale * 100) + { + aOption.SetZoom(fScale * 100); + pWrtViewShell->ApplyViewOptions(aOption); + + // Changing the zoom value doesn't always trigger the updating of + // the client ole object area, so we call it directly. + pIPClient->VisAreaChanged(); + } + } +} + Pointer SwXTextDocument::getPointer() { SolarMutexGuard aGuard; @@ -3322,6 +3357,11 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css:: } } + // Set the initial zoom value to 1; usually it is set in setClientZoom and + // SwViewShell::PaintTile; zoom value is used for chart in place + // editing, see postMouseEvent and setGraphicSelection methods. + aViewOption.SetZoom(1 * 100); + aViewOption.SetPostIts(comphelper::LibreOfficeKit::isTiledAnnotations()); pViewShell->ApplyViewOptions(aViewOption); @@ -3354,16 +3394,25 @@ void SwXTextDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode) { SolarMutexGuard aGuard; - SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin(); + vcl::Window* pWindow = &(pDocShell->GetView()->GetEditWin()); + + SfxViewShell* pViewShell = pDocShell->GetView(); + LokChartHelper aChartHelper(pViewShell); + vcl::Window* pChartWindow = aChartHelper.GetWindow(); + if (pChartWindow) + { + pWindow = pChartWindow; + } + KeyEvent aEvent(nCharCode, nKeyCode, 0); switch (nType) { case LOK_KEYEVENT_KEYINPUT: - rEditWin.KeyInput(aEvent); + pWindow->KeyInput(aEvent); break; case LOK_KEYEVENT_KEYUP: - rEditWin.KeyUp(aEvent); + pWindow->KeyUp(aEvent); break; default: assert(false); @@ -3375,6 +3424,26 @@ void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int { SolarMutexGuard aGuard; + SwViewShell* pWrtViewShell = pDocShell->GetWrtShell(); + SwViewOption aOption(*(pWrtViewShell->GetViewOptions())); + double fScale = aOption.GetZoom() / (TWIPS_PER_PIXEL * 100.0); + + // check if user hit a chart which is being edited by him + SfxViewShell* pViewShell = pDocShell->GetView(); + LokChartHelper aChartHelper(pViewShell); + if (aChartHelper.postMouseEvent(nType, nX, nY, + nCount, nButtons, nModifier, + fScale, fScale)) + return; + + // check if the user hit a chart which is being edited by someone else + // and, if so, skip current mouse event + if (nType != LOK_MOUSEEVENT_MOUSEMOVE) + { + if (LokChartHelper::HitAny(Point(nX, nY))) + return; + } + SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin(); Point aPos(nX , nY); MouseEvent aEvent(aPos, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier); @@ -3406,6 +3475,11 @@ void SwXTextDocument::setTextSelection(int nType, int nX, int nY) { SolarMutexGuard aGuard; + SfxViewShell* pViewShell = pDocShell->GetView(); + LokChartHelper aChartHelper(pViewShell); + if (aChartHelper.setTextSelection(nType, nX, nY)) + return; + SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin(); switch (nType) { @@ -3504,6 +3578,15 @@ void SwXTextDocument::setGraphicSelection(int nType, int nX, int nY) { SolarMutexGuard aGuard; + SwViewShell* pWrtViewShell = pDocShell->GetWrtShell(); + SwViewOption aOption(*(pWrtViewShell->GetViewOptions())); + double fScale = aOption.GetZoom() / (TWIPS_PER_PIXEL * 100.0); + + SfxViewShell* pViewShell = pDocShell->GetView(); + LokChartHelper aChartHelper(pViewShell); + if (aChartHelper.setGraphicSelection(nType, nX, nY, fScale, fScale)) + return; + SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin(); switch (nType) { |