diff options
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/qa/unit/data/MCGR_OldToNew.odg | bin | 0 -> 14577 bytes | |||
-rw-r--r-- | xmloff/qa/unit/data/MCGR_OldToNew_opacity.odg | bin | 0 -> 16806 bytes | |||
-rw-r--r-- | xmloff/qa/unit/data/MCGR_threeStops.fodt | 317 | ||||
-rw-r--r-- | xmloff/qa/unit/style.cxx | 206 | ||||
-rw-r--r-- | xmloff/source/core/xmltoken.cxx | 5 | ||||
-rw-r--r-- | xmloff/source/style/FillStyleContext.cxx | 165 | ||||
-rw-r--r-- | xmloff/source/style/FillStyleContext.hxx | 38 | ||||
-rw-r--r-- | xmloff/source/style/GradientStyle.cxx | 56 | ||||
-rw-r--r-- | xmloff/source/style/TransGradientStyle.cxx | 48 | ||||
-rw-r--r-- | xmloff/source/token/tokens.txt | 4 |
10 files changed, 811 insertions, 28 deletions
diff --git a/xmloff/qa/unit/data/MCGR_OldToNew.odg b/xmloff/qa/unit/data/MCGR_OldToNew.odg Binary files differnew file mode 100644 index 000000000000..7db627d0c23b --- /dev/null +++ b/xmloff/qa/unit/data/MCGR_OldToNew.odg diff --git a/xmloff/qa/unit/data/MCGR_OldToNew_opacity.odg b/xmloff/qa/unit/data/MCGR_OldToNew_opacity.odg Binary files differnew file mode 100644 index 000000000000..8b64a9037e73 --- /dev/null +++ b/xmloff/qa/unit/data/MCGR_OldToNew_opacity.odg diff --git a/xmloff/qa/unit/data/MCGR_threeStops.fodt b/xmloff/qa/unit/data/MCGR_threeStops.fodt new file mode 100644 index 000000000000..ac9c9978e299 --- /dev/null +++ b/xmloff/qa/unit/data/MCGR_threeStops.fodt @@ -0,0 +1,317 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:officeooo="http://openoffice.org/2009/office" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:meta><meta:initial-creator>Regina Henschel</meta:initial-creator><meta:creation-date>2023-04-18T23:09:21.434000000</meta:creation-date><dc:date>2023-04-18T23:28:52.397000000</dc:date><dc:creator>Regina Henschel</dc:creator><meta:editing-duration>PT9M47S</meta:editing-duration><meta:editing-cycles>3</meta:editing-cycles><meta:generator>B2020/7.6.0.0.alpha0$Windows_X86_64 LibreOffice_project/bcf20273b7036cae9b58d8f452933c0c8d0b8e47</meta:generator><meta:document-statistic meta:table-count="0" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="1" meta:word-count="1" meta:character-count="5" meta:non-whitespace-character-count="5"/></office:meta> + <office:settings> + <config:config-item-set config:name="ooo:view-settings"> + <config:config-item config:name="ViewAreaTop" config:type="long">0</config:config-item> + <config:config-item config:name="ViewAreaLeft" config:type="long">0</config:config-item> + <config:config-item config:name="ViewAreaWidth" config:type="long">27349</config:config-item> + <config:config-item config:name="ViewAreaHeight" config:type="long">9527</config:config-item> + <config:config-item config:name="ShowRedlineChanges" config:type="boolean">true</config:config-item> + <config:config-item config:name="InBrowseMode" config:type="boolean">false</config:config-item> + <config:config-item-map-indexed config:name="Views"> + <config:config-item-map-entry> + <config:config-item config:name="ViewId" config:type="string">view2</config:config-item> + <config:config-item config:name="ViewLeft" config:type="long">6562</config:config-item> + <config:config-item config:name="ViewTop" config:type="long">2501</config:config-item> + <config:config-item config:name="VisibleLeft" config:type="long">0</config:config-item> + <config:config-item config:name="VisibleTop" config:type="long">0</config:config-item> + <config:config-item config:name="VisibleRight" config:type="long">27347</config:config-item> + <config:config-item config:name="VisibleBottom" config:type="long">9525</config:config-item> + <config:config-item config:name="ZoomType" config:type="short">0</config:config-item> + <config:config-item config:name="ViewLayoutColumns" config:type="short">1</config:config-item> + <config:config-item config:name="ViewLayoutBookMode" config:type="boolean">false</config:config-item> + <config:config-item config:name="ZoomFactor" config:type="short">100</config:config-item> + <config:config-item config:name="IsSelectedFrame" config:type="boolean">true</config:config-item> + <config:config-item config:name="KeepRatio" config:type="boolean">false</config:config-item> + <config:config-item config:name="AnchoredTextOverflowLegacy" config:type="boolean">false</config:config-item> + <config:config-item config:name="LegacySingleLineFontwork" config:type="boolean">false</config:config-item> + <config:config-item config:name="ConnectorUseSnapRect" config:type="boolean">false</config:config-item> + <config:config-item config:name="IgnoreBreakAfterMultilineField" config:type="boolean">false</config:config-item> + </config:config-item-map-entry> + </config:config-item-map-indexed> + </config:config-item-set> + <config:config-item-set config:name="ooo:configuration-settings"> + <config:config-item config:name="AlignTabStopPosition" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrinterSetup" config:type="base64Binary"/> + <config:config-item config:name="AddParaTableSpacing" config:type="boolean">false</config:config-item> + <config:config-item config:name="IgnoreFirstLineIndentInNumbering" config:type="boolean">false</config:config-item> + <config:config-item config:name="TabAtLeftIndentForParagraphsInList" config:type="boolean">false</config:config-item> + <config:config-item config:name="IsKernAsianPunctuation" config:type="boolean">false</config:config-item> + <config:config-item config:name="ChartAutoUpdate" config:type="boolean">true</config:config-item> + <config:config-item config:name="LinkUpdateMode" config:type="short">1</config:config-item> + <config:config-item config:name="FieldAutoUpdate" config:type="boolean">true</config:config-item> + <config:config-item config:name="UnxForceZeroExtLeading" config:type="boolean">false</config:config-item> + <config:config-item config:name="UseOldNumbering" config:type="boolean">false</config:config-item> + <config:config-item config:name="AddParaTableSpacingAtStart" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrinterName" config:type="string"/> + <config:config-item config:name="InvertBorderSpacing" config:type="boolean">false</config:config-item> + <config:config-item config:name="RedlineProtectionKey" config:type="base64Binary"/> + <config:config-item config:name="UseFormerTextWrapping" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrinterPaperFromSetup" config:type="boolean">false</config:config-item> + <config:config-item config:name="BackgroundParaOverDrawings" config:type="boolean">false</config:config-item> + <config:config-item config:name="CurrentDatabaseCommand" config:type="string"/> + <config:config-item config:name="CharacterCompressionType" config:type="short">0</config:config-item> + <config:config-item config:name="DisableOffPagePositioning" config:type="boolean">false</config:config-item> + <config:config-item config:name="ApplyUserData" config:type="boolean">true</config:config-item> + <config:config-item config:name="SaveThumbnail" config:type="boolean">true</config:config-item> + <config:config-item config:name="SaveVersionOnClose" config:type="boolean">false</config:config-item> + <config:config-item config:name="StylesNoDefault" config:type="boolean">false</config:config-item> + <config:config-item config:name="SaveGlobalDocumentLinks" config:type="boolean">false</config:config-item> + <config:config-item config:name="CurrentDatabaseDataSource" config:type="string"/> + <config:config-item config:name="CurrentDatabaseCommandType" config:type="int">0</config:config-item> + <config:config-item config:name="EmbeddedDatabaseName" config:type="string"/> + <config:config-item config:name="UpdateFromTemplate" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrinterIndependentLayout" config:type="string">high-resolution</config:config-item> + <config:config-item config:name="IsLabelDocument" config:type="boolean">false</config:config-item> + <config:config-item config:name="ClippedPictures" config:type="boolean">false</config:config-item> + <config:config-item config:name="AddFrameOffsets" config:type="boolean">false</config:config-item> + <config:config-item config:name="AddVerticalFrameOffsets" config:type="boolean">false</config:config-item> + <config:config-item config:name="AddExternalLeading" config:type="boolean">true</config:config-item> + <config:config-item config:name="UnbreakableNumberings" config:type="boolean">false</config:config-item> + <config:config-item config:name="HeaderSpacingBelowLastPara" config:type="boolean">false</config:config-item> + <config:config-item config:name="TabsRelativeToIndent" config:type="boolean">true</config:config-item> + <config:config-item config:name="TableRowKeep" config:type="boolean">false</config:config-item> + <config:config-item config:name="OutlineLevelYieldsNumbering" config:type="boolean">false</config:config-item> + <config:config-item config:name="AllowPrintJobCancel" config:type="boolean">true</config:config-item> + <config:config-item config:name="TabOverflow" config:type="boolean">true</config:config-item> + <config:config-item config:name="UseFormerLineSpacing" config:type="boolean">false</config:config-item> + <config:config-item config:name="AddParaSpacingToTableCells" config:type="boolean">false</config:config-item> + <config:config-item config:name="DoNotCaptureDrawObjsOnPage" config:type="boolean">false</config:config-item> + <config:config-item config:name="ConsiderTextWrapOnObjPos" config:type="boolean">true</config:config-item> + <config:config-item config:name="AddParaLineSpacingToTableCells" config:type="boolean">false</config:config-item> + <config:config-item config:name="CollapseEmptyCellPara" config:type="boolean">true</config:config-item> + <config:config-item config:name="UseFormerObjectPositioning" config:type="boolean">false</config:config-item> + <config:config-item config:name="EmbedSystemFonts" config:type="boolean">false</config:config-item> + <config:config-item config:name="DoNotJustifyLinesWithManualBreak" config:type="boolean">true</config:config-item> + <config:config-item config:name="DoNotResetParaAttrsForNumFont" config:type="boolean">false</config:config-item> + <config:config-item config:name="FloattableNomargins" config:type="boolean">false</config:config-item> + <config:config-item config:name="IgnoreTabsAndBlanksForLineCalculation" config:type="boolean">false</config:config-item> + <config:config-item config:name="LoadReadonly" config:type="boolean">false</config:config-item> + <config:config-item config:name="ClipAsCharacterAnchoredWriterFlyFrames" config:type="boolean">false</config:config-item> + <config:config-item config:name="UseOldPrinterMetrics" config:type="boolean">false</config:config-item> + <config:config-item config:name="Rsid" config:type="int">447710</config:config-item> + <config:config-item config:name="RsidRoot" config:type="int">238319</config:config-item> + <config:config-item config:name="ProtectForm" config:type="boolean">false</config:config-item> + <config:config-item config:name="MsWordCompTrailingBlanks" config:type="boolean">false</config:config-item> + <config:config-item config:name="MsWordCompMinLineHeightByFly" config:type="boolean">false</config:config-item> + <config:config-item config:name="MathBaselineAlignment" config:type="boolean">true</config:config-item> + <config:config-item config:name="SmallCapsPercentage66" config:type="boolean">false</config:config-item> + <config:config-item config:name="EmbedFonts" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintDrawings" config:type="boolean">true</config:config-item> + <config:config-item config:name="EmbedComplexScriptFonts" config:type="boolean">true</config:config-item> + <config:config-item config:name="EmbedOnlyUsedFonts" config:type="boolean">false</config:config-item> + <config:config-item config:name="EmbedLatinScriptFonts" config:type="boolean">true</config:config-item> + <config:config-item config:name="EmbedAsianScriptFonts" config:type="boolean">true</config:config-item> + <config:config-item config:name="TabOverMargin" config:type="boolean">false</config:config-item> + <config:config-item config:name="ApplyParagraphMarkFormatToNumbering" config:type="boolean">false</config:config-item> + <config:config-item config:name="TabOverSpacing" config:type="boolean">false</config:config-item> + <config:config-item config:name="TreatSingleColumnBreakAsPageBreak" config:type="boolean">false</config:config-item> + <config:config-item config:name="SurroundTextWrapSmall" config:type="boolean">false</config:config-item> + <config:config-item config:name="PropLineSpacingShrinksFirstLine" config:type="boolean">true</config:config-item> + <config:config-item config:name="SubtractFlysAnchoredAtFlys" config:type="boolean">false</config:config-item> + <config:config-item config:name="EmptyDbFieldHidesPara" config:type="boolean">true</config:config-item> + <config:config-item config:name="ContinuousEndnotes" config:type="boolean">false</config:config-item> + <config:config-item config:name="ProtectBookmarks" config:type="boolean">false</config:config-item> + <config:config-item config:name="ProtectFields" config:type="boolean">false</config:config-item> + <config:config-item config:name="FrameAutowidthWithMorePara" config:type="boolean">false</config:config-item> + <config:config-item config:name="GutterAtTop" config:type="boolean">false</config:config-item> + <config:config-item config:name="FootnoteInColumnToPageEnd" config:type="boolean">true</config:config-item> + <config:config-item config:name="ImagePreferredDPI" config:type="int">0</config:config-item> + <config:config-item config:name="AutoFirstLineIndentDisregardLineSpace" config:type="boolean">true</config:config-item> + <config:config-item config:name="HyphenateURLs" config:type="boolean">false</config:config-item> + <config:config-item config:name="WordLikeWrapForAsCharFlys" config:type="boolean">false</config:config-item> + <config:config-item config:name="NoNumberingShowFollowBy" config:type="boolean">false</config:config-item> + <config:config-item config:name="DropCapPunctuation" config:type="boolean">true</config:config-item> + <config:config-item config:name="UseVariableWidthNBSP" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintAnnotationMode" config:type="short">0</config:config-item> + <config:config-item config:name="PrintPageBackground" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrintBlackFonts" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintControls" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrintLeftPages" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrintGraphics" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrintEmptyPages" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrintHiddenText" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintTextPlaceholder" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintProspect" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintProspectRTL" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintReversed" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintRightPages" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrintFaxName" config:type="string"/> + <config:config-item config:name="PrintPaperFromSetup" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintTables" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrintSingleJobs" config:type="boolean">false</config:config-item> + </config:config-item-set> + </office:settings> + <office:scripts> + <office:script script:language="ooo:Basic"> + <ooo:libraries xmlns:ooo="http://openoffice.org/2004/office" xmlns:xlink="http://www.w3.org/1999/xlink"> + <ooo:library-embedded ooo:name="Standard"/> + </ooo:libraries> + </office:script> + </office:scripts> + <office:font-face-decls> + <style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/> + <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Lucida Sans" svg:font-family="'Lucida Sans'" style:font-family-generic="swiss"/> + <style:font-face style:name="Lucida Sans1" svg:font-family="'Lucida Sans'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Microsoft YaHei" svg:font-family="'Microsoft YaHei'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="NSimSun" svg:font-family="NSimSun" style:font-family-generic="system" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + <draw:gradient draw:name="threeStops" draw:style="square" draw:cx="0%" draw:cy="50%" draw:start-color="#ff0000" draw:end-color="#ffff00" draw:start-intensity="100%" draw:end-intensity="100%" draw:angle="45deg" draw:border="10%"> + <loext:gradient-stop svg:offset="0" loext:color-type="rgb" loext:color-value="#ff0000"/> + <loext:gradient-stop svg:offset="0.3" loext:color-type="rgb" loext:color-value="#0099bb"/> + <loext:gradient-stop svg:offset="1" loext:color-type="rgb" loext:color-value="#ffff00"/></draw:gradient> + <style:default-style style:family="graphic"> + <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="3mm" draw:shadow-offset-y="3mm" draw:start-line-spacing-horizontal="2.83mm" draw:start-line-spacing-vertical="2.83mm" draw:end-line-spacing-horizontal="2.83mm" draw:end-line-spacing-vertical="2.83mm" style:writing-mode="lr-tb" style:flow-with-text="false"/> + <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" loext:tab-stop-distance="0mm" style:writing-mode="lr-tb" style:font-independent-line-spacing="false"> + <style:tab-stops/> + </style:paragraph-properties> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="NSimSun" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lucida Sans1" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/> + </style:default-style> + <style:default-style style:family="paragraph"> + <style:paragraph-properties fo:orphans="2" fo:widows="2" fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="12.51mm" style:writing-mode="lr-tb"/> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="NSimSun" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lucida Sans1" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" loext:hyphenation-no-caps="false" loext:hyphenation-no-last-word="false" loext:hyphenation-word-char-count="5" loext:hyphenation-zone="no-limit"/> + </style:default-style> + <style:default-style style:family="table"> + <style:table-properties table:border-model="collapsing"/> + </style:default-style> + <style:default-style style:family="table-row"> + <style:table-row-properties fo:keep-together="auto"/> + </style:default-style> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + <style:style style:name="Heading" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_20_body" style:class="text"> + <style:paragraph-properties fo:margin-top="4.23mm" fo:margin-bottom="2.12mm" style:contextual-spacing="false" fo:keep-with-next="always"/> + <style:text-properties style:font-name="Liberation Sans" fo:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable" fo:font-size="14pt" style:font-name-asian="Microsoft YaHei" style:font-family-asian="'Microsoft YaHei'" style:font-family-generic-asian="system" style:font-pitch-asian="variable" style:font-size-asian="14pt" style:font-name-complex="Lucida Sans1" style:font-family-complex="'Lucida Sans'" style:font-family-generic-complex="system" style:font-pitch-complex="variable" style:font-size-complex="14pt"/> + </style:style> + <style:style style:name="Text_20_body" style:display-name="Text body" style:family="paragraph" style:parent-style-name="Standard" style:class="text"> + <style:paragraph-properties fo:margin-top="0mm" fo:margin-bottom="2.47mm" style:contextual-spacing="false" fo:line-height="115%"/> + </style:style> + <style:style style:name="List" style:family="paragraph" style:parent-style-name="Text_20_body" style:class="list"> + <style:text-properties style:font-size-asian="12pt" style:font-name-complex="Lucida Sans" style:font-family-complex="'Lucida Sans'" style:font-family-generic-complex="swiss"/> + </style:style> + <style:style style:name="Caption" style:family="paragraph" style:parent-style-name="Standard" style:class="extra"> + <style:paragraph-properties fo:margin-top="2.12mm" fo:margin-bottom="2.12mm" style:contextual-spacing="false" text:number-lines="false" text:line-number="0"/> + <style:text-properties fo:font-size="12pt" fo:font-style="italic" style:font-size-asian="12pt" style:font-style-asian="italic" style:font-name-complex="Lucida Sans" style:font-family-complex="'Lucida Sans'" style:font-family-generic-complex="swiss" style:font-size-complex="12pt" style:font-style-complex="italic"/> + </style:style> + <style:style style:name="Index" style:family="paragraph" style:parent-style-name="Standard" style:class="index"> + <style:paragraph-properties text:number-lines="false" text:line-number="0"/> + <style:text-properties style:font-size-asian="12pt" style:font-name-complex="Lucida Sans" style:font-family-complex="'Lucida Sans'" style:font-family-generic-complex="swiss"/> + </style:style> + <text:outline-style style:name="Outline"> + <text:outline-level-style text:level="1" loext:num-list-format="%1%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="2" loext:num-list-format="%2%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="3" loext:num-list-format="%3%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="4" loext:num-list-format="%4%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="5" loext:num-list-format="%5%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="6" loext:num-list-format="%6%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="7" loext:num-list-format="%7%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="8" loext:num-list-format="%8%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="9" loext:num-list-format="%9%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="10" loext:num-list-format="%10%" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + </text:outline-style> + <text:notes-configuration text:note-class="footnote" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/> + <text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/> + <text:linenumbering-configuration text:number-lines="false" text:offset="4.99mm" style:num-format="1" text:number-position="left" text:increment="5"/> + <style:default-page-layout> + <style:page-layout-properties style:writing-mode="lr-tb" style:layout-grid-standard-mode="true"/> + </style:default-page-layout> + <loext:theme loext:name="Office"> + <loext:color-table loext:name="LibreOffice"> + <loext:color loext:name="dk1" loext:color="#000000"/> + <loext:color loext:name="lt1" loext:color="#ffffff"/> + <loext:color loext:name="dk2" loext:color="#000000"/> + <loext:color loext:name="lt2" loext:color="#ffffff"/> + <loext:color loext:name="accent1" loext:color="#18a303"/> + <loext:color loext:name="accent2" loext:color="#0369a3"/> + <loext:color loext:name="accent3" loext:color="#a33e03"/> + <loext:color loext:name="accent4" loext:color="#8e03a3"/> + <loext:color loext:name="accent5" loext:color="#c99c00"/> + <loext:color loext:name="accent6" loext:color="#c9211e"/> + <loext:color loext:name="hlink" loext:color="#0000ee"/> + <loext:color loext:name="folHlink" loext:color="#551a8b"/> + </loext:color-table> + </loext:theme> + </office:styles> + <office:automatic-styles> + <style:style style:name="P1" style:family="paragraph"> + <loext:graphic-properties draw:fill="gradient" draw:fill-gradient-name="threeStops" draw:gradient-step-count="64"/> + </style:style> + <style:style style:name="gr1" style:family="graphic"> + <style:graphic-properties draw:stroke="none" draw:fill="gradient" draw:fill-gradient-name="threeStops" draw:gradient-step-count="0" draw:textarea-horizontal-align="justify" draw:textarea-vertical-align="middle" draw:auto-grow-height="false" fo:min-height="40.02mm" fo:min-width="80.01mm" style:run-through="foreground" style:wrap="run-through" style:number-wrapped-paragraphs="no-limit" style:vertical-pos="from-top" style:vertical-rel="paragraph" style:horizontal-pos="from-left" style:horizontal-rel="paragraph" draw:wrap-influence-on-position="once-concurrent" loext:allow-overlap="true" style:flow-with-text="false"/> + </style:style> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="210.01mm" fo:page-height="148.01mm" style:num-format="1" style:print-orientation="landscape" fo:margin-top="20mm" fo:margin-bottom="20mm" fo:margin-left="20mm" fo:margin-right="20mm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="44" style:layout-grid-base-height="5.5mm" style:layout-grid-ruby-height="0mm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="true" style:layout-grid-display="true" style:layout-grid-base-width="3.7mm" style:layout-grid-snap-to="true" style:footnote-max-height="0mm" loext:margin-gutter="0mm"> + <style:footnote-sep style:width="0.18mm" style:distance-before-sep="1.01mm" style:distance-after-sep="1.01mm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style/> + </style:page-layout> + <style:style style:name="dp1" style:family="drawing-page"> + <style:drawing-page-properties draw:background-size="full"/> + </style:style> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1" draw:style-name="dp1"/> + </office:master-styles> + <office:body> + <office:text> + <text:sequence-decls> + <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> + <text:sequence-decl text:display-outline-level="0" text:name="Table"/> + <text:sequence-decl text:display-outline-level="0" text:name="Text"/> + <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> + <text:sequence-decl text:display-outline-level="0" text:name="Figure"/> + </text:sequence-decls> + <text:p text:style-name="Standard"><draw:custom-shape text:anchor-type="paragraph" draw:z-index="0" draw:name="Shape 1" draw:style-name="gr1" draw:text-style-name="P1" svg:width="80mm" svg:height="40.01mm" svg:x="39.71mm" svg:y="12.03mm"> + <text:p/> + <draw:enhanced-geometry svg:viewBox="0 0 21600 21600" draw:text-areas="0 0 21600 21600" draw:type="pentagon-right" draw:modifiers="10800" draw:enhanced-path="M 0 0 L ?f0 0 21600 10800 ?f0 21600 0 21600 Z N"> + <draw:equation draw:name="f0" draw:formula="$0 "/> + <draw:handle draw:handle-position="$0 top" draw:handle-range-x-minimum="0" draw:handle-range-x-maximum="21600"/> + </draw:enhanced-geometry> + </draw:custom-shape>Dummy</text:p> + </office:text> + </office:body> +</office:document>
\ No newline at end of file diff --git a/xmloff/qa/unit/style.cxx b/xmloff/qa/unit/style.cxx index 88e7177f3b91..9f67fb9d20d6 100644 --- a/xmloff/qa/unit/style.cxx +++ b/xmloff/qa/unit/style.cxx @@ -11,8 +11,13 @@ #include <test/unoapixml_test.hxx> -#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/awt/ColorStop.hpp> +#include <com/sun/star/awt/Gradient2.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/rendering/RGBColor.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <officecfg/Office/Common.hxx> @@ -25,6 +30,7 @@ class XmloffStyleTest : public UnoApiXmlTest { public: XmloffStyleTest(); + uno::Reference<drawing::XShape> getShape(sal_uInt8 nShapeIndex); }; XmloffStyleTest::XmloffStyleTest() @@ -32,6 +38,17 @@ XmloffStyleTest::XmloffStyleTest() { } +uno::Reference<drawing::XShape> XmloffStyleTest::getShape(sal_uInt8 nShapeIndex) +{ + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, + uno::UNO_QUERY_THROW); + uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages()); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(nShapeIndex), + uno::UNO_QUERY_THROW); + return xShape; +} + CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testFillImageBase64) { // Load a flat ODG that has base64-encoded bitmap as a fill style. @@ -310,6 +327,193 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelTopMargin) } } +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_OldToNew) +{ + // The file contains a shape with linear gradient fill from red #ff0000 to yellow #ffff00, + // named 'red2yellow' + loadFromURL(u"MCGR_OldToNew.odg"); + + // saveAndReload includes validation and must not fail with the new elements and attributes. + saveAndReload("draw8"); + + // Examine file markup + // For compatibilty the file should still have the old attributes 'start-color' and 'end-color' + xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + OString sPath = "/office:document-styles/office:styles/draw:gradient[@draw:name='red2yellow']"; + assertXPath(pXmlDoc, sPath, "start-color", "#ff0000"); + assertXPath(pXmlDoc, sPath, "end-color", "#ffff00"); + + // And it must have the new 'gradient-stop' elements. + // The prefix 'loext' needs to be adapted, when the element is available in ODF strict. + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "offset", "0"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "color-type", "rgb"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "color-value", "#ff0000"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "offset", "1"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "color-type", "rgb"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "color-value", "#ffff00"); + + // Examine reloaded file + uno::Reference<drawing::XShape> xShape(getShape(0)); + CPPUNIT_ASSERT(xShape.is()); + uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY); + + // The old properties need to be still available, as they might be used in macros. + OUString sGradientName; + xShapeProperties->getPropertyValue("FillGradientName") >>= sGradientName; + CPPUNIT_ASSERT_EQUAL(OUString(u"red2yellow"), sGradientName); + awt::Gradient2 aGradient; + xShapeProperties->getPropertyValue("FillGradient") >>= aGradient; + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF0000), aGradient.StartColor); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFF00), aGradient.EndColor); + + // Test new properties + auto aColorStopSeq = aGradient.ColorStops; + awt::ColorStop aColorStop = aColorStopSeq[0]; + CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopOffset); + CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopColor.Red); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Green); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Blue); + aColorStop = aColorStopSeq[1]; + CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopOffset); + CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopColor.Red); + CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopColor.Green); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Blue); +} + +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_OldToNew_opacity) +{ + // The file contains a shape with solid fill and a radial transparency gradient with start 90%, + // end 0%, border 20% and center at 50%|50%. There is only one draw:opacity element in file. + loadFromURL(u"MCGR_OldToNew_opacity.odg"); + + // saveAndReload includes validation and must not fail with the new elements and attributes. + saveAndReload("draw8"); + + // Examine file markup + // For compatibilty the file should still have the old attributes. + xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + OString sPath = "/office:document-styles/office:styles/draw:opacity"; + assertXPath(pXmlDoc, sPath, "start", "10%"); // UI 90% transparency + assertXPath(pXmlDoc, sPath, "end", "100%"); // UI 0% transparency + assertXPath(pXmlDoc, sPath, "border", "20%"); + assertXPath(pXmlDoc, sPath, "cx", "50%"); + assertXPath(pXmlDoc, sPath, "cy", "50%"); + assertXPath(pXmlDoc, sPath, "style", "radial"); + + // And it must have the new 'opacity-stop' elements. + // The prefix 'loext' needs to be adapted, when the element is available in ODF strict. + OString sFirstStop = sPath + "/loext:opacity-stop[1]"; + assertXPath(pXmlDoc, sFirstStop, "offset", "0"); + // Because of converting through color, the grade of opacity is not exact "0.1" + double fOpacity = getXPathContent(pXmlDoc, sFirstStop + "/@svg:stop-opacity").toDouble(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1, fOpacity, 0.002); + + assertXPath(pXmlDoc, sPath + "/loext:opacity-stop[2]", "offset", "1"); + assertXPath(pXmlDoc, sPath + "/loext:opacity-stop[2]", "stop-opacity", "1"); + + // Examine reloaded file + uno::Reference<drawing::XShape> xShape(getShape(0)); + CPPUNIT_ASSERT(xShape.is()); + uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY); + + // The old properties need to be still available, as they might be used in macros. + awt::Gradient2 aGradient; + xShapeProperties->getPropertyValue("FillTransparenceGradient") >>= aGradient; + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xE5E5E5), aGradient.StartColor); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aGradient.EndColor); + CPPUNIT_ASSERT_EQUAL(sal_Int16(20), aGradient.Border); + CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient.XOffset); + CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient.YOffset); + CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL, aGradient.Style); + + // Test new properties + auto aColorStopSeq = aGradient.ColorStops; + awt::ColorStop aColorStop = aColorStopSeq[0]; + CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopOffset); + // Rounding error because of converting through color: 90% => 0.9 * 255 => 229 + // 299.0 / 255.0 = 0.898039215686275 + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.9, aColorStop.StopColor.Red, 0.002); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.9, aColorStop.StopColor.Green, 0.002); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.9, aColorStop.StopColor.Blue, 0.002); + aColorStop = aColorStopSeq[1]; + CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopOffset); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Red); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Green); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Blue); +} + +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_threeStops) +{ + // The file contains a shape with square gradient fill from red #ff0000 over teal #0099bb to + // yellow #ffff00, named 'threeStops'. It has 45deg rotation, center 0%|50%, border 10%. + loadFromURL(u"MCGR_threeStops.fodt"); + + // saveAndReload includes validation and must not fail with the new elements and attributes. + saveAndReload("draw8"); + + // Examine file markup + // For compatibilty the file should still have the old attributes 'start-color' and 'end-color' + xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + OString sPath = "/office:document-styles/office:styles/draw:gradient[@draw:name='threeStops']"; + assertXPath(pXmlDoc, sPath, "start-color", "#ff0000"); + assertXPath(pXmlDoc, sPath, "end-color", "#ffff00"); + assertXPath(pXmlDoc, sPath, "style", "square"); + assertXPath(pXmlDoc, sPath, "cx", "0%"); + assertXPath(pXmlDoc, sPath, "cy", "50%"); + assertXPath(pXmlDoc, sPath, "angle", "45deg"); + assertXPath(pXmlDoc, sPath, "border", "10%"); + + // And it must have the new 'gradient-stop' elements. + // The prefix 'loext' needs to be adapted, when the element is available in ODF strict. + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "offset", "0"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "color-type", "rgb"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "color-value", "#ff0000"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "offset", "0.3"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "color-type", "rgb"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "color-value", "#0099bb"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[3]", "offset", "1"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[3]", "color-type", "rgb"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[3]", "color-value", "#ffff00"); + + // Examine reloaded file + uno::Reference<drawing::XShape> xShape(getShape(0)); + CPPUNIT_ASSERT(xShape.is()); + uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY); + + // The old properties need to be still available, as they might be used in macros. + OUString sGradientName; + xShapeProperties->getPropertyValue("FillGradientName") >>= sGradientName; + CPPUNIT_ASSERT_EQUAL(OUString(u"threeStops"), sGradientName); + awt::Gradient2 aGradient; + xShapeProperties->getPropertyValue("FillGradient") >>= aGradient; + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF0000), aGradient.StartColor); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFF00), aGradient.EndColor); + CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_SQUARE, aGradient.Style); + CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aGradient.XOffset); + CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient.YOffset); + CPPUNIT_ASSERT_EQUAL(sal_Int16(450), aGradient.Angle); + CPPUNIT_ASSERT_EQUAL(sal_Int16(10), aGradient.Border); + + // Test new properties + auto aColorStopSeq = aGradient.ColorStops; + awt::ColorStop aColorStop = aColorStopSeq[0]; + CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopOffset); + CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopColor.Red); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Green); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Blue); + aColorStop = aColorStopSeq[1]; + CPPUNIT_ASSERT_EQUAL(0.3, aColorStop.StopOffset); + // 0x99 = 153 => 153/255 = 0.6, 0xbb = 187 => 187/255 = 0.733... + CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Red); + CPPUNIT_ASSERT_EQUAL(0.6, aColorStop.StopColor.Green); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.733333333333333, aColorStop.StopColor.Blue, 0.0000001); + aColorStop = aColorStopSeq[2]; + CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopOffset); + CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopColor.Red); + CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopColor.Green); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Blue); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index b42aa9c43f42..30ea348588ce 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3522,6 +3522,11 @@ namespace xmloff::token { TOKEN("may-break-between-pages", XML_MAY_BREAK_BETWEEN_PAGES), + TOKEN("gradient-stop", XML_GRADIENT_STOP), + TOKEN("opacity-stop", XML_OPACITY_STOP), + TOKEN("color-value", XML_COLOR_VALUE), + TOKEN("color-type", XML_COLOR_TYPE), + #if OSL_DEBUG_LEVEL > 0 { 0, nullptr, std::nullopt, XML_TOKEN_END } #else diff --git a/xmloff/source/style/FillStyleContext.cxx b/xmloff/source/style/FillStyleContext.cxx index 8cd99a25b261..cae1bcd0313b 100644 --- a/xmloff/source/style/FillStyleContext.cxx +++ b/xmloff/source/style/FillStyleContext.cxx @@ -17,21 +17,31 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include "FillStyleContext.hxx" + +#include <TransGradientStyle.hxx> + +#include <com/sun/star/awt/ColorStop.hpp> +#include <com/sun/star/awt/Gradient2.hpp> +#include <com/sun/star/awt/XBitmap.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/graphic/XGraphic.hpp> -#include <com/sun/star/awt/XBitmap.hpp> -#include "FillStyleContext.hxx" +#include <com/sun/star/rendering/RGBColor.hpp> + +#include <comphelper/sequence.hxx> +#include <sax/tools/converter.hxx> #include <xmloff/xmlimp.hxx> #include <xmloff/GradientStyle.hxx> #include <xmloff/HatchStyle.hxx> #include <xmloff/ImageStyle.hxx> -#include <TransGradientStyle.hxx> #include <xmloff/MarkerStyle.hxx> #include <xmloff/DashStyle.hxx> #include <xmloff/xmlnamespace.hxx> #include <xmloff/xmltkmap.hxx> #include <xmloff/XMLBase64ImportContext.hxx> +#include <vector> + using namespace ::com::sun::star; @@ -48,10 +58,29 @@ XMLGradientStyleContext::~XMLGradientStyleContext() { } +css::uno::Reference<css::xml::sax::XFastContextHandler> XMLGradientStyleContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) +{ + if (nElement == XML_ELEMENT(LO_EXT, xmloff::token::XML_GRADIENT_STOP)) + return new XMLGradientStopContext(GetImport(), nElement, xAttrList, maColorStopVec); + + return nullptr; +} + void XMLGradientStyleContext::endFastElement(sal_Int32 ) { - uno::Reference< container::XNameContainer > xGradient( GetImport().GetGradientHelper() ); + // correcting invalid StopOffset values is done at the model. Therefore we import them here + // without any change. + if (!maColorStopVec.empty()) + { + awt::Gradient2 aGradient; + maAny >>= aGradient; + aGradient.ColorStops = comphelper::containerToSequence(maColorStopVec); + maAny <<= aGradient; + } + uno::Reference< container::XNameContainer > xGradient( GetImport().GetGradientHelper() ); try { if(xGradient.is()) @@ -75,6 +104,67 @@ bool XMLGradientStyleContext::IsTransient() const return true; } +XMLGradientStopContext::XMLGradientStopContext( + SvXMLImport& rImport, sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList >& xAttrList, + std::vector<awt::ColorStop>& rColorStopVec) +: SvXMLStyleContext(rImport) +{ + if(nElement != XML_ELEMENT(LO_EXT, xmloff::token::XML_GRADIENT_STOP)) + return; + + double fOffset = -1.0; + OUString sColorType; + OUString sColorValue; + // First collect all attributes + for (auto &aIter : sax_fastparser::castToFastAttributeList(xAttrList)) + { + switch(aIter.getToken()) + { + case XML_ELEMENT(SVG, xmloff::token::XML_OFFSET): // needed?? + case XML_ELEMENT(SVG_COMPAT, xmloff::token::XML_OFFSET): + if (!::sax::Converter::convertDouble(fOffset, aIter.toView())) + return; + break; + case XML_ELEMENT(LO_EXT, xmloff::token::XML_COLOR_VALUE): + sColorValue = aIter.toString(); + if (sColorValue.isEmpty()) + return; + break; + case XML_ELEMENT(LO_EXT, xmloff::token::XML_COLOR_TYPE): + sColorType = aIter.toString(); + if (sColorType.isEmpty()) + return; + break; + default: + XMLOFF_WARN_UNKNOWN("xmloff.style", aIter); + } + } + + // As of LO 7.6.0 only "rgb" is implemented. + if (sColorType != u"rgb") + return; + + // Type "rgb" requires kind color-value="#rrggbb". + ::Color aColor; + if (!::sax::Converter::convertColor(aColor, sColorValue)) + return; + + // All attribute values OK. Generate ColorStop. + css::rendering::RGBColor aRGBColor; + aRGBColor.Red = aColor.GetRed() / 255.0; + aRGBColor.Green = aColor.GetGreen() / 255.0; + aRGBColor.Blue = aColor.GetBlue() / 255.0; + + awt::ColorStop aColorStop; + aColorStop.StopOffset = fOffset; + aColorStop.StopColor = aRGBColor; + rColorStopVec.push_back(aColorStop); +} + +XMLGradientStopContext::~XMLGradientStopContext() +{ +} XMLHatchStyleContext::XMLHatchStyleContext( SvXMLImport& rImport, sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList) @@ -205,10 +295,30 @@ XMLTransGradientStyleContext::~XMLTransGradientStyleContext() { } +css::uno::Reference<css::xml::sax::XFastContextHandler> XMLTransGradientStyleContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) +{ + if (nElement == XML_ELEMENT(LO_EXT, xmloff::token::XML_OPACITY_STOP)) + return new XMLTransparencyStopContext(GetImport(), nElement, xAttrList, maColorStopVec); + + return nullptr; +} + void XMLTransGradientStyleContext::endFastElement(sal_Int32 ) { uno::Reference< container::XNameContainer > xTransGradient( GetImport().GetTransGradientHelper() ); + // correcting invalid StopOffset values is done at the model. Therefore we import them here + // without any change. + if (!maColorStopVec.empty()) + { + awt::Gradient2 aGradient; + maAny >>= aGradient; + aGradient.ColorStops = comphelper::containerToSequence(maColorStopVec); + maAny <<= aGradient; + } + try { if(xTransGradient.is()) @@ -232,6 +342,53 @@ bool XMLTransGradientStyleContext::IsTransient() const return true; } +XMLTransparencyStopContext::XMLTransparencyStopContext( + SvXMLImport& rImport, sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList >& xAttrList, + std::vector<awt::ColorStop>& rColorStopVec) +: SvXMLStyleContext(rImport) +{ + if(nElement != XML_ELEMENT(LO_EXT, xmloff::token::XML_OPACITY_STOP)) + return; + + double fOffset = -1.0; + css::rendering::RGBColor aRGBColor; // transparency is handled as gray color + for (auto &aIter : sax_fastparser::castToFastAttributeList(xAttrList)) + { + switch(aIter.getToken()) + { + case XML_ELEMENT(SVG, xmloff::token::XML_OFFSET): // needed?? + case XML_ELEMENT(SVG_COMPAT, xmloff::token::XML_OFFSET): + if (!::sax::Converter::convertDouble(fOffset, aIter.toView())) + return; + break; + case XML_ELEMENT(SVG, xmloff::token::XML_STOP_OPACITY): + case XML_ELEMENT(SVG_COMPAT, xmloff::token::XML_STOP_OPACITY): + { + double fOpacity = 1.0; + if (!::sax::Converter::convertDouble(fOpacity, aIter.toView())) + return; + // Transparency is gray, full transparent is (1|1|1). + double fGrayComponent = std::clamp<double>(1.0 - fOpacity, 0.0, 1.0); + aRGBColor.Red = fGrayComponent; + aRGBColor.Green = fGrayComponent; + aRGBColor.Blue = fGrayComponent; + } + break; + default: + XMLOFF_WARN_UNKNOWN("xmloff.style", aIter); + } + } + + awt::ColorStop aColorStop; + aColorStop.StopOffset = fOffset; + aColorStop.StopColor = aRGBColor; + rColorStopVec.push_back(aColorStop); +} + +XMLTransparencyStopContext::~XMLTransparencyStopContext() +{ +} XMLMarkerStyleContext::XMLMarkerStyleContext( SvXMLImport& rImport, sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList) diff --git a/xmloff/source/style/FillStyleContext.hxx b/xmloff/source/style/FillStyleContext.hxx index 3b17c29c8239..aee8f6d81038 100644 --- a/xmloff/source/style/FillStyleContext.hxx +++ b/xmloff/source/style/FillStyleContext.hxx @@ -19,9 +19,13 @@ #pragma once +#include <com/sun/star/awt/ColorStop.hpp> #include <com/sun/star/io/XOutputStream.hpp> #include <xmloff/xmlstyle.hxx> #include <rtl/ustring.hxx> +#include <sal/types.h> + +#include <vector> // draw:gradient context @@ -30,6 +34,7 @@ class XMLGradientStyleContext: public SvXMLStyleContext private: css::uno::Any maAny; OUString maStrName; + std::vector<css::awt::ColorStop> maColorStopVec; public: @@ -37,11 +42,27 @@ public: const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ); virtual ~XMLGradientStyleContext() override; + virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& AttrList) override; + virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; virtual bool IsTransient() const override; }; +class XMLGradientStopContext: public SvXMLStyleContext +{ +private: + +public: + + XMLGradientStopContext(SvXMLImport& rImport, sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList, + std::vector<css::awt::ColorStop>& rColorStopVec); + virtual ~XMLGradientStopContext() override; +}; + // draw:hatch context class XMLHatchStyleContext: public SvXMLStyleContext @@ -91,6 +112,7 @@ class XMLTransGradientStyleContext: public SvXMLStyleContext private: css::uno::Any maAny; OUString maStrName; + std::vector<css::awt::ColorStop> maColorStopVec; // Transparency is handled as color gray. public: @@ -98,11 +120,27 @@ public: const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ); virtual ~XMLTransGradientStyleContext() override; + virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& AttrList) override; + virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; virtual bool IsTransient() const override; }; +class XMLTransparencyStopContext: public SvXMLStyleContext +{ +private: + +public: + + XMLTransparencyStopContext(SvXMLImport& rImport, sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList, + std::vector<css::awt::ColorStop>& rColorStopVec); + virtual ~XMLTransparencyStopContext() override; +}; + // draw:marker context class XMLMarkerStyleContext: public SvXMLStyleContext diff --git a/xmloff/source/style/GradientStyle.cxx b/xmloff/source/style/GradientStyle.cxx index 81ccd84d2b55..9f2723078a89 100644 --- a/xmloff/source/style/GradientStyle.cxx +++ b/xmloff/source/style/GradientStyle.cxx @@ -19,22 +19,21 @@ #include <xmloff/GradientStyle.hxx> -#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/awt/Gradient2.hpp> -#include <sax/tools/converter.hxx> #include <comphelper/documentconstants.hxx> - -#include <xmloff/namespacemap.hxx> -#include <xmloff/xmluconv.hxx> -#include <xmloff/xmlnamespace.hxx> -#include <xmloff/xmltoken.hxx> #include <rtl/ustrbuf.hxx> #include <rtl/ustring.hxx> #include <sal/log.hxx> -#include <xmloff/xmltkmap.hxx> +#include <sax/tools/converter.hxx> +#include <xmloff/namespacemap.hxx> +#include <xmloff/xmlement.hxx> #include <xmloff/xmlexp.hxx> #include <xmloff/xmlimp.hxx> -#include <xmloff/xmlement.hxx> +#include <xmloff/xmlnamespace.hxx> +#include <xmloff/xmltkmap.hxx> +#include <xmloff/xmltoken.hxx> +#include <xmloff/xmluconv.hxx> using namespace ::com::sun::star; using namespace ::xmloff::token; @@ -64,7 +63,7 @@ void XMLGradientStyleImport::importXML( { OUString aDisplayName; - awt::Gradient aGradient; + awt::Gradient2 aGradient; aGradient.Style = css::awt::GradientStyle_LINEAR; aGradient.StartColor = 0; aGradient.EndColor = 0; @@ -158,7 +157,7 @@ void XMLGradientStyleExport::exportXML( const OUString& rStrName, const uno::Any& rValue ) { - awt::Gradient aGradient; + awt::Gradient2 aGradient; if( rStrName.isEmpty() ) return; @@ -230,9 +229,42 @@ void XMLGradientStyleExport::exportXML( aStrValue = aOut.makeStringAndClear(); rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_BORDER, aStrValue ); - // Do Write + // ctor writes start tag. End-tag is written by destructor at block end. SvXMLElementExport aElem( rExport, XML_NAMESPACE_DRAW, XML_GRADIENT, true, false ); + + // Write child elements <loext:gradient-stop> + // Do not export in standard ODF 1.3 or older. + if ((rExport.getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED) == 0) + return; + sal_Int32 nCount = aGradient.ColorStops.getLength(); + if (nCount == 0) + return; + + double fPreviousOffset = 0.0; + for (auto& aCandidate : aGradient.ColorStops) + { + // Attribute svg:offset. Make sure offsets are increasing. + double fOffset = std::clamp<double>(aCandidate.StopOffset, 0.0, 1.0); + if (fOffset < fPreviousOffset) + fOffset = fPreviousOffset; + rExport.AddAttribute(XML_NAMESPACE_SVG, XML_OFFSET, OUString::number(fOffset)); + fPreviousOffset = fOffset; + + // As of LO 7.6.0 only color-type="rgb" is implemented. + rExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_COLOR_TYPE, u"rgb"); + + // Attribute loext:color-value, data type color, that is #rrggbb. + rendering::RGBColor aDecimalColor = aCandidate.StopColor; + ::Color aToolsColor(std::clamp<sal_uInt8>(std::round(aDecimalColor.Red * 255.0), 0, 255), + std::clamp<sal_uInt8>(std::round(aDecimalColor.Green * 255.0), 0, 255), + std::clamp<sal_uInt8>(std::round(aDecimalColor.Blue * 255.0), 0, 255)); + rExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_COLOR_VALUE, + rtl::OUStringChar('#') + aToolsColor.AsRGBHexString()); + + // write gradient stop element + SvXMLElementExport aStopElement(rExport, XML_NAMESPACE_LO_EXT, XML_GRADIENT_STOP, true, true); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/style/TransGradientStyle.cxx b/xmloff/source/style/TransGradientStyle.cxx index 9b000c3eb448..d89348bbe0e8 100644 --- a/xmloff/source/style/TransGradientStyle.cxx +++ b/xmloff/source/style/TransGradientStyle.cxx @@ -19,22 +19,21 @@ #include <TransGradientStyle.hxx> -#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/awt/Gradient2.hpp> -#include <sax/tools/converter.hxx> #include <comphelper/documentconstants.hxx> - -#include <xmloff/namespacemap.hxx> -#include <xmloff/xmluconv.hxx> -#include <xmloff/xmlnamespace.hxx> #include <rtl/ustrbuf.hxx> #include <rtl/ustring.hxx> #include <sal/log.hxx> +#include <sax/tools/converter.hxx> #include <tools/color.hxx> -#include <xmloff/xmltkmap.hxx> +#include <xmloff/namespacemap.hxx> +#include <xmloff/xmlement.hxx> #include <xmloff/xmlexp.hxx> #include <xmloff/xmlimp.hxx> -#include <xmloff/xmlement.hxx> +#include <xmloff/xmlnamespace.hxx> +#include <xmloff/xmltkmap.hxx> +#include <xmloff/xmluconv.hxx> using namespace ::com::sun::star; @@ -65,7 +64,7 @@ void XMLTransGradientStyleImport::importXML( { OUString aDisplayName; - awt::Gradient aGradient; + awt::Gradient2 aGradient; aGradient.XOffset = 0; aGradient.YOffset = 0; aGradient.StartIntensity = 100; @@ -170,7 +169,7 @@ void XMLTransGradientStyleExport::exportXML( const OUString& rStrName, const uno::Any& rValue ) { - awt::Gradient aGradient; + awt::Gradient2 aGradient; if( rStrName.isEmpty() ) return; @@ -237,10 +236,37 @@ void XMLTransGradientStyleExport::exportXML( aStrValue = aOut.makeStringAndClear(); rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_BORDER, aStrValue ); - // Do Write + // ctor writes start tag. End-tag is written by destructor at block end. SvXMLElementExport rElem( rExport, XML_NAMESPACE_DRAW, XML_OPACITY, true, false ); + + // Write child elements <loext:opacity-stop> + // Do not export in standard ODF 1.3 or older. + if ((rExport.getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED) == 0) + return; + sal_Int32 nCount = aGradient.ColorStops.getLength(); + if (nCount == 0) + return; + double fPreviousOffset = 0.0; + for (auto& aCandidate : aGradient.ColorStops) + { + // Attribute svg:offset. Make sure offsets are increasing. + double fOffset = std::clamp<double>(aCandidate.StopOffset, 0.0, 1.0); + if (fOffset < fPreviousOffset) + fOffset = fPreviousOffset; + rExport.AddAttribute(XML_NAMESPACE_SVG, XML_OFFSET, OUString::number(fOffset)); + fPreviousOffset = fOffset; + + // Attribute svg:stop-opacity, data type zeroToOneDecimal + rendering::RGBColor aDecimalColor = aCandidate.StopColor; + // transparency is encoded as gray, 1.0 corresponds to full transparent + double fOpacity = std::clamp<double>(1.0 - aDecimalColor.Red, 0.0, 1.0); + rExport.AddAttribute(XML_NAMESPACE_SVG, XML_STOP_OPACITY, OUString::number(fOpacity)); + + // write opacity stop element + SvXMLElementExport aStopElement(rExport, XML_NAMESPACE_LO_EXT, XML_OPACITY_STOP, true, true); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt index 01b9515172e2..8a5615a0a790 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -3262,4 +3262,8 @@ alias tag fill-use-slide-background may-break-between-pages +gradient-stop +opacity-stop +color-value +color-type TOKEN_END_DUMMY |