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)
106 sal_uInt16 nRet = *pVal++;
107 nRet += (*pVal++) << 8;
112 sal_uInt16 nPointSize)
115 if ((nPointSize == 0xfff0) || (nPointSize == 4))
117 sal_uInt16 nUnsigned = *pVal++;
118 nUnsigned += (*pVal++) << 8;
121 nRet = sal_Int16(nUnsigned);
123 else if (nPointSize == 8)
125 sal_uInt32 nUnsigned = *pVal++;
126 nUnsigned += (*pVal++) << 8;
127 nUnsigned += (*pVal++) << 16;
128 nUnsigned += (*pVal++) << 24;
149 for (
const auto& rOpt : rOpts)
151 sal_uInt16
nId = (rOpt.nPropId & 0x0FFF);
158 switch (rOpt.nPropValue)
182 std::pair<OString, OString>(
"fillColor", OString::number(rOpt.nPropValue)));
186 std::pair<OString, OString>(
"fillBackColor", OString::number(rOpt.nPropValue)));
190 std::pair<OString, OString>(
"anchorText", OString::number(rOpt.nPropValue)));
195 std::pair<OString, OString>(
"fNoFillHitTest", OString::number(1)));
199 if (rOpt.nPropValue == 0x90000)
200 m_aShapeProps.insert(std::pair<OString, OString>(
"fLine", OString::number(0)));
204 std::pair<OString, OString>(
"lineColor", OString::number(rOpt.nPropValue)));
208 std::pair<OString, OString>(
"lineBackColor", OString::number(rOpt.nPropValue)));
212 std::pair<OString, OString>(
"lineJoinStyle", OString::number(rOpt.nPropValue)));
216 m_aShapeProps.insert(std::pair<OString, OString>(
"fshadowObscured",
"1"));
221 sal_uInt32 nLeft = 0;
226 nLeft = rOpt.nPropValue;
231 nTop = rOpt.nPropValue;
236 std::pair<OString, OString>(
"geoLeft", OString::number(sal_Int32(nLeft))));
238 std::pair<OString, OString>(
"geoTop", OString::number(sal_Int32(nTop))));
245 sal_uInt32 nLeft = 0;
246 sal_uInt32 nRight = 0;
248 sal_uInt32 nBottom = 0;
254 nRight = rOpt.nPropValue;
259 nBottom = rOpt.nPropValue;
264 "geoRight", OString::number(sal_Int32(nRight) - sal_Int32(nLeft))));
266 "geoBottom", OString::number(sal_Int32(nBottom) - sal_Int32(nTop))));
280 std::size_t nVerticesPos = 6;
283 OStringBuffer aSegmentInfo(512);
284 OStringBuffer aVerticies(512);
286 sal_uInt16 nPointSize = aVertices.
nProp[4] + (aVertices.
nProp[5] << 8);
290 sal_Int32 nVertices = 0;
291 aSegmentInfo.append(
"2;" + OString::number(nSegments));
294 for (; nSegments; --nSegments)
301 unsigned char nSegmentType = (nSeg & 0xE000) >> 13;
302 unsigned short nSegmentCount = nSeg & 0x03FF;
304 aSegmentInfo.append(
";" + OString::number(
static_cast<sal_Int32
>(nSeg)));
305 switch (nSegmentType)
308 for (
unsigned short i = 0;
i < nSegmentCount; ++
i)
314 aVerticies.append(
";(" + OString::number(nX) +
","
315 + OString::number(nY) +
")");
325 aVerticies.append(
";(" + OString::number(nX) +
","
326 + OString::number(nY) +
")");
331 for (
unsigned short j = 0; j < nSegmentCount; ++j)
333 for (
int i = 0;
i < 3;
i++)
336 pVerticesIt, nVerticesPos, nPointSize);
338 pVerticesIt, nVerticesPos, nPointSize);
339 aVerticies.append(
";(" + OString::number(nX) +
","
340 + OString::number(nY) +
")");
350 unsigned char nVertexCount = nSegmentCount & 0x00FF;
351 nVerticesPos += nVertexCount;
359 SAL_WARN(
"sw.rtf",
"Totally b0rked");
364 if (!aVerticies.isEmpty())
368 "pVerticies",
"8;" + OString::number(nVertices) + aVerticies));
370 if (!aSegmentInfo.isEmpty())
372 "pSegmentInfo", aSegmentInfo.makeStringAndClear()));
378 <<
": unhandled shape path, missing either pVertices or pSegmentInfo");
385 if (!rOpt.nPropValue)
386 m_aShapeProps.insert(std::pair<OString, OString>(
"fFillOK",
"0"));
390 std::pair<OString, OString>(
"dxTextLeft", OString::number(rOpt.nPropValue)));
394 std::pair<OString, OString>(
"dyTextTop", OString::number(rOpt.nPropValue)));
398 std::pair<OString, OString>(
"dxTextRight", OString::number(rOpt.nPropValue)));
402 std::pair<OString, OString>(
"dyTextBottom", OString::number(rOpt.nPropValue)));
409 std::pair<OString, OString>(
"adjustValue", OString::number(rOpt.nPropValue)));
413 std::pair<OString, OString>(
"txflTextFlow", OString::number(rOpt.nPropValue)));
417 std::pair<OString, OString>(
"fillType", OString::number(rOpt.nPropValue)));
421 std::pair<OString, OString>(
"fillOpacity", OString::number(rOpt.nPropValue)));
430 rOpt.nProp.size() - nHeaderSize)
436 SAL_INFO(
"sw.rtf", __func__ <<
": unhandled property: " <<
nId
437 <<
" (value: " << rOpt.nPropValue <<
")");
446 m_aShapeProps.insert(std::pair<OString, OString>(
"posrelh",
"3"));
449 m_aShapeProps.insert(std::pair<OString, OString>(
"fFlipV",
"1"));
452 m_aShapeProps.insert(std::pair<OString, OString>(
"fFlipH",
"1"));
465 m_aShapeProps.insert(std::pair<OString, OString>(
"posrelh",
"3"));
473static void lcl_AppendSP(OStringBuffer& rRunText,
const char* cName, std::string_view rValue)
487 uno::Reference<drawing::XShape> xShape
489 uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
491 uno::Reference<graphic::XGraphic> xGraphic;
497 xPropertySet->getPropertyValue(
"Graphic") >>= xGraphic;
499 catch (beans::UnknownPropertyException
const&)
512 sal_uInt32 nSize = aStream.
TellEnd();
525 m_aShapeProps.insert(std::pair<OString, OString>(
"pib",
aBuf.makeStringAndClear()));
577 if (pTextBox == &rFrame.GetFrameFormat())
601 if (pTextObj->IsTextEditActive())
603 pOwnedParaObj = pTextObj->CreateEditOutlinerParaObject();
605 pParaObj = &*pOwnedParaObj;
609 pParaObj = pTextObj->GetOutlinerParaObject();
616 if (pTextObj->TakeObjNameSingul().match(
"Text Frame"))
635 auto pFontHeight = rItemSet.
GetItem(SID_ATTR_CHAR_FONTHEIGHT);
639 FieldUnit::TWIP, FieldUnit::POINT);
649 = -1 * pTextObj->GetGeoStat().m_nRotationAngle.get() *
RTF_MULTIPLIER / 100;
662 SAL_INFO(
"sw.rtf", __func__ <<
" start");
672 for (sal_Int32
n = 0;
n < nPara; ++
n)
680 sal_Int32 nCurrentPos = 0;
681 const sal_Int32 nEnd =
aStr.getLength();
691 aAttrIter.
OutAttr(nCurrentPos);
695 bool bTextAtr = aAttrIter.
IsTextAttr(nCurrentPos);
698 OUString aOut(
aStr.copy(nCurrentPos, nNextAttr - nCurrentPos));
704 nCurrentPos = nNextAttr;
705 eChrSet = eNextChrSet;
707 }
while (nCurrentPos < nEnd);
708 if (bShape ||
n + 1 < nPara)
714 SAL_INFO(
"sw.rtf", __func__ <<
" end");
719 if (nShapeElement >= 0)
virtual sal_Int32 GetParagraphCount() const=0
virtual OUString GetText(sal_Int32 nPara) const=0
virtual const SfxItemSet & GetParaAttribs(sal_Int32 nPara) const=0
sal_uInt32 AddSdrObject(const SdrObject &rObj, bool ooxmlExport=false, sal_uInt32 nId=0)
virtual sal_uInt32 GenerateShapeId()
virtual void OpenContainer(sal_uInt16 nEscherContainer, int nRecInstance=0)
std::vector< sal_uInt16 > mRecTypes
virtual void CloseContainer()
bool GetOpt(sal_uInt16 nPropertyID, sal_uInt32 &rPropValue) const
const EscherProperties & GetOpts() const
static ErrCode Export(SvStream &rOStm, const Graphic &rGraphic, ConvertDataFormat nFormat)
Used to export formatted text associated to drawings.
void OutAttr(sal_Int32 nSwPos)
rtl_TextEncoding GetNextCharSet() const
void OutParaAttr(bool bCharAttr, const std::set< sal_uInt16 > *pWhichsToIgnore=nullptr)
rtl_TextEncoding GetNodeCharSet() const
void NextPara(sal_Int32 nPar)
bool IsTextAttr(sal_Int32 nSwPos)
sal_Int32 WhereNext() const
const EditTextObject & GetTextObject() const
The class that has handlers for various resource types when exporting as RTF.
void RunText(const OUString &rText, rtl_TextEncoding eCharSet=RTL_TEXTENCODING_UTF8, const OUString &rSymbolFont=OUString()) override
Output text (inside a run).
void writeTextFrame(const ww8::Frame &rFrame, bool bTextBox=false)
Handles just the {\shptxt ...} part of a shape export.
OString MoveCharacterProperties(bool aAutoWriteRtlLtr=false)
The class that does all the actual RTF export-related work.
rtl_TextEncoding GetCurrentEncoding() const
void AddRectangleDimensions(OStringBuffer &rBuffer, const tools::Rectangle &rRectangle)
Add position and size to the OStringBuffer.
void EndShape(sal_Int32 nShapeElement)
sal_uInt32 m_nShapeType
Remember the shape type.
void Commit(EscherPropertyContainer &rProps, const tools::Rectangle &rRect) override
sal_uInt32 EnterGroup(const OUString &rShapeName, const tools::Rectangle *pBoundRect) override
void CloseContainer() override
void WriteOutliner(const OutlinerParaObject &rParaObj, TextTypes eType)
Write editeng text, e.g. shape or comment.
void LeaveGroup() override
OStringBuffer m_aShapeStyle
Remember style, the most important shape attribute ;-)
ShapeFlag m_nShapeFlags
Remember the shape flags.
RtfSdrExport(RtfExport &rExport)
std::map< OString, OString > m_aShapeProps
const SdrObject * m_pSdrObject
void AddSdrObject(const SdrObject &rObj)
Export the sdr object as Sdr.
std::unique_ptr< bool[]> m_pShapeTypeWritten
Remember which shape types we had already written.
void impl_writeGraphic()
Exports the pib property of the shape.
static bool isTextBox(const SwFrameFormat &rFrameFormat)
Is this a standalone TextFrame, or used as a TextBox of a shape?
void AddShape(sal_uInt32 nShapeType, ShapeFlag nShapeFlags, sal_uInt32 nShapeId=0) override
void AddLineDimensions(const tools::Rectangle &rRectangle)
Add starting and ending point of a line to the m_pShapeAttrList.
RtfAttributeOutput & m_rAttrOutput
void OpenContainer(sal_uInt16 nEscherContainer, int nRecInstance=0) override
Wrapper around OStringBuffers, so less hexdump of graphics have to be kept in memory during RTF expor...
sal_uInt32 GetOrdNum() const
virtual OUString GetDescription() const
virtual const OUString & GetName() const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
virtual sal_uInt64 TellEnd() override
const OUString & GetFamilyName() const
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
If we have an associated TextFrame, then return that.
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
Is the frame format a text box?
Make exporting a Writer Frame easy.
#define SAL_NEWLINE_STRING
#define TOOLS_WARN_EXCEPTION(area, stream)
#define ESCHER_Prop_lineColor
#define ESCHER_Prop_shapePath
std::vector< EscherPropSortStruct > EscherProperties
#define ESCHER_ShpInst_COUNT
#define ESCHER_Prop_fNoFillHitTest
#define ESCHER_Prop_lineJoinStyle
#define ESCHER_Prop_fshadowObscured
#define ESCHER_Prop_geoRight
#define ESCHER_Prop_FitTextToShape
#define ESCHER_Prop_fNoLineDrawDash
#define ESCHER_Prop_AnchorText
#define ESCHER_Prop_WrapText
#define ESCHER_Prop_txflTextFlow
#define ESCHER_Prop_geoLeft
#define ESCHER_Prop_lineBackColor
#define ESCHER_Prop_dxTextLeft
#define ESCHER_Prop_pSegmentInfo
#define ESCHER_Prop_geoBottom
#define ESCHER_Prop_dyTextTop
#define ESCHER_Prop_fillBackColor
#define ESCHER_Prop_pVertices
#define ESCHER_Prop_fillBlip
#define ESCHER_Prop_fFillOK
#define ESCHER_Prop_dyTextBottom
#define ESCHER_Prop_geoTop
#define ESCHER_ShpInst_Nil
#define ESCHER_Prop_fillType
#define ESCHER_Prop_adjustValue
#define ESCHER_Prop_fillOpacity
#define ESCHER_SpContainer
#define ESCHER_Prop_dxTextRight
#define ESCHER_Prop_fillColor
#define ESCHER_ShpInst_Line
#define ESCHER_ShpInst_PictureFrame
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(162)
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(165)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
OString OutString(std::u16string_view rStr, rtl_TextEncoding eDestEnc, bool bUnicode=true)
OString WriteHex(const sal_uInt8 *pData, sal_uInt32 nSize, SvStream *pStream=nullptr, sal_uInt32 nLimit=64)
std::shared_ptr< T > make_shared(Args &&... args)
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
#define OOO_STRING_SVTOOLS_RTF_SV
#define OOO_STRING_SVTOOLS_RTF_SHPRIGHT
#define OOO_STRING_SVTOOLS_RTF_SHPBXIGNORE
#define OOO_STRING_SVTOOLS_RTF_SP
#define OOO_STRING_SVTOOLS_RTF_SHP
#define OOO_STRING_SVTOOLS_RTF_PAR
#define OOO_STRING_SVTOOLS_RTF_PICW
#define OOO_STRING_SVTOOLS_RTF_SHPINST
#define OOO_STRING_SVTOOLS_RTF_SHPLEFT
#define OOO_STRING_SVTOOLS_RTF_SHPWR
#define OOO_STRING_SVTOOLS_RTF_SHPBOTTOM
#define OOO_STRING_SVTOOLS_RTF_PICH
#define OOO_STRING_SVTOOLS_RTF_SHPTOP
#define OOO_STRING_SVTOOLS_RTF_SHPTXT
#define OOO_STRING_SVTOOLS_RTF_SN
#define OOO_STRING_SVTOOLS_RTF_SHPZ
#define OOO_STRING_SVTOOLS_RTF_IGNORE
#define OOO_STRING_SVTOOLS_RTF_SHPBYIGNORE
#define OOO_STRING_SVTOOLS_RTF_PICT
#define OOO_STRING_SVTOOLS_RTF_PNGBLIP
static void lcl_AppendSP(OStringBuffer &rRunText, const char *cName, std::string_view rValue)
static sal_Int32 impl_GetPointComponent(const sal_uInt8 *&pVal, std::size_t &rVerticesPos, sal_uInt16 nPointSize)
static sal_uInt16 impl_GetUInt16(const sal_uInt8 *&pVal)
std::vector< sal_uInt8 > nProp
SVXCORE_DLLPUBLIC SdrTextObj * DynCastSdrTextObj(SdrObject *)
SVT_DLLPUBLIC tools::Long TransformMetric(tools::Long nVal, FieldUnit aOld, FieldUnit aNew)
SVXCORE_DLLPUBLIC css::uno::Reference< css::drawing::XShape > GetXShapeForSdrObject(SdrObject *pObj) noexcept
std::vector< ISegmentProgressBarRef > aSegments