[Libreoffice-commits] core.git: sc/source

Vasily Melenchuk Vasily.Melenchuk at cib.de
Thu Nov 30 10:26:53 UTC 2017


 sc/source/ui/docshell/docfunc.cxx |    2 ++
 sc/source/ui/inc/notemark.hxx     |    6 +++---
 sc/source/ui/view/gridwin5.cxx    |   21 +--------------------
 sc/source/ui/view/notemark.cxx    |   10 ++++++++--
 4 files changed, 14 insertions(+), 25 deletions(-)

New commits:
commit 25555c50ad2a57c1b2313f39b8132ac5e80a45fd
Author: Vasily Melenchuk <Vasily.Melenchuk at cib.de>
Date:   Wed Nov 8 16:53:12 2017 +0300

    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/44464
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index cd8b38ce0850..16b0a61aed51 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -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;
diff --git a/sc/source/ui/inc/notemark.hxx b/sc/source/ui/inc/notemark.hxx
index 8b87809d0fd1..967b8d4962e4 100644
--- a/sc/source/ui/inc/notemark.hxx
+++ b/sc/source/ui/inc/notemark.hxx
@@ -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
diff --git a/sc/source/ui/view/gridwin5.cxx b/sc/source/ui/view/gridwin5.cxx
index 7e7503a6331c..3f4fc29c776f 100644
--- a/sc/source/ui/view/gridwin5.cxx
+++ b/sc/source/ui/view/gridwin5.cxx
@@ -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)
diff --git a/sc/source/ui/view/notemark.cxx b/sc/source/ui/view/notemark.cxx
index f486a70d0168..e76941626af3 100644
--- a/sc/source/ui/view/notemark.cxx
+++ b/sc/source/ui/view/notemark.cxx
@@ -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


More information about the Libreoffice-commits mailing list