[Libreoffice-commits] core.git: 2 commits - svtools/inc svtools/source svx/inc svx/source sw/AllLangResTarget_sw.mk sw/Library_sw.mk sw/source

Rodolfo Ribeiro Gomes rodolforg at gmail.com
Mon Mar 11 02:11:49 PDT 2013


 svtools/inc/svtools/ruler.hxx    |    4 
 svtools/source/control/ruler.cxx |    8 -
 svx/inc/svx/ruler.hxx            |    7 -
 svx/source/dialog/svxruler.cxx   |    5 
 sw/AllLangResTarget_sw.mk        |    1 
 sw/Library_sw.mk                 |    1 
 sw/source/core/doc/doctxm.cxx    |   28 ++++
 sw/source/ui/inc/misc.hrc        |    6 
 sw/source/ui/inc/swruler.hxx     |  105 +++++++++++++++
 sw/source/ui/misc/swruler.cxx    |  263 +++++++++++++++++++++++++++++++++++++++
 sw/source/ui/misc/swruler.src    |   25 +++
 sw/source/ui/uiview/view.cxx     |   18 +-
 12 files changed, 454 insertions(+), 17 deletions(-)

New commits:
commit e047a967b0db8c61dc977b52f3876fc4e385ad77
Author: Rodolfo Ribeiro Gomes <rodolforg at gmail.com>
Date:   Sat Mar 9 14:08:21 2013 -0300

    fdo#38246 Comment control on Writer ruler feature
    
    It follows the directions from design team available at
    https://wiki.documentfoundation.org/Design/Whiteboards/Comments_Ruler_Control.
    It misses some fancy stuff though (like animated/delayed highlight and fading border).
    Some work should be done with (svtools) Ruler also for a cleaner implementation.
    
    Change-Id: Ib065043d05fe56fbfe6d00e0bb654966f046129b
    Signed-off-by: Rodolfo Ribeiro Gomes <rodolforg at gmail.com>

diff --git a/svtools/inc/svtools/ruler.hxx b/svtools/inc/svtools/ruler.hxx
index 864ebf9..a06109b 100644
--- a/svtools/inc/svtools/ruler.hxx
+++ b/svtools/inc/svtools/ruler.hxx
@@ -681,6 +681,9 @@ private:
     Ruler (const Ruler &);
     Ruler & operator= (const Ruler &);
 
+protected:
+    long GetRulerVirHeight() const;
+
 public:
                         Ruler( Window* pParent, WinBits nWinStyle = WB_STDRULER );
     virtual             ~Ruler();
@@ -709,6 +712,7 @@ public:
     long                GetWinWidth() const { return mnWinWidth; }
     void                SetPagePos( long nOff = 0, long nWidth = 0 );
     long                GetPageOffset() const;
+    long                GetPageWidth() const;
     void                SetBorderPos( long nOff = 0 );
     long                GetBorderOffset() const { return mnBorderOff; }
     Rectangle           GetExtraRect() const { return maExtraRect; }
diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx
index fcc2037..5e19a66 100644
--- a/svtools/source/control/ruler.cxx
+++ b/svtools/source/control/ruler.cxx
@@ -2775,9 +2775,11 @@ void Ruler::SetTextRTL(sal_Bool bRTL)
 
 }
 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::GetPageWidth() const { return mpData->nPageWidth; }
+long Ruler::GetNullOffset() const { return mpData->nNullOff; }
+long    Ruler::GetMargin1() const { return mpData->nMargin1; }
+long    Ruler::GetMargin2() const { return mpData->nMargin2; }
+long Ruler::GetRulerVirHeight() const { return mnVirHeight; }
 
 void Ruler::DrawTicks()
 {
diff --git a/svx/inc/svx/ruler.hxx b/svx/inc/svx/ruler.hxx
index e39ccde..aa18893 100644
--- a/svx/inc/svx/ruler.hxx
+++ b/svx/inc/svx/ruler.hxx
@@ -148,7 +148,6 @@ class SVX_DLLPUBLIC SvxRuler: public Ruler, public SfxListener
     long GetLeftIndent() const;
     long GetRightIndent() const;
     long GetLogicRightIndent() const;
-    long GetPageWidth() const;
 
     inline long GetLeftFrameMargin() const;
     long GetRightFrameMargin() const;
@@ -184,14 +183,13 @@ class SVX_DLLPUBLIC SvxRuler: public Ruler, public SfxListener
     sal_uInt16 GetNextVisible(sal_uInt16 nColumn);
     sal_uInt16 GetPrevVisible(sal_uInt16 nColumn);
 
-    void Update();
-
 enum UpdateType {
     MOVE_ALL,
     MOVE_LEFT,
     MOVE_RIGHT
     };
     void UpdateParaContents_Impl(long lDiff, UpdateType = MOVE_ALL);
+
 protected:
     virtual void    Command( const CommandEvent& rCEvt );
     virtual void    Click();
@@ -203,6 +201,8 @@ protected:
 
     virtual void    Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
 
+    virtual void    Update();
+
     // calculation of boundary values for object borders
     // values refer to the page
     virtual sal_Bool    CalcLimits(long &nMax1, long &nMax2, sal_Bool bFirst) const;
@@ -215,6 +215,7 @@ protected:
     sal_uInt16 GetActRightColumn (
         sal_Bool bForceDontConsiderHidden = sal_False, sal_uInt16 nAct=USHRT_MAX ) const;
     long CalcPropMaxRight(sal_uInt16 nCol=USHRT_MAX) const;
+    long GetPageWidth() const;
 
 public:
 #define     SVXRULER_SUPPORT_TABS                       0x0001
diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx
index 117642e..24f856f 100644
--- a/svx/source/dialog/svxruler.cxx
+++ b/svx/source/dialog/svxruler.cxx
@@ -1340,10 +1340,11 @@ void SvxRuler::Update()
 }
 
 
-inline long SvxRuler::GetPageWidth() const
+long SvxRuler::GetPageWidth() const
 {
+    if ( !pPagePosItem )
+        return 0;
     return bHorz ? pPagePosItem->GetWidth() : pPagePosItem->GetHeight();
-
 }
 
 
diff --git a/sw/AllLangResTarget_sw.mk b/sw/AllLangResTarget_sw.mk
index a388fc1..dd4856e 100644
--- a/sw/AllLangResTarget_sw.mk
+++ b/sw/AllLangResTarget_sw.mk
@@ -144,6 +144,7 @@ $(eval $(call gb_SrsTarget_add_files,sw/res,\
     sw/source/ui/misc/pggrid.src \
     sw/source/ui/misc/redlndlg.src \
     sw/source/ui/misc/srtdlg.src \
+    sw/source/ui/misc/swruler.src \
     sw/source/ui/ribbar/inputwin.src \
     sw/source/ui/ribbar/tbxanchr.src \
     sw/source/ui/ribbar/workctrl.src \
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index f3d0920..d2ba82c 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -602,6 +602,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     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/misc.hrc b/sw/source/ui/inc/misc.hrc
index e5a380f..c8a4f7d 100644
--- a/sw/source/ui/inc/misc.hrc
+++ b/sw/source/ui/inc/misc.hrc
@@ -47,7 +47,11 @@
 #define STRRES_NUMTYPES             (RC_MISC_BEGIN + 63)
 #define STR_MY_AUTOTEXT             (RC_MISC_BEGIN + 64)
 
-#define MISC_ACT_END                STRRES_NUMTYPES
+#define STR_COMMENTS_LABEL          (RC_MISC_BEGIN + 65)
+#define STR_SHOW_COMMENTS           (RC_MISC_BEGIN + 66)
+#define STR_HIDE_COMMENTS           (RC_MISC_BEGIN + 67)
+
+#define MISC_ACT_END                STR_HIDE_COMMENTS
 
 #if MISC_ACT_END > RC_MISC_END
 #error Resource-Id Ueberlauf in #file, #line
diff --git a/sw/source/ui/inc/swruler.hxx b/sw/source/ui/inc/swruler.hxx
new file mode 100644
index 0000000..9e59ae1
--- /dev/null
+++ b/sw/source/ui/inc/swruler.hxx
@@ -0,0 +1,105 @@
+/* -*- 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/.
+ */
+
+#ifndef SW_COMMENT_RULER_HXX
+#define SW_COMMENT_RULER_HXX
+
+#include <svx/ruler.hxx>
+
+class ViewShell;
+class View;
+class Window;
+class SwEditWin;
+
+/**
+ * An horizontal ruler with a control for comment panel visibility fo Writer.
+ *
+ * The comment control only appears when the document has comments already.
+ */
+class SwCommentRuler
+    : public SvxRuler
+{
+public:
+    SwCommentRuler (
+        ViewShell* pViewSh,
+        Window* pParent,
+        SwEditWin* pWin,
+        sal_uInt16 nRulerFlags,
+        SfxBindings& rBindings,
+        WinBits nWinStyle);
+    virtual ~SwCommentRuler ();
+
+    /**
+     * Paint the ruler.
+     * \param rRect ignored
+     */
+    virtual void Paint( const Rectangle& rRect );
+
+protected:
+    ViewShell * mpViewShell;     //< Shell to check if there is any comments on doc and their visibility
+    SwEditWin * mpSwWin;         //< Used to get SwView to change the SideBar visibility
+    bool        mbIsHighlighted; //< If comment control is highlighted (mouse is over it)
+    VirtualDevice maVirDev;      //< VirtualDevice of this window. Just for convenience.
+
+    /**
+     * Callback function to handle a mouse button down event.
+     *
+     * When on comment control, it toggles the comment panel visibility.
+     */
+    virtual void MouseButtonDown( const MouseEvent& rMEvt );
+    /**
+     * Callback function to handle a mouse move event.
+     *
+     * When on comment control, it let the control responsive by highlighting.
+     */
+    virtual void MouseMove(const MouseEvent& rMEvt);
+    /**
+     * Callback function to handle a context menu call (mouse right button click).
+     *
+     * When on comment control, it does not do anything.
+     */
+    virtual void Command( const CommandEvent& rCEvt );
+    /**
+     * Update the view.
+     *
+     * Update the ruler appearance according to the document view and
+     * current cursor position.
+     */
+    virtual void Update();
+
+    /**
+     * Get the rectangle area that should be used to draw the comment control.
+     *
+     * It is horizontally aligned to the SideBar panel.
+     * \param Rectangle The area where the comment control is.
+     */
+    Rectangle GetCommentControlRegion();
+
+    /**
+     * Paint the comment control on VirtualDevice.
+     */
+    void DrawCommentControl();
+    /**
+     * Draw a little horizontal arrow tip on VirtualDevice.
+     * \param nX left coordinate of arrow
+     * \param nY top coordinate of arrow
+     * \param Color arrow color
+     * \param bPointRight if arrow should point to right. Otherwise, it will point left.
+     */
+    void ImplDrawArrow(long nX, long nY, const Color& rColor, bool bPointRight);
+
+    /**
+     * Update the tooltip text.
+     */
+    void UpdateCommentHelpText();
+};
+
+#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..47508ff
--- /dev/null
+++ b/sw/source/ui/misc/swruler.cxx
@@ -0,0 +1,263 @@
+/* -*- 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/.
+ */
+
+// FIX fdo#38246 https://bugs.freedesktop.org/show_bug.cgi?id=38246
+// Design proposal: https://wiki.documentfoundation.org/Design/Whiteboards/Comments_Ruler_Control
+// TODO Alpha blend border when it doesn't fit in window
+// TODO Delayed highlight fading when user moves mouse over and out the control
+
+#include "swruler.hxx"
+
+#include "viewsh.hxx"
+#include "edtwin.hxx"
+#include "PostItMgr.hxx"
+#include "viewopt.hxx"
+#include <view.hxx>
+#include "cmdid.h"
+#include <sfx2/request.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include "misc.hrc"
+
+#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)
+, mbIsHighlighted(false)
+, maVirDev( *this )
+{
+}
+
+// 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 bIsCollapsed = ! mpViewShell->GetPostItMgr()->ShowNotes();
+
+    Rectangle aControlRect = GetCommentControlRegion();
+    maVirDev.SetOutputSizePixel( aControlRect.GetSize() );
+
+    // Paint comment control background
+    // TODO Check if these are best colors to be used
+    if ( mbIsHighlighted )
+        maVirDev.SetFillColor( rStyleSettings.GetDarkShadowColor() );
+    else
+        maVirDev.SetFillColor( rStyleSettings.GetWorkspaceColor() );
+
+    if ( mbIsHighlighted || !bIsCollapsed )
+    {
+        // Draw borders
+        maVirDev.SetLineColor( rStyleSettings.GetShadowColor() );
+    }
+    else
+    {
+        // No borders
+        maVirDev.SetLineColor();
+    }
+
+    maVirDev.DrawRect( Rectangle( Point(), aControlRect.GetSize() ) );
+
+    String aLabel( SW_RESSTR ( STR_COMMENTS_LABEL ) );
+    // Get label and arrow coordinates
+    Point aLabelPos;
+    Point aArrowPos;
+    bool  bArrowToRight;
+    // TODO Discover why it should be 0 instead of CONTROL_BORDER_WIDTH + CONTROL_TOP_OFFSET
+    aLabelPos.Y() = 0;
+    aArrowPos.Y() = CONTROL_BORDER_WIDTH + CONTROL_TOP_OFFSET;
+    if ( !Application::GetSettings().GetLayoutRTL() )
+    {
+        // LTR
+        if ( bIsCollapsed )
+        {
+            // It should draw something like | > Comments  |
+            aLabelPos.X() = CONTROL_LEFT_OFFSET + CONTROL_TRIANGLE_WIDTH + CONTROL_TRIANGLE_PAD;
+            aArrowPos.X() = CONTROL_LEFT_OFFSET;
+        }
+        else
+        {
+            // It should draw something like | Comments  < |
+            aLabelPos.X() = CONTROL_LEFT_OFFSET;
+            aArrowPos.X() = aControlRect.GetSize().Width() - 1 - CONTROL_RIGHT_OFFSET - CONTROL_BORDER_WIDTH - CONTROL_TRIANGLE_WIDTH;
+        }
+        bArrowToRight = bIsCollapsed;
+    }
+    else
+    {
+        // RTL
+        long nLabelWidth = GetTextWidth( aLabel );
+        if ( bIsCollapsed )
+        {
+            // It should draw something like |  Comments < |
+            aArrowPos.X() = aControlRect.GetSize().Width() - 1 - CONTROL_RIGHT_OFFSET - CONTROL_BORDER_WIDTH - CONTROL_TRIANGLE_WIDTH;
+            aLabelPos.X() = aArrowPos.X() - CONTROL_TRIANGLE_PAD - nLabelWidth;
+        }
+        else
+        {
+            // It should draw something like | >  Comments |
+            aLabelPos.X() = aControlRect.GetSize().Width() - 1 - CONTROL_RIGHT_OFFSET - CONTROL_BORDER_WIDTH - nLabelWidth;
+            aArrowPos.X() = CONTROL_LEFT_OFFSET;
+        }
+        bArrowToRight = !bIsCollapsed;
+    }
+
+    // Draw label
+    const Color &rTextColor = mbIsHighlighted ? rStyleSettings.GetButtonTextColor() : rStyleSettings.GetDeactiveTextColor();
+    maVirDev.SetTextColor( rTextColor );
+    // FIXME Expected font size?
+    maVirDev.DrawText( aLabelPos, aLabel );
+
+    // Draw arrow
+    // FIXME consistence of button colors. http://opengrok.libreoffice.org/xref/core/vcl/source/control/button.cxx#785
+    const Color &rArrowColor = mbIsHighlighted ? Color( COL_BLACK ) : rStyleSettings.GetShadowColor();
+    ImplDrawArrow ( aArrowPos.X(), aArrowPos.Y(), rArrowColor, bArrowToRight );
+
+    // 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();
+    // Ignore command request if it is inside Comment Control
+    if ( !mpViewShell->GetPostItMgr()
+          || !mpViewShell->GetPostItMgr()->HasNotes()
+          || !GetCommentControlRegion().IsInside( aMousePos ) )
+        SvxRuler::Command( rCEvt );
+}
+
+void SwCommentRuler::MouseMove(const MouseEvent& rMEvt)
+{
+    SvxRuler::MouseMove(rMEvt);
+    if ( ! mpViewShell->GetPostItMgr() || ! mpViewShell->GetPostItMgr()->HasNotes() )
+        return;
+    // TODO Delay 0.1s to highlight and 0.2s to "lowlight"
+    Point aMousePos = rMEvt.GetPosPixel();
+    bool  bWasHighlighted = mbIsHighlighted;
+    mbIsHighlighted = GetCommentControlRegion().IsInside( aMousePos );
+    if ( mbIsHighlighted != bWasHighlighted )
+    {
+        // Repaint for highlight changes make effect
+        Invalidate();
+        // Set proper help text
+        if ( mbIsHighlighted )
+        {
+            // Mouse over comment control
+            UpdateCommentHelpText();
+        }
+        else
+        {
+            // Mouse out of comment control
+            // FIXME Should remember previous tooltip text?
+            SetQuickHelpText( String() );
+        }
+    }
+}
+
+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 );
+
+    // It is inside comment control, so update help text
+    UpdateCommentHelpText();
+
+    Invalidate();
+}
+
+void SwCommentRuler::Update()
+{
+    Rectangle aPreviousControlRect = GetCommentControlRegion();
+    SvxRuler::Update();
+    if (aPreviousControlRect != GetCommentControlRegion())
+        Invalidate();
+}
+
+void SwCommentRuler::UpdateCommentHelpText()
+{
+    int nTooltipResId;
+    if ( mpViewShell->GetPostItMgr()->ShowNotes() )
+        nTooltipResId = STR_HIDE_COMMENTS;
+    else
+        nTooltipResId = STR_SHOW_COMMENTS;
+    SetQuickHelpText( OUString( SW_RESSTR( nTooltipResId ) ) );
+}
+
+// NOTE: If sometime ahead SwSidebar moves from page right side due RTL layout,
+//   change how this rectangle is used by callers
+// TODO Make Ruler return its central rectangle instead of margins.
+Rectangle SwCommentRuler::GetCommentControlRegion()
+{
+    SwPostItMgr *pPostItMgr = mpViewShell->GetPostItMgr();
+    //FIXME When the page width is larger then screen, the ruler is misplaced by one pixel
+    long nLeft   = GetWinOffset() + GetPageOffset() + mpSwWin->LogicToPixel(Size(GetPageWidth(), 0)).Width();
+    long nTop    = 0 + 4; // Ruler::ImplDraw uses RULER_OFF (value: 3px) as offset, and Ruler::ImplFormat adds one extra pixel
+    // Somehow pPostItMgr->GetSidebarBorderWidth() returns border width already doubled
+    long nRight  = nLeft+ pPostItMgr->GetSidebarWidth(true) + pPostItMgr->GetSidebarBorderWidth(true);
+    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/misc/swruler.src b/sw/source/ui/misc/swruler.src
new file mode 100644
index 0000000..092173f
--- /dev/null
+++ b/sw/source/ui/misc/swruler.src
@@ -0,0 +1,25 @@
+/*
+ * 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/.
+ */
+
+#include "misc.hrc"
+
+String STR_COMMENTS_LABEL
+{
+    Text [ en-US ] = "Comments" ;
+};
+
+String STR_SHOW_COMMENTS
+{
+    Text [ en-US ] = "Show comments" ;
+};
+
+String STR_HIDE_COMMENTS
+{
+    Text [ en-US ] = "Hide comments" ;
+};
+
diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx
index f8b7b3e..431278b 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 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
     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,
@@ -876,6 +869,15 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
     }
     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();
commit 4ec9f68f25f1d75f63e57570eb24f30ebfcfe2b2
Author: Ádám Csaba Király <kiraly.adam.csaba at gmail.com>
Date:   Fri Mar 8 16:56:57 2013 +0100

    fdo#61458, index should be "flat"
    
    Change-Id: I46db120fc5e7d616cd4c9eadee7fc4c502569e86

diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index 903a7bc..6d15761 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -1559,6 +1559,32 @@ static String lcl_GetNumString( const SwTOXSortTabBase& rBase, bool bUsePrefix,
     return sRet;
 }
 
+/*--------------------------------------------------------------------
+  Description: Generate String with newlines changed to spaces,
+  consecutive spaces changed to a single space, and trailing space removed.
+ --------------------------------------------------------------------*/
+String lcl_RemoveLineBreaks( String sRet )
+{
+    xub_StrLen nOffset = 0;
+    sRet.SearchAndReplaceAll('\n', ' ');
+    for (xub_StrLen i = 1; i < sRet.Len(); i++)
+    {
+        if ( sRet.GetChar(i - 1) == ' ' && sRet.GetChar(i) == ' ' )
+        {
+            nOffset += 1;
+        }
+        else
+        {
+            sRet.SetChar(i - nOffset, sRet.GetChar(i));
+        }
+    }
+    if (sRet.GetChar(sRet.Len() - 1) == ' ')
+    {
+        nOffset += 1;
+    }
+    return sRet.Copy(0, sRet.Len() - nOffset);
+}
+
 // Add parameter <_TOXSectNdIdx> and <_pDefaultPageDesc> in order to control,
 // which page description is used, no appropriate one is found.
 void SwTOXBaseSection::GenerateText( sal_uInt16 nArrayIdx,
@@ -1607,6 +1633,7 @@ void SwTOXBaseSection::GenerateText( sal_uInt16 nArrayIdx,
                 {
                     SwIndex aIdx( pTOXNd, rTxt.Len() );
                     rBase.FillText( *pTOXNd, aIdx );
+                    rTxt = lcl_RemoveLineBreaks(rTxt);
                 }
                 break;
 
@@ -1617,6 +1644,7 @@ void SwTOXBaseSection::GenerateText( sal_uInt16 nArrayIdx,
 
                     SwIndex aIdx( pTOXNd, rTxt.Len() );
                     rBase.FillText( *pTOXNd, aIdx );
+                    rTxt = lcl_RemoveLineBreaks(rTxt);
                 }
                 break;
 


More information about the Libreoffice-commits mailing list