summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorAndre Fischer <af@apache.org>2012-07-13 07:55:43 +0000
committerAndre Fischer <af@apache.org>2012-07-13 07:55:43 +0000
commit57fdcdd79d1682ee7d5e88fbab3803631496afa2 (patch)
tree3625a989a01f4248e0083428d386052c88e17c91 /filter
parent1289f5be48f50b38b16fb0ad34c7743317e8c79d (diff)
#i119874 Fixed text alignment in RTL layout.
Reported by: Li Feng Wang Patch by: Jianyuan Li Review by: Andre Fischer
Notes
Diffstat (limited to 'filter')
-rw-r--r--filter/inc/filter/msfilter/svdfppt.hxx3
-rw-r--r--filter/source/msfilter/svdfppt.cxx130
2 files changed, 132 insertions, 1 deletions
diff --git a/filter/inc/filter/msfilter/svdfppt.hxx b/filter/inc/filter/msfilter/svdfppt.hxx
index b18f5197438b..6c22b32ab256 100644
--- a/filter/inc/filter/msfilter/svdfppt.hxx
+++ b/filter/inc/filter/msfilter/svdfppt.hxx
@@ -580,7 +580,8 @@ protected:
sal_uInt32 GetNotesPageId(sal_uInt16 nPageNum ) const;
SdrOutliner* GetDrawOutliner( SdrTextObj* pSdrText ) const;
void SeekOle( SfxObjectShell* pShell, sal_uInt32 nFilterOptions );
-
+ void ApplyTextAnchorAttributes( PPTTextObj& rTextObj, SfxItemSet& rSet ) const;
+ sal_Bool IsVerticalText() const;
public:
SdrPowerPointImport( PowerPointImportParam&, const String& rBaseURL );
virtual ~SdrPowerPointImport();
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 60c1e8de63a2..0e2eb95e428f 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -7865,4 +7865,134 @@ SdrObject* SdrPowerPointImport::CreateTable( SdrObject* pGroup, sal_uInt32* pTab
////////////////////////////////////////////////////////////////////////////////////////////////////
+sal_Bool SdrPowerPointImport::IsVerticalText() const
+{
+ sal_Bool bVerticalText = sal_False;
+ if ( IsProperty( DFF_Prop_txflTextFlow ) )
+ {
+ MSO_TextFlow eTextFlow = (MSO_TextFlow)( GetPropertyValue( DFF_Prop_txflTextFlow ) & 0xFFFF );
+ switch( eTextFlow )
+ {
+ case mso_txflTtoBA : // Top to Bottom @-font, above -> below
+ case mso_txflTtoBN : // Top to Bottom non-@, above -> below
+ case mso_txflVertN : // Vertical, non-@, above -> below
+ bVerticalText = !bVerticalText;
+ break;
+ default: break;
+ }
+ }
+
+ return bVerticalText;
+}
+
+void SdrPowerPointImport::ApplyTextAnchorAttributes( PPTTextObj& rTextObj, SfxItemSet& rSet ) const
+{
+ SdrTextVertAdjust eTVA;
+ SdrTextHorzAdjust eTHA;
+
+ sal_uInt32 nTextFlags = rTextObj.GetTextFlags();
+
+ nTextFlags &= PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT
+ | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK;
+
+ if ( IsVerticalText() )
+ {
+ eTVA = SDRTEXTVERTADJUST_BLOCK;
+ eTHA = SDRTEXTHORZADJUST_CENTER;
+
+ // Textverankerung lesen
+ MSO_Anchor eTextAnchor = (MSO_Anchor)GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop );
+
+ switch( eTextAnchor )
+ {
+ case mso_anchorTop:
+ case mso_anchorTopCentered:
+ eTHA = SDRTEXTHORZADJUST_RIGHT;
+ break;
+
+ case mso_anchorMiddle :
+ case mso_anchorMiddleCentered:
+ eTHA = SDRTEXTHORZADJUST_CENTER;
+ break;
+
+ case mso_anchorBottom:
+ case mso_anchorBottomCentered:
+ eTHA = SDRTEXTHORZADJUST_LEFT;
+ break;
+ }
+ // if there is a 100% use of following attributes, the textbox can been aligned also in vertical direction
+ switch ( eTextAnchor )
+ {
+ case mso_anchorTopCentered :
+ case mso_anchorMiddleCentered :
+ case mso_anchorBottomCentered :
+ {
+ // check if it is sensible to use the centered alignment
+ sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT;
+ if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left or also right aligned pararagraphs
+ eTVA = SDRTEXTVERTADJUST_CENTER; // the text has to be displayed using the full width;
+ }
+ break;
+
+ default :
+ {
+ if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT )
+ eTVA = SDRTEXTVERTADJUST_TOP;
+ else if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT )
+ eTVA = SDRTEXTVERTADJUST_BOTTOM;
+ }
+ break;
+ }
+ }
+ else
+ {
+ eTVA = SDRTEXTVERTADJUST_CENTER;
+ eTHA = SDRTEXTHORZADJUST_BLOCK;
+
+ // Textverankerung lesen
+ MSO_Anchor eTextAnchor = (MSO_Anchor)GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop );
+
+ switch( eTextAnchor )
+ {
+ case mso_anchorTop:
+ case mso_anchorTopCentered:
+ eTVA = SDRTEXTVERTADJUST_TOP;
+ break;
+
+ case mso_anchorMiddle :
+ case mso_anchorMiddleCentered:
+ eTVA = SDRTEXTVERTADJUST_CENTER;
+ break;
+ case mso_anchorBottom:
+ case mso_anchorBottomCentered:
+ eTVA = SDRTEXTVERTADJUST_BOTTOM;
+ break;
+ }
+ // if there is a 100% usage of following attributes, the textbox can be aligned also in horizontal direction
+ switch ( eTextAnchor )
+ {
+ case mso_anchorTopCentered :
+ case mso_anchorMiddleCentered :
+ case mso_anchorBottomCentered :
+ {
+ // check if it is sensible to use the centered alignment
+ sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT;
+ if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left or also right aligned pararagraphs
+ eTHA = SDRTEXTHORZADJUST_CENTER; // the text has to be displayed using the full width;
+ }
+ break;
+
+ default :
+ {
+ if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT )
+ eTHA = SDRTEXTHORZADJUST_LEFT;
+ else if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT )
+ eTHA = SDRTEXTHORZADJUST_RIGHT;
+ }
+ break;
+ }
+ }
+ rSet.Put( SdrTextVertAdjustItem( eTVA ) );
+ rSet.Put( SdrTextHorzAdjustItem( eTHA ) );
+}