27 #include <editeng/editids.hrc>
40 #include <com/sun/star/beans/XPropertySet.hpp>
41 #include <com/sun/star/graphic/XGraphic.hpp>
49 , m_pSdrObject(nullptr)
110 sal_uInt16 nRet = *pVal++;
111 nRet += (*pVal++) << 8;
116 sal_uInt16 nPointSize)
119 if ((nPointSize == 0xfff0) || (nPointSize == 4))
121 sal_uInt16 nUnsigned = *pVal++;
122 nUnsigned += (*pVal++) << 8;
125 nRet = sal_Int16(nUnsigned);
127 else if (nPointSize == 8)
129 sal_uInt32 nUnsigned = *pVal++;
130 nUnsigned += (*pVal++) << 8;
131 nUnsigned += (*pVal++) << 16;
132 nUnsigned += (*pVal++) << 24;
153 for (
const auto& rOpt : rOpts)
155 sal_uInt16
nId = (rOpt.nPropId & 0x0FFF);
162 switch (rOpt.nPropValue)
186 std::pair<OString, OString>(
"fillColor", OString::number(rOpt.nPropValue)));
190 std::pair<OString, OString>(
"fillBackColor", OString::number(rOpt.nPropValue)));
194 std::pair<OString, OString>(
"anchorText", OString::number(rOpt.nPropValue)));
199 std::pair<OString, OString>(
"fNoFillHitTest", OString::number(1)));
203 if (rOpt.nPropValue == 0x90000)
204 m_aShapeProps.insert(std::pair<OString, OString>(
"fLine", OString::number(0)));
208 std::pair<OString, OString>(
"lineColor", OString::number(rOpt.nPropValue)));
212 std::pair<OString, OString>(
"lineBackColor", OString::number(rOpt.nPropValue)));
216 std::pair<OString, OString>(
"lineJoinStyle", OString::number(rOpt.nPropValue)));
220 m_aShapeProps.insert(std::pair<OString, OString>(
"fshadowObscured",
"1"));
225 sal_uInt32 nLeft = 0;
230 nLeft = rOpt.nPropValue;
235 nTop = rOpt.nPropValue;
240 std::pair<OString, OString>(
"geoLeft", OString::number(sal_Int32(nLeft))));
242 std::pair<OString, OString>(
"geoTop", OString::number(sal_Int32(nTop))));
249 sal_uInt32 nLeft = 0;
250 sal_uInt32 nRight = 0;
252 sal_uInt32 nBottom = 0;
258 nRight = rOpt.nPropValue;
263 nBottom = rOpt.nPropValue;
268 "geoRight", OString::number(sal_Int32(nRight) - sal_Int32(nLeft))));
270 "geoBottom", OString::number(sal_Int32(nBottom) - sal_Int32(nTop))));
281 && aVertices.
nProp.size() >= 6 && aSegments.
nProp.size() >= 6)
284 std::size_t nVerticesPos = 6;
287 OStringBuffer aSegmentInfo(512);
288 OStringBuffer aVerticies(512);
290 sal_uInt16 nPointSize = aVertices.
nProp[4] + (aVertices.
nProp[5] << 8);
294 sal_Int32 nVertices = 0;
295 aSegmentInfo.append(
"2;" + OString::number(nSegments));
298 for (; nSegments; --nSegments)
305 unsigned char nSegmentType = (nSeg & 0xE000) >> 13;
306 unsigned short nSegmentCount = nSeg & 0x03FF;
308 aSegmentInfo.append(
';').append(static_cast<sal_Int32>(nSeg));
309 switch (nSegmentType)
312 for (
unsigned short i = 0;
i < nSegmentCount; ++
i)
318 aVerticies.append(
";(" + OString::number(nX) +
","
319 + OString::number(nY) +
")");
329 aVerticies.append(
";(" + OString::number(nX) +
","
330 + OString::number(nY) +
")");
335 for (
unsigned short j = 0; j < nSegmentCount; ++j)
337 for (
int i = 0;
i < 3;
i++)
340 pVerticesIt, nVerticesPos, nPointSize);
342 pVerticesIt, nVerticesPos, nPointSize);
343 aVerticies.append(
";(" + OString::number(nX) +
","
344 + OString::number(nY) +
")");
354 unsigned char nVertexCount = nSegmentCount & 0x00FF;
355 nVerticesPos += nVertexCount;
363 SAL_WARN(
"sw.rtf",
"Totally b0rked");
368 if (!aVerticies.isEmpty())
373 "8;" + OString::number(nVertices) + aVerticies.makeStringAndClear()));
375 if (!aSegmentInfo.isEmpty())
377 "pSegmentInfo", aSegmentInfo.makeStringAndClear()));
383 <<
": unhandled shape path, missing either pVertices or pSegmentInfo");
390 if (!rOpt.nPropValue)
391 m_aShapeProps.insert(std::pair<OString, OString>(
"fFillOK",
"0"));
395 std::pair<OString, OString>(
"dxTextLeft", OString::number(rOpt.nPropValue)));
399 std::pair<OString, OString>(
"dyTextTop", OString::number(rOpt.nPropValue)));
403 std::pair<OString, OString>(
"dxTextRight", OString::number(rOpt.nPropValue)));
407 std::pair<OString, OString>(
"dyTextBottom", OString::number(rOpt.nPropValue)));
414 std::pair<OString, OString>(
"adjustValue", OString::number(rOpt.nPropValue)));
418 std::pair<OString, OString>(
"txflTextFlow", OString::number(rOpt.nPropValue)));
422 std::pair<OString, OString>(
"fillType", OString::number(rOpt.nPropValue)));
426 std::pair<OString, OString>(
"fillOpacity", OString::number(rOpt.nPropValue)));
435 rOpt.nProp.size() - nHeaderSize)
437 m_aShapeProps.insert(std::pair<OString, OString>(
"fillBlip", aBuf));
441 SAL_INFO(
"sw.rtf", __func__ <<
": unhandled property: " << nId
442 <<
" (value: " << rOpt.nPropValue <<
")");
451 m_aShapeProps.insert(std::pair<OString, OString>(
"posrelh",
"3"));
454 m_aShapeProps.insert(std::pair<OString, OString>(
"fFlipV",
"1"));
457 m_aShapeProps.insert(std::pair<OString, OString>(
"fFlipH",
"1"));
470 m_aShapeProps.insert(std::pair<OString, OString>(
"posrelh",
"3"));
478 static void lcl_AppendSP(OStringBuffer& rRunText,
const char* cName, std::string_view rValue)
492 uno::Reference<drawing::XShape> xShape
494 uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
496 uno::Reference<graphic::XGraphic> xGraphic;
502 xPropertySet->getPropertyValue(
"Graphic") >>= xGraphic;
504 catch (beans::UnknownPropertyException
const&)
517 sal_uInt32 nSize = aStream.
TellEnd();
530 m_aShapeProps.insert(std::pair<OString, OString>(
"pib", aBuf.makeStringAndClear()));
581 if (pTextBox == &rFrame.GetFrameFormat())
605 if (pTextObj->IsTextEditActive())
607 pOwnedParaObj = pTextObj->CreateEditOutlinerParaObject();
609 pParaObj = &*pOwnedParaObj;
613 pParaObj = pTextObj->GetOutlinerParaObject();
620 if (pTextObj->TakeObjNameSingul().match(
"Text Frame"))
640 rItemSet.
GetItem(SID_ATTR_CHAR_FONTHEIGHT));
644 FieldUnit::TWIP, FieldUnit::POINT);
654 = -1 * pTextObj->GetGeoStat().nRotationAngle.get() *
RTF_MULTIPLIER / 100;
667 SAL_INFO(
"sw.rtf", __func__ <<
" start");
677 for (sal_Int32
n = 0;
n < nPara; ++
n)
685 sal_Int32 nCurrentPos = 0;
686 const sal_Int32 nEnd =
aStr.getLength();
696 aAttrIter.
OutAttr(nCurrentPos);
700 bool bTextAtr = aAttrIter.
IsTextAttr(nCurrentPos);
703 OUString aOut(
aStr.copy(nCurrentPos, nNextAttr - nCurrentPos));
709 nCurrentPos = nNextAttr;
710 eChrSet = eNextChrSet;
712 }
while (nCurrentPos < nEnd);
713 if (bShape ||
n + 1 < nPara)
719 SAL_INFO(
"sw.rtf", __func__ <<
" end");
724 if (nShapeElement >= 0)
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
If we have an associated TextFrame, then return that.
std::unique_ptr< bool[]> m_pShapeTypeWritten
Remember which shape types we had already written.
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
#define ESCHER_ShpInst_Nil
Wrapper around OStringBuffers, so less hexdump of graphics have to be kept in memory during RTF expor...
void OutAttr(sal_Int32 nSwPos)
sal_Int32 WhereNext() const
#define OOO_STRING_SVTOOLS_RTF_SHPRIGHT
#define ESCHER_Prop_geoRight
#define ESCHER_Prop_geoLeft
#define ESCHER_Prop_fshadowObscured
#define OOO_STRING_SVTOOLS_RTF_SN
#define OOO_STRING_SVTOOLS_RTF_PNGBLIP
rtl_TextEncoding GetNodeCharSet() const
void OpenContainer(sal_uInt16 nEscherContainer, int nRecInstance=0) override
#define ESCHER_Prop_dyTextTop
rtl_TextEncoding GetCurrentEncoding() const
void OutParaAttr(bool bCharAttr, const std::set< sal_uInt16 > *pWhichsToIgnore=nullptr)
void impl_writeGraphic()
Exports the pib property of the shape.
#define ESCHER_Prop_geoBottom
std::vector< sal_uInt8 > nProp
OUString GetDescription() const
std::vector< sal_uInt16 > mRecTypes
#define ESCHER_Prop_pVertices
sal_uInt32 AddSdrObject(const SdrObject &rObj, bool ooxmlExport=false)
#define OOO_STRING_SVTOOLS_RTF_PICT
tools::Long TransformMetric(tools::Long nVal, FieldUnit aOld, FieldUnit aNew)
#define ESCHER_Prop_txflTextFlow
std::shared_ptr< T > make_shared(Args &&...args)
Used to export formatted text associated to drawings.
#define OOO_STRING_SVTOOLS_RTF_PICH
#define ESCHER_Prop_pSegmentInfo
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
static bool isTextBox(const SwFrameFormat &rFrameFormat)
Is this a standalone TextFrame, or used as a TextBox of a shape?
virtual sal_uInt32 GenerateShapeId()
virtual sal_uInt64 TellEnd() override
static sal_uInt16 impl_GetUInt16(const sal_uInt8 *&pVal)
sal_uInt32 m_nShapeType
Remember the shape type.
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
#define ESCHER_Prop_AnchorText
The class that does all the actual RTF export-related work.
ShapeFlag m_nShapeFlags
Remember the shape flags.
void LeaveGroup() override
#define OOO_STRING_SVTOOLS_RTF_SHPZ
The class that has handlers for various resource types when exporting as RTF.
#define ESCHER_ShpInst_Line
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
Is the frame format a text box?
virtual const SfxItemSet & GetParaAttribs(sal_Int32 nPara) const =0
OString WriteHex(const sal_uInt8 *pData, sal_uInt32 nSize, SvStream *pStream=nullptr, sal_uInt32 nLimit=64)
RtfAttributeOutput & m_rAttrOutput
#define ESCHER_Prop_fillOpacity
void Commit(EscherPropertyContainer &rProps, const tools::Rectangle &rRect) override
#define OOO_STRING_SVTOOLS_RTF_SP
#define ESCHER_Prop_dyTextBottom
#define ESCHER_Prop_fNoLineDrawDash
#define OOO_STRING_SVTOOLS_RTF_SHPLEFT
#define ESCHER_Prop_lineBackColor
const EditTextObject & GetTextObject() const
#define TOOLS_WARN_EXCEPTION(area, stream)
OString MoveCharacterProperties(bool aAutoWriteRtlLtr=false)
#define ESCHER_Prop_WrapText
#define OOO_STRING_SVTOOLS_RTF_SHPWR
#define ESCHER_Prop_geoTop
sal_uInt32 EnterGroup(const OUString &rShapeName, const tools::Rectangle *pBoundRect) override
virtual OUString GetText(sal_Int32 nPara) const =0
void writeTextFrame(const ww8::Frame &rFrame, bool bTextBox=false)
Handles just the { ...} part of a shape export.
sal_uInt32 GetOrdNum() const
void AddShape(sal_uInt32 nShapeType, ShapeFlag nShapeFlags, sal_uInt32 nShapeId=0) override
#define OOO_STRING_SVTOOLS_RTF_SHP
#define ESCHER_Prop_FitTextToShape
#define ESCHER_ShpInst_COUNT
#define OOO_STRING_SVTOOLS_RTF_SHPTOP
#define OOO_STRING_SVTOOLS_RTF_PAR
#define ESCHER_Prop_lineJoinStyle
#define ESCHER_Prop_fillBlip
#define OOO_STRING_SVTOOLS_RTF_SHPINST
OStringBuffer m_aShapeStyle
Remember style, the most important shape attribute ;-)
#define ESCHER_Prop_fillBackColor
std::vector< ISegmentProgressBarRef > aSegments
#define OOO_STRING_SVTOOLS_RTF_PICW
#define ESCHER_Prop_dxTextLeft
void RunText(const OUString &rText, rtl_TextEncoding eCharSet=RTL_TEXTENCODING_UTF8) override
Output text (inside a run).
#define ESCHER_Prop_fillColor
#define ESCHER_Prop_fFillOK
const OUString & GetFamilyName() const
static ErrCode Export(SvStream &rOStm, const Graphic &rGraphic, ConvertDataFormat nFormat)
#define ESCHER_SpContainer
#define OOO_STRING_SVTOOLS_RTF_IGNORE
OString OutString(const OUString &rStr, rtl_TextEncoding eDestEnc, bool bUnicode=true)
virtual void CloseContainer()
static void lcl_AppendSP(OStringBuffer &rRunText, const char *cName, std::string_view rValue)
#define ESCHER_ShpInst_PictureFrame
#define OOO_STRING_SVTOOLS_RTF_SHPBOTTOM
const SdrObject * m_pSdrObject
void WriteOutliner(const OutlinerParaObject &rParaObj, TextTypes eType)
Write editeng text, e.g. shape or comment.
Make exporting a Writer Frame easy.
#define ESCHER_Prop_lineColor
#define ESCHER_Prop_fNoFillHitTest
virtual sal_Int32 GetParagraphCount() const =0
bool IsTextAttr(sal_Int32 nSwPos)
virtual void OpenContainer(sal_uInt16 nEscherContainer, int nRecInstance=0)
#define SAL_INFO(area, stream)
SVXCORE_DLLPUBLIC css::uno::Reference< css::drawing::XShape > GetXShapeForSdrObject(SdrObject *pObj) noexcept
#define ESCHER_Prop_fillType
#define ESCHER_Prop_adjustValue
void AddLineDimensions(const tools::Rectangle &rRectangle)
Add starting and ending point of a line to the m_pShapeAttrList.
#define ESCHER_Prop_shapePath
#define OOO_STRING_SVTOOLS_RTF_SHPBXIGNORE
const EscherProperties & GetOpts() const
void AddSdrObject(const SdrObject &rObj)
Export the sdr object as Sdr.
#define OOO_STRING_SVTOOLS_RTF_SV
#define SAL_WARN(area, stream)
void CloseContainer() override
#define OOO_STRING_SVTOOLS_RTF_SHPTXT
static sal_Int32 impl_GetPointComponent(const sal_uInt8 *&pVal, std::size_t &rVerticesPos, sal_uInt16 nPointSize)
#define OOO_STRING_SVTOOLS_RTF_SHPBYIGNORE
rtl_TextEncoding GetNextCharSet() const
bool GetOpt(sal_uInt16 nPropertyID, sal_uInt32 &rPropValue) const
std::map< OString, OString > m_aShapeProps
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const OUString & GetName() const
void NextPara(sal_Int32 nPar)
RtfSdrExport(RtfExport &rExport)
#define SAL_NEWLINE_STRING
std::vector< EscherPropSortStruct > EscherProperties
void EndShape(sal_Int32 nShapeElement)
void AddRectangleDimensions(OStringBuffer &rBuffer, const tools::Rectangle &rRectangle)
Add position and size to the OStringBuffer.
#define ESCHER_Prop_dxTextRight