[Libreoffice-commits] .: 3 commits - sfx2/inc sfx2/source

Rafael Dominguez rdominguez at kemper.freedesktop.org
Tue Jul 31 11:09:29 PDT 2012


 sfx2/inc/sfx2/templateonlineview.hxx       |    9 ++-
 sfx2/inc/templatedlg.hxx                   |    4 +
 sfx2/source/control/templateonlineview.cxx |   48 +++++++++++-------
 sfx2/source/control/thumbnailview.cxx      |    3 +
 sfx2/source/doc/templatedlg.cxx            |   76 ++++++++++++++++++++++++-----
 sfx2/source/doc/templatedlg.hrc            |   10 +++
 sfx2/source/doc/templatedlg.src            |   20 ++++---
 7 files changed, 128 insertions(+), 42 deletions(-)

New commits:
commit 953a08b2dea5e07efb487b4d9bfccce5960193fc
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Tue Jul 31 12:31:24 2012 -0430

    After closing a remote repository overlay display local view.
    
    Change-Id: Ic7a2274b36719eeb979218b3dd54f19488f114dc

diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 4947aa5..765f664 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -324,7 +324,11 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, CloseOverlayHdl)
     mpTemplateBar->Hide();
     mpViewBar->Show();
 
-    mpCurView->showOverlay(false);
+    if (mpCurView == maView)
+        mpCurView->showOverlay(false);
+    else
+        switchMainView(true);
+
     return 0;
 }
 
commit bff778a8d8bf9b634408db3dfdf0270d58ebb1c4
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Mon Jul 30 20:37:49 2012 -0430

    Display repository list in a popup menu instead of a thumbnail view.
    
    Change-Id: Ib8205631a3c49b3ef4a942fa32a4b08ad9d4cb23

diff --git a/sfx2/inc/sfx2/templateonlineview.hxx b/sfx2/inc/sfx2/templateonlineview.hxx
index 245da5f..d60e048 100644
--- a/sfx2/inc/sfx2/templateonlineview.hxx
+++ b/sfx2/inc/sfx2/templateonlineview.hxx
@@ -14,6 +14,8 @@
 
 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
 
+class TemplateOnlineViewItem;
+
 class TemplateOnlineView : public TemplateAbstractView
 {
 public:
@@ -29,18 +31,21 @@ public:
 
     virtual void showOverlay (bool bVisible);
 
+    bool loadRepository (const sal_uInt16 nRepositoryId);
+
+    const std::vector<TemplateOnlineViewItem*>& getRepositories () const { return maRepositories; }
+
     void setItemDimensions (long ItemWidth, long ThumbnailHeight, long DisplayHeight, int itemPadding);
 
 private:
 
     virtual void Resize ();
 
-    virtual void OnItemDblClicked (ThumbnailViewItem *pItem);
-
 private:
 
     com::sun::star::uno::Sequence< rtl::OUString > maUrls;
     com::sun::star::uno::Sequence< rtl::OUString > maNames;
+    std::vector<TemplateOnlineViewItem*> maRepositories;
     com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xCmdEnv;
 };
 
diff --git a/sfx2/inc/templatedlg.hxx b/sfx2/inc/templatedlg.hxx
index 406fcb5..e22fe8c 100644
--- a/sfx2/inc/templatedlg.hxx
+++ b/sfx2/inc/templatedlg.hxx
@@ -64,6 +64,7 @@ private:
 
     DECL_LINK(MenuSelectHdl, Menu*);
     DECL_LINK(MoveMenuSelectHdl, Menu*);
+    DECL_LINK(RepositoryMenuSelectHdl, Menu*);
 
     DECL_LINK(OpenTemplateHdl, ThumbnailViewItem*);
 
@@ -78,6 +79,8 @@ private:
 
     void centerTopButtons ();
 
+    void createRepositoryMenu ();
+
     // Exchange view between local/online view.
     void switchMainView (bool bDisplayLocal);
 
@@ -119,6 +122,7 @@ private:
     TemplateOnlineView *mpOnlineView;
     PopupMenu *mpCreateMenu;
     PopupMenu *mpActionMenu;
+    PopupMenu *mpRepositoryMenu;
 
     int mnSelectionCount;
     std::set<const ThumbnailViewItem*> maSelTemplates;
diff --git a/sfx2/source/control/templateonlineview.cxx b/sfx2/source/control/templateonlineview.cxx
index 822145c..f33d0bd 100644
--- a/sfx2/source/control/templateonlineview.cxx
+++ b/sfx2/source/control/templateonlineview.cxx
@@ -66,6 +66,8 @@ TemplateOnlineView::TemplateOnlineView (Window *pParent, WinBits nWinStyle, bool
 
 TemplateOnlineView::~TemplateOnlineView ()
 {
+    for (size_t i = 0, n = maRepositories.size(); i < n; ++i)
+        delete maRepositories[i];
 }
 
 void TemplateOnlineView::Populate()
@@ -84,13 +86,8 @@ void TemplateOnlineView::Populate()
         pItem->maTitle = maNames[i];
         pItem->setURL(maUrls[i]);
 
-        mItemList.push_back(pItem);
+        maRepositories.push_back(pItem);
     }
-
-    CalculateItemPositions();
-
-    if (IsReallyVisible() && IsUpdateMode())
-        Invalidate();
 }
 
 void TemplateOnlineView::filterTemplatesByApp(const FILTER_APPLICATION &eApp)
@@ -113,20 +110,22 @@ void TemplateOnlineView::showOverlay (bool bVisible)
     }
 }
 
-void TemplateOnlineView::setItemDimensions(long ItemWidth, long ThumbnailHeight, long DisplayHeight, int itemPadding)
+bool TemplateOnlineView::loadRepository (const sal_uInt16 nRepositoryId)
 {
-    ThumbnailView::setItemDimensions(ItemWidth,ThumbnailHeight,DisplayHeight,itemPadding);
+    TemplateOnlineViewItem *pItem = NULL;
 
-    mpItemView->setItemDimensions(ItemWidth,ThumbnailHeight,DisplayHeight,itemPadding);
-}
+    for (size_t i = 0, n = maRepositories.size(); i < n; ++i)
+    {
+        if (maRepositories[i]->mnId == nRepositoryId)
+        {
+            pItem = maRepositories[i];
+            break;
+        }
+    }
 
-void TemplateOnlineView::Resize()
-{
-    mpItemView->SetSizePixel(GetSizePixel());
-}
+    if (!pItem)
+        return false;
 
-void TemplateOnlineView::OnItemDblClicked(ThumbnailViewItem *pItem)
-{
     rtl::OUString aURL = static_cast<TemplateOnlineViewItem*>(pItem)->getURL();
 
     try
@@ -156,6 +155,8 @@ void TemplateOnlineView::OnItemDblClicked(ThumbnailViewItem *pItem)
 
         if ( xResultSet.is() )
         {
+            mpItemView->Clear();
+
             uno::Reference< XRow > xRow( xResultSet, UNO_QUERY );
             uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY );
 
@@ -220,7 +221,6 @@ void TemplateOnlineView::OnItemDblClicked(ThumbnailViewItem *pItem)
 
             mpItemView->setName(pItem->maTitle);
             mpItemView->InsertItems(aItems);
-            mpItemView->Show();
         }
     }
     catch( ucb::CommandAbortedException& )
@@ -232,6 +232,20 @@ void TemplateOnlineView::OnItemDblClicked(ThumbnailViewItem *pItem)
     catch( uno::Exception& )
     {
     }
+
+    return true;
+}
+
+void TemplateOnlineView::setItemDimensions(long ItemWidth, long ThumbnailHeight, long DisplayHeight, int itemPadding)
+{
+    ThumbnailView::setItemDimensions(ItemWidth,ThumbnailHeight,DisplayHeight,itemPadding);
+
+    mpItemView->setItemDimensions(ItemWidth,ThumbnailHeight,DisplayHeight,itemPadding);
+}
+
+void TemplateOnlineView::Resize()
+{
+    mpItemView->SetSizePixel(GetSizePixel());
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 28b7f86..4947aa5 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -19,6 +19,7 @@
 #include <sfx2/templatelocalview.hxx>
 #include <sfx2/templatelocalviewitem.hxx>
 #include <sfx2/templateonlineview.hxx>
+#include <sfx2/templateonlineviewitem.hxx>
 #include <sfx2/templateviewitem.hxx>
 #include <sfx2/thumbnailviewitem.hxx>
 #include <tools/urlobj.hxx>
@@ -118,6 +119,9 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
     mpActionMenu->InsertItem(MNI_ACTION_SORT_NAME,SfxResId(STR_ACTION_SORT_NAME).toString(),SfxResId(IMG_ACTION_SORT));
     mpActionMenu->SetSelectHdl(LINK(this,SfxTemplateManagerDlg,MenuSelectHdl));
 
+    mpRepositoryMenu = new PopupMenu;
+    mpRepositoryMenu->SetSelectHdl(LINK(this,SfxTemplateManagerDlg,RepositoryMenuSelectHdl));
+
     Size aWinSize = GetOutputSize();
 
     // Calculate thumbnail view minimum size
@@ -150,6 +154,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
     // Set toolbox button bits
     mpViewBar->EnableItem(TBI_TEMPLATE_IMPORT,false);
     mpViewBar->SetItemBits(TBI_TEMPLATE_CREATE, TIB_DROPDOWNONLY);
+    mpViewBar->SetItemBits(TBI_TEMPLATE_REPOSITORY, TIB_DROPDOWNONLY);
     mpActionBar->SetItemBits(TBI_TEMPLATE_ACTION, TIB_DROPDOWNONLY);
     mpTemplateBar->SetItemBits(TBI_TEMPLATE_MOVE,TIB_DROPDOWNONLY);
 
@@ -243,6 +248,8 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
 
     mpOnlineView->Populate();
 
+    createRepositoryMenu();
+
     maView->Populate();
     maView->Show();
 
@@ -260,6 +267,7 @@ SfxTemplateManagerDlg::~SfxTemplateManagerDlg ()
     delete mpOnlineView;
     delete mpCreateMenu;
     delete mpActionMenu;
+    delete mpRepositoryMenu;
 }
 
 IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewAllHdl)
@@ -336,12 +344,6 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg,TBXViewHdl)
     case TBI_TEMPLATE_FOLDER_DEL:
         OnFolderDelete();
         break;
-    case TBI_TEMPLATE_LOCAL:
-        switchMainView(true);
-        break;
-    case TBI_TEMPLATE_ONLINE:
-        switchMainView(false);
-        break;
     default:
         break;
     }
@@ -438,6 +440,16 @@ IMPL_LINK(SfxTemplateManagerDlg, TBXDropdownHdl, ToolBox*, pBox)
         pBox->Invalidate();
         break;
     }
+    case TBI_TEMPLATE_REPOSITORY:
+        pBox->SetItemDown( nCurItemId, true );
+
+        mpRepositoryMenu->Execute(pBox,pBox->GetItemRect(TBI_TEMPLATE_REPOSITORY),
+                                  POPUPMENU_EXECUTE_DOWN);
+
+        pBox->SetItemDown( nCurItemId, false );
+        pBox->EndSelection();
+        pBox->Invalidate();
+        break;
     default:
         break;
     }
@@ -559,6 +571,31 @@ IMPL_LINK(SfxTemplateManagerDlg, MoveMenuSelectHdl, Menu*, pMenu)
     return 0;
 }
 
+IMPL_LINK(SfxTemplateManagerDlg, RepositoryMenuSelectHdl, Menu*, pMenu)
+{
+    sal_uInt16 nMenuId = pMenu->GetCurItemId();
+
+    if (nMenuId == MNI_REPOSITORY_LOCAL)
+    {
+        switchMainView(true);
+    }
+    else if (nMenuId == MNI_REPOSITORY_NEW)
+    {
+    }
+    else
+    {
+        sal_uInt16 nRepoId = nMenuId - MNI_REPOSITORY_BASE;
+
+        if (mpOnlineView->loadRepository(nRepoId))
+        {
+            switchMainView(false);
+            mpOnlineView->showOverlay(true);
+        }
+    }
+
+    return 0;
+}
+
 IMPL_LINK(SfxTemplateManagerDlg, OpenTemplateHdl, ThumbnailViewItem*, pItem)
 {
     uno::Sequence< PropertyValue > aArgs(1);
@@ -859,15 +896,27 @@ void SfxTemplateManagerDlg::centerTopButtons()
     maButtonSelMode.SetPosPixel(aBtnPos);
 }
 
+void SfxTemplateManagerDlg::createRepositoryMenu()
+{
+    mpRepositoryMenu->Clear();
+
+    mpRepositoryMenu->InsertItem(MNI_REPOSITORY_LOCAL,SfxResId(STR_REPOSITORY_LOCAL).toString());
+
+    const std::vector<TemplateOnlineViewItem*> &rRepos = mpOnlineView->getRepositories();
+
+    for (size_t i = 0, n = rRepos.size(); i < n; ++i)
+        mpRepositoryMenu->InsertItem(MNI_REPOSITORY_BASE+rRepos[i]->mnId,rRepos[i]->maTitle);
+
+    mpRepositoryMenu->InsertSeparator();
+    mpRepositoryMenu->InsertItem(MNI_REPOSITORY_NEW,SfxResId(STR_REPOSITORY_NEW).toString());
+}
+
 void SfxTemplateManagerDlg::switchMainView(bool bDisplayLocal)
 {
     if (bDisplayLocal)
     {
         mpCurView = maView;
 
-        mpViewBar->ShowItem(TBI_TEMPLATE_ONLINE);
-        mpViewBar->HideItem(TBI_TEMPLATE_LOCAL);
-
         // Enable deleting items from the filesystem
         mpTemplateBar->ShowItem(TBI_TEMPLATE_DELETE);
 
@@ -878,9 +927,6 @@ void SfxTemplateManagerDlg::switchMainView(bool bDisplayLocal)
     {
         mpCurView = mpOnlineView;
 
-        mpViewBar->ShowItem(TBI_TEMPLATE_LOCAL);
-        mpViewBar->HideItem(TBI_TEMPLATE_ONLINE);
-
         // Disable deleting items from remote repositories
         mpTemplateBar->HideItem(TBI_TEMPLATE_DELETE);
 
diff --git a/sfx2/source/doc/templatedlg.hrc b/sfx2/source/doc/templatedlg.hrc
index fd94bc0..c489a30 100644
--- a/sfx2/source/doc/templatedlg.hrc
+++ b/sfx2/source/doc/templatedlg.hrc
@@ -39,8 +39,7 @@
 #define BTN_TEMPLATE_CLOSE          24
 
 #define TBI_TEMPLATE_FOLDER_DEL     25
-#define TBI_TEMPLATE_LOCAL          26
-#define TBI_TEMPLATE_ONLINE         27
+#define TBI_TEMPLATE_REPOSITORY     26
 
 #define STR_CREATE_TEXT             260
 #define STR_CREATE_SHEET            261
@@ -55,6 +54,13 @@
 #define STR_MOVE_NEW                268
 #define STR_INPUT_NEW               271
 
+#define STR_REPOSITORY_LOCAL        272
+#define STR_REPOSITORY_NEW          273
+
+#define MNI_REPOSITORY_LOCAL        274
+#define MNI_REPOSITORY_NEW          275
+#define MNI_REPOSITORY_BASE         276
+
 #define IMG_ONLINE_REPOSITORY       100
 #define IMG_CREATE_TEXT             300
 #define IMG_CREATE_SHEET            301
diff --git a/sfx2/source/doc/templatedlg.src b/sfx2/source/doc/templatedlg.src
index cb73de0..f396bac 100644
--- a/sfx2/source/doc/templatedlg.src
+++ b/sfx2/source/doc/templatedlg.src
@@ -45,6 +45,16 @@ String STR_INPUT_NEW
     Text [ en-US ] = "Enter folder name:";
 };
 
+String STR_REPOSITORY_LOCAL
+{
+    Text [ en-US ] = "Local";
+};
+
+String STR_REPOSITORY_NEW
+{
+    Text [ en-US ] = "New Repository";
+};
+
 ModelessDialog DLG_TEMPLATE_MANAGER
 {
     HelpId = CMD_SID_TEMPLATE_MANAGER;
@@ -187,14 +197,8 @@ ModelessDialog DLG_TEMPLATE_MANAGER
 
             ToolBoxItem
             {
-                Identifier = TBI_TEMPLATE_LOCAL;
-                Text [ en-US ] = "Local";
-            };
-
-            ToolBoxItem
-            {
-                Identifier = TBI_TEMPLATE_ONLINE;
-                Text [ en-US ] = "Online";
+                Identifier = TBI_TEMPLATE_REPOSITORY;
+                Text [ en-US ] = "Repository";
             };
 
             ToolBoxItem
commit dfcca5410adb184b8acee160eec5e2036b73f0b7
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Mon Jul 30 18:32:40 2012 -0430

    Avoid dividing by 0.
    
    Change-Id: Iab1bd0dbe28403a6063a681f11c282b7f15ce7b6

diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index f6042b5..5f08084 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -256,6 +256,9 @@ void ThumbnailView::CalculateItemPositions ()
     // calculate maximum number of visible columns
     mnCols = (sal_uInt16)((aWinSize.Width()-nScrBarWidth) / (mnItemWidth));
 
+    if (!mnCols)
+        mnCols = 1;
+
     if ( mnUserCols && mnUserCols < mnCols )
         mnCols = mnUserCols;
 


More information about the Libreoffice-commits mailing list