Kaydet (Commit) d0216f56 authored tarafından Matteo Casalin's avatar Matteo Casalin

SdrMarkView: provide OUString as return value

Change-Id: I2d45f4ada683da4f69df6d81a072d2f3ba813dae
üst dbc3c4ed
......@@ -79,8 +79,8 @@ enum class SdrViewEditMode {
GluePointEdit // Glue point editing mode
};
/** options for ImpTakeDescriptionStr() */
enum class ImpTakeDescriptionOptions
/** options for ImpGetDescriptionString() */
enum class ImpGetDescriptionOptions
{
NONE = 0,
POINTS = 1,
......@@ -154,7 +154,7 @@ protected:
SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObjList const * pOL, SdrPageView* pPV, SdrSearchOptions nOptions, const SdrLayerIDSet* pMVisLay, SdrObject*& rpRootObj) const;
SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObjList const * pOL, SdrPageView* pPV, SdrSearchOptions nOptions, const SdrLayerIDSet* pMVisLay, SdrObject*& rpRootObj,const SdrMarkList * pMarkList) const;
bool ImpIsFrameHandles() const;
void ImpTakeDescriptionStr(const char* pStrCacheID, OUString& rStr, ImpTakeDescriptionOptions nOpt=ImpTakeDescriptionOptions::NONE) const;
OUString ImpGetDescriptionString(const char* pStrCacheID, ImpGetDescriptionOptions nOpt=ImpGetDescriptionOptions::NONE) const;
// Generates a string including degrees symbol, from an angel specification in 1/100deg
bool ImpMarkPoint(SdrHdl* pHdl, SdrMark* pMark, bool bUnmark);
......
......@@ -552,13 +552,13 @@ void SdrDragMethod::createSdrDragEntries_GlueDrag()
void SdrDragMethod::ImpTakeDescriptionStr(const char* pStrCacheID, OUString& rStr) const
{
ImpTakeDescriptionOptions nOpt=ImpTakeDescriptionOptions::NONE;
ImpGetDescriptionOptions nOpt=ImpGetDescriptionOptions::NONE;
if (IsDraggingPoints()) {
nOpt=ImpTakeDescriptionOptions::POINTS;
nOpt=ImpGetDescriptionOptions::POINTS;
} else if (IsDraggingGluePoints()) {
nOpt=ImpTakeDescriptionOptions::GLUEPOINTS;
nOpt=ImpGetDescriptionOptions::GLUEPOINTS;
}
getSdrDragView().ImpTakeDescriptionStr(pStrCacheID,rStr,nOpt);
rStr = getSdrDragView().ImpGetDescriptionString(pStrCacheID, nOpt);
}
SdrObject* SdrDragMethod::GetDragObj() const
......
......@@ -83,12 +83,10 @@ void SdrEditView::SetMarkedObjRect(const tools::Rectangle& rRect)
long y1=rRect.Top();
long w1=rRect.Right()-x1;
long h1=rRect.Bottom()-y1;
OUString aStr;
ImpTakeDescriptionStr(STR_EditPosSize,aStr);
const bool bUndo = IsUndoEnabled();
if( bUndo )
BegUndo(aStr);
BegUndo(ImpGetDescriptionString(STR_EditPosSize));
for (size_t nm=0; nm<nCount; ++nm)
{
......@@ -211,8 +209,7 @@ void SdrEditView::ResizeMarkedObj(const Point& rRef, const Fraction& xFact, cons
const bool bUndo = IsUndoEnabled();
if( bUndo )
{
OUString aStr;
ImpTakeDescriptionStr(STR_EditResize,aStr);
OUString aStr {ImpGetDescriptionString(STR_EditResize)};
if (bCopy)
aStr+=ImpGetResStr(STR_EditWithCopy);
BegUndo(aStr);
......@@ -247,9 +244,7 @@ void SdrEditView::ResizeMultMarkedObj(const Point& rRef,
const bool bUndo = IsUndoEnabled();
if( bUndo )
{
OUString aStr;
ImpTakeDescriptionStr(STR_EditResize,aStr);
BegUndo(aStr);
BegUndo(ImpGetDescriptionString(STR_EditResize));
}
const size_t nMarkCount=GetMarkedObjectCount();
......@@ -310,8 +305,7 @@ void SdrEditView::RotateMarkedObj(const Point& rRef, long nAngle, bool bCopy)
const bool bUndo = IsUndoEnabled();
if( bUndo )
{
OUString aStr;
ImpTakeDescriptionStr(STR_EditRotate,aStr);
OUString aStr {ImpGetDescriptionString(STR_EditRotate)};
if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
BegUndo(aStr);
}
......@@ -370,10 +364,14 @@ void SdrEditView::MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool b
{
OUString aStr;
Point aDif(rRef2-rRef1);
if (aDif.X()==0) ImpTakeDescriptionStr(STR_EditMirrorHori,aStr);
else if (aDif.Y()==0) ImpTakeDescriptionStr(STR_EditMirrorVert,aStr);
else if (std::abs(aDif.X()) == std::abs(aDif.Y())) ImpTakeDescriptionStr(STR_EditMirrorDiag,aStr);
else ImpTakeDescriptionStr(STR_EditMirrorFree,aStr);
if (aDif.X()==0)
aStr = ImpGetDescriptionString(STR_EditMirrorHori);
else if (aDif.Y()==0)
aStr = ImpGetDescriptionString(STR_EditMirrorVert);
else if (std::abs(aDif.X()) == std::abs(aDif.Y()))
aStr = ImpGetDescriptionString(STR_EditMirrorDiag);
else
aStr = ImpGetDescriptionString(STR_EditMirrorFree);
if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
BegUndo(aStr);
}
......@@ -464,8 +462,7 @@ void SdrEditView::ShearMarkedObj(const Point& rRef, long nAngle, bool bVShear, b
if( bUndo )
{
OUString aStr;
ImpTakeDescriptionStr(STR_EditShear,aStr);
OUString aStr {ImpGetDescriptionString(STR_EditShear)};
if (bCopy)
aStr+=ImpGetResStr(STR_EditWithCopy);
BegUndo(aStr);
......@@ -581,8 +578,7 @@ void SdrEditView::CrookMarkedObj(const Point& rRef, const Point& rRad, SdrCrookM
if( bUndo )
{
OUString aStr;
ImpTakeDescriptionStr(bNoContortion?STR_EditCrook:STR_EditCrookContortion,aStr);
OUString aStr {ImpGetDescriptionString(bNoContortion ? STR_EditCrook : STR_EditCrookContortion)};
if (bCopy)
aStr+=ImpGetResStr(STR_EditWithCopy);
BegUndo(aStr);
......@@ -655,8 +651,7 @@ void SdrEditView::DistortMarkedObj(const tools::Rectangle& rRef, const XPolygon&
if( bUndo )
{
OUString aStr;
ImpTakeDescriptionStr(STR_EditDistort,aStr);
OUString aStr {ImpGetDescriptionString(STR_EditDistort)};
if (bCopy)
aStr+=ImpGetResStr(STR_EditWithCopy);
BegUndo(aStr);
......@@ -1009,9 +1004,7 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll)
const bool bUndo = IsUndoEnabled();
if( bUndo )
{
OUString aStr;
ImpTakeDescriptionStr(STR_EditSetAttributes,aStr);
BegUndo(aStr);
BegUndo(ImpGetDescriptionString(STR_EditSetAttributes));
}
const size_t nMarkCount(GetMarkedObjectCount());
......@@ -1190,9 +1183,9 @@ void SdrEditView::SetStyleSheetToMarked(SfxStyleSheet* pStyleSheet, bool bDontRe
{
OUString aStr;
if (pStyleSheet!=nullptr)
ImpTakeDescriptionStr(STR_EditSetStylesheet,aStr);
aStr = ImpGetDescriptionString(STR_EditSetStylesheet);
else
ImpTakeDescriptionStr(STR_EditDelStylesheet,aStr);
aStr = ImpGetDescriptionString(STR_EditDelStylesheet);
BegUndo(aStr);
}
......@@ -1748,9 +1741,15 @@ void SdrEditView::AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert)
{
switch (eVert)
{
case SdrVertAlign::Top : ImpTakeDescriptionStr(STR_EditAlignVTop ,aStr); break;
case SdrVertAlign::Bottom: ImpTakeDescriptionStr(STR_EditAlignVBottom,aStr); break;
case SdrVertAlign::Center: ImpTakeDescriptionStr(STR_EditAlignVCenter,aStr); break;
case SdrVertAlign::Top:
aStr = ImpGetDescriptionString(STR_EditAlignVTop);
break;
case SdrVertAlign::Bottom:
aStr = ImpGetDescriptionString(STR_EditAlignVBottom);
break;
case SdrVertAlign::Center:
aStr = ImpGetDescriptionString(STR_EditAlignVCenter);
break;
default: break;
}
}
......@@ -1758,19 +1757,25 @@ void SdrEditView::AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert)
{
switch (eHor)
{
case SdrHorAlign::Left : ImpTakeDescriptionStr(STR_EditAlignHLeft ,aStr); break;
case SdrHorAlign::Right : ImpTakeDescriptionStr(STR_EditAlignHRight ,aStr); break;
case SdrHorAlign::Center: ImpTakeDescriptionStr(STR_EditAlignHCenter,aStr); break;
case SdrHorAlign::Left:
aStr = ImpGetDescriptionString(STR_EditAlignHLeft);
break;
case SdrHorAlign::Right:
aStr = ImpGetDescriptionString(STR_EditAlignHRight);
break;
case SdrHorAlign::Center:
aStr = ImpGetDescriptionString(STR_EditAlignHCenter);
break;
default: break;
}
}
else if (eHor==SdrHorAlign::Center && eVert==SdrVertAlign::Center)
{
ImpTakeDescriptionStr(STR_EditAlignCenter,aStr);
aStr = ImpGetDescriptionString(STR_EditAlignCenter);
}
else
{
ImpTakeDescriptionStr(STR_EditAlign,aStr);
aStr = ImpGetDescriptionString(STR_EditAlign);
}
BegUndo(aStr);
}
......
......@@ -2096,9 +2096,7 @@ bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
if( bUndo )
{
OUString aStr;
ImpTakeDescriptionStr(STR_EditSetAttributes,aStr);
BegUndo(aStr);
BegUndo(ImpGetDescriptionString(STR_EditSetAttributes));
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get()));
// If this is a text object also rescue the OutlinerParaObject since
......@@ -2143,9 +2141,7 @@ bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
{
if( IsUndoEnabled() )
{
OUString aStr;
ImpTakeDescriptionStr(STR_EditSetAttributes,aStr);
BegUndo(aStr);
BegUndo(ImpGetDescriptionString(STR_EditSetAttributes));
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get()));
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*mxTextEditObj.get()));
EndUndo();
......
......@@ -2075,28 +2075,28 @@ const tools::Rectangle& SdrMarkView::GetMarkedObjRect() const
}
void SdrMarkView::ImpTakeDescriptionStr(const char* pStrCacheID, OUString& rStr, ImpTakeDescriptionOptions nOpt) const
OUString SdrMarkView::ImpGetDescriptionString(const char* pStrCacheID, ImpGetDescriptionOptions nOpt) const
{
rStr = ImpGetResStr(pStrCacheID);
sal_Int32 nPos = rStr.indexOf("%1");
OUString sStr = ImpGetResStr(pStrCacheID);
const sal_Int32 nPos = sStr.indexOf("%1");
if(nPos != -1)
{
if(nOpt == ImpTakeDescriptionOptions::POINTS)
if(nOpt == ImpGetDescriptionOptions::POINTS)
{
rStr = rStr.replaceAt(nPos, 2, GetDescriptionOfMarkedPoints());
sStr = sStr.replaceAt(nPos, 2, GetDescriptionOfMarkedPoints());
}
else if(nOpt == ImpTakeDescriptionOptions::GLUEPOINTS)
else if(nOpt == ImpGetDescriptionOptions::GLUEPOINTS)
{
rStr = rStr.replaceAt(nPos, 2, GetDescriptionOfMarkedGluePoints());
sStr = sStr.replaceAt(nPos, 2, GetDescriptionOfMarkedGluePoints());
}
else
{
rStr = rStr.replaceAt(nPos, 2, GetDescriptionOfMarkedObjects());
sStr = sStr.replaceAt(nPos, 2, GetDescriptionOfMarkedObjects());
}
}
rStr = rStr.replaceFirst("%2", "0");
return sStr.replaceFirst("%2", "0");
}
......
......@@ -1269,14 +1269,14 @@ OUString SdrView::GetStatusText()
if(aStr == STR_NOTHING)
{
if (AreObjectsMarked()) {
ImpTakeDescriptionStr(STR_ViewMarked,aStr);
aStr = ImpGetDescriptionString(STR_ViewMarked);
if (IsGluePointEditMode()) {
if (HasMarkedGluePoints()) {
ImpTakeDescriptionStr(STR_ViewMarked,aStr,ImpTakeDescriptionOptions::GLUEPOINTS);
aStr = ImpGetDescriptionString(STR_ViewMarked, ImpGetDescriptionOptions::GLUEPOINTS);
}
} else {
if (HasMarkedPoints()) {
ImpTakeDescriptionStr(STR_ViewMarked,aStr,ImpTakeDescriptionOptions::POINTS);
aStr = ImpGetDescriptionString(STR_ViewMarked, ImpGetDescriptionOptions::POINTS);
}
}
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment