Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1785

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/85/1785/1

Initial/partial implementation of comment control on Writer ruler fdo#38246

Lots of incompleted things. But I need feedback and directions.
Mainly how to make it appears without need a first mouse-over event...
How can I vertically align text forcing a base line?
Is the license section of those two new files correct?

Change-Id: Ib065043d05fe56fbfe6d00e0bb654966f046129b
Signed-off-by: Rodolfo Ribeiro Gomes <rodolforg@gmail.com>
---
M svtools/inc/svtools/ruler.hxx
M svtools/source/control/ruler.cxx
M sw/Library_sw.mk
A sw/source/ui/inc/swruler.hxx
A sw/source/ui/misc/swruler.cxx
M sw/source/ui/uiview/view.cxx
6 files changed, 288 insertions(+), 11 deletions(-)



diff --git a/svtools/inc/svtools/ruler.hxx b/svtools/inc/svtools/ruler.hxx
index 3156044..2b19bc3 100644
--- a/svtools/inc/svtools/ruler.hxx
+++ b/svtools/inc/svtools/ruler.hxx
@@ -681,6 +681,9 @@
     Ruler (const Ruler &);
     Ruler & operator= (const Ruler &);
 
+protected:
+    long GetRulerVirHeight() const;
+
 public:
                         Ruler( Window* pParent, WinBits nWinStyle = WB_STDRULER );
     virtual             ~Ruler();
@@ -712,6 +715,9 @@
     void                SetBorderPos( long nOff = 0 );
     long                GetBorderOffset() const { return mnBorderOff; }
     Rectangle           GetExtraRect() const { return maExtraRect; }
+    long                GetWidth() const { return mnWidth; }
+    long                GetHeight() const { return mnHeight; }
+    long                GetRulerWidth() const;
 
     void                SetUnit( FieldUnit eNewUnit );
     FieldUnit           GetUnit() const { return meUnit; }
diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx
index 153e915..ecf337b 100644
--- a/svtools/source/control/ruler.cxx
+++ b/svtools/source/control/ruler.cxx
@@ -2777,9 +2777,11 @@
 
 }
 long Ruler::GetPageOffset() const { return mpData->nPageOff; }
-long                Ruler::GetNullOffset() const { return mpData->nNullOff; }
-long                Ruler::GetMargin1() const { return mpData->nMargin1; }
-long                Ruler::GetMargin2() const { return mpData->nMargin2; }
+long Ruler::GetNullOffset() const { return mpData->nNullOff; }
+long    Ruler::GetMargin1() const { return mpData->nMargin1; }
+long    Ruler::GetMargin2() const { return mpData->nMargin2; }
+long Ruler::GetRulerWidth() const { return mpData->nRulWidth; }
+long Ruler::GetRulerVirHeight() const { return mnVirHeight; }
 
 void Ruler::DrawTicks()
 {
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index c66cb26..6e62489 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -600,6 +600,7 @@
     sw/source/ui/misc/glshell \
     sw/source/ui/misc/numberingtypelistbox \
     sw/source/ui/misc/redlndlg \
+    sw/source/ui/misc/swruler \
     sw/source/ui/ribbar/conarc \
     sw/source/ui/ribbar/concustomshape \
     sw/source/ui/ribbar/conform \
diff --git a/sw/source/ui/inc/swruler.hxx b/sw/source/ui/inc/swruler.hxx
new file mode 100644
index 0000000..6700df8
--- /dev/null
+++ b/sw/source/ui/inc/swruler.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef SW_COMMENT_RULER_HXX
+#define SW_COMMENT_RULER_HXX
+
+#include <svx/ruler.hxx>
+
+class ViewShell;
+class View;
+class Window;
+class SwEditWin;
+
+class SwCommentRuler
+    : public SvxRuler
+{
+public:
+    SwCommentRuler (
+        ViewShell* pViewSh,
+        Window* pParent,
+        SwEditWin* pWin,
+        sal_uInt16 nRulerFlags,
+        SfxBindings& rBindings,
+        WinBits nWinStyle);
+    virtual ~SwCommentRuler ();
+
+    virtual void Paint( const Rectangle& rRect );
+
+protected:
+    ViewShell * mpViewShell;
+    SwEditWin * mpSwWin;
+    bool        mbHighlighted;
+    VirtualDevice maVirDev;
+
+    virtual void MouseButtonDown( const MouseEvent& rMEvt );
+    virtual void MouseMove(const MouseEvent& rMEvt);
+    virtual void Command( const CommandEvent& rCEvt );
+
+    Rectangle    GetCommentControlRegion();
+
+    void         DrawCommentControl();
+    void         ImplDrawArrow(long nX, long nY, const Color& rColor, bool bPointRight);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/misc/swruler.cxx b/sw/source/ui/misc/swruler.cxx
new file mode 100644
index 0000000..a65e7bd
--- /dev/null
+++ b/sw/source/ui/misc/swruler.cxx
@@ -0,0 +1,203 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+// FIXME https://bugs.freedesktop.org/show_bug.cgi?id=38246
+// Design proposal: https://wiki.documentfoundation.org/Design/Whiteboards/Comments_Ruler_Control
+
+#include "swruler.hxx"
+
+#include "viewsh.hxx"
+#include "vcl/window.hxx"
+#include "edtwin.hxx"
+#include "PostItMgr.hxx"
+#include "viewopt.hxx"
+#include <view.hxx>
+#include "cmdid.h"
+#include <sfx2/request.hxx>
+
+#define CONTROL_BORDER_WIDTH    1
+
+#define CONTROL_LEFT_OFFSET     6
+#define CONTROL_RIGHT_OFFSET    3
+#define CONTROL_TOP_OFFSET      4
+#define CONTROL_BOTTOM_OFFSET   4
+
+#define CONTROL_TRIANGLE_WIDTH  4
+#define CONTROL_TRIANGLE_HEIGHT 7
+#define CONTROL_TRIANGLE_PAD    3
+
+// Constructor
+SwCommentRuler::SwCommentRuler( ViewShell* pViewSh, Window* pParent, SwEditWin* pWin, sal_uInt16 
nRulerFlags,  SfxBindings& rBindings, WinBits nWinStyle)
+: SvxRuler(pParent, pWin, nRulerFlags, rBindings, nWinStyle | WB_HSCROLL)
+, mpViewShell(pViewSh)
+, mpSwWin(pWin)
+, mbHighlighted(false)
+, maVirDev( *this )
+{
+    // FIXME Initially it doesn't paint it
+}
+
+// Destructor
+SwCommentRuler::~SwCommentRuler()
+{
+}
+
+void SwCommentRuler::Paint( const Rectangle& rRect )
+{
+    SvxRuler::Paint( rRect );
+    // Don't draw if there is not any note
+    if ( mpViewShell->GetPostItMgr()->HasNotes() )
+        DrawCommentControl();
+}
+
+void SwCommentRuler::DrawCommentControl()
+{
+    const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+    bool bCollapsed = ! mpViewShell->GetPostItMgr()->ShowNotes();
+
+    // FIXME RTL
+    Rectangle aControlRect = GetCommentControlRegion();
+    maVirDev.SetOutputSizePixel( aControlRect.GetSize() );
+
+    // Paint comment control background
+    // TODO Check if these are best colors to be used
+    if ( mbHighlighted )
+        maVirDev.SetFillColor( rStyleSettings.GetDarkShadowColor() );
+    else
+        maVirDev.SetFillColor( rStyleSettings.GetWorkspaceColor() );
+
+    if ( mbHighlighted || !bCollapsed )
+    {
+        // Draw borders
+        maVirDev.SetLineColor( rStyleSettings.GetShadowColor() );
+    }
+    else
+    {
+        // No borders
+        maVirDev.SetLineColor();
+    }
+
+    maVirDev.DrawRect( Rectangle( Point(), aControlRect.GetSize() ) );
+
+    // Get label and arrow coordinates
+    Point aLabelPos;
+    Point aArrowPos;
+    aLabelPos.Y() = CONTROL_BORDER_WIDTH + CONTROL_TOP_OFFSET;
+    aArrowPos.Y() = CONTROL_BORDER_WIDTH + CONTROL_TOP_OFFSET;
+    if ( bCollapsed )
+    {
+        aLabelPos.X() = CONTROL_LEFT_OFFSET + CONTROL_TRIANGLE_WIDTH + CONTROL_TRIANGLE_PAD;
+        aArrowPos.X() = CONTROL_LEFT_OFFSET;
+    }
+    else
+    {
+        aLabelPos.X() = CONTROL_LEFT_OFFSET;
+        aArrowPos.X() = aControlRect.GetSize().Width() - 1 - CONTROL_RIGHT_OFFSET - 
CONTROL_BORDER_WIDTH - CONTROL_TRIANGLE_WIDTH;
+    }
+
+    // Draw label
+    const Color &rTextColor = mbHighlighted ? rStyleSettings.GetButtonTextColor() : 
rStyleSettings.GetDeactiveTextColor();
+    maVirDev.SetTextColor( rTextColor );
+    // FIXME i18n
+    // FIXME Vertical alignment
+    // FIXME Expected font size?
+    maVirDev.DrawText( aLabelPos, String("Comments") );
+
+    // Draw arrow
+    // FIXME colors consistence. 
http://opengrok.libreoffice.org/xref/core/vcl/source/control/button.cxx#785
+    const Color &rArrowColor = mbHighlighted ? Color( COL_BLACK ) : 
rStyleSettings.GetShadowColor();
+    ImplDrawArrow ( aArrowPos.X(), aArrowPos.Y(), rArrowColor, bCollapsed );
+
+    // Blit comment control
+    DrawOutDev( aControlRect.TopLeft(), aControlRect.GetSize(), Point(), aControlRect.GetSize(), 
maVirDev );
+}
+
+void SwCommentRuler::ImplDrawArrow(long nX, long nY, const Color& rColor, bool bPointRight)
+{
+    maVirDev.SetLineColor();
+    maVirDev.SetFillColor( rColor );
+    if ( bPointRight )
+    {
+        maVirDev.DrawRect( Rectangle( nX+0, nY+0, nX+0, nY+6 ) );
+        maVirDev.DrawRect( Rectangle( nX+1, nY+1, nX+1, nY+5 ) );
+        maVirDev.DrawRect( Rectangle( nX+2, nY+2, nX+2, nY+4 ) );
+        maVirDev.DrawRect( Rectangle( nX+3, nY+3, nX+3, nY+3 ) );
+    }
+    else
+    {
+        maVirDev.DrawRect( Rectangle( nX+0, nY+3, nX+0, nY+3 ) );
+        maVirDev.DrawRect( Rectangle( nX+1, nY+2, nX+1, nY+4 ) );
+        maVirDev.DrawRect( Rectangle( nX+2, nY+1, nX+2, nY+5 ) );
+        maVirDev.DrawRect( Rectangle( nX+3, nY+0, nX+3, nY+6 ) );
+    }
+}
+
+// Just accept double-click outside comment control
+void SwCommentRuler::Command( const CommandEvent& rCEvt )
+{
+    Point aMousePos = rCEvt.GetMousePosPixel();
+    if ( !mpViewShell->GetPostItMgr()
+          || !mpViewShell->GetPostItMgr()->HasNotes()
+          || !GetCommentControlRegion().IsInside( aMousePos ) )
+        SvxRuler::Command( rCEvt );
+}
+
+void SwCommentRuler::MouseMove(const MouseEvent& rMEvt)
+{
+    SvxRuler::MouseMove(rMEvt);
+    // TODO Delay 0.1s to highlight and 0.2s to "lowlight"
+    Point aMousePos = rMEvt.GetPosPixel();
+    bool  bWasHighlighted = mbHighlighted;
+    mbHighlighted = GetCommentControlRegion().IsInside( aMousePos );
+    if ( mbHighlighted != bWasHighlighted )
+        Invalidate();
+}
+
+void SwCommentRuler::MouseButtonDown( const MouseEvent& rMEvt )
+{
+    Point   aMousePos = rMEvt.GetPosPixel();
+    if ( !rMEvt.IsLeft() || IsTracking() || !GetCommentControlRegion().IsInside( aMousePos ) )
+    {
+        SvxRuler::MouseButtonDown(rMEvt);
+        return;
+    }
+
+    // Toggle notes visibility
+    SwView &rView = mpSwWin->GetView();
+    SfxRequest aRequest( rView.GetViewFrame(), FN_VIEW_NOTES );
+    rView.ExecViewOptions( aRequest );
+
+    // FIXME Maybe invalid or useless... Correct region will be updated?
+    // FIXME Doesn't update correctly
+    Invalidate();
+}
+
+Rectangle SwCommentRuler::GetCommentControlRegion()
+{
+    long nLeft   = GetWinOffset() + GetPageOffset() + GetRulerWidth();
+    long nTop    = 0 + 4;
+    // Right: need to add sidebar border width not included
+    long nRight  = nLeft+ mpViewShell->GetPostItMgr()->GetSidebarWidth(true) + 2*1;
+    long nBottom = nTop + GetRulerVirHeight() - 3;
+
+    Rectangle aRect(nLeft, nTop, nRight, nBottom);
+    return aRect;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx
index 96623d9..126ecbe 100644
--- a/sw/source/ui/uiview/view.cxx
+++ b/sw/source/ui/uiview/view.cxx
@@ -96,6 +96,7 @@
 #include "formatclipboard.hxx"
 #include <PostItMgr.hxx>
 #include <annotsh.hxx>
+#include <swruler.hxx>
 
 #include <fldbas.hxx>
 
@@ -715,14 +716,6 @@
     pHScrollbar(0),
     pVScrollbar(0),
     pScrollFill(new ScrollBarBox( &_pFrame->GetWindow(), _pFrame->GetFrame().GetParentFrame() ? 0 
: WB_SIZEABLE )),
-    pHRuler( new SvxRuler(&GetViewFrame()->GetWindow(), pEditWin,
-                    SVXRULER_SUPPORT_TABS |
-                    SVXRULER_SUPPORT_PARAGRAPH_MARGINS |
-                    SVXRULER_SUPPORT_BORDERS |
-                    SVXRULER_SUPPORT_NEGATIVE_MARGINS|
-                    SVXRULER_SUPPORT_REDUCED_METRIC,
-                    GetViewFrame()->GetBindings(),
-                    WB_STDRULER | WB_EXTRAFIELD | WB_BORDER)),
     pVRuler(new SvxRuler(&GetViewFrame()->GetWindow(), pEditWin,
                             SVXRULER_SUPPORT_TABS | SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL|
                                 SVXRULER_SUPPORT_BORDERS | SVXRULER_SUPPORT_REDUCED_METRIC,
@@ -868,6 +861,15 @@
     }
     RTL_LOGFILE_CONTEXT_TRACE( aLog, "after create WrtShell" );
 
+    pHRuler = new SwCommentRuler(pWrtShell, &GetViewFrame()->GetWindow(), pEditWin,
+                SVXRULER_SUPPORT_TABS |
+                SVXRULER_SUPPORT_PARAGRAPH_MARGINS |
+                SVXRULER_SUPPORT_BORDERS |
+                SVXRULER_SUPPORT_NEGATIVE_MARGINS|
+                SVXRULER_SUPPORT_REDUCED_METRIC,
+                GetViewFrame()->GetBindings(),
+                WB_STDRULER | WB_EXTRAFIELD | WB_BORDER);
+
     // assure that modified state of document
     // isn't reset, if document is already modified.
     const bool bIsDocModified = pWrtShell->GetDoc()->IsModified();

-- 
To view, visit https://gerrit.libreoffice.org/1785
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib065043d05fe56fbfe6d00e0bb654966f046129b
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Rodolfo Ribeiro Gomes <libo@rodolfo.eng.br>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.