Kaydet (Commit) 25555c50 authored tarafından Vasily Melenchuk's avatar Vasily Melenchuk Kaydeden (comit) Katarina Behrens

tdf#113901: Grid offset for notes and temporary notes modified.

Older calculations for gird offset were incomplete: are not used for notes
(only for temporary ones on mouse over), were not taken into account during
temporary note disappear and contain duplicated code from
ScDrawView::SyncForGrid()

New approach elminate described above problems.

Change-Id: I5f92971e156f37f052b4e6d47b2f16480bdbaf7e
Reviewed-on: https://gerrit.libreoffice.org/44464Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst e134bebe
......@@ -29,6 +29,7 @@
#include <vcl/waitobj.hxx>
#include <svl/PasswordHelper.hxx>
#include <o3tl/make_unique.hxx>
#include <svx/svdocapt.hxx>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/script/ModuleType.hpp>
......@@ -1215,6 +1216,7 @@ bool ScDocFunc::ShowNote( const ScAddress& rPos, bool bShow )
ScTabView::OnLOKNoteStateChanged(pNote);
ScDocShell::GetViewData()->GetScDrawView()->SyncForGrid(pNote->GetCaption());
rDocShell.SetDocumentModified();
return true;
......
......@@ -27,6 +27,7 @@
#include <postit.hxx>
class SdrModel;
class ScDrawView;
class ScNoteMarker
{
......@@ -45,16 +46,16 @@ private:
bool bByKeyboard;
tools::Rectangle aRect;
ScDrawView* aDrawView;
SdrModel* pModel;
ScCaptionPtr mxObject;
bool bVisible;
Point aGridOff;
DECL_LINK( TimeHdl, Timer*, void );
public:
ScNoteMarker( vcl::Window* pWin, vcl::Window* pRight, vcl::Window* pBottom, vcl::Window* pDiagonal,
ScDocument* pD, const ScAddress& aPos, const OUString& rUser,
const MapMode& rMap, bool bLeftEdge, bool bForce, bool bKeyboard );
const MapMode& rMap, bool bLeftEdge, bool bForce, bool bKeyboard, ScDrawView * pDrawView);
~ScNoteMarker();
void Draw();
......@@ -62,7 +63,6 @@ public:
const ScAddress& GetDocPos() const { return aDocPos; }
bool IsByKeyboard() const { return bByKeyboard; }
void SetGridOff( const Point& rOff ) { aGridOff = rOff; }
};
#endif
......
......@@ -207,26 +207,7 @@ bool ScGridWindow::ShowNoteMarker( SCCOL nPosX, SCROW nPosY, bool bKeyboard )
mpNoteMarker.reset(new ScNoteMarker(pLeft, pRight, pBottom, pDiagonal,
pDoc, aCellPos, aTrackText,
aMapMode, bLeftEdge, bFast, bKeyboard));
if ( pViewData->GetScDrawView() )
{
// get position for aCellPos
// get draw position in hmm for aCellPos
Point aOldPos( pDoc->GetColOffset( aCellPos.Col(), aCellPos.Tab() ), pDoc->GetRowOffset( aCellPos.Row(), aCellPos.Tab() ) );
aOldPos.X() = sc::TwipsToHMM( aOldPos.X() );
aOldPos.Y() = sc::TwipsToHMM( aOldPos.Y() );
// get screen pos in hmm for aCellPos
// and equiv screen pos
Point aScreenPos = pViewData->GetScrPos( aCellPos.Col(), aCellPos.Row(), eWhich, true );
MapMode aDrawMode = GetDrawMapMode();
Point aCurPosHmm = PixelToLogic(aScreenPos, aDrawMode );
Point aGridOff = aCurPosHmm -aOldPos;
// fdo#63323 fix the X Position for the showing comment when
// the mouse over the cell when the sheet are RTL
if ( pDoc->IsNegativePage(nTab))
aGridOff.setX(aCurPosHmm.getX() + aOldPos.getX());
mpNoteMarker->SetGridOff( aGridOff );
}
aMapMode, bLeftEdge, bFast, bKeyboard, pViewData->GetScDrawView()));
}
bDone = true; // something is shown (old or new)
......
......@@ -30,13 +30,14 @@
#include <notemark.hxx>
#include <document.hxx>
#include <postit.hxx>
#include <drawview.hxx>
#define SC_NOTEMARK_TIME 800
#define SC_NOTEMARK_SHORT 70
ScNoteMarker::ScNoteMarker( vcl::Window* pWin, vcl::Window* pRight, vcl::Window* pBottom, vcl::Window* pDiagonal,
ScDocument* pD, const ScAddress& aPos, const OUString& rUser,
const MapMode& rMap, bool bLeftEdge, bool bForce, bool bKeyboard ) :
const MapMode& rMap, bool bLeftEdge, bool bForce, bool bKeyboard, ScDrawView *pDrawView) :
pWindow( pWin ),
pRightWin( pRight ),
pBottomWin( pBottom ),
......@@ -47,6 +48,7 @@ ScNoteMarker::ScNoteMarker( vcl::Window* pWin, vcl::Window* pRight, vcl::Window*
aMapMode( rMap ),
bLeft( bLeftEdge ),
bByKeyboard( bKeyboard ),
aDrawView ( pDrawView ),
pModel( nullptr ),
bVisible( false )
{
......@@ -99,8 +101,12 @@ IMPL_LINK_NOARG(ScNoteMarker, TimeHdl, Timer *, void)
mxObject = ScNoteUtil::CreateTempCaption( *pDoc, aDocPos, *pPage, aUserText, aVisRect, bLeft );
if( mxObject )
{
mxObject->SetGridOffset( aGridOff );
aDrawView->SyncForGrid(mxObject.get());
aRect = mxObject->GetCurrentBoundRect();
// Need to include grid offset: GetCurrentBoundRect is removing it
// but we need to know actual rect position
aRect += mxObject->GetGridOffset();
}
// Insert page so that the model recognise it and also deleted
......
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