[Libreoffice-commits] .: Branch 'feature/template-dialog' - 16 commits - sfx2/inc sfx2/Library_sfx.mk sfx2/source

Rafael Dominguez rdominguez at kemper.freedesktop.org
Thu Jun 21 14:09:31 PDT 2012


 sfx2/Library_sfx.mk                            |    1 
 sfx2/inc/sfx2/templatefolderview.hxx           |   30 +---
 sfx2/inc/sfx2/templatefolderviewitem.hxx       |    3 
 sfx2/inc/sfx2/templateproperties.hxx           |   15 ++
 sfx2/inc/sfx2/templateview.hxx                 |    3 
 sfx2/inc/sfx2/templateviewitem.hxx             |   44 +++++++
 sfx2/source/control/templatefolderview.cxx     |  157 ++++++++++++++++++++++---
 sfx2/source/control/templatefolderviewitem.cxx |    3 
 sfx2/source/control/templateview.cxx           |   22 +++
 sfx2/source/control/templateviewitem.cxx       |   23 +++
 sfx2/source/control/thumbnailview.cxx          |   53 --------
 sfx2/source/doc/templatedlg.cxx                |   13 ++
 12 files changed, 282 insertions(+), 85 deletions(-)

New commits:
commit 7e5d09a26fcb69681c6251b1c1a10066f010e5e4
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Thu Jun 21 16:39:16 2012 -0430

    Apply overlay filter to folder view when closing overlay.
    
    Change-Id: If1e8a9791e34d7217fc26791cd19373b84182292

diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx
index bc2a176..340e179 100644
--- a/sfx2/source/control/templatefolderview.cxx
+++ b/sfx2/source/control/templatefolderview.cxx
@@ -312,6 +312,8 @@ void TemplateFolderView::showOverlay (bool bVisible)
         // Check if the folder view needs to be filtered
         if (mbFilteredResults)
         {
+            filterItems(FolderFilter_Application(mpDocTemplates,meFilterOption));
+
             mbFilteredResults = false;
             meFilterOption = FILTER_APP_NONE;
         }
commit 6e8eca4bf6a8b98689146ce435b184257f47b10d
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Thu Jun 21 16:27:03 2012 -0430

    Match item by position correctly by inspecting items assigned draw area.
    
    Change-Id: I6ec9544f4924059267458ca2e3536b13dac698d5

diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index a25fb38..6d04248 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -462,23 +462,10 @@ size_t ThumbnailView::ImplGetItem( const Point& rPos, bool bMove ) const
 
     if ( maItemListRect.IsInside( rPos ) )
     {
-        const int xc = rPos.X()-maItemListRect.Left();
-        const int yc = rPos.Y()-maItemListRect.Top();
-        // The point is inside the area of item list,
-        // let's find the containing item.
-        const int col = xc/(mnItemWidth+mnSpacing);
-        const int x = xc%(mnItemWidth+mnSpacing);
-        const int row = yc/(mnItemHeight+mnSpacing);
-        const int y = yc%(mnItemHeight+mnSpacing);
-
-        if (x<mnItemWidth && y<mnItemHeight)
+        for (size_t i = 0; i < mItemList.size(); ++i)
         {
-            // the point is inside item rect and not inside spacing
-            const size_t item = (mnFirstLine+row)*mnCols+col;
-            if (item < mItemList.size())
-            {
-                return item;
-            }
+            if (mItemList[i]->isVisible() && mItemList[i]->getDrawArea().IsInside(rPos))
+                return i;
         }
 
         // return the previously selected item if spacing is set and
commit 9112d20ae31fbefcd49dad284b85a9627b3021b2
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Thu Jun 21 15:19:08 2012 -0430

    Create filter to template folders.
    
    - Update their thumbnails depending on the filter.
    - Dont display folder if theres no template of that type available.
    
    Change-Id: Ifba889ea3fdbb132d93fead304e2a13007a40371

diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx
index 1247ab2..bc2a176 100644
--- a/sfx2/source/control/templatefolderview.cxx
+++ b/sfx2/source/control/templatefolderview.cxx
@@ -183,6 +183,54 @@ private:
     SfxDocumentTemplates *mpDocTemplates;
 };
 
+class FolderFilter_Application
+{
+public:
+
+    FolderFilter_Application ( SfxDocumentTemplates *pDocTemplates, FILTER_APPLICATION eApp)
+        : meApp(eApp)
+    {
+        maFilterFunc = ViewFilter_Application(pDocTemplates,eApp);
+    }
+
+    bool operator () (const ThumbnailViewItem *pItem)
+    {
+        TemplateFolderViewItem *pFolderItem = (TemplateFolderViewItem*)pItem;
+
+        std::vector<TemplateViewItem*> &rTemplates = pFolderItem->maTemplates;
+
+        size_t nVisCount = 0;
+        ThumbnailViewItem *pTemplateItem;
+
+        // Clear thumbnails
+        pFolderItem->maPreview1.Clear();
+        pFolderItem->maPreview2.Clear();
+
+        for (size_t i = 0, n = rTemplates.size(); i < n; ++i)
+        {
+            pTemplateItem = rTemplates[i];
+
+            if (maFilterFunc(pTemplateItem))
+            {
+                ++nVisCount;
+
+                // Update the thumbnails
+                if (nVisCount == 1)
+                    pFolderItem->maPreview1 = pTemplateItem->maPreview1;
+                else if (nVisCount == 2)
+                    pFolderItem->maPreview2 = pTemplateItem->maPreview1;
+            }
+        }
+
+        return nVisCount;
+    }
+
+private:
+
+    FILTER_APPLICATION meApp;
+    boost::function<bool (const ThumbnailViewItem*)> maFilterFunc;
+};
+
 TemplateFolderView::TemplateFolderView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren)
     : ThumbnailView(pParent,rResId,bDisableTransientChildren),
       mbFilteredResults(false),
@@ -285,6 +333,7 @@ void TemplateFolderView::filterTemplatesByApp (const FILTER_APPLICATION &eApp)
     }
     else
     {
+        filterItems(FolderFilter_Application(mpDocTemplates,eApp));
     }
 }
 
commit f83e9cf9c76d2e6376d8fa2017f7e2a042a755f9
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Thu Jun 21 14:15:48 2012 -0430

    Apply current folder filter to overlay when you open it.
    
    Change-Id: I72e91d05360f283277dd7e48eec1296516affcb4

diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx
index 4524495..1247ab2 100644
--- a/sfx2/source/control/templatefolderview.cxx
+++ b/sfx2/source/control/templatefolderview.cxx
@@ -276,10 +276,11 @@ void TemplateFolderView::showOverlay (bool bVisible)
 
 void TemplateFolderView::filterTemplatesByApp (const FILTER_APPLICATION &eApp)
 {
+    meFilterOption = eApp;
+
     if (mpItemView->IsVisible())
     {
         mbFilteredResults = true;
-        meFilterOption = eApp;
         mpItemView->filterItems(ViewFilter_Application(mpDocTemplates,eApp));
     }
     else
@@ -309,6 +310,9 @@ void TemplateFolderView::OnItemDblClicked (ThumbnailViewItem *pRegionItem)
     if (mbSelectionMode)
         mpItemView->setSelectionMode(true);
 
+    if (meFilterOption != FILTER_APP_NONE)
+        mpItemView->filterItems(ViewFilter_Application(mpDocTemplates,meFilterOption));
+
     mpItemView->Show();
 }
 
commit d4dd76938cdc6f08ab86ba2462aae2e6fe9fbaea
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Thu Jun 21 14:08:58 2012 -0430

    Add a filter option to display all items.
    
    Change-Id: I32284a50ba5566ef02f2b78c6fcb7bea41bac0d5

diff --git a/sfx2/inc/sfx2/templatefolderview.hxx b/sfx2/inc/sfx2/templatefolderview.hxx
index 0de22e0..1203883 100644
--- a/sfx2/inc/sfx2/templatefolderview.hxx
+++ b/sfx2/inc/sfx2/templatefolderview.hxx
@@ -17,6 +17,7 @@ class TemplateView;
 
 enum FILTER_APPLICATION
 {
+    FILTER_APP_NONE,
     FILTER_APP_WRITER,
     FILTER_APP_CALC,
     FILTER_APP_IMPRESS,
diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx
index 1a0b85d..4524495 100644
--- a/sfx2/source/control/templatefolderview.cxx
+++ b/sfx2/source/control/templatefolderview.cxx
@@ -186,6 +186,7 @@ private:
 TemplateFolderView::TemplateFolderView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren)
     : ThumbnailView(pParent,rResId,bDisableTransientChildren),
       mbFilteredResults(false),
+      meFilterOption(FILTER_APP_NONE),
       mpDocTemplates(new SfxDocumentTemplates),
       mpItemView(new TemplateView(this,mpDocTemplates))
 {
@@ -263,8 +264,8 @@ void TemplateFolderView::showOverlay (bool bVisible)
         // Check if the folder view needs to be filtered
         if (mbFilteredResults)
         {
-
             mbFilteredResults = false;
+            meFilterOption = FILTER_APP_NONE;
         }
 
         mpItemView->Clear();
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index b08257c..1582084 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -54,6 +54,7 @@ SfxTemplateManagerDlg::~SfxTemplateManagerDlg ()
 
 IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewAllHdl)
 {
+    maView->filterTemplatesByApp(FILTER_APP_NONE);
     return 0;
 }
 
commit cfec7637cb6952d6f97e0e12b516bf5d17c93d72
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Thu Jun 21 14:05:59 2012 -0430

    Filter items in template folder view by a selected application.
    
    Change-Id: If6e1f8c6d3973ca5b07a3b3027b43261eff30dcc

diff --git a/sfx2/inc/sfx2/templatefolderview.hxx b/sfx2/inc/sfx2/templatefolderview.hxx
index b615eb4..0de22e0 100644
--- a/sfx2/inc/sfx2/templatefolderview.hxx
+++ b/sfx2/inc/sfx2/templatefolderview.hxx
@@ -39,6 +39,8 @@ public:
 
     void showOverlay (bool bVisible);
 
+    void filterTemplatesByApp (const FILTER_APPLICATION &eApp);
+
 private:
 
     virtual void OnSelectionMode (bool bMode);
@@ -47,6 +49,8 @@ private:
 
 private:
 
+    bool mbFilteredResults;     // Flag keep track if overlay has been filtered so folders can get filtered too afterwards
+    FILTER_APPLICATION meFilterOption;
     SfxDocumentTemplates *mpDocTemplates;
     TemplateView *mpItemView;
 };
diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx
index 735b453..1a0b85d 100644
--- a/sfx2/source/control/templatefolderview.cxx
+++ b/sfx2/source/control/templatefolderview.cxx
@@ -185,6 +185,7 @@ private:
 
 TemplateFolderView::TemplateFolderView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren)
     : ThumbnailView(pParent,rResId,bDisableTransientChildren),
+      mbFilteredResults(false),
       mpDocTemplates(new SfxDocumentTemplates),
       mpItemView(new TemplateView(this,mpDocTemplates))
 {
@@ -259,12 +260,32 @@ void TemplateFolderView::showOverlay (bool bVisible)
     // Clear items is the overlay is closed.
     if (!bVisible)
     {
+        // Check if the folder view needs to be filtered
+        if (mbFilteredResults)
+        {
+
+            mbFilteredResults = false;
+        }
+
         mpItemView->Clear();
 
         setSelectionMode(mbSelectionMode);
     }
 }
 
+void TemplateFolderView::filterTemplatesByApp (const FILTER_APPLICATION &eApp)
+{
+    if (mpItemView->IsVisible())
+    {
+        mbFilteredResults = true;
+        meFilterOption = eApp;
+        mpItemView->filterItems(ViewFilter_Application(mpDocTemplates,eApp));
+    }
+    else
+    {
+    }
+}
+
 void TemplateFolderView::OnSelectionMode (bool bMode)
 {
     if (mpItemView->IsVisible())
commit 1dd694616d646d773e0e727b428cb7f3aa756bcb
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Thu Jun 21 13:47:43 2012 -0430

    Implement,connect missing button handlers and filter results by app.
    
    Change-Id: Ie79ae3ae10c080e8947dd549723c8ad859f0ce39

diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 6fab400..b08257c 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -36,6 +36,9 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
 
     aButtonAll.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewAllHdl));
     aButtonDocs.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewDocsHdl));
+    aButtonPresents.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewPresentsHdl));
+    aButtonSheets.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewSheetsHdl));
+    aButtonDraws.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewDrawsHdl));
     maButtonSelMode.SetClickHdl(LINK(this,SfxTemplateManagerDlg,OnClickSelectionMode));
 
     maView->Populate();
@@ -56,16 +59,25 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewAllHdl)
 
 IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewDocsHdl)
 {
+    maView->filterTemplatesByApp(FILTER_APP_WRITER);
     return 0;
 }
 
 IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewPresentsHdl)
 {
+    maView->filterTemplatesByApp(FILTER_APP_IMPRESS);
+    return 0;
+}
+
+IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewSheetsHdl)
+{
+    maView->filterTemplatesByApp(FILTER_APP_CALC);
     return 0;
 }
 
 IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewDrawsHdl)
 {
+    maView->filterTemplatesByApp(FILTER_APP_DRAW);
     return 0;
 }
 
commit c8e143206c611c62e9c32afe03e5cb93dd3e7cf2
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Thu Jun 21 11:23:57 2012 -0430

    Dont expose ViewFilter_Application class.
    
    Change-Id: I27f1df59f5e70657306bc74d498fa98342c96490

diff --git a/sfx2/inc/sfx2/templatefolderview.hxx b/sfx2/inc/sfx2/templatefolderview.hxx
index d6ae0a1..b615eb4 100644
--- a/sfx2/inc/sfx2/templatefolderview.hxx
+++ b/sfx2/inc/sfx2/templatefolderview.hxx
@@ -23,23 +23,6 @@ enum FILTER_APPLICATION
     FILTER_APP_DRAW
 };
 
-// Display template items depending on the generator application
-class ViewFilter_Application
-{
-public:
-
-
-
-    ViewFilter_Application (SfxDocumentTemplates *pDocTemplates, FILTER_APPLICATION App);
-
-    bool operator () (const ThumbnailViewItem *pItem);
-
-private:
-
-    FILTER_APPLICATION mApp;
-    SfxDocumentTemplates *mpDocTemplates;
-};
-
 class TemplateFolderView : public ThumbnailView
 {
 public:
diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx
index d4a187b..735b453 100644
--- a/sfx2/source/control/templatefolderview.cxx
+++ b/sfx2/source/control/templatefolderview.cxx
@@ -140,39 +140,48 @@ BitmapEx lcl_fetchThumbnail (const rtl::OUString &msURL, int width, int height)
     return aThumbnail;
 }
 
-ViewFilter_Application::ViewFilter_Application (SfxDocumentTemplates *pDocTemplates,
-                                                FILTER_APPLICATION App)
-    : mApp(App), mpDocTemplates(pDocTemplates)
+// Display template items depending on the generator application
+class ViewFilter_Application
 {
-}
+public:
 
-bool ViewFilter_Application::operator () (const ThumbnailViewItem *pItem)
-{
-    const TemplateViewItem *pTempItem = static_cast<const TemplateViewItem*>(pItem);
+    ViewFilter_Application (SfxDocumentTemplates *pDocTemplates, FILTER_APPLICATION App)
+        : mApp(App), mpDocTemplates(pDocTemplates)
+    {}
 
-    if (mApp == FILTER_APP_WRITER)
-    {
-        return pTempItem->getFileType() == "OpenDocument Text" ||
-                pTempItem->getFileType() == "OpenDocument Text Template";
-    }
-    else if (mApp == FILTER_APP_CALC)
-    {
-        return pTempItem->getFileType() == "OpenDocument Spreadsheet" ||
-                pTempItem->getFileType() == "OpenDocument Spreadsheet Template";
-    }
-    else if (mApp == FILTER_APP_IMPRESS)
-    {
-        return pTempItem->getFileType() == "OpenDocument Presentation" ||
-                pTempItem->getFileType() == "OpenDocument Presentation Template";
-    }
-    else if (mApp == FILTER_APP_DRAW)
+    bool operator () (const ThumbnailViewItem *pItem)
     {
-        return pTempItem->getFileType() == "OpenDocument Drawing" ||
-                pTempItem->getFileType() == "OpenDocument Drawing Template";
+        const TemplateViewItem *pTempItem = static_cast<const TemplateViewItem*>(pItem);
+
+        if (mApp == FILTER_APP_WRITER)
+        {
+            return pTempItem->getFileType() == "OpenDocument Text" ||
+                    pTempItem->getFileType() == "OpenDocument Text Template";
+        }
+        else if (mApp == FILTER_APP_CALC)
+        {
+            return pTempItem->getFileType() == "OpenDocument Spreadsheet" ||
+                    pTempItem->getFileType() == "OpenDocument Spreadsheet Template";
+        }
+        else if (mApp == FILTER_APP_IMPRESS)
+        {
+            return pTempItem->getFileType() == "OpenDocument Presentation" ||
+                    pTempItem->getFileType() == "OpenDocument Presentation Template";
+        }
+        else if (mApp == FILTER_APP_DRAW)
+        {
+            return pTempItem->getFileType() == "OpenDocument Drawing" ||
+                    pTempItem->getFileType() == "OpenDocument Drawing Template";
+        }
+
+        return true;
     }
 
-    return true;
-}
+private:
+
+    FILTER_APPLICATION mApp;
+    SfxDocumentTemplates *mpDocTemplates;
+};
 
 TemplateFolderView::TemplateFolderView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren)
     : ThumbnailView(pParent,rResId,bDisableTransientChildren),
commit 0805a180b96e548045f6fd28713d80874f6a6d92
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Thu Jun 21 11:21:58 2012 -0430

    Separate application filter enum from ViewFilter_Application class.
    
    Change-Id: I3619f6355e9ca6aabc7ebde546ab92196ef57a4e

diff --git a/sfx2/inc/sfx2/templatefolderview.hxx b/sfx2/inc/sfx2/templatefolderview.hxx
index d75d679..d6ae0a1 100644
--- a/sfx2/inc/sfx2/templatefolderview.hxx
+++ b/sfx2/inc/sfx2/templatefolderview.hxx
@@ -15,26 +15,28 @@
 class SfxDocumentTemplates;
 class TemplateView;
 
+enum FILTER_APPLICATION
+{
+    FILTER_APP_WRITER,
+    FILTER_APP_CALC,
+    FILTER_APP_IMPRESS,
+    FILTER_APP_DRAW
+};
+
 // Display template items depending on the generator application
 class ViewFilter_Application
 {
 public:
 
-    enum APP_GENERATOR
-    {
-        APP_WRITER,
-        APP_CALC,
-        APP_IMPRESS,
-        APP_DRAW
-    };
 
-    ViewFilter_Application (SfxDocumentTemplates *pDocTemplates, APP_GENERATOR App);
+
+    ViewFilter_Application (SfxDocumentTemplates *pDocTemplates, FILTER_APPLICATION App);
 
     bool operator () (const ThumbnailViewItem *pItem);
 
 private:
 
-    APP_GENERATOR mApp;
+    FILTER_APPLICATION mApp;
     SfxDocumentTemplates *mpDocTemplates;
 };
 
diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx
index 8abe747..d4a187b 100644
--- a/sfx2/source/control/templatefolderview.cxx
+++ b/sfx2/source/control/templatefolderview.cxx
@@ -141,7 +141,7 @@ BitmapEx lcl_fetchThumbnail (const rtl::OUString &msURL, int width, int height)
 }
 
 ViewFilter_Application::ViewFilter_Application (SfxDocumentTemplates *pDocTemplates,
-                                                ViewFilter_Application::APP_GENERATOR App)
+                                                FILTER_APPLICATION App)
     : mApp(App), mpDocTemplates(pDocTemplates)
 {
 }
@@ -150,22 +150,22 @@ bool ViewFilter_Application::operator () (const ThumbnailViewItem *pItem)
 {
     const TemplateViewItem *pTempItem = static_cast<const TemplateViewItem*>(pItem);
 
-    if (mApp == APP_WRITER)
+    if (mApp == FILTER_APP_WRITER)
     {
         return pTempItem->getFileType() == "OpenDocument Text" ||
                 pTempItem->getFileType() == "OpenDocument Text Template";
     }
-    else if (mApp == APP_CALC)
+    else if (mApp == FILTER_APP_CALC)
     {
         return pTempItem->getFileType() == "OpenDocument Spreadsheet" ||
                 pTempItem->getFileType() == "OpenDocument Spreadsheet Template";
     }
-    else if (mApp == APP_IMPRESS)
+    else if (mApp == FILTER_APP_IMPRESS)
     {
         return pTempItem->getFileType() == "OpenDocument Presentation" ||
                 pTempItem->getFileType() == "OpenDocument Presentation Template";
     }
-    else if (mApp == APP_DRAW)
+    else if (mApp == FILTER_APP_DRAW)
     {
         return pTempItem->getFileType() == "OpenDocument Drawing" ||
                 pTempItem->getFileType() == "OpenDocument Drawing Template";
commit 982635df51fc4b927c5cbe9dfe9f4c7bbbb57e64
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Thu Jun 21 10:19:28 2012 -0430

    Fix selection mode for folder view when overlay is open.
    
    Change-Id: Ia594cc15c5abc4d30272a77f8a10b2cd1fe35137

diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx
index 00f9e8f..8abe747 100644
--- a/sfx2/source/control/templatefolderview.cxx
+++ b/sfx2/source/control/templatefolderview.cxx
@@ -249,17 +249,19 @@ void TemplateFolderView::showOverlay (bool bVisible)
 
     // Clear items is the overlay is closed.
     if (!bVisible)
+    {
         mpItemView->Clear();
+
+        setSelectionMode(mbSelectionMode);
+    }
 }
 
 void TemplateFolderView::OnSelectionMode (bool bMode)
 {
     if (mpItemView->IsVisible())
     {
+        mbSelectionMode = bMode;
         mpItemView->setSelectionMode(bMode);
-
-        for (size_t i = 0, n = mItemList.size(); i < n; ++i)
-            mItemList[i]->setSelectionMode(bMode);
     }
     else
         ThumbnailView::OnSelectionMode(bMode);
commit 7d7dc568ff4ab88e2b1760f42b2f4614c0adae66
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Thu Jun 21 10:09:13 2012 -0430

    Add ViewFilter_Application logic
    
    - Filter TemplateViewItems by their associated file type.
    
    Change-Id: Ie9aea8c1fc4a62dae5004c2598761e8d890c40e5

diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx
index 5580975..00f9e8f 100644
--- a/sfx2/source/control/templatefolderview.cxx
+++ b/sfx2/source/control/templatefolderview.cxx
@@ -148,6 +148,29 @@ ViewFilter_Application::ViewFilter_Application (SfxDocumentTemplates *pDocTempla
 
 bool ViewFilter_Application::operator () (const ThumbnailViewItem *pItem)
 {
+    const TemplateViewItem *pTempItem = static_cast<const TemplateViewItem*>(pItem);
+
+    if (mApp == APP_WRITER)
+    {
+        return pTempItem->getFileType() == "OpenDocument Text" ||
+                pTempItem->getFileType() == "OpenDocument Text Template";
+    }
+    else if (mApp == APP_CALC)
+    {
+        return pTempItem->getFileType() == "OpenDocument Spreadsheet" ||
+                pTempItem->getFileType() == "OpenDocument Spreadsheet Template";
+    }
+    else if (mApp == APP_IMPRESS)
+    {
+        return pTempItem->getFileType() == "OpenDocument Presentation" ||
+                pTempItem->getFileType() == "OpenDocument Presentation Template";
+    }
+    else if (mApp == APP_DRAW)
+    {
+        return pTempItem->getFileType() == "OpenDocument Drawing" ||
+                pTempItem->getFileType() == "OpenDocument Drawing Template";
+    }
+
     return true;
 }
 
commit 75646ece894683aa59b8e1fc52110cb30a9f8571
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Thu Jun 21 10:07:00 2012 -0430

    Load template info into TemplateFolderViewItem.
    
    - Dont load items when displaying the overlay just fetch
    them from the folder item.
    
    Change-Id: I7d7b37e0b62c09a46f94d9d10ffeccba9909773c

diff --git a/sfx2/inc/sfx2/templatefolderviewitem.hxx b/sfx2/inc/sfx2/templatefolderviewitem.hxx
index d0ebfe1..b504a9d 100644
--- a/sfx2/inc/sfx2/templatefolderviewitem.hxx
+++ b/sfx2/inc/sfx2/templatefolderviewitem.hxx
@@ -12,9 +12,12 @@
 
 #include <sfx2/thumbnailviewitem.hxx>
 
+class TemplateViewItem;
+
 struct TemplateFolderViewItem : public ThumbnailViewItem
 {
     BitmapEx maPreview2;
+    std::vector<TemplateViewItem*> maTemplates;
 
     TemplateFolderViewItem (ThumbnailView &rView, Window *pParent);
 
diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx
index e000b5b..5580975 100644
--- a/sfx2/source/control/templatefolderview.cxx
+++ b/sfx2/source/control/templatefolderview.cxx
@@ -12,7 +12,11 @@
 #include <comphelper/processfactory.hxx>
 #include <sfx2/doctempl.hxx>
 #include <sfx2/templateview.hxx>
+#include <sfx2/templateviewitem.hxx>
 #include <sfx2/templatefolderviewitem.hxx>
+#include <svl/inettype.hxx>
+#include <svtools/imagemgr.hxx>
+#include <tools/urlobj.hxx>
 #include <unotools/ucbstreamhelper.hxx>
 #include <vcl/pngread.hxx>
 
@@ -187,6 +191,20 @@ void TemplateFolderView::Populate ()
             if ( nEntries > 2 )
                 pItem->maPreview2 = lcl_fetchThumbnail(mpDocTemplates->GetPath(i,1),128,128);
 
+            for (sal_uInt16 j = 0; j < nEntries; ++j)
+            {
+                rtl::OUString aURL = mpDocTemplates->GetPath(i,j);
+                rtl::OUString aType = SvFileInformationManager::GetDescription(INetURLObject(aURL));
+
+                TemplateViewItem *pTemplateItem = new TemplateViewItem(*mpItemView,mpItemView);
+                pTemplateItem->mnId = j+1;
+                pTemplateItem->maText = mpDocTemplates->GetName(i,j);
+                pTemplateItem->setFileType(aType);
+                pTemplateItem->maPreview1 = lcl_fetchThumbnail(aURL,128,128);
+
+                pItem->maTemplates.push_back(pTemplateItem);
+            }
+
             mItemList.push_back(pItem);
         }
     }
@@ -230,13 +248,7 @@ void TemplateFolderView::OnItemDblClicked (ThumbnailViewItem *pRegionItem)
     sal_uInt16 nRegionId = pRegionItem->mnId-1;
 
     mpItemView->setRegionId(nRegionId);
-
-    sal_uInt16 nEntries = mpDocTemplates->GetCount(nRegionId);
-    for (sal_uInt16 i = 0; i < nEntries; ++i)
-    {
-        mpItemView->InsertItem(i+1,lcl_fetchThumbnail(mpDocTemplates->GetPath(nRegionId,i),128,128),
-                               mpDocTemplates->GetName(nRegionId,i));
-    }
+    mpItemView->InsertItems(static_cast<TemplateFolderViewItem*>(pRegionItem)->maTemplates);
 
     if (mbSelectionMode)
         mpItemView->setSelectionMode(true);
diff --git a/sfx2/source/control/templatefolderviewitem.cxx b/sfx2/source/control/templatefolderviewitem.cxx
index 2486560..dd0d393 100644
--- a/sfx2/source/control/templatefolderviewitem.cxx
+++ b/sfx2/source/control/templatefolderviewitem.cxx
@@ -17,6 +17,7 @@
 #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
 #include <drawinglayer/primitive2d/textprimitive2d.hxx>
 #include <drawinglayer/processor2d/baseprocessor2d.hxx>
+#include <sfx2/templateviewitem.hxx>
 #include <vcl/button.hxx>
 
 using namespace basegfx;
@@ -31,6 +32,8 @@ TemplateFolderViewItem::TemplateFolderViewItem (ThumbnailView &rView, Window *pP
 
 TemplateFolderViewItem::~TemplateFolderViewItem ()
 {
+    for (size_t i = 0; i < maTemplates.size(); ++i)
+        delete maTemplates[i];
 }
 
 void TemplateFolderViewItem::calculateItemsPosition ()
commit ba88e36f52d1aeb86d327fb17d93d57ac24c9ffe
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Thu Jun 21 09:27:21 2012 -0430

    Allow to insert several items at once in TemplateView.
    
    Change-Id: I369e6dc348bae9a2212bfaf112570b175ed9c6a7

diff --git a/sfx2/inc/sfx2/templateview.hxx b/sfx2/inc/sfx2/templateview.hxx
index 300a95f..f54f707 100644
--- a/sfx2/inc/sfx2/templateview.hxx
+++ b/sfx2/inc/sfx2/templateview.hxx
@@ -14,6 +14,7 @@
 #include <vcl/image.hxx>
 
 class SfxDocumentTemplates;
+class TemplateViewItem;
 
 class TemplateView : public ThumbnailView
 {
@@ -29,6 +30,8 @@ public:
 
     virtual void Paint (const Rectangle &rRect);
 
+    void InsertItems (const std::vector<TemplateViewItem*> &rTemplates);
+
 protected:
 
     virtual void MouseButtonDown (const MouseEvent &rMEvt);
diff --git a/sfx2/source/control/templateview.cxx b/sfx2/source/control/templateview.cxx
index 8ef3be4..6ff1c1f 100644
--- a/sfx2/source/control/templateview.cxx
+++ b/sfx2/source/control/templateview.cxx
@@ -19,7 +19,7 @@
 #include <drawinglayer/processor2d/baseprocessor2d.hxx>
 #include <sfx2/doctempl.hxx>
 #include <sfx2/sfxresid.hxx>
-#include <sfx2/thumbnailviewitem.hxx>
+#include <sfx2/templateviewitem.hxx>
 
 #include "templateview.hrc"
 
@@ -90,6 +90,26 @@ void TemplateView::Paint (const Rectangle &rRect)
     mpProcessor->process(aSeq);
 }
 
+void TemplateView::InsertItems (const std::vector<TemplateViewItem*> &rTemplates)
+{
+    for (size_t i = 0, n = rTemplates.size(); i < n; ++i )
+    {
+        TemplateViewItem *pItem = new TemplateViewItem(*this,this);
+        TemplateViewItem *pCur = rTemplates[i];
+
+        pItem->mnId = pCur->mnId;
+        pItem->maText = pCur->maText;
+        pItem->setFileType(pCur->getFileType());
+        pItem->maPreview1 = pCur->maPreview1;
+
+        mItemList.push_back(pItem);
+    }
+
+    CalculateItemPositions();
+
+    Invalidate();
+}
+
 void TemplateView::MouseButtonDown (const MouseEvent &rMEvt)
 {
     if (rMEvt.IsLeft())
commit 8299e8e84f0d1841cfb22a03bd830956e6a09a51
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Wed Jun 20 23:30:48 2012 -0430

    Only paint visible items.
    
    Change-Id: Ia17b13822b987c05752e3df5d7cbfed033b12616

diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index c47c0fc..a25fb38 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -877,27 +877,8 @@ void ThumbnailView::Command( const CommandEvent& rCEvt )
 
 void ThumbnailView::Paint( const Rectangle &aRect)
 {
-    Size        aWinSize = GetOutputSizePixel();
     size_t      nItemCount = mItemList.size();
 
-    // calculate offsets
-    long nStartX = 0;
-    long nStartY = mnHeaderHeight;
-
-    // calculate and draw items
-    long x = nStartX;
-    long y = nStartY;
-
-    // draw items
-    sal_uLong nFirstItem = mnFirstLine * mnCols;
-    sal_uLong nLastItem = nFirstItem + (mnVisLines * mnCols);
-
-    // If want also draw parts of items in the last line,
-    // then we add one more line if parts of these line are
-    // visible
-    if ( y+(mnVisLines*(mnItemHeight+mnSpacing)) < aWinSize.Height() )
-        nLastItem += mnCols;
-
     // Draw background
     Primitive2DSequence aSeq(1);
     aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D(
@@ -906,22 +887,13 @@ void ThumbnailView::Paint( const Rectangle &aRect)
 
     mpProcessor->process(aSeq);
 
+    // draw items
     for ( size_t i = 0; i < nItemCount; i++ )
     {
         ThumbnailViewItem *const pItem = mItemList[i];
 
-        if ( (i >= nFirstItem) && (i < nLastItem) )
-        {
+        if ( pItem->isVisible() )
             DrawItem(pItem);
-
-            if ( !((i+1) % mnCols) )
-            {
-                x = nStartX;
-                y += mnItemHeight+mnSpacing;
-            }
-            else
-                x += mnItemWidth+mnSpacing;
-        }
     }
 
     if ( mpScrBar && mpScrBar->IsVisible() )
commit 5f766d9007bc2b8584297d7e74fe394c9d92e395
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Wed Jun 20 23:27:50 2012 -0430

    Calculate item position correctly based on the item count.
    
    Change-Id: I422ab5605802218a2c31737c975d56f61a5aa180

diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 626828c..c47c0fc 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -374,7 +374,7 @@ void ThumbnailView::CalculateItemPositions ()
                 pItem->setDrawArea(Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) ));
                 pItem->calculateItemsPosition();
 
-                if ( !((i+1) % mnCols) )
+                if ( !((nCurCount+1) % mnCols) )
                 {
                     x = nStartX;
                     y += mnItemHeight+mnSpacing;
commit 330e8c3fbdfce15c0ff0ffa2c602994e6915315f
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Wed Jun 20 22:22:28 2012 -0430

    Create class to store templates data for display in TemplateView.
    
    Change-Id: I4b3478e97528020a2ffdff4f6c49e627b9af54cd

diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 5f2dd61..0bff14e 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -149,6 +149,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
     sfx2/source/control/sorgitm \
     sfx2/source/control/statcach \
     sfx2/source/control/templateview \
+    sfx2/source/control/templateviewitem \
     sfx2/source/control/templatefolderview \
     sfx2/source/control/templatefolderviewitem \
     sfx2/source/control/thumbnailviewitem \
diff --git a/sfx2/inc/sfx2/templateproperties.hxx b/sfx2/inc/sfx2/templateproperties.hxx
new file mode 100644
index 0000000..dc0fc3f
--- /dev/null
+++ b/sfx2/inc/sfx2/templateproperties.hxx
@@ -0,0 +1,15 @@
+/* -*- 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/.
+ */
+...
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
+#ifndef TEMPLATEPROPERTIES_HXX
+#define TEMPLATEPROPERTIES_HXX
+
+#endif // TEMPLATEPROPERTIES_HXX
diff --git a/sfx2/inc/sfx2/templateviewitem.hxx b/sfx2/inc/sfx2/templateviewitem.hxx
new file mode 100644
index 0000000..f9797f4
--- /dev/null
+++ b/sfx2/inc/sfx2/templateviewitem.hxx
@@ -0,0 +1,44 @@
+/* -*- 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 TEMPLATEVIEWITEM_HXX
+#define TEMPLATEVIEWITEM_HXX
+
+#include <sfx2/thumbnailviewitem.hxx>
+
+class TemplateViewItem : public ThumbnailViewItem
+{
+public:
+
+    TemplateViewItem (ThumbnailView &rView, Window *pParent);
+
+    virtual ~TemplateViewItem ();
+
+    void setAuthor (const rtl::OUString &rAuthor) { maAuthor = rAuthor; }
+
+    const rtl::OUString& getAuthor () const { return maAuthor; }
+
+    void setKeywords (const rtl::OUString &rKeywords) { maKeywords = rKeywords; }
+
+    const rtl::OUString& getKeywords () const { return maKeywords; }
+
+    void setFileType (const rtl::OUString &rType) { maFileType = rType; }
+
+    const rtl::OUString& getFileType () const { return maFileType; }
+
+private:
+
+    rtl::OUString maAuthor;
+    rtl::OUString maKeywords;
+    rtl::OUString maFileType;
+};
+
+#endif // TEMPLATEVIEWITEM_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/templateviewitem.cxx b/sfx2/source/control/templateviewitem.cxx
new file mode 100644
index 0000000..156f8ea
--- /dev/null
+++ b/sfx2/source/control/templateviewitem.cxx
@@ -0,0 +1,23 @@
+/* -*- 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/templateviewitem.hxx>
+
+TemplateViewItem::TemplateViewItem (ThumbnailView &rView, Window *pParent)
+    : ThumbnailViewItem(rView,pParent)
+{
+}
+
+TemplateViewItem::~TemplateViewItem ()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
+


More information about the Libreoffice-commits mailing list