summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2024-02-13 14:45:25 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2024-02-13 17:06:34 +0100
commit47f50af3f057bac1739b7d17d781c0b1d05faa95 (patch)
treecdee0bbd687f1b9422164e96f09d3dcd7f68dd24
parent625fa07d3399eb85d8f4bf4bf9ae1d11532b477c (diff)
tdf#155663 writerfilter: RTF import: don't lose \piccrop*
For DOCX the a:srcRect is imported in oox module in BlipFillContext and set on the XShape; obviously that doesn't work for RTF. The crop was already taken into account in RTFDocumentImpl::resolvePict(), but only to set the size of the picture; to actually set a crop effect, set shape's "GraphicsCrop" property in dmapper::GraphicImport::lcl_attribute(). Change-Id: Ib12853724744542a09b0073fefc42ad32bb2ff19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163310 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r--sw/qa/extras/rtfexport/data/piccrop.rtf74
-rw-r--r--sw/qa/extras/rtfexport/rtfexport8.cxx25
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx12
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx10
-rw-r--r--writerfilter/source/rtftok/rtfvalue.cxx9
-rw-r--r--writerfilter/source/rtftok/rtfvalue.hxx6
6 files changed, 134 insertions, 2 deletions
diff --git a/sw/qa/extras/rtfexport/data/piccrop.rtf b/sw/qa/extras/rtfexport/data/piccrop.rtf
new file mode 100644
index 000000000000..4e8a70420575
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/piccrop.rtf
@@ -0,0 +1,74 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31505\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1028\themelang1033\themelangfe1028\themelangcs1025{\fonttbl{\f1\fbidi \fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial{\*\falt Arial};}
+{\f14\fbidi \fnil\fcharset136\fprq2{\*\panose 02010601000101010101}PMingLiU{\*\falt Arial Unicode MS};}{\f34\fbidi \froman\fcharset0\fprq2{\*\panose 02040503050406030204}Cambria Math;}
+{\f37\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\f291\fbidi \fnil\fcharset136\fprq2{\*\panose 00000000000000000000}@PMingLiU;}
+{\flomajor\f31500\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Arial};}{\fdbmajor\f31501\fbidi \fnil\fcharset136\fprq2{\*\panose 02010601000101010101}PMingLiU{\*\falt Arial Unicode MS};}
+{\fhimajor\f31502\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0302020204030204}Calibri Light;}{\fbimajor\f31503\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Arial};}
+{\flominor\f31504\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Arial};}{\fdbminor\f31505\fbidi \fnil\fcharset136\fprq2{\*\panose 02010601000101010101}PMingLiU{\*\falt Arial Unicode MS};}
+{\fhiminor\f31506\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\fbiminor\f31507\fbidi \fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial{\*\falt Arial};}{\f302\fbidi \fswiss\fcharset238\fprq2 Arial CE{\*\falt Arial};}
+{\f303\fbidi \fswiss\fcharset204\fprq2 Arial Cyr{\*\falt Arial};}{\f305\fbidi \fswiss\fcharset161\fprq2 Arial Greek{\*\falt Arial};}{\f306\fbidi \fswiss\fcharset162\fprq2 Arial Tur{\*\falt Arial};}
+{\f307\fbidi \fswiss\fcharset177\fprq2 Arial (Hebrew){\*\falt Arial};}{\f308\fbidi \fswiss\fcharset178\fprq2 Arial (Arabic){\*\falt Arial};}{\f309\fbidi \fswiss\fcharset186\fprq2 Arial Baltic{\*\falt Arial};}
+{\f310\fbidi \fswiss\fcharset163\fprq2 Arial (Vietnamese){\*\falt Arial};}{\f632\fbidi \froman\fcharset238\fprq2 Cambria Math CE;}{\f633\fbidi \froman\fcharset204\fprq2 Cambria Math Cyr;}{\f635\fbidi \froman\fcharset161\fprq2 Cambria Math Greek;}
+{\f636\fbidi \froman\fcharset162\fprq2 Cambria Math Tur;}{\f639\fbidi \froman\fcharset186\fprq2 Cambria Math Baltic;}{\f640\fbidi \froman\fcharset163\fprq2 Cambria Math (Vietnamese);}{\f662\fbidi \fswiss\fcharset238\fprq2 Calibri CE;}
+{\f663\fbidi \fswiss\fcharset204\fprq2 Calibri Cyr;}{\f665\fbidi \fswiss\fcharset161\fprq2 Calibri Greek;}{\f666\fbidi \fswiss\fcharset162\fprq2 Calibri Tur;}{\f667\fbidi \fswiss\fcharset177\fprq2 Calibri (Hebrew);}
+{\f668\fbidi \fswiss\fcharset178\fprq2 Calibri (Arabic);}{\f669\fbidi \fswiss\fcharset186\fprq2 Calibri Baltic;}{\f670\fbidi \fswiss\fcharset163\fprq2 Calibri (Vietnamese);}
+{\flomajor\f31508\fbidi \froman\fcharset238\fprq2 Times New Roman CE{\*\falt Arial};}{\flomajor\f31509\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt Arial};}
+{\flomajor\f31511\fbidi \froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Arial};}{\flomajor\f31512\fbidi \froman\fcharset162\fprq2 Times New Roman Tur{\*\falt Arial};}
+{\flomajor\f31513\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew){\*\falt Arial};}{\flomajor\f31514\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic){\*\falt Arial};}
+{\flomajor\f31515\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Arial};}{\flomajor\f31516\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese){\*\falt Arial};}{\fhimajor\f31528\fbidi \fswiss\fcharset238\fprq2 Calibri Light CE;}
+{\fhimajor\f31529\fbidi \fswiss\fcharset204\fprq2 Calibri Light Cyr;}{\fhimajor\f31531\fbidi \fswiss\fcharset161\fprq2 Calibri Light Greek;}{\fhimajor\f31532\fbidi \fswiss\fcharset162\fprq2 Calibri Light Tur;}
+{\fhimajor\f31533\fbidi \fswiss\fcharset177\fprq2 Calibri Light (Hebrew);}{\fhimajor\f31534\fbidi \fswiss\fcharset178\fprq2 Calibri Light (Arabic);}{\fhimajor\f31535\fbidi \fswiss\fcharset186\fprq2 Calibri Light Baltic;}
+{\fhimajor\f31536\fbidi \fswiss\fcharset163\fprq2 Calibri Light (Vietnamese);}{\fbimajor\f31538\fbidi \froman\fcharset238\fprq2 Times New Roman CE{\*\falt Arial};}{\fbimajor\f31539\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt Arial};}
+{\fbimajor\f31541\fbidi \froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Arial};}{\fbimajor\f31542\fbidi \froman\fcharset162\fprq2 Times New Roman Tur{\*\falt Arial};}
+{\fbimajor\f31543\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew){\*\falt Arial};}{\fbimajor\f31544\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic){\*\falt Arial};}
+{\fbimajor\f31545\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Arial};}{\fbimajor\f31546\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese){\*\falt Arial};}
+{\flominor\f31548\fbidi \froman\fcharset238\fprq2 Times New Roman CE{\*\falt Arial};}{\flominor\f31549\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt Arial};}
+{\flominor\f31551\fbidi \froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Arial};}{\flominor\f31552\fbidi \froman\fcharset162\fprq2 Times New Roman Tur{\*\falt Arial};}
+{\flominor\f31553\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew){\*\falt Arial};}{\flominor\f31554\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic){\*\falt Arial};}
+{\flominor\f31555\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Arial};}{\flominor\f31556\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese){\*\falt Arial};}{\fhiminor\f31568\fbidi \fswiss\fcharset238\fprq2 Calibri CE;}
+{\fhiminor\f31569\fbidi \fswiss\fcharset204\fprq2 Calibri Cyr;}{\fhiminor\f31571\fbidi \fswiss\fcharset161\fprq2 Calibri Greek;}{\fhiminor\f31572\fbidi \fswiss\fcharset162\fprq2 Calibri Tur;}
+{\fhiminor\f31573\fbidi \fswiss\fcharset177\fprq2 Calibri (Hebrew);}{\fhiminor\f31574\fbidi \fswiss\fcharset178\fprq2 Calibri (Arabic);}{\fhiminor\f31575\fbidi \fswiss\fcharset186\fprq2 Calibri Baltic;}
+{\fhiminor\f31576\fbidi \fswiss\fcharset163\fprq2 Calibri (Vietnamese);}{\fbiminor\f31578\fbidi \fswiss\fcharset238\fprq2 Arial CE{\*\falt Arial};}{\fbiminor\f31579\fbidi \fswiss\fcharset204\fprq2 Arial Cyr{\*\falt Arial};}
+{\fbiminor\f31581\fbidi \fswiss\fcharset161\fprq2 Arial Greek{\*\falt Arial};}{\fbiminor\f31582\fbidi \fswiss\fcharset162\fprq2 Arial Tur{\*\falt Arial};}{\fbiminor\f31583\fbidi \fswiss\fcharset177\fprq2 Arial (Hebrew){\*\falt Arial};}
+{\fbiminor\f31584\fbidi \fswiss\fcharset178\fprq2 Arial (Arabic){\*\falt Arial};}{\fbiminor\f31585\fbidi \fswiss\fcharset186\fprq2 Arial Baltic{\*\falt Arial};}{\fbiminor\f31586\fbidi \fswiss\fcharset163\fprq2 Arial (Vietnamese){\*\falt Arial};}
+{\f292\fbidi \froman\fcharset238\fprq2 Times New Roman CE{\*\falt Arial};}{\f293\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt Arial};}{\f295\fbidi \froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Arial};}
+{\f296\fbidi \froman\fcharset162\fprq2 Times New Roman Tur{\*\falt Arial};}{\f297\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew){\*\falt Arial};}{\f298\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic){\*\falt Arial};}
+{\f299\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Arial};}{\f300\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese){\*\falt Arial};}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;
+\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;
+\red128\green128\blue128;\red192\green192\blue192;}{\*\defchp \fs22\loch\af31506\hich\af31506\dbch\af31505 }{\*\defpap \ql \li0\ri0\sa160\sl259\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 }\noqfpromote {\stylesheet{
+\ql \li0\ri0\sa160\sl259\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \fs22\lang1033\langfe1028\loch\f31506\hich\af31506\dbch\af31505\cgrid\langnp1033\langfenp1028
+\snext0 \sqformat \spriority0 Normal;}{\*\cs10 \additive \ssemihidden \sunhideused \spriority1 Default Paragraph Font;}{\*
+\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblind0\tblindtype3\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv \ql \li0\ri0\sa160\sl259\slmult1
+\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \fs22\lang1033\langfe1028\loch\f31506\hich\af31506\dbch\af31505\cgrid\langnp1033\langfenp1028 \snext11 \ssemihidden \sunhideused
+Normal Table;}}{\*\rsidtbl \rsid1539605\rsid6818220\rsid9513591}{\mmathPr\mmathFont34\mbrkBin0\mbrkBinSub0\msmallFrac0\mdispDef1\mlMargin0\mrMargin0\mdefJc1\mwrapIndent1440\mintLim0\mnaryLim1}{\info{\author ms}{\operator ms}
+{\creatim\yr2024\mo2\dy13\hr14\min53}{\revtim\yr2024\mo2\dy13\hr14\min57}{\version1}{\edmins4}{\nofpages1}{\nofwords0}{\nofchars1}{\nofcharsws1}{\vern57435}}{\*\xmlnstbl {\xmlns1 http://schemas.microsoft.com/office/word/2003/wordml}}
+\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440\gutter0\ltrsect
+\widowctrl\ftnbj\aenddoc\trackmoves0\trackformatting1\donotembedsysfont1\relyonvml0\donotembedlingdata0\grfdocevents0\validatexml1\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0\showxmlerrors1\noxlattoyen
+\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1440\dgvorigin1440\dghshow1\dgvshow1
+\jexpand\viewkind1\viewscale100\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct
+\asianbrkrule\rsidroot1539605\newtblstyruls\nogrowautofit\usenormstyforlist\noindnmbrts\felnbrelev\nocxsptable\indrlsweleven\noafcnsttbl\afelev\utinl\hwelev\spltpgpar\notcvasp\notbrkcnstfrctbl\notvatxbx\krnprsnet\cachedcolbal \nouicompat \fet0
+{\*\wgrffmtfilter 2450}\nofeaturethrottle1\ilfomacatclnup0\ltrpar \sectd \ltrsect\linex0\headery708\footery708\colsx708\endnhere\sectlinegrid360\sectdefaultcl\sftnbj
+\pard\plain \ltrpar\ql \li0\ri0\sa160\sl259\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0
+\fs22\lang1033\langfe1028\loch\af31506\hich\af31506\dbch\af31505\cgrid\langnp1033\langfenp1028 {\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1024\langfe1024\noproof\insrsid9513591\charrsid4597901 {\*\shppict
+{\pict{\*\picprop\shplid1025{\sp{\sn shapeType}{\sv 75}}{\sp{\sn fFlipH}{\sv 0}}{\sp{\sn fFlipV}{\sv 0}}{\sp{\sn fLockAspectRatio}{\sv 1}}{\sp{\sn fLockPosition}{\sv 0}}{\sp{\sn fLockAgainstSelect}{\sv 0}}{\sp{\sn fLockAgainstGrouping}{\sv 0}}
+{\sp{\sn pictureGray}{\sv 0}}{\sp{\sn pictureBiLevel}{\sv 0}}{\sp{\sn fFilled}{\sv 0}}{\sp{\sn fLine}{\sv 0}}{\sp{\sn wzName}{\sv Picture 1}}{\sp{\sn dhgt}{\sv 251658240}}{\sp{\sn fHidden}{\sv 0}}{\sp{\sn fLayoutInCell}{\sv 1}}}
+\picscalex780\picscaley780\piccropl70\piccropr70\piccropt70\piccropb70\picw503\pich503\picwgoal285\pichgoal285\pngblip\bliptag-2138324634{\*\blipuid 808bc16643ef1085bdc9d6183a9f49dc}
+89504e470d0a1a0a0000000d4948445200000013000000130806000000725036cc0000000467414d410000d6d8d44f58320000001974455874536f6674776172
+650041646f626520496d616765526561647971c9653c000001694944415478da62fcffff3f03b50040003111a3e8e3646ba26c04082026620ce2bf720cc5c049
+eb57fe076174b50001c4448c41479f3232201bd83b733356f50001c4448c4120806e20360010404cc418c4d1b81dc5c04bdef7192e5d7a8da10f208098883148
+53d312c3c05ea1e518860104101331067171f1613510ddcb0001c4448c4120408c810001c4084ab4f80cfaf6ed13dc6618fffaf5e30c3fea3dc162d6d240fd3a
+560cfcb9471901028809dda0a83f5128068134e6752f02d3203ecc852075e82e040820963b56750c0c5640d700258c8ddd195d1ba7fc87790d64c0f42db71926
+95c6810dcc84a8011be86a69c1605dbf84f1ecd99dffcf425d0e10400c206f22e3e486c9ff41e0ebd78fff416c108d8d0f5587a2172080f0e680ddc74fa04400
+888f0f000410130315014000b160130405f48f1f5fb16ac0250e02000184d53050c0e302f7ef5fc229071040580d03c5200cc87bc4e09443070001c448cd921620c000313009ee012707180000000049454e44ae426082}}{\nonshppict
+{\pict\picscalex781\picscaley790\piccropl70\piccropr70\piccropt70\piccropb70\picw503\pich503\picwgoal285\pichgoal285\wmetafile8\bliptag-2138324634{\*\blipuid 808bc16643ef1085bdc9d6183a9f49dc}
+010009000003370100000000b300000000000400000003010800050000000b0200000000050000000c0214001400030000001e00040000000701040004000000
+070104000800000026060f000600544e505006014b000000410b8600ee0013001300000000001300130000000000280000001300000013000000010001000000
+0000000000000000000000000000000000000000000000000000ffffff000000000c0ffe000c0ffe00000ffe00000ffe00000ffe00000ffe0000effee000ffff
+e0007fffc0003fff80001fff00000ffe000507fe000003fe000c01f6000c00e600000040000000000000b3000000410bc6008800130013000000000013001300
+000000002800000013000000130000000100040000000000000000000000000000000000000000000000000000000000ffffff004ba1f3000078ff00b5baa000
+035dcd006d592c00c3d4d400a2907500f3f7f700eaf0f00000000000000000000000000000000000000000001111111111111111111001011111888666668881
+11100101111187761116778111100801111189a61116a98111100706111181961116918111100100111181961116918111100106111181989198918111100101
+77718117898711817770080123556919787919655320090612355791999197553210010011235579111975532110090811123557919755321110070111112355
+797553211110080111111235575532811110010911111123555326411110024c1111111235321641111009011111111123211441111002031111111112111111111005031111111111111111111005070800000026060f000600544e50500701040000002701ffff030000000000}}}{\rtlch\fcs1 \af31507
+\ltrch\fcs0 \insrsid6818220
+\par }
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport8.cxx b/sw/qa/extras/rtfexport/rtfexport8.cxx
index 6773aba8d44e..c78298cdddd0 100644
--- a/sw/qa/extras/rtfexport/rtfexport8.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport8.cxx
@@ -9,9 +9,10 @@
#include <swmodeltestbase.hxx>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/text/GraphicCrop.hpp>
#include <com/sun/star/text/XFootnote.hpp>
#include <com/sun/star/text/XFootnotesSupplier.hpp>
-#include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/text/XEndnotesSupplier.hpp>
#include <com/sun/star/text/XTextFieldsSupplier.hpp>
#include <com/sun/star/text/XTextTablesSupplier.hpp>
@@ -48,6 +49,28 @@ public:
}
};
+DECLARE_RTFEXPORT_TEST(testTdf155663, "piccrop.rtf")
+{
+ auto const xShape(getShape(1));
+ if (!isExported())
+ {
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2004), xShape->getSize().Height);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2004), xShape->getSize().Width);
+ }
+ else // bit of rounding loss?
+ {
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2013), xShape->getSize().Height);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2013), xShape->getSize().Width);
+ }
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(123), getProperty<text::GraphicCrop>(xShape, "GraphicCrop").Top);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(123),
+ getProperty<text::GraphicCrop>(xShape, "GraphicCrop").Bottom);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(123),
+ getProperty<text::GraphicCrop>(xShape, "GraphicCrop").Left);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(123),
+ getProperty<text::GraphicCrop>(xShape, "GraphicCrop").Right);
+}
+
DECLARE_RTFEXPORT_TEST(testTdf158586_0, "tdf158586_pageBreak0.rtf")
{
// The specified page break must be lost because it is in a text frame
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index fd80491c3265..c11717b4048a 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -275,6 +275,7 @@ public:
std::optional<sal_Int32> m_oEffectExtentTop;
std::optional<sal_Int32> m_oEffectExtentRight;
std::optional<sal_Int32> m_oEffectExtentBottom;
+ std::optional<text::GraphicCrop> m_oCrop;
GraphicImport_Impl(GraphicImportType & rImportType, DomainMapper& rDMapper,
std::pair<OUString, OUString>& rPositionOffsets,
@@ -834,6 +835,9 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
case NS_ooxml::LN_CT_WrapSquare_wrapText:
handleWrapTextValue(rValue.getInt());
break;
+ case NS_ooxml::LN_CT_BlipFillProperties_srcRect:
+ m_pImpl->m_oCrop.emplace(rValue.getAny().get<text::GraphicCrop>());
+ break;
case NS_ooxml::LN_shape:
{
uno::Reference< drawing::XShape> xShape;
@@ -896,7 +900,13 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
text::GraphicCrop aGraphicCrop( 0, 0, 0, 0 );
uno::Reference< beans::XPropertySet > xSourceGraphProps( xShape, uno::UNO_QUERY );
uno::Any aAny = xSourceGraphProps->getPropertyValue("GraphicCrop");
- if(aAny >>= aGraphicCrop) {
+ if (m_pImpl->m_oCrop)
+ { // RTF: RTFValue from resolvePict()
+ xGraphProps->setPropertyValue("GraphicCrop",
+ uno::Any(*m_pImpl->m_oCrop));
+ }
+ else if (aAny >>= aGraphicCrop)
+ { // DOCX: imported in oox BlipFillContext
xGraphProps->setPropertyValue("GraphicCrop",
uno::Any( aGraphicCrop ) );
}
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 19fe333e3e0c..ab700ff0dc14 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1070,6 +1070,16 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS
RTFSprms aAttributes;
// shape attribute
RTFSprms aPicAttributes;
+ if (m_aStates.top().getPicture().nCropT != 0 || m_aStates.top().getPicture().nCropB != 0
+ || m_aStates.top().getPicture().nCropL != 0 || m_aStates.top().getPicture().nCropR != 0)
+ {
+ text::GraphicCrop const crop{ m_aStates.top().getPicture().nCropT,
+ m_aStates.top().getPicture().nCropB,
+ m_aStates.top().getPicture().nCropL,
+ m_aStates.top().getPicture().nCropR };
+ auto const pCrop = new RTFValue(crop);
+ aPicAttributes.set(NS_ooxml::LN_CT_BlipFillProperties_srcRect, pCrop);
+ }
auto pShapeValue = new RTFValue(xShape);
aPicAttributes.set(NS_ooxml::LN_shape, pShapeValue);
// pic sprm
diff --git a/writerfilter/source/rtftok/rtfvalue.cxx b/writerfilter/source/rtftok/rtfvalue.cxx
index 7a9137f5db4a..6654a3f2eca5 100644
--- a/writerfilter/source/rtftok/rtfvalue.cxx
+++ b/writerfilter/source/rtftok/rtfvalue.cxx
@@ -85,6 +85,11 @@ RTFValue::RTFValue(const RTFPicture& rPicture)
{
}
+RTFValue::RTFValue(text::GraphicCrop const& rCrop)
+ : m_oCrop(rCrop)
+{
+}
+
RTFValue::~RTFValue() = default;
int RTFValue::getInt() const { return m_nValue; }
@@ -110,6 +115,10 @@ uno::Any RTFValue::getAny() const
ret <<= m_xStream;
else if (m_xObject.is())
ret <<= m_xObject;
+ else if (m_oCrop)
+ {
+ ret <<= *m_oCrop;
+ }
else
ret <<= static_cast<sal_Int32>(m_nValue);
return ret;
diff --git a/writerfilter/source/rtftok/rtfvalue.hxx b/writerfilter/source/rtftok/rtfvalue.hxx
index 4f37a5dcbcec..6c87c61a1d05 100644
--- a/writerfilter/source/rtftok/rtfvalue.hxx
+++ b/writerfilter/source/rtftok/rtfvalue.hxx
@@ -11,6 +11,10 @@
#include <dmapper/resourcemodel.hxx>
+#include <com/sun/star/text/GraphicCrop.hpp>
+
+#include <optional>
+
namespace com::sun::star
{
namespace embed
@@ -49,6 +53,7 @@ public:
explicit RTFValue(css::uno::Reference<css::embed::XEmbeddedObject> xObject);
explicit RTFValue(const RTFShape& aShape);
explicit RTFValue(const RTFPicture& rPicture);
+ explicit RTFValue(css::text::GraphicCrop const& rCrop);
~RTFValue() override;
void setString(const OUString& sValue);
int getInt() const override;
@@ -79,6 +84,7 @@ private:
bool m_bForceString = false;
mutable tools::SvRef<RTFShape> m_pShape;
mutable tools::SvRef<RTFPicture> m_pPicture;
+ ::std::optional<css::text::GraphicCrop> m_oCrop;
};
} // namespace writerfilter::rtftok