diff options
author | Rafael Dominguez <venccsralph@gmail.com> | 2012-07-14 20:09:30 -0430 |
---|---|---|
committer | Rafael Dominguez <venccsralph@gmail.com> | 2012-07-15 08:15:23 -0430 |
commit | 29a0a916f4991d936bf1a648d3f401277b9f5ec8 (patch) | |
tree | 76847954319d14383d30f0f15d626a402c012f6b /sfx2 | |
parent | 58a404ca3ae47b2a57e2f50d82e633a0f7184116 (diff) |
Refactor setting TemplateView name through regionId.
Change-Id: I4c03c5d254e1552abf8c30fc1f3f5dfbf24c1c84
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/templateview.hxx | 12 | ||||
-rw-r--r-- | sfx2/source/control/templatefolderview.cxx | 13 | ||||
-rw-r--r-- | sfx2/source/control/templateview.cxx | 19 |
3 files changed, 23 insertions, 21 deletions
diff --git a/sfx2/inc/sfx2/templateview.hxx b/sfx2/inc/sfx2/templateview.hxx index 8e8bc10ecb19..04de1ee33386 100644 --- a/sfx2/inc/sfx2/templateview.hxx +++ b/sfx2/inc/sfx2/templateview.hxx @@ -26,11 +26,13 @@ public: virtual ~TemplateView (); - void setRegionId (const sal_uInt16 nRegionId); + void setId (const sal_uInt16 nId) { mnId = nId; } - sal_uInt16 getRegionId () const { return mnRegionId; } + sal_uInt16 getId () const { return mnId; } - const rtl::OUString& getRegionName () const { return maFolderName; } + void setName (const rtl::OUString &rName); + + const rtl::OUString& getName () const { return maName; } virtual void Paint (const Rectangle &rRect); @@ -56,8 +58,8 @@ private: Image maCloseImg; bool mbRenderTitle; - sal_uInt16 mnRegionId; - rtl::OUString maFolderName; + sal_uInt16 mnId; + rtl::OUString maName; SfxDocumentTemplates *mpDocTemplates; Link maDblClickHdl; Link maChangeNameHdl; diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index eb6031d07443..acfdb3824a69 100644 --- a/sfx2/source/control/templatefolderview.cxx +++ b/sfx2/source/control/templatefolderview.cxx @@ -482,7 +482,7 @@ bool TemplateFolderView::removeRegion(const sal_uInt16 nItemId) bool TemplateFolderView::removeTemplate (const sal_uInt16 nItemId) { - sal_uInt16 nRegionId = mpItemView->getRegionId(); + sal_uInt16 nRegionId = mpItemView->getId(); sal_uInt16 nItemRegionId = nRegionId + 1; sal_uInt16 nTemplateId = nItemId - 1; @@ -525,7 +525,7 @@ bool TemplateFolderView::moveTemplates(std::set<const ThumbnailViewItem *> &rIte bool ret = true; bool refresh = false; - sal_uInt16 nSrcRegionId = mpItemView->getRegionId(); + sal_uInt16 nSrcRegionId = mpItemView->getId(); sal_uInt16 nSrcRegionItemId = nSrcRegionId + 1; TemplateFolderViewItem *pTarget = NULL; @@ -665,7 +665,8 @@ void TemplateFolderView::OnItemDblClicked (ThumbnailViewItem *pRegionItem) // Fill templates sal_uInt16 nRegionId = pRegionItem->mnId-1; - mpItemView->setRegionId(nRegionId); + mpItemView->setId(nRegionId); + mpItemView->setName(mpDocTemplates->GetRegionName(nRegionId)); mpItemView->InsertItems(static_cast<TemplateFolderViewItem*>(pRegionItem)->maTemplates); if (mbSelectionMode) @@ -686,17 +687,17 @@ IMPL_LINK(TemplateFolderView, TVTemplateStateHdl, const ThumbnailViewItem*, pIte IMPL_LINK(TemplateFolderView, ChangeNameHdl, TemplateView*, pView) { - sal_uInt16 nRegionId = pView->getRegionId(); + sal_uInt16 nRegionId = pView->getId(); sal_uInt16 nItemId = nRegionId + 1; - if (!mpDocTemplates->SetName(pView->getRegionName(),nRegionId,USHRT_MAX)) + if (!mpDocTemplates->SetName(pView->getName(),nRegionId,USHRT_MAX)) return false; for (size_t i = 0; i < mItemList.size(); ++i) { if (mItemList[i]->mnId == nItemId) { - mItemList[i]->maTitle = pView->getRegionName(); + mItemList[i]->maTitle = pView->getName(); mItemList[i]->calculateItemsPosition(mpItemAttrs->nMaxTextLenght); Invalidate(); break; diff --git a/sfx2/source/control/templateview.cxx b/sfx2/source/control/templateview.cxx index a8190944a86c..b97fc20cd73a 100644 --- a/sfx2/source/control/templateview.cxx +++ b/sfx2/source/control/templateview.cxx @@ -36,7 +36,7 @@ TemplateView::TemplateView (Window *pParent, SfxDocumentTemplates *pTemplates) : ThumbnailView(pParent,WB_VSCROLL), maCloseImg(SfxResId(IMG_TEMPLATE_VIEW_CLOSE)), mbRenderTitle(true), - mnRegionId(0), + mnId(0), mpDocTemplates(pTemplates), mpEditName(new Edit(this, WB_BORDER | WB_HIDE)) { @@ -48,10 +48,9 @@ TemplateView::~TemplateView () delete mpEditName; } -void TemplateView::setRegionId (const sal_uInt16 nRegionId) +void TemplateView::setName (const rtl::OUString &rName) { - mnRegionId = nRegionId; - maFolderName = mpDocTemplates->GetRegionName(nRegionId); + maName = rName; mpEditName->SetText(rtl::OUString()); } @@ -74,7 +73,7 @@ void TemplateView::Paint (const Rectangle &rRect) if (mbRenderTitle) { - aPos.X() = (aWinSize.getWidth() - aTextDev.getTextWidth(maFolderName,0,maFolderName.getLength()))/2; + aPos.X() = (aWinSize.getWidth() - aTextDev.getTextWidth(maName,0,maName.getLength()))/2; aPos.Y() = aTextDev.getTextHeight() + (mnHeaderHeight - aTextDev.getTextHeight())/2; basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix( @@ -83,7 +82,7 @@ void TemplateView::Paint (const Rectangle &rRect) aSeq[nCount++] = Primitive2DReference( new TextSimplePortionPrimitive2D(aTextMatrix, - maFolderName,0,maFolderName.getLength(), + maName,0,maName.getLength(), std::vector< double >( ), mpItemAttrs->aFontAttr, com::sun::star::lang::Locale(), @@ -188,7 +187,7 @@ void TemplateView::MouseButtonDown (const MouseEvent &rMEvt) { drawinglayer::primitive2d::TextLayouterDevice aTextDev; - float fTextWidth = aTextDev.getTextWidth(maFolderName,0,maFolderName.getLength()); + float fTextWidth = aTextDev.getTextWidth(maName,0,maName.getLength()); aPos.X() = (aWinSize.getWidth() - fTextWidth)/2; aPos.Y() = (mnHeaderHeight - aTextDev.getTextHeight())/2; @@ -215,11 +214,11 @@ void TemplateView::OnItemDblClicked(ThumbnailViewItem *pItem) IMPL_LINK_NOARG(TemplateView, ChangeNameHdl) { - rtl::OUString aTmp = maFolderName; - maFolderName = mpEditName->GetText(); + rtl::OUString aTmp = maName; + maName = mpEditName->GetText(); if (!maChangeNameHdl.Call(this)) - maFolderName = aTmp; + maName = aTmp; mpEditName->SetText(rtl::OUString()); |