[Libreoffice-commits] core.git: include/sfx2 sfx2/source
Akshay Deep
akshaydeepiitr at gmail.com
Wed May 25 09:24:59 UTC 2016
include/sfx2/templateabstractview.hxx | 3
include/sfx2/templatecontaineritem.hxx | 23 ---
include/sfx2/templatelocalview.hxx | 4
include/sfx2/templateremoteview.hxx | 2
sfx2/source/control/templateabstractview.cxx | 16 --
sfx2/source/control/templatecontaineritem.cxx | 155 --------------------------
sfx2/source/control/templatelocalview.cxx | 53 +++-----
sfx2/source/control/templateremoteview.cxx | 2
sfx2/source/doc/templatedlg.cxx | 2
9 files changed, 35 insertions(+), 225 deletions(-)
New commits:
commit 72a1fbe16b147911ff90fb5145ea3e2d783193f8
Author: Akshay Deep <akshaydeepiitr at gmail.com>
Date: Sat May 21 23:16:28 2016 +0530
New Template Manager: Remove inheritance of TemplateContainerItem
Conflicts:
include/sfx2/templatelocalview.hxx
sfx2/source/control/templatelocalview.cxx
Change-Id: I5eb120853be768c3770a71829c40d00c97fcdadb
Reviewed-on: https://gerrit.libreoffice.org/25272
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
diff --git a/include/sfx2/templateabstractview.hxx b/include/sfx2/templateabstractview.hxx
index 2d6ad72..903c997 100644
--- a/include/sfx2/templateabstractview.hxx
+++ b/include/sfx2/templateabstractview.hxx
@@ -31,6 +31,7 @@
class SfxDocumentTemplates;
class TemplateViewItem;
+class TemplateContainerItem;
enum class FILTER_APPLICATION
{
@@ -86,7 +87,7 @@ public:
virtual void showAllTemplates () = 0;
- virtual void showRegion (ThumbnailViewItem *pItem) = 0;
+ virtual void showRegion (TemplateContainerItem *pItem) = 0;
virtual sal_uInt16 createRegion (const OUString &rName) = 0;
diff --git a/include/sfx2/templatecontaineritem.hxx b/include/sfx2/templatecontaineritem.hxx
index 99047c3..3aedcb2 100644
--- a/include/sfx2/templatecontaineritem.hxx
+++ b/include/sfx2/templatecontaineritem.hxx
@@ -11,34 +11,19 @@
#define INCLUDED_SFX2_TEMPLATECONTAINERITEM_HXX
#include <sfx2/templateproperties.hxx>
-#include <sfx2/thumbnailviewitem.hxx>
-class TemplateContainerItem : public ThumbnailViewItem
+class TemplateContainerItem
{
public:
+ sal_uInt16 mnId;
sal_uInt16 mnRegionId;
- BitmapEx maPreview2;
- BitmapEx maPreview3;
- BitmapEx maPreview4;
+ OUString maTitle;
std::vector<TemplateItemProperties> maTemplates;
- TemplateContainerItem (ThumbnailView &rView, sal_uInt16 nId);
+ TemplateContainerItem (sal_uInt16 nId);
virtual ~TemplateContainerItem ();
-
- virtual void Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor,
- const ThumbnailItemAttributes *pAttrs) override;
-
- virtual void calculateItemsPosition (const long nThumbnailHeight, const long nDisplayHeight,
- const long nPadding, sal_uInt32 nMaxTextLength,
- const ThumbnailItemAttributes *pAttrs) override;
-
- bool HasMissingPreview( );
-
-private:
-
- Rectangle maThumbnailArea;
};
#endif // INCLUDED_SFX2_TEMPLATECONTAINERITEM_HXX
diff --git a/include/sfx2/templatelocalview.hxx b/include/sfx2/templatelocalview.hxx
index b426531..1cfc8d8 100644
--- a/include/sfx2/templatelocalview.hxx
+++ b/include/sfx2/templatelocalview.hxx
@@ -43,7 +43,7 @@ public:
virtual void showAllTemplates () override;
- virtual void showRegion (ThumbnailViewItem *pItem) override;
+ virtual void showRegion (TemplateContainerItem *pItem) override;
void showRegion (const OUString &rName);
@@ -53,7 +53,7 @@ public:
sal_uInt16 getCurRegionItemId () const;
- ThumbnailViewItem* getRegion(OUString const & sStr);
+ TemplateContainerItem* getRegion(OUString const & sStr);
sal_uInt16 getRegionId (size_t pos) const;
diff --git a/include/sfx2/templateremoteview.hxx b/include/sfx2/templateremoteview.hxx
index 854a6c5..067ef0a 100644
--- a/include/sfx2/templateremoteview.hxx
+++ b/include/sfx2/templateremoteview.hxx
@@ -25,7 +25,7 @@ public:
virtual void showAllTemplates () override;
- virtual void showRegion (ThumbnailViewItem *pItem) override;
+ virtual void showRegion (TemplateContainerItem *pItem) override;
bool loadRepository (TemplateRepository* pRepository);
diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx
index 117d04b..8f08f58 100644
--- a/sfx2/source/control/templateabstractview.cxx
+++ b/sfx2/source/control/templateabstractview.cxx
@@ -260,20 +260,10 @@ BitmapEx TemplateAbstractView::fetchThumbnail (const OUString &msURL, long width
void TemplateAbstractView::OnItemDblClicked (ThumbnailViewItem *pItem)
{
- //Check if the item is a TemplateContainerItem (Folder) or a TemplateViewItem (File)
+ TemplateViewItem* pViewItem = dynamic_cast<TemplateViewItem*>(pItem);
- TemplateContainerItem* pContainerItem = dynamic_cast<TemplateContainerItem*>(pItem);
- if ( pContainerItem )
- {
- // Fill templates
- mnCurRegionId = pContainerItem->mnRegionId+1;
- maCurRegionName = pContainerItem->maTitle;
- showRegion(pItem);
- }
- else
- {
- maOpenTemplateHdl.Call(pItem);
- }
+ if( pViewItem )
+ maOpenTemplateHdl.Call(pViewItem);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/templatecontaineritem.cxx b/sfx2/source/control/templatecontaineritem.cxx
index afeac95..2d5cbb2 100644
--- a/sfx2/source/control/templatecontaineritem.cxx
+++ b/sfx2/source/control/templatecontaineritem.cxx
@@ -8,28 +8,10 @@
*/
#include <sfx2/templatecontaineritem.hxx>
-#include <sfx2/templateabstractview.hxx>
-
-#include <basegfx/matrix/b2dhommatrixtools.hxx>
-#include <basegfx/polygon/b2dpolygon.hxx>
-#include <drawinglayer/attribute/fillgraphicattribute.hxx>
-#include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx>
-#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
-#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
-#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
-#include <drawinglayer/primitive2d/textprimitive2d.hxx>
-#include <drawinglayer/processor2d/baseprocessor2d.hxx>
#include <sfx2/templateviewitem.hxx>
-#include <vcl/button.hxx>
-#include <vcl/graph.hxx>
-
-using namespace basegfx;
-using namespace basegfx::tools;
-using namespace drawinglayer::attribute;
-using namespace drawinglayer::primitive2d;
-TemplateContainerItem::TemplateContainerItem (ThumbnailView &rView, sal_uInt16 nId)
- : ThumbnailViewItem(rView, nId)
+TemplateContainerItem::TemplateContainerItem (sal_uInt16 nId)
+ : mnId(nId)
, mnRegionId(0)
{
}
@@ -38,139 +20,6 @@ TemplateContainerItem::~TemplateContainerItem ()
{
}
-void TemplateContainerItem::calculateItemsPosition (const long nThumbnailHeight, const long nDisplayHeight,
- const long nPadding, sal_uInt32 nMaxTextLength,
- const ThumbnailItemAttributes *pAttrs)
-{
- ThumbnailViewItem::calculateItemsPosition( nThumbnailHeight, nDisplayHeight, nPadding, nMaxTextLength, pAttrs);
- Point aPos (maDrawArea.getX() + nPadding, maDrawArea.getY() + nPadding);
- maThumbnailArea = Rectangle(aPos, Size(maDrawArea.GetWidth() - 2 * nPadding, nThumbnailHeight));
-}
-
-void TemplateContainerItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor,
- const ThumbnailItemAttributes *pAttrs)
-{
- int nCount = 0;
- int nSeqSize = 3;
-
- if (!maPreview1.IsEmpty())
- nSeqSize += 3;
-
- if (!maPreview2.IsEmpty())
- nSeqSize += 3;
-
- if (!maPreview3.IsEmpty())
- nSeqSize += 3;
-
- if (!maPreview4.IsEmpty())
- nSeqSize += 3;
-
- BColor aFillColor = pAttrs->aFillColor;
- drawinglayer::primitive2d::Primitive2DContainer aSeq(nSeqSize);
- double fTransparence = 0.0;
-
- // Draw background
- if ( mbSelected || mbHover )
- aFillColor = pAttrs->aHighlightColor;
-
- if (mbHover)
- fTransparence = pAttrs->fHighlightTransparence;
-
- aSeq[nCount++] = drawinglayer::primitive2d::Primitive2DReference(
- new PolyPolygonSelectionPrimitive2D( B2DPolyPolygon( ::tools::Polygon(maDrawArea,5,5).getB2DPolygon()),
- aFillColor,
- fTransparence,
- 0.0,
- true));
-
- // Create rounded rectangle border
- aSeq[nCount++] = drawinglayer::primitive2d::Primitive2DReference(
- new PolygonStrokePrimitive2D( ::tools::Polygon(maThumbnailArea, 5, 5).getB2DPolygon(),
- LineAttribute(BColor(0.5, 0.5, 0.5), 2.0)));
-
- // Paint the thumbnails side by side on a 2x2 grid
- long nThumbPadding = 4;
- Size aThumbSize( ( maThumbnailArea.getWidth() - 3 * nThumbPadding ) / 2, ( maThumbnailArea.getHeight() - 3* nThumbPadding ) / 2 );
-
- // Draw thumbnail
- for (int i=0; i<4; ++i)
- {
- long nPosX = 0;
- long nPosY = 0;
- BitmapEx* pImage = nullptr;
-
- switch (i)
- {
- case 0:
- pImage = &maPreview1;
- break;
- case 1:
- pImage = &maPreview2;
- nPosX = aThumbSize.getWidth() + nThumbPadding;
- break;
- case 2:
- pImage = &maPreview3;
- nPosY = aThumbSize.getHeight() + nThumbPadding;
- break;
- case 3:
- pImage = &maPreview4;
- nPosX = aThumbSize.getWidth() + nThumbPadding;
- nPosY = aThumbSize.getHeight() + nThumbPadding;
- break;
- }
-
- if (!pImage->IsEmpty())
- {
- // Check the size of the picture and resize if needed
- Size aImageSize = pImage->GetSizePixel();
- if (aImageSize.getWidth() > aThumbSize.getWidth() || aImageSize.getHeight() > aThumbSize.getHeight())
- {
- // Resize the picture and store it for next times
- *pImage = TemplateAbstractView::scaleImg( *pImage, aThumbSize.getWidth(), aThumbSize.getHeight() );
- aImageSize = pImage->GetSizePixel();
- }
-
- float nOffX = (aThumbSize.getWidth() - aImageSize.getWidth()) / 2.0;
- float nOffY = (aThumbSize.getHeight() - aImageSize.getHeight()) / 2.0;
-
- float fWidth = aImageSize.Width();
- float fHeight = aImageSize.Height();
- float fPosX = maThumbnailArea.Left() + nThumbPadding + nPosX + nOffX;
- float fPosY = maThumbnailArea.Top() + nThumbPadding + nPosY + nOffY;
-
- B2DPolygon aBounds;
- aBounds.append(B2DPoint(fPosX,fPosY));
- aBounds.append(B2DPoint(fPosX+fWidth,fPosY));
- aBounds.append(B2DPoint(fPosX+fWidth,fPosY+fHeight));
- aBounds.append(B2DPoint(fPosX,fPosY+fHeight));
- aBounds.setClosed(true);
-
- aSeq[nCount++] = drawinglayer::primitive2d::Primitive2DReference( new PolyPolygonColorPrimitive2D(
- B2DPolyPolygon(aBounds), Color(COL_WHITE).getBColor()));
- aSeq[nCount++] = drawinglayer::primitive2d::Primitive2DReference( new FillGraphicPrimitive2D(
- createScaleTranslateB2DHomMatrix(1.0,1.0,fPosX,fPosY),
- FillGraphicAttribute(Graphic(*pImage),
- B2DRange(
- B2DPoint(0.0,0.0),
- B2DPoint(aImageSize.Width(),aImageSize.Height())),
- false)
- ));
-
- // draw thumbnail borders
- aSeq[nCount++] = drawinglayer::primitive2d::Primitive2DReference(createBorderLine(aBounds));
- }
- }
-
- addTextPrimitives(maTitle, pAttrs, maTextPos, aSeq);
-
- pProcessor->process(aSeq);
-}
-
-bool TemplateContainerItem::HasMissingPreview( )
-{
- return maPreview1.IsEmpty() || maPreview2.IsEmpty() || maPreview3.IsEmpty() || maPreview4.IsEmpty();
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index c0c2b3a..2070a48 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -81,7 +81,7 @@ void TemplateLocalView::Populate ()
{
OUString aRegionName(mpDocTemplates->GetFullRegionName(i));
- TemplateContainerItem* pItem = new TemplateContainerItem( *this, i+1 );
+ TemplateContainerItem* pItem = new TemplateContainerItem( i+1 );
pItem->mnRegionId = i;
pItem->maTitle = aRegionName;
@@ -147,12 +147,12 @@ void TemplateLocalView::showAllTemplates()
maOpenRegionHdl.Call(nullptr);
}
-void TemplateLocalView::showRegion(ThumbnailViewItem *pItem)
+void TemplateLocalView::showRegion(TemplateContainerItem *pItem)
{
- mnCurRegionId = static_cast<TemplateContainerItem*>(pItem)->mnRegionId+1;
+ mnCurRegionId = pItem->mnRegionId+1;
maCurRegionName = pItem->maTitle;
- insertItems(reinterpret_cast<TemplateContainerItem*>(pItem)->maTemplates);
+ insertItems((pItem)->maTemplates);
maOpenRegionHdl.Call(nullptr);
}
@@ -169,7 +169,7 @@ void TemplateLocalView::showRegion(const OUString &rName)
}
}
-ThumbnailViewItem* TemplateLocalView::getRegion(OUString const & rName)
+TemplateContainerItem* TemplateLocalView::getRegion(OUString const & rName)
{
for (TemplateContainerItem* pRegion : maRegions)
if (pRegion->maTitle == rName)
@@ -333,21 +333,12 @@ sal_uInt16 TemplateLocalView::createRegion(const OUString &rName)
return 0;
// Insert to the region cache list and to the thumbnail item list
- TemplateContainerItem* pItem = new TemplateContainerItem( *this, nItemId );
+ TemplateContainerItem* pItem = new TemplateContainerItem( nItemId );
pItem->mnRegionId = nRegionId;
pItem->maTitle = rName;
maRegions.push_back(pItem);
- pItem = new TemplateContainerItem(*this, nItemId);
- pItem->mnRegionId = nRegionId;
- pItem->maTitle = rName;
-
- AppendItem(pItem);
-
- CalculateItemPositions();
- Invalidate();
-
return pItem->mnId;
}
@@ -383,15 +374,13 @@ bool TemplateLocalView::removeRegion(const sal_uInt16 nItemId)
return false;
// Synchronize view regions ids with SfxDocumentTemplates
- std::vector<ThumbnailViewItem*>::iterator pViewIt = mItemList.begin();
- for ( pViewIt = mItemList.begin(); pViewIt != mItemList.end(); ++pViewIt)
+ std::vector<TemplateContainerItem*>::iterator pRegionIter = maRegions.begin();
+ for ( ; pRegionIter != maRegions.end(); ++pRegionIter)
{
- if (static_cast<TemplateContainerItem*>(*pViewIt)->mnRegionId > nRegionId)
- --static_cast<TemplateContainerItem*>(*pViewIt)->mnRegionId;
+ if ((*pRegionIter)->mnRegionId > nRegionId)
+ --(*pRegionIter)->mnRegionId;
}
- RemoveItem(nItemId);
-
return true;
}
@@ -401,7 +390,7 @@ bool TemplateLocalView::removeTemplate (const sal_uInt16 nItemId, const sal_uInt
{
if (pRegion->mnId == nSrcItemId)
{
- TemplateContainerItem *pItem = static_cast<TemplateContainerItem*>(pRegion);
+ TemplateContainerItem *pItem = pRegion;
std::vector<TemplateItemProperties>::iterator pIter;
for (pIter = pItem->maTemplates.begin(); pIter != pItem->maTemplates.end(); ++pIter)
{
@@ -443,9 +432,9 @@ bool TemplateLocalView::moveTemplate (const ThumbnailViewItem *pItem, const sal_
for (TemplateContainerItem* pRegion : maRegions)
{
if (pRegion->mnId == nTargetItem)
- pTarget = static_cast<TemplateContainerItem*>(pRegion);
+ pTarget = pRegion;
else if (pRegion->mnId == nSrcItem)
- pSrc = static_cast<TemplateContainerItem*>(pRegion);
+ pSrc = pRegion;
}
if (pTarget && pSrc)
@@ -526,7 +515,7 @@ bool TemplateLocalView::moveTemplates(const std::set<const ThumbnailViewItem*, s
for (TemplateContainerItem* pRegion : maRegions)
{
if (pRegion->mnId == nTargetItem)
- pTarget = static_cast<TemplateContainerItem*>(pRegion);
+ pTarget = pRegion;
}
if (pTarget)
@@ -546,7 +535,7 @@ bool TemplateLocalView::moveTemplates(const std::set<const ThumbnailViewItem*, s
for (TemplateContainerItem* pRegion : maRegions)
{
if (pRegion->mnRegionId == nSrcRegionId)
- pSrc = static_cast<TemplateContainerItem*>(pRegion);
+ pSrc = pRegion;
}
if(pSrc)
@@ -637,7 +626,7 @@ bool TemplateLocalView::copyFrom(const sal_uInt16 nRegionItemId, const BitmapEx
sal_uInt16 nDocId = 0;
TemplateContainerItem *pRegionItem =
- static_cast<TemplateContainerItem*>(pRegion);
+ pRegion;
if (!pRegionItem->maTemplates.empty())
{
@@ -659,8 +648,7 @@ bool TemplateLocalView::copyFrom(const sal_uInt16 nRegionItemId, const BitmapEx
aTemplate.aThumbnail = rThumbnail;
aTemplate.aPath = mpDocTemplates->GetPath(nRegionId,nDocId);
- TemplateContainerItem *pItem =
- static_cast<TemplateContainerItem*>(pRegion);
+ TemplateContainerItem *pItem = pRegion;
pItem->maTemplates.push_back(aTemplate);
@@ -776,16 +764,13 @@ bool TemplateLocalView::renameItem(ThumbnailViewItem* pItem, const OUString& sNe
sal_uInt16 nRegionId = 0;
sal_uInt16 nDocId = USHRT_MAX;
TemplateViewItem* pDocItem = dynamic_cast<TemplateViewItem*>( pItem );
- TemplateContainerItem* pContainerItem = dynamic_cast<TemplateContainerItem*>( pItem );
+
if ( pDocItem )
{
nRegionId = pDocItem->mnRegionId;
nDocId = pDocItem->mnDocId;
}
- else if ( pContainerItem )
- {
- nRegionId = pContainerItem->mnRegionId;
- }
+
return mpDocTemplates->SetName( sNewTitle, nRegionId, nDocId );
}
diff --git a/sfx2/source/control/templateremoteview.cxx b/sfx2/source/control/templateremoteview.cxx
index 1e9409a..c04b4d1 100644
--- a/sfx2/source/control/templateremoteview.cxx
+++ b/sfx2/source/control/templateremoteview.cxx
@@ -60,7 +60,7 @@ VCL_BUILDER_DECL_FACTORY(TemplateRemoteView)
rRet = VclPtr<TemplateRemoteView>::Create(pParent, WB_VSCROLL, false);
}
-void TemplateRemoteView::showRegion(ThumbnailViewItem * /*pItem*/)
+void TemplateRemoteView::showRegion(TemplateContainerItem * /*pItem*/)
{
//TODO:
}
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 13476b8..fe9c922 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -1034,7 +1034,7 @@ void SfxTemplateManagerDlg::OnTemplateImportCategory(const OUString& sCategory)
if (aFiles.hasElements())
{
//Import to the selected regions
- TemplateContainerItem* pContItem = const_cast<TemplateContainerItem*>(static_cast<const TemplateContainerItem*>(mpLocalView->getRegion(sCategory)));
+ TemplateContainerItem* pContItem = mpLocalView->getRegion(sCategory);
if(pContItem)
{
OUString aTemplateList;
More information about the Libreoffice-commits
mailing list