summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2017-04-05 15:12:11 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2017-04-15 15:40:56 +0200
commitc671094154ecec6f3ba5beea9d26ff0d2d4d86ad (patch)
tree3a7d65d16e9161cc5326235041a35ff3e488e54e /svx
parent727bf1bdd516dc826620ea9254de1b0b76805907 (diff)
Introduce text rotation for Impress tables
* Introduce new table property for text rotation * Support only two rotation angle (270° and 90°) * Implement editing and rendering of 270° rotated text (90° rotation was already implemented) Change-Id: Ifc2e0f171e9c840e86b365e9af2c30aa97ecd92e
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdattr.cxx2
-rw-r--r--svx/source/svdraw/svdotext.cxx13
-rw-r--r--svx/source/svdraw/svdotextdecomposition.cxx24
-rw-r--r--svx/source/table/cell.cxx49
-rw-r--r--svx/source/table/svdotable.cxx4
-rw-r--r--svx/source/unodraw/unoshtxt.cxx2
6 files changed, 76 insertions, 18 deletions
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
index 7a09e8a8c313..427242539cc3 100644
--- a/svx/source/svdraw/svdattr.cxx
+++ b/svx/source/svdraw/svdattr.cxx
@@ -38,6 +38,7 @@
#include <editeng/adjustitem.hxx>
#include <editeng/editdata.hxx>
#include <editeng/writingmodeitem.hxx>
+#include <editeng/charrotateitem.hxx>
#include <i18nutil/unicode.hxx>
#include <svl/solar.hrc>
#include <tools/bigint.hxx>
@@ -320,6 +321,7 @@ SdrItemPool::SdrItemPool(
rPoolDefaults[ SDRATTR_TABLE_BORDER_INNER - SDRATTR_START ] = pBoxInfoItem;
rPoolDefaults[ SDRATTR_TABLE_BORDER_TLBR - SDRATTR_START ] = new SvxLineItem( SDRATTR_TABLE_BORDER_TLBR );
rPoolDefaults[ SDRATTR_TABLE_BORDER_BLTR - SDRATTR_START ] = new SvxLineItem( SDRATTR_TABLE_BORDER_BLTR );
+ rPoolDefaults[ SDRATTR_TABLE_TEXT_ROTATION - SDRATTR_START ] = new SvxTextRotateItem(0, SDRATTR_TABLE_TEXT_ROTATION);
// set own ItemInfos
mpLocalItemInfos[SDRATTR_SHADOW-SDRATTR_START]._nSID=SID_ATTR_FILL_SHADOW;
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 6e75fd299131..50522622e646 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1384,7 +1384,7 @@ void SdrTextObj::NbcSetOutlinerParaObjectForText( OutlinerParaObject* pTextObjec
if (pText && pText->GetOutlinerParaObject())
{
- SvxWritingModeItem aWritingMode(pText->GetOutlinerParaObject()->IsVertical()
+ SvxWritingModeItem aWritingMode(pText->GetOutlinerParaObject()->IsVertical() && pText->GetOutlinerParaObject()->IsTopToBottom()
? css::text::WritingMode_TB_RL
: css::text::WritingMode_LR_TB,
SDRATTR_TEXTDIRECTION);
@@ -1529,6 +1529,7 @@ bool SdrTextObj::IsVerticalWriting() const
void SdrTextObj::SetVerticalWriting(bool bVertical)
{
OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
+
if( !pOutlinerParaObject && bVertical )
{
// we only need to force a outliner para object if the default of
@@ -1537,7 +1538,8 @@ void SdrTextObj::SetVerticalWriting(bool bVertical)
pOutlinerParaObject = GetOutlinerParaObject();
}
- if( pOutlinerParaObject && (pOutlinerParaObject->IsVertical() != bVertical) )
+ if (pOutlinerParaObject &&
+ (pOutlinerParaObject->IsVertical() != bVertical))
{
// get item settings
const SfxItemSet& rSet = GetObjectItemSet();
@@ -1564,14 +1566,14 @@ void SdrTextObj::SetVerticalWriting(bool bVertical)
aNewSet.Put(makeSdrTextAutoGrowHeightItem(bAutoGrowWidth));
// Exchange horz and vert adjusts
- switch(eVert)
+ switch (eVert)
{
case SDRTEXTVERTADJUST_TOP: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); break;
case SDRTEXTVERTADJUST_CENTER: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER)); break;
case SDRTEXTVERTADJUST_BOTTOM: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT)); break;
case SDRTEXTVERTADJUST_BLOCK: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK)); break;
}
- switch(eHorz)
+ switch (eHorz)
{
case SDRTEXTHORZADJUST_LEFT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM)); break;
case SDRTEXTHORZADJUST_CENTER: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); break;
@@ -1582,7 +1584,7 @@ void SdrTextObj::SetVerticalWriting(bool bVertical)
SetObjectItemSet(aNewSet);
pOutlinerParaObject = GetOutlinerParaObject();
- if( pOutlinerParaObject )
+ if (pOutlinerParaObject)
{
// set ParaObject orientation accordingly
pOutlinerParaObject->SetVertical(bVertical);
@@ -1593,7 +1595,6 @@ void SdrTextObj::SetVerticalWriting(bool bVertical)
}
}
-
// transformation interface for StarOfficeAPI. This implements support for
// homogeneous 3x3 matrices containing the transformation of the SdrObject. At the
// moment it contains a shearX, rotation and translation, but for setting all linear
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx
index 926ae34dfc31..a05a428b6798 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -759,6 +759,7 @@ void SdrTextObj::impDecomposeAutoFitTextPrimitive(
const OutlinerParaObject* pOutlinerParaObject = rSdrAutofitTextPrimitive.getSdrText()->GetOutlinerParaObject();
OSL_ENSURE(pOutlinerParaObject, "impDecomposeBlockTextPrimitive used with no OutlinerParaObject (!)");
const bool bVerticalWriting(pOutlinerParaObject->IsVertical());
+ const bool bTopToBottom(pOutlinerParaObject->IsTopToBottom());
const Size aAnchorTextSize(Size(nAnchorTextWidth, nAnchorTextHeight));
if((rSdrAutofitTextPrimitive.getWordWrap() || IsTextFrame()))
@@ -829,8 +830,9 @@ void SdrTextObj::impDecomposeAutoFitTextPrimitive(
// translate relative to given primitive to get same rotation and shear
// as the master shape we are working on. For vertical, use the top-right
// corner
- const double fStartInX(bVerticalWriting ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX());
- aNewTransformA.translate(fStartInX, aAdjustTranslate.getY());
+ const double fStartInX(bVerticalWriting && bTopToBottom ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX());
+ const double fStartInY(bVerticalWriting && !bTopToBottom ? aAdjustTranslate.getY() + aOutlinerScale.getY() : aAdjustTranslate.getY());
+ aNewTransformA.translate(fStartInX, fStartInY);
// mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y,
// move the null point which was top left to bottom right.
@@ -922,6 +924,7 @@ void SdrTextObj::impDecomposeBlockTextPrimitive(
const sal_uInt32 nAnchorTextWidth(FRound(aAnchorTextRange.getWidth() + 1L));
const sal_uInt32 nAnchorTextHeight(FRound(aAnchorTextRange.getHeight() + 1L));
const bool bVerticalWriting(rSdrBlockTextPrimitive.getOutlinerParaObject().IsVertical());
+ const bool bTopToBottom(rSdrBlockTextPrimitive.getOutlinerParaObject().IsTopToBottom());
const Size aAnchorTextSize(Size(nAnchorTextWidth, nAnchorTextHeight));
if(bIsCell)
@@ -1082,8 +1085,9 @@ void SdrTextObj::impDecomposeBlockTextPrimitive(
// Translate relative to given primitive to get same rotation and shear
// as the master shape we are working on. For vertical, use the top-right
// corner
- const double fStartInX(bVerticalWriting ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX());
- const basegfx::B2DTuple aAdjOffset(fStartInX, aAdjustTranslate.getY());
+ const double fStartInX(bVerticalWriting && bTopToBottom ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX());
+ const double fStartInY(bVerticalWriting && !bTopToBottom ? aAdjustTranslate.getY() + aOutlinerScale.getY() : aAdjustTranslate.getY());
+ const basegfx::B2DTuple aAdjOffset(fStartInX, fStartInY);
basegfx::B2DHomMatrix aNewTransformA(basegfx::tools::createTranslateB2DHomMatrix(aAdjOffset.getX(), aAdjOffset.getY()));
// mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y,
@@ -1162,10 +1166,14 @@ void SdrTextObj::impDecomposeStretchTextPrimitive(
// needs to translate the text initially around object width to orient
// it relative to the topper right instead of the topper left
const bool bVertical(rSdrStretchTextPrimitive.getOutlinerParaObject().IsVertical());
+ const bool bTopToBottom(rSdrStretchTextPrimitive.getOutlinerParaObject().IsTopToBottom());
if(bVertical)
{
- aNewTransformA.translate(aScale.getX(), 0.0);
+ if(bTopToBottom)
+ aNewTransformA.translate(aScale.getX(), 0.0);
+ else
+ aNewTransformA.translate(0.0, aScale.getY());
}
// calculate global char stretching scale parameters. Use non-mirrored sizes
@@ -1517,6 +1525,7 @@ void SdrTextObj::impDecomposeChainedTextPrimitive(
OSL_ENSURE(pOutlinerParaObject, "impDecomposeBlockTextPrimitive used with no OutlinerParaObject (!)");
const bool bVerticalWriting(pOutlinerParaObject->IsVertical());
+ const bool bTopToBottom(pOutlinerParaObject->IsTopToBottom());
const Size aAnchorTextSize(Size(nAnchorTextWidth, nAnchorTextHeight));
if(IsTextFrame())
@@ -1593,8 +1602,9 @@ void SdrTextObj::impDecomposeChainedTextPrimitive(
// translate relative to given primitive to get same rotation and shear
// as the master shape we are working on. For vertical, use the top-right
// corner
- const double fStartInX(bVerticalWriting ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX());
- aNewTransformA.translate(fStartInX, aAdjustTranslate.getY());
+ const double fStartInX(bVerticalWriting && bTopToBottom ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX());
+ const double fStartInY(bVerticalWriting && !bTopToBottom ? aAdjustTranslate.getY() + aOutlinerScale.getY() : aAdjustTranslate.getY());
+ aNewTransformA.translate(fStartInX, fStartInY);
// mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y,
// move the null point which was top left to bottom right.
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index 41601c98be83..814e69ce3790 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -51,6 +51,7 @@
#include "svx/unoshape.hxx"
#include "editeng/editobj.hxx"
#include "editeng/boxitem.hxx"
+#include <editeng/charrotateitem.hxx>
#include "svx/xflbstit.hxx"
#include "svx/xflbmtit.hxx"
#include <svx/svdpool.hxx>
@@ -284,6 +285,7 @@ namespace sdr
OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, nParaCount);
pOutliner->Clear();
+ pTemp->SetVertical(pParaObj->IsVertical(), pParaObj->IsTopToBottom());
mxCell->SetOutlinerParaObject(pTemp);
}
@@ -307,8 +309,7 @@ namespace sdr
bool bVertical(css::text::WritingMode_TB_RL == static_cast<const SvxWritingModeItem*>(pNewItem)->GetValue());
sdr::table::SdrTableObj& rObj = static_cast<sdr::table::SdrTableObj&>(GetSdrObject());
- if( rObj.IsVerticalWriting() != bVertical )
- rObj.SetVerticalWriting(bVertical);
+ rObj.SetVerticalWriting(bVertical);
// Set a cell vertical property
OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject();
@@ -327,6 +328,50 @@ namespace sdr
}
}
+ if (pNewItem && (SDRATTR_TABLE_TEXT_ROTATION == nWhich))
+ {
+ const SvxTextRotateItem* pRotateItem = static_cast<const SvxTextRotateItem*>(pNewItem);
+
+ // Set a cell vertical property
+ OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject();
+
+ const bool bOwnParaObj = pParaObj != nullptr;
+
+ if (pParaObj == nullptr)
+ pParaObj = mxCell->GetOutlinerParaObject();
+
+ if (pParaObj)
+ {
+ pParaObj->SetVertical(pRotateItem->IsVertical(), pRotateItem->IsTopToBottom());
+
+ if (bOwnParaObj)
+ delete pParaObj;
+ }
+
+ // Change autogrow direction
+ SdrTextObj& rObj = static_cast<SdrTextObj&>(GetSdrObject());
+
+ // rescue object size
+ tools::Rectangle aObjectRect = rObj.GetSnapRect();
+
+ const SfxItemSet& rSet = rObj.GetObjectItemSet();
+ bool bAutoGrowWidth = static_cast<const SdrOnOffItem&>(rSet.Get(SDRATTR_TEXT_AUTOGROWWIDTH)).GetValue();
+ bool bAutoGrowHeight = static_cast<const SdrOnOffItem&>(rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT)).GetValue();
+
+ // prepare ItemSet to set exchanged width and height items
+ SfxItemSet aNewSet(*rSet.GetPool(),
+ SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT,
+ 0, 0);
+
+ aNewSet.Put(rSet);
+ aNewSet.Put(makeSdrTextAutoGrowWidthItem(bAutoGrowHeight));
+ aNewSet.Put(makeSdrTextAutoGrowHeightItem(bAutoGrowWidth));
+ rObj.SetObjectItemSet(aNewSet);
+
+ // restore object size
+ rObj.SetSnapRect(aObjectRect);
+ }
+
// call parent
AttributeProperties::ItemChange( nWhich, pNewItem );
}
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 7aea17aebfdf..0b0596bae078 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -1943,9 +1943,9 @@ bool SdrTableObj::IsVerticalWriting() const
}
-void SdrTableObj::SetVerticalWriting(bool bVertical )
+void SdrTableObj::SetVerticalWriting(bool bVertical)
{
- if( bVertical != IsVerticalWriting() )
+ if(bVertical != IsVerticalWriting() )
{
SvxWritingModeItem aModeItem( css::text::WritingMode_LR_TB, SDRATTR_TEXTDIRECTION );
SetObjectItem( aModeItem );
diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx
index cb5b73836645..0d688e55bf3c 100644
--- a/svx/source/unodraw/unoshtxt.cxx
+++ b/svx/source/unodraw/unoshtxt.cxx
@@ -635,7 +635,7 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder()
mpOutliner->SetStyleSheet( 0, pStyleSheet );
if( bVertical )
- mpOutliner->SetVertical( true );
+ mpOutliner->SetVertical( true, pOutlinerParaObject->IsTopToBottom());
}
// maybe we have to set the border attributes