[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - 3 commits - sfx2/inc sfx2/source

Rafael Dominguez venccsralph at gmail.com
Mon Apr 8 00:39:04 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/doc/doctempl.cxx                 |   18 ++++++++
 sfx2/source/doc/templatedlg.cxx              |    4 -
 7 files changed, 79 insertions(+), 12 deletions(-)

New commits:
commit 17a9ea9ede3ff48d7c98f7b69d4ef63b1dc57b7a
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Thu Mar 28 20:40:48 2013 -0430

    Dont reload template information after saving.
    
    Change-Id: Ib75bd4561581254f690e6dd4a2b83343c99d65af
    Reviewed-on: https://gerrit.libreoffice.org/3255
    Reviewed-by: Miklos Vajna <vmiklos at suse.cz>
    Tested-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/sfx2/inc/sfx2/doctempl.hxx b/sfx2/inc/sfx2/doctempl.hxx
index b9ca56d..add39df 100644
--- a/sfx2/inc/sfx2/doctempl.hxx
+++ b/sfx2/inc/sfx2/doctempl.hxx
@@ -96,6 +96,8 @@ public:
     sal_Bool            InsertDir(const String &rText, sal_uInt16 nRegion);
     sal_Bool            SetName(const String &rName, sal_uInt16 nRegion, sal_uInt16 nIdx);
 
+    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 f17f0f8..8490e37 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 c6d32af..012fdba 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 6678600..dd09be0 100644
--- a/sfx2/source/doc/doctempl.cxx
+++ b/sfx2/source/doc/doctempl.cxx
@@ -1098,6 +1098,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 94bbea6..9cf663c 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -1274,8 +1274,6 @@ void SfxTemplateManagerDlg::OnTemplateSaveAs()
                 }
             }
 
-            maView->reload();
-
             if (!aFolderList.isEmpty())
             {
             }
commit e2f27811c404f29691f8c1158f3102fc5b18ae90
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Thu Mar 28 16:23:36 2013 -0430

    Display empty folders in Template Manager.
    
    Change-Id: I1cab8c78dc6dc3f1969cd2e4e8bcda0b684a4caa
    Reviewed-on: https://gerrit.libreoffice.org/3254
    Reviewed-by: Miklos Vajna <vmiklos at suse.cz>
    Tested-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx
index 8fac81e..5c0b563 100644
--- a/sfx2/source/control/templateabstractview.cxx
+++ b/sfx2/source/control/templateabstractview.cxx
@@ -102,8 +102,6 @@ bool ViewFilter_Application::operator () (const ThumbnailViewItem *pItem)
                 }
             }
         }
-
-        return mApp != FILTER_APP_NONE ? nVisCount : true ;
     }
     return true;
 }
commit ec733eeb1156ad2d666a80721c44897dc225cd17
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: I785a351a5a936a42b56081a868c01d97e0a6105f
    Reviewed-on: https://gerrit.libreoffice.org/3253
    Reviewed-by: Miklos Vajna <vmiklos at suse.cz>
    Tested-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/sfx2/inc/sfx2/templateabstractview.hxx b/sfx2/inc/sfx2/templateabstractview.hxx
index a60fdb3..f14efad 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 05dd022..94bbea6 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -225,7 +225,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));


More information about the Libreoffice-commits mailing list