[Libreoffice-commits] .: 5 commits - sfx2/inc sfx2/source
Rafael Dominguez
rdominguez at kemper.freedesktop.org
Wed Jul 11 12:05:39 PDT 2012
sfx2/inc/sfx2/templateviewitem.hxx | 11 ++
sfx2/inc/sfx2/thumbnailviewitem.hxx | 2
sfx2/source/control/templatefolderview.cxx | 10 +-
sfx2/source/control/templatefolderviewitem.cxx | 2
sfx2/source/control/templatesearchview.cxx | 6 -
sfx2/source/control/templateview.cxx | 2
sfx2/source/control/templateviewitem.cxx | 101 +++++++++++++++++++++++++
sfx2/source/control/thumbnailview.cxx | 4
sfx2/source/control/thumbnailviewacc.cxx | 2
sfx2/source/control/thumbnailviewitem.cxx | 4
sfx2/source/doc/templatedlg.cxx | 5 -
sfx2/source/inc/templatesearchview.hxx | 4
12 files changed, 134 insertions(+), 19 deletions(-)
New commits:
commit 802e3fa7e6eff9d6ca5d731096e4bf5e38f3c51a
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Wed Jul 11 13:45:22 2012 -0430
Draw thumbnail subtitle.
- In the case of the SearchViewItem will be Folders name and in the case
of TemplateViewItem it will be author.
Change-Id: I251a3db323f7f02d023c9673d0a7a8027456bda6
diff --git a/sfx2/inc/sfx2/templateviewitem.hxx b/sfx2/inc/sfx2/templateviewitem.hxx
index a0c4049..74b53c0 100644
--- a/sfx2/inc/sfx2/templateviewitem.hxx
+++ b/sfx2/inc/sfx2/templateviewitem.hxx
@@ -40,6 +40,10 @@ public:
const rtl::OUString& getSubTitle () const { return maSubTitle; }
+ virtual void calculateItemsPosition (sal_uInt32 nMaxTextLength);
+
+ virtual void Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor,
+ const ThumbnailItemAttributes *pAttrs);
private:
rtl::OUString maPath;
@@ -47,6 +51,8 @@ private:
rtl::OUString maKeywords;
rtl::OUString maFileType;
rtl::OUString maSubTitle;
+
+ Point maSubTitlePos;
};
#endif // TEMPLATEVIEWITEM_HXX
diff --git a/sfx2/source/control/templateviewitem.cxx b/sfx2/source/control/templateviewitem.cxx
index 156f8ea..01041a9 100644
--- a/sfx2/source/control/templateviewitem.cxx
+++ b/sfx2/source/control/templateviewitem.cxx
@@ -9,6 +9,21 @@
#include <sfx2/templateviewitem.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/attribute/fillbitmapattribute.hxx>
+#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
+#include <drawinglayer/primitive2d/textprimitive2d.hxx>
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+#include <vcl/button.hxx>
+
+using namespace basegfx;
+using namespace basegfx::tools;
+using namespace drawinglayer::attribute;
+using namespace drawinglayer::primitive2d;
+
TemplateViewItem::TemplateViewItem (ThumbnailView &rView, Window *pParent)
: ThumbnailViewItem(rView,pParent)
{
@@ -18,6 +33,92 @@ TemplateViewItem::~TemplateViewItem ()
{
}
+void TemplateViewItem::calculateItemsPosition(sal_uInt32 nMaxTextLength)
+{
+ ThumbnailViewItem::calculateItemsPosition(nMaxTextLength);
+
+ if (!maSubTitle.isEmpty())
+ {
+ Size aRectSize = maDrawArea.GetSize();
+ Size aImageSize = maPreview1.GetSizePixel();
+ aRectSize.Height() -= aImageSize.getHeight();
+
+ drawinglayer::primitive2d::TextLayouterDevice aTextDev;
+
+ long nSpace = (aRectSize.getHeight() - 2*aTextDev.getTextHeight()) / 3;
+
+ // Set title position
+ maTextPos.setY(maPrev1Pos.getY() + aImageSize.getHeight() + nSpace);
+
+ // Set subtitle position
+ maSubTitlePos.setY(maTextPos.getY() + nSpace);
+ maSubTitlePos.setX(maDrawArea.Left() + (aRectSize.Width() - aTextDev.getTextWidth(maSubTitle,0,nMaxTextLength))/2);
+ }
+}
+
+void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProcessor,
+ const ThumbnailItemAttributes *pAttrs)
+{
+ BColor aFillColor = pAttrs->aFillColor;
+
+ int nCount = maSubTitle.isEmpty() ? 3 : 4;
+ Primitive2DSequence aSeq(nCount);
+
+ // Draw background
+ if ( mbSelected || mbHover )
+ aFillColor = pAttrs->aHighlightColor;
+
+ aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D(
+ B2DPolyPolygon(Polygon(maDrawArea,5,5).getB2DPolygon()),
+ aFillColor));
+
+ // Draw thumbnail
+ Size aImageSize = maPreview1.GetSizePixel();
+
+ aSeq[1] = Primitive2DReference( new FillBitmapPrimitive2D(
+ createTranslateB2DHomMatrix(maPrev1Pos.X(),maPrev1Pos.Y()),
+ FillBitmapAttribute(maPreview1,
+ B2DPoint(0,0),
+ B2DVector(aImageSize.Width(),aImageSize.Height()),
+ false)
+ ));
+
+ // Draw centered text below thumbnail
+
+ // Create the text primitive
+ basegfx::B2DHomMatrix aTitleMatrix( createScaleTranslateB2DHomMatrix(
+ pAttrs->aFontSize.getX(), pAttrs->aFontSize.getY(),
+ double( maTextPos.X() ), double( maTextPos.Y() ) ) );
+
+ aSeq[2] = Primitive2DReference(
+ new TextSimplePortionPrimitive2D(aTitleMatrix,
+ maTitle,0,pAttrs->nMaxTextLenght,
+ std::vector< double >( ),
+ pAttrs->aFontAttr,
+ com::sun::star::lang::Locale(),
+ Color(COL_BLACK).getBColor() ) );
+
+ if (!maSubTitle.isEmpty())
+ {
+ basegfx::B2DHomMatrix aSubTitleMatrix( createScaleTranslateB2DHomMatrix(
+ pAttrs->aFontSize.getX(), pAttrs->aFontSize.getY(),
+ double( maSubTitlePos.X() ), double( maSubTitlePos.Y() ) ) );
+
+ aSeq[3] = Primitive2DReference(
+ new TextSimplePortionPrimitive2D(aSubTitleMatrix,
+ maSubTitle,0,pAttrs->nMaxTextLenght,
+ std::vector< double >( ),
+ pAttrs->aFontAttr,
+ com::sun::star::lang::Locale(),
+ Color(COL_BLACK).getBColor() ) );
+ }
+
+ pProcessor->process(aSeq);
+
+ if (mbMode || mbHover || mbSelected)
+ mpSelectBox->Paint(maDrawArea);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 2ef58e5af9d05fcf1e3d6a709b2f9e113fb64cf5
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Wed Jul 11 12:32:04 2012 -0430
Ignore case when searching for a template.
Change-Id: I47e35241a67892ff7c1d9aedf04cf2ab86c1371c
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 4967d89..de48d57 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -74,7 +74,7 @@ public:
bool operator() (const TemplateItemProperties &rItem)
{
- return rItem.aName.indexOf(maKeyword) != -1;
+ return rItem.aName.matchIgnoreAsciiCase(maKeyword);
}
private:
commit 1bc6db06c4d5515d8d858641d0ae26a8b8572b8b
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Wed Jul 11 11:53:21 2012 -0430
Set SearchViewItem subtitle folder name.
Change-Id: I1fc3f69ed5ecdfa9d9adb4b2b69801f2bb01e7f7
diff --git a/sfx2/source/control/templatesearchview.cxx b/sfx2/source/control/templatesearchview.cxx
index ab3e122..edd4bd4 100644
--- a/sfx2/source/control/templatesearchview.cxx
+++ b/sfx2/source/control/templatesearchview.cxx
@@ -34,7 +34,8 @@ TemplateSearchView::~TemplateSearchView ()
}
void TemplateSearchView::AppendItem(sal_uInt16 nItemId, sal_uInt16 nRegionId, sal_uInt16 nIdx,
- const rtl::OUString &rStr, const rtl::OUString &rPath,
+ const rtl::OUString &rTitle, const rtl::OUString &rSubtitle,
+ const rtl::OUString &rPath,
const BitmapEx &rImage)
{
TemplateSearchViewItem *pItem = new TemplateSearchViewItem(*this,this);
@@ -42,7 +43,8 @@ void TemplateSearchView::AppendItem(sal_uInt16 nItemId, sal_uInt16 nRegionId, sa
pItem->mnIdx = nIdx;
pItem->mnRegionId = nRegionId;
pItem->maPreview1 = rImage;
- pItem->maTitle = rStr;
+ pItem->maTitle = rTitle;
+ pItem->setSubTitle(rSubtitle);
pItem->setPath(rPath);
pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnItemSelected));
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 9738060..4967d89 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -601,6 +601,7 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, SearchUpdateHdl)
mpSearchView->AppendItem(++nCounter,pItem->nRegionId,
pItem->nId-1,
pItem->aName,
+ maView->GetItemText(pItem->nRegionId+1),
pItem->aPath,
pItem->aThumbnail);
}
diff --git a/sfx2/source/inc/templatesearchview.hxx b/sfx2/source/inc/templatesearchview.hxx
index 3d453b3..a8333ce 100644
--- a/sfx2/source/inc/templatesearchview.hxx
+++ b/sfx2/source/inc/templatesearchview.hxx
@@ -21,8 +21,8 @@ public:
virtual ~TemplateSearchView();
void AppendItem(sal_uInt16 nItemId, sal_uInt16 nRegionId, sal_uInt16 nIdx,
- const rtl::OUString &rStr, const rtl::OUString &rPath,
- const BitmapEx &rImage );
+ const rtl::OUString &rTitle, const rtl::OUString &rSubtitle,
+ const rtl::OUString &rPath, const BitmapEx &rImage );
};
#endif // __SFX2_TEMPLATESEARCHVIEW_HXX__
commit 665891eba17de4c40846d4569d306d79bd0c2fa2
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Wed Jul 11 11:45:41 2012 -0430
Add subtitle attribute to TemplateViewItem.
Change-Id: I181a84b468cf10d7c80f84030890965fa0dc4ffa
diff --git a/sfx2/inc/sfx2/templateviewitem.hxx b/sfx2/inc/sfx2/templateviewitem.hxx
index ffb72cd..a0c4049 100644
--- a/sfx2/inc/sfx2/templateviewitem.hxx
+++ b/sfx2/inc/sfx2/templateviewitem.hxx
@@ -36,12 +36,17 @@ public:
const rtl::OUString& getFileType () const { return maFileType; }
+ void setSubTitle (const rtl::OUString &rTitle) { maSubTitle = rTitle; }
+
+ const rtl::OUString& getSubTitle () const { return maSubTitle; }
+
private:
rtl::OUString maPath;
rtl::OUString maAuthor;
rtl::OUString maKeywords;
rtl::OUString maFileType;
+ rtl::OUString maSubTitle;
};
#endif // TEMPLATEVIEWITEM_HXX
commit a93e06c0c7500778cbe9bc8d6c023a2cf3a4661f
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Wed Jul 11 11:28:25 2012 -0430
Rename ThumbnailViewItem maText attribute to maTitle.
Change-Id: Id253d06325ec05bb587c9759027ea07b65fe257f
diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx
index 9b4289d..e6719c9 100644
--- a/sfx2/inc/sfx2/thumbnailviewitem.hxx
+++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx
@@ -69,7 +69,7 @@ public:
bool mbSelected;
bool mbHover;
BitmapEx maPreview1;
- rtl::OUString maText;
+ rtl::OUString maTitle;
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >* mpxAcc;
ThumbnailViewItem (ThumbnailView &rView, Window *pParent);
diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx
index 1db2f77..a23114d 100644
--- a/sfx2/source/control/templatefolderview.cxx
+++ b/sfx2/source/control/templatefolderview.cxx
@@ -310,7 +310,7 @@ void TemplateFolderView::Populate ()
TemplateFolderViewItem* pItem = new TemplateFolderViewItem( *this, this );
pItem->mnId = i+1;
- pItem->maText = aRegionName;
+ pItem->maTitle = aRegionName;
pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnItemSelected));
sal_uInt16 nEntries = mpDocTemplates->GetCount(i);
@@ -355,7 +355,7 @@ std::vector<rtl::OUString> TemplateFolderView::getFolderNames()
std::vector<rtl::OUString> ret(n);
for (size_t i = 0; i < n; ++i)
- ret[i] = mItemList[i]->maText;
+ ret[i] = mItemList[i]->maTitle;
return ret;
}
@@ -455,7 +455,7 @@ sal_uInt16 TemplateFolderView::createRegion(const rtl::OUString &rName)
TemplateFolderViewItem* pItem = new TemplateFolderViewItem( *this, this );
pItem->mnId = nRegionId+1;
- pItem->maText = aRegionName;
+ pItem->maTitle = aRegionName;
pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnItemSelected));
mItemList.push_back(pItem);
@@ -567,7 +567,7 @@ bool TemplateFolderView::moveTemplates(std::set<const ThumbnailViewItem *> &rIte
TemplateItemProperties aTemplateItem;
aTemplateItem.nId = nTargetIdx + 1;
aTemplateItem.nRegionId = nTargetRegion;
- aTemplateItem.aName = pViewItem->maText;
+ aTemplateItem.aName = pViewItem->maTitle;
aTemplateItem.aPath = pViewItem->getPath();
aTemplateItem.aType = pViewItem->getFileType();
aTemplateItem.aThumbnail = pViewItem->maPreview1;
@@ -696,7 +696,7 @@ IMPL_LINK(TemplateFolderView, ChangeNameHdl, TemplateView*, pView)
{
if (mItemList[i]->mnId == nItemId)
{
- mItemList[i]->maText = pView->getRegionName();
+ mItemList[i]->maTitle = pView->getRegionName();
mItemList[i]->calculateItemsPosition(mpItemAttrs->nMaxTextLenght);
Invalidate();
break;
diff --git a/sfx2/source/control/templatefolderviewitem.cxx b/sfx2/source/control/templatefolderviewitem.cxx
index 36f1909..8e9e381 100644
--- a/sfx2/source/control/templatefolderviewitem.cxx
+++ b/sfx2/source/control/templatefolderviewitem.cxx
@@ -98,7 +98,7 @@ void TemplateFolderViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *
aSeq[nCount++] = Primitive2DReference(
new TextSimplePortionPrimitive2D(aTextMatrix,
- maText,0,maText.getLength(),
+ maTitle,0,maTitle.getLength(),
std::vector< double >( ),
pAttrs->aFontAttr,
com::sun::star::lang::Locale(),
diff --git a/sfx2/source/control/templatesearchview.cxx b/sfx2/source/control/templatesearchview.cxx
index 5bf2f73..ab3e122 100644
--- a/sfx2/source/control/templatesearchview.cxx
+++ b/sfx2/source/control/templatesearchview.cxx
@@ -42,7 +42,7 @@ void TemplateSearchView::AppendItem(sal_uInt16 nItemId, sal_uInt16 nRegionId, sa
pItem->mnIdx = nIdx;
pItem->mnRegionId = nRegionId;
pItem->maPreview1 = rImage;
- pItem->maText = rStr;
+ pItem->maTitle = rStr;
pItem->setPath(rPath);
pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnItemSelected));
diff --git a/sfx2/source/control/templateview.cxx b/sfx2/source/control/templateview.cxx
index b804341..a819094 100644
--- a/sfx2/source/control/templateview.cxx
+++ b/sfx2/source/control/templateview.cxx
@@ -115,7 +115,7 @@ void TemplateView::InsertItems (const std::vector<TemplateItemProperties> &rTemp
const TemplateItemProperties *pCur = &rTemplates[i];
pItem->mnId = pCur->nId;
- pItem->maText = pCur->aName;
+ pItem->maTitle = pCur->aName;
pItem->setPath(pCur->aPath);
pItem->setFileType(pCur->aType);
pItem->maPreview1 = pCur->aThumbnail;
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index d64edf1..886ec9b 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -803,7 +803,7 @@ void ThumbnailView::InsertItem( sal_uInt16 nItemId, const BitmapEx& rImage,
ThumbnailViewItem* pItem = new ThumbnailViewItem( *this, this );
pItem->mnId = nItemId;
pItem->maPreview1 = rImage;
- pItem->maText = rText;
+ pItem->maTitle = rText;
pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnItemSelected));
ImplInsertItem( pItem, nPos );
}
@@ -1047,7 +1047,7 @@ rtl::OUString ThumbnailView::GetItemText( sal_uInt16 nItemId ) const
size_t nPos = GetItemPos( nItemId );
if ( nPos != THUMBNAILVIEW_ITEM_NOTFOUND )
- return mItemList[nPos]->maText;
+ return mItemList[nPos]->maTitle;
return rtl::OUString();
}
diff --git a/sfx2/source/control/thumbnailviewacc.cxx b/sfx2/source/control/thumbnailviewacc.cxx
index 48a6ce9..5ba12d3 100644
--- a/sfx2/source/control/thumbnailviewacc.cxx
+++ b/sfx2/source/control/thumbnailviewacc.cxx
@@ -772,7 +772,7 @@ sal_Int16 SAL_CALL ThumbnailViewItemAcc::getAccessibleRole()
if( mpParent )
{
- aRet = mpParent->maText;
+ aRet = mpParent->maTitle;
if( aRet.isEmpty() )
{
diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx
index dbbbcb7..dad7702 100644
--- a/sfx2/source/control/thumbnailviewitem.cxx
+++ b/sfx2/source/control/thumbnailviewitem.cxx
@@ -132,7 +132,7 @@ void ThumbnailViewItem::calculateItemsPosition (sal_uInt32 nMaxTextLenght)
// Calculate text position
aPos.Y() += aImageSize.Height();
aPos.Y() = aPos.Y() + aTextDev.getTextHeight() + (maDrawArea.Bottom() - aPos.Y() - aTextDev.getTextHeight())/2;
- aPos.X() = maDrawArea.Left() + (aRectSize.Width() - aTextDev.getTextWidth(maText,0,nMaxTextLenght))/2;
+ aPos.X() = maDrawArea.Left() + (aRectSize.Width() - aTextDev.getTextWidth(maTitle,0,nMaxTextLenght))/2;
maTextPos = aPos;
// Calculate checkbox position
@@ -199,7 +199,7 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc
aSeq[2] = Primitive2DReference(
new TextSimplePortionPrimitive2D(aTextMatrix,
- maText,0,pAttrs->nMaxTextLenght,
+ maTitle,0,pAttrs->nMaxTextLenght,
std::vector< double >( ),
pAttrs->aFontAttr,
com::sun::star::lang::Locale(),
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index decb401..9738060 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -60,7 +60,7 @@ public:
bool operator() (const ThumbnailViewItem *pItem1, const ThumbnailViewItem *pItem2)
{
- return (pItem1->maText.compareTo(pItem2->maText) < 0);
+ return (pItem1->maTitle.compareTo(pItem2->maTitle) < 0);
}
};
More information about the Libreoffice-commits
mailing list