[Libreoffice-commits] core.git: 2 commits - include/svx svx/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Thu Oct 10 06:14:40 UTC 2019
include/svx/svdtrans.hxx | 7 -
svx/source/svdraw/svdattr.cxx | 21 +----
svx/source/svdraw/svdtrans.cxx | 151 +++++++++--------------------------------
3 files changed, 44 insertions(+), 135 deletions(-)
New commits:
commit f26a5f32dc11cd8b4a72ef1519b8f38ec80e126c
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Oct 9 17:09:39 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Oct 10 08:14:05 2019 +0200
rename TakeUnitStr to GetUnitStr
and return a value instead of an awkward out-parameter
Change-Id: Ia78bf0188dd9ca1078230ed7cd020ab77d05757e
Reviewed-on: https://gerrit.libreoffice.org/80555
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/svx/svdtrans.hxx b/include/svx/svdtrans.hxx
index 804c57a7a7de..a85edab7ef4a 100644
--- a/include/svx/svdtrans.hxx
+++ b/include/svx/svdtrans.hxx
@@ -292,9 +292,8 @@ public:
{
}
OUString GetStr(long nVal) const;
- static void TakeUnitStr(MapUnit eUnit, OUString& rStr);
- static void TakeUnitStr(FieldUnit eUnit, OUString& rStr);
- static OUString GetUnitStr(FieldUnit eUnit) { OUString aStr; TakeUnitStr(eUnit,aStr); return aStr; }
+ static OUString GetUnitStr(MapUnit eUnit);
+ static OUString GetUnitStr(FieldUnit eUnit);
};
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
index 5ea950355a04..528af23ac7e1 100644
--- a/svx/source/svdraw/svdattr.cxx
+++ b/svx/source/svdraw/svdattr.cxx
@@ -862,9 +862,7 @@ bool SdrMetricItem::GetPresentation(SfxItemPresentation ePres,
long nValue=GetValue();
SdrFormatter aFmt(eCoreMetric,ePresMetric);
rText = aFmt.GetStr(nValue);
- OUString aStr;
- SdrFormatter::TakeUnitStr(ePresMetric,aStr);
- rText += " " + aStr;
+ rText += " " + SdrFormatter::GetUnitStr(ePresMetric);
if (ePres==SfxItemPresentation::Complete) {
rText = SdrItemPool::GetItemName(Which()) + " " + rText;
}
@@ -1263,11 +1261,8 @@ bool SdrTextAniAmountItem::GetPresentation(
else
{
SdrFormatter aFmt(eCoreMetric, ePresMetric);
- OUString aStr;
-
- rText = aFmt.GetStr(nValue);
- SdrFormatter::TakeUnitStr(ePresMetric, aStr);
- rText += aStr;
+ rText = aFmt.GetStr(nValue) +
+ SdrFormatter::GetUnitStr(ePresMetric);
}
if(ePres == SfxItemPresentation::Complete)
@@ -1638,14 +1633,10 @@ sal_uInt16 SdrMeasureUnitItem::GetValueCount() const { return 14; }
OUString SdrMeasureUnitItem::GetValueTextByPos(sal_uInt16 nPos)
{
- OUString aRetval;
-
if(static_cast<FieldUnit>(nPos) == FieldUnit::NONE)
- aRetval = "default";
+ return "default";
else
- SdrFormatter::TakeUnitStr(static_cast<FieldUnit>(nPos), aRetval);
-
- return aRetval;
+ return SdrFormatter::GetUnitStr(static_cast<FieldUnit>(nPos));
}
bool SdrMeasureUnitItem::GetPresentation(SfxItemPresentation ePres,
diff --git a/svx/source/svdraw/svdtrans.cxx b/svx/source/svdraw/svdtrans.cxx
index 1605e592da5f..49e6f0cf2929 100644
--- a/svx/source/svdraw/svdtrans.cxx
+++ b/svx/source/svdraw/svdtrans.cxx
@@ -838,166 +838,86 @@ OUString SdrFormatter::GetStr(long nVal) const
return aStr.makeStringAndClear();
}
-void SdrFormatter::TakeUnitStr(MapUnit eUnit, OUString& rStr)
+OUString SdrFormatter::GetUnitStr(MapUnit eUnit)
{
switch(eUnit)
{
// metrically
case MapUnit::Map100thMM :
- {
- rStr = "/100mm";
- break;
- }
+ return "/100mm";
case MapUnit::Map10thMM :
- {
- rStr = "/10mm";
- break;
- }
+ return "/10mm";
case MapUnit::MapMM :
- {
- rStr = "mm";
- break;
- }
+ return "mm";
case MapUnit::MapCM :
- {
- rStr = "cm";
- break;
- }
+ return "cm";
// Inch
case MapUnit::Map1000thInch:
- {
- rStr = "/1000\"";
- break;
- }
+ return "/1000\"";
case MapUnit::Map100thInch :
- {
- rStr = "/100\"";
- break;
- }
+ return "/100\"";
case MapUnit::Map10thInch :
- {
- rStr = "/10\"";
- break;
- }
+ return "/10\"";
case MapUnit::MapInch :
- {
- rStr = "\"";
- break;
- }
+ return "\"";
case MapUnit::MapPoint :
- {
- rStr = "pt";
- break;
- }
+ return "pt";
case MapUnit::MapTwip :
- {
- rStr = "twip";
- break;
- }
+ return "twip";
// others
case MapUnit::MapPixel :
- {
- rStr = "pixel";
- break;
- }
+ return "pixel";
case MapUnit::MapSysFont :
- {
- rStr = "sysfont";
- break;
- }
+ return "sysfont";
case MapUnit::MapAppFont :
- {
- rStr = "appfont";
- break;
- }
+ return "appfont";
case MapUnit::MapRelative :
- {
- rStr = "%";
- break;
- }
- default: break;
+ return "%";
+ default:
+ return OUString();
}
}
-void SdrFormatter::TakeUnitStr(FieldUnit eUnit, OUString& rStr)
+OUString SdrFormatter::GetUnitStr(FieldUnit eUnit)
{
switch(eUnit)
{
default :
case FieldUnit::NONE :
case FieldUnit::CUSTOM :
- {
- rStr.clear();
- break;
- }
+ return OUString();
// metrically
case FieldUnit::MM_100TH:
- {
- rStr = "/100mm";
- break;
- }
+ return "/100mm";
case FieldUnit::MM :
- {
- rStr = "mm";
- break;
- }
+ return "mm";
case FieldUnit::CM :
- {
- rStr = "cm";
- break;
- }
+ return "cm";
case FieldUnit::M :
- {
- rStr = "m";
- break;
- }
+ return "m";
case FieldUnit::KM :
- {
- rStr = "km";
- break;
- }
+ return "km";
// Inch
case FieldUnit::TWIP :
- {
- rStr = "twip";
- break;
- }
+ return "twip";
case FieldUnit::POINT :
- {
- rStr = "pt";
- break;
- }
+ return "pt";
case FieldUnit::PICA :
- {
- rStr = "pica";
- break;
- }
+ return "pica";
case FieldUnit::INCH :
- {
- rStr = "\"";
- break;
- }
+ return "\"";
case FieldUnit::FOOT :
- {
- rStr = "ft";
- break;
- }
+ return "ft";
case FieldUnit::MILE :
- {
- rStr = "mile(s)";
- break;
- }
+ return "mile(s)";
// others
case FieldUnit::PERCENT:
- {
- rStr = "%";
- break;
- }
+ return "%";
}
}
commit 1ce0a72094fd09b4506a2380ff7787ac03c6e534
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Oct 9 17:01:37 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Oct 10 08:13:52 2019 +0200
rename TakeStr to GetStr
and return a value instead of the awkward out-parameter
Change-Id: I4c2c430329bab45787b3cd67339edce4c1c7a326
Reviewed-on: https://gerrit.libreoffice.org/80551
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/svx/svdtrans.hxx b/include/svx/svdtrans.hxx
index 51f43fcea15d..804c57a7a7de 100644
--- a/include/svx/svdtrans.hxx
+++ b/include/svx/svdtrans.hxx
@@ -291,7 +291,7 @@ public:
, eDstMU(eDst)
{
}
- void TakeStr(long nVal, OUString& rStr) const;
+ OUString GetStr(long nVal) const;
static void TakeUnitStr(MapUnit eUnit, OUString& rStr);
static void TakeUnitStr(FieldUnit eUnit, OUString& rStr);
static OUString GetUnitStr(FieldUnit eUnit) { OUString aStr; TakeUnitStr(eUnit,aStr); return aStr; }
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
index 80ee71ba8da7..5ea950355a04 100644
--- a/svx/source/svdraw/svdattr.cxx
+++ b/svx/source/svdraw/svdattr.cxx
@@ -861,7 +861,7 @@ bool SdrMetricItem::GetPresentation(SfxItemPresentation ePres,
{
long nValue=GetValue();
SdrFormatter aFmt(eCoreMetric,ePresMetric);
- aFmt.TakeStr(nValue,rText);
+ rText = aFmt.GetStr(nValue);
OUString aStr;
SdrFormatter::TakeUnitStr(ePresMetric,aStr);
rText += " " + aStr;
@@ -1265,7 +1265,7 @@ bool SdrTextAniAmountItem::GetPresentation(
SdrFormatter aFmt(eCoreMetric, ePresMetric);
OUString aStr;
- aFmt.TakeStr(nValue, rText);
+ rText = aFmt.GetStr(nValue);
SdrFormatter::TakeUnitStr(ePresMetric, aStr);
rText += aStr;
}
diff --git a/svx/source/svdraw/svdtrans.cxx b/svx/source/svdraw/svdtrans.cxx
index 14ec58c04cd3..1605e592da5f 100644
--- a/svx/source/svdraw/svdtrans.cxx
+++ b/svx/source/svdraw/svdtrans.cxx
@@ -727,14 +727,13 @@ void SdrFormatter::Undirty()
}
-void SdrFormatter::TakeStr(long nVal, OUString& rStr) const
+OUString SdrFormatter::GetStr(long nVal) const
{
- OUString aNullCode("0");
+ const OUString aNullCode("0");
if(!nVal)
{
- rStr = aNullCode;
- return;
+ return aNullCode;
}
// we may lose some decimal places here, because of MulDiv instead of Real
@@ -836,7 +835,7 @@ void SdrFormatter::TakeStr(long nVal, OUString& rStr) const
aStr.insert(0, "-");
}
- rStr = aStr.makeStringAndClear();
+ return aStr.makeStringAndClear();
}
void SdrFormatter::TakeUnitStr(MapUnit eUnit, OUString& rStr)
More information about the Libreoffice-commits
mailing list