summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-06-19 15:32:16 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2017-07-06 15:02:39 +0200
commitbba6e442b0d8a4adae1b4e64a7fa7246130e300e (patch)
treef2c586ef5c4613df5922efb9444bc4c3c4b9f845 /filter
parent0a040f72397f235f8fd61e4161efad219b1ef710 (diff)
Watermark: tdf#91687 correct size in the .doc
Export: * Watermarks saved using Writer were very small in the MSO. Export fUsegtextFStretch property in the Geometry Text Boolean Properties. * tdf#91687: SnapRect contains size of Watermark after rotation. We have to export size without rotation. Import: * When import set height depending on used font and width. Text will keep the ratio. Remember the padding for export. * added unit test * introduced enum to avoid magic numbers for stretch and best fit properties. Change-Id: I3427afe78488d499f13c543ca401c096161aaf34 Reviewed-on: https://gerrit.libreoffice.org/38979 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Andras Timar <andras.timar@collabora.com> (cherry picked from commit d72e0cadceb0b43928a9b4f18d75c9d5d30afdda) Reviewed-on: https://gerrit.libreoffice.org/39607 Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'filter')
-rw-r--r--filter/source/msfilter/escherex.cxx4
-rw-r--r--filter/source/msfilter/msdffimp.cxx34
2 files changed, 33 insertions, 5 deletions
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index cf83e13057d6..6149a1ccc8c0 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -3486,6 +3486,10 @@ void EscherPropertyContainer::CreateCustomShapeProperties( const MSO_SPT eShapeT
if ( pOutlinerParaObject && pOutlinerParaObject->IsVertical() )
nTextPathFlags |= 0x2000;
}
+
+ // Use gtextFStretch for Watermark like MSO does
+ nTextPathFlags |= use_gtextFStretch | gtextFStretch;
+
if ( nTextPathFlags != nTextPathFlagsOrg )
AddOpt( DFF_Prop_gtextFStrikethrough, nTextPathFlags );
}
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 4dd1519bd74f..8053abeb8d26 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -4338,7 +4338,8 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
pRet = new SdrObjCustomShape();
pRet->SetModel( pSdrModel );
- bool bIsFontwork = ( GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ) & 0x4000 ) != 0;
+ sal_uInt32 ngtextFStrikethrough = GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 );
+ bool bIsFontwork = ( ngtextFStrikethrough & 0x4000 ) != 0;
// in case of a FontWork, the text is set by the escher import
if ( bIsFontwork )
@@ -4363,16 +4364,16 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
// SJ: applying fontattributes for Fontwork :
if ( IsHardAttribute( DFF_Prop_gtextFItalic ) )
- aSet.Put( SvxPostureItem( ( GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ) & 0x0010 ) != 0 ? ITALIC_NORMAL : ITALIC_NONE, EE_CHAR_ITALIC ) );
+ aSet.Put( SvxPostureItem( ( ngtextFStrikethrough & 0x0010 ) != 0 ? ITALIC_NORMAL : ITALIC_NONE, EE_CHAR_ITALIC ) );
if ( IsHardAttribute( DFF_Prop_gtextFBold ) )
- aSet.Put( SvxWeightItem( ( GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ) & 0x0020 ) != 0 ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
+ aSet.Put( SvxWeightItem( ( ngtextFStrikethrough & 0x0020 ) != 0 ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
// SJ TODO: Vertical Writing is not correct, instead
// this should be replaced through "CharacterRotation"
// by 90 degrees, therefore a new Item has to be
// supported by svx core, api and xml file format
- static_cast<SdrObjCustomShape*>(pRet)->SetVerticalWriting( ( GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ) & 0x2000 ) != 0 );
+ static_cast<SdrObjCustomShape*>(pRet)->SetVerticalWriting( ( ngtextFStrikethrough & 0x2000 ) != 0 );
if ( SeekToContent( DFF_Prop_gtextUNICODE, rSt ) )
{
@@ -4407,12 +4408,35 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
if ( nTextWidth != 100 )
aSet.Put( SvxCharScaleWidthItem( (sal_uInt16)nTextWidth, EE_CHAR_FONTWIDTH ) );
}
- if ( GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ) & 0x1000 ) // SJ: Font Kerning On ?
+ if ( ngtextFStrikethrough & 0x1000 ) // SJ: Font Kerning On ?
aSet.Put( SvxKerningItem( 1, EE_CHAR_KERNING ) );
// #i119496# the resize autoshape to fit text attr of word art in MS PPT is always false
aSet.Put(makeSdrTextAutoGrowHeightItem(false));
aSet.Put(makeSdrTextAutoGrowWidthItem(false));
+
+ double fRatio = 0;
+ OutputDevice* pOut = Application::GetDefaultDevice();
+ vcl::Font aFont( pOut->GetFont() );
+ aFont.SetFamilyName( aFontName );
+ auto nTextWidth = pOut->GetTextWidth( aObjectText );
+
+ if ( nTextWidth )
+ {
+ fRatio = aFont.GetFontSize().Height();
+ fRatio /= nTextWidth;
+ sal_Int32 nNewHeight = fRatio * aObjData.aBoundRect.getWidth();
+ sal_Int32 nPaddingY = aObjData.aBoundRect.getHeight() - nNewHeight;
+
+ if ( nPaddingY > 0 )
+ {
+ // Remember that value because original size have to be exported
+ aSet.Put( SdrMetricItem( SDRATTR_TEXT_UPPERDIST, nPaddingY ) );
+ aObjData.aBoundRect.setHeight( nNewHeight );
+ }
+ else
+ aSet.Put( SdrMetricItem( SDRATTR_TEXT_UPPERDIST, 0 ) );
+ }
}
pRet->SetMergedItemSet( aSet );