/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * 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/.
*/
namespace
{ /** * Draw a little arrow / triangle with different directions * * \param nX left coordinate of arrow square * \param nY top coordinate of arrow square * \param nSize size of the long triangle side / arrow square * \param Color arrow color * \param bCollapsed if the arrow should display the collapsed state
*/ void ImplDrawArrow(vcl::RenderContext& rRenderContext, tools::Long nX, tools::Long nY,
tools::Long nSize, const Color& rColor, bool bCollapsed)
{
tools::Polygon aTrianglePolygon(4);
if (bCollapsed)
{ if (AllSettings::GetLayoutRTL()) // <
{
aTrianglePolygon.SetPoint({ nX + nSize / 2, nY }, 0);
aTrianglePolygon.SetPoint({ nX + nSize / 2, nY + nSize }, 1);
aTrianglePolygon.SetPoint({ nX, nY + nSize / 2 }, 2);
aTrianglePolygon.SetPoint({ nX + nSize / 2, nY }, 3);
} else// >
{
aTrianglePolygon.SetPoint({ nX, nY }, 0);
aTrianglePolygon.SetPoint({ nX + nSize / 2, nY + nSize / 2 }, 1);
aTrianglePolygon.SetPoint({ nX, nY + nSize }, 2);
aTrianglePolygon.SetPoint({ nX, nY }, 3);
}
} else// v
{
aTrianglePolygon.SetPoint({ nX, nY + nSize / 2 }, 0);
aTrianglePolygon.SetPoint({ nX + nSize, nY + nSize / 2 }, 1);
aTrianglePolygon.SetPoint({ nX + nSize / 2, nY + nSize }, 2);
aTrianglePolygon.SetPoint({ nX, nY + nSize / 2 }, 3);
}
// we have a little bit more space, as we don't draw ruler ticks
vcl::Font aFont(maVirDev->GetFont());
aFont.SetFontHeight(aFont.GetFontHeight() + 1);
maVirDev->SetFont(aFont);
}
void SwCommentRuler::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
{ if (comphelper::LibreOfficeKit::isActive()) return; // no need to waste time on startup
SvxRuler::Paint(rRenderContext, rRect);
// Don't draw if there is not any note if (mpViewShell->GetPostItMgr() && mpViewShell->GetPostItMgr()->HasNotes())
DrawCommentControl(rRenderContext);
}
// 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().Contains(aMousePos))
SvxRuler::Command(rCEvt);
}
// TODO Make Ruler return its central rectangle instead of margins.
tools::Rectangle SwCommentRuler::GetCommentControlRegion()
{
SwPostItMgr* pPostItMgr = mpViewShell->GetPostItMgr();
//rhbz#1006850 When the SwPostItMgr ctor is called from SwView::SwView it //triggers an update of the uiview, but the result of the ctor hasn't been //set into the mpViewShell yet, so GetPostItMgr is temporarily still NULL if (!pPostItMgr) return tools::Rectangle();
//FIXME When the page width is larger then screen, the ruler is misplaced by one pixel
tools::Long nLeft = GetPageOffset(); if (GetSidebarPosition() == sw::sidebarwindows::SidebarPosition::LEFT)
nLeft += GetBorderOffset() - nSidebarWidth; else
nLeft += GetWinOffset() + mpSwWin->LogicToPixel(Size(GetPageWidth(), 0)).Width();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.