diff --git a/sfx2/inc/sfx2/templatefolderviewitem.hxx b/sfx2/inc/sfx2/templatefolderviewitem.hxx index b504a9d15883..16fb6463b341 100644 --- a/sfx2/inc/sfx2/templatefolderviewitem.hxx +++ b/sfx2/inc/sfx2/templatefolderviewitem.hxx @@ -23,7 +23,7 @@ struct TemplateFolderViewItem : public ThumbnailViewItem virtual ~TemplateFolderViewItem (); - virtual void calculateItemsPosition (); + virtual void calculateItemsPosition (sal_uInt32 nMaxTextLenght); const Point& getPrev2Pos () const { return maPrev2Pos; } diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index bbdeeb1c2af6..9c40f700fcd1 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -207,6 +207,8 @@ public: long GetItemHeight() const { return mnItemHeight; } + void setItemMaxTextLength (sal_uInt32 nLength); + void setItemDimensions (long ItemWidth, long ThumbnailHeight, long DisplayHeight, int itemPadding); diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx index 0d9fbd4be808..e771db3d13ac 100644 --- a/sfx2/inc/sfx2/thumbnailviewitem.hxx +++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx @@ -51,6 +51,7 @@ namespace drawinglayer { struct ThumbnailItemAttributes { + sal_uInt32 nMaxTextLenght; basegfx::BColor aFillColor; basegfx::BColor aHighlightColor; basegfx::B2DVector aFontSize; @@ -91,7 +92,7 @@ struct ThumbnailViewItem const Rectangle& getDrawArea () const { return maDrawArea; } - virtual void calculateItemsPosition (); + virtual void calculateItemsPosition (sal_uInt32 nMaxTextLenght); const Point& getTextPos () const { return maTextPos; } diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index fb1e5d665980..f874b720bdcd 100644 --- a/sfx2/source/control/templatefolderview.cxx +++ b/sfx2/source/control/templatefolderview.cxx @@ -277,6 +277,12 @@ void TemplateFolderView::Populate () { rtl::OUString aRegionName(mpDocTemplates->GetFullRegionName(i)); + if (aRegionName.getLength() > mpItemAttrs->nMaxTextLenght) + { + aRegionName = aRegionName.copy(0,mpItemAttrs->nMaxTextLenght-3); + aRegionName += "..."; + } + sal_uInt16 nEntries = mpDocTemplates->GetCount(i); if (nEntries) @@ -298,12 +304,19 @@ void TemplateFolderView::Populate () for (sal_uInt16 j = 0; j < nEntries; ++j) { + rtl::OUString aName = mpDocTemplates->GetName(i,j); rtl::OUString aURL = mpDocTemplates->GetPath(i,j); rtl::OUString aType = SvFileInformationManager::GetDescription(INetURLObject(aURL)); + if (aName.getLength() > mpItemAttrs->nMaxTextLenght) + { + aName = aName.copy(0,mpItemAttrs->nMaxTextLenght-3); + aName += "..."; + } + TemplateViewItem *pTemplateItem = new TemplateViewItem(*mpItemView,mpItemView); pTemplateItem->mnId = j+1; - pTemplateItem->maText = mpDocTemplates->GetName(i,j); + pTemplateItem->maText = aName; pTemplateItem->setPath(aURL); pTemplateItem->setFileType(aType); pTemplateItem->maPreview1 = lcl_fetchThumbnail(aURL,THUMBNAIL_MAX_WIDTH,THUMBNAIL_MAX_HEIGHT); diff --git a/sfx2/source/control/templatefolderviewitem.cxx b/sfx2/source/control/templatefolderviewitem.cxx index dd0d393f7ab1..7c5459b173e4 100644 --- a/sfx2/source/control/templatefolderviewitem.cxx +++ b/sfx2/source/control/templatefolderviewitem.cxx @@ -36,9 +36,9 @@ TemplateFolderViewItem::~TemplateFolderViewItem () delete maTemplates[i]; } -void TemplateFolderViewItem::calculateItemsPosition () +void TemplateFolderViewItem::calculateItemsPosition (sal_uInt32 nMaxTextLenght) { - ThumbnailViewItem::calculateItemsPosition(); + ThumbnailViewItem::calculateItemsPosition(nMaxTextLenght); } void TemplateFolderViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor, diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index a2a7626b9139..517fb835fe07 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -172,6 +172,7 @@ void ThumbnailView::ImplInitSettings( bool bFont, bool bForeground, bool bBackgr mpItemAttrs->aFillColor = maColor.getBColor(); mpItemAttrs->aHighlightColor = rStyleSettings.GetHighlightColor().getBColor(); mpItemAttrs->aFontAttr = getFontAttributeFromVclFont(mpItemAttrs->aFontSize,GetFont(),false,true); + mpItemAttrs->nMaxTextLenght = -1; } void ThumbnailView::ImplInitScrollBar() @@ -328,7 +329,7 @@ void ThumbnailView::CalculateItemPositions () pItem->show(true); pItem->setDrawArea(Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) )); - pItem->calculateItemsPosition(); + pItem->calculateItemsPosition(mpItemAttrs->nMaxTextLenght); if ( !((nCurCount+1) % mnCols) ) { @@ -530,7 +531,7 @@ IMPL_LINK( ThumbnailView,ImplScrollHdl, ScrollBar*, pScrollBar ) pItem->show(true); pItem->setDrawArea(Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) )); - pItem->calculateItemsPosition(); + pItem->calculateItemsPosition(mpItemAttrs->nMaxTextLenght); if ( !((i+1) % mnCols) ) { @@ -1085,6 +1086,11 @@ void ThumbnailView::SetLineCount( sal_uInt16 nNewLines ) } } +void ThumbnailView::setItemMaxTextLength(sal_uInt32 nLength) +{ + mpItemAttrs->nMaxTextLenght = nLength; +} + void ThumbnailView::setItemDimensions(long itemWidth, long thumbnailHeight, long displayHeight, int itemPadding) { mnItemWidth = itemWidth + 2*itemPadding; diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx index a23fcb203e17..dbbbcb79ac3c 100644 --- a/sfx2/source/control/thumbnailviewitem.cxx +++ b/sfx2/source/control/thumbnailviewitem.cxx @@ -116,7 +116,7 @@ void ThumbnailViewItem::setDrawArea (const Rectangle &area) maDrawArea = area; } -void ThumbnailViewItem::calculateItemsPosition () +void ThumbnailViewItem::calculateItemsPosition (sal_uInt32 nMaxTextLenght) { drawinglayer::primitive2d::TextLayouterDevice aTextDev; @@ -132,7 +132,7 @@ void ThumbnailViewItem::calculateItemsPosition () // 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,maText.getLength()))/2; + aPos.X() = maDrawArea.Left() + (aRectSize.Width() - aTextDev.getTextWidth(maText,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,maText.getLength(), + maText,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 89e638cecc14..e39f5ab65cfd 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -35,6 +35,7 @@ #define ITEM_MAX_HEIGHT 192 #define ITEM_PADDING 5 #define ITEM_SPACE 20 +#define ITEM_MAX_TEXT_LENGTH 20 #define THUMBNAIL_MAX_HEIGHT 128 #define INIT_FOLDER_COLS 3 @@ -149,6 +150,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent) maView->SetStyle(WB_TABSTOP | WB_VSCROLL); maView->SetColor(GetBackground().GetColor()); maView->SetSizePixel(aThumbSize); + maView->setItemMaxTextLength(ITEM_MAX_TEXT_LENGTH); maView->setItemDimensions(ITEM_MAX_WIDTH,THUMBNAIL_MAX_HEIGHT, ITEM_MAX_HEIGHT-THUMBNAIL_MAX_HEIGHT,