sfx2/Library_sfx.mk | 6 sfx2/Package_inc.mk | 4 sfx2/inc/sfx2/templateabstractview.hxx | 2 sfx2/inc/sfx2/templatelocalview.hxx | 6 sfx2/inc/sfx2/templateonlineview.hxx | 64 ---- sfx2/inc/sfx2/templateonlineviewitem.hxx | 42 --- sfx2/inc/sfx2/templateremoteview.hxx | 64 ++++ sfx2/inc/sfx2/templateremoteviewitem.hxx | 42 +++ sfx2/inc/sfx2/templateview.hxx | 6 sfx2/inc/sfx2/thumbnailview.hxx | 4 sfx2/inc/templatedlg.hxx | 4 sfx2/source/control/templateabstractview.cxx | 2 sfx2/source/control/templatelocalview.cxx | 20 - sfx2/source/control/templateonlineview.cxx | 340 ------------------------- sfx2/source/control/templateonlineviewitem.cxx | 21 - sfx2/source/control/templateremoteview.cxx | 340 +++++++++++++++++++++++++ sfx2/source/control/templateremoteviewitem.cxx | 21 + sfx2/source/control/templatesearchview.cxx | 4 sfx2/source/control/templateview.cxx | 12 sfx2/source/control/templateviewitem.cxx | 2 sfx2/source/control/thumbnailview.cxx | 6 sfx2/source/doc/templatedlg.cxx | 34 +- sfx2/source/inc/templatesearchview.hxx | 4 23 files changed, 525 insertions(+), 525 deletions(-)
New commits: commit 515b260cb4dd6d0615919b4c6703f1a1d24d1eba Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Aug 23 15:17:27 2012 -0430 Fix rendering subtitle for template search results. Change-Id: I1d1a5100bdbd2be238d045df3c7790dde8afd63f diff --git a/sfx2/source/control/templateviewitem.cxx b/sfx2/source/control/templateviewitem.cxx index 4ef6aa1..2c27e5f 100644 --- a/sfx2/source/control/templateviewitem.cxx +++ b/sfx2/source/control/templateviewitem.cxx @@ -126,7 +126,7 @@ void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProces pAttrs->aFontSize.getX()*SUBTITLE_SCALE_FACTOR, pAttrs->aFontSize.getY()*SUBTITLE_SCALE_FACTOR, double( maSubTitlePos.X() ), double( maSubTitlePos.Y() ) ) ); - aSeq[8] = Primitive2DReference( + aSeq[7] = Primitive2DReference( new TextSimplePortionPrimitive2D(aSubTitleMatrix, maSubTitle,0,pAttrs->nMaxTextLenght, std::vector< double >( ), commit 2addf49c27eb80dcf65cf2727ac03c8a6d1f1e06 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Aug 23 09:54:34 2012 -0430 rtl::OUString -> OUString Change-Id: Id435edc2d2f8801bde4be6e4acbe42608e0be179 diff --git a/sfx2/inc/sfx2/templateabstractview.hxx b/sfx2/inc/sfx2/templateabstractview.hxx index eff8da5..89de530 100644 --- a/sfx2/inc/sfx2/templateabstractview.hxx +++ b/sfx2/inc/sfx2/templateabstractview.hxx @@ -112,7 +112,7 @@ public: static BitmapEx scaleImg (const BitmapEx &rImg, long width, long height); - static BitmapEx fetchThumbnail (const rtl::OUString &msURL, long width, long height); + static BitmapEx fetchThumbnail (const OUString &msURL, long width, long height); protected: diff --git a/sfx2/inc/sfx2/templatelocalview.hxx b/sfx2/inc/sfx2/templatelocalview.hxx index 268ca8e..9a101f2 100644 --- a/sfx2/inc/sfx2/templatelocalview.hxx +++ b/sfx2/inc/sfx2/templatelocalview.hxx @@ -37,7 +37,7 @@ public: virtual void reload (); - std::vector<rtl::OUString> getFolderNames (); + std::vector<OUString> getFolderNames (); virtual void showOverlay (bool bVisible); @@ -46,7 +46,7 @@ public: std::vector<TemplateItemProperties> getFilteredItems (const boost::function<bool (const TemplateItemProperties&) > &rFunc) const; - sal_uInt16 createRegion (const rtl::OUString &rName); + sal_uInt16 createRegion (const OUString &rName); bool removeRegion (const sal_uInt16 nItemId); @@ -59,7 +59,7 @@ public: bool copyFrom (const sal_uInt16 nRegionItemId, const BitmapEx &rThumbnail, const OUString &rPath); - bool copyFrom(TemplateLocalViewItem *pItem, const rtl::OUString &rPath); + bool copyFrom(TemplateLocalViewItem *pItem, const OUString &rPath); bool exportTo (const sal_uInt16 nItemId, const sal_uInt16 nRegionItemId, const OUString &rName); diff --git a/sfx2/inc/sfx2/templateview.hxx b/sfx2/inc/sfx2/templateview.hxx index d9279b3..881c68d 100644 --- a/sfx2/inc/sfx2/templateview.hxx +++ b/sfx2/inc/sfx2/templateview.hxx @@ -29,9 +29,9 @@ public: sal_uInt16 getId () const { return mnId; } - void setName (const rtl::OUString &rName); + void setName (const OUString &rName); - const rtl::OUString& getName () const { return maName; } + const OUString& getName () const { return maName; } virtual void Paint (const Rectangle &rRect); @@ -58,7 +58,7 @@ private: Image maCloseImg; bool mbRenderTitle; sal_uInt16 mnId; - rtl::OUString maName; + OUString maName; Link maDblClickHdl; Link maChangeNameHdl; Link maCloseHdl; diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index a42b805..12d2812 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -180,7 +180,7 @@ public: virtual ~ThumbnailView (); void InsertItem( sal_uInt16 nItemId, - const BitmapEx &rImage, const rtl::OUString &rStr, + const BitmapEx &rImage, const OUString &rStr, size_t nPos = THUMBNAILVIEW_APPEND ); void RemoveItem( sal_uInt16 nItemId ); @@ -223,7 +223,7 @@ public: void deselectItems (); - rtl::OUString GetItemText( sal_uInt16 nItemId ) const; + OUString GetItemText( sal_uInt16 nItemId ) const; void SetColor( const Color& rColor ); diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx index 7483f80..22e8121 100644 --- a/sfx2/source/control/templateabstractview.cxx +++ b/sfx2/source/control/templateabstractview.cxx @@ -141,7 +141,7 @@ BitmapEx TemplateAbstractView::scaleImg (const BitmapEx &rImg, long width, long return aImg; } -BitmapEx TemplateAbstractView::fetchThumbnail (const rtl::OUString &msURL, long width, long height) +BitmapEx TemplateAbstractView::fetchThumbnail (const OUString &msURL, long width, long height) { using namespace ::com::sun::star; using namespace ::com::sun::star::uno; diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index b230260..a9754b4 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -71,7 +71,7 @@ public: return meApp != FILTER_APP_NONE ? nVisCount : true ; } - bool isValid (const rtl::OUString &rType) const + bool isValid (const OUString &rType) const { bool bRet = true; @@ -120,7 +120,7 @@ void TemplateLocalView::Populate () sal_uInt16 nCount = mpDocTemplates->GetRegionCount(); for (sal_uInt16 i = 0; i < nCount; ++i) { - rtl::OUString aRegionName(mpDocTemplates->GetFullRegionName(i)); + OUString aRegionName(mpDocTemplates->GetFullRegionName(i)); if ((sal_uInt32)aRegionName.getLength() > mpItemAttrs->nMaxTextLenght) { @@ -137,9 +137,9 @@ void TemplateLocalView::Populate () for (sal_uInt16 j = 0; j < nEntries; ++j) { - rtl::OUString aName = mpDocTemplates->GetName(i,j); - rtl::OUString aURL = mpDocTemplates->GetPath(i,j); - rtl::OUString aType = SvFileInformationManager::GetDescription(INetURLObject(aURL)); + OUString aName = mpDocTemplates->GetName(i,j); + OUString aURL = mpDocTemplates->GetPath(i,j); + OUString aType = SvFileInformationManager::GetDescription(INetURLObject(aURL)); if ((sal_uInt32)aName.getLength() > mpItemAttrs->nMaxTextLenght) { @@ -196,10 +196,10 @@ void TemplateLocalView::reload () } } -std::vector<rtl::OUString> TemplateLocalView::getFolderNames() +std::vector<OUString> TemplateLocalView::getFolderNames() { size_t n = mItemList.size(); - std::vector<rtl::OUString> ret(n); + std::vector<OUString> ret(n); for (size_t i = 0; i < n; ++i) ret[i] = mItemList[i]->maTitle; @@ -263,14 +263,14 @@ TemplateLocalView::getFilteredItems(const boost::function<bool (const TemplateIt return aItems; } -sal_uInt16 TemplateLocalView::createRegion(const rtl::OUString &rName) +sal_uInt16 TemplateLocalView::createRegion(const OUString &rName) { sal_uInt16 nRegionId = mpDocTemplates->GetRegionCount(); // Next regionId if (!mpDocTemplates->InsertDir(rName,nRegionId)) return false; - rtl::OUString aRegionName = rName; + OUString aRegionName = rName; if ((sal_uInt32)aRegionName.getLength() > mpItemAttrs->nMaxTextLenght) { @@ -576,7 +576,7 @@ bool TemplateLocalView::copyFrom(const sal_uInt16 nRegionItemId, const BitmapEx return false; } -bool TemplateLocalView::copyFrom (TemplateLocalViewItem *pItem, const rtl::OUString &rPath) +bool TemplateLocalView::copyFrom (TemplateLocalViewItem *pItem, const OUString &rPath) { sal_uInt16 nId = 0; sal_uInt16 nDocId = 0; diff --git a/sfx2/source/control/templateremoteview.cxx b/sfx2/source/control/templateremoteview.cxx index a5282da..bef9102 100644 --- a/sfx2/source/control/templateremoteview.cxx +++ b/sfx2/source/control/templateremoteview.cxx @@ -70,10 +70,10 @@ void TemplateRemoteView::Populate() uno::Reference < uno::XComponentContext > m_context(comphelper::getProcessComponentContext()); // Load from user settings - com::sun::star::uno::Sequence< rtl::OUString > aUrls = + com::sun::star::uno::Sequence<OUString> aUrls = officecfg::Office::Common::Misc::TemplateRepositoryUrls::get(m_context); - com::sun::star::uno::Sequence< rtl::OUString > aNames = + com::sun::star::uno::Sequence<OUString> aNames = officecfg::Office::Common::Misc::TemplateRepositoryNames::get(m_context); for (sal_Int32 i = 0; i < aUrls.getLength() && i < aNames.getLength(); ++i) @@ -143,12 +143,12 @@ bool TemplateRemoteView::loadRepository (const sal_uInt16 nRepositoryId, bool bR mpItemView->setId(nRepositoryId); mpItemView->setName(pItem->maTitle); - rtl::OUString aURL = static_cast<TemplateRemoteViewItem*>(pItem)->getURL(); + OUString aURL = static_cast<TemplateRemoteViewItem*>(pItem)->getURL(); try { - uno::Sequence< rtl::OUString > aProps(8); + uno::Sequence<OUString> aProps(8); aProps[0] = "Title"; aProps[1] = "Size"; @@ -197,11 +197,11 @@ bool TemplateRemoteView::loadRepository (const sal_uInt16 nRepositoryId, bool bR bContainsDate = !xRow->wasNull(); } - rtl::OUString aContentURL = xContentAccess->queryContentIdentifierString(); - rtl::OUString aTargetURL = xRow->getString( ROW_TARGET_URL ); + OUString aContentURL = xContentAccess->queryContentIdentifierString(); + OUString aTargetURL = xRow->getString( ROW_TARGET_URL ); bool bHasTargetURL = !xRow->wasNull() && !aTargetURL.isEmpty(); - rtl::OUString sRealURL = bHasTargetURL ? aTargetURL : aContentURL; + OUString sRealURL = bHasTargetURL ? aTargetURL : aContentURL; TemplateItemProperties aTemplateItem; aTemplateItem.nId = nIdx+1; diff --git a/sfx2/source/control/templatesearchview.cxx b/sfx2/source/control/templatesearchview.cxx index 620d815..24554fb 100644 --- a/sfx2/source/control/templatesearchview.cxx +++ b/sfx2/source/control/templatesearchview.cxx @@ -21,8 +21,8 @@ TemplateSearchView::~TemplateSearchView () } void TemplateSearchView::AppendItem(sal_uInt16 nItemId, sal_uInt16 nRegionId, sal_uInt16 nIdx, - const rtl::OUString &rTitle, const rtl::OUString &rSubtitle, - const rtl::OUString &rPath, + const OUString &rTitle, const OUString &rSubtitle, + const OUString &rPath, const BitmapEx &rImage) { TemplateSearchViewItem *pItem = new TemplateSearchViewItem(*this,this); diff --git a/sfx2/source/control/templateview.cxx b/sfx2/source/control/templateview.cxx index e2c7960..7173268 100644 --- a/sfx2/source/control/templateview.cxx +++ b/sfx2/source/control/templateview.cxx @@ -46,10 +46,10 @@ TemplateView::~TemplateView () delete mpEditName; } -void TemplateView::setName (const rtl::OUString &rName) +void TemplateView::setName (const OUString &rName) { maName = rName; - mpEditName->SetText(rtl::OUString()); + mpEditName->SetText(OUString()); } void TemplateView::Paint (const Rectangle &rRect) @@ -153,7 +153,7 @@ void TemplateView::MouseButtonDown (const MouseEvent &rMEvt) mbRenderTitle = true; // Update name if its not empty - rtl::OUString aTmp = mpEditName->GetText(); + OUString aTmp = mpEditName->GetText(); if (!aTmp.isEmpty()) { @@ -161,7 +161,7 @@ void TemplateView::MouseButtonDown (const MouseEvent &rMEvt) } else { - mpEditName->SetText(rtl::OUString()); + mpEditName->SetText(OUString()); Invalidate(); } @@ -215,13 +215,13 @@ void TemplateView::OnItemDblClicked(ThumbnailViewItem *pItem) IMPL_LINK_NOARG(TemplateView, ChangeNameHdl) { - rtl::OUString aTmp = maName; + OUString aTmp = maName; maName = mpEditName->GetText(); if (!maChangeNameHdl.Call(this)) maName = aTmp; - mpEditName->SetText(rtl::OUString()); + mpEditName->SetText(OUString()); Invalidate(); return 0; diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 589766d..e494cdc 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -791,7 +791,7 @@ void ThumbnailView::DataChanged( const DataChangedEvent& rDCEvt ) } void ThumbnailView::InsertItem( sal_uInt16 nItemId, const BitmapEx& rImage, - const rtl::OUString& rText, size_t nPos ) + const OUString& rText, size_t nPos ) { ThumbnailViewItem* pItem = new ThumbnailViewItem( *this, this ); pItem->mnId = nItemId; @@ -1041,14 +1041,14 @@ void ThumbnailView::deselectItems() Invalidate(); } -rtl::OUString ThumbnailView::GetItemText( sal_uInt16 nItemId ) const +OUString ThumbnailView::GetItemText( sal_uInt16 nItemId ) const { size_t nPos = GetItemPos( nItemId ); if ( nPos != THUMBNAILVIEW_ITEM_NOTFOUND ) return mItemList[nPos]->maTitle; - return rtl::OUString(); + return OUString(); } void ThumbnailView::SetColor( const Color& rColor ) diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index a41d4eb..a01366b 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -85,7 +85,7 @@ class SearchView_Keyword { public: - SearchView_Keyword (const rtl::OUString &rKeyword) + SearchView_Keyword (const OUString &rKeyword) : maKeyword(rKeyword) {} @@ -96,7 +96,7 @@ public: private: - rtl::OUString maKeyword; + OUString maKeyword; }; SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent) @@ -441,7 +441,7 @@ IMPL_LINK(SfxTemplateManagerDlg, TBXDropdownHdl, ToolBox*, pBox) { pBox->SetItemDown( nCurItemId, true ); - std::vector<rtl::OUString> aNames = maView->getFolderNames(); + std::vector<OUString> aNames = maView->getFolderNames(); PopupMenu *pMoveMenu = new PopupMenu; pMoveMenu->SetSelectHdl(LINK(this,SfxTemplateManagerDlg,MoveMenuSelectHdl)); @@ -669,7 +669,7 @@ IMPL_LINK(SfxTemplateManagerDlg, OpenTemplateHdl, ThumbnailViewItem*, pItem) try { - mxDesktop->loadComponentFromURL(pTemplateItem->getPath(),rtl::OUString("_default"), 0, aArgs ); + mxDesktop->loadComponentFromURL(pTemplateItem->getPath(),"_default", 0, aArgs ); } catch( const uno::Exception& ) { @@ -691,7 +691,7 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, SearchUpdateHdl) mpCurView->Hide(); } - rtl::OUString aKeyword = mpSearchEdit->GetText(); + OUString aKeyword = mpSearchEdit->GetText(); if (!aKeyword.isEmpty()) { @@ -756,8 +756,8 @@ void SfxTemplateManagerDlg::OnTemplateImport () DEFINE_CONST_UNICODE(FILEDIALOG_FILTER_ALL) ); // add template filter - rtl::OUString sFilterExt; - rtl::OUString sFilterName( SfxResId( STR_TEMPLATE_FILTER ).toString() ); + OUString sFilterExt; + OUString sFilterName( SfxResId( STR_TEMPLATE_FILTER ).toString() ); // add filters of modules which are installed SvtModuleOptions aModuleOpt; @@ -804,7 +804,7 @@ void SfxTemplateManagerDlg::OnTemplateImport () if ( nCode == ERRCODE_NONE ) { - com::sun::star::uno::Sequence< ::rtl::OUString > aFiles = aFileDlg.GetSelectedFiles(); + com::sun::star::uno::Sequence<OUString> aFiles = aFileDlg.GetSelectedFiles(); if (aFiles.hasElements()) { @@ -956,7 +956,7 @@ void SfxTemplateManagerDlg::OnTemplateSearch () } mpSearchEdit->Show(!bVisible); - mpSearchEdit->SetText(rtl::OUString()); + mpSearchEdit->SetText(OUString()); // display all templates if we hide the search bar if (bVisible && mpCurView->isOverlayVisible()) @@ -978,7 +978,7 @@ void SfxTemplateManagerDlg::OnTemplateEdit () try { xStorable = uno::Reference< XStorable >( - mxDesktop->loadComponentFromURL(pItem->getPath(),rtl::OUString("_blank"), 0, aArgs ), + mxDesktop->loadComponentFromURL(pItem->getPath(),"_blank", 0, aArgs ), uno::UNO_QUERY ); } catch( const uno::Exception& ) @@ -1320,7 +1320,7 @@ void SfxTemplateManagerDlg::localMoveTo(sal_uInt16 nMenuId) if (ret) { - rtl::OUString aName = dlg.getEntryText(); + OUString aName = dlg.getEntryText(); if (!aName.isEmpty()) nItemId = maView->createRegion(aName); @@ -1369,7 +1369,7 @@ void SfxTemplateManagerDlg::remoteMoveTo(const sal_uInt16 nMenuId) if (ret) { - rtl::OUString aName = dlg.getEntryText(); + OUString aName = dlg.getEntryText(); if (!aName.isEmpty()) nItemId = maView->createRegion(aName); @@ -1423,7 +1423,7 @@ void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nMenuId) if (ret) { - rtl::OUString aName = dlg.getEntryText(); + OUString aName = dlg.getEntryText(); if (!aName.isEmpty()) nItemId = maView->createRegion(aName); diff --git a/sfx2/source/inc/templatesearchview.hxx b/sfx2/source/inc/templatesearchview.hxx index a8333ce..de5514d 100644 --- a/sfx2/source/inc/templatesearchview.hxx +++ b/sfx2/source/inc/templatesearchview.hxx @@ -21,8 +21,8 @@ public: virtual ~TemplateSearchView(); void AppendItem(sal_uInt16 nItemId, sal_uInt16 nRegionId, sal_uInt16 nIdx, - const rtl::OUString &rTitle, const rtl::OUString &rSubtitle, - const rtl::OUString &rPath, const BitmapEx &rImage ); + const OUString &rTitle, const OUString &rSubtitle, + const OUString &rPath, const BitmapEx &rImage ); }; #endif // __SFX2_TEMPLATESEARCHVIEW_HXX__ commit 9c94045bd2802a3f7e8c286b4082a55fe43a666d Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Aug 21 18:00:39 2012 -0430 Rename class from TemplateOnlineView to TemplateRemoteView. Change-Id: I3d1cc00274c4f758cb4e8e6a09cea9cb63b0a733 diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 5bc8903..3ed3a02 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -138,8 +138,8 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/control/templateviewitem \ sfx2/source/control/templatelocalview \ sfx2/source/control/templatelocalviewitem \ - sfx2/source/control/templateonlineview \ - sfx2/source/control/templateonlineviewitem \ + sfx2/source/control/templateremoteview \ + sfx2/source/control/templateremoteviewitem \ sfx2/source/control/templatesearchview \ sfx2/source/control/thumbnailviewitem \ sfx2/source/control/thumbnailviewacc \ @@ -303,6 +303,6 @@ endif # Runtime dependency for unit-tests $(call gb_LinkTarget_get_target,$(call gb_Library_get_linktargetname,sfx)) :| \ - $(call gb_AllLangResTarget_get_target,sfx) + $(call gb_AllLangResTarget_get_target,sfx) # vim: set noet sw=4 ts=4: diff --git a/sfx2/Package_inc.mk b/sfx2/Package_inc.mk index 31f190d..4156354 100644 --- a/sfx2/Package_inc.mk +++ b/sfx2/Package_inc.mk @@ -123,8 +123,8 @@ $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templateinfodlg.hxx,sfx2/tem $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templateview.hxx,sfx2/templateview.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templatelocalview.hxx,sfx2/templatelocalview.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templatelocalviewitem.hxx,sfx2/templatelocalviewitem.hxx)) -$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templateonlineview.hxx,sfx2/templateonlineview.hxx)) -$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templateonlineviewitem.hxx,sfx2/templateonlineviewitem.hxx)) +$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templateremoteview.hxx,sfx2/templateremoteview.hxx)) +$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templateremoteviewitem.hxx,sfx2/templateremoteviewitem.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/thumbnailview.hxx,sfx2/thumbnailview.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/thumbnailviewitem.hxx,sfx2/thumbnailviewitem.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/titledockwin.hxx,sfx2/titledockwin.hxx)) diff --git a/sfx2/inc/sfx2/templateonlineview.hxx b/sfx2/inc/sfx2/templateonlineview.hxx deleted file mode 100644 index d64f947..0000000 --- a/sfx2/inc/sfx2/templateonlineview.hxx +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * 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 __SFX2_TEMPLATEONLINEVIEW_HXX__ -#define __SFX2_TEMPLATEONLINEVIEW_HXX__ - -#include <sfx2/templateabstractview.hxx> -#include <sfx2/templateproperties.hxx> - -#include <com/sun/star/ucb/XCommandEnvironment.hpp> - -class TemplateOnlineViewItem; - -class TemplateOnlineView : public TemplateAbstractView -{ -public: - - TemplateOnlineView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren); - - virtual ~TemplateOnlineView (); - - // Load repositories from user settings. - virtual void Populate (); - - virtual void reload (); - - virtual void filterTemplatesByApp (const FILTER_APPLICATION &eApp); - - virtual void showOverlay (bool bVisible); - - void setOverlayChangeNameHdl (const Link &rLink); - - bool loadRepository (const sal_uInt16 nRepositoryId, bool bRefresh); - - const std::vector<TemplateOnlineViewItem*>& getRepositories () const { return maRepositories; } - - bool insertRepository (const OUString &rName, const OUString &rURL); - - bool deleteRepository (const sal_uInt16 nRepositoryId); - - void syncRepositories () const; - -private: - - DECL_LINK(ChangeNameHdl, TemplateView*); - -private: - - bool mbIsSynced; - Link maChangeNameHdl; - std::vector<TemplateOnlineViewItem*> maRepositories; - com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xCmdEnv; -}; - -#endif // __SFX2_TEMPLATEONLINEVIEW_HXX__ - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/inc/sfx2/templateonlineviewitem.hxx b/sfx2/inc/sfx2/templateonlineviewitem.hxx deleted file mode 100644 index 07996b3..0000000 --- a/sfx2/inc/sfx2/templateonlineviewitem.hxx +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * 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 __SFX2_TEMPLATEONLINEVIEWITEM_HXX__ -#define __SFX2_TEMPLATEONLINEVIEWITEM_HXX__ - -#include <sfx2/thumbnailviewitem.hxx> -#include <sfx2/templateproperties.hxx> - -class TemplateOnlineViewItem : public ThumbnailViewItem -{ -public: - - TemplateOnlineViewItem (ThumbnailView &rView, Window *pParent); - - virtual ~TemplateOnlineViewItem (); - - void setURL (const rtl::OUString &rURL) { maUrl = rURL; } - - const rtl::OUString& getURL () const { return maUrl; } - - void insertTemplate (const TemplateItemProperties &prop) { maTemplates.push_back(prop); } - - void clearTemplates () { maTemplates.clear(); } - - const std::vector<TemplateItemProperties>& getTemplates () const { return maTemplates; } - -private: - - rtl::OUString maUrl; - std::vector<TemplateItemProperties> maTemplates; -}; - -#endif // __SFX2_TEMPLATEONLINEVIEWITEM_HXX__ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/inc/sfx2/templateremoteview.hxx b/sfx2/inc/sfx2/templateremoteview.hxx new file mode 100644 index 0000000..bbea147 --- /dev/null +++ b/sfx2/inc/sfx2/templateremoteview.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * 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 __SFX2_TEMPLATEREMOTEVIEW_HXX__ +#define __SFX2_TEMPLATEREMOTEVIEW_HXX__ + +#include <sfx2/templateabstractview.hxx> +#include <sfx2/templateproperties.hxx> + +#include <com/sun/star/ucb/XCommandEnvironment.hpp> + +class TemplateRemoteViewItem; + +class TemplateRemoteView : public TemplateAbstractView +{ +public: + + TemplateRemoteView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren); + + virtual ~TemplateRemoteView (); + + // Load repositories from user settings. + virtual void Populate (); + + virtual void reload (); + + virtual void filterTemplatesByApp (const FILTER_APPLICATION &eApp); + + virtual void showOverlay (bool bVisible); + + void setOverlayChangeNameHdl (const Link &rLink); + + bool loadRepository (const sal_uInt16 nRepositoryId, bool bRefresh); + + const std::vector<TemplateRemoteViewItem*>& getRepositories () const { return maRepositories; } + + bool insertRepository (const OUString &rName, const OUString &rURL); + + bool deleteRepository (const sal_uInt16 nRepositoryId); + + void syncRepositories () const; + +private: + + DECL_LINK(ChangeNameHdl, TemplateView*); + +private: + + bool mbIsSynced; + Link maChangeNameHdl; + std::vector<TemplateRemoteViewItem*> maRepositories; + com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xCmdEnv; +}; + +#endif // __SFX2_TEMPLATEREMOTEVIEW_HXX__ + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/inc/sfx2/templateremoteviewitem.hxx b/sfx2/inc/sfx2/templateremoteviewitem.hxx new file mode 100644 index 0000000..396b965 --- /dev/null +++ b/sfx2/inc/sfx2/templateremoteviewitem.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * 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 __SFX2_TEMPLATEREMOTEVIEWITEM_HXX__ +#define __SFX2_TEMPLATEREMOTEVIEWITEM_HXX__ + +#include <sfx2/thumbnailviewitem.hxx> +#include <sfx2/templateproperties.hxx> + +class TemplateRemoteViewItem : public ThumbnailViewItem +{ +public: + + TemplateRemoteViewItem (ThumbnailView &rView, Window *pParent); + + virtual ~TemplateRemoteViewItem (); + + void setURL (const rtl::OUString &rURL) { maUrl = rURL; } + + const rtl::OUString& getURL () const { return maUrl; } + + void insertTemplate (const TemplateItemProperties &prop) { maTemplates.push_back(prop); } + + void clearTemplates () { maTemplates.clear(); } + + const std::vector<TemplateItemProperties>& getTemplates () const { return maTemplates; } + +private: + + rtl::OUString maUrl; + std::vector<TemplateItemProperties> maTemplates; +}; + +#endif // __SFX2_TEMPLATEREMOTEVIEWITEM_HXX__ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/inc/templatedlg.hxx b/sfx2/inc/templatedlg.hxx index 7d6940c..5ba2a87 100644 --- a/sfx2/inc/templatedlg.hxx +++ b/sfx2/inc/templatedlg.hxx @@ -20,7 +20,7 @@ class PopupMenu; class SfxTemplateInfoDlg; class TemplateAbstractView; class TemplateLocalView; -class TemplateOnlineView; +class TemplateRemoteView; class TemplateSearchView; class ThumbnailView; class ThumbnailViewItem; @@ -132,7 +132,7 @@ private: TemplateSearchView *mpSearchView; TemplateAbstractView *mpCurView; TemplateLocalView *maView; - TemplateOnlineView *mpOnlineView; + TemplateRemoteView *mpOnlineView; PopupMenu *mpActionMenu; PopupMenu *mpRepositoryMenu; PopupMenu *mpTemplateDefaultMenu; diff --git a/sfx2/source/control/templateonlineview.cxx b/sfx2/source/control/templateonlineview.cxx deleted file mode 100644 index c608a11..0000000 --- a/sfx2/source/control/templateonlineview.cxx +++ /dev/null @@ -1,340 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * 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/templateonlineview.hxx> - -#include <comphelper/processfactory.hxx> -#include <officecfg/Office/Common.hxx> -#include <sfx2/templateonlineviewitem.hxx> -#include <sfx2/templateview.hxx> -#include <sfx2/templateviewitem.hxx> -#include <svtools/imagemgr.hxx> -#include <tools/urlobj.hxx> -#include <ucbhelper/content.hxx> -#include <ucbhelper/commandenvironment.hxx> - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/task/XInteractionHandler.hpp> -#include <com/sun/star/sdbc/XResultSet.hpp> -#include <com/sun/star/sdbc/XRow.hpp> -#include <com/sun/star/ucb/XContentAccess.hpp> -#include <com/sun/star/ucb/XDynamicResultSet.hpp> - -using namespace com::sun::star; -using namespace com::sun::star::lang; -using namespace com::sun::star::task; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::ucb; -using namespace com::sun::star::uno; - -enum -{ - ROW_TITLE = 1, - ROW_SIZE, - ROW_DATE_MOD, - ROW_DATE_CREATE, - ROW_TARGET_URL, - ROW_IS_HIDDEN, - ROW_IS_REMOTE, - ROW_IS_REMOVEABLE -}; - -TemplateOnlineView::TemplateOnlineView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren) - : TemplateAbstractView(pParent,nWinStyle,bDisableTransientChildren) - , mbIsSynced(true) -{ - mpItemView->SetColor(Color(COL_WHITE)); - mpItemView->setChangeNameHdl(LINK(this,TemplateOnlineView,ChangeNameHdl)); - - Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); - Reference< XInteractionHandler > xGlobalInteractionHandler = Reference< XInteractionHandler >( - xFactory->createInstance("com.sun.star.task.InteractionHandler" ), UNO_QUERY ); - - m_xCmdEnv = new ucbhelper::CommandEnvironment( xGlobalInteractionHandler, Reference< XProgressHandler >() ); -} - -TemplateOnlineView::~TemplateOnlineView () -{ - for (size_t i = 0, n = maRepositories.size(); i < n; ++i) - delete maRepositories[i]; -} - -void TemplateOnlineView::Populate() -{ - uno::Reference < uno::XComponentContext > m_context(comphelper::getProcessComponentContext()); - - // Load from user settings - com::sun::star::uno::Sequence< rtl::OUString > aUrls = - officecfg::Office::Common::Misc::TemplateRepositoryUrls::get(m_context); - - com::sun::star::uno::Sequence< rtl::OUString > aNames = - officecfg::Office::Common::Misc::TemplateRepositoryNames::get(m_context); - - for (sal_Int32 i = 0; i < aUrls.getLength() && i < aNames.getLength(); ++i) - { - TemplateOnlineViewItem *pItem = new TemplateOnlineViewItem(*this,this); - - pItem->mnId = i+1; - pItem->maTitle = aNames[i]; - pItem->setURL(aUrls[i]); - - maRepositories.push_back(pItem); - } -} - -void TemplateOnlineView::reload () -{ - loadRepository(mpItemView->getId(),true); -} - -void TemplateOnlineView::filterTemplatesByApp(const FILTER_APPLICATION &eApp) -{ - if (mpItemView->IsVisible()) - mpItemView->filterItems(ViewFilter_Application(eApp)); -} - -void TemplateOnlineView::showOverlay (bool bVisible) -{ - mpItemView->Show(bVisible); - - // Clear items is the overlay is closed. - if (!bVisible) - { - mpItemView->Clear(); - - setSelectionMode(mbSelectionMode); - } -} - -void TemplateOnlineView::setOverlayChangeNameHdl(const Link &rLink) -{ - maChangeNameHdl = rLink; -} - -bool TemplateOnlineView::loadRepository (const sal_uInt16 nRepositoryId, bool bRefresh) -{ - TemplateOnlineViewItem *pItem = NULL; - - for (size_t i = 0, n = maRepositories.size(); i < n; ++i) - { - if (maRepositories[i]->mnId == nRepositoryId) - { - pItem = maRepositories[i]; - break; - } - } - - if (!pItem) - return false; - - if (!pItem->getTemplates().empty() && !bRefresh) - { - mpItemView->InsertItems(pItem->getTemplates()); - return true; - } - - mpItemView->Clear(); - mpItemView->setId(nRepositoryId); - mpItemView->setName(pItem->maTitle); - - rtl::OUString aURL = static_cast<TemplateOnlineViewItem*>(pItem)->getURL(); - - try - { - - uno::Sequence< rtl::OUString > aProps(8); - - aProps[0] = "Title"; - aProps[1] = "Size"; - aProps[2] = "DateModified"; - aProps[3] = "DateCreated"; - aProps[4] = "TargetURL"; - aProps[5] = "IsHidden"; - aProps[6] = "IsRemote"; - aProps[7] = "IsRemoveable"; - - ucbhelper::Content aContent(aURL,m_xCmdEnv); - - uno::Reference< XResultSet > xResultSet; - uno::Reference< XDynamicResultSet > xDynResultSet; - - ucbhelper::ResultSetInclude eInclude = ucbhelper::INCLUDE_DOCUMENTS_ONLY; - xDynResultSet = aContent.createDynamicCursor( aProps, eInclude ); - - if ( xDynResultSet.is() ) - xResultSet = xDynResultSet->getStaticResultSet(); - - if ( xResultSet.is() ) - { - pItem->clearTemplates(); - - uno::Reference< XRow > xRow( xResultSet, UNO_QUERY ); - uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY ); - - util::DateTime aDT; - std::vector<TemplateItemProperties> aItems; - - sal_uInt16 nIdx = 0; - while ( xResultSet->next() ) - { - bool bIsHidden = xRow->getBoolean( ROW_IS_HIDDEN ); - - // don't show hidden files or anything besides documents - if ( !bIsHidden || xRow->wasNull() ) - { - aDT = xRow->getTimestamp( ROW_DATE_MOD ); - bool bContainsDate = !xRow->wasNull(); - - if ( !bContainsDate ) - { - aDT = xRow->getTimestamp( ROW_DATE_CREATE ); - bContainsDate = !xRow->wasNull(); - } - - rtl::OUString aContentURL = xContentAccess->queryContentIdentifierString(); - rtl::OUString aTargetURL = xRow->getString( ROW_TARGET_URL ); - bool bHasTargetURL = !xRow->wasNull() && !aTargetURL.isEmpty(); - - rtl::OUString sRealURL = bHasTargetURL ? aTargetURL : aContentURL; - - TemplateItemProperties aTemplateItem; - aTemplateItem.nId = nIdx+1; - aTemplateItem.nRegionId = pItem->mnId-1; - aTemplateItem.aPath = sRealURL; - aTemplateItem.aThumbnail = TemplateAbstractView::fetchThumbnail(sRealURL, - TEMPLATE_THUMBNAIL_MAX_WIDTH, - TEMPLATE_THUMBNAIL_MAX_HEIGHT); -// pData->mbIsRemote = xRow->getBoolean( ROW_IS_REMOTE ) && !xRow->wasNull(); -// pData->mbIsRemoveable = xRow->getBoolean( ROW_IS_REMOVEABLE ) && !xRow->wasNull(); - aTemplateItem.aName = xRow->getString( ROW_TITLE ); -// pData->maSize = xRow->getLong( ROW_SIZE ); - - if ( bHasTargetURL && - INetURLObject( aContentURL ).GetProtocol() == INET_PROT_VND_SUN_STAR_HIER ) - { - ucbhelper::Content aCnt( aTargetURL, m_xCmdEnv ); - - try - { -// aCnt.getPropertyValue("Size") >>= pData->maSize; - aCnt.getPropertyValue("DateModified") >>= aDT; - } - catch (...) - {} - } - - aTemplateItem.aType = SvFileInformationManager::GetFileDescription(INetURLObject(sRealURL)); - - pItem->insertTemplate(aTemplateItem); - aItems.push_back(aTemplateItem); - ++nIdx; - } - } - - mpItemView->InsertItems(aItems); - } - } - catch( ucb::CommandAbortedException& ) - { - } - catch( uno::RuntimeException& ) - { - } - catch( uno::Exception& ) - { - } - - return true; -} - -bool TemplateOnlineView::insertRepository(const OUString &rName, const OUString &rURL) -{ - for (size_t i = 0, n = maRepositories.size(); i < n; ++i) - { - if (maRepositories[i]->maTitle == rName) - return false; - } - - TemplateOnlineViewItem *pItem = new TemplateOnlineViewItem(*this,this); - - pItem->mnId = maRepositories.size()+1; - pItem->maTitle = rName; - pItem->setURL(rURL); - - maRepositories.push_back(pItem); - - mbIsSynced = false; - return true; -} - -bool TemplateOnlineView::deleteRepository(const sal_uInt16 nRepositoryId) -{ - bool bRet = false; - - for (size_t i = 0, n = maRepositories.size(); i < n; ++i) - { - if (maRepositories[i]->mnId == nRepositoryId) - { - delete maRepositories[i]; - - maRepositories.erase(maRepositories.begin() + i); - mbIsSynced = false; - bRet = true; - break; - } - } - - return bRet; -} - -void TemplateOnlineView::syncRepositories() const -{ - if (!mbIsSynced) - { - uno::Reference < uno::XComponentContext > pContext(comphelper::getProcessComponentContext()); - boost::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(pContext)); - - size_t nSize = maRepositories.size(); - uno::Sequence<OUString> aUrls(nSize); - uno::Sequence<OUString> aNames(nSize); - - for(size_t i = 0; i < nSize; ++i) - { - aUrls[i] = maRepositories[i]->getURL(); - aNames[i] = maRepositories[i]->maTitle; - } - - officecfg::Office::Common::Misc::TemplateRepositoryUrls::set(aUrls, batch, pContext); - officecfg::Office::Common::Misc::TemplateRepositoryNames::set(aNames, batch, pContext); - batch->commit(); - } -} - -IMPL_LINK (TemplateOnlineView, ChangeNameHdl, TemplateView*, pView) -{ - bool bRet = false; - - // check if there isnt another repository with the same name. - for (size_t i = 0, n = maRepositories.size(); i < n; ++i) - { - if (maRepositories[i]->mnId == pView->getId()) - { - maRepositories[i]->maTitle = pView->getName(); - - bRet = true; - mbIsSynced = false; - maChangeNameHdl.Call(this); - break; - } - } - - return bRet; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/control/templateonlineviewitem.cxx b/sfx2/source/control/templateonlineviewitem.cxx deleted file mode 100644 index e874a3d..0000000 --- a/sfx2/source/control/templateonlineviewitem.cxx +++ /dev/null @@ -1,21 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * 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/templateonlineviewitem.hxx> - -TemplateOnlineViewItem::TemplateOnlineViewItem (ThumbnailView &rView, Window *pParent) - : ThumbnailViewItem(rView,pParent) -{ -} - -TemplateOnlineViewItem::~TemplateOnlineViewItem() -{ -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/control/templateremoteview.cxx b/sfx2/source/control/templateremoteview.cxx new file mode 100644 index 0000000..a5282da --- /dev/null +++ b/sfx2/source/control/templateremoteview.cxx @@ -0,0 +1,340 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * 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/templateremoteview.hxx> + +#include <comphelper/processfactory.hxx> +#include <officecfg/Office/Common.hxx> +#include <sfx2/templateremoteviewitem.hxx> +#include <sfx2/templateview.hxx> +#include <sfx2/templateviewitem.hxx> +#include <svtools/imagemgr.hxx> +#include <tools/urlobj.hxx> +#include <ucbhelper/content.hxx> +#include <ucbhelper/commandenvironment.hxx> + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/ucb/XContentAccess.hpp> +#include <com/sun/star/ucb/XDynamicResultSet.hpp> + +using namespace com::sun::star; +using namespace com::sun::star::lang; +using namespace com::sun::star::task; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::ucb; +using namespace com::sun::star::uno; + +enum +{ + ROW_TITLE = 1, + ROW_SIZE, + ROW_DATE_MOD, + ROW_DATE_CREATE, + ROW_TARGET_URL, + ROW_IS_HIDDEN, + ROW_IS_REMOTE, + ROW_IS_REMOVEABLE +}; + +TemplateRemoteView::TemplateRemoteView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren) + : TemplateAbstractView(pParent,nWinStyle,bDisableTransientChildren) + , mbIsSynced(true) +{ + mpItemView->SetColor(Color(COL_WHITE)); + mpItemView->setChangeNameHdl(LINK(this,TemplateRemoteView,ChangeNameHdl)); + + Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); + Reference< XInteractionHandler > xGlobalInteractionHandler = Reference< XInteractionHandler >( + xFactory->createInstance("com.sun.star.task.InteractionHandler" ), UNO_QUERY ); + + m_xCmdEnv = new ucbhelper::CommandEnvironment( xGlobalInteractionHandler, Reference< XProgressHandler >() ); +} + +TemplateRemoteView::~TemplateRemoteView () +{ + for (size_t i = 0, n = maRepositories.size(); i < n; ++i) + delete maRepositories[i]; +} + +void TemplateRemoteView::Populate() +{ + uno::Reference < uno::XComponentContext > m_context(comphelper::getProcessComponentContext()); + + // Load from user settings + com::sun::star::uno::Sequence< rtl::OUString > aUrls = + officecfg::Office::Common::Misc::TemplateRepositoryUrls::get(m_context); + + com::sun::star::uno::Sequence< rtl::OUString > aNames = + officecfg::Office::Common::Misc::TemplateRepositoryNames::get(m_context); + + for (sal_Int32 i = 0; i < aUrls.getLength() && i < aNames.getLength(); ++i) + { + TemplateRemoteViewItem *pItem = new TemplateRemoteViewItem(*this,this); + + pItem->mnId = i+1; + pItem->maTitle = aNames[i]; + pItem->setURL(aUrls[i]); + + maRepositories.push_back(pItem); + } +} + +void TemplateRemoteView::reload () +{ + loadRepository(mpItemView->getId(),true); +} + +void TemplateRemoteView::filterTemplatesByApp(const FILTER_APPLICATION &eApp) +{ + if (mpItemView->IsVisible()) + mpItemView->filterItems(ViewFilter_Application(eApp)); +} + +void TemplateRemoteView::showOverlay (bool bVisible) +{ + mpItemView->Show(bVisible); + + // Clear items is the overlay is closed. + if (!bVisible) + { + mpItemView->Clear(); + + setSelectionMode(mbSelectionMode); + } +} + +void TemplateRemoteView::setOverlayChangeNameHdl(const Link &rLink) +{ + maChangeNameHdl = rLink; +} + +bool TemplateRemoteView::loadRepository (const sal_uInt16 nRepositoryId, bool bRefresh) +{ + TemplateRemoteViewItem *pItem = NULL; + + for (size_t i = 0, n = maRepositories.size(); i < n; ++i) + { + if (maRepositories[i]->mnId == nRepositoryId) + { + pItem = maRepositories[i]; + break; + } + } + + if (!pItem) + return false; + + if (!pItem->getTemplates().empty() && !bRefresh) + { + mpItemView->InsertItems(pItem->getTemplates()); + return true; + } + + mpItemView->Clear(); + mpItemView->setId(nRepositoryId); + mpItemView->setName(pItem->maTitle); + + rtl::OUString aURL = static_cast<TemplateRemoteViewItem*>(pItem)->getURL(); + + try + { + + uno::Sequence< rtl::OUString > aProps(8); + + aProps[0] = "Title"; + aProps[1] = "Size"; + aProps[2] = "DateModified"; + aProps[3] = "DateCreated"; + aProps[4] = "TargetURL"; + aProps[5] = "IsHidden"; + aProps[6] = "IsRemote"; + aProps[7] = "IsRemoveable"; + + ucbhelper::Content aContent(aURL,m_xCmdEnv); + + uno::Reference< XResultSet > xResultSet; + uno::Reference< XDynamicResultSet > xDynResultSet; + + ucbhelper::ResultSetInclude eInclude = ucbhelper::INCLUDE_DOCUMENTS_ONLY; + xDynResultSet = aContent.createDynamicCursor( aProps, eInclude ); + + if ( xDynResultSet.is() ) + xResultSet = xDynResultSet->getStaticResultSet(); + + if ( xResultSet.is() ) + { + pItem->clearTemplates(); + + uno::Reference< XRow > xRow( xResultSet, UNO_QUERY ); + uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY ); + + util::DateTime aDT; + std::vector<TemplateItemProperties> aItems; + + sal_uInt16 nIdx = 0; + while ( xResultSet->next() ) + { + bool bIsHidden = xRow->getBoolean( ROW_IS_HIDDEN ); + + // don't show hidden files or anything besides documents + if ( !bIsHidden || xRow->wasNull() ) + { + aDT = xRow->getTimestamp( ROW_DATE_MOD ); + bool bContainsDate = !xRow->wasNull(); + + if ( !bContainsDate ) + { + aDT = xRow->getTimestamp( ROW_DATE_CREATE ); + bContainsDate = !xRow->wasNull(); + } + + rtl::OUString aContentURL = xContentAccess->queryContentIdentifierString(); + rtl::OUString aTargetURL = xRow->getString( ROW_TARGET_URL ); + bool bHasTargetURL = !xRow->wasNull() && !aTargetURL.isEmpty(); + + rtl::OUString sRealURL = bHasTargetURL ? aTargetURL : aContentURL; + + TemplateItemProperties aTemplateItem; + aTemplateItem.nId = nIdx+1; + aTemplateItem.nRegionId = pItem->mnId-1; + aTemplateItem.aPath = sRealURL; + aTemplateItem.aThumbnail = TemplateAbstractView::fetchThumbnail(sRealURL, + TEMPLATE_THUMBNAIL_MAX_WIDTH, + TEMPLATE_THUMBNAIL_MAX_HEIGHT); +// pData->mbIsRemote = xRow->getBoolean( ROW_IS_REMOTE ) && !xRow->wasNull(); +// pData->mbIsRemoveable = xRow->getBoolean( ROW_IS_REMOVEABLE ) && !xRow->wasNull(); + aTemplateItem.aName = xRow->getString( ROW_TITLE ); +// pData->maSize = xRow->getLong( ROW_SIZE ); + + if ( bHasTargetURL && + INetURLObject( aContentURL ).GetProtocol() == INET_PROT_VND_SUN_STAR_HIER ) + { + ucbhelper::Content aCnt( aTargetURL, m_xCmdEnv ); + + try + { +// aCnt.getPropertyValue("Size") >>= pData->maSize; + aCnt.getPropertyValue("DateModified") >>= aDT; + } + catch (...) + {} + } + + aTemplateItem.aType = SvFileInformationManager::GetFileDescription(INetURLObject(sRealURL)); + + pItem->insertTemplate(aTemplateItem); + aItems.push_back(aTemplateItem); + ++nIdx; + } + } + + mpItemView->InsertItems(aItems); + } + } + catch( ucb::CommandAbortedException& ) + { + } + catch( uno::RuntimeException& ) + { + } + catch( uno::Exception& ) + { + } + + return true; +} + +bool TemplateRemoteView::insertRepository(const OUString &rName, const OUString &rURL) +{ + for (size_t i = 0, n = maRepositories.size(); i < n; ++i) + { + if (maRepositories[i]->maTitle == rName) + return false; + } + + TemplateRemoteViewItem *pItem = new TemplateRemoteViewItem(*this,this); + + pItem->mnId = maRepositories.size()+1; + pItem->maTitle = rName; + pItem->setURL(rURL); + + maRepositories.push_back(pItem); + + mbIsSynced = false; + return true; +} + +bool TemplateRemoteView::deleteRepository(const sal_uInt16 nRepositoryId) +{ + bool bRet = false; + + for (size_t i = 0, n = maRepositories.size(); i < n; ++i) + { + if (maRepositories[i]->mnId == nRepositoryId) + { + delete maRepositories[i]; + + maRepositories.erase(maRepositories.begin() + i); + mbIsSynced = false; + bRet = true; + break; + } + } + + return bRet; +} + +void TemplateRemoteView::syncRepositories() const +{ + if (!mbIsSynced) + { + uno::Reference < uno::XComponentContext > pContext(comphelper::getProcessComponentContext()); + boost::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(pContext)); + + size_t nSize = maRepositories.size(); + uno::Sequence<OUString> aUrls(nSize); + uno::Sequence<OUString> aNames(nSize); + + for(size_t i = 0; i < nSize; ++i) + { + aUrls[i] = maRepositories[i]->getURL(); + aNames[i] = maRepositories[i]->maTitle; + } + + officecfg::Office::Common::Misc::TemplateRepositoryUrls::set(aUrls, batch, pContext); + officecfg::Office::Common::Misc::TemplateRepositoryNames::set(aNames, batch, pContext); + batch->commit(); + } +} + +IMPL_LINK (TemplateRemoteView, ChangeNameHdl, TemplateView*, pView) +{ + bool bRet = false; + + // check if there isnt another repository with the same name. + for (size_t i = 0, n = maRepositories.size(); i < n; ++i) + { + if (maRepositories[i]->mnId == pView->getId()) + { + maRepositories[i]->maTitle = pView->getName(); + + bRet = true; + mbIsSynced = false; + maChangeNameHdl.Call(this); + break; + } + } + + return bRet; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/control/templateremoteviewitem.cxx b/sfx2/source/control/templateremoteviewitem.cxx new file mode 100644 index 0000000..cb6de5e --- /dev/null +++ b/sfx2/source/control/templateremoteviewitem.cxx @@ -0,0 +1,21 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * 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/templateremoteviewitem.hxx> + +TemplateRemoteViewItem::TemplateRemoteViewItem (ThumbnailView &rView, Window *pParent) + : ThumbnailViewItem(rView,pParent) +{ +} + +TemplateRemoteViewItem::~TemplateRemoteViewItem() +{ +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index fa37e3d..a41d4eb 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -23,8 +23,8 @@ #include <sfx2/templateinfodlg.hxx> #include <sfx2/templatelocalview.hxx> #include <sfx2/templatelocalviewitem.hxx> -#include <sfx2/templateonlineview.hxx> -#include <sfx2/templateonlineviewitem.hxx> +#include <sfx2/templateremoteview.hxx> +#include <sfx2/templateremoteviewitem.hxx> #include <sfx2/templateviewitem.hxx> #include <sfx2/thumbnailviewitem.hxx> #include <sot/storage.hxx> @@ -113,7 +113,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent) mpTemplateBar( new ToolBox(this, SfxResId(TBX_ACTION_TEMPLATES))), mpSearchView(new TemplateSearchView(this)), maView(new TemplateLocalView(this,SfxResId(TEMPLATE_VIEW))), - mpOnlineView(new TemplateOnlineView(this, WB_VSCROLL,false)), + mpOnlineView(new TemplateRemoteView(this, WB_VSCROLL,false)), mbIsSaveMode(false), mxDesktop(comphelper::getProcessServiceFactory()->createInstance( "com.sun.star.frame.Desktop" ),uno::UNO_QUERY ) { @@ -1246,7 +1246,7 @@ void SfxTemplateManagerDlg::createRepositoryMenu() mpRepositoryMenu->InsertItem(MNI_REPOSITORY_LOCAL,SfxResId(STR_REPOSITORY_LOCAL).toString()); - const std::vector<TemplateOnlineViewItem*> &rRepos = mpOnlineView->getRepositories(); + const std::vector<TemplateRemoteViewItem*> &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); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits