sfx2/inc/sfx2/templateabstractview.hxx | 11 + sfx2/inc/sfx2/templatefolderview.hxx | 13 - sfx2/inc/sfx2/thumbnailview.hxx | 8 sfx2/inc/templatedlg.hxx | 18 + sfx2/source/control/templateabstractview.cxx | 143 +++++++++++++ sfx2/source/control/templatefolderview.cxx | 279 +++++++++++++-------------- sfx2/source/control/templateonlineview.cxx | 27 +- sfx2/source/control/templatesearchview.cxx | 15 - sfx2/source/control/thumbnailview.cxx | 16 + sfx2/source/doc/templatedlg.cxx | 215 +++++++++++++++++--- sfx2/source/inc/templatesearchviewitem.hxx | 30 ++ 11 files changed, 564 insertions(+), 211 deletions(-)
New commits: commit 6c0d0bc410b4c5b4c2c559bbe2247d4bbea610c0 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sun Jul 29 21:28:31 2012 -0430 Import templates from a remote repository. Change-Id: I2a3420903b546cc6ead8dcdc6196b31fc2c1a24a diff --git a/sfx2/inc/sfx2/templatefolderview.hxx b/sfx2/inc/sfx2/templatefolderview.hxx index f6cb683..cc7f957 100644 --- a/sfx2/inc/sfx2/templatefolderview.hxx +++ b/sfx2/inc/sfx2/templatefolderview.hxx @@ -58,6 +58,9 @@ public: bool moveTemplates (std::set<const ThumbnailViewItem*> &rItems, const sal_uInt16 nTargetItem, bool bCopy); + void copyFrom (const sal_uInt16 nRegionItemId, const OUString &rName, + const BitmapEx &rThumbnail, const OUString &rPath); + void copyFrom (TemplateFolderViewItem *pItem, const rtl::OUString &rPath); private: diff --git a/sfx2/inc/templatedlg.hxx b/sfx2/inc/templatedlg.hxx index 607d394..bffc83b 100644 --- a/sfx2/inc/templatedlg.hxx +++ b/sfx2/inc/templatedlg.hxx @@ -89,6 +89,8 @@ private: void localMoveTo (sal_uInt16 nMenuId); + void remoteMoveTo (const sal_uInt16 nMenuId); + /** * * Move search result templates stored in the filesystem to another folder. diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index c47b2ab..657e543 100644 --- a/sfx2/source/control/templatefolderview.cxx +++ b/sfx2/source/control/templatefolderview.cxx @@ -551,6 +551,44 @@ bool TemplateFolderView::moveTemplates(std::set<const ThumbnailViewItem *> &rIte return ret; } +void TemplateFolderView::copyFrom(const sal_uInt16 nRegionItemId, const OUString &rName, + const BitmapEx &rThumbnail, const OUString &rPath) +{ + sal_uInt16 nId = 0; + sal_uInt16 nRegionId = nRegionItemId - 1; + + if (!mItemList.empty()) + nId = (mItemList.back())->mnId; + + String aPath(rPath); + + if (mpDocTemplates->CopyFrom(nRegionId,nId,aPath)) + { + TemplateItemProperties aTemplate; + aTemplate.nId = nId+1; + aTemplate.nRegionId = nRegionId; + aTemplate.aName = aPath; + aTemplate.aThumbnail = rThumbnail; + aTemplate.aPath = mpDocTemplates->GetPath(nRegionId,nId); + aTemplate.aType = SvFileInformationManager::GetDescription(INetURLObject(aPath)); + + for (size_t i = 0, n = mItemList.size(); i < n; ++i) + { + if (mItemList[i]->mnId == nRegionItemId) + { + TemplateFolderViewItem *pItem = + static_cast<TemplateFolderViewItem*>(mItemList[i]); + + pItem->maTemplates.push_back(aTemplate); + + lcl_updateThumbnails(pItem); + } + } + + CalculateItemPositions(); + } +} + void TemplateFolderView::copyFrom (TemplateFolderViewItem *pItem, const rtl::OUString &rPath) { sal_uInt16 nId = 0; diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index ea7b009..fffc400 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -552,6 +552,8 @@ IMPL_LINK(SfxTemplateManagerDlg, MoveMenuSelectHdl, Menu*, pMenu) // Check if we are displaying the local or remote templates if (mpCurView == maView) localMoveTo(nMenuId); + else + remoteMoveTo(nMenuId); } return 0; @@ -915,6 +917,42 @@ void SfxTemplateManagerDlg::localMoveTo(sal_uInt16 nMenuId) } } +void SfxTemplateManagerDlg::remoteMoveTo(const sal_uInt16 nMenuId) +{ + sal_uInt16 nItemId = 0; + + if (nMenuId == MNI_MOVE_NEW) + { + InputDialog dlg(SfxResId(STR_INPUT_NEW).toString(),this); + + int ret = dlg.Execute(); + + if (ret) + { + rtl::OUString aName = dlg.getEntryText(); + + if (!aName.isEmpty()) + nItemId = maView->createRegion(aName); + } + } + else + { + nItemId = maView->GetItemId(nMenuId-MNI_MOVE_FOLDER_BASE); + } + + if (nItemId) + { + std::set<const ThumbnailViewItem*>::const_iterator aIter; + for (aIter = maSelTemplates.begin(); aIter != maSelTemplates.end(); ++aIter) + { + const TemplateSearchViewItem *pItem = + static_cast<const TemplateSearchViewItem*>(*aIter); + + maView->copyFrom(nItemId,pItem->maTitle,pItem->maPreview1,pItem->getPath()); + } + } +} + void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nMenuId) { sal_uInt16 nItemId = 0; commit a2a041a0a1b1d00229c25e16d07e39b0e32bec86 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sun Jul 29 19:37:54 2012 -0430 Track overlay item state for online view. Change-Id: Iad58a4f6dd7dec034359e4b29b00fa9531a8b7ec diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 3109d9c..ea7b009 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -200,6 +200,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent) ITEM_MAX_HEIGHT-THUMBNAIL_MAX_HEIGHT, ITEM_PADDING); + mpOnlineView->setOverlayItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVTemplateStateHdl)); mpOnlineView->setOverlayDblClickHdl(LINK(this,SfxTemplateManagerDlg,OpenTemplateHdl)); mpOnlineView->setOverlayCloseHdl(LINK(this,SfxTemplateManagerDlg,CloseOverlayHdl)); commit 2f14792a4d1788fb1d63acacf1d037389c2d6f98 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sun Jul 29 19:13:14 2012 -0430 Move setting overlay item state handler to TemplateAbstractView. - Rename method to a more descriptive name. Change-Id: Ib8fc988209ed6bf1453f3ef6784cae865caf2fe0 diff --git a/sfx2/inc/sfx2/templateabstractview.hxx b/sfx2/inc/sfx2/templateabstractview.hxx index 24ca449..74dcd8a 100644 --- a/sfx2/inc/sfx2/templateabstractview.hxx +++ b/sfx2/inc/sfx2/templateabstractview.hxx @@ -37,6 +37,8 @@ public: void sortOverlayItems (const boost::function<bool (const ThumbnailViewItem*, const ThumbnailViewItem*) > &func); + void setOverlayItemStateHdl (const Link &aLink) { maOverlayItemStateHdl = aLink; } + void setOverlayDblClickHdl (const Link &rLink); void setOverlayCloseHdl (const Link &rLink); @@ -49,9 +51,12 @@ protected: virtual void OnSelectionMode (bool bMode); + DECL_LINK(OverlayItemStateHdl, const ThumbnailViewItem*); + protected: TemplateView *mpItemView; + Link maOverlayItemStateHdl; }; #endif // __SFX2_TEMPLATEABSTRACTVIEW_HXX__ diff --git a/sfx2/inc/sfx2/templatefolderview.hxx b/sfx2/inc/sfx2/templatefolderview.hxx index 5d23b9f..f6cb683 100644 --- a/sfx2/inc/sfx2/templatefolderview.hxx +++ b/sfx2/inc/sfx2/templatefolderview.hxx @@ -47,8 +47,6 @@ public: std::vector<TemplateItemProperties> getFilteredItems (const boost::function<bool (const TemplateItemProperties&) > &rFunc) const; - void setTemplateStateHdl (const Link &aLink) { maTemplateStateHdl = aLink; } - sal_uInt16 createRegion (const rtl::OUString &rName); bool removeRegion (const sal_uInt16 nItemId); @@ -68,8 +66,6 @@ private: virtual void OnItemDblClicked (ThumbnailViewItem *pRegionItem); - DECL_LINK(TVTemplateStateHdl, const ThumbnailViewItem*); - DECL_LINK(ChangeNameHdl, TemplateView*); private: @@ -77,7 +73,6 @@ private: bool mbFilteredResults; // Flag keep track if overlay has been filtered so folders can get filtered too afterwards FILTER_APPLICATION meFilterOption; SfxDocumentTemplates *mpDocTemplates; - Link maTemplateStateHdl; }; #endif // TEMPLATEFOLDERVIEW_HXX diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx index 940874b..8f8d78b 100644 --- a/sfx2/source/control/templateabstractview.cxx +++ b/sfx2/source/control/templateabstractview.cxx @@ -24,12 +24,14 @@ TemplateAbstractView::TemplateAbstractView (Window *pParent, WinBits nWinStyle, : ThumbnailView(pParent,nWinStyle,bDisableTransientChildren), mpItemView(new TemplateView(this)) { + mpItemView->setItemStateHdl(LINK(this,TemplateAbstractView,OverlayItemStateHdl)); } TemplateAbstractView::TemplateAbstractView(Window *pParent, const ResId &rResId, bool bDisableTransientChildren) : ThumbnailView(pParent,rResId,bDisableTransientChildren), mpItemView(new TemplateView(this)) { + mpItemView->setItemStateHdl(LINK(this,TemplateAbstractView,OverlayItemStateHdl)); } TemplateAbstractView::~TemplateAbstractView () @@ -195,4 +197,10 @@ void TemplateAbstractView::OnSelectionMode (bool bMode) ThumbnailView::OnSelectionMode(bMode); } +IMPL_LINK(TemplateAbstractView, OverlayItemStateHdl, const ThumbnailViewItem*, pItem) +{ + maOverlayItemStateHdl.Call((void*)pItem); + return 0; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index c9f53b1..c47b2ab 100644 --- a/sfx2/source/control/templatefolderview.cxx +++ b/sfx2/source/control/templatefolderview.cxx @@ -163,7 +163,6 @@ TemplateFolderView::TemplateFolderView ( Window* pParent, const ResId& rResId, b ITEM_MAX_HEIGHT-THUMBNAIL_MAX_HEIGHT, ITEM_PADDING); - mpItemView->setItemStateHdl(LINK(this,TemplateFolderView,TVTemplateStateHdl)); mpItemView->setChangeNameHdl(LINK(this,TemplateFolderView,ChangeNameHdl)); } @@ -609,12 +608,6 @@ void TemplateFolderView::OnItemDblClicked (ThumbnailViewItem *pRegionItem) mpItemView->Show(); } -IMPL_LINK(TemplateFolderView, TVTemplateStateHdl, const ThumbnailViewItem*, pItem) -{ - maTemplateStateHdl.Call((void*)pItem); - return 0; -} - IMPL_LINK(TemplateFolderView, ChangeNameHdl, TemplateView*, pView) { sal_uInt16 nRegionId = pView->getId(); diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index b977342..3109d9c 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -188,7 +188,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent) ITEM_PADDING); maView->setItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVFolderStateHdl)); - maView->setTemplateStateHdl(LINK(this,SfxTemplateManagerDlg,TVTemplateStateHdl)); + maView->setOverlayItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVTemplateStateHdl)); maView->setOverlayDblClickHdl(LINK(this,SfxTemplateManagerDlg,OpenTemplateHdl)); maView->setOverlayCloseHdl(LINK(this,SfxTemplateManagerDlg,CloseOverlayHdl)); commit 39089e15739eb4de2f055e220976ea501a624e3e Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sun Jul 29 16:10:25 2012 -0430 Fetch thumbnails for templates in a remote repository. Change-Id: I1e2cdfcd7a98a798fde22722e8bba0a1ad8b3cd3 diff --git a/sfx2/source/control/templateonlineview.cxx b/sfx2/source/control/templateonlineview.cxx index a7e1c99..2d6c75d 100644 --- a/sfx2/source/control/templateonlineview.cxx +++ b/sfx2/source/control/templateonlineview.cxx @@ -26,6 +26,13 @@ #include <com/sun/star/ucb/XContentAccess.hpp> #include <com/sun/star/ucb/XDynamicResultSet.hpp> +#define ITEM_MAX_WIDTH 192 +#define ITEM_MAX_HEIGHT 192 +#define ITEM_PADDING 5 +#define ITEM_SPACE 20 +#define THUMBNAIL_MAX_HEIGHT 128 - 2*ITEM_PADDING +#define THUMBNAIL_MAX_WIDTH ITEM_MAX_WIDTH - 2*ITEM_PADDING + using namespace com::sun::star; using namespace com::sun::star::lang; using namespace com::sun::star::task; @@ -176,6 +183,9 @@ void TemplateOnlineView::OnItemDblClicked(ThumbnailViewItem *pItem) aTemplateItem.nId = nIdx+1; aTemplateItem.nRegionId = pItem->mnId-1; aTemplateItem.aPath = sRealURL; + aTemplateItem.aThumbnail = TemplateAbstractView::fetchThumbnail(sRealURL, + THUMBNAIL_MAX_WIDTH, + 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 ); commit 76b7f976e4020b90ef5be7151944dd98abd927d7 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sun Jul 29 15:43:18 2012 -0430 Move fetching thumbnail functions to TemplateAbstractView. - Reallocate lcl_ScaleImg and lcl_fetchThumbnail to be available for other classes to use them. - Mark this functions as static public. Change-Id: Ia64a1bad76d7d47519f50e144daa6ea78dfa0e59 diff --git a/sfx2/inc/sfx2/templateabstractview.hxx b/sfx2/inc/sfx2/templateabstractview.hxx index 8bb6426..24ca449 100644 --- a/sfx2/inc/sfx2/templateabstractview.hxx +++ b/sfx2/inc/sfx2/templateabstractview.hxx @@ -41,6 +41,10 @@ public: void setOverlayCloseHdl (const Link &rLink); + static BitmapEx scaleImg (const BitmapEx &rImg, long width, long height); + + static BitmapEx fetchThumbnail (const rtl::OUString &msURL, long width, long height); + protected: virtual void OnSelectionMode (bool bMode); diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx index 28a78b6..940874b 100644 --- a/sfx2/source/control/templateabstractview.cxx +++ b/sfx2/source/control/templateabstractview.cxx @@ -9,7 +9,16 @@ #include <sfx2/templateabstractview.hxx> +#include <comphelper/processfactory.hxx> #include <sfx2/templateview.hxx> +#include <unotools/ucbstreamhelper.hxx> +#include <vcl/pngread.hxx> + +#include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/embed/XStorage.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> TemplateAbstractView::TemplateAbstractView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren) : ThumbnailView(pParent,nWinStyle,bDisableTransientChildren), @@ -54,6 +63,127 @@ void TemplateAbstractView::setOverlayCloseHdl(const Link &rLink) mpItemView->setCloseHdl(rLink); } +BitmapEx TemplateAbstractView::scaleImg (const BitmapEx &rImg, long width, long height) +{ + BitmapEx aImg = rImg; + + int sWidth = std::min(aImg.GetSizePixel().getWidth(),width); + int sHeight = std::min(aImg.GetSizePixel().getHeight(),height); + + aImg.Scale(Size(sWidth,sHeight),BMP_SCALE_INTERPOLATE); + + return aImg; +} + +BitmapEx TemplateAbstractView::fetchThumbnail (const rtl::OUString &msURL, long width, long height) +{ + using namespace ::com::sun::star; + using namespace ::com::sun::star::uno; + + // Load the thumbnail from a template document. + uno::Reference<io::XInputStream> xIStream; + + uno::Reference< lang::XMultiServiceFactory > xServiceManager (comphelper::getProcessServiceFactory()); + + if (xServiceManager.is()) + { + try + { + uno::Reference<lang::XSingleServiceFactory> xStorageFactory( + xServiceManager->createInstance( "com.sun.star.embed.StorageFactory"), + uno::UNO_QUERY); + + if (xStorageFactory.is()) + { + uno::Sequence<uno::Any> aArgs (2); + aArgs[0] <<= msURL; + aArgs[1] <<= embed::ElementModes::READ; + uno::Reference<embed::XStorage> xDocStorage ( + xStorageFactory->createInstanceWithArguments(aArgs), + uno::UNO_QUERY); + + try + { + if (xDocStorage.is()) + { + uno::Reference<embed::XStorage> xStorage ( + xDocStorage->openStorageElement( + "Thumbnails", + embed::ElementModes::READ)); + if (xStorage.is()) + { + uno::Reference<io::XStream> xThumbnailCopy ( + xStorage->cloneStreamElement("thumbnail.png")); + if (xThumbnailCopy.is()) + xIStream = xThumbnailCopy->getInputStream(); + } + } + } + catch (const uno::Exception& rException) + { + OSL_TRACE ( + "caught exception while trying to access Thumbnail/thumbnail.png of %s: %s", + ::rtl::OUStringToOString(msURL, + RTL_TEXTENCODING_UTF8).getStr(), + ::rtl::OUStringToOString(rException.Message, + RTL_TEXTENCODING_UTF8).getStr()); + } + + try + { + // An (older) implementation had a bug - The storage + // name was "Thumbnail" instead of "Thumbnails". The + // old name is still used as fallback but this code can + // be removed soon. + if ( ! xIStream.is()) + { + uno::Reference<embed::XStorage> xStorage ( + xDocStorage->openStorageElement( "Thumbnail", + embed::ElementModes::READ)); + if (xStorage.is()) + { + uno::Reference<io::XStream> xThumbnailCopy ( + xStorage->cloneStreamElement("thumbnail.png")); + if (xThumbnailCopy.is()) + xIStream = xThumbnailCopy->getInputStream(); + } + } + } + catch (const uno::Exception& rException) + { + OSL_TRACE ( + "caught exception while trying to access Thumbnails/thumbnail.png of %s: %s", + ::rtl::OUStringToOString(msURL, + RTL_TEXTENCODING_UTF8).getStr(), + ::rtl::OUStringToOString(rException.Message, + RTL_TEXTENCODING_UTF8).getStr()); + } + } + } + catch (const uno::Exception& rException) + { + OSL_TRACE ( + "caught exception while trying to access tuhmbnail of %s: %s", + ::rtl::OUStringToOString(msURL, + RTL_TEXTENCODING_UTF8).getStr(), + ::rtl::OUStringToOString(rException.Message, + RTL_TEXTENCODING_UTF8).getStr()); + } + } + + // Extract the image from the stream. + BitmapEx aThumbnail; + if (xIStream.is()) + { + ::std::auto_ptr<SvStream> pStream ( + ::utl::UcbStreamHelper::CreateStream (xIStream)); + ::vcl::PNGReader aReader (*pStream); + aThumbnail = aReader.Read (); + } + + return TemplateAbstractView::scaleImg(aThumbnail,width,height); +} + void TemplateAbstractView::OnSelectionMode (bool bMode) { if (mpItemView->IsVisible()) diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index 5521962..c9f53b1 100644 --- a/sfx2/source/control/templatefolderview.cxx +++ b/sfx2/source/control/templatefolderview.cxx @@ -38,127 +38,6 @@ void lcl_updateThumbnails (TemplateFolderViewItem *pItem); -BitmapEx lcl_ScaleImg (const BitmapEx &rImg, long width, long height) -{ - BitmapEx aImg = rImg; - - int sWidth = std::min(aImg.GetSizePixel().getWidth(),width); - int sHeight = std::min(aImg.GetSizePixel().getHeight(),height); - - aImg.Scale(Size(sWidth,sHeight),BMP_SCALE_INTERPOLATE); - - return aImg; -} - -BitmapEx lcl_fetchThumbnail (const rtl::OUString &msURL, long width, long height) -{ - using namespace ::com::sun::star; - using namespace ::com::sun::star::uno; - - // Load the thumbnail from a template document. - uno::Reference<io::XInputStream> xIStream; - - uno::Reference< lang::XMultiServiceFactory > xServiceManager ( - ::comphelper::getProcessServiceFactory()); - if (xServiceManager.is()) - { - try - { - uno::Reference<lang::XSingleServiceFactory> xStorageFactory( - xServiceManager->createInstance( "com.sun.star.embed.StorageFactory"), - uno::UNO_QUERY); - - if (xStorageFactory.is()) - { - uno::Sequence<uno::Any> aArgs (2); - aArgs[0] <<= msURL; - aArgs[1] <<= embed::ElementModes::READ; - uno::Reference<embed::XStorage> xDocStorage ( - xStorageFactory->createInstanceWithArguments(aArgs), - uno::UNO_QUERY); - - try - { - if (xDocStorage.is()) - { - uno::Reference<embed::XStorage> xStorage ( - xDocStorage->openStorageElement( - "Thumbnails", - embed::ElementModes::READ)); - if (xStorage.is()) - { - uno::Reference<io::XStream> xThumbnailCopy ( - xStorage->cloneStreamElement("thumbnail.png")); - if (xThumbnailCopy.is()) - xIStream = xThumbnailCopy->getInputStream(); - } - } - } - catch (const uno::Exception& rException) - { - OSL_TRACE ( - "caught exception while trying to access Thumbnail/thumbnail.png of %s: %s", - ::rtl::OUStringToOString(msURL, - RTL_TEXTENCODING_UTF8).getStr(), - ::rtl::OUStringToOString(rException.Message, - RTL_TEXTENCODING_UTF8).getStr()); - } - - try - { - // An (older) implementation had a bug - The storage - // name was "Thumbnail" instead of "Thumbnails". The - // old name is still used as fallback but this code can - // be removed soon. - if ( ! xIStream.is()) - { - uno::Reference<embed::XStorage> xStorage ( - xDocStorage->openStorageElement( "Thumbnail", - embed::ElementModes::READ)); - if (xStorage.is()) - { - uno::Reference<io::XStream> xThumbnailCopy ( - xStorage->cloneStreamElement("thumbnail.png")); - if (xThumbnailCopy.is()) - xIStream = xThumbnailCopy->getInputStream(); - } - } - } - catch (const uno::Exception& rException) - { - OSL_TRACE ( - "caught exception while trying to access Thumbnails/thumbnail.png of %s: %s", - ::rtl::OUStringToOString(msURL, - RTL_TEXTENCODING_UTF8).getStr(), - ::rtl::OUStringToOString(rException.Message, - RTL_TEXTENCODING_UTF8).getStr()); - } - } - } - catch (const uno::Exception& rException) - { - OSL_TRACE ( - "caught exception while trying to access tuhmbnail of %s: %s", - ::rtl::OUStringToOString(msURL, - RTL_TEXTENCODING_UTF8).getStr(), - ::rtl::OUStringToOString(rException.Message, - RTL_TEXTENCODING_UTF8).getStr()); - } - } - - // Extract the image from the stream. - BitmapEx aThumbnail; - if (xIStream.is()) - { - ::std::auto_ptr<SvStream> pStream ( - ::utl::UcbStreamHelper::CreateStream (xIStream)); - ::vcl::PNGReader aReader (*pStream); - aThumbnail = aReader.Read (); - } - - return lcl_ScaleImg(aThumbnail,width,height); -} - // Display template items depending on the generator application class ViewFilter_Application { @@ -331,7 +210,7 @@ void TemplateFolderView::Populate () aProperties.aName = aName; aProperties.aPath = aURL; aProperties.aType = aType; - aProperties.aThumbnail = lcl_fetchThumbnail(aURL,THUMBNAIL_MAX_WIDTH,THUMBNAIL_MAX_HEIGHT); + aProperties.aThumbnail = TemplateAbstractView::fetchThumbnail(aURL,THUMBNAIL_MAX_WIDTH,THUMBNAIL_MAX_HEIGHT); pItem->maTemplates.push_back(aProperties); } @@ -688,7 +567,7 @@ void TemplateFolderView::copyFrom (TemplateFolderViewItem *pItem, const rtl::OUS aTemplate.nId = nId; aTemplate.nRegionId = nRegionId; aTemplate.aName = mpDocTemplates->GetName(nRegionId,nId); - aTemplate.aThumbnail = lcl_fetchThumbnail(rPath,128,128); + aTemplate.aThumbnail = TemplateAbstractView::fetchThumbnail(rPath,128,128); aTemplate.aPath = rPath; aTemplate.aType = SvFileInformationManager::GetDescription(INetURLObject(rPath)); @@ -765,15 +644,15 @@ void lcl_updateThumbnails (TemplateFolderViewItem *pItem) { if (i == 0) { - pItem->maPreview1 = lcl_ScaleImg(pItem->maTemplates[i].aThumbnail, - THUMBNAIL_MAX_WIDTH*0.75, - THUMBNAIL_MAX_HEIGHT*0.75); + pItem->maPreview1 = TemplateAbstractView::scaleImg(pItem->maTemplates[i].aThumbnail, + THUMBNAIL_MAX_WIDTH*0.75, + THUMBNAIL_MAX_HEIGHT*0.75); } else { - pItem->maPreview2 = lcl_ScaleImg(pItem->maTemplates[i].aThumbnail, - THUMBNAIL_MAX_WIDTH*0.75, - THUMBNAIL_MAX_HEIGHT*0.75); + pItem->maPreview2 = TemplateAbstractView::scaleImg(pItem->maTemplates[i].aThumbnail, + THUMBNAIL_MAX_WIDTH*0.75, + THUMBNAIL_MAX_HEIGHT*0.75); } } } commit 724d575e79797bb2b734d39f91ae5e2806f2e528 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sun Jul 29 14:39:45 2012 -0430 Open remote templates when double clicking in the thumbnail. Change-Id: I74dfd2b9c117e577e777e8e5defa6f2964d97292 diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 1256fdf..b977342 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -200,6 +200,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent) ITEM_MAX_HEIGHT-THUMBNAIL_MAX_HEIGHT, ITEM_PADDING); + mpOnlineView->setOverlayDblClickHdl(LINK(this,SfxTemplateManagerDlg,OpenTemplateHdl)); mpOnlineView->setOverlayCloseHdl(LINK(this,SfxTemplateManagerDlg,CloseOverlayHdl)); mpSearchView->SetSizePixel(aThumbSize); commit 3d05b0c22708bdb876e45e344cad8cf5a6b71b7b Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sun Jul 29 14:28:11 2012 -0430 Fetch only documents. Change-Id: If775f159ba94d364f28c675a9493fd3c19d4a2e9 diff --git a/sfx2/source/control/templateonlineview.cxx b/sfx2/source/control/templateonlineview.cxx index a776515..a7e1c99 100644 --- a/sfx2/source/control/templateonlineview.cxx +++ b/sfx2/source/control/templateonlineview.cxx @@ -39,7 +39,6 @@ enum ROW_SIZE, ROW_DATE_MOD, ROW_DATE_CREATE, - ROW_IS_DOCUMENT, ROW_TARGET_URL, ROW_IS_HIDDEN, ROW_IS_REMOTE, @@ -120,24 +119,23 @@ void TemplateOnlineView::OnItemDblClicked(ThumbnailViewItem *pItem) try { - uno::Sequence< rtl::OUString > aProps(9); + uno::Sequence< rtl::OUString > aProps(8); aProps[0] = "Title"; aProps[1] = "Size"; aProps[2] = "DateModified"; aProps[3] = "DateCreated"; - aProps[4] = "IsDocument"; - aProps[5] = "TargetURL"; - aProps[6] = "IsHidden"; - aProps[7] = "IsRemote"; - aProps[8] = "IsRemoveable"; + 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_FOLDERS_AND_DOCUMENTS; + ucbhelper::ResultSetInclude eInclude = ucbhelper::INCLUDE_DOCUMENTS_ONLY; xDynResultSet = aContent.createDynamicCursor( aProps, eInclude ); if ( xDynResultSet.is() ) @@ -154,11 +152,10 @@ void TemplateOnlineView::OnItemDblClicked(ThumbnailViewItem *pItem) sal_uInt16 nIdx = 0; while ( xResultSet->next() ) { - bool bIsDocument = xRow->getBoolean( ROW_IS_DOCUMENT ) && !xRow->wasNull(); bool bIsHidden = xRow->getBoolean( ROW_IS_HIDDEN ); // don't show hidden files or anything besides documents - if ( bIsDocument && (!bIsHidden || xRow->wasNull()) ) + if ( !bIsHidden || xRow->wasNull() ) { aDT = xRow->getTimestamp( ROW_DATE_MOD ); bool bContainsDate = !xRow->wasNull(); commit 3390725129eb694cb42e99086b90f34c8aa0e14d Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sat Jul 28 23:07:55 2012 -0430 Close dialog after opening a template to edit it. Change-Id: I9d2aaddb6aece8db87d82d4a889be8e545303dd3 diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 41edc77..1256fdf 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -757,6 +757,8 @@ void SfxTemplateManagerDlg::OnTemplateEdit () { } } + + Close(); } void SfxTemplateManagerDlg::OnTemplateProperties () commit 194429cea1f55f385de9b1ad8793fb1688e71670 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sat Jul 28 23:04:50 2012 -0430 Hide folder actions is all selected folders were deleted. Change-Id: Id9056cbed6f2b3a28a8008a58a7b94a70f1916fc diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 118e063..41edc77 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -815,6 +815,12 @@ void SfxTemplateManagerDlg::OnFolderDelete() else ++pIter; } + + if (maSelFolders.empty()) + { + mpViewBar->EnableItem(TBI_TEMPLATE_IMPORT,false); + mpViewBar->HideItem(TBI_TEMPLATE_FOLDER_DEL); + } } void SfxTemplateManagerDlg::centerTopButtons() commit 3187312a1e2de62fde48e600c97ad891bbf82c5d Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sat Jul 28 22:36:17 2012 -0430 Erase templates selected in the search view. Change-Id: I3c1035d061ec6c3e7430a1703d6873dc6d2b1d33 diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index bdf48b3..118e063 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -765,13 +765,43 @@ void SfxTemplateManagerDlg::OnTemplateProperties () void SfxTemplateManagerDlg::OnTemplateDelete () { - std::set<const ThumbnailViewItem*>::const_iterator pIter; - for (pIter = maSelTemplates.begin(); pIter != maSelTemplates.end();) + if (mpSearchView->IsVisible()) { - if (maView->removeTemplate((*pIter)->mnId,maView->getOverlayRegionId()+1)) - maSelTemplates.erase(pIter++); - else - ++pIter; + std::set<const ThumbnailViewItem*>::const_iterator pIter; + for (pIter = maSelTemplates.begin(); pIter != maSelTemplates.end();) + { + const TemplateSearchViewItem *pItem = + static_cast<const TemplateSearchViewItem*>(*pIter); + + sal_uInt16 nItemId = pItem->mnIdx + 1; + sal_uInt16 nItemRegionId = pItem->mnRegionId + 1; + + if (maView->removeTemplate(nItemId,nItemRegionId)) + maSelTemplates.erase(pIter++); + else + ++pIter; + } + + // Update search results + if (maSelTemplates.empty()) + { + mpTemplateBar->Show(false); + mpViewBar->Show(); + mpActionBar->Show(); + } + + SearchUpdateHdl(mpSearchEdit); + } + else + { + std::set<const ThumbnailViewItem*>::const_iterator pIter; + for (pIter = maSelTemplates.begin(); pIter != maSelTemplates.end();) + { + if (maView->removeTemplate((*pIter)->mnId,maView->getOverlayRegionId()+1)) + maSelTemplates.erase(pIter++); + else + ++pIter; + } } } commit 29536cbd49c4bb51cb668f8f2ce45365b29d8333 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sat Jul 28 22:28:59 2012 -0430 Add template region source as an argument to removeTemplate method. - Update OnTemplateDelete to reflect changes. Change-Id: Idd8f39d490168c5c826b0c917c8e0c3e3b78c694 diff --git a/sfx2/inc/sfx2/templatefolderview.hxx b/sfx2/inc/sfx2/templatefolderview.hxx index e11d524..5d23b9f 100644 --- a/sfx2/inc/sfx2/templatefolderview.hxx +++ b/sfx2/inc/sfx2/templatefolderview.hxx @@ -53,7 +53,7 @@ public: bool removeRegion (const sal_uInt16 nItemId); - bool removeTemplate (const sal_uInt16 nItemId); + bool removeTemplate (const sal_uInt16 nItemId, const sal_uInt16 nSrcItemId); bool moveTemplate (const ThumbnailViewItem* pItem, const sal_uInt16 nSrcItem, const sal_uInt16 nTargetItem, bool bCopy); diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index 117899f..5521962 100644 --- a/sfx2/source/control/templatefolderview.cxx +++ b/sfx2/source/control/templatefolderview.cxx @@ -457,10 +457,9 @@ bool TemplateFolderView::removeRegion(const sal_uInt16 nItemId) return true; } -bool TemplateFolderView::removeTemplate (const sal_uInt16 nItemId) +bool TemplateFolderView::removeTemplate (const sal_uInt16 nItemId, const sal_uInt16 nSrcItemId) { - sal_uInt16 nRegionId = mpItemView->getId(); - sal_uInt16 nItemRegionId = nRegionId + 1; + sal_uInt16 nRegionId = nSrcItemId - 1; sal_uInt16 nTemplateId = nItemId - 1; if (!mpDocTemplates->Delete(nRegionId,nTemplateId)) @@ -468,7 +467,7 @@ bool TemplateFolderView::removeTemplate (const sal_uInt16 nItemId) for (size_t i = 0, n = mItemList.size(); i < n; ++i) { - if (mItemList[i]->mnId == nItemRegionId) + if (mItemList[i]->mnId == nSrcItemId) { TemplateFolderViewItem *pItem = static_cast<TemplateFolderViewItem*>(mItemList[i]); diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 5011e8a..bdf48b3 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -768,7 +768,7 @@ void SfxTemplateManagerDlg::OnTemplateDelete () std::set<const ThumbnailViewItem*>::const_iterator pIter; for (pIter = maSelTemplates.begin(); pIter != maSelTemplates.end();) { - if (maView->removeTemplate((*pIter)->mnId)) + if (maView->removeTemplate((*pIter)->mnId,maView->getOverlayRegionId()+1)) maSelTemplates.erase(pIter++); else ++pIter; commit 80acf6916401420991cc7a7a83063e893b119a24 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sat Jul 28 22:27:31 2012 -0430 Add a method to return overlay current region id. Change-Id: Icdbd01b050af9fc1f0532c20885cbad13605cdcd diff --git a/sfx2/inc/sfx2/templateabstractview.hxx b/sfx2/inc/sfx2/templateabstractview.hxx index 323e125..8bb6426 100644 --- a/sfx2/inc/sfx2/templateabstractview.hxx +++ b/sfx2/inc/sfx2/templateabstractview.hxx @@ -29,6 +29,8 @@ public: virtual void showOverlay (bool bVisible) = 0; + sal_uInt16 getOverlayRegionId () const; + // Check if the overlay is visible or not. bool isOverlayVisible () const; diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx index b32bdd2..28a78b6 100644 --- a/sfx2/source/control/templateabstractview.cxx +++ b/sfx2/source/control/templateabstractview.cxx @@ -28,6 +28,11 @@ TemplateAbstractView::~TemplateAbstractView () delete mpItemView; } +sal_uInt16 TemplateAbstractView::getOverlayRegionId() const +{ + return mpItemView->getId(); +} + bool TemplateAbstractView::isOverlayVisible () const { return mpItemView->IsVisible(); commit eaa24544961408a62b8fe20996e773261e745c06 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sat Jul 28 20:41:14 2012 -0430 Update search view after moving templates from the results. Change-Id: I894d786b69c52deb5756d4c17881acb25e861207 diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 739ff13..5011e8a 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -24,6 +24,7 @@ #include <tools/urlobj.hxx> #include <unotools/moduleoptions.hxx> #include <vcl/edit.hxx> +#include <vcl/msgbox.hxx> #include <vcl/toolbox.hxx> #include <com/sun/star/beans/PropertyValue.hpp> @@ -913,6 +914,11 @@ void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nMenuId) } } } + + // Deselect all items and update search results + mpSearchView->unselectItems(); + + SearchUpdateHdl(mpSearchEdit); } void lcl_createTemplate(uno::Reference< com::sun::star::frame::XComponentLoader > xDesktop, commit d4af0655a3fc765b73dd8b36442f8139e0d1ea03 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sat Jul 28 20:03:18 2012 -0430 Add a method to deselect all currently selected items in the view. Change-Id: I4d05e5b851b028798c75a7767706b5aabb94e4b6 diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index da69b2b..24827ee 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -221,6 +221,14 @@ public: bool IsItemSelected( sal_uInt16 nItemId ) const { return nItemId == mnSelItemId; } + /** + * + * @brief unselect all current selected items. + * + **/ + + void unselectItems (); + rtl::OUString GetItemText( sal_uInt16 nItemId ) const; void SetColor( const Color& rColor ); diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 886ec9b..f6042b5 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -1042,6 +1042,22 @@ void ThumbnailView::SelectItem( sal_uInt16 nItemId ) } } +void ThumbnailView::unselectItems() +{ + for (size_t i = 0, n = mItemList.size(); i < n; ++i) + { + if (mItemList[i]->isSelected()) + { + mItemList[i]->setSelection(false); + + maItemStateHdl.Call(mItemList[i]); + } + } + + if (IsReallyVisible() && IsUpdateMode()) + Invalidate(); +} + rtl::OUString ThumbnailView::GetItemText( sal_uInt16 nItemId ) const { size_t nPos = GetItemPos( nItemId ); commit e3bb872add7705ff956056c5a86cbdd1fe8e34c8 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sat Jul 28 18:02:34 2012 -0430 Move/Copy selected templates in the search view to target region. Change-Id: I94dfc3610925b37ca25e1fe1ea591d9b5abbeae1 diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 6c942b5..739ff13 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -11,6 +11,7 @@ #include "inputdlg.hxx" #include "templatesearchview.hxx" +#include "templatesearchviewitem.hxx" #include <comphelper/processfactory.hxx> #include <sfx2/filedlghelper.hxx> @@ -900,9 +901,16 @@ void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nMenuId) { // Move templates to desired folder if for some reason move fails // try copying them. - if (!maView->moveTemplates(maSelTemplates,nItemId,false) && - !maView->moveTemplates(maSelTemplates,nItemId,true)) + std::set<const ThumbnailViewItem*>::const_iterator aIter; + for (aIter = maSelTemplates.begin(); aIter != maSelTemplates.end(); ++aIter) { + const TemplateSearchViewItem *pItem = + static_cast<const TemplateSearchViewItem*>(*aIter); + + if(!maView->moveTemplate(pItem,pItem->mnRegionId+1,nItemId,false) + && !maView->moveTemplate(pItem,pItem->mnRegionId+1,nItemId,true)) + { + } } } } commit 4b0999916a17327337129dea7695648be1478529 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sat Jul 28 17:43:45 2012 -0430 Implement moveTemplate function for a single template. - Copy or move a template from a source region to a target region. Change-Id: I6dc2eedd0b8fdb310d67c63c6c315bf51d03e881 diff --git a/sfx2/inc/sfx2/templatefolderview.hxx b/sfx2/inc/sfx2/templatefolderview.hxx index 5274dd6..e11d524 100644 --- a/sfx2/inc/sfx2/templatefolderview.hxx +++ b/sfx2/inc/sfx2/templatefolderview.hxx @@ -55,6 +55,9 @@ public: bool removeTemplate (const sal_uInt16 nItemId); + bool moveTemplate (const ThumbnailViewItem* pItem, const sal_uInt16 nSrcItem, + const sal_uInt16 nTargetItem, bool bCopy); + bool moveTemplates (std::set<const ThumbnailViewItem*> &rItems, const sal_uInt16 nTargetItem, bool bCopy); void copyFrom (TemplateFolderViewItem *pItem, const rtl::OUString &rPath); diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index 59ef94b..117899f 100644 --- a/sfx2/source/control/templatefolderview.cxx +++ b/sfx2/source/control/templatefolderview.cxx @@ -496,6 +496,92 @@ bool TemplateFolderView::removeTemplate (const sal_uInt16 nItemId) return true; } +bool TemplateFolderView::moveTemplate (const ThumbnailViewItem *pItem, const sal_uInt16 nSrcItem, + const sal_uInt16 nTargetItem, bool bCopy) +{ + bool bRet = true; + bool bRefresh = false; + + TemplateFolderViewItem *pTarget = NULL; + TemplateFolderViewItem *pSrc = NULL; + + for (size_t i = 0, n = mItemList.size(); i < n; ++i) + { + if (mItemList[i]->mnId == nTargetItem) + pTarget = static_cast<TemplateFolderViewItem*>(mItemList[i]); + else if (mItemList[i]->mnId == nSrcItem) + pSrc = static_cast<TemplateFolderViewItem*>(mItemList[i]); + } + + if (pTarget && pSrc) + { + sal_uInt16 nSrcRegionId = nSrcItem-1; + sal_uInt16 nTargetRegion = pTarget->mnId-1; + sal_uInt16 nTargetIdx = mpDocTemplates->GetCount(nTargetRegion); // Next Idx + + const TemplateViewItem *pViewItem = static_cast<const TemplateViewItem*>(pItem); + + bool bOK; + + if (bCopy) + bOK = mpDocTemplates->Copy(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnId-1); + else + bOK = mpDocTemplates->Move(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnId-1); + + if (!bOK) + return false; + + // move template to destination + + TemplateItemProperties aTemplateItem; + aTemplateItem.nId = nTargetIdx + 1; + aTemplateItem.nRegionId = nTargetRegion; + aTemplateItem.aName = pViewItem->maTitle; + aTemplateItem.aPath = pViewItem->getPath(); + aTemplateItem.aType = pViewItem->getFileType(); + aTemplateItem.aThumbnail = pViewItem->maPreview1; + + pTarget->maTemplates.push_back(aTemplateItem); + + if (!bCopy) + { + // remove template from overlay and from cached data + + std::vector<TemplateItemProperties>::iterator aIter; + for (aIter = pSrc->maTemplates.begin(); aIter != pSrc->maTemplates.end(); ++aIter) + { + if (aIter->nId == pViewItem->mnId) + { + pSrc->maTemplates.erase(aIter); + + mpItemView->RemoveItem(pViewItem->mnId); + break; + } + } + } + + bRefresh = true; + } + else + bRet = false; + + if (bRefresh) + { + lcl_updateThumbnails(pSrc); + lcl_updateThumbnails(pTarget); + + CalculateItemPositions(); + + if (IsReallyVisible() && IsUpdateMode()) + { + Invalidate(); + mpItemView->Invalidate(); + } + } + + return bRet; +} + bool TemplateFolderView::moveTemplates(std::set<const ThumbnailViewItem *> &rItems, const sal_uInt16 nTargetItem, bool bCopy) { commit 7cc0477506ffa023b6e360863e43c8afc90b8712 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sat Jul 28 17:21:47 2012 -0430 Move TemplateSearchViewItem to its own header. Change-Id: Ie00b5e81fdae69dea31be2a680b0d37f867b5f4e diff --git a/sfx2/source/control/templatesearchview.cxx b/sfx2/source/control/templatesearchview.cxx index edd4bd4..620d815 100644 --- a/sfx2/source/control/templatesearchview.cxx +++ b/sfx2/source/control/templatesearchview.cxx @@ -9,20 +9,7 @@ #include "templatesearchview.hxx" -#include <sfx2/templateviewitem.hxx> - -struct TemplateSearchViewItem : public TemplateViewItem -{ - TemplateSearchViewItem (ThumbnailView &rView, Window *pParent) - : TemplateViewItem(rView,pParent) - {} - - virtual ~TemplateSearchViewItem () - {} - - sal_uInt16 mnIdx; // Template associated Index - sal_uInt16 mnRegionId; // Template associated Region id -}; +#include "templatesearchviewitem.hxx" TemplateSearchView::TemplateSearchView (Window *pParent, WinBits nWinStyle) : ThumbnailView(pParent,nWinStyle) diff --git a/sfx2/source/inc/templatesearchviewitem.hxx b/sfx2/source/inc/templatesearchviewitem.hxx new file mode 100644 index 0000000..185560a --- /dev/null +++ b/sfx2/source/inc/templatesearchviewitem.hxx @@ -0,0 +1,30 @@ +/* -*- 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_TEMPLATESEARCHVIEWITEM_HXX__ +#define __SFX2_TEMPLATESEARCHVIEWITEM_HXX__ + +#include <sfx2/templateviewitem.hxx> + +struct TemplateSearchViewItem : public TemplateViewItem +{ + TemplateSearchViewItem (ThumbnailView &rView, Window *pParent) + : TemplateViewItem(rView,pParent) + {} + + virtual ~TemplateSearchViewItem () + {} + + sal_uInt16 mnIdx; // Template associated Index + sal_uInt16 mnRegionId; // Template associated Region id +}; + +#endif // __SFX2_TEMPLATESEARCHVIEWITEM_HXX__ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 5dd1eb17806a7acebdb0323d76111006ce3ee7fb Author: Rafael Dominguez <venccsra...@gmail.com> Date: Sat Jul 28 13:26:20 2012 -0430 Return correct new region id. Change-Id: Ifbe3a0dd13a286b6e39883ebd9a7e8d79c4602cf diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index b7c5310..59ef94b 100644 --- a/sfx2/source/control/templatefolderview.cxx +++ b/sfx2/source/control/templatefolderview.cxx @@ -442,7 +442,7 @@ sal_uInt16 TemplateFolderView::createRegion(const rtl::OUString &rName) if ( IsReallyVisible() && IsUpdateMode() ) Invalidate(); - return true; + return pItem->mnId; } bool TemplateFolderView::removeRegion(const sal_uInt16 nItemId) commit 72b48950556820cac8198da467254b25f2e054c4 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Fri Jul 27 09:10:24 2012 -0430 Do different action when moving templates depending on the active view. Change-Id: I97726bf0d8e26f833fc96274a908e72c6110d86b diff --git a/sfx2/inc/templatedlg.hxx b/sfx2/inc/templatedlg.hxx index 23fd9a4..607d394 100644 --- a/sfx2/inc/templatedlg.hxx +++ b/sfx2/inc/templatedlg.hxx @@ -81,6 +81,22 @@ private: // Exchange view between local/online view. void switchMainView (bool bDisplayLocal); + /** + * + * Move templates stored in the filesystem to another folder. + * + **/ + + void localMoveTo (sal_uInt16 nMenuId); + + /** + * + * Move search result templates stored in the filesystem to another folder. + * + **/ + + void localSearchMoveTo (sal_uInt16 nMenuId); + private: PushButton aButtonAll; diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index a6afee1..6c942b5 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -537,42 +537,17 @@ IMPL_LINK(SfxTemplateManagerDlg, MoveMenuSelectHdl, Menu*, pMenu) { sal_uInt16 nMenuId = pMenu->GetCurItemId(); - if (nMenuId == MNI_MOVE_NEW) + if (mpSearchView->IsVisible()) { - InputDialog dlg(SfxResId(STR_INPUT_NEW).toString(),this); - - int ret = dlg.Execute(); - - if (ret) - { - rtl::OUString aName = dlg.getEntryText(); - - if (!aName.isEmpty()) - { - sal_uInt16 nNewRegionId = maView->createRegion(aName); - - if (nNewRegionId) - { - // Move templates to desired folder if for some reason move fails - // try copying them. - if (!maView->moveTemplates(maSelTemplates,nNewRegionId,false) && - !maView->moveTemplates(maSelTemplates,nNewRegionId,true)) - { - } - } - } - } + // Check if we are searching the local or remote templates + if (mpCurView == maView) + localSearchMoveTo(nMenuId); } else { - // Try to move the template, if isnt possible try to copy it. - - sal_uInt16 nItemId = maView->GetItemId(nMenuId-MNI_MOVE_FOLDER_BASE); - - if (!maView->moveTemplates(maSelTemplates,nItemId,false) && - !maView->moveTemplates(maSelTemplates,nItemId,true)) - { - } + // Check if we are displaying the local or remote templates + if (mpCurView == maView) + localMoveTo(nMenuId); } return 0; @@ -864,6 +839,74 @@ void SfxTemplateManagerDlg::switchMainView(bool bDisplayLocal) } } +void SfxTemplateManagerDlg::localMoveTo(sal_uInt16 nMenuId) +{ + sal_uInt16 nItemId = 0; + + if (nMenuId == MNI_MOVE_NEW) + { + InputDialog dlg(SfxResId(STR_INPUT_NEW).toString(),this); + + int ret = dlg.Execute(); + + if (ret) + { + rtl::OUString aName = dlg.getEntryText(); + + if (!aName.isEmpty()) + nItemId = maView->createRegion(aName); + } + } + else + { + nItemId = maView->GetItemId(nMenuId-MNI_MOVE_FOLDER_BASE); + } + + if (nItemId) + { + // Move templates to desired folder if for some reason move fails + // try copying them. + if (!maView->moveTemplates(maSelTemplates,nItemId,false) && + !maView->moveTemplates(maSelTemplates,nItemId,true)) + { + } + } +} + +void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nMenuId) +{ + sal_uInt16 nItemId = 0; + + if (nMenuId == MNI_MOVE_NEW) + { + InputDialog dlg(SfxResId(STR_INPUT_NEW).toString(),this); + + int ret = dlg.Execute(); + + if (ret) + { + rtl::OUString aName = dlg.getEntryText(); + + if (!aName.isEmpty()) + nItemId = maView->createRegion(aName); + } + } + else + { + nItemId = maView->GetItemId(nMenuId-MNI_MOVE_FOLDER_BASE); + } + + if (nItemId) + { + // Move templates to desired folder if for some reason move fails + // try copying them. + if (!maView->moveTemplates(maSelTemplates,nItemId,false) && + !maView->moveTemplates(maSelTemplates,nItemId,true)) + { + } + } +} + void lcl_createTemplate(uno::Reference< com::sun::star::frame::XComponentLoader > xDesktop, const FILTER_APPLICATION eApp) { commit c180c37c032532df0534856cd1d9791c0e965d49 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Jul 26 19:28:35 2012 -0430 Set SearchView item state handle. Change-Id: I60d8552de9648b0b5f360612fa46b474e8dd9734 diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 4add070..a6afee1 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -207,6 +207,8 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent) ITEM_MAX_HEIGHT-THUMBNAIL_MAX_HEIGHT, ITEM_PADDING); + mpSearchView->setItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVTemplateStateHdl)); + // Set OK button position Point aBtnPos; Size aBtnSize = maButtonClose.GetSizePixel(); commit 1d6d7bff8d3c55bf974d504efe3fbb591f2f597d Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Jul 26 16:49:23 2012 -0430 Display all available folders when all button is clicked. Change-Id: Ia7f0acca967c5ef4057ad0f5f891f095efa5cf1e diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index 3972a49..b7c5310 100644 --- a/sfx2/source/control/templatefolderview.cxx +++ b/sfx2/source/control/templatefolderview.cxx @@ -242,7 +242,7 @@ public: bool isValid (const rtl::OUString &rType) const { - bool bRet = false; + bool bRet = true; if (meApp == FILTER_APP_WRITER) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits