[Libreoffice-commits] core.git: 5 commits - sfx2/inc sfx2/source
Rafael Dominguez
venccsralph at gmail.com
Thu Mar 28 18:14:35 PDT 2013
sfx2/inc/sfx2/doctempl.hxx | 2
sfx2/inc/sfx2/templateabstractview.hxx | 5 +-
sfx2/inc/sfx2/templatelocalview.hxx | 2
sfx2/source/control/templateabstractview.cxx | 2
sfx2/source/control/templatelocalview.cxx | 58 ++++++++++++++++++++++++---
sfx2/source/control/templateviewitem.cxx | 3 -
sfx2/source/doc/doctempl.cxx | 18 ++++++++
sfx2/source/doc/templatedlg.cxx | 5 --
8 files changed, 80 insertions(+), 15 deletions(-)
New commits:
commit ba632715b0a2f610f4146e950898625481cb8d9c
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Thu Mar 28 20:40:48 2013 -0430
Dont reload template information after saving.
Change-Id: Id4170e500d92dc912087eac137f38d243c3c1372
diff --git a/sfx2/inc/sfx2/doctempl.hxx b/sfx2/inc/sfx2/doctempl.hxx
index ee91fd4..a84ac11 100644
--- a/sfx2/inc/sfx2/doctempl.hxx
+++ b/sfx2/inc/sfx2/doctempl.hxx
@@ -92,6 +92,8 @@ public:
sal_Bool Delete(sal_uInt16 nRegion, sal_uInt16 nIdx);
sal_Bool InsertDir(const String &rText, sal_uInt16 nRegion);
+ sal_Bool InsertTemplate (sal_uInt16 nSourceRegion, sal_uInt16 nIdx, const OUString &rName, const OUString &rPath);
+
/** Change the name of an entry or a directory
\param rName
diff --git a/sfx2/inc/sfx2/templatelocalview.hxx b/sfx2/inc/sfx2/templatelocalview.hxx
index b0d86ae..2837eca 100644
--- a/sfx2/inc/sfx2/templatelocalview.hxx
+++ b/sfx2/inc/sfx2/templatelocalview.hxx
@@ -81,7 +81,7 @@ public:
com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rModel,
const OUString &rName);
- bool saveTemplateAs (const TemplateContainerItem *pDstItem,
+ bool saveTemplateAs (TemplateContainerItem *pDstItem,
com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rModel,
const OUString &rName);
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index b6fcc50..90f928b 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -695,21 +695,50 @@ bool TemplateLocalView::saveTemplateAs (sal_uInt16 nItemId,
com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rModel,
const OUString &rName)
{
- bool bRet = false;
for (size_t i = 0, n = maRegions.size(); i < n; ++i)
{
if (maRegions[i]->mnId == nItemId)
{
- bRet = saveTemplateAs((const TemplateContainerItem*)maRegions[i],rModel,rName);
- break;
+ uno::Reference< frame::XStorable > xStorable(rModel, uno::UNO_QUERY_THROW );
+
+ uno::Reference< frame::XDocumentTemplates > xTemplates(
+ frame::DocumentTemplates::create(comphelper::getProcessComponentContext()) );
+
+ if (!xTemplates->storeTemplate(mpDocTemplates->GetRegionName(maRegions[i]->mnRegionId),rName, xStorable ))
+ return false;
+
+ sal_uInt16 nDocId = maRegions[i]->maTemplates.size();
+
+ OUString aURL = mpDocTemplates->GetTemplateTargetURLFromComponent(mpDocTemplates->GetRegionName(maRegions[i]->mnRegionId),rName);
+
+ if(!mpDocTemplates->InsertTemplate(maRegions[i]->mnRegionId,nDocId,rName,aURL))
+ return false;
+
+
+ TemplateItemProperties aTemplate;
+ aTemplate.aIsFolder = false;
+ aTemplate.nId = getNextItemId();
+ aTemplate.nDocId = nDocId;
+ aTemplate.nRegionId = maRegions[i]->mnRegionId;
+ aTemplate.aName = rName;
+ aTemplate.aThumbnail = TemplateAbstractView::fetchThumbnail(aURL,
+ TEMPLATE_THUMBNAIL_MAX_WIDTH,
+ TEMPLATE_THUMBNAIL_MAX_HEIGHT);
+ aTemplate.aPath = aURL;
+
+ maRegions[i]->maTemplates.push_back(aTemplate);
+
+ insertItem(aTemplate);
+
+ return true;
}
}
- return bRet;
+ return false;
}
-bool TemplateLocalView::saveTemplateAs(const TemplateContainerItem *pDstItem,
+bool TemplateLocalView::saveTemplateAs(TemplateContainerItem *pDstItem,
com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rModel,
const OUString &rName)
{
@@ -721,6 +750,25 @@ bool TemplateLocalView::saveTemplateAs(const TemplateContainerItem *pDstItem,
if (!xTemplates->storeTemplate(mpDocTemplates->GetRegionName(pDstItem->mnRegionId),rName, xStorable ))
return false;
+ sal_uInt16 nDocId = pDstItem->maTemplates.size();
+ OUString aURL = mpDocTemplates->GetTemplateTargetURLFromComponent(mpDocTemplates->GetRegionName(pDstItem->mnRegionId),rName);
+
+ if(!mpDocTemplates->InsertTemplate(pDstItem->mnRegionId,nDocId,rName,aURL))
+ return false;
+
+ TemplateItemProperties aTemplate;
+ aTemplate.aIsFolder = false;
+ aTemplate.nId = pDstItem->maTemplates.empty() ? 1 : pDstItem->maTemplates.back().nId+1;
+ aTemplate.nDocId = nDocId;
+ aTemplate.nRegionId = pDstItem->mnRegionId;
+ aTemplate.aName = rName;
+ aTemplate.aThumbnail = TemplateAbstractView::fetchThumbnail(aURL,
+ TEMPLATE_THUMBNAIL_MAX_WIDTH,
+ TEMPLATE_THUMBNAIL_MAX_HEIGHT);
+ aTemplate.aPath = aURL;
+
+ pDstItem->maTemplates.push_back(aTemplate);
+
return true;
}
diff --git a/sfx2/source/doc/doctempl.cxx b/sfx2/source/doc/doctempl.cxx
index 8faa60a..5132e70 100644
--- a/sfx2/source/doc/doctempl.cxx
+++ b/sfx2/source/doc/doctempl.cxx
@@ -1037,6 +1037,24 @@ sal_Bool SfxDocumentTemplates::InsertDir
return sal_False;
}
+sal_Bool SfxDocumentTemplates::InsertTemplate(sal_uInt16 nSourceRegion, sal_uInt16 nIdx, const OUString &rName, const OUString &rPath)
+{
+ DocTemplLocker_Impl aLocker( *pImp );
+
+ if ( ! pImp->Construct() )
+ return sal_False;
+
+ RegionData_Impl *pRegion = pImp->GetRegion( nSourceRegion );
+
+ if ( !pRegion )
+ return sal_False;
+
+ size_t pos = nIdx;
+ pRegion->AddEntry( rName, rPath, &pos );
+
+ return sal_True;
+}
+
sal_Bool SfxDocumentTemplates::SetName( const OUString& rName, sal_uInt16 nRegion, sal_uInt16 nIdx )
{
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 5f13254..f9e1d55 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -1286,8 +1286,6 @@ void SfxTemplateManagerDlg::OnTemplateSaveAs()
}
}
- maView->reload();
-
if (!aFolderList.isEmpty())
{
}
commit 0d3906aa95e06f96efcf698d8926be0aae267b04
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Thu Mar 28 16:23:36 2013 -0430
Display empty folders in Template Manager.
Change-Id: I5924fabd911d1b9bfb70cd7611fd1fe7a1a44dce
diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx
index 8287cad..aae6328 100644
--- a/sfx2/source/control/templateabstractview.cxx
+++ b/sfx2/source/control/templateabstractview.cxx
@@ -103,8 +103,6 @@ bool ViewFilter_Application::operator () (const ThumbnailViewItem *pItem)
}
}
}
-
- return mApp != FILTER_APP_NONE ? nVisCount : true ;
}
return true;
}
commit cf8bd2d0e991329accbff4dabd5661828cd55e48
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Thu Mar 28 15:22:12 2013 -0430
Make template thumbnail sizes appropiate to the content in them.
Change-Id: Iaf238413b95ed3d09f58d7adb49da13da9d71887
diff --git a/sfx2/inc/sfx2/templateabstractview.hxx b/sfx2/inc/sfx2/templateabstractview.hxx
index c7ae46a..71ce703 100644
--- a/sfx2/inc/sfx2/templateabstractview.hxx
+++ b/sfx2/inc/sfx2/templateabstractview.hxx
@@ -17,11 +17,14 @@
//template thumbnail item defines
#define TEMPLATE_ITEM_MAX_WIDTH 160
-#define TEMPLATE_ITEM_MAX_HEIGHT 160
+#define TEMPLATE_ITEM_MAX_HEIGHT 140
#define TEMPLATE_ITEM_PADDING 5
#define TEMPLATE_ITEM_MAX_TEXT_LENGTH 20
#define TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT 88
+//template thumbnail height with a subtitle
+#define TEMPLATE_ITEM_MAX_HEIGHT_SUB 160
+
//template thumbnail image defines
#define TEMPLATE_THUMBNAIL_MAX_HEIGHT TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT - 2*TEMPLATE_ITEM_PADDING
#define TEMPLATE_THUMBNAIL_MAX_WIDTH TEMPLATE_ITEM_MAX_WIDTH - 2*TEMPLATE_ITEM_PADDING
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 6746e31..5f13254 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -226,7 +226,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
mpSearchView->setItemMaxTextLength(TEMPLATE_ITEM_MAX_TEXT_LENGTH);
mpSearchView->setItemDimensions(TEMPLATE_ITEM_MAX_WIDTH,TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT,
- TEMPLATE_ITEM_MAX_HEIGHT-TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT,
+ TEMPLATE_ITEM_MAX_HEIGHT_SUB-TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT,
TEMPLATE_ITEM_PADDING);
mpSearchView->setItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVItemStateHdl));
commit db0e80438f53942628dab8d8ef01c4982b9cf650
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Thu Mar 28 14:50:24 2013 -0430
Calculate template thumbnail subtitle position to fit drawing area.
Change-Id: I8dc7d5dd055c9ef722279754381208d684686934
diff --git a/sfx2/source/control/templateviewitem.cxx b/sfx2/source/control/templateviewitem.cxx
index 94ce4d3..d68268b 100644
--- a/sfx2/source/control/templateviewitem.cxx
+++ b/sfx2/source/control/templateviewitem.cxx
@@ -55,9 +55,6 @@ void TemplateViewItem::calculateItemsPosition(const long nThumbnailHeight, const
long nSpace = (nDisplayHeight + nPadding - 2*aTextDev.getTextHeight()) / 3;
- // Set title position
- maTextPos.setY(maDrawArea.getY() + nThumbnailHeight + nPadding + nSpace + aTextDev.getTextHeight());
-
// Set subtitle position
maSubTitlePos.setY(maTextPos.getY() + nSpace + aTextDev.getTextHeight());
maSubTitlePos.setX(maDrawArea.Left() +
commit 2c8ea7d9dff35e64701883b089e30715ed7b56b5
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Thu Mar 28 14:49:49 2013 -0430
Deselect items when searching for templates to reset toolbars.
Change-Id: Ifacbc257abcc84284deb1723d30e74d45adca192
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 0273f55..6746e31 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -682,6 +682,7 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, SearchUpdateHdl)
// if the search view is hidden, hide the folder view and display search one
if (!mpSearchView->IsVisible())
{
+ mpCurView->deselectItems();
mpSearchView->Show();
mpCurView->Hide();
}
More information about the Libreoffice-commits
mailing list