summaryrefslogtreecommitdiff
path: root/oox/source/vml
diff options
context:
space:
mode:
Diffstat (limited to 'oox/source/vml')
-rw-r--r--oox/source/vml/vmlformatting.cxx25
-rw-r--r--oox/source/vml/vmlshape.cxx69
-rw-r--r--oox/source/vml/vmlshapecontext.cxx1
3 files changed, 27 insertions, 68 deletions
diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index 2f9cf34fdd2a..5861ed88bbe3 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -20,6 +20,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp>
#include <com/sun/star/table/ShadowFormat.hpp>
#include <com/sun/star/text/XTextRange.hpp>
@@ -36,6 +37,7 @@
#include <oox/token/tokens.hxx>
#include <svx/svdtrans.hxx>
#include <comphelper/propertysequence.hxx>
+#include <vcl/virdev.hxx>
namespace oox {
namespace vml {
@@ -897,6 +899,8 @@ beans::PropertyValue lcl_createTextpathProps()
void TextpathModel::pushToPropMap(ShapePropertyMap& rPropMap, const uno::Reference<drawing::XShape>& xShape, const GraphicHelper& rGraphicHelper) const
{
+ OUString sFont = "";
+
if (moString.has())
{
uno::Reference<text::XTextRange> xTextRange(xShape, uno::UNO_QUERY);
@@ -940,6 +944,7 @@ void TextpathModel::pushToPropMap(ShapePropertyMap& rPropMap, const uno::Referen
uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
xPropertySet->setPropertyValue("CharFontName", uno::makeAny(aValue));
+ sFont = aValue;
}
else if (aName == "font-size")
{
@@ -952,6 +957,26 @@ void TextpathModel::pushToPropMap(ShapePropertyMap& rPropMap, const uno::Referen
}
}
}
+ if (!moTrim.has() || !moTrim.get())
+ {
+ OUString sText = moString.get();
+ double fRatio = 0;
+ VclPtr<VirtualDevice> pDevice = VclPtr<VirtualDevice>::Create();
+ vcl::Font aFont = pDevice->GetFont();
+ aFont.SetFamilyName(sFont);
+ aFont.SetFontSize(Size(0, 96));
+ pDevice->SetFont(aFont);
+
+ auto nTextWidth = pDevice->GetTextWidth(sText);
+ if (nTextWidth)
+ {
+ fRatio = pDevice->GetTextHeight();
+ fRatio /= nTextWidth;
+
+ sal_Int32 nNewHeight = fRatio * xShape->getSize().Width;
+ xShape->setSize(awt::Size(xShape->getSize().Width, nNewHeight));
+ }
+ }
}
} // namespace vml
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 6e792d93157e..8dfadd766f19 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -1143,79 +1143,12 @@ CustomShape::CustomShape( Drawing& rDrawing ) :
{
}
-static OUString lcl_getFontFamily( const oox::OptValue<OUString>& rStyle )
-{
- OUString sFont = "";
-
- if( rStyle.has() )
- {
- OUString aStyle = rStyle.get( OUString() );
-
- sal_Int32 nIndex = 0;
- while( nIndex >= 0 )
- {
- OUString aName;
- if( ConversionHelper::separatePair( aName, sFont, aStyle.getToken( 0, ';', nIndex ), ':' ) )
- {
- if( aName == "font-family" )
- {
- // remove " (first, and last character)
- if( sFont.getLength() > 2 )
- sFont = sFont.copy( 1, sFont.getLength() - 2 );
- }
- }
- }
- }
-
- return sFont;
-}
-
-/// modifies rShapeRect's height and returns difference
-sal_Int32 lcl_correctWatermarkRect( awt::Rectangle& rShapeRect, const OUString& sFont, const OUString& sText )
-{
- sal_Int32 nPaddingY = 0;
- double fRatio = 0;
- VclPtr<VirtualDevice> pDevice = VclPtr<VirtualDevice>::Create();
- vcl::Font aFont = pDevice->GetFont();
- aFont.SetFamilyName( sFont );
- aFont.SetFontSize( Size( 0, 96 ) );
- pDevice->SetFont( aFont );
-
- auto nTextWidth = pDevice->GetTextWidth( sText );
- if( nTextWidth )
- {
- fRatio = pDevice->GetTextHeight();
- fRatio /= nTextWidth;
-
- sal_Int32 nNewHeight = fRatio * rShapeRect.Width;
- nPaddingY = rShapeRect.Height - nNewHeight;
- rShapeRect.Height = nNewHeight;
- }
-
- return nPaddingY;
-}
-
Reference< XShape > CustomShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect ) const
{
- awt::Rectangle aShapeRect( rShapeRect );
-
- // Add padding for Watermark like Word does
- sal_Int32 nPaddingY = 0;
- if( getShapeName().match( "PowerPlusWaterMarkObject" ) && maTypeModel.maTextpathModel.moString.has() )
- {
- OUString sText = maTypeModel.maTextpathModel.moString.get();
- OUString sFont = lcl_getFontFamily( maTypeModel.maTextpathModel.moStyle );
- nPaddingY = lcl_correctWatermarkRect( aShapeRect, sFont, sText );
- }
-
// try to create a custom shape
- Reference< XShape > xShape = SimpleShape::implConvertAndInsert( rxShapes, aShapeRect );
+ Reference< XShape > xShape = SimpleShape::implConvertAndInsert( rxShapes, rShapeRect );
if( xShape.is() ) try
{
- // Remember padding for Watermark
- if( nPaddingY )
- PropertySet( xShape ).setAnyProperty( PROP_TextUpperDistance, makeAny( nPaddingY ) );
-
// create the custom shape geometry
Reference< XEnhancedCustomShapeDefaulter > xDefaulter( xShape, UNO_QUERY_THROW );
xDefaulter->createCustomShapeDefaults( OUString::number( getShapeType() ) );
diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx
index 8181c982780d..18dc68dbc2f5 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -396,6 +396,7 @@ ContextHandlerRef ShapeTypeContext::onCreateContext( sal_Int32 nElement, const A
case VML_TOKEN( textpath ):
mrTypeModel.maTextpathModel.moString.assignIfUsed(rAttribs.getString(XML_string));
mrTypeModel.maTextpathModel.moStyle.assignIfUsed(rAttribs.getString(XML_style));
+ mrTypeModel.maTextpathModel.moTrim.assignIfUsed(lclDecodeBool(rAttribs, XML_trim));
break;
}
return nullptr;