[Libreoffice-commits] core.git: 6 commits - chart2/source editeng/source include/editeng svx/source
Kohei Yoshida
kohei.yoshida at collabora.com
Thu Aug 14 08:19:49 PDT 2014
chart2/source/view/charttypes/PieChart.cxx | 229 ++++++++++++++++-------------
chart2/source/view/charttypes/PieChart.hxx | 22 +-
editeng/source/outliner/outlobj.cxx | 152 +++++++++----------
include/editeng/outlobj.hxx | 5
svx/source/unodraw/unopage.cxx | 150 +++++++++---------
svx/source/unodraw/unoprov.cxx | 97 ++++++------
svx/source/unodraw/unoshap2.cxx | 62 ++++---
7 files changed, 379 insertions(+), 338 deletions(-)
New commits:
commit aa3babb42fa88840706f5b487ca0e88552cd8f83
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu Aug 14 10:57:09 2014 -0400
Use boost::intrusive_ptr in lieu of manual ref-counting.
Change-Id: I0a29a1e490f5aa52a9057be71164573e403affe9
diff --git a/editeng/source/outliner/outlobj.cxx b/editeng/source/outliner/outlobj.cxx
index d4aee9d..9a5ead1 100644
--- a/editeng/source/outliner/outlobj.cxx
+++ b/editeng/source/outliner/outlobj.cxx
@@ -32,24 +32,25 @@
#include <vcl/bitmap.hxx>
#include <tools/stream.hxx>
+#include <boost/intrusive_ptr.hpp>
+
/**
* This is the guts of OutlinerParaObject, refcounted and shared among
* multiple instances of OutlinerParaObject.
*/
-class OutlinerParaObjData
+struct OutlinerParaObjData
{
-public:
// data members
EditTextObject* mpEditTextObject;
ParagraphDataVector maParagraphDataVector;
bool mbIsEditDoc;
// refcounter
- sal_uInt32 mnRefCount;
+ mutable size_t mnRefCount;
// constuctor
- OutlinerParaObjData(EditTextObject* pEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
- : mpEditTextObject(pEditTextObject),
+ OutlinerParaObjData( EditTextObject* pEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc ) :
+ mpEditTextObject(pEditTextObject),
maParagraphDataVector(rParagraphDataVector),
mbIsEditDoc(bIsEditDoc),
mnRefCount(0)
@@ -58,6 +59,11 @@ public:
maParagraphDataVector.resize(pEditTextObject->GetParagraphCount());
}
+ OutlinerParaObjData( const OutlinerParaObjData& r ) :
+ mpEditTextObject(r.mpEditTextObject->Clone()),
+ maParagraphDataVector(r.maParagraphDataVector),
+ mbIsEditDoc(r.mbIsEditDoc) {}
+
// destructor
~OutlinerParaObjData()
{
@@ -78,41 +84,37 @@ public:
}
};
+inline void intrusive_ptr_add_ref(const OutlinerParaObjData* p)
+{
+ ++p->mnRefCount;
+}
+
+inline void intrusive_ptr_release(const OutlinerParaObjData* p)
+{
+ --p->mnRefCount;
+ if (!p->mnRefCount)
+ delete p;
+}
+
struct OutlinerParaObject::Impl
{
- OutlinerParaObjData* mpData;
+ typedef boost::intrusive_ptr<OutlinerParaObjData> DataRef;
+ DataRef mxData;
Impl( const EditTextObject& rTextObj, const ParagraphDataVector& rParaData, bool bIsEditDoc ) :
- mpData(new OutlinerParaObjData(rTextObj.Clone(), rParaData, bIsEditDoc)) {}
+ mxData(new OutlinerParaObjData(rTextObj.Clone(), rParaData, bIsEditDoc)) {}
Impl( const EditTextObject& rTextObj ) :
- mpData(new OutlinerParaObjData(rTextObj.Clone(), ParagraphDataVector(), true)) {}
+ mxData(new OutlinerParaObjData(rTextObj.Clone(), ParagraphDataVector(), true)) {}
- Impl( const Impl& r ) : mpData(r.mpData)
- {
- mpData->mnRefCount++;
- }
+ Impl( const Impl& r ) : mxData(r.mxData) {}
- ~Impl()
- {
- if (mpData->mnRefCount)
- mpData->mnRefCount--;
- else
- delete mpData;
- }
+ ~Impl() {}
};
void OutlinerParaObject::ImplMakeUnique()
{
- if (mpImpl->mpData->mnRefCount)
- {
- OutlinerParaObjData* pNew = new OutlinerParaObjData(
- mpImpl->mpData->mpEditTextObject->Clone(),
- mpImpl->mpData->maParagraphDataVector,
- mpImpl->mpData->mbIsEditDoc);
- mpImpl->mpData->mnRefCount--;
- mpImpl->mpData = pNew;
- }
+ mpImpl->mxData.reset(new OutlinerParaObjData(*mpImpl->mxData));
}
OutlinerParaObject::OutlinerParaObject(
@@ -124,86 +126,72 @@ OutlinerParaObject::OutlinerParaObject( const EditTextObject& rTextObj ) :
{
}
-OutlinerParaObject::OutlinerParaObject(const OutlinerParaObject& rCandidate) :
- mpImpl(new Impl(*rCandidate.mpImpl)) {}
+OutlinerParaObject::OutlinerParaObject( const OutlinerParaObject& r ) :
+ mpImpl(new Impl(*r.mpImpl)) {}
OutlinerParaObject::~OutlinerParaObject()
{
delete mpImpl;
}
-OutlinerParaObject& OutlinerParaObject::operator=(const OutlinerParaObject& rCandidate)
+OutlinerParaObject& OutlinerParaObject::operator=( const OutlinerParaObject& r )
{
- if(rCandidate.mpImpl->mpData != mpImpl->mpData)
- {
- if (mpImpl->mpData->mnRefCount)
- {
- mpImpl->mpData->mnRefCount--;
- }
- else
- {
- delete mpImpl->mpData;
- }
-
- mpImpl->mpData = rCandidate.mpImpl->mpData;
- mpImpl->mpData->mnRefCount++;
- }
-
+ mpImpl->mxData = r.mpImpl->mxData;
return *this;
}
-bool OutlinerParaObject::operator==(const OutlinerParaObject& rCandidate) const
+bool OutlinerParaObject::operator==( const OutlinerParaObject& r ) const
{
- if (rCandidate.mpImpl->mpData == mpImpl->mpData)
+ if (r.mpImpl->mxData.get() == mpImpl->mxData.get())
{
return true;
}
- return (*rCandidate.mpImpl->mpData == *mpImpl->mpData);
+ return (*r.mpImpl->mxData == *mpImpl->mxData);
}
// #i102062#
-bool OutlinerParaObject::isWrongListEqual(const OutlinerParaObject& rCompare) const
+bool OutlinerParaObject::isWrongListEqual( const OutlinerParaObject& r ) const
{
- if (rCompare.mpImpl->mpData == mpImpl->mpData)
+ if (r.mpImpl->mxData.get() == mpImpl->mxData.get())
{
return true;
}
- return mpImpl->mpData->isWrongListEqual(*rCompare.mpImpl->mpData);
+ return mpImpl->mxData->isWrongListEqual(*r.mpImpl->mxData);
}
sal_uInt16 OutlinerParaObject::GetOutlinerMode() const
{
- return mpImpl->mpData->mpEditTextObject->GetUserType();
+ return mpImpl->mxData->mpEditTextObject->GetUserType();
}
void OutlinerParaObject::SetOutlinerMode(sal_uInt16 nNew)
{
- if (mpImpl->mpData->mpEditTextObject->GetUserType() != nNew)
+ if (mpImpl->mxData->mpEditTextObject->GetUserType() != nNew)
{
ImplMakeUnique();
- mpImpl->mpData->mpEditTextObject->SetUserType(nNew);
+ mpImpl->mxData->mpEditTextObject->SetUserType(nNew);
}
}
bool OutlinerParaObject::IsVertical() const
{
- return mpImpl->mpData->mpEditTextObject->IsVertical();
+ return mpImpl->mxData->mpEditTextObject->IsVertical();
}
void OutlinerParaObject::SetVertical(bool bNew)
{
- if((bool)mpImpl->mpData->mpEditTextObject->IsVertical() != bNew)
+ if (mpImpl->mxData->mpEditTextObject->IsVertical() != bNew)
{
ImplMakeUnique();
- mpImpl->mpData->mpEditTextObject->SetVertical(bNew);
+ mpImpl->mxData->mpEditTextObject->SetVertical(bNew);
}
}
sal_Int32 OutlinerParaObject::Count() const
{
- size_t nSize = mpImpl->mpData->maParagraphDataVector.size();
+ size_t nSize = mpImpl->mxData->maParagraphDataVector.size();
if (nSize > EE_PARA_MAX_COUNT)
{
SAL_WARN( "editeng", "OutlinerParaObject::Count - overflow " << nSize);
@@ -214,9 +202,9 @@ sal_Int32 OutlinerParaObject::Count() const
sal_Int16 OutlinerParaObject::GetDepth(sal_Int32 nPara) const
{
- if(0 <= nPara && static_cast<size_t>(nPara) < mpImpl->mpData->maParagraphDataVector.size())
+ if(0 <= nPara && static_cast<size_t>(nPara) < mpImpl->mxData->maParagraphDataVector.size())
{
- return mpImpl->mpData->maParagraphDataVector[nPara].getDepth();
+ return mpImpl->mxData->maParagraphDataVector[nPara].getDepth();
}
else
{
@@ -226,19 +214,19 @@ sal_Int16 OutlinerParaObject::GetDepth(sal_Int32 nPara) const
const EditTextObject& OutlinerParaObject::GetTextObject() const
{
- return *mpImpl->mpData->mpEditTextObject;
+ return *mpImpl->mxData->mpEditTextObject;
}
bool OutlinerParaObject::IsEditDoc() const
{
- return mpImpl->mpData->mbIsEditDoc;
+ return mpImpl->mxData->mbIsEditDoc;
}
const ParagraphData& OutlinerParaObject::GetParagraphData(sal_Int32 nIndex) const
{
- if(0 <= nIndex && static_cast<size_t>(nIndex) < mpImpl->mpData->maParagraphDataVector.size())
+ if(0 <= nIndex && static_cast<size_t>(nIndex) < mpImpl->mxData->maParagraphDataVector.size())
{
- return mpImpl->mpData->maParagraphDataVector[nIndex];
+ return mpImpl->mxData->maParagraphDataVector[nIndex];
}
else
{
@@ -251,21 +239,21 @@ const ParagraphData& OutlinerParaObject::GetParagraphData(sal_Int32 nIndex) cons
void OutlinerParaObject::ClearPortionInfo()
{
ImplMakeUnique();
- mpImpl->mpData->mpEditTextObject->ClearPortionInfo();
+ mpImpl->mxData->mpEditTextObject->ClearPortionInfo();
}
bool OutlinerParaObject::ChangeStyleSheets(const OUString& rOldName,
SfxStyleFamily eOldFamily, const OUString& rNewName, SfxStyleFamily eNewFamily)
{
ImplMakeUnique();
- return mpImpl->mpData->mpEditTextObject->ChangeStyleSheets(rOldName, eOldFamily, rNewName, eNewFamily);
+ return mpImpl->mxData->mpEditTextObject->ChangeStyleSheets(rOldName, eOldFamily, rNewName, eNewFamily);
}
void OutlinerParaObject::ChangeStyleSheetName(SfxStyleFamily eFamily,
const OUString& rOldName, const OUString& rNewName)
{
ImplMakeUnique();
- mpImpl->mpData->mpEditTextObject->ChangeStyleSheetName(eFamily, rOldName, rNewName);
+ mpImpl->mxData->mpEditTextObject->ChangeStyleSheetName(eFamily, rOldName, rNewName);
}
void OutlinerParaObject::SetStyleSheets(sal_uInt16 nLevel, const OUString& rNewName,
@@ -282,7 +270,7 @@ void OutlinerParaObject::SetStyleSheets(sal_uInt16 nLevel, const OUString& rNewN
{
if(GetDepth(--nDecrementer) == nLevel)
{
- mpImpl->mpData->mpEditTextObject->SetStyleSheet(nDecrementer, rNewName, rNewFamily);
+ mpImpl->mxData->mpEditTextObject->SetStyleSheet(nDecrementer, rNewName, rNewFamily);
}
}
}
commit af246f94554e646880ffcdfc83f6163fdff1fef5
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu Aug 14 10:28:36 2014 -0400
Apply a simple pimpl idiom and rename the old Impl to make it non-Impl.
The old Impl instance is ref-counted, which I'd like to convert to using
boost::intrusive_ptr. But to make it happen, we need to really hide this
from public header...
Change-Id: I1f1e9e500f2112eea04e3e6d661a7dfa74655c62
diff --git a/editeng/source/outliner/outlobj.cxx b/editeng/source/outliner/outlobj.cxx
index 077d567..d4aee9d 100644
--- a/editeng/source/outliner/outlobj.cxx
+++ b/editeng/source/outliner/outlobj.cxx
@@ -32,9 +32,11 @@
#include <vcl/bitmap.hxx>
#include <tools/stream.hxx>
-
-
-class ImplOutlinerParaObject
+/**
+ * This is the guts of OutlinerParaObject, refcounted and shared among
+ * multiple instances of OutlinerParaObject.
+ */
+class OutlinerParaObjData
{
public:
// data members
@@ -46,7 +48,7 @@ public:
sal_uInt32 mnRefCount;
// constuctor
- ImplOutlinerParaObject(EditTextObject* pEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
+ OutlinerParaObjData(EditTextObject* pEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
: mpEditTextObject(pEditTextObject),
maParagraphDataVector(rParagraphDataVector),
mbIsEditDoc(bIsEditDoc),
@@ -57,12 +59,12 @@ public:
}
// destructor
- ~ImplOutlinerParaObject()
+ ~OutlinerParaObjData()
{
delete mpEditTextObject;
}
- bool operator==(const ImplOutlinerParaObject& rCandidate) const
+ bool operator==(const OutlinerParaObjData& rCandidate) const
{
return (*mpEditTextObject == *rCandidate.mpEditTextObject
&& maParagraphDataVector == rCandidate.maParagraphDataVector
@@ -70,69 +72,81 @@ public:
}
// #i102062#
- bool isWrongListEqual(const ImplOutlinerParaObject& rCompare) const
+ bool isWrongListEqual(const OutlinerParaObjData& rCompare) const
{
return mpEditTextObject->isWrongListEqual(*rCompare.mpEditTextObject);
}
};
+struct OutlinerParaObject::Impl
+{
+ OutlinerParaObjData* mpData;
+ Impl( const EditTextObject& rTextObj, const ParagraphDataVector& rParaData, bool bIsEditDoc ) :
+ mpData(new OutlinerParaObjData(rTextObj.Clone(), rParaData, bIsEditDoc)) {}
-void OutlinerParaObject::ImplMakeUnique()
-{
- if(mpImplOutlinerParaObject->mnRefCount)
+ Impl( const EditTextObject& rTextObj ) :
+ mpData(new OutlinerParaObjData(rTextObj.Clone(), ParagraphDataVector(), true)) {}
+
+ Impl( const Impl& r ) : mpData(r.mpData)
{
- ImplOutlinerParaObject* pNew = new ImplOutlinerParaObject(
- mpImplOutlinerParaObject->mpEditTextObject->Clone(),
- mpImplOutlinerParaObject->maParagraphDataVector,
- mpImplOutlinerParaObject->mbIsEditDoc);
- mpImplOutlinerParaObject->mnRefCount--;
- mpImplOutlinerParaObject = pNew;
+ mpData->mnRefCount++;
}
-}
-OutlinerParaObject::OutlinerParaObject(const EditTextObject& rEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
-: mpImplOutlinerParaObject(new ImplOutlinerParaObject(rEditTextObject.Clone(), rParagraphDataVector, bIsEditDoc))
+ ~Impl()
+ {
+ if (mpData->mnRefCount)
+ mpData->mnRefCount--;
+ else
+ delete mpData;
+ }
+};
+
+void OutlinerParaObject::ImplMakeUnique()
{
+ if (mpImpl->mpData->mnRefCount)
+ {
+ OutlinerParaObjData* pNew = new OutlinerParaObjData(
+ mpImpl->mpData->mpEditTextObject->Clone(),
+ mpImpl->mpData->maParagraphDataVector,
+ mpImpl->mpData->mbIsEditDoc);
+ mpImpl->mpData->mnRefCount--;
+ mpImpl->mpData = pNew;
+ }
}
-OutlinerParaObject::OutlinerParaObject( const EditTextObject& rEditTextObject)
-: mpImplOutlinerParaObject( new ImplOutlinerParaObject( rEditTextObject.Clone(), ParagraphDataVector(), true))
-{}
+OutlinerParaObject::OutlinerParaObject(
+ const EditTextObject& rTextObj, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc ) :
+ mpImpl(new Impl(rTextObj, rParagraphDataVector, bIsEditDoc)) {}
-OutlinerParaObject::OutlinerParaObject(const OutlinerParaObject& rCandidate)
-: mpImplOutlinerParaObject(rCandidate.mpImplOutlinerParaObject)
+OutlinerParaObject::OutlinerParaObject( const EditTextObject& rTextObj ) :
+ mpImpl(new Impl(rTextObj))
{
- mpImplOutlinerParaObject->mnRefCount++;
}
+OutlinerParaObject::OutlinerParaObject(const OutlinerParaObject& rCandidate) :
+ mpImpl(new Impl(*rCandidate.mpImpl)) {}
+
OutlinerParaObject::~OutlinerParaObject()
{
- if(mpImplOutlinerParaObject->mnRefCount)
- {
- mpImplOutlinerParaObject->mnRefCount--;
- }
- else
- {
- delete mpImplOutlinerParaObject;
- }
+ delete mpImpl;
}
OutlinerParaObject& OutlinerParaObject::operator=(const OutlinerParaObject& rCandidate)
{
- if(rCandidate.mpImplOutlinerParaObject != mpImplOutlinerParaObject)
+ if(rCandidate.mpImpl->mpData != mpImpl->mpData)
{
- if(mpImplOutlinerParaObject->mnRefCount)
+ if (mpImpl->mpData->mnRefCount)
{
- mpImplOutlinerParaObject->mnRefCount--;
+ mpImpl->mpData->mnRefCount--;
}
else
{
- delete mpImplOutlinerParaObject;
+ delete mpImpl->mpData;
}
- mpImplOutlinerParaObject = rCandidate.mpImplOutlinerParaObject;
- mpImplOutlinerParaObject->mnRefCount++;
+ mpImpl->mpData = rCandidate.mpImpl->mpData;
+ mpImpl->mpData->mnRefCount++;
}
return *this;
@@ -140,56 +154,56 @@ OutlinerParaObject& OutlinerParaObject::operator=(const OutlinerParaObject& rCan
bool OutlinerParaObject::operator==(const OutlinerParaObject& rCandidate) const
{
- if(rCandidate.mpImplOutlinerParaObject == mpImplOutlinerParaObject)
+ if (rCandidate.mpImpl->mpData == mpImpl->mpData)
{
return true;
}
- return (*rCandidate.mpImplOutlinerParaObject == *mpImplOutlinerParaObject);
+ return (*rCandidate.mpImpl->mpData == *mpImpl->mpData);
}
// #i102062#
bool OutlinerParaObject::isWrongListEqual(const OutlinerParaObject& rCompare) const
{
- if(rCompare.mpImplOutlinerParaObject == mpImplOutlinerParaObject)
+ if (rCompare.mpImpl->mpData == mpImpl->mpData)
{
return true;
}
- return mpImplOutlinerParaObject->isWrongListEqual(*rCompare.mpImplOutlinerParaObject);
+ return mpImpl->mpData->isWrongListEqual(*rCompare.mpImpl->mpData);
}
sal_uInt16 OutlinerParaObject::GetOutlinerMode() const
{
- return mpImplOutlinerParaObject->mpEditTextObject->GetUserType();
+ return mpImpl->mpData->mpEditTextObject->GetUserType();
}
void OutlinerParaObject::SetOutlinerMode(sal_uInt16 nNew)
{
- if(mpImplOutlinerParaObject->mpEditTextObject->GetUserType() != nNew)
+ if (mpImpl->mpData->mpEditTextObject->GetUserType() != nNew)
{
ImplMakeUnique();
- mpImplOutlinerParaObject->mpEditTextObject->SetUserType(nNew);
+ mpImpl->mpData->mpEditTextObject->SetUserType(nNew);
}
}
bool OutlinerParaObject::IsVertical() const
{
- return mpImplOutlinerParaObject->mpEditTextObject->IsVertical();
+ return mpImpl->mpData->mpEditTextObject->IsVertical();
}
void OutlinerParaObject::SetVertical(bool bNew)
{
- if((bool)mpImplOutlinerParaObject->mpEditTextObject->IsVertical() != bNew)
+ if((bool)mpImpl->mpData->mpEditTextObject->IsVertical() != bNew)
{
ImplMakeUnique();
- mpImplOutlinerParaObject->mpEditTextObject->SetVertical(bNew);
+ mpImpl->mpData->mpEditTextObject->SetVertical(bNew);
}
}
sal_Int32 OutlinerParaObject::Count() const
{
- size_t nSize = mpImplOutlinerParaObject->maParagraphDataVector.size();
+ size_t nSize = mpImpl->mpData->maParagraphDataVector.size();
if (nSize > EE_PARA_MAX_COUNT)
{
SAL_WARN( "editeng", "OutlinerParaObject::Count - overflow " << nSize);
@@ -200,9 +214,9 @@ sal_Int32 OutlinerParaObject::Count() const
sal_Int16 OutlinerParaObject::GetDepth(sal_Int32 nPara) const
{
- if(0 <= nPara && static_cast<size_t>(nPara) < mpImplOutlinerParaObject->maParagraphDataVector.size())
+ if(0 <= nPara && static_cast<size_t>(nPara) < mpImpl->mpData->maParagraphDataVector.size())
{
- return mpImplOutlinerParaObject->maParagraphDataVector[nPara].getDepth();
+ return mpImpl->mpData->maParagraphDataVector[nPara].getDepth();
}
else
{
@@ -212,19 +226,19 @@ sal_Int16 OutlinerParaObject::GetDepth(sal_Int32 nPara) const
const EditTextObject& OutlinerParaObject::GetTextObject() const
{
- return *mpImplOutlinerParaObject->mpEditTextObject;
+ return *mpImpl->mpData->mpEditTextObject;
}
bool OutlinerParaObject::IsEditDoc() const
{
- return mpImplOutlinerParaObject->mbIsEditDoc;
+ return mpImpl->mpData->mbIsEditDoc;
}
const ParagraphData& OutlinerParaObject::GetParagraphData(sal_Int32 nIndex) const
{
- if(0 <= nIndex && static_cast<size_t>(nIndex) < mpImplOutlinerParaObject->maParagraphDataVector.size())
+ if(0 <= nIndex && static_cast<size_t>(nIndex) < mpImpl->mpData->maParagraphDataVector.size())
{
- return mpImplOutlinerParaObject->maParagraphDataVector[nIndex];
+ return mpImpl->mpData->maParagraphDataVector[nIndex];
}
else
{
@@ -237,21 +251,21 @@ const ParagraphData& OutlinerParaObject::GetParagraphData(sal_Int32 nIndex) cons
void OutlinerParaObject::ClearPortionInfo()
{
ImplMakeUnique();
- mpImplOutlinerParaObject->mpEditTextObject->ClearPortionInfo();
+ mpImpl->mpData->mpEditTextObject->ClearPortionInfo();
}
bool OutlinerParaObject::ChangeStyleSheets(const OUString& rOldName,
SfxStyleFamily eOldFamily, const OUString& rNewName, SfxStyleFamily eNewFamily)
{
ImplMakeUnique();
- return mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheets(rOldName, eOldFamily, rNewName, eNewFamily);
+ return mpImpl->mpData->mpEditTextObject->ChangeStyleSheets(rOldName, eOldFamily, rNewName, eNewFamily);
}
void OutlinerParaObject::ChangeStyleSheetName(SfxStyleFamily eFamily,
const OUString& rOldName, const OUString& rNewName)
{
ImplMakeUnique();
- mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheetName(eFamily, rOldName, rNewName);
+ mpImpl->mpData->mpEditTextObject->ChangeStyleSheetName(eFamily, rOldName, rNewName);
}
void OutlinerParaObject::SetStyleSheets(sal_uInt16 nLevel, const OUString& rNewName,
@@ -268,7 +282,7 @@ void OutlinerParaObject::SetStyleSheets(sal_uInt16 nLevel, const OUString& rNewN
{
if(GetDepth(--nDecrementer) == nLevel)
{
- mpImplOutlinerParaObject->mpEditTextObject->SetStyleSheet(nDecrementer, rNewName, rNewFamily);
+ mpImpl->mpData->mpEditTextObject->SetStyleSheet(nDecrementer, rNewName, rNewFamily);
}
}
}
diff --git a/include/editeng/outlobj.hxx b/include/editeng/outlobj.hxx
index 4464bf3..c57397e 100644
--- a/include/editeng/outlobj.hxx
+++ b/include/editeng/outlobj.hxx
@@ -26,12 +26,11 @@
#include <rsc/rscsfx.hxx>
class EditTextObject;
-class ImplOutlinerParaObject;
class EDITENG_DLLPUBLIC OutlinerParaObject
{
-private:
- ImplOutlinerParaObject* mpImplOutlinerParaObject;
+ struct Impl;
+ Impl* mpImpl;
void ImplMakeUnique();
commit e12d21fee9471ca1c4546b23df475aa39c953e13
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Aug 13 16:44:49 2014 -0400
Aligh this correctly...
Also use 4-char tab space etc.
Change-Id: I5ca007f58a588823ce9961af154cd97c25dd6f9b
diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
index 8d0cc2b..b4d7575 100644
--- a/svx/source/unodraw/unoprov.cxx
+++ b/svx/source/unodraw/unoprov.cxx
@@ -810,52 +810,57 @@ comphelper::PropertyMapEntry const * ImplGetAdditionalWriterDrawingDefaultsPrope
typedef ::boost::unordered_map< OUString, sal_uInt32, OUStringHash > UHashMapImpl;
namespace {
- static const UHashMapImpl &GetUHashImpl()
- {
- static UHashMapImpl aImpl(63);
- static bool bInited = false;
- if (!bInited) {
- const struct { const char *name; sal_Int32 length; sal_uInt32 id; } aInit[] = {
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.RectangleShape"), OBJ_RECT },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.EllipseShape"), OBJ_CIRC },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ControlShape"), OBJ_UNO },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ConnectorShape"), OBJ_EDGE },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MeasureShape"), OBJ_MEASURE },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.LineShape"), OBJ_LINE },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyPolygonShape"), OBJ_POLY },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyLineShape"), OBJ_PLIN },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OpenBezierShape"), OBJ_PATHLINE },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ClosedBezierShape"), OBJ_PATHFILL },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OpenFreeHandShape"), OBJ_FREELINE },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ClosedFreeHandShape"), OBJ_FREEFILL },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyPolygonPathShape"), OBJ_PATHPOLY },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyLinePathShape"), OBJ_PATHPLIN },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GraphicObjectShape"), OBJ_GRAF },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GroupShape"), OBJ_GRUP },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TextShape"), OBJ_TEXT },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OLE2Shape"), OBJ_OLE2 },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PageShape"), OBJ_PAGE },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.CaptionShape"), OBJ_CAPTION },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.FrameShape"), OBJ_FRAME },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PluginShape"), OBJ_OLE2_PLUGIN },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.AppletShape"), OBJ_OLE2_APPLET },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.CustomShape"), OBJ_CUSTOMSHAPE },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MediaShape"), OBJ_MEDIA },
-
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DSceneObject"), E3D_POLYSCENE_ID | E3D_INVENTOR_FLAG },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DCubeObject"), E3D_CUBEOBJ_ID | E3D_INVENTOR_FLAG },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DSphereObject"), E3D_SPHEREOBJ_ID | E3D_INVENTOR_FLAG },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DLatheObject"), E3D_LATHEOBJ_ID | E3D_INVENTOR_FLAG },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DExtrudeObject"), E3D_EXTRUDEOBJ_ID | E3D_INVENTOR_FLAG },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DPolygonObject"), E3D_POLYGONOBJ_ID | E3D_INVENTOR_FLAG },
- { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OpenGLObject"), OBJ_OPENGL },
- };
- for (sal_uInt32 i = 0; i < sizeof(aInit)/sizeof(aInit[0]); i++)
- aImpl[OUString( aInit[i].name, aInit[i].length, RTL_TEXTENCODING_ASCII_US ) ] = aInit[i].id;
- bInited = true;
- }
- return aImpl;
- }
+
+const UHashMapImpl& GetUHashImpl()
+{
+ static UHashMapImpl aImpl(63);
+ static bool bInited = false;
+ if (!bInited)
+ {
+ const struct { const char *name; sal_Int32 length; sal_uInt32 id; } aInit[] = {
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.RectangleShape"), OBJ_RECT },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.EllipseShape"), OBJ_CIRC },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ControlShape"), OBJ_UNO },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ConnectorShape"), OBJ_EDGE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MeasureShape"), OBJ_MEASURE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.LineShape"), OBJ_LINE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyPolygonShape"), OBJ_POLY },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyLineShape"), OBJ_PLIN },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OpenBezierShape"), OBJ_PATHLINE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ClosedBezierShape"), OBJ_PATHFILL },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OpenFreeHandShape"), OBJ_FREELINE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ClosedFreeHandShape"), OBJ_FREEFILL },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyPolygonPathShape"), OBJ_PATHPOLY },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyLinePathShape"), OBJ_PATHPLIN },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GraphicObjectShape"), OBJ_GRAF },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GroupShape"), OBJ_GRUP },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TextShape"), OBJ_TEXT },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OLE2Shape"), OBJ_OLE2 },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PageShape"), OBJ_PAGE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.CaptionShape"), OBJ_CAPTION },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.FrameShape"), OBJ_FRAME },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PluginShape"), OBJ_OLE2_PLUGIN },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.AppletShape"), OBJ_OLE2_APPLET },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.CustomShape"), OBJ_CUSTOMSHAPE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MediaShape"), OBJ_MEDIA },
+
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DSceneObject"), E3D_POLYSCENE_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DCubeObject"), E3D_CUBEOBJ_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DSphereObject"), E3D_SPHEREOBJ_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DLatheObject"), E3D_LATHEOBJ_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DExtrudeObject"), E3D_EXTRUDEOBJ_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DPolygonObject"), E3D_POLYGONOBJ_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OpenGLObject"), OBJ_OPENGL },
+ };
+
+ for (sal_uInt32 i = 0; i < sizeof(aInit)/sizeof(aInit[0]); i++)
+ aImpl[OUString( aInit[i].name, aInit[i].length, RTL_TEXTENCODING_ASCII_US ) ] = aInit[i].id;
+ bInited = true;
+ }
+
+ return aImpl;
+}
+
}
commit 8f6a1b509125e4c0a4ebfb12b42c2a072912fa01
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Aug 13 16:14:34 2014 -0400
Scope reduction by early bailout.
Change-Id: If66f732265505a97990cf6c75ff53797a1d91b7a
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index f8d91c277..cfad41b 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -499,91 +499,91 @@ SdrObject *SvxDrawPage::_CreateSdrObject(const Reference< drawing::XShape > & xS
sal_uInt32 nInventor = 0;
GetTypeAndInventor( nType, nInventor, xShape->getShapeType() );
+ if (!nType)
+ return NULL;
+
SdrObject* pNewObj = 0;
- if( nType != 0 )
+ awt::Size aSize = xShape->getSize();
+ aSize.Width += 1;
+ aSize.Height += 1;
+ awt::Point aPos = xShape->getPosition();
+ Rectangle aRect( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) );
+
+ // special cases
+ if( nInventor == SdrInventor )
{
- awt::Size aSize = xShape->getSize();
- aSize.Width += 1;
- aSize.Height += 1;
- awt::Point aPos = xShape->getPosition();
- Rectangle aRect( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) );
-
- // special cases
- if( nInventor == SdrInventor )
+ switch( nType )
{
- switch( nType )
+ case OBJ_MEASURE:
{
- case OBJ_MEASURE:
- {
- pNewObj = new SdrMeasureObj( aRect.TopLeft(), aRect.BottomRight() );
- break;
- }
- case OBJ_LINE:
- {
- basegfx::B2DPolygon aPoly;
- aPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Top()));
- aPoly.append(basegfx::B2DPoint(aRect.Right(), aRect.Bottom()));
- pNewObj = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPoly));
- break;
- }
+ pNewObj = new SdrMeasureObj( aRect.TopLeft(), aRect.BottomRight() );
+ break;
+ }
+ case OBJ_LINE:
+ {
+ basegfx::B2DPolygon aPoly;
+ aPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Top()));
+ aPoly.append(basegfx::B2DPoint(aRect.Right(), aRect.Bottom()));
+ pNewObj = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPoly));
+ break;
}
}
+ }
- if( pNewObj == NULL )
- pNewObj = SdrObjFactory::MakeNewObject( nInventor, nType, mpPage );
+ if( pNewObj == NULL )
+ pNewObj = SdrObjFactory::MakeNewObject( nInventor, nType, mpPage );
- if(pNewObj)
- {
- pNewObj->SetSnapRect(aRect);
+ if (!pNewObj)
+ return NULL;
- if( pNewObj->ISA(E3dPolyScene))
- {
- // Szene initialisieren
- E3dScene* pScene = (E3dScene*)pNewObj;
-
- double fW = (double)aSize.Width;
- double fH = (double)aSize.Height;
-
- Camera3D aCam(pScene->GetCamera());
- aCam.SetAutoAdjustProjection(false);
- aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH);
- basegfx::B3DPoint aLookAt;
- basegfx::B3DPoint aCamPos(0.0, 0.0, 10000.0);
- aCam.SetPosAndLookAt(aCamPos, aLookAt);
- aCam.SetFocalLength(100.0);
- aCam.SetDefaults(aCamPos, aLookAt, 10000.0);
- pScene->SetCamera(aCam);
-
- pScene->SetRectsDirty();
- }
- else if(pNewObj->ISA(E3dExtrudeObj))
- {
- E3dExtrudeObj* pObj = (E3dExtrudeObj*)pNewObj;
- basegfx::B2DPolygon aNewPolygon;
- aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
- aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
- aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
- aNewPolygon.setClosed(true);
- pObj->SetExtrudePolygon(basegfx::B2DPolyPolygon(aNewPolygon));
-
- // #107245# pObj->SetExtrudeCharacterMode(sal_True);
- pObj->SetMergedItem(Svx3DCharacterModeItem(true));
- }
- else if(pNewObj->ISA(E3dLatheObj))
- {
- E3dLatheObj* pObj = (E3dLatheObj*)pNewObj;
- basegfx::B2DPolygon aNewPolygon;
- aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
- aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
- aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
- aNewPolygon.setClosed(true);
- pObj->SetPolyPoly2D(basegfx::B2DPolyPolygon(aNewPolygon));
-
- // #107245# pObj->SetLatheCharacterMode(sal_True);
- pObj->SetMergedItem(Svx3DCharacterModeItem(true));
- }
- }
+ pNewObj->SetSnapRect(aRect);
+
+ if( pNewObj->ISA(E3dPolyScene))
+ {
+ // Szene initialisieren
+ E3dScene* pScene = (E3dScene*)pNewObj;
+
+ double fW = (double)aSize.Width;
+ double fH = (double)aSize.Height;
+
+ Camera3D aCam(pScene->GetCamera());
+ aCam.SetAutoAdjustProjection(false);
+ aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH);
+ basegfx::B3DPoint aLookAt;
+ basegfx::B3DPoint aCamPos(0.0, 0.0, 10000.0);
+ aCam.SetPosAndLookAt(aCamPos, aLookAt);
+ aCam.SetFocalLength(100.0);
+ aCam.SetDefaults(aCamPos, aLookAt, 10000.0);
+ pScene->SetCamera(aCam);
+
+ pScene->SetRectsDirty();
+ }
+ else if(pNewObj->ISA(E3dExtrudeObj))
+ {
+ E3dExtrudeObj* pObj = (E3dExtrudeObj*)pNewObj;
+ basegfx::B2DPolygon aNewPolygon;
+ aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
+ aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
+ aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
+ aNewPolygon.setClosed(true);
+ pObj->SetExtrudePolygon(basegfx::B2DPolyPolygon(aNewPolygon));
+
+ // #107245# pObj->SetExtrudeCharacterMode(sal_True);
+ pObj->SetMergedItem(Svx3DCharacterModeItem(true));
+ }
+ else if(pNewObj->ISA(E3dLatheObj))
+ {
+ E3dLatheObj* pObj = (E3dLatheObj*)pNewObj;
+ basegfx::B2DPolygon aNewPolygon;
+ aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
+ aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
+ aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
+ aNewPolygon.setClosed(true);
+ pObj->SetPolyPoly2D(basegfx::B2DPolyPolygon(aNewPolygon));
+
+ // #107245# pObj->SetLatheCharacterMode(sal_True);
+ pObj->SetMergedItem(Svx3DCharacterModeItem(true));
}
return pNewObj;
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index 3449f8d..faeeebc 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -188,40 +188,44 @@ void SAL_CALL SvxShapeGroup::leaveGroup( ) throw(uno::RuntimeException, std::ex
void SvxShapeGroup::addUnoShape( const uno::Reference< drawing::XShape >& xShape, sal_uIntPtr nPos )
{
- SvxShape* pShape = SvxShape::getImplementation( xShape );
-
- if( mpObj.is()&& mxPage.is() && pShape )
+ if (!mpObj.is() || !mxPage.is())
{
- SdrObject* pSdrShape = pShape->GetSdrObject();
- if( pSdrShape == NULL )
- pSdrShape = mxPage->_CreateSdrObject( xShape );
-
- if( pSdrShape->IsInserted() )
- pSdrShape->GetObjList()->RemoveObject( pSdrShape->GetOrdNum() );
-
- mpObj->GetSubList()->InsertObject(pSdrShape, nPos);
- pSdrShape->SetModel(mpObj->GetModel());
-
- // #85922# It makes no sense to set the layer asked
- // from the group object since these is an iteration
- // over the contained objects. In consequence, this
- // statement erases all layer information from the draw
- // objects. Layers need to be set at draw objects directly
- // and have nothing to do with grouping at all.
- // pSdrShape->SetLayer(pObject->GetLayer());
-
- // Establish connection between new SdrObject and its wrapper before
- // inserting the new shape into the group. There a new wrapper
- // would be created when this connection would not already exist.
- pShape->Create( pSdrShape, mxPage.get() );
-
- if( mpModel )
- mpModel->SetChanged();
+ OSL_FAIL("could not add XShape to group shape!");
+ return;
}
- else
+
+ SvxShape* pShape = SvxShape::getImplementation( xShape );
+ if (!pShape)
{
OSL_FAIL("could not add XShape to group shape!");
+ return;
}
+
+ SdrObject* pSdrShape = pShape->GetSdrObject();
+ if( pSdrShape == NULL )
+ pSdrShape = mxPage->_CreateSdrObject( xShape );
+
+ if( pSdrShape->IsInserted() )
+ pSdrShape->GetObjList()->RemoveObject( pSdrShape->GetOrdNum() );
+
+ mpObj->GetSubList()->InsertObject(pSdrShape, nPos);
+ pSdrShape->SetModel(mpObj->GetModel());
+
+ // #85922# It makes no sense to set the layer asked
+ // from the group object since these is an iteration
+ // over the contained objects. In consequence, this
+ // statement erases all layer information from the draw
+ // objects. Layers need to be set at draw objects directly
+ // and have nothing to do with grouping at all.
+ // pSdrShape->SetLayer(pObject->GetLayer());
+
+ // Establish connection between new SdrObject and its wrapper before
+ // inserting the new shape into the group. There a new wrapper
+ // would be created when this connection would not already exist.
+ pShape->Create( pSdrShape, mxPage.get() );
+
+ if( mpModel )
+ mpModel->SetChanged();
}
// XShapes
commit be0de8b9db9c428de5c65be51be2eef17947e4dc
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Aug 13 14:26:16 2014 -0400
Use struct to group together parameters to reduce number of method args.
And to make it easier to share common parameters between methods.
Change-Id: Ibdbad66ea8f2f30b4518f9ecaec2f43087c54837
diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx
index 51142bd..b900e9c 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -34,11 +34,33 @@
#include <boost/scoped_ptr.hpp>
-namespace chart
-{
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
+namespace chart {
+
+struct PieChart::ShapeParam
+{
+ double mfUnitCircleStartAngleDegree;
+ double mfUnitCircleWidthAngleDegree;
+ double mfUnitCircleOuterRadius;
+ double mfUnitCircleInnerRadius;
+ double mfExplodePercentage;
+ double mfLogicYSum;
+ double mfLogicZ;
+ double mfDepth;
+
+ ShapeParam() :
+ mfUnitCircleStartAngleDegree(0.0),
+ mfUnitCircleWidthAngleDegree(0.0),
+ mfUnitCircleOuterRadius(0.0),
+ mfUnitCircleInnerRadius(0.0),
+ mfExplodePercentage(0.0),
+ mfLogicYSum(0.0),
+ mfLogicZ(0.0),
+ mfDepth(0.0) {}
+};
+
class PiePositionHelper : public PolarPlottingPositionHelper
{
public:
@@ -163,21 +185,19 @@ bool PieChart::shouldSnapRectToUsedArea()
}
uno::Reference< drawing::XShape > PieChart::createDataPoint(
- const uno::Reference< drawing::XShapes >& xTarget
- , const uno::Reference< beans::XPropertySet >& xObjectProperties
- , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree
- , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius
- , double fLogicZ, double fDepth, double fExplodePercentage
- , tPropertyNameValueMap* pOverwritePropertiesMap )
+ const uno::Reference<drawing::XShapes>& xTarget,
+ const uno::Reference<beans::XPropertySet>& xObjectProperties,
+ tPropertyNameValueMap* pOverwritePropertiesMap,
+ const ShapeParam& rParam )
{
//transform position:
drawing::Direction3D aOffset;
- if( !::rtl::math::approxEqual( fExplodePercentage, 0.0 ) )
+ if (!::rtl::math::approxEqual(rParam.mfExplodePercentage, 0.0))
{
- double fAngle = fUnitCircleStartAngleDegree + fUnitCircleWidthAngleDegree/2.0;
- double fRadius = (fUnitCircleOuterRadius-fUnitCircleInnerRadius)*fExplodePercentage;
- drawing::Position3D aOrigin = m_pPosHelper->transformUnitCircleToScene( 0, 0, fLogicZ );
- drawing::Position3D aNewOrigin = m_pPosHelper->transformUnitCircleToScene( fAngle, fRadius, fLogicZ );
+ double fAngle = rParam.mfUnitCircleStartAngleDegree + rParam.mfUnitCircleWidthAngleDegree/2.0;
+ double fRadius = (rParam.mfUnitCircleOuterRadius-rParam.mfUnitCircleInnerRadius)*rParam.mfExplodePercentage;
+ drawing::Position3D aOrigin = m_pPosHelper->transformUnitCircleToScene(0, 0, rParam.mfLogicZ);
+ drawing::Position3D aNewOrigin = m_pPosHelper->transformUnitCircleToScene(fAngle, fRadius, rParam.mfLogicZ);
aOffset = aNewOrigin - aOrigin;
}
@@ -186,16 +206,16 @@ uno::Reference< drawing::XShape > PieChart::createDataPoint(
if(m_nDimension==3)
{
xShape = m_pShapeFactory->createPieSegment( xTarget
- , fUnitCircleStartAngleDegree, fUnitCircleWidthAngleDegree
- , fUnitCircleInnerRadius, fUnitCircleOuterRadius
+ , rParam.mfUnitCircleStartAngleDegree, rParam.mfUnitCircleWidthAngleDegree
+ , rParam.mfUnitCircleInnerRadius, rParam.mfUnitCircleOuterRadius
, aOffset, B3DHomMatrixToHomogenMatrix( m_pPosHelper->getUnitCartesianToScene() )
- , fDepth );
+ , rParam.mfDepth );
}
else
{
xShape = m_pShapeFactory->createPieSegment2D( xTarget
- , fUnitCircleStartAngleDegree, fUnitCircleWidthAngleDegree
- , fUnitCircleInnerRadius, fUnitCircleOuterRadius
+ , rParam.mfUnitCircleStartAngleDegree, rParam.mfUnitCircleWidthAngleDegree
+ , rParam.mfUnitCircleInnerRadius, rParam.mfUnitCircleOuterRadius
, aOffset, B3DHomMatrixToHomogenMatrix( m_pPosHelper->getUnitCartesianToScene() ) );
}
this->setMappedProperties( xShape, xObjectProperties, PropertyMapper::getPropertyNameMapForFilledSeriesProperties(), pOverwritePropertiesMap );
@@ -204,19 +224,16 @@ uno::Reference< drawing::XShape > PieChart::createDataPoint(
void PieChart::createTextLabelShape(
const uno::Reference<drawing::XShapes>& xTextTarget,
- VDataSeries& rSeries, sal_Int32 nPointIndex,
- double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree,
- double fUnitCircleOuterRadius, double fUnitCircleInnerRadius, double fExplodePercentage,
- double fLogicYSum, double fLogicZ )
+ VDataSeries& rSeries, sal_Int32 nPointIndex, ShapeParam& rParam )
{
if (!rSeries.getDataPointLabelIfLabel(nPointIndex))
return;
- if( !::rtl::math::approxEqual( fExplodePercentage, 0.0 ) )
+ if (!rtl::math::approxEqual(rParam.mfExplodePercentage, 0.0))
{
- double fExplodeOffset = (fUnitCircleOuterRadius-fUnitCircleInnerRadius)*fExplodePercentage;
- fUnitCircleInnerRadius += fExplodeOffset;
- fUnitCircleOuterRadius += fExplodeOffset;
+ double fExplodeOffset = (rParam.mfUnitCircleOuterRadius-rParam.mfUnitCircleInnerRadius)*rParam.mfExplodePercentage;
+ rParam.mfUnitCircleInnerRadius += fExplodeOffset;
+ rParam.mfUnitCircleOuterRadius += fExplodeOffset;
}
sal_Int32 nLabelPlacement = rSeries.getLabelPlacement(
@@ -240,12 +257,12 @@ void PieChart::createTextLabelShape(
PolarLabelPositionHelper aPolarPosHelper(m_pPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory);
awt::Point aScreenPosition2D(
aPolarPosHelper.getLabelScreenPositionAndAlignmentForUnitCircleValues(eAlignment, nLabelPlacement
- , fUnitCircleStartAngleDegree, fUnitCircleWidthAngleDegree
- , fUnitCircleInnerRadius, fUnitCircleOuterRadius, fLogicZ+0.5, 0 ));
+ , rParam.mfUnitCircleStartAngleDegree, rParam.mfUnitCircleWidthAngleDegree
+ , rParam.mfUnitCircleInnerRadius, rParam.mfUnitCircleOuterRadius, rParam.mfLogicZ+0.5, 0 ));
PieLabelInfo aPieLabelInfo;
aPieLabelInfo.aFirstPosition = basegfx::B2IVector( aScreenPosition2D.X, aScreenPosition2D.Y );
- awt::Point aOrigin( aPolarPosHelper.transformSceneToScreenPosition( m_pPosHelper->transformUnitCircleToScene( 0.0, 0.0, fLogicZ+1.0 ) ) );
+ awt::Point aOrigin( aPolarPosHelper.transformSceneToScreenPosition( m_pPosHelper->transformUnitCircleToScene( 0.0, 0.0, rParam.mfLogicZ+1.0 ) ) );
aPieLabelInfo.aOrigin = basegfx::B2IVector( aOrigin.X, aOrigin.Y );
//add a scaling independent Offset if requested
@@ -259,7 +276,7 @@ void PieChart::createTextLabelShape(
double nVal = rSeries.getYValue(nPointIndex);
aPieLabelInfo.xTextShape = createDataLabel(
- xTextTarget, rSeries, nPointIndex, nVal, fLogicYSum, aScreenPosition2D, eAlignment);
+ xTextTarget, rSeries, nPointIndex, nVal, rParam.mfLogicYSum, aScreenPosition2D, eAlignment);
uno::Reference< container::XChild > xChild( aPieLabelInfo.xTextShape, uno::UNO_QUERY );
if( xChild.is() )
@@ -409,6 +426,8 @@ void PieChart::createShapes()
for( double fSlotX=0; aXSlotIter != aXSlotEnd && (m_bUseRings||fSlotX<0.5 ); ++aXSlotIter, fSlotX+=1.0 )
{
+ ShapeParam aParam;
+
::std::vector< VDataSeries* >* pSeriesList = &(aXSlotIter->m_aSeriesVector);
if( pSeriesList->size()<=0 )//there should be only one series in each x slot
continue;
@@ -420,7 +439,6 @@ void PieChart::createShapes()
m_pPosHelper->m_fAngleDegreeOffset = pSeries->getStartingAngle();
- double fLogicYSum = 0.0;
//iterate through all points to get the sum
sal_Int32 nPointIndex=0;
sal_Int32 nPointCount=pSeries->getTotalPointCount();
@@ -433,10 +451,12 @@ void PieChart::createShapes()
}
if( ::rtl::math::isNan(fY) )
continue;
- fLogicYSum += fabs(fY);
+ aParam.mfLogicYSum += fabs(fY);
}
- if(fLogicYSum==0.0)
+
+ if (aParam.mfLogicYSum == 0.0)
continue;
+
double fLogicYForNextPoint = 0.0;
//iterate through all points to create shapes
for( nPointIndex = 0; nPointIndex < nPointCount; nPointIndex++ )
@@ -447,7 +467,7 @@ void PieChart::createShapes()
if( !bIsVisible )
continue;
- double fDepth = this->getTransformedDepth() * (n3DRelativeHeight / 100.0);
+ aParam.mfDepth = this->getTransformedDepth() * (n3DRelativeHeight / 100.0);
uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShape(pSeries, xSeriesTarget);
//collect data point information (logic coordinates, style ):
@@ -464,14 +484,14 @@ void PieChart::createShapes()
//iterate through all subsystems to create partial points
{
//logic values on angle axis:
- double fLogicStartAngleValue = fLogicYPos/fLogicYSum;
- double fLogicEndAngleValue = (fLogicYPos+fLogicYValue)/fLogicYSum;
+ double fLogicStartAngleValue = fLogicYPos / aParam.mfLogicYSum;
+ double fLogicEndAngleValue = (fLogicYPos+fLogicYValue) / aParam.mfLogicYSum;
- double fExplodePercentage=0.0;
+ aParam.mfExplodePercentage = 0.0;
bool bDoExplode = ( nExplodeableSlot == static_cast< ::std::vector< VDataSeriesGroup >::size_type >(fSlotX) );
if(bDoExplode) try
{
- xPointProperties->getPropertyValue( "Offset") >>= fExplodePercentage;
+ xPointProperties->getPropertyValue( "Offset") >>= aParam.mfExplodePercentage;
}
catch( const uno::Exception& e )
{
@@ -479,10 +499,10 @@ void PieChart::createShapes()
}
//transforme to unit circle:
- double fUnitCircleWidthAngleDegree = m_pPosHelper->getWidthAngleDegree( fLogicStartAngleValue, fLogicEndAngleValue );
- double fUnitCircleStartAngleDegree = m_pPosHelper->transformToAngleDegree( fLogicStartAngleValue );
- double fUnitCircleInnerRadius = m_pPosHelper->transformToRadius( fLogicInnerRadius );
- double fUnitCircleOuterRadius = m_pPosHelper->transformToRadius( fLogicOuterRadius );
+ aParam.mfUnitCircleWidthAngleDegree = m_pPosHelper->getWidthAngleDegree( fLogicStartAngleValue, fLogicEndAngleValue );
+ aParam.mfUnitCircleStartAngleDegree = m_pPosHelper->transformToAngleDegree( fLogicStartAngleValue );
+ aParam.mfUnitCircleInnerRadius = m_pPosHelper->transformToRadius( fLogicInnerRadius );
+ aParam.mfUnitCircleOuterRadius = m_pPosHelper->transformToRadius( fLogicOuterRadius );
//point color:
boost::scoped_ptr< tPropertyNameValueMap > apOverwritePropertiesMap(NULL);
@@ -496,12 +516,10 @@ void PieChart::createShapes()
}
//create data point
- double fLogicZ = -1.0; // For 3D pie chart label position
- uno::Reference<drawing::XShape> xPointShape(
- createDataPoint( xSeriesGroupShape_Shapes, xPointProperties
- , fUnitCircleStartAngleDegree, fUnitCircleWidthAngleDegree
- , fUnitCircleInnerRadius, fUnitCircleOuterRadius
- , fLogicZ, fDepth, fExplodePercentage, apOverwritePropertiesMap.get() ) );
+ aParam.mfLogicZ = -1.0; // For 3D pie chart label position
+ uno::Reference<drawing::XShape> xPointShape =
+ createDataPoint(
+ xSeriesGroupShape_Shapes, xPointProperties, apOverwritePropertiesMap.get(), aParam);
if(bHasFillColorMapping)
{
@@ -514,11 +532,7 @@ void PieChart::createShapes()
}
//create label
- createTextLabelShape(
- xTextTarget, *pSeries, nPointIndex,
- fUnitCircleStartAngleDegree, fUnitCircleWidthAngleDegree,
- fUnitCircleOuterRadius, fUnitCircleInnerRadius,
- fExplodePercentage, fLogicYSum, fLogicZ);
+ createTextLabelShape(xTextTarget, *pSeries, nPointIndex, aParam);
if(!bDoExplode)
{
@@ -529,12 +543,12 @@ void PieChart::createShapes()
{
//enable dragging of outer segments
- double fAngle = fUnitCircleStartAngleDegree + fUnitCircleWidthAngleDegree/2.0;
- double fMaxDeltaRadius = fUnitCircleOuterRadius-fUnitCircleInnerRadius;
- drawing::Position3D aOrigin = m_pPosHelper->transformUnitCircleToScene( fAngle, fUnitCircleOuterRadius, fLogicZ );
- drawing::Position3D aNewOrigin = m_pPosHelper->transformUnitCircleToScene( fAngle, fUnitCircleOuterRadius + fMaxDeltaRadius, fLogicZ );
+ double fAngle = aParam.mfUnitCircleStartAngleDegree + aParam.mfUnitCircleWidthAngleDegree/2.0;
+ double fMaxDeltaRadius = aParam.mfUnitCircleOuterRadius-aParam.mfUnitCircleInnerRadius;
+ drawing::Position3D aOrigin = m_pPosHelper->transformUnitCircleToScene( fAngle, aParam.mfUnitCircleOuterRadius, aParam.mfLogicZ );
+ drawing::Position3D aNewOrigin = m_pPosHelper->transformUnitCircleToScene( fAngle, aParam.mfUnitCircleOuterRadius + fMaxDeltaRadius, aParam.mfLogicZ );
- sal_Int32 nOffsetPercent( static_cast<sal_Int32>(fExplodePercentage * 100.0) );
+ sal_Int32 nOffsetPercent( static_cast<sal_Int32>(aParam.mfExplodePercentage * 100.0) );
awt::Point aMinimumPosition( PlottingPositionHelper::transformSceneToScreenPosition(
aOrigin, m_xLogicTarget, m_pShapeFactory, m_nDimension ) );
diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx
index a9c723d..2b88b1a 100644
--- a/chart2/source/view/charttypes/PieChart.hxx
+++ b/chart2/source/view/charttypes/PieChart.hxx
@@ -30,7 +30,8 @@ class PiePositionHelper;
class PieChart : public VSeriesPlotter
{
- // public methods
+ struct ShapeParam;
+
public:
PieChart( const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartType >& xChartTypeModel
@@ -63,22 +64,16 @@ private: //methods
//no default constructor
PieChart();
- ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
- createDataPoint( const ::com::sun::star::uno::Reference<
- ::com::sun::star::drawing::XShapes >& xTarget
- , const ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertySet >& xObjectProperties
- , double fUnitCircleStartAngleDegree, double fWidthAngleDegree
- , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius
- , double fLogicZ, double fDepth, double fExplodePercentage
- , tPropertyNameValueMap* pOverWritePropertiesMap );
+ css::uno::Reference<css::drawing::XShape>
+ createDataPoint(
+ const css::uno::Reference<css::drawing::XShapes>& xTarget,
+ const css::uno::Reference<css::beans::XPropertySet>& xObjectProperties,
+ tPropertyNameValueMap* pOverWritePropertiesMap,
+ const ShapeParam& rParam );
void createTextLabelShape(
const css::uno::Reference<css::drawing::XShapes>& xTextTarget,
- VDataSeries& rSeries, sal_Int32 nPointIndex,
- double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree,
- double fUnitCircleOuterRadius, double fUnitCircleInnerRadius, double fExplodePercentage,
- double fLogicYSum, double fLogicZ );
+ VDataSeries& rSeries, sal_Int32 nPointIndex, ShapeParam& rParam );
double getMaxOffset();
bool detectLabelOverlapsAndMove(const ::com::sun::star::awt::Size& rPageSize);//returns true when there might be more to do
commit 8bd81a6520174d8f2086d9a220973f86453d022e
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Aug 13 13:56:02 2014 -0400
Extract code block into its own method.
Change-Id: I4cb450afee9200ce749356b6a4bda8f046da305f
diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx
index eedc03ed..51142bd 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -202,6 +202,75 @@ uno::Reference< drawing::XShape > PieChart::createDataPoint(
return xShape;
}
+void PieChart::createTextLabelShape(
+ const uno::Reference<drawing::XShapes>& xTextTarget,
+ VDataSeries& rSeries, sal_Int32 nPointIndex,
+ double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree,
+ double fUnitCircleOuterRadius, double fUnitCircleInnerRadius, double fExplodePercentage,
+ double fLogicYSum, double fLogicZ )
+{
+ if (!rSeries.getDataPointLabelIfLabel(nPointIndex))
+ return;
+
+ if( !::rtl::math::approxEqual( fExplodePercentage, 0.0 ) )
+ {
+ double fExplodeOffset = (fUnitCircleOuterRadius-fUnitCircleInnerRadius)*fExplodePercentage;
+ fUnitCircleInnerRadius += fExplodeOffset;
+ fUnitCircleOuterRadius += fExplodeOffset;
+ }
+
+ sal_Int32 nLabelPlacement = rSeries.getLabelPlacement(
+ nPointIndex, m_xChartTypeModel, m_nDimension, m_pPosHelper->isSwapXAndY());
+
+ // AVOID_OVERLAP is in fact "Best fit" in the UI.
+ bool bMovementAllowed = ( nLabelPlacement == ::com::sun::star::chart::DataLabelPlacement::AVOID_OVERLAP );
+ if( bMovementAllowed )
+ // Use center for "Best fit" for now. In the future we
+ // may want to implement a real best fit algorithm.
+ // But center is good enough, and close to what Excel
+ // does.
+ nLabelPlacement = ::com::sun::star::chart::DataLabelPlacement::CENTER;
+
+ LabelAlignment eAlignment(LABEL_ALIGN_CENTER);
+ sal_Int32 nScreenValueOffsetInRadiusDirection = 0 ;
+ if( nLabelPlacement == ::com::sun::star::chart::DataLabelPlacement::OUTSIDE )
+ nScreenValueOffsetInRadiusDirection = (3!=m_nDimension) ? 150 : 0;//todo maybe calculate this font height dependent
+ else if( nLabelPlacement == ::com::sun::star::chart::DataLabelPlacement::INSIDE )
+ nScreenValueOffsetInRadiusDirection = (3!=m_nDimension) ? -150 : 0;//todo maybe calculate this font height dependent
+ PolarLabelPositionHelper aPolarPosHelper(m_pPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory);
+ awt::Point aScreenPosition2D(
+ aPolarPosHelper.getLabelScreenPositionAndAlignmentForUnitCircleValues(eAlignment, nLabelPlacement
+ , fUnitCircleStartAngleDegree, fUnitCircleWidthAngleDegree
+ , fUnitCircleInnerRadius, fUnitCircleOuterRadius, fLogicZ+0.5, 0 ));
+
+ PieLabelInfo aPieLabelInfo;
+ aPieLabelInfo.aFirstPosition = basegfx::B2IVector( aScreenPosition2D.X, aScreenPosition2D.Y );
+ awt::Point aOrigin( aPolarPosHelper.transformSceneToScreenPosition( m_pPosHelper->transformUnitCircleToScene( 0.0, 0.0, fLogicZ+1.0 ) ) );
+ aPieLabelInfo.aOrigin = basegfx::B2IVector( aOrigin.X, aOrigin.Y );
+
+ //add a scaling independent Offset if requested
+ if( nScreenValueOffsetInRadiusDirection != 0)
+ {
+ basegfx::B2IVector aDirection( aScreenPosition2D.X- aOrigin.X, aScreenPosition2D.Y- aOrigin.Y );
+ aDirection.setLength(nScreenValueOffsetInRadiusDirection);
+ aScreenPosition2D.X += aDirection.getX();
+ aScreenPosition2D.Y += aDirection.getY();
+ }
+
+ double nVal = rSeries.getYValue(nPointIndex);
+ aPieLabelInfo.xTextShape = createDataLabel(
+ xTextTarget, rSeries, nPointIndex, nVal, fLogicYSum, aScreenPosition2D, eAlignment);
+
+ uno::Reference< container::XChild > xChild( aPieLabelInfo.xTextShape, uno::UNO_QUERY );
+ if( xChild.is() )
+ aPieLabelInfo.xLabelGroupShape = uno::Reference<drawing::XShape>( xChild->getParent(), uno::UNO_QUERY );
+ aPieLabelInfo.fValue = nVal;
+ aPieLabelInfo.bMovementAllowed = bMovementAllowed;
+ aPieLabelInfo.bMoved= false;
+ aPieLabelInfo.xTextTarget = xTextTarget;
+ m_aLabelInfoList.push_back(aPieLabelInfo);
+}
+
void PieChart::addSeries( VDataSeries* pSeries, sal_Int32 /* zSlot */, sal_Int32 /* xSlot */, sal_Int32 /* ySlot */ )
{
VSeriesPlotter::addSeries( pSeries, 0, -1, 0 );
@@ -445,65 +514,11 @@ void PieChart::createShapes()
}
//create label
- if( pSeries->getDataPointLabelIfLabel(nPointIndex) )
- {
- if( !::rtl::math::approxEqual( fExplodePercentage, 0.0 ) )
- {
- double fExplodeOffset = (fUnitCircleOuterRadius-fUnitCircleInnerRadius)*fExplodePercentage;
- fUnitCircleInnerRadius += fExplodeOffset;
- fUnitCircleOuterRadius += fExplodeOffset;
- }
-
- sal_Int32 nLabelPlacement = pSeries->getLabelPlacement( nPointIndex, m_xChartTypeModel, m_nDimension, m_pPosHelper->isSwapXAndY() );
-
- // AVOID_OVERLAP is in fact "Best fit" in the UI.
- bool bMovementAllowed = ( nLabelPlacement == ::com::sun::star::chart::DataLabelPlacement::AVOID_OVERLAP );
- if( bMovementAllowed )
- // Use center for "Best fit" for now. In the future we
- // may want to implement a real best fit algorithm.
- // But center is good enough, and close to what Excel
- // does.
- nLabelPlacement = ::com::sun::star::chart::DataLabelPlacement::CENTER;
-
- LabelAlignment eAlignment(LABEL_ALIGN_CENTER);
- sal_Int32 nScreenValueOffsetInRadiusDirection = 0 ;
- if( nLabelPlacement == ::com::sun::star::chart::DataLabelPlacement::OUTSIDE )
- nScreenValueOffsetInRadiusDirection = (3!=m_nDimension) ? 150 : 0;//todo maybe calculate this font height dependent
- else if( nLabelPlacement == ::com::sun::star::chart::DataLabelPlacement::INSIDE )
- nScreenValueOffsetInRadiusDirection = (3!=m_nDimension) ? -150 : 0;//todo maybe calculate this font height dependent
- PolarLabelPositionHelper aPolarPosHelper(m_pPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory);
- awt::Point aScreenPosition2D(
- aPolarPosHelper.getLabelScreenPositionAndAlignmentForUnitCircleValues(eAlignment, nLabelPlacement
- , fUnitCircleStartAngleDegree, fUnitCircleWidthAngleDegree
- , fUnitCircleInnerRadius, fUnitCircleOuterRadius, fLogicZ+0.5, 0 ));
-
- PieLabelInfo aPieLabelInfo;
- aPieLabelInfo.aFirstPosition = basegfx::B2IVector( aScreenPosition2D.X, aScreenPosition2D.Y );
- awt::Point aOrigin( aPolarPosHelper.transformSceneToScreenPosition( m_pPosHelper->transformUnitCircleToScene( 0.0, 0.0, fLogicZ+1.0 ) ) );
- aPieLabelInfo.aOrigin = basegfx::B2IVector( aOrigin.X, aOrigin.Y );
-
- //add a scaling independent Offset if requested
- if( nScreenValueOffsetInRadiusDirection != 0)
- {
- basegfx::B2IVector aDirection( aScreenPosition2D.X- aOrigin.X, aScreenPosition2D.Y- aOrigin.Y );
- aDirection.setLength(nScreenValueOffsetInRadiusDirection);
- aScreenPosition2D.X += aDirection.getX();
- aScreenPosition2D.Y += aDirection.getY();
- }
-
- double nVal = pSeries->getYValue( nPointIndex );
- aPieLabelInfo.xTextShape = createDataLabel( xTextTarget, *pSeries, nPointIndex
- , nVal, fLogicYSum, aScreenPosition2D, eAlignment );
-
- uno::Reference< container::XChild > xChild( aPieLabelInfo.xTextShape, uno::UNO_QUERY );
- if( xChild.is() )
- aPieLabelInfo.xLabelGroupShape = uno::Reference<drawing::XShape>( xChild->getParent(), uno::UNO_QUERY );
- aPieLabelInfo.fValue = nVal;
- aPieLabelInfo.bMovementAllowed = bMovementAllowed;
- aPieLabelInfo.bMoved= false;
- aPieLabelInfo.xTextTarget = xTextTarget;
- m_aLabelInfoList.push_back(aPieLabelInfo);
- }
+ createTextLabelShape(
+ xTextTarget, *pSeries, nPointIndex,
+ fUnitCircleStartAngleDegree, fUnitCircleWidthAngleDegree,
+ fUnitCircleOuterRadius, fUnitCircleInnerRadius,
+ fExplodePercentage, fLogicYSum, fLogicZ);
if(!bDoExplode)
{
diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx
index 6814b86..a9c723d 100644
--- a/chart2/source/view/charttypes/PieChart.hxx
+++ b/chart2/source/view/charttypes/PieChart.hxx
@@ -73,6 +73,13 @@ private: //methods
, double fLogicZ, double fDepth, double fExplodePercentage
, tPropertyNameValueMap* pOverWritePropertiesMap );
+ void createTextLabelShape(
+ const css::uno::Reference<css::drawing::XShapes>& xTextTarget,
+ VDataSeries& rSeries, sal_Int32 nPointIndex,
+ double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree,
+ double fUnitCircleOuterRadius, double fUnitCircleInnerRadius, double fExplodePercentage,
+ double fLogicYSum, double fLogicZ );
+
double getMaxOffset();
bool detectLabelOverlapsAndMove(const ::com::sun::star::awt::Size& rPageSize);//returns true when there might be more to do
void resetLabelPositionsToPreviousState();
More information about the Libreoffice-commits
mailing list