summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorRafael Dominguez <venccsralph@gmail.com>2012-07-30 20:37:49 -0430
committerRafael Dominguez <venccsralph@gmail.com>2012-07-31 13:39:18 -0430
commitbff778a8d8bf9b634408db3dfdf0270d58ebb1c4 (patch)
tree75933cbdd6135c97875beb95752376294ccc1877 /sfx2
parentdfcca5410adb184b8acee160eec5e2036b73f0b7 (diff)
Display repository list in a popup menu instead of a thumbnail view.
Change-Id: Ib8205631a3c49b3ef4a942fa32a4b08ad9d4cb23
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/sfx2/templateonlineview.hxx9
-rw-r--r--sfx2/inc/templatedlg.hxx4
-rw-r--r--sfx2/source/control/templateonlineview.cxx48
-rw-r--r--sfx2/source/doc/templatedlg.cxx70
-rw-r--r--sfx2/source/doc/templatedlg.hrc10
-rw-r--r--sfx2/source/doc/templatedlg.src20
6 files changed, 120 insertions, 41 deletions
diff --git a/sfx2/inc/sfx2/templateonlineview.hxx b/sfx2/inc/sfx2/templateonlineview.hxx
index 245da5f2d051..d60e048b51dd 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 406fcb513ca1..e22fe8c8164e 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 822145cff05e..f33d0bd62d2c 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 28b7f8604b1e..4947aa5c109f 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 fd94bc090085..c489a309b859 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 cb73de02a066..f396bac45bcb 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