sfx2/inc/sfx2/templateabstractview.hxx | 5 +++ sfx2/inc/sfx2/templatelocalview.hxx | 5 +++ sfx2/inc/sfx2/templateremoteview.hxx | 2 + sfx2/source/control/templateabstractview.cxx | 26 +++++++++++++++ sfx2/source/control/templatelocalview.cxx | 41 +++++++++++++++++++++++++ sfx2/source/control/templateremoteview.cxx | 5 +++ sfx2/source/doc/templatedlg.cxx | 44 +++++++++++++++++++++------ 7 files changed, 119 insertions(+), 9 deletions(-)
New commits: commit f1a49f94b97601646c403a4b6e627f5ed3755970 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Mar 28 00:01:40 2013 -0430 Show search and extra buttons when a template is selected. Change-Id: Ia3e97f3f540ab07725ae3871251aefe4ba3d5e2d Reviewed-on: https://gerrit.libreoffice.org/3249 Reviewed-by: Miklos Vajna <vmik...@suse.cz> Tested-by: Miklos Vajna <vmik...@suse.cz> diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 6ca1fb4..46270ff 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -356,7 +356,7 @@ void SfxTemplateManagerDlg::Resize() long nToolbarsHeight = std::max(std::max(aViewSize.getHeight(), aActionSize.getHeight()), aTemplateSize.getHeight()); - aActionSize.setWidth(3*aActionSize.getWidth()); + aActionSize.setWidth(2.5*aActionSize.getWidth()); aViewSize.setWidth(aWinSize.getWidth()-aActionSize.getWidth()-mpViewBar->GetPosPixel().X()); aTemplateSize.setWidth(aWinSize.getWidth()); @@ -776,7 +776,6 @@ void SfxTemplateManagerDlg::OnTemplateState (const ThumbnailViewItem *pItem) if (maSelTemplates.empty()) { mpViewBar->Show(false); - mpActionBar->Show(false); mpTemplateBar->Show(); } else if (maSelTemplates.size() != 1 || !bInSelection) @@ -802,7 +801,6 @@ void SfxTemplateManagerDlg::OnTemplateState (const ThumbnailViewItem *pItem) { mpTemplateBar->Show(false); mpViewBar->Show(); - mpActionBar->Show(); } else if (maSelTemplates.size() == 1) { commit 6bdcdb6523d17470c17b84b2da573ade6f321aad Author: Rafael Dominguez <venccsra...@gmail.com> Date: Wed Mar 27 18:19:53 2013 -0430 fdo#60581 Import templates into current directory. Change-Id: I3dfec069c606e61fc49b44e36602804054ca1bca Reviewed-on: https://gerrit.libreoffice.org/3248 Reviewed-by: Miklos Vajna <vmik...@suse.cz> Tested-by: Miklos Vajna <vmik...@suse.cz> diff --git a/sfx2/inc/sfx2/templateabstractview.hxx b/sfx2/inc/sfx2/templateabstractview.hxx index e181a00..a60fdb3 100644 --- a/sfx2/inc/sfx2/templateabstractview.hxx +++ b/sfx2/inc/sfx2/templateabstractview.hxx @@ -82,6 +82,8 @@ public: virtual ~TemplateAbstractView (); + void insertItem (const TemplateItemProperties &rTemplate); + // Fill view with new item list void insertItems (const std::vector<TemplateItemProperties> &rTemplates); diff --git a/sfx2/inc/sfx2/templatelocalview.hxx b/sfx2/inc/sfx2/templatelocalview.hxx index 59d0588..f17f0f8 100644 --- a/sfx2/inc/sfx2/templatelocalview.hxx +++ b/sfx2/inc/sfx2/templatelocalview.hxx @@ -70,6 +70,9 @@ public: bool copyFrom (const sal_uInt16 nRegionItemId, const BitmapEx &rThumbnail, const OUString &rPath); + // Import a template to the current region + bool copyFrom (const OUString &rPath); + bool copyFrom(TemplateContainerItem *pItem, const OUString &rPath); bool exportTo (const sal_uInt16 nItemId, const sal_uInt16 nRegionItemId, const OUString &rName); diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx index 49aea81..8fac81e 100644 --- a/sfx2/source/control/templateabstractview.cxx +++ b/sfx2/source/control/templateabstractview.cxx @@ -143,6 +143,32 @@ TemplateAbstractView::~TemplateAbstractView () { } +void TemplateAbstractView::insertItem(const TemplateItemProperties &rTemplate) +{ + const TemplateItemProperties *pCur = &rTemplate; + + TemplateViewItem *pChild = new TemplateViewItem(*this); + pChild->mnId = pCur->nId; + pChild->mnDocId = pCur->nDocId; + pChild->mnRegionId = pCur->nRegionId; + pChild->maTitle = pCur->aName; + pChild->setPath(pCur->aPath); + pChild->maPreview1 = pCur->aThumbnail; + + if ( pCur->aThumbnail.IsEmpty() ) + { + // Use the default thumbnail if we have nothing else + pChild->maPreview1 = TemplateAbstractView::getDefaultThumbnail(pCur->aPath); + } + + pChild->setSelectClickHdl(LINK(this,ThumbnailView,OnItemSelected)); + + mItemList.push_back(pChild); + + CalculateItemPositions(); + Invalidate(); +} + void TemplateAbstractView::insertItems(const std::vector<TemplateItemProperties> &rTemplates) { std::vector<ThumbnailViewItem*> aItems(rTemplates.size()); diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index 571cbec..c6d32af 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -590,6 +590,42 @@ bool TemplateLocalView::copyFrom(const sal_uInt16 nRegionItemId, const BitmapEx return false; } +bool TemplateLocalView::copyFrom(const OUString &rPath) +{ + assert(mnCurRegionId); + + TemplateContainerItem *pRegItem = maRegions[mnCurRegionId-1]; + + sal_uInt16 nId = getNextItemId(); + sal_uInt16 nDocId = 0; + sal_uInt16 nRegionId = pRegItem->mnRegionId; + + String aPath(rPath); + + if (!pRegItem->maTemplates.empty()) + nDocId = (pRegItem->maTemplates.back()).nDocId+1; + + if (!mpDocTemplates->CopyFrom(nRegionId,nDocId,aPath)) + return false; + + TemplateItemProperties aTemplate; + aTemplate.aIsFolder = false; + aTemplate.nId = nId; + aTemplate.nDocId = nDocId; + aTemplate.nRegionId = nRegionId; + aTemplate.aName = aPath; + aTemplate.aThumbnail = TemplateAbstractView::fetchThumbnail(rPath, + TEMPLATE_THUMBNAIL_MAX_WIDTH, + TEMPLATE_THUMBNAIL_MAX_HEIGHT); + aTemplate.aPath = rPath; + + pRegItem->maTemplates.push_back(aTemplate); + + insertItem(aTemplate); + + return true; +} + bool TemplateLocalView::copyFrom (TemplateContainerItem *pItem, const OUString &rPath) { sal_uInt16 nId = 1; diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 7c13f95..6ca1fb4 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -879,15 +879,41 @@ void SfxTemplateManagerDlg::OnTemplateImport () if (aFiles.hasElements()) { - std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator pIter; - for (pIter = maSelFolders.begin(); pIter != maSelFolders.end(); ++pIter) + if (!maSelFolders.empty()) { - OUString aTemplateList; - TemplateContainerItem *pFolder = (TemplateContainerItem*)(*pIter); + //Import to the selected regions + std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator pIter; + for (pIter = maSelFolders.begin(); pIter != maSelFolders.end(); ++pIter) + { + OUString aTemplateList; + TemplateContainerItem *pFolder = (TemplateContainerItem*)(*pIter); + + for (size_t i = 0, n = aFiles.getLength(); i < n; ++i) + { + if(!maView->copyFrom(pFolder,aFiles[i])) + { + if (aTemplateList.isEmpty()) + aTemplateList = aFiles[i]; + else + aTemplateList = aTemplateList + "\n" + aFiles[i]; + } + } + if (!aTemplateList.isEmpty()) + { + OUString aMsg(SfxResId(STR_MSG_ERROR_IMPORT).toString()); + aMsg = aMsg.replaceFirst("$1",pFolder->maTitle); + ErrorBox(this,WB_OK,aMsg.replaceFirst("$2",aTemplateList)); + } + } + } + else + { + //Import to current region + OUString aTemplateList; for (size_t i = 0, n = aFiles.getLength(); i < n; ++i) { - if(!maView->copyFrom(pFolder,aFiles[i])) + if(!maView->copyFrom(aFiles[i])) { if (aTemplateList.isEmpty()) aTemplateList = aFiles[i]; @@ -899,7 +925,7 @@ void SfxTemplateManagerDlg::OnTemplateImport () if (!aTemplateList.isEmpty()) { OUString aMsg(SfxResId(STR_MSG_ERROR_IMPORT).toString()); - aMsg = aMsg.replaceFirst("$1",pFolder->maTitle); + aMsg = aMsg.replaceFirst("$1",maView->getCurRegionName()); ErrorBox(this,WB_OK,aMsg.replaceFirst("$2",aTemplateList)); } } commit 73c7e4e5a0da6e4326b9dad3d48ddd0b3aa12d61 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Wed Mar 27 17:03:02 2013 -0430 fdo#60581 Display import templates only when its allowed. Change-Id: Iefe4fdd1484389d0bbbccecdca49e4c0061ec81e Reviewed-on: https://gerrit.libreoffice.org/3247 Reviewed-by: Miklos Vajna <vmik...@suse.cz> Tested-by: Miklos Vajna <vmik...@suse.cz> diff --git a/sfx2/inc/sfx2/templateabstractview.hxx b/sfx2/inc/sfx2/templateabstractview.hxx index 1df856d..e181a00 100644 --- a/sfx2/inc/sfx2/templateabstractview.hxx +++ b/sfx2/inc/sfx2/templateabstractview.hxx @@ -97,6 +97,9 @@ public: // Return if we can have regions inside the current region virtual bool isNestedRegionAllowed () const = 0; + // Return if we can import templates to the current region + virtual bool isImportAllowed () const = 0; + sal_uInt16 getCurRegionId () const; const OUString& getCurRegionName () const; diff --git a/sfx2/inc/sfx2/templatelocalview.hxx b/sfx2/inc/sfx2/templatelocalview.hxx index 762dbf5..59d0588 100644 --- a/sfx2/inc/sfx2/templatelocalview.hxx +++ b/sfx2/inc/sfx2/templatelocalview.hxx @@ -57,6 +57,8 @@ public: virtual bool isNestedRegionAllowed () const; + virtual bool isImportAllowed () const; + bool removeRegion (const sal_uInt16 nItemId); bool removeTemplate (const sal_uInt16 nItemId, const sal_uInt16 nSrcItemId); diff --git a/sfx2/inc/sfx2/templateremoteview.hxx b/sfx2/inc/sfx2/templateremoteview.hxx index 0a89803..01a582f 100644 --- a/sfx2/inc/sfx2/templateremoteview.hxx +++ b/sfx2/inc/sfx2/templateremoteview.hxx @@ -33,6 +33,8 @@ public: virtual bool isNestedRegionAllowed () const; + virtual bool isImportAllowed () const; + private: com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xCmdEnv; diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index dd472f2..571cbec 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -263,6 +263,11 @@ bool TemplateLocalView::isNestedRegionAllowed() const return !mnCurRegionId; } +bool TemplateLocalView::isImportAllowed() const +{ + return mnCurRegionId; +} + bool TemplateLocalView::removeRegion(const sal_uInt16 nItemId) { sal_uInt16 nRegionId = USHRT_MAX; diff --git a/sfx2/source/control/templateremoteview.cxx b/sfx2/source/control/templateremoteview.cxx index 8fd2e87..3fc85a7 100644 --- a/sfx2/source/control/templateremoteview.cxx +++ b/sfx2/source/control/templateremoteview.cxx @@ -195,4 +195,9 @@ bool TemplateRemoteView::isNestedRegionAllowed() const return true; } +bool TemplateRemoteView::isImportAllowed() const +{ + return true; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 99d083d..7c13f95 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -639,6 +639,8 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, OpenRegionHdl) maSelFolders.clear(); maSelTemplates.clear(); + mpViewBar->ShowItem(TBI_TEMPLATE_IMPORT,mpCurView->isImportAllowed()); + mpTemplateBar->Hide(); mpViewBar->Show(); mpActionBar->Show(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits