sfx2/inc/sfx2/templateabstractview.hxx | 8 + sfx2/inc/sfx2/templatelocalview.hxx | 7 + sfx2/inc/sfx2/templateremoteview.hxx | 4 sfx2/inc/sfx2/thumbnailview.hxx | 1 sfx2/source/control/templateabstractview.cxx | 26 +++++ sfx2/source/control/templatelocalview.cxx | 46 +++++++++ sfx2/source/control/templateremoteview.cxx | 10 ++ sfx2/source/control/thumbnailview.cxx | 7 - sfx2/source/doc/templatedlg.cxx | 126 +++++++++++++++++++-------- 9 files changed, 197 insertions(+), 38 deletions(-)
New commits: commit d9bcb1b2b9eb975f505ce72461f9d5eeef07145c Author: Rafael Dominguez <[email protected]> Date: Thu Mar 28 00:19:59 2013 -0430 Deselect templates when closing the search view. Change-Id: Ib3b47cea8a35c2197d065c1d699f0de4bc3f04eb diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index e547c12..0273f55 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -1043,6 +1043,7 @@ void SfxTemplateManagerDlg::OnTemplateSearch () // Hide search view if (bVisible) { + mpSearchView->deselectItems(); mpSearchView->Hide(); mpCurView->Show(); } commit f7c47eddc9d736ec59772106cada2e4adde9c82c Author: Rafael Dominguez <[email protected]> Date: Thu Mar 28 00:01:40 2013 -0430 Show search and extra buttons when a template is selected. Change-Id: I8e331849aa4d973ed905e9afee5d08e9b6bbc230 diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 8ce5420..e547c12 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -353,7 +353,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()); @@ -773,7 +773,6 @@ void SfxTemplateManagerDlg::OnTemplateState (const ThumbnailViewItem *pItem) if (maSelTemplates.empty()) { mpViewBar->Show(false); - mpActionBar->Show(false); mpTemplateBar->Show(); } else if (maSelTemplates.size() != 1 || !bInSelection) @@ -799,7 +798,6 @@ void SfxTemplateManagerDlg::OnTemplateState (const ThumbnailViewItem *pItem) { mpTemplateBar->Show(false); mpViewBar->Show(); - mpActionBar->Show(); } else if (maSelTemplates.size() == 1) { commit 6f0d3a51968051d4b6a390054f2e6a23e511b1a7 Author: Rafael Dominguez <[email protected]> Date: Wed Mar 27 23:50:56 2013 -0430 Position correctly widgets in Template Manager. Change-Id: I2bb16913f20fcc093acaec9de8b07d27a692056b diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index 467ac74..5287605 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -309,7 +309,6 @@ protected: long mnDisplayHeight; // Height of the data display box (name, etc) long mnVisLines; long mnLines; - sal_uInt16 mnScrBarOffset; sal_uInt16 mnHighItemId; sal_uInt16 mnCols; sal_uInt16 mnFirstLine; diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 605ee50..488a50d 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -91,7 +91,6 @@ void ThumbnailView::ImplInit() mnVisLines = 0; mnLines = 0; mnFirstLine = 0; - mnScrBarOffset = 1; mnHighItemId = 0; mnCols = 0; mnSpacing = 0; @@ -243,7 +242,7 @@ void ThumbnailView::CalculateItemPositions () // calculate ScrollBar width long nScrBarWidth = 0; if ( mpScrBar ) - nScrBarWidth = mpScrBar->GetSizePixel().Width()+mnScrBarOffset; + nScrBarWidth = mpScrBar->GetSizePixel().Width(); // calculate maximum number of visible columns mnCols = (sal_uInt16)((aWinSize.Width()-nScrBarWidth) / (mnItemWidth)); @@ -383,8 +382,8 @@ void ThumbnailView::CalculateItemPositions () mbScroll = mnLines > mnVisLines; - Point aPos( aWinSize.Width() - nScrBarWidth - mnScrBarOffset, mnHeaderHeight ); - Size aSize( nScrBarWidth - mnScrBarOffset, aWinSize.Height() - mnHeaderHeight ); + Point aPos( aWinSize.Width() - nScrBarWidth, mnHeaderHeight ); + Size aSize( nScrBarWidth, aWinSize.Height() - mnHeaderHeight ); mpScrBar->SetPosSizePixel( aPos, aSize ); mpScrBar->SetRangeMax( (nCurCount+mnCols-1)/mnCols); diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 2ee3e10..8ce5420 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -342,13 +342,9 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg,ActivatePageHdl) void SfxTemplateManagerDlg::Resize() { - Size aWinSize = GetSizePixel(); - // Fit the tab page control and the toolbars - Size aTabSize = maTabControl.GetSizePixel(); - aTabSize.setWidth(aWinSize.getWidth()); - maTabControl.SetSizePixel(aTabSize); - maTabControl.SetTabPageSizePixel(aWinSize); + maTabControl.SetSizePixel(GetSizePixel()); + const Size aWinSize = maTabControl.GetTabPageSizePixel(); // Calculate toolboxes size and positions Size aViewSize = mpViewBar->CalcMinimumWindowSizePixel(); @@ -372,11 +368,7 @@ void SfxTemplateManagerDlg::Resize() Point aViewPos = maView->GetPosPixel(); aViewPos.setY(nToolbarsHeight); aViewPos.setX(0); - Size aThumbSize(aWinSize.getWidth(), maTabControl.GetTabPageSizePixel().getHeight() - aViewPos.getY()); - maView->SetPosSizePixel(aViewPos, aThumbSize); - - if (aWinSize.getHeight() < aViewPos.getY() + aThumbSize.getHeight() + PADDING_DLG_BORDER) - aWinSize.setHeight(aViewPos.getY() + aThumbSize.getHeight() + PADDING_DLG_BORDER); + Size aThumbSize(aWinSize.getWidth(), aWinSize.getHeight() - aViewPos.getY()); // Set search box position and size Size aSearchSize = mpSearchEdit->CalcMinimumSize(); @@ -385,11 +377,9 @@ void SfxTemplateManagerDlg::Resize() mpSearchEdit->SetSizePixel(aSearchSize); mpSearchEdit->SetPosPixel(Point(PADDING_DLG_BORDER,aViewPos.Y())); - maView->SetSizePixel(aThumbSize); + maView->SetPosSizePixel(aViewPos,aThumbSize); mpOnlineView->SetPosSizePixel(aViewPos,aThumbSize); - mpSearchView->SetSizePixel(aThumbSize); - - mpCurView->Resize(); + mpSearchView->SetPosSizePixel(aViewPos,aThumbSize); ModelessDialog::Resize(); } commit 0e173abeaef967e8b8dfee53dceaae343af6e215 Author: Rafael Dominguez <[email protected]> Date: Wed Mar 27 21:46:15 2013 -0430 Hide creating a new template folder when theres one already selected. Change-Id: I9924eb5ca66c61b2a1d3b66989b794d58e26d703 diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index b9502af..2ee3e10 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -754,6 +754,7 @@ void SfxTemplateManagerDlg::OnRegionState (const ThumbnailViewItem *pItem) { mpViewBar->ShowItem(TBI_TEMPLATE_IMPORT); mpViewBar->ShowItem(TBI_TEMPLATE_FOLDER_DEL); + mpViewBar->HideItem(TBI_TEMPLATE_FOLDER_NEW); } maSelFolders.insert(pItem); @@ -766,6 +767,7 @@ void SfxTemplateManagerDlg::OnRegionState (const ThumbnailViewItem *pItem) { mpViewBar->HideItem(TBI_TEMPLATE_IMPORT); mpViewBar->HideItem(TBI_TEMPLATE_FOLDER_DEL); + mpViewBar->ShowItem(TBI_TEMPLATE_FOLDER_NEW); } } } commit 85b567374edb6456fcf7d1c78dc0ba5d8a3afb10 Author: Rafael Dominguez <[email protected]> Date: Wed Mar 27 18:19:53 2013 -0430 fdo#60581 Import templates into current directory. Change-Id: I965586748ab51ddb6face485e0db292c4c7b5274 diff --git a/sfx2/inc/sfx2/templateabstractview.hxx b/sfx2/inc/sfx2/templateabstractview.hxx index 564978e..c7ae46a 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 902b7cf..b0d86ae 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 eb725ba..8287cad 100644 --- a/sfx2/source/control/templateabstractview.cxx +++ b/sfx2/source/control/templateabstractview.cxx @@ -144,6 +144,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 a73fa23..b6fcc50 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 48ed3fd..b9502af 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -884,15 +884,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]; @@ -904,7 +930,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 a544f366867cb03ccc3a90703fc437e81fabc7a2 Author: Rafael Dominguez <[email protected]> Date: Wed Mar 27 17:03:02 2013 -0430 fdo#60581 Display import templates only when its allowed. Change-Id: I004b50118b1b261de4807660012b55eeecff41a3 diff --git a/sfx2/inc/sfx2/templateabstractview.hxx b/sfx2/inc/sfx2/templateabstractview.hxx index 2e39144..564978e 100644 --- a/sfx2/inc/sfx2/templateabstractview.hxx +++ b/sfx2/inc/sfx2/templateabstractview.hxx @@ -99,6 +99,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 2977354..902b7cf 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 915f422..bcb2b68 100644 --- a/sfx2/inc/sfx2/templateremoteview.hxx +++ b/sfx2/inc/sfx2/templateremoteview.hxx @@ -35,6 +35,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 611f908..a73fa23 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 6750991..ea97350 100644 --- a/sfx2/source/control/templateremoteview.cxx +++ b/sfx2/source/control/templateremoteview.cxx @@ -174,4 +174,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 d286397..48ed3fd 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -644,6 +644,7 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, OpenRegionHdl) maSelTemplates.clear(); mpViewBar->ShowItem(TBI_TEMPLATE_FOLDER_NEW,mpCurView->isNestedRegionAllowed()); + mpViewBar->ShowItem(TBI_TEMPLATE_IMPORT,mpCurView->isImportAllowed()); mpTemplateBar->Hide(); mpViewBar->Show(); commit 57ca68147e6e6df358fcb7a991847513aa0efe9d Author: Rafael Dominguez <[email protected]> Date: Wed Mar 27 16:59:50 2013 -0430 Display create template folder only when its allowed. Change-Id: Ie2acd2246694ce792f628a7057df5c30dac5db32 diff --git a/sfx2/inc/sfx2/templateabstractview.hxx b/sfx2/inc/sfx2/templateabstractview.hxx index 16a82e4..2e39144 100644 --- a/sfx2/inc/sfx2/templateabstractview.hxx +++ b/sfx2/inc/sfx2/templateabstractview.hxx @@ -96,6 +96,9 @@ public: virtual sal_uInt16 createRegion (const OUString &rName) = 0; + // Return if we can have regions inside the current region + virtual bool isNestedRegionAllowed () 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 17eb140..2977354 100644 --- a/sfx2/inc/sfx2/templatelocalview.hxx +++ b/sfx2/inc/sfx2/templatelocalview.hxx @@ -55,6 +55,8 @@ public: virtual sal_uInt16 createRegion (const OUString &rName); + virtual bool isNestedRegionAllowed () 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 a2341c4..915f422 100644 --- a/sfx2/inc/sfx2/templateremoteview.hxx +++ b/sfx2/inc/sfx2/templateremoteview.hxx @@ -33,6 +33,8 @@ public: virtual sal_uInt16 createRegion (const OUString &rName); + virtual bool isNestedRegionAllowed () 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 69f0c91..611f908 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -258,6 +258,11 @@ sal_uInt16 TemplateLocalView::createRegion(const OUString &rName) return pItem->mnId; } +bool TemplateLocalView::isNestedRegionAllowed() 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 663ae2b..6750991 100644 --- a/sfx2/source/control/templateremoteview.cxx +++ b/sfx2/source/control/templateremoteview.cxx @@ -169,4 +169,9 @@ sal_uInt16 TemplateRemoteView::createRegion(const OUString &/*rName*/) return 0; } +bool TemplateRemoteView::isNestedRegionAllowed() 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 2dee3e8..d286397 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -643,6 +643,8 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, OpenRegionHdl) maSelFolders.clear(); maSelTemplates.clear(); + mpViewBar->ShowItem(TBI_TEMPLATE_FOLDER_NEW,mpCurView->isNestedRegionAllowed()); + mpTemplateBar->Hide(); mpViewBar->Show(); mpActionBar->Show(); commit 6ba185d1fff1f3bb26ae03b21c7d6a3acefd6d2f Author: Rafael Dominguez <[email protected]> Date: Wed Mar 27 13:43:52 2013 -0430 Update search results when changing template type in Template Manager. Change-Id: I3e4cde13076c4de092a8bab9c40d64ba81530abd diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 29aca67..2dee3e8 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -333,6 +333,10 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg,ActivatePageHdl) break; } mpCurView->filterItems(ViewFilter_Application(eFilter)); + + if (mpSearchView->IsVisible()) + SearchUpdateHdl(NULL); + return 0; } commit 4c29d595b620b80fb3b913611f724376e5aa9dc4 Author: Rafael Dominguez <[email protected]> Date: Wed Mar 27 13:38:57 2013 -0430 Filter search results by type and keyword in Template Manager. Change-Id: I549d349b9be3a36c35f50ae614a12fcf09315b08 diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index c0beedf..29aca67 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -86,18 +86,41 @@ class SearchView_Keyword { public: - SearchView_Keyword (const OUString &rKeyword) - : maKeyword(rKeyword) + SearchView_Keyword (const OUString &rKeyword, FILTER_APPLICATION App) + : maKeyword(rKeyword), meApp(App) {} bool operator() (const TemplateItemProperties &rItem) { - return rItem.aName.matchIgnoreAsciiCase(maKeyword); + bool bRet = true; + + INetURLObject aUrl(rItem.aPath); + OUString aExt = aUrl.getExtension(); + + if (meApp == FILTER_APP_WRITER) + { + bRet = aExt == "ott" || aExt == "stw" || aExt == "oth" || aExt == "dot" || aExt == "dotx"; + } + else if (meApp == FILTER_APP_CALC) + { + bRet = aExt == "ots" || aExt == "stc" || aExt == "xlt" || aExt == "xltm" || aExt == "xltx"; + } + else if (meApp == FILTER_APP_IMPRESS) + { + bRet = aExt == "otp" || aExt == "sti" || aExt == "pot" || aExt == "potm" || aExt == "potx"; + } + else if (meApp == FILTER_APP_DRAW) + { + bRet = aExt == "otg" || aExt == "std"; + } + + return bRet && rItem.aName.matchIgnoreAsciiCase(maKeyword); } private: OUString maKeyword; + FILTER_APPLICATION meApp; }; /*** @@ -668,8 +691,25 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, SearchUpdateHdl) bool bDisplayFolder = !mpCurView->isNonRootRegionVisible(); + FILTER_APPLICATION eFilter = FILTER_APP_NONE; + switch (maTabControl.GetCurPageId()) + { + case FILTER_DOCS: + eFilter = FILTER_APP_WRITER; + break; + case FILTER_PRESENTATIONS: + eFilter = FILTER_APP_IMPRESS; + break; + case FILTER_SHEETS: + eFilter = FILTER_APP_CALC; + break; + case FILTER_DRAWS: + eFilter = FILTER_APP_DRAW; + break; + } + std::vector<TemplateItemProperties> aItems = - maView->getFilteredItems(SearchView_Keyword(aKeyword)); + maView->getFilteredItems(SearchView_Keyword(aKeyword,eFilter)); for (size_t i = 0; i < aItems.size(); ++i) { commit c2f47cf1576ddcf5d7bd63e252b8bc0f61f5f10b Author: Rafael Dominguez <[email protected]> Date: Wed Mar 27 13:18:42 2013 -0430 Dont display all templates types after closing the search bar. Change-Id: I9157cc5fc0a0d673869d877b478feacbeaa43a33 diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 6cb4472..c0beedf 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -988,10 +988,6 @@ void SfxTemplateManagerDlg::OnTemplateSearch () mpSearchEdit->SetText(OUString()); if (!bVisible) mpSearchEdit->GrabFocus(); - - // display all templates if we hide the search bar - if (bVisible && mpCurView->isNonRootRegionVisible()) - mpCurView->filterItems(ViewFilter_Application(FILTER_APP_NONE)); } void SfxTemplateManagerDlg::OnTemplateEdit () commit 49ff1db2951eaf88b711e8a546a194d51323a996 Author: Rafael Dominguez <[email protected]> Date: Wed Mar 27 12:54:37 2013 -0430 Get the correct region id view when saving a template. Change-Id: Ib1fcbc7748437460f8e21b06d676c5bd317ae581 diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 2f86818..6cb4472 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -1185,7 +1185,7 @@ void SfxTemplateManagerDlg::OnTemplateSaveAs() if (maView->isNonRootRegionVisible()) { - sal_uInt16 nRegionItemId = maView->getCurRegionId()+1; + sal_uInt16 nRegionItemId = maView->getRegionId(maView->getCurRegionId()-1); if (!maView->isTemplateNameUnique(nRegionItemId,aName)) { _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
