[Libreoffice-commits] .: Branch 'feature/template-dialog' - 15 commits - sfx2/inc sfx2/Library_sfx.mk sfx2/Package_inc.mk sfx2/source svtools/inc svtools/Library_svt.mk svtools/Package_inc.mk svtools/source
Rafael Dominguez
rdominguez at kemper.freedesktop.org
Mon Jun 11 02:27:58 PDT 2012
sfx2/Library_sfx.mk | 3
sfx2/Package_inc.mk | 4
sfx2/inc/sfx2/thumbnailview.hxx | 375 ++++
sfx2/inc/sfx2/thumbnailviewitem.hxx | 60
sfx2/inc/templatedlg.hxx | 8
sfx2/source/control/thumbnailview.cxx | 1825 +++++++++++++++++++++++
sfx2/source/control/thumbnailviewacc.cxx | 1011 +++++++++++++
sfx2/source/control/thumbnailviewacc.hxx | 245 +++
sfx2/source/control/thumbnailviewitem.cxx | 64
sfx2/source/doc/templatedlg.cxx | 159 --
sfx2/source/doc/templatedlg.src | 4
svtools/Library_svt.mk | 3
svtools/Package_inc.mk | 2
svtools/inc/svtools/thumbnailview.hxx | 415 -----
svtools/inc/svtools/thumbnailviewitem.hxx | 60
svtools/source/control/thumbnailview.cxx | 2059 ---------------------------
svtools/source/control/thumbnailviewacc.cxx | 1040 -------------
svtools/source/control/thumbnailviewacc.hxx | 253 ---
svtools/source/control/thumbnailviewitem.cxx | 64
19 files changed, 3598 insertions(+), 4056 deletions(-)
New commits:
commit c935b5a30e80e25318c569b8a4d4eeb8eba16d94
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Mon Jun 11 04:58:49 2012 -0430
Display preview of thumbnails inside a region.
Change-Id: Ib2e61ecdda55022d3c8e2d151c1d6452fd1eeaa4
diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx
index 57fbb80..f878494 100644
--- a/sfx2/inc/sfx2/thumbnailviewitem.hxx
+++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx
@@ -43,6 +43,7 @@ struct ThumbnailViewItem
ThumbnailView &mrParent;
sal_uInt16 mnId;
bool mbVisible;
+ bool mbSelected;
Image maImage;
rtl::OUString maText;
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >* mpxAcc;
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 03efb69..bb5f8b9 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -1285,10 +1285,24 @@ void ThumbnailView::Populate ()
sal_uInt16 nEntries = pTemplates->GetCount(i);
- for ( sal_uInt16 j = 0; j < nEntries; ++j)
+ if (nEntries)
{
- Image aImg = lcl_fetchThumbnail(pTemplates->GetPath(i,j),128,128);
- InsertItem(i*100+j,aImg,pTemplates->GetName(i,j));
+ /// Preview first 2 thumbnails for folder
+ Image aImg = lcl_fetchThumbnail(pTemplates->GetPath(i,0),96,96);
+
+ if ( nEntries > 2 )
+ {
+ Color aWhite(COL_WHITE);
+ BitmapEx aResult = lcl_fetchThumbnail(pTemplates->GetPath(i,1),96,96).GetBitmapEx();
+ BitmapEx aBmp = aImg.GetBitmapEx();
+ aResult.Expand(20,20,&aWhite,sal_True);
+ aResult.CopyPixel(Rectangle(24,24,106,106),Rectangle(0,0,96,96),&aBmp);
+
+ aImg = aResult;
+
+ }
+
+ InsertItem(i,aImg,aRegionName);
}
}
}
diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx
index 1a24bd1..1d9aa07 100644
--- a/sfx2/source/control/thumbnailviewitem.cxx
+++ b/sfx2/source/control/thumbnailviewitem.cxx
@@ -37,6 +37,7 @@ ThumbnailViewItem::ThumbnailViewItem( ThumbnailView& rParent )
: mrParent(rParent)
, mnId(0)
, mbVisible(true)
+ , mbSelected(false)
, mpxAcc(NULL)
{
}
commit 469f0f8a0c881c156e0b81ba8667fa46eb5c2fe9
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Mon Jun 11 04:05:35 2012 -0430
Adjust template dialog size.
Change-Id: I5e798a8cab58f336271c6ce621e9a6829d5b7776
diff --git a/sfx2/source/doc/templatedlg.src b/sfx2/source/doc/templatedlg.src
index 73ea0c7..1fb3e73 100644
--- a/sfx2/source/doc/templatedlg.src
+++ b/sfx2/source/doc/templatedlg.src
@@ -18,7 +18,7 @@ ModalDialog DLG_TEMPLATE_MANAGER
Moveable = TRUE;
Closeable = TRUE;
Hide = TRUE;
- Size = MAP_APPFONT ( 270 , 190 );
+ Size = MAP_APPFONT ( 290 , 250 );
Text [en-US] = "Template Manager";
PushButton BTN_SELECT_ALL
@@ -65,7 +65,7 @@ ModalDialog DLG_TEMPLATE_MANAGER
Control TEMPLATE_VIEW
{
Pos = MAP_APPFONT(5,30);
- Size = MAP_APPFONT(260,150);
+ Size = MAP_APPFONT(280,220);
TabStop = TRUE;
};
commit b656c56b66c5593918e28aba1aef3be7ff0b7c18
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Mon Jun 11 03:56:41 2012 -0430
Remove data attribute from thumbnailviewitem.
Change-Id: I9536a991dca00c6124c4ed17de1f13b47bab689a
diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index 3b95e2e..28706df 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -224,10 +224,6 @@ public:
Image GetItemImage( sal_uInt16 nItemId ) const;
- void SetItemData( sal_uInt16 nItemId, void* pData );
-
- void* GetItemData( sal_uInt16 nItemId ) const;
-
void SetItemText( sal_uInt16 nItemId, const rtl::OUString &rStr );
rtl::OUString GetItemText( sal_uInt16 nItemId ) const;
diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx
index 6ba8351..57fbb80 100644
--- a/sfx2/inc/sfx2/thumbnailviewitem.hxx
+++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx
@@ -45,7 +45,6 @@ struct ThumbnailViewItem
bool mbVisible;
Image maImage;
rtl::OUString maText;
- void* mpData;
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >* mpxAcc;
ThumbnailViewItem ( ThumbnailView& rParent );
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 3d79336..03efb69 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -1630,36 +1630,6 @@ Image ThumbnailView::GetItemImage( sal_uInt16 nItemId ) const
return Image();
}
-void ThumbnailView::SetItemData( sal_uInt16 nItemId, void* pData )
-{
- size_t nPos = GetItemPos( nItemId );
-
- if ( nPos == THUMBNAILVIEW_ITEM_NOTFOUND )
- return;
-
- ThumbnailViewItem* pItem = mItemList[nPos];
- pItem->mpData = pData;
-
- if ( !mbFormat && IsReallyVisible() && IsUpdateMode() )
- {
- const Rectangle aRect = ImplGetItemRect(nPos);
- DrawItem( pItem, aRect );
- Invalidate( aRect );
- }
- else
- mbFormat = true;
-}
-
-void* ThumbnailView::GetItemData( sal_uInt16 nItemId ) const
-{
- size_t nPos = GetItemPos( nItemId );
-
- if ( nPos != THUMBNAILVIEW_ITEM_NOTFOUND )
- return mItemList[nPos]->mpData;
- else
- return NULL;
-}
-
void ThumbnailView::SetItemText( sal_uInt16 nItemId, const rtl::OUString& rText )
{
size_t nPos = GetItemPos( nItemId );
diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx
index 955cf5f..1a24bd1 100644
--- a/sfx2/source/control/thumbnailviewitem.cxx
+++ b/sfx2/source/control/thumbnailviewitem.cxx
@@ -37,7 +37,6 @@ ThumbnailViewItem::ThumbnailViewItem( ThumbnailView& rParent )
: mrParent(rParent)
, mnId(0)
, mbVisible(true)
- , mpData(NULL)
, mpxAcc(NULL)
{
}
commit d0af4dcc51a1ef14f2c7aed634674973dc9a3a74
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Mon Jun 11 03:50:14 2012 -0430
Scale fetched thumbnail as desired.
Change-Id: Ia55acde093a2fcfb61740d7dbe57c60bcda7673e
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 9f37c13..3d79336 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -44,7 +44,7 @@ enum
SCROLL_OFFSET = 4
};
-Image lcl_fetchThumbnail (const rtl::OUString &msURL)
+Image lcl_fetchThumbnail (const rtl::OUString &msURL, int width, int height)
{
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -150,6 +150,8 @@ Image lcl_fetchThumbnail (const rtl::OUString &msURL)
aThumbnail = aReader.Read ();
}
+ aThumbnail.Scale(Size(width,height));
+
// Note that the preview is returned without scaling it to the desired
// width. This gives the caller the chance to take advantage of a
// possibly larger resolution then was asked for.
@@ -1285,7 +1287,7 @@ void ThumbnailView::Populate ()
for ( sal_uInt16 j = 0; j < nEntries; ++j)
{
- Image aImg = lcl_fetchThumbnail(pTemplates->GetPath(i,j));
+ Image aImg = lcl_fetchThumbnail(pTemplates->GetPath(i,j),128,128);
InsertItem(i*100+j,aImg,pTemplates->GetName(i,j));
}
}
commit a0bf8f8900922ec361408ba24301c1bba3649c3b
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Sun Jun 10 15:37:54 2012 -0430
Display thumbnailview scrollbar in template dialog.
Change-Id: I836eb9ee81a21f91bbf99148b61626cf1781159b
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index da9ad38..b9a2918 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -27,7 +27,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
aButtonDraws(this,SfxResId(BTN_SELECT_DRAWS)),
maView(new ThumbnailView(this,SfxResId(TEMPLATE_VIEW)))
{
- maView->SetStyle(WB_TABSTOP);
+ maView->SetStyle(WB_TABSTOP | WB_VSCROLL);
maView->SetColCount(MAX_COLUMN_COUNT);
maView->SetLineCount(MAX_LINE_COUNT);
commit 37229126c0a821a925839bbca4b6ec7245f861e9
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Sun Jun 10 15:37:11 2012 -0430
Make WB_RADIOSEL style behaviour as default.
Change-Id: Ic2d26f795247cf9173d3d8393f838d7b07faa3d4
diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index 2823953..3b95e2e 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -58,11 +58,6 @@ class ThumbnailViewItemAcc;
WinBits
- WB_RADIOSEL If set the selection will be drawn like an
- ImageRadioButton. This does only make sense if the image
- is at least 8 pixel smaller on each side than the item
- and also WB_DOUBLEBORDER is set and as color
- COL_WINDOWWORKSPACE is specified.
WB_VSCROLL A scroolbar will be always shown. The visible number of
lines have to be specified with SetLineCount() if this
flag is set.
@@ -148,8 +143,6 @@ class ThumbnailViewItemAcc;
/* ThumbnailView types */
-#define WB_RADIOSEL ((WinBits)0x00008000)
-
#define THUMBNAILVIEW_APPEND ((sal_uInt16)-1)
#define THUMBNAILVIEW_ITEM_NOTFOUND ((sal_uInt16)-1)
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 2a270c4..9f37c13 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -301,8 +301,6 @@ void ThumbnailView::ImplInitScrollBar()
void ThumbnailView::DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect)
{
- WinBits nStyle = GetStyle();
-
if ( (aRect.GetHeight() > 0) && (aRect.GetWidth() > 0) )
{
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
@@ -657,86 +655,24 @@ void ThumbnailView::DrawSelectedItem( const sal_uInt16 nItemId, const bool bFocu
}
// specify selection output
- WinBits nStyle = GetStyle();
- if ( nStyle & WB_RADIOSEL )
- {
- aRect.Left() += 3;
- aRect.Top() += 3;
- aRect.Right() -= 3;
- aRect.Bottom() -= 3;
+ aRect.Left() += 4;
+ aRect.Top() += 4;
+ aRect.Right() -= 4;
+ aRect.Bottom() -= 4;
- if ( bFocus )
- ShowFocus( aRect );
-
- aRect.Left()++;
- aRect.Top()++;
- aRect.Right()--;
- aRect.Bottom()--;
-
- if ( bDrawSel )
- {
- SetLineColor( aDoubleColor );
- aRect.Left()++;
- aRect.Top()++;
- aRect.Right()--;
- aRect.Bottom()--;
- DrawRect( aRect );
- aRect.Left()++;
- aRect.Top()++;
- aRect.Right()--;
- aRect.Bottom()--;
- DrawRect( aRect );
- }
- }
- else
+ if ( bDrawSel )
{
- if ( bDrawSel )
- {
- SetLineColor( mbBlackSel ? Color( COL_BLACK ) : aDoubleColor );
- DrawRect( aRect );
- }
- if ( mbDoubleSel )
- {
- aRect.Left()++;
- aRect.Top()++;
- aRect.Right()--;
- aRect.Bottom()--;
- if ( bDrawSel )
- DrawRect( aRect );
- }
+ SetLineColor( aDoubleColor );
aRect.Left()++;
aRect.Top()++;
aRect.Right()--;
aRect.Bottom()--;
- Rectangle aRect2 = aRect;
+ DrawRect( aRect );
aRect.Left()++;
aRect.Top()++;
aRect.Right()--;
aRect.Bottom()--;
- if ( bDrawSel )
- DrawRect( aRect );
- if ( mbDoubleSel )
- {
- aRect.Left()++;
- aRect.Top()++;
- aRect.Right()--;
- aRect.Bottom()--;
- if ( bDrawSel )
- DrawRect( aRect );
- }
-
- if ( bDrawSel )
- {
- SetLineColor( mbBlackSel ? Color( COL_WHITE ) : aSingleColor );
- }
- else
- {
- SetLineColor( Color( COL_LIGHTGRAY ) );
- }
- DrawRect( aRect2 );
-
- if ( bFocus )
- ShowFocus( aRect2 );
+ DrawRect( aRect );
}
}
}
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 59ab1b9..da9ad38 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -27,7 +27,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
aButtonDraws(this,SfxResId(BTN_SELECT_DRAWS)),
maView(new ThumbnailView(this,SfxResId(TEMPLATE_VIEW)))
{
- maView->SetStyle(WB_RADIOSEL | WB_TABSTOP);
+ maView->SetStyle(WB_TABSTOP);
maView->SetColCount(MAX_COLUMN_COUNT);
maView->SetLineCount(MAX_LINE_COUNT);
commit 2b0240fcc07f5e2850e9cffa0cd9271925fc1383
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Sun Jun 10 15:22:09 2012 -0430
Remove support for extra styles.
Change-Id: Ic39113ea482c394605548902af54823ff63cf729
diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index e0708d2..2823953 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -63,11 +63,9 @@ class ThumbnailViewItemAcc;
is at least 8 pixel smaller on each side than the item
and also WB_DOUBLEBORDER is set and as color
COL_WINDOWWORKSPACE is specified.
- WB_FLATVALUESET Flat Look.
WB_VSCROLL A scroolbar will be always shown. The visible number of
lines have to be specified with SetLineCount() if this
flag is set.
- WB_BORDER A border will be drawn around the window.
WB_TABSTOP It is possible to jump into the ValueSet with the tab key.
WB_NOTABSTOP It is not possible to jump into the ValueSet with the
tab key.
@@ -151,8 +149,6 @@ class ThumbnailViewItemAcc;
/* ThumbnailView types */
#define WB_RADIOSEL ((WinBits)0x00008000)
-#define WB_FLATVALUESET ((WinBits)0x02000000)
-#define WB_MENUSTYLEVALUESET ((WinBits)0x08000000)
#define THUMBNAILVIEW_APPEND ((sal_uInt16)-1)
#define THUMBNAILVIEW_ITEM_NOTFOUND ((sal_uInt16)-1)
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 677e153..2a270c4 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -275,10 +275,6 @@ void ThumbnailView::ImplInitSettings( bool bFont, bool bForeground, bool bBackgr
Color aColor;
if ( IsControlBackground() )
aColor = GetControlBackground();
- else if ( GetStyle() & WB_MENUSTYLEVALUESET )
- aColor = rStyleSettings.GetMenuColor();
- else if ( IsEnabled() && (GetStyle() & WB_FLATVALUESET) )
- aColor = rStyleSettings.GetWindowColor();
else
aColor = rStyleSettings.GetFaceColor();
SetBackground( aColor );
@@ -313,8 +309,6 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect)
if ( IsColor() )
maVirDev.SetFillColor( maColor );
- else if ( nStyle & WB_MENUSTYLEVALUESET )
- maVirDev.SetFillColor( rStyleSettings.GetMenuColor() );
else if ( IsEnabled() )
maVirDev.SetFillColor( rStyleSettings.GetWindowColor() );
else
@@ -664,18 +658,7 @@ void ThumbnailView::DrawSelectedItem( const sal_uInt16 nItemId, const bool bFocu
// specify selection output
WinBits nStyle = GetStyle();
- if ( nStyle & WB_MENUSTYLEVALUESET )
- {
- if ( bFocus )
- ShowFocus( aRect );
-
- if ( bDrawSel )
- {
- SetLineColor( mbBlackSel ? Color( COL_BLACK ) : aDoubleColor );
- DrawRect( aRect );
- }
- }
- else if ( nStyle & WB_RADIOSEL )
+ if ( nStyle & WB_RADIOSEL )
{
aRect.Left() += 3;
aRect.Top() += 3;
@@ -986,16 +969,10 @@ void ThumbnailView::ImplTracking( const Point& rPos, bool bRepeat )
ThumbnailViewItem* pItem = ImplGetItem( ImplGetItem( rPos ) );
if ( pItem )
{
- if( GetStyle() & WB_MENUSTYLEVALUESET )
- mbHighlight = true;
-
ImplHighlightItem( pItem->mnId );
}
else
{
- if( GetStyle() & WB_MENUSTYLEVALUESET )
- mbHighlight = true;
-
ImplHighlightItem( mnSelItemId, false );
}
}
@@ -1013,7 +990,7 @@ void ThumbnailView::ImplEndTracking( const Point& rPos, bool bCancel )
if ( pItem )
{
SelectItem( pItem->mnId );
- if ( !mbSelection && !(GetStyle() & WB_NOPOINTERFOCUS) )
+ if ( !mbSelection )
GrabFocus();
mbHighlight = false;
mbSelection = false;
@@ -1077,7 +1054,7 @@ void ThumbnailView::MouseButtonUp( const MouseEvent& rMEvt )
void ThumbnailView::MouseMove( const MouseEvent& rMEvt )
{
// because of SelectionMode
- if ( mbSelection || (GetStyle() & WB_MENUSTYLEVALUESET) )
+ if ( mbSelection )
ImplTracking( rMEvt.GetPosPixel(), false );
Control::MouseMove( rMEvt );
}
@@ -1233,16 +1210,6 @@ void ThumbnailView::Command( const CommandEvent& rCEvt )
void ThumbnailView::Paint( const Rectangle& )
{
- if ( GetStyle() & WB_FLATVALUESET )
- {
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- SetLineColor();
- SetFillColor( rStyleSettings.GetFaceColor() );
- long nOffY = maVirDev.GetOutputSizePixel().Height();
- Size aWinSize = GetOutputSizePixel();
- DrawRect( Rectangle( Point( 0, nOffY ), Point( aWinSize.Width(), aWinSize.Height() ) ) );
- }
-
ImplDraw();
}
commit 94314b6d10a1432a63d0d36bc3a5b9bef12c7b3c
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Sun Jun 10 15:11:53 2012 -0430
Remove support for WB_NO_DIRECTSELECT.
Change-Id: I0ec244b98cd366a2554cf108d5e3adda112f201d
diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index f27da7d..e0708d2 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -68,13 +68,9 @@ class ThumbnailViewItemAcc;
lines have to be specified with SetLineCount() if this
flag is set.
WB_BORDER A border will be drawn around the window.
- WB_NOPOINTERFOCUS The focus won't be gathered, if the control was pressed by
- the mouse.
WB_TABSTOP It is possible to jump into the ValueSet with the tab key.
WB_NOTABSTOP It is not possible to jump into the ValueSet with the
tab key.
- WB_NO_DIRECTSELECT Cursor travelling doesn't call select immediately. To
- execute the selection <RETURN> has to be pressed.
--------------------------------------------------------------------------
The number of columns must be either set with SetColCount() or
@@ -156,7 +152,6 @@ class ThumbnailViewItemAcc;
#define WB_RADIOSEL ((WinBits)0x00008000)
#define WB_FLATVALUESET ((WinBits)0x02000000)
-#define WB_NO_DIRECTSELECT ((WinBits)0x04000000)
#define WB_MENUSTYLEVALUESET ((WinBits)0x08000000)
#define THUMBNAILVIEW_APPEND ((sal_uInt16)-1)
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index bf5cf2c..677e153 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -1191,13 +1191,6 @@ void ThumbnailView::KeyInput( const KeyEvent& rKEvt )
}
}
break;
-
- case KEY_RETURN:
- if (GetStyle() & WB_NO_DIRECTSELECT)
- {
- Select();
- break;
- }
// intentional fall-through
default:
Control::KeyInput( rKEvt );
@@ -1220,11 +1213,7 @@ void ThumbnailView::KeyInput( const KeyEvent& rKEvt )
if ( nItemId != mnSelItemId )
{
SelectItem( nItemId );
- if (!(GetStyle() & WB_NO_DIRECTSELECT))
- {
- // select only if WB_NO_DIRECTSELECT is not set
- Select();
- }
+ Select();
}
}
}
commit d1d559af047602da866eee5487e434be331eb73f
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Sun Jun 10 14:59:12 2012 -0430
Remove unused variables and attributes.
Change-Id: Idcd433cb078f7e325699ae5a120344a9e3f9ab9f
diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index 7e7e742..f27da7d 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -355,13 +355,11 @@ protected:
Timer maTimer;
ValueItemList mItemList;
SfxOrganizeMgr *mpMgr;
- ThumbnailViewItem* mpNoneItem;
ScrollBar* mpScrBar;
Rectangle maNoneItemRect;
Rectangle maItemListRect;
long mnItemWidth;
long mnItemHeight;
- long mnTextOffset;
long mnVisLines;
long mnLines;
long mnUserItemWidth;
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 0fa79f6..bf5cf2c 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -185,7 +185,6 @@ ThumbnailView::~ThumbnailView()
delete mpMgr;
delete mpScrBar;
- delete mpNoneItem;
ImplDeleteItems();
}
@@ -193,11 +192,9 @@ ThumbnailView::~ThumbnailView()
void ThumbnailView::ImplInit()
{
mpMgr = new SfxOrganizeMgr(NULL,NULL);
- mpNoneItem = NULL;
mpScrBar = NULL;
mnItemWidth = 0;
mnItemHeight = 0;
- mnTextOffset = 0;
mnVisLines = 0;
mnLines = 0;
mnUserItemWidth = 0;
@@ -310,78 +307,47 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect)
{
WinBits nStyle = GetStyle();
- if ( pItem == mpNoneItem )
- pItem->maText = GetText();
-
if ( (aRect.GetHeight() > 0) && (aRect.GetWidth() > 0) )
{
- if ( pItem == mpNoneItem )
- {
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- maVirDev.SetFont( GetFont() );
- maVirDev.SetTextColor( ( nStyle & WB_MENUSTYLEVALUESET ) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor() );
- maVirDev.SetTextFillColor();
- maVirDev.SetFillColor( ( nStyle & WB_MENUSTYLEVALUESET ) ? rStyleSettings.GetMenuColor() : rStyleSettings.GetWindowColor() );
- maVirDev.DrawRect( aRect );
- Point aTxtPos( aRect.Left()+2, aRect.Top() );
- long nTxtWidth = GetTextWidth( pItem->maText );
- if ( nStyle & WB_RADIOSEL )
- {
- aTxtPos.X() += 4;
- aTxtPos.Y() += 4;
- }
- if ( (aTxtPos.X()+nTxtWidth) > aRect.Right() )
- {
- maVirDev.SetClipRegion( Region( aRect ) );
- maVirDev.DrawText( aTxtPos, pItem->maText );
- maVirDev.SetClipRegion();
- }
- else
- maVirDev.DrawText( aTxtPos, pItem->maText );
- }
- else
- {
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
-
- if ( IsColor() )
- maVirDev.SetFillColor( maColor );
- else if ( nStyle & WB_MENUSTYLEVALUESET )
- maVirDev.SetFillColor( rStyleSettings.GetMenuColor() );
- else if ( IsEnabled() )
- maVirDev.SetFillColor( rStyleSettings.GetWindowColor() );
- else
- maVirDev.SetFillColor( rStyleSettings.GetFaceColor() );
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- maVirDev.DrawRect( aRect );
+ if ( IsColor() )
+ maVirDev.SetFillColor( maColor );
+ else if ( nStyle & WB_MENUSTYLEVALUESET )
+ maVirDev.SetFillColor( rStyleSettings.GetMenuColor() );
+ else if ( IsEnabled() )
+ maVirDev.SetFillColor( rStyleSettings.GetWindowColor() );
+ else
+ maVirDev.SetFillColor( rStyleSettings.GetFaceColor() );
- // Draw thumbnail
- Size aImageSize = pItem->maImage.GetSizePixel();
- Size aRectSize = aRect.GetSize();
- Point aPos( aRect.Left(), aRect.Top() );
- aPos.X() += (aRectSize.Width()-aImageSize.Width())/2;
- aPos.Y() += (aRectSize.Height()-aImageSize.Height())/2;
+ maVirDev.DrawRect( aRect );
- sal_uInt16 nImageStyle = 0;
- if( !IsEnabled() )
- nImageStyle |= IMAGE_DRAW_DISABLE;
+ // Draw thumbnail
+ Size aImageSize = pItem->maImage.GetSizePixel();
+ Size aRectSize = aRect.GetSize();
+ Point aPos( aRect.Left(), aRect.Top() );
+ aPos.X() += (aRectSize.Width()-aImageSize.Width())/2;
+ aPos.Y() += (aRectSize.Height()-aImageSize.Height())/2;
- if ( (aImageSize.Width() > aRectSize.Width()) ||
- (aImageSize.Height() > aRectSize.Height()) )
- {
- maVirDev.SetClipRegion( Region( aRect ) );
- maVirDev.DrawImage( aPos, pItem->maImage, nImageStyle);
- maVirDev.SetClipRegion();
- }
- else
- maVirDev.DrawImage( aPos, pItem->maImage, nImageStyle );
+ sal_uInt16 nImageStyle = 0;
+ if( !IsEnabled() )
+ nImageStyle |= IMAGE_DRAW_DISABLE;
- // Draw centered text below thumbnail
- aPos.Y() += 5 + aImageSize.Height();
- aPos.X() = aRect.Left() + (aRectSize.Width() - maVirDev.GetTextWidth(pItem->maText))/2;
+ if ( (aImageSize.Width() > aRectSize.Width()) ||
+ (aImageSize.Height() > aRectSize.Height()) )
+ {
+ maVirDev.SetClipRegion( Region( aRect ) );
+ maVirDev.DrawImage( aPos, pItem->maImage, nImageStyle);
+ maVirDev.SetClipRegion();
+ }
+ else
+ maVirDev.DrawImage( aPos, pItem->maImage, nImageStyle );
- maVirDev.DrawText(aPos,pItem->maText);
+ // Draw centered text below thumbnail
+ aPos.Y() += 5 + aImageSize.Height();
+ aPos.X() = aRect.Left() + (aRectSize.Width() - maVirDev.GetTextWidth(pItem->maText))/2;
- }
+ maVirDev.DrawText(aPos,pItem->maText);
}
}
@@ -395,8 +361,8 @@ void ThumbnailView::Format()
Size aWinSize = GetOutputSizePixel();
size_t nItemCount = mItemList.size();
WinBits nStyle = GetStyle();
- long nNoneHeight;
- long nNoneSpace;
+ long nNoneHeight = 0;
+ long nNoneSpace = 0;
ScrollBar* pDelScrBar = NULL;
// consider the scrolling
@@ -412,17 +378,6 @@ void ThumbnailView::Format()
}
}
- mnTextOffset = 0;
-
- nNoneHeight = 0;
- nNoneSpace = 0;
-
- if ( mpNoneItem )
- {
- delete mpNoneItem;
- mpNoneItem = NULL;
- }
-
// calculate ScrollBar width
long nScrBarWidth = 0;
if ( mpScrBar )
@@ -668,11 +623,6 @@ void ThumbnailView::DrawSelectedItem( const sal_uInt16 nItemId, const bool bFocu
pItem = mItemList[ nPos ];
aRect = ImplGetItemRect( nPos );
}
- else if ( mpNoneItem )
- {
- pItem = mpNoneItem;
- aRect = maNoneItemRect;
- }
else if ( bFocus && (pItem = ImplGetFirstItem()) )
{
aRect = ImplGetItemRect( 0 );
@@ -813,27 +763,15 @@ void ThumbnailView::ImplHideSelect( sal_uInt16 nItemId )
Rectangle aRect;
const size_t nItemPos = GetItemPos( nItemId );
- if ( nItemPos != THUMBNAILVIEW_ITEM_NOTFOUND )
+ if ( nItemPos != THUMBNAILVIEW_ITEM_NOTFOUND && mItemList[nItemPos]->mbVisible )
{
- if ( !mItemList[nItemPos]->mbVisible )
- {
- return;
- }
aRect = ImplGetItemRect(nItemPos);
- }
- else
- {
- if ( !mpNoneItem )
- {
- return;
- }
- aRect = maNoneItemRect;
- }
- HideFocus();
- const Point aPos = aRect.TopLeft();
- const Size aSize = aRect.GetSize();
- DrawOutDev( aPos, aSize, aPos, aSize, maVirDev );
+ HideFocus();
+ const Point aPos = aRect.TopLeft();
+ const Size aSize = aRect.GetSize();
+ DrawOutDev( aPos, aSize, aPos, aSize, maVirDev );
+ }
}
void ThumbnailView::ImplHighlightItem( sal_uInt16 nItemId, bool bIsSelection )
@@ -927,11 +865,6 @@ size_t ThumbnailView::ImplGetItem( const Point& rPos, bool bMove ) const
return THUMBNAILVIEW_ITEM_NOTFOUND;
}
- if ( mpNoneItem && maNoneItemRect.IsInside( rPos ) )
- {
- return THUMBNAILVIEW_ITEM_NONEITEM;
- }
-
if ( maItemListRect.IsInside( rPos ) )
{
const int xc = rPos.X()-maItemListRect.Left();
@@ -966,10 +899,7 @@ size_t ThumbnailView::ImplGetItem( const Point& rPos, bool bMove ) const
ThumbnailViewItem* ThumbnailView::ImplGetItem( size_t nPos )
{
- if ( nPos == THUMBNAILVIEW_ITEM_NONEITEM )
- return mpNoneItem;
- else
- return ( nPos < mItemList.size() ) ? mItemList[nPos] : NULL;
+ return ( nPos < mItemList.size() ) ? mItemList[nPos] : NULL;
}
ThumbnailViewItem* ThumbnailView::ImplGetFirstItem()
@@ -1173,15 +1103,14 @@ void ThumbnailView::KeyInput( const KeyEvent& rKEvt )
}
--nLastItem;
- const size_t nCurPos = mnSelItemId ? GetItemPos( mnSelItemId )
- : mpNoneItem ? THUMBNAILVIEW_ITEM_NONEITEM : 0;
+ const size_t nCurPos = mnSelItemId ? GetItemPos( mnSelItemId ) : 0;
size_t nItemPos = THUMBNAILVIEW_ITEM_NOTFOUND;
size_t nVStep = mnCols;
switch ( rKEvt.GetKeyCode().GetCode() )
{
case KEY_HOME:
- nItemPos = mpNoneItem ? THUMBNAILVIEW_ITEM_NONEITEM : 0;
+ nItemPos = 0;
break;
case KEY_END:
@@ -1195,25 +1124,13 @@ void ThumbnailView::KeyInput( const KeyEvent& rKEvt )
{
nItemPos = nCurPos-1;
}
- else if (mpNoneItem)
- {
- nItemPos = THUMBNAILVIEW_ITEM_NONEITEM;
- }
}
break;
case KEY_RIGHT:
if (nCurPos < nLastItem)
- {
- if (nCurPos == THUMBNAILVIEW_ITEM_NONEITEM)
- {
- nItemPos = 0;
- }
- else
- {
- nItemPos = nCurPos+1;
- }
- }
+ nItemPos = nCurPos+1;
+
break;
case KEY_PAGEUP:
@@ -1241,10 +1158,6 @@ void ThumbnailView::KeyInput( const KeyEvent& rKEvt )
// Go up of a whole page
nItemPos = nCurPos-nVStep;
}
- else if (mpNoneItem)
- {
- nItemPos = THUMBNAILVIEW_ITEM_NONEITEM;
- }
else if (nCurPos > mnCols)
{
// Go to same column in first row
@@ -1416,11 +1329,6 @@ void ThumbnailView::StateChanged( StateChangedType nType )
}
else if ( nType == STATE_CHANGE_TEXT )
{
- if ( mpNoneItem && !mbFormat && IsReallyVisible() && IsUpdateMode() )
- {
- DrawItem( mpNoneItem, maNoneItemRect );
- Invalidate( maNoneItemRect );
- }
}
else if ( (nType == STATE_CHANGE_ZOOM) ||
(nType == STATE_CHANGE_CONTROLFONT) )
@@ -1756,11 +1664,9 @@ void ThumbnailView::SelectItem( sal_uInt16 nItemId )
// focus event (select)
const size_t nPos = GetItemPos( mnSelItemId );
- ThumbnailViewItem* pItem;
+ ThumbnailViewItem* pItem = NULL;
if( nPos != THUMBNAILVIEW_ITEM_NOTFOUND )
pItem = mItemList[nPos];
- else
- pItem = mpNoneItem;
ThumbnailViewAcc* pItemAcc = NULL;
if (pItem != NULL)
commit d2268bdf2ad77c8ced3184a1abbdd3dcffe8e638
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Sun Jun 10 14:33:47 2012 -0430
Remove support for WB_NAMEFIELD.
Change-Id: Iea7bb4af10f788c133a0d6d9ffa481003eceb534
diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index 2b03829..7e7e742 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -64,8 +64,6 @@ class ThumbnailViewItemAcc;
and also WB_DOUBLEBORDER is set and as color
COL_WINDOWWORKSPACE is specified.
WB_FLATVALUESET Flat Look.
- WB_NAMEFIELD There is a namefield, where the name of an item will be
- shown.
WB_VSCROLL A scroolbar will be always shown. The visible number of
lines have to be specified with SetLineCount() if this
flag is set.
@@ -157,7 +155,6 @@ class ThumbnailViewItemAcc;
/* ThumbnailView types */
#define WB_RADIOSEL ((WinBits)0x00008000)
-#define WB_NAMEFIELD ((WinBits)0x00040000)
#define WB_FLATVALUESET ((WinBits)0x02000000)
#define WB_NO_DIRECTSELECT ((WinBits)0x04000000)
#define WB_MENUSTYLEVALUESET ((WinBits)0x08000000)
@@ -319,8 +316,6 @@ protected:
virtual void DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect);
- virtual void DrawItemText (const rtl::OUString &rStr );
-
virtual void DrawSelectedItem (const sal_uInt16 nItemId, const bool bFocus, const bool bDrawSel);
private:
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index feabf4e..0fa79f6 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -395,7 +395,6 @@ void ThumbnailView::Format()
Size aWinSize = GetOutputSizePixel();
size_t nItemCount = mItemList.size();
WinBits nStyle = GetStyle();
- long nTxtHeight = GetTextHeight();
long nNoneHeight;
long nNoneSpace;
ScrollBar* pDelScrBar = NULL;
@@ -413,20 +412,7 @@ void ThumbnailView::Format()
}
}
- // consider size, if NameField does exist
- if ( nStyle & WB_NAMEFIELD )
- {
- mnTextOffset = aWinSize.Height()-nTxtHeight-NAME_OFFSET;
- aWinSize.Height() -= nTxtHeight+NAME_OFFSET;
-
- if ( !(nStyle & WB_FLATVALUESET) )
- {
- mnTextOffset -= NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
- aWinSize.Height() -= NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
- }
- }
- else
- mnTextOffset = 0;
+ mnTextOffset = 0;
nNoneHeight = 0;
nNoneSpace = 0;
@@ -654,32 +640,6 @@ void ThumbnailView::Format()
delete pDelScrBar;
}
-void ThumbnailView::DrawItemText( const rtl::OUString& rText )
-{
- if ( !(GetStyle() & WB_NAMEFIELD) )
- return;
-
- Size aWinSize = GetOutputSizePixel();
- long nTxtWidth = GetTextWidth( rText );
- long nTxtOffset = mnTextOffset;
-
- // delete rectangle and show text
- if ( GetStyle() & WB_FLATVALUESET )
- {
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- SetLineColor();
- SetFillColor( rStyleSettings.GetFaceColor() );
- DrawRect( Rectangle( Point( 0, nTxtOffset ), Point( aWinSize.Width(), aWinSize.Height() ) ) );
- SetTextColor( rStyleSettings.GetButtonTextColor() );
- }
- else
- {
- nTxtOffset += NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
- Erase( Rectangle( Point( 0, nTxtOffset ), Point( aWinSize.Width(), aWinSize.Height() ) ) );
- }
- DrawText( Point( (aWinSize.Width()-nTxtWidth) / 2, nTxtOffset+(NAME_OFFSET/2) ), rText );
-}
-
void ThumbnailView::ImplDrawSelect()
{
if ( !IsReallyVisible() )
@@ -689,11 +649,7 @@ void ThumbnailView::ImplDrawSelect()
const bool bDrawSel = !( (mbNoSelection && !mbHighlight) || (!mbDrawSelection && mbHighlight) );
if ( !bFocus && !bDrawSel )
- {
- rtl::OUString aEmptyStr;
- DrawItemText( aEmptyStr );
return;
- }
DrawSelectedItem( mnSelItemId, bFocus, bDrawSel );
if (mbHighlight)
@@ -849,8 +805,6 @@ void ThumbnailView::DrawSelectedItem( const sal_uInt16 nItemId, const bool bFocu
if ( bFocus )
ShowFocus( aRect2 );
}
-
- DrawItemText( pItem->maText );
}
}
@@ -930,29 +884,6 @@ void ThumbnailView::ImplDraw()
else
DrawOutDev( aDefPos, aSize, aDefPos, aSize, maVirDev );
- // draw parting line to the Namefield
- if ( GetStyle() & WB_NAMEFIELD )
- {
- if ( !(GetStyle() & WB_FLATVALUESET) )
- {
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- Size aWinSize = GetOutputSizePixel();
- Point aPos1( NAME_LINE_OFF_X, mnTextOffset+NAME_LINE_OFF_Y );
- Point aPos2( aWinSize.Width()-(NAME_LINE_OFF_X*2), mnTextOffset+NAME_LINE_OFF_Y );
- if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
- {
- SetLineColor( rStyleSettings.GetShadowColor() );
- DrawLine( aPos1, aPos2 );
- aPos1.Y()++;
- aPos2.Y()++;
- SetLineColor( rStyleSettings.GetLightColor() );
- }
- else
- SetLineColor( rStyleSettings.GetWindowTextColor() );
- DrawLine( aPos1, aPos2 );
- }
- }
-
ImplDrawSelect();
}
@@ -1954,9 +1885,6 @@ void ThumbnailView::SetItemText( sal_uInt16 nItemId, const rtl::OUString& rText
if ( mbHighlight )
nTempId = mnHighItemId;
-
- if ( nTempId == nItemId )
- DrawItemText( pItem->maText );
}
if (ImplHasAccessibleListeners())
@@ -2079,8 +2007,6 @@ Size ThumbnailView::CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nDesi
}
Size aSize( rItemSize.Width()*nCalcCols, rItemSize.Height()*nCalcLines );
- WinBits nStyle = GetStyle();
- long nTxtHeight = GetTextHeight();
if ( mnSpacing )
{
@@ -2088,13 +2014,6 @@ Size ThumbnailView::CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nDesi
aSize.Height() += mnSpacing*(nCalcLines-1);
}
- if ( nStyle & WB_NAMEFIELD )
- {
- aSize.Height() += nTxtHeight + NAME_OFFSET;
- if ( !(nStyle & WB_FLATVALUESET) )
- aSize.Height() += NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
- }
-
// sum possible ScrollBar width
aSize.Width() += GetScrollWidth();
commit 2e5fa82e733963a4411666f010a0cf66b0572d4c
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Sun Jun 10 13:23:09 2012 -0430
Remove window style WB_NONEFIELD.
Change-Id: I0e9e275072fc67466f66c9b2c78dc680ac10d73d
diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index d2efbb8..2b03829 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -66,12 +66,6 @@ class ThumbnailViewItemAcc;
WB_FLATVALUESET Flat Look.
WB_NAMEFIELD There is a namefield, where the name of an item will be
shown.
- WB_NONEFIELD There is a NoSelection field which can be selected if
- 0 is passed along with SelectItem. Respectively
- GetSelectItemId() returns 0 if this field or nothing
- is selected. This field shows the text which is specified
- by SetText() respectively no one, if no text was set. With
- SetNoSelection() the selection can be disabled.
WB_VSCROLL A scroolbar will be always shown. The visible number of
lines have to be specified with SetLineCount() if this
flag is set.
@@ -164,7 +158,6 @@ class ThumbnailViewItemAcc;
#define WB_RADIOSEL ((WinBits)0x00008000)
#define WB_NAMEFIELD ((WinBits)0x00040000)
-#define WB_NONEFIELD ((WinBits)0x00080000)
#define WB_FLATVALUESET ((WinBits)0x02000000)
#define WB_NO_DIRECTSELECT ((WinBits)0x04000000)
#define WB_MENUSTYLEVALUESET ((WinBits)0x08000000)
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 7b7cfdb..feabf4e 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -396,7 +396,6 @@ void ThumbnailView::Format()
size_t nItemCount = mItemList.size();
WinBits nStyle = GetStyle();
long nTxtHeight = GetTextHeight();
- long nOff = 0;
long nNoneHeight;
long nNoneSpace;
ScrollBar* pDelScrBar = NULL;
@@ -429,24 +428,13 @@ void ThumbnailView::Format()
else
mnTextOffset = 0;
- // consider offset and size, if NoneField does exist
- if ( nStyle & WB_NONEFIELD )
- {
- nNoneHeight = nTxtHeight+nOff;
- nNoneSpace = mnSpacing;
- if ( nStyle & WB_RADIOSEL )
- nNoneHeight += 8;
- }
- else
- {
- nNoneHeight = 0;
- nNoneSpace = 0;
+ nNoneHeight = 0;
+ nNoneSpace = 0;
- if ( mpNoneItem )
- {
- delete mpNoneItem;
- mpNoneItem = NULL;
- }
+ if ( mpNoneItem )
+ {
+ delete mpNoneItem;
+ mpNoneItem = NULL;
}
// calculate ScrollBar width
@@ -532,15 +520,6 @@ void ThumbnailView::Format()
{
mbHasVisibleItems = false;
- if ( nStyle & WB_NONEFIELD )
- {
- if ( mpNoneItem )
- {
- mpNoneItem->mbVisible = false;
- mpNoneItem->maText = GetText();
- }
- }
-
for ( size_t i = 0; i < nItemCount; i++ )
{
mItemList[i]->mbVisible = false;
@@ -593,24 +572,6 @@ void ThumbnailView::Format()
long x = nStartX;
long y = nStartY;
- // create NoSelection field and show it
- if ( nStyle & WB_NONEFIELD )
- {
- if ( !mpNoneItem )
- mpNoneItem = new ThumbnailViewItem( *this );
-
- mpNoneItem->mnId = 0;
- mpNoneItem->mbVisible = true;
- maNoneItemRect.Left() = x;
- maNoneItemRect.Top() = y;
- maNoneItemRect.Right() = maNoneItemRect.Left()+aWinSize.Width()-x-1;
- maNoneItemRect.Bottom() = y+nNoneHeight-1;
-
- DrawItem( mpNoneItem, maNoneItemRect );
-
- y += nNoneHeight+nNoneSpace;
- }
-
// draw items
sal_uLong nFirstItem = mnFirstLine * mnCols;
sal_uLong nLastItem = nFirstItem + (mnVisLines * mnCols);
@@ -673,12 +634,7 @@ void ThumbnailView::Format()
{
Point aPos( aWinSize.Width()-nScrBarWidth+SCRBAR_OFFSET, 0 );
Size aSize( nScrBarWidth-SCRBAR_OFFSET, aWinSize.Height() );
- // If a none field is visible, then we center the scrollbar
- if ( nStyle & WB_NONEFIELD )
- {
- aPos.Y() = nStartY+nNoneHeight+1;
- aSize.Height() = ((mnItemHeight+mnSpacing)*mnVisLines)-2-mnSpacing;
- }
+
mpScrBar->SetPosSizePixel( aPos, aSize );
mpScrBar->SetRangeMax( mnLines );
mpScrBar->SetVisibleSize( mnVisLines );
@@ -2125,7 +2081,6 @@ Size ThumbnailView::CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nDesi
Size aSize( rItemSize.Width()*nCalcCols, rItemSize.Height()*nCalcLines );
WinBits nStyle = GetStyle();
long nTxtHeight = GetTextHeight();
- long n = 0;
if ( mnSpacing )
{
@@ -2140,13 +2095,6 @@ Size ThumbnailView::CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nDesi
aSize.Height() += NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
}
- if ( nStyle & WB_NONEFIELD )
- {
- aSize.Height() += nTxtHeight + n + mnSpacing;
- if ( nStyle & WB_RADIOSEL )
- aSize.Height() += 8;
- }
-
// sum possible ScrollBar width
aSize.Width() += GetScrollWidth();
diff --git a/sfx2/source/control/thumbnailviewacc.cxx b/sfx2/source/control/thumbnailviewacc.cxx
index f3ce539..cb03405 100644
--- a/sfx2/source/control/thumbnailviewacc.cxx
+++ b/sfx2/source/control/thumbnailviewacc.cxx
@@ -142,8 +142,6 @@ sal_Int32 SAL_CALL ThumbnailViewAcc::getAccessibleChildCount()
ThrowIfDisposed();
sal_Int32 nCount = mpParent->ImplGetVisibleItemCount();
- if (HasNoneField())
- nCount += 1;
return nCount;
}
@@ -600,31 +598,12 @@ void SAL_CALL ThumbnailViewAcc::disposing (void)
sal_uInt16 ThumbnailViewAcc::getItemCount (void) const
{
- sal_uInt16 nCount = mpParent->ImplGetVisibleItemCount();
- // When the None-Item is visible then increase the number of items by
- // one.
- if (HasNoneField())
- nCount += 1;
- return nCount;
+ return mpParent->ImplGetVisibleItemCount();
}
ThumbnailViewItem* ThumbnailViewAcc::getItem (sal_uInt16 nIndex) const
{
- ThumbnailViewItem* pItem = NULL;
-
- if (HasNoneField())
- {
- if (nIndex == 0)
- // When present the first item is the then allways visible none field.
- pItem = mpParent->ImplGetItem (THUMBNAILVIEW_ITEM_NONEITEM);
- else
- // Shift down the index to compensate for the none field.
- nIndex -= 1;
- }
- if (pItem == NULL)
- pItem = mpParent->ImplGetVisibleItem (static_cast<sal_uInt16>(nIndex));
-
- return pItem;
+ return mpParent->ImplGetVisibleItem (static_cast<sal_uInt16>(nIndex));
}
void ThumbnailViewAcc::ThrowIfDisposed (void)
@@ -643,14 +622,6 @@ void ThumbnailViewAcc::ThrowIfDisposed (void)
}
}
-
-
-bool ThumbnailViewAcc::HasNoneField (void) const
-{
- DBG_ASSERT (mpParent!=NULL, "ThumbnailViewAcc::HasNoneField called with mpParent==NULL");
- return ((mpParent->GetStyle() & WB_NONEFIELD) != 0);
-}
-
ThumbnailViewItemAcc::ThumbnailViewItemAcc( ThumbnailViewItem* pParent, bool bIsTransientChildrenDisabled ) :
mpParent( pParent ),
mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled )
diff --git a/sfx2/source/control/thumbnailviewacc.hxx b/sfx2/source/control/thumbnailviewacc.hxx
index d5014fa..f74cadd 100644
--- a/sfx2/source/control/thumbnailviewacc.hxx
+++ b/sfx2/source/control/thumbnailviewacc.hxx
@@ -173,14 +173,6 @@ private:
*/
void ThrowIfDisposed (void)
throw (::com::sun::star::lang::DisposedException);
-
- /** Check whether the value set has a 'none' field, i.e. a field (button)
- that deselects any items (selects none of them).
- @return
- Returns <true/> if there is a 'none' field and <false/> it it is
- missing.
- */
- bool HasNoneField (void) const;
};
class ThumbnailViewItemAcc : public ::cppu::WeakImplHelper5< ::com::sun::star::accessibility::XAccessible,
commit b67630b3d9f4538aeaa00ddf8ad6af1efff2a606
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Sun Jun 10 11:20:01 2012 -0430
Use forward declaration for ThumbnailView.
Change-Id: I349ffa2250c56d03cdfe5d9d0f601185657ed188
diff --git a/sfx2/inc/templatedlg.hxx b/sfx2/inc/templatedlg.hxx
index 0a414fc..b1b7598 100644
--- a/sfx2/inc/templatedlg.hxx
+++ b/sfx2/inc/templatedlg.hxx
@@ -10,11 +10,11 @@
#ifndef TEMPLATEDLG_HXX
#define TEMPLATEDLG_HXX
-#include <sfx2/thumbnailview.hxx>
-
#include <vcl/dialog.hxx>
#include <vcl/button.hxx>
+class ThumbnailView;
+
class SfxTemplateManagerDlg : public ModalDialog
{
public:
@@ -37,7 +37,7 @@ private:
PushButton aButtonSheets;
PushButton aButtonDraws;
- ThumbnailView maView;
+ ThumbnailView *maView;
};
#endif // TEMPLATEDLG_HXX
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 67766b8..59ab1b9 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -10,6 +10,7 @@
#include "templatedlg.hxx"
#include <sfx2/sfxresid.hxx>
+#include <sfx2/thumbnailview.hxx>
#include "doc.hrc"
#include "templatedlg.hrc"
@@ -24,23 +25,24 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
aButtonPresents(this,SfxResId(BTN_SELECT_PRESENTATIONS)),
aButtonSheets(this,SfxResId(BTN_SELECT_SHEETS)),
aButtonDraws(this,SfxResId(BTN_SELECT_DRAWS)),
- maView(this,SfxResId(TEMPLATE_VIEW))
+ maView(new ThumbnailView(this,SfxResId(TEMPLATE_VIEW)))
{
- maView.SetStyle(WB_RADIOSEL | WB_TABSTOP);
- maView.SetColCount(MAX_COLUMN_COUNT);
- maView.SetLineCount(MAX_LINE_COUNT);
+ maView->SetStyle(WB_RADIOSEL | WB_TABSTOP);
+ maView->SetColCount(MAX_COLUMN_COUNT);
+ maView->SetLineCount(MAX_LINE_COUNT);
aButtonAll.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewAllHdl));
aButtonDocs.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewDocsHdl));
- maView.Populate();
- maView.Show();
+ maView->Populate();
+ maView->Show();
FreeResource();
}
SfxTemplateManagerDlg::~SfxTemplateManagerDlg ()
{
+ delete maView;
}
IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewAllHdl)
commit cc7324c6a3461e359937b0076abd8b6140c7c8c7
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Sun Jun 10 11:03:46 2012 -0430
Populate template thumbnails in thumbnailview instead of dialog.
- Create a Populate method to fill the view.
- Move lcl_fetchThumbnail function to thumbnailview.cxx.
Change-Id: Id009160c4bebd9d715c9605a8c1a0f08f5b0a476
diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index 62ed25a..d2efbb8 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -25,7 +25,7 @@ class HelpEvent;
class KeyEvent;
class DataChangedEvent;
class ScrollBar;
-
+class SfxOrganizeMgr;
struct ThumbnailViewItem;
typedef ::std::vector< ThumbnailViewItem* > ValueItemList;
@@ -192,6 +192,9 @@ public:
virtual void DoubleClick();
+ // Fill view with template thumbnails
+ void Populate ();
+
void InsertItem( sal_uInt16 nItemId,
const Image& rImage, const rtl::OUString &rStr,
size_t nPos = THUMBNAILVIEW_APPEND );
@@ -363,6 +366,7 @@ protected:
VirtualDevice maVirDev;
Timer maTimer;
ValueItemList mItemList;
+ SfxOrganizeMgr *mpMgr;
ThumbnailViewItem* mpNoneItem;
ScrollBar* mpScrBar;
Rectangle maNoneItemRect;
diff --git a/sfx2/inc/templatedlg.hxx b/sfx2/inc/templatedlg.hxx
index 867a74f..0a414fc 100644
--- a/sfx2/inc/templatedlg.hxx
+++ b/sfx2/inc/templatedlg.hxx
@@ -15,8 +15,6 @@
#include <vcl/dialog.hxx>
#include <vcl/button.hxx>
-class SfxOrganizeMgr;
-
class SfxTemplateManagerDlg : public ModalDialog
{
public:
@@ -40,8 +38,6 @@ private:
PushButton aButtonDraws;
ThumbnailView maView;
-
- SfxOrganizeMgr *mpMgr;
};
#endif // TEMPLATEDLG_HXX
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index e4eb099..7b7cfdb 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -9,18 +9,28 @@
#include <sfx2/thumbnailview.hxx>
#include <sfx2/thumbnailviewitem.hxx>
+#include <sfx2/doctempl.hxx>
+#include "orgmgr.hxx"
#include "thumbnailviewacc.hxx"
+#include <comphelper/processfactory.hxx>
#include <rtl/ustring.hxx>
+#include <unotools/ucbstreamhelper.hxx>
#include <vcl/decoview.hxx>
#include <vcl/svapp.hxx>
#include <vcl/scrbar.hxx>
#include <vcl/help.hxx>
+#include <vcl/pngread.hxx>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
enum
{
@@ -34,6 +44,118 @@ enum
SCROLL_OFFSET = 4
};
+Image lcl_fetchThumbnail (const rtl::OUString &msURL)
+{
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+
+ // Load the thumbnail from a template document.
+ uno::Reference<io::XInputStream> xIStream;
+
+ uno::Reference< lang::XMultiServiceFactory > xServiceManager (
+ ::comphelper::getProcessServiceFactory());
+ if (xServiceManager.is())
+ {
+ try
+ {
+ uno::Reference<lang::XSingleServiceFactory> xStorageFactory(
+ xServiceManager->createInstance( "com.sun.star.embed.StorageFactory"),
+ uno::UNO_QUERY);
+
+ if (xStorageFactory.is())
+ {
+ uno::Sequence<uno::Any> aArgs (2);
+ aArgs[0] <<= msURL;
+ aArgs[1] <<= embed::ElementModes::READ;
+ uno::Reference<embed::XStorage> xDocStorage (
+ xStorageFactory->createInstanceWithArguments(aArgs),
+ uno::UNO_QUERY);
+
+ try
+ {
+ if (xDocStorage.is())
+ {
+ uno::Reference<embed::XStorage> xStorage (
+ xDocStorage->openStorageElement(
+ "Thumbnails",
+ embed::ElementModes::READ));
+ if (xStorage.is())
+ {
+ uno::Reference<io::XStream> xThumbnailCopy (
+ xStorage->cloneStreamElement("thumbnail.png"));
+ if (xThumbnailCopy.is())
+ xIStream = xThumbnailCopy->getInputStream();
+ }
+ }
+ }
+ catch (const uno::Exception& rException)
+ {
+ OSL_TRACE (
+ "caught exception while trying to access Thumbnail/thumbnail.png of %s: %s",
+ ::rtl::OUStringToOString(msURL,
+ RTL_TEXTENCODING_UTF8).getStr(),
+ ::rtl::OUStringToOString(rException.Message,
+ RTL_TEXTENCODING_UTF8).getStr());
+ }
+
+ try
+ {
+ // An (older) implementation had a bug - The storage
+ // name was "Thumbnail" instead of "Thumbnails". The
+ // old name is still used as fallback but this code can
+ // be removed soon.
+ if ( ! xIStream.is())
+ {
+ uno::Reference<embed::XStorage> xStorage (
+ xDocStorage->openStorageElement( "Thumbnail",
+ embed::ElementModes::READ));
+ if (xStorage.is())
+ {
+ uno::Reference<io::XStream> xThumbnailCopy (
+ xStorage->cloneStreamElement("thumbnail.png"));
+ if (xThumbnailCopy.is())
+ xIStream = xThumbnailCopy->getInputStream();
+ }
+ }
+ }
+ catch (const uno::Exception& rException)
+ {
+ OSL_TRACE (
+ "caught exception while trying to access Thumbnails/thumbnail.png of %s: %s",
+ ::rtl::OUStringToOString(msURL,
+ RTL_TEXTENCODING_UTF8).getStr(),
+ ::rtl::OUStringToOString(rException.Message,
+ RTL_TEXTENCODING_UTF8).getStr());
+ }
+ }
+ }
+ catch (const uno::Exception& rException)
+ {
+ OSL_TRACE (
+ "caught exception while trying to access tuhmbnail of %s: %s",
+ ::rtl::OUStringToOString(msURL,
+ RTL_TEXTENCODING_UTF8).getStr(),
+ ::rtl::OUStringToOString(rException.Message,
+ RTL_TEXTENCODING_UTF8).getStr());
+ }
+ }
+
+ // Extract the image from the stream.
+ BitmapEx aThumbnail;
+ if (xIStream.is())
+ {
+ ::std::auto_ptr<SvStream> pStream (
+ ::utl::UcbStreamHelper::CreateStream (xIStream));
+ ::vcl::PNGReader aReader (*pStream);
+ aThumbnail = aReader.Read ();
+ }
+
+ // Note that the preview is returned without scaling it to the desired
+ // width. This gives the caller the chance to take advantage of a
+ // possibly larger resolution then was asked for.
+ return aThumbnail;
+}
+
ThumbnailView::ThumbnailView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren)
: Control( pParent, nWinStyle ),
maVirDev( *this ),
@@ -61,6 +183,7 @@ ThumbnailView::~ThumbnailView()
if (xComponent.is())
xComponent->dispose ();
+ delete mpMgr;
delete mpScrBar;
delete mpNoneItem;
@@ -69,6 +192,7 @@ ThumbnailView::~ThumbnailView()
void ThumbnailView::ImplInit()
{
+ mpMgr = new SfxOrganizeMgr(NULL,NULL);
mpNoneItem = NULL;
mpScrBar = NULL;
mnItemWidth = 0;
@@ -1461,6 +1585,25 @@ void ThumbnailView::DoubleClick()
maDoubleClickHdl.Call( this );
}
+void ThumbnailView::Populate ()
+{
+ const SfxDocumentTemplates* pTemplates = mpMgr->GetTemplates();
+
+ sal_uInt16 nCount = pTemplates->GetRegionCount();
+ for (sal_uInt16 i = 0; i < nCount; ++i)
+ {
+ rtl::OUString aRegionName(pTemplates->GetFullRegionName(i));
+
+ sal_uInt16 nEntries = pTemplates->GetCount(i);
+
+ for ( sal_uInt16 j = 0; j < nEntries; ++j)
+ {
+ Image aImg = lcl_fetchThumbnail(pTemplates->GetPath(i,j));
+ InsertItem(i*100+j,aImg,pTemplates->GetName(i,j));
+ }
+ }
+}
+
void ThumbnailView::InsertItem( sal_uInt16 nItemId, const Image& rImage,
const rtl::OUString& rText, size_t nPos )
{
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 337061c..67766b8 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -9,138 +9,14 @@
#include "templatedlg.hxx"
-#include <comphelper/processfactory.hxx>
-#include <sfx2/doctempl.hxx>
#include <sfx2/sfxresid.hxx>
-#include <unotools/ucbstreamhelper.hxx>
-#include <vcl/pngread.hxx>
-
-#include <com/sun/star/embed/ElementModes.hpp>
-#include <com/sun/star/embed/XStorage.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-#include "orgmgr.hxx"
#include "doc.hrc"
#include "templatedlg.hrc"
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-
#define MAX_COLUMN_COUNT 4
#define MAX_LINE_COUNT 2
-Image lcl_fetchThumbnail (const rtl::OUString &msURL)
-{
-
- // Load the thumbnail from a template document.
- uno::Reference<io::XInputStream> xIStream;
-
- uno::Reference< lang::XMultiServiceFactory > xServiceManager (
- ::comphelper::getProcessServiceFactory());
- if (xServiceManager.is())
- {
- try
- {
- uno::Reference<lang::XSingleServiceFactory> xStorageFactory(
- xServiceManager->createInstance( "com.sun.star.embed.StorageFactory"),
- uno::UNO_QUERY);
-
- if (xStorageFactory.is())
- {
- uno::Sequence<uno::Any> aArgs (2);
- aArgs[0] <<= msURL;
- aArgs[1] <<= embed::ElementModes::READ;
- uno::Reference<embed::XStorage> xDocStorage (
- xStorageFactory->createInstanceWithArguments(aArgs),
- uno::UNO_QUERY);
-
- try
- {
- if (xDocStorage.is())
- {
- uno::Reference<embed::XStorage> xStorage (
- xDocStorage->openStorageElement(
- "Thumbnails",
- embed::ElementModes::READ));
- if (xStorage.is())
- {
- uno::Reference<io::XStream> xThumbnailCopy (
- xStorage->cloneStreamElement("thumbnail.png"));
- if (xThumbnailCopy.is())
- xIStream = xThumbnailCopy->getInputStream();
- }
- }
- }
- catch (const uno::Exception& rException)
- {
- OSL_TRACE (
- "caught exception while trying to access Thumbnail/thumbnail.png of %s: %s",
- ::rtl::OUStringToOString(msURL,
- RTL_TEXTENCODING_UTF8).getStr(),
- ::rtl::OUStringToOString(rException.Message,
- RTL_TEXTENCODING_UTF8).getStr());
- }
-
- try
- {
- // An (older) implementation had a bug - The storage
- // name was "Thumbnail" instead of "Thumbnails". The
- // old name is still used as fallback but this code can
- // be removed soon.
- if ( ! xIStream.is())
- {
- uno::Reference<embed::XStorage> xStorage (
- xDocStorage->openStorageElement( "Thumbnail",
- embed::ElementModes::READ));
- if (xStorage.is())
- {
- uno::Reference<io::XStream> xThumbnailCopy (
- xStorage->cloneStreamElement("thumbnail.png"));
- if (xThumbnailCopy.is())
- xIStream = xThumbnailCopy->getInputStream();
- }
- }
- }
- catch (const uno::Exception& rException)
- {
- OSL_TRACE (
- "caught exception while trying to access Thumbnails/thumbnail.png of %s: %s",
- ::rtl::OUStringToOString(msURL,
- RTL_TEXTENCODING_UTF8).getStr(),
- ::rtl::OUStringToOString(rException.Message,
- RTL_TEXTENCODING_UTF8).getStr());
- }
- }
- }
- catch (const uno::Exception& rException)
- {
- OSL_TRACE (
- "caught exception while trying to access tuhmbnail of %s: %s",
- ::rtl::OUStringToOString(msURL,
- RTL_TEXTENCODING_UTF8).getStr(),
- ::rtl::OUStringToOString(rException.Message,
- RTL_TEXTENCODING_UTF8).getStr());
- }
- }
-
- // Extract the image from the stream.
- BitmapEx aThumbnail;
- if (xIStream.is())
- {
- ::std::auto_ptr<SvStream> pStream (
- ::utl::UcbStreamHelper::CreateStream (xIStream));
- ::vcl::PNGReader aReader (*pStream);
- aThumbnail = aReader.Read ();
- }
-
- // Note that the preview is returned without scaling it to the desired
- // width. This gives the caller the chance to take advantage of a
- // possibly larger resolution then was asked for.
- return aThumbnail;
-}
-
SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
: ModalDialog(parent, SfxResId(DLG_TEMPLATE_MANAGER)),
aButtonAll(this,SfxResId(BTN_SELECT_ALL)),
@@ -148,8 +24,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
aButtonPresents(this,SfxResId(BTN_SELECT_PRESENTATIONS)),
aButtonSheets(this,SfxResId(BTN_SELECT_SHEETS)),
aButtonDraws(this,SfxResId(BTN_SELECT_DRAWS)),
- maView(this,SfxResId(TEMPLATE_VIEW)),
- mpMgr(new SfxOrganizeMgr(NULL,NULL))
+ maView(this,SfxResId(TEMPLATE_VIEW))
{
maView.SetStyle(WB_RADIOSEL | WB_TABSTOP);
maView.SetColCount(MAX_COLUMN_COUNT);
@@ -158,27 +33,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
aButtonAll.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewAllHdl));
aButtonDocs.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewDocsHdl));
- const SfxDocumentTemplates* pTemplates = mpMgr->GetTemplates();
-
- sal_uInt16 nCount = pTemplates->GetRegionCount();
- for (sal_uInt16 i = 0; i < nCount; ++i)
- {
- rtl::OUString aRegionName(pTemplates->GetFullRegionName(i));
-
- if (aRegionName == "My Templates")
- {
- sal_uInt16 nEntries = pTemplates->GetCount(i);
-
- for ( sal_uInt16 j = 0; j < nEntries; ++j)
- {
- Image aImg = lcl_fetchThumbnail(pTemplates->GetPath(i,j));
- maView.InsertItem(i,aImg,pTemplates->GetName(i,j));
- }
-
- break;
- }
- }
-
+ maView.Populate();
maView.Show();
FreeResource();
commit 9757fdd2cf41dc1fc2e17e30cf73a2c9ac937626
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Sun Jun 10 08:47:11 2012 -0430
Move thumbnailview to sfx2 folder.
Change-Id: Iace30ac7911938184cee5f4e5e16159598771014
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 0a97789..a516bb3 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -146,6 +146,9 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/control/shell \
sfx2/source/control/sorgitm \
sfx2/source/control/statcach \
+ sfx2/source/control/thumbnailviewitem \
+ sfx2/source/control/thumbnailviewacc \
+ sfx2/source/control/thumbnailview \
sfx2/source/control/unoctitm \
sfx2/source/dialog/alienwarn \
sfx2/source/dialog/basedlgs \
diff --git a/sfx2/Package_inc.mk b/sfx2/Package_inc.mk
index 4c2594c..dee4610 100644
--- a/sfx2/Package_inc.mk
+++ b/sfx2/Package_inc.mk
@@ -2,7 +2,7 @@
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
+#
# Copyright 2000, 2011 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
@@ -127,6 +127,8 @@ $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/taskpane.hxx,sfx2/taskpane.h
$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/tbxctrl.hxx,sfx2/tbxctrl.hxx))
$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templdlg.hxx,sfx2/templdlg.hxx))
$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templatelocnames.hrc,sfx2/templatelocnames.hrc))
+$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/thumbnailview.hxx,sfx2/thumbnailview.hxx))
+$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/thumbnailviewitem.hxx,sfx2/thumbnailviewitem.hxx))
$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/titledockwin.hxx,sfx2/titledockwin.hxx))
$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/tplpitem.hxx,sfx2/tplpitem.hxx))
$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/unoctitm.hxx,sfx2/unoctitm.hxx))
diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
new file mode 100644
index 0000000..62ed25a
--- /dev/null
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -0,0 +1,405 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * 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 THUMBNAILVIEW_HXX
+#define THUMBNAILVIEW_HXX
+
+#include "svtools/svtdllapi.h"
+
+#include <vector>
+
+#include <vcl/ctrl.hxx>
+#include <vcl/image.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/timer.hxx>
+
+class MouseEvent;
+class TrackingEvent;
+class HelpEvent;
+class KeyEvent;
+class DataChangedEvent;
+class ScrollBar;
+
+struct ThumbnailViewItem;
+typedef ::std::vector< ThumbnailViewItem* > ValueItemList;
+
+class ThumbnailViewAcc;
+class ThumbnailViewItemAcc;
+
+/*************************************************************************
+
+ Description
+ ============
+
+ class ThumbnailView
+
+ This class allows the selection of an item. In the process items are
+ drawn side by side. The selection of items can be more clear than in a
+ ListBox shape for example in case of colors or samples.
+ The amount of columns drawn by the control and whether the items
+ should be encircled can be specified. Optional a NoSelection or name
+ field could be shown. By default image and color items are supported.
+ Items could be drawn by oneself if InsertItem() is only called with
+ an ID. To achieve this the UserDraw handler needs to be overloaded. The
+ description text could be specified afterwards in case of UserDraw
+ and any other items.
+
+ Cross references
+
+ class ListBox
+
+ --------------------------------------------------------------------------
+
+ WinBits
+
+ WB_RADIOSEL If set the selection will be drawn like an
+ ImageRadioButton. This does only make sense if the image
+ is at least 8 pixel smaller on each side than the item
+ and also WB_DOUBLEBORDER is set and as color
+ COL_WINDOWWORKSPACE is specified.
+ WB_FLATVALUESET Flat Look.
+ WB_NAMEFIELD There is a namefield, where the name of an item will be
+ shown.
+ WB_NONEFIELD There is a NoSelection field which can be selected if
+ 0 is passed along with SelectItem. Respectively
+ GetSelectItemId() returns 0 if this field or nothing
+ is selected. This field shows the text which is specified
+ by SetText() respectively no one, if no text was set. With
+ SetNoSelection() the selection can be disabled.
+ WB_VSCROLL A scroolbar will be always shown. The visible number of
+ lines have to be specified with SetLineCount() if this
+ flag is set.
+ WB_BORDER A border will be drawn around the window.
+ WB_NOPOINTERFOCUS The focus won't be gathered, if the control was pressed by
+ the mouse.
+ WB_TABSTOP It is possible to jump into the ValueSet with the tab key.
+ WB_NOTABSTOP It is not possible to jump into the ValueSet with the
+ tab key.
+ WB_NO_DIRECTSELECT Cursor travelling doesn't call select immediately. To
+ execute the selection <RETURN> has to be pressed.
+ --------------------------------------------------------------------------
+
+ The number of columns must be either set with SetColCount() or
+ SetItemWidth(). If the number of colums is specified by SetColCount()
+ the width of the items will be calculated by the visible range.
+ If the items should have a static width, it has to be specified
+ with SetItemWidth(). In this case the number of columns will be calculated
+ by the visible range.
+
+ The number of rows is given by the number of items / number of columns. The
+ number of visible rows must either specified by SetLineCount() or
+ SetItemWidth(). If the number of visible rows is specified by SetLineCount(),
+ the height of the items will be calculated from the visible height. If the
+ items should have a fixed height it has to be specified with SetItemHeight().
+ In this case the number of visible rows is then calculated from the visible
+ height. If the number of visible rows is neither specified by SetLineCount()
+ nor by SetItemHeight() all rows will be shown. The height of the items will
+ be calculated by the visible height. If the number of visible rows is
+ specified by SetLineCount() or SetItemHeight() ValueSet does scroll
+ automatically when more lines are available, as are visible. If scrolling
+ should be also possible with a ScrollBar WB_VSCROLL needs to be set.
+
+ The distance between the items can be increased by SetExtraSpacing(). The
+ distance, which will be shown between two items (both in x and in y), is
+ measured in pixels.
+
+ The exact window size for a specific item size can be calculated by
+ CalcWindowSizePixel(). To do this all relevant data (number of columns/...)
+ have to be specified and if no number of rows was set, all items need to
+ be inserted. If the window was created with WB_BORDER/Border=sal_True the
+ size has to be specified with SetOutputSizePixel(). In other cases different
+ size-methods can be used. With CalcItemSize() the inner and outer size of
+ an item could be calculated (for this the free space defined by
+ SetExtraSpacing() will not be included).
+
+ The background color could be specified by SetColor(), with which the image
+ or UserDraw items will be underlayed. If no color is specified the the color
+ of other windows (WindowColor) will be used for the background.
+
+ --------------------------------------------------------------------------
+
+ At first all items should be inserted and only then Show() should be called
+ since the output area will be precomputed. If this is not done the first
+ Paint will appear a little bit slower. Therefore the Control, if it is loaded
+ from the resource and only supplied with items during runtime, should be
+ loaded with Hide = sal_True and then displayed with Show().
+
+ In case of a visible Control the creation of the new output area could be
+ activated before Paint by calling Format().
+
+ --------------------------------------------------------------------------
+
+ If Drag and Drop will be called from the ValueSet the Command-Handler has to
+ be overloaded. From this StartDrag needs to be called. If this method returns
+ sal_True the drag-process could be initiated by ExecuteDrag(), otherwise no
+ processing will take place. This method makes sure that ValueSet stops its
+ processing and as appropriate selects the entry. Therefore the calling of
+ Select-Handler within this function must be expected.
+
+ For dropping QueryDrop() and Drop() need to be overloaded and ShowDropPos()
+ and HideDropPos() should be called within these methods.
+ To show the insertion point ShowDropPos() has to be called within the
+ QueryDrop-Handler. ShowDropPos() also scrolls the ValueSet if the passed
+ position is located at the window border. Furthermore ShowDropPos() returns
+ the position, at which the item should be inserted respectively which
+ insertion point was shown. If no insertion point was determined
+ VALUESET_ITEM_NOTFOUND will be returned. If the window was left during dragging
+ or the drag process is terminated HideDropPos() should be called in any case.
+
+ --------------------------------------------------------------------------
+
+ This class is currently still in the SV-Tools. That's why the ValueSet needs
+ to be loaded as a Control out of the resource and the desired WinBits have
+ to be set (before Show) with SetStyle().
+
+*************************************************************************/
+
+/* ThumbnailView types */
+
+#define WB_RADIOSEL ((WinBits)0x00008000)
+#define WB_NAMEFIELD ((WinBits)0x00040000)
+#define WB_NONEFIELD ((WinBits)0x00080000)
+#define WB_FLATVALUESET ((WinBits)0x02000000)
+#define WB_NO_DIRECTSELECT ((WinBits)0x04000000)
+#define WB_MENUSTYLEVALUESET ((WinBits)0x08000000)
+
+#define THUMBNAILVIEW_APPEND ((sal_uInt16)-1)
+#define THUMBNAILVIEW_ITEM_NOTFOUND ((sal_uInt16)-1)
+
+/**
+ *
+ * Class to display thumbnails with their names below their respective icons
+ *
+ **/
+
+class SVT_DLLPUBLIC ThumbnailView : public Control
+{
+public:
+
+ ThumbnailView ( Window* pParent, WinBits nWinStyle = WB_TABSTOP, bool bDisableTransientChildren = false );
+
+ ThumbnailView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren = false );
+
+ virtual ~ThumbnailView ();
+
+ virtual void Select();
+
+ virtual void DoubleClick();
+
+ void InsertItem( sal_uInt16 nItemId,
+ const Image& rImage, const rtl::OUString &rStr,
+ size_t nPos = THUMBNAILVIEW_APPEND );
+
+ void RemoveItem( sal_uInt16 nItemId );
+
+ void Clear();
+
+ size_t GetItemCount() const;
+
+ size_t GetItemPos( sal_uInt16 nItemId ) const;
+
+ sal_uInt16 GetItemId( size_t nPos ) const;
+
+ sal_uInt16 GetItemId( const Point& rPos ) const;
+
+ Rectangle GetItemRect( sal_uInt16 nItemId ) const;
+
+ void EnableFullItemMode( bool bFullMode = true );
+
+ bool IsFullItemModeEnabled() const { return mbFullMode; }
+
+ void SetColCount( sal_uInt16 nNewCols = 1 );
+
+ sal_uInt16 GetColCount() const { return mnUserCols; }
+
+ void SetLineCount( sal_uInt16 nNewLines = 0 );
+
+ sal_uInt16 GetLineCount() const { return mnUserVisLines; }
+
+ void SetItemWidth( long nItemWidth = 0 );
+
+ long GetItemWidth() const { return mnUserItemWidth; }
+
+ void SetItemHeight( long nLineHeight = 0 );
+
+ long GetItemHeight() const { return mnUserItemHeight; }
+
+ sal_uInt16 GetFirstLine() const { return mnFirstLine; }
+
+ void SelectItem( sal_uInt16 nItemId );
+
+ sal_uInt16 GetSelectItemId() const { return mnSelItemId; }
+
+ bool IsItemSelected( sal_uInt16 nItemId ) const
+ { return !mbNoSelection && (nItemId == mnSelItemId); }
+
+ void SetNoSelection();
+
+ bool IsNoSelection() const { return mbNoSelection; }
+
+ void SetItemImage( sal_uInt16 nItemId, const Image& rImage );
+
+ Image GetItemImage( sal_uInt16 nItemId ) const;
+
+ void SetItemData( sal_uInt16 nItemId, void* pData );
+
+ void* GetItemData( sal_uInt16 nItemId ) const;
+
+ void SetItemText( sal_uInt16 nItemId, const rtl::OUString &rStr );
+
+ rtl::OUString GetItemText( sal_uInt16 nItemId ) const;
+
+ void SetColor( const Color& rColor );
+
+ void SetColor() { SetColor( Color( COL_TRANSPARENT ) ); }
+
+ Color GetColor() const { return maColor; }
+
+ bool IsColor() const { return maColor.GetTransparency() == 0; }
+
+ void Format();
+
+ void StartSelection();
+
+ void EndSelection();
+
+ Size CalcWindowSizePixel( const Size& rItemSize,
+ sal_uInt16 nCalcCols = 0,
+ sal_uInt16 nCalcLines = 0 );
+
+ long GetScrollWidth() const;
+
+ void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; }
+
+ const Link& GetSelectHdl() const { return maSelectHdl; }
+
+ void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; }
+
+ const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; }
+
+ void SetHighlightHdl( const Link& rLink );
+
+protected:
+
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+
+ virtual void MouseMove( const MouseEvent& rMEvt );
+
+ virtual void Tracking( const TrackingEvent& rMEvt );
+
+ virtual void KeyInput( const KeyEvent& rKEvt );
+
+ virtual void Command( const CommandEvent& rCEvt );
+
+ virtual void Paint( const Rectangle& rRect );
+
+ virtual void GetFocus();
+
+ virtual void LoseFocus();
+
+ virtual void Resize();
+
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+
+ virtual void StateChanged( StateChangedType nStateChange );
+
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ virtual bool StartDrag( const CommandEvent& rCEvt, Region& rRegion );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+
+protected:
+
+ // Drawing item related functions, override them to make your own custom ones.
+
+ virtual void DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect);
+
+ virtual void DrawItemText (const rtl::OUString &rStr );
+
+ virtual void DrawSelectedItem (const sal_uInt16 nItemId, const bool bFocus, const bool bDrawSel);
+
+private:
+
+ friend class ThumbnailViewAcc;
+ friend class ThumbnailViewItemAcc;
+ using Control::ImplInitSettings;
+ using Window::ImplInit;
+
+ SVT_DLLPRIVATE void ImplInit();
+ SVT_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
+ SVT_DLLPRIVATE void ImplInitScrollBar();
+ SVT_DLLPRIVATE void ImplDeleteItems();
+ SVT_DLLPRIVATE void ImplDrawSelect();
+ SVT_DLLPRIVATE void ImplHideSelect( sal_uInt16 nItemId );
+ SVT_DLLPRIVATE void ImplHighlightItem( sal_uInt16 nItemId, bool bIsSelection = true );
+ SVT_DLLPRIVATE void ImplDraw();
+ using Window::ImplScroll;
+ SVT_DLLPRIVATE bool ImplScroll( const Point& rPos );
+ SVT_DLLPRIVATE size_t ImplGetItem( const Point& rPoint, bool bMove = false ) const;
+ SVT_DLLPRIVATE ThumbnailViewItem* ImplGetItem( size_t nPos );
+ SVT_DLLPRIVATE ThumbnailViewItem* ImplGetFirstItem();
+ SVT_DLLPRIVATE sal_uInt16 ImplGetVisibleItemCount() const;
+ SVT_DLLPRIVATE ThumbnailViewItem* ImplGetVisibleItem( sal_uInt16 nVisiblePos );
+ SVT_DLLPRIVATE void ImplInsertItem( ThumbnailViewItem *const pItem, const size_t nPos );
+ SVT_DLLPRIVATE Rectangle ImplGetItemRect( size_t nPos ) const;
+ SVT_DLLPRIVATE void ImplFireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue );
+ SVT_DLLPRIVATE bool ImplHasAccessibleListeners();
+ SVT_DLLPRIVATE void ImplTracking( const Point& rPos, bool bRepeat );
+ SVT_DLLPRIVATE void ImplEndTracking( const Point& rPos, bool bCancel );
+ DECL_DLLPRIVATE_LINK( ImplScrollHdl, ScrollBar* );
+ DECL_DLLPRIVATE_LINK( ImplTimerHdl, void* );
+
+protected:
+
+ VirtualDevice maVirDev;
+ Timer maTimer;
+ ValueItemList mItemList;
+ ThumbnailViewItem* mpNoneItem;
+ ScrollBar* mpScrBar;
+ Rectangle maNoneItemRect;
+ Rectangle maItemListRect;
+ long mnItemWidth;
+ long mnItemHeight;
+ long mnTextOffset;
+ long mnVisLines;
+ long mnLines;
+ long mnUserItemWidth;
+ long mnUserItemHeight;
+ sal_uInt16 mnSelItemId;
+ sal_uInt16 mnHighItemId;
+ sal_uInt16 mnCols;
+ sal_uInt16 mnCurCol;
+ sal_uInt16 mnUserCols;
+ sal_uInt16 mnUserVisLines;
+ sal_uInt16 mnFirstLine;
+ sal_uInt16 mnSpacing;
+ sal_uInt16 mnFrameStyle;
+ bool mbFormat : 1;
+ bool mbHighlight : 1;
+ bool mbSelection : 1;
+ bool mbNoSelection : 1;
+ bool mbDrawSelection : 1;
+ bool mbBlackSel : 1;
+ bool mbDoubleSel : 1;
+ bool mbScroll : 1;
+ bool mbFullMode : 1;
+ bool mbIsTransientChildrenDisabled : 1;
+ bool mbHasVisibleItems : 1;
+ Color maColor;
+ Link maDoubleClickHdl;
+ Link maSelectHdl;
+ Link maHighlightHdl;
+};
+
+#endif // THUMBNAILVIEW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx
new file mode 100644
index 0000000..6ba8351
--- /dev/null
+++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef THUMBNAILVIEWITEM_HXX
+#define THUMBNAILVIEWITEM_HXX
+
+#include <osl/mutex.hxx>
+#include <vcl/image.hxx>
+
+#include <com/sun/star/accessibility/XAccessible.hpp>
+
+#define THUMBNAILVIEW_ITEM_NONEITEM 0xFFFE
+
+class ThumbnailView;
+
+struct ThumbnailViewItem
+{
+ ThumbnailView &mrParent;
+ sal_uInt16 mnId;
+ bool mbVisible;
+ Image maImage;
+ rtl::OUString maText;
+ void* mpData;
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >* mpxAcc;
+
+ ThumbnailViewItem ( ThumbnailView& rParent );
+ ~ThumbnailViewItem ();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ GetAccessible( bool bIsTransientChildrenDisabled );
+};
+
+#endif // THUMBNAILVIEWITEM_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/inc/templatedlg.hxx b/sfx2/inc/templatedlg.hxx
index 0af1cb7..867a74f 100644
--- a/sfx2/inc/templatedlg.hxx
+++ b/sfx2/inc/templatedlg.hxx
@@ -10,7 +10,7 @@
#ifndef TEMPLATEDLG_HXX
#define TEMPLATEDLG_HXX
-#include <svtools/thumbnailview.hxx>
+#include <sfx2/thumbnailview.hxx>
#include <vcl/dialog.hxx>
#include <vcl/button.hxx>
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
new file mode 100644
index 0000000..e4eb099
--- /dev/null
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -0,0 +1,2031 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * 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 <sfx2/thumbnailview.hxx>
+#include <sfx2/thumbnailviewitem.hxx>
+
+#include "thumbnailviewacc.hxx"
+
+#include <rtl/ustring.hxx>
+#include <vcl/decoview.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/scrbar.hxx>
+#include <vcl/help.hxx>
+
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+enum
+{
+ ITEM_OFFSET = 4,
+ ITEM_OFFSET_DOUBLE = 6,
+ NAME_LINE_OFF_X = 2,
+ NAME_LINE_OFF_Y = 2,
+ NAME_LINE_HEIGHT = 2,
+ NAME_OFFSET = 2,
+ SCRBAR_OFFSET = 1,
+ SCROLL_OFFSET = 4
+};
+
+ThumbnailView::ThumbnailView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren)
+ : Control( pParent, nWinStyle ),
+ maVirDev( *this ),
+ maColor( COL_TRANSPARENT )
+{
+ ImplInit();
+ mbIsTransientChildrenDisabled = bDisableTransientChildren;
+}
+
+ThumbnailView::ThumbnailView (Window *pParent, const ResId &rResId, bool bDisableTransientChildren)
+ : Control( pParent, rResId ),
+ maVirDev( *this ),
+ maColor( COL_TRANSPARENT )
+{
+ ImplInit();
+ mbIsTransientChildrenDisabled = bDisableTransientChildren;
+}
+
+ThumbnailView::~ThumbnailView()
+{
+ com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent>
+ xComponent(GetAccessible(sal_False),
+ com::sun::star::uno::UNO_QUERY);
+
+ if (xComponent.is())
+ xComponent->dispose ();
+
+ delete mpScrBar;
+ delete mpNoneItem;
+
+ ImplDeleteItems();
+}
+
+void ThumbnailView::ImplInit()
+{
+ mpNoneItem = NULL;
+ mpScrBar = NULL;
+ mnItemWidth = 0;
+ mnItemHeight = 0;
+ mnTextOffset = 0;
+ mnVisLines = 0;
+ mnLines = 0;
+ mnUserItemWidth = 0;
+ mnUserItemHeight = 0;
+ mnFirstLine = 0;
+ mnSelItemId = 0;
+ mnHighItemId = 0;
+ mnCols = 0;
+ mnCurCol = 0;
+ mnUserCols = 0;
+ mnUserVisLines = 0;
+ mnSpacing = 0;
+ mnFrameStyle = 0;
+ mbFormat = true;
+ mbHighlight = false;
+ mbSelection = false;
+ mbNoSelection = true;
+ mbDrawSelection = true;
+ mbBlackSel = false;
+ mbDoubleSel = false;
+ mbScroll = false;
+ mbFullMode = true;
+ mbHasVisibleItems = false;
+
+ // #106446#, #106601# force mirroring of virtual device
+ maVirDev.EnableRTL( GetParent()->IsRTLEnabled() );
+
+ ImplInitSettings( true, true, true );
+}
+
+void ThumbnailView::ImplDeleteItems()
+{
+ const size_t n = mItemList.size();
+
+ for ( size_t i = 0; i < n; ++i )
+ {
+ ThumbnailViewItem *const pItem = mItemList[i];
+ if ( pItem->mbVisible && ImplHasAccessibleListeners() )
+ {
+ ::com::sun::star::uno::Any aOldAny, aNewAny;
+
+ aOldAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
+ ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
+ }
+
+ delete pItem;
+ }
+
+ mItemList.clear();
+}
+
+void ThumbnailView::ImplInitSettings( bool bFont, bool bForeground, bool bBackground )
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ if ( bFont )
+ {
+ Font aFont;
+ aFont = rStyleSettings.GetAppFont();
+ if ( IsControlFont() )
+ aFont.Merge( GetControlFont() );
+ SetZoomedPointFont( aFont );
+ }
+
+ if ( bForeground || bFont )
+ {
+ Color aColor;
+ if ( IsControlForeground() )
+ aColor = GetControlForeground();
+ else
+ aColor = rStyleSettings.GetButtonTextColor();
+ SetTextColor( aColor );
+ SetTextFillColor();
+ }
+
+ if ( bBackground )
+ {
+ Color aColor;
+ if ( IsControlBackground() )
+ aColor = GetControlBackground();
+ else if ( GetStyle() & WB_MENUSTYLEVALUESET )
+ aColor = rStyleSettings.GetMenuColor();
+ else if ( IsEnabled() && (GetStyle() & WB_FLATVALUESET) )
+ aColor = rStyleSettings.GetWindowColor();
+ else
+ aColor = rStyleSettings.GetFaceColor();
+ SetBackground( aColor );
+ }
+}
+
+void ThumbnailView::ImplInitScrollBar()
+{
+ if ( GetStyle() & WB_VSCROLL )
+ {
+ if ( !mpScrBar )
+ {
+ mpScrBar = new ScrollBar( this, WB_VSCROLL | WB_DRAG );
+ mpScrBar->SetScrollHdl( LINK( this, ThumbnailView, ImplScrollHdl ) );
+ }
+ else
+ {
+ // adapt the width because of the changed settings
+ long nScrBarWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
+ mpScrBar->SetPosSizePixel( 0, 0, nScrBarWidth, 0, WINDOW_POSSIZE_WIDTH );
+ }
+ }
+}
+
+void ThumbnailView::DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect)
+{
+ WinBits nStyle = GetStyle();
+
+ if ( pItem == mpNoneItem )
+ pItem->maText = GetText();
+
+ if ( (aRect.GetHeight() > 0) && (aRect.GetWidth() > 0) )
+ {
+ if ( pItem == mpNoneItem )
+ {
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ maVirDev.SetFont( GetFont() );
+ maVirDev.SetTextColor( ( nStyle & WB_MENUSTYLEVALUESET ) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor() );
+ maVirDev.SetTextFillColor();
+ maVirDev.SetFillColor( ( nStyle & WB_MENUSTYLEVALUESET ) ? rStyleSettings.GetMenuColor() : rStyleSettings.GetWindowColor() );
+ maVirDev.DrawRect( aRect );
+ Point aTxtPos( aRect.Left()+2, aRect.Top() );
+ long nTxtWidth = GetTextWidth( pItem->maText );
+ if ( nStyle & WB_RADIOSEL )
+ {
+ aTxtPos.X() += 4;
+ aTxtPos.Y() += 4;
+ }
+ if ( (aTxtPos.X()+nTxtWidth) > aRect.Right() )
+ {
+ maVirDev.SetClipRegion( Region( aRect ) );
+ maVirDev.DrawText( aTxtPos, pItem->maText );
+ maVirDev.SetClipRegion();
+ }
+ else
+ maVirDev.DrawText( aTxtPos, pItem->maText );
+ }
+ else
+ {
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ if ( IsColor() )
+ maVirDev.SetFillColor( maColor );
+ else if ( nStyle & WB_MENUSTYLEVALUESET )
+ maVirDev.SetFillColor( rStyleSettings.GetMenuColor() );
+ else if ( IsEnabled() )
+ maVirDev.SetFillColor( rStyleSettings.GetWindowColor() );
+ else
+ maVirDev.SetFillColor( rStyleSettings.GetFaceColor() );
+
+ maVirDev.DrawRect( aRect );
+
+ // Draw thumbnail
+ Size aImageSize = pItem->maImage.GetSizePixel();
+ Size aRectSize = aRect.GetSize();
+ Point aPos( aRect.Left(), aRect.Top() );
+ aPos.X() += (aRectSize.Width()-aImageSize.Width())/2;
+ aPos.Y() += (aRectSize.Height()-aImageSize.Height())/2;
+
+ sal_uInt16 nImageStyle = 0;
+ if( !IsEnabled() )
+ nImageStyle |= IMAGE_DRAW_DISABLE;
+
+ if ( (aImageSize.Width() > aRectSize.Width()) ||
+ (aImageSize.Height() > aRectSize.Height()) )
+ {
+ maVirDev.SetClipRegion( Region( aRect ) );
+ maVirDev.DrawImage( aPos, pItem->maImage, nImageStyle);
+ maVirDev.SetClipRegion();
+ }
+ else
+ maVirDev.DrawImage( aPos, pItem->maImage, nImageStyle );
+
+ // Draw centered text below thumbnail
+ aPos.Y() += 5 + aImageSize.Height();
+ aPos.X() = aRect.Left() + (aRectSize.Width() - maVirDev.GetTextWidth(pItem->maText))/2;
+
+ maVirDev.DrawText(aPos,pItem->maText);
+
+ }
+ }
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ThumbnailView::CreateAccessible()
+{
+ return new ThumbnailViewAcc( this, mbIsTransientChildrenDisabled );
+}
+
+void ThumbnailView::Format()
+{
+ Size aWinSize = GetOutputSizePixel();
+ size_t nItemCount = mItemList.size();
+ WinBits nStyle = GetStyle();
+ long nTxtHeight = GetTextHeight();
+ long nOff = 0;
+ long nNoneHeight;
+ long nNoneSpace;
+ ScrollBar* pDelScrBar = NULL;
+
+ // consider the scrolling
+ if ( nStyle & WB_VSCROLL )
+ ImplInitScrollBar();
+ else
+ {
+ if ( mpScrBar )
+ {
+ // delete ScrollBar not until later, to prevent recursive calls
+ pDelScrBar = mpScrBar;
+ mpScrBar = NULL;
+ }
+ }
+
+ // consider size, if NameField does exist
+ if ( nStyle & WB_NAMEFIELD )
+ {
+ mnTextOffset = aWinSize.Height()-nTxtHeight-NAME_OFFSET;
+ aWinSize.Height() -= nTxtHeight+NAME_OFFSET;
+
+ if ( !(nStyle & WB_FLATVALUESET) )
+ {
+ mnTextOffset -= NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
+ aWinSize.Height() -= NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
+ }
+ }
+ else
+ mnTextOffset = 0;
+
+ // consider offset and size, if NoneField does exist
+ if ( nStyle & WB_NONEFIELD )
+ {
+ nNoneHeight = nTxtHeight+nOff;
+ nNoneSpace = mnSpacing;
+ if ( nStyle & WB_RADIOSEL )
+ nNoneHeight += 8;
+ }
+ else
+ {
+ nNoneHeight = 0;
+ nNoneSpace = 0;
+
+ if ( mpNoneItem )
+ {
+ delete mpNoneItem;
+ mpNoneItem = NULL;
+ }
+ }
+
+ // calculate ScrollBar width
+ long nScrBarWidth = 0;
+ if ( mpScrBar )
+ nScrBarWidth = mpScrBar->GetSizePixel().Width()+SCRBAR_OFFSET;
+
+ // calculate number of columns
+ if ( !mnUserCols )
+ {
+ if ( mnUserItemWidth )
+ {
+ mnCols = (sal_uInt16)((aWinSize.Width()-nScrBarWidth+mnSpacing) / (mnUserItemWidth+mnSpacing));
+ if ( !mnCols )
+ mnCols = 1;
+ }
+ else
+ mnCols = 1;
+ }
+ else
+ mnCols = mnUserCols;
+
+ // calculate number of rows
+ mbScroll = false;
+ // Floor( (M+N-1)/N )==Ceiling( M/N )
+ mnLines = (static_cast<long>(nItemCount)+mnCols-1) / mnCols;
+ if ( !mnLines )
+ mnLines = 1;
+
+ long nCalcHeight = aWinSize.Height()-nNoneHeight;
+ if ( mnUserVisLines )
+ mnVisLines = mnUserVisLines;
+ else if ( mnUserItemHeight )
+ {
+ mnVisLines = (nCalcHeight-nNoneSpace+mnSpacing) / (mnUserItemHeight+mnSpacing);
+ if ( !mnVisLines )
+ mnVisLines = 1;
+ }
+ else
+ mnVisLines = mnLines;
+ if ( mnLines > mnVisLines )
+ mbScroll = true;
+ if ( mnLines <= mnVisLines )
+ mnFirstLine = 0;
+ else
+ {
+ if ( mnFirstLine > (sal_uInt16)(mnLines-mnVisLines) )
+ mnFirstLine = (sal_uInt16)(mnLines-mnVisLines);
+ }
+
+ // calculate item size
+ const long nColSpace = (mnCols-1)*mnSpacing;
+ const long nLineSpace = ((mnVisLines-1)*mnSpacing)+nNoneSpace;
+ if ( mnUserItemWidth && !mnUserCols )
+ {
+ mnItemWidth = mnUserItemWidth;
+ if ( mnItemWidth > aWinSize.Width()-nScrBarWidth-nColSpace )
+ mnItemWidth = aWinSize.Width()-nScrBarWidth-nColSpace;
+ }
+ else
+ mnItemWidth = (aWinSize.Width()-nScrBarWidth-nColSpace) / mnCols;
+ if ( mnUserItemHeight && !mnUserVisLines )
+ {
+ mnItemHeight = mnUserItemHeight;
+ if ( mnItemHeight > nCalcHeight-nNoneSpace )
+ mnItemHeight = nCalcHeight-nNoneSpace;
+ }
+ else
+ {
+ nCalcHeight -= nLineSpace;
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list