summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-08-19 14:59:33 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-08-26 17:14:31 +0200
commitfd2ea8e03510c6a99ec8be6228b7422f6c5b182b (patch)
tree0d79547d16857ce9f0f885fe11adb23189654833 /sfx2
parent57666b8ba70f27c7250ef32f4cb9e7660e258521 (diff)
weld OApplicationSwapWindow
Change-Id: I71d24494b5fe7dd2949876944ab9aff41330ad50 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101027 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/control/thumbnailview.cxx17
-rw-r--r--sfx2/source/control/thumbnailviewitem.cxx37
2 files changed, 47 insertions, 7 deletions
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index a607493119a4..f0f31700fb39 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -1221,6 +1221,8 @@ BitmapEx ThumbnailView::readThumbnail(const OUString &msURL)
SfxThumbnailView::SfxThumbnailView(std::unique_ptr<weld::ScrolledWindow> xWindow, std::unique_ptr<weld::Menu> xMenu)
: mnThumbnailHeight(0)
, mnDisplayHeight(0)
+ , mnVItemSpace(-1)
+ , mbAllowVScrollBar(xWindow->get_vpolicy() != VclPolicyType::NEVER)
, mpItemAttrs(new ThumbnailItemAttributes)
, mxScrolledWindow(std::move(xWindow))
, mxContextMenu(std::move(xMenu))
@@ -1314,6 +1316,7 @@ void SfxThumbnailView::ImplInit()
mbScroll = false;
mbHasVisibleItems = false;
mbShowTooltips = false;
+ mbDrawMnemonics = false;
mbIsMultiSelectionEnabled = true;
maFilterFunc = ViewFilterAll();
@@ -1418,7 +1421,7 @@ void SfxThumbnailView::CalculateItemPositions(bool bScrollBarUsed)
nScrollRatio = 0;
// calculate ScrollBar width
- long nScrBarWidth = mxScrolledWindow->get_vscroll_width();
+ long nScrBarWidth = mbAllowVScrollBar ? mxScrolledWindow->get_vscroll_width() : 0;
// calculate maximum number of visible columns
mnCols = static_cast<sal_uInt16>((aWinSize.Width()-nScrBarWidth) / mnItemWidth);
@@ -1433,7 +1436,9 @@ void SfxThumbnailView::CalculateItemPositions(bool bScrollBarUsed)
long nHSpace = aWinSize.Width()-nScrBarWidth - mnCols*mnItemWidth;
long nVSpace = aWinSize.Height() - mnVisLines*mnItemHeight;
long nHItemSpace = nHSpace / (mnCols+1);
- long nVItemSpace = nVSpace / (mnVisLines+1);
+ long nVItemSpace = mnVItemSpace;
+ if (nVItemSpace == -1) // auto, split up extra space to use as vertical spacing
+ nVItemSpace = nVSpace / (mnVisLines+1);
// calculate maximum number of rows
// Floor( (M+N-1)/N )==Ceiling( M/N )
@@ -1545,7 +1550,8 @@ void SfxThumbnailView::CalculateItemPositions(bool bScrollBarUsed)
if ( nPageSize < 1 )
nPageSize = 1;
mxScrolledWindow->vadjustment_set_page_increment(nPageSize);
- mxScrolledWindow->set_vpolicy(mbScroll ? VclPolicyType::ALWAYS : VclPolicyType::NEVER);
+ if (mbAllowVScrollBar)
+ mxScrolledWindow->set_vpolicy(mbScroll ? VclPolicyType::ALWAYS : VclPolicyType::NEVER);
}
size_t SfxThumbnailView::ImplGetItem( const Point& rPos ) const
@@ -2237,6 +2243,11 @@ void SfxThumbnailView::ShowTooltips( bool bShowTooltips )
mbShowTooltips = bShowTooltips;
}
+void SfxThumbnailView::DrawMnemonics( bool bDrawMnemonics )
+{
+ mbDrawMnemonics = bDrawMnemonics;
+}
+
void SfxThumbnailView::SetMultiSelectionEnabled( bool bIsMultiSelectionEnabled )
{
mbIsMultiSelectionEnabled = bIsMultiSelectionEnabled;
diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx
index 474f415e73cb..b3a6e7d4af97 100644
--- a/sfx2/source/control/thumbnailviewitem.cxx
+++ b/sfx2/source/control/thumbnailviewitem.cxx
@@ -27,6 +27,7 @@
#include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx>
#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
#include <drawinglayer/primitive2d/PolyPolygonSelectionPrimitive2D.hxx>
+#include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx>
#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
#include <drawinglayer/primitive2d/textprimitive2d.hxx>
#include <drawinglayer/processor2d/baseprocessor2d.hxx>
@@ -213,27 +214,30 @@ void ThumbnailViewItem::addTextPrimitives (const OUString& rText, const Thumbnai
aPos.setY(aPos.getY() + aTextDev.getTextHeight());
- OUString aText (rText);
+ sal_Int32 nMnemonicPos = -1;
+ OUString aOrigText(mrParent.isDrawMnemonic() ? OutputDevice::GetNonMnemonicString(rText, nMnemonicPos) : rText);
TextEngine aTextEngine;
aTextEngine.SetFont(getVclFontFromFontAttribute(pAttrs->aFontAttr,
pAttrs->aFontSize.getX(), pAttrs->aFontSize.getY(), 0,
css::lang::Locale()));
aTextEngine.SetMaxTextWidth(maDrawArea.getWidth());
- aTextEngine.SetText(rText);
+ aTextEngine.SetText(aOrigText);
sal_Int32 nPrimitives = rSeq.size();
- rSeq.resize(nPrimitives + aTextEngine.GetLineCount(0));
+ sal_Int32 nFinalPrimCount = nPrimitives + aTextEngine.GetLineCount(0);
+ rSeq.resize(nFinalPrimCount);
// Create the text primitives
sal_uInt16 nLineStart = 0;
+ OUString aText(aOrigText);
for (sal_uInt16 i=0; i < aTextEngine.GetLineCount(0); ++i)
{
sal_Int32 nLineLength = aTextEngine.GetLineLen(0, i);
double nLineWidth = aTextDev.getTextWidth (aText, nLineStart, nLineLength);
bool bTooLong = (aPos.getY() + aTextEngine.GetCharHeight()) > maDrawArea.Bottom();
- if (bTooLong && (nLineLength + nLineStart) < rText.getLength())
+ if (bTooLong && (nLineLength + nLineStart) < aOrigText.getLength())
{
// Add the '...' to the last line to show, even though it may require to shorten the line
double nDotsWidth = aTextDev.getTextWidth("...",0,3);
@@ -271,6 +275,31 @@ void ThumbnailViewItem::addTextPrimitives (const OUString& rText, const Thumbnai
pAttrs->aFontAttr,
css::lang::Locale(),
aTextColor));
+
+ if (nMnemonicPos != -1 && nMnemonicPos >= nLineStart && nMnemonicPos < nLineStart + nLineLength)
+ {
+ rSeq.resize(nFinalPrimCount + 1);
+
+ auto aCaretPositions = aTextDev.getCaretPositions(aText, nLineStart, nLineLength);
+
+ auto lc_x1 = aCaretPositions[2*(nMnemonicPos - nLineStart)];
+ auto lc_x2 = aCaretPositions[2*(nMnemonicPos - nLineStart)+1];
+ auto fMnemonicWidth = std::abs(lc_x1 - lc_x2);
+ auto fMnemonicHeight = aTextDev.getUnderlineHeight();
+
+ auto fPosX = nLineX + std::min(lc_x1, lc_x2);
+ auto fPosY = aPos.Y() + aTextDev.getUnderlineOffset();
+
+ B2DPolygon aLine;
+ aLine.append(B2DPoint(fPosX, fPosY));
+ aLine.append(B2DPoint(fPosX + fMnemonicWidth, fPosY));
+
+ drawinglayer::attribute::LineAttribute aLineAttribute(Color(aTextColor).getBColor(), fMnemonicHeight);
+
+ rSeq[nPrimitives++] = drawinglayer::primitive2d::Primitive2DReference(
+ new PolygonStrokePrimitive2D(aLine, aLineAttribute));
+ }
+
nLineStart += nLineLength;
aPos.setY(aPos.getY() + aTextEngine.GetCharHeight());