Rebased ref, commits from common ancestor: commit a765a9b52fdcbb2592e8ca121b93895a59ee120d Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Jul 25 15:38:24 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Jun 14 01:23:58 2023 +0900
svgio: use "frozen" for mapping between token strings and enums Change-Id: I2061606146cfcb34169dccf69b6f720727839d04 diff --git a/svgio/Library_svgio.mk b/svgio/Library_svgio.mk index 6221cb141316..76c0e87123bb 100644 --- a/svgio/Library_svgio.mk +++ b/svgio/Library_svgio.mk @@ -25,7 +25,10 @@ $(eval $(call gb_Library_set_include,svgio,\ -I$(SRCDIR)/svgio/inc \ )) -$(eval $(call gb_Library_use_external,svgio,boost_headers)) +$(eval $(call gb_Library_use_externals,svgio,\ + boost_headers \ + frozen \ +)) $(eval $(call gb_Library_set_precompiled_header,svgio,svgio/inc/pch/precompiled_svgio)) diff --git a/svgio/source/svgreader/svgtoken.cxx b/svgio/source/svgreader/svgtoken.cxx index 8228689606bf..e283b6e344bb 100644 --- a/svgio/source/svgreader/svgtoken.cxx +++ b/svgio/source/svgreader/svgtoken.cxx @@ -18,357 +18,369 @@ */ #include <svgtoken.hxx> -#include <unordered_map> +#include <frozen/bits/defines.h> +#include <frozen/bits/elsa_std.h> +#include <frozen/map.h> +#include <frozen/unordered_map.h> namespace svgio::svgreader { - const char aSVGStrWidth[] = "width"; - const char aSVGStrHeight[] = "height"; - const char aSVGStrViewBox[] = "viewBox"; - const char aSVGStrTransform[] = "transform"; - const char aSVGStrStyle[] = "style"; - const char aSVGStrDisplay[] = "display"; // #i121656# - const char aSVGStrD[] = "d"; - const char aSVGStrX[] = "x"; - const char aSVGStrY[] = "y"; - const char aSVGStrXmlns[] = "xmlns"; - const char aSVGStrVersion[] = "version"; - const char aSVGStrId[] = "id"; - const char aSVGStrIn[] = "in"; - const char aSVGStrRx[] = "rx"; - const char aSVGStrRy[] = "ry"; - const char aSVGStrPoints[] = "points"; - const char aSVGStrDx[] = "dx"; - const char aSVGStrDy[] = "dy"; - const char aSVGStrRotate[] = "rotate"; - const char aSVGStrTextLength[] = "textLength"; - const char aSVGStrLengthAdjust[] = "lengthAdjust"; - const char aSVGStrFont[] = "font"; - const char aSVGStrFontFamily[] = "font-family"; - const char aSVGStrFontSize[] = "font-size"; - const char aSVGStrFontSizeAdjust[] = "font-size-adjust"; - const char aSVGStrFontStretch[] = "font-stretch"; - const char aSVGStrFontStyle[] = "font-style"; - const char aSVGStrFontVariant[] = "font-variant"; - const char aSVGStrFontWeight[] = "font-weight"; - const char aSVGStrDirection[] = "direction"; - const char aSVGStrLetterSpacing[] = "letter-spacing"; - const char aSVGStrTextDecoration[] = "text-decoration"; - const char aSVGStrUnicodeBidi[] = "unicode-bidi"; - const char aSVGStrWordSpacing[] = "word-spacing"; - const char aSVGStrTspan[] = "tspan"; - const char aSVGStrTref[] = "tref"; - const char aSVGStrTextPath[] = "textPath"; - const char aSVGStrStartOffset[] = "startOffset"; - const char aSVGStrMethod[] = "method"; - const char aSVGStrSpacing[] = "spacing"; - const char aSVGStrStdDeviation[] = "stdDeviation"; - const char aSVGStrTextAlign[] = "text-align"; - const char aSVGStrPathLength[] = "pathLength"; - const char aSVGStrType[] = "type"; - const char aSVGStrClass[] = "class"; - const char aSVGStrTextAnchor[] = "text-anchor"; - const char aSVGStrXmlSpace[] = "xml:space"; - const char aSVGStrColor[] = "color"; - const char aSVGStrClipPathNode[] = "clipPath"; - const char aSVGStrClipPathProperty[] = "clip-path"; - const char aSVGStrFeGaussianBlur[] = "feGaussianBlur"; - const char aSVGStrFeColorMatrix[] = "feColorMatrix"; - const char aSVGStrFilter[] = "filter"; - const char aSVGStrMask[] = "mask"; - const char aSVGStrClipPathUnits[] = "clipPathUnits"; - const char aSVGStrMaskUnits[] = "maskUnits"; - const char aSVGStrMaskContentUnits[] = "maskContentUnits"; - const char aSVGStrClipRule[] = "clip-rule"; - const char aSVGStrMarker[] = "marker"; - const char aSVGStrMarkerStart[] = "marker-start"; - const char aSVGStrMarkerMid[] = "marker-mid"; - const char aSVGStrMarkerEnd[] = "marker-end"; - const char aSVGStrRefX[] = "refX"; - const char aSVGStrRefY[] = "refY"; - const char aSVGStrMarkerUnits[] = "markerUnits"; - const char aSVGStrMarkerWidth[] = "markerWidth"; - const char aSVGStrMarkerHeight[] = "markerHeight"; - const char aSVGStrOrient[] = "orient"; - const char aSVGStrPattern[] = "pattern"; - const char aSVGStrPatternUnits[] = "patternUnits"; - const char aSVGStrPatternContentUnits[] = "patternContentUnits"; - const char aSVGStrPatternTransform[] = "patternTransform"; - const char aSVGStrOpacity[] = "opacity"; - const char aSVGStrVisibility[] = "visibility"; - constexpr OUStringLiteral aSVGStrTitle = u"title"; - constexpr OUStringLiteral aSVGStrDesc = u"desc"; - const char aSVGStrPreserveAspectRatio[] = "preserveAspectRatio"; - const char aSVGStrDefer[] = "defer"; - const char aSVGStrNone[] = "none"; - const char aSVGStrXMinYMin[] = "xMinYMin"; - const char aSVGStrXMidYMin[] = "xMidYMin"; - const char aSVGStrXMaxYMin[] = "xMaxYMin"; - const char aSVGStrXMinYMid[] = "xMinYMid"; - const char aSVGStrXMidYMid[] = "xMidYMid"; - const char aSVGStrXMaxYMid[] = "xMaxYMid"; - const char aSVGStrXMinYMax[] = "xMinYMax"; - const char aSVGStrXMidYMax[] = "xMidYMax"; - const char aSVGStrXMaxYMax[] = "xMaxYMax"; - const char aSVGStrMeet[] = "meet"; - const char aSVGStrSlice[] = "slice"; +constexpr const std::u16string_view constToken_PathLength = u"pathLength"; +constexpr const std::u16string_view constTokenLowercase_PathLength = u"pathlength"; +constexpr const std::u16string_view constToken_Type = u"type"; +constexpr const std::u16string_view constToken_Class = u"class"; +constexpr const std::u16string_view constToken_TextAnchor = u"text-anchor"; +constexpr const std::u16string_view constToken_XmlSpace = u"xml:space"; +constexpr const std::u16string_view constToken_Color = u"color"; +constexpr const std::u16string_view constToken_ClipPathNode = u"clipPath"; +constexpr const std::u16string_view constTokenLowercase_ClipPathNode = u"clippath"; +constexpr const std::u16string_view constToken_ClipPathProperty = u"clip-path"; +constexpr const std::u16string_view constToken_Mask = u"mask"; +constexpr const std::u16string_view constToken_ClipPathUnits = u"clipPathUnits"; +constexpr const std::u16string_view constTokenLowercase_ClipPathUnits = u"clippathunits"; +constexpr const std::u16string_view constToken_MaskUnits = u"maskUnits"; +constexpr const std::u16string_view constTokenLowercase_MaskUnits = u"maskunits"; +constexpr const std::u16string_view constToken_MaskContentUnits = u"maskContentUnits"; +constexpr const std::u16string_view constTokenLowercase_MaskContentUnits = u"maskcontentunits"; +constexpr const std::u16string_view constToken_ClipRule = u"clip-rule"; +constexpr const std::u16string_view constToken_Marker = u"marker"; +constexpr const std::u16string_view constToken_MarkerStart = u"marker-start"; +constexpr const std::u16string_view constToken_MarkerMid = u"marker-mid"; +constexpr const std::u16string_view constToken_MarkerEnd = u"marker-end"; +constexpr const std::u16string_view constToken_RefX = u"refX"; +constexpr const std::u16string_view constToken_RefY = u"refY"; +constexpr const std::u16string_view constToken_MarkerUnits = u"markerUnits"; +constexpr const std::u16string_view constTokenLowercase_MarkerUnits = u"markerunits"; +constexpr const std::u16string_view constToken_MarkerWidth = u"markerWidth"; +constexpr const std::u16string_view constTokenLowercase_MarkerWidth = u"markerwidth"; +constexpr const std::u16string_view constToken_MarkerHeight = u"markerHeight"; +constexpr const std::u16string_view constTokenLowercase_MarkerHeight = u"markerheight"; +constexpr const std::u16string_view constToken_Orient = u"orient"; +constexpr const std::u16string_view constToken_Pattern = u"pattern"; +constexpr const std::u16string_view constToken_PatternUnits = u"patternUnits"; +constexpr const std::u16string_view constTokenLowercase_PatternUnits = u"patternunits"; +constexpr const std::u16string_view constToken_PatternContentUnits = u"patternContentUnits"; +constexpr const std::u16string_view constTokenLowercase_PatternContentUnits = u"patterncontentunits"; +constexpr const std::u16string_view constToken_PatternTransform = u"patternTransform"; +constexpr const std::u16string_view constTokenLowercase_PatternTransform = u"patterntransform"; +constexpr const std::u16string_view constToken_Opacity = u"opacity"; +constexpr const std::u16string_view constToken_Visibility = u"visibility"; +constexpr const std::u16string_view constToken_Title = u"title"; +constexpr const std::u16string_view constToken_Desc = u"desc"; - const char aSVGStrDefs[] = "defs"; - const char aSVGStrG[] = "g"; - const char aSVGStrSvg[] = "svg"; - const char aSVGStrSymbol[] = "symbol"; - const char aSVGStrUse[] = "use"; - const char aSVGStrA[] = "a"; +constexpr const std::u16string_view constToken_PreserveAspectRatio = u"preserveAspectRatio"; +constexpr const std::u16string_view constTokenLowercase_PreserveAspectRatio = u"preserveaspectratio"; +constexpr const std::u16string_view constToken_Defer = u"defer"; +constexpr const std::u16string_view constToken_None = u"none"; +constexpr const std::u16string_view constToken_XMinYMin = u"xMinYMin"; +constexpr const std::u16string_view constTokenLowercase_XMinYMin = u"xminymin"; +constexpr const std::u16string_view constToken_XMidYMin = u"xMidYMin"; +constexpr const std::u16string_view constTokenLowercase_XMidYMin = u"xmidymin"; +constexpr const std::u16string_view constToken_XMaxYMin = u"xMaxYMin"; +constexpr const std::u16string_view constTokenLowercase_XMaxYMin = u"xmaxymin"; +constexpr const std::u16string_view constToken_XMinYMid = u"xMinYMid"; +constexpr const std::u16string_view constTokenLowercase_XMinYMid = u"xminymid"; +constexpr const std::u16string_view constToken_XMidYMid = u"xMidYMid"; +constexpr const std::u16string_view constTokenLowercase_XMidYMid = u"xmidymid"; +constexpr const std::u16string_view constToken_XMaxYMid = u"xMaxYMid"; +constexpr const std::u16string_view constTokenLowercase_XMaxYMid = u"xmaxymid"; +constexpr const std::u16string_view constToken_XMinYMax = u"xMinYMax"; +constexpr const std::u16string_view constTokenLowercase_XMinYMax = u"xminymax"; +constexpr const std::u16string_view constToken_XMidYMax = u"xMidYMax"; +constexpr const std::u16string_view constTokenLowercase_XMidYMax = u"xmidymax"; +constexpr const std::u16string_view constToken_XMaxYMax = u"xMaxYMax"; +constexpr const std::u16string_view constTokenLowercase_XMaxYMax = u"xmaxymax"; +constexpr const std::u16string_view constToken_Meet = u"meet"; +constexpr const std::u16string_view constToken_Slice = u"slice"; - const char aSVGStrCircle[] = "circle"; - const char aSVGStrEllipse[] = "ellipse"; - const char aSVGStrLine[] = "line"; - const char aSVGStrPath[] = "path"; - const char aSVGStrPolygon[] = "polygon"; - const char aSVGStrPolyline[] = "polyline"; - const char aSVGStrRect[] = "rect"; - const char aSVGStrImage[] = "image"; +constexpr const std::u16string_view constToken_Defs = u"defs"; +constexpr const std::u16string_view constToken_G = u"g"; +constexpr const std::u16string_view constToken_Svg = u"svg"; +constexpr const std::u16string_view constToken_Symbol = u"symbol"; +constexpr const std::u16string_view constToken_Use = u"use"; +constexpr const std::u16string_view constToken_A = u"a"; - const char aSVGStrLinearGradient[] = "linearGradient"; - const char aSVGStrRadialGradient[] = "radialGradient"; - const char aSVGStrStop[] = "stop"; - const char aSVGStrOffset[] = "offset"; - const char aSVGStrX1[] = "x1"; - const char aSVGStrY1[] = "y1"; - const char aSVGStrX2[] = "x2"; - const char aSVGStrY2[] = "y2"; - const char aSVGStrCx[] = "cx"; - const char aSVGStrCy[] = "cy"; - const char aSVGStrFx[] = "fx"; - const char aSVGStrFy[] = "fy"; - const char aSVGStrR[] = "r"; - const char aSVGStrGradientUnits[] = "gradientUnits"; - const char aSVGStrGradientTransform[] = "gradientTransform"; - const char aSVGStrSpreadMethod[] = "spreadMethod"; - const char aSVGStrHref[] = "href"; - const char aSVGStrXlinkHref[] = "xlink:href"; - const char aSVGStrStopColor[] = "stop-color"; - const char aSVGStrStopOpacity[] = "stop-opacity"; +constexpr const std::u16string_view constToken_Circle = u"circle"; +constexpr const std::u16string_view constToken_Ellipse = u"ellipse"; +constexpr const std::u16string_view constToken_Line = u"line"; +constexpr const std::u16string_view constToken_Path = u"path"; +constexpr const std::u16string_view constToken_Polygon = u"polygon"; +constexpr const std::u16string_view constToken_Polyline = u"polyline"; +constexpr const std::u16string_view constToken_Rect = u"rect"; +constexpr const std::u16string_view constToken_Image = u"image"; - const char aSVGStrFill[] = "fill"; - const char aSVGStrFillOpacity[] = "fill-opacity"; - const char aSVGStrFillRule[] = "fill-rule"; +constexpr const std::u16string_view constToken_LinearGradient = u"linearGradient"; +constexpr const std::u16string_view constTokenLowercase_LinearGradient = u"lineargradient"; +constexpr const std::u16string_view constToken_RadialGradient = u"radialGradient"; +constexpr const std::u16string_view constTokenLowercase_RadialGradient = u"radialgradient"; +constexpr const std::u16string_view constToken_Stop = u"stop"; +constexpr const std::u16string_view constToken_Offset = u"offset"; +constexpr const std::u16string_view constToken_X1 = u"x1"; +constexpr const std::u16string_view constToken_Y1 = u"y1"; +constexpr const std::u16string_view constToken_X2 = u"x2"; +constexpr const std::u16string_view constToken_Y2 = u"y2"; +constexpr const std::u16string_view constToken_Cx = u"cx"; +constexpr const std::u16string_view constToken_Cy = u"cy"; +constexpr const std::u16string_view constToken_Fx = u"fx"; +constexpr const std::u16string_view constToken_Fy = u"fy"; +constexpr const std::u16string_view constToken_R = u"r"; +constexpr const std::u16string_view constToken_GradientUnits = u"gradientUnits"; +constexpr const std::u16string_view constTokenLowercase_GradientUnits = u"gradientunits"; +constexpr const std::u16string_view constToken_GradientTransform = u"gradientTransform"; +constexpr const std::u16string_view constTokenLowercase_GradientTransform = u"gradienttransform"; +constexpr const std::u16string_view constToken_SpreadMethod = u"spreadMethod"; +constexpr const std::u16string_view constTokenLowercase_SpreadMethod = u"spreadmethod"; +constexpr const std::u16string_view constToken_Href = u"href"; +constexpr const std::u16string_view constToken_XlinkHref = u"xlink:href"; +constexpr const std::u16string_view constToken_StopColor = u"stop-color"; +constexpr const std::u16string_view constToken_StopOpacity = u"stop-opacity"; - const char aSVGStrStroke[] = "stroke"; - const char aSVGStrStrokeDasharray[] = "stroke-dasharray"; - const char aSVGStrStrokeDashoffset[] = "stroke-dashoffset"; - const char aSVGStrStrokeLinecap[] = "stroke-linecap"; - const char aSVGStrStrokeLinejoin[] = "stroke-linejoin"; - const char aSVGStrStrokeMiterlimit[] = "stroke-miterlimit"; - const char aSVGStrStrokeOpacity[] = "stroke-opacity"; - const char aSVGStrStrokeWidth[] = "stroke-width"; +constexpr const std::u16string_view constToken_Fill = u"fill"; +constexpr const std::u16string_view constToken_FillOpacity = u"fill-opacity"; +constexpr const std::u16string_view constToken_FillRule = u"fill-rule"; - const char aSVGStrText[] = "text"; - const char aSVGStrBaselineShift[] = "baseline-shift"; +constexpr const std::u16string_view constToken_Stroke = u"stroke"; +constexpr const std::u16string_view constToken_StrokeDasharray = u"stroke-dasharray"; +constexpr const std::u16string_view constToken_StrokeDashoffset = u"stroke-dashoffset"; +constexpr const std::u16string_view constToken_StrokeLinecap = u"stroke-linecap"; +constexpr const std::u16string_view constToken_StrokeLinejoin = u"stroke-linejoin"; +constexpr const std::u16string_view constToken_StrokeMiterlimit = u"stroke-miterlimit"; +constexpr const std::u16string_view constToken_StrokeOpacity = u"stroke-opacity"; +constexpr const std::u16string_view constToken_StrokeWidth = u"stroke-width"; - const char aSVGStrFlowRoot[] = "flowRoot"; +constexpr const std::u16string_view constToken_Text = u"text"; +constexpr const std::u16string_view constToken_BaselineShift = u"baseline-shift"; + +constexpr const std::u16string_view constToken_FlowRoot = u"flowRoot"; +constexpr const std::u16string_view constTokenLowercase_FlowRoot = u"flowroot"; - SVGToken StrToSVGToken(const OUString& rStr, bool bCaseIndependent) - { - typedef std::unordered_map< OUString, SVGToken > SVGTokenMapper; - typedef std::pair< OUString, SVGToken > SVGTokenValueType; - static SVGTokenMapper aSVGTokenMapperList { - { aSVGStrWidth, SVGToken::Width }, - { aSVGStrHeight, SVGToken::Height }, - { aSVGStrViewBox, SVGToken::ViewBox }, - { aSVGStrTransform, SVGToken::Transform }, - { aSVGStrStyle, SVGToken::Style }, - { aSVGStrDisplay, SVGToken::Display }, // #i121656# - { aSVGStrD, SVGToken::D }, - { aSVGStrX, SVGToken::X }, - { aSVGStrY, SVGToken::Y }, - { aSVGStrXmlns, SVGToken::Xmlns }, - { aSVGStrVersion, SVGToken::Version }, - { aSVGStrId, SVGToken::Id }, - { aSVGStrIn, SVGToken::In }, - { aSVGStrRx, SVGToken::Rx }, - { aSVGStrRy, SVGToken::Ry }, - { aSVGStrPoints, SVGToken::Points }, - { aSVGStrDx, SVGToken::Dx }, - { aSVGStrDy, SVGToken::Dy }, - { aSVGStrRotate, SVGToken::Rotate }, - { aSVGStrTextLength, SVGToken::TextLength }, - { aSVGStrLengthAdjust, SVGToken::LengthAdjust }, - { aSVGStrFont, SVGToken::Font }, - { aSVGStrFontFamily, SVGToken::FontFamily }, - { aSVGStrFontSize, SVGToken::FontSize }, - { aSVGStrFontSizeAdjust, SVGToken::FontSizeAdjust }, - { aSVGStrFontStretch, SVGToken::FontStretch }, - { aSVGStrFontStyle, SVGToken::FontStyle }, - { aSVGStrFontVariant, SVGToken::FontVariant }, - { aSVGStrFontWeight, SVGToken::FontWeight }, - { aSVGStrDirection, SVGToken::Direction }, - { aSVGStrLetterSpacing, SVGToken::LetterSpacing }, - { aSVGStrTextDecoration, SVGToken::TextDecoration }, - { aSVGStrUnicodeBidi, SVGToken::UnicodeBidi }, - { aSVGStrWordSpacing, SVGToken::WordSpacing }, - { aSVGStrTspan, SVGToken::Tspan }, - { aSVGStrTref, SVGToken::Tref }, - { aSVGStrTextPath, SVGToken::TextPath }, - { aSVGStrStartOffset, SVGToken::StartOffset }, - { aSVGStrMethod, SVGToken::Method }, - { aSVGStrSpacing, SVGToken::Spacing }, - { aSVGStrStdDeviation, SVGToken::StdDeviation }, - { aSVGStrTextAlign, SVGToken::TextAlign }, - { aSVGStrPathLength, SVGToken::PathLength }, - { aSVGStrType, SVGToken::Type }, - { aSVGStrClass, SVGToken::Class }, - { aSVGStrTextAnchor, SVGToken::TextAnchor }, - { aSVGStrXmlSpace, SVGToken::XmlSpace }, - { aSVGStrColor, SVGToken::Color }, - { aSVGStrClipPathNode, SVGToken::ClipPathNode }, - { aSVGStrClipPathProperty, SVGToken::ClipPathProperty }, - { aSVGStrFeGaussianBlur, SVGToken::FeGaussianBlur }, - { aSVGStrFeColorMatrix, SVGToken::FeColorMatrix }, - { aSVGStrFilter, SVGToken::Filter }, - { aSVGStrMask, SVGToken::Mask }, - { aSVGStrClipPathUnits, SVGToken::ClipPathUnits }, - { aSVGStrMaskUnits, SVGToken::MaskUnits }, - { aSVGStrMaskContentUnits, SVGToken::MaskContentUnits }, - { aSVGStrClipRule, SVGToken::ClipRule }, - { aSVGStrMarker, SVGToken::Marker }, - { aSVGStrMarkerStart, SVGToken::MarkerStart }, - { aSVGStrMarkerMid, SVGToken::MarkerMid }, - { aSVGStrMarkerEnd, SVGToken::MarkerEnd }, - { aSVGStrRefX, SVGToken::RefX }, - { aSVGStrRefY, SVGToken::RefY }, - { aSVGStrMarkerUnits, SVGToken::MarkerUnits }, - { aSVGStrMarkerWidth, SVGToken::MarkerWidth }, - { aSVGStrMarkerHeight, SVGToken::MarkerHeight }, - { aSVGStrOrient, SVGToken::Orient }, - { aSVGStrPattern, SVGToken::Pattern }, - { aSVGStrPatternUnits, SVGToken::PatternUnits }, - { aSVGStrPatternContentUnits, SVGToken::PatternContentUnits }, - { aSVGStrPatternTransform, SVGToken::PatternTransform }, - { aSVGStrOpacity, SVGToken::Opacity }, - { aSVGStrVisibility, SVGToken::Visibility }, - { aSVGStrTitle, SVGToken::Title }, - { aSVGStrDesc, SVGToken::Desc }, - { aSVGStrPreserveAspectRatio, SVGToken::PreserveAspectRatio }, - { aSVGStrDefer, SVGToken::Defer }, - { aSVGStrNone, SVGToken::None }, - { aSVGStrXMinYMin, SVGToken::XMinYMin }, - { aSVGStrXMidYMin, SVGToken::XMidYMin }, - { aSVGStrXMaxYMin, SVGToken::XMaxYMin }, - { aSVGStrXMinYMid, SVGToken::XMinYMid }, - { aSVGStrXMidYMid, SVGToken::XMidYMid }, - { aSVGStrXMaxYMid, SVGToken::XMaxYMid }, - { aSVGStrXMinYMax, SVGToken::XMinYMax }, - { aSVGStrXMidYMax, SVGToken::XMidYMax }, - { aSVGStrXMaxYMax, SVGToken::XMaxYMax }, - { aSVGStrMeet, SVGToken::Meet }, - { aSVGStrSlice, SVGToken::Slice }, +static constexpr frozen::unordered_map<std::u16string_view, SVGToken, 138> aSVGTokenMapperList +{ + { u"width", SVGToken::Width }, + { u"height", SVGToken::Height }, + { u"viewBox", SVGToken::ViewBox }, + { u"transform", SVGToken::Transform }, + { u"style", SVGToken::Style }, + { u"display", SVGToken::Display }, // #i121656# + { u"d", SVGToken::D }, + { u"x", SVGToken::X }, + { u"y", SVGToken::Y }, + { u"xmlns", SVGToken::Xmlns }, + { u"version", SVGToken::Version }, + { u"id", SVGToken::Id }, + { u"in", SVGToken::In }, + { u"rx", SVGToken::Rx }, + { u"ry", SVGToken::Ry }, + { u"points", SVGToken::Points }, + { u"dx", SVGToken::Dx }, + { u"dy", SVGToken::Dy }, + { u"rotate", SVGToken::Rotate }, + { u"textLength", SVGToken::TextLength }, + { u"lengthAdjust", SVGToken::LengthAdjust }, + { u"font", SVGToken::Font }, + { u"font-family", SVGToken::FontFamily }, + { u"font-size", SVGToken::FontSize }, + { u"font-size-adjust", SVGToken::FontSizeAdjust }, + { u"font-stretch", SVGToken::FontStretch }, + { u"font-style", SVGToken::FontStyle }, + { u"font-variant", SVGToken::FontVariant }, + { u"font-weight", SVGToken::FontWeight }, + { u"direction", SVGToken::Direction }, + { u"letter-spacing", SVGToken::LetterSpacing }, + { u"text-decoration", SVGToken::TextDecoration }, + { u"unicode-bidi", SVGToken::UnicodeBidi }, + { u"word-spacing", SVGToken::WordSpacing }, + { u"tspan", SVGToken::Tspan }, + { u"tref", SVGToken::Tref }, + { u"textPath", SVGToken::TextPath }, + { u"startOffset", SVGToken::StartOffset }, + { u"method", SVGToken::Method }, + { u"spacing", SVGToken::Spacing }, + { u"stdDeviation", SVGToken::StdDeviation }, + { u"text-align", SVGToken::TextAlign }, + { constToken_PathLength, SVGToken::PathLength }, + { constToken_Type, SVGToken::Type }, + { constToken_Class, SVGToken::Class }, + { constToken_TextAnchor, SVGToken::TextAnchor }, + { constToken_XmlSpace, SVGToken::XmlSpace }, + { constToken_Color, SVGToken::Color }, + { constToken_ClipPathNode, SVGToken::ClipPathNode }, + { constToken_ClipPathProperty, SVGToken::ClipPathProperty }, + { u"feGaussianBlur", SVGToken::FeGaussianBlur }, + { u"feColorMatrix", SVGToken::FeColorMatrix }, + { u"filter", SVGToken::Filter }, + { constToken_Mask, SVGToken::Mask }, + { constToken_ClipPathUnits, SVGToken::ClipPathUnits }, + { constToken_MaskUnits, SVGToken::MaskUnits }, + { constToken_MaskContentUnits, SVGToken::MaskContentUnits }, + { constToken_ClipRule, SVGToken::ClipRule }, + { constToken_Marker, SVGToken::Marker }, + { constToken_MarkerStart, SVGToken::MarkerStart }, + { constToken_MarkerMid, SVGToken::MarkerMid }, + { constToken_MarkerEnd, SVGToken::MarkerEnd }, + { constToken_RefX, SVGToken::RefX }, + { constToken_RefY, SVGToken::RefY }, + { constToken_MarkerUnits, SVGToken::MarkerUnits }, + { constToken_MarkerWidth, SVGToken::MarkerWidth }, + { constToken_MarkerHeight, SVGToken::MarkerHeight }, + { constToken_Orient, SVGToken::Orient }, + { constToken_Pattern, SVGToken::Pattern }, + { constToken_PatternUnits, SVGToken::PatternUnits }, + { constToken_PatternContentUnits, SVGToken::PatternContentUnits }, + { constToken_PatternTransform, SVGToken::PatternTransform }, + { constToken_Opacity, SVGToken::Opacity }, + { constToken_Visibility, SVGToken::Visibility }, + { constToken_Title, SVGToken::Title }, + { constToken_Desc, SVGToken::Desc }, - { aSVGStrDefs, SVGToken::Defs }, - { aSVGStrG, SVGToken::G }, - { aSVGStrSvg, SVGToken::Svg }, - { aSVGStrSymbol, SVGToken::Symbol }, - { aSVGStrUse, SVGToken::Use }, - { aSVGStrA, SVGToken::A }, + { constToken_PreserveAspectRatio, SVGToken::PreserveAspectRatio }, + { constToken_Defer, SVGToken::Defer }, + { constToken_None, SVGToken::None }, + { constToken_XMinYMin, SVGToken::XMinYMin }, + { constToken_XMidYMin, SVGToken::XMidYMin }, + { constToken_XMaxYMin, SVGToken::XMaxYMin }, + { constToken_XMinYMid, SVGToken::XMinYMid }, + { constToken_XMidYMid, SVGToken::XMidYMid }, + { constToken_XMaxYMid, SVGToken::XMaxYMid }, + { constToken_XMinYMax, SVGToken::XMinYMax }, + { constToken_XMidYMax, SVGToken::XMidYMax }, + { constToken_XMaxYMax, SVGToken::XMaxYMax }, + { constToken_Meet, SVGToken::Meet }, + { constToken_Slice, SVGToken::Slice }, - { aSVGStrCircle, SVGToken::Circle }, - { aSVGStrEllipse, SVGToken::Ellipse }, - { aSVGStrLine, SVGToken::Line }, - { aSVGStrPath, SVGToken::Path }, - { aSVGStrPolygon, SVGToken::Polygon }, - { aSVGStrPolyline, SVGToken::Polyline }, - { aSVGStrRect, SVGToken::Rect }, - { aSVGStrImage, SVGToken::Image }, + { constToken_Defs, SVGToken::Defs }, + { constToken_G, SVGToken::G }, + { constToken_Svg, SVGToken::Svg }, + { constToken_Symbol, SVGToken::Symbol }, + { constToken_Use, SVGToken::Use }, + { constToken_A, SVGToken::A }, - { aSVGStrLinearGradient, SVGToken::LinearGradient }, - { aSVGStrRadialGradient, SVGToken::RadialGradient }, - { aSVGStrStop, SVGToken::Stop }, - { aSVGStrOffset, SVGToken::Offset }, - { aSVGStrX1, SVGToken::X1 }, - { aSVGStrY1, SVGToken::Y1 }, - { aSVGStrX2, SVGToken::X2 }, - { aSVGStrY2, SVGToken::Y2 }, - { aSVGStrCx, SVGToken::Cx }, - { aSVGStrCy, SVGToken::Cy }, - { aSVGStrFx, SVGToken::Fx }, - { aSVGStrFy, SVGToken::Fy }, - { aSVGStrR, SVGToken::R }, - { aSVGStrGradientUnits, SVGToken::GradientUnits }, - { aSVGStrGradientTransform, SVGToken::GradientTransform }, - { aSVGStrSpreadMethod, SVGToken::SpreadMethod }, - { aSVGStrHref, SVGToken::Href }, - { aSVGStrXlinkHref, SVGToken::XlinkHref }, - { aSVGStrStopColor, SVGToken::StopColor }, - { aSVGStrStopOpacity, SVGToken::StopOpacity }, + { constToken_Circle, SVGToken::Circle }, + { constToken_Ellipse, SVGToken::Ellipse }, + { constToken_Line, SVGToken::Line }, + { constToken_Path, SVGToken::Path }, + { constToken_Polygon, SVGToken::Polygon }, + { constToken_Polyline, SVGToken::Polyline }, + { constToken_Rect, SVGToken::Rect }, + { constToken_Image, SVGToken::Image }, - { aSVGStrFill, SVGToken::Fill }, - { aSVGStrFillOpacity, SVGToken::FillOpacity }, - { aSVGStrFillRule, SVGToken::FillRule }, + { constToken_LinearGradient, SVGToken::LinearGradient }, + { constToken_RadialGradient, SVGToken::RadialGradient }, + { constToken_Stop, SVGToken::Stop }, + { constToken_Offset, SVGToken::Offset }, + { constToken_X1, SVGToken::X1 }, + { constToken_Y1, SVGToken::Y1 }, + { constToken_X2, SVGToken::X2 }, + { constToken_Y2, SVGToken::Y2 }, + { constToken_Cx, SVGToken::Cx }, + { constToken_Cy, SVGToken::Cy }, + { constToken_Fx, SVGToken::Fx }, + { constToken_Fy, SVGToken::Fy }, + { constToken_R, SVGToken::R }, + { constToken_GradientUnits, SVGToken::GradientUnits }, + { constToken_GradientTransform, SVGToken::GradientTransform }, + { constToken_SpreadMethod, SVGToken::SpreadMethod }, + { constToken_Href, SVGToken::Href }, + { constToken_XlinkHref, SVGToken::XlinkHref }, + { constToken_StopColor, SVGToken::StopColor }, + { constToken_StopOpacity, SVGToken::StopOpacity }, - { aSVGStrStroke, SVGToken::Stroke }, - { aSVGStrStrokeDasharray, SVGToken::StrokeDasharray }, - { aSVGStrStrokeDashoffset, SVGToken::StrokeDashoffset }, - { aSVGStrStrokeLinecap, SVGToken::StrokeLinecap }, - { aSVGStrStrokeLinejoin, SVGToken::StrokeLinejoin }, - { aSVGStrStrokeMiterlimit, SVGToken::StrokeMiterlimit }, - { aSVGStrStrokeOpacity, SVGToken::StrokeOpacity }, - { aSVGStrStrokeWidth, SVGToken::StrokeWidth }, + { constToken_Fill, SVGToken::Fill }, + { constToken_FillOpacity, SVGToken::FillOpacity }, + { constToken_FillRule, SVGToken::FillRule }, - { aSVGStrText, SVGToken::Text }, - { aSVGStrBaselineShift, SVGToken::BaselineShift }, - { aSVGStrFlowRoot, SVGToken::FlowRoot } - }; + { constToken_Stroke, SVGToken::Stroke }, + { constToken_StrokeDasharray, SVGToken::StrokeDasharray }, + { constToken_StrokeDashoffset, SVGToken::StrokeDashoffset }, + { constToken_StrokeLinecap, SVGToken::StrokeLinecap }, + { constToken_StrokeLinejoin, SVGToken::StrokeLinejoin }, + { constToken_StrokeMiterlimit, SVGToken::StrokeMiterlimit }, + { constToken_StrokeOpacity, SVGToken::StrokeOpacity }, + { constToken_StrokeWidth, SVGToken::StrokeWidth }, - const SVGTokenMapper::const_iterator aResult(aSVGTokenMapperList.find(rStr.startsWith("svg:") ? rStr.copy(4) : rStr)); + { constToken_Text, SVGToken::Text }, + { constToken_BaselineShift, SVGToken::BaselineShift }, + { constToken_FlowRoot, SVGToken::FlowRoot } +}; - if(aResult == aSVGTokenMapperList.end()) - { - if(bCaseIndependent) - { - static SVGTokenMapper aCaseLindependentSVGTokenMapperList; +static constexpr frozen::unordered_map<std::u16string_view, SVGToken, 32> aLowerCaseList +{ + { u"viewbox", SVGToken::ViewBox }, + { u"textlength", SVGToken::TextLength }, + { u"lengthadjust", SVGToken::LengthAdjust }, + { u"textpath", SVGToken::TextPath }, + { u"startoffset", SVGToken::StartOffset }, + { constTokenLowercase_PathLength, SVGToken::PathLength }, + { constTokenLowercase_ClipPathNode, SVGToken::ClipPathNode }, + { constTokenLowercase_ClipPathUnits, SVGToken::ClipPathUnits }, + { constTokenLowercase_MaskUnits, SVGToken::MaskUnits }, + { constTokenLowercase_MaskContentUnits, SVGToken::MaskContentUnits }, + { constTokenLowercase_MarkerUnits, SVGToken::MarkerUnits }, + { constTokenLowercase_MarkerWidth, SVGToken::MarkerWidth }, + { constTokenLowercase_MarkerHeight, SVGToken::MarkerHeight }, + { constTokenLowercase_PatternUnits, SVGToken::PatternUnits }, + { constTokenLowercase_PatternContentUnits, SVGToken::PatternContentUnits }, + { constTokenLowercase_PatternTransform, SVGToken::PatternTransform }, + { constTokenLowercase_PreserveAspectRatio, SVGToken::PreserveAspectRatio }, + { constTokenLowercase_XMinYMin, SVGToken::XMinYMin }, + { constTokenLowercase_XMidYMin, SVGToken::XMidYMin }, + { constTokenLowercase_XMaxYMin, SVGToken::XMaxYMin }, + { constTokenLowercase_XMinYMid, SVGToken::XMinYMid }, + { constTokenLowercase_XMidYMid, SVGToken::XMidYMid }, + { constTokenLowercase_XMaxYMid, SVGToken::XMaxYMid }, + { constTokenLowercase_XMinYMax, SVGToken::XMinYMax }, + { constTokenLowercase_XMidYMax, SVGToken::XMidYMax }, + { constTokenLowercase_XMaxYMax, SVGToken::XMaxYMax }, + { constTokenLowercase_LinearGradient, SVGToken::LinearGradient }, + { constTokenLowercase_RadialGradient, SVGToken::RadialGradient }, + { constTokenLowercase_GradientUnits, SVGToken::GradientUnits }, + { constTokenLowercase_GradientTransform, SVGToken::GradientTransform }, + { constTokenLowercase_SpreadMethod, SVGToken::SpreadMethod }, + { constTokenLowercase_FlowRoot, SVGToken::FlowRoot } +}; - if(aCaseLindependentSVGTokenMapperList.empty()) - { - for(const auto& rCurrent : aSVGTokenMapperList) - { - aCaseLindependentSVGTokenMapperList.insert( - SVGTokenValueType( - rCurrent.first.toAsciiLowerCase(), - rCurrent.second)); - } - } +SVGToken StrToSVGToken(const OUString& rStr, bool bCaseIndependent) +{ + OUString aSearchString = rStr.startsWith("svg:") ? rStr.copy(4) : rStr; - const SVGTokenMapper::const_iterator aResult2(aCaseLindependentSVGTokenMapperList.find(rStr.toAsciiLowerCase())); + auto const aResult = aSVGTokenMapperList.find(aSearchString); - if(aResult2 == aCaseLindependentSVGTokenMapperList.end()) - { - return SVGToken::Unknown; - } - else - { - return aResult2->second; - } - } + if (aResult == aSVGTokenMapperList.end()) + { + if (bCaseIndependent) + { + auto const aResultLowerCase(aLowerCaseList.find(rStr.toAsciiLowerCase())); + if (aResultLowerCase == aLowerCaseList.end()) + { return SVGToken::Unknown; } else { - return aResult->second; + return aResultLowerCase->second; } } - OUString getStrTitle() - { - return aSVGStrTitle; - } + return SVGToken::Unknown; + } + else + { + return aResult->second; + } +} + +OUString getStrTitle() +{ + return OUString(constToken_Title); +} + +OUString getStrDesc() +{ + return OUString(constToken_Desc); +} - OUString getStrDesc() - { - return aSVGStrDesc; - } } // end of namespace svgio /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit b7c3f940377c16bb2936e99c0ffbd457a948b9e0 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat Jul 16 12:17:20 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Jun 14 01:23:58 2023 +0900 Add frozen library support - for compile-time dict, set support Change-Id: I8fa02569ba02048cc3ef02b349aafba1c0cbebb4 diff --git a/Makefile.fetch b/Makefile.fetch index c8c5c91941f2..625e781dc36a 100644 --- a/Makefile.fetch +++ b/Makefile.fetch @@ -125,6 +125,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_$(gb_Side).mk $(SRCDIR)/download.lst $(S $(call fetch_Optional,FONTCONFIG,FONTCONFIG_TARBALL) \ $(call fetch_Optional,FREEHAND,FREEHAND_TARBALL) \ $(call fetch_Optional,FREETYPE,FREETYPE_TARBALL) \ + FROZEN_TARBALL \ $(call fetch_Optional,EPOXY,EPOXY_TARBALL) \ $(call fetch_Optional,GLM,GLM_TARBALL) \ $(call fetch_Optional,GPGMEPP,GPGME_TARBALL) \ diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk index 3ec3cd924395..631466f0001a 100644 --- a/RepositoryExternal.mk +++ b/RepositoryExternal.mk @@ -4297,4 +4297,14 @@ endif # ENABLE_ZXING endif # SYSTEM_ZXING + +define gb_LinkTarget__use_frozen +$(call gb_LinkTarget_use_unpacked,$(1),frozen) +$(call gb_LinkTarget_set_include,$(1),\ + -I$(call gb_UnpackedTarball_get_dir,frozen/include/)\ + $$(INCLUDE) \ +) +endef + + # vim: set noet sw=4 ts=4: diff --git a/download.lst b/download.lst index 4ceea56e14a2..e50f51b90c0c 100644 --- a/download.lst +++ b/download.lst @@ -202,6 +202,11 @@ FREETYPE_TARBALL := freetype-2.13.0.tar.xz # three static lines # so that git cherry-pick # will not run into conflicts +FROZEN_SHA256SUM := f7c7075750e8fceeac081e9ef01944f221b36d9725beac8681cbd2838d26be45 +FROZEN_TARBALL := frozen-1.1.1.tar.gz +# three static lines +# so that git cherry-pick +# will not run into conflicts GLM_SHA256SUM := 6bba5f032bed47c73ad9397f2313b9acbfb56253d0d0576b5873d3dcb25e99ad GLM_TARBALL := glm-0.9.9.8.zip # three static lines diff --git a/external/Module_external.mk b/external/Module_external.mk index 73d6530ac10f..cd9c5924d71d 100644 --- a/external/Module_external.mk +++ b/external/Module_external.mk @@ -41,6 +41,7 @@ $(eval $(call gb_Module_add_moduledirs,external,\ $(call gb_Helper_optional,FONTCONFIG,fontconfig) \ $(call gb_Helper_optional,FREEHAND,libfreehand) \ $(call gb_Helper_optional,FREETYPE,freetype) \ + frozen \ $(call gb_Helper_optional,GLM,glm) \ $(call gb_Helper_optional,GPGMEPP,gpgmepp) \ $(call gb_Helper_optional,GRAPHITE,graphite) \ diff --git a/external/frozen/Module_frozen.mk b/external/frozen/Module_frozen.mk new file mode 100644 index 000000000000..10fa0997e0ed --- /dev/null +++ b/external/frozen/Module_frozen.mk @@ -0,0 +1,16 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*- +# +# 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/. +# + +$(eval $(call gb_Module_Module,frozen)) + +$(eval $(call gb_Module_add_targets,frozen,\ + UnpackedTarball_frozen \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/external/frozen/UnpackedTarball_frozen.mk b/external/frozen/UnpackedTarball_frozen.mk new file mode 100644 index 000000000000..01ad0f803f51 --- /dev/null +++ b/external/frozen/UnpackedTarball_frozen.mk @@ -0,0 +1,14 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*- +# +# 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/. +# + +$(eval $(call gb_UnpackedTarball_UnpackedTarball,frozen)) + +$(eval $(call gb_UnpackedTarball_set_tarball,frozen,$(FROZEN_TARBALL))) + +# vim: set noet sw=4 ts=4: commit 89f4037d4bf5fd2f42cec13195ad2dcc28d13448 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sun Mar 5 18:48:23 2023 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Jun 14 01:23:57 2023 +0900 svx: use gfx::Length based types directly in SdrTextObj::NbcResize Change-Id: I839430b30685994e1767998b353c63b97f461284 diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx index 74afe966425f..60c968bc1847 100644 --- a/svx/source/svdraw/svdotxtr.cxx +++ b/svx/source/svdraw/svdotxtr.cxx @@ -122,81 +122,103 @@ void SdrTextObj::NbcMove(const Size& rSize) void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { - bool bNotSheared=maGeo.nShearAngle==0_deg100; - bool bRotate90=bNotSheared && maGeo.nRotationAngle.get() % 9000 ==0; - bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); - bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); - if (bXMirr || bYMirr) { + bool bNotSheared = maGeo.nShearAngle == 0_deg100; + bool bRotate90 = bNotSheared && maGeo.nRotationAngle.get() % 9000 == 0; + + bool bXMirrored = (xFact.GetNumerator() < 0) != (xFact.GetDenominator() < 0); + bool bYMirrored = (yFact.GetNumerator() < 0) != (yFact.GetDenominator() < 0); + + double fFactorX = xFact.IsValid() ? double(xFact) : 1.0; + double fFactorY = yFact.IsValid() ? double(yFact) : 1.0; + + if (bXMirrored || bYMirrored) + { Point aRef1(GetSnapRect().Center()); - if (bXMirr) { + if (bXMirrored) + { Point aRef2(aRef1); aRef2.AdjustY( 1 ); NbcMirrorGluePoints(aRef1,aRef2); } - if (bYMirr) { + if (bYMirrored) + { Point aRef2(aRef1); aRef2.AdjustX( 1 ); NbcMirrorGluePoints(aRef1,aRef2); } } - if (maGeo.nRotationAngle==0_deg100 && maGeo.nShearAngle==0_deg100) { - auto aRectangle = getRectangle(); - ResizeRect(aRectangle, rRef, xFact, yFact); - setRectangle(aRectangle); - if (bYMirr) + if (maGeo.nRotationAngle == 0_deg100 && maGeo.nShearAngle == 0_deg100) + { + auto eUnit = getSdrModelFromSdrObject().getUnit(); + gfx::Tuple2DL aReference = createTupleFromPoint(rRef, eUnit); + svx::resizeRange(maRectangleRange, aReference, fFactorX, fFactorY); + + if (bYMirrored) { - //maRectangle.Normalize(); - moveRectangle(aRectangle.Right() - aRectangle.Left(), aRectangle.Bottom() - aRectangle.Top()); - maGeo.nRotationAngle=18000_deg100; + maRectangleRange.shift(maRectangleRange.getWidth(), maRectangleRange.getHeight()); + maGeo.nRotationAngle = 18000_deg100; maGeo.RecalcSinCos(); } } else { - tools::Polygon aPol(Rect2Poly(getRectangle(), maGeo)); + tools::Polygon aPolygon(Rect2Poly(getRectangle(), maGeo)); - for(sal_uInt16 a(0); a < aPol.GetSize(); a++) + for (sal_uInt16 a(0); a < aPolygon.GetSize(); a++) { - ResizePoint(aPol[a], rRef, xFact, yFact); + ResizePoint(aPolygon[a], rRef, xFact, yFact); } - if(bXMirr != bYMirr) + if (bXMirrored != bYMirrored) { // turn polygon and move it a little - tools::Polygon aPol0(aPol); + tools::Polygon aPol0(aPolygon); - aPol[0] = aPol0[1]; - aPol[1] = aPol0[0]; - aPol[2] = aPol0[3]; - aPol[3] = aPol0[2]; - aPol[4] = aPol0[1]; + aPolygon[0] = aPol0[1]; + aPolygon[1] = aPol0[0]; + aPolygon[2] = aPol0[3]; + aPolygon[3] = aPol0[2]; + aPolygon[4] = aPol0[1]; } - tools::Rectangle aRectangle = svx::polygonToRectangle(aPol, maGeo); + tools::Rectangle aRectangle = svx::polygonToRectangle(aPolygon, maGeo); setRectangle(aRectangle); } - if (bRotate90) { - bool bRota90=maGeo.nRotationAngle.get() % 9000 ==0; - if (!bRota90) { // there's seems to be a rounding error occurring: correct it - Degree100 a=NormAngle36000(maGeo.nRotationAngle); - if (a<4500_deg100) a=0_deg100; - else if (a<13500_deg100) a=9000_deg100; - else if (a<22500_deg100) a=18000_deg100; - else if (a<31500_deg100) a=27000_deg100; - else a=0_deg100; - maGeo.nRotationAngle=a; + if (bRotate90) + { + bool bRota90 = maGeo.nRotationAngle.get() % 9000 == 0; + if (!bRota90) + { + // there's seems to be a rounding error occurring: correct it + + Degree100 angle = NormAngle36000(maGeo.nRotationAngle); + if (angle < 4500_deg100) + angle = 0_deg100; + else if (angle < 13500_deg100) + angle = 9000_deg100; + else if (angle < 22500_deg100) + angle = 18000_deg100; + else if (angle < 31500_deg100) + angle = 27000_deg100; + else + angle = 0_deg100; + + maGeo.nRotationAngle = angle; maGeo.RecalcSinCos(); } - if (bNotSheared!=(maGeo.nShearAngle==0_deg100)) { // correct a rounding error occurring with Shear - maGeo.nShearAngle=0_deg100; + if (bNotSheared != (maGeo.nShearAngle == 0_deg100)) + { + // correct a rounding error occurring with Shear + + maGeo.nShearAngle = 0_deg100; maGeo.RecalcTan(); } } AdaptTextMinSize(); - if(mbTextFrame && !getSdrModelFromSdrObject().IsPasteResize()) + if (mbTextFrame && !getSdrModelFromSdrObject().IsPasteResize()) { NbcAdjustTextFrameWidthAndHeight(); } commit c2aab4b9f5608015dc9645f636b7e20090ec4217 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sun Mar 5 14:46:10 2023 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Jun 14 01:23:57 2023 +0900 svx: use gfx::Length based types directly in SdrTextObj::NbcMove Change-Id: Ib0d4a9f60a2ae7f64d914c7a39aa146fef6a9f74 diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx index b3afdb9a5779..74afe966425f 100644 --- a/svx/source/svdraw/svdotxtr.cxx +++ b/svx/source/svdraw/svdotxtr.cxx @@ -40,6 +40,18 @@ using namespace com::sun::star; +namespace +{ + +gfx::Tuple2DL createTupleFromPoint(Point const& rPoint, gfx::LengthUnit eUnit = gfx::LengthUnit::hmm) +{ + auto x = gfx::Length::from(eUnit, rPoint.X()); + auto y = gfx::Length::from(eUnit, rPoint.Y()); + return gfx::Tuple2DL(x, y); +} + +} // end anonymous + void SdrTextObj::NbcSetSnapRect(const tools::Rectangle& rRect) { if (maGeo.nRotationAngle || maGeo.nShearAngle) @@ -95,8 +107,15 @@ Degree100 SdrTextObj::GetShearAngle(bool /*bVertical*/) const void SdrTextObj::NbcMove(const Size& rSize) { - moveRectangle(rSize.Width(), rSize.Height()); - moveOutRectangle(rSize.Width(), rSize.Height()); + gfx::Tuple2DL aDelta = createTupleFromPoint(Point(rSize.Width(), rSize.Height()), getSdrModelFromSdrObject().getUnit()); + gfx::Length xDelta = aDelta.getX(); + gfx::Length yDelta = aDelta.getY(); + + if (xDelta == 0_emu && yDelta == 0_emu) + return; + + maRectangleRange.shift(xDelta, yDelta); + m_aOutterRange.shift(xDelta, yDelta); maSnapRect.Move(rSize); SetBoundAndSnapRectsDirty(true); } @@ -186,19 +205,6 @@ void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract SetBoundAndSnapRectsDirty(); } -namespace -{ - -gfx::Tuple2DL createTupleFromPoint(Point const& rPoint, gfx::LengthUnit eUnit = gfx::LengthUnit::hmm) -{ - auto x = gfx::Length::from(eUnit, rPoint.X()); - auto y = gfx::Length::from(eUnit, rPoint.Y()); - return gfx::Tuple2DL(x, y); -} - -} // end anonymous - - void SdrTextObj::NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs) { SetGlueReallyAbsolute(true); commit cb5bebc0793fd0a7a9c5869014506ef5b1d97511 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat Mar 4 22:12:51 2023 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Jun 14 01:23:57 2023 +0900 svx: use gfx::Length based types directly in SdrTextObj::NbcRotate Change-Id: Ic5ee712fa7507e016441595f8847649fd18b50ee diff --git a/include/svx/svdtrans.hxx b/include/svx/svdtrans.hxx index e213d5f1ea61..549e84ed9d67 100644 --- a/include/svx/svdtrans.hxx +++ b/include/svx/svdtrans.hxx @@ -46,13 +46,15 @@ SVXCORE_DLLPUBLIC void ResizeRect(tools::Rectangle& rRect, const Point& rRef, co namespace svx { SVXCORE_DLLPUBLIC void resizeRange(gfx::Range2DLWrap& rRange, gfx::Tuple2DL const& rReference, double fFactorX, double fFactorY); +SVXCORE_DLLPUBLIC gfx::Tuple2DL rotatePoint(gfx::Tuple2DL const& rPoint, gfx::Tuple2DL const& rReference, double sinAngle, double cosAngle); } inline void ResizePoint(Point& rPnt, const Point& rRef, const Fraction& xFract, const Fraction& yFract); void ResizePoly(tools::Polygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact); void ResizeXPoly(XPolygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact); -inline void RotatePoint(Point& rPnt, const Point& rRef, double sn, double cs); +SVXCORE_DLLPUBLIC void RotatePoint(Point& rPnt, const Point& rRef, double sn, double cs); + SVXCORE_DLLPUBLIC void RotatePoly(tools::Polygon& rPoly, const Point& rRef, double sn, double cs); void RotateXPoly(XPolygon& rPoly, const Point& rRef, double sn, double cs); void RotateXPoly(XPolyPolygon& rPoly, const Point& rRef, double sn, double cs); @@ -107,14 +109,6 @@ inline void ResizePoint(Point& rPnt, const Point& rRef, const Fraction& xFract, rPnt.setY(rRef.Y() + FRound( (rPnt.Y() - rRef.Y()) * nyFract )); } -inline void RotatePoint(Point& rPnt, const Point& rRef, double sn, double cs) -{ - tools::Long dx=rPnt.X()-rRef.X(); - tools::Long dy=rPnt.Y()-rRef.Y(); - rPnt.setX(FRound(rRef.X()+dx*cs+dy*sn)); - rPnt.setY(FRound(rRef.Y()+dy*cs-dx*sn)); -} - inline void ShearPoint(Point& rPnt, const Point& rRef, double tn, bool bVShear) { if (!bVShear) { // Horizontal diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx index 7022251f431c..083cac84c16a 100644 --- a/svx/qa/unit/svdraw.cxx +++ b/svx/qa/unit/svdraw.cxx @@ -559,7 +559,7 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testRectangleObjectMove) pModel->GetItemPool().FreezeIdRanges(); rtl::Reference<SdrPage> pPage(new SdrPage(*pModel, false)); - pPage->setSize({50_cm, 50_cm}); + pPage->setSize({ 50_cm, 50_cm }); pModel->InsertPage(pPage.get(), 0); tools::Rectangle aRect(Point(), Size(100, 100)); @@ -581,7 +581,7 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testRectangleObjectRotate) pModel->GetItemPool().FreezeIdRanges(); rtl::Reference<SdrPage> pPage(new SdrPage(*pModel, false)); - pPage->setSize({50_cm, 50_cm}); + pPage->setSize({ 50_cm, 50_cm }); pModel->InsertPage(pPage.get(), 0); { @@ -779,6 +779,46 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testResizeRect) CPPUNIT_ASSERT_EQUAL(tools::Rectangle(6, 6, 10, 10), aRectangle); } } + +CPPUNIT_TEST_FIXTURE(SvdrawTest, testRotatePoint2D) +{ + { + auto angle = 18000_deg100; + double angleRadians = toRadians(angle); + gfx::Tuple2DL aPoint(2_cm, 1_cm); + gfx::Tuple2DL aReference(1_cm, 1_cm); + aPoint + = svx::rotatePoint(aPoint, aReference, std::sin(angleRadians), std::cos(angleRadians)); + + CPPUNIT_ASSERT_EQUAL(0_cm, aPoint.getX()); + CPPUNIT_ASSERT_EQUAL(1_cm, aPoint.getY()); + } + + { + auto angle = 9000_deg100; + double angleRadians = toRadians(angle); + gfx::Tuple2DL aPoint(2_cm, 1_cm); + gfx::Tuple2DL aReference(1_cm, 1_cm); + aPoint + = svx::rotatePoint(aPoint, aReference, std::sin(angleRadians), std::cos(angleRadians)); + + CPPUNIT_ASSERT_EQUAL(1_cm, aPoint.getX()); + CPPUNIT_ASSERT_EQUAL(0_cm, aPoint.getY()); + } + + { + auto angle = 18000_deg100; + double angleRadians = toRadians(angle); + gfx::Tuple2DL aPoint(1_cm, 1_cm); + gfx::Tuple2DL aReference(2_cm, 2_cm); + aPoint + = svx::rotatePoint(aPoint, aReference, std::sin(angleRadians), std::cos(angleRadians)); + + CPPUNIT_ASSERT_EQUAL(3_cm, aPoint.getX()); + CPPUNIT_ASSERT_EQUAL(3_cm, aPoint.getY()); + } +} + } // end anonymous namespace /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx index f2df68068717..b3afdb9a5779 100644 --- a/svx/source/svdraw/svdotxtr.cxx +++ b/svx/source/svdraw/svdotxtr.cxx @@ -186,28 +186,50 @@ void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract SetBoundAndSnapRectsDirty(); } +namespace +{ + +gfx::Tuple2DL createTupleFromPoint(Point const& rPoint, gfx::LengthUnit eUnit = gfx::LengthUnit::hmm) +{ + auto x = gfx::Length::from(eUnit, rPoint.X()); + auto y = gfx::Length::from(eUnit, rPoint.Y()); + return gfx::Tuple2DL(x, y); +} + +} // end anonymous + + void SdrTextObj::NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs) { SetGlueReallyAbsolute(true); - tools::Rectangle aRectangle = getRectangle(); - tools::Long dx = aRectangle.Right() - aRectangle.Left(); - tools::Long dy = aRectangle.Bottom() - aRectangle.Top(); - Point aPoint1(aRectangle.TopLeft()); - RotatePoint(aPoint1, rRef, sn, cs); - Point aPoint2(aPoint1.X() + dx, aPoint1.Y() + dy); - aRectangle = tools::Rectangle(aPoint1, aPoint2); - setRectangle(aRectangle); + gfx::Tuple2DL aReference = createTupleFromPoint(rRef, getSdrModelFromSdrObject().getUnit()); - if (maGeo.nRotationAngle==0_deg100) { - maGeo.nRotationAngle=NormAngle36000(nAngle); - maGeo.mfSinRotationAngle=sn; - maGeo.mfCosRotationAngle=cs; - } else { - maGeo.nRotationAngle=NormAngle36000(maGeo.nRotationAngle+nAngle); + gfx::Length aWidth = maRectangleRange.getWidth(); + gfx::Length aHeight = maRectangleRange.getHeight(); + + gfx::Tuple2DL aPoint(maRectangleRange.getMinX(), maRectangleRange.getMinY()); + gfx::Tuple2DL aRotated = svx::rotatePoint(aPoint, aReference, sn, cs); + + maRectangleRange = gfx::Range2DLWrap( + aRotated.getX(), + aRotated.getY(), + aRotated.getX() + aWidth, + aRotated.getY() + aHeight); + + if (maGeo.nRotationAngle == 0_deg100) + { + maGeo.nRotationAngle = NormAngle36000(nAngle); + maGeo.mfSinRotationAngle = sn; + maGeo.mfCosRotationAngle = cs; + } + else + { + maGeo.nRotationAngle = NormAngle36000(maGeo.nRotationAngle + nAngle); maGeo.RecalcSinCos(); } + SetBoundAndSnapRectsDirty(); - NbcRotateGluePoints(rRef,nAngle,sn,cs); + NbcRotateGluePoints(rRef, nAngle, sn, cs); SetGlueReallyAbsolute(false); } diff --git a/svx/source/svdraw/svdtrans.cxx b/svx/source/svdraw/svdtrans.cxx index 04b02e9184c6..5afacc34dd9a 100644 --- a/svx/source/svdraw/svdtrans.cxx +++ b/svx/source/svdraw/svdtrans.cxx @@ -75,8 +75,24 @@ void resizeRange(gfx::Range2DLWrap& rRange, gfx::Tuple2DL const& rReference, dou rRange = gfx::Range2DLWrap(left, top, right, bottom, rRange.getUnit()); } +gfx::Tuple2DL rotatePoint(gfx::Tuple2DL const& rPoint, gfx::Tuple2DL const& rReference, double sinAngle, double cosAngle) +{ + gfx::Length dx = rPoint.getX() - rReference.getX(); + gfx::Length dy = rPoint.getY() - rReference.getY(); + gfx::Length x = rReference.getX() + dx * cosAngle + dy * sinAngle; + gfx::Length y = rReference.getY() + dy * cosAngle - dx * sinAngle; + return {x, y}; +} + } // end svx namespace +void RotatePoint(Point& rPnt, const Point& rRef, double sn, double cs) +{ + tools::Long dx=rPnt.X()-rRef.X(); + tools::Long dy=rPnt.Y()-rRef.Y(); + rPnt.setX(FRound(rRef.X()+dx*cs+dy*sn)); + rPnt.setY(FRound(rRef.Y()+dy*cs-dx*sn)); +} void ResizePoly(tools::Polygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact) { commit aa76f89a15dd6df4050acad71fd58dcbef8414b0 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Feb 21 22:05:02 2023 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Jun 14 01:23:57 2023 +0900 svx: change SdrObjGeoData aBoundRectangle using gfx::Range2DLWrap Change-Id: I13213ea2bdbfc5badb87d1bbd836192b8ae45e72 diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index 64a2ee1cee58..821ed552fb26 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -173,8 +173,20 @@ public: */ class SVXCORE_DLLPUBLIC SdrObjGeoData { +private: + gfx::Range2DLWrap maBoundRange; + public: - tools::Rectangle aBoundRect; + gfx::Range2DLWrap const& getBoundRange() const + { + return maBoundRange; + } + + void setBoundRange(gfx::Range2DLWrap const& rRange) + { + maBoundRange = rRange; + } + Point aAnchor; std::unique_ptr<SdrGluePointList> pGPL; @@ -185,7 +197,6 @@ public: bool mbVisible; SdrLayerID mnLayerID; -public: SdrObjGeoData(); virtual ~SdrObjGeoData(); }; @@ -416,6 +427,7 @@ public: // non-useful BoundRects sometimes) i rename that method from GetBoundRect() to // GetCurrentBoundRect(). virtual const tools::Rectangle& GetCurrentBoundRect() const; + virtual const gfx::Range2DLWrap& getCurrentBoundRange() const; // To have a possibility to get the last calculated BoundRect e.g for producing // the first rectangle for repaints (old and new need to be used) without forcing diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 8c3fea081c1b..30cf66ab3162 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -934,6 +934,13 @@ const tools::Rectangle& SdrObject::GetCurrentBoundRect() const return getOutRectangle(); } +const gfx::Range2DLWrap& SdrObject::getCurrentBoundRange() const +{ + if (m_aOutterRange.isEmpty()) + const_cast<SdrObject*>(this)->RecalcBoundRect(); + return m_aOutterRange; +} + // To have a possibility to get the last calculated BoundRect e.g for producing // the first rectangle for repaints (old and new need to be used) without forcing // a RecalcBoundRect (which may be problematical and expensive sometimes) I add here @@ -1868,7 +1875,7 @@ std::unique_ptr<SdrObjGeoData> SdrObject::NewGeoData() const void SdrObject::SaveGeoData(SdrObjGeoData& rGeo) const { - rGeo.aBoundRect =GetCurrentBoundRect(); + rGeo.setBoundRange(getCurrentBoundRange()); rGeo.aAnchor =m_aAnchor ; rGeo.bMovProt =m_bMovProt ; rGeo.bSizProt =m_bSizProt ; @@ -1892,7 +1899,7 @@ void SdrObject::SaveGeoData(SdrObjGeoData& rGeo) const void SdrObject::RestoreGeoData(const SdrObjGeoData& rGeo) { SetBoundAndSnapRectsDirty(); - setOutRectangle(rGeo.aBoundRect); + m_aOutterRange = rGeo.getBoundRange(); m_aAnchor =rGeo.aAnchor ; m_bMovProt =rGeo.bMovProt ; m_bSizProt =rGeo.bSizProt ; commit e8cf5a5b6e415ea3bcb7d35e6957158bfe6b7d7b Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Feb 10 18:10:33 2023 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Jun 14 01:23:57 2023 +0900 svx: refactor SdrObject resize to use m_aOutterRange directly Change-Id: I77aad10b32a53545c7f7bbf8fd87b914395a5bad diff --git a/include/svx/svdtrans.hxx b/include/svx/svdtrans.hxx index dea845a26bc1..e213d5f1ea61 100644 --- a/include/svx/svdtrans.hxx +++ b/include/svx/svdtrans.hxx @@ -29,6 +29,9 @@ #include <tools/mapunit.hxx> #include <tools/poly.hxx> +#include <basegfx/units/Range2DLWrap.hxx> +#include <basegfx/units/LengthTypes.hxx> + // That maximum shear angle constexpr Degree100 SDRMAXSHEAR(8900); @@ -39,6 +42,12 @@ inline void MovePoly(tools::Polygon& rPoly, const Size& S) { rPoly.Move(S.W void MoveXPoly(XPolygon& rPoly, const Size& S); SVXCORE_DLLPUBLIC void ResizeRect(tools::Rectangle& rRect, const Point& rRef, const Fraction& xFact, const Fraction& yFact); + +namespace svx +{ +SVXCORE_DLLPUBLIC void resizeRange(gfx::Range2DLWrap& rRange, gfx::Tuple2DL const& rReference, double fFactorX, double fFactorY); +} + inline void ResizePoint(Point& rPnt, const Point& rRef, const Fraction& xFract, const Fraction& yFract); void ResizePoly(tools::Polygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact); void ResizeXPoly(XPolygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact); diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx index 3710aa59802d..7022251f431c 100644 --- a/svx/qa/unit/svdraw.cxx +++ b/svx/qa/unit/svdraw.cxx @@ -7,7 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <test/unoapixml_test.hxx> +#include <basegfx/units/Length.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> @@ -38,6 +38,8 @@ #include <sdr/contact/objectcontactofobjlistpainter.hxx> +#include <test/unoapixml_test.hxx> + using namespace ::com::sun::star; namespace @@ -670,6 +672,7 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testRotatePoint) } } +<<<<<<< HEAD CPPUNIT_TEST_FIXTURE(SvdrawTest, testClipVerticalTextOverflow) { // File contains a slide with 4 rectangle shapes with text inside @@ -713,6 +716,69 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testClipVerticalTextOverflow) assertXPath(pDocument, "((//sdrblocktext)[7]//textsimpleportion)[1]", "x", "25417"); assertXPath(pDocument, "((//sdrblocktext)[7]//textsimpleportion)[3]", "x", "23893"); } + +CPPUNIT_TEST_FIXTURE(SvdrawTest, testResizeRect) +{ + { + tools::Rectangle aRectangle(1, 1, 10, 10); + Point aReference(1, 1); + ResizeRect(aRectangle, aReference, Fraction(1, 2), Fraction(1, 2)); + + CPPUNIT_ASSERT_EQUAL(tools::Rectangle(1, 1, 6, 6), aRectangle); + } + + { + tools::Rectangle aRectangle(1, 1, 10, 10); + Point aReference(10, 10); + ResizeRect(aRectangle, aReference, Fraction(1, 2), Fraction(1, 2)); + + CPPUNIT_ASSERT_EQUAL(tools::Rectangle(5, 5, 10, 10), aRectangle); + } + + { + gfx::Range2DLWrap aRange(1_hmm, 1_hmm, 10_hmm, 10_hmm); + CPPUNIT_ASSERT_EQUAL(9_hmm, aRange.getWidth()); + CPPUNIT_ASSERT_EQUAL(9_hmm, aRange.getHeight()); + + gfx::Tuple2DL aReference(1_hmm, 1_hmm); + svx::resizeRange(aRange, aReference, 0.5, 0.5); + + CPPUNIT_ASSERT_EQUAL(false, aRange.isEmpty()); + + CPPUNIT_ASSERT_EQUAL(1_hmm, aRange.getMinX()); + CPPUNIT_ASSERT_EQUAL(5.5_hmm, aRange.getMaxX()); + CPPUNIT_ASSERT_EQUAL(1_hmm, aRange.getMinY()); + CPPUNIT_ASSERT_EQUAL(5.5_hmm, aRange.getMaxY()); + + CPPUNIT_ASSERT_EQUAL(4.5_hmm, aRange.getWidth()); + CPPUNIT_ASSERT_EQUAL(4.5_hmm, aRange.getHeight()); + + auto aRectangle = aRange.toToolsRect(); + CPPUNIT_ASSERT_EQUAL(tools::Rectangle(1, 1, 6, 6), aRectangle); + } + + { + gfx::Range2DLWrap aRange(1_hmm, 1_hmm, 10_hmm, 10_hmm); + CPPUNIT_ASSERT_EQUAL(9_hmm, aRange.getWidth()); + CPPUNIT_ASSERT_EQUAL(9_hmm, aRange.getHeight()); + + gfx::Tuple2DL aReference(10_hmm, 10_hmm); + svx::resizeRange(aRange, aReference, 0.5, 0.5); + + CPPUNIT_ASSERT_EQUAL(false, aRange.isEmpty()); + + CPPUNIT_ASSERT_EQUAL(5.5_hmm, aRange.getMinX()); + CPPUNIT_ASSERT_EQUAL(10_hmm, aRange.getMaxX()); + CPPUNIT_ASSERT_EQUAL(5.5_hmm, aRange.getMinY()); + CPPUNIT_ASSERT_EQUAL(10_hmm, aRange.getMaxY()); + + CPPUNIT_ASSERT_EQUAL(4.5_hmm, aRange.getWidth()); + CPPUNIT_ASSERT_EQUAL(4.5_hmm, aRange.getHeight()); + + auto aRectangle = aRange.toToolsRect(); + CPPUNIT_ASSERT_EQUAL(tools::Rectangle(6, 6, 10, 10), aRectangle); + } +} } // end anonymous namespace /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 54f46199aab2..8c3fea081c1b 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -35,6 +35,7 @@ #include <basegfx/polygon/b2dpolypolygoncutter.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/units/Range2DLWrap.hxx> +#include <basegfx/units/LengthTypes.hxx> #include <basegfx/range/b2drange.hxx> #include <drawinglayer/processor2d/contourextractor2d.hxx> #include <drawinglayer/processor2d/linegeometryextractor2d.hxx> @@ -948,10 +949,8 @@ void SdrObject::RecalcBoundRect() if ((getSdrModelFromSdrObject().isLocked()) || utl::ConfigManager::IsFuzzing()) return; - auto const& rRectangle = getOutRectangle(); - // central new method which will calculate the BoundRect using primitive geometry - if (!rRectangle.IsEmpty()) + if (!isOutRectangleEmpty()) return; // Use view-independent data - we do not want any connections @@ -1406,24 +1405,32 @@ void SdrObject::NbcMove(const Size& rSize) void SdrObject::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { - bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); - bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); - if (bXMirr || bYMirr) { + bool bXMirror = (xFact.GetNumerator() < 0) != (xFact.GetDenominator() < 0); + bool bYMirror = (yFact.GetNumerator() < 0) != (yFact.GetDenominator() < 0); + if (bXMirror || bYMirror) + { Point aRef1(GetSnapRect().Center()); - if (bXMirr) { + if (bXMirror) + { Point aRef2(aRef1); aRef2.AdjustY( 1 ); - NbcMirrorGluePoints(aRef1,aRef2); + NbcMirrorGluePoints(aRef1, aRef2); } - if (bYMirr) { + if (bYMirror) + { Point aRef2(aRef1); aRef2.AdjustX( 1 ); - NbcMirrorGluePoints(aRef1,aRef2); + NbcMirrorGluePoints(aRef1, aRef2); } } - auto aRectangle = getOutRectangle(); - ResizeRect(aRectangle, rRef, xFact, yFact); - setOutRectangle(aRectangle); + + auto eUnit = getSdrModelFromSdrObject().getUnit(); + gfx::Tuple2DL aReference{ + gfx::Length::from(eUnit, rRef.X()), + gfx::Length::from(eUnit, rRef.Y())}; + double fFactorX = xFact.IsValid() ? double(xFact) : 1.0; + double fFactorY = yFact.IsValid() ? double(yFact) : 1.0; + svx::resizeRange(m_aOutterRange, aReference, fFactorX, fFactorY); SetBoundAndSnapRectsDirty(); } diff --git a/svx/source/svdraw/svdtrans.cxx b/svx/source/svdraw/svdtrans.cxx index ad44aa230e17..04b02e9184c6 100644 --- a/svx/source/svdraw/svdtrans.cxx +++ b/svx/source/svdraw/svdtrans.cxx @@ -61,6 +61,22 @@ void ResizeRect(tools::Rectangle& rRect, const Point& rRef, const Fraction& rxFa rRect.Normalize(); } +namespace svx +{ + +void resizeRange(gfx::Range2DLWrap& rRange, gfx::Tuple2DL const& rReference, double fFactorX, double fFactorY) +{ + auto left = rReference.getX() + ((rRange.getMinX() - rReference.getX()) * fFactorX); + auto right = rReference.getX() + ((rRange.getMaxX() - rReference.getX()) * fFactorX); + + auto top = rReference.getY() + ((rRange.getMinY() - rReference.getY()) * fFactorY); + auto bottom = rReference.getY() + ((rRange.getMaxY() - rReference.getY()) * fFactorY); + + rRange = gfx::Range2DLWrap(left, top, right, bottom, rRange.getUnit()); +} + +} // end svx namespace + void ResizePoly(tools::Polygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact) { commit 29f9c395ea18eec3bd4757407e0c2cc24049fa7e Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Feb 9 10:03:43 2023 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Jun 14 01:23:57 2023 +0900 use Range2DLWrap for the main rectangle in SdrTextObject Change-Id: I0d8ac090f9442fe561b4f87aa767185a987874c4 diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index d9c0908e505b..0dac8fe682a5 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -28,6 +28,7 @@ #include <tools/datetime.hxx> #include <svl/style.hxx> #include <svx/svdtext.hxx> +#include <svx/svdmodel.hxx> #include <svx/svxdllapi.h> #include <drawinglayer/primitive2d/Primitive2DContainer.hxx> #include <memory> @@ -165,31 +166,44 @@ protected: // The "aRect" is also the rect of RectObj and CircObj. // When mbTextFrame=true the text will be formatted into this rect // When mbTextFrame=false the text will be centered around its middle - tools::Rectangle maRectangle; + gfx::Range2DLWrap maRectangleRange; tools::Rectangle const& getRectangle() const { - return maRectangle; + return maRectangleRange.toToolsRect(); } void setRectangle(tools::Rectangle const& rRectangle) { - maRectangle = rRectangle; + auto eUnit = getSdrModelFromSdrObject().getUnit(); + maRectangleRange = gfx::Range2DLWrap::create(rRectangle, eUnit); } void setRectangleSize(sal_Int32 nWidth, sal_Int32 nHeight) { - maRectangle.SetSize(Size(nWidth, nHeight)); + auto eUnit = getSdrModelFromSdrObject().getUnit(); + auto width = gfx::Length::from(eUnit, nWidth); + auto height = gfx::Length::from(eUnit, nHeight); + maRectangleRange.setSize(width, height); } void moveRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta) { - maRectangle.Move(nXDelta, nYDelta); + if (nXDelta == 0 && nYDelta == 0) + return; + + auto eUnit = getSdrModelFromSdrObject().getUnit(); + auto xDelta = gfx::Length::from(eUnit, nXDelta); + auto yDelta = gfx::Length::from(eUnit, nYDelta); + maRectangleRange.shift(xDelta, yDelta); } void moveRectanglePosition(sal_Int32 nX, sal_Int32 nY) { - maRectangle.SetPos(Point(nX, nY)); + auto eUnit = getSdrModelFromSdrObject().getUnit(); + auto x = gfx::Length::from(eUnit, nX); + auto y = gfx::Length::from(eUnit, nY); + maRectangleRange.setPosition(x, y); } // The GeoStat contains the rotation and shear angles diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx index ab8bc58ddf85..020551bcdf5e 100644 --- a/svx/source/svdraw/svdocirc.cxx +++ b/svx/source/svdraw/svdocirc.cxx @@ -706,8 +706,9 @@ bool SdrCircObj::MovCreate(SdrDragStat& rStat) ImpSetCreateParams(rStat); ImpCircUser* pU=static_cast<ImpCircUser*>(rStat.GetUser()); rStat.SetActionRect(pU->aR); - setRectangle(pU->aR); // for ObjName - ImpJustifyRect(maRectangle); + auto aRectangle = pU->aR; + ImpJustifyRect(aRectangle); + setRectangle(aRectangle); // for ObjName nStartAngle=pU->nStart; nEndAngle=pU->nEnd; SetBoundRectDirty(); @@ -1048,8 +1049,9 @@ void SdrCircObj::NbcSetSnapRect(const tools::Rectangle& rRect) NbcResize(maSnapRect.TopLeft(),Fraction(nWdt1,nWdt0),Fraction(nHgt1,nHgt0)); NbcMove(Size(rRect.Left()-aSR0.Left(),rRect.Top()-aSR0.Top())); } else { - setRectangle(rRect); - ImpJustifyRect(maRectangle); + tools::Rectangle aRectangle(rRect); + ImpJustifyRect(aRectangle); + setRectangle(aRectangle); } SetBoundAndSnapRectsDirty(); SetXPolyDirty(); diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index a27e112d85cb..a4fc1b84ab6e 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -105,7 +105,7 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel, SdrTextObj const & rSource) // #i25616# mbSupportTextIndentingOnLineWidthChange = true; - maRectangle = rSource.maRectangle; + maRectangleRange = rSource.maRectangleRange; maGeo = rSource.maGeo; maTextSize = rSource.maTextSize; @@ -205,8 +205,6 @@ SdrTextObj::~SdrTextObj() void SdrTextObj::FitFrameToTextSize() { - ImpJustifyRect(maRectangle); - SdrText* pText = getActiveText(); if(pText==nullptr || !pText->GetOutlinerParaObject()) return; diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx index 1454bc52f946..f2df68068717 100644 --- a/svx/source/svdraw/svdotxtr.cxx +++ b/svx/source/svdraw/svdotxtr.cxx @@ -56,9 +56,9 @@ void SdrTextObj::NbcSetSnapRect(const tools::Rectangle& rRect) else { // No rotation or shear. - - setRectangle(rRect); - ImpJustifyRect(maRectangle); + tools::Rectangle aRectangle(rRect); + ImpJustifyRect(aRectangle); + setRectangle(aRectangle); AdaptTextMinSize(); @@ -74,8 +74,9 @@ const tools::Rectangle& SdrTextObj::GetLogicRect() const void SdrTextObj::NbcSetLogicRect(const tools::Rectangle& rRect) { - setRectangle(rRect); - ImpJustifyRect(maRectangle); + tools::Rectangle aRectangle(rRect); + ImpJustifyRect(aRectangle); + setRectangle(aRectangle); AdaptTextMinSize(); @@ -126,7 +127,7 @@ void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract setRectangle(aRectangle); if (bYMirr) { - maRectangle.Normalize(); + //maRectangle.Normalize(); moveRectangle(aRectangle.Right() - aRectangle.Left(), aRectangle.Bottom() - aRectangle.Top()); maGeo.nRotationAngle=18000_deg100; maGeo.RecalcSinCos(); @@ -174,8 +175,6 @@ void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract } } - ImpJustifyRect(maRectangle); - AdaptTextMinSize(); if(mbTextFrame && !getSdrModelFromSdrObject().IsPasteResize()) @@ -190,12 +189,13 @@ void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract void SdrTextObj::NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs) { SetGlueReallyAbsolute(true); - tools::Long dx = getRectangle().Right() - getRectangle().Left(); - tools::Long dy = getRectangle().Bottom() - getRectangle().Top(); - Point aPoint1(getRectangle().TopLeft()); + tools::Rectangle aRectangle = getRectangle(); + tools::Long dx = aRectangle.Right() - aRectangle.Left(); + tools::Long dy = aRectangle.Bottom() - aRectangle.Top(); + Point aPoint1(aRectangle.TopLeft()); RotatePoint(aPoint1, rRef, sn, cs); Point aPoint2(aPoint1.X() + dx, aPoint1.Y() + dy); - tools::Rectangle aRectangle(aPoint1, aPoint2); + aRectangle = tools::Rectangle(aPoint1, aPoint2); setRectangle(aRectangle); if (maGeo.nRotationAngle==0_deg100) { @@ -215,16 +215,17 @@ void SdrTextObj::NbcShear(const Point& rRef, Degree100 /*nAngle*/, double tn, bo { SetGlueReallyAbsolute(true); + auto aRectangle = getRectangle(); // when this is a SdrPathObj, aRect may be uninitialized - tools::Polygon aPol(Rect2Poly(getRectangle().IsEmpty() ? GetSnapRect() : getRectangle(), maGeo)); + tools::Polygon aPol(Rect2Poly(aRectangle.IsEmpty() ? GetSnapRect() : aRectangle, maGeo)); sal_uInt16 nPointCount=aPol.GetSize(); for (sal_uInt16 i=0; i<nPointCount; i++) { ShearPoint(aPol[i],rRef,tn,bVShear); } - tools::Rectangle aRectangle = svx::polygonToRectangle(aPol, maGeo); + aRectangle = svx::polygonToRectangle(aPol, maGeo); + ImpJustifyRect(aRectangle); setRectangle(aRectangle); - ImpJustifyRect(maRectangle); if (mbTextFrame) { NbcAdjustTextFrameWidthAndHeight(); @@ -245,7 +246,7 @@ void SdrTextObj::NbcMirror(const Point& rRef1, const Point& rRef2) std::abs(rRef1.X()-rRef2.X())==std::abs(rRef1.Y()-rRef2.Y()))) { bRotate90=maGeo.nRotationAngle.get() % 9000 ==0; } - tools::Polygon aPol(Rect2Poly(getRectangle(),maGeo)); + tools::Polygon aPol(Rect2Poly(getRectangle(), maGeo)); sal_uInt16 i; sal_uInt16 nPointCount=aPol.GetSize(); for (i=0; i<nPointCount; i++) { @@ -279,7 +280,6 @@ void SdrTextObj::NbcMirror(const Point& rRef1, const Point& rRef2) maGeo.RecalcTan(); } - ImpJustifyRect(maRectangle); if (mbTextFrame) { NbcAdjustTextFrameWidthAndHeight(); } diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index 25ab8715d307..b927bfbd2ebe 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -842,7 +842,7 @@ SdrTableObj::SdrTableObj(SdrModel& rSdrModel, SdrTableObj const & rSource) TableModelNotifyGuard aGuard( mpImpl.is() ? mpImpl->mxTable.get() : nullptr ); maLogicRect = rSource.maLogicRect; - maRectangle = rSource.maRectangle; + maRectangleRange = rSource.maRectangleRange; maGeo = rSource.maGeo; meTextKind = rSource.meTextKind; mbTextFrame = rSource.mbTextFrame; commit 817b21fdb789c00b03791b76dde7494ddacee7eb Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed Feb 8 10:42:19 2023 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Jun 14 01:23:56 2023 +0900 use Range2DLWrap for "OutRectangle" in SdrObject Change-Id: I243b44a84bc09991744009ae24ac7657d493c5cf diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index 54376b1f0397..64a2ee1cee58 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -34,6 +34,7 @@ #include <tools/gen.hxx> #include <unotools/resmgr.hxx> #include <unotools/weakref.hxx> +#include <basegfx/units/Range2DLWrap.hxx> #include <osl/diagnose.h> #include <typeinfo> @@ -884,13 +885,15 @@ public: void ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) const noexcept; protected: - const tools::Rectangle& getOutRectangle() const; + tools::Rectangle const& getOutRectangle() const; + bool isOutRectangleEmpty() const; void setOutRectangleConst(tools::Rectangle const& rRectangle) const; // need to do something about this void setOutRectangle(tools::Rectangle const& rRectangle); void resetOutRectangle(); void moveOutRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta); - mutable tools::Rectangle m_aOutRect; // surrounding rectangle for Paint (incl. LineWidth, ...) + mutable gfx::Range2DLWrap m_aOutterRange; // surrounding rectangle for Paint (incl. LineWidth, ...) + Point m_aAnchor; // anchor position (Writer) SdrObjUserCall* m_pUserCall; std::unique_ptr<SdrObjPlusData> diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx index 2c71ff99aa8f..de2c61bb40b5 100644 --- a/include/svx/svdpage.hxx +++ b/include/svx/svdpage.hxx @@ -399,6 +399,14 @@ public: tools::Long upperUnit() const { return maUpper.as(meUnit); } tools::Long lowerUnit() const { return maLower.as(meUnit); } + bool operator==(Border const& other) const + { + return maLeft == other.maLeft + && maRight == other.maRight + && maUpper == other.maUpper + && maLower == other.maLower; + } + tools::Rectangle toToolsRect() const { return tools::Rectangle(leftUnit(), upperUnit(), rightUnit(), lowerUnit()); @@ -589,10 +597,7 @@ public: return maBorder; } - virtual void setBorder(svx::Border const& rBorder) - { - maBorder = rBorder; - } + virtual void setBorder(svx::Border const& rBorder); virtual void SetBorder(sal_Int32 nLeft, sal_Int32 nUpper, sal_Int32 nRight, sal_Int32 Lower); virtual void SetLeftBorder(sal_Int32 nBorder); diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 03f9f0f95739..54f46199aab2 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -34,6 +34,7 @@ #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolypolygoncutter.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <basegfx/units/Range2DLWrap.hxx> #include <basegfx/range/b2drange.hxx> #include <drawinglayer/processor2d/contourextractor2d.hxx> #include <drawinglayer/processor2d/linegeometryextractor2d.hxx> @@ -927,13 +928,9 @@ void SdrObject::SetNavigationPosition (const sal_uInt32 nNewPosition) // GetCurrentBoundRect(). const tools::Rectangle& SdrObject::GetCurrentBoundRect() const { - auto const& rRectangle = getOutRectangle(); - if (rRectangle.IsEmpty()) - { - const_cast< SdrObject* >(this)->RecalcBoundRect(); - } - - return rRectangle; + if (isOutRectangleEmpty()) + const_cast<SdrObject*>(this)->RecalcBoundRect(); + return getOutRectangle(); } // To have a possibility to get the last calculated BoundRect e.g for producing @@ -971,13 +968,12 @@ void SdrObject::RecalcBoundRect() if (!aRange.isEmpty()) { - tools::Rectangle aNewRectangle( - tools::Long(floor(aRange.getMinX())), - tools::Long(floor(aRange.getMinY())), - tools::Long(ceil(aRange.getMaxX())), - tools::Long(ceil(aRange.getMaxY()))); - setOutRectangle(aNewRectangle); - return; + const basegfx::B2DRange aRoundedRange( + std::floor(aRange.getMinX()), + std::floor(aRange.getMinY()), + std::ceil(aRange.getMaxX()), + std::ceil(aRange.getMaxY())); + m_aOutterRange = gfx::Range2DLWrap::create(aRoundedRange, getSdrModelFromSdrObject().getUnit()); } } @@ -3138,27 +3134,41 @@ void SdrObject::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygo const tools::Rectangle& SdrObject::getOutRectangle() const { - return m_aOutRect; + return m_aOutterRange.toToolsRect(); +} + +bool SdrObject::isOutRectangleEmpty() const +{ + return getOutRectangle().IsEmpty(); } void SdrObject::setOutRectangleConst(tools::Rectangle const& rRectangle) const { - m_aOutRect = rRectangle; + auto eUnit = getSdrModelFromSdrObject().getUnit(); + m_aOutterRange = gfx::Range2DLWrap::create(rRectangle, eUnit); } void SdrObject::setOutRectangle(tools::Rectangle const& rRectangle) { - m_aOutRect = rRectangle; + auto eUnit = getSdrModelFromSdrObject().getUnit(); + m_aOutterRange = gfx::Range2DLWrap::create(rRectangle, eUnit); } void SdrObject::resetOutRectangle() { - m_aOutRect = tools::Rectangle(); + m_aOutterRange.reset(); } void SdrObject::moveOutRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta) { - m_aOutRect.Move(nXDelta, nYDelta); + if (nXDelta == 0 && nYDelta == 0) + return; + + auto eUnit = getSdrModelFromSdrObject().getUnit(); + auto xDelta = gfx::Length::from(eUnit, nXDelta); + auto yDelta = gfx::Length::from(eUnit, nYDelta); + + m_aOutterRange.shift(xDelta, yDelta); } E3dScene* DynCastE3dScene(SdrObject* pObj) diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index d3123eb1eb72..724a8ccf024e 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -1419,16 +1419,11 @@ rtl::Reference<SdrPage> SdrPage::CloneSdrPage(SdrModel& rTargetModel) const void SdrPage::setSize(gfx::Size2DLWrap const& rSize) { - bool bChanged = false; - - if (maSize != rSize) - { - maSize = rSize; - bChanged = true; - } + if (maSize == rSize) + return; - if (bChanged) - SetChanged(); + maSize = rSize; + SetChanged(); } void SdrPage::SetOrientation(Orientation eOri) @@ -1452,6 +1447,14 @@ Orientation SdrPage::GetOrientation() const return Orientation::Portrait; } +void SdrPage::setBorder(svx::Border const& rBorder) +{ + if (maBorder == rBorder) + return; + + maBorder = rBorder; + SetChanged(); +} void SdrPage::SetBorder(sal_Int32 nLeft, sal_Int32 nUpper, sal_Int32 nRight, sal_Int32 nLower) { diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index d1de10fa0a9e..3097cfa7f082 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -2434,10 +2434,8 @@ void SwDrawVirtObj::NbcSetAnchorPos(const Point& rPnt) const tools::Rectangle& SwDrawVirtObj::GetCurrentBoundRect() const { - if (getOutRectangle().IsEmpty()) - { + if (isOutRectangleEmpty()) const_cast<SwDrawVirtObj*>(this)->RecalcBoundRect(); - } return getOutRectangle(); } commit 92f221d0aa66134bc086d19f61f422487ef39b6a Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed Oct 26 20:21:37 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Jun 14 01:23:56 2023 +0900 svx: change PaperInfo to return gfx::Length paper sizes Change-Id: Ie99a748ab9282893a852278be9793f7379522541 diff --git a/editeng/source/items/paperinf.cxx b/editeng/source/items/paperinf.cxx index 86401e63f387..47dd992b4f02 100644 --- a/editeng/source/items/paperinf.cxx +++ b/editeng/source/items/paperinf.cxx @@ -39,6 +39,12 @@ Size SvxPaperInfo::GetPaperSize( Paper ePaper, MapUnit eUnit ) : OutputDevice::LogicToLogic(aRet, MapMode(MapUnit::Map100thMM), MapMode(eUnit)); } +gfx::Size2DLWrap SvxPaperInfo::getPaperSize(Paper ePaper) +{ + PaperInfo aInfo(ePaper); + return { gfx::Length::hmm(aInfo.getWidth()), gfx::Length::hmm(aInfo.getHeight()) }; +} + /*------------------------------------------------------------------------ Description: Return the paper size of the printer, aligned to our own sizes. If no Printer is set in the system, A4 portrait @@ -108,6 +114,12 @@ Size SvxPaperInfo::GetDefaultPaperSize( MapUnit eUnit ) : OutputDevice::LogicToLogic(aRet, MapMode(MapUnit::Map100thMM), MapMode(eUnit)); } +gfx::Size2DLWrap SvxPaperInfo::getDefaultPaperSize() +{ + PaperInfo aInfo(PaperInfo::getSystemDefaultPaper()); + return { gfx::Length::hmm(aInfo.getWidth()), gfx::Length::hmm(aInfo.getHeight()) }; +} + /*------------------------------------------------------------------------ Description: String representation for the SV-defines of paper size ------------------------------------------------------------------------*/ diff --git a/include/editeng/paperinf.hxx b/include/editeng/paperinf.hxx index 2ccc8fbf96fa..0d12100e5903 100644 --- a/include/editeng/paperinf.hxx +++ b/include/editeng/paperinf.hxx @@ -25,6 +25,7 @@ #include <tools/mapunit.hxx> #include <i18nutil/paper.hxx> #include <tools/gen.hxx> +#include <basegfx/units/Size2DLWrap.hxx> #include <editeng/editengdllapi.h> // forward --------------------------------------------------------------- @@ -42,6 +43,9 @@ public: static Paper GetSvxPaper( const Size &rSize, MapUnit eUnit ); static tools::Long GetSloppyPaperDimension( tools::Long nSize ); static OUString GetName( Paper ePaper ); + + static gfx::Size2DLWrap getPaperSize(Paper ePaper); + static gfx::Size2DLWrap getDefaultPaperSize(); }; // INLINE ----------------------------------------------------------------- diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx index 9e68f223d14d..2c71ff99aa8f 100644 --- a/include/svx/svdpage.hxx +++ b/include/svx/svdpage.hxx @@ -377,6 +377,13 @@ public: , meUnit(eUnit) {} + Border(gfx::Length const& nLeft, gfx::Length const& nUpper, gfx::Length const& nRight, gfx::Length const& nLower) + : maLeft(nLeft) + , maRight(nRight) + , maUpper(nUpper) + , maLower(nLower) + {} + gfx::Length const& left() const { return maLeft; } gfx::Length const& right() const { return maRight; } gfx::Length const& upper() const { return maUpper; } diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx index 924ed8474472..9ff7288e5be4 100644 --- a/sd/source/core/drawdoc2.cxx +++ b/sd/source/core/drawdoc2.cxx @@ -499,7 +499,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const * pRefDocument /* = return; // #i57181# Paper size depends on Language, like in Writer - Size aDefSize = SvxPaperInfo::GetDefaultPaperSize( MapUnit::Map100thMM ); + gfx::Size2DLWrap aDefaultSize = SvxPaperInfo::getDefaultPaperSize(); // Insert handout page rtl::Reference<SdPage> pHandoutPage = AllocSdPage(false); @@ -516,8 +516,8 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const * pRefDocument /* = } else { - pHandoutPage->setToolsSize(aDefSize); - pHandoutPage->SetBorder(0, 0, 0, 0); + pHandoutPage->setSize(aDefaultSize); + pHandoutPage->setBorder(svx::Border()); } pHandoutPage->SetPageKind(PageKind::Handout); @@ -553,7 +553,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const * pRefDocument /* = else if (meDocType == DocumentType::Draw) { // Draw: always use default size with margins - pPage->setToolsSize(aDefSize); + pPage->setSize(aDefaultSize); SfxPrinter* pPrinter = mpDocSh->GetPrinter(false); if (pPrinter && pPrinter->IsValid()) @@ -563,12 +563,12 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const * pRefDocument /* = aPageOffset -= pPrinter->PixelToLogic( Point() ); ::tools::Long nOffset = !aPageOffset.X() && !aPageOffset.Y() ? 0 : PRINT_OFFSET; - sal_uLong nTop = aPageOffset.Y(); - sal_uLong nLeft = aPageOffset.X(); - sal_uLong nBottom = std::max(::tools::Long(aDefSize.Height() - aOutSize.Height() - nTop + nOffset), ::tools::Long(0)); - sal_uLong nRight = std::max(::tools::Long(aDefSize.Width() - aOutSize.Width() - nLeft + nOffset), ::tools::Long(0)); + gfx::Length nTop = gfx::Length::hmm(aPageOffset.Y()); + gfx::Length nLeft = gfx::Length::hmm(aPageOffset.X()); + gfx::Length nBottom = gfx::Length::hmm(std::max(::tools::Long(aDefaultSize.getHeight().as_hmm() - aOutSize.Height() - aPageOffset.Y() + nOffset), tools::Long(0))); + gfx::Length nRight = gfx::Length::hmm(std::max(::tools::Long(aDefaultSize.getWidth().as_hmm() - aOutSize.Width() - aPageOffset.X() + nOffset), tools::Long(0))); - pPage->SetBorder(nLeft, nTop, nRight, nBottom); + pPage->setBorder(svx::Border(nLeft, nTop, nRight, nBottom)); } else { @@ -577,14 +577,14 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const * pRefDocument /* = // This has to be kept synchronized with the border // width set in the // SvxPageDescPage::PaperSizeSelect_Impl callback. - pPage->SetBorder(1000, 1000, 1000, 1000); + pPage->setBorder(svx::Border(1000_hmm, 1000_hmm, 1000_hmm, 1000_hmm)); } } else { // Impress: always use screen format, landscape. - Size aSize = SvxPaperInfo::GetPaperSize(PAPER_SCREEN_16_9, MapUnit::Map100thMM); - pPage->setToolsSize(Size(aSize.Height(), aSize.Width())); + gfx::Size2DLWrap aSize = SvxPaperInfo::getPaperSize(PAPER_SCREEN_16_9); + pPage->setSize({ aSize.getHeight(), aSize.getWidth() }); pPage->setBorder(svx::Border()); } @@ -619,16 +619,16 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const * pRefDocument /* = else { // Always use portrait format - if (aDefSize.Height() >= aDefSize.Width()) + if (aDefaultSize.getHeight() >= aDefaultSize.getWidth()) { - pNotesPage->setToolsSize(aDefSize); + pNotesPage->setSize(aDefaultSize); } else { - pNotesPage->setToolsSize(Size(aDefSize.Height(), aDefSize.Width())); + pNotesPage->setSize({ aDefaultSize.getHeight(), aDefaultSize.getWidth() }); } - pNotesPage->SetBorder(0, 0, 0, 0); + pNotesPage->setBorder(svx::Border()); } pNotesPage->SetPageKind(PageKind::Notes); InsertPage(pNotesPage.get(), 2); commit 175ee4c7745905f035ca9de04615d4b9647c2674 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Feb 2 19:22:23 2023 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Jun 14 01:23:48 2023 +0900 svx: change SdrPage size and border to use gfx::Length Change-Id: I382cfba6189eab02581057ab5af437cd1d163138 diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx index 1917e3ff4a56..80e14785b194 100644 --- a/basctl/source/dlged/dlged.cxx +++ b/basctl/source/dlged/dlged.cxx @@ -216,12 +216,13 @@ DlgEditor::DlgEditor ( aMarkIdle.SetInvokeHandler( LINK( this, DlgEditor, MarkTimeout ) ); rWindow.SetMapMode( MapMode( MapUnit::Map100thMM ) ); - pDlgEdPage->SetSize( rWindow.PixelToLogic( Size(DLGED_PAGE_WIDTH_MIN, DLGED_PAGE_HEIGHT_MIN) ) ); + Size aPageSize = rWindow.PixelToLogic(Size(DLGED_PAGE_WIDTH_MIN, DLGED_PAGE_HEIGHT_MIN)); + pDlgEdPage->setToolsSize(aPageSize); pDlgEdView->ShowSdrPage(pDlgEdView->GetModel().GetPage(0)); pDlgEdView->SetLayerVisible( "HiddenLayer", false ); pDlgEdView->SetMoveSnapOnlyTopLeft(true); - pDlgEdView->SetWorkArea( tools::Rectangle( Point( 0, 0 ), pDlgEdPage->GetSize() ) ); + pDlgEdView->SetWorkArea(pDlgEdPage->getRectangle().toToolsRect()); Size aGridSize( 100, 100 ); // 100TH_MM pDlgEdView->SetGridCoarse( aGridSize ); @@ -267,7 +268,7 @@ void DlgEditor::InitScrollBars() return; Size aOutSize = rWindow.GetOutDev()->GetOutputSize(); - Size aPgSize = pDlgEdPage->GetSize(); + Size aPgSize = pDlgEdPage->getSize().toToolsSize(); pHScroll->SetRange( Range( 0, aPgSize.Width() )); pVScroll->SetRange( Range( 0, aPgSize.Height() )); @@ -1218,11 +1219,11 @@ bool DlgEditor::AdjustPageSize() if ( pDlgEdPage ) { - Size aPageSize = pDlgEdPage->GetSize(); + Size aPageSize = pDlgEdPage->getSize().toToolsSize(); if ( nNewPageWidth != aPageSize.Width() || nNewPageHeight != aPageSize.Height() ) { Size aNewPageSize( nNewPageWidth, nNewPageHeight ); - pDlgEdPage->SetSize( aNewPageSize ); + pDlgEdPage->setToolsSize(aNewPageSize); pDlgEdView->SetWorkArea( tools::Rectangle( Point( 0, 0 ), aNewPageSize ) ); bAdjustedPageSize = true; } diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx index 1f4421d5ca43..cd7d1969f11c 100644 --- a/basctl/source/dlged/dlgedobj.cxx +++ b/basctl/source/dlged/dlgedobj.cxx @@ -419,7 +419,7 @@ void DlgEdObj::PositionAndSizeChange( const beans::PropertyChangeEvent& evt ) DBG_ASSERT( pDlgEdForm, "DlgEdObj::PositionAndSizeChange: no form!" ); DlgEdPage& rPage = pDlgEdForm->GetDlgEditor().GetPage(); { - Size aPageSize = rPage.GetSize(); + Size aPageSize = rPage.getSize().toToolsSize(); sal_Int32 nPageWidthIn = aPageSize.Width(); sal_Int32 nPageHeightIn = aPageSize.Height(); sal_Int32 nPageX, nPageY, nPageWidth, nPageHeight; @@ -1298,7 +1298,7 @@ void DlgEdForm::PositionAndSizeChange( const beans::PropertyChangeEvent& evt ) sal_Int32 nPageXIn = 0; sal_Int32 nPageYIn = 0; - Size aPageSize = rPage.GetSize(); + Size aPageSize = rPage.getSize().toToolsSize(); sal_Int32 nPageWidthIn = aPageSize.Width(); sal_Int32 nPageHeightIn = aPageSize.Height(); sal_Int32 nPageX, nPageY, nPageWidth, nPageHeight; @@ -1348,7 +1348,7 @@ void DlgEdForm::PositionAndSizeChange( const beans::PropertyChangeEvent& evt ) if ( bAdjustedPageSize ) { rEditor.InitScrollBars(); - aPageSize = rPage.GetSize(); + aPageSize = rPage.getSize().toToolsSize(); nPageWidthIn = aPageSize.Width(); nPageHeightIn = aPageSize.Height(); if ( TransformSdrToControlCoordinates( nPageXIn, nPageYIn, nPageWidthIn, nPageHeightIn, nPageX, nPageY, nPageWidth, nPageHeight ) ) diff --git a/basctl/source/dlged/dlgedview.cxx b/basctl/source/dlged/dlgedview.cxx index 81271d38f8bd..a9a6c821e480 100644 --- a/basctl/source/dlged/dlgedview.cxx +++ b/basctl/source/dlged/dlgedview.cxx @@ -90,7 +90,7 @@ void DlgEdView::MakeVisible( const tools::Rectangle& rRect, vcl::Window& rWin ) nScrollY -= nDeltaY; // don't scroll beyond the page size - Size aPageSize = rDlgEditor.GetPage().GetSize(); + Size aPageSize = rDlgEditor.GetPage().getSize().toToolsSize(); sal_Int32 nPageWidth = aPageSize.Width(); sal_Int32 nPageHeight = aPageSize.Height(); diff --git a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx index 0b3df1aa22ad..f90c781ee84e 100644 --- a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx +++ b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx @@ -149,7 +149,7 @@ Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, co pModel->GetItemPool().FreezeIdRanges(); rtl::Reference<SdrPage> pPage = new SdrPage( *pModel, false ); - pPage->SetSize(Size(1000,1000)); + pPage->setSize({ 1000_hmm, 1000_hmm }); pModel->InsertPage( pPage.get(), 0 ); SdrView aView(*pModel, pVDev); aView.hideMarkHandles(); diff --git a/chart2/source/controller/main/DrawCommandDispatch.cxx b/chart2/source/controller/main/DrawCommandDispatch.cxx index 935c0832d649..3a8be649e3cf 100644 --- a/chart2/source/controller/main/DrawCommandDispatch.cxx +++ b/chart2/source/controller/main/DrawCommandDispatch.cxx @@ -424,7 +424,7 @@ rtl::Reference<SdrObject> DrawCommandDispatch::createDefaultObject( const sal_uI if ( pObj ) { Size aObjectSize( 4000, 2500 ); - tools::Rectangle aPageRect( tools::Rectangle( Point( 0, 0 ), pPage->GetSize() ) ); + tools::Rectangle aPageRect(pPage->getRectangle().toToolsRect()); Point aObjectPos = aPageRect.Center(); aObjectPos.AdjustX( -(aObjectSize.Width() / 2) ); aObjectPos.AdjustY( -(aObjectSize.Height() / 2) ); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx ... etc. - the rest is truncated