summaryrefslogtreecommitdiff
path: root/sfx2/source/control
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source/control')
-rw-r--r--sfx2/source/control/templateabstractview.cxx26
-rw-r--r--sfx2/source/control/templatelocalview.cxx36
2 files changed, 62 insertions, 0 deletions
diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx
index eb725ba4c1fb..8287cad62388 100644
--- a/sfx2/source/control/templateabstractview.cxx
+++ b/sfx2/source/control/templateabstractview.cxx
@@ -144,6 +144,32 @@ TemplateAbstractView::~TemplateAbstractView ()
{
}
+void TemplateAbstractView::insertItem(const TemplateItemProperties &rTemplate)
+{
+ const TemplateItemProperties *pCur = &rTemplate;
+
+ TemplateViewItem *pChild = new TemplateViewItem(*this);
+ pChild->mnId = pCur->nId;
+ pChild->mnDocId = pCur->nDocId;
+ pChild->mnRegionId = pCur->nRegionId;
+ pChild->maTitle = pCur->aName;
+ pChild->setPath(pCur->aPath);
+ pChild->maPreview1 = pCur->aThumbnail;
+
+ if ( pCur->aThumbnail.IsEmpty() )
+ {
+ // Use the default thumbnail if we have nothing else
+ pChild->maPreview1 = TemplateAbstractView::getDefaultThumbnail(pCur->aPath);
+ }
+
+ pChild->setSelectClickHdl(LINK(this,ThumbnailView,OnItemSelected));
+
+ mItemList.push_back(pChild);
+
+ CalculateItemPositions();
+ Invalidate();
+}
+
void TemplateAbstractView::insertItems(const std::vector<TemplateItemProperties> &rTemplates)
{
std::vector<ThumbnailViewItem*> aItems(rTemplates.size());
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index a73fa23ce3b9..b6fcc50b44d0 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -590,6 +590,42 @@ bool TemplateLocalView::copyFrom(const sal_uInt16 nRegionItemId, const BitmapEx
return false;
}
+bool TemplateLocalView::copyFrom(const OUString &rPath)
+{
+ assert(mnCurRegionId);
+
+ TemplateContainerItem *pRegItem = maRegions[mnCurRegionId-1];
+
+ sal_uInt16 nId = getNextItemId();
+ sal_uInt16 nDocId = 0;
+ sal_uInt16 nRegionId = pRegItem->mnRegionId;
+
+ String aPath(rPath);
+
+ if (!pRegItem->maTemplates.empty())
+ nDocId = (pRegItem->maTemplates.back()).nDocId+1;
+
+ if (!mpDocTemplates->CopyFrom(nRegionId,nDocId,aPath))
+ return false;
+
+ TemplateItemProperties aTemplate;
+ aTemplate.aIsFolder = false;
+ aTemplate.nId = nId;
+ aTemplate.nDocId = nDocId;
+ aTemplate.nRegionId = nRegionId;
+ aTemplate.aName = aPath;
+ aTemplate.aThumbnail = TemplateAbstractView::fetchThumbnail(rPath,
+ TEMPLATE_THUMBNAIL_MAX_WIDTH,
+ TEMPLATE_THUMBNAIL_MAX_HEIGHT);
+ aTemplate.aPath = rPath;
+
+ pRegItem->maTemplates.push_back(aTemplate);
+
+ insertItem(aTemplate);
+
+ return true;
+}
+
bool TemplateLocalView::copyFrom (TemplateContainerItem *pItem, const OUString &rPath)
{
sal_uInt16 nId = 1;