/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::geometry::IntegerRectangle2D;
case XML_gradFill: // do not create gradient struct if property is not supported... if( rPropMap.supportsProperty( ShapeProperty::FillGradient ) )
{ // prepare ColorStops
basegfx::BColorStops aColorStops;
basegfx::BColorStops aTransparencyStops; bool bContainsTransparency(false);
// convert to BColorStops, check for contained transparency for (constauto& rCandidate : maGradientProps.maGradientStops)
{ const ::Color aColor(rCandidate.second.getColor(rGraphicHelper, nPhClr));
aColorStops.emplace_back(rCandidate.first, aColor.getBColor());
bContainsTransparency = bContainsTransparency || rCandidate.second.hasTransparency();
}
// if we have transparency, convert to BColorStops if (bContainsTransparency)
{ for (constauto& rCandidate : maGradientProps.maGradientStops)
{ constdouble fTrans(rCandidate.second.getTransparency() * (1.0/100.0));
aTransparencyStops.emplace_back(rCandidate.first, basegfx::BColor(fTrans, fTrans, fTrans));
}
}
// prepare BGradient with some defaults // CAUTION: This used awt::Gradient2 before who's empty constructor // (see workdir/UnoApiHeadersTarget/offapi/normal/com/sun/ // star/awt/Gradient.hpp) initializes all to zeros, so reflect // this here. OTOH set all that were set, e.g. Start/EndIntens // were set to 100, so just use default of BGradient constructor
basegfx::BGradient aGradient(
aColorStops,
awt::GradientStyle_LINEAR,
Degree10(900),
0, // border
0, // OfsX -> 0, not 50 (!)
0); // OfsY -> 0, not 50 (!)
// "rotate with shape" set to false -> do not rotate if (!maGradientProps.moRotateWithShape.value_or(true))
{
nShapeRotation = 0;
}
// FIXME tdf#166140: Size of gradient is smaller than in MSO if( maGradientProps.moGradientPath.value() == XML_circle )
{
aGradient.SetGradientStyle(awt::GradientStyle_RADIAL);
} else
{ // XML_rect or XML_shape, but the latter is not implemented.
aGradient.SetGradientStyle(awt::GradientStyle_RECT);
}
// convert DrawingML angle (in 1/60000 degrees) to API angle (in 1/10 degrees)
aGradient.SetAngle(Degree10(static_cast< sal_Int16 >( (8100 - (nDmlAngle / (PER_DEGREE / 10))) % 3600 )));
// If this is symmetrical, set it as an axial gradient for better UI/export. // There were chart2 unit test failures when doing this to transparent gradients // so just avoid that case. if (!bContainsTransparency)
aGradient.tryToConvertToAxial();
}
if (awt::GradientStyle_RECT == aGradient.GetGradientStyle())
{ // MCGR: tdf#155362: better support border // CAUTION: Need to handle TransparencyStops if used
aGradient.tryToRecreateBorder(aTransparencyStops.empty() ? nullptr : &aTransparencyStops);
}
// push gradient or named gradient to property map if (rPropMap.setProperty(ShapeProperty::FillGradient, model::gradient::createUnoGradient2(aGradient)))
{
eFillStyle = FillStyle_GRADIENT;
}
// push gradient transparency to property map if it exists if (!aTransparencyStops.empty())
{
aGradient.SetColorStops(aTransparencyStops);
rPropMap.setProperty(ShapeProperty::GradientTransparency, model::gradient::createUnoGradient2(aGradient));
}
} break;
case XML_blipFill: // do not start complex graphic transformation if property is not supported... if (maBlipProps.mxFillGraphic.is() && rPropMap.supportsProperty(ShapeProperty::FillBitmap))
{
uno::Reference<graphic::XGraphic> xGraphic = lclCheckAndApplyDuotoneTransform(maBlipProps, maBlipProps.mxFillGraphic, rGraphicHelper, nPhClr); // TODO: "rotate with shape" is not possible with our current core
if (xGraphic.is())
{ if (maBlipProps.moColorEffect.value_or(XML_TOKEN_INVALID) == XML_grayscl)
xGraphic = lclGreysScaleGraphic(xGraphic);
// set other bitmap properties, if bitmap has been inserted into the map if( eFillStyle == FillStyle_BITMAP )
{ // bitmap mode (single, repeat, stretch)
BitmapMode eBitmapMode = lclGetBitmapMode( maBlipProps.moBitmapMode.value_or( XML_TOKEN_INVALID ) );
switch( maBlipProps.moColorEffect.value_or( XML_TOKEN_INVALID ) )
{ case XML_biLevel: eColorMode = ColorMode_MONO; break; case XML_grayscl: eColorMode = ColorMode_GREYS; break;
}
if (maBlipProps.mxFillGraphic.is())
{ // created transformed graphic
uno::Reference<graphic::XGraphic> xGraphic = lclCheckAndApplyChangeColorTransform(maBlipProps, maBlipProps.mxFillGraphic, rGraphicHelper, API_RGB_TRANSPARENT);
xGraphic = lclCheckAndApplyDuotoneTransform(maBlipProps, xGraphic, rGraphicHelper, API_RGB_TRANSPARENT);
if( eColorMode == ColorMode_MONO )
{ // ColorMode_MONO is the same with MSO's biLevel with 50000 (50%) threshold, // when threshold isn't 50000 bake the effect instead. if( maBlipProps.moBiLevelThreshold != 50000 )
{
xGraphic = lclApplyBlackWhiteEffect(maBlipProps, xGraphic);
eColorMode = ColorMode_STANDARD;
}
}
if (eColorMode == ColorMode_STANDARD && nBrightness == 70 && nContrast == -70)
{ // map MSO 'washout' to our Watermark colormode
eColorMode = ColorMode_WATERMARK;
nBrightness = 0;
nContrast = 0;
} elseif( nBrightness != 0 && nContrast != 0 )
{ // MSO uses a different algorithm for contrast+brightness, LO applies contrast before brightness, // while MSO apparently applies half of brightness before contrast and half after. So if only // contrast or brightness need to be altered, the result is the same, but if both are involved, // there's no way to map that, so just force a conversion of the image.
xGraphic = applyBrightnessContrast( xGraphic, nBrightness, nContrast );
nBrightness = 0;
nContrast = 0;
}
if(mbIsCustomShape)
{ // it is a cropped graphic.
rPropMap.setProperty(PROP_FillStyle, FillStyle_BITMAP);
rPropMap.setProperty(PROP_FillBitmapMode, BitmapMode_STRETCH);
// It is a bitmap filled and rotated graphic. // When custom shape is rotated, bitmap have to be rotated too. // Only in extruded mode the bitmap is transformed together with the shape if(rPropMap.hasProperty(PROP_RotateAngle) && !mbIsExtruded)
{
tools::Long nAngle = rPropMap.getProperty(PROP_RotateAngle).get<tools::Long>();
xGraphic = lclRotateGraphic(xGraphic, Degree10(nAngle/10) );
}
// We have not core feature that flips graphic in the shape. // Here we are applying flip property to bitmap directly. if((bFlipH || bFlipV) && !mbIsExtruded)
xGraphic = lclMirrorGraphic(xGraphic, bFlipH, bFlipV );
// Media content if (!m_sMediaPackageURL.isEmpty())
{
rPropMap.setProperty(PROP_MediaURL, m_sMediaPackageURL); if (m_xMediaStream.is())
rPropMap.setProperty(PROP_PrivateStream, m_xMediaStream);
}
}
OUString ArtisticEffectProperties::getEffectString( sal_Int32 nToken )
{ switch( nToken )
{ // effects case OOX_TOKEN( a14, artisticBlur ): return u"artisticBlur"_ustr; case OOX_TOKEN( a14, artisticCement ): return u"artisticCement"_ustr; case OOX_TOKEN( a14, artisticChalkSketch ): return u"artisticChalkSketch"_ustr; case OOX_TOKEN( a14, artisticCrisscrossEtching ): return u"artisticCrisscrossEtching"_ustr; case OOX_TOKEN( a14, artisticCutout ): return u"artisticCutout"_ustr; case OOX_TOKEN( a14, artisticFilmGrain ): return u"artisticFilmGrain"_ustr; case OOX_TOKEN( a14, artisticGlass ): return u"artisticGlass"_ustr; case OOX_TOKEN( a14, artisticGlowDiffused ): return u"artisticGlowDiffused"_ustr; case OOX_TOKEN( a14, artisticGlowEdges ): return u"artisticGlowEdges"_ustr; case OOX_TOKEN( a14, artisticLightScreen ): return u"artisticLightScreen"_ustr; case OOX_TOKEN( a14, artisticLineDrawing ): return u"artisticLineDrawing"_ustr; case OOX_TOKEN( a14, artisticMarker ): return u"artisticMarker"_ustr; case OOX_TOKEN( a14, artisticMosiaicBubbles ): return u"artisticMosiaicBubbles"_ustr; case OOX_TOKEN( a14, artisticPaintStrokes ): return u"artisticPaintStrokes"_ustr; case OOX_TOKEN( a14, artisticPaintBrush ): return u"artisticPaintBrush"_ustr; case OOX_TOKEN( a14, artisticPastelsSmooth ): return u"artisticPastelsSmooth"_ustr; case OOX_TOKEN( a14, artisticPencilGrayscale ): return u"artisticPencilGrayscale"_ustr; case OOX_TOKEN( a14, artisticPencilSketch ): return u"artisticPencilSketch"_ustr; case OOX_TOKEN( a14, artisticPhotocopy ): return u"artisticPhotocopy"_ustr; case OOX_TOKEN( a14, artisticPlasticWrap ): return u"artisticPlasticWrap"_ustr; case OOX_TOKEN( a14, artisticTexturizer ): return u"artisticTexturizer"_ustr; case OOX_TOKEN( a14, artisticWatercolorSponge ): return u"artisticWatercolorSponge"_ustr; case OOX_TOKEN( a14, brightnessContrast ): return u"brightnessContrast"_ustr; case OOX_TOKEN( a14, colorTemperature ): return u"colorTemperature"_ustr; case OOX_TOKEN( a14, saturation ): return u"saturation"_ustr; case OOX_TOKEN( a14, sharpenSoften ): return u"sharpenSoften"_ustr;
// attributes case XML_visible: return u"visible"_ustr; case XML_trans: return u"trans"_ustr; case XML_crackSpacing: return u"crackSpacing"_ustr; case XML_pressure: return u"pressure"_ustr; case XML_numberOfShades: return u"numberOfShades"_ustr; case XML_grainSize: return u"grainSize"_ustr; case XML_intensity: return u"intensity"_ustr; case XML_smoothness: return u"smoothness"_ustr; case XML_gridSize: return u"gridSize"_ustr; case XML_pencilSize: return u"pencilSize"_ustr; case XML_size: return u"size"_ustr; case XML_brushSize: return u"brushSize"_ustr; case XML_scaling: return u"scaling"_ustr; case XML_detail: return u"detail"_ustr; case XML_bright: return u"bright"_ustr; case XML_contrast: return u"contrast"_ustr; case XML_colorTemp: return u"colorTemp"_ustr; case XML_sat: return u"sat"_ustr; case XML_amount: return u"amount"_ustr;
}
SAL_WARN( "oox.drawingml", "ArtisticEffectProperties::getEffectString: unexpected token " << nToken ); return OUString();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.