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 @@ ...@@ -29,6 +29,7 @@
#include <vcl/waitobj.hxx> #include <vcl/waitobj.hxx>
#include <svl/PasswordHelper.hxx> #include <svl/PasswordHelper.hxx>
#include <o3tl/make_unique.hxx> #include <o3tl/make_unique.hxx>
#include <svx/svdocapt.hxx>
#include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/script/ModuleType.hpp> #include <com/sun/star/script/ModuleType.hpp>
...@@ -1215,6 +1216,7 @@ bool ScDocFunc::ShowNote( const ScAddress& rPos, bool bShow ) ...@@ -1215,6 +1216,7 @@ bool ScDocFunc::ShowNote( const ScAddress& rPos, bool bShow )
ScTabView::OnLOKNoteStateChanged(pNote); ScTabView::OnLOKNoteStateChanged(pNote);
ScDocShell::GetViewData()->GetScDrawView()->SyncForGrid(pNote->GetCaption());
rDocShell.SetDocumentModified(); rDocShell.SetDocumentModified();
return true; return true;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <postit.hxx> #include <postit.hxx>
class SdrModel; class SdrModel;
class ScDrawView;
class ScNoteMarker class ScNoteMarker
{ {
...@@ -45,16 +46,16 @@ private: ...@@ -45,16 +46,16 @@ private:
bool bByKeyboard; bool bByKeyboard;
tools::Rectangle aRect; tools::Rectangle aRect;
ScDrawView* aDrawView;
SdrModel* pModel; SdrModel* pModel;
ScCaptionPtr mxObject; ScCaptionPtr mxObject;
bool bVisible; bool bVisible;
Point aGridOff;
DECL_LINK( TimeHdl, Timer*, void ); DECL_LINK( TimeHdl, Timer*, void );
public: public:
ScNoteMarker( vcl::Window* pWin, vcl::Window* pRight, vcl::Window* pBottom, vcl::Window* pDiagonal, ScNoteMarker( vcl::Window* pWin, vcl::Window* pRight, vcl::Window* pBottom, vcl::Window* pDiagonal,
ScDocument* pD, const ScAddress& aPos, const OUString& rUser, 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(); ~ScNoteMarker();
void Draw(); void Draw();
...@@ -62,7 +63,6 @@ public: ...@@ -62,7 +63,6 @@ public:
const ScAddress& GetDocPos() const { return aDocPos; } const ScAddress& GetDocPos() const { return aDocPos; }
bool IsByKeyboard() const { return bByKeyboard; } bool IsByKeyboard() const { return bByKeyboard; }
void SetGridOff( const Point& rOff ) { aGridOff = rOff; }
}; };
#endif #endif
......
...@@ -207,26 +207,7 @@ bool ScGridWindow::ShowNoteMarker( SCCOL nPosX, SCROW nPosY, bool bKeyboard ) ...@@ -207,26 +207,7 @@ bool ScGridWindow::ShowNoteMarker( SCCOL nPosX, SCROW nPosY, bool bKeyboard )
mpNoteMarker.reset(new ScNoteMarker(pLeft, pRight, pBottom, pDiagonal, mpNoteMarker.reset(new ScNoteMarker(pLeft, pRight, pBottom, pDiagonal,
pDoc, aCellPos, aTrackText, pDoc, aCellPos, aTrackText,
aMapMode, bLeftEdge, bFast, bKeyboard)); aMapMode, bLeftEdge, bFast, bKeyboard, pViewData->GetScDrawView()));
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 );
}
} }
bDone = true; // something is shown (old or new) bDone = true; // something is shown (old or new)
......
...@@ -30,13 +30,14 @@ ...@@ -30,13 +30,14 @@
#include <notemark.hxx> #include <notemark.hxx>
#include <document.hxx> #include <document.hxx>
#include <postit.hxx> #include <postit.hxx>
#include <drawview.hxx>
#define SC_NOTEMARK_TIME 800 #define SC_NOTEMARK_TIME 800
#define SC_NOTEMARK_SHORT 70 #define SC_NOTEMARK_SHORT 70
ScNoteMarker::ScNoteMarker( vcl::Window* pWin, vcl::Window* pRight, vcl::Window* pBottom, vcl::Window* pDiagonal, ScNoteMarker::ScNoteMarker( vcl::Window* pWin, vcl::Window* pRight, vcl::Window* pBottom, vcl::Window* pDiagonal,
ScDocument* pD, const ScAddress& aPos, const OUString& rUser, 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 ), pWindow( pWin ),
pRightWin( pRight ), pRightWin( pRight ),
pBottomWin( pBottom ), pBottomWin( pBottom ),
...@@ -47,6 +48,7 @@ ScNoteMarker::ScNoteMarker( vcl::Window* pWin, vcl::Window* pRight, vcl::Window* ...@@ -47,6 +48,7 @@ ScNoteMarker::ScNoteMarker( vcl::Window* pWin, vcl::Window* pRight, vcl::Window*
aMapMode( rMap ), aMapMode( rMap ),
bLeft( bLeftEdge ), bLeft( bLeftEdge ),
bByKeyboard( bKeyboard ), bByKeyboard( bKeyboard ),
aDrawView ( pDrawView ),
pModel( nullptr ), pModel( nullptr ),
bVisible( false ) bVisible( false )
{ {
...@@ -99,8 +101,12 @@ IMPL_LINK_NOARG(ScNoteMarker, TimeHdl, Timer *, void) ...@@ -99,8 +101,12 @@ IMPL_LINK_NOARG(ScNoteMarker, TimeHdl, Timer *, void)
mxObject = ScNoteUtil::CreateTempCaption( *pDoc, aDocPos, *pPage, aUserText, aVisRect, bLeft ); mxObject = ScNoteUtil::CreateTempCaption( *pDoc, aDocPos, *pPage, aUserText, aVisRect, bLeft );
if( mxObject ) if( mxObject )
{ {
mxObject->SetGridOffset( aGridOff ); aDrawView->SyncForGrid(mxObject.get());
aRect = mxObject->GetCurrentBoundRect(); 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 // 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