summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editeng/source/items/svxitems.src8
-rw-r--r--editeng/source/items/textitem.cxx119
-rw-r--r--include/editeng/charrotateitem.hxx56
-rw-r--r--include/editeng/editrids.hrc2
4 files changed, 166 insertions, 19 deletions
diff --git a/editeng/source/items/svxitems.src b/editeng/source/items/svxitems.src
index 087ee07bb6cd..47da1c953d5c 100644
--- a/editeng/source/items/svxitems.src
+++ b/editeng/source/items/svxitems.src
@@ -889,6 +889,14 @@ String RID_SVXITEMS_CHARROTATE_FITLINE
{
Text [ en-US ] = "Fit to line";
};
+String RID_SVXITEMS_TEXTROTATE_OFF
+{
+ Text [ en-US ] = "Text is not rotated";
+};
+String RID_SVXITEMS_TEXTROTATE
+{
+ Text [ en-US ] = "Text is rotated by $(ARG1)°";
+};
String RID_SVXITEMS_CHARSCALE
{
Text [ en-US ] = "Characters scaled $(ARG1)%";
diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx
index 72fc2c210f66..e1d24094c8a7 100644
--- a/editeng/source/items/textitem.cxx
+++ b/editeng/source/items/textitem.cxx
@@ -2833,13 +2833,114 @@ sal_uInt16 SvxTwoLinesItem::GetVersion( sal_uInt16 nFFVer ) const
/*************************************************************************
+|* class SvxTextRotateItem
+*************************************************************************/
+
+SvxTextRotateItem::SvxTextRotateItem(sal_uInt16 nValue, const sal_uInt16 nW)
+ : SfxUInt16Item(nW, nValue)
+{
+}
+
+SfxPoolItem* SvxTextRotateItem::Clone(SfxItemPool*) const
+{
+ return new SvxTextRotateItem(GetValue(), Which());
+}
+
+SfxPoolItem* SvxTextRotateItem::Create(SvStream& rStrm, sal_uInt16) const
+{
+ sal_uInt16 nVal;
+ rStrm.ReadUInt16(nVal);
+ return new SvxTextRotateItem(nVal, Which());
+}
+
+SvStream& SvxTextRotateItem::Store(SvStream & rStrm, sal_uInt16) const
+{
+ rStrm.WriteUInt16(GetValue());
+ return rStrm;
+}
+
+sal_uInt16 SvxTextRotateItem::GetVersion(sal_uInt16 nFFVer) const
+{
+ return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
+}
+
+bool SvxTextRotateItem::GetPresentation(
+ SfxItemPresentation /*ePres*/,
+ MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/,
+ OUString &rText, const IntlWrapper*) const
+{
+ if (!GetValue())
+ rText = EditResId::GetString(RID_SVXITEMS_TEXTROTATE_OFF);
+ else
+ {
+ rText = EditResId::GetString(RID_SVXITEMS_TEXTROTATE);
+ rText = rText.replaceFirst("$(ARG1)",
+ OUString::number(GetValue() / 10));
+ }
+ return true;
+}
+
+bool SvxTextRotateItem::QueryValue(css::uno::Any& rVal,
+ sal_uInt8 nMemberId) const
+{
+ nMemberId &= ~CONVERT_TWIPS;
+ bool bRet = true;
+ switch (nMemberId)
+ {
+ case MID_ROTATE:
+ rVal <<= (sal_Int16)GetValue();
+ break;
+ default:
+ bRet = false;
+ break;
+ }
+ return bRet;
+}
+
+bool SvxTextRotateItem::PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId)
+{
+ nMemberId &= ~CONVERT_TWIPS;
+ bool bRet = true;
+ switch (nMemberId)
+ {
+ case MID_ROTATE:
+ {
+ sal_Int16 nVal = 0;
+ if ((rVal >>= nVal) && (0 == nVal || 900 == nVal || 2700 == nVal))
+ SetValue((sal_uInt16)nVal);
+ else
+ bRet = false;
+ break;
+ }
+ default:
+ bRet = false;
+ }
+ return bRet;
+}
+
+bool SvxTextRotateItem::operator==(const SfxPoolItem& rItem) const
+{
+ assert(SfxPoolItem::operator==(rItem));
+ return SfxUInt16Item::operator==(rItem);
+}
+
+void SvxTextRotateItem::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+ xmlTextWriterStartElement(pWriter, BAD_CAST("SvxTextRotateItem"));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
+ xmlTextWriterEndElement(pWriter);
+}
+
+
+/*************************************************************************
|* class SvxCharRotateItem
*************************************************************************/
SvxCharRotateItem::SvxCharRotateItem( sal_uInt16 nValue,
bool bFitIntoLine,
const sal_uInt16 nW )
- : SfxUInt16Item( nW, nValue ), bFitToLine( bFitIntoLine )
+ : SvxTextRotateItem(nValue, nW), bFitToLine( bFitIntoLine )
{
}
@@ -2889,12 +2990,11 @@ bool SvxCharRotateItem::GetPresentation(
bool SvxCharRotateItem::QueryValue( css::uno::Any& rVal,
sal_uInt8 nMemberId ) const
{
- nMemberId &= ~CONVERT_TWIPS;
bool bRet = true;
- switch( nMemberId )
+ switch(nMemberId & ~CONVERT_TWIPS)
{
case MID_ROTATE:
- rVal <<= (sal_Int16)GetValue();
+ SvxTextRotateItem::QueryValue(rVal, nMemberId);
break;
case MID_FITTOLINE:
rVal <<= (bool) IsFitToLine();
@@ -2909,17 +3009,12 @@ bool SvxCharRotateItem::QueryValue( css::uno::Any& rVal,
bool SvxCharRotateItem::PutValue( const css::uno::Any& rVal,
sal_uInt8 nMemberId )
{
- nMemberId &= ~CONVERT_TWIPS;
bool bRet = true;
- switch( nMemberId )
+ switch(nMemberId & ~CONVERT_TWIPS)
{
case MID_ROTATE:
{
- sal_Int16 nVal = 0;
- if((rVal >>= nVal) && (0 == nVal || 900 == nVal || 2700 == nVal))
- SetValue( (sal_uInt16)nVal );
- else
- bRet = false;
+ bRet = SvxTextRotateItem::PutValue(rVal, nMemberId);
break;
}
@@ -2935,7 +3030,7 @@ bool SvxCharRotateItem::PutValue( const css::uno::Any& rVal,
bool SvxCharRotateItem::operator==( const SfxPoolItem& rItem ) const
{
assert(SfxPoolItem::operator==(rItem));
- return SfxUInt16Item::operator==( rItem ) &&
+ return SvxTextRotateItem::operator==( rItem ) &&
IsFitToLine() == static_cast<const SvxCharRotateItem&>(rItem).IsFitToLine();
}
diff --git a/include/editeng/charrotateitem.hxx b/include/editeng/charrotateitem.hxx
index fd08402b0e41..922cbdff11cb 100644
--- a/include/editeng/charrotateitem.hxx
+++ b/include/editeng/charrotateitem.hxx
@@ -22,6 +22,54 @@
#include <svl/intitem.hxx>
#include <editeng/editengdllapi.h>
+ // class SvxTextRotateItem ----------------------------------------------
+
+ /* [Description]
+
+ This item defines a text rotation value. Currently
+ text can only be rotated 90,0 and 270,0 degrees.
+
+ */
+
+class EDITENG_DLLPUBLIC SvxTextRotateItem : public SfxUInt16Item
+{
+public:
+ static SfxPoolItem* CreateDefault();
+
+ SvxTextRotateItem(sal_uInt16 nValue, const sal_uInt16 nId);
+
+ virtual SfxPoolItem* Clone(SfxItemPool *pPool = nullptr) const override;
+ virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const override;
+ virtual SvStream& Store(SvStream & rStrm, sal_uInt16 nIVer) const override;
+ virtual sal_uInt16 GetVersion(sal_uInt16 nFileVersion) const override;
+
+ virtual bool GetPresentation(SfxItemPresentation ePres,
+ MapUnit eCoreMetric,
+ MapUnit ePresMetric,
+ OUString &rText,
+ const IntlWrapper * = nullptr) const override;
+
+ virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
+ virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
+
+ SvxTextRotateItem& operator=(const SvxTextRotateItem& rItem)
+ {
+ SetValue(rItem.GetValue());
+ return *this;
+ }
+
+ virtual bool operator==(const SfxPoolItem&) const override;
+
+ // our currently only degree values
+ void SetTopToBottom() { SetValue(2700); }
+ void SetBottomToTop() { SetValue(900); }
+ bool IsTopToBottom() const { return 2700 == GetValue(); }
+ bool IsBottomToTop() const { return 900 == GetValue(); }
+
+ void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
+};
+
+
// class SvxCharRotateItem ----------------------------------------------
/* [Description]
@@ -33,7 +81,7 @@
*/
-class EDITENG_DLLPUBLIC SvxCharRotateItem : public SfxUInt16Item
+class EDITENG_DLLPUBLIC SvxCharRotateItem : public SvxTextRotateItem
{
bool bFitToLine;
public:
@@ -66,12 +114,6 @@ public:
virtual bool operator==( const SfxPoolItem& ) const override;
- // our currently only degree values
- void SetTopToBottom() { SetValue( 2700 ); }
- void SetBottomToTop() { SetValue( 900 ); }
- bool IsTopToBottom() const { return 2700 == GetValue(); }
- bool IsBottomToTop() const { return 900 == GetValue(); }
-
bool IsFitToLine() const { return bFitToLine; }
void SetFitToLine( bool b ) { bFitToLine = b; }
diff --git a/include/editeng/editrids.hrc b/include/editeng/editrids.hrc
index d302d1ad3415..a281d1814207 100644
--- a/include/editeng/editrids.hrc
+++ b/include/editeng/editrids.hrc
@@ -106,6 +106,8 @@
#define RID_SVXITEMS_CHARROTATE_OFF (RID_EDIT_START + 81)
#define RID_SVXITEMS_CHARROTATE (RID_EDIT_START + 82)
#define RID_SVXITEMS_CHARROTATE_FITLINE (RID_EDIT_START + 83)
+#define RID_SVXITEMS_TEXTROTATE_OFF (RID_EDIT_START + 84)
+#define RID_SVXITEMS_TEXTROTATE (RID_EDIT_START + 89)
#define RID_SVXITEMS_RELIEF_BEGIN (RID_EDIT_START + 85)
#define RID_SVXITEMS_RELIEF_NONE (RID_EDIT_START + 85)