summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-04-27 01:21:50 +0200
committerJan Holesovsky <kendy@collabora.com>2014-04-27 01:30:51 +0200
commit60cd850d672bc1dcc3eb24adfffa7a6ab98a44bd (patch)
treef83bc715cf2964476eb53e0be307418d246c5b3b /sfx2
parent978ba69d33cf31cd334f18af5215166dd3926402 (diff)
startcenter: Add possibility to selectively remove recent documents.
Change-Id: Id0c20de6dc3375e64dd3dbef34dcd6eb77f02340
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/control/recentdocsview.cxx76
-rw-r--r--sfx2/source/control/recentdocsviewitem.cxx154
-rw-r--r--sfx2/source/control/templateview.hrc12
-rw-r--r--sfx2/source/control/templateview.src10
-rw-r--r--sfx2/source/control/thumbnailview.cxx17
-rw-r--r--sfx2/source/control/thumbnailviewitem.cxx25
-rw-r--r--sfx2/source/dialog/backingwindow.cxx2
7 files changed, 213 insertions, 83 deletions
diff --git a/sfx2/source/control/recentdocsview.cxx b/sfx2/source/control/recentdocsview.cxx
index 51e44b24248c..0564e8b3e398 100644
--- a/sfx2/source/control/recentdocsview.cxx
+++ b/sfx2/source/control/recentdocsview.cxx
@@ -26,7 +26,6 @@
#include <unotools/historyoptions.hxx>
#include <vcl/builder.hxx>
#include <vcl/pngread.hxx>
-#include <vcl/svapp.hxx>
#include <tools/urlobj.hxx>
#include <com/sun/star/util/URLTransformer.hpp>
#include <com/sun/star/frame/Desktop.hpp>
@@ -148,7 +147,7 @@ void RecentDocsView::insertItem(const OUString &rURL, const OUString &rTitle, co
AppendItem(pChild);
}
-void RecentDocsView::loadRecentDocs()
+void RecentDocsView::Reload()
{
Clear();
@@ -212,78 +211,33 @@ void RecentDocsView::loadRecentDocs()
void RecentDocsView::MouseButtonDown( const MouseEvent& rMEvt )
{
- if ( rMEvt.IsLeft() )
+ if (rMEvt.IsLeft())
{
- if( rMEvt.GetClicks() > 1 )
- return;
+ // ignore to avoid stuff done in ThumbnailView; we don't do selections etc.
+ return;
+ }
+ ThumbnailView::MouseButtonDown(rMEvt);
+}
+
+void RecentDocsView::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ if (rMEvt.IsLeft())
+ {
size_t nPos = ImplGetItem(rMEvt.GetPosPixel());
ThumbnailViewItem* pItem = ImplGetItem(nPos);
if (pItem)
{
- OpenItem(pItem);
+ pItem->MouseButtonUp(rMEvt);
return;
}
}
- ThumbnailView::MouseButtonDown( rMEvt );
+ ThumbnailView::MouseButtonUp(rMEvt);
}
-void RecentDocsView::OnItemDblClicked(ThumbnailViewItem *pItem)
+void RecentDocsView::OnItemDblClicked(ThumbnailViewItem *)
{
- OpenItem( pItem );
-}
-
-void RecentDocsView::OpenItem( const ThumbnailViewItem *pItem )
-{
- const RecentDocsViewItem* pRecentItem = dynamic_cast<const RecentDocsViewItem*>(pItem);
- if (!pRecentItem)
- return;
-
- // show busy mouse pointer
- SetPointer(Pointer(POINTER_WAIT));
-
- Reference< XDispatch > xDispatch;
- Reference< XDispatchProvider > xDispatchProvider;
- css::util::URL aTargetURL;
- Sequence< PropertyValue > aArgsList;
-
- uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create( ::comphelper::getProcessComponentContext() );
- uno::Reference< frame::XFrame > xActiveFrame = xDesktop->getActiveFrame();
-
- osl::ClearableMutexGuard aLock( m_aMutex );
- xDispatchProvider = Reference< XDispatchProvider >( xActiveFrame, UNO_QUERY );
- aLock.clear();
-
- aTargetURL.Complete = pRecentItem->maURL;
- Reference< ::com::sun::star::util::XURLTransformer > xTrans(
- ::com::sun::star::util::URLTransformer::create(
- ::comphelper::getProcessComponentContext() ) );
- xTrans->parseStrict( aTargetURL );
-
- sal_Int32 nSize = 2;
- aArgsList.realloc( nSize );
- aArgsList[0].Name = "Referer";
- aArgsList[0].Value = makeAny( OUString( "private:user" ) );
-
- // documents will never be opened as templates
- aArgsList[1].Name = "AsTemplate";
- aArgsList[1].Value = makeAny( false );
-
- xDispatch = xDispatchProvider->queryDispatch( aTargetURL, "_default", 0 );
-
- if ( xDispatch.is() )
- {
- // Call dispatch asychronously as we can be destroyed while dispatch is
- // executed. VCL is not able to survive this as it wants to call listeners
- // after select!!!
- LoadRecentFile* pLoadRecentFile = new LoadRecentFile;
- pLoadRecentFile->xDispatch = xDispatch;
- pLoadRecentFile->aTargetURL = aTargetURL;
- pLoadRecentFile->aArgSeq = aArgsList;
-
- Application::PostUserEvent( STATIC_LINK(0, RecentDocsView, ExecuteHdl_Impl), pLoadRecentFile );
- }
}
void RecentDocsView::Paint( const Rectangle &aRect )
diff --git a/sfx2/source/control/recentdocsviewitem.cxx b/sfx2/source/control/recentdocsviewitem.cxx
index 8c64fb4ddfd4..b6f727400900 100644
--- a/sfx2/source/control/recentdocsviewitem.cxx
+++ b/sfx2/source/control/recentdocsviewitem.cxx
@@ -9,15 +9,52 @@
#include <sfx2/recentdocsviewitem.hxx>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/util/URLTransformer.hpp>
+#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <drawinglayer/primitive2d/discretebitmapprimitive2d.hxx>
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
#include <i18nutil/paper.hxx>
-#include <sfx2/templateabstractview.hxx>
#include <sfx2/recentdocsview.hxx>
+#include <sfx2/sfxresid.hxx>
+#include <sfx2/templateabstractview.hxx>
#include <tools/urlobj.hxx>
+#include <unotools/historyoptions.hxx>
+#include <vcl/svapp.hxx>
+
+#include <templateview.hrc>
+
+using namespace basegfx;
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace drawinglayer::primitive2d;
+using namespace drawinglayer::processor2d;
+
+/// Icon that the user can click to remove the document from the recent documents.
+struct theRemoveRecentBitmap : public rtl::StaticWithInit<BitmapEx, theRemoveRecentBitmap>
+{
+ BitmapEx operator()()
+ {
+ return SfxResId(IMG_RECENTDOC_REMOVE);
+ }
+
+};
+
+/// Highlighted version of icon that the user can click to remove the document from the recent documents.
+struct theRemoveRecentBitmapHighlighted : public rtl::StaticWithInit<BitmapEx, theRemoveRecentBitmapHighlighted>
+{
+ BitmapEx operator()()
+ {
+ return SfxResId(IMG_RECENTDOC_REMOVE_HIGHLIGHTED);
+ }
+
+};
RecentDocsViewItem::RecentDocsViewItem(ThumbnailView &rView, const OUString &rURL,
const OUString &rTitle, const BitmapEx &rThumbnail, sal_uInt16 nId)
: ThumbnailViewItem(rView, nId),
- maURL(rURL)
+ maURL(rURL),
+ m_bRemoveIconHighlighted(false)
{
OUString aTitle(rTitle);
INetURLObject aURLObj(rURL);
@@ -89,9 +126,122 @@ void RecentDocsViewItem::setEditTitle (bool edit, bool bChangeFocus)
(void)bChangeFocus;
}
+Rectangle RecentDocsViewItem::updateHighlight(bool bVisible, const Point& rPoint)
+{
+ Rectangle aRect(ThumbnailViewItem::updateHighlight(bVisible, rPoint));
+
+ if (bVisible && getRemoveIconArea().IsInside(rPoint))
+ {
+ if (!m_bRemoveIconHighlighted)
+ aRect.Union(getRemoveIconArea());
+
+ m_bRemoveIconHighlighted = true;
+ }
+ else
+ {
+ if (m_bRemoveIconHighlighted)
+ aRect.Union(getRemoveIconArea());
+
+ m_bRemoveIconHighlighted = false;
+ }
+
+ return aRect;
+}
+
+Rectangle RecentDocsViewItem::getRemoveIconArea() const
+{
+ Rectangle aArea(getDrawArea());
+ Size aSize(theRemoveRecentBitmap::get().GetSizePixel());
+
+ return Rectangle(
+ Point(aArea.Right() - aSize.Width() - THUMBNAILVIEW_ITEM_CORNER, aArea.Top() + THUMBNAILVIEW_ITEM_CORNER),
+ aSize);
+}
+
OUString RecentDocsViewItem::getHelpText() const
{
return m_sHelpText;
}
+void RecentDocsViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProcessor, const ThumbnailItemAttributes *pAttrs)
+{
+ ThumbnailViewItem::Paint(pProcessor, pAttrs);
+
+ // paint the remove icon when highlighted
+ if (isHighlighted())
+ {
+ Primitive2DSequence aSeq(1);
+
+ Point aIconPos(getRemoveIconArea().TopLeft());
+
+ aSeq[0] = Primitive2DReference(new DiscreteBitmapPrimitive2D(
+ m_bRemoveIconHighlighted? theRemoveRecentBitmapHighlighted::get(): theRemoveRecentBitmap::get(),
+ B2DPoint(aIconPos.X(), aIconPos.Y())));
+
+ pProcessor->process(aSeq);
+ }
+}
+
+void RecentDocsViewItem::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ if (rMEvt.IsLeft())
+ {
+ if (getRemoveIconArea().IsInside(rMEvt.GetPosPixel()))
+ {
+ SvtHistoryOptions().DeleteItem(ePICKLIST, maURL);
+ mrParent.Reload();
+ return;
+ }
+
+ OpenDocument();
+ return;
+ }
+}
+
+void RecentDocsViewItem::OpenDocument()
+{
+ // show busy mouse pointer
+ mrParent.SetPointer(Pointer(POINTER_WAIT));
+
+ Reference<frame::XDispatch> xDispatch;
+ Reference<frame::XDispatchProvider> xDispatchProvider;
+ css::util::URL aTargetURL;
+ Sequence<beans::PropertyValue> aArgsList;
+
+ uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(::comphelper::getProcessComponentContext());
+ uno::Reference<frame::XFrame> xActiveFrame = xDesktop->getActiveFrame();
+
+ //osl::ClearableMutexGuard aLock(m_aMutex);
+ xDispatchProvider = Reference<frame::XDispatchProvider>(xActiveFrame, UNO_QUERY);
+ //aLock.clear();
+
+ aTargetURL.Complete = maURL;
+ Reference<util::XURLTransformer> xTrans(util::URLTransformer::create(::comphelper::getProcessComponentContext()));
+ xTrans->parseStrict(aTargetURL);
+
+ sal_Int32 nSize = 2;
+ aArgsList.realloc(nSize);
+ aArgsList[0].Name = "Referer";
+ aArgsList[0].Value = makeAny(OUString("private:user"));
+
+ // documents will never be opened as templates
+ aArgsList[1].Name = "AsTemplate";
+ aArgsList[1].Value = makeAny(false);
+
+ xDispatch = xDispatchProvider->queryDispatch(aTargetURL, "_default", 0);
+
+ if (xDispatch.is())
+ {
+ // Call dispatch asychronously as we can be destroyed while dispatch is
+ // executed. VCL is not able to survive this as it wants to call listeners
+ // after select!!!
+ LoadRecentFile* pLoadRecentFile = new LoadRecentFile;
+ pLoadRecentFile->xDispatch = xDispatch;
+ pLoadRecentFile->aTargetURL = aTargetURL;
+ pLoadRecentFile->aArgSeq = aArgsList;
+
+ Application::PostUserEvent(STATIC_LINK(0, RecentDocsView, ExecuteHdl_Impl), pLoadRecentFile);
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/templateview.hrc b/sfx2/source/control/templateview.hrc
index 95bf930501ea..d2073bc8a304 100644
--- a/sfx2/source/control/templateview.hrc
+++ b/sfx2/source/control/templateview.hrc
@@ -7,10 +7,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#define BTN_ALL_TEMPLATES 256
-#define FT_NAME 258
-#define STR_WELCOME_LINE1 259
-#define STR_WELCOME_LINE2 260
-#define IMG_WELCOME 261
+#define BTN_ALL_TEMPLATES 256
+#define FT_NAME 258
+#define STR_WELCOME_LINE1 259
+#define STR_WELCOME_LINE2 260
+#define IMG_WELCOME 261
+#define IMG_RECENTDOC_REMOVE 262
+#define IMG_RECENTDOC_REMOVE_HIGHLIGHTED 263
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/templateview.src b/sfx2/source/control/templateview.src
index 49fe01588d12..70f3ff30844c 100644
--- a/sfx2/source/control/templateview.src
+++ b/sfx2/source/control/templateview.src
@@ -38,4 +38,14 @@ Image IMG_WELCOME
ImageBitmap = Bitmap { File = "logo.png" ; };
};
+Bitmap IMG_RECENTDOC_REMOVE
+{
+ File = "recentdoc_remove.png";
+};
+
+Bitmap IMG_RECENTDOC_REMOVE_HIGHLIGHTED
+{
+ File = "recentdoc_remove_highlighted.png";
+};
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 53a0564444d1..884084dabea1 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -87,26 +87,17 @@ void ThumbnailView::MouseMove(const MouseEvent& rMEvt)
for (size_t i = 0; i < nItemCount; i++)
{
- bool bNeedsPaint = false;
ThumbnailViewItem *pItem = mFilteredItemList[i];
if (pItem->mbVisible && !rMEvt.IsLeaveWindow() && pItem->getDrawArea().IsInside(aPoint))
{
aHelp = pItem->getHelpText();
-
- if (!pItem->isHighlighted())
- bNeedsPaint = true;
- pItem->setHighlight(true);
- }
- else
- {
- if (pItem->isHighlighted())
- bNeedsPaint = true;
- pItem->setHighlight(false);
}
- if (bNeedsPaint && IsReallyVisible() && IsUpdateMode())
- Invalidate(pItem->getDrawArea());
+ Rectangle aToInvalidate(pItem->updateHighlight(pItem->mbVisible && !rMEvt.IsLeaveWindow(), aPoint));
+
+ if (!aToInvalidate.IsEmpty() && IsReallyVisible() && IsUpdateMode())
+ Invalidate(aToInvalidate);
}
if (mbShowTooltips)
diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx
index ee72c1f0cc87..9d66868c5094 100644
--- a/sfx2/source/control/thumbnailviewitem.cxx
+++ b/sfx2/source/control/thumbnailviewitem.cxx
@@ -146,6 +146,29 @@ void ThumbnailViewItem::setHighlight (bool state)
mbHover = state;
}
+Rectangle ThumbnailViewItem::updateHighlight(bool bVisible, const Point& rPoint)
+{
+ bool bNeedsPaint = false;
+
+ if (bVisible && getDrawArea().IsInside(rPoint))
+ {
+ if (!isHighlighted())
+ bNeedsPaint = true;
+ setHighlight(true);
+ }
+ else
+ {
+ if (isHighlighted())
+ bNeedsPaint = true;
+ setHighlight(false);
+ }
+
+ if (bNeedsPaint)
+ return getDrawArea();
+
+ return Rectangle();
+}
+
OUString ThumbnailViewItem::getHelpText() const
{
return maTitle;
@@ -265,7 +288,7 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc
sal_uInt32 nPrimitive = 0;
aSeq[nPrimitive++] = drawinglayer::primitive2d::Primitive2DReference( new PolyPolygonSelectionPrimitive2D(
- B2DPolyPolygon(Polygon(maDrawArea,5,5).getB2DPolygon()),
+ B2DPolyPolygon(Polygon(maDrawArea, THUMBNAILVIEW_ITEM_CORNER, THUMBNAILVIEW_ITEM_CORNER).getB2DPolygon()),
aFillColor,
fTransparence,
0.0,
diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx
index f988fc7b7b1d..9c177575a02e 100644
--- a/sfx2/source/dialog/backingwindow.cxx
+++ b/sfx2/source/dialog/backingwindow.cxx
@@ -224,7 +224,7 @@ void BackingWindow::initControls()
mpAllRecentThumbnails->mnFileTypes |= TYPE_MATH;
mpAllRecentThumbnails->mnFileTypes |= TYPE_OTHER;
- mpAllRecentThumbnails->loadRecentDocs();
+ mpAllRecentThumbnails->Reload();
mpAllRecentThumbnails->ShowTooltips( true );
setupButton( mpOpenButton );