diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-03-28 19:24:49 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2017-04-18 20:14:53 +0200 |
commit | 253e2035474b830c07bf327ca7204fa362312a47 (patch) | |
tree | cd7536d37cb85713bf3baaff9a5156804ab68555 /svx | |
parent | 3526b7c0db27cb8e333d30813b79982873aa4501 (diff) |
tdf#105286: Implement text rotation for Impress tables
Typo: TopToBotton -> TopToBottom
Change-Id: I1b4d3ab9ec1d1383d76a56c9662ffeeb9fe69655
Reviewed-on: https://gerrit.libreoffice.org/36014
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit 334e6e2f1ad3da319be0849ec426aa64b18cb599)
Add SvxTextRotateItem inherited from SvxCharRotatItem
I will be use it later for text rotation inside a table.
Change-Id: I4cbaf05953b0e71331d2f3fdb45b7c4254a2b8cc
Reviewed-on: https://gerrit.libreoffice.org/36021
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit 1e30d2aface12a31687e5a27126e2061efd4b0cd)
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)
(cherry picked from commit c671094154ecec6f3ba5beea9d26ff0d2d4d86ad)
Change-Id: Ifc2e0f171e9c840e86b365e9af2c30aa97ecd92e
Implement RotateAngle API property for Impress table cells
(cherry picked from commit a0755ab8772d01797f4945016a978a2bbd8fdf20)
Change-Id: I01379c0fc21e8fe294bc882bf824f64502863ff4
tdf#100926: PPTX import of table with rotated text
(cherry picked from commit 2436cf17304f25c7d34da52a321d6da0e9011d19)
Change-Id: I05a8e979ac11b179e15784023032a56edc5b569b
ODF import / export of rotated text in Impress table
(cherry picked from commit bcb371b1a830442610ad7fda476eda5271427a50)
Change-Id: I57136e32ed2db5e405a45e8e4bad1b8d459b7ae8
Fix vertical text and bitmap bullet rendering
Change-Id: I881fce0511c81b164516d68f72c7e750687d4e0e
(cherry picked from commit 15ac3f9f4dc65fc0c6020284064e3725956f5d0a)
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdattr.cxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdotext.cxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdotextdecomposition.cxx | 24 | ||||
-rw-r--r-- | svx/source/table/cell.cxx | 67 | ||||
-rw-r--r-- | svx/source/table/svdotable.cxx | 4 | ||||
-rw-r--r-- | svx/source/unodraw/unoshtxt.cxx | 2 |
6 files changed, 87 insertions, 14 deletions
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx index 196a344b6111..c3519a3fcbe0 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> @@ -319,6 +320,7 @@ SdrItemPool::SdrItemPool( mppLocalPoolDefaults[ SDRATTR_TABLE_BORDER_INNER - SDRATTR_START ] = pBoxInfoItem; mppLocalPoolDefaults[ SDRATTR_TABLE_BORDER_TLBR - SDRATTR_START ] = new SvxLineItem( SDRATTR_TABLE_BORDER_TLBR ); mppLocalPoolDefaults[ SDRATTR_TABLE_BORDER_BLTR - SDRATTR_START ] = new SvxLineItem( SDRATTR_TABLE_BORDER_BLTR ); + mppLocalPoolDefaults[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 f052d6964c1a..6824c46bad95 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); diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index c567477a0f1a..e97b77cf50a0 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 5eaa3f99b5b9..3f484d378245 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> @@ -89,6 +90,7 @@ static const SvxItemPropertySet* ImplGetSvxCellPropertySet() { OUString("BottomBorder"), SDRATTR_TABLE_BORDER, cppu::UnoType<BorderLine>::get(), 0, BOTTOM_BORDER }, \ { OUString("LeftBorder"), SDRATTR_TABLE_BORDER, cppu::UnoType<BorderLine>::get(), 0, LEFT_BORDER }, \ { OUString("RightBorder"), SDRATTR_TABLE_BORDER, cppu::UnoType<BorderLine>::get(), 0, RIGHT_BORDER }, \ + { OUString("RotateAngle"), SDRATTR_TABLE_TEXT_ROTATION, cppu::UnoType<sal_Int32>::get(), 0, 0 }, \ SVX_UNOEDIT_OUTLINER_PROPERTIES, SVX_UNOEDIT_CHAR_PROPERTIES, @@ -291,7 +293,6 @@ namespace sdr OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, nParaCount); pOutliner->Clear(); - mxCell->SetOutlinerParaObject(pTemp); } @@ -314,8 +315,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(); @@ -334,6 +334,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 + 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 ); } @@ -1068,6 +1112,18 @@ void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any& mpProperties->SetObjectItem( XFillBmpTileItem( eMode == BitmapMode_REPEAT ) ); return; } + case SDRATTR_TABLE_TEXT_ROTATION: + { + sal_Int32 nRotVal = 0; + if (!(rValue >>= nRotVal)) + throw IllegalArgumentException(); + + if (nRotVal != 27000 && nRotVal != 9000 && nRotVal != 0) + throw IllegalArgumentException(); + + mpProperties->SetObjectItem(SvxTextRotateItem(nRotVal/10, SDRATTR_TABLE_TEXT_ROTATION)); + return; + } default: { SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID); @@ -1183,6 +1239,11 @@ Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName ) throw(Unknow return Any( BitmapMode_NO_REPEAT ); } } + case SDRATTR_TABLE_TEXT_ROTATION: + { + const SvxTextRotateItem& rTextRotate = static_cast<const SvxTextRotateItem&>(mpProperties->GetItem(SDRATTR_TABLE_TEXT_ROTATION)); + return Any(sal_Int32(rTextRotate.GetValue() * 10)); + } default: { SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID); diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index d53ddfffd777..a4374b9a7633 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -1950,9 +1950,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 3a5705f64508..b7bd9a66fcba 100644 --- a/svx/source/unodraw/unoshtxt.cxx +++ b/svx/source/unodraw/unoshtxt.cxx @@ -636,7 +636,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 |