[Libreoffice-commits] core.git: 2 commits - include/touch ios/experimental sw/source vcl/inc vcl/ios

Tor Lillqvist tml at collabora.com
Tue Oct 22 14:20:02 PDT 2013


 include/touch/touch-impl.h                                         |    4 
 include/touch/touch.h                                              |    7 -
 ios/experimental/LibreOffice/LibreOffice.xcodeproj/project.pbxproj |    2 
 ios/experimental/LibreOffice/LibreOffice/View.m                    |   48 +++-----
 sw/source/core/crsr/viscrs.cxx                                     |   58 +++++-----
 sw/source/ui/docvw/edtwin.cxx                                      |   31 ++++-
 vcl/inc/ios/iosinst.hxx                                            |    6 +
 vcl/ios/iosinst.cxx                                                |   26 ++++
 8 files changed, 119 insertions(+), 63 deletions(-)

New commits:
commit 54ef5bd641ef5c6938b591697115d63af381ebc3
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Oct 22 23:30:26 2013 +0300

    More work on selection handling in iOS
    
    Got the selection start and end handle dragging working... The trick was not
    to call SwWrtShell::SetCursor(), but SwCrsrShell::SetCrsr(). Sounds easy but
    took a lot of guessing and experimentation to figure out. Anyway, now it does
    what I had expected it to do a few das ago already.
    
    There are glitches, especially in corner cases like if you move the start
    handle past the end handle or vice versa.
    
    more
    
    Change-Id: Id6c1d99a4052531789bccf0d48165cfb41b89cfe
    9b94c0dd55b04a7b6b3c40654562a9c51fa9b450

diff --git a/include/touch/touch-impl.h b/include/touch/touch-impl.h
index a2550b1..f786f44 100644
--- a/include/touch/touch-impl.h
+++ b/include/touch/touch-impl.h
@@ -20,6 +20,10 @@ extern "C" {
 // "Implementation" of touch_lo_* functions, called on the LO thread through
 // the PostUserEvent mechanism. Not called by UI thread code.
 
+void touch_lo_selection_start_move_impl(const void *documentHandle,
+                                        int x,
+                                        int y);
+
 void touch_lo_selection_end_move_impl(const void *documentHandle,
                                       int x,
                                       int y);
diff --git a/include/touch/touch.h b/include/touch/touch.h
index f999eca..7dddaf3 100644
--- a/include/touch/touch.h
+++ b/include/touch/touch.h
@@ -113,9 +113,12 @@ void touch_lo_draw_tile(void *context, int contextWidth, int contextHeight, int
 
 void touch_lo_mouse_drag(int x, int y, MLOMouseButtonState state);
 
+// Move the start of the selection to (x,y)
+void touch_lo_selection_start_move(const void *documentHandle,
+                                   int x,
+                                   int y);
+
 // Move the end of the selection to (x,y)
-// (work in progress, of course there should be a corresponding function
-// to move the start of the selection, too.)
 void touch_lo_selection_end_move(const void *documentHandle,
                                  int x,
                                  int y);
diff --git a/ios/experimental/LibreOffice/LibreOffice/View.m b/ios/experimental/LibreOffice/LibreOffice/View.m
index cb96e48..3a9b35b 100644
--- a/ios/experimental/LibreOffice/LibreOffice/View.m
+++ b/ios/experimental/LibreOffice/LibreOffice/View.m
@@ -154,71 +154,59 @@
 
 - (void)panGesture:(UIPanGestureRecognizer *)gestureRecognizer
 {
+    const int N = self.selectionRectangleCount;
+
     static enum { NONE, TOPLEFT, BOTTOMRIGHT } draggedHandle = NONE;
-    static CGFloat previousX, previousY;
+    static CGPoint previous;
+    static CGPoint dragOffset;
 
     CGPoint location = [gestureRecognizer locationInView:self];
     CGPoint translation = [gestureRecognizer translationInView:self];
 
     if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
-        previousX = previousY = 0;
+        previous = CGPointMake(0, 0);
     }
 
     CGPoint delta;
-    delta.x = translation.x - previousX;
-    delta.y = translation.y - previousY;
+    delta.x = translation.x - previous.x;
+    delta.y = translation.y - previous.y;
 
     // NSLog(@"location: (%f,%f) , drag: (%f,%f)", location.x, location.y, delta.x, delta.y);
 
-    previousX = translation.x;
-    previousY = translation.y;
+    previous = translation;
 
     if (gestureRecognizer.state == UIGestureRecognizerStateBegan &&
         gestureRecognizer.numberOfTouches == 1) {
         if (CGRectContainsPoint([self topLeftResizeHandle], location)) {
             NSLog(@"===> dragging TOPLEFT handle");
             draggedHandle = TOPLEFT;
+            dragOffset.x = location.x - self.selectionRectangles[0].origin.x;
+            dragOffset.y = location.y - self.selectionRectangles[0].origin.y;
         } else if (CGRectContainsPoint([self bottomRightResizeHandle], location)) {
             NSLog(@"===> dragging BOTTOMRIGHT handle");
             draggedHandle = BOTTOMRIGHT;
+            dragOffset.x = location.x - self.selectionRectangles[N-1].origin.x;
+            dragOffset.y = location.y - self.selectionRectangles[N-1].origin.y;
         }
     }
 
     if (draggedHandle == TOPLEFT) {
-        const int N = self.selectionRectangleCount;
 
-        CGPoint old = self.selectionRectangles[0].origin;
+        touch_lo_selection_start_move(self.documentHandle,
+                                      location.x - dragOffset.x, location.y - dragOffset.y);
 
-        self.selectionRectangles[0].origin = location;
-        self.selectionRectangles[0].size.width -= (location.x - old.x);
-        self.selectionRectangles[0].size.height -= (location.y - old.y);
-
-#if 0
-        touch_lo_selection_attempt_resize(self.documentHandle,
-                                          self.selectionRectangles,
-                                          self.selectionRectangleCount);
-#else
-        touch_lo_tap((self.selectionRectangles[0].origin.x + self.selectionRectangles[N-1].origin.x) / 2,
-                     (self.selectionRectangles[0].origin.y + self.selectionRectangles[N-1].origin.y) / 2);
-
-        touch_lo_mouse(self.selectionRectangles[0].origin.x,
-                       self.selectionRectangles[0].origin.y,
-                       DOWN, NONE);
-        touch_lo_mouse(self.selectionRectangles[N-1].origin.x +
-                       self.selectionRectangles[N-1].size.width,
-                       self.selectionRectangles[N-1].origin.y +
-                       self.selectionRectangles[N-1].size.height,
-                       UP, NONE);
-#endif
         if (gestureRecognizer.state == UIGestureRecognizerStateEnded)
             draggedHandle = NONE;
+
         return;
     } else if (draggedHandle == BOTTOMRIGHT) {
 
-        touch_lo_selection_end_move(self.documentHandle, location.x, location.y);
+        touch_lo_selection_end_move(self.documentHandle,
+                                    location.x - dragOffset.x, location.y - dragOffset.y);
 
         if (gestureRecognizer.state == UIGestureRecognizerStateEnded)
             draggedHandle = NONE;
+
         return;
     }
 
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 432a93b..e766fa5 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -262,36 +262,8 @@ void SwSelPaintRects::Show()
                 mpCursorOverlay = 0;
             }
         }
-#else
-        if (false)
-            ;
-#endif
         else if(!empty())
         {
-#if !HAVE_FEATURE_DESKTOP
-#ifdef IOS
-            const OutputDevice* pOut = GetShell()->GetWin();
-            if ( ! pOut )
-                pOut = GetShell()->GetOut();
-            SwWrtShell *pWrtShell = dynamic_cast<SwWrtShell*>(const_cast<SwCrsrShell*>(GetShell()));
-            if ( pWrtShell )
-            {
-                // Buffer will be deallocated in the UI layer
-                CGRect *rects = (CGRect *) malloc((sizeof(CGRect))*size());
-                for (size_t i = 0; i < size(); ++i)
-                {
-                    Point origin = pOut->LogicToPixel((*this)[i].Pos());
-                    Size size = pOut->LogicToPixel((*this)[i].SSize());
-                    rects[i] = CGRectMake(origin.X(), origin.Y(),
-                                          size.Width(), size.Height());
-                }
-                // GetShell returns a SwCrsrShell which actually is a SwWrtShell
-                touch_ui_selection_start(MLOSelectionText, pWrtShell, rects, size(), NULL);
-            }
-#else
-            // Not yet implemented
-#endif
-#else
             SdrPaintWindow* pCandidate = pView->GetPaintWindow(0);
             rtl::Reference< ::sdr::overlay::OverlayManager > xTargetOverlay = pCandidate->GetOverlayManager();
 
@@ -310,8 +282,38 @@ void SwSelPaintRects::Show()
 
                 xTargetOverlay->add(*mpCursorOverlay);
             }
+        }
+#else
+        const OutputDevice* pOut = GetShell()->GetWin();
+        if ( ! pOut )
+            pOut = GetShell()->GetOut();
+        SwWrtShell *pWrtShell = dynamic_cast<SwWrtShell*>(const_cast<SwCrsrShell*>(GetShell()));
+        if (!empty())
+        {
+            if (pWrtShell)
+            {
+                // Buffer will be deallocated in the UI layer
+                MLORect *rects = (MLORect *) malloc((sizeof(MLORect))*size());
+                for (size_t i = 0; i < size(); ++i)
+                {
+                    Point origin = pOut->LogicToPixel((*this)[i].Pos());
+                    Size size = pOut->LogicToPixel((*this)[i].SSize());
+#ifdef IOS
+                    rects[i] = CGRectMake(origin.X(), origin.Y(),
+                                          size.Width(), size.Height());
+#else
+                    // Not yet implemented
 #endif
+                }
+                // GetShell returns a SwCrsrShell which actually is a SwWrtShell
+                touch_ui_selection_start(MLOSelectionText, pWrtShell, rects, size(), NULL);
+            }
+        }
+        else
+        {
+            touch_ui_selection_none();
         }
+#endif
     }
 }
 
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 62c5bb1..d6bd8db 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -2688,6 +2688,33 @@ static bool lcl_urlOverBackground(SwWrtShell& rSh, const Point& rDocPos)
 
 #if !HAVE_FEATURE_DESKTOP
 
+void touch_lo_selection_start_move_impl(const void *documentHandle,
+                                        int x,
+                                        int y)
+{
+    SwWrtShell *pWrtShell = reinterpret_cast<SwWrtShell*>(const_cast<void*>(documentHandle));
+
+    if (!pWrtShell)
+        return;
+
+    const OutputDevice *pOut = pWrtShell->GetWin();
+    if (!pOut)
+        pOut = pWrtShell->GetOut();
+
+    const Point aDocPos( pOut->PixelToLogic( Point(x, y) ) );
+
+    pWrtShell->ChgCurrPam( aDocPos );
+
+    // Keep mark normally at the start and point at the end,
+    // just exchange for the duration of moving the start.
+    pWrtShell->GetCrsr()->Exchange();
+    {
+        SwMvContext aMvContext( pWrtShell );
+        pWrtShell->SwCrsrShell::SetCrsr( aDocPos );
+    }
+    pWrtShell->GetCrsr()->Exchange();
+}
+
 void touch_lo_selection_end_move_impl(const void *documentHandle,
                                       int x,
                                       int y)
@@ -2703,13 +2730,11 @@ void touch_lo_selection_end_move_impl(const void *documentHandle,
 
     const Point aDocPos( pOut->PixelToLogic( Point(x, y) ) );
 
-    // SAL _ DEBUG("touch_lo_selection_end_move_impl: " << Point(x, y) << " => " << aDocPos);
-
     pWrtShell->ChgCurrPam( aDocPos );
 
     {
         SwMvContext aMvContext( pWrtShell );
-        pWrtShell->SetCursor( &aDocPos, sal_False );
+        pWrtShell->SwCrsrShell::SetCrsr( aDocPos );
     }
 }
 
diff --git a/vcl/inc/ios/iosinst.hxx b/vcl/inc/ios/iosinst.hxx
index 0dfa7eb..58f0648 100644
--- a/vcl/inc/ios/iosinst.hxx
+++ b/vcl/inc/ios/iosinst.hxx
@@ -65,6 +65,12 @@ public:
     typedef struct {
         const void *documentHandle;
         int x, y;
+    } SelectionStartMoveArg;
+    DECL_LINK( SelectionStartMove, SelectionStartMoveArg* );
+
+    typedef struct {
+        const void *documentHandle;
+        int x, y;
     } SelectionEndMoveArg;
     DECL_LINK( SelectionEndMove, SelectionEndMoveArg* );
 
diff --git a/vcl/ios/iosinst.cxx b/vcl/ios/iosinst.cxx
index 50716f0..ccec3f7 100644
--- a/vcl/ios/iosinst.cxx
+++ b/vcl/ios/iosinst.cxx
@@ -508,6 +508,32 @@ void touch_lo_keyboard_did_hide()
     }
 }
 
+IMPL_LINK( IosSalInstance, SelectionStartMove, SelectionStartMoveArg*, pArg )
+{
+    touch_lo_selection_start_move_impl(pArg->documentHandle, pArg->x, pArg->y);
+
+    delete pArg;
+
+    return 0;
+}
+
+extern "C"
+void touch_lo_selection_start_move(const void *documentHandle,
+                                   int x,
+                                   int y)
+{
+    IosSalInstance *pInstance = IosSalInstance::getInstance();
+
+    if ( pInstance == NULL )
+        return;
+
+    IosSalInstance::SelectionStartMoveArg *pArg = new IosSalInstance::SelectionStartMoveArg;
+    pArg->documentHandle = documentHandle;
+    pArg->x = x;
+    pArg->y = y;
+    Application::PostUserEvent( LINK( pInstance, IosSalInstance, SelectionStartMove), pArg );
+}
+
 IMPL_LINK( IosSalInstance, SelectionEndMove, SelectionEndMoveArg*, pArg )
 {
     touch_lo_selection_end_move_impl(pArg->documentHandle, pArg->x, pArg->y);
commit 025bd0fab4cd8e4f90c362ec03b51c23e0a55655
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Oct 22 23:29:50 2013 +0300

    Add a file
    
    Change-Id: I0d0934d964143231b11356fc25cc3e6dad289d15

diff --git a/ios/experimental/LibreOffice/LibreOffice.xcodeproj/project.pbxproj b/ios/experimental/LibreOffice/LibreOffice.xcodeproj/project.pbxproj
index 0494dc4..89e04be 100644
--- a/ios/experimental/LibreOffice/LibreOffice.xcodeproj/project.pbxproj
+++ b/ios/experimental/LibreOffice/LibreOffice.xcodeproj/project.pbxproj
@@ -78,6 +78,7 @@
 		BE9086FF16FF02B3004400A1 /* svptext.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = svptext.cxx; path = ../../../../vcl/headless/svptext.cxx; sourceTree = "<group>"; };
 		BE90870016FF02B3004400A1 /* svpvd.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = svpvd.cxx; path = ../../../../vcl/headless/svpvd.cxx; sourceTree = "<group>"; };
 		BE954A2E1704F9500040D517 /* iosinst.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = iosinst.cxx; path = ../../../../vcl/ios/iosinst.cxx; sourceTree = "<group>"; };
+		BE9B03C8181671C000E1B0CF /* edws.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = edws.cxx; path = ../../../../sw/source/core/edit/edws.cxx; sourceTree = "<group>"; };
 		BEB752BD180C90D0005B5696 /* outmap.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = outmap.cxx; path = ../../../../vcl/source/gdi/outmap.cxx; sourceTree = "<group>"; };
 		BEBF3E3A17002D0200C454AC /* svapp.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = svapp.cxx; path = ../../../../vcl/source/app/svapp.cxx; sourceTree = "<group>"; };
 		BEBF3E3B17002D0200C454AC /* svmain.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = svmain.cxx; path = ../../../../vcl/source/app/svmain.cxx; sourceTree = "<group>"; };
@@ -281,6 +282,7 @@
 				BE2CB96318082A7800953CB4 /* edtwin.cxx */,
 				BE2CB96418082A7800953CB4 /* edtwin2.cxx */,
 				BE2CB96518082A7800953CB4 /* edtwin3.cxx */,
+				BE9B03C8181671C000E1B0CF /* edws.cxx */,
 				BE02DE57175F2E2A00ED4032 /* guess.cxx */,
 				BE2CB9611808297500953CB4 /* select.cxx */,
 				BE2CB962180829DD00953CB4 /* txtcrsr.cxx */,


More information about the Libreoffice-commits mailing list