16#include <com/sun/star/embed/XEmbeddedObject.hpp>
17#include <com/sun/star/beans/PropertyAttribute.hpp>
18#include <com/sun/star/io/WrongFormatException.hpp>
19#include <com/sun/star/lang/XServiceInfo.hpp>
20#include <com/sun/star/lang/XMultiServiceFactory.hpp>
21#include <com/sun/star/text/TextContentAnchorType.hpp>
22#include <com/sun/star/text/XDependentTextField.hpp>
23#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
28#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
40#include <ooxml/resourceids.hxx>
41#include <oox/token/namespaces.hxx>
44#include <rtl/tencinfo.h>
46#include <osl/diagnose.h>
64util::DateTime getDateTimeFromUserProp(std::u16string_view rString)
67 size_t nLen = rString.size();
88 static const Id aBorderIds[]
89 = { NS_ooxml::LN_CT_PBdr_top, NS_ooxml::LN_CT_PBdr_left, NS_ooxml::LN_CT_PBdr_bottom,
90 NS_ooxml::LN_CT_PBdr_right, NS_ooxml::LN_CT_PBdr_between };
102 if (nParent == NS_ooxml::LN_CT_TcPrBase_shd)
108 auto pParentValue =
new RTFValue(aAttributes);
109 rSprms.
set(nParent, pParentValue, eOverwrite);
110 pParent = pParentValue;
112 RTFSprms& rAttributes = (bAttribute ? pParent->getAttributes() : pParent->getSprms());
113 rAttributes.
set(
nId, pValue, eOverwrite);
127 RTFSprms& rAttributes = pParent->getAttributes();
136 RTFSprms& rInner = pParent->getSprms();
146 RTFSprms& rAttributes = pParent->getAttributes();
153 if (
p && !
p->getSprms().empty())
154 return p->getSprms().back().second->getAttributes();
156 SAL_WARN(
"writerfilter.rtf",
"trying to set property when no type is defined");
164 for (
int i = 0;
i < 4;
i++)
169 RTFSprms& rAttributes =
p->getAttributes();
170 rAttributes.
set(
nId, pValue);
179 RTFSprms& rAttributes = pPointer->getAttributes();
180 rAttributes.
set(
nId, pValue);
189 NS_ooxml::LN_CT_TcPrBase_tcBorders);
192 NS_ooxml::LN_EG_SectPrContents_pgBorders);
196 for (
int i = 0;
i < 4; ++
i)
201 aAttributes.
set(NS_ooxml::LN_CT_Border_val,
202 new RTFValue(NS_ooxml::LN_Value_ST_Border_none));
209 pAttributes->
set(
nId, pValue);
221 if (!rString.isEmpty())
224 auto pString =
new RTFValue(rString);
225 aAttributes.
set(NS_ooxml::LN_CT_Bookmark_name, pString);
227 aAttributes.
set(NS_ooxml::LN_CT_MarkupRangeBookmark_id, pPos);
249 static_cast<sal_Int16
>(aState.
getYear()),
256 if (!pDestinationText)
258 OUString
aStr = pDestinationText->makeStringAndClear();
284 , m_xInputStream(xInputStream)
287 , m_xStatusIndicator(xStatusIndicator)
288 , m_pMapperStream(nullptr)
289 , m_aDefaultState(this)
290 , m_bSkipUnknown(false)
292 , m_bFirstRunException(false)
295 , m_bNeedCrOrig(false)
297 , m_bNeedFinalPar(false)
299 , m_nTopLevelCells(0)
300 , m_nInheritingCells(0)
302 , m_nTopLevelTRLeft(0)
303 , m_nNestedCurrentCellX(0)
304 , m_nTopLevelCurrentCellX(0)
305 , m_nBackupTopLevelCurrentCellX(0)
306 , m_aTableBufferStack(1)
307 , m_pSuperstream(nullptr)
309 , m_nGroupStartPos(0)
312 , m_nCurrentFontIndex(0)
313 , m_nCurrentEncoding(-1)
314 , m_nDefaultFontIndex(-1)
316 , m_nCurrentStyleIndex(0)
317 , m_bFormField(false)
319 , m_bIgnoreNextContSectBreak(false)
322 , m_bWasInFrame(false)
323 , m_bHadPicture(false)
326 , m_nListPictureId(0)
327 , m_bIsNewDoc(!rMediaDescriptor.getUnpackedValueOrDefault(
"InsertMode", false))
328 , m_rMediaDescriptor(rMediaDescriptor)
329 , m_hasRHeader(false)
330 , m_hasFHeader(false)
331 , m_hasRFooter(false)
332 , m_hasFFooter(false)
333 , m_bAfterCellBeforeRow(false)
335 OSL_ASSERT(xInputStream.is());
342 if (xDocumentPropertiesSupplier.is())
370 sal_uInt64
const nCurrent =
Strm().
Tell();
374 pImpl->setSuperstream(
this);
375 pImpl->m_nStreamType =
nId;
376 pImpl->m_aIgnoreFirst = rIgnoreFirst;
389 pImpl->Strm().Seek(
nPos);
390 SAL_INFO(
"writerfilter.rtf",
"substream start");
392 SAL_INFO(
"writerfilter.rtf",
"substream end");
404 aSettingsTableEntries.insert(std::make_pair(0, pProp));
407 Mapper().
table(NS_ooxml::LN_settings_settings, pTable);
424 NS_ooxml::LN_CT_Fonts_ascii);
432 NS_ooxml::LN_CT_Fonts_ascii);
435 NS_ooxml::LN_CT_Fonts_ascii, pFont);
475 for (
auto& rSprm : rProps.
getSprms())
478 if (rSprm.first == NS_ooxml::LN_CT_Style_rPr)
481 RTFSprms& rRPrSprms = rSprm.second->getSprms();
482 for (
const auto& rRPrSprm : rRPrSprms)
483 rStyleSprms.
set(rRPrSprm.first, rRPrSprm.second);
485 RTFSprms& rRPrAttributes = rSprm.second->getAttributes();
486 for (
const auto& rRPrAttribute : rRPrAttributes)
487 rStyleAttributes.
set(rRPrAttribute.first, rRPrAttribute.second);
490 rStyleSprms.
set(rSprm.first, rSprm.second);
494 for (
const auto& rAttribute : rAttributes)
495 rStyleAttributes.
set(rAttribute.first, rAttribute.second);
503 int nAbstractListId = -1;
505 =
getNestedSprm(aSprms, NS_ooxml::LN_CT_PPrBase_numPr, NS_ooxml::LN_CT_NumPr_numId);
513 nAbstractListId = itNumId->second;
516 pAbstractList = itAbstract->second;
553 if (!nStyleType || nStyleType == NS_ooxml::LN_Value_ST_StyleType_character)
588 NS_ooxml::LN_Value_ST_StyleType_paragraph));
591 bool hasBreakBeforeFrame
594 if (hasBreakBeforeFrame)
600 if (hasBreakBeforeFrame)
624 NS_ooxml::LN_Value_ST_StyleType_character);
632 NS_ooxml::LN_Value_ST_StyleType_character);
678 SAL_INFO(
"writerfilter.rtf", __func__ <<
": final? " << bFinal <<
", needed? " <<
m_bNeedSect);
682 bool bContinuous = pBreak && pBreak->getInt() == NS_ooxml::LN_Value_ST_SectionMark_continuous;
707 if (bFinal && bContinuous)
716 aSprms.
set(NS_ooxml::LN_CT_PPr_sectPr, pValue);
840 SAL_INFO(
"writerfilter.rtf",
"RTFDocumentImpl::resolve: finished without errors");
843 SAL_INFO(
"writerfilter.rtf",
"RTFDocumentImpl::resolve: unmatched '}'");
846 SAL_INFO(
"writerfilter.rtf",
"RTFDocumentImpl::resolve: unmatched '{'");
847 throw io::WrongFormatException(
m_pTokenizer->getPosition());
850 SAL_INFO(
"writerfilter.rtf",
"RTFDocumentImpl::resolve: unexpected end of file");
851 throw io::WrongFormatException(
m_pTokenizer->getPosition());
854 SAL_INFO(
"writerfilter.rtf",
"RTFDocumentImpl::resolve: invalid hex char");
855 throw io::WrongFormatException(
m_pTokenizer->getPosition());
858 SAL_INFO(
"writerfilter.rtf",
"RTFDocumentImpl::resolve: characters after last '}'");
862 "RTFDocumentImpl::resolve: classification prevented paste");
880 rDestinationTextBuffer.setLength(0);
881 for (
int i = 0;
i <
aStr.getLength(); ++
i)
884 if (
ch != 0x0d &&
ch != 0x0a &&
ch != 0x20)
904 if (!pStream->
Tell())
923 pStream = &aDIBStream;
936 aExtHeader.
xExt = sal_uInt16(std::clamp<sal_Int32>(
939 aExtHeader.
yExt = sal_uInt16(std::clamp<sal_Int32>(
946 if (xServiceInfo.is() && xServiceInfo->supportsService(
"com.sun.star.text.TextFrame"))
947 pExtHeader =
nullptr;
971 awt::Size aSize = xShape->getSize();
972 if (aSize.Width || aSize.Height)
988 if (!xSI->supportsService(
"com.sun.star.drawing.GraphicObjectShape"))
995 "cannot set graphic on existing shape, creating a new GraphicObjectShape");
1002 xShape.set(
m_xModelFactory->createInstance(
"com.sun.star.drawing.GraphicObjectShape"),
1005 if (xDrawSupplier.is())
1009 xShapes->add(xShape);
1015 if (xPropertySet.is())
1016 xPropertySet->setPropertyValue(
"Graphic",
uno::Any(xGraphic));
1030 xShape->setSize(aSize);
1033 xPropertySet->setPropertyValue(
"AnchorType",
1034 uno::Any(text::TextContentAnchorType_AS_CHARACTER));
1036 auto pShapeValue =
new RTFValue(xShape);
1054 auto pShapeValue =
new RTFValue(xShape);
1055 aPicAttributes.
set(NS_ooxml::LN_shape, pShapeValue);
1059 auto pPicValue =
new RTFValue(aPicAttributes);
1060 aGraphicDataSprms.
set(NS_ooxml::LN_pic_pic, pPicValue);
1064 auto pGraphicDataValue =
new RTFValue(aGraphicDataAttributes, aGraphicDataSprms);
1065 aGraphicSprms.
set(NS_ooxml::LN_CT_GraphicalObject_graphicData, pGraphicDataValue);
1067 auto pGraphicValue =
new RTFValue(aGraphicAttributes, aGraphicSprms);
1086 aExtentAttributes.
set(NS_ooxml::LN_CT_PositiveSize2D_cx, pXExtValue);
1087 aExtentAttributes.
set(NS_ooxml::LN_CT_PositiveSize2D_cy, pYExtValue);
1088 auto pExtentValue =
new RTFValue(aExtentAttributes);
1092 if (rCharacterAttribute.first == NS_ooxml::LN_CT_NonVisualDrawingProps_name
1093 || rCharacterAttribute.first == NS_ooxml::LN_CT_NonVisualDrawingProps_descr)
1094 aDocprAttributes.
set(rCharacterAttribute.first, rCharacterAttribute.second);
1095 auto pDocprValue =
new RTFValue(aDocprAttributes);
1099 aInlineAttributes.
set(NS_ooxml::LN_CT_Inline_distT,
new RTFValue(0));
1100 aInlineAttributes.
set(NS_ooxml::LN_CT_Inline_distB,
new RTFValue(0));
1101 aInlineAttributes.
set(NS_ooxml::LN_CT_Inline_distL,
new RTFValue(0));
1102 aInlineAttributes.
set(NS_ooxml::LN_CT_Inline_distR,
new RTFValue(0));
1104 aInlineSprms.
set(NS_ooxml::LN_CT_Inline_extent, pExtentValue);
1105 aInlineSprms.
set(NS_ooxml::LN_CT_Inline_docPr, pDocprValue);
1106 aInlineSprms.
set(NS_ooxml::LN_graphic_graphic, pGraphicValue);
1108 auto pValue =
new RTFValue(aInlineAttributes, aInlineSprms);
1109 aSprms.
set(NS_ooxml::LN_inline_inline, pValue);
1116 NS_ooxml::LN_CT_Anchor_behindDoc,
1121 if (rCharacterAttribute.first == NS_ooxml::LN_CT_WrapSquare_wrapText)
1122 aAnchorWrapAttributes.
set(rCharacterAttribute.first, rCharacterAttribute.second);
1124 sal_Int32 nWrap = -1;
1127 if (rCharacterSprm.first == NS_ooxml::LN_EG_WrapType_wrapNone
1128 || rCharacterSprm.first == NS_ooxml::LN_EG_WrapType_wrapTight)
1130 nWrap = rCharacterSprm.first;
1133 if (rCharacterSprm.first == NS_ooxml::LN_EG_WrapType_wrapTight
1135 rCharacterSprm.second->getSprms().set(
1136 NS_ooxml::LN_CT_WrapTight_wrapPolygon,
1139 aAnchorSprms.
set(rCharacterSprm.first, rCharacterSprm.second);
1149 aAnchorSprms.
set(NS_ooxml::LN_CT_Anchor_extent, pExtentValue);
1150 if (!aAnchorWrapAttributes.
empty() && nWrap == -1)
1151 aAnchorSprms.
set(NS_ooxml::LN_EG_WrapType_wrapSquare,
1152 new RTFValue(aAnchorWrapAttributes));
1158 aPoshAttributes.
set(
1159 NS_ooxml::LN_CT_PosH_relativeFrom,
1166 aPoshSprms.
set(NS_ooxml::LN_CT_PosH_posOffset,
new RTFValue());
1168 aAnchorSprms.
set(NS_ooxml::LN_CT_Anchor_positionH,
1169 new RTFValue(aPoshAttributes, aPoshSprms));
1174 aPosvAttributes.
set(
1175 NS_ooxml::LN_CT_PosV_relativeFrom,
1182 aPosvSprms.
set(NS_ooxml::LN_CT_PosV_posOffset,
new RTFValue());
1184 aAnchorSprms.
set(NS_ooxml::LN_CT_Anchor_positionV,
1185 new RTFValue(aPosvAttributes, aPosvSprms));
1187 aAnchorSprms.
set(NS_ooxml::LN_CT_Anchor_docPr, pDocprValue);
1188 aAnchorSprms.
set(NS_ooxml::LN_graphic_graphic, pGraphicValue);
1191 aSprms.
set(NS_ooxml::LN_anchor_anchor, pValue);
1205 auto pValue =
new RTFValue(aAttributes, aSprms);
1225 OStringBuffer
aBuf(512);
1227 bool bUnicodeChecked =
false;
1228 bool bSkipped =
false;
1230 while (!
Strm().eof()
1232 || (
ch !=
'{' &&
ch !=
'}' &&
ch !=
'\\')))
1235 || (
ch != 0x0d &&
ch != 0x0a))
1239 if (!bUnicodeChecked)
1242 bUnicodeChecked =
true;
1259 unsigned char uch =
ch;
1260 if ((uch >= 0x80 && uch <= 0x9F) || uch >= 0xE0)
1269 "writerfilter.rtf",
"invalid Shift-JIS without DBCH");
1270 assert(bUnicodeChecked);
1293 if ((
ch ==
'\r' ||
ch ==
'\n')
1311 OString
aStr =
aBuf.makeStringAndClear();
1314 if (
aStr.toChar() !=
';')
1320 "RTFDocumentImpl::resolveChars: collected '"
1330 else if (!
aStr.isEmpty())
1344 if (!pCurrentBuffer)
1357 if (!pCurrentBuffer)
1364 auto pValue =
new RTFValue(*sValue);
1374 if (
aName.isEmpty())
1377 if (
aName.endsWith(
";"))
1387 OUString aFontSuffix;
1388 OUString aNameNoSuffix(
aName);
1389 sal_Int32 nLastSpace =
aName.lastIndexOf(
' ');
1390 if (nLastSpace >= 0)
1392 aFontSuffix =
aName.copy(nLastSpace + 1);
1393 aNameNoSuffix =
aName.copy(0, nLastSpace);
1394 sal_Int32 nEncoding = RTL_TEXTENCODING_DONTKNOW;
1403 if (nEncoding > RTL_TEXTENCODING_DONTKNOW)
1411 aNameNoSuffix =
aName;
1444 if (
ch == 0x0d ||
ch == 0x0a)
1458 if (rString.endsWith(
";"))
1460 rString = rString.copy(0, rString.getLength() - 1);
1467 OUString
const aName
1491 SAL_INFO(
"writerfilter.rtf",
"no RTF style type defined, ignoring");
1564 if (!rString.startsWithIgnoreAsciiCase(
"Microsoft"))
1603 else if (pCurrentBuffer)
1614 if (!pCurrentBuffer)
1618 auto pValue =
new RTFValue(rString);
1626 else if (pCurrentBuffer)
1637 int const nCurrentCellX)
1639 o_rpParagraphProperties
1641 NS_ooxml::LN_Value_ST_StyleType_paragraph);
1651 if (!pTableWidthProps)
1655 NS_ooxml::LN_CT_TblWidth_type, pUnitValue);
1656 auto pWValue =
new RTFValue(nCurrentCellX);
1658 NS_ooxml::LN_CT_TblWidth_w, pWValue);
1670 aAttributes.
set(NS_ooxml::LN_CT_TblWidth_type,
1671 new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa));
1672 aAttributes.
set(NS_ooxml::LN_CT_TblWidth_w,
new RTFValue(0));
1674 NS_ooxml::LN_CT_TblCellMar_left,
new RTFValue(aAttributes));
1676 NS_ooxml::LN_CT_TblCellMar_right,
new RTFValue(aAttributes));
1679 o_rpTableRowProperties
1690 if (pFrameProperties)
1701 ::std::deque<RTFSprms>& rCellsAttributes,
int const nCells)
1703 for (
int i = 0;
i < nCells; ++
i)
1705 replayBuffer(rBuffer, &rCellsSprms.front(), &rCellsAttributes.front());
1706 rCellsSprms.pop_front();
1707 rCellsAttributes.pop_front();
1713 assert(rCellsSprms.empty());
1714 assert(rCellsAttributes.empty());
1720 while (!rBuffer.empty())
1722 Buf_t aTuple(rBuffer.front());
1723 rBuffer.pop_front();
1728 std::get<1>(aTuple)->getAttributes(), std::get<1>(aTuple)->getSprms(),
1729 std::get<0>(aTuple) ==
BUFFER_PROPS_CHAR ? NS_ooxml::LN_Value_ST_StyleType_character
1745 assert(pSprms && pAttributes);
1747 pSprms->
set(NS_ooxml::LN_tblCell, pValue);
1763 OUString
const aString(std::get<1>(aTuple)->
getString());
1765 aString.getLength());
1793 RTFSprms& rAttributes = std::get<1>(aTuple)->getAttributes();
1794 std::size_t
nPos = rAttributes.
find(0)->getInt();
1796 OUString aCustomMark = rAttributes.
find(2)->getString();
1811bool findPropertyName(
const std::vector<beans::PropertyValue>& rProperties,
const OUString& rName)
1814 rProperties.begin(), rProperties.end(),
1815 [&rName](
const beans::PropertyValue& rProperty) { return rProperty.Name == rName; });
1865 nSprm = NS_ooxml::LN_Value_ST_Underline_single;
1868 nSprm = NS_ooxml::LN_Value_ST_Underline_dash;
1871 nSprm = NS_ooxml::LN_Value_ST_Underline_dotDash;
1874 nSprm = NS_ooxml::LN_Value_ST_Underline_dotDotDash;
1877 nSprm = NS_ooxml::LN_Value_ST_Underline_double;
1880 nSprm = NS_ooxml::LN_Value_ST_Underline_wavyHeavy;
1883 nSprm = NS_ooxml::LN_Value_ST_Underline_dashLong;
1886 nSprm = NS_ooxml::LN_Value_ST_Underline_thick;
1889 nSprm = NS_ooxml::LN_Value_ST_Underline_dottedHeavy;
1892 nSprm = NS_ooxml::LN_Value_ST_Underline_dashedHeavy;
1895 nSprm = NS_ooxml::LN_Value_ST_Underline_dashDotHeavy;
1898 nSprm = NS_ooxml::LN_Value_ST_Underline_dashDotDotHeavy;
1901 nSprm = NS_ooxml::LN_Value_ST_Underline_dashLongHeavy;
1904 nSprm = NS_ooxml::LN_Value_ST_Underline_wavyDouble;
1907 nSprm = NS_ooxml::LN_Value_ST_Underline_wave;
1915 =
new RTFValue((!bParam || nParam != 0) ? nSprm : NS_ooxml::LN_Value_ST_Underline_none);
1924 nSprm = NS_ooxml::LN_Value_ST_Em_none;
1927 nSprm = NS_ooxml::LN_Value_ST_Em_dot;
1930 nSprm = NS_ooxml::LN_Value_ST_Em_comma;
1933 nSprm = NS_ooxml::LN_Value_ST_Em_circle;
1936 nSprm = NS_ooxml::LN_Value_ST_Em_underDot;
1943 auto pValue =
new RTFValue((!bParam || nParam != 0) ? nSprm : 0);
1958 nSprm = NS_ooxml::LN_EG_RPrBase_bCs;
1966 nSprm = NS_ooxml::LN_EG_RPrBase_b;
1977 nSprm = NS_ooxml::LN_EG_RPrBase_iCs;
1985 nSprm = NS_ooxml::LN_EG_RPrBase_i;
1990 nSprm = NS_ooxml::LN_EG_RPrBase_outline;
1993 nSprm = NS_ooxml::LN_EG_RPrBase_shadow;
1996 nSprm = NS_ooxml::LN_EG_RPrBase_vanish;
1999 nSprm = NS_ooxml::LN_EG_RPrBase_strike;
2002 nSprm = NS_ooxml::LN_EG_RPrBase_dstrike;
2005 nSprm = NS_ooxml::LN_EG_RPrBase_smallCaps;
2008 nSprm = NS_ooxml::LN_EG_RPrBase_imprint;
2011 nSprm = NS_ooxml::LN_EG_RPrBase_caps;
2041 NS_ooxml::LN_token, pValue);
2046 NS_ooxml::LN_CT_Spacing_beforeAutospacing, pBoolValue);
2050 NS_ooxml::LN_CT_Spacing_afterAutospacing, pBoolValue);
2060 new RTFValue(
int(bParam && nParam == 0)));
2115 auto pValue =
new RTFValue(NS_ooxml::LN_Value_ST_StyleType_paragraph);
2160 nBasedOn = pBasedOn->getInt();
2165 for (
const auto&
nId :
2166 { NS_ooxml::LN_CT_Ind_firstLine, NS_ooxml::LN_CT_Ind_left, NS_ooxml::LN_CT_Ind_right,
2167 NS_ooxml::LN_CT_Ind_start, NS_ooxml::LN_CT_Ind_end })
2170 NS_ooxml::LN_CT_PPrBase_ind,
nId);
2171 if (pValue && pValue->getInt() == 0)
2173 NS_ooxml::LN_CT_PPrBase_ind,
nId);
2205 auto pStyle = it.second;
2206 ret[it.first] = pStyle;
2211 NS_ooxml::LN_CT_Style_basedOn));
2214 int const nBasedOn(pBasedOn->getInt());
2216 if (it.first == nBasedOn)
2222 auto const pStyleType(
2224 NS_ooxml::LN_CT_Style_type));
2226 int const nStyleType(pStyleType->getInt());
2234 .cloneAndDeduplicate(
2242 SAL_WARN(
"writerfilter.rtf",
"parent style not found: " << nBasedOn);
2265 std::u16string_view rName)
2267 return std::any_of(rProperties.begin(), rProperties.end(),
2268 [&](
const beans::Property& rProperty) { return rProperty.Name == rName; });
2292 NS_ooxml::LN_EG_RPrBase_rFonts, NS_ooxml::LN_CT_Fonts_ascii,
2312 aListTableEntries.insert(std::make_pair(0, pProp));
2328 aFFSprms.
set(NS_ooxml::LN_ffdata, pValue);
2337 auto pFFValue =
new RTFValue(aFFAttributes, aFFSprms);
2360 OUString aPictureURL;
2363 aPictureURL = rtl::Uri::convertRelToAbs(aFileURL,
m_aPicturePath);
2365 catch (
const rtl::MalformedUriException& rException)
2368 "rtl::Uri::convertRelToAbs() failed: " << rException.getMessage());
2371 if (!aPictureURL.isEmpty())
2376 OUStringBuffer
aBuf;
2377 while (aStream.
good())
2379 unsigned char ch = 0;
2383 aBuf.append(
static_cast<sal_Int32
>(
ch), 16);
2407 auto pValue =
new RTFValue(aValue,
true);
2413 bool bNestedLevelNumbers =
false;
2418 if (!bNestedLevelNumbers && rState.
getTableSprms().
find(NS_ooxml::LN_CT_Lvl_lvlText))
2425 OUString aOrig = pValue->getString();
2427 OUStringBuffer
aBuf(aOrig.getLength() * 2);
2428 sal_Int32 nReplaces = 1;
2429 for (
int i = 0;
i < aOrig.getLength();
i++)
2441 aBuf.append(aOrig[
i]);
2444 pValue->setString(
aBuf.makeStringAndClear());
2448 pValue->setString(OUString());
2508 if (rCharacterSprm.first == NS_ooxml::LN_EG_WrapType_wrapNone
2509 || rCharacterSprm.first == NS_ooxml::LN_EG_WrapType_wrapTight)
2524 m_pSdrImport->appendGroupProperty(rGroupProperty.first, rGroupProperty.second);
2567 ? std::u16string_view(
u"XE")
2568 : std::u16string_view(
u"TC"));
2569 str = OUString::Concat(field) +
" \"" + str.replaceAll(
"\"",
"\\\"") +
"\"";
2603 OUStringBuffer* pCurrentDestinationText
2609 pCurrentDestinationText->setLength(0);
2614 for (
int i = 0;
i <
aStr.getLength(); ++
i)
2617 if (
ch != 0x0d &&
ch != 0x0a)
2627 aBuf.append(
static_cast<char>(b));
2636 if (
aStr.getLength() > 8)
2640 if (!
aStr.isEmpty())
2650 if (!
aStr.isEmpty())
2656 OString aDefaultText =
aStr.copy(0, std::min(
nLength,
aStr.getLength()));
2692 OUStringBuffer* pCurrentDestinationText
2696 pCurrentDestinationText->setLength(0);
2741 : OUString(
"Company");
2750 = xPropertySet->getPropertySetInfo();
2751 if (xPropertySetInfo->hasPropertyByName(
aName))
2752 xPropertySet->setPropertyValue(
aName, aValue);
2754 xUserDefinedProperties->addProperty(
aName, beans::PropertyAttribute::REMOVABLE,
2789 aObjectSprms.
set(NS_ooxml::LN_OLEObject_OLEObject, pOLEValue);
2794 aObjSprms.
set(NS_ooxml::LN_object, pValue);
2801 pShape->getAny() >>= xShape;
2820 pCurrentDestinationText->setLength(0);
2823 aAnnAttributes.
set(NS_ooxml::LN_CT_TrackChange_date, pValue);
2851 aAttributes.
set(NS_ooxml::LN_EG_RangeMarkupElements_commentRangeStart, pValue);
2853 aAttributes.
set(NS_ooxml::LN_EG_RangeMarkupElements_commentRangeEnd, pValue);
2874 aAnnAttributes.
set(NS_ooxml::LN_CT_Markup_id,
new RTFValue(
aStr.toInt32()));
2896 bool bTextFrame = xServiceInfo->supportsService(
"com.sun.star.text.TextFrame");
2899 xPropertySet->setPropertyValue(
"AnchorType",
2900 uno::Any(text::TextContentAnchorType_AT_CHARACTER));
2904 xPropertySet->setPropertyValue(
"HoriOrientPosition",
2906 xPropertySet->setPropertyValue(
"VertOrientPosition",
2911 xShape->setPosition(awt::Point(rDrawing.
getLeft(), rDrawing.
getTop()));
2925 xPropertySet->setPropertyValue(
2929 else if (!bTextFrame)
2931 xPropertySet->setPropertyValue(
"FillTransparence",
uno::Any(sal_Int32(100)));
2975 uno::UNO_SET_THROW);
2976 if (oox::FormulaImExportBase* pImport
2977 =
dynamic_cast<oox::FormulaImExportBase*
>(xComponent.get()))
2980 auto pValue =
new RTFValue(xObject);
2982 aMathAttributes.
set(NS_ooxml::LN_starmath, pValue);
3029 sal_Int32 nMathToken = 0;
3033 nMathToken = M_TOKEN(chr);
3036 nMathToken = M_TOKEN(
pos);
3039 nMathToken = M_TOKEN(vertJc);
3042 nMathToken = M_TOKEN(strikeH);
3045 nMathToken = M_TOKEN(degHide);
3048 nMathToken = M_TOKEN(begChr);
3051 nMathToken = M_TOKEN(sepChr);
3054 nMathToken = M_TOKEN(endChr);
3057 nMathToken = M_TOKEN(subHide);
3060 nMathToken = M_TOKEN(supHide);
3063 nMathToken = M_TOKEN(
type);
3066 nMathToken = M_TOKEN(grow);
3073 aAttribs[M_TOKEN(val)]
3214 aAny <<= aStaticVal;
3216 aAny <<= aStaticVal.toInt32();
3218 aAny <<= aStaticVal.toBoolean();
3220 aAny <<= getDateTimeFromUserProp(aStaticVal);
3222 aAny <<= aStaticVal.toDouble();
3224 xPropertyContainer->addProperty(rKey, beans::PropertyAttribute::REMOVABLE, aAny);
3236 if (xDocumentPropertiesSupplier.is())
3250 = xDocumentProperties->getUserDefinedProperties();
3254 xClipboardPropertyContainer, uno::UNO_QUERY);
3258 = xClipboardPropertySet->getPropertySetInfo()->getProperties();
3260 = xDocumentPropertySet->getPropertySetInfo()->getProperties();
3262 for (
const beans::Property& rProperty : aClipboardProperties)
3264 const OUString& rKey = rProperty.Name;
3265 uno::Any aValue = xClipboardPropertySet->getPropertyValue(rKey);
3273 xDocumentPropertySet->setPropertyValue(rKey, aValue);
3276 xDocumentPropertyContainer->addProperty(
3277 rKey, beans::PropertyAttribute::REMOVABLE, aValue);
3279 catch (
const uno::Exception&)
3319 OUString aTextValue;
3323 aTextValue += pTextBefore->getString();
3328 aTextValue += pTextAfter->getString();
3329 auto pTextValue =
new RTFValue(aTextValue);
3330 aLeveltextAttributes.
set(NS_ooxml::LN_CT_LevelText_val, pTextValue);
3335 aLevelAttributes.
set(NS_ooxml::LN_CT_Lvl_ilvl, pIlvlValue);
3340 aLevelSprms.
set(NS_ooxml::LN_CT_Lvl_numFmt, pFmtValue);
3345 aLevelSprms.
set(NS_ooxml::LN_CT_Lvl_start, pStartatValue);
3347 auto pLeveltextValue =
new RTFValue(aLeveltextAttributes);
3348 aLevelSprms.
set(NS_ooxml::LN_CT_Lvl_lvlText, pLeveltextValue);
3352 aLevelSprms.
set(NS_ooxml::LN_CT_Lvl_rPr, pRunProps);
3356 aAbstractAttributes.
set(NS_ooxml::LN_CT_AbstractNum_abstractNumId, pIdValue);
3357 auto pLevelValue =
new RTFValue(aLevelAttributes, aLevelSprms);
3358 aAbstractSprms.
set(NS_ooxml::LN_CT_AbstractNum_lvl, pLevelValue,
3362 auto pAbstractValue =
new RTFValue(aAbstractAttributes, aAbstractSprms);
3364 aListTableSprms.
set(NS_ooxml::LN_CT_Numbering_abstractNum, pAbstractValue,
3370 aNumberingAttributes.
set(NS_ooxml::LN_CT_AbstractNum_nsid, pIdValue);
3371 aNumberingSprms.
set(NS_ooxml::LN_CT_Num_abstractNumId, pIdValue);
3372 auto pNumberingValue =
new RTFValue(aNumberingAttributes, aNumberingSprms);
3373 aListTableSprms.
set(NS_ooxml::LN_CT_Numbering_num, pNumberingValue,
3379 std::move(aListTableAttributes), std::move(aListTableSprms));
3382 aListTableEntries.insert(std::make_pair(0, pProp));
3499 m_xModelFactory->createInstance(
"com.sun.star.text.FieldMaster.User"),
3500 uno::UNO_QUERY_THROW);
3505 xField->attachTextFieldMaster(xMaster);
3506 xField->getTextFieldMaster()->setPropertyValue(
"Content",
uno::Any(docvar));
3556 aAttributes.
set(NS_ooxml::LN_CT_NumPicBullet_numPicBulletId,
3560 aSprms.
set(NS_ooxml::LN_CT_NumPicBullet_pict,
new RTFValue(0));
3561 auto pValue =
new RTFValue(aAttributes, aSprms);
3623 case NS_ooxml::LN_headerl:
3624 case NS_ooxml::LN_headerr:
3625 case NS_ooxml::LN_headerf:
3626 case NS_ooxml::LN_footerl:
3627 case NS_ooxml::LN_footerr:
3628 case NS_ooxml::LN_footerf:
3643 aTCSprms.
set(NS_ooxml::LN_endtrackchange, pValue);
3700 pCurrentDestinationText->setLength(0);
3707 auto pStreamValue =
new RTFValue(xInputStream);
3747 OUStringBuffer buf(rString.getLength());
3748 for (sal_Int32
i = 0;
i < rString.getLength(); ++
i)
3757 SAL_INFO(
"writerfilter.rtf",
"filtering control character");
3760 return buf.makeStringAndClear();
3777 nEncoding = RTL_TEXTENCODING_MS_1252;
3778 OUString aString = OStringToOUString(
m_aHexBuffer, nEncoding);
3786 : m_pDocumentImpl(pDocumentImpl)
3790 , m_bFieldLocked(false)
3792 , m_nCurrentEncoding(rtl_getTextEncodingFromWindowsCharset(0))
3795 , m_nBinaryToRead(0)
3796 , m_nListLevelNum(0)
3797 , m_bLevelNumbersValid(true)
3805 , m_pCurrentDestinationText(nullptr)
3806 , m_nCurrentStyleIndex(0)
3807 , m_nCurrentCharacterStyleIndex(-1)
3808 , m_pCurrentBuffer(nullptr)
3809 , m_bInListpicture(false)
3810 , m_bInBackground(false)
3811 , m_bHadShapeText(false)
3812 , m_bInShapeGroup(false)
3814 , m_bCreatedShapeGroup(false)
3815 , m_bStartedTrackchange(false)
3816 , m_nTableRowWidthAfter(0)
3824 Id const nStyleType)
3828 assert(nStyleType == 0 || nStyleType == NS_ooxml::LN_Value_ST_StyleType_character);
3829 rBuffer.emplace_back(nStyleType == NS_ooxml::LN_Value_ST_StyleType_character ?
BUFFER_PROPS_CHAR
3831 pValue, pTableProperties);
3839 : m_pDocumentImpl(pParserState->getDocumentImpl())
3850 , m_nHRule(NS_ooxml::LN_Value_doc_ST_HeightRule_auto)
3863 case NS_ooxml::LN_CT_FramePr_w:
3866 case NS_ooxml::LN_CT_FramePr_h:
3869 case NS_ooxml::LN_CT_FramePr_x:
3872 case NS_ooxml::LN_CT_FramePr_y:
3875 case NS_ooxml::LN_CT_FramePr_hSpace:
3878 case NS_ooxml::LN_CT_FramePr_vSpace:
3881 case NS_ooxml::LN_CT_FramePr_xAlign:
3884 case NS_ooxml::LN_CT_FramePr_hAnchor:
3887 case NS_ooxml::LN_CT_FramePr_yAlign:
3890 case NS_ooxml::LN_CT_FramePr_vAnchor:
3893 case NS_ooxml::LN_CT_FramePr_wrap:
3905 static const Id pNames[]
3906 = { NS_ooxml::LN_CT_FramePr_x, NS_ooxml::LN_CT_FramePr_y,
3907 NS_ooxml::LN_CT_FramePr_hRule,
3908 NS_ooxml::LN_CT_FramePr_h, NS_ooxml::LN_CT_FramePr_w,
3909 NS_ooxml::LN_CT_FramePr_hSpace, NS_ooxml::LN_CT_FramePr_vSpace,
3910 NS_ooxml::LN_CT_FramePr_hAnchor, NS_ooxml::LN_CT_FramePr_vAnchor,
3911 NS_ooxml::LN_CT_FramePr_xAlign, NS_ooxml::LN_CT_FramePr_yAlign,
3912 NS_ooxml::LN_CT_FramePr_wrap, NS_ooxml::LN_CT_FramePr_dropCap,
3913 NS_ooxml::LN_CT_FramePr_lines };
3915 for (
Id nId : pNames)
3921 case NS_ooxml::LN_CT_FramePr_x:
3925 case NS_ooxml::LN_CT_FramePr_y:
3929 case NS_ooxml::LN_CT_FramePr_h:
3932 if (
m_nHRule == NS_ooxml::LN_Value_doc_ST_HeightRule_exact)
3938 case NS_ooxml::LN_CT_FramePr_w:
3942 case NS_ooxml::LN_CT_FramePr_hSpace:
3946 case NS_ooxml::LN_CT_FramePr_vSpace:
3950 case NS_ooxml::LN_CT_FramePr_hAnchor:
3957 case NS_ooxml::LN_CT_FramePr_vAnchor:
3964 case NS_ooxml::LN_CT_FramePr_xAlign:
3967 case NS_ooxml::LN_CT_FramePr_yAlign:
3970 case NS_ooxml::LN_CT_FramePr_hRule:
3973 m_nHRule = NS_ooxml::LN_Value_doc_ST_HeightRule_exact;
3975 m_nHRule = NS_ooxml::LN_Value_doc_ST_HeightRule_atLeast;
3979 case NS_ooxml::LN_CT_FramePr_wrap:
3992 frameprSprms.
set(NS_ooxml::LN_CT_PPrBase_framePr,
new RTFValue(sprms));
3993 return frameprSprms;
Reference< XComponentContext > m_xContext
css::uno::Reference< css::lang::XComponent > m_xFrame
static OutputDevice * GetDefaultDevice()
static const AllSettings & GetSettings()
MapMode GetPrefMapMode() const
MapUnit GetMapUnit() const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
static bool ShowPasteInfo(SfxClassificationCheckPasteResult eResult)
static SfxClassificationCheckPasteResult CheckPaste(const css::uno::Reference< css::document::XDocumentProperties > &xSource, const css::uno::Reference< css::document::XDocumentProperties > &xDestination)
constexpr tools::Long Height() const
constexpr tools::Long Width() const
css::uno::Sequence< sal_Int8 > GetByteSequence() const
SvStream & WriteUInt32(sal_uInt32 nUInt32)
SvStream & ReadChar(char &rChar)
sal_uInt64 Seek(sal_uInt64 nPos)
SvStream & WriteChar(char nChar)
sal_uInt64 SeekRel(sal_Int64 nPos)
SvStream & ReadUChar(unsigned char &rChar)
SvStream & WriteStream(SvStream &rStream)
css::uno::Reference< css::embed::XEmbeddedObject > CreateEmbeddedObject(const css::uno::Sequence< sal_Int8 > &, OUString &, OUString const *pBaseURL=nullptr)
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
Reference to a resource that generates events and sends them to a handler.
virtual void endParagraphGroup()=0
Receives end mark for group with the same paragraph properties.
virtual void endCharacterGroup()=0
Receives end mark for group with the same character properties.
virtual void props(writerfilter::Reference< Properties >::Pointer_t ref)=0
Receives properties of the current run of text.
virtual void markLastSectionGroup()
The current section is the last one in this body text.
virtual void startSectionGroup()=0
Receives start mark for group with the same section properties.
virtual void endSectionGroup()=0
Receives end mark for group with the same section properties.
virtual void startParagraphGroup()=0
Receives start mark for group with the same paragraph properties.
virtual void text(const sal_uInt8 *data, size_t len)=0
Receives 8-bit per character text.
virtual void startShape(css::uno::Reference< css::drawing::XShape > const &xShape)=0
Receives a shape.
virtual void startCharacterGroup()=0
Receives start mark for group with the same character properties.
virtual void table(Id name, writerfilter::Reference< Table >::Pointer_t ref)=0
Receives table.
virtual void substream(Id name, writerfilter::Reference< Stream >::Pointer_t ref)=0
Receives a substream.
virtual void positionOffset(const OUString &rText, bool bVertical)=0
Offset in EMUs for a shape.
virtual void utext(const sal_uInt8 *data, size_t len)=0
Receives 16-bit per character text.
virtual void endShape()=0
An entry in the color table.
Implementation of the RTFDocument interface.
OUStringBuffer m_aUnicodeBuffer
void replayRowBuffer(RTFBuffer_t &rBuffer, ::std::deque< RTFSprms > &rCellsSprms, ::std::deque< RTFSprms > &rCellsAttributes, int nCells)
void resolvePict(bool bInline, css::uno::Reference< css::drawing::XShape > const &rShape)
Resolve a picture: If not inline, then anchored.
void resolve(Stream &rMapper) override
Resolves this document to a stream handler.
int m_nNestedCurrentCellX
Current cellx value (nested table)
void resetTableRowProperties()
void setNeedSect(bool bNeedSect)
If we need a final section break at the end of the document.
void restoreTableRowProperties()
void afterPopState(RTFParserState &rState)
RTFSprms m_aSettingsTableAttributes
The settings table attributes.
bool m_bHadPicture
A picture was seen in the current paragraph.
RTFDocumentImpl * m_pSuperstream
Superstream of this substream.
bool m_bObject
If we are in an object group and if the we use its \objdata element.
css::uno::Reference< css::frame::XFrame > const & m_xFrame
std::deque< RTFBuffer_t > m_aTableBufferStack
Buffered table cells, till cell definitions are not reached.
int m_nDefaultFontIndex
Raw default font index, use getFont() on it to get a real one.
std::map< int, RTFValue::Pointer_t > m_aListTable
Maps listtable indexes to listtable entries.
std::map< int, OUString > m_aFontNames
Font index <-> name map.
int m_nBackupTopLevelCurrentCellX
writerfilter::Reference< Properties >::Pointer_t getProperties(const RTFSprms &rAttributes, RTFSprms const &rSprms, Id nStyleType)
std::size_t m_nGroupStartPos
RTFSprms m_aOLEAttributes
OLE attributes are attributes of the ooxml:OLEObject_OLEObject sprm.
bool isStyleSheetImport()
Are we inside the stylesheet table?
OUString m_aIgnoreFirst
Ignore the first occurrence of this text.
std::map< int, int > m_aInvalidListLevelFirstIndents
Maps List level indexes to removed values in the current list entry.
~RTFDocumentImpl() override
int m_nListPictureId
ID of the next \listlevel picture.
OUString m_aAuthor
Annotation author of the next annotation.
bool m_bNeedFinalPar
If set, an empty paragraph will be added at the end of the document.
std::map< int, int > m_aListOverrideTable
Maps between listoverridetable and listtable indexes.
OUString m_aPicturePath
For the INCLUDEPICTURE field's argument.
void handleFontTableEntry()
RTFError dispatchDestination(RTFKeyword nKeyword) override
RTFKeyword m_nResetBreakOnSectBreak
clean up a synthetic page break, see RTF_PAGE if inactive value is -1, otherwise the RTF_SKB* to rest...
void resetFrame()
Resets m_aStates.top().aFrame.
const utl::MediaDescriptor & m_rMediaDescriptor
The media descriptor contains e.g. the base URL of the document.
RTFError dispatchSymbol(RTFKeyword nKeyword) override
void finishSubstream() override
std::queue< std::pair< Id, std::size_t > > m_nHeaderFooterPositions
css::uno::Reference< css::task::XStatusIndicator > const & m_xStatusIndicator
RTFSprms m_aSettingsTableSprms
The settings table sprms.
int m_nCurrentEncoding
Used only during font table parsing till we don't know the font name.
bool m_bNeedCrOrig
Original value of m_bNeedCr – saved/restored before/after textframes.
Destination getDestination() override
OUString getFontName(int nIndex)
Return the name of the font, based on a dmapper index.
bool m_bHadSect
The document has multiple sections.
RTFReferenceTable::Entries_t m_aFontTableEntries
css::uno::Reference< css::uno::XComponentContext > const & m_xContext
RTFError handleEmbeddedObject()
Turns the destination text into an input stream of the current OLE attributes.
void singleChar(sal_uInt8 nValue, bool bRunProps=false)
Id m_nStreamType
Type of the stream: header, footer, footnote, etc.
int m_nTopLevelCurrentCellX
Current cellx value (top-level table)
bool m_bFirstRunException
except in the case of tables in initial multicolumn section (global for assertion)
bool getFirstRun() const
If the initial paragraph is started.
bool isSubstream() const override
bool m_bFirstRun
to start initial paragraph / section after font/style tables
void checkUnicode(bool bUnicode, bool bHex)
If we have some unicode or hex characters to send.
RTFBuffer_t m_aSuperBuffer
Buffered superscript, till footnote is reached (or not).
std::unique_ptr< SvStream > m_pInStream
css::uno::Reference< css::lang::XMultiServiceFactory > m_xModelFactory
OStringBuffer m_aHexBuffer
Same for hex characters.
std::map< int, rtl_TextEncoding > m_aFontEncodings
Font index <-> encoding map, not part of the parser state.
RTFInternalState getInternalState() override
Id getStyleType(int nIndex)
Return the style type of an RTF style index.
bool m_bIsNewDoc
New document means not pasting into an existing one.
bool getSkipUnknown() override
std::shared_ptr< SvStream > m_pBinaryData
If the data for a picture is a binary one, it's stored here.
RTFParserState & getDefaultState()
Get the default parser state.
void setDestination(Destination eDestination) override
std::map< int, std::map< int, int > > m_aInvalidListTableFirstIndents
Maps list table indexes to levels (and their removed values).
std::map< OUString, int > m_aBookmarks
Bookmark name <-> index map.
int m_nListLevel
Index of the current list level in a list table entry.
void bufferProperties(RTFBuffer_t &rBuffer, const RTFValue::Pointer_t &pValue, const tools::SvRef< TableRowBuffer > &pTableProperties, Id nStyleType=0)
Buffers properties to be sent later.
oox::formulaimport::XmlStreamBuilder m_aMathBuffer
Formula import.
std::map< int, Id > m_aStyleTypes
Maps style indexes to style types.
std::shared_ptr< oox::GraphicHelper > m_pGraphicHelper
OUString getStyleName(int nIndex)
Return the style name of an RTF style index.
std::vector< Color > m_aColorTable
Color index <-> RGB color value map.
OUString m_aAuthorInitials
Initials of author of the next annotation.
css::uno::Reference< css::io::XInputStream > const & m_xInputStream
writerfilter::Reference< Properties >::Pointer_t createStyleProperties()
void sendProperties(writerfilter::Reference< Properties >::Pointer_t const &pParagraphProperties, writerfilter::Reference< Properties >::Pointer_t const &pFrameProperties, writerfilter::Reference< Properties >::Pointer_t const &pTableRowProperties)
Send the passed properties to dmapper.
int getFontIndex(int nIndex)
Return the dmapper index of an RTF index for fonts.
bool m_bMathNor
Normal text property, that is math italic and math spacing are not applied to the current run.
RTFDocumentImpl(css::uno::Reference< css::uno::XComponentContext > const &xContext, css::uno::Reference< css::io::XInputStream > const &xInputStream, css::uno::Reference< css::lang::XComponent > const &xDstDoc, css::uno::Reference< css::frame::XFrame > const &xFrame, css::uno::Reference< css::task::XStatusIndicator > const &xStatusIndicator, const utl::MediaDescriptor &rMediaDescriptor)
oox::GraphicHelper & getGraphicHelper()
void setInternalState(RTFInternalState nInternalState) override
RTFSprms m_aFormfieldAttributes
bool m_bNeedCr
If we need to emit a CR at the end of substream.
css::uno::Reference< css::lang::XComponent > const & m_xDstDoc
int m_nTopLevelCells
cell props buffer for top-level table, reset by \row
tools::SvRef< RTFTokenizer > m_pTokenizer
void prepareProperties(RTFParserState &rState, writerfilter::Reference< Properties >::Pointer_t &o_rpParagraphProperties, writerfilter::Reference< Properties >::Pointer_t &o_rpFrameProperties, writerfilter::Reference< Properties >::Pointer_t &o_rpTableRowProperties, int nCells, int nCurrentCellX)
RTFParserState m_aDefaultState
Read by RTF_PARD.
void checkFirstRun()
If this is the first run of the document, starts the initial paragraph.
void replayBuffer(RTFBuffer_t &rBuffer, RTFSprms *pSprms, RTFSprms const *pAttributes)
std::map< int, OUString > m_aAuthors
Revision index <-> author map.
RTFReferenceTable::Entries_t deduplicateStyleTable()
implement non-obvious RTF specific style inheritance
tools::SvRef< RTFSdrImport > m_pSdrImport
void text(OUString &rString)
RTFError beforePopState(RTFParserState &rState)
RTFSprms m_aObjectAttributes
void setSkipUnknown(bool bSkipUnknown) override
void setSuperstream(RTFDocumentImpl *pSuperstream)
RTFError dispatchFlag(RTFKeyword nKeyword) override
void sectBreak(bool bFinal=false)
RTFSprms m_aBackupTableRowSprms
std::map< int, OUString > m_aStyleNames
Maps style indexes to style names.
void resolveSubstream(std::size_t nPos, Id nId)
rtl_TextEncoding getEncoding(int nFontIndex)
Return the encoding associated with a font index.
RTFError dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam) override
void setNeedPar(bool bNeedPar)
If we need to add a dummy paragraph before a section break.
void setDestinationText(std::u16string_view rString)
RTFSprms m_aFormfieldSprms
bool m_bNeedPap
If paragraph properties should be emitted on next run.
RTFSprms m_aBackupTableRowAttributes
RTFError pushState() override
std::shared_ptr< RTFReferenceTable::Entries_t > m_pStyleTableEntries
To avoid copying entries between DomainMapper instances it is stored as pointer.
std::vector< int > m_aFontIndexes
Maps the non-continuous font indexes to the continuous dmapper indexes.
bool m_hasRHeader
Flags for ensuring that only one header and footer is added per section.
RTFError resolveChars(char ch) override
void backupTableRowProperties()
RTFSprms m_aListTableSprms
The list table and list override table combined.
bool m_bWasInFrame
If aFrame.inFrame() was true in the previous state.
RTFError popState() override
bool m_bNeedSect
If a section break is needed before the end of the doc (false right after a section break).
void outputSettingsTable()
Send NS_ooxml::LN_settings_settings to dmapper.
Color getColorTable(sal_uInt32 nIndex)
css::uno::Reference< css::document::XDocumentProperties > m_xDocumentProperties
Stores the properties of a drawing object.
sal_uInt8 getLineColorR() const
const css::uno::Reference< css::beans::XPropertySet > & getPropertySet() const
sal_Int32 getFLine() const
bool getHasFillColor() const
sal_uInt8 getFillColorR() const
sal_uInt8 getLineColorG() const
bool getHadShapeText() const
const css::uno::Reference< css::drawing::XShape > & getShape() const
sal_uInt8 getFillColorG() const
bool getHasLineColor() const
sal_uInt8 getLineColorB() const
sal_uInt8 getFillColorB() const
Stores the properties of a frame.
bool hasProperties() const
RTFFrame(RTFParserState *pParserState)
bool inFrame() const
If we got tokens indicating we're in a frame.
RTFDocumentImpl * m_pDocumentImpl
RTFSprms getSprms()
Convert the stored properties to Sprms.
void setSprm(Id nId, Id nValue)
Store a property.
std::optional< Id > m_oWrap
This acts like an importer, but used for looking ahead, e.g.
State of the parser, which gets saved / restored when changing groups.
void setRunType(RunType eRunType)
void setStartedTrackchange(bool bStartedTrackchange)
void setCurrentEncoding(rtl_TextEncoding nCurrentEncoding)
RTFSprms & getParagraphSprms()
RTFParserState(RTFDocumentImpl *pDocumentImpl)
sal_uInt16 getMinute() const
void setDocVarName(OUString &aDocVarName)
RTFColorTableEntry & getCurrentColor()
OUStringBuffer & getDestinationText()
RTFSprms & getTableRowSprms()
int getCurrentListIndex() const
OUString const & getPropName() const
RTFDrawingObject & getDrawingObject()
void setCurrentStyleIndex(int nCurrentStyleIndex)
int getCurrentListOverrideIndex() const
bool getHadShapeText() const
RTFInternalState getInternalState() const
Destination getDestination() const
RTFSprms & getSectionAttributes()
RTFSprms & getListLevelEntries()
RTFSprms & getTableRowAttributes()
bool getCreatedShapeGroup() const
bool getInBackground() const
void setLevelNumbersValid(bool bLevelNumbersValid)
int getTableRowWidthAfter() const
void setCurrentBuffer(RTFBuffer_t *pCurrentBuffer)
sal_uInt16 getHour() const
RTFPicture & getPicture()
rtl_TextEncoding getCurrentEncoding() const
RTFSprms & getTableSprms()
css::uno::Type const & getPropType() const
RTFFieldStatus getFieldStatus() const
void setDestination(Destination eDestination)
bool getInListpicture() const
sal_uInt16 getMonth() const
RTFSprms & getCharacterAttributes()
void setPropName(const OUString &rPropName)
void setTableRowWidthAfter(int nTableRowWidthAfter)
OUStringBuffer * getCurrentDestinationText() const
RTFBorderState getBorderState() const
int getCurrentCharacterStyleIndex() const
bool getStartedTrackchange() const
RTFBuffer_t * getCurrentBuffer() const
void setFieldStatus(RTFFieldStatus eFieldStatus)
RTFSprms & getCharacterSprms()
bool isFieldLocked() const
RTFSprms & getSectionSprms()
RTFSprms & getParagraphAttributes()
bool getInShapeGroup() const
RunType
Maps to OOXML's ascii, cs or eastAsia.
void appendDocVar(OUString &aDocVar)
sal_uInt16 getYear() const
int getCurrentStyleIndex() const
RTFSprms & getTableAttributes()
std::vector< sal_Int32 > & getLevelNumbers()
void appendDestinationText(std::u16string_view rString)
void setHadShapeText(bool bHadShapeText)
sal_uInt16 getDay() const
void setInternalState(RTFInternalState nInternalState)
RunType getRunType() const
bool getLevelNumbersValid() const
RTFSprms & getTableCellSprms()
void setCurrentDestinationText(OUStringBuffer *pDestinationText)
Sends RTFSprm instances to DomainMapper.
RTFSprms & getAttributes()
Sends tables (e.g. font table) to the domain mapper.
std::map< int, writerfilter::Reference< Properties >::Pointer_t > Entries_t
Handles the import of drawings using RTF markup.
static void resolveFLine(css::uno::Reference< css::beans::XPropertySet > const &xPropertySet, sal_Int32 nFLine)
static void resolveLineColorAndWidth(bool bTextFrame, const css::uno::Reference< css::beans::XPropertySet > &xPropertySet, css::uno::Any const &rLineColor, css::uno::Any const &rLineWidth)
Set line color and line width on the shape, using the relevant API depending on if the shape is a tex...
Stores the properties of a shape.
std::vector< std::pair< OUString, OUString > > & getProperties()
void setBottom(sal_Int32 nBottom)
sal_Int32 getBottom() const
sal_uInt32 getHoriOrientRelationToken() const
std::pair< Id, RTFValue::Pointer_t > & getWrapSprm()
std::vector< std::pair< OUString, OUString > > & getGroupProperties()
RTFSprms & getWrapPolygonSprms()
bool getInBackground() const
RTFSprms & getAnchorAttributes()
void setLeft(sal_Int32 nLeft)
sal_Int32 getLeft() const
void setTop(sal_Int32 nTop)
sal_uInt32 getVertOrientRelationToken() const
sal_Int32 getRight() const
void setRight(sal_Int32 nRight)
Skips a destination after a not parsed control word if it was prefixed with *.
void setParsed(bool bParsed)
A list of RTFSprm with a copy constructor that performs a deep copy.
RTFValue::Pointer_t find(Id nKeyword, bool bFirst=true, bool bForWrite=false)
void deduplicateList(const std::map< int, int > &rInvalidListLevelFirstIndents)
Removes duplicated values based on in-list properties.
void set(Id nKeyword, const RTFValue::Pointer_t &pValue, RTFOverwrite eOverwrite=RTFOverwrite::YES)
Does the same as ->push_back(), except that it can overwrite or ignore existing entries.
RTFSprms cloneAndDeduplicate(RTFSprms &rReference, Id nStyleType, bool bImplicitPPr=false, RTFSprms *pDirect=nullptr) const
Removes elements which are already in the reference set.
void duplicateList(const RTFValue::Pointer_t &pAbstract)
Inserts default values to override attributes of pAbstract.
const char * GetKeyword() const
RTF tokenizer that separates control words from text.
tools::SvRef< RTFValue > Pointer_t
holds one nested table row
writerfilter::Reference< Properties >::Pointer_t & GetParaProperties()
std::deque< RTFSprms > & GetCellsSprms()
std::deque< RTFSprms > & GetCellsAttributes()
writerfilter::Reference< Properties >::Pointer_t & GetRowProperties()
writerfilter::Reference< Properties >::Pointer_t & GetFrameProperties()
RTFBuffer_t & GetBuffer()
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
TOOLS_DLLPUBLIC OString DateTimeToOString(const DateTime &rDateTime)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define SAL_INFO_IF(condition, area, stream)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
tools::Long const nBorder
const LanguageTag & getLocale()
OUString convertCommaSeparated(uno::Sequence< OUString > const &i_rSeq)
OUString getString(const Any &_rAny)
bool IsControlChar(sal_Unicode cChar)
bool ExtractOLE2FromObjdata(const OString &rObjdata, SvStream &rOle2)
DateTime DTTM2DateTime(tools::Long lDTTM)
rtl_TextEncoding getBestTextEncodingFromLocale(const css::lang::Locale &rLocale)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
sal_Int64 convertHmmToEmu(sal_Int32 nValue)
std::shared_ptr< StorageBase > StorageRef
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
static void lcl_copyFlatten(RTFReferenceProperties &rProps, RTFSprms &rStyleAttributes, RTFSprms &rStyleSprms)
Copy rProps to rStyleAttributes and rStyleSprms, but in case of nested sprms, copy their children as ...
bool findPropertyName(const std::vector< beans::PropertyValue > &rProperties, const OUString &rName)
RTFValue::Pointer_t getNestedAttribute(RTFSprms &rSprms, Id nParent, Id nId)
Looks up the nParent then the nested nId attribute in rSprms.
static RTFSprms lcl_getBookmarkProperties(int nPos, const OUString &rString)
RTFFontNameSuffix const aRTFFontNameSuffixes[]
std::tuple< RTFBufferTypes, RTFValue::Pointer_t, tools::SvRef< TableRowBuffer > > Buf_t
A buffer storing dmapper calls.
RTFSymbol const aRTFControlWords[]
void putNestedAttribute(RTFSprms &rSprms, Id nParent, Id nId, const RTFValue::Pointer_t &pValue, RTFOverwrite eOverwrite, bool bAttribute)
bool eraseNestedAttribute(RTFSprms &rSprms, Id nParent, Id nId)
@ NO_APPEND
No, always append the value to the end of the list.
@ YES_PREPEND
Yes, always prepend the value to the start of the list and remove existing entries.
@ YES
Yes, if an existing key is found, overwrite it.
void putNestedSprm(RTFSprms &rSprms, Id nParent, Id nId, const RTFValue::Pointer_t &pValue, RTFOverwrite eOverwrite)
RTFValue::Pointer_t getNestedSprm(RTFSprms &rSprms, Id nParent, Id nId)
Looks up the nParent then the nested nId sprm in rSprms.
Destination
An RTF destination state is the last open destination control word.
@ PARAGRAPHNUMBERING_TEXTAFTER
@ ANNOTATIONREFERENCESTART
@ PARAGRAPHNUMBERING_TEXTBEFORE
static util::DateTime lcl_getDateTime(RTFParserState const &aState)
RTFFormFieldType
Form field types.
Id getParagraphBorder(sal_uInt32 nIndex)
OString DTTM22OString(tools::Long nDTTM)
@ BUFFER_RESOLVESHAPE
Imports a shape.
@ BUFFER_RESOLVESUBSTREAM
@ BUFFER_PROPS
Stores properties, should be created only in bufferProperties().
@ BUFFER_PICTURE
Restores RTFParserState::aPicture.
static auto FilterControlChars(Destination const destination, OUString const &rString) -> OUString
RTFSprms & getLastAttributes(RTFSprms &rSprms, Id nId)
const char * keywordToString(RTFKeyword nKeyword)
static void lcl_DestinationToMath(OUStringBuffer *pDestinationText, oox::formulaimport::XmlStreamBuilder &rMathBuffer, bool &rMathNor)
std::deque< Buf_t > RTFBuffer_t
static bool lcl_containsProperty(const uno::Sequence< beans::Property > &rProperties, std::u16string_view rName)
const int nRTFControlWords
void putBorderProperty(RTFStack &aStates, Id nId, const RTFValue::Pointer_t &pValue)
const sal_uInt8 cFieldSep
const sal_uInt8 cFieldStart
const sal_uInt8 cFieldEnd
const sal_uInt8 cFieldLock
HashMap_OWString_Interface aMap
An RTF stack is similar to std::stack, except that it has an operator[].
void push(RTFParserState const &rState)
Reference< XFrame > xFrame