summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/filter/ww8')
-rw-r--r--sw/source/filter/ww8/WW8FFData.cxx2
-rw-r--r--sw/source/filter/ww8/WW8Sttbf.cxx19
-rw-r--r--sw/source/filter/ww8/WW8Sttbf.hxx10
-rw-r--r--sw/source/filter/ww8/WW8TableInfo.cxx24
-rw-r--r--sw/source/filter/ww8/WW8TableInfo.hxx1
-rw-r--r--sw/source/filter/ww8/attributeoutputbase.hxx57
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx4459
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx318
-rw-r--r--sw/source/filter/ww8/docxexport.cxx590
-rw-r--r--sw/source/filter/ww8/docxexport.hxx33
-rw-r--r--sw/source/filter/ww8/docxexportfilter.cxx35
-rw-r--r--sw/source/filter/ww8/docxhelper.hxx2
-rw-r--r--sw/source/filter/ww8/docxsdrexport.cxx1161
-rw-r--r--sw/source/filter/ww8/docxsdrexport.hxx9
-rw-r--r--sw/source/filter/ww8/docxtableexport.cxx898
-rw-r--r--sw/source/filter/ww8/docxtablestyleexport.cxx79
-rw-r--r--sw/source/filter/ww8/escher.hxx15
-rw-r--r--sw/source/filter/ww8/fields.cxx2
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx1156
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.hxx85
-rw-r--r--sw/source/filter/ww8/rtfexport.cxx489
-rw-r--r--sw/source/filter/ww8/rtfexport.hxx23
-rw-r--r--sw/source/filter/ww8/rtfexportfilter.cxx15
-rw-r--r--sw/source/filter/ww8/rtfexportfilter.hxx8
-rw-r--r--sw/source/filter/ww8/rtfsdrexport.cxx53
-rw-r--r--sw/source/filter/ww8/rtfstringbuffer.cxx8
-rw-r--r--sw/source/filter/ww8/sortedarray.hxx43
-rw-r--r--sw/source/filter/ww8/sprmids.hxx1
-rw-r--r--sw/source/filter/ww8/styles.cxx186
-rw-r--r--sw/source/filter/ww8/writerhelper.cxx113
-rw-r--r--sw/source/filter/ww8/writerhelper.hxx158
-rw-r--r--sw/source/filter/ww8/writerwordglue.cxx172
-rw-r--r--sw/source/filter/ww8/writerwordglue.hxx8
-rw-r--r--sw/source/filter/ww8/wrtw8esh.cxx532
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx981
-rw-r--r--sw/source/filter/ww8/wrtw8num.cxx193
-rw-r--r--sw/source/filter/ww8/wrtw8sty.cxx1010
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx1336
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx277
-rw-r--r--sw/source/filter/ww8/wrtww8gr.cxx172
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx1020
-rw-r--r--sw/source/filter/ww8/ww8attributeoutput.hxx112
-rw-r--r--sw/source/filter/ww8/ww8glsy.cxx83
-rw-r--r--sw/source/filter/ww8/ww8glsy.hxx18
-rw-r--r--sw/source/filter/ww8/ww8graf.cxx381
-rw-r--r--sw/source/filter/ww8/ww8graf2.cxx81
-rw-r--r--sw/source/filter/ww8/ww8par.cxx1301
-rw-r--r--sw/source/filter/ww8/ww8par.hxx304
-rw-r--r--sw/source/filter/ww8/ww8par2.cxx510
-rw-r--r--sw/source/filter/ww8/ww8par2.hxx38
-rw-r--r--sw/source/filter/ww8/ww8par3.cxx535
-rw-r--r--sw/source/filter/ww8/ww8par4.cxx55
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx440
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx720
-rw-r--r--sw/source/filter/ww8/ww8scan.cxx1072
-rw-r--r--sw/source/filter/ww8/ww8scan.hxx244
-rw-r--r--sw/source/filter/ww8/ww8struc.hxx26
-rw-r--r--sw/source/filter/ww8/ww8toolbar.cxx430
-rw-r--r--sw/source/filter/ww8/ww8toolbar.hxx162
59 files changed, 12883 insertions, 9382 deletions
diff --git a/sw/source/filter/ww8/WW8FFData.cxx b/sw/source/filter/ww8/WW8FFData.cxx
index 291cd845d439..ea7288e349ab 100644
--- a/sw/source/filter/ww8/WW8FFData.cxx
+++ b/sw/source/filter/ww8/WW8FFData.cxx
@@ -76,7 +76,7 @@ void WW8FFData::WriteOUString(SvStream * pDataStrm, const OUString & rStr,
void WW8FFData::Write(SvStream * pDataStrm)
{
- sal_uLong nDataStt = pDataStrm->Tell();
+ sal_uInt64 nDataStt = pDataStrm->Tell();
static const sal_uInt8 aHeader[] =
{
diff --git a/sw/source/filter/ww8/WW8Sttbf.cxx b/sw/source/filter/ww8/WW8Sttbf.cxx
index 1e23c8ca89a7..3143faece7dd 100644
--- a/sw/source/filter/ww8/WW8Sttbf.cxx
+++ b/sw/source/filter/ww8/WW8Sttbf.cxx
@@ -24,14 +24,12 @@
#include "WW8Sttbf.hxx"
#include <osl/endian.h>
#include <o3tl/make_shared.hxx>
+#include <o3tl/safeint.hxx>
+#include <rtl/ustrbuf.hxx>
#include <tools/stream.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
-#ifdef OSL_BIGENDIAN
-#include <rtl/ustrbuf.hxx>
-#endif
-
namespace ww8
{
WW8Struct::WW8Struct(SvStream& rSt, sal_uInt32 nPos, sal_uInt32 nSize)
@@ -70,7 +68,7 @@ namespace ww8
}
OUString WW8Struct::getUString(sal_uInt32 nOffset,
- sal_uInt32 nCount)
+ sal_Int32 nCount)
{
OUString aResult;
@@ -81,17 +79,12 @@ namespace ww8
if (nStartOff >= mn_size)
return aResult;
sal_uInt32 nAvailable = (mn_size - nStartOff)/sizeof(sal_Unicode);
- if (nCount > nAvailable)
+ if (o3tl::make_unsigned(nCount) > nAvailable)
nCount = nAvailable;
-#if defined OSL_LITENDIAN
- aResult = OUString(reinterpret_cast<const sal_Unicode *>(
- m_pData.get() + nStartOff), nCount);
-#else
- OUStringBuffer aBuf;
- for (sal_uInt32 i = 0; i < nCount; ++i)
+ OUStringBuffer aBuf(nCount);
+ for (sal_Int32 i = 0; i < nCount; ++i)
aBuf.append(static_cast<sal_Unicode>(getU16(nStartOff+i*2)));
aResult = aBuf.makeStringAndClear();
-#endif
}
SAL_INFO( "sw.ww8.level2", "<WW8Struct-getUString offset=\"" << nOffset
diff --git a/sw/source/filter/ww8/WW8Sttbf.hxx b/sw/source/filter/ww8/WW8Sttbf.hxx
index 89ec4113b308..c061362bf829 100644
--- a/sw/source/filter/ww8/WW8Sttbf.hxx
+++ b/sw/source/filter/ww8/WW8Sttbf.hxx
@@ -47,14 +47,14 @@ namespace ww8
sal_uInt16 getU16(sal_uInt32 nOffset)
{ return getU8(nOffset) + (getU8(nOffset + 1) << 8); }
- OUString getUString(sal_uInt32 nOffset, sal_uInt32 nCount);
+ OUString getUString(sal_uInt32 nOffset, sal_Int32 nCount);
};
template <class T>
class WW8Sttb : public WW8Struct
{
typedef std::shared_ptr< void > ExtraPointer_t;
- bool bDoubleByteCharacters;
+ bool m_bDoubleByteCharacters;
std::vector<OUString> m_Strings;
std::vector< ExtraPointer_t > m_Extras;
@@ -70,13 +70,13 @@ namespace ww8
template <class T>
WW8Sttb<T>::WW8Sttb(SvStream& rSt, sal_Int32 nPos, sal_uInt32 nSize)
- : WW8Struct(rSt, nPos, nSize), bDoubleByteCharacters(false)
+ : WW8Struct(rSt, nPos, nSize), m_bDoubleByteCharacters(false)
{
sal_uInt32 nOffset = 0;
if (getU16(nOffset) == 0xffff)
{
- bDoubleByteCharacters = true;
+ m_bDoubleByteCharacters = true;
nOffset += 2;
}
@@ -86,7 +86,7 @@ namespace ww8
nOffset += 4;
for (sal_uInt16 i = 0; i < nCount; i++)
{
- if (bDoubleByteCharacters)
+ if (m_bDoubleByteCharacters)
{
sal_uInt16 nStrLen = getU16(nOffset);
diff --git a/sw/source/filter/ww8/WW8TableInfo.cxx b/sw/source/filter/ww8/WW8TableInfo.cxx
index 907e4131cec0..5f843439bf2b 100644
--- a/sw/source/filter/ww8/WW8TableInfo.cxx
+++ b/sw/source/filter/ww8/WW8TableInfo.cxx
@@ -28,6 +28,7 @@
#include <dbgoutsw.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
+#include <rtl/string.hxx>
namespace ww8
{
@@ -49,10 +50,6 @@ WW8TableNodeInfoInner::WW8TableNodeInfoInner(WW8TableNodeInfo * pParent)
{
}
-WW8TableNodeInfoInner::~WW8TableNodeInfoInner()
-{
-}
-
void WW8TableNodeInfoInner::setDepth(sal_uInt32 nDepth)
{
mnDepth = nDepth;
@@ -580,7 +577,7 @@ WW8TableInfo::processSwTableByLayout(const SwTable * pTable, RowEndInners_t &rLa
bool bDone = false;
do
{
- SwNode & rNode = aPam.GetPoint()->nNode.GetNode();
+ SwNode & rNode = aPam.GetPoint()->GetNode();
insertTableNodeInfo(&rNode, pTable, pTableBox, 0, 0, 1, & aRect);
@@ -593,7 +590,7 @@ WW8TableInfo::processSwTableByLayout(const SwTable * pTable, RowEndInners_t &rLa
bDone = true;
}
- aPam.GetPoint()->nNode++;
+ aPam.GetPoint()->Adjust(SwNodeOffset(1));
}
while (!bDone);
}
@@ -705,14 +702,14 @@ WW8TableInfo::processTableBoxLines(const SwTableBox * pBox,
bool bDone = false;
while (!bDone)
{
- SwNode & rNode = aPaM.GetPoint()->nNode.GetNode();
+ SwNode & rNode = aPaM.GetPoint()->GetNode();
pNodeInfo = insertTableNodeInfo(&rNode, pTable, pBoxToSet, nRow, nCell, nDepth);
- if (aPaM.GetPoint()->nNode == aEndPaM.GetPoint()->nNode)
+ if (aPaM.GetPoint()->GetNode() == aEndPaM.GetPoint()->GetNode())
bDone = true;
else
- aPaM.GetPoint()->nNode++;
+ aPaM.GetPoint()->Adjust(SwNodeOffset(1));
}
}
@@ -775,7 +772,7 @@ WW8TableInfo::processTableBox(const SwTable * pTable,
do
{
- SwNode & rNode = aPaM.GetPoint()->nNode.GetNode();
+ SwNode & rNode = aPaM.GetPoint()->GetNode();
if (rNode.IsStartNode())
{
@@ -808,7 +805,7 @@ WW8TableInfo::processTableBox(const SwTable * pTable,
bDone = true;
}
- aPaM.GetPoint()->nNode++;
+ aPaM.GetPoint()->Adjust(SwNodeOffset(1));
}
while (!bDone);
@@ -1278,8 +1275,9 @@ std::string WW8TableCellGrid::toString()
static char sBuffer[1024];
while (aTopsIt != getRowTopsEnd())
{
- sprintf(sBuffer, "<row y=\"%" SAL_PRIdINT64 "\">", sal_Int64(*aTopsIt));
- sResult += sBuffer;
+ sResult += "<row y=\"";
+ sResult += OString::number(*aTopsIt);
+ sResult += "\">";
CellInfoMultiSet::const_iterator aCellIt = getCellsBegin(*aTopsIt);
CellInfoMultiSet::const_iterator aCellsEnd = getCellsEnd(*aTopsIt);
diff --git a/sw/source/filter/ww8/WW8TableInfo.hxx b/sw/source/filter/ww8/WW8TableInfo.hxx
index 5b3294cd506e..bae0e69f5821 100644
--- a/sw/source/filter/ww8/WW8TableInfo.hxx
+++ b/sw/source/filter/ww8/WW8TableInfo.hxx
@@ -70,7 +70,6 @@ public:
typedef std::shared_ptr<WW8TableNodeInfoInner> Pointer_t;
explicit WW8TableNodeInfoInner(WW8TableNodeInfo * pParent);
- ~WW8TableNodeInfoInner();
void setDepth(sal_uInt32 nDepth);
void setCell(sal_uInt32 nCell);
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index 34920374537c..4ce7f495cc3b 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -31,7 +31,7 @@
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include <swtypes.hxx>
#include <fldbas.hxx>
-#include <unotools/saveopt.hxx>
+#include <utility>
class Point;
class SvxCaseMapItem;
@@ -143,7 +143,6 @@ enum StyleType
class AttributeOutputBase
{
private:
- SvtSaveOptions m_aSaveOpt;
OUString m_sBaseURL; // To be used in ConvertURL
OUString ConvertURL( const OUString& rUrl, bool bAbsoluteOut );
@@ -174,7 +173,7 @@ public:
virtual void StartRun( const SwRedlineData* pRedlineData, sal_Int32 nPos, bool bSingleEmptyRun = false ) = 0;
/// End of the text run.
- virtual void EndRun( const SwTextNode* pNode, sal_Int32 nPos, bool bLastRun = false ) = 0;
+ virtual void EndRun( const SwTextNode* pNode, sal_Int32 nPos, sal_Int32 nLen, bool bLastRun = false ) = 0;
/// Called before we start outputting the attributes.
virtual void StartRunProperties() = 0;
@@ -192,7 +191,7 @@ public:
virtual void WritePostitFieldReference() {};
/// Output text (inside a run).
- virtual void RunText( const OUString& rText, rtl_TextEncoding eCharSet = RTL_TEXTENCODING_UTF8 ) = 0;
+ virtual void RunText( const OUString& rText, rtl_TextEncoding eCharSet = RTL_TEXTENCODING_UTF8, const OUString& rSymbolFont = OUString() ) = 0;
/// Output text (without markup).
virtual void RawText(const OUString& rText, rtl_TextEncoding eCharSet) = 0;
@@ -209,7 +208,7 @@ public:
/// Output URL end.
virtual bool EndURL(bool isAtEndOfParagraph) = 0;
- virtual void FieldVanish(const OUString& rText, ww::eField eType, OUString const*) = 0;
+ virtual void FieldVanish(const OUString& rText, ww::eField eType, OUString const* pBookmarkName) = 0;
/// MSO uses bookmarks to reference sequence fields, so we need to generate these additional bookmarks during export
void GenerateBookmarksForSequenceField(const SwTextNode& rNode, SwWW8AttrIter& rAttrIter);
@@ -235,33 +234,33 @@ public:
/// Output style.
virtual void ParagraphStyle( sal_uInt16 nStyle ) = 0;
- virtual void TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0;
+ virtual void TableInfoCell( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) = 0;
- virtual void TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0;
+ virtual void TableInfoRow( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) = 0;
- virtual void TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0;
+ virtual void TableDefinition( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) = 0;
- virtual void TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0;
+ virtual void TableDefaultBorders( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) = 0;
- virtual void TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0;
+ virtual void TableBackgrounds( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) = 0;
- virtual void TableRowRedline( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0;
+ virtual void TableRowRedline( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) = 0;
- virtual void TableCellRedline( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0;
+ virtual void TableCellRedline( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) = 0;
- virtual void TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0;
+ virtual void TableHeight( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) = 0;
- virtual void TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0;
+ virtual void TableCanSplit( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) = 0;
- virtual void TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0;
+ virtual void TableBidi( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) = 0;
- virtual void TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0;
+ virtual void TableVerticalCell( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) = 0;
- virtual void TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner ) = 0;
+ virtual void TableNodeInfoInner( const ww8::WW8TableNodeInfoInner::Pointer_t& pNodeInfoInner ) = 0;
- virtual void TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) = 0;
+ virtual void TableOrientation( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) = 0;
- virtual void TableSpacing( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) = 0;
+ virtual void TableSpacing( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) = 0;
virtual void TableRowEnd( sal_uInt32 nDepth ) = 0;
@@ -276,7 +275,7 @@ public:
/// Start of a style in the styles table.
virtual void StartStyle( const OUString& rName, StyleType eType,
- sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 nWwId, sal_uInt16 nId,
+ sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 nLink, sal_uInt16 nWwId, sal_uInt16 nSlot,
bool bAutoUpdate ) = 0;
/// End of a style in the styles table.
@@ -369,7 +368,8 @@ public:
sal_Int16 nFirstLineIndex,
sal_Int16 nListTabPos,
const OUString &rNumberingString,
- const SvxBrushItem* pBrush) = 0; // #i120928 export graphic of bullet
+ const SvxBrushItem* pBrush, // #i120928 export graphic of bullet
+ bool isLegal) = 0;
protected:
@@ -509,6 +509,9 @@ protected:
/// Sfx item RES_TXTATR_FTN
virtual void TextFootnote_Impl( const SwFormatFootnote& ) = 0;
+ /// RES_TXTATR_LINEBREAK, i.e. clearing breaks.
+ virtual void TextLineBreak(const SwFormatLineBreak&) = 0;
+
/// Sfx item RES_PARATR_LINESPACING
void ParaLineSpacing( const SvxLineSpacingItem& );
@@ -557,6 +560,13 @@ protected:
/// Sfx item RES_PAPER_BIN
virtual void FormatPaperBin( const SvxPaperBinItem& ) = 0;
+ /// Sfx item RES_MARGIN_FIRSTLINE
+ virtual void FormatFirstLineIndent(const SvxFirstLineIndentItem & rFirstLine) = 0;
+ /// Sfx item RES_MARGIN_TEXTLEFT
+ virtual void FormatTextLeftMargin(const SvxTextLeftMarginItem & rTextLeftMargin) = 0;
+ /// Sfx item RES_MARGIN_RIGHT
+ virtual void FormatRightMargin(const SvxRightMarginItem & rRightMargin) = 0;
+
/// Sfx item RES_LR_SPACE
virtual void FormatLRSpace( const SvxLRSpaceItem& ) = 0;
@@ -608,6 +618,7 @@ protected:
virtual void FormatTextGrid( const SwTextGridItem& ) = 0;
/// Sfx item RES_LINENUMBER
+ void FormatLineNumberingBase(const SwFormatLineNumber&);
virtual void FormatLineNumbering( const SwFormatLineNumber& ) = 0;
/// Sfx item RES_FRAMEDIR
@@ -645,8 +656,8 @@ protected:
virtual void SectionRtlGutter(const SfxBoolItem& rRtlGutter) = 0;
public:
- AttributeOutputBase(const OUString& sBaseURL)
- : m_sBaseURL(sBaseURL)
+ AttributeOutputBase(OUString sBaseURL)
+ : m_sBaseURL(std::move(sBaseURL))
{
}
virtual ~AttributeOutputBase() {}
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index f0775d63f6b8..31711eb4e887 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -34,7 +34,6 @@
#include <fmtanchr.hxx>
#include <breakit.hxx>
#include <redline.hxx>
-#include <unocoll.hxx>
#include <unoframe.hxx>
#include <textboxhelper.hxx>
#include <rdfhelper.hxx>
@@ -48,11 +47,12 @@
#include <oox/token/namespaces.hxx>
#include <oox/token/tokens.hxx>
#include <oox/export/utils.hxx>
-#include <oox/mathml/export.hxx>
+#include <oox/mathml/imexport.hxx>
#include <oox/drawingml/drawingmltypes.hxx>
#include <oox/token/relationship.hxx>
#include <oox/export/vmlexport.hxx>
#include <oox/ole/olehelper.hxx>
+#include <oox/export/drawingml.hxx>
#include <editeng/autokernitem.hxx>
#include <editeng/unoprnms.hxx>
@@ -98,9 +98,9 @@
#include <svx/svdouno.hxx>
#include <svx/unobrushitemhelper.hxx>
#include <svl/grabbagitem.hxx>
-#include <sfx2/sfxbasemodel.hxx>
+#include <tools/date.hxx>
+#include <tools/datetime.hxx>
#include <tools/datetimeutils.hxx>
-#include <tools/UnitConversion.hxx>
#include <svl/whiter.hxx>
#include <rtl/tencinfo.h>
#include <sal/log.hxx>
@@ -111,7 +111,6 @@
#include <flddropdown.hxx>
#include <fmtclds.hxx>
#include <fmtinfmt.hxx>
-#include <fmtrowsplt.hxx>
#include <fmtline.hxx>
#include <ftninfo.hxx>
#include <htmltbl.hxx>
@@ -134,7 +133,10 @@
#include <frmatr.hxx>
#include <txtatr.hxx>
#include <frameformats.hxx>
+#include <textcontentcontrol.hxx>
+#include <formatflysplit.hxx>
+#include <o3tl/string_view.hxx>
#include <o3tl/unit_conversion.hxx>
#include <osl/file.hxx>
#include <utility>
@@ -147,13 +149,20 @@
#include <com/sun/star/text/GraphicCrop.hpp>
#include <com/sun/star/embed/EmbedStates.hpp>
#include <com/sun/star/embed/Aspects.hpp>
+#include <com/sun/star/text/ControlCharacter.hpp>
#include <algorithm>
+#include <cstddef>
#include <stdarg.h>
#include <string_view>
#include <toolkit/helper/vclunohelper.hxx>
#include <unicode/regex.h>
+#include <frozen/bits/defines.h>
+#include <frozen/bits/elsa_std.h>
+#include <frozen/unordered_map.h>
+#include <IDocumentDeviceAccess.hxx>
+#include <sfx2/printer.hxx>
using ::editeng::SvxBorderLine;
@@ -165,24 +174,6 @@ using namespace sw::util;
using namespace ::com::sun::star;
using namespace ::com::sun::star::drawing;
-const sal_Int32 Tag_StartParagraph_1 = 1;
-const sal_Int32 Tag_StartParagraph_2 = 2;
-const sal_Int32 Tag_WriteSdtBlock = 3;
-const sal_Int32 Tag_StartParagraphProperties = 4;
-const sal_Int32 Tag_InitCollectedParagraphProperties = 5;
-const sal_Int32 Tag_StartRun_1 = 6;
-const sal_Int32 Tag_StartRun_2 = 7;
-const sal_Int32 Tag_StartRun_3 = 8;
-const sal_Int32 Tag_EndRun_1 = 9;
-const sal_Int32 Tag_EndRun_2 = 10;
-const sal_Int32 Tag_StartRunProperties = 11;
-const sal_Int32 Tag_InitCollectedRunProperties = 12;
-//static const sal_Int32 Tag_Redline_1 = 13;
-const sal_Int32 Tag_Redline_2 = 14;
-const sal_Int32 Tag_TableDefinition = 15;
-const sal_Int32 Tag_OutputFlyFrame = 16;
-const sal_Int32 Tag_StartSection = 17;
-
namespace {
class FFDataWriterHelper
@@ -299,8 +290,116 @@ OUString NumberToHexBinary(sal_Int32 n)
return aBuf.makeStringAndClear();
}
+// Returns a new reference with the previous content of src; src is empty after this
+auto detachFrom(rtl::Reference<sax_fastparser::FastAttributeList>& src)
+{
+ return rtl::Reference(std::move(src));
}
+void lclAddThemeValuesToCustomAttributes(
+ rtl::Reference<sax_fastparser::FastAttributeList>& pAttrList, model::ComplexColor const& rComplexColor,
+ sal_Int32 nThemeAttrId, sal_Int32 nThemeTintAttrId, sal_Int32 nThemeShadeAttrId)
+{
+ static constexpr auto constThemeColorTypeTokenMap = frozen::make_unordered_map<model::ThemeColorType, const char*>({
+ { model::ThemeColorType::Dark1, "dark1" },
+ { model::ThemeColorType::Light1, "light1" },
+ { model::ThemeColorType::Dark2, "dark2" },
+ { model::ThemeColorType::Light2, "light2" },
+ { model::ThemeColorType::Accent1, "accent1" },
+ { model::ThemeColorType::Accent2, "accent2" },
+ { model::ThemeColorType::Accent3, "accent3" },
+ { model::ThemeColorType::Accent4, "accent4" },
+ { model::ThemeColorType::Accent5, "accent5" },
+ { model::ThemeColorType::Accent6, "accent6" },
+ { model::ThemeColorType::Hyperlink, "hyperlink" },
+ { model::ThemeColorType::FollowedHyperlink, "followedHyperlink" }
+ });
+
+ if (rComplexColor.isValidThemeType())
+ {
+ const auto iter = constThemeColorTypeTokenMap.find(rComplexColor.getThemeColorType());
+ assert(iter != constThemeColorTypeTokenMap.end());
+ OString sSchemeType = iter->second;
+ if (rComplexColor.getThemeColorUsage() == model::ThemeColorUsage::Text)
+ {
+ if (rComplexColor.getThemeColorType() == model::ThemeColorType::Dark1)
+ sSchemeType = "text1"_ostr;
+ else if (rComplexColor.getThemeColorType() == model::ThemeColorType::Dark2)
+ sSchemeType = "text2"_ostr;
+ }
+ else if (rComplexColor.getThemeColorUsage() == model::ThemeColorUsage::Background)
+ {
+ if (rComplexColor.getThemeColorType() == model::ThemeColorType::Light1)
+ sSchemeType = "background1"_ostr;
+ else if (rComplexColor.getThemeColorType() == model::ThemeColorType::Light2)
+ sSchemeType = "background2"_ostr;
+ }
+
+ DocxAttributeOutput::AddToAttrList(pAttrList, FSNS(XML_w, nThemeAttrId), sSchemeType);
+
+ sal_Int16 nLumMod = 10'000;
+ sal_Int16 nLumOff = 0;
+ sal_Int16 nTint = 0;
+ sal_Int16 nShade = 0;
+
+ for (auto const& rTransform : rComplexColor.getTransformations())
+ {
+ if (rTransform.meType == model::TransformationType::LumMod)
+ nLumMod = rTransform.mnValue;
+ if (rTransform.meType == model::TransformationType::LumOff)
+ nLumOff = rTransform.mnValue;
+ if (rTransform.meType == model::TransformationType::Tint)
+ nTint = rTransform.mnValue;
+ if (rTransform.meType == model::TransformationType::Shade)
+ nShade = rTransform.mnValue;
+ }
+ if (nLumMod == 10'000 && nLumOff == 0)
+ {
+ if (nTint != 0)
+ {
+ // Convert from 0-100 into 0-255
+ sal_Int16 nTint255 = std::round(255.0 - (double(nTint) / 10000.0) * 255.0);
+ DocxAttributeOutput::AddToAttrList(pAttrList, FSNS(XML_w, nThemeTintAttrId), OString::number(nTint255, 16));
+ }
+ else if (nShade != 0)
+ {
+ // Convert from 0-100 into 0-255
+ sal_Int16 nShade255 = std::round(255.0 - (double(nShade) / 10000.0) * 255.0);
+ DocxAttributeOutput::AddToAttrList(pAttrList, FSNS(XML_w, nThemeShadeAttrId), OString::number(nShade255, 16));
+ }
+ }
+ else
+ {
+ double nPercentage = 0.0;
+
+ if (nLumOff > 0)
+ nPercentage = double(nLumOff) / 100.0;
+ else
+ nPercentage = (-10'000 + double(nLumMod)) / 100.0;
+
+ // Convert from 0-100 into 0-255
+ sal_Int16 nTintShade255 = std::round(255.0 - (std::abs(nPercentage) / 100.0) * 255.0);
+
+ if (nPercentage > 0)
+ DocxAttributeOutput::AddToAttrList(pAttrList, FSNS(XML_w, nThemeTintAttrId), OString::number(nTintShade255, 16));
+ else if (nPercentage < 0)
+ DocxAttributeOutput::AddToAttrList(pAttrList, FSNS(XML_w, nThemeShadeAttrId), OString::number(nTintShade255, 16));
+ }
+ }
+}
+
+void lclAddThemeFillColorAttributes(rtl::Reference<sax_fastparser::FastAttributeList>& pAttrList, model::ComplexColor const& rComplexColor)
+{
+ lclAddThemeValuesToCustomAttributes(pAttrList, rComplexColor, XML_themeFill, XML_themeFillTint, XML_themeFillShade);
+}
+
+void lclAddThemeColorAttributes(rtl::Reference<sax_fastparser::FastAttributeList>& pAttrList, model::ComplexColor const& rComplexColor)
+{
+ lclAddThemeValuesToCustomAttributes(pAttrList, rComplexColor, XML_themeColor, XML_themeTint, XML_themeShade);
+}
+
+} // end anonymous namespace
+
void DocxAttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 /*nScript*/ )
{
if (bIsRTL)
@@ -320,12 +419,15 @@ void DocxAttributeOutput::WriteFloatingTable(ww8::Frame const* pParentFrame)
m_aFloatingTablesOfParagraph.insert(&rFrameFormat);
const SwNodeIndex* pNodeIndex = rFrameFormat.GetContent().GetContentIdx();
- sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex() + 1 : 0;
- sal_uLong nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0;
+ SwNodeOffset nStt = pNodeIndex ? pNodeIndex->GetIndex() + 1 : SwNodeOffset(0);
+ SwNodeOffset nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : SwNodeOffset(0);
//Save data here and restore when out of scope
ExportDataSaveRestore aDataGuard(GetExport(), nStt, nEnd, pParentFrame);
+ // Stash away info about the current table, so m_tableReference is clean.
+ DocxTableExportContext aTableExportContext(*this);
+
// set a floatingTableFrame AND unset parent frame,
// otherwise exporter thinks we are still in a frame
m_rExport.SetFloatingTableFrame(pParentFrame);
@@ -344,12 +446,12 @@ static void checkAndWriteFloatingTables(DocxAttributeOutput& rDocxAttributeOutpu
{
const SwFrameFormat* pFrameFormat = (*rExport.m_rDoc.GetSpzFrameFormats())[ --nCnt ];
const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor();
- const SwPosition* pPosition = rAnchor.GetContentAnchor();
+ const SwNode* pAnchorNode = rAnchor.GetAnchorNode();
- if (!pPosition || ! rExport.m_pCurPam->GetNode().GetTextNode())
+ if (!pAnchorNode || ! rExport.m_pCurPam->GetPointNode().GetTextNode())
continue;
- if (pPosition->nNode != rExport.m_pCurPam->GetNode().GetTextNode()->GetIndex())
+ if (*pAnchorNode != *rExport.m_pCurPam->GetPointNode().GetTextNode())
continue;
const SwNodeIndex* pStartNode = pFrameFormat->GetContent().GetContentIdx();
@@ -366,7 +468,7 @@ static void checkAndWriteFloatingTables(DocxAttributeOutput& rDocxAttributeOutpu
continue;
// go to the end of the table
- sal_uLong aEndIndex = aStartNode.GetNode().EndOfSectionIndex();
+ SwNodeOffset aEndIndex = aStartNode.GetNode().EndOfSectionIndex();
// go one deeper
aEndIndex++;
// this has to be the end of the content
@@ -378,13 +480,20 @@ static void checkAndWriteFloatingTables(DocxAttributeOutput& rDocxAttributeOutpu
SwTable& rTable = pTableNode->GetTable();
SwFrameFormat* pTableFormat = rTable.GetFrameFormat();
const SfxGrabBagItem* pTableGrabBag = pTableFormat->GetAttrSet().GetItem<SfxGrabBagItem>(RES_FRMATR_GRABBAG);
- std::map<OUString, css::uno::Any> aTableGrabBag = pTableGrabBag->GetGrabBag();
+ const std::map<OUString, css::uno::Any> & rTableGrabBag = pTableGrabBag->GetGrabBag();
// no grabbag?
- if (aTableGrabBag.find("TablePosition") == aTableGrabBag.end())
+ if (rTableGrabBag.find("TablePosition") == rTableGrabBag.end())
+ {
+ if (pFrameFormat->GetFlySplit().GetValue())
+ {
+ ww8::Frame aFrame(*pFrameFormat, *rAnchor.GetContentAnchor());
+ rDocxAttributeOutput.WriteFloatingTable(&aFrame);
+ }
continue;
+ }
// write table to docx
- ww8::Frame aFrame(*pFrameFormat,*pPosition);
+ ww8::Frame aFrame(*pFrameFormat, *rAnchor.GetContentAnchor());
rDocxAttributeOutput.WriteFloatingTable(&aFrame);
}
}
@@ -398,13 +507,6 @@ sal_Int32 DocxAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t p
if ( !m_aFramesOfParagraph.size() || !m_nTextFrameLevel )
m_aFramesOfParagraph.push(std::vector<ww8::Frame>());
- // look ahead for floating tables that were put into a frame during import
- // floating tables in shapes are not supported: exclude this case
- if (!pTextNodeInfo && !m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen())
- {
- checkAndWriteFloatingTables(*this);
- }
-
if ( m_nColBreakStatus == COLBRK_POSTPONE )
m_nColBreakStatus = COLBRK_WRITE;
@@ -412,9 +514,9 @@ sal_Int32 DocxAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t p
if ( pTextNodeInfo )
{
// New cell/row?
- if ( m_tableReference->m_nTableDepth > 0 && !m_tableReference->m_bTableCellOpen )
+ if ( m_tableReference.m_nTableDepth > 0 && !m_tableReference.m_bTableCellOpen )
{
- ww8::WW8TableNodeInfoInner::Pointer_t pDeepInner( pTextNodeInfo->getInnerForDepth( m_tableReference->m_nTableDepth ) );
+ ww8::WW8TableNodeInfoInner::Pointer_t pDeepInner( pTextNodeInfo->getInnerForDepth( m_tableReference.m_nTableDepth ) );
if ( pDeepInner->getCell() == 0 )
StartTableRow( pDeepInner );
@@ -434,10 +536,10 @@ sal_Int32 DocxAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t p
// continue the table cell]
sal_uInt32 nCurrentDepth = pTextNodeInfo->getDepth();
- if ( nCurrentDepth > m_tableReference->m_nTableDepth )
+ if ( nCurrentDepth > m_tableReference.m_nTableDepth )
{
// Start all the tables that begin here
- for ( sal_uInt32 nDepth = m_tableReference->m_nTableDepth + 1; nDepth <= nCurrentDepth; ++nDepth )
+ for ( sal_uInt32 nDepth = m_tableReference.m_nTableDepth + 1; nDepth <= nCurrentDepth; ++nDepth )
{
ww8::WW8TableNodeInfoInner::Pointer_t pInner( pTextNodeInfo->getInnerForDepth( nDepth ) );
@@ -447,18 +549,27 @@ sal_Int32 DocxAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t p
StartTableCell(pInner, 0, nDepth == nCurrentDepth ? nRow : 0);
}
- m_tableReference->m_nTableDepth = nCurrentDepth;
+ m_tableReference.m_nTableDepth = nCurrentDepth;
}
}
}
+ // look ahead for floating tables that were put into a frame during import
+ // floating tables in shapes are not supported: exclude this case
+ if (!m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen())
+ {
+ // Do this after opening table/row/cell, so floating tables anchored at cell start go inside
+ // the cell, not outside.
+ checkAndWriteFloatingTables(*this);
+ }
+
// Look up the "sdt end before this paragraph" property early, when it
// would normally arrive, it would be too late (would be after the
// paragraph start has been written).
bool bEndParaSdt = false;
- if (m_bStartedParaSdt)
+ if (m_aParagraphSdt.m_bStartedSdt)
{
- SwTextNode* pTextNode = m_rExport.m_pCurPam->GetNode().GetTextNode();
+ SwTextNode* pTextNode = m_rExport.m_pCurPam->GetPointNode().GetTextNode();
if (pTextNode && pTextNode->GetpSwAttrSet())
{
const SfxItemSet* pSet = pTextNode->GetpSwAttrSet();
@@ -466,17 +577,16 @@ sal_Int32 DocxAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t p
{
const SfxGrabBagItem& rParaGrabBag = static_cast<const SfxGrabBagItem&>(*pItem);
const std::map<OUString, css::uno::Any>& rMap = rParaGrabBag.GetGrabBag();
- bEndParaSdt = m_bStartedParaSdt && rMap.find("ParaSdtEndBefore") != rMap.end();
+ bEndParaSdt = m_aParagraphSdt.m_bStartedSdt && rMap.contains("ParaSdtEndBefore");
}
}
}
// TODO also avoid multiline paragraphs in those SDT types for shape text
- bool bOneliner = m_bStartedParaSdt && !m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen() && lcl_isOnelinerSdt(m_aStartedParagraphSdtPrAlias);
- if (bEndParaSdt || (m_bStartedParaSdt && m_bHadSectPr) || bOneliner)
+ bool bOneliner = m_aParagraphSdt.m_bStartedSdt && !m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen() && lcl_isOnelinerSdt(m_aStartedParagraphSdtPrAlias);
+ if (bEndParaSdt || (m_aParagraphSdt.m_bStartedSdt && m_bHadSectPr) || bOneliner)
{
// This is the common case: "close sdt before the current paragraph" was requested by the next paragraph.
- EndSdtBlock();
- m_bStartedParaSdt = false;
+ m_aParagraphSdt.EndSdtBlock(m_pSerializer);
m_aStartedParagraphSdtPrAlias.clear();
}
m_bHadSectPr = false;
@@ -503,114 +613,472 @@ sal_Int32 DocxAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t p
m_bParagraphOpened = true;
m_bIsFirstParagraph = false;
+ m_nHyperLinkCount.push_back(0);
return nParaId;
}
-static OString convertToOOXMLVertOrient(sal_Int16 nOrient)
+OString DocxAttributeOutput::convertToOOXMLVertOrient(sal_Int16 nOrient)
{
switch( nOrient )
{
case text::VertOrientation::CENTER:
case text::VertOrientation::LINE_CENTER:
- return "center";
+ return "center"_ostr;
case text::VertOrientation::BOTTOM:
- return "bottom";
+ return "bottom"_ostr;
case text::VertOrientation::LINE_BOTTOM:
- return "outside";
+ return "outside"_ostr;
case text::VertOrientation::TOP:
- return "top";
+ return "top"_ostr;
case text::VertOrientation::LINE_TOP:
- return "inside";
+ return "inside"_ostr;
default:
return OString();
}
}
-static OString convertToOOXMLHoriOrient(sal_Int16 nOrient, bool bIsPosToggle)
+OString DocxAttributeOutput::convertToOOXMLHoriOrient(sal_Int16 nOrient, bool bIsPosToggle)
{
switch( nOrient )
{
case text::HoriOrientation::LEFT:
return bIsPosToggle ? "inside" : "left";
case text::HoriOrientation::INSIDE:
- return "inside";
+ return "inside"_ostr;
case text::HoriOrientation::RIGHT:
return bIsPosToggle ? "outside" : "right";
case text::HoriOrientation::OUTSIDE:
- return "outside";
+ return "outside"_ostr;
case text::HoriOrientation::CENTER:
case text::HoriOrientation::FULL:
- return "center";
+ return "center"_ostr;
default:
return OString();
}
}
-static OString convertToOOXMLVertOrientRel(sal_Int16 nOrientRel)
+OString DocxAttributeOutput::convertToOOXMLVertOrientRel(sal_Int16 nOrientRel)
{
switch (nOrientRel)
{
case text::RelOrientation::PAGE_PRINT_AREA:
- return "margin";
+ return "margin"_ostr;
case text::RelOrientation::PAGE_FRAME:
- return "page";
+ return "page"_ostr;
case text::RelOrientation::FRAME:
case text::RelOrientation::TEXT_LINE:
default:
- return "text";
+ return "text"_ostr;
}
}
-static OString convertToOOXMLHoriOrientRel(sal_Int16 nOrientRel)
+OString DocxAttributeOutput::convertToOOXMLHoriOrientRel(sal_Int16 nOrientRel)
{
switch (nOrientRel)
{
case text::RelOrientation::PAGE_PRINT_AREA:
- return "margin";
+ return "margin"_ostr;
case text::RelOrientation::PAGE_FRAME:
- return "page";
+ return "page"_ostr;
case text::RelOrientation::CHAR:
case text::RelOrientation::PAGE_RIGHT:
case text::RelOrientation::FRAME:
default:
- return "text";
+ return "text"_ostr;
}
}
-static void lcl_deleteAndResetTheLists( rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrTokenChildren, rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrDataBindingAttrs, OUString& rSdtPrAlias)
+void FramePrHelper::SetFrame(ww8::Frame* pFrame, sal_Int32 nTableDepth)
{
- if( pSdtPrTokenChildren.is() )
- pSdtPrTokenChildren.clear();
- if( pSdtPrDataBindingAttrs.is() )
- pSdtPrDataBindingAttrs.clear();
- if (!rSdtPrAlias.isEmpty())
- rSdtPrAlias.clear();
+ assert(!pFrame || !m_pFrame);
+ m_pFrame = pFrame;
+ m_nTableDepth = nTableDepth;
+ if (m_pFrame)
+ {
+ m_bUseFrameBorders = true;
+ m_bUseFrameBackground = true;
+ m_bUseFrameTextDirection = true;
+ }
+}
+
+bool FramePrHelper::UseFrameBorders(sal_Int32 nTableDepth)
+{
+ if (!m_pFrame || m_nTableDepth < nTableDepth)
+ return false;
+
+ return m_bUseFrameBorders;
+}
+
+bool FramePrHelper::UseFrameBackground()
+{
+ if (!m_pFrame)
+ return false;
+
+ return m_bUseFrameBackground;
+}
+
+bool FramePrHelper::UseFrameTextDirection(sal_Int32 nTableDepth)
+{
+ if (!m_pFrame || m_nTableDepth < nTableDepth)
+ return false;
+
+ return m_bUseFrameTextDirection;
+}
+
+void SdtBlockHelper::DeleteAndResetTheLists()
+{
+ if (m_pTokenChildren.is() )
+ m_pTokenChildren.clear();
+ if (m_pDataBindingAttrs.is() )
+ m_pDataBindingAttrs.clear();
+ if (m_pTextAttrs.is())
+ m_pTextAttrs.clear();
+ if (!m_aAlias.isEmpty())
+ m_aAlias.clear();
+ if (!m_aTag.isEmpty())
+ m_aTag.clear();
+ if (!m_aLock.isEmpty())
+ m_aLock.clear();
+ if (!m_aPlaceHolderDocPart.isEmpty())
+ m_aPlaceHolderDocPart.clear();
+ if (!m_aColor.isEmpty())
+ m_aColor.clear();
+ if (!m_aAppearance.isEmpty())
+ m_aAppearance.clear();
+ m_bShowingPlaceHolder = false;
+ m_nId = 0;
+ m_nTabIndex = 0;
+}
+
+void SdtBlockHelper::WriteSdtBlock(const ::sax_fastparser::FSHelperPtr& pSerializer, bool bRunTextIsOn, bool bParagraphHasDrawing)
+{
+ if (m_nSdtPrToken <= 0 && !m_pDataBindingAttrs.is() && !m_nId)
+ return;
+
+ // sdt start mark
+ pSerializer->mark(DocxAttributeOutput::Tag_WriteSdtBlock);
+
+ pSerializer->startElementNS(XML_w, XML_sdt);
+
+ // output sdt properties
+ pSerializer->startElementNS(XML_w, XML_sdtPr);
+
+ if (m_nSdtPrToken > 0 && m_pTokenChildren.is())
+ {
+ if (!m_pTokenAttributes.is())
+ pSerializer->startElement(m_nSdtPrToken);
+ else
+ {
+ pSerializer->startElement(m_nSdtPrToken, detachFrom(m_pTokenAttributes));
+ }
+
+ if (m_nSdtPrToken == FSNS(XML_w, XML_date) || m_nSdtPrToken == FSNS(XML_w, XML_docPartObj) || m_nSdtPrToken == FSNS(XML_w, XML_docPartList) || m_nSdtPrToken == FSNS(XML_w14, XML_checkbox)) {
+ const uno::Sequence<xml::FastAttribute> aChildren = m_pTokenChildren->getFastAttributes();
+ for (const auto& rChild : aChildren)
+ pSerializer->singleElement(rChild.Token, FSNS(XML_w, XML_val), rChild.Value);
+ }
+
+ pSerializer->endElement(m_nSdtPrToken);
+ }
+ else if ((m_nSdtPrToken > 0) && m_nSdtPrToken != FSNS(XML_w, XML_id) && !(bRunTextIsOn && bParagraphHasDrawing))
+ {
+ if (!m_pTokenAttributes.is())
+ pSerializer->singleElement(m_nSdtPrToken);
+ else
+ {
+ pSerializer->singleElement(m_nSdtPrToken, detachFrom(m_pTokenAttributes));
+ }
+ }
+
+ WriteExtraParams(pSerializer);
+
+ pSerializer->endElementNS(XML_w, XML_sdtPr);
+
+ // sdt contents start tag
+ pSerializer->startElementNS(XML_w, XML_sdtContent);
+
+ // prepend the tags since the sdt start mark before the paragraph
+ pSerializer->mergeTopMarks(DocxAttributeOutput::Tag_WriteSdtBlock, sax_fastparser::MergeMarks::PREPEND);
+
+ // write the ending tags after the paragraph
+ m_bStartedSdt = true;
+
+ // clear sdt status
+ m_nSdtPrToken = 0;
+ DeleteAndResetTheLists();
+}
+
+void SdtBlockHelper::WriteExtraParams(const ::sax_fastparser::FSHelperPtr& pSerializer)
+{
+ if (m_nId)
+ {
+ pSerializer->singleElementNS(XML_w, XML_id, FSNS(XML_w, XML_val), OString::number(m_nId));
+ }
+
+ if (m_pDataBindingAttrs.is())
+ {
+ pSerializer->singleElementNS(XML_w, XML_dataBinding, detachFrom(m_pDataBindingAttrs));
+ }
+
+ if (m_pTextAttrs.is())
+ {
+ pSerializer->singleElementNS(XML_w, XML_text, detachFrom(m_pTextAttrs));
+ }
+
+ if (!m_aPlaceHolderDocPart.isEmpty())
+ {
+ pSerializer->startElementNS(XML_w, XML_placeholder);
+ pSerializer->singleElementNS(XML_w, XML_docPart, FSNS(XML_w, XML_val), m_aPlaceHolderDocPart);
+ pSerializer->endElementNS(XML_w, XML_placeholder);
+ }
+
+ if (m_bShowingPlaceHolder)
+ pSerializer->singleElementNS(XML_w, XML_showingPlcHdr);
+
+ if (!m_aColor.isEmpty())
+ {
+ pSerializer->singleElementNS(XML_w15, XML_color, FSNS(XML_w, XML_val), m_aColor);
+ }
+
+ if (!m_aAppearance.isEmpty())
+ {
+ pSerializer->singleElementNS(XML_w15, XML_appearance, FSNS(XML_w15, XML_val), m_aAppearance);
+ }
+
+ if (!m_aAlias.isEmpty())
+ pSerializer->singleElementNS(XML_w, XML_alias, FSNS(XML_w, XML_val), m_aAlias);
+
+ if (!m_aTag.isEmpty())
+ pSerializer->singleElementNS(XML_w, XML_tag, FSNS(XML_w, XML_val), m_aTag);
+
+ if (m_nTabIndex)
+ pSerializer->singleElementNS(XML_w, XML_tabIndex, FSNS(XML_w, XML_val),
+ OString::number(m_nTabIndex));
+
+ if (!m_aLock.isEmpty())
+ pSerializer->singleElementNS(XML_w, XML_lock, FSNS(XML_w, XML_val), m_aLock);
+}
+
+void SdtBlockHelper::EndSdtBlock(const ::sax_fastparser::FSHelperPtr& pSerializer)
+{
+ pSerializer->endElementNS(XML_w, XML_sdtContent);
+ pSerializer->endElementNS(XML_w, XML_sdt);
+ m_bStartedSdt = false;
+}
+
+void SdtBlockHelper::GetSdtParamsFromGrabBag(const uno::Sequence<beans::PropertyValue>& aGrabBagSdt)
+{
+ for (const beans::PropertyValue& aPropertyValue : aGrabBagSdt)
+ {
+ if (aPropertyValue.Name == "ooxml:CT_SdtPr_checkbox")
+ {
+ m_nSdtPrToken = FSNS(XML_w14, XML_checkbox);
+ uno::Sequence<beans::PropertyValue> aGrabBag;
+ aPropertyValue.Value >>= aGrabBag;
+ for (const auto& rProp : aGrabBag)
+ {
+ if (rProp.Name == "ooxml:CT_SdtCheckbox_checked")
+ DocxAttributeOutput::AddToAttrList(m_pTokenChildren,
+ FSNS(XML_w14, XML_checked), rProp.Value.get<OUString>());
+ else if (rProp.Name == "ooxml:CT_SdtCheckbox_checkedState")
+ DocxAttributeOutput::AddToAttrList(m_pTokenChildren,
+ FSNS(XML_w14, XML_checkedState), rProp.Value.get<OUString>());
+ else if (rProp.Name == "ooxml:CT_SdtCheckbox_uncheckedState")
+ DocxAttributeOutput::AddToAttrList(m_pTokenChildren,
+ FSNS(XML_w14, XML_uncheckedState), rProp.Value.get<OUString>());
+ }
+ }
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_dataBinding" && !m_pDataBindingAttrs.is())
+ {
+ uno::Sequence<beans::PropertyValue> aGrabBag;
+ aPropertyValue.Value >>= aGrabBag;
+ for (const auto& rProp : aGrabBag)
+ {
+ if (rProp.Name == "ooxml:CT_DataBinding_prefixMappings")
+ DocxAttributeOutput::AddToAttrList( m_pDataBindingAttrs,
+ FSNS( XML_w, XML_prefixMappings ), rProp.Value.get<OUString>());
+ else if (rProp.Name == "ooxml:CT_DataBinding_xpath")
+ DocxAttributeOutput::AddToAttrList( m_pDataBindingAttrs,
+ FSNS( XML_w, XML_xpath ), rProp.Value.get<OUString>());
+ else if (rProp.Name == "ooxml:CT_DataBinding_storeItemID")
+ DocxAttributeOutput::AddToAttrList( m_pDataBindingAttrs,
+ FSNS( XML_w, XML_storeItemID ), rProp.Value.get<OUString>());
+ }
+ }
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_text")
+ {
+ uno::Sequence<beans::PropertyValue> aGrabBag;
+ aPropertyValue.Value >>= aGrabBag;
+ if (aGrabBag.hasElements())
+ {
+ for (const auto& rProp : aGrabBag)
+ {
+ if (rProp.Name == "ooxml:CT_SdtText_multiLine")
+ DocxAttributeOutput::AddToAttrList(m_pTextAttrs,
+ FSNS(XML_w, XML_multiLine), rProp.Value.get<OUString>());
+ }
+ }
+ else
+ {
+ // We still have w:text, but no attrs
+ m_nSdtPrToken = FSNS(XML_w, XML_text);
+ }
+ }
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPlaceholder_docPart")
+ {
+ uno::Sequence<beans::PropertyValue> aGrabBag;
+ aPropertyValue.Value >>= aGrabBag;
+ for (const auto& rProp : aGrabBag)
+ {
+ if (rProp.Name == "ooxml:CT_SdtPlaceholder_docPart_val")
+ m_aPlaceHolderDocPart = rProp.Value.get<OUString>();
+ }
+ }
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_color")
+ {
+ uno::Sequence<beans::PropertyValue> aGrabBag;
+ aPropertyValue.Value >>= aGrabBag;
+ for (const auto& rProp : aGrabBag)
+ {
+ if (rProp.Name == "ooxml:CT_SdtColor_val")
+ m_aColor = rProp.Value.get<OUString>();
+ }
+ }
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_appearance")
+ {
+ if (!(aPropertyValue.Value >>= m_aAppearance))
+ SAL_WARN("sw.ww8", "DocxAttributeOutput::GrabBag: unexpected sdt appearance value");
+ }
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_showingPlcHdr")
+ {
+ if (!(aPropertyValue.Value >>= m_bShowingPlaceHolder))
+ SAL_WARN("sw.ww8", "DocxAttributeOutput::GrabBag: unexpected sdt ShowingPlcHdr");
+ }
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_alias" && m_aAlias.isEmpty())
+ {
+ if (!(aPropertyValue.Value >>= m_aAlias))
+ SAL_WARN("sw.ww8", "DocxAttributeOutput::GrabBag: unexpected sdt alias value");
+ }
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_tag" && m_aTag.isEmpty())
+ {
+ if (!(aPropertyValue.Value >>= m_aTag))
+ SAL_WARN("sw.ww8", "DocxAttributeOutput::GrabBag: unexpected sdt tag value");
+ }
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_id")
+ {
+ if (!(aPropertyValue.Value >>= m_nId))
+ SAL_WARN("sw.ww8", "DocxAttributeOutput::GrabBag: unexpected sdt id value");
+ }
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_tabIndex" && !m_nTabIndex)
+ {
+ if (!(aPropertyValue.Value >>= m_nTabIndex))
+ SAL_WARN("sw.ww8", "DocxAttributeOutput::GrabBag: unexpected sdt tabIndex value");
+ }
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_lock" && m_aLock.isEmpty())
+ {
+ if (!(aPropertyValue.Value >>= m_aLock))
+ SAL_WARN("sw.ww8", "DocxAttributeOutput::GrabBag: unexpected sdt lock value");
+ }
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_citation")
+ m_nSdtPrToken = FSNS(XML_w, XML_citation);
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_docPartObj" ||
+ aPropertyValue.Name == "ooxml:CT_SdtPr_docPartList")
+ {
+ if (aPropertyValue.Name == "ooxml:CT_SdtPr_docPartObj")
+ m_nSdtPrToken = FSNS(XML_w, XML_docPartObj);
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_docPartList")
+ m_nSdtPrToken = FSNS(XML_w, XML_docPartList);
+
+ uno::Sequence<beans::PropertyValue> aGrabBag;
+ aPropertyValue.Value >>= aGrabBag;
+ for (const auto& rProp : aGrabBag)
+ {
+ if (rProp.Name == "ooxml:CT_SdtDocPart_docPartGallery")
+ DocxAttributeOutput::AddToAttrList(m_pTokenChildren,
+ FSNS(XML_w, XML_docPartGallery), rProp.Value.get<OUString>());
+ else if (rProp.Name == "ooxml:CT_SdtDocPart_docPartCategory")
+ DocxAttributeOutput::AddToAttrList(m_pTokenChildren,
+ FSNS(XML_w, XML_docPartCategory), rProp.Value.get<OUString>());
+ else if (rProp.Name == "ooxml:CT_SdtDocPart_docPartUnique")
+ {
+ OUString sValue = rProp.Value.get<OUString>();
+ if (sValue.isEmpty())
+ sValue = "true";
+ DocxAttributeOutput::AddToAttrList(m_pTokenChildren, FSNS(XML_w, XML_docPartUnique),
+ sValue);
+ }
+ }
+ }
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_equation")
+ m_nSdtPrToken = FSNS(XML_w, XML_equation);
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_picture")
+ m_nSdtPrToken = FSNS(XML_w, XML_picture);
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_group")
+ m_nSdtPrToken = FSNS(XML_w, XML_group);
+ else
+ SAL_WARN("sw.ww8", "GetSdtParamsFromGrabBag unhandled SdtPr grab bag property " << aPropertyValue.Name);
+ }
}
void DocxAttributeOutput::PopulateFrameProperties(const SwFrameFormat* pFrameFormat, const Size& rSize)
{
rtl::Reference<sax_fastparser::FastAttributeList> attrList = FastSerializerHelper::createAttrList();
- awt::Point aPos(pFrameFormat->GetHoriOrient().GetPos(), pFrameFormat->GetVertOrient().GetPos());
-
- attrList->add( FSNS( XML_w, XML_w), OString::number(rSize.Width()));
+ const SwFormatHoriOrient& rHoriOrient = pFrameFormat->GetHoriOrient();
+ const SwFormatVertOrient& rVertOrient = pFrameFormat->GetVertOrient();
+ awt::Point aPos(rHoriOrient.GetPos(), rVertOrient.GetPos());
+
+ // A few assumptions need to be made here, because framePr is a confused mixture
+ // of (multiple) paragraph's border properties being transferred to/from a frame.
+ // The frame size describes the size BEFORE the PARAGRAPH border spacing is applied.
+ // However, we can't actually look at all the paragraphs' borders because they might be
+ // different, and all MUST specify the same frame width in order to belong to the same frame.
+ // In order for them all to be consistent, the only choice is to use the frame's border spacing.
+ // During import, the frame was assigned border spacing based on the contained paragraphs.
+ // So now at export time we have to assume that none of this has been changed by the user.
+
+ // 620 (31pt) is the maximum paragraph border spacing allowed in MS Formats,
+ // so if the value is greater than that, avoid adjusting the size - the user has interfered.
+ const sal_uInt32 nLeftBorderSpacing = pFrameFormat->GetBox().GetDistance(SvxBoxItemLine::LEFT);
+ const sal_uInt32 nRighttBorderSpacing = pFrameFormat->GetBox().GetDistance(SvxBoxItemLine::RIGHT);
+ sal_uInt32 nAdjustedWidth = rSize.Width();
+ if (nLeftBorderSpacing < 621 && nRighttBorderSpacing < 621
+ && nAdjustedWidth > nLeftBorderSpacing + nRighttBorderSpacing)
+ {
+ nAdjustedWidth -= nLeftBorderSpacing + nRighttBorderSpacing;
+ }
+ attrList->add( FSNS( XML_w, XML_w), OString::number(nAdjustedWidth));
attrList->add( FSNS( XML_w, XML_h), OString::number(rSize.Height()));
- attrList->add( FSNS( XML_w, XML_x), OString::number(aPos.X));
- attrList->add( FSNS( XML_w, XML_y), OString::number(aPos.Y));
+ const OString relativeFromH = convertToOOXMLHoriOrientRel(rHoriOrient.GetRelationOrient());
+ const OString relativeFromV = convertToOOXMLVertOrientRel(rVertOrient.GetRelationOrient());
+ OString aXAlign = convertToOOXMLHoriOrient(rHoriOrient.GetHoriOrient(), /*bIsPosToggle=*/false);
+ OString aYAlign = convertToOOXMLVertOrient(rVertOrient.GetVertOrient());
+ if (!aXAlign.isEmpty())
+ attrList->add(FSNS(XML_w, XML_xAlign), aXAlign);
+ else if (aPos.X)
+ attrList->add( FSNS( XML_w, XML_x), OString::number(aPos.X));
+ if (!aYAlign.isEmpty() && relativeFromV != "text")
+ attrList->add(FSNS(XML_w, XML_yAlign), aYAlign);
+ else if (aPos.Y)
+ attrList->add( FSNS( XML_w, XML_y), OString::number(aPos.Y));
sal_Int16 nLeft = pFrameFormat->GetLRSpace().GetLeft();
sal_Int16 nRight = pFrameFormat->GetLRSpace().GetRight();
sal_Int16 nUpper = pFrameFormat->GetULSpace().GetUpper();
sal_Int16 nLower = pFrameFormat->GetULSpace().GetLower();
+ // To emulate, on import left was ignored (set to zero) if aligned to left,
+ // so just double up the right spacing in order to prevent cutting in half each round-trip.
+ if (rHoriOrient.GetHoriOrient() == text::HoriOrientation::LEFT)
+ nLeft = nRight;
+ else if (rHoriOrient.GetHoriOrient() == text::HoriOrientation::RIGHT)
+ nRight = nLeft;
+
attrList->add(FSNS(XML_w, XML_hSpace), OString::number((nLeft + nRight) / 2));
attrList->add(FSNS(XML_w, XML_vSpace), OString::number((nUpper + nLower) / 2));
- OString relativeFromH = convertToOOXMLHoriOrientRel( pFrameFormat->GetHoriOrient().GetRelationOrient() );
- OString relativeFromV = convertToOOXMLVertOrientRel( pFrameFormat->GetVertOrient().GetRelationOrient() );
-
switch (pFrameFormat->GetSurround().GetValue())
{
case css::text::WrapTextMode_NONE:
@@ -633,27 +1101,27 @@ void DocxAttributeOutput::PopulateFrameProperties(const SwFrameFormat* pFrameFor
bool DocxAttributeOutput::TextBoxIsFramePr(const SwFrameFormat& rFrameFormat)
{
- uno::Reference< drawing::XShape > xShape;
- const SdrObject* pSdrObj = rFrameFormat.FindRealSdrObject();
- if (pSdrObj)
- xShape.set(const_cast<SdrObject*>(pSdrObj)->getUnoShape(), uno::UNO_QUERY);
- uno::Reference< beans::XPropertySet > xPropertySet(xShape, uno::UNO_QUERY);
- uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
- if (xPropertySet.is())
- xPropSetInfo = xPropertySet->getPropertySetInfo();
- uno::Any aFrameProperties ;
- if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag"))
- {
- uno::Sequence< beans::PropertyValue > propList;
- xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList;
- auto pProp = std::find_if(propList.begin(), propList.end(),
- [](const beans::PropertyValue& rProp) { return rProp.Name == "ParaFrameProperties"; });
- if (pProp != propList.end())
- aFrameProperties = pProp->Value;
- }
- bool bFrameProperties = false;
- aFrameProperties >>= bFrameProperties;
- return bFrameProperties;
+ SdrObject* pSdrObj = const_cast<SdrObject*>(rFrameFormat.FindRealSdrObject());
+ if (!pSdrObj)
+ return false;
+
+ uno::Reference<beans::XPropertySet> xPropertySet(pSdrObj->getUnoShape(), uno::UNO_QUERY);
+ if (!xPropertySet.is())
+ return false;
+
+ uno::Reference<beans::XPropertySetInfo> xPropSetInfo(xPropertySet->getPropertySetInfo());
+ if (!xPropSetInfo.is() || !xPropSetInfo->hasPropertyByName("FrameInteropGrabBag"))
+ return false;
+
+ bool bRet = false;
+ uno::Sequence<beans::PropertyValue> propList;
+ xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList;
+ auto pProp = std::find_if(std::cbegin(propList), std::cend(propList),
+ [](const beans::PropertyValue& rProp) { return rProp.Name == "ParaFrameProperties"; });
+ if (pProp != std::cend(propList))
+ pProp->Value >>= bRet;
+
+ return bRet;
}
void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner )
@@ -666,10 +1134,10 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
++m_nTextFrameLevel;
if( m_nTextFrameLevel == 1 && !m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen() )
{
- comphelper::FlagRestorationGuard aStartedParaSdtGuard(m_bStartedParaSdt, false);
+ comphelper::FlagRestorationGuard aStartedParaSdtGuard(m_aParagraphSdt.m_bStartedSdt, false);
- assert(!m_pPostponedCustomShape);
- m_pPostponedCustomShape.reset(new std::vector<PostponedDrawing>);
+ assert(!m_oPostponedCustomShape);
+ m_oPostponedCustomShape.emplace();
// The for loop can change the size of m_aFramesOfParagraph, so the max size cannot be set in stone before the loop.
size_t nFrames = m_aFramesOfParagraph.size() ? m_aFramesOfParagraph.top().size() : 0;
@@ -679,13 +1147,17 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
ww8::Frame aFrame = m_aFramesOfParagraph.top()[nIndex];
const SwFrameFormat& rFrameFormat = aFrame.GetFrameFormat();
- if (!TextBoxIsFramePr(rFrameFormat) || m_bWritingHeaderFooter)
+ if (!m_bWritingHeaderFooter && TextBoxIsFramePr(rFrameFormat))
{
- if (m_bStartedCharSdt)
+ std::shared_ptr<ww8::Frame> pFramePr = std::make_shared<ww8::Frame>(aFrame);
+ aFramePrTextbox.push_back(pFramePr);
+ }
+ else
+ {
+ if (m_aRunSdt.m_bStartedSdt)
{
// Run-level SDT still open? Close it before AlternateContent.
- EndSdtBlock();
- m_bStartedCharSdt = false;
+ m_aRunSdt.EndSdtBlock(m_pSerializer);
}
m_pSerializer->startElementNS(XML_w, XML_r);
m_pSerializer->startElementNS(XML_mc, XML_AlternateContent);
@@ -701,7 +1173,7 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
spawned from within the VML & DML block and alter
the contents.
*/
- ww8::WW8TableInfo::Pointer_t pOldTableInfo = m_rExport.m_pTableInfo;
+ ww8::WW8TableInfo::Pointer_t xOldTableInfo = m_rExport.m_pTableInfo;
//Reset the table infos after saving.
m_rExport.m_pTableInfo = std::make_shared<ww8::WW8TableInfo>();
@@ -728,28 +1200,23 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
DocxTableExportContext aVMLTableExportContext(*this);
m_rExport.SdrExporter().writeVMLTextFrame(&aFrame);
}
- m_rExport.m_pTableInfo = pOldTableInfo;
+ m_rExport.m_pTableInfo = std::move(xOldTableInfo);
m_pSerializer->endElementNS(XML_mc, XML_Fallback);
m_pSerializer->endElementNS(XML_mc, XML_AlternateContent);
m_pSerializer->endElementNS( XML_w, XML_r );
m_bParagraphFrameOpen = false;
}
- else
- {
- std::shared_ptr<ww8::Frame> pFramePr = std::make_shared<ww8::Frame>(aFrame);
- aFramePrTextbox.push_back(pFramePr);
- }
nFrames = m_aFramesOfParagraph.size() ? m_aFramesOfParagraph.top().size() : 0;
}
- if (!m_pPostponedCustomShape->empty())
+ if (!m_oPostponedCustomShape->empty())
{
m_pSerializer->startElementNS(XML_w, XML_r);
WritePostponedCustomShape();
m_pSerializer->endElementNS( XML_w, XML_r );
}
- m_pPostponedCustomShape.reset();
+ m_oPostponedCustomShape.reset();
if ( m_aFramesOfParagraph.size() )
m_aFramesOfParagraph.top().clear();
@@ -768,18 +1235,17 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
/* If m_nHyperLinkCount > 0 that means hyperlink tag is not yet closed.
* This is due to nested hyperlink tags. So close it before end of paragraph.
*/
- if(m_nHyperLinkCount > 0)
+ if(m_nHyperLinkCount.back() > 0)
{
- for(sal_Int32 nHyperLinkToClose = 0; nHyperLinkToClose < m_nHyperLinkCount; ++nHyperLinkToClose)
+ for(sal_Int32 nHyperLinkToClose = 0; nHyperLinkToClose < m_nHyperLinkCount.back(); ++nHyperLinkToClose)
m_pSerializer->endElementNS( XML_w, XML_hyperlink );
- m_nHyperLinkCount = 0;
}
+ m_nHyperLinkCount.pop_back();
- if (m_bStartedCharSdt)
+ if (m_aRunSdt.m_bStartedSdt)
{
// Run-level SDT still open? Close it now.
- EndSdtBlock();
- m_bStartedCharSdt = false;
+ m_aRunSdt.EndSdtBlock(m_pSerializer);
}
if (m_bPageBreakAfter)
@@ -791,15 +1257,24 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
m_pSerializer->endElementNS( XML_w, XML_p );
// on export sdt blocks are never nested ATM
- if( !m_bAnchorLinkedToNode && !m_bStartedParaSdt )
- WriteSdtBlock( m_nParagraphSdtPrToken, m_pParagraphSdtPrTokenChildren, m_pParagraphSdtPrTokenAttributes, m_pParagraphSdtPrDataBindingAttrs, m_aParagraphSdtPrAlias, /*bPara=*/true );
+ if (!m_bAnchorLinkedToNode && !m_aParagraphSdt.m_bStartedSdt)
+ {
+ m_aParagraphSdt.WriteSdtBlock(m_pSerializer, m_bRunTextIsOn, m_rExport.SdrExporter().IsParagraphHasDrawing());
+
+ if (m_aParagraphSdt.m_bStartedSdt)
+ {
+ if (m_tableReference.m_bTableCellOpen)
+ m_tableReference.m_bTableCellParaSdtOpen = true;
+ if (m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen())
+ m_rExport.SdrExporter().setParagraphSdtOpen(true);
+ }
+ }
else
{
//These should be written out to the actual Node and not to the anchor.
//Clear them as they will be repopulated when the node is processed.
- m_nParagraphSdtPrToken = 0;
- m_bParagraphSdtHasId = false;
- lcl_deleteAndResetTheLists( m_pParagraphSdtPrTokenChildren, m_pParagraphSdtPrDataBindingAttrs, m_aParagraphSdtPrAlias );
+ m_aParagraphSdt.m_nSdtPrToken = 0;
+ m_aParagraphSdt.DeleteAndResetTheLists();
}
m_pSerializer->mark(Tag_StartParagraph_2);
@@ -808,9 +1283,9 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
for ( const auto & pFrame : aFramePrTextbox )
{
DocxTableExportContext aTableExportContext(*this);
- m_pCurrentFrame = pFrame.get();
+ m_aFramePr.SetFrame(pFrame.get(), !m_xTableWrt ? -1 : m_tableReference.m_nTableDepth);
m_rExport.SdrExporter().writeOnlyTextOfFrame(pFrame.get());
- m_pCurrentFrame = nullptr;
+ m_aFramePr.SetFrame(nullptr);
}
m_pSerializer->mergeTopMarks(Tag_StartParagraph_2, sax_fastparser::MergeMarks::PREPEND);
@@ -832,111 +1307,15 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
m_aBookmarksOfParagraphEnd.clear();
}
-void DocxAttributeOutput::WriteSdtBlock( sal_Int32& nSdtPrToken,
- rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrTokenChildren,
- rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrTokenAttributes,
- rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrDataBindingAttrs,
- OUString& rSdtPrAlias,
- bool bPara )
-{
- if( nSdtPrToken <= 0 && !pSdtPrDataBindingAttrs.is() )
- return;
-
- // sdt start mark
- m_pSerializer->mark(Tag_WriteSdtBlock);
-
- m_pSerializer->startElementNS(XML_w, XML_sdt);
-
- // output sdt properties
- m_pSerializer->startElementNS(XML_w, XML_sdtPr);
-
- if( nSdtPrToken > 0 && pSdtPrTokenChildren.is() )
- {
- if (!pSdtPrTokenAttributes.is())
- m_pSerializer->startElement(nSdtPrToken);
- else
- {
- rtl::Reference<FastAttributeList> xAttrList = std::move(pSdtPrTokenAttributes);
- m_pSerializer->startElement(nSdtPrToken, xAttrList);
- }
-
- if (nSdtPrToken == FSNS( XML_w, XML_date ) || nSdtPrToken == FSNS( XML_w, XML_docPartObj ) || nSdtPrToken == FSNS( XML_w, XML_docPartList ) || nSdtPrToken == FSNS( XML_w14, XML_checkbox )) {
- const uno::Sequence<xml::FastAttribute> aChildren = pSdtPrTokenChildren->getFastAttributes();
- for( const auto& rChild : aChildren )
- m_pSerializer->singleElement(rChild.Token, FSNS(XML_w, XML_val), rChild.Value);
- }
-
- m_pSerializer->endElement( nSdtPrToken );
- }
- else if( (nSdtPrToken > 0) && nSdtPrToken != FSNS( XML_w, XML_id ) && !(m_bRunTextIsOn && m_rExport.SdrExporter().IsParagraphHasDrawing()))
- {
- if (!pSdtPrTokenAttributes.is())
- m_pSerializer->singleElement(nSdtPrToken);
- else
- {
- rtl::Reference<FastAttributeList> xAttrList = std::move(pSdtPrTokenAttributes);
- m_pSerializer->singleElement(nSdtPrToken, xAttrList);
- }
- }
-
- if( nSdtPrToken == FSNS( XML_w, XML_id ) || ( bPara && m_bParagraphSdtHasId ) )
- //Word won't open a document with an empty id tag, we fill it with a random number
- m_pSerializer->singleElementNS(XML_w, XML_id, FSNS(XML_w, XML_val),
- OString::number(comphelper::rng::uniform_int_distribution(0, std::numeric_limits<int>::max())));
-
- if( pSdtPrDataBindingAttrs.is() && !m_rExport.SdrExporter().IsParagraphHasDrawing())
- {
- rtl::Reference<FastAttributeList> xAttrList = std::move( pSdtPrDataBindingAttrs );
- m_pSerializer->singleElementNS(XML_w, XML_dataBinding, xAttrList);
- }
-
- if (!rSdtPrAlias.isEmpty())
- m_pSerializer->singleElementNS(XML_w, XML_alias, FSNS(XML_w, XML_val), rSdtPrAlias);
-
- m_pSerializer->endElementNS( XML_w, XML_sdtPr );
-
- // sdt contents start tag
- m_pSerializer->startElementNS(XML_w, XML_sdtContent);
-
- // prepend the tags since the sdt start mark before the paragraph
- m_pSerializer->mergeTopMarks(Tag_WriteSdtBlock, sax_fastparser::MergeMarks::PREPEND);
-
- // write the ending tags after the paragraph
- if (bPara)
- {
- m_bStartedParaSdt = true;
- if (m_tableReference->m_bTableCellOpen)
- m_tableReference->m_bTableCellParaSdtOpen = true;
- if (m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen())
- m_rExport.SdrExporter().setParagraphSdtOpen(true);
- }
- else
- // Support multiple runs inside a run-level SDT: don't close the SDT block yet.
- m_bStartedCharSdt = true;
-
- // clear sdt status
- nSdtPrToken = 0;
- pSdtPrTokenChildren.clear();
- pSdtPrDataBindingAttrs.clear();
- rSdtPrAlias.clear();
-
-}
-
-void DocxAttributeOutput::EndSdtBlock()
-{
- m_pSerializer->endElementNS( XML_w, XML_sdtContent );
- m_pSerializer->endElementNS( XML_w, XML_sdt );
-}
-
#define MAX_CELL_IN_WORD 62
void DocxAttributeOutput::SyncNodelessCells(ww8::WW8TableNodeInfoInner::Pointer_t const & pInner, sal_Int32 nCell, sal_uInt32 nRow)
{
- sal_Int32 nOpenCell = lastOpenCell.back();
+ sal_Int32 nOpenCell = m_LastOpenCell.back();
if (nOpenCell != -1 && nOpenCell != nCell && nOpenCell < MAX_CELL_IN_WORD)
EndTableCell(nOpenCell);
- sal_Int32 nClosedCell = lastClosedCell.back();
+ sal_Int32 nClosedCell = m_LastClosedCell.back();
for (sal_Int32 i = nClosedCell+1; i < nCell; ++i)
{
if (i >= MAX_CELL_IN_WORD)
@@ -974,17 +1353,17 @@ void DocxAttributeOutput::FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointe
if (bEndCell)
{
- while (pInner->getDepth() < m_tableReference->m_nTableDepth)
+ while (pInner->getDepth() < m_tableReference.m_nTableDepth)
{
//we expect that the higher depth row was closed, and
//we are just missing the table close
- assert(lastOpenCell.back() == -1 && lastClosedCell.back() == -1);
+ assert(m_LastOpenCell.back() == -1 && m_LastClosedCell.back() == -1);
EndTable();
}
SyncNodelessCells(pInner, nCell, nRow);
- sal_Int32 nClosedCell = lastClosedCell.back();
+ sal_Int32 nClosedCell = m_LastClosedCell.back();
if (nCell == nClosedCell)
{
//Start missing trailing cell(s)
@@ -1043,7 +1422,7 @@ void DocxAttributeOutput::SectionBreaks(const SwNode& rNode)
if (aNextIndex.GetNode().IsTextNode())
{
const SwTextNode* pTextNode = static_cast<SwTextNode*>(&aNextIndex.GetNode());
- m_rExport.OutputSectionBreaks(pTextNode->GetpSwAttrSet(), *pTextNode, m_tableReference->m_bTableCellOpen);
+ m_rExport.OutputSectionBreaks(pTextNode->GetpSwAttrSet(), *pTextNode, m_tableReference.m_bTableCellOpen);
}
else if (aNextIndex.GetNode().IsTableNode())
{
@@ -1060,7 +1439,7 @@ void DocxAttributeOutput::SectionBreaks(const SwNode& rNode)
// Also handle section endings
const SwTextNode* pTextNode = aNextIndex.GetNode().GetTextNode();
if (rNode.StartOfSectionNode()->IsTableNode() || rNode.StartOfSectionNode()->IsSectionNode())
- m_rExport.OutputSectionBreaks(pTextNode->GetpSwAttrSet(), *pTextNode, m_tableReference->m_bTableCellOpen);
+ m_rExport.OutputSectionBreaks(pTextNode->GetpSwAttrSet(), *pTextNode, m_tableReference.m_bTableCellOpen);
}
else if (aNextIndex.GetNode().IsTableNode())
{
@@ -1090,6 +1469,7 @@ void DocxAttributeOutput::StartParagraphProperties()
void DocxAttributeOutput::InitCollectedParagraphProperties()
{
+ m_pLRSpaceAttrList.clear();
m_pParagraphSpacingAttrList.clear();
// Write the elements in the spec order
@@ -1135,6 +1515,7 @@ void DocxAttributeOutput::InitCollectedParagraphProperties()
// postpone the output so that we can later [in EndParagraphProperties()]
// prepend the properties before the run
+ // coverity[overrun-buffer-arg : FALSE] - coverity has difficulty with css::uno::Sequence
m_pSerializer->mark(Tag_InitCollectedParagraphProperties, comphelper::containerToSequence(aOrder));
}
@@ -1142,22 +1523,24 @@ void DocxAttributeOutput::WriteCollectedParagraphProperties()
{
if ( m_rExport.SdrExporter().getFlyAttrList().is() )
{
- rtl::Reference<FastAttributeList> xAttrList( m_rExport.SdrExporter().getFlyAttrList() );
- m_rExport.SdrExporter().getFlyAttrList().clear();
+ m_pSerializer->singleElementNS( XML_w, XML_framePr,
+ detachFrom(m_rExport.SdrExporter().getFlyAttrList() ) );
+ }
- m_pSerializer->singleElementNS( XML_w, XML_framePr, xAttrList );
+ if (m_pLRSpaceAttrList.is())
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_ind, detachFrom(m_pLRSpaceAttrList));
}
if ( m_pParagraphSpacingAttrList.is() )
{
- rtl::Reference<FastAttributeList> xAttrList = std::move( m_pParagraphSpacingAttrList );
- m_pSerializer->singleElementNS( XML_w, XML_spacing, xAttrList );
+ m_pSerializer->singleElementNS( XML_w, XML_spacing, detachFrom( m_pParagraphSpacingAttrList ) );
}
if ( m_pBackgroundAttrList.is() )
{
- rtl::Reference<FastAttributeList> xAttrList = std::move( m_pBackgroundAttrList );
- m_pSerializer->singleElementNS( XML_w, XML_shd, xAttrList );
+ m_pSerializer->singleElementNS( XML_w, XML_shd, detachFrom( m_pBackgroundAttrList ) );
+ m_aFramePr.SetUseFrameBackground(false);
}
}
@@ -1175,18 +1558,22 @@ void lcl_writeParagraphMarkerProperties(DocxAttributeOutput& rAttributeOutput, c
const SfxPoolItem* pItem = nullptr;
// Did we already produce a <w:sz> element?
bool bFontSizeWritten = false;
+ bool bBoldWritten = false;
while (nWhichId)
{
- if (rParagraphMarkerProperties.GetItemState(nWhichId, true, &pItem) == SfxItemState::SET)
+ if (aIter.GetItemState(true, &pItem) == SfxItemState::SET)
{
if (isCHRATR(nWhichId) || nWhichId == RES_TXTATR_CHARFMT)
{
// Will this item produce a <w:sz> element?
bool bFontSizeItem = nWhichId == RES_CHRATR_FONTSIZE || nWhichId == RES_CHRATR_CJK_FONTSIZE;
- if (!bFontSizeWritten || !bFontSizeItem)
+ bool bBoldItem = nWhichId == RES_CHRATR_WEIGHT || nWhichId == RES_CHRATR_CJK_WEIGHT;
+ if (!(bFontSizeWritten && bFontSizeItem) && !(bBoldWritten && bBoldItem))
rAttributeOutput.OutputItem(*pItem);
if (bFontSizeItem)
bFontSizeWritten = true;
+ if (bBoldItem)
+ bBoldWritten = true;
}
else if (nWhichId == RES_TXTATR_AUTOFMT)
{
@@ -1246,12 +1633,9 @@ void DocxAttributeOutput::EndParagraphProperties(const SfxItemSet& rParagraphMar
// to the DOCX when the function 'WriteCollectedRunProperties' gets called.
// So we need to store the current status of these lists, so that we can revert back to them when
// we are done exporting the redline attributes.
- rtl::Reference<sax_fastparser::FastAttributeList> pFontsAttrList_Original(m_pFontsAttrList);
- m_pFontsAttrList.clear();
- rtl::Reference<sax_fastparser::FastAttributeList> pEastAsianLayoutAttrList_Original(m_pEastAsianLayoutAttrList);
- m_pEastAsianLayoutAttrList.clear();
- rtl::Reference<sax_fastparser::FastAttributeList> pCharLangAttrList_Original(m_pCharLangAttrList);
- m_pCharLangAttrList.clear();
+ auto pFontsAttrList_Original(detachFrom(m_pFontsAttrList));
+ auto pEastAsianLayoutAttrList_Original(detachFrom(m_pEastAsianLayoutAttrList));
+ auto pCharLangAttrList_Original(detachFrom(m_pCharLangAttrList));
lcl_writeParagraphMarkerProperties(*this, rParagraphMarkerProperties);
@@ -1259,42 +1643,82 @@ void DocxAttributeOutput::EndParagraphProperties(const SfxItemSet& rParagraphMar
WriteCollectedRunProperties();
// Revert back the original values that were stored in 'm_pFontsAttrList', 'm_pEastAsianLayoutAttrList', 'm_pCharLangAttrList'
- m_pFontsAttrList = pFontsAttrList_Original.get();
- m_pEastAsianLayoutAttrList = pEastAsianLayoutAttrList_Original.get();
- m_pCharLangAttrList = pCharLangAttrList_Original.get();
+ m_pFontsAttrList = std::move(pFontsAttrList_Original);
+ m_pEastAsianLayoutAttrList = std::move(pEastAsianLayoutAttrList_Original);
+ m_pCharLangAttrList = std::move(pCharLangAttrList_Original);
if ( pRedlineParagraphMarkerDeleted )
{
- StartRedline( pRedlineParagraphMarkerDeleted );
- EndRedline( pRedlineParagraphMarkerDeleted );
+ StartRedline( pRedlineParagraphMarkerDeleted, /*bLastRun=*/true );
+ EndRedline( pRedlineParagraphMarkerDeleted, /*bLastRun=*/true );
}
if ( pRedlineParagraphMarkerInserted )
{
- StartRedline( pRedlineParagraphMarkerInserted );
- EndRedline( pRedlineParagraphMarkerInserted );
+ StartRedline( pRedlineParagraphMarkerInserted, /*bLastRun=*/true );
+ EndRedline( pRedlineParagraphMarkerInserted, /*bLastRun=*/true );
}
// mergeTopMarks() after paragraph mark properties child elements.
m_pSerializer->mergeTopMarks(Tag_InitCollectedRunProperties);
m_pSerializer->endElementNS( XML_w, XML_rPr );
- if (!m_bWritingHeaderFooter && m_pCurrentFrame)
+ if (!m_bWritingHeaderFooter && m_aFramePr.Frame())
{
- const SwFrameFormat& rFrameFormat = m_pCurrentFrame->GetFrameFormat();
- const SvxBoxItem& rBox = rFrameFormat.GetBox();
- if (TextBoxIsFramePr(rFrameFormat))
+ const SwFrameFormat& rFrameFormat = m_aFramePr.Frame()->GetFrameFormat();
+ assert(TextBoxIsFramePr(rFrameFormat) && "by definition, because Frame()");
+
+ const Size aSize = m_aFramePr.Frame()->GetSize();
+ PopulateFrameProperties(&rFrameFormat, aSize);
+
+ // if the paragraph itself never called FormatBox, do so now
+ if (m_aFramePr.UseFrameBorders(!m_xTableWrt ? -1 : m_tableReference.m_nTableDepth))
+ FormatBox(rFrameFormat.GetBox());
+
+ if (m_aFramePr.UseFrameBackground())
{
- const Size aSize = m_pCurrentFrame->GetSize();
- PopulateFrameProperties(&rFrameFormat, aSize);
- FormatBox(rBox);
+ // The frame is usually imported as 100% transparent. Ignore in that case.
+ // Background only exports as fully opaque. Emulate - ignore transparency more than 50%
+ const SwAttrSet& rSet = rFrameFormat.GetAttrSet();
+ const XFillStyleItem* pFillStyle(rSet.GetItem<XFillStyleItem>(XATTR_FILLSTYLE));
+ if (pFillStyle && pFillStyle->GetValue() != drawing::FillStyle_NONE)
+ {
+ std::unique_ptr<SvxBrushItem> pBrush(
+ getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
+ if (pBrush->GetColor().GetAlpha() > 127) // more opaque than transparent
+ {
+ FormatBackground(*pBrush);
+ WriteCollectedParagraphProperties();
+ }
+ }
}
+
+ if (m_aFramePr.UseFrameTextDirection(!m_xTableWrt ? -1 : m_tableReference.m_nTableDepth))
+ {
+ const SvxFrameDirectionItem& rFrameDir = rFrameFormat.GetFrameDir();
+ if (rFrameDir.GetValue() != SvxFrameDirection::Environment)
+ {
+ assert(!m_rExport.m_bOutPageDescs);
+ // hack: use existing variable to write out the full TextDirection attribute.
+ // This is valid for paragraphs/styles - just not native in LO, so hack for now.
+ m_rExport.m_bOutPageDescs = true;
+ FormatFrameDirection(rFrameDir);
+ m_rExport.m_bOutPageDescs = false;
+ }
+ }
+
+ // reset to true in preparation for the next paragraph in the frame
+ m_aFramePr.SetUseFrameBorders(true);
+ m_aFramePr.SetUseFrameBackground(true);
+ m_aFramePr.SetUseFrameTextDirection(true);
}
m_pSerializer->endElementNS( XML_w, XML_pPr );
// RDF metadata for this text node.
- SwTextNode* pTextNode = m_rExport.m_pCurPam->GetNode().GetTextNode();
- std::map<OUString, OUString> aStatements = SwRDFHelper::getTextNodeStatements("urn:bails", *pTextNode);
+ SwTextNode* pTextNode = m_rExport.m_pCurPam->GetPointNode().GetTextNode();
+ std::map<OUString, OUString> aStatements;
+ if (pTextNode)
+ aStatements = SwRDFHelper::getTextNodeStatements("urn:bails", *pTextNode);
if (!aStatements.empty())
{
m_pSerializer->startElementNS(XML_w, XML_smartTag,
@@ -1309,7 +1733,8 @@ void DocxAttributeOutput::EndParagraphProperties(const SfxItemSet& rParagraphMar
m_pSerializer->endElementNS(XML_w, XML_smartTag);
}
- if ( m_nColBreakStatus == COLBRK_WRITE || m_nColBreakStatus == COLBRK_WRITEANDPOSTPONE )
+ if ((m_nColBreakStatus == COLBRK_WRITE || m_nColBreakStatus == COLBRK_WRITEANDPOSTPONE)
+ && !m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen())
{
m_pSerializer->startElementNS(XML_w, XML_r);
m_pSerializer->singleElementNS(XML_w, XML_br, FSNS(XML_w, XML_type), "column");
@@ -1321,7 +1746,8 @@ void DocxAttributeOutput::EndParagraphProperties(const SfxItemSet& rParagraphMar
m_nColBreakStatus = COLBRK_NONE;
}
- if ( m_bPostponedPageBreak && !m_bWritingHeaderFooter )
+ if (m_bPostponedPageBreak && !m_bWritingHeaderFooter
+ && !m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen())
{
m_pSerializer->startElementNS(XML_w, XML_r);
m_pSerializer->singleElementNS(XML_w, XML_br, FSNS(XML_w, XML_type), "page");
@@ -1374,7 +1800,7 @@ void DocxAttributeOutput::StartRun( const SwRedlineData* pRedlineData, sal_Int32
m_pSerializer->mark(Tag_StartRun_3); // let's call it "postponed text"
}
-void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /*bLastRun*/)
+void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, sal_Int32 nLen, bool bLastRun)
{
int nFieldsInPrevHyperlink = m_nFieldsInHyperlink;
// Reset m_nFieldsInHyperlink if a new hyperlink is about to start
@@ -1387,7 +1813,10 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /
for ( std::vector<FieldInfos>::iterator pIt = m_Fields.begin() + nFieldsInPrevHyperlink; pIt != m_Fields.end(); )
{
// Add the fields starts for all but hyperlinks and TOCs
- if (pIt->bOpen && pIt->pField && pIt->eType != ww::eFORMDROPDOWN)
+ if (pIt->bOpen && pIt->pField && pIt->eType != ww::eFORMDROPDOWN &&
+ // it is not an input field with extra grabbag params (sdt field)
+ (!(pIt->eType == ww::eFILLIN && static_cast<const SwInputField*>(pIt->pField.get())->getGrabBagParams().hasElements()))
+ )
{
StartField_Impl( pNode, nPos, *pIt );
@@ -1399,7 +1828,7 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /
continue;
}
- if (m_startedHyperlink || m_pHyperlinkAttrList.is())
+ if (m_nHyperLinkCount.back() > 0 || m_pHyperlinkAttrList.is())
{
++m_nFieldsInHyperlink;
}
@@ -1421,17 +1850,16 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /
// if another sdt starts in this run, then wait
// as closing the sdt now, might cause nesting of sdts
- if (m_nRunSdtPrToken > 0)
+ if (m_aRunSdt.m_nSdtPrToken > 0)
bCloseEarlierSDT = true;
else
- EndSdtBlock();
+ m_aRunSdt.EndSdtBlock(m_pSerializer);
m_bEndCharSdt = false;
- m_bStartedCharSdt = false;
}
if ( m_closeHyperlinkInPreviousRun )
{
- if ( m_startedHyperlink )
+ if (m_nHyperLinkCount.back() > 0)
{
for ( int i = 0; i < nFieldsInPrevHyperlink; i++ )
{
@@ -1441,24 +1869,39 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /
m_Fields.pop_back();
}
m_pSerializer->endElementNS( XML_w, XML_hyperlink );
- m_startedHyperlink = false;
m_endPageRef = false;
- m_nHyperLinkCount--;
+ m_nHyperLinkCount.back()--;
+ m_closeHyperlinkInPreviousRun = false;
+ }
+ else
+ {
+ bool bIsStartedHyperlink = false;
+ for (const sal_Int32 nLinkCount : m_nHyperLinkCount)
+ {
+ if (nLinkCount > 0)
+ {
+ bIsStartedHyperlink = true;
+ break;
+ }
+ }
+ if (!bIsStartedHyperlink)
+ m_closeHyperlinkInPreviousRun = false;
}
- m_closeHyperlinkInPreviousRun = false;
}
// Write the hyperlink and toc fields starts
for ( std::vector<FieldInfos>::iterator pIt = m_Fields.begin(); pIt != m_Fields.end(); )
{
// Add the fields starts for hyperlinks, TOCs and index marks
- if (pIt->bOpen && (!pIt->pField || pIt->eType == ww::eFORMDROPDOWN))
+ if (pIt->bOpen && (!pIt->pField || pIt->eType == ww::eFORMDROPDOWN ||
+ // InputField with extra grabbag params - it is sdt field
+ (pIt->eType == ww::eFILLIN && static_cast<const SwInputField*>(pIt->pField.get())->getGrabBagParams().hasElements())))
{
- StartRedline( m_pRedlineData );
+ StartRedline( m_pRedlineData, bLastRun );
StartField_Impl( pNode, nPos, *pIt, true );
- EndRedline( m_pRedlineData );
+ EndRedline( m_pRedlineData, bLastRun );
- if (m_startedHyperlink)
+ if (m_nHyperLinkCount.back() > 0)
++m_nFieldsInHyperlink;
// Remove the field if no end needs to be written
@@ -1517,25 +1960,38 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /
}
newStartedHyperlink = true;
- rtl::Reference<FastAttributeList> xAttrList = std::move( m_pHyperlinkAttrList );
-
- m_pSerializer->startElementNS( XML_w, XML_hyperlink, xAttrList );
- m_startedHyperlink = true;
- m_nHyperLinkCount++;
+ m_pSerializer->startElementNS( XML_w, XML_hyperlink, detachFrom( m_pHyperlinkAttrList ) );
+ m_nHyperLinkCount.back()++;
}
// if there is some redlining in the document, output it
- StartRedline( m_pRedlineData );
+ bool bSkipRedline = false;
+ if (nLen == 1)
+ {
+ // Don't redline content-controls--Word doesn't do them.
+ SwTextAttr* pAttr
+ = pNode->GetTextAttrAt(nPos, RES_TXTATR_CONTENTCONTROL, sw::GetTextAttrMode::Default);
+ if (pAttr && pAttr->GetStart() == nPos)
+ {
+ bSkipRedline = true;
+ }
+ }
+
+ if (!bSkipRedline)
+ {
+ StartRedline(m_pRedlineData, bLastRun);
+ }
// XML_r node should be surrounded with bookmark-begin and bookmark-end nodes if it has bookmarks.
// The same is applied for permission ranges.
// But due to unit test "testFdo85542" let's output bookmark-begin with bookmark-end.
- DoWriteBookmarksStart(m_rBookmarksStart);
+ DoWriteBookmarksStart(m_rBookmarksStart, m_pMoveRedlineData);
DoWriteBookmarksEnd(m_rBookmarksEnd);
DoWritePermissionsStart();
DoWriteAnnotationMarks();
- if( m_closeHyperlinkInThisRun && m_startedHyperlink && !m_hyperLinkAnchor.isEmpty() && m_hyperLinkAnchor.startsWith("_Toc"))
+ if (m_closeHyperlinkInThisRun && m_nHyperLinkCount.back() > 0 && !m_hyperLinkAnchor.isEmpty()
+ && m_hyperLinkAnchor.startsWith("_Toc"))
{
OUString sToken;
m_pSerializer->startElementNS(XML_w, XML_r);
@@ -1569,6 +2025,20 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /
DoWriteBookmarkStartIfExist(nPos);
+ if (nLen != -1)
+ {
+ SwTextAttr* pAttr = pNode->GetTextAttrAt(nPos, RES_TXTATR_CONTENTCONTROL, ::sw::GetTextAttrMode::Default);
+ if (pAttr && pAttr->GetStart() == nPos)
+ {
+ auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
+ m_pContentControl = pTextContentControl->GetContentControl().GetContentControl();
+ if (!m_tableReference.m_bTableCellChanged)
+ {
+ WriteContentControlStart();
+ }
+ }
+ }
+
m_pSerializer->startElementNS(XML_w, XML_r);
if(GetExport().m_bTabInTOC && m_pHyperlinkAttrList.is())
{
@@ -1589,27 +2059,39 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /
// if there is some redlining in the document, output it
// (except in the case of fields with multiple runs)
- EndRedline( m_pRedlineData );
+ if (!bSkipRedline)
+ {
+ EndRedline(m_pRedlineData, bLastRun);
+ }
+
+ if (nLen != -1)
+ {
+ sal_Int32 nEnd = nPos + nLen;
+ SwTextAttr* pAttr = pNode->GetTextAttrAt(nPos, RES_TXTATR_CONTENTCONTROL, ::sw::GetTextAttrMode::Default);
+ if (pAttr && *pAttr->GetEnd() == nEnd && !m_tableReference.m_bTableCellChanged)
+ {
+ WriteContentControlEnd();
+ }
+ }
// enclose in a sdt block, if necessary: if one is already started, then don't do it for now
// (so on export sdt blocks are never nested ATM)
- if ( !m_bAnchorLinkedToNode && !m_bStartedCharSdt )
+ if ( !m_bAnchorLinkedToNode && !m_aRunSdt.m_bStartedSdt)
{
- rtl::Reference<sax_fastparser::FastAttributeList> pRunSdtPrTokenAttributes;
- WriteSdtBlock( m_nRunSdtPrToken, m_pRunSdtPrTokenChildren, pRunSdtPrTokenAttributes, m_pRunSdtPrDataBindingAttrs, m_aRunSdtPrAlias, /*bPara=*/false );
+ m_aRunSdt.WriteSdtBlock(m_pSerializer, m_bRunTextIsOn, m_rExport.SdrExporter().IsParagraphHasDrawing());
}
else
{
//These should be written out to the actual Node and not to the anchor.
//Clear them as they will be repopulated when the node is processed.
- m_nRunSdtPrToken = 0;
- lcl_deleteAndResetTheLists( m_pRunSdtPrTokenChildren, m_pRunSdtPrDataBindingAttrs, m_aRunSdtPrAlias );
+ m_aRunSdt.m_nSdtPrToken = 0;
+ m_aRunSdt.DeleteAndResetTheLists();
}
if (bCloseEarlierSDT)
{
m_pSerializer->mark(Tag_EndRun_2);
- EndSdtBlock();
+ m_aRunSdt.EndSdtBlock(m_pSerializer);
m_pSerializer->mergeTopMarks(Tag_EndRun_2, sax_fastparser::MergeMarks::PREPEND);
}
@@ -1637,7 +2119,7 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /
if ( m_closeHyperlinkInThisRun )
{
- if ( m_startedHyperlink )
+ if (m_nHyperLinkCount.back() > 0)
{
if( m_endPageRef )
{
@@ -1662,10 +2144,23 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /
m_nFieldsInHyperlink = 0;
m_pSerializer->endElementNS( XML_w, XML_hyperlink );
- m_startedHyperlink = false;
- m_nHyperLinkCount--;
+ m_nHyperLinkCount.back()--;
+ m_closeHyperlinkInThisRun = false;
+ }
+ else
+ {
+ bool bIsStartedHyperlink = false;
+ for (const sal_Int32 nLinkCount : m_nHyperLinkCount)
+ {
+ if (nLinkCount > 0)
+ {
+ bIsStartedHyperlink = true;
+ break;
+ }
+ }
+ if (!bIsStartedHyperlink)
+ m_closeHyperlinkInThisRun = false;
}
- m_closeHyperlinkInThisRun = false;
}
if (!newStartedHyperlink)
@@ -1694,7 +2189,7 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /
if ( m_pRedlineData )
{
- EndRedline( m_pRedlineData );
+ EndRedline( m_pRedlineData, bLastRun );
m_pRedlineData = nullptr;
}
@@ -1703,11 +2198,11 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /
DoWriteBookmarkEndIfExist(nPos);
}
-void DocxAttributeOutput::DoWriteBookmarkTagStart(const OUString & bookmarkName)
+void DocxAttributeOutput::DoWriteBookmarkTagStart(const OUString& bookmarkName)
{
m_pSerializer->singleElementNS(XML_w, XML_bookmarkStart,
FSNS(XML_w, XML_id), OString::number(m_nNextBookmarkId),
- FSNS(XML_w, XML_name), BookmarkToWord(bookmarkName));
+ FSNS(XML_w, XML_name), GetExport().BookmarkToWord(bookmarkName));
}
void DocxAttributeOutput::DoWriteBookmarkTagEnd(sal_Int32 const nId)
@@ -1716,6 +2211,47 @@ void DocxAttributeOutput::DoWriteBookmarkTagEnd(sal_Int32 const nId)
FSNS(XML_w, XML_id), OString::number(nId));
}
+void DocxAttributeOutput::DoWriteMoveRangeTagStart(std::u16string_view bookmarkName,
+ bool bFrom, const SwRedlineData* pRedlineData)
+{
+ bool bRemovePersonalInfo = SvtSecurityOptions::IsOptionSet(
+ SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo ) && !SvtSecurityOptions::IsOptionSet(
+ SvtSecurityOptions::EOption::DocWarnKeepRedlineInfo);
+
+ const OUString &rAuthor( SW_MOD()->GetRedlineAuthor( pRedlineData->GetAuthor() ) );
+ const DateTime aDateTime = pRedlineData->GetTimeStamp();
+ bool bNoDate = bRemovePersonalInfo ||
+ ( aDateTime.GetYear() == 1970 && aDateTime.GetMonth() == 1 && aDateTime.GetDay() == 1 );
+
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
+ = sax_fastparser::FastSerializerHelper::createAttrList();
+
+ pAttributeList->add(FSNS(XML_w, XML_id), OString::number(m_nNextBookmarkId));
+ pAttributeList->add(FSNS(XML_w, XML_author ), bRemovePersonalInfo
+ ? "Author" + OString::number( GetExport().GetInfoID(rAuthor) )
+ : OUStringToOString(rAuthor, RTL_TEXTENCODING_UTF8));
+ if (!bNoDate)
+ pAttributeList->add(FSNS(XML_w, XML_date ), DateTimeToOString( aDateTime ));
+ pAttributeList->add(FSNS(XML_w, XML_name), bookmarkName);
+ m_pSerializer->singleElementNS( XML_w, bFrom ? XML_moveFromRangeStart : XML_moveToRangeStart, pAttributeList );
+
+ // tdf#150166 avoid of unpaired moveRangeEnd at moved ToC
+ m_rSavedBookmarksIds.insert(m_nNextBookmarkId);
+}
+
+void DocxAttributeOutput::DoWriteMoveRangeTagEnd(sal_Int32 const nId, bool bFrom)
+{
+ if ( m_rSavedBookmarksIds.count(nId) )
+ {
+ m_pSerializer->singleElementNS(XML_w, bFrom
+ ? XML_moveFromRangeEnd
+ : XML_moveToRangeEnd,
+ FSNS(XML_w, XML_id), OString::number(nId));
+
+ m_rSavedBookmarksIds.erase(nId);
+ }
+}
+
void DocxAttributeOutput::DoWriteBookmarkStartIfExist(sal_Int32 nRunPos)
{
auto aRange = m_aBookmarksOfParagraphStart.equal_range(nRunPos);
@@ -1723,7 +2259,7 @@ void DocxAttributeOutput::DoWriteBookmarkStartIfExist(sal_Int32 nRunPos)
{
DoWriteBookmarkTagStart(aIter->second);
m_rOpenedBookmarksIds[aIter->second] = m_nNextBookmarkId;
- m_sLastOpenedBookmark = OUStringToOString(BookmarkToWord(aIter->second), RTL_TEXTENCODING_UTF8);
+ m_sLastOpenedBookmark = GetExport().BookmarkToWord(aIter->second);
m_nNextBookmarkId++;
}
}
@@ -1745,15 +2281,28 @@ void DocxAttributeOutput::DoWriteBookmarkEndIfExist(sal_Int32 nRunPos)
}
/// Write the start bookmarks
-void DocxAttributeOutput::DoWriteBookmarksStart(std::vector<OUString>& rStarts)
+void DocxAttributeOutput::DoWriteBookmarksStart(std::vector<OUString>& rStarts, const SwRedlineData* pRedlineData)
{
for (const OUString & bookmarkName : rStarts)
{
- // Output the bookmark
- DoWriteBookmarkTagStart(bookmarkName);
+ // Output the bookmark (including MoveBookmark of the tracked moving)
+ bool bMove = false;
+ bool bFrom = false;
+ OUString sBookmarkName = GetExport().BookmarkToWord(bookmarkName, &bMove, &bFrom);
+ if ( bMove )
+ {
+ // TODO: redline data of MoveBookmark is restored from the first redline of the bookmark
+ // range. But a later deletion within a tracked moving is still imported as plain
+ // deletion, so check IsMoved() and skip the export of the tracked moving to avoid
+ // export with bad author or date
+ if ( pRedlineData && pRedlineData->IsMoved() )
+ DoWriteMoveRangeTagStart(sBookmarkName, bFrom, pRedlineData);
+ }
+ else
+ DoWriteBookmarkTagStart(bookmarkName);
m_rOpenedBookmarksIds[bookmarkName] = m_nNextBookmarkId;
- m_sLastOpenedBookmark = OUStringToOString(BookmarkToWord(bookmarkName), RTL_TEXTENCODING_UTF8);
+ m_sLastOpenedBookmark = sBookmarkName;
m_nNextBookmarkId++;
}
rStarts.clear();
@@ -1766,10 +2315,17 @@ void DocxAttributeOutput::DoWriteBookmarksEnd(std::vector<OUString>& rEnds)
{
// Get the id of the bookmark
auto pPos = m_rOpenedBookmarksIds.find(bookmarkName);
+
if (pPos != m_rOpenedBookmarksIds.end())
{
- // Output the bookmark
- DoWriteBookmarkTagEnd(pPos->second);
+ bool bMove = false;
+ bool bFrom = false;
+ GetExport().BookmarkToWord(bookmarkName, &bMove, &bFrom);
+ // Output the bookmark (including MoveBookmark of the tracked moving)
+ if ( bMove )
+ DoWriteMoveRangeTagEnd(pPos->second, bFrom);
+ else
+ DoWriteBookmarkTagEnd(pPos->second);
m_rOpenedBookmarksIds.erase(bookmarkName);
}
@@ -1784,29 +2340,34 @@ void DocxAttributeOutput::DoWriteBookmarksEnd(std::vector<OUString>& rEnds)
// - "permission-for-user:<permission-id>:<permission-user-name>"
// - "permission-for-group:<permission-id>:<permission-group-name>"
//
-void DocxAttributeOutput::DoWritePermissionTagStart(const OUString & permission)
+void DocxAttributeOutput::DoWritePermissionTagStart(std::u16string_view permission)
{
- OUString permissionIdAndName;
+ std::u16string_view permissionIdAndName;
- if (permission.startsWith("permission-for-group:", &permissionIdAndName))
+ if (o3tl::starts_with(permission, u"permission-for-group:", &permissionIdAndName))
{
- const sal_Int32 sparatorIndex = permissionIdAndName.indexOf(':');
- const OUString permissionId = permissionIdAndName.copy(0, sparatorIndex);
- const OUString permissionName = permissionIdAndName.copy(sparatorIndex + 1);
+ const std::size_t separatorIndex = permissionIdAndName.find(u':');
+ assert(separatorIndex != std::u16string_view::npos);
+ const OUString permissionId(permissionIdAndName.substr(0, separatorIndex));
+ const OUString permissionName(permissionIdAndName.substr(separatorIndex + 1));
m_pSerializer->singleElementNS(XML_w, XML_permStart,
- FSNS(XML_w, XML_id), BookmarkToWord(permissionId),
- FSNS(XML_w, XML_edGrp), BookmarkToWord(permissionName));
+ FSNS(XML_w, XML_id), GetExport().BookmarkToWord(permissionId),
+ FSNS(XML_w, XML_edGrp), GetExport().BookmarkToWord(permissionName));
}
- else // if (permission.startsWith("permission-for-user:", &permissionIdAndName))
+ else
{
- const sal_Int32 sparatorIndex = permissionIdAndName.indexOf(':');
- const OUString permissionId = permissionIdAndName.copy(0, sparatorIndex);
- const OUString permissionName = permissionIdAndName.copy(sparatorIndex + 1);
+ auto const ok = o3tl::starts_with(
+ permission, u"permission-for-user:", &permissionIdAndName);
+ assert(ok); (void)ok;
+ const std::size_t separatorIndex = permissionIdAndName.find(u':');
+ assert(separatorIndex != std::u16string_view::npos);
+ const OUString permissionId(permissionIdAndName.substr(0, separatorIndex));
+ const OUString permissionName(permissionIdAndName.substr(separatorIndex + 1));
m_pSerializer->singleElementNS(XML_w, XML_permStart,
- FSNS(XML_w, XML_id), BookmarkToWord(permissionId),
- FSNS(XML_w, XML_ed), BookmarkToWord(permissionName));
+ FSNS(XML_w, XML_id), GetExport().BookmarkToWord(permissionId),
+ FSNS(XML_w, XML_ed), GetExport().BookmarkToWord(permissionName));
}
}
@@ -1818,19 +2379,20 @@ void DocxAttributeOutput::DoWritePermissionTagStart(const OUString & permission)
// - "permission-for-user:<permission-id>:<permission-user-name>"
// - "permission-for-group:<permission-id>:<permission-group-name>"
//
-void DocxAttributeOutput::DoWritePermissionTagEnd(const OUString & permission)
+void DocxAttributeOutput::DoWritePermissionTagEnd(std::u16string_view permission)
{
- OUString permissionIdAndName;
+ std::u16string_view permissionIdAndName;
- if (permission.startsWith("permission-for-group:", &permissionIdAndName) ||
- permission.startsWith("permission-for-user:", &permissionIdAndName))
- {
- const sal_Int32 sparatorIndex = permissionIdAndName.indexOf(':');
- const OUString permissionId = permissionIdAndName.copy(0, sparatorIndex);
+ auto const ok = o3tl::starts_with(permission, u"permission-for-group:", &permissionIdAndName) ||
+ o3tl::starts_with(permission, u"permission-for-user:", &permissionIdAndName);
+ assert(ok); (void)ok;
- m_pSerializer->singleElementNS(XML_w, XML_permEnd,
- FSNS(XML_w, XML_id), BookmarkToWord(permissionId));
- }
+ const std::size_t separatorIndex = permissionIdAndName.find(u':');
+ assert(separatorIndex != std::u16string_view::npos);
+ const OUString permissionId(permissionIdAndName.substr(0, separatorIndex));
+
+ m_pSerializer->singleElementNS(XML_w, XML_permEnd,
+ FSNS(XML_w, XML_id), GetExport().BookmarkToWord(permissionId));
}
/// Write the start permissions
@@ -1879,7 +2441,7 @@ void DocxAttributeOutput::DoWriteAnnotationMarks()
for ( const auto & rName : m_rAnnotationMarksEnd )
{
// Get the id of the annotation mark
- std::map< OString, sal_Int32 >::iterator pPos = m_rOpenedAnnotationMarksIds.find( rName );
+ auto pPos = m_rOpenedAnnotationMarksIds.find( rName );
if ( pPos != m_rOpenedAnnotationMarksIds.end( ) )
{
const sal_Int32 nId = ( *pPos ).second;
@@ -1934,11 +2496,9 @@ void DocxAttributeOutput::WriteFFData( const FieldInfos& rInfos )
}
else if ( rInfos.eType == ww::eFORMCHECKBOX )
{
- OUString sName;
+ const OUString sName = params.getName();
bool bChecked = false;
- params.extractParam( ODF_FORMCHECKBOX_NAME, sName );
-
const sw::mark::ICheckboxFieldmark* pCheckboxFm = dynamic_cast<const sw::mark::ICheckboxFieldmark*>(&rFieldmark);
if ( pCheckboxFm && pCheckboxFm->IsChecked() )
bChecked = true;
@@ -1962,7 +2522,7 @@ void DocxAttributeOutput::WriteFFData( const FieldInfos& rInfos )
}
}
-void DocxAttributeOutput::WriteFormDateStart(const OUString& sFullDate, const OUString& sDateFormat, const OUString& sLang)
+void DocxAttributeOutput::WriteFormDateStart(const OUString& sFullDate, const OUString& sDateFormat, const OUString& sLang, const uno::Sequence<beans::PropertyValue>& aGrabBagSdt)
{
m_pSerializer->startElementNS(XML_w, XML_sdt);
m_pSerializer->startElementNS(XML_w, XML_sdtPr);
@@ -1982,21 +2542,270 @@ void DocxAttributeOutput::WriteFormDateStart(const OUString& sFullDate, const OU
FSNS(XML_w, XML_val), "dateTime");
m_pSerializer->singleElementNS(XML_w, XML_calendar,
FSNS(XML_w, XML_val), "gregorian");
-
m_pSerializer->endElementNS(XML_w, XML_date);
+
+ if (aGrabBagSdt.hasElements())
+ {
+ // There are some extra sdt parameters came from grab bag
+ SdtBlockHelper aSdtBlock;
+ aSdtBlock.GetSdtParamsFromGrabBag(aGrabBagSdt);
+ aSdtBlock.WriteExtraParams(m_pSerializer);
+ }
+
+ m_pSerializer->endElementNS(XML_w, XML_sdtPr);
+
+ m_pSerializer->startElementNS(XML_w, XML_sdtContent);
+}
+
+void DocxAttributeOutput::WriteSdtPlainText(const OUString & sValue, const uno::Sequence<beans::PropertyValue>& aGrabBagSdt)
+{
+ m_pSerializer->startElementNS(XML_w, XML_sdt);
+ m_pSerializer->startElementNS(XML_w, XML_sdtPr);
+
+ if (aGrabBagSdt.hasElements())
+ {
+ // There are some extra sdt parameters came from grab bag
+ SdtBlockHelper aSdtBlock;
+ aSdtBlock.GetSdtParamsFromGrabBag(aGrabBagSdt);
+ aSdtBlock.WriteExtraParams(m_pSerializer);
+
+ if (aSdtBlock.m_nSdtPrToken && aSdtBlock.m_nSdtPrToken != FSNS(XML_w, XML_id))
+ {
+ // Write <w:text/> or whatsoever from grabbag
+ m_pSerializer->singleElement(aSdtBlock.m_nSdtPrToken);
+ }
+
+ // Store databindings data for later writing to corresponding XMLs
+ OUString sPrefixMapping, sXpath;
+ for (const auto& rProp : aGrabBagSdt)
+ {
+ if (rProp.Name == "ooxml:CT_SdtPr_dataBinding")
+ {
+ uno::Sequence<beans::PropertyValue> aDataBindingProps;
+ rProp.Value >>= aDataBindingProps;
+ for (const auto& rDBProp : aDataBindingProps)
+ {
+ if (rDBProp.Name == "ooxml:CT_DataBinding_prefixMappings")
+ sPrefixMapping = rDBProp.Value.get<OUString>();
+ else if (rDBProp.Name == "ooxml:CT_DataBinding_xpath")
+ sXpath = rDBProp.Value.get<OUString>();
+ }
+ }
+ }
+
+ if (sXpath.getLength())
+ {
+ // Given xpath is sufficient
+ m_rExport.AddSdtData(sPrefixMapping, sXpath, sValue);
+ }
+ }
+
m_pSerializer->endElementNS(XML_w, XML_sdtPr);
m_pSerializer->startElementNS(XML_w, XML_sdtContent);
}
-void DocxAttributeOutput::WriteSdtEnd()
+void DocxAttributeOutput::WriteContentControlStart()
+{
+ if (!m_pContentControl)
+ {
+ return;
+ }
+
+ m_pSerializer->startElementNS(XML_w, XML_sdt);
+ m_pSerializer->startElementNS(XML_w, XML_sdtPr);
+ if (!m_pContentControl->GetPlaceholderDocPart().isEmpty())
+ {
+ m_pSerializer->startElementNS(XML_w, XML_placeholder);
+ m_pSerializer->singleElementNS(XML_w, XML_docPart, FSNS(XML_w, XML_val),
+ m_pContentControl->GetPlaceholderDocPart());
+ m_pSerializer->endElementNS(XML_w, XML_placeholder);
+ }
+
+ if (!m_pContentControl->GetDataBindingPrefixMappings().isEmpty() || !m_pContentControl->GetDataBindingXpath().isEmpty() || !m_pContentControl->GetDataBindingStoreItemID().isEmpty())
+ {
+ m_pSerializer->singleElementNS( XML_w, XML_dataBinding,
+ FSNS(XML_w, XML_prefixMappings), m_pContentControl->GetDataBindingPrefixMappings(),
+ FSNS(XML_w, XML_xpath), m_pContentControl->GetDataBindingXpath(),
+ FSNS(XML_w, XML_storeItemID), m_pContentControl->GetDataBindingStoreItemID());
+ }
+
+ if (!m_pContentControl->GetColor().isEmpty())
+ {
+ m_pSerializer->singleElementNS(XML_w15, XML_color, FSNS(XML_w, XML_val),
+ m_pContentControl->GetColor());
+ }
+
+ if (!m_pContentControl->GetAppearance().isEmpty())
+ {
+ m_pSerializer->singleElementNS(XML_w15, XML_appearance, FSNS(XML_w15, XML_val),
+ m_pContentControl->GetAppearance());
+ }
+
+ if (!m_pContentControl->GetAlias().isEmpty())
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_alias, FSNS(XML_w, XML_val),
+ m_pContentControl->GetAlias());
+ }
+
+ if (!m_pContentControl->GetTag().isEmpty())
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_tag, FSNS(XML_w, XML_val),
+ m_pContentControl->GetTag());
+ }
+
+ if (m_pContentControl->GetId())
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_id, FSNS(XML_w, XML_val),
+ OString::number(m_pContentControl->GetId()));
+ }
+
+ if (m_pContentControl->GetTabIndex())
+ {
+ // write the unsigned value as if it were signed since that is all we can import
+ const sal_Int32 nTabIndex = static_cast<sal_Int32>(m_pContentControl->GetTabIndex());
+ m_pSerializer->singleElementNS(XML_w, XML_tabIndex, FSNS(XML_w, XML_val),
+ OString::number(nTabIndex));
+ }
+
+ if (!m_pContentControl->GetLock().isEmpty())
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_lock, FSNS(XML_w, XML_val),
+ m_pContentControl->GetLock());
+ }
+
+ if (m_pContentControl->GetShowingPlaceHolder())
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_showingPlcHdr);
+ }
+
+ if (m_pContentControl->GetPicture())
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_picture);
+ }
+
+ if (m_pContentControl->GetCheckbox())
+ {
+ m_pSerializer->startElementNS(XML_w14, XML_checkbox);
+ m_pSerializer->singleElementNS(XML_w14, XML_checked, FSNS(XML_w14, XML_val),
+ OString::number(int(m_pContentControl->GetChecked())));
+ OUString aCheckedState = m_pContentControl->GetCheckedState();
+ if (!aCheckedState.isEmpty())
+ {
+ m_pSerializer->singleElementNS(XML_w14, XML_checkedState, FSNS(XML_w14, XML_val),
+ OString::number(aCheckedState[0], /*radix=*/16));
+ }
+ OUString aUncheckedState = m_pContentControl->GetUncheckedState();
+ if (!aUncheckedState.isEmpty())
+ {
+ m_pSerializer->singleElementNS(XML_w14, XML_uncheckedState, FSNS(XML_w14, XML_val),
+ OString::number(aUncheckedState[0], /*radix=*/16));
+ }
+ m_pSerializer->endElementNS(XML_w14, XML_checkbox);
+ }
+
+ if (m_pContentControl->GetComboBox() || m_pContentControl->GetDropDown())
+ {
+ if (m_pContentControl->GetComboBox())
+ {
+ m_pSerializer->startElementNS(XML_w, XML_comboBox);
+ }
+ else
+ {
+ m_pSerializer->startElementNS(XML_w, XML_dropDownList);
+ }
+ for (const auto& rItem : m_pContentControl->GetListItems())
+ {
+ rtl::Reference<FastAttributeList> xAttributes = FastSerializerHelper::createAttrList();
+ if (!rItem.m_aDisplayText.isEmpty())
+ {
+ // If there is no display text, need to omit the attribute, not write an empty one.
+ xAttributes->add(FSNS(XML_w, XML_displayText), rItem.m_aDisplayText);
+ }
+ xAttributes->add(FSNS(XML_w, XML_value), rItem.m_aValue);
+ m_pSerializer->singleElementNS(XML_w, XML_listItem, xAttributes);
+ }
+ if (m_pContentControl->GetComboBox())
+ {
+ m_pSerializer->endElementNS(XML_w, XML_comboBox);
+ }
+ else
+ {
+ m_pSerializer->endElementNS(XML_w, XML_dropDownList);
+ }
+ }
+
+ if (m_pContentControl->GetDate())
+ {
+ OUString aCurrentDate = m_pContentControl->GetCurrentDate();
+ if (aCurrentDate.isEmpty())
+ {
+ m_pSerializer->startElementNS(XML_w, XML_date);
+ }
+ else
+ {
+ m_pSerializer->startElementNS(XML_w, XML_date, FSNS(XML_w, XML_fullDate), aCurrentDate);
+ }
+ OUString aDateFormat = m_pContentControl->GetDateFormat().replaceAll("\"", "'");
+ if (!aDateFormat.isEmpty())
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_dateFormat, FSNS(XML_w, XML_val),
+ aDateFormat);
+ }
+ OUString aDateLanguage = m_pContentControl->GetDateLanguage();
+ if (!aDateLanguage.isEmpty())
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_lid, FSNS(XML_w, XML_val),
+ aDateLanguage);
+ }
+ m_pSerializer->endElementNS(XML_w, XML_date);
+ }
+
+ if (!m_pContentControl->GetMultiLine().isEmpty())
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_text, FSNS(XML_w, XML_multiLine), m_pContentControl->GetMultiLine());
+ }
+ else if (m_pContentControl->GetPlainText())
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_text);
+ }
+
+ m_pSerializer->endElementNS(XML_w, XML_sdtPr);
+ m_pSerializer->startElementNS(XML_w, XML_sdtContent);
+
+ const OUString& rPrefixMapping = m_pContentControl->GetDataBindingPrefixMappings();
+ const OUString& rXpath = m_pContentControl->GetDataBindingXpath();
+ if (!rXpath.isEmpty())
+ {
+ // This content control has a data binding, update the data source.
+ SwTextContentControl* pTextAttr = m_pContentControl->GetTextAttr();
+ SwTextNode* pTextNode = m_pContentControl->GetTextNode();
+ if (pTextNode && pTextAttr)
+ {
+ SwPosition aPoint(*pTextNode, pTextAttr->GetStart());
+ SwPosition aMark(*pTextNode, *pTextAttr->GetEnd());
+ SwPaM aPam(aMark, aPoint);
+ OUString aSnippet = aPam.GetText();
+ static sal_Unicode const aForbidden[] = {
+ CH_TXTATR_BREAKWORD,
+ 0
+ };
+ aSnippet = comphelper::string::removeAny(aSnippet, aForbidden);
+ m_rExport.AddSdtData(rPrefixMapping, rXpath, aSnippet);
+ }
+ }
+
+ m_pContentControl = nullptr;
+}
+
+void DocxAttributeOutput::WriteContentControlEnd()
{
m_pSerializer->endElementNS(XML_w, XML_sdtContent);
m_pSerializer->endElementNS(XML_w, XML_sdt);
}
void DocxAttributeOutput::WriteSdtDropDownStart(
- std::u16string_view rName,
+ OUString const& rName,
OUString const& rSelected,
uno::Sequence<OUString> const& rListItems)
{
@@ -2004,7 +2813,7 @@ void DocxAttributeOutput::WriteSdtDropDownStart(
m_pSerializer->startElementNS(XML_w, XML_sdtPr);
m_pSerializer->singleElementNS(XML_w, XML_alias,
- FSNS(XML_w, XML_val), OUStringToOString(rName, RTL_TEXTENCODING_UTF8));
+ FSNS(XML_w, XML_val), rName);
sal_Int32 nId = comphelper::findValue(rListItems, rSelected);
if (nId == -1)
@@ -2050,7 +2859,7 @@ void DocxAttributeOutput::WriteSdtDropDownEnd(OUString const& rSelected,
m_pSerializer->endElementNS(XML_w, XML_r);
}
- WriteSdtEnd();
+ WriteContentControlEnd();
}
void DocxAttributeOutput::StartField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun )
@@ -2058,7 +2867,8 @@ void DocxAttributeOutput::StartField_Impl( const SwTextNode* pNode, sal_Int32 nP
if ( rInfos.pField && rInfos.eType == ww::eUNKNOWN )
{
// Expand unsupported fields
- RunText( rInfos.pField->GetFieldName() );
+ RunText(rInfos.pField->ExpandField(/*bCached=*/true, nullptr));
+ return;
}
else if ( rInfos.eType == ww::eFORMDATE )
{
@@ -2086,7 +2896,11 @@ void DocxAttributeOutput::StartField_Impl( const SwTextNode* pNode, sal_Int32 nP
OUString sLang;
params.extractParam( ODF_FORMDATE_DATEFORMAT_LANGUAGE, sLang );
- WriteFormDateStart( sFullDate, sDateFormat, sLang );
+ uno::Sequence<beans::PropertyValue> aSdtParams;
+ params.extractParam(UNO_NAME_MISC_OBJ_INTEROPGRABBAG, aSdtParams);
+
+ WriteFormDateStart( sFullDate, sDateFormat, sLang, aSdtParams);
+ return;
}
else if (rInfos.eType == ww::eFORMDROPDOWN && rInfos.pField)
{
@@ -2095,8 +2909,20 @@ void DocxAttributeOutput::StartField_Impl( const SwTextNode* pNode, sal_Int32 nP
WriteSdtDropDownStart(rField2.GetName(),
rField2.GetSelectedItem(),
rField2.GetItemSequence());
+ return;
+ }
+ else if (rInfos.eType == ww::eFILLIN)
+ {
+ const SwInputField* pField = static_cast<SwInputField const*>(rInfos.pField.get());
+ if (pField && pField->getGrabBagParams().hasElements())
+ {
+ WriteSdtPlainText(pField->GetPar1(), pField->getGrabBagParams());
+ m_sRawText = pField->GetPar1(); // Write field content also as a fallback
+ return;
+ }
}
- else if ( rInfos.eType != ww::eNONE ) // HYPERLINK fields are just commands
+
+ if ( rInfos.eType != ww::eNONE ) // HYPERLINK fields are just commands
{
if ( bWriteRun )
m_pSerializer->startElementNS(XML_w, XML_r);
@@ -2147,12 +2973,12 @@ void DocxAttributeOutput::StartField_Impl( const SwTextNode* pNode, sal_Int32 nP
}
}
-void DocxAttributeOutput::DoWriteCmd( const OUString& rCmd )
+void DocxAttributeOutput::DoWriteCmd( std::u16string_view rCmd )
{
- OUString sCmd = rCmd.trim();
- if (sCmd.startsWith("SEQ"))
+ std::u16string_view sCmd = o3tl::trim(rCmd);
+ if (o3tl::starts_with(sCmd, u"SEQ"))
{
- OUString sSeqName = msfilter::util::findQuotedText(sCmd, "SEQ ", '\\').trim();
+ OUString sSeqName( o3tl::trim(msfilter::util::findQuotedText(sCmd, u"SEQ ", '\\')) );
m_aSeqBookmarksNames[sSeqName].push_back(m_sLastOpenedBookmark);
}
// Write the Field command
@@ -2160,7 +2986,7 @@ void DocxAttributeOutput::DoWriteCmd( const OUString& rCmd )
if ( m_pRedlineData && m_pRedlineData->GetType() == RedlineType::Delete )
nTextToken = XML_delInstrText;
- m_pSerializer->startElementNS(XML_w, nTextToken);
+ m_pSerializer->startElementNS(XML_w, nTextToken, FSNS(XML_xml, XML_space), "preserve");
m_pSerializer->writeEscaped( rCmd );
m_pSerializer->endElementNS( XML_w, nTextToken );
@@ -2205,7 +3031,7 @@ void DocxAttributeOutput::CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos
const std::map<OUString, uno::Any>& rGrabBag = pItem->GetGrabBag();
std::map<OUString, uno::Any>::const_iterator aStoredFormula = rGrabBag.find("CellFormulaConverted");
if ( aStoredFormula != rGrabBag.end() && sActualFormula.indexOf('=') == 0 &&
- sActualFormula.copy(1).trim() == aStoredFormula->second.get<OUString>().trim() )
+ o3tl::trim(sActualFormula.subView(1)) == o3tl::trim(aStoredFormula->second.get<OUString>()) )
{
aStoredFormula = rGrabBag.find("CellFormula");
if ( aStoredFormula != rGrabBag.end() )
@@ -2332,10 +3158,10 @@ void DocxAttributeOutput::EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos
{
if (rInfos.eType == ww::eFORMDATE)
{
- WriteSdtEnd();
+ WriteContentControlEnd();
return;
}
- if (rInfos.eType == ww::eFORMDROPDOWN && rInfos.pField)
+ else if (rInfos.eType == ww::eFORMDROPDOWN && rInfos.pField)
{
// write selected item from End not Start to ensure that any bookmarks
// precede it
@@ -2343,7 +3169,15 @@ void DocxAttributeOutput::EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos
WriteSdtDropDownEnd(rField.GetSelectedItem(), rField.GetItemSequence());
return;
}
-
+ else if (rInfos.eType == ww::eFILLIN && rInfos.pField)
+ {
+ SwInputField const& rField(*static_cast<SwInputField const*>(rInfos.pField.get()));
+ if (rField.getGrabBagParams().hasElements())
+ {
+ WriteContentControlEnd();
+ return;
+ }
+ }
// The command has to be written before for the hyperlinks
if ( rInfos.pField )
{
@@ -2448,17 +3282,17 @@ void DocxAttributeOutput::StartRunProperties()
}
InitCollectedRunProperties();
- assert( !m_pPostponedGraphic );
- m_pPostponedGraphic.reset(new std::vector<PostponedGraphic>);
+ assert( !m_oPostponedGraphic );
+ m_oPostponedGraphic.emplace();
- assert( !m_pPostponedDiagrams );
- m_pPostponedDiagrams.reset(new std::vector<PostponedDiagram>);
+ assert( !m_oPostponedDiagrams );
+ m_oPostponedDiagrams.emplace();
- assert(!m_pPostponedDMLDrawings);
- m_pPostponedDMLDrawings.reset(new std::vector<PostponedDrawing>);
+ assert(!m_oPostponedDMLDrawings);
+ m_oPostponedDMLDrawings.emplace();
- assert( !m_pPostponedOLEs );
- m_pPostponedOLEs.reset(new std::vector<PostponedOLE>);
+ assert( !m_oPostponedOLEs );
+ m_oPostponedOLEs.emplace();
}
void DocxAttributeOutput::InitCollectedRunProperties()
@@ -2511,6 +3345,9 @@ void DocxAttributeOutput::InitCollectedRunProperties()
FSNS( XML_w, XML_oMath ),
FSNS( XML_w, XML_rPrChange ),
FSNS( XML_w, XML_del ),
+ FSNS( XML_w, XML_ins ),
+ FSNS( XML_w, XML_moveFrom ),
+ FSNS( XML_w, XML_moveTo ),
FSNS( XML_w14, XML_glow ),
FSNS( XML_w14, XML_shadow ),
FSNS( XML_w14, XML_reflection ),
@@ -2527,6 +3364,7 @@ void DocxAttributeOutput::InitCollectedRunProperties()
// postpone the output so that we can later [in EndParagraphProperties()]
// prepend the properties before the run
+ // coverity[overrun-buffer-arg : FALSE] - coverity has difficulty with css::uno::Sequence
m_pSerializer->mark(Tag_InitCollectedRunProperties, comphelper::containerToSequence(aOrder));
}
@@ -2652,7 +3490,7 @@ void lclProcessRecursiveGrabBag(sal_Int32 aElementId, const css::uno::Sequence<c
}
}
- for (const auto& rAttribute : std::as_const(aAttributes))
+ for (const auto& rAttribute : aAttributes)
{
uno::Any aAny = rAttribute.Value;
OString aValue;
@@ -2695,38 +3533,34 @@ void DocxAttributeOutput::WriteCollectedRunProperties()
// Write all differed properties
if ( m_pFontsAttrList.is() )
{
- rtl::Reference<FastAttributeList> xAttrList = std::move( m_pFontsAttrList );
- m_pSerializer->singleElementNS( XML_w, XML_rFonts, xAttrList );
+ m_pSerializer->singleElementNS( XML_w, XML_rFonts, detachFrom( m_pFontsAttrList ) );
}
if ( m_pColorAttrList.is() )
{
- rtl::Reference<FastAttributeList> xAttrList( m_pColorAttrList );
-
- m_pSerializer->singleElementNS( XML_w, XML_color, xAttrList );
+ m_pSerializer->singleElementNS( XML_w, XML_color, m_pColorAttrList );
}
if ( m_pEastAsianLayoutAttrList.is() )
{
- rtl::Reference<FastAttributeList> xAttrList = std::move( m_pEastAsianLayoutAttrList );
- m_pSerializer->singleElementNS( XML_w, XML_eastAsianLayout, xAttrList );
+ m_pSerializer->singleElementNS( XML_w, XML_eastAsianLayout,
+ detachFrom(m_pEastAsianLayoutAttrList ) );
}
if ( m_pCharLangAttrList.is() )
{
- rtl::Reference<FastAttributeList> xAttrList = std::move( m_pCharLangAttrList );
- m_pSerializer->singleElementNS( XML_w, XML_lang, xAttrList );
+ m_pSerializer->singleElementNS( XML_w, XML_lang, detachFrom( m_pCharLangAttrList ) );
}
if (m_nCharTransparence != 0 && m_pColorAttrList && m_aTextEffectsGrabBag.empty())
{
- const char* pVal = nullptr;
- m_pColorAttrList->getAsChar(FSNS(XML_w, XML_val), pVal);
- if (std::string_view("auto") != pVal)
+ std::string_view pVal;
+ m_pColorAttrList->getAsView(FSNS(XML_w, XML_val), pVal);
+ if (!pVal.empty() && pVal != "auto")
{
m_pSerializer->startElementNS(XML_w14, XML_textFill);
m_pSerializer->startElementNS(XML_w14, XML_solidFill);
- m_pSerializer->startElementNS(XML_w14, XML_srgbClr, FSNS(XML_w14, XML_val), pVal);
+ m_pSerializer->startElementNS(XML_w14, XML_srgbClr, FSNS(XML_w14, XML_val), pVal.data());
sal_Int32 nTransparence = m_nCharTransparence * oox::drawingml::MAX_PERCENT / 255.0;
m_pSerializer->singleElementNS(XML_w14, XML_alpha, FSNS(XML_w14, XML_val), OString::number(nTransparence));
m_pSerializer->endElementNS(XML_w14, XML_srgbClr);
@@ -2753,6 +3587,11 @@ void DocxAttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData )
{
// Call the 'Redline' function. This will add redline (change-tracking) information that regards to run properties.
// This includes changes like 'Bold', 'Underline', 'Strikethrough' etc.
+
+ // If there is RedlineData present, call WriteCollectedRunProperties() for writing rPr before calling Redline().
+ // As there will be another rPr for redline and LO might mix both.
+ if(pRedlineData)
+ WriteCollectedRunProperties();
Redline( pRedlineData );
WriteCollectedRunProperties();
@@ -2765,6 +3604,8 @@ void DocxAttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData )
// write footnotes/endnotes if we have any
FootnoteEndnoteReference();
+ WriteLineBreak();
+
// merge the properties _before_ the run text (strictly speaking, just
// after the start of the run)
m_pSerializer->mergeTopMarks(Tag_StartRunProperties, sax_fastparser::MergeMarks::PREPEND);
@@ -2788,7 +3629,7 @@ void DocxAttributeOutput::GetSdtEndBefore(const SdrObject* pSdrObj)
if (!pSdrObj)
return;
- uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pSdrObj)->getUnoShape(), uno::UNO_QUERY_THROW);
+ uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pSdrObj)->getUnoShape());
uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
if( !xPropSet.is() )
return;
@@ -2804,28 +3645,28 @@ void DocxAttributeOutput::GetSdtEndBefore(const SdrObject* pSdrObj)
xPropSet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
}
- auto pProp = std::find_if(aGrabBag.begin(), aGrabBag.end(),
+ auto pProp = std::find_if(std::cbegin(aGrabBag), std::cend(aGrabBag),
[this](const beans::PropertyValue& rProp) {
- return "SdtEndBefore" == rProp.Name && m_bStartedCharSdt && !m_bEndCharSdt; });
- if (pProp != aGrabBag.end())
+ return "SdtEndBefore" == rProp.Name && m_aRunSdt.m_bStartedSdt && !m_bEndCharSdt; });
+ if (pProp != std::cend(aGrabBag))
pProp->Value >>= m_bEndCharSdt;
}
void DocxAttributeOutput::WritePostponedGraphic()
{
- for (const auto & rPostponedDiagram : *m_pPostponedGraphic)
+ for (const auto & rPostponedDiagram : *m_oPostponedGraphic)
FlyFrameGraphic(rPostponedDiagram.grfNode, rPostponedDiagram.size,
nullptr, nullptr,
rPostponedDiagram.pSdrObj);
- m_pPostponedGraphic.reset();
+ m_oPostponedGraphic.reset();
}
void DocxAttributeOutput::WritePostponedDiagram()
{
- for( const auto & rPostponedDiagram : *m_pPostponedDiagrams )
+ for( const auto & rPostponedDiagram : *m_oPostponedDiagrams )
m_rExport.SdrExporter().writeDiagram(rPostponedDiagram.object,
*rPostponedDiagram.frame, m_anchorId++);
- m_pPostponedDiagrams.reset();
+ m_oPostponedDiagrams.reset();
}
bool DocxAttributeOutput::FootnoteEndnoteRefTag()
@@ -2860,7 +3701,8 @@ bool DocxAttributeOutput::FootnoteEndnoteRefTag()
the switch in DocxAttributeOutput::RunText() nicer ;-)
*/
static bool impl_WriteRunText( FSHelperPtr const & pSerializer, sal_Int32 nTextToken,
- const sal_Unicode* &rBegin, const sal_Unicode* pEnd, bool bMove = true )
+ const sal_Unicode* &rBegin, const sal_Unicode* pEnd, bool bMove = true,
+ const OUString& rSymbolFont = OUString() )
{
const sal_Unicode *pBegin = rBegin;
@@ -2871,22 +3713,34 @@ static bool impl_WriteRunText( FSHelperPtr const & pSerializer, sal_Int32 nTextT
if ( pBegin >= pEnd )
return false; // we want to write at least one character
- // we have to add 'preserve' when starting/ending with space
- if ( *pBegin == ' ' || *( pEnd - 1 ) == ' ' )
+ bool bIsSymbol = !rSymbolFont.isEmpty();
+
+ std::u16string_view aView( pBegin, pEnd - pBegin );
+ if (bIsSymbol)
{
- pSerializer->startElementNS(XML_w, nTextToken, FSNS(XML_xml, XML_space), "preserve");
+ for (char16_t aChar : aView)
+ {
+ pSerializer->singleElementNS(XML_w, XML_sym,
+ FSNS(XML_w, XML_font), rSymbolFont,
+ FSNS(XML_w, XML_char), OString::number(aChar, 16));
+ }
}
else
- pSerializer->startElementNS(XML_w, nTextToken);
-
- pSerializer->writeEscaped( std::u16string_view( pBegin, pEnd - pBegin ) );
+ {
+ // we have to add 'preserve' when starting/ending with space
+ if ( *pBegin == ' ' || *( pEnd - 1 ) == ' ' )
+ pSerializer->startElementNS(XML_w, nTextToken, FSNS(XML_xml, XML_space), "preserve");
+ else
+ pSerializer->startElementNS(XML_w, nTextToken);
- pSerializer->endElementNS( XML_w, nTextToken );
+ pSerializer->writeEscaped( aView );
+ pSerializer->endElementNS( XML_w, nTextToken );
+ }
return true;
}
-void DocxAttributeOutput::RunText( const OUString& rText, rtl_TextEncoding /*eCharSet*/ )
+void DocxAttributeOutput::RunText( const OUString& rText, rtl_TextEncoding /*eCharSet*/, const OUString& rSymbolFont )
{
if( m_closeHyperlinkInThisRun )
{
@@ -2897,10 +3751,17 @@ void DocxAttributeOutput::RunText( const OUString& rText, rtl_TextEncoding /*eCh
const sal_Unicode *pBegin = rText.getStr();
const sal_Unicode *pEnd = pBegin + rText.getLength();
- // the text run is usually XML_t, with the exception of the deleted text
+ // the text run is usually XML_t, with the exception of the deleted (and not moved) text
sal_Int32 nTextToken = XML_t;
- if ( m_pRedlineData && m_pRedlineData->GetType() == RedlineType::Delete )
+
+ bool bMoved = m_pRedlineData && m_pRedlineData->IsMoved() &&
+ // tdf#150166 save tracked moving around TOC as w:ins, w:del
+ SwDoc::GetCurTOX(*m_rExport.m_pCurPam->GetPoint()) == nullptr;
+
+ if ( m_pRedlineData && m_pRedlineData->GetType() == RedlineType::Delete && !bMoved )
+ {
nTextToken = XML_delText;
+ }
sal_Unicode prevUnicode = *pBegin;
@@ -2914,6 +3775,7 @@ void DocxAttributeOutput::RunText( const OUString& rText, rtl_TextEncoding /*eCh
prevUnicode = *pIt;
break;
case 0x0b: // line break
+ case static_cast<sal_Unicode>(text::ControlCharacter::LINE_BREAK):
{
if (impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt ) || prevUnicode < 0x0020)
{
@@ -2943,7 +3805,7 @@ void DocxAttributeOutput::RunText( const OUString& rText, rtl_TextEncoding /*eCh
}
}
- impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pEnd, false );
+ impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pEnd, false, rSymbolFont );
}
void DocxAttributeOutput::RawText(const OUString& rText, rtl_TextEncoding /*eCharSet*/)
@@ -2955,7 +3817,7 @@ void DocxAttributeOutput::StartRuby( const SwTextNode& rNode, sal_Int32 nPos, co
{
WW8Ruby aWW8Ruby( rNode, rRuby, GetExport() );
SAL_INFO("sw.ww8", "TODO DocxAttributeOutput::StartRuby( const SwTextNode& rNode, const SwFormatRuby& rRuby )" );
- EndRun( &rNode, nPos ); // end run before starting ruby to avoid nested runs, and overlap
+ EndRun( &rNode, nPos, -1 ); // end run before starting ruby to avoid nested runs, and overlap
assert(!m_closeHyperlinkInThisRun); // check that no hyperlink overlaps ruby
assert(!m_closeHyperlinkInPreviousRun);
m_pSerializer->startElementNS(XML_w, XML_r);
@@ -2989,17 +3851,17 @@ void DocxAttributeOutput::StartRuby( const SwTextNode& rNode, sal_Int32 nPos, co
{
const SwCharFormat* pFormat = rRuby.GetTextRuby()->GetCharFormat();
sal_uInt16 nScript = g_pBreakIt->GetBreakIter()->getScriptType(rRuby.GetText(), 0);
- sal_uInt16 nWhichFont = (nScript == i18n::ScriptType::LATIN) ? RES_CHRATR_FONT : RES_CHRATR_CJK_FONT;
- sal_uInt16 nWhichFontSize = (nScript == i18n::ScriptType::LATIN) ? RES_CHRATR_FONTSIZE : RES_CHRATR_CJK_FONTSIZE;
+ TypedWhichId<SvxFontItem> nWhichFont = (nScript == i18n::ScriptType::LATIN) ? RES_CHRATR_FONT : RES_CHRATR_CJK_FONT;
+ TypedWhichId<SvxFontHeightItem> nWhichFontSize = (nScript == i18n::ScriptType::LATIN) ? RES_CHRATR_FONTSIZE : RES_CHRATR_CJK_FONTSIZE;
- CharFont(ItemGet<SvxFontItem>(*pFormat, nWhichFont));
- CharFontSize(ItemGet<SvxFontHeightItem>(*pFormat, nWhichFontSize));
- CharFontSize(ItemGet<SvxFontHeightItem>(*pFormat, RES_CHRATR_CTL_FONTSIZE));
+ CharFont(pFormat->GetFormatAttr(nWhichFont));
+ CharFontSize(pFormat->GetFormatAttr(nWhichFontSize));
+ CharFontSize(pFormat->GetFormatAttr(RES_CHRATR_CTL_FONTSIZE));
}
EndRunProperties( nullptr );
RunText( rRuby.GetText( ) );
- EndRun( &rNode, nPos );
+ EndRun( &rNode, nPos, -1 );
m_pSerializer->endElementNS( XML_w, XML_rt );
m_pSerializer->startElementNS(XML_w, XML_rubyBase);
@@ -3009,7 +3871,7 @@ void DocxAttributeOutput::StartRuby( const SwTextNode& rNode, sal_Int32 nPos, co
void DocxAttributeOutput::EndRuby(const SwTextNode& rNode, sal_Int32 nPos)
{
SAL_INFO("sw.ww8", "TODO DocxAttributeOutput::EndRuby()" );
- EndRun( &rNode, nPos );
+ EndRun( &rNode, nPos, -1 );
m_pSerializer->endElementNS( XML_w, XML_rubyBase );
m_pSerializer->endElementNS( XML_w, XML_ruby );
m_pSerializer->endElementNS( XML_w, XML_r );
@@ -3019,8 +3881,10 @@ void DocxAttributeOutput::EndRuby(const SwTextNode& rNode, sal_Int32 nPos)
bool DocxAttributeOutput::AnalyzeURL( const OUString& rUrl, const OUString& rTarget, OUString* pLinkURL, OUString* pMark )
{
bool bBookMarkOnly = AttributeOutputBase::AnalyzeURL( rUrl, rTarget, pLinkURL, pMark );
+ if (bBookMarkOnly)
+ *pMark = GetExport().BookmarkToWord(*pMark);
- if ( !pMark->isEmpty() )
+ if (!pMark->isEmpty() && (bBookMarkOnly || rTarget.isEmpty()))
{
OUString sURL = *pLinkURL;
@@ -3055,7 +3919,7 @@ bool DocxAttributeOutput::StartURL( const OUString& rUrl, const OUString& rTarge
m_hyperLinkAnchor = sMark;
- if ( !sMark.isEmpty() && !bBookmarkOnly )
+ if (!sMark.isEmpty() && !bBookmarkOnly && rTarget.isEmpty())
{
m_rExport.OutputField( nullptr, ww::eHYPERLINK, sUrl );
}
@@ -3066,11 +3930,16 @@ bool DocxAttributeOutput::StartURL( const OUString& rUrl, const OUString& rTarge
if ( !bBookmarkOnly )
{
- OString sId = OUStringToOString( GetExport().GetFilter().addRelation( m_pSerializer->getOutputStream(),
+ OUString sId = GetExport().GetFilter().addRelation( m_pSerializer->getOutputStream(),
oox::getRelationship(Relationship::HYPERLINK),
- sUrl, true ), RTL_TEXTENCODING_UTF8 );
+ sUrl, true );
m_pHyperlinkAttrList->add(FSNS(XML_r, XML_id), sId);
+ if (!sMark.isEmpty())
+ {
+ sMark = sMark.replace(' ', '_');
+ m_pHyperlinkAttrList->add(FSNS(XML_w, XML_anchor), sMark);
+ }
}
else
{
@@ -3085,14 +3954,14 @@ bool DocxAttributeOutput::StartURL( const OUString& rUrl, const OUString& rTarge
// Extract <seqname>, the field instruction text has the name quoted.
OUString aSequenceName = sMark.copy(0, nPos);
// Extract <index>.
- sal_uInt32 nIndex = sMark.copy(nPos + 1, sMark.getLength() - nPos - sizeof("|sequence")).toUInt32();
- std::map<OUString, std::vector<OString> >::iterator it = m_aSeqBookmarksNames.find(aSequenceName);
+ sal_uInt32 nIndex = o3tl::toUInt32(sMark.subView(nPos + 1, sMark.getLength() - nPos - sizeof("|sequence")));
+ auto it = m_aSeqBookmarksNames.find(aSequenceName);
if (it != m_aSeqBookmarksNames.end())
{
- std::vector<OString>& rNames = it->second;
+ std::vector<OUString>& rNames = it->second;
if (rNames.size() > nIndex)
// We know the bookmark name for this sequence and this index, do the replacement.
- sMark = OStringToOUString(rNames[nIndex], RTL_TEXTENCODING_UTF8);
+ sMark = rNames[nIndex];
}
}
}
@@ -3106,14 +3975,12 @@ bool DocxAttributeOutput::StartURL( const OUString& rUrl, const OUString& rTarge
}
// Spaces are prohibited in bookmark name.
sMark = sMark.replace(' ', '_');
- m_pHyperlinkAttrList->add( FSNS( XML_w, XML_anchor ),
- OUStringToOString( sMark, RTL_TEXTENCODING_UTF8 ) );
+ m_pHyperlinkAttrList->add( FSNS( XML_w, XML_anchor ), sMark );
}
if ( !rTarget.isEmpty() )
{
- OString soTarget = OUStringToOString( rTarget, RTL_TEXTENCODING_UTF8 );
- m_pHyperlinkAttrList->add(FSNS(XML_w, XML_tgtFrame), soTarget);
+ m_pHyperlinkAttrList->add(FSNS(XML_w, XML_tgtFrame), rTarget);
}
}
@@ -3123,7 +3990,8 @@ bool DocxAttributeOutput::StartURL( const OUString& rUrl, const OUString& rTarge
bool DocxAttributeOutput::EndURL(bool const)
{
m_closeHyperlinkInThisRun = true;
- if(m_startedHyperlink && !m_hyperLinkAnchor.isEmpty() && m_hyperLinkAnchor.startsWith("_Toc"))
+ if (m_nHyperLinkCount.back() > 0 && !m_hyperLinkAnchor.isEmpty()
+ && m_hyperLinkAnchor.startsWith("_Toc"))
{
m_endPageRef = true;
}
@@ -3144,9 +4012,15 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData)
if ( !pRedlineData )
return;
+ bool bRemovePersonalInfo = SvtSecurityOptions::IsOptionSet(
+ SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo ) && !SvtSecurityOptions::IsOptionSet(
+ SvtSecurityOptions::EOption::DocWarnKeepRedlineInfo);
+
OString aId( OString::number( pRedlineData->GetSeqNo() ) );
const OUString &rAuthor( SW_MOD()->GetRedlineAuthor( pRedlineData->GetAuthor() ) );
- OString aDate( DateTimeToOString( pRedlineData->GetTimeStamp() ) );
+ const DateTime aDateTime = pRedlineData->GetTimeStamp();
+ bool bNoDate = bRemovePersonalInfo ||
+ ( aDateTime.GetYear() == 1970 && aDateTime.GetMonth() == 1 && aDateTime.GetDay() == 1 );
switch( pRedlineData->GetType() )
{
@@ -3157,19 +4031,61 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData)
break;
case RedlineType::Format:
- m_pSerializer->startElementNS( XML_w, XML_rPrChange,
- FSNS( XML_w, XML_id ), aId,
- FSNS( XML_w, XML_author ), rAuthor,
- FSNS( XML_w, XML_date ), aDate );
+ {
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
+ = sax_fastparser::FastSerializerHelper::createAttrList();
+
+ pAttributeList->add(FSNS( XML_w, XML_id ), aId);
+ pAttributeList->add(FSNS( XML_w, XML_author ), bRemovePersonalInfo
+ ? "Author" + OString::number( GetExport().GetInfoID(rAuthor) )
+ : rAuthor.toUtf8());
+ if (!bNoDate)
+ pAttributeList->add(FSNS( XML_w, XML_date ), DateTimeToOString( aDateTime ));
+ m_pSerializer->startElementNS( XML_w, XML_rPrChange, pAttributeList );
+
+ // Check if there is any extra data stored in the redline object
+ if (pRedlineData->GetExtraData())
+ {
+ const SwRedlineExtraData* pExtraData = pRedlineData->GetExtraData();
+ const SwRedlineExtraData_FormatColl* pFormattingChanges = dynamic_cast<const SwRedlineExtraData_FormatColl*>(pExtraData);
+
+ // Check if the extra data is of type 'formatting changes'
+ if (pFormattingChanges)
+ {
+ // Get the item set that holds all the changes properties
+ const SfxItemSet *pChangesSet = pFormattingChanges->GetItemSet();
+ if (pChangesSet)
+ {
+ m_pSerializer->mark(Tag_Redline_1);
+
+ m_pSerializer->startElementNS(XML_w, XML_rPr);
+
+ // Output the redline item set
+ if (pChangesSet)
+ m_rExport.OutputItemSet( *pChangesSet, false, true, i18n::ScriptType::LATIN, m_rExport.m_bExportModeRTF );
+
+ m_pSerializer->endElementNS( XML_w, XML_rPr );
+
+ m_pSerializer->mergeTopMarks(Tag_Redline_1, sax_fastparser::MergeMarks::PREPEND);
+ }
+ }
+ }
m_pSerializer->endElementNS( XML_w, XML_rPrChange );
break;
-
+ }
case RedlineType::ParagraphFormat:
- m_pSerializer->startElementNS( XML_w, XML_pPrChange,
- FSNS( XML_w, XML_id ), aId,
- FSNS( XML_w, XML_author ), rAuthor,
- FSNS( XML_w, XML_date ), aDate );
+ {
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
+ = sax_fastparser::FastSerializerHelper::createAttrList();
+
+ pAttributeList->add(FSNS( XML_w, XML_id ), aId);
+ pAttributeList->add(FSNS( XML_w, XML_author ), bRemovePersonalInfo
+ ? "Author" + OString::number( GetExport().GetInfoID(rAuthor) )
+ : rAuthor.toUtf8());
+ if (!bNoDate)
+ pAttributeList->add(FSNS( XML_w, XML_date ), DateTimeToOString( aDateTime ));
+ m_pSerializer->startElementNS( XML_w, XML_pPrChange, pAttributeList );
// Check if there is any extra data stored in the redline object
if (pRedlineData->GetExtraData())
@@ -3189,19 +4105,29 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData)
m_pSerializer->startElementNS(XML_w, XML_pPr);
- OString sStyleName = MSWordStyles::CreateStyleId( sParaStyleName );
- if ( !sStyleName.isEmpty() )
- m_pSerializer->singleElementNS(XML_w, XML_pStyle, FSNS(XML_w, XML_val), sStyleName);
+ if (!sParaStyleName.isEmpty())
+ {
+ OString sStyleName;
+ if (auto format = m_rExport.m_rDoc.FindTextFormatCollByName(sParaStyleName))
+ if (auto slot = m_rExport.m_pStyles->GetSlot(format); slot != 0xfff)
+ sStyleName = m_rExport.m_pStyles->GetStyleId(slot);
+ // The resolved style name can be empty at this point, sParaStyleName can be
+ // an arbitrary string from the original document.
+ // Note that Word does *not* roundtrip unknown style names in redlines!
+ if (sStyleName.isEmpty())
+ sStyleName = MSWordStyles::CreateStyleId(sParaStyleName);
+ if (!sStyleName.isEmpty())
+ m_pSerializer->singleElementNS(XML_w, XML_pStyle, FSNS(XML_w, XML_val), sStyleName);
+ }
// The 'm_rExport.SdrExporter().getFlyAttrList()', 'm_pParagraphSpacingAttrList' are used to hold information
// that should be collected by different properties in the core, and are all flushed together
// to the DOCX when the function 'WriteCollectedParagraphProperties' gets called.
// So we need to store the current status of these lists, so that we can revert back to them when
// we are done exporting the redline attributes.
- rtl::Reference<sax_fastparser::FastAttributeList> pFlyAttrList_Original(m_rExport.SdrExporter().getFlyAttrList());
- m_rExport.SdrExporter().getFlyAttrList().clear();
- rtl::Reference<sax_fastparser::FastAttributeList> pParagraphSpacingAttrList_Original(m_pParagraphSpacingAttrList);
- m_pParagraphSpacingAttrList.clear();
+ auto pFlyAttrList_Original(detachFrom(m_rExport.SdrExporter().getFlyAttrList()));
+ auto pLRSpaceAttrList_Original(detachFrom(m_pLRSpaceAttrList));
+ auto pParagraphSpacingAttrList_Original(detachFrom(m_pParagraphSpacingAttrList));
// Output the redline item set
if (pChangesSet)
@@ -3211,8 +4137,9 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData)
WriteCollectedParagraphProperties();
// Revert back the original values that were stored in 'm_rExport.SdrExporter().getFlyAttrList()', 'm_pParagraphSpacingAttrList'
- m_rExport.SdrExporter().getFlyAttrList() = pFlyAttrList_Original;
- m_pParagraphSpacingAttrList = pParagraphSpacingAttrList_Original;
+ m_rExport.SdrExporter().getFlyAttrList() = std::move(pFlyAttrList_Original);
+ m_pLRSpaceAttrList = std::move(pLRSpaceAttrList_Original);
+ m_pParagraphSpacingAttrList = std::move(pParagraphSpacingAttrList_Original);
m_pSerializer->endElementNS( XML_w, XML_pPr );
@@ -3222,7 +4149,7 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData)
}
m_pSerializer->endElementNS( XML_w, XML_pPrChange );
break;
-
+ }
default:
SAL_WARN("sw.ww8", "Unhandled redline type for export " << SwRedlineTypeToOUString(pRedlineData->GetType()));
break;
@@ -3232,36 +4159,51 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData)
// The difference between 'Redline' and 'StartRedline'+'EndRedline' is that:
// 'Redline' is used for tracked changes of formatting information of a run like Bold, Underline. (the '<w:rPrChange>' is inside the 'run' node)
// 'StartRedline' is used to output tracked changes of run insertion and deletion (the run is inside the '<w:ins>' node)
-void DocxAttributeOutput::StartRedline( const SwRedlineData * pRedlineData )
+void DocxAttributeOutput::StartRedline( const SwRedlineData * pRedlineData, bool bLastRun )
{
if ( !pRedlineData )
return;
- // FIXME check if it's necessary to travel over the Next()'s in pRedlineData
+ // write out stack of this redline recursively (first the oldest)
+ if ( !bLastRun )
+ StartRedline( pRedlineData->Next(), false );
OString aId( OString::number( m_nRedlineId++ ) );
- const OUString &rAuthor( SW_MOD()->GetRedlineAuthor( pRedlineData->GetAuthor() ) );
- OString aAuthor( OUStringToOString( rAuthor, RTL_TEXTENCODING_UTF8 ) );
-
- OString aDate( DateTimeToOString( pRedlineData->GetTimeStamp() ) );
+ bool bRemovePersonalInfo = SvtSecurityOptions::IsOptionSet(
+ SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo ) && !SvtSecurityOptions::IsOptionSet(
+ SvtSecurityOptions::EOption::DocWarnKeepRedlineInfo);
+ const OUString &rAuthor( SW_MOD()->GetRedlineAuthor( pRedlineData->GetAuthor() ) );
+ OString aAuthor( OUStringToOString( bRemovePersonalInfo
+ ? "Author" + OUString::number( GetExport().GetInfoID(rAuthor) )
+ : rAuthor, RTL_TEXTENCODING_UTF8 ) );
+
+ const DateTime aDateTime = pRedlineData->GetTimeStamp();
+ bool bNoDate = bRemovePersonalInfo ||
+ ( aDateTime.GetYear() == 1970 && aDateTime.GetMonth() == 1 && aDateTime.GetDay() == 1 );
+ bool bMoved = pRedlineData->IsMoved() &&
+ // tdf#150166 save tracked moving around TOC as w:ins, w:del
+ SwDoc::GetCurTOX(*m_rExport.m_pCurPam->GetPoint()) == nullptr;
switch ( pRedlineData->GetType() )
{
case RedlineType::Insert:
- m_pSerializer->startElementNS( XML_w, XML_ins,
- FSNS( XML_w, XML_id ), aId,
- FSNS( XML_w, XML_author ), aAuthor,
- FSNS( XML_w, XML_date ), aDate );
- break;
-
case RedlineType::Delete:
- m_pSerializer->startElementNS( XML_w, XML_del,
+ {
+ sal_Int32 eElement = RedlineType::Insert == pRedlineData->GetType()
+ ? ( bMoved ? XML_moveTo : XML_ins )
+ : ( bMoved ? XML_moveFrom : XML_del );
+ if ( bNoDate )
+ m_pSerializer->startElementNS( XML_w, eElement,
+ FSNS( XML_w, XML_id ), aId,
+ FSNS( XML_w, XML_author ), aAuthor );
+ else
+ m_pSerializer->startElementNS( XML_w, eElement,
FSNS( XML_w, XML_id ), aId,
FSNS( XML_w, XML_author ), aAuthor,
- FSNS( XML_w, XML_date ), aDate );
+ FSNS( XML_w, XML_date ), DateTimeToOString( aDateTime ) );
break;
-
+ }
case RedlineType::Format:
SAL_INFO("sw.ww8", "TODO DocxAttributeOutput::StartRedline()" );
break;
@@ -3270,19 +4212,22 @@ void DocxAttributeOutput::StartRedline( const SwRedlineData * pRedlineData )
}
}
-void DocxAttributeOutput::EndRedline( const SwRedlineData * pRedlineData )
+void DocxAttributeOutput::EndRedline( const SwRedlineData * pRedlineData, bool bLastRun )
{
if ( !pRedlineData || m_bWritingField )
return;
+ bool bMoved = pRedlineData->IsMoved() &&
+ // tdf#150166 save tracked moving around TOC as w:ins, w:del
+ SwDoc::GetCurTOX(*m_rExport.m_pCurPam->GetPoint()) == nullptr;
switch ( pRedlineData->GetType() )
{
case RedlineType::Insert:
- m_pSerializer->endElementNS( XML_w, XML_ins );
+ m_pSerializer->endElementNS( XML_w, bMoved ? XML_moveTo : XML_ins );
break;
case RedlineType::Delete:
- m_pSerializer->endElementNS( XML_w, XML_del );
+ m_pSerializer->endElementNS( XML_w, bMoved ? XML_moveFrom : XML_del );
break;
case RedlineType::Format:
@@ -3291,6 +4236,10 @@ void DocxAttributeOutput::EndRedline( const SwRedlineData * pRedlineData )
default:
break;
}
+
+ // write out stack of this redline recursively (first the newest)
+ if ( !bLastRun )
+ EndRedline( pRedlineData->Next(), false );
}
void DocxAttributeOutput::FormatDrop( const SwTextNode& /*rNode*/, const SwFormatDrop& /*rSwFormatDrop*/, sal_uInt16 /*nStyle*/, ww8::WW8TableNodeInfo::Pointer_t /*pTextNodeInfo*/, ww8::WW8TableNodeInfoInner::Pointer_t )
@@ -3306,7 +4255,7 @@ void DocxAttributeOutput::ParagraphStyle( sal_uInt16 nStyle )
}
static void impl_borderLine( FSHelperPtr const & pSerializer, sal_Int32 elementToken, const SvxBorderLine* pBorderLine, sal_uInt16 nDist,
- bool bWriteShadow, const table::BorderLine2* rStyleProps = nullptr )
+ bool bWriteShadow, const table::BorderLine2* pStyleProps = nullptr)
{
// Compute val attribute value
// Can be one of:
@@ -3377,7 +4326,7 @@ static void impl_borderLine( FSHelperPtr const & pSerializer, sal_Int32 elementT
break;
}
}
- else if ( !rStyleProps || !rStyleProps->LineWidth )
+ else if (!pStyleProps || !pStyleProps->LineWidth)
// no line, and no line set by the style either:
// there is no need to write the property
return;
@@ -3385,14 +4334,17 @@ static void impl_borderLine( FSHelperPtr const & pSerializer, sal_Int32 elementT
// compare the properties with the theme properties before writing them:
// if they are equal, it means that they were style-defined and there is
// no need to write them.
- if( rStyleProps != nullptr && pBorderLine && !pBorderLine->isEmpty() &&
- pBorderLine->GetBorderLineStyle() == static_cast<SvxBorderLineStyle>(rStyleProps->LineStyle) &&
- pBorderLine->GetColor() == Color(ColorTransparency, rStyleProps->Color) &&
- pBorderLine->GetWidth() == convertMm100ToTwip( rStyleProps->LineWidth ) )
+ if (pStyleProps && pBorderLine && !pBorderLine->isEmpty()
+ && pBorderLine->GetBorderLineStyle()
+ == static_cast<SvxBorderLineStyle>(pStyleProps->LineStyle)
+ && pBorderLine->GetColor() == Color(ColorTransparency, pStyleProps->Color)
+ && pBorderLine->GetWidth() == o3tl::toTwips(pStyleProps->LineWidth, o3tl::Length::mm100))
+ {
return;
+ }
rtl::Reference<FastAttributeList> pAttr = FastSerializerHelper::createAttrList();
- pAttr->add( FSNS( XML_w, XML_val ), OString( pVal ) );
+ pAttr->add( FSNS( XML_w, XML_val ), pVal );
if ( pBorderLine && !pBorderLine->isEmpty() )
{
@@ -3417,7 +4369,10 @@ static void impl_borderLine( FSHelperPtr const & pSerializer, sal_Int32 elementT
// Get the color code as an RRGGBB hex value
OString sColor( msfilter::util::ConvertColor( pBorderLine->GetColor( ) ) );
- pAttr->add( FSNS( XML_w, XML_color ), sColor );
+ pAttr->add( FSNS(XML_w, XML_color), sColor);
+
+ model::ComplexColor const& rComplexColor = pBorderLine->getComplexColor();
+ lclAddThemeColorAttributes(pAttr, rComplexColor);
}
if (bWriteShadow)
@@ -3457,7 +4412,8 @@ static void impl_borders( FSHelperPtr const & pSerializer,
const SvxBoxItem& rBox,
const OutputBorderOptions& rOptions,
std::map<SvxBoxItemLine,
- css::table::BorderLine2> &rTableStyleConf )
+ css::table::BorderLine2> &rTableStyleConf,
+ ww8::Frame* pFramePr = nullptr)
{
static const SvxBoxItemLine aBorders[] =
{
@@ -3478,8 +4434,9 @@ static void impl_borders( FSHelperPtr const & pSerializer,
{
const SvxBorderLine* pLn = rBox.GetLine( *pBrd );
const table::BorderLine2 *aStyleProps = nullptr;
- if( rTableStyleConf.find( *pBrd ) != rTableStyleConf.end() )
- aStyleProps = &rTableStyleConf[ *pBrd ];
+ auto it = rTableStyleConf.find( *pBrd );
+ if( it != rTableStyleConf.end() )
+ aStyleProps = &(it->second);
if (!tagWritten && rOptions.bWriteTag)
{
@@ -3537,6 +4494,34 @@ static void impl_borders( FSHelperPtr const & pSerializer,
}
}
+ if (pFramePr)
+ {
+ assert(rOptions.bWriteDistance && !rOptions.pDistances);
+
+ // In addition to direct properties, and paragraph styles,
+ // for framePr-floated paragraphs the frame borders also affect the exported values.
+
+ // For border spacing, there is a special situation to consider
+ // because a compat setting ignores left/right paragraph spacing on layout.
+ const SwFrameFormat& rFormat = pFramePr->GetFrameFormat();
+ const SvxBoxItem& rFramePrBox = rFormat.GetBox();
+ const IDocumentSettingAccess& rIDSA = rFormat.GetDoc()->getIDocumentSettingAccess();
+ if (rIDSA.get(DocumentSettingId::INVERT_BORDER_SPACING)
+ && (*pBrd == SvxBoxItemLine::LEFT || *pBrd == SvxBoxItemLine::RIGHT))
+ {
+ // only the frame's border spacing affects layout - so use that value instead.
+ nDist = rFramePrBox.GetDistance(*pBrd);
+ }
+ else
+ {
+ nDist += rFramePrBox.GetDistance(*pBrd);
+ }
+
+ // Unless the user added a paragraph border, the border normally comes from the frame.
+ if (!pLn)
+ pLn = rFramePrBox.GetLine(*pBrd);
+ }
+
impl_borderLine( pSerializer, aXmlElements[i], pLn, nDist, bWriteShadow, aStyleProps );
}
if (tagWritten && rOptions.bWriteTag) {
@@ -3544,7 +4529,7 @@ static void impl_borders( FSHelperPtr const & pSerializer,
}
}
-static void impl_cellMargins( FSHelperPtr const & pSerializer, const SvxBoxItem& rBox, sal_Int32 tag, bool bUseStartEnd, const SvxBoxItem* pDefaultMargins = nullptr)
+void DocxAttributeOutput::ImplCellMargins( FSHelperPtr const & pSerializer, const SvxBoxItem& rBox, sal_Int32 tag, bool bUseStartEnd, const SvxBoxItem* pDefaultMargins)
{
static const SvxBoxItemLine aBorders[] =
{
@@ -3590,7 +4575,7 @@ void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Point
const SwTableBox *pTableBox = pTableTextNodeInfoInner->getTableBox( );
- bool bEcma = GetExport().GetFilter().getVersion( ) == oox::core::ECMA_DIALECT;
+ bool const bEcma = GetExport().GetFilter().getVersion() == oox::core::ECMA_376_1ST_EDITION;
// Output any table cell redlines if there are any attached to this specific cell
TableCellRedline( pTableTextNodeInfoInner );
@@ -3605,15 +4590,20 @@ void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Point
// Horizontal spans
const SwWriteTableRows& rRows = m_xTableWrt->GetRows( );
- SwWriteTableRow *pRow = rRows[ nRow ].get();
- const SwWriteTableCells& rTableCells = pRow->GetCells();
- if (nCell < rTableCells.size() )
+ if (nRow >= rRows.size())
+ SAL_WARN("sw.ww8", "DocxAttributeOutput::TableCellProperties: out of range row: " << nRow);
+ else
{
- const SwWriteTableCell& rCell = *rTableCells[nCell];
- const sal_uInt16 nColSpan = rCell.GetColSpan();
- if ( nColSpan > 1 )
- m_pSerializer->singleElementNS( XML_w, XML_gridSpan,
- FSNS( XML_w, XML_val ), OString::number(nColSpan) );
+ SwWriteTableRow *pRow = rRows[ nRow ].get();
+ const SwWriteTableCells& rTableCells = pRow->GetCells();
+ if (nCell < rTableCells.size() )
+ {
+ const SwWriteTableCell& rCell = *rTableCells[nCell];
+ const sal_uInt16 nColSpan = rCell.GetColSpan();
+ if ( nColSpan > 1 )
+ m_pSerializer->singleElementNS( XML_w, XML_gridSpan,
+ FSNS( XML_w, XML_val ), OString::number(nColSpan) );
+ }
}
// Vertical merges
@@ -3641,7 +4631,7 @@ void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Point
const SvxBoxItem& rBox = pTableBox->GetFrameFormat( )->GetBox( );
- const SvxBoxItem& rDefaultBox = (*tableFirstCells.rbegin())->getTableBox( )->GetFrameFormat( )->GetBox( );
+ const SvxBoxItem& rDefaultBox = (*m_TableFirstCells.rbegin())->getTableBox( )->GetFrameFormat( )->GetBox( );
{
// The cell borders
impl_borders(m_pSerializer, rBox, lcl_getTableCellBorderOptions(bEcma),
@@ -3652,7 +4642,7 @@ void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Point
{
// Cell margins
- impl_cellMargins( m_pSerializer, rBox, XML_tcMar, !bEcma, &rDefaultBox );
+ DocxAttributeOutput::ImplCellMargins( m_pSerializer, rBox, XML_tcMar, !bEcma, &rDefaultBox );
}
TableVerticalCell( pTableTextNodeInfoInner );
@@ -3684,16 +4674,16 @@ void DocxAttributeOutput::InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t
void DocxAttributeOutput::StartTable( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner )
{
- m_aTableStyleConfs.push_back({});
+ m_aTableStyleConfs.emplace_back();
// In case any paragraph SDT's are open, close them here.
EndParaSdtBlock();
m_pSerializer->startElementNS(XML_w, XML_tbl);
- tableFirstCells.push_back(pTableTextNodeInfoInner);
- lastOpenCell.push_back(-1);
- lastClosedCell.push_back(-1);
+ m_TableFirstCells.push_back(pTableTextNodeInfoInner);
+ m_LastOpenCell.push_back(-1);
+ m_LastClosedCell.push_back(-1);
InitTableHelper( pTableTextNodeInfoInner );
TableDefinition( pTableTextNodeInfoInner );
@@ -3703,18 +4693,18 @@ void DocxAttributeOutput::EndTable()
{
m_pSerializer->endElementNS( XML_w, XML_tbl );
- if ( m_tableReference->m_nTableDepth > 0 )
- --m_tableReference->m_nTableDepth;
+ if ( m_tableReference.m_nTableDepth > 0 )
+ --m_tableReference.m_nTableDepth;
- lastClosedCell.pop_back();
- lastOpenCell.pop_back();
- tableFirstCells.pop_back();
+ m_LastClosedCell.pop_back();
+ m_LastOpenCell.pop_back();
+ m_TableFirstCells.pop_back();
// We closed the table; if it is a nested table, the cell that contains it
// still continues
// set to true only if we were in a nested table, not otherwise.
- if( !tableFirstCells.empty() )
- m_tableReference->m_bTableCellOpen = true;
+ if( !m_TableFirstCells.empty() )
+ m_tableReference.m_bTableCellOpen = true;
// Cleans the table helper
m_xTableWrt.reset();
@@ -3758,785 +4748,43 @@ void DocxAttributeOutput::StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t c
void DocxAttributeOutput::EndTableRow( )
{
m_pSerializer->endElementNS( XML_w, XML_tr );
- lastOpenCell.back() = -1;
- lastClosedCell.back() = -1;
+ m_LastOpenCell.back() = -1;
+ m_LastClosedCell.back() = -1;
}
void DocxAttributeOutput::StartTableCell( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner, sal_uInt32 nCell, sal_uInt32 nRow )
{
- lastOpenCell.back() = nCell;
+ m_LastOpenCell.back() = nCell;
InitTableHelper( pTableTextNodeInfoInner );
+ // check tracked table column deletion or insertion
+ const SwTableBox* pTabBox = pTableTextNodeInfoInner->getTableBox();
+ SwRedlineTable::size_type nChange = pTabBox->GetRedline();
+ if (nChange != SwRedlineTable::npos)
+ m_tableReference.m_bTableCellChanged = true;
+
m_pSerializer->startElementNS(XML_w, XML_tc);
// Write the cell properties here
TableCellProperties( pTableTextNodeInfoInner, nCell, nRow );
- m_tableReference->m_bTableCellOpen = true;
+ m_tableReference.m_bTableCellOpen = true;
}
void DocxAttributeOutput::EndTableCell(sal_uInt32 nCell)
{
- lastClosedCell.back() = nCell;
- lastOpenCell.back() = -1;
+ m_LastClosedCell.back() = nCell;
+ m_LastOpenCell.back() = -1;
- if (m_tableReference->m_bTableCellParaSdtOpen)
+ if (m_tableReference.m_bTableCellParaSdtOpen)
EndParaSdtBlock();
m_pSerializer->endElementNS( XML_w, XML_tc );
- m_tableReference->m_bTableCellOpen = false;
- m_tableReference->m_bTableCellParaSdtOpen = false;
-}
-
-void DocxAttributeOutput::TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
-{
-}
-
-void DocxAttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfo*/ )
-{
-}
-
-namespace
-{
-
-/// Does the same as comphelper::string::padToLength(), but extends the start, not the end.
-OString lcl_padStartToLength(OString const & aString, sal_Int32 nLen, char cFill)
-{
- if (nLen > aString.getLength())
- {
- sal_Int32 nDiff = nLen - aString.getLength();
- OStringBuffer aBuffer;
- comphelper::string::padToLength(aBuffer, nDiff, cFill);
- aBuffer.append(aString);
- return aBuffer.makeStringAndClear();
- }
- else
- return aString;
-}
-
-//Keep this function in-sync with the one in writerfilter/.../SettingsTable.cxx
-//Since this is not import code, "-1" needs to be handled as the mode that LO will save as.
-//To identify how your code should handle a "-1", look in DocxExport::WriteSettings().
-sal_Int32 lcl_getWordCompatibilityMode( const SwDoc& rDoc )
-{
- uno::Reference< beans::XPropertySet > xPropSet( rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
- uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
-
- sal_Int32 nWordCompatibilityMode = -1;
- if ( xPropSetInfo->hasPropertyByName( UNO_NAME_MISC_OBJ_INTEROPGRABBAG ) )
- {
- uno::Sequence< beans::PropertyValue > propList;
- xPropSet->getPropertyValue( UNO_NAME_MISC_OBJ_INTEROPGRABBAG ) >>= propList;
-
- for ( const auto& rProp : std::as_const(propList) )
- {
- if ( rProp.Name == "CompatSettings" )
- {
- css::uno::Sequence< css::beans::PropertyValue > aCurrentCompatSettings;
- rProp.Value >>= aCurrentCompatSettings;
-
- for ( const auto& rCurrentCompatSetting : std::as_const(aCurrentCompatSettings) )
- {
- uno::Sequence< beans::PropertyValue > aCompatSetting;
- rCurrentCompatSetting.Value >>= aCompatSetting;
-
- OUString sName;
- OUString sUri;
- OUString sVal;
-
- for ( const auto& rPropVal : std::as_const(aCompatSetting) )
- {
- if ( rPropVal.Name == "name" ) rPropVal.Value >>= sName;
- if ( rPropVal.Name == "uri" ) rPropVal.Value >>= sUri;
- if ( rPropVal.Name == "val" ) rPropVal.Value >>= sVal;
- }
-
- if ( sName == "compatibilityMode" && sUri == "http://schemas.microsoft.com/office/word" )
- {
- const sal_Int32 nValidMode = sVal.toInt32();
- // if repeated, highest mode wins in MS Word. 11 is the first valid mode.
- if ( nValidMode > 10 && nValidMode > nWordCompatibilityMode )
- nWordCompatibilityMode = nValidMode;
-
- }
- }
- }
- }
- }
-
- // TODO: this is duplicated, better store it in DocxExport member?
- if (!rDoc.getIDocumentSettingAccess().get(DocumentSettingId::ADD_EXT_LEADING))
- {
- if (nWordCompatibilityMode == -1 || 14 < nWordCompatibilityMode)
- {
- nWordCompatibilityMode = 14;
- }
- }
-
- return nWordCompatibilityMode;
-}
-
-}
-
-void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
-{
- bool bEcma = GetExport().GetFilter().getVersion( ) == oox::core::ECMA_DIALECT;
-
- // Write the table properties
- m_pSerializer->startElementNS(XML_w, XML_tblPr);
-
- static const sal_Int32 aOrder[] =
- {
- FSNS( XML_w, XML_tblStyle ),
- FSNS( XML_w, XML_tblpPr ),
- FSNS( XML_w, XML_tblOverlap ),
- FSNS( XML_w, XML_bidiVisual ),
- FSNS( XML_w, XML_tblStyleRowBandSize ),
- FSNS( XML_w, XML_tblStyleColBandSize ),
- FSNS( XML_w, XML_tblW ),
- FSNS( XML_w, XML_jc ),
- FSNS( XML_w, XML_tblCellSpacing ),
- FSNS( XML_w, XML_tblInd ),
- FSNS( XML_w, XML_tblBorders ),
- FSNS( XML_w, XML_shd ),
- FSNS( XML_w, XML_tblLayout ),
- FSNS( XML_w, XML_tblCellMar ),
- FSNS( XML_w, XML_tblLook ),
- FSNS( XML_w, XML_tblPrChange )
- };
-
- // postpone the output so that we can later []
- // prepend the properties before the run
- m_pSerializer->mark(Tag_TableDefinition, comphelper::containerToSequence(aOrder));
-
- tools::Long nPageSize = 0;
- const char* widthType = "dxa";
-
- // If actual width of table is relative it should export is as "pct".`
- const SwTable *pTable = pTableTextNodeInfoInner->getTable();
- SwFrameFormat *pTableFormat = pTable->GetFrameFormat( );
- const SwFormatFrameSize &rSize = pTableFormat->GetFrameSize();
- int nWidthPercent = rSize.GetWidthPercent();
- // If we export a floating table: we use the widthPercent of the surrounding frame
- const ww8::Frame* pFloatingTableFrame = m_rExport.GetFloatingTableFrame();
- if (pFloatingTableFrame)
- {
- const SwFormatFrameSize &rFrameSize = pFloatingTableFrame->GetFrameFormat().GetFrameSize();
- nWidthPercent = rFrameSize.GetWidthPercent();
- }
- uno::Reference<beans::XPropertySet> xPropertySet(SwXTextTables::GetObject(*pTable->GetFrameFormat( )),uno::UNO_QUERY);
- bool isWidthRelative = false;
- xPropertySet->getPropertyValue("IsWidthRelative") >>= isWidthRelative;
-
- if(isWidthRelative)
- {
- /**
- * As per ECMA Specification : ECMA-376, Second Edition, Part 1 - Fundamentals And Markup Language Reference [ 17.18.90 ST_TableWidth (Table Width Units)]
- * http://www.schemacentral.com/sc/ooxml/a-w_type-7.html
- *
- * Fiftieths of a Percent :
- * http://startbigthinksmall.wordpress.com/2010/01/04/points-inches-and-emus-measuring-units-in-office-open-xml/
- * pct Width is in Fiftieths of a Percent
- *
- * ex. If the Table width is 50% then
- * Width in Fiftieths of a percent is (50 * 50) % or 0.5 * 5000 = 2500pct
- **/
- nPageSize = nWidthPercent * 50 ;
- widthType = "pct" ;
- }
- else
- {
- bool bRelBoxSize = false;
- // Create the SwWriteTable instance to use col spans (and maybe other infos)
- GetTablePageSize( pTableTextNodeInfoInner.get(), nPageSize, bRelBoxSize );
- if(nPageSize == 0)
- widthType = "auto";
- }
-
- // Output the table preferred width
- m_pSerializer->singleElementNS( XML_w, XML_tblW,
- FSNS( XML_w, XML_w ), OString::number(nPageSize),
- FSNS( XML_w, XML_type ), widthType );
-
- // Disable layout autofit, as it does not exist in LibreOffice yet
- m_pSerializer->singleElementNS( XML_w, XML_tblLayout,
- FSNS( XML_w, XML_type ), "fixed" );
-
- // Look for the table style property in the table grab bag
- std::map<OUString, css::uno::Any> aGrabBag =
- pTableFormat->GetAttrSet().GetItem<SfxGrabBagItem>(RES_FRMATR_GRABBAG)->GetGrabBag();
-
- // We should clear the TableStyle map. In case of Table inside multiple tables it contains the
- // table border style of the previous table.
- std::map<SvxBoxItemLine, css::table::BorderLine2>& rTableStyleConf = m_aTableStyleConfs.back();
- rTableStyleConf.clear();
-
- // Extract properties from grab bag
- for( const auto & rGrabBagElement : aGrabBag )
- {
- if( rGrabBagElement.first == "TableStyleName")
- {
- OString sStyleName = OUStringToOString( rGrabBagElement.second.get<OUString>(), RTL_TEXTENCODING_UTF8 );
- m_pSerializer->singleElementNS(XML_w, XML_tblStyle, FSNS(XML_w, XML_val), sStyleName);
- }
- else if( rGrabBagElement.first == "TableStyleTopBorder" )
- rTableStyleConf[SvxBoxItemLine::TOP] = rGrabBagElement.second.get<table::BorderLine2>();
- else if( rGrabBagElement.first == "TableStyleBottomBorder" )
- rTableStyleConf[SvxBoxItemLine::BOTTOM]
- = rGrabBagElement.second.get<table::BorderLine2>();
- else if( rGrabBagElement.first == "TableStyleLeftBorder" )
- rTableStyleConf[SvxBoxItemLine::LEFT]
- = rGrabBagElement.second.get<table::BorderLine2>();
- else if( rGrabBagElement.first == "TableStyleRightBorder" )
- rTableStyleConf[SvxBoxItemLine::RIGHT]
- = rGrabBagElement.second.get<table::BorderLine2>();
- else if (rGrabBagElement.first == "TableStyleLook")
- {
- rtl::Reference<FastAttributeList> pAttributeList = FastSerializerHelper::createAttrList();
- const uno::Sequence<beans::PropertyValue> aAttributeList = rGrabBagElement.second.get< uno::Sequence<beans::PropertyValue> >();
-
- for (const auto& rAttribute : aAttributeList)
- {
- if (rAttribute.Name == "val")
- pAttributeList->add(FSNS(XML_w, XML_val), lcl_padStartToLength(OString::number(rAttribute.Value.get<sal_Int32>(), 16), 4, '0'));
- else
- {
- static DocxStringTokenMap const aTokens[] =
- {
- {"firstRow", XML_firstRow},
- {"lastRow", XML_lastRow},
- {"firstColumn", XML_firstColumn},
- {"lastColumn", XML_lastColumn},
- {"noHBand", XML_noHBand},
- {"noVBand", XML_noVBand},
- {nullptr, 0}
- };
-
- if (sal_Int32 nToken = DocxStringGetToken(aTokens, rAttribute.Name))
- pAttributeList->add(FSNS(XML_w, nToken), (rAttribute.Value.get<sal_Int32>() ? "1" : "0"));
- }
- }
-
- m_pSerializer->singleElementNS(XML_w, XML_tblLook, pAttributeList);
- }
- else if (rGrabBagElement.first == "TablePosition" &&
- // skip empty table position (tables in footnotes converted to
- // floating tables temporarily, don't export this)
- rGrabBagElement.second != uno::Any() )
- {
- rtl::Reference<FastAttributeList> attrListTablePos = FastSerializerHelper::createAttrList( );
- const uno::Sequence<beans::PropertyValue> aTablePosition = rGrabBagElement.second.get<uno::Sequence<beans::PropertyValue> >();
- // look for a surrounding frame and take it's position values
- const ww8::Frame* pFrame = m_rExport.GetFloatingTableFrame();
- if( pFrame )
- {
- // we export the values of the surrounding Frame
- OString sOrientation;
- sal_Int32 nValue;
-
- // If tblpXSpec or tblpYSpec are present, we do not write tblpX or tblpY!
- OString sTblpXSpec = convertToOOXMLHoriOrient( pFrame->GetFrameFormat().GetHoriOrient().GetHoriOrient(), pFrame->GetFrameFormat().GetHoriOrient().IsPosToggle() );
- OString sTblpYSpec = convertToOOXMLVertOrient( pFrame->GetFrameFormat().GetVertOrient().GetVertOrient() );
-
- sOrientation = convertToOOXMLVertOrientRel( pFrame->GetFrameFormat().GetVertOrient().GetRelationOrient() );
- attrListTablePos->add(FSNS(XML_w, XML_vertAnchor), sOrientation);
-
- if( !sTblpYSpec.isEmpty() )
- attrListTablePos->add(FSNS(XML_w, XML_tblpYSpec), sTblpYSpec);
-
- sOrientation = convertToOOXMLHoriOrientRel( pFrame->GetFrameFormat().GetHoriOrient().GetRelationOrient() );
- attrListTablePos->add(FSNS(XML_w, XML_horzAnchor), sOrientation);
-
- if( !sTblpXSpec.isEmpty() )
- attrListTablePos->add(FSNS(XML_w, XML_tblpXSpec), sTblpXSpec);
-
- nValue = pFrame->GetFrameFormat().GetULSpace().GetLower();
- if( nValue != 0 )
- attrListTablePos->add( FSNS( XML_w, XML_bottomFromText ), OString::number( nValue ) );
-
- nValue = pFrame->GetFrameFormat().GetLRSpace().GetLeft();
- if( nValue != 0 )
- attrListTablePos->add( FSNS( XML_w, XML_leftFromText ), OString::number( nValue ) );
-
- nValue = pFrame->GetFrameFormat().GetLRSpace().GetRight();
- if( nValue != 0 )
- attrListTablePos->add( FSNS( XML_w, XML_rightFromText ), OString::number( nValue ) );
-
- nValue = pFrame->GetFrameFormat().GetULSpace().GetUpper();
- if( nValue != 0 )
- attrListTablePos->add( FSNS( XML_w, XML_topFromText ), OString::number( nValue ) );
-
- if( sTblpXSpec.isEmpty() ) // do not write tblpX if tblpXSpec is present
- {
- nValue = pFrame->GetFrameFormat().GetHoriOrient().GetPos();
- // we need to revert the additional shift introduced by
- // lcl_DecrementHoriOrientPosition() in writerfilter
- // 1st: left distance of the table
- const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
- const SwFrameFormat * pFrameFormat = pTabBox->GetFrameFormat();
- const SvxBoxItem& rBox = pFrameFormat->GetBox( );
- sal_uInt16 nLeftDistance = rBox.GetDistance(SvxBoxItemLine::LEFT);
- nValue += nLeftDistance;
-
- // 2nd: if a left border is given, revert the shift by half the width
- // from lcl_DecrementHoriOrientPosition() in writerfilter
- if (const editeng::SvxBorderLine* pLeftBorder = rBox.GetLeft())
- {
- tools::Long nWidth = pLeftBorder->GetWidth();
- nValue += (nWidth / 2);
- }
-
- attrListTablePos->add( FSNS( XML_w, XML_tblpX ), OString::number( nValue ) );
- }
-
- if( sTblpYSpec.isEmpty() ) // do not write tblpY if tblpYSpec is present
- {
- nValue = pFrame->GetFrameFormat().GetVertOrient().GetPos();
- attrListTablePos->add( FSNS( XML_w, XML_tblpY ), OString::number( nValue ) );
- }
- }
- else // ( pFrame = 0 )
- {
- // we export the values from the grabBag
- for (const auto& rProp : aTablePosition)
- {
- if (rProp.Name == "vertAnchor" && !rProp.Value.get<OUString>().isEmpty())
- {
- OString sOrientation = OUStringToOString( rProp.Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
- attrListTablePos->add(FSNS(XML_w, XML_vertAnchor), sOrientation);
- }
- else if (rProp.Name == "tblpYSpec" && !rProp.Value.get<OUString>().isEmpty())
- {
- OString sOrientation = OUStringToOString( rProp.Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
- attrListTablePos->add(FSNS(XML_w, XML_tblpYSpec), sOrientation);
- }
- else if (rProp.Name == "horzAnchor" && !rProp.Value.get<OUString>().isEmpty())
- {
- OString sOrientation = OUStringToOString( rProp.Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
- attrListTablePos->add(FSNS(XML_w, XML_horzAnchor), sOrientation);
- }
- else if (rProp.Name == "tblpXSpec" && !rProp.Value.get<OUString>().isEmpty())
- {
- OString sOrientation = OUStringToOString( rProp.Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
- attrListTablePos->add(FSNS(XML_w, XML_tblpXSpec), sOrientation);
- }
- else if (rProp.Name == "bottomFromText")
- {
- sal_Int32 nValue = rProp.Value.get<sal_Int32>();
- attrListTablePos->add( FSNS( XML_w, XML_bottomFromText ), OString::number( nValue ) );
- }
- else if (rProp.Name == "leftFromText")
- {
- sal_Int32 nValue = rProp.Value.get<sal_Int32>();
- attrListTablePos->add( FSNS( XML_w, XML_leftFromText ), OString::number( nValue ) );
- }
- else if (rProp.Name == "rightFromText")
- {
- sal_Int32 nValue = rProp.Value.get<sal_Int32>();
- attrListTablePos->add( FSNS( XML_w, XML_rightFromText ), OString::number( nValue ) );
- }
- else if (rProp.Name == "topFromText")
- {
- sal_Int32 nValue = rProp.Value.get<sal_Int32>();
- attrListTablePos->add( FSNS( XML_w, XML_topFromText ), OString::number( nValue ) );
- }
- else if (rProp.Name == "tblpX")
- {
- sal_Int32 nValue = rProp.Value.get<sal_Int32>();
- attrListTablePos->add( FSNS( XML_w, XML_tblpX ), OString::number( nValue ) );
- }
- else if (rProp.Name == "tblpY")
- {
- sal_Int32 nValue = rProp.Value.get<sal_Int32>();
- attrListTablePos->add( FSNS( XML_w, XML_tblpY ), OString::number( nValue ) );
- }
- }
- }
-
- m_pSerializer->singleElementNS( XML_w, XML_tblpPr, attrListTablePos);
- attrListTablePos = nullptr;
- }
- else
- SAL_WARN("sw.ww8", "DocxAttributeOutput::TableDefinition: unhandled property: " << rGrabBagElement.first);
- }
-
- // Output the table alignment
- const char* pJcVal;
- sal_Int32 nIndent = 0;
- switch ( pTableFormat->GetHoriOrient( ).GetHoriOrient( ) )
- {
- case text::HoriOrientation::CENTER:
- pJcVal = "center";
- break;
- case text::HoriOrientation::RIGHT:
- if ( bEcma )
- pJcVal = "right";
- else
- pJcVal = "end";
- break;
- default:
- case text::HoriOrientation::NONE:
- case text::HoriOrientation::LEFT_AND_WIDTH:
- {
- if ( bEcma )
- pJcVal = "left";
- else
- pJcVal = "start";
- nIndent = sal_Int32( pTableFormat->GetLRSpace().GetLeft() );
-
- // Table indentation has different meaning in Word, depending if the table is nested or not.
- // If nested, tblInd is added to parent table's left spacing and defines left edge position
- // If not nested, text position of left-most cell must be at absolute X = tblInd
- // so, table_spacing + table_spacing_to_content = tblInd
-
- // tdf#106742: since MS Word 2013 (compatibilityMode >= 15), top-level tables are handled the same as nested tables;
- // if no compatibilityMode is defined (which now should only happen on a new export to .docx),
- // LO uses a higher compatibility than 2010's 14.
- sal_Int32 nMode = lcl_getWordCompatibilityMode( m_rExport.m_rDoc );
-
- const SwFrameFormat* pFrameFormat = pTableTextNodeInfoInner->getTableBox()->GetFrameFormat();
- if ((0 < nMode && nMode <= 14) && m_tableReference->m_nTableDepth == 0)
- nIndent += pFrameFormat->GetBox().GetDistance( SvxBoxItemLine::LEFT );
- else
- {
- // adjust for SW considering table to start mid-border instead of nested/2013's left-side-of-border.
- nIndent -= pFrameFormat->GetBox().CalcLineWidth( SvxBoxItemLine::LEFT ) / 2;
- }
-
- break;
- }
- }
- m_pSerializer->singleElementNS(XML_w, XML_jc, FSNS(XML_w, XML_val), pJcVal);
-
- // Output the table background color (although cell value still needs to be specified)
- const SvxBrushItem *pColorProp = pTableFormat->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
- Color aColor = pColorProp ? pColorProp->GetColor() : COL_AUTO;
- if ( aColor != COL_AUTO )
- {
- OString sColor = msfilter::util::ConvertColor( aColor );
- m_pSerializer->singleElementNS( XML_w, XML_shd,
- FSNS( XML_w, XML_fill ), sColor,
- FSNS( XML_w, XML_val ), "clear" );
- }
-
- // Output the table borders
- TableDefaultBorders( pTableTextNodeInfoInner );
-
- // Output the default cell margins
- TableDefaultCellMargins( pTableTextNodeInfoInner );
-
- TableBidi( pTableTextNodeInfoInner );
-
- // Table indent (need to get written even if == 0)
- m_pSerializer->singleElementNS( XML_w, XML_tblInd,
- FSNS( XML_w, XML_w ), OString::number(nIndent),
- FSNS( XML_w, XML_type ), "dxa" );
-
- // Merge the marks for the ordered elements
- m_pSerializer->mergeTopMarks(Tag_TableDefinition);
-
- m_pSerializer->endElementNS( XML_w, XML_tblPr );
-
- // Write the table grid infos
- m_pSerializer->startElementNS(XML_w, XML_tblGrid);
- sal_Int32 nPrv = 0;
- ww8::WidthsPtr pColumnWidths = GetColumnWidths( pTableTextNodeInfoInner );
- for ( auto aColumnWidth : *pColumnWidths )
- {
- sal_Int32 nWidth = sal_Int32( aColumnWidth ) - nPrv;
- m_pSerializer->singleElementNS( XML_w, XML_gridCol,
- FSNS( XML_w, XML_w ), OString::number(nWidth) );
- nPrv = sal_Int32( aColumnWidth );
- }
-
- m_pSerializer->endElementNS( XML_w, XML_tblGrid );
-}
-
-void DocxAttributeOutput::TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
-{
- // Table defaults should only be created IF m_aTableStyleConf contents haven't come from a table style.
- // Previously this function wrote out Cell A1 as the table default, causing problems with no benefit.
-}
-
-void DocxAttributeOutput::TableDefaultCellMargins( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner )
-{
- const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
- const SwFrameFormat * pFrameFormat = pTabBox->GetFrameFormat();
- const SvxBoxItem& rBox = pFrameFormat->GetBox( );
- const bool bEcma = GetExport().GetFilter().getVersion( ) == oox::core::ECMA_DIALECT;
-
- impl_cellMargins(m_pSerializer, rBox, XML_tblCellMar, !bEcma);
-}
-
-void DocxAttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
-{
- const SwTable *pTable = pTableTextNodeInfoInner->getTable();
- const SwTableBox *pTableBox = pTableTextNodeInfoInner->getTableBox( );
- const SwTableLine *pTableRow = pTableBox->GetUpper();
- const SwFrameFormat *pFormat = pTableBox->GetFrameFormat( );
-
- const SvxBrushItem *pColorProp = pFormat->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
- Color aColor = pColorProp ? pColorProp->GetColor() : COL_AUTO;
-
- const SwFrameFormat *pRowFormat = pTableRow->GetFrameFormat( );
- const SvxBrushItem *pRowColorProp = pRowFormat->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
- if ( pRowColorProp && aColor == COL_AUTO)
- aColor = pRowColorProp->GetColor();
-
- const SwFrameFormat *pTableFormat = pTable->GetFrameFormat( );
- const SvxBrushItem *pTableColorProp = pTableFormat->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
- if ( pTableColorProp && aColor == COL_AUTO )
- aColor = pTableColorProp->GetColor();
-
- const OString sColor = msfilter::util::ConvertColor( aColor );
-
- std::map<OUString, css::uno::Any> aGrabBag =
- pFormat->GetAttrSet().GetItem<SfxGrabBagItem>(RES_FRMATR_GRABBAG)->GetGrabBag();
-
- OString sOriginalColor;
- std::map<OUString, css::uno::Any>::iterator aGrabBagElement = aGrabBag.find("originalColor");
- if( aGrabBagElement != aGrabBag.end() )
- sOriginalColor = OUStringToOString( aGrabBagElement->second.get<OUString>(), RTL_TEXTENCODING_UTF8 );
-
- if ( sOriginalColor != sColor )
- {
- // color changed by the user, or no grab bag: write sColor
- if ( sColor != "auto" )
- {
- m_pSerializer->singleElementNS( XML_w, XML_shd,
- FSNS( XML_w, XML_fill ), sColor,
- FSNS( XML_w, XML_val ), "clear" );
- }
- }
- else
- {
- rtl::Reference<sax_fastparser::FastAttributeList> pAttrList;
-
- for( const auto & rGrabBagElement : aGrabBag )
- {
- if (!rGrabBagElement.second.has<OUString>())
- continue;
-
- OString sValue = OUStringToOString( rGrabBagElement.second.get<OUString>(), RTL_TEXTENCODING_UTF8 );
- if( rGrabBagElement.first == "themeFill")
- AddToAttrList( pAttrList, FSNS( XML_w, XML_themeFill ), sValue.getStr() );
- else if( rGrabBagElement.first == "themeFillTint")
- AddToAttrList( pAttrList, FSNS( XML_w, XML_themeFillTint ), sValue.getStr() );
- else if( rGrabBagElement.first == "themeFillShade")
- AddToAttrList( pAttrList, FSNS( XML_w, XML_themeFillShade ), sValue.getStr() );
- else if( rGrabBagElement.first == "fill" )
- AddToAttrList( pAttrList, FSNS( XML_w, XML_fill ), sValue.getStr() );
- else if( rGrabBagElement.first == "themeColor")
- AddToAttrList( pAttrList, FSNS( XML_w, XML_themeColor ), sValue.getStr() );
- else if( rGrabBagElement.first == "themeTint")
- AddToAttrList( pAttrList, FSNS( XML_w, XML_themeTint ), sValue.getStr() );
- else if( rGrabBagElement.first == "themeShade")
- AddToAttrList( pAttrList, FSNS( XML_w, XML_themeShade ), sValue.getStr() );
- else if( rGrabBagElement.first == "color")
- AddToAttrList( pAttrList, FSNS( XML_w, XML_color ), sValue.getStr() );
- else if( rGrabBagElement.first == "val")
- AddToAttrList( pAttrList, FSNS( XML_w, XML_val ), sValue.getStr() );
- }
- m_pSerializer->singleElementNS( XML_w, XML_shd, pAttrList.get() );
- }
-}
-
-void DocxAttributeOutput::TableRowRedline( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
-{
- const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
- const SwTableLine * pTabLine = pTabBox->GetUpper();
-
- // search next Redline
- const SwExtraRedlineTable& aExtraRedlineTable = m_rExport.m_rDoc.getIDocumentRedlineAccess().GetExtraRedlineTable();
- for(sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < aExtraRedlineTable.GetSize(); ++nCurRedlinePos )
- {
- SwExtraRedline* pExtraRedline = aExtraRedlineTable.GetRedline(nCurRedlinePos);
- const SwTableRowRedline* pTableRowRedline = dynamic_cast<const SwTableRowRedline*>(pExtraRedline);
- if (pTableRowRedline && &pTableRowRedline->GetTableLine() == pTabLine)
- {
- // Redline for this table row
- const SwRedlineData& aRedlineData = pTableRowRedline->GetRedlineData();
- RedlineType nRedlineType = aRedlineData.GetType();
- switch (nRedlineType)
- {
- case RedlineType::TableRowInsert:
- case RedlineType::TableRowDelete:
- {
- OString aId( OString::number( m_nRedlineId++ ) );
- const OUString &rAuthor( SW_MOD()->GetRedlineAuthor( aRedlineData.GetAuthor() ) );
- OString aAuthor( OUStringToOString( rAuthor, RTL_TEXTENCODING_UTF8 ) );
-
- OString aDate( DateTimeToOString( aRedlineData.GetTimeStamp() ) );
-
- if (nRedlineType == RedlineType::TableRowInsert)
- m_pSerializer->singleElementNS( XML_w, XML_ins,
- FSNS( XML_w, XML_id ), aId,
- FSNS( XML_w, XML_author ), aAuthor,
- FSNS( XML_w, XML_date ), aDate );
- else if (nRedlineType == RedlineType::TableRowDelete)
- m_pSerializer->singleElementNS( XML_w, XML_del,
- FSNS( XML_w, XML_id ), aId,
- FSNS( XML_w, XML_author ), aAuthor,
- FSNS( XML_w, XML_date ), aDate );
- }
- break;
- default: break;
- }
- }
- }
-}
-
-void DocxAttributeOutput::TableCellRedline( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
-{
- const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
-
- // search next Redline
- const SwExtraRedlineTable& aExtraRedlineTable = m_rExport.m_rDoc.getIDocumentRedlineAccess().GetExtraRedlineTable();
- for(sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < aExtraRedlineTable.GetSize(); ++nCurRedlinePos )
- {
- SwExtraRedline* pExtraRedline = aExtraRedlineTable.GetRedline(nCurRedlinePos);
- const SwTableCellRedline* pTableCellRedline = dynamic_cast<const SwTableCellRedline*>(pExtraRedline);
- if (pTableCellRedline && &pTableCellRedline->GetTableBox() == pTabBox)
- {
- // Redline for this table cell
- const SwRedlineData& aRedlineData = pTableCellRedline->GetRedlineData();
- RedlineType nRedlineType = aRedlineData.GetType();
- switch (nRedlineType)
- {
- case RedlineType::TableCellInsert:
- case RedlineType::TableCellDelete:
- {
- OString aId( OString::number( m_nRedlineId++ ) );
- const OUString &rAuthor( SW_MOD()->GetRedlineAuthor( aRedlineData.GetAuthor() ) );
- OString aAuthor( OUStringToOString( rAuthor, RTL_TEXTENCODING_UTF8 ) );
-
- OString aDate( DateTimeToOString( aRedlineData.GetTimeStamp() ) );
-
- if (nRedlineType == RedlineType::TableCellInsert)
- m_pSerializer->singleElementNS( XML_w, XML_cellIns,
- FSNS( XML_w, XML_id ), aId,
- FSNS( XML_w, XML_author ), aAuthor,
- FSNS( XML_w, XML_date ), aDate );
- else if (nRedlineType == RedlineType::TableCellDelete)
- m_pSerializer->singleElementNS( XML_w, XML_cellDel,
- FSNS( XML_w, XML_id ), aId,
- FSNS( XML_w, XML_author ), aAuthor,
- FSNS( XML_w, XML_date ), aDate );
- }
- break;
- default: break;
- }
- }
- }
-}
-
-void DocxAttributeOutput::TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
-{
- const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
- const SwTableLine * pTabLine = pTabBox->GetUpper();
- const SwFrameFormat * pLineFormat = pTabLine->GetFrameFormat();
-
- const SwFormatFrameSize& rLSz = pLineFormat->GetFrameSize();
- if ( !(SwFrameSize::Variable != rLSz.GetHeightSizeType() && rLSz.GetHeight()) )
- return;
-
- sal_Int32 nHeight = rLSz.GetHeight();
- const char *pRule = nullptr;
-
- switch ( rLSz.GetHeightSizeType() )
- {
- case SwFrameSize::Fixed: pRule = "exact"; break;
- case SwFrameSize::Minimum: pRule = "atLeast"; break;
- default: break;
- }
-
- if ( pRule )
- m_pSerializer->singleElementNS( XML_w, XML_trHeight,
- FSNS( XML_w, XML_val ), OString::number(nHeight),
- FSNS( XML_w, XML_hRule ), pRule );
-}
-
-void DocxAttributeOutput::TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
-{
- const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
- const SwTableLine * pTabLine = pTabBox->GetUpper();
- const SwFrameFormat * pLineFormat = pTabLine->GetFrameFormat();
-
- const SwFormatRowSplit& rSplittable = pLineFormat->GetRowSplit( );
- // if rSplittable is true then no need to write <w:cantSplit w:val="false"/>
- // as default row prop is allow row to break across page.
- if( !rSplittable.GetValue( ) )
- m_pSerializer->singleElementNS(XML_w, XML_cantSplit, FSNS(XML_w, XML_val), "true");
-}
-
-void DocxAttributeOutput::TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
-{
- const SwTable * pTable = pTableTextNodeInfoInner->getTable();
- const SwFrameFormat * pFrameFormat = pTable->GetFrameFormat();
-
- if ( m_rExport.TrueFrameDirection( *pFrameFormat ) == SvxFrameDirection::Horizontal_RL_TB )
- {
- m_pSerializer->singleElementNS(XML_w, XML_bidiVisual, FSNS(XML_w, XML_val), "true");
- }
-}
-
-void DocxAttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
-{
- const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
- const SwFrameFormat *pFrameFormat = pTabBox->GetFrameFormat( );
-
- if ( SvxFrameDirection::Vertical_RL_TB == m_rExport.TrueFrameDirection( *pFrameFormat ) )
- m_pSerializer->singleElementNS(XML_w, XML_textDirection, FSNS(XML_w, XML_val), "tbRl");
- else if ( SvxFrameDirection::Vertical_LR_BT == m_rExport.TrueFrameDirection( *pFrameFormat ) )
- {
- m_pSerializer->singleElementNS(XML_w, XML_textDirection, FSNS(XML_w, XML_val), "btLr");
- }
-
- const SwWriteTableRows& rRows = m_xTableWrt->GetRows( );
- SwWriteTableRow *pRow = rRows[ pTableTextNodeInfoInner->getRow( ) ].get();
- sal_uInt32 nCell = pTableTextNodeInfoInner->getCell();
- const SwWriteTableCells& rTableCells = pRow->GetCells();
- if (nCell >= rTableCells.size() )
- return;
-
- const SwWriteTableCell *const pCell = pRow->GetCells()[ nCell ].get();
- switch( pCell->GetVertOri())
- {
- case text::VertOrientation::TOP:
- break;
- case text::VertOrientation::CENTER:
- m_pSerializer->singleElementNS(XML_w, XML_vAlign, FSNS(XML_w, XML_val), "center");
- break;
- case text::VertOrientation::BOTTOM:
- m_pSerializer->singleElementNS(XML_w, XML_vAlign, FSNS(XML_w, XML_val), "bottom");
- break;
- }
-}
-
-void DocxAttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner )
-{
- // This is called when the nested table ends in a cell, and there's no
- // paragraph behind that; so we must check for the ends of cell, rows,
- // tables
- // ['true' to write an empty paragraph, MS Word insists on that]
- FinishTableRowCell( pNodeInfoInner, true );
-}
-
-void DocxAttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
-{
- SAL_INFO("sw.ww8", "TODO: DocxAttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )" );
-}
-
-void DocxAttributeOutput::TableSpacing( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
-{
- SAL_INFO("sw.ww8", "TODO: DocxAttributeOutput::TableSpacing( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )" );
-}
-
-void DocxAttributeOutput::TableRowEnd( sal_uInt32 /*nDepth*/ )
-{
- SAL_INFO("sw.ww8", "TODO: DocxAttributeOutput::TableRowEnd( sal_uInt32 nDepth = 1 )" );
+ m_tableReference.m_bTableCellOpen = false;
+ m_tableReference.m_bTableCellParaSdtOpen = false;
+ m_tableReference.m_bTableCellChanged = false;
}
void DocxAttributeOutput::StartStyles()
@@ -4595,9 +4843,9 @@ void DocxAttributeOutput::LatentStyles()
uno::Sequence<beans::PropertyValue> aInteropGrabBag;
xPropertySet->getPropertyValue("InteropGrabBag") >>= aInteropGrabBag;
uno::Sequence<beans::PropertyValue> aLatentStyles;
- auto pProp = std::find_if(aInteropGrabBag.begin(), aInteropGrabBag.end(),
+ auto pProp = std::find_if(std::cbegin(aInteropGrabBag), std::cend(aInteropGrabBag),
[](const beans::PropertyValue& rProp) { return rProp.Name == "latentStyles"; });
- if (pProp != aInteropGrabBag.end())
+ if (pProp != std::cend(aInteropGrabBag))
pProp->Value >>= aLatentStyles;
if (!aLatentStyles.hasElements())
return;
@@ -4605,30 +4853,28 @@ void DocxAttributeOutput::LatentStyles()
// Extract default attributes first.
rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList = FastSerializerHelper::createAttrList();
uno::Sequence<beans::PropertyValue> aLsdExceptions;
- for (const auto& rLatentStyle : std::as_const(aLatentStyles))
+ for (const auto& rLatentStyle : aLatentStyles)
{
if (sal_Int32 nToken = DocxStringGetToken(aDefaultTokens, rLatentStyle.Name))
- pAttributeList->add(FSNS(XML_w, nToken), OUStringToOString(rLatentStyle.Value.get<OUString>(), RTL_TEXTENCODING_UTF8));
+ pAttributeList->add(FSNS(XML_w, nToken), rLatentStyle.Value.get<OUString>());
else if (rLatentStyle.Name == "lsdExceptions")
rLatentStyle.Value >>= aLsdExceptions;
}
- m_pSerializer->startElementNS(XML_w, XML_latentStyles, pAttributeList);
- pAttributeList = nullptr;
+ m_pSerializer->startElementNS(XML_w, XML_latentStyles, detachFrom(pAttributeList));
// Then handle the exceptions.
- for (const auto& rLsdException : std::as_const(aLsdExceptions))
+ for (const auto& rLsdException : aLsdExceptions)
{
pAttributeList = FastSerializerHelper::createAttrList();
uno::Sequence<beans::PropertyValue> aAttributes;
rLsdException.Value >>= aAttributes;
- for (const auto& rAttribute : std::as_const(aAttributes))
+ for (const auto& rAttribute : aAttributes)
if (sal_Int32 nToken = DocxStringGetToken(aExceptionTokens, rAttribute.Name))
- pAttributeList->add(FSNS(XML_w, nToken), OUStringToOString(rAttribute.Value.get<OUString>(), RTL_TEXTENCODING_UTF8));
+ pAttributeList->add(FSNS(XML_w, nToken), rAttribute.Value.get<OUString>());
- m_pSerializer->singleElementNS(XML_w, XML_lsdException, pAttributeList);
- pAttributeList = nullptr;
+ m_pSerializer->singleElementNS(XML_w, XML_lsdException, detachFrom(pAttributeList));
}
m_pSerializer->endElementNS(XML_w, XML_latentStyles);
@@ -4689,7 +4935,6 @@ void DocxAttributeOutput::OutputDefaultItem(const SfxPoolItem& rHt)
const SvxBrushItem& rBrushItem = static_cast< const SvxBrushItem& >(rHt);
bMustWrite = (rBrushItem.GetColor() != COL_AUTO ||
rBrushItem.GetShadingValue() != ShadingPattern::CLEAR ||
- rBrushItem.GetGraphic() != nullptr ||
rBrushItem.GetGraphicObject() != nullptr);
}
break;
@@ -4757,7 +5002,6 @@ void DocxAttributeOutput::OutputDefaultItem(const SfxPoolItem& rHt)
const SvxBrushItem& rBrushItem = static_cast< const SvxBrushItem& >(rHt);
bMustWrite = (rBrushItem.GetColor() != COL_AUTO ||
rBrushItem.GetShadingValue() != ShadingPattern::CLEAR ||
- rBrushItem.GetGraphic() != nullptr ||
rBrushItem.GetGraphicObject() != nullptr);
}
break;
@@ -4888,17 +5132,16 @@ void DocxAttributeOutput::WriteSrcRect(
sal_Int32 nCropB = aGraphicCropStruct.Bottom;
// simulate border padding as a negative crop.
- const SfxPoolItem* pItem;
- if (pFrameFormat && SfxItemState::SET == pFrameFormat->GetItemState(RES_BOX, false, &pItem))
+ const SvxBoxItem* pBoxItem;
+ if (pFrameFormat && (pBoxItem = pFrameFormat->GetItemIfSet(RES_BOX, false)))
{
- const SvxBoxItem& rBox = *static_cast<const SvxBoxItem*>(pItem);
- nCropL -= rBox.GetDistance( SvxBoxItemLine::LEFT );
- nCropR -= rBox.GetDistance( SvxBoxItemLine::RIGHT );
- nCropT -= rBox.GetDistance( SvxBoxItemLine::TOP );
- nCropB -= rBox.GetDistance( SvxBoxItemLine::BOTTOM );
+ nCropL -= pBoxItem->GetDistance( SvxBoxItemLine::LEFT );
+ nCropR -= pBoxItem->GetDistance( SvxBoxItemLine::RIGHT );
+ nCropT -= pBoxItem->GetDistance( SvxBoxItemLine::TOP );
+ nCropB -= pBoxItem->GetDistance( SvxBoxItemLine::BOTTOM );
}
- if ( !((0 != nCropL) || (0 != nCropT) || (0 != nCropR) || (0 != nCropB)) )
+ if (nCropL == 0 && nCropT == 0 && nCropR == 0 && nCropB == 0)
return;
double widthMultiplier = 100000.0/aOriginalSize.Width();
@@ -4916,65 +5159,34 @@ void DocxAttributeOutput::WriteSrcRect(
XML_b, OString::number(bottom) );
}
-void DocxAttributeOutput::PushRelIdCache()
-{
- m_aRelIdCache.emplace();
- m_aSdrRelIdCache.emplace();
-}
-
-OUString DocxAttributeOutput::FindRelId(BitmapChecksum nChecksum)
-{
- OUString aRet;
-
- if (!m_aSdrRelIdCache.empty() && m_aSdrRelIdCache.top().find(nChecksum) != m_aSdrRelIdCache.top().end())
- aRet = m_aSdrRelIdCache.top()[nChecksum].first;
-
- return aRet;
-}
-
-OUString DocxAttributeOutput::FindFileName(BitmapChecksum nChecksum)
-{
- OUString aRet;
-
- if (!m_aSdrRelIdCache.empty() && m_aSdrRelIdCache.top().find(nChecksum) != m_aSdrRelIdCache.top().end())
- aRet = m_aSdrRelIdCache.top()[nChecksum].second;
-
- return aRet;
-}
-
-void DocxAttributeOutput::CacheRelId(BitmapChecksum nChecksum, const OUString& rRelId, const OUString& rFileName)
-{
- if (!m_aSdrRelIdCache.empty())
- m_aSdrRelIdCache.top()[nChecksum] = std::pair(rRelId, rFileName);
-}
-
uno::Reference<css::text::XTextFrame> DocxAttributeOutput::GetUnoTextFrame(
css::uno::Reference<css::drawing::XShape> xShape)
{
return SwTextBoxHelper::getUnoTextFrame(xShape);
}
-std::pair<OString, OUString> DocxAttributeOutput::getExistingGraphicRelId(BitmapChecksum nChecksum)
+static rtl::Reference<::sax_fastparser::FastAttributeList> CreateDocPrAttrList(
+ DocxExport & rExport, int const nAnchorId, std::u16string_view const& rName,
+ std::u16string_view const& rTitle, std::u16string_view const& rDescription)
{
- std::pair<OString, OUString> aResult;
-
- if (m_aRelIdCache.empty())
- return aResult;
-
- auto pIterator = m_aRelIdCache.top().find(nChecksum);
-
- if (pIterator != m_aRelIdCache.top().end())
+ rtl::Reference<::sax_fastparser::FastAttributeList> const pAttrs(FastSerializerHelper::createAttrList());
+ pAttrs->add(XML_id, OString::number(nAnchorId));
+ pAttrs->add(XML_name, rName);
+ if (rExport.GetFilter().getVersion() != oox::core::ECMA_376_1ST_EDITION)
{
- aResult = pIterator->second;
+ pAttrs->add(XML_descr, rDescription);
+ pAttrs->add(XML_title, rTitle);
}
-
- return aResult;
-}
-
-void DocxAttributeOutput::cacheGraphicRelId(BitmapChecksum nChecksum, OString const & rRelId, OUString const & rFileName)
-{
- if (!m_aRelIdCache.empty())
- m_aRelIdCache.top().emplace(nChecksum, std::pair(rRelId, rFileName));
+ else
+ { // tdf#148952 no title attribute, merge it into descr
+ OUString const value(rTitle.empty()
+ ? OUString(rDescription)
+ : rDescription.empty()
+ ? OUString(rTitle)
+ : OUString::Concat(rTitle) + "\n" + rDescription);
+ pAttrs->add(XML_descr, value);
+ }
+ return pAttrs;
}
void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size& rSize, const SwFlyFrameFormat* pOLEFrameFormat, SwOLENode* pOLENode, const SdrObject* pSdrObj )
@@ -4988,6 +5200,7 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
const SwFrameFormat* pFrameFormat = pGrfNode ? pGrfNode->GetFlyFormat() : pOLEFrameFormat;
// create the relation ID
OString aRelId;
+ OUString sSvgRelId;
sal_Int32 nImageType;
if ( pGrfNode && pGrfNode->IsLinkedFile() )
{
@@ -5022,41 +5235,22 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
else
aGraphic = *pOLENode->GetGraphic();
- BitmapChecksum aChecksum = aGraphic.GetChecksum();
- OUString aFileName;
- std::tie(aRelId, aFileName) = getExistingGraphicRelId(aChecksum);
- OUString aImageId;
-
- if (aRelId.isEmpty())
- {
- // Not in cache, then need to write it.
- m_rDrawingML.SetFS( m_pSerializer ); // to be sure that we write to the right stream
-
- aImageId = m_rDrawingML.WriteImage(aGraphic, false, &aFileName);
+ m_rDrawingML.SetFS(m_pSerializer); // to be sure that we write to the right stream
+ auto pGraphicExport = m_rDrawingML.createGraphicExport();
+ OUString aImageId = pGraphicExport->writeToStorage(aGraphic, false);
+ aRelId = OUStringToOString(aImageId, RTL_TEXTENCODING_UTF8);
- aRelId = OUStringToOString( aImageId, RTL_TEXTENCODING_UTF8 );
- cacheGraphicRelId(aChecksum, aRelId, aFileName);
- }
- else
+ if (aGraphic.getVectorGraphicData() && aGraphic.getVectorGraphicData()->getType() == VectorGraphicDataType::Svg)
{
- // Include the same relation again. This makes it possible to
- // reuse an image across different headers.
- aImageId = m_rDrawingML.GetFB()->addRelation( m_pSerializer->getOutputStream(),
- oox::getRelationship(Relationship::IMAGE),
- aFileName );
-
- aRelId = OUStringToOString( aImageId, RTL_TEXTENCODING_UTF8 );
+ sSvgRelId = pGraphicExport->writeToStorage(aGraphic, false, drawingml::GraphicExport::TypeHint::SVG);
}
-
nImageType = XML_embed;
}
// In case there are any grab-bag items on the graphic frame, emit them now.
// These are always character grab-bags, as graphics are at-char or as-char in Word.
- const SfxPoolItem* pItem = nullptr;
- if (pFrameFormat->GetAttrSet().HasItem(RES_FRMATR_GRABBAG, &pItem))
+ if (const SfxGrabBagItem* pGrabBag = pFrameFormat->GetAttrSet().GetItemIfSet(RES_FRMATR_GRABBAG))
{
- const SfxGrabBagItem* pGrabBag = static_cast<const SfxGrabBagItem*>(pItem);
CharGrabBag(*pGrabBag);
}
@@ -5073,7 +5267,7 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
if (Degree10 nRot = rSet.Get(RES_GRFATR_ROTATION).GetValue())
{
// RES_GRFATR_ROTATION is in 10ths of degree; convert to 100ths for macro
- sal_uInt32 mOOXMLRot = oox::drawingml::ExportRotateClockwisify(toDegree100(nRot));
+ sal_uInt32 mOOXMLRot = oox::drawingml::ExportRotateClockwisify(to<Degree100>(nRot));
xFrameAttributes->add(XML_rot, OString::number(mOOXMLRot));
}
}
@@ -5093,18 +5287,16 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
if (xShapePropSet)
{
if (css::awt::Size val; xShapePropSet->getPropertyValue("Size") >>= val)
- aSize = Size(convertMm100ToTwip(val.Width), convertMm100ToTwip(val.Height));
+ aSize = Size(o3tl::toTwips(val.Width, o3tl::Length::mm100), o3tl::toTwips(val.Height, o3tl::Length::mm100));
}
m_rExport.SdrExporter().startDMLAnchorInline(pFrameFormat, aSize);
// picture description (used for pic:cNvPr later too)
- rtl::Reference<::sax_fastparser::FastAttributeList> docPrattrList = FastSerializerHelper::createAttrList();
- docPrattrList->add( XML_id, OString::number( m_anchorId++).getStr());
- docPrattrList->add( XML_name, OUStringToOString( pFrameFormat->GetName(), RTL_TEXTENCODING_UTF8 ) );
- docPrattrList->add( XML_descr, OUStringToOString( pGrfNode ? pGrfNode->GetDescription() : pOLEFrameFormat->GetObjDescription(), RTL_TEXTENCODING_UTF8 ));
- if( GetExport().GetFilter().getVersion( ) != oox::core::ECMA_DIALECT )
- docPrattrList->add( XML_title, OUStringToOString( pGrfNode ? pGrfNode->GetTitle() : pOLEFrameFormat->GetObjTitle(), RTL_TEXTENCODING_UTF8 ));
+ OUString const descr(pGrfNode ? pGrfNode->GetDescription() : pOLEFrameFormat->GetObjDescription());
+ OUString const title(pGrfNode ? pGrfNode->GetTitle() : pOLEFrameFormat->GetObjTitle());
+ auto const docPrattrList(CreateDocPrAttrList(
+ GetExport(), m_anchorId++, pFrameFormat->GetName(), title, descr));
m_pSerializer->startElementNS( XML_wp, XML_docPr, docPrattrList );
OUString sURL, sRelId;
@@ -5126,6 +5318,7 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main",
FSNS( XML_r, XML_id ), sRelId);
}
+ AddExtLst(m_pSerializer, GetExport(), xShapePropSet);
}
m_pSerializer->endElementNS( XML_wp, XML_docPr );
@@ -5175,11 +5368,10 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
else
m_pSerializer->startElementNS(XML_a, XML_blip, FSNS(XML_r, nImageType), aRelId);
- pItem = nullptr;
-
- if ( pGrfNode && SfxItemState::SET == pGrfNode->GetSwAttrSet().GetItemState(RES_GRFATR_DRAWMODE, true, &pItem))
+ const SfxEnumItemInterface* pGrafModeItem = nullptr;
+ if ( pGrfNode && (pGrafModeItem = pGrfNode->GetSwAttrSet().GetItemIfSet(RES_GRFATR_DRAWMODE)))
{
- GraphicDrawMode nMode = static_cast<GraphicDrawMode>(static_cast<const SfxEnumItemInterface*>(pItem)->GetEnumValue());
+ GraphicDrawMode nMode = static_cast<GraphicDrawMode>(pGrafModeItem->GetEnumValue());
if (nMode == GraphicDrawMode::Greys)
m_pSerializer->singleElementNS (XML_a, XML_grayscl);
else if (nMode == GraphicDrawMode::Mono) //black/white has a 0,5 threshold in LibreOffice
@@ -5187,6 +5379,13 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
else if (nMode == GraphicDrawMode::Watermark) //watermark has a brightness/luminance of 0,5 and contrast of -0.7 in LibreOffice
m_pSerializer->singleElementNS( XML_a, XML_lum, XML_bright, OString::number(70000), XML_contrast, OString::number(-70000) );
}
+
+ if (!sSvgRelId.isEmpty())
+ {
+ auto pGraphicExport = m_rDrawingML.createGraphicExport();
+ pGraphicExport->writeSvgExtension(sSvgRelId);
+ }
+
m_pSerializer->endElementNS( XML_a, XML_blip );
if (xShapePropSet)
@@ -5293,14 +5492,19 @@ void DocxAttributeOutput::WritePostponedChart()
if( xNamed.is() )
sName = xNamed->getName();
+ // tdf#153203 export a11y related properties
+ uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
+ OUString const title(xShapeProps->getPropertyValue("Title").get<OUString>());
+ OUString const descr(xShapeProps->getPropertyValue("Description").get<OUString>());
+
/* If there is a scenario where a chart is followed by a shape
which is being exported as an alternate content then, the
docPr Id is being repeated, ECMA 20.4.2.5 says that the
docPr Id should be unique, ensuring the same here.
*/
- m_pSerializer->singleElementNS( XML_wp, XML_docPr,
- XML_id, OString::number(m_anchorId++),
- XML_name, sName );
+ auto const docPrattrList(CreateDocPrAttrList(
+ GetExport(), m_anchorId++, sName, title, descr));
+ m_pSerializer->singleElementNS(XML_wp, XML_docPr, docPrattrList);
m_pSerializer->singleElementNS(XML_wp, XML_cNvGraphicFramePr);
@@ -5370,14 +5574,11 @@ void DocxAttributeOutput::WritePostponedMath(const SwOLENode* pPostponedMath, sa
SAL_WARN("sw.ww8", "Broken math object");
return;
}
-// gcc4.4 (and 4.3 and possibly older) have a problem with dynamic_cast directly to the target class,
-// so help it with an intermediate cast. I'm not sure what exactly the problem is, seems to be unrelated
-// to RTLD_GLOBAL, so most probably a gcc bug.
- oox::FormulaExportBase* formulaexport = dynamic_cast<oox::FormulaExportBase*>(dynamic_cast<SfxBaseModel*>(xInterface.get()));
- assert( formulaexport != nullptr );
- if (formulaexport)
+ if( oox::FormulaImExportBase* formulaexport = dynamic_cast< oox::FormulaImExportBase* >( xInterface.get()))
formulaexport->writeFormulaOoxml( m_pSerializer, GetExport().GetFilter().getVersion(),
oox::drawingml::DOCUMENT_DOCX, nAlign);
+ else
+ OSL_FAIL( "Math OLE object cannot write out OOXML" );
}
void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject)
@@ -5410,7 +5611,7 @@ void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject)
bHasDate = true;
Date aDate(aUNODate.Day, aUNODate.Month, aUNODate.Year);
sDate = DateToOString(aDate);
- aContentText = OUString::createFromAscii(DateToDDMMYYYYOString(aDate).getStr());
+ aContentText = OUString::createFromAscii(DateToDDMMYYYYOString(aDate));
sDateFormat = "dd/MM/yyyy";
}
else
@@ -5525,7 +5726,7 @@ void DocxAttributeOutput::WriteActiveXControl(const SdrObject* pObject, const Sw
// VML shape definition
m_rExport.VMLExporter().SetSkipwzName(true);
m_rExport.VMLExporter().SetHashMarkForType(true);
- m_rExport.VMLExporter().OverrideShapeIDGen(true, "control_shape_");
+ m_rExport.VMLExporter().OverrideShapeIDGen(true, "control_shape_"_ostr);
OString sShapeId;
if(bAnchoredInline)
{
@@ -5598,11 +5799,11 @@ bool DocxAttributeOutput::ExportAsActiveXControl(const SdrObject* pObject) const
void DocxAttributeOutput::PostponeOLE( SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat )
{
- if( !m_pPostponedOLEs )
+ if( !m_oPostponedOLEs )
//cannot be postponed, try to write now
WriteOLE( rNode, rSize, pFlyFrameFormat );
else
- m_pPostponedOLEs->push_back( PostponedOLE( &rNode, rSize, pFlyFrameFormat ) );
+ m_oPostponedOLEs->push_back( PostponedOLE( &rNode, rSize, pFlyFrameFormat ) );
}
/*
@@ -5610,16 +5811,16 @@ void DocxAttributeOutput::PostponeOLE( SwOLENode& rNode, const Size& rSize, cons
*/
void DocxAttributeOutput::WritePostponedOLE()
{
- if( !m_pPostponedOLEs )
+ if( !m_oPostponedOLEs )
return;
- for( const auto & rPostponedOLE : *m_pPostponedOLEs )
+ for( const auto & rPostponedOLE : *m_oPostponedOLEs )
{
WriteOLE( *rPostponedOLE.object, rPostponedOLE.size, rPostponedOLE.frame );
}
// clear list of postponed objects
- m_pPostponedOLEs.reset();
+ m_oPostponedOLEs.reset();
}
void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat )
@@ -5630,9 +5831,9 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
uno::Reference< beans::XPropertySet > xPropSet( m_rExport.m_rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
uno::Sequence< beans::PropertyValue > aGrabBag, aObjectsInteropList,aObjectInteropAttributes;
xPropSet->getPropertyValue( UNO_NAME_MISC_OBJ_INTEROPGRABBAG ) >>= aGrabBag;
- auto pProp = std::find_if(aGrabBag.begin(), aGrabBag.end(),
+ auto pProp = std::find_if(std::cbegin(aGrabBag), std::cend(aGrabBag),
[](const beans::PropertyValue& rProp) { return rProp.Name == "EmbeddedObjects"; });
- if (pProp != aGrabBag.end())
+ if (pProp != std::cend(aGrabBag))
pProp->Value >>= aObjectsInteropList;
SwOLEObj& aObject = rNode.GetOLEObj();
@@ -5651,12 +5852,12 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
default:
SAL_WARN("sw.ww8", "DocxAttributeOutput::WriteOLE: invalid aspect value");
}
- auto pObjectsInterop = std::find_if(aObjectsInteropList.begin(), aObjectsInteropList.end(),
+ auto pObjectsInterop = std::find_if(std::cbegin(aObjectsInteropList), std::cend(aObjectsInteropList),
[&sObjectName](const beans::PropertyValue& rProp) { return rProp.Name == sObjectName; });
- if (pObjectsInterop != aObjectsInteropList.end())
+ if (pObjectsInterop != std::cend(aObjectsInteropList))
pObjectsInterop->Value >>= aObjectInteropAttributes;
- for( const auto& rObjectInteropAttribute : std::as_const(aObjectInteropAttributes) )
+ for (const auto& rObjectInteropAttribute : aObjectInteropAttributes)
{
if ( rObjectInteropAttribute.Name == "ProgID" )
{
@@ -5678,7 +5879,7 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
// write preview image
const Graphic* pGraphic = rNode.GetGraphic();
m_rDrawingML.SetFS(m_pSerializer);
- OUString sImageId = m_rDrawingML.WriteImage( *pGraphic );
+ OUString sImageId = m_rDrawingML.writeGraphicToStorage(*pGraphic);
if ( sDrawAspect == "Content" )
{
@@ -5713,7 +5914,7 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
m_pSerializer->singleElementNS(XML_o, XML_OLEObject,
XML_Type, "Embed",
XML_ProgID, sProgID,
- XML_ShapeID, sShapeId.getStr(),
+ XML_ShapeID, sShapeId,
XML_DrawAspect, sDrawAspect,
XML_ObjectID, "_" + OString::number(comphelper::rng::uniform_int_distribution(0, std::numeric_limits<int>::max())),
FSNS( XML_r, XML_id ), sId );
@@ -5722,7 +5923,7 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
}
void DocxAttributeOutput::WriteOLEShape(const SwFlyFrameFormat& rFrameFormat, const Size& rSize,
- const OString& rShapeId, const OUString& rImageId)
+ std::string_view rShapeId, const OUString& rImageId)
{
assert(m_pSerializer);
@@ -5732,7 +5933,7 @@ void DocxAttributeOutput::WriteOLEShape(const SwFlyFrameFormat& rFrameFormat, co
//export the fixed shape type for picture frame
m_pSerializer->write(vml::VMLExport::GetVMLShapeTypeDefinition(rShapeId, true));
- pAttr->add(XML_type, "_x0000_t" + rShapeId);
+ pAttr->add(XML_type, OString::Concat("_x0000_t") + rShapeId);
//Export the style attribute for position and size
pAttr->add(XML_style, GetOLEStyle(rFrameFormat, rSize));
@@ -5753,68 +5954,68 @@ void DocxAttributeOutput::WriteOLEShape(const SwFlyFrameFormat& rFrameFormat, co
switch (rBox.GetLeft()->GetBorderLineStyle())
{
case SvxBorderLineStyle::SOLID:
- sLineType = OString("Single");
- sDashType = OString("Solid");
+ sLineType = "Single"_ostr;
+ sDashType = "Solid"_ostr;
break;
case SvxBorderLineStyle::DASHED:
- sLineType = OString("Single");
- sDashType = OString("Dash");
+ sLineType = "Single"_ostr;
+ sDashType = "Dash"_ostr;
break;
case SvxBorderLineStyle::DASH_DOT:
- sLineType = OString("Single");
- sDashType = OString("DashDot");
+ sLineType = "Single"_ostr;
+ sDashType = "DashDot"_ostr;
break;
case SvxBorderLineStyle::DASH_DOT_DOT:
- sLineType = OString("Single");
- sDashType = OString("ShortDashDotDot");
+ sLineType = "Single"_ostr;
+ sDashType = "ShortDashDotDot"_ostr;
break;
case SvxBorderLineStyle::DOTTED:
- sLineType = OString("Single");
- sDashType = OString("Dot");
+ sLineType = "Single"_ostr;
+ sDashType = "Dot"_ostr;
break;
case SvxBorderLineStyle::DOUBLE:
- sLineType = OString("ThinThin");
- sDashType = OString("Solid");
+ sLineType = "ThinThin"_ostr;
+ sDashType = "Solid"_ostr;
break;
case SvxBorderLineStyle::DOUBLE_THIN:
- sLineType = OString("ThinThin");
- sDashType = OString("Solid");
+ sLineType = "ThinThin"_ostr;
+ sDashType = "Solid"_ostr;
break;
case SvxBorderLineStyle::EMBOSSED:
- sLineType = OString("Single");
- sDashType = OString("Solid");
+ sLineType = "Single"_ostr;
+ sDashType = "Solid"_ostr;
break;
case SvxBorderLineStyle::ENGRAVED:
- sLineType = OString("Single");
- sDashType = OString("Solid");
+ sLineType = "Single"_ostr;
+ sDashType = "Solid"_ostr;
break;
case SvxBorderLineStyle::FINE_DASHED:
- sLineType = OString("Single");
- sDashType = OString("Dot");
+ sLineType = "Single"_ostr;
+ sDashType = "Dot"_ostr;
break;
case SvxBorderLineStyle::INSET:
- sLineType = OString("Single");
- sDashType = OString("Solid");
+ sLineType = "Single"_ostr;
+ sDashType = "Solid"_ostr;
break;
case SvxBorderLineStyle::OUTSET:
- sLineType = OString("Single");
- sDashType = OString("Solid");
+ sLineType = "Single"_ostr;
+ sDashType = "Solid"_ostr;
break;
case SvxBorderLineStyle::THICKTHIN_LARGEGAP:
case SvxBorderLineStyle::THICKTHIN_MEDIUMGAP:
case SvxBorderLineStyle::THICKTHIN_SMALLGAP:
- sLineType = OString("ThickThin");
- sDashType = OString("Solid");
+ sLineType = "ThickThin"_ostr;
+ sDashType = "Solid"_ostr;
break;
case SvxBorderLineStyle::THINTHICK_LARGEGAP:
case SvxBorderLineStyle::THINTHICK_MEDIUMGAP:
case SvxBorderLineStyle::THINTHICK_SMALLGAP:
- sLineType = OString("ThinThick");
- sDashType = OString("Solid");
+ sLineType = "ThinThick"_ostr;
+ sDashType = "Solid"_ostr;
break;
case SvxBorderLineStyle::NONE:
- sLineType = OString("");
- sDashType = OString("");
+ sLineType = ""_ostr;
+ sDashType = ""_ostr;
break;
default:
SAL_WARN("sw.ww8", "Unknown line type on OOXML ELE export!");
@@ -5897,7 +6098,7 @@ OString DocxAttributeOutput::GetOLEStyle(const SwFlyFrameFormat& rFormat, const
//Get the relative horizontal positions for the anchors
OString aHAnch
= bIsPageAnchor
- ? OString("page")
+ ? "page"_ostr
: convertToOOXMLHoriOrientRel(rFormat.GetHoriOrient().GetRelationOrient());
//Get the relative vertical positions for the anchors
OString aVAnch = convertToOOXMLVertOrientRel(rFormat.GetVertOrient().GetRelationOrient());
@@ -5953,22 +6154,22 @@ void DocxAttributeOutput::ExportOLESurround(const SwFormatSurround& rWrap)
switch (rWrap.GetSurround())
{
case text::WrapTextMode::WrapTextMode_NONE:
- sSurround = OString("topAndBottom");
+ sSurround = "topAndBottom"_ostr;
break;
case text::WrapTextMode::WrapTextMode_PARALLEL:
- sSurround = bIsContour ? OString("tight") : OString("square");
+ sSurround = bIsContour ? "tight"_ostr : "square"_ostr;
break;
case text::WrapTextMode::WrapTextMode_DYNAMIC:
- sSide = OString("largest");
- sSurround = bIsContour ? OString("tight") : OString("square");
+ sSide = "largest"_ostr;
+ sSurround = bIsContour ? "tight"_ostr : "square"_ostr;
break;
case text::WrapTextMode::WrapTextMode_LEFT:
- sSide = OString("left");
- sSurround = bIsContour ? OString("tight") : OString("square");
+ sSide = "left"_ostr;
+ sSurround = bIsContour ? "tight"_ostr : "square"_ostr;
break;
case text::WrapTextMode::WrapTextMode_RIGHT:
- sSide = OString("right");
- sSurround = bIsContour ? OString("tight") : OString("square");
+ sSide = "right"_ostr;
+ sSurround = bIsContour ? "tight"_ostr : "square"_ostr;
break;
default:
SAL_WARN("sw.ww8", "Unknown surround type on OOXML export!");
@@ -5987,41 +6188,47 @@ void DocxAttributeOutput::ExportOLESurround(const SwFormatSurround& rWrap)
void DocxAttributeOutput::WritePostponedCustomShape()
{
- if (!m_pPostponedCustomShape)
+ if (!m_oPostponedCustomShape)
return;
- for( const auto & rPostponedDrawing : *m_pPostponedCustomShape)
+ for( const auto & rPostponedDrawing : *m_oPostponedCustomShape)
{
+ m_rExport.GetFilter().SetMaxDocId(m_anchorId + 1);
if ( IsAlternateContentChoiceOpen() )
m_rExport.SdrExporter().writeDMLDrawing(rPostponedDrawing.object, rPostponedDrawing.frame, m_anchorId++);
else
m_rExport.SdrExporter().writeDMLAndVMLDrawing(rPostponedDrawing.object, *rPostponedDrawing.frame, m_anchorId++);
+ m_anchorId = m_rExport.GetFilter().GetMaxDocId();
}
- m_pPostponedCustomShape.reset();
+ m_oPostponedCustomShape.reset();
}
void DocxAttributeOutput::WritePostponedDMLDrawing()
{
- if (!m_pPostponedDMLDrawings)
+ if (!m_oPostponedDMLDrawings)
return;
// Clear the list early, this method may be called recursively.
- std::unique_ptr< std::vector<PostponedDrawing> > pPostponedDMLDrawings(std::move(m_pPostponedDMLDrawings));
- std::unique_ptr< std::vector<PostponedOLE> > pPostponedOLEs(std::move(m_pPostponedOLEs));
+ std::optional< std::vector<PostponedDrawing> > pPostponedDMLDrawings(std::move(m_oPostponedDMLDrawings));
+ std::optional< std::vector<PostponedOLE> > pPostponedOLEs(std::move(m_oPostponedOLEs));
+ m_oPostponedDMLDrawings.reset();
+ m_oPostponedOLEs.reset();
for( const auto & rPostponedDrawing : *pPostponedDMLDrawings )
{
// Avoid w:drawing within another w:drawing.
+ m_rExport.GetFilter().SetMaxDocId(m_anchorId + 1);
if ( IsAlternateContentChoiceOpen() && !( m_rExport.SdrExporter().IsDrawingOpen()) )
m_rExport.SdrExporter().writeDMLDrawing(rPostponedDrawing.object, rPostponedDrawing.frame, m_anchorId++);
else
m_rExport.SdrExporter().writeDMLAndVMLDrawing(rPostponedDrawing.object, *rPostponedDrawing.frame, m_anchorId++);
+ m_anchorId = m_rExport.GetFilter().GetMaxDocId();
}
- m_pPostponedOLEs = std::move(pPostponedOLEs);
+ m_oPostponedOLEs = std::move(pPostponedOLEs);
}
-void DocxAttributeOutput::OutputFlyFrame_Impl( const ww8::Frame &rFrame, const Point& /*rNdTopLeft*/ )
+void DocxAttributeOutput::WriteFlyFrame(const ww8::Frame& rFrame)
{
m_pSerializer->mark(Tag_OutputFlyFrame);
@@ -6034,7 +6241,7 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const ww8::Frame &rFrame, const P
const SwGrfNode *pGrfNode = pNode ? pNode->GetGrfNode() : nullptr;
if ( pGrfNode )
{
- if (!m_pPostponedGraphic)
+ if (!m_oPostponedGraphic)
{
m_bPostponedProcessingFly = false ;
FlyFrameGraphic( pGrfNode, rFrame.GetLayoutSize(), nullptr, nullptr, pSdrObj);
@@ -6042,7 +6249,7 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const ww8::Frame &rFrame, const P
else // we are writing out attributes, but w:drawing should not be inside w:rPr,
{ // so write it out later
m_bPostponedProcessingFly = true ;
- m_pPostponedGraphic->push_back(PostponedGraphic(pGrfNode, rFrame.GetLayoutSize(), pSdrObj));
+ m_oPostponedGraphic->push_back(PostponedGraphic(pGrfNode, rFrame.GetLayoutSize(), pSdrObj));
}
}
}
@@ -6052,12 +6259,11 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const ww8::Frame &rFrame, const P
const SdrObject* pSdrObj = rFrame.GetFrameFormat().FindRealSdrObject();
if ( pSdrObj )
{
- uno::Reference<drawing::XShape> xShape(
- const_cast<SdrObject*>(pSdrObj)->getUnoShape(), uno::UNO_QUERY);
+ const bool bIsDiagram(nullptr != pSdrObj && pSdrObj->isDiagram());
- if (xShape.is() && oox::drawingml::DrawingML::IsDiagram(xShape))
+ if (bIsDiagram)
{
- if ( !m_pPostponedDiagrams )
+ if ( !m_oPostponedDiagrams )
{
m_bPostponedProcessingFly = false ;
m_rExport.SdrExporter().writeDiagram( pSdrObj, rFrame.GetFrameFormat(), m_anchorId++);
@@ -6065,35 +6271,37 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const ww8::Frame &rFrame, const P
else // we are writing out attributes, but w:drawing should not be inside w:rPr,
{ // so write it out later
m_bPostponedProcessingFly = true ;
- m_pPostponedDiagrams->push_back( PostponedDiagram( pSdrObj, &(rFrame.GetFrameFormat()) ));
+ m_oPostponedDiagrams->push_back( PostponedDiagram( pSdrObj, &(rFrame.GetFrameFormat()) ));
}
}
else
{
- if (!m_pPostponedDMLDrawings)
+ if (!m_oPostponedDMLDrawings)
{
+ m_rExport.GetFilter().SetMaxDocId(m_anchorId + 1);
if ( IsAlternateContentChoiceOpen() )
{
// Do not write w:drawing inside w:drawing. Instead Postpone the Inner Drawing.
if( m_rExport.SdrExporter().IsDrawingOpen() )
- m_pPostponedCustomShape->push_back(PostponedDrawing(pSdrObj, &(rFrame.GetFrameFormat())));
+ m_oPostponedCustomShape->push_back(PostponedDrawing(pSdrObj, &(rFrame.GetFrameFormat())));
else
m_rExport.SdrExporter().writeDMLDrawing( pSdrObj, &rFrame.GetFrameFormat(), m_anchorId++);
}
else
m_rExport.SdrExporter().writeDMLAndVMLDrawing( pSdrObj, rFrame.GetFrameFormat(), m_anchorId++);
+ m_anchorId = m_rExport.GetFilter().GetMaxDocId();
m_bPostponedProcessingFly = false ;
}
// IsAlternateContentChoiceOpen(): check is to ensure that only one object is getting added. Without this check, plus one object gets added
// m_bParagraphFrameOpen: check if the frame is open.
else if (IsAlternateContentChoiceOpen() && m_bParagraphFrameOpen)
- m_pPostponedCustomShape->push_back(PostponedDrawing(pSdrObj, &(rFrame.GetFrameFormat())));
+ m_oPostponedCustomShape->push_back(PostponedDrawing(pSdrObj, &(rFrame.GetFrameFormat())));
else
{
// we are writing out attributes, but w:drawing should not be inside w:rPr, so write it out later
m_bPostponedProcessingFly = true ;
- m_pPostponedDMLDrawings->push_back(PostponedDrawing(pSdrObj, &(rFrame.GetFrameFormat())));
+ m_oPostponedDMLDrawings->push_back(PostponedDrawing(pSdrObj, &(rFrame.GetFrameFormat())));
}
}
}
@@ -6142,29 +6350,29 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const ww8::Frame &rFrame, const P
SwOLENode& rOLENd = *aIdx.GetNode().GetOLENode();
//output variable for the formula alignment (default inline)
- sal_Int8 nAlign(FormulaExportBase::eFormulaAlign::INLINE);
+ sal_Int8 nAlign(FormulaImExportBase::eFormulaAlign::INLINE);
auto xObj(rOLENd.GetOLEObj().GetOleRef()); //get the xObject of the formula
//tdf133030: Export formula position
//If we have a formula with inline anchor...
if(SotExchange::IsMath(xObj->getClassID()) && rFrame.IsInline())
{
- SwPosition const* const aAPos = rFrameFormat.GetAnchor().GetContentAnchor();
- if(aAPos)
+ SwNode const* const pAnchorNode = rFrameFormat.GetAnchor().GetAnchorNode();
+ if(pAnchorNode)
{
//Get the text node what the formula anchored to
- const SwTextNode* pTextNode = aAPos->nNode.GetNode().GetTextNode();
+ const SwTextNode* pTextNode = pAnchorNode->GetTextNode();
if(pTextNode && pTextNode->Len() == 1)
{
//Get the paragraph alignment
auto aParaAdjust = pTextNode->GetSwAttrSet().GetAdjust().GetAdjust();
//And set the formula according to the paragraph alignment
if (aParaAdjust == SvxAdjust::Center)
- nAlign = FormulaExportBase::eFormulaAlign::CENTER;
+ nAlign = FormulaImExportBase::eFormulaAlign::CENTER;
else if (aParaAdjust == SvxAdjust::Right)
- nAlign = FormulaExportBase::eFormulaAlign::RIGHT;
+ nAlign = FormulaImExportBase::eFormulaAlign::RIGHT;
else // left in the case of left and justified paragraph alignments
- nAlign = FormulaExportBase::eFormulaAlign::LEFT;
+ nAlign = FormulaImExportBase::eFormulaAlign::LEFT;
}
}
}
@@ -6193,6 +6401,71 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const ww8::Frame &rFrame, const P
m_pSerializer->mergeTopMarks(Tag_OutputFlyFrame);
}
+void DocxAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Point& /*rNdTopLeft*/)
+{
+ /// The old OutputFlyFrame_Impl() moved to WriteFlyFrame().
+ /// Now if a frame anchored inside another frame, it will
+ /// not be exported immediately, because OOXML does not
+ /// support that feature, instead it postponed and exported
+ /// later when the original shape closed.
+
+ if (rFrame.GetFrameFormat().GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR
+ || rFrame.IsInline())
+ {
+ m_nEmbedFlyLevel++;
+ WriteFlyFrame(rFrame);
+ m_nEmbedFlyLevel--;
+ return;
+ }
+
+ if (m_nEmbedFlyLevel == 0)
+ {
+ if (m_vPostponedFlys.empty())
+ {
+ m_nEmbedFlyLevel++;
+ WriteFlyFrame(rFrame);
+ m_nEmbedFlyLevel--;
+ }
+ else
+ for (auto it = m_vPostponedFlys.begin(); it != m_vPostponedFlys.end();)
+ {
+ m_nEmbedFlyLevel++;
+ WriteFlyFrame(*it);
+ it = m_vPostponedFlys.erase(it);
+ m_nEmbedFlyLevel--;
+ }
+ }
+ else
+ {
+ bool bFound = false;
+ for (const auto& i : m_vPostponedFlys)
+ {
+ if (i.RefersToSameFrameAs(rFrame))
+ {
+ bFound = true;
+ break;
+ }
+ }
+ if (!bFound)
+ {
+ if (auto pParentFly = rFrame.GetContentNode()->GetFlyFormat())
+ {
+ auto aHori(rFrame.GetFrameFormat().GetHoriOrient());
+ aHori.SetPos(aHori.GetPos() + pParentFly->GetHoriOrient().GetPos());
+ auto aVori(rFrame.GetFrameFormat().GetVertOrient());
+ aVori.SetPos(aVori.GetPos() + pParentFly->GetVertOrient().GetPos());
+
+ const_cast<SwFrameFormat&>(rFrame.GetFrameFormat()).SetFormatAttr(aHori);
+ const_cast<SwFrameFormat&>(rFrame.GetFrameFormat()).SetFormatAttr(aVori);
+ const_cast<SwFrameFormat&>(rFrame.GetFrameFormat()).SetFormatAttr(pParentFly->GetAnchor());
+
+ m_vPostponedFlys.push_back(rFrame);
+ }
+
+ }
+ }
+}
+
void DocxAttributeOutput::WriteOutliner(const OutlinerParaObject& rParaObj)
{
const EditTextObject& rEditObj = rParaObj.GetTextObject();
@@ -6258,22 +6531,29 @@ void DocxAttributeOutput::pushToTableExportContext(DocxTableExportContext& rCont
rContext.m_pTableInfo = m_rExport.m_pTableInfo;
m_rExport.m_pTableInfo = std::make_shared<ww8::WW8TableInfo>();
- rContext.m_bTableCellOpen = m_tableReference->m_bTableCellOpen;
- m_tableReference->m_bTableCellOpen = false;
+ rContext.m_bTableCellOpen = m_tableReference.m_bTableCellOpen;
+ m_tableReference.m_bTableCellOpen = false;
- rContext.m_nTableDepth = m_tableReference->m_nTableDepth;
- m_tableReference->m_nTableDepth = 0;
+ rContext.m_nTableDepth = m_tableReference.m_nTableDepth;
+ m_tableReference.m_nTableDepth = 0;
- rContext.m_bStartedParaSdt = m_bStartedParaSdt;
- m_bStartedParaSdt = false;
+ rContext.m_bStartedParaSdt = m_aParagraphSdt.m_bStartedSdt;
+ m_aParagraphSdt.m_bStartedSdt = false;
+ rContext.m_bStartedRunSdt = m_aRunSdt.m_bStartedSdt;
+ m_aRunSdt.m_bStartedSdt = false;
+
+ rContext.m_nHyperLinkCount = m_nHyperLinkCount.back();
+ m_nHyperLinkCount.back() = 0;
}
void DocxAttributeOutput::popFromTableExportContext(DocxTableExportContext const & rContext)
{
m_rExport.m_pTableInfo = rContext.m_pTableInfo;
- m_tableReference->m_bTableCellOpen = rContext.m_bTableCellOpen;
- m_tableReference->m_nTableDepth = rContext.m_nTableDepth;
- m_bStartedParaSdt = rContext.m_bStartedParaSdt;
+ m_tableReference.m_bTableCellOpen = rContext.m_bTableCellOpen;
+ m_tableReference.m_nTableDepth = rContext.m_nTableDepth;
+ m_aParagraphSdt.m_bStartedSdt = rContext.m_bStartedParaSdt;
+ m_aRunSdt.m_bStartedSdt = rContext.m_bStartedRunSdt;
+ m_nHyperLinkCount.back() = rContext.m_nHyperLinkCount;
}
void DocxAttributeOutput::WriteTextBox(uno::Reference<drawing::XShape> xShape)
@@ -6283,7 +6563,8 @@ void DocxAttributeOutput::WriteTextBox(uno::Reference<drawing::XShape> xShape)
SwFrameFormat* pTextBox = SwTextBoxHelper::getOtherTextBoxFormat(xShape);
assert(pTextBox);
const SwPosition* pAnchor = nullptr;
- if (pTextBox->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE) //tdf135711
+ const bool bFlyAtPage = pTextBox->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE;
+ if (bFlyAtPage) //tdf135711
{
auto pNdIdx = pTextBox->GetContent().GetContentIdx();
if (pNdIdx) //Is that possible it is null?
@@ -6298,7 +6579,7 @@ void DocxAttributeOutput::WriteTextBox(uno::Reference<drawing::XShape> xShape)
{
ww8::Frame aFrame(*pTextBox, *pAnchor);
m_rExport.SdrExporter().writeDMLTextFrame(&aFrame, m_anchorId++, /*bTextBoxOnly=*/true);
- if (pTextBox->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE)
+ if (bFlyAtPage)
{
delete pAnchor;
}
@@ -6366,9 +6647,9 @@ namespace {
/// Functor to do case-insensitive ordering of OUString instances.
struct OUStringIgnoreCase
{
- bool operator() (const OUString& lhs, std::u16string_view rhs) const
+ bool operator() (std::u16string_view lhs, std::u16string_view rhs) const
{
- return lhs.compareToIgnoreAsciiCase(rhs) < 0;
+ return o3tl::compareToIgnoreAsciiCase(lhs, rhs) < 0;
}
};
@@ -6395,7 +6676,7 @@ static bool lcl_guessQFormat(const OUString& rName, sal_uInt16 nWwId)
"List Paragraph",
"Quote",
"Intense Quote",
- "Subtle Emphasis,",
+ "Subtle Emphasis",
"Intense Emphasis",
"Subtle Reference",
"Intense Reference",
@@ -6407,20 +6688,20 @@ static bool lcl_guessQFormat(const OUString& rName, sal_uInt16 nWwId)
}
void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
- sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 nWwId, sal_uInt16 nId, bool bAutoUpdate )
+ sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 nLink, sal_uInt16 nWwId, sal_uInt16 nSlot, bool bAutoUpdate )
{
bool bQFormat = false, bUnhideWhenUsed = false, bSemiHidden = false, bLocked = false, bDefault = false, bCustomStyle = false;
- OUString aLink, aRsid, aUiPriority;
+ OUString aRsid, aUiPriority;
rtl::Reference<FastAttributeList> pStyleAttributeList = FastSerializerHelper::createAttrList();
uno::Any aAny;
if (eType == STYLE_TYPE_PARA || eType == STYLE_TYPE_CHAR)
{
- const SwFormat* pFormat = m_rExport.m_pStyles->GetSwFormat(nId);
+ const SwFormat* pFormat = m_rExport.m_pStyles->GetSwFormat(nSlot);
pFormat->GetGrabBagItem(aAny);
}
else
{
- const SwNumRule* pRule = m_rExport.m_pStyles->GetSwNumRule(nId);
+ const SwNumRule* pRule = m_rExport.m_pStyles->GetSwNumRule(nSlot);
pRule->GetGrabBagItem(aAny);
}
const uno::Sequence<beans::PropertyValue>& rGrabBag = aAny.get< uno::Sequence<beans::PropertyValue> >();
@@ -6431,8 +6712,6 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
aUiPriority = rProp.Value.get<OUString>();
else if (rProp.Name == "qFormat")
bQFormat = true;
- else if (rProp.Name == "link")
- aLink = rProp.Value.get<OUString>();
else if (rProp.Name == "rsid")
aRsid = rProp.Value.get<OUString>();
else if (rProp.Name == "unhideWhenUsed")
@@ -6449,28 +6728,25 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
SAL_WARN("sw.ww8", "Unhandled style property: " << rProp.Name);
}
- // MSO exports English names and writerfilter only recognize them.
- const char *pEnglishName = nullptr;
const char* pType = nullptr;
switch (eType)
{
case STYLE_TYPE_PARA:
pType = "paragraph";
- if ( nWwId < ww::stiMax)
- pEnglishName = ww::GetEnglishNameFromSti( static_cast<ww::sti>(nWwId ) );
break;
- case STYLE_TYPE_CHAR: pType = "character"; break;
+ case STYLE_TYPE_CHAR:
+ pType = "character";
+ break;
case STYLE_TYPE_LIST: pType = "numbering"; break;
}
pStyleAttributeList->add(FSNS( XML_w, XML_type ), pType);
- pStyleAttributeList->add(FSNS(XML_w, XML_styleId), m_rExport.m_pStyles->GetStyleId(nId));
+ pStyleAttributeList->add(FSNS(XML_w, XML_styleId), m_rExport.m_pStyles->GetStyleId(nSlot));
if (bDefault)
pStyleAttributeList->add(FSNS(XML_w, XML_default), "1");
if (bCustomStyle)
pStyleAttributeList->add(FSNS(XML_w, XML_customStyle), "1");
m_pSerializer->startElementNS( XML_w, XML_style, pStyleAttributeList);
- m_pSerializer->singleElementNS( XML_w, XML_name,
- FSNS( XML_w, XML_val ), pEnglishName ? pEnglishName : rName.toUtf8() );
+ m_pSerializer->singleElementNS(XML_w, XML_name, FSNS(XML_w, XML_val), rName);
if ( nBase != 0x0FFF && eType != STYLE_TYPE_LIST)
{
@@ -6478,14 +6754,17 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
FSNS( XML_w, XML_val ), m_rExport.m_pStyles->GetStyleId(nBase) );
}
- if ( nNext != nId && eType != STYLE_TYPE_LIST)
+ if ( nNext != nSlot && eType != STYLE_TYPE_LIST)
{
m_pSerializer->singleElementNS( XML_w, XML_next,
FSNS( XML_w, XML_val ), m_rExport.m_pStyles->GetStyleId(nNext) );
}
- if (!aLink.isEmpty())
- m_pSerializer->singleElementNS(XML_w, XML_link, FSNS(XML_w, XML_val), aLink);
+ if (nLink != 0x0FFF && (eType == STYLE_TYPE_PARA || eType == STYLE_TYPE_CHAR))
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_link, FSNS(XML_w, XML_val),
+ m_rExport.m_pStyles->GetStyleId(nLink));
+ }
if ( bAutoUpdate )
m_pSerializer->singleElementNS(XML_w, XML_autoRedefine);
@@ -6585,7 +6864,7 @@ void DocxAttributeOutput::SectionBreak( sal_uInt8 nC, bool bBreakAfter, const WW
// Detect when the current node is the last node in the
// document: the last section is written explicitly in
// DocxExport::WriteMainText(), don't duplicate that here.
- SwNodeIndex aCurrentNode(m_rExport.m_pCurPam->GetNode());
+ SwNodeIndex aCurrentNode(m_rExport.m_pCurPam->GetPointNode());
SwNodeIndex aLastNode(m_rExport.m_rDoc.GetNodes().GetEndOfContent(), -1);
bool bEmit = aCurrentNode != aLastNode;
@@ -6664,11 +6943,10 @@ void DocxAttributeOutput::SectionBreak( sal_uInt8 nC, bool bBreakAfter, const WW
void DocxAttributeOutput::EndParaSdtBlock()
{
- if (m_bStartedParaSdt)
+ if (m_aParagraphSdt.m_bStartedSdt)
{
// Paragraph-level SDT still open? Close it now.
- EndSdtBlock();
- m_bStartedParaSdt = false;
+ m_aParagraphSdt.EndSdtBlock(m_pSerializer);
}
}
@@ -6706,6 +6984,7 @@ void DocxAttributeOutput::StartSection()
// postpone the output so that we can later [in EndParagraphProperties()]
// prepend the properties before the run
+ // coverity[overrun-buffer-arg : FALSE] - coverity has difficulty with css::uno::Sequence
m_pSerializer->mark(Tag_StartSection, comphelper::containerToSequence(aOrder));
m_bHadSectPr = true;
}
@@ -6715,8 +6994,7 @@ void DocxAttributeOutput::EndSection()
// Write the section properties
if ( m_pSectionSpacingAttrList.is() )
{
- rtl::Reference<FastAttributeList> xAttrList = std::move( m_pSectionSpacingAttrList );
- m_pSerializer->singleElementNS( XML_w, XML_pgMar, xAttrList );
+ m_pSerializer->singleElementNS( XML_w, XML_pgMar, detachFrom( m_pSectionSpacingAttrList ) );
}
// Order the elements
@@ -6744,16 +7022,50 @@ void DocxAttributeOutput::SectionRtlGutter(const SfxBoolItem& rRtlGutter)
m_pSerializer->singleElementNS(XML_w, XML_rtlGutter);
}
+void DocxAttributeOutput::TextLineBreak(const SwFormatLineBreak& rLineBreak)
+{
+ m_oLineBreakClear = rLineBreak.GetValue();
+}
+
+void DocxAttributeOutput::WriteLineBreak()
+{
+ if (!m_oLineBreakClear.has_value())
+ {
+ return;
+ }
+
+ rtl::Reference<FastAttributeList> pAttr = FastSerializerHelper::createAttrList();
+ pAttr->add(FSNS(XML_w, XML_type), "textWrapping");
+ switch (*m_oLineBreakClear)
+ {
+ case SwLineBreakClear::NONE:
+ pAttr->add(FSNS(XML_w, XML_clear), "none");
+ break;
+ case SwLineBreakClear::LEFT:
+ pAttr->add(FSNS(XML_w, XML_clear), "left");
+ break;
+ case SwLineBreakClear::RIGHT:
+ pAttr->add(FSNS(XML_w, XML_clear), "right");
+ break;
+ case SwLineBreakClear::ALL:
+ pAttr->add(FSNS(XML_w, XML_clear), "all");
+ break;
+ }
+ m_oLineBreakClear.reset();
+
+ m_pSerializer->singleElementNS(XML_w, XML_br, pAttr);
+}
+
void DocxAttributeOutput::SectionLineNumbering( sal_uLong nRestartNo, const SwLineNumberInfo& rLnNumInfo )
{
rtl::Reference<FastAttributeList> pAttr = FastSerializerHelper::createAttrList();
- pAttr->add( FSNS( XML_w, XML_countBy ), OString::number(rLnNumInfo.GetCountBy()).getStr());
+ pAttr->add( FSNS( XML_w, XML_countBy ), OString::number(rLnNumInfo.GetCountBy()));
pAttr->add( FSNS( XML_w, XML_restart ), rLnNumInfo.IsRestartEachPage() ? "newPage" : "continuous" );
if( rLnNumInfo.GetPosFromLeft())
- pAttr->add( FSNS( XML_w, XML_distance ), OString::number(rLnNumInfo.GetPosFromLeft()).getStr());
+ pAttr->add( FSNS( XML_w, XML_distance ), OString::number(rLnNumInfo.GetPosFromLeft()));
if (nRestartNo > 0)
// Writer is 1-based, Word is 0-based.
- pAttr->add(FSNS(XML_w, XML_start), OString::number(nRestartNo - 1).getStr());
+ pAttr->add(FSNS(XML_w, XML_start), OString::number(nRestartNo - 1));
m_pSerializer->singleElementNS( XML_w, XML_lnNumType, pAttr );
}
@@ -6790,10 +7102,10 @@ void DocxAttributeOutput::SectionPageBorders( const SwFrameFormat* pFormat, cons
editeng::WordPageMargins aMargins = m_pageMargins;
HdFtDistanceGlue aGlue(pFormat->GetAttrSet());
if (aGlue.HasHeader())
- aMargins.nTop = aGlue.dyaHdrTop;
+ aMargins.nTop = aGlue.m_DyaHdrTop;
// Ditto for bottom margin.
if (aGlue.HasFooter())
- aMargins.nBottom = aGlue.dyaHdrBottom;
+ aMargins.nBottom = aGlue.m_DyaHdrBottom;
if (pFormat->GetDoc()->getIDocumentSettingAccess().get(DocumentSettingId::GUTTER_AT_TOP))
{
@@ -6826,78 +7138,81 @@ void DocxAttributeOutput::SectionBiDi( bool bBiDi )
}
// Converting Numbering Format Code to string
-static OString lcl_ConvertNumberingType(sal_Int16 nNumberingType, const SfxItemSet* pOutSet, OString& rFormat, const OString& sDefault = "" )
+static OString lcl_ConvertNumberingType(sal_Int16 nNumberingType, const SfxItemSet* pOutSet, OString& rFormat, const OString& sDefault = ""_ostr )
{
OString aType = sDefault;
switch ( nNumberingType )
{
case SVX_NUM_CHARS_UPPER_LETTER:
- case SVX_NUM_CHARS_UPPER_LETTER_N: aType = "upperLetter"; break;
+ case SVX_NUM_CHARS_UPPER_LETTER_N: aType = "upperLetter"_ostr; break;
case SVX_NUM_CHARS_LOWER_LETTER:
- case SVX_NUM_CHARS_LOWER_LETTER_N: aType = "lowerLetter"; break;
+ case SVX_NUM_CHARS_LOWER_LETTER_N: aType = "lowerLetter"_ostr; break;
- case SVX_NUM_ROMAN_UPPER: aType = "upperRoman"; break;
- case SVX_NUM_ROMAN_LOWER: aType = "lowerRoman"; break;
- case SVX_NUM_ARABIC: aType = "decimal"; break;
+ case SVX_NUM_ROMAN_UPPER: aType = "upperRoman"_ostr; break;
+ case SVX_NUM_ROMAN_LOWER: aType = "lowerRoman"_ostr; break;
+ case SVX_NUM_ARABIC: aType = "decimal"_ostr; break;
case SVX_NUM_BITMAP:
- case SVX_NUM_CHAR_SPECIAL: aType = "bullet"; break;
-
- case style::NumberingType::CHARS_HEBREW: aType = "hebrew2"; break;
- case style::NumberingType::NUMBER_HEBREW: aType = "hebrew1"; break;
- case style::NumberingType::NUMBER_NONE: aType = "none"; break;
- case style::NumberingType::FULLWIDTH_ARABIC: aType="decimalFullWidth"; break;
- case style::NumberingType::TIAN_GAN_ZH: aType="ideographTraditional"; break;
- case style::NumberingType::DI_ZI_ZH: aType="ideographZodiac"; break;
+ case SVX_NUM_CHAR_SPECIAL: aType = "bullet"_ostr; break;
+
+ case style::NumberingType::CHARS_HEBREW: aType = "hebrew2"_ostr; break;
+ case style::NumberingType::NUMBER_HEBREW: aType = "hebrew1"_ostr; break;
+ case style::NumberingType::NUMBER_NONE: aType = "none"_ostr; break;
+ case style::NumberingType::FULLWIDTH_ARABIC: aType="decimalFullWidth"_ostr; break;
+ case style::NumberingType::TIAN_GAN_ZH: aType="ideographTraditional"_ostr; break;
+ case style::NumberingType::DI_ZI_ZH: aType="ideographZodiac"_ostr; break;
case style::NumberingType::NUMBER_LOWER_ZH:
- aType="taiwaneseCountingThousand";
+ aType="taiwaneseCountingThousand"_ostr;
if (pOutSet) {
const SvxLanguageItem& rLang = pOutSet->Get( RES_CHRATR_CJK_LANGUAGE);
const LanguageType eLang = rLang.GetLanguage();
if (LANGUAGE_CHINESE_SIMPLIFIED == eLang) {
- aType="chineseCountingThousand";
+ aType="chineseCountingThousand"_ostr;
}
}
break;
- case style::NumberingType::NUMBER_UPPER_ZH_TW: aType="ideographLegalTraditional";break;
- case style::NumberingType::NUMBER_UPPER_ZH: aType="chineseLegalSimplified"; break;
- case style::NumberingType::NUMBER_TRADITIONAL_JA: aType="japaneseLegal";break;
- case style::NumberingType::AIU_FULLWIDTH_JA: aType="aiueoFullWidth";break;
- case style::NumberingType::AIU_HALFWIDTH_JA: aType="aiueo";break;
- case style::NumberingType::IROHA_FULLWIDTH_JA: aType="iroha";break;
- case style::NumberingType::IROHA_HALFWIDTH_JA: aType="irohaFullWidth";break;
- case style::NumberingType::HANGUL_SYLLABLE_KO: aType="ganada";break;
- case style::NumberingType::HANGUL_JAMO_KO: aType="chosung";break;
- case style::NumberingType::NUMBER_HANGUL_KO: aType="koreanDigital";break;
- case style::NumberingType::NUMBER_UPPER_KO: aType="koreanLegal"; break;
- case style::NumberingType::CIRCLE_NUMBER: aType="decimalEnclosedCircle"; break;
- case style::NumberingType::CHARS_ARABIC: aType="arabicAlpha"; break;
- case style::NumberingType::CHARS_ARABIC_ABJAD: aType="arabicAbjad"; break;
- case style::NumberingType::CHARS_THAI: aType="thaiLetters"; break;
- case style::NumberingType::CHARS_PERSIAN: aType="hindiVowels"; break;
+ case style::NumberingType::NUMBER_UPPER_ZH_TW: aType="ideographLegalTraditional"_ostr;break;
+ case style::NumberingType::NUMBER_UPPER_ZH: aType="chineseLegalSimplified"_ostr; break;
+ case style::NumberingType::NUMBER_TRADITIONAL_JA: aType="japaneseLegal"_ostr;break;
+ case style::NumberingType::AIU_FULLWIDTH_JA: aType="aiueoFullWidth"_ostr;break;
+ case style::NumberingType::AIU_HALFWIDTH_JA: aType="aiueo"_ostr;break;
+ case style::NumberingType::IROHA_FULLWIDTH_JA: aType="iroha"_ostr;break;
+ case style::NumberingType::IROHA_HALFWIDTH_JA: aType="irohaFullWidth"_ostr;break;
+ case style::NumberingType::HANGUL_SYLLABLE_KO: aType="ganada"_ostr;break;
+ case style::NumberingType::HANGUL_JAMO_KO: aType="chosung"_ostr;break;
+ case style::NumberingType::NUMBER_HANGUL_KO: aType="koreanCounting"_ostr; break;
+ case style::NumberingType::NUMBER_LEGAL_KO: aType = "koreanLegal"_ostr; break;
+ case style::NumberingType::NUMBER_DIGITAL_KO: aType = "koreanDigital"_ostr; break;
+ case style::NumberingType::NUMBER_DIGITAL2_KO: aType = "koreanDigital2"_ostr; break;
+ case style::NumberingType::CIRCLE_NUMBER: aType="decimalEnclosedCircle"_ostr; break;
+ case style::NumberingType::CHARS_ARABIC: aType="arabicAlpha"_ostr; break;
+ case style::NumberingType::CHARS_ARABIC_ABJAD: aType="arabicAbjad"_ostr; break;
+ case style::NumberingType::CHARS_THAI: aType="thaiLetters"_ostr; break;
+ case style::NumberingType::CHARS_PERSIAN:
+ case style::NumberingType::CHARS_NEPALI: aType="hindiVowels"_ostr; break;
case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_RU:
- case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_N_RU: aType = "russianUpper"; break;
+ case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_N_RU: aType = "russianUpper"_ostr; break;
case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_RU:
- case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_N_RU: aType = "russianLower"; break;
- case style::NumberingType::TEXT_NUMBER: aType="ordinal"; break;
- case style::NumberingType::TEXT_CARDINAL: aType="cardinalText"; break;
- case style::NumberingType::TEXT_ORDINAL: aType="ordinalText"; break;
- case style::NumberingType::SYMBOL_CHICAGO: aType="chicago"; break;
- case style::NumberingType::ARABIC_ZERO: aType = "decimalZero"; break;
+ case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_N_RU: aType = "russianLower"_ostr; break;
+ case style::NumberingType::TEXT_NUMBER: aType="ordinal"_ostr; break;
+ case style::NumberingType::TEXT_CARDINAL: aType="cardinalText"_ostr; break;
+ case style::NumberingType::TEXT_ORDINAL: aType="ordinalText"_ostr; break;
+ case style::NumberingType::SYMBOL_CHICAGO: aType="chicago"_ostr; break;
+ case style::NumberingType::ARABIC_ZERO: aType = "decimalZero"_ostr; break;
case style::NumberingType::ARABIC_ZERO3:
- aType = "custom";
- rFormat = "001, 002, 003, ...";
+ aType = "custom"_ostr;
+ rFormat = "001, 002, 003, ..."_ostr;
break;
case style::NumberingType::ARABIC_ZERO4:
- aType = "custom";
- rFormat = "0001, 0002, 0003, ...";
+ aType = "custom"_ostr;
+ rFormat = "0001, 0002, 0003, ..."_ostr;
break;
case style::NumberingType::ARABIC_ZERO5:
- aType = "custom";
- rFormat = "00001, 00002, 00003, ...";
+ aType = "custom"_ostr;
+ rFormat = "00001, 00002, 00003, ..."_ostr;
break;
/*
Fallback the rest to the suggested default.
@@ -6908,7 +7223,6 @@ static OString lcl_ConvertNumberingType(sal_Int16 nNumberingType, const SfxItemS
case style::NumberingType::CHARS_GREEK_LOWER_LETTER:
case style::NumberingType::PAGE_DESCRIPTOR:
case style::NumberingType::TRANSLITERATION:
- case style::NumberingType::CHARS_NEPALI:
case style::NumberingType::CHARS_KHMER:
case style::NumberingType::CHARS_LAO:
case style::NumberingType::CHARS_TIBETAN:
@@ -6921,6 +7235,10 @@ static OString lcl_ConvertNumberingType(sal_Int16 nNumberingType, const SfxItemS
case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_SR:
case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_N_SR:
case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_N_SR:
+ case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_UK:
+ case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_UK:
+ case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_N_UK:
+ case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_N_UK:
*/
default: break;
}
@@ -7010,7 +7328,7 @@ void DocxAttributeOutput::FontCharset( sal_uInt8 nCharSet, rtl_TextEncoding nEnc
aCharSet = "0" + aCharSet;
pAttr->add(FSNS(XML_w, XML_val), aCharSet);
- if( GetExport().GetFilter().getVersion( ) != oox::core::ECMA_DIALECT )
+ if (GetExport().GetFilter().getVersion() != oox::core::ECMA_376_1ST_EDITION)
{
if( const char* charset = rtl_getMimeCharsetFromTextEncoding( nEncoding ))
pAttr->add( FSNS( XML_w, XML_characterSet ), charset );
@@ -7052,10 +7370,16 @@ void DocxAttributeOutput::EmbedFont( std::u16string_view name, FontFamily family
{
if( !m_rExport.m_rDoc.getIDocumentSettingAccess().get( DocumentSettingId::EMBED_FONTS ))
return; // no font embedding with this document
- EmbedFontStyle( name, XML_embedRegular, family, ITALIC_NONE, WEIGHT_NORMAL, pitch );
- EmbedFontStyle( name, XML_embedBold, family, ITALIC_NONE, WEIGHT_BOLD, pitch );
- EmbedFontStyle( name, XML_embedItalic, family, ITALIC_NORMAL, WEIGHT_NORMAL, pitch );
- EmbedFontStyle( name, XML_embedBoldItalic, family, ITALIC_NORMAL, WEIGHT_BOLD, pitch );
+ bool foundFont
+ = EmbedFontStyle(name, XML_embedRegular, family, ITALIC_NONE, WEIGHT_NORMAL, pitch);
+ foundFont
+ = EmbedFontStyle(name, XML_embedBold, family, ITALIC_NONE, WEIGHT_BOLD, pitch) || foundFont;
+ foundFont = EmbedFontStyle(name, XML_embedItalic, family, ITALIC_NORMAL, WEIGHT_NORMAL, pitch)
+ || foundFont;
+ foundFont = EmbedFontStyle(name, XML_embedBoldItalic, family, ITALIC_NORMAL, WEIGHT_BOLD, pitch)
+ || foundFont;
+ if (!foundFont)
+ EmbedFontStyle(name, XML_embedRegular, family, ITALIC_NONE, WEIGHT_DONTKNOW, pitch);
}
static char toHexChar( int value )
@@ -7063,21 +7387,21 @@ static char toHexChar( int value )
return value >= 10 ? value + 'A' - 10 : value + '0';
}
-void DocxAttributeOutput::EmbedFontStyle( std::u16string_view name, int tag, FontFamily family, FontItalic italic,
- FontWeight weight, FontPitch pitch )
+bool DocxAttributeOutput::EmbedFontStyle(std::u16string_view name, int tag, FontFamily family,
+ FontItalic italic, FontWeight weight, FontPitch pitch)
{
// Embed font if at least viewing is allowed (in which case the opening app must check
// the font license rights too and open either read-only or not use the font for editing).
OUString fontUrl = EmbeddedFontsHelper::fontFileUrl( name, family, italic, weight, pitch,
EmbeddedFontsHelper::FontRights::ViewingAllowed );
if( fontUrl.isEmpty())
- return;
+ return false;
// TODO IDocumentSettingAccess::EMBED_SYSTEM_FONTS
- if( !fontFilesMap.count( fontUrl ))
+ if( !m_FontFilesMap.count( fontUrl ))
{
osl::File file( fontUrl );
if( file.open( osl_File_OpenFlag_Read ) != osl::File::E_None )
- return;
+ return false;
uno::Reference< css::io::XOutputStream > xOutStream = m_rExport.GetFilter().openFragmentStream(
"word/fonts/font" + OUString::number(m_nextFontId) + ".odttf",
"application/vnd.openxmlformats-officedocument.obfuscatedFont" );
@@ -7096,7 +7420,7 @@ void DocxAttributeOutput::EmbedFontStyle( std::u16string_view name, int tag, Fon
{
SAL_WARN( "sw.ww8", "Font file size too small (" << fontUrl << ")" );
xOutStream->closeOutput();
- return;
+ return false;
}
for( int i = 0;
i < 16;
@@ -7113,7 +7437,7 @@ void DocxAttributeOutput::EmbedFontStyle( std::u16string_view name, int tag, Fon
{
SAL_WARN( "sw.ww8", "Error reading font file " << fontUrl );
xOutStream->closeOutput();
- return;
+ return false;
}
if( eof )
break;
@@ -7121,7 +7445,7 @@ void DocxAttributeOutput::EmbedFontStyle( std::u16string_view name, int tag, Fon
{
SAL_WARN( "sw.ww8", "Error reading font file " << fontUrl );
xOutStream->closeOutput();
- return;
+ return false;
}
if( readSize == 0 )
break;
@@ -7129,41 +7453,41 @@ void DocxAttributeOutput::EmbedFontStyle( std::u16string_view name, int tag, Fon
xOutStream->writeBytes( uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( buffer ), readSize ));
}
xOutStream->closeOutput();
- OString relId = OUStringToOString( GetExport().GetFilter().addRelation( m_pSerializer->getOutputStream(),
- oox::getRelationship(Relationship::FONT),
- OUString("fonts/font" + OUString::number( m_nextFontId ) + ".odttf") ), RTL_TEXTENCODING_UTF8 );
EmbeddedFontRef ref;
- ref.relId = relId;
+ ref.relId = OUStringToOString( GetExport().GetFilter().addRelation( m_pSerializer->getOutputStream(),
+ oox::getRelationship(Relationship::FONT),
+ Concat2View("fonts/font" + OUString::number( m_nextFontId ) + ".odttf") ), RTL_TEXTENCODING_UTF8 );
ref.fontKey = fontKeyStr;
- fontFilesMap[ fontUrl ] = ref;
+ m_FontFilesMap[ fontUrl ] = ref;
++m_nextFontId;
}
m_pSerializer->singleElementNS( XML_w, tag,
- FSNS( XML_r, XML_id ), fontFilesMap[ fontUrl ].relId,
- FSNS( XML_w, XML_fontKey ), fontFilesMap[ fontUrl ].fontKey );
+ FSNS( XML_r, XML_id ), m_FontFilesMap[ fontUrl ].relId,
+ FSNS( XML_w, XML_fontKey ), m_FontFilesMap[ fontUrl ].fontKey );
+ return true;
}
OString DocxAttributeOutput::TransHighlightColor( sal_uInt8 nIco )
{
switch (nIco)
{
- case 0: return "none"; break;
- case 1: return "black"; break;
- case 2: return "blue"; break;
- case 3: return "cyan"; break;
- case 4: return "green"; break;
- case 5: return "magenta"; break;
- case 6: return "red"; break;
- case 7: return "yellow"; break;
- case 8: return "white"; break;
- case 9: return "darkBlue"; break;
- case 10: return "darkCyan"; break;
- case 11: return "darkGreen"; break;
- case 12: return "darkMagenta"; break;
- case 13: return "darkRed"; break;
- case 14: return "darkYellow"; break;
- case 15: return "darkGray"; break;
- case 16: return "lightGray"; break;
+ case 0: return "none"_ostr; break;
+ case 1: return "black"_ostr; break;
+ case 2: return "blue"_ostr; break;
+ case 3: return "cyan"_ostr; break;
+ case 4: return "green"_ostr; break;
+ case 5: return "magenta"_ostr; break;
+ case 6: return "red"_ostr; break;
+ case 7: return "yellow"_ostr; break;
+ case 8: return "white"_ostr; break;
+ case 9: return "darkBlue"_ostr; break;
+ case 10: return "darkCyan"_ostr; break;
+ case 11: return "darkGreen"_ostr; break;
+ case 12: return "darkMagenta"_ostr; break;
+ case 13: return "darkRed"_ostr; break;
+ case 14: return "darkYellow"_ostr; break;
+ case 15: return "darkGray"_ostr; break;
+ case 16: return "lightGray"_ostr; break;
default: return OString(); break;
}
}
@@ -7233,6 +7557,7 @@ void DocxAttributeOutput::OverrideNumberingDefinition(
SwNumRule const& rAbstractRule = *(*m_rExport.m_pUsedNumTable)[nAbstractNum - 1];
sal_uInt8 const nLevels = static_cast<sal_uInt8>(rRule.IsContinusNum()
? WW8ListManager::nMinLevel : WW8ListManager::nMaxLevel);
+ sal_uInt8 nPreviousOverrideLevel = 0;
for (sal_uInt8 nLevel = 0; nLevel < nLevels; ++nLevel)
{
const auto levelOverride = rLevelOverrides.find(nLevel);
@@ -7242,6 +7567,18 @@ void DocxAttributeOutput::OverrideNumberingDefinition(
// or we have a level numbering override
if (bListsAreDifferent || levelOverride != rLevelOverrides.end())
{
+ // If there are "gaps" in w:lvlOverride numbers, MS Word can have issues with numbering.
+ // So we need to emit default override tokens up to current one.
+ while (nPreviousOverrideLevel < nLevel)
+ {
+ const SwNumFormat& rFormat = rRule.Get(nPreviousOverrideLevel);
+ m_pSerializer->startElementNS(XML_w, XML_lvlOverride, FSNS(XML_w, XML_ilvl), OString::number(nPreviousOverrideLevel));
+ // tdf#153104: absent startOverride is treated by Word as "startOverride value 0".
+ m_pSerializer->singleElementNS(XML_w, XML_startOverride, FSNS(XML_w, XML_val), OString::number(rFormat.GetStart()));
+ m_pSerializer->endElementNS(XML_w, XML_lvlOverride);
+ nPreviousOverrideLevel++;
+ }
+
m_pSerializer->startElementNS(XML_w, XML_lvlOverride, FSNS(XML_w, XML_ilvl), OString::number(nLevel));
if (bListsAreDifferent)
@@ -7287,7 +7624,8 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
sal_Int16 nFirstLineIndex,
sal_Int16 nListTabPos,
const OUString &rNumberingString,
- const SvxBrushItem* pBrush)
+ const SvxBrushItem* pBrush,
+ bool isLegal)
{
m_pSerializer->startElementNS(XML_w, XML_lvl, FSNS(XML_w, XML_ilvl), OString::number(nLevel));
@@ -7307,9 +7645,13 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
m_pSerializer->singleElementNS( XML_w, XML_pStyle ,
FSNS( XML_w, XML_val ), m_rExport.m_pStyles->GetStyleId(nId) );
}
+
+ if (isLegal)
+ m_pSerializer->singleElementNS(XML_w, XML_isLgl);
+
// format
OString aCustomFormat;
- OString aFormat(lcl_ConvertNumberingType(nNumberingType, pOutSet, aCustomFormat, "decimal"));
+ OString aFormat(lcl_ConvertNumberingType(nNumberingType, pOutSet, aCustomFormat, "decimal"_ostr));
{
if (aCustomFormat.isEmpty())
@@ -7355,9 +7697,9 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
// FIXME so far we support the ww8 limit of levels only
if ( *pIt < sal_Unicode( WW8ListManager::nMaxLevel ) )
{
- aBuffer.append( pPrev, pIt - pPrev );
- aBuffer.append( '%' );
- aBuffer.append( sal_Int32( *pIt ) + 1 );
+ aBuffer.append( OUString::Concat(std::u16string_view(pPrev, pIt - pPrev))
+ + "%"
+ + OUString::number(sal_Int32( *pIt ) + 1 ));
pPrev = pIt + 1;
}
@@ -7394,7 +7736,7 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
// justification
const char *pJc;
- bool ecmaDialect = ( m_rExport.GetFilter().getVersion() == oox::core::ECMA_DIALECT );
+ bool const ecmaDialect = m_rExport.GetFilter().getVersion() == oox::core::ECMA_376_1ST_EDITION;
switch ( eAdjust )
{
case SvxAdjust::Center: pJc = "center"; break;
@@ -7468,19 +7810,23 @@ void DocxAttributeOutput::CharCaseMap( const SvxCaseMapItem& rCaseMap )
}
}
-void DocxAttributeOutput::CharColor( const SvxColorItem& rColor )
+void DocxAttributeOutput::CharColor(const SvxColorItem& rColorItem)
{
- const Color aColor( rColor.GetValue() );
- OString aColorString = msfilter::util::ConvertColor( aColor );
+ const Color aColor = rColorItem.getColor();
+ const model::ComplexColor aComplexColor = rColorItem.getComplexColor();
- const char* pExistingValue(nullptr);
- if (m_pColorAttrList.is() && m_pColorAttrList->getAsChar(FSNS(XML_w, XML_val), pExistingValue))
+ OString aColorString = msfilter::util::ConvertColor(aColor);
+
+ std::string_view pExistingValue;
+ if (m_pColorAttrList.is() && m_pColorAttrList->getAsView(FSNS(XML_w, XML_val), pExistingValue))
{
- assert(aColorString.equalsL(pExistingValue, rtl_str_getLength(pExistingValue)));
+ assert(aColorString.equalsL(pExistingValue.data(), pExistingValue.size()));
return;
}
- AddToAttrList( m_pColorAttrList, FSNS( XML_w, XML_val ), aColorString.getStr() );
+ lclAddThemeColorAttributes(m_pColorAttrList, aComplexColor);
+
+ AddToAttrList(m_pColorAttrList, FSNS(XML_w, XML_val), aColorString);
m_nCharTransparence = 255 - aColor.GetAlpha();
}
@@ -7514,8 +7860,14 @@ void DocxAttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement )
OString sIss;
short nEsc = rEscapement.GetEsc(), nProp = rEscapement.GetProportionalHeight();
+ bool bParaStyle = false;
+ if (m_rExport.m_bStyDef && m_rExport.m_pCurrentStyle)
+ {
+ bParaStyle = m_rExport.m_pCurrentStyle->Which() == RES_TXTFMTCOLL;
+ }
+
// Simplify styles to avoid impossible complexity. Import and export as defaults only
- if ( m_rExport.m_bStyDef && nEsc )
+ if ( m_rExport.m_bStyDef && nEsc && !(bParaStyle && nEsc < 0))
{
nProp = DFLT_ESC_PROP;
nEsc = (nEsc > 0) ? DFLT_ESC_AUTO_SUPER : DFLT_ESC_AUTO_SUB;
@@ -7523,16 +7875,16 @@ void DocxAttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement )
if ( !nEsc )
{
- sIss = OString( "baseline" );
+ sIss = "baseline"_ostr;
nEsc = 0;
nProp = 100;
}
else if ( DFLT_ESC_PROP == nProp || nProp < 1 || nProp > 100 )
{
if ( DFLT_ESC_SUB == nEsc || DFLT_ESC_AUTO_SUB == nEsc )
- sIss = OString( "subscript" );
+ sIss = "subscript"_ostr;
else if ( DFLT_ESC_SUPER == nEsc || DFLT_ESC_AUTO_SUPER == nEsc )
- sIss = OString( "superscript" );
+ sIss = "superscript"_ostr;
}
else if ( DFLT_ESC_AUTO_SUPER == nEsc )
{
@@ -7571,8 +7923,7 @@ void DocxAttributeOutput::CharFont( const SvxFontItem& rFont)
{
GetExport().GetId( rFont ); // ensure font info is written to fontTable.xml
const OUString& sFontName(rFont.GetFamilyName());
- const OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8);
- if (sFontNameUtf8.isEmpty())
+ if (sFontName.isEmpty())
return;
if (m_pFontsAttrList &&
@@ -7586,9 +7937,9 @@ void DocxAttributeOutput::CharFont( const SvxFontItem& rFont)
return;
}
- AddToAttrList( m_pFontsAttrList, 2,
- FSNS( XML_w, XML_ascii ), sFontNameUtf8.getStr(),
- FSNS( XML_w, XML_hAnsi ), sFontNameUtf8.getStr() );
+ AddToAttrList( m_pFontsAttrList,
+ FSNS( XML_w, XML_ascii ), sFontName,
+ FSNS( XML_w, XML_hAnsi ), sFontName );
}
void DocxAttributeOutput::CharFontSize( const SvxFontHeightItem& rFontSize)
@@ -7615,20 +7966,18 @@ void DocxAttributeOutput::CharKerning( const SvxKerningItem& rKerning )
void DocxAttributeOutput::CharLanguage( const SvxLanguageItem& rLanguage )
{
- OString aLanguageCode( OUStringToOString(
- LanguageTag( rLanguage.GetLanguage()).getBcp47MS(),
- RTL_TEXTENCODING_UTF8));
+ OUString aLanguageCode(LanguageTag( rLanguage.GetLanguage()).getBcp47MS());
switch ( rLanguage.Which() )
{
case RES_CHRATR_LANGUAGE:
- AddToAttrList( m_pCharLangAttrList, FSNS( XML_w, XML_val ), aLanguageCode.getStr() );
+ AddToAttrList( m_pCharLangAttrList, FSNS( XML_w, XML_val ), aLanguageCode );
break;
case RES_CHRATR_CJK_LANGUAGE:
- AddToAttrList( m_pCharLangAttrList, FSNS( XML_w, XML_eastAsia ), aLanguageCode.getStr() );
+ AddToAttrList( m_pCharLangAttrList, FSNS( XML_w, XML_eastAsia ), aLanguageCode );
break;
case RES_CHRATR_CTL_LANGUAGE:
- AddToAttrList( m_pCharLangAttrList, FSNS( XML_w, XML_bidi ), aLanguageCode.getStr() );
+ AddToAttrList( m_pCharLangAttrList, FSNS( XML_w, XML_bidi ), aLanguageCode );
break;
}
}
@@ -7679,10 +8028,14 @@ void DocxAttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline )
bool bUnderlineHasColor = !aUnderlineColor.IsTransparent();
if (bUnderlineHasColor)
{
+ model::ComplexColor const& rComplexColor = rUnderline.getComplexColor();
// Underline has a color
- m_pSerializer->singleElementNS( XML_w, XML_u,
- FSNS( XML_w, XML_val ), pUnderlineValue,
- FSNS( XML_w, XML_color ), msfilter::util::ConvertColor(aUnderlineColor) );
+ rtl::Reference<FastAttributeList> pAttrList = FastSerializerHelper::createAttrList();
+ pAttrList->add(FSNS(XML_w, XML_val), pUnderlineValue);
+ pAttrList->add(FSNS(XML_w, XML_color), msfilter::util::ConvertColor(aUnderlineColor));
+ lclAddThemeColorAttributes(pAttrList, rComplexColor);
+ m_pSerializer->singleElementNS(XML_w, XML_u, pAttrList);
+
}
else
{
@@ -7715,9 +8068,9 @@ void DocxAttributeOutput::CharAnimatedText( const SvxBlinkItem& rBlink )
m_pSerializer->singleElementNS(XML_w, XML_effect, FSNS(XML_w, XML_val), "none");
}
-#define MSWORD_CH_SHADING_FILL "FFFFFF" // The attribute w:fill of w:shd, for MS-Word's character shading,
-#define MSWORD_CH_SHADING_COLOR "auto" // The attribute w:color of w:shd, for MS-Word's character shading,
-#define MSWORD_CH_SHADING_VAL "pct15" // The attribute w:value of w:shd, for MS-Word's character shading,
+constexpr OUStringLiteral MSWORD_CH_SHADING_FILL = u"FFFFFF"; // The attribute w:fill of w:shd, for MS-Word's character shading,
+constexpr OUStringLiteral MSWORD_CH_SHADING_COLOR = u"auto"; // The attribute w:color of w:shd, for MS-Word's character shading,
+constexpr OUStringLiteral MSWORD_CH_SHADING_VAL = u"pct15"; // The attribute w:value of w:shd, for MS-Word's character shading,
void DocxAttributeOutput::CharBackground( const SvxBrushItem& rBrush )
{
@@ -7747,9 +8100,7 @@ void DocxAttributeOutput::CharFontCJK( const SvxFontItem& rFont )
return;
}
- const OUString& sFontName(rFont.GetFamilyName());
- OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8);
- AddToAttrList( m_pFontsAttrList, FSNS( XML_w, XML_eastAsia ), sFontNameUtf8.getStr() );
+ AddToAttrList( m_pFontsAttrList, FSNS( XML_w, XML_eastAsia ), rFont.GetFamilyName() );
}
void DocxAttributeOutput::CharPostureCJK( const SvxPostureItem& rPosture )
@@ -7778,9 +8129,7 @@ void DocxAttributeOutput::CharFontCTL( const SvxFontItem& rFont )
return;
}
- const OUString& sFontName(rFont.GetFamilyName());
- OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8);
- AddToAttrList( m_pFontsAttrList, FSNS( XML_w, XML_cs ), sFontNameUtf8.getStr() );
+ AddToAttrList( m_pFontsAttrList, FSNS( XML_w, XML_cs ), rFont.GetFamilyName() );
}
void DocxAttributeOutput::CharPostureCTL( const SvxPostureItem& rPosture)
@@ -7851,16 +8200,16 @@ void DocxAttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines )
if (!cStart && !cEnd)
return;
- OString sBracket;
+ std::string_view sBracket;
if ((cStart == '{') || (cEnd == '}'))
- sBracket = const_cast<char *>("curly");
+ sBracket = "curly";
else if ((cStart == '<') || (cEnd == '>'))
- sBracket = const_cast<char *>("angle");
+ sBracket = "angle";
else if ((cStart == '[') || (cEnd == ']'))
- sBracket = const_cast<char *>("square");
+ sBracket = "square";
else
- sBracket = const_cast<char *>("round");
- AddToAttrList( m_pEastAsianLayoutAttrList, FSNS( XML_w, XML_combineBrackets ), sBracket.getStr() );
+ sBracket = "round";
+ AddToAttrList( m_pEastAsianLayoutAttrList, FSNS( XML_w, XML_combineBrackets ), sBracket );
}
void DocxAttributeOutput::CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth )
@@ -7905,7 +8254,12 @@ void DocxAttributeOutput::CharBorder(
if ( GetExport().m_bStyDef && GetExport().m_pCurrentStyle && GetExport().m_pCurrentStyle->DerivedFrom() )
pInherited = GetExport().m_pCurrentStyle->DerivedFrom()->GetAttrSet().GetItem<SvxBoxItem>(RES_CHRATR_BOX);
else if ( m_rExport.m_pChpIter ) // incredibly undocumented, but this is the character-style info, right?
- pInherited = static_cast<const SvxBoxItem*>(GetExport().m_pChpIter->HasTextItem(RES_CHRATR_BOX));
+ {
+ if (const SvxBoxItem* pPoolItem = GetExport().m_pChpIter->HasTextItem(RES_CHRATR_BOX))
+ {
+ pInherited = pPoolItem;
+ }
+ }
if ( pInherited )
rStyleBorder = SvxBoxItem::SvxLineToLine(pInherited->GetRight(), false);
@@ -7924,9 +8278,13 @@ void DocxAttributeOutput::CharHighlight( const SvxBrushItem& rHighlight )
void DocxAttributeOutput::TextINetFormat( const SwFormatINetFormat& rLink )
{
- OString aStyleId = MSWordStyles::CreateStyleId(rLink.GetINetFormat());
- if (!aStyleId.isEmpty() && !aStyleId.equalsIgnoreAsciiCase("DefaultStyle"))
- m_pSerializer->singleElementNS(XML_w, XML_rStyle, FSNS(XML_w, XML_val), aStyleId);
+ const SwCharFormat* pFormat = m_rExport.m_rDoc.FindCharFormatByName(rLink.GetINetFormat());
+ if (pFormat)
+ {
+ OString aStyleId(m_rExport.m_pStyles->GetStyleId(m_rExport.GetId(pFormat)));
+ if (!aStyleId.equalsIgnoreAsciiCase("DefaultStyle"))
+ m_pSerializer->singleElementNS(XML_w, XML_rStyle, FSNS(XML_w, XML_val), aStyleId);
+ }
}
void DocxAttributeOutput::TextCharFormat( const SwFormatCharFormat& rCharFormat )
@@ -7950,30 +8308,8 @@ void DocxAttributeOutput::RefField( const SwField& rField, const OUString& rRef
// There is nothing to do here for the set fields
}
-void DocxAttributeOutput::HiddenField(const SwField& rField)
+void DocxAttributeOutput::HiddenField(const SwField& /*rField*/)
{
- auto eSubType = static_cast<SwFieldTypesEnum>(rField.GetSubType());
- if (eSubType == SwFieldTypesEnum::ConditionalText)
- {
- OUString aCond = rField.GetPar1();
- OUString aTrueFalse = rField.GetPar2();
- sal_Int32 nPos = aTrueFalse.indexOf('|');
- OUString aTrue;
- OUString aFalse;
- if (nPos == -1)
- {
- aTrue = aTrueFalse;
- }
- else
- {
- aTrue = aTrueFalse.subView(0, nPos);
- aFalse = aTrueFalse.subView(nPos + 1);
- }
- OUString aCmd = FieldString(ww::eIF) + aCond + " \"" + aTrue + "\" \"" + aFalse + "\"";
- m_rExport.OutputField(&rField, ww::eIF, aCmd);
- return;
- }
-
SAL_INFO("sw.ww8", "TODO DocxAttributeOutput::HiddenField()" );
}
@@ -7981,9 +8317,8 @@ void DocxAttributeOutput::PostitField( const SwField* pField )
{
assert( dynamic_cast< const SwPostItField* >( pField ));
const SwPostItField* pPostItField = static_cast<const SwPostItField*>(pField);
- OString aName = OUStringToOString(pPostItField->GetName(), RTL_TEXTENCODING_UTF8);
sal_Int32 nId = 0;
- std::map< OString, sal_Int32 >::iterator it = m_rOpenedAnnotationMarksIds.find(aName);
+ auto it = m_rOpenedAnnotationMarksIds.find(pPostItField->GetName());
if (it != m_rOpenedAnnotationMarksIds.end())
// If the postit field has an annotation mark associated, we already have an id.
nId = it->second;
@@ -8001,28 +8336,62 @@ void DocxAttributeOutput::WritePostitFieldReference()
// In case this file is inside annotation marks, we want to write the
// comment reference after the annotation mark is closed, not here.
- OString idname = OUStringToOString(m_postitFields[m_postitFieldsMaxId].first->GetName(), RTL_TEXTENCODING_UTF8);
- std::map< OString, sal_Int32 >::iterator it = m_rOpenedAnnotationMarksIds.find( idname );
+ const OUString& idname = m_postitFields[m_postitFieldsMaxId].first->GetName();
+ auto it = m_rOpenedAnnotationMarksIds.find( idname );
if ( it == m_rOpenedAnnotationMarksIds.end( ) )
m_pSerializer->singleElementNS(XML_w, XML_commentReference, FSNS(XML_w, XML_id), idstr);
++m_postitFieldsMaxId;
}
}
-DocxAttributeOutput::hasResolved DocxAttributeOutput::WritePostitFields()
+DocxAttributeOutput::hasProperties DocxAttributeOutput::WritePostitFields()
{
- hasResolved eResult = hasResolved::no;
+ bool bRemovePersonalInfo = SvtSecurityOptions::IsOptionSet(
+ SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo ) && !SvtSecurityOptions::IsOptionSet(
+ SvtSecurityOptions::EOption::DocWarnKeepRedlineInfo);
+
+ hasProperties eResult = hasProperties::no;
+ for (auto& [f1, data1] : m_postitFields)
+ {
+ if (f1->GetParentId() != 0)
+ {
+ for (size_t i = 0; i < m_postitFields.size(); i++)
+ {
+ auto& [f2, data2] = m_postitFields[i];
+ if (f2->GetParaId() == f1->GetParentId())
+ {
+ data2.parentStatus = ParentStatus::IsParent;
+ data1.parentStatus = ParentStatus::HasParent;
+ data1.parentIndex = i;
+ break;
+ }
+ }
+ }
+ }
for (auto& [f, data] : m_postitFields)
{
- OString idstr = OString::number(data.id);
- m_pSerializer->startElementNS( XML_w, XML_comment, FSNS( XML_w, XML_id ), idstr,
- FSNS( XML_w, XML_author ), f->GetPar1(),
- FSNS( XML_w, XML_date ), DateTimeToOString(f->GetDateTime()),
- FSNS( XML_w, XML_initials ), f->GetInitials() );
-
- const bool bNeedParaId = f->GetResolved();
+ const DateTime aDateTime = f->GetDateTime();
+ bool bNoDate = bRemovePersonalInfo ||
+ ( aDateTime.GetYear() == 1970 && aDateTime.GetMonth() == 1 && aDateTime.GetDay() == 1 );
+
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
+ = sax_fastparser::FastSerializerHelper::createAttrList();
+
+ pAttributeList->add(FSNS( XML_w, XML_id ), OString::number(data.id));
+ pAttributeList->add(FSNS( XML_w, XML_author ), bRemovePersonalInfo
+ ? "Author" + OString::number( GetExport().GetInfoID(f->GetPar1()) )
+ : f->GetPar1().toUtf8());
+ if (!bNoDate)
+ pAttributeList->add(FSNS( XML_w, XML_date ), DateTimeToOString( aDateTime ));
+ pAttributeList->add(FSNS( XML_w, XML_initials ), bRemovePersonalInfo
+ ? OString::number( GetExport().GetInfoID(f->GetInitials()) )
+ : f->GetInitials().toUtf8());
+ m_pSerializer->startElementNS( XML_w, XML_comment, pAttributeList );
+
+ // Make sure to give parent/child fields a paraId
+ const bool bNeedParaId = f->GetResolved() || data.parentStatus != ParentStatus::None;
if (bNeedParaId)
- eResult = hasResolved::yes;
+ eResult = hasProperties::yes;
if (f->GetTextObject() != nullptr)
{
@@ -8055,11 +8424,30 @@ void DocxAttributeOutput::WritePostItFieldsResolved()
{
for (auto& [f, data] : m_postitFields)
{
- if (!f->GetResolved())
+ // Parent fields don't need to be exported here if they don't have a resolved attribute
+ if (!f->GetResolved() && data.parentStatus != ParentStatus::HasParent)
continue;
OUString idstr = NumberToHexBinary(data.lastParaId);
- m_pSerializer->singleElementNS(XML_w15, XML_commentEx, FSNS(XML_w15, XML_paraId), idstr,
- FSNS(XML_w15, XML_done), "1");
+ std::optional<OUString> sDone, sParentId;
+ if (f->GetParentId() != 0)
+ {
+ if (data.parentStatus == ParentStatus::HasParent)
+ {
+ // Since parent fields have been resolved first, they should already have an id
+ const PostItDOCXData& aParentFieldData = m_postitFields[data.parentIndex].second;
+ sParentId = NumberToHexBinary(aParentFieldData.lastParaId);
+ }
+ else
+ {
+ SAL_WARN("sw.ww8", "SwPostItField has a parent id, but a matching parent was not found");
+ }
+ }
+ if (f->GetResolved())
+ sDone = "1";
+ m_pSerializer->singleElementNS(XML_w15, XML_commentEx,
+ FSNS(XML_w15, XML_paraId), idstr,
+ FSNS(XML_w15, XML_done), sDone,
+ FSNS(XML_w15, XML_paraIdParent), sParentId);
}
}
@@ -8074,17 +8462,17 @@ bool DocxAttributeOutput::DropdownField( const SwField* pField )
bool DocxAttributeOutput::PlaceholderField( const SwField* pField )
{
- assert( pendingPlaceholder == nullptr );
- pendingPlaceholder = pField;
+ assert( m_PendingPlaceholder == nullptr );
+ m_PendingPlaceholder = pField;
return false; // do not expand
}
void DocxAttributeOutput::WritePendingPlaceholder()
{
- if( pendingPlaceholder == nullptr )
+ if( m_PendingPlaceholder == nullptr )
return;
- const SwField* pField = pendingPlaceholder;
- pendingPlaceholder = nullptr;
+ const SwField* pField = m_PendingPlaceholder;
+ m_PendingPlaceholder = nullptr;
m_pSerializer->startElementNS(XML_w, XML_sdt);
m_pSerializer->startElementNS(XML_w, XML_sdtPr);
if( !pField->GetPar2().isEmpty())
@@ -8160,7 +8548,7 @@ void DocxAttributeOutput::WriteFormData_Impl( const ::sw::mark::IFieldmark& rFie
m_Fields.begin()->pFieldmark = &rFieldmark;
}
-void DocxAttributeOutput::WriteBookmarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds )
+void DocxAttributeOutput::WriteBookmarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds, const SwRedlineData* pRedlineData )
{
for ( const OUString & name : rStarts )
{
@@ -8172,6 +8560,7 @@ void DocxAttributeOutput::WriteBookmarks_Impl( std::vector< OUString >& rStarts,
else
{
m_rBookmarksStart.push_back(name);
+ m_pMoveRedlineData = const_cast<SwRedlineData*>(pRedlineData);
}
}
rStarts.clear();
@@ -8225,18 +8614,10 @@ void DocxAttributeOutput::WriteFinalBookmarks_Impl( std::vector< OUString >& rSt
void DocxAttributeOutput::WriteAnnotationMarks_Impl( std::vector< OUString >& rStarts,
std::vector< OUString >& rEnds )
{
- for ( const auto & rAnnotationName : rStarts )
- {
- OString rName = OUStringToOString(rAnnotationName, RTL_TEXTENCODING_UTF8 ).getStr( );
- m_rAnnotationMarksStart.push_back( rName );
- }
+ m_rAnnotationMarksStart.insert(m_rAnnotationMarksStart.end(), rStarts.begin(), rStarts.end());
rStarts.clear();
- for ( const auto & rAnnotationName : rEnds )
- {
- OString rName = OUStringToOString( rAnnotationName, RTL_TEXTENCODING_UTF8 ).getStr( );
- m_rAnnotationMarksEnd.push_back( rName );
- }
+ m_rAnnotationMarksEnd.insert(m_rAnnotationMarksEnd.end(), rEnds.begin(), rEnds.end());
rEnds.clear();
}
@@ -8405,8 +8786,8 @@ void DocxAttributeOutput::WriteFootnoteEndnotePr( ::sax_fastparser::FSHelperPtr
{
switch( pFootnoteInfo->m_eNum )
{
- case FTNNUM_PAGE: fmt = "eachPage"; break;
- case FTNNUM_CHAPTER: fmt = "eachSect"; break;
+ case FTNNUM_PAGE: fmt = "eachPage"_ostr; break;
+ case FTNNUM_CHAPTER: fmt = "eachSect"_ostr; break;
default: fmt.clear(); break;
}
if (!fmt.isEmpty())
@@ -8433,21 +8814,21 @@ void DocxAttributeOutput::ParaLineSpacing_Impl( short nSpace, short nMulti )
{
if ( nSpace < 0 )
{
- AddToAttrList( m_pParagraphSpacingAttrList, 2,
+ AddToAttrList( m_pParagraphSpacingAttrList,
FSNS( XML_w, XML_lineRule ), "exact",
- FSNS( XML_w, XML_line ), OString::number( -nSpace ).getStr() );
+ FSNS( XML_w, XML_line ), OString::number( -nSpace ) );
}
else if( nSpace > 0 && nMulti )
{
- AddToAttrList( m_pParagraphSpacingAttrList, 2,
+ AddToAttrList( m_pParagraphSpacingAttrList,
FSNS( XML_w, XML_lineRule ), "auto",
- FSNS( XML_w, XML_line ), OString::number( nSpace ).getStr() );
+ FSNS( XML_w, XML_line ), OString::number( nSpace ) );
}
else
{
- AddToAttrList( m_pParagraphSpacingAttrList, 2,
+ AddToAttrList( m_pParagraphSpacingAttrList,
FSNS( XML_w, XML_lineRule ), "atLeast",
- FSNS( XML_w, XML_line ), OString::number( nSpace ).getStr() );
+ FSNS( XML_w, XML_line ), OString::number( nSpace ) );
}
}
@@ -8455,7 +8836,7 @@ void DocxAttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
{
const char *pAdjustString;
- bool bEcma = GetExport().GetFilter().getVersion( ) == oox::core::ECMA_DIALECT;
+ bool const bEcma = GetExport().GetFilter().getVersion() == oox::core::ECMA_376_1ST_EDITION;
const SfxItemSet* pItems = GetExport().GetCurItemSet();
const SvxFrameDirectionItem* rFrameDir = pItems?
@@ -8536,18 +8917,18 @@ static void impl_WriteTabElement( FSHelperPtr const & pSerializer,
switch (rTab.GetAdjustment())
{
case SvxTabAdjust::Right:
- pTabElementAttrList->add( FSNS( XML_w, XML_val ), OString( "right" ) );
+ pTabElementAttrList->add( FSNS( XML_w, XML_val ), "right" );
break;
case SvxTabAdjust::Decimal:
- pTabElementAttrList->add( FSNS( XML_w, XML_val ), OString( "decimal" ) );
+ pTabElementAttrList->add( FSNS( XML_w, XML_val ), "decimal" );
break;
case SvxTabAdjust::Center:
- pTabElementAttrList->add( FSNS( XML_w, XML_val ), OString( "center" ) );
+ pTabElementAttrList->add( FSNS( XML_w, XML_val ), "center" );
break;
case SvxTabAdjust::Default:
case SvxTabAdjust::Left:
default:
- pTabElementAttrList->add( FSNS( XML_w, XML_val ), OString( "left" ) );
+ pTabElementAttrList->add( FSNS( XML_w, XML_val ), "left" );
break;
}
@@ -8560,15 +8941,15 @@ static void impl_WriteTabElement( FSHelperPtr const & pSerializer,
sal_Unicode cFillChar = rTab.GetFill();
if ('.' == cFillChar )
- pTabElementAttrList->add( FSNS( XML_w, XML_leader ), OString( "dot" ) );
+ pTabElementAttrList->add( FSNS( XML_w, XML_leader ), "dot" );
else if ( '-' == cFillChar )
- pTabElementAttrList->add( FSNS( XML_w, XML_leader ), OString( "hyphen" ) );
+ pTabElementAttrList->add( FSNS( XML_w, XML_leader ), "hyphen" );
else if ( u'\x00B7' == cFillChar ) // middle dot
- pTabElementAttrList->add( FSNS( XML_w, XML_leader ), OString( "middleDot" ) );
+ pTabElementAttrList->add( FSNS( XML_w, XML_leader ), "middleDot" );
else if ( '_' == cFillChar )
- pTabElementAttrList->add( FSNS( XML_w, XML_leader ), OString( "underscore" ) );
+ pTabElementAttrList->add( FSNS( XML_w, XML_leader ), "underscore" );
else
- pTabElementAttrList->add( FSNS( XML_w, XML_leader ), OString( "none" ) );
+ pTabElementAttrList->add( FSNS( XML_w, XML_leader ), "none" );
pSerializer->singleElementNS(XML_w, XML_tab, pTabElementAttrList);
}
@@ -8604,9 +8985,7 @@ void DocxAttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStop )
// Get offset for tabs
// In DOCX, w:pos specifies the position of the current custom tab stop with respect to the current page margins.
// But in ODT, zero position could be page margins or paragraph indent according to used settings.
- tools::Long tabsOffset = 0;
- if (m_rExport.m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::TABS_RELATIVE_TO_INDENT))
- tabsOffset = m_rExport.GetItem(RES_LR_SPACE).GetTextLeft();
+ tools::Long tabsOffset = m_rExport.GetParaTabStopOffset();
// clear unused inherited tabs - otherwise the style will add them back in
sal_Int32 nCurrTab = 0;
@@ -8645,20 +9024,29 @@ void DocxAttributeOutput::ParaNumRule_Impl( const SwTextNode* pTextNd, sal_Int32
if ( USHRT_MAX == nNumId )
return;
+ // LibreOffice is not very flexible with "Outline Numbering" (aka "Outline" numbering style).
+ // Only ONE numbering rule ("Outline") can be associated with a style-assigned-listLevel,
+ // and no other style is able to inherit these numId/nLvl settings - only text nodes can.
+ // So listLevel only exists in paragraph properties EXCEPT for up to ten styles that have been
+ // assigned to one of these special Chapter Numbering listlevels (by default Heading 1-10).
const sal_Int32 nTableSize = m_rExport.m_pUsedNumTable ? m_rExport.m_pUsedNumTable->size() : 0;
const SwNumRule* pRule = nNumId > 0 && nNumId <= nTableSize ? (*m_rExport.m_pUsedNumTable)[nNumId-1] : nullptr;
- const bool bOutlineRule = pRule && pRule->IsOutlineRule();
-
- // Do not export outline rules (Chapter Numbering) as paragraph properties, only as style properties.
- if ( !pTextNd || !bOutlineRule )
- {
- m_pSerializer->startElementNS(XML_w, XML_numPr);
- m_pSerializer->singleElementNS(XML_w, XML_ilvl,
- FSNS(XML_w, XML_val), OString::number(nLvl));
- m_pSerializer->singleElementNS(XML_w, XML_numId,
- FSNS(XML_w, XML_val), OString::number(nNumId));
- m_pSerializer->endElementNS( XML_w, XML_numPr );
+ const SwTextFormatColl* pColl = pTextNd ? pTextNd->GetTextColl() : nullptr;
+ // Do not duplicate numbering that is inherited from the (Chapter numbering) style
+ // (since on import we duplicate style numbering/listlevel to the paragraph).
+ if (pColl && pColl->IsAssignedToListLevelOfOutlineStyle()
+ && nLvl == pColl->GetAssignedOutlineStyleLevel() && pRule && pRule->IsOutlineRule())
+ {
+ // By definition of how LO is implemented, assignToListLevel is only possible
+ // when the style is also using OutlineRule for numbering. Adjust logic if that changes.
+ assert(pRule->GetName() == pColl->GetNumRule(true).GetValue());
+ return;
}
+
+ m_pSerializer->startElementNS(XML_w, XML_numPr);
+ m_pSerializer->singleElementNS(XML_w, XML_ilvl, FSNS(XML_w, XML_val), OString::number(nLvl));
+ m_pSerializer->singleElementNS(XML_w, XML_numId, FSNS(XML_w, XML_val), OString::number(nNumId));
+ m_pSerializer->endElementNS(XML_w, XML_numPr);
}
void DocxAttributeOutput::ParaScriptSpace( const SfxBoolItem& rScriptSpace )
@@ -8727,16 +9115,16 @@ void DocxAttributeOutput::FormatFrameSize( const SwFormatFrameSize& rSize )
{
if ( rSize.GetWidth() && rSize.GetWidthSizeType() == SwFrameSize::Fixed )
AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(),
- FSNS( XML_w, XML_w ), OString::number( rSize.GetWidth( ) ).getStr() );
+ FSNS( XML_w, XML_w ), OString::number( rSize.GetWidth( ) ) );
if ( rSize.GetHeight() )
{
- OString sRule( "exact" );
+ std::string_view sRule( "exact" );
if ( rSize.GetHeightSizeType() == SwFrameSize::Minimum )
- sRule = OString( "atLeast" );
- AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), 2,
- FSNS( XML_w, XML_hRule ), sRule.getStr(),
- FSNS( XML_w, XML_h ), OString::number( rSize.GetHeight( ) ).getStr() );
+ sRule = "atLeast";
+ AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(),
+ FSNS( XML_w, XML_hRule ), sRule,
+ FSNS( XML_w, XML_h ), OString::number( rSize.GetHeight( ) ) );
}
}
else if ( m_rExport.m_bOutPageDescs )
@@ -8752,15 +9140,78 @@ void DocxAttributeOutput::FormatFrameSize( const SwFormatFrameSize& rSize )
}
}
-void DocxAttributeOutput::FormatPaperBin( const SvxPaperBinItem& )
+void DocxAttributeOutput::FormatPaperBin(const SvxPaperBinItem& rPaperBin)
{
- SAL_INFO("sw.ww8", "TODO DocxAttributeOutput::FormatPaperBin()" );
+ sal_Int8 nPaperBin = rPaperBin.GetValue();
+ rtl::Reference<FastAttributeList> attrList = FastSerializerHelper::createAttrList( );
+ SfxPrinter* pPrinter = m_rExport.m_rDoc.getIDocumentDeviceAccess().getPrinter(true);
+ sal_Int16 nPaperSource = pPrinter->GetSourceIndexByPaperBin(nPaperBin);
+ attrList->add( FSNS( XML_w, XML_first ), OString::number(nPaperSource) );
+ attrList->add( FSNS( XML_w, XML_other ), OString::number(nPaperSource) );
+ m_pSerializer->singleElementNS( XML_w, XML_paperSrc, attrList );
}
-void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace )
+void DocxAttributeOutput::FormatFirstLineIndent(SvxFirstLineIndentItem const& rFirstLine)
+{
+ sal_Int32 const nFirstLineAdjustment(rFirstLine.GetTextFirstLineOffset());
+ if (nFirstLineAdjustment > 0)
+ {
+ AddToAttrList(m_pLRSpaceAttrList, FSNS(XML_w, XML_firstLine),
+ OString::number(nFirstLineAdjustment));
+ }
+ else
+ {
+ AddToAttrList(m_pLRSpaceAttrList, FSNS(XML_w, XML_hanging),
+ OString::number(- nFirstLineAdjustment));
+ }
+}
+
+void DocxAttributeOutput::FormatTextLeftMargin(SvxTextLeftMarginItem const& rTextLeftMargin)
{
- bool bEcma = m_rExport.GetFilter().getVersion( ) == oox::core::ECMA_DIALECT;
+ SvxTextLeftMarginItem const* pTextLeftMargin(&rTextLeftMargin);
+ ::std::optional<SvxTextLeftMarginItem> oCopy;
+ if (dynamic_cast<SwContentNode const*>(GetExport().m_pOutFormatNode) != nullptr)
+ {
+ auto pTextNd(static_cast<SwTextNode const*>(GetExport().m_pOutFormatNode));
+ // WW doesn't have a concept of a paragraph that's in a list but not
+ // counted in the list - see AttributeOutputBase::ParaNumRule()
+ // forcing non-existent numId="0" in this case.
+ // This means WW won't apply the indents from the numbering,
+ // so try to add them as paragraph properties here.
+ if (!pTextNd->IsCountedInList())
+ {
+ SfxItemSetFixed<RES_MARGIN_TEXTLEFT, RES_MARGIN_TEXTLEFT> temp(m_rExport.m_rDoc.GetAttrPool());
+ pTextNd->GetParaAttr(temp, 0, 0, false, true, true, nullptr);
+ if (auto *const pItem = temp.GetItem(RES_MARGIN_TEXTLEFT))
+ {
+ oCopy.emplace(*pItem);
+ pTextLeftMargin = &*oCopy;
+ }
+ }
+ }
+ bool const bEcma1st(m_rExport.GetFilter().getVersion() == oox::core::ECMA_376_1ST_EDITION);
+ AddToAttrList(m_pLRSpaceAttrList,
+ FSNS(XML_w, (bEcma1st ? XML_left : XML_start)),
+ OString::number(pTextLeftMargin->GetTextLeft()));
+}
+
+void DocxAttributeOutput::FormatRightMargin(SvxRightMarginItem const& rRightMargin)
+{
+ // (paragraph case, this will be an else branch once others are converted)
+#if 0
+ else
+#endif
+ {
+ bool const bEcma1st(m_rExport.GetFilter().getVersion() == oox::core::ECMA_376_1ST_EDITION);
+ AddToAttrList(m_pLRSpaceAttrList,
+ FSNS(XML_w, (bEcma1st ? XML_right : XML_end)),
+ OString::number(rRightMargin.GetRight()));
+ }
+}
+void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace )
+{
+ bool const bEcma = m_rExport.GetFilter().getVersion() == oox::core::ECMA_376_1ST_EDITION;
if (m_rExport.SdrExporter().getTextFrameSyntax())
{
m_rExport.SdrExporter().getTextFrameStyle().append(";mso-wrap-distance-left:" + OString::number(double(rLRSpace.GetLeft()) / 20) + "pt");
@@ -8773,14 +9224,15 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace )
{
AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_hSpace ),
OString::number(
- ( rLRSpace.GetLeft() + rLRSpace.GetRight() ) / 2 ).getStr() );
+ ( rLRSpace.GetLeft() + rLRSpace.GetRight() ) / 2 ) );
}
else if ( m_rExport.m_bOutPageDescs )
{
m_pageMargins.nLeft = 0;
m_pageMargins.nRight = 0;
- if ( auto pBoxItem = static_cast<const SvxBoxItem*>(m_rExport.HasItem( RES_BOX )) )
+ const SvxBoxItem* pBoxItem = m_rExport.HasItem(RES_BOX);
+ if (pBoxItem)
{
m_pageMargins.nLeft = pBoxItem->CalcLineSpace( SvxBoxItemLine::LEFT, /*bEvenIfNoLine*/true );
m_pageMargins.nRight = pBoxItem->CalcLineSpace( SvxBoxItemLine::RIGHT, /*bEvenIfNoLine*/true );
@@ -8790,23 +9242,27 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace )
m_pageMargins.nRight += sal::static_int_cast<sal_uInt16>(rLRSpace.GetRight());
sal_uInt16 nGutter = rLRSpace.GetGutterMargin();
- AddToAttrList( m_pSectionSpacingAttrList, 3,
- FSNS( XML_w, XML_left ), OString::number( m_pageMargins.nLeft ).getStr(),
- FSNS( XML_w, XML_right ), OString::number( m_pageMargins.nRight ).getStr(),
- FSNS( XML_w, XML_gutter ), OString::number( nGutter ).getStr() );
+ AddToAttrList( m_pSectionSpacingAttrList,
+ FSNS( XML_w, XML_left ), OString::number( m_pageMargins.nLeft ),
+ FSNS( XML_w, XML_right ), OString::number( m_pageMargins.nRight ),
+ FSNS( XML_w, XML_gutter ), OString::number( nGutter ) );
}
else
{
+ // note: this is not possible for SwTextNode but is for EditEngine!
+ SvxLRSpaceItem const* pLRSpace(&rLRSpace);
+ ::std::optional<SvxLRSpaceItem> oLRSpace;
+ assert(dynamic_cast<SwContentNode const*>(GetExport().m_pOutFormatNode) == nullptr);
rtl::Reference<FastAttributeList> pLRSpaceAttrList = FastSerializerHelper::createAttrList();
- if((0 != rLRSpace.GetTextLeft()) || (rLRSpace.IsExplicitZeroMarginValLeft()))
+ if ((0 != pLRSpace->GetTextLeft()) || (pLRSpace->IsExplicitZeroMarginValLeft()))
{
- pLRSpaceAttrList->add( FSNS( XML_w, ( bEcma ? XML_left : XML_start ) ), OString::number( rLRSpace.GetTextLeft() ) );
+ pLRSpaceAttrList->add( FSNS(XML_w, (bEcma ? XML_left : XML_start)), OString::number(pLRSpace->GetTextLeft()) );
}
- if((0 != rLRSpace.GetRight()) || (rLRSpace.IsExplicitZeroMarginValRight()))
+ if ((0 != pLRSpace->GetRight()) || (pLRSpace->IsExplicitZeroMarginValRight()))
{
- pLRSpaceAttrList->add( FSNS( XML_w, ( bEcma ? XML_right : XML_end ) ), OString::number( rLRSpace.GetRight() ) );
+ pLRSpaceAttrList->add( FSNS(XML_w, (bEcma ? XML_right : XML_end)), OString::number(pLRSpace->GetRight()) );
}
- sal_Int32 nFirstLineAdjustment = rLRSpace.GetTextFirstLineOffset();
+ sal_Int32 const nFirstLineAdjustment = pLRSpace->GetTextFirstLineOffset();
if (nFirstLineAdjustment > 0)
pLRSpaceAttrList->add( FSNS( XML_w, XML_firstLine ), OString::number( nFirstLineAdjustment ) );
else
@@ -8830,7 +9286,7 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
{
AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_vSpace ),
OString::number(
- ( rULSpace.GetLower() + rULSpace.GetUpper() ) / 2 ).getStr() );
+ ( rULSpace.GetLower() + rULSpace.GetUpper() ) / 2 ) );
}
else if (m_rExport.m_bOutPageDescs )
{
@@ -8842,7 +9298,7 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
sal_Int32 nHeader = 0;
if ( aDistances.HasHeader() )
- nHeader = sal_Int32( aDistances.dyaHdrTop );
+ nHeader = sal_Int32( aDistances.m_DyaHdrTop );
else if (m_rExport.m_pFirstPageFormat)
{
HdFtDistanceGlue aFirstPageDistances(m_rExport.m_pFirstPageFormat->GetAttrSet());
@@ -8851,16 +9307,16 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
// The follow page style has no header, but the first page style has. In Word terms,
// this means that the header margin of "the" section is coming from the first page
// style.
- nHeader = sal_Int32(aFirstPageDistances.dyaHdrTop);
+ nHeader = sal_Int32(aFirstPageDistances.m_DyaHdrTop);
}
}
// Page top
- m_pageMargins.nTop = aDistances.dyaTop;
+ m_pageMargins.nTop = aDistances.m_DyaTop;
sal_Int32 nFooter = 0;
if ( aDistances.HasFooter() )
- nFooter = sal_Int32( aDistances.dyaHdrBottom );
+ nFooter = sal_Int32( aDistances.m_DyaHdrBottom );
else if (m_rExport.m_pFirstPageFormat)
{
HdFtDistanceGlue aFirstPageDistances(m_rExport.m_pFirstPageFormat->GetAttrSet());
@@ -8869,18 +9325,18 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
// The follow page style has no footer, but the first page style has. In Word terms,
// this means that the footer margin of "the" section is coming from the first page
// style.
- nFooter = sal_Int32(aFirstPageDistances.dyaHdrBottom);
+ nFooter = sal_Int32(aFirstPageDistances.m_DyaHdrBottom);
}
}
// Page Bottom
- m_pageMargins.nBottom = aDistances.dyaBottom;
+ m_pageMargins.nBottom = aDistances.m_DyaBottom;
- AddToAttrList( m_pSectionSpacingAttrList, 4,
- FSNS( XML_w, XML_header ), OString::number( nHeader ).getStr(),
- FSNS( XML_w, XML_top ), OString::number( m_pageMargins.nTop ).getStr(),
- FSNS( XML_w, XML_footer ), OString::number( nFooter ).getStr(),
- FSNS( XML_w, XML_bottom ), OString::number( m_pageMargins.nBottom ).getStr() );
+ AddToAttrList( m_pSectionSpacingAttrList,
+ FSNS( XML_w, XML_header ), OString::number( nHeader ),
+ FSNS( XML_w, XML_top ), OString::number( m_pageMargins.nTop ),
+ FSNS( XML_w, XML_footer ), OString::number( nFooter ),
+ FSNS( XML_w, XML_bottom ), OString::number( m_pageMargins.nBottom ) );
}
else
{
@@ -8895,14 +9351,13 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
else if (m_bParaBeforeAutoSpacing && m_nParaBeforeSpacing == -1)
{
AddToAttrList( m_pParagraphSpacingAttrList,
- FSNS( XML_w, XML_beforeAutospacing ), "0" );
- AddToAttrList( m_pParagraphSpacingAttrList,
- FSNS( XML_w, XML_before ), OString::number( rULSpace.GetUpper() ).getStr() );
+ FSNS( XML_w, XML_beforeAutospacing ), "0",
+ FSNS( XML_w, XML_before ), OString::number( rULSpace.GetUpper() ) );
}
else
{
AddToAttrList( m_pParagraphSpacingAttrList,
- FSNS( XML_w, XML_before ), OString::number( rULSpace.GetUpper() ).getStr() );
+ FSNS( XML_w, XML_before ), OString::number( rULSpace.GetUpper() ) );
}
m_bParaBeforeAutoSpacing = false;
// check if after auto spacing was set during import and spacing we get from actual object is same
@@ -8915,14 +9370,13 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
else if (m_bParaAfterAutoSpacing && m_nParaAfterSpacing == -1)
{
AddToAttrList( m_pParagraphSpacingAttrList,
- FSNS( XML_w, XML_afterAutospacing ), "0" );
- AddToAttrList( m_pParagraphSpacingAttrList,
- FSNS( XML_w, XML_after ), OString::number( rULSpace.GetLower()).getStr() );
+ FSNS( XML_w, XML_afterAutospacing ), "0",
+ FSNS( XML_w, XML_after ), OString::number( rULSpace.GetLower()) );
}
else
{
AddToAttrList( m_pParagraphSpacingAttrList,
- FSNS( XML_w, XML_after ), OString::number( rULSpace.GetLower()).getStr() );
+ FSNS( XML_w, XML_after ), OString::number( rULSpace.GetLower()) );
}
m_bParaAfterAutoSpacing = false;
@@ -8947,9 +9401,8 @@ namespace docx {
rtl::Reference<FastAttributeList> SurroundToVMLWrap(SwFormatSurround const& rSurround)
{
- rtl::Reference<FastAttributeList> pAttrList;
- OString sType;
- OString sSide;
+ std::string_view sType;
+ std::string_view sSide;
switch (rSurround.GetSurround())
{
case css::text::WrapTextMode_NONE:
@@ -8976,18 +9429,11 @@ rtl::Reference<FastAttributeList> SurroundToVMLWrap(SwFormatSurround const& rSur
sType = "none";
break;
}
- if (!sType.isEmpty() || !sSide.isEmpty())
- {
- pAttrList = FastSerializerHelper::createAttrList();
- if (!sType.isEmpty())
- {
- pAttrList->add(XML_type, sType);
- }
- if (!sSide.isEmpty())
- {
- pAttrList->add(XML_side, sSide);
- }
- }
+ rtl::Reference<FastAttributeList> pAttrList;
+ if (!sType.empty())
+ DocxAttributeOutput::AddToAttrList(pAttrList, XML_type, sType);
+ if (!sSide.empty())
+ DocxAttributeOutput::AddToAttrList(pAttrList, XML_side, sSide);
return pAttrList;
}
@@ -9008,24 +9454,24 @@ void DocxAttributeOutput::FormatSurround( const SwFormatSurround& rSurround )
}
else if ( m_rExport.m_bOutFlyFrameAttrs )
{
- OString sWrap( "auto" );
+ std::string_view sWrap;
switch ( rSurround.GetSurround( ) )
{
case css::text::WrapTextMode_NONE:
- sWrap = OString( "none" );
+ sWrap = "none";
break;
case css::text::WrapTextMode_THROUGH:
- sWrap = OString( "through" );
+ sWrap = "through";
break;
case css::text::WrapTextMode_DYNAMIC:
case css::text::WrapTextMode_PARALLEL:
case css::text::WrapTextMode_LEFT:
case css::text::WrapTextMode_RIGHT:
default:
- sWrap = OString( "around" );
+ sWrap = "around";
}
- AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_wrap ), sWrap.getStr() );
+ AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_wrap ), sWrap );
}
}
@@ -9047,11 +9493,11 @@ void DocxAttributeOutput::FormatVertOrientation( const SwFormatVertOrient& rFlyV
else if ( m_rExport.m_bOutFlyFrameAttrs )
{
if ( !sAlign.isEmpty() )
- AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_yAlign ), sAlign.getStr() );
+ AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_yAlign ), sAlign );
else
AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_y ),
- OString::number( rFlyVert.GetPos() ).getStr() );
- AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_vAnchor ), sVAnchor.getStr() );
+ OString::number( rFlyVert.GetPos() ) );
+ AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_vAnchor ), sVAnchor );
}
}
@@ -9073,11 +9519,11 @@ void DocxAttributeOutput::FormatHorizOrientation( const SwFormatHoriOrient& rFly
else if ( m_rExport.m_bOutFlyFrameAttrs )
{
if ( !sAlign.isEmpty() )
- AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_xAlign ), sAlign.getStr() );
+ AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_xAlign ), sAlign );
else
AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_x ),
- OString::number( rFlyHori.GetPos() ).getStr() );
- AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_hAnchor ), sHAnchor.getStr() );
+ OString::number( rFlyHori.GetPos() ) );
+ AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_hAnchor ), sHAnchor );
}
}
@@ -9106,6 +9552,7 @@ static std::optional<sal_Int32> lcl_getDmlAlpha(const SvxBrushItem& rBrush)
void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
{
const Color aColor = rBrush.GetColor();
+ model::ComplexColor const& rComplexColor = rBrush.getComplexColor();
OString sColor = msfilter::util::ConvertColor( aColor.GetRGBColor() );
std::optional<sal_Int32> oAlpha = lcl_getDmlAlpha(rBrush);
if (m_rExport.SdrExporter().getTextFrameSyntax())
@@ -9116,13 +9563,12 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
// Calculate opacity value
// Consider oox/source/vml/vmlformatting.cxx : decodeColor() function.
double fOpacity = static_cast<double>(*oAlpha) * 65535 / ::oox::drawingml::MAX_PERCENT;
- OUString sOpacity = OUString::number(fOpacity) + "f";
- AddToAttrList( m_rExport.SdrExporter().getFlyFillAttrList(), XML_opacity, OUStringToOString(sOpacity, RTL_TEXTENCODING_UTF8).getStr() );
+ AddToAttrList( m_rExport.SdrExporter().getFlyFillAttrList(), XML_opacity, OString::number(fOpacity) + "f" );
}
- sColor = "#" + sColor;
- AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), XML_fillcolor, sColor.getStr() );
+ AddToAttrList(m_rExport.SdrExporter().getFlyAttrList(), XML_fillcolor, "#" + sColor );
+ lclAddThemeFillColorAttributes(m_rExport.SdrExporter().getFlyAttrList(), rComplexColor);
}
else if (m_rExport.SdrExporter().getDMLTextFrameSyntax())
{
@@ -9154,7 +9600,7 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
m_sOriginalBackgroundColor, RTL_TEXTENCODING_UTF8 );
if ( aColor == COL_AUTO )
- sColor = "auto";
+ sColor = "auto"_ostr;
if( !m_pBackgroundAttrList.is() )
{
@@ -9189,59 +9635,74 @@ void DocxAttributeOutput::FormatFillGradient( const XFillGradientItem& rFillGrad
{
if (m_oFillStyle && *m_oFillStyle == drawing::FillStyle_GRADIENT && !m_rExport.SdrExporter().getDMLTextFrameSyntax())
{
- AddToAttrList( m_rExport.SdrExporter().getFlyFillAttrList(), XML_type, "gradient" );
-
- const XGradient& rGradient = rFillGradient.GetGradientValue();
- OString sStartColor = msfilter::util::ConvertColor(rGradient.GetStartColor());
- OString sEndColor = msfilter::util::ConvertColor(rGradient.GetEndColor());
-
- // Calculate the angle that was originally in the imported DOCX file
- // (reverse calculate the angle that was converted in the file
- // /oox/source/vml/vmlformatting.cxx :: FillModel::pushToPropMap
- // and also in
- // /oox/source/drawingml/fillproperties.cxx :: FillProperties::pushToPropMap
- sal_Int32 nReverseAngle = (4500_deg10 - rGradient.GetAngle()).get();
- nReverseAngle = nReverseAngle / 10;
- nReverseAngle = (270 - nReverseAngle) % 360;
- if (nReverseAngle != 0)
+ const basegfx::BGradient& rGradient = rFillGradient.GetGradientValue();
+ OString sStartColor = msfilter::util::ConvertColor(Color(rGradient.GetColorStops().front().getStopColor()));
+ OString sEndColor = msfilter::util::ConvertColor(Color(rGradient.GetColorStops().back().getStopColor()));
+
+ const sal_Int32 nAngle = toDegrees(rGradient.GetAngle());
+ if (nAngle != 0)
AddToAttrList( m_rExport.SdrExporter().getFlyFillAttrList(),
- XML_angle, OString::number( nReverseAngle ).getStr() );
+ XML_angle, OString::number(nAngle));
- OString sColor1 = sStartColor;
- OString sColor2 = sEndColor;
+ // LO does linear gradients top to bottom, while MSO does bottom to top.
+ // LO does axial gradients inner to outer, while MSO does outer to inner.
+ // Conclusion: swap start and end colors.
+ const OString sColor1 = sEndColor; // LO end color is MSO start color
+ OString sColor2 = sStartColor; // LO start color is MSO end color
switch (rGradient.GetGradientStyle())
{
case css::awt::GradientStyle_AXIAL:
- AddToAttrList( m_rExport.SdrExporter().getFlyFillAttrList(), XML_focus, "50%" );
- // If it is an 'axial' gradient - swap the colors
- // (because in the import process they were imported swapped)
- sColor1 = sEndColor;
- sColor2 = sStartColor;
+ case css::awt::GradientStyle_LINEAR:
+ {
+ bool bIsSymmetrical = rGradient.GetGradientStyle() == css::awt::GradientStyle_AXIAL;
+ if (!bIsSymmetrical)
+ {
+ const basegfx::BColorStops& rColorStops = rGradient.GetColorStops();
+ if (rColorStops.size() > 2 && rColorStops.isSymmetrical())
+ {
+ for (auto& rStop : rColorStops)
+ {
+ if (basegfx::fTools::less(rStop.getStopOffset(), 0.5))
+ continue;
+ if (basegfx::fTools::more(rStop.getStopOffset(), 0.5))
+ break;
+
+ // from MSO export perspective, the inner color is the end color
+ sColor2 = msfilter::util::ConvertColor(Color(rStop.getStopColor()));
+ bIsSymmetrical = true;
+ }
+ }
+ }
+
+ if (bIsSymmetrical)
+ AddToAttrList( m_rExport.SdrExporter().getFlyFillAttrList(), XML_focus, "50%" );
+
+ AddToAttrList(m_rExport.SdrExporter().getFlyFillAttrList(), XML_type, "gradient");
+ break;
+ }
+ case css::awt::GradientStyle_RADIAL:
+ case css::awt::GradientStyle_ELLIPTICAL:
+ case css::awt::GradientStyle_SQUARE:
+ case css::awt::GradientStyle_RECT:
+ AddToAttrList(m_rExport.SdrExporter().getFlyFillAttrList(), XML_type,
+ "gradientRadial");
break;
- case css::awt::GradientStyle_LINEAR: break;
- case css::awt::GradientStyle_RADIAL: break;
- case css::awt::GradientStyle_ELLIPTICAL: break;
- case css::awt::GradientStyle_SQUARE: break;
- case css::awt::GradientStyle_RECT: break;
default:
break;
}
- sColor1 = "#" + sColor1;
- sColor2 = "#" + sColor2;
- AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), XML_fillcolor, sColor1.getStr() );
- AddToAttrList( m_rExport.SdrExporter().getFlyFillAttrList(), XML_color2, sColor2.getStr() );
+ AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), XML_fillcolor, "#" + sColor1 );
+ AddToAttrList( m_rExport.SdrExporter().getFlyFillAttrList(), XML_color2, "#" + sColor2 );
}
else if (m_oFillStyle && *m_oFillStyle == drawing::FillStyle_GRADIENT && m_rExport.SdrExporter().getDMLTextFrameSyntax())
{
SwFrameFormat & rFormat(
const_cast<SwFrameFormat&>(m_rExport.m_pParentFrame->GetFrameFormat()));
- uno::Reference<beans::XPropertySet> const xPropertySet(
- SwXTextFrame::CreateXTextFrame(*rFormat.GetDoc(), &rFormat),
- uno::UNO_QUERY);
+ rtl::Reference<SwXTextFrame> const xPropertySet =
+ SwXTextFrame::CreateXTextFrame(*rFormat.GetDoc(), &rFormat);
m_rDrawingML.SetFS(m_pSerializer);
- m_rDrawingML.WriteGradientFill(xPropertySet);
+ m_rDrawingML.WriteGradientFill(uno::Reference<beans::XPropertySet>(static_cast<SwXFrame*>(xPropertySet.get())));
}
m_oFillStyle.reset();
}
@@ -9294,7 +9755,7 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox )
{
if (m_rExport.SdrExporter().getTextFrameSyntax())
{
- AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), 2,
+ AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(),
XML_stroked, "f", XML_strokeweight, "0pt" );
}
}
@@ -9305,12 +9766,10 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox )
if (m_rExport.SdrExporter().getTextFrameSyntax())
{
- sColor = "#" + sColor;
sal_Int32 nWidth = sal_Int32(fConverted / 20);
- OString sWidth = OString::number(nWidth) + "pt";
- AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), 2,
- XML_strokecolor, sColor.getStr(),
- XML_strokeweight, sWidth.getStr() );
+ AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(),
+ XML_strokecolor, "#" + sColor,
+ XML_strokeweight, OString::number(nWidth) + "pt" );
if( SvxBorderLineStyle::DASHED == pTop->GetBorderLineStyle() ) // Line Style is Dash type
AddToAttrList( m_rExport.SdrExporter().getDashLineStyle(),
XML_dashstyle, "dash" );
@@ -9347,19 +9806,19 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox )
// and so on.
OStringBuffer aInset;
if(!aInset.isEmpty() || fDistanceBottomInch != 0.05)
- aInset.insert(0, "," + OString::number(fDistanceBottomInch) + "in");
+ aInset.insert(0, Concat2View("," + OString::number(fDistanceBottomInch) + "in"));
if(!aInset.isEmpty() || fDistanceRightInch != 0.1)
- aInset.insert(0, "," + OString::number(fDistanceRightInch) + "in");
+ aInset.insert(0, Concat2View("," + OString::number(fDistanceRightInch) + "in"));
if(!aInset.isEmpty() || fDistanceTopInch != 0.05)
- aInset.insert(0, "," + OString::number(fDistanceTopInch) + "in");
+ aInset.insert(0, Concat2View("," + OString::number(fDistanceTopInch) + "in"));
if(!aInset.isEmpty() || fDistanceLeftInch != 0.1)
- aInset.insert(0, OString::number(fDistanceLeftInch) + "in");
+ aInset.insert(0, Concat2View(OString::number(fDistanceLeftInch) + "in"));
if (!aInset.isEmpty())
- m_rExport.SdrExporter().getTextboxAttrList()->add(XML_inset, aInset.makeStringAndClear());
+ m_rExport.SdrExporter().getTextboxAttrList()->add(XML_inset, aInset);
return;
}
@@ -9395,11 +9854,14 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox )
aStyleBorders[ SvxBoxItemLine::LEFT ] = SvxBoxItem::SvxLineToLine(pInherited->GetLeft(), false);
aStyleBorders[ SvxBoxItemLine::RIGHT ] = SvxBoxItem::SvxLineToLine(pInherited->GetRight(), false);
}
-
- impl_borders( m_pSerializer, rBox, aOutputBorderOptions, aStyleBorders );
+ bool bUseFrame = m_aFramePr.UseFrameBorders(!m_xTableWrt ? -1 : m_tableReference.m_nTableDepth);
+ impl_borders(m_pSerializer, rBox, aOutputBorderOptions, aStyleBorders,
+ bUseFrame ? m_aFramePr.Frame() : nullptr);
// Close the paragraph's borders tag
m_pSerializer->endElementNS( XML_w, XML_pBdr );
+
+ m_aFramePr.SetUseFrameBorders(false);
}
void DocxAttributeOutput::FormatColumns_Impl( sal_uInt16 nCols, const SwFormatCol& rCol, bool bEven, SwTwips nPageSize )
@@ -9407,15 +9869,13 @@ void DocxAttributeOutput::FormatColumns_Impl( sal_uInt16 nCols, const SwFormatCo
// Get the columns attributes
rtl::Reference<FastAttributeList> pColsAttrList = FastSerializerHelper::createAttrList();
- pColsAttrList->add( FSNS( XML_w, XML_num ),
- OString::number( nCols ). getStr( ) );
+ pColsAttrList->add( FSNS( XML_w, XML_num ), OString::number( nCols ) );
- const char* pEquals = "false";
+ std::string_view pEquals = "false";
if ( bEven )
{
sal_uInt16 nWidth = rCol.GetGutterWidth( true );
- pColsAttrList->add( FSNS( XML_w, XML_space ),
- OString::number( nWidth ).getStr( ) );
+ pColsAttrList->add( FSNS( XML_w, XML_space ), OString::number( nWidth ) );
pEquals = "true";
}
@@ -9436,15 +9896,13 @@ void DocxAttributeOutput::FormatColumns_Impl( sal_uInt16 nCols, const SwFormatCo
for ( sal_uInt16 n = 0; n < nCols; ++n )
{
rtl::Reference<FastAttributeList> pColAttrList = FastSerializerHelper::createAttrList();
- sal_uInt16 nWidth = rCol.CalcPrtColWidth( n, static_cast<sal_uInt16>(nPageSize) );
- pColAttrList->add( FSNS( XML_w, XML_w ),
- OString::number( nWidth ).getStr( ) );
+ sal_uInt16 nWidth = rCol.CalcPrtColWidth( n, o3tl::narrowing<sal_uInt16>(nPageSize) );
+ pColAttrList->add( FSNS( XML_w, XML_w ), OString::number( nWidth ) );
if ( n + 1 != nCols )
{
sal_uInt16 nSpacing = rColumns[n].GetRight( ) + rColumns[n + 1].GetLeft( );
- pColAttrList->add( FSNS( XML_w, XML_space ),
- OString::number( nSpacing ).getStr( ) );
+ pColAttrList->add( FSNS( XML_w, XML_space ), OString::number( nSpacing ) );
}
m_pSerializer->singleElementNS( XML_w, XML_col, pColAttrList );
@@ -9464,31 +9922,31 @@ void DocxAttributeOutput::FormatTextGrid( const SwTextGridItem& rGrid )
{
rtl::Reference<FastAttributeList> pGridAttrList = FastSerializerHelper::createAttrList();
- OString sGridType;
+ std::string_view sGridType;
switch ( rGrid.GetGridType( ) )
{
default:
case GRID_NONE:
- sGridType = OString( "default" );
+ sGridType = "default";
break;
case GRID_LINES_ONLY:
- sGridType = OString( "lines" );
+ sGridType = "lines";
break;
case GRID_LINES_CHARS:
if ( rGrid.IsSnapToChars( ) )
- sGridType = OString( "snapToChars" );
+ sGridType = "snapToChars";
else
- sGridType = OString( "linesAndChars" );
+ sGridType = "linesAndChars";
break;
}
pGridAttrList->add(FSNS(XML_w, XML_type), sGridType);
sal_uInt16 nHeight = rGrid.GetBaseHeight() + rGrid.GetRubyHeight();
pGridAttrList->add( FSNS( XML_w, XML_linePitch ),
- OString::number( nHeight ).getStr( ) );
+ OString::number( nHeight ) );
pGridAttrList->add( FSNS( XML_w, XML_charSpace ),
- OString::number( GridCharacterPitch( rGrid ) ).getStr( ) );
+ OString::number( GridCharacterPitch( rGrid ) ) );
m_pSerializer->singleElementNS( XML_w, XML_docGrid, pGridAttrList );
}
@@ -9497,6 +9955,8 @@ void DocxAttributeOutput::FormatLineNumbering( const SwFormatLineNumber& rNumber
{
if ( !rNumbering.IsCount( ) )
m_pSerializer->singleElementNS(XML_w, XML_suppressLineNumbers);
+ else
+ m_pSerializer->singleElementNS(XML_w, XML_suppressLineNumbers, FSNS(XML_w, XML_val), "0");
}
void DocxAttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDirection )
@@ -9512,15 +9972,23 @@ void DocxAttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDi
{
default:
case SvxFrameDirection::Horizontal_LR_TB:
- sTextFlow = OString( "lrTb" );
+ sTextFlow = "lrTb"_ostr;
break;
case SvxFrameDirection::Horizontal_RL_TB:
- sTextFlow = OString( "lrTb" );
+ sTextFlow = "lrTb"_ostr;
bBiDi = true;
break;
- case SvxFrameDirection::Vertical_LR_TB: // many things but not this one
- case SvxFrameDirection::Vertical_RL_TB:
- sTextFlow = OString( "tbRl" );
+ case SvxFrameDirection::Vertical_LR_TB: // ~ vert="mongolianVert"
+ sTextFlow = "tbLrV"_ostr;
+ break;
+ case SvxFrameDirection::Vertical_RL_TB: // ~ vert="eaVert"
+ sTextFlow = "tbRl"_ostr;
+ break;
+ case SvxFrameDirection::Vertical_LR_BT: // ~ vert="vert270"
+ sTextFlow = "btLr"_ostr;
+ break;
+ case SvxFrameDirection::Vertical_RL_TB90: // ~ vert="vert"
+ sTextFlow = "tbRlV"_ostr;
break;
}
@@ -9536,6 +10004,7 @@ void DocxAttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDi
m_pSerializer->singleElementNS(XML_w, XML_bidi, FSNS(XML_w, XML_val), "1");
else
m_pSerializer->singleElementNS(XML_w, XML_bidi, FSNS(XML_w, XML_val), "0");
+ m_aFramePr.SetUseFrameTextDirection(false);
}
}
@@ -9551,7 +10020,7 @@ void DocxAttributeOutput::ParaGrabBag(const SfxGrabBagItem& rItem)
m_bParaBeforeAutoSpacing = true;
// get fixed value which was set during import
rGrabBagElement.second >>= m_nParaBeforeSpacing;
- m_nParaBeforeSpacing = convertMm100ToTwip(m_nParaBeforeSpacing);
+ m_nParaBeforeSpacing = o3tl::toTwips(m_nParaBeforeSpacing, o3tl::Length::mm100);
SAL_INFO("sw.ww8", "DocxAttributeOutput::ParaGrabBag: property =" << rGrabBagElement.first << " : m_nParaBeforeSpacing= " << m_nParaBeforeSpacing);
}
else if (rGrabBagElement.first == "ParaBottomMarginAfterAutoSpacing")
@@ -9559,7 +10028,7 @@ void DocxAttributeOutput::ParaGrabBag(const SfxGrabBagItem& rItem)
m_bParaAfterAutoSpacing = true;
// get fixed value which was set during import
rGrabBagElement.second >>= m_nParaAfterSpacing;
- m_nParaAfterSpacing = convertMm100ToTwip(m_nParaAfterSpacing);
+ m_nParaAfterSpacing = o3tl::toTwips(m_nParaAfterSpacing, o3tl::Length::mm100);
SAL_INFO("sw.ww8", "DocxAttributeOutput::ParaGrabBag: property =" << rGrabBagElement.first << " : m_nParaBeforeSpacing= " << m_nParaAfterSpacing);
}
else if (rGrabBagElement.first == "CharThemeFill")
@@ -9567,31 +10036,31 @@ void DocxAttributeOutput::ParaGrabBag(const SfxGrabBagItem& rItem)
uno::Sequence<beans::PropertyValue> aGrabBagSeq;
rGrabBagElement.second >>= aGrabBagSeq;
- for (const auto& rProp : std::as_const(aGrabBagSeq))
+ for (const auto& rProp : aGrabBagSeq)
{
- OString sVal = OUStringToOString(rProp.Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
+ OUString sVal = rProp.Value.get<OUString>();
if (sVal.isEmpty())
continue;
if (rProp.Name == "val")
- AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_val), sVal.getStr());
+ AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_val), sVal);
else if (rProp.Name == "color")
- AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_color), sVal.getStr());
+ AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_color), sVal);
else if (rProp.Name == "themeColor")
- AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_themeColor), sVal.getStr());
+ AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_themeColor), sVal);
else if (rProp.Name == "themeTint")
- AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_themeTint), sVal.getStr());
+ AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_themeTint), sVal);
else if (rProp.Name == "themeShade")
- AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_themeShade), sVal.getStr());
+ AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_themeShade), sVal);
else if (rProp.Name == "fill")
- AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_fill), sVal.getStr());
+ AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_fill), sVal);
else if (rProp.Name == "themeFill")
- AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_themeFill), sVal.getStr());
+ AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_themeFill), sVal);
else if (rProp.Name == "themeFillTint")
- AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_themeFillTint), sVal.getStr());
+ AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_themeFillTint), sVal);
else if (rProp.Name == "themeFillShade")
- AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_themeFillShade), sVal.getStr());
+ AddToAttrList(m_pBackgroundAttrList, FSNS(XML_w, XML_themeFillShade), sVal);
else if (rProp.Name == "originalColor")
rProp.Value >>= m_sOriginalBackgroundColor;
}
@@ -9600,102 +10069,8 @@ void DocxAttributeOutput::ParaGrabBag(const SfxGrabBagItem& rItem)
{
const uno::Sequence<beans::PropertyValue> aGrabBagSdt =
rGrabBagElement.second.get< uno::Sequence<beans::PropertyValue> >();
- for (const beans::PropertyValue& aPropertyValue : aGrabBagSdt)
- {
- if (aPropertyValue.Name == "ooxml:CT_SdtPr_docPartObj" ||
- aPropertyValue.Name == "ooxml:CT_SdtPr_docPartList")
- {
- if (aPropertyValue.Name == "ooxml:CT_SdtPr_docPartObj")
- m_nParagraphSdtPrToken = FSNS( XML_w, XML_docPartObj );
- else if (aPropertyValue.Name == "ooxml:CT_SdtPr_docPartList")
- m_nParagraphSdtPrToken = FSNS( XML_w, XML_docPartList );
-
- uno::Sequence<beans::PropertyValue> aGrabBag;
- aPropertyValue.Value >>= aGrabBag;
- for (const auto& rProp : std::as_const(aGrabBag))
- {
- OUString sValue = rProp.Value.get<OUString>();
- if (rProp.Name == "ooxml:CT_SdtDocPart_docPartGallery")
- AddToAttrList( m_pParagraphSdtPrTokenChildren,
- FSNS( XML_w, XML_docPartGallery ),
- OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() );
- else if (rProp.Name == "ooxml:CT_SdtDocPart_docPartCategory")
- AddToAttrList( m_pParagraphSdtPrTokenChildren,
- FSNS( XML_w, XML_docPartCategory ),
- OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() );
- else if (rProp.Name == "ooxml:CT_SdtDocPart_docPartUnique")
- {
- if (sValue.isEmpty())
- sValue = "true";
- AddToAttrList( m_pParagraphSdtPrTokenChildren, FSNS( XML_w, XML_docPartUnique ),
- OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
- }
- }
- else if (aPropertyValue.Name == "ooxml:CT_SdtPr_equation")
- m_nParagraphSdtPrToken = FSNS( XML_w, XML_equation );
- else if (aPropertyValue.Name == "ooxml:CT_SdtPr_picture")
- m_nParagraphSdtPrToken = FSNS( XML_w, XML_picture );
- else if (aPropertyValue.Name == "ooxml:CT_SdtPr_citation")
- m_nParagraphSdtPrToken = FSNS( XML_w, XML_citation );
- else if (aPropertyValue.Name == "ooxml:CT_SdtPr_group")
- m_nParagraphSdtPrToken = FSNS( XML_w, XML_group );
- else if (aPropertyValue.Name == "ooxml:CT_SdtPr_text")
- m_nParagraphSdtPrToken = FSNS(XML_w, XML_text);
- else if (aPropertyValue.Name == "ooxml:CT_SdtPr_dataBinding" && !m_pParagraphSdtPrDataBindingAttrs.is())
- {
- uno::Sequence<beans::PropertyValue> aGrabBag;
- aPropertyValue.Value >>= aGrabBag;
- for (const auto& rProp : std::as_const(aGrabBag))
- {
- OUString sValue = rProp.Value.get<OUString>();
- if (rProp.Name == "ooxml:CT_DataBinding_prefixMappings")
- AddToAttrList( m_pParagraphSdtPrDataBindingAttrs,
- FSNS( XML_w, XML_prefixMappings ),
- OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() );
- else if (rProp.Name == "ooxml:CT_DataBinding_xpath")
- AddToAttrList( m_pParagraphSdtPrDataBindingAttrs,
- FSNS( XML_w, XML_xpath ),
- OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() );
- else if (rProp.Name == "ooxml:CT_DataBinding_storeItemID")
- AddToAttrList( m_pParagraphSdtPrDataBindingAttrs,
- FSNS( XML_w, XML_storeItemID ),
- OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
- }
- else if (aPropertyValue.Name == "ooxml:CT_SdtPr_alias" && m_aParagraphSdtPrAlias.isEmpty())
- {
- if (!(aPropertyValue.Value >>= m_aParagraphSdtPrAlias))
- SAL_WARN("sw.ww8", "DocxAttributeOutput::ParaGrabBag: unexpected sdt alias value");
- m_aStartedParagraphSdtPrAlias = m_aParagraphSdtPrAlias;
- }
- else if (aPropertyValue.Name == "ooxml:CT_SdtPr_checkbox")
- {
- m_nParagraphSdtPrToken = FSNS( XML_w14, XML_checkbox );
- uno::Sequence<beans::PropertyValue> aGrabBag;
- aPropertyValue.Value >>= aGrabBag;
- for (const auto& rProp : std::as_const(aGrabBag))
- {
- OUString sValue = rProp.Value.get<OUString>();
- if (rProp.Name == "ooxml:CT_SdtCheckbox_checked")
- AddToAttrList( m_pParagraphSdtPrTokenChildren,
- FSNS( XML_w14, XML_checked ),
- OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() );
- else if (rProp.Name == "ooxml:CT_SdtCheckbox_checkedState")
- AddToAttrList( m_pParagraphSdtPrTokenChildren,
- FSNS( XML_w14, XML_checkedState ),
- OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() );
- else if (rProp.Name == "ooxml:CT_SdtCheckbox_uncheckedState")
- AddToAttrList( m_pParagraphSdtPrTokenChildren,
- FSNS( XML_w14, XML_uncheckedState ),
- OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
- }
- else if (aPropertyValue.Name == "ooxml:CT_SdtPr_id")
- m_bParagraphSdtHasId = true;
- else
- SAL_WARN("sw.ww8", "DocxAttributeOutput::ParaGrabBag: unhandled SdtPr grab bag property " << aPropertyValue.Name);
- }
+ m_aParagraphSdt.GetSdtParamsFromGrabBag(aGrabBagSdt);
+ m_aStartedParagraphSdtPrAlias = m_aParagraphSdt.m_aAlias;
}
else if (rGrabBagElement.first == "ParaCnfStyle")
{
@@ -9722,7 +10097,6 @@ void DocxAttributeOutput::CharGrabBag( const SfxGrabBagItem& rItem )
bool bWriteCSTheme = true;
bool bWriteAsciiTheme = true;
bool bWriteEastAsiaTheme = true;
- bool bWriteThemeFontColor = true;
OUString sOriginalValue;
for ( const auto & rGrabBagElement : rMap )
{
@@ -9744,12 +10118,6 @@ void DocxAttributeOutput::CharGrabBag( const SfxGrabBagItem& rItem )
bWriteEastAsiaTheme =
( m_pFontsAttrList->getOptionalValue( FSNS( XML_w, XML_eastAsia ) ) == sOriginalValue );
}
- else if ( m_pColorAttrList.is() && rGrabBagElement.first == "CharThemeOriginalColor" )
- {
- if ( rGrabBagElement.second >>= sOriginalValue )
- bWriteThemeFontColor =
- ( m_pColorAttrList->getOptionalValue( FSNS( XML_w, XML_val ) ) == sOriginalValue );
- }
}
// save theme attributes back to the run properties
@@ -9759,46 +10127,24 @@ void DocxAttributeOutput::CharGrabBag( const SfxGrabBagItem& rItem )
if ( rGrabBagElement.first == "CharThemeNameAscii" && bWriteAsciiTheme )
{
rGrabBagElement.second >>= str;
- AddToAttrList( m_pFontsAttrList, FSNS( XML_w, XML_asciiTheme ),
- OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() );
+ AddToAttrList( m_pFontsAttrList, FSNS( XML_w, XML_asciiTheme ), str );
}
else if ( rGrabBagElement.first == "CharThemeNameCs" && bWriteCSTheme )
{
rGrabBagElement.second >>= str;
- AddToAttrList( m_pFontsAttrList, FSNS( XML_w, XML_cstheme ),
- OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() );
+ AddToAttrList( m_pFontsAttrList, FSNS( XML_w, XML_cstheme ), str );
}
else if ( rGrabBagElement.first == "CharThemeNameEastAsia" && bWriteEastAsiaTheme )
{
rGrabBagElement.second >>= str;
- AddToAttrList( m_pFontsAttrList, FSNS( XML_w, XML_eastAsiaTheme ),
- OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() );
+ AddToAttrList( m_pFontsAttrList, FSNS( XML_w, XML_eastAsiaTheme ), str );
}
else if ( rGrabBagElement.first == "CharThemeNameHAnsi" && bWriteAsciiTheme )
// this is not a mistake: in LibO we don't directly support the hAnsi family
// of attributes so we save the same value from ascii attributes instead
{
rGrabBagElement.second >>= str;
- AddToAttrList( m_pFontsAttrList, FSNS( XML_w, XML_hAnsiTheme ),
- OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
- else if ( rGrabBagElement.first == "CharThemeColor" && bWriteThemeFontColor )
- {
- rGrabBagElement.second >>= str;
- AddToAttrList( m_pColorAttrList, FSNS( XML_w, XML_themeColor ),
- OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
- else if ( rGrabBagElement.first == "CharThemeColorShade" )
- {
- rGrabBagElement.second >>= str;
- AddToAttrList( m_pColorAttrList, FSNS( XML_w, XML_themeShade ),
- OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
- else if ( rGrabBagElement.first == "CharThemeColorTint" )
- {
- rGrabBagElement.second >>= str;
- AddToAttrList( m_pColorAttrList, FSNS( XML_w, XML_themeTint ),
- OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() );
+ AddToAttrList( m_pFontsAttrList, FSNS( XML_w, XML_hAnsiTheme ), str );
}
else if( rGrabBagElement.first == "CharThemeFontNameCs" ||
rGrabBagElement.first == "CharThemeFontNameAscii" ||
@@ -9826,72 +10172,14 @@ void DocxAttributeOutput::CharGrabBag( const SfxGrabBagItem& rItem )
}
else if (rGrabBagElement.first == "SdtEndBefore")
{
- if (m_bStartedCharSdt)
+ if (m_aRunSdt.m_bStartedSdt)
m_bEndCharSdt = true;
}
else if (rGrabBagElement.first == "SdtPr" && FLY_NOT_PROCESSED != m_nStateOfFlyFrame )
{
const uno::Sequence<beans::PropertyValue> aGrabBagSdt =
rGrabBagElement.second.get< uno::Sequence<beans::PropertyValue> >();
- for (const beans::PropertyValue& aPropertyValue : aGrabBagSdt)
- {
- if (aPropertyValue.Name == "ooxml:CT_SdtPr_checkbox")
- {
- m_nRunSdtPrToken = FSNS( XML_w14, XML_checkbox );
- uno::Sequence<beans::PropertyValue> aGrabBag;
- aPropertyValue.Value >>= aGrabBag;
- for (const auto& rProp : std::as_const(aGrabBag))
- {
- OUString sValue = rProp.Value.get<OUString>();
- if (rProp.Name == "ooxml:CT_SdtCheckbox_checked")
- AddToAttrList( m_pRunSdtPrTokenChildren,
- FSNS( XML_w14, XML_checked ),
- OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() );
- else if (rProp.Name == "ooxml:CT_SdtCheckbox_checkedState")
- AddToAttrList( m_pRunSdtPrTokenChildren,
- FSNS( XML_w14, XML_checkedState ),
- OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() );
- else if (rProp.Name == "ooxml:CT_SdtCheckbox_uncheckedState")
- AddToAttrList( m_pRunSdtPrTokenChildren,
- FSNS( XML_w14, XML_uncheckedState ),
- OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
- }
- else if (aPropertyValue.Name == "ooxml:CT_SdtPr_dataBinding" && !m_pRunSdtPrDataBindingAttrs.is())
- {
- uno::Sequence<beans::PropertyValue> aGrabBag;
- aPropertyValue.Value >>= aGrabBag;
- for (const auto& rProp : std::as_const(aGrabBag))
- {
- OUString sValue = rProp.Value.get<OUString>();
- if (rProp.Name == "ooxml:CT_DataBinding_prefixMappings")
- AddToAttrList( m_pRunSdtPrDataBindingAttrs,
- FSNS( XML_w, XML_prefixMappings ),
- OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() );
- else if (rProp.Name == "ooxml:CT_DataBinding_xpath")
- AddToAttrList( m_pRunSdtPrDataBindingAttrs,
- FSNS( XML_w, XML_xpath ),
- OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() );
- else if (rProp.Name == "ooxml:CT_DataBinding_storeItemID")
- AddToAttrList( m_pRunSdtPrDataBindingAttrs,
- FSNS( XML_w, XML_storeItemID ),
- OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
- }
- else if (aPropertyValue.Name == "ooxml:CT_SdtPr_alias" && m_aRunSdtPrAlias.isEmpty())
- {
- if (!(aPropertyValue.Value >>= m_aRunSdtPrAlias))
- SAL_WARN("sw.ww8", "DocxAttributeOutput::CharGrabBag: unexpected sdt alias value");
- }
- //do not overwrite the parent node.
- else if (aPropertyValue.Name == "ooxml:CT_SdtPr_text" && !m_pRunSdtPrTokenChildren.is())
- m_nRunSdtPrToken = FSNS( XML_w, XML_text );
- else if (aPropertyValue.Name == "ooxml:CT_SdtPr_id" && m_nRunSdtPrToken == 0)
- // only write id token as a marker if no other exist
- m_nRunSdtPrToken = FSNS( XML_w, XML_id );
- else if (aPropertyValue.Name == "ooxml:CT_SdtPr_citation")
- m_nRunSdtPrToken = FSNS( XML_w, XML_citation );
- }
+ m_aRunSdt.GetSdtParamsFromGrabBag(aGrabBagSdt);
}
else
SAL_INFO("sw.ww8", "DocxAttributeOutput::CharGrabBag: unhandled grab bag property " << rGrabBagElement.first);
@@ -9904,13 +10192,10 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, const FSHelperPtr
m_pSerializer( pSerializer ),
m_rDrawingML( *pDrawingML ),
m_bEndCharSdt(false),
- m_bStartedCharSdt(false),
- m_bStartedParaSdt(false),
m_endPageRef( false ),
m_pFootnotesList( new ::docx::FootnotesList() ),
m_pEndnotesList( new ::docx::FootnotesList() ),
m_footnoteEndnoteRefTag( 0 ),
- m_footnoteCustomLabel(),
m_pRedlineData( nullptr ),
m_nRedlineId( 0 ),
m_bOpenedSectPr( false ),
@@ -9920,10 +10205,10 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, const FSHelperPtr
m_bAnchorLinkedToNode(false),
m_bWritingField( false ),
m_bPreventDoubleFieldsHandling( false ),
- m_sFieldBkm( ),
m_nNextBookmarkId( 0 ),
m_nNextAnnotationMarkId( 0 ),
- m_pCurrentFrame( nullptr ),
+ m_nEmbedFlyLevel(0),
+ m_pMoveRedlineData(nullptr),
m_bParagraphOpened( false ),
m_bParagraphFrameOpen( false ),
m_bIsFirstParagraph( true ),
@@ -9934,31 +10219,22 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, const FSHelperPtr
m_nTextFrameLevel( 0 ),
m_closeHyperlinkInThisRun( false ),
m_closeHyperlinkInPreviousRun( false ),
- m_startedHyperlink( false ),
- m_nHyperLinkCount(0),
m_nFieldsInHyperlink( 0 ),
m_bExportingOutline(false),
m_nChartCount(0),
- pendingPlaceholder( nullptr ),
+ m_PendingPlaceholder( nullptr ),
m_postitFieldsMaxId( 0 ),
m_anchorId( 1 ),
m_nextFontId( 1 ),
- m_tableReference(new TableReference()),
m_bIgnoreNextFill(false),
m_pTableStyleExport(std::make_shared<DocxTableStyleExport>(rExport.m_rDoc, pSerializer)),
m_bParaBeforeAutoSpacing(false),
m_bParaAfterAutoSpacing(false),
m_nParaBeforeSpacing(0),
m_nParaAfterSpacing(0)
- , m_nParagraphSdtPrToken(0)
- , m_nRunSdtPrToken(0)
, m_nStateOfFlyFrame( FLY_NOT_PROCESSED )
- , m_bParagraphSdtHasId(false)
{
- // Push initial items to the RelId cache. In case the document contains no
- // special streams (headers, footers, etc.) then these items are used
- // during the full export.
- PushRelIdCache();
+ m_nHyperLinkCount.push_back(0);
}
DocxAttributeOutput::~DocxAttributeOutput()
@@ -9996,18 +10272,17 @@ void DocxAttributeOutput::BulletDefinition(int nId, const Graphic& rGraphic, Siz
m_pSerializer->startElementNS(XML_w, XML_numPicBullet,
FSNS(XML_w, XML_numPicBulletId), OString::number(nId));
- OStringBuffer aStyle;
// Size is in twips, we need it in points.
- aStyle.append("width:" + OString::number(double(aSize.Width()) / 20));
- aStyle.append("pt;height:" + OString::number(double(aSize.Height()) / 20) + "pt");
+ OString aStyle = "width:" + OString::number(double(aSize.Width()) / 20)+ "pt;"
+ "height:" + OString::number(double(aSize.Height()) / 20) + "pt";
m_pSerializer->startElementNS(XML_w, XML_pict);
m_pSerializer->startElementNS( XML_v, XML_shape,
- XML_style, aStyle.getStr(),
+ XML_style, aStyle,
FSNS(XML_o, XML_bullet), "t");
- OUString aRelId = m_rDrawingML.WriteImage(rGraphic);
+ OUString aRelId = m_rDrawingML.writeGraphicToStorage(rGraphic);
m_pSerializer->singleElementNS( XML_v, XML_imagedata,
- FSNS(XML_r, XML_id), OUStringToOString(aRelId, RTL_TEXTENCODING_UTF8),
+ FSNS(XML_r, XML_id), aRelId,
FSNS(XML_o, XML_title), "");
m_pSerializer->endElementNS(XML_v, XML_shape);
@@ -10016,26 +10291,4 @@ void DocxAttributeOutput::BulletDefinition(int nId, const Graphic& rGraphic, Siz
m_pSerializer->endElementNS(XML_w, XML_numPicBullet);
}
-void DocxAttributeOutput::AddToAttrList( rtl::Reference<sax_fastparser::FastAttributeList>& pAttrList, sal_Int32 nAttrName, const char* sAttrValue )
-{
- AddToAttrList( pAttrList, 1, nAttrName, sAttrValue );
-}
-
-void DocxAttributeOutput::AddToAttrList( rtl::Reference<sax_fastparser::FastAttributeList>& pAttrList, sal_Int32 nAttrs, ... )
-{
- if( !pAttrList.is() )
- pAttrList = FastSerializerHelper::createAttrList();
-
- va_list args;
- va_start( args, nAttrs );
- for( sal_Int32 i = 0; i<nAttrs; i++)
- {
- sal_Int32 nName = va_arg( args, sal_Int32 );
- const char* pValue = va_arg( args, const char* );
- if( pValue )
- pAttrList->add( nName, pValue );
- }
- va_end( args );
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index b0688183ab69..b1da698c3dec 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -28,6 +28,7 @@
#include <IMark.hxx>
#include "docxexport.hxx"
#include <wrtswtbl.hxx>
+#include <redline.hxx>
#include <editeng/boxitem.hxx>
#include <sax/fshelper.hxx>
@@ -50,6 +51,8 @@
class SwGrfNode;
class SdrObject;
enum class SvxBoxItemLine;
+enum class SwLineBreakClear;
+class SwContentControl;
namespace docx { class FootnotesList; }
namespace oox::drawingml { class DrawingML; }
@@ -110,17 +113,89 @@ struct TableReference
/// If paragraph sdt got opened in this table cell.
bool m_bTableCellParaSdtOpen;
+ /// Remember if we are in a deleted/inserted cell, or not.
+ bool m_bTableCellChanged;
+
/// Remember the current table depth.
sal_uInt32 m_nTableDepth;
TableReference()
: m_bTableCellOpen(false),
m_bTableCellParaSdtOpen(false),
+ m_bTableCellChanged(false),
m_nTableDepth(0)
{
}
};
+/** Using framePr, a paragraph can be enclosed in a frame described by its pPr paragraph settings,
+ * and therefore it needs to apply the frame's properties when exporting the paragraph properties.
+ */
+class FramePrHelper
+{
+ ww8::Frame* m_pFrame;
+ sal_Int32 m_nTableDepth;
+ bool m_bUseFrameBorders;
+ bool m_bUseFrameBackground;
+ bool m_bUseFrameTextDirection;
+
+public:
+ FramePrHelper()
+ : m_pFrame(nullptr)
+ , m_nTableDepth(0)
+ , m_bUseFrameBorders(true)
+ , m_bUseFrameBackground(true)
+ , m_bUseFrameTextDirection(true)
+ {}
+
+ ww8::Frame* Frame() { return m_pFrame; }
+ void SetFrame(ww8::Frame* pSet, sal_Int32 nTableDepth = -1);
+ bool UseFrameBorders(sal_Int32 nTableDepth);
+ void SetUseFrameBorders(bool bSet) { m_bUseFrameBorders = bSet; }
+ bool UseFrameBackground();
+ void SetUseFrameBackground(bool bSet) { m_bUseFrameBackground = bSet; }
+ bool UseFrameTextDirection(sal_Int32 nTableDepth);
+ void SetUseFrameTextDirection(bool bSet) { m_bUseFrameTextDirection = bSet; }
+};
+
+class SdtBlockHelper
+{
+public:
+ SdtBlockHelper()
+ : m_nId(0)
+ , m_bStartedSdt(false)
+ , m_bShowingPlaceHolder(false)
+ , m_nTabIndex(0)
+ , m_nSdtPrToken(0)
+ {}
+
+ sal_Int32 m_nId;
+ bool m_bStartedSdt;
+ rtl::Reference<sax_fastparser::FastAttributeList> m_pTokenChildren;
+ rtl::Reference<sax_fastparser::FastAttributeList> m_pTokenAttributes;
+ rtl::Reference<sax_fastparser::FastAttributeList> m_pTextAttrs;
+ rtl::Reference<sax_fastparser::FastAttributeList> m_pDataBindingAttrs;
+ OUString m_aColor;
+ OUString m_aAppearance;
+ OUString m_aPlaceHolderDocPart;
+ bool m_bShowingPlaceHolder;
+ OUString m_aAlias;
+ OUString m_aTag;
+ sal_Int32 m_nTabIndex;
+ OUString m_aLock;
+ sal_Int32 m_nSdtPrToken;
+
+ void DeleteAndResetTheLists();
+
+ void WriteSdtBlock(const ::sax_fastparser::FSHelperPtr& pSerializer, bool bRunTextIsOn, bool bParagraphHasDrawing);
+ void WriteExtraParams(const ::sax_fastparser::FSHelperPtr& pSerializer);
+
+ /// Closes a currently open SDT block.
+ void EndSdtBlock(const ::sax_fastparser::FSHelperPtr& pSerializer);
+
+ void GetSdtParamsFromGrabBag(const uno::Sequence<beans::PropertyValue>& aGrabBagSdt);
+};
+
/// The class that has handlers for various resource types when exporting as DOCX.
class DocxAttributeOutput : public AttributeOutputBase, public oox::vml::VMLTextExport, public oox::drawingml::DMLTextExport
{
@@ -151,7 +226,7 @@ public:
virtual void StartRun( const SwRedlineData* pRedlineData, sal_Int32 nPos, bool bSingleEmptyRun = false ) override;
/// End of the text run.
- virtual void EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool bLastRun = false) override;
+ virtual void EndRun(const SwTextNode* pNode, sal_Int32 nPos, sal_Int32 nLen, bool bLastRun = false) override;
/// Called before we start outputting the attributes.
virtual void StartRunProperties() override;
@@ -166,7 +241,7 @@ public:
virtual void WritePostitFieldReference() override;
/// Output text (inside a run).
- virtual void RunText( const OUString& rText, rtl_TextEncoding eCharSet = RTL_TEXTENCODING_UTF8 ) override;
+ virtual void RunText( const OUString& rText, rtl_TextEncoding eCharSet = RTL_TEXTENCODING_UTF8, const OUString& rSymbolFont = OUString() ) override;
/// Output text (without markup).
virtual void RawText(const OUString& rText, rtl_TextEncoding eCharSet) override;
@@ -194,12 +269,12 @@ public:
///
/// Start of the tag that encloses the run, fills the info according to
/// the value of pRedlineData.
- void StartRedline( const SwRedlineData * pRedlineData );
+ void StartRedline( const SwRedlineData * pRedlineData, bool bLastRun );
/// Output redlining.
///
/// End of the tag that encloses the run.
- void EndRedline( const SwRedlineData * pRedlineData );
+ void EndRedline( const SwRedlineData * pRedlineData, bool bLastRun );
virtual void SetStateOfFlyFrame( FlyProcessingState nStateOfFlyFrame ) override;
virtual void SetAnchorIsLinkedToNode( bool bAnchorLinkedToNode ) override;
@@ -211,21 +286,21 @@ public:
/// Output style.
virtual void ParagraphStyle( sal_uInt16 nStyle ) override;
- virtual void TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
- virtual void TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
- virtual void TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
- virtual void TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
- void TableDefaultCellMargins( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner );
- virtual void TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
- virtual void TableRowRedline( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
- virtual void TableCellRedline( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
- virtual void TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
- virtual void TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
- virtual void TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
- virtual void TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
- virtual void TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner ) override;
- virtual void TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
- virtual void TableSpacing( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
+ virtual void TableInfoCell( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) override;
+ virtual void TableInfoRow( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) override;
+ virtual void TableDefinition( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) override;
+ virtual void TableDefaultBorders( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) override;
+ void TableDefaultCellMargins( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner );
+ virtual void TableBackgrounds( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) override;
+ virtual void TableRowRedline( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) override;
+ virtual void TableCellRedline( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) override;
+ virtual void TableHeight( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) override;
+ virtual void TableCanSplit( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) override;
+ virtual void TableBidi( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) override;
+ virtual void TableVerticalCell( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) override;
+ virtual void TableNodeInfoInner( const ww8::WW8TableNodeInfoInner::Pointer_t& pNodeInfoInner ) override;
+ virtual void TableOrientation( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) override;
+ virtual void TableSpacing( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) override;
virtual void TableRowEnd( sal_uInt32 nDepth ) override;
/// Start of the styles table.
@@ -252,7 +327,7 @@ public:
/// Start of a style in the styles table.
virtual void StartStyle( const OUString& rName, StyleType eType,
- sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 nWwId, sal_uInt16 nId,
+ sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 nLink, sal_uInt16 nWwId, sal_uInt16 nSlot,
bool bAutoUpdate ) override;
/// End of a style in the styles table.
@@ -355,17 +430,17 @@ public:
sal_Int16 nFirstLineIndex,
sal_Int16 nListTabPos,
const OUString &rNumberingString,
- const SvxBrushItem* pBrush ) override;
+ const SvxBrushItem* pBrush,
+ bool isLegal ) override;
void WriteField_Impl(const SwField* pField, ww::eField eType,
const OUString& rFieldCmd, FieldFlags nMode,
OUString const* pBookmarkName = nullptr);
void WriteFormData_Impl( const ::sw::mark::IFieldmark& rFieldmark );
- void WriteBookmarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds );
+ void WriteBookmarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds, const SwRedlineData* pRedlineData = nullptr );
void WriteFinalBookmarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds );
void WriteAnnotationMarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds );
- void PushRelIdCache();
/// End possibly opened paragraph sdt block.
void EndParaSdtBlock();
@@ -413,7 +488,7 @@ private:
void PostponeOLE( SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat );
void WriteOLE( SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* rFlyFrameFormat );
void WriteOLEShape(const SwFlyFrameFormat& rFrameFormat, const Size& rSize,
- const OString& rShapeId, const OUString& rImageId);
+ std::string_view rShapeId, const OUString& rImageId);
static OString GetOLEStyle(const SwFlyFrameFormat& rFormat, const Size& rSize);
void ExportOLESurround(const SwFormatSurround& rWrap);
@@ -437,11 +512,11 @@ private:
void WriteFFData( const FieldInfos& rInfos );
void WritePendingPlaceholder();
- void EmbedFontStyle( std::u16string_view name, int tag, FontFamily family, FontItalic italic, FontWeight weight,
+ bool EmbedFontStyle( std::u16string_view name, int tag, FontFamily family, FontItalic italic, FontWeight weight,
FontPitch pitch );
/**
- * Translate an ico value to the corresponding HighlightColorValues enumaration item
+ * Translate an ico value to the corresponding HighlightColorValues enumeration item
*
* @param[in] nIco ico value [0..16]
* @return color name (e.g. "red"), if color is inside [1..16] range
@@ -615,6 +690,13 @@ protected:
/// Sfx item RES_PAPER_BIN
virtual void FormatPaperBin( const SvxPaperBinItem& ) override;
+ /// Sfx item RES_MARGIN_FIRSTLINE
+ virtual void FormatFirstLineIndent(const SvxFirstLineIndentItem & rFirstLine) override;
+ /// Sfx item RES_MARGIN_TEXTLEFT
+ virtual void FormatTextLeftMargin(const SvxTextLeftMarginItem & rTextLeftMargin) override;
+ /// Sfx item RES_MARGIN_RIGHT
+ virtual void FormatRightMargin(const SvxRightMarginItem & rRightMargin) override;
+
/// Sfx item RES_LR_SPACE
virtual void FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) override;
@@ -685,26 +767,25 @@ protected:
void SectionRtlGutter( const SfxBoolItem& rRtlGutter) override;
- /// Reference to the export, where to get the data from
- DocxExport &m_rExport;
-
- /// Fast serializer to output the data
- ::sax_fastparser::FSHelperPtr m_pSerializer;
+ void TextLineBreak(const SwFormatLineBreak& rLineBreak) override;
- /// DrawingML access
- oox::drawingml::DrawingML &m_rDrawingML;
+ /// Writes a clearing line break at the end of run properties, if there are any.
+ void WriteLineBreak();
private:
- void DoWriteBookmarkTagStart(const OUString & bookmarkName);
+ void DoWriteBookmarkTagStart(const OUString& bookmarkName);
void DoWriteBookmarkTagEnd(sal_Int32 nId);
- void DoWriteBookmarksStart(std::vector<OUString>& rStarts);
+ void DoWriteMoveRangeTagStart(std::u16string_view bookmarkName,
+ bool bFrom, const SwRedlineData* pRedlineData);
+ void DoWriteMoveRangeTagEnd(sal_Int32 nId, bool bFrom);
+ void DoWriteBookmarksStart(std::vector<OUString>& rStarts, const SwRedlineData* pRedlineData = nullptr);
void DoWriteBookmarksEnd(std::vector<OUString>& rEnds);
void DoWriteBookmarkStartIfExist(sal_Int32 nRunPos);
void DoWriteBookmarkEndIfExist(sal_Int32 nRunPos);
- void DoWritePermissionTagStart(const OUString & permission);
- void DoWritePermissionTagEnd(const OUString & permission);
+ void DoWritePermissionTagStart(std::u16string_view permission);
+ void DoWritePermissionTagEnd(std::u16string_view permission);
void DoWritePermissionsStart();
void DoWritePermissionsEnd();
@@ -718,43 +799,41 @@ private:
void WritePostponedOLE();
void WritePostponedDMLDrawing();
void WritePostponedCustomShape();
+ void WriteFlyFrame(const ww8::Frame& rFrame);
- void WriteSdtBlock(sal_Int32& nSdtPrToken,
- rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrTokenChildren,
- rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrTokenAttributes,
- rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrDataBindingAttrs,
- OUString& rSdtPrAlias,
- bool bPara);
- /// Closes a currently open SDT block.
- void EndSdtBlock();
-
- void WriteFormDateStart(const OUString& sFullDate, const OUString& sDateFormat, const OUString& sLang);
- void WriteSdtDropDownStart(std::u16string_view rName, OUString const& rSelected, uno::Sequence<OUString> const& rListItems);
+ void WriteFormDateStart(const OUString& sFullDate, const OUString& sDateFormat, const OUString& sLang, const uno::Sequence<beans::PropertyValue>& aGrabBagSdt);
+ void WriteSdtPlainText(const OUString& sValue, const uno::Sequence<beans::PropertyValue>& aGrabBagSdt);
+ void WriteSdtDropDownStart(const OUString& rName, OUString const& rSelected, uno::Sequence<OUString> const& rListItems);
void WriteSdtDropDownEnd(OUString const& rSelected, uno::Sequence<OUString> const& rListItems);
- void WriteSdtEnd();
+ void WriteContentControlStart();
+ void WriteContentControlEnd();
void StartField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun = false );
- void DoWriteCmd( const OUString& rCmd );
+ void DoWriteCmd( std::u16string_view rCmd );
void CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun );
void CmdEndField_Impl( const SwTextNode* pNode, sal_Int32 nPos, bool bWriteRun );
void EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos& rInfos );
void DoWriteFieldRunProperties( const SwTextNode* pNode, sal_Int32 nPos, bool bWriteCombChars = false );
- static void AddToAttrList( rtl::Reference<sax_fastparser::FastAttributeList>& pAttrList, sal_Int32 nAttrName, const char* sAttrValue );
- static void AddToAttrList( rtl::Reference<sax_fastparser::FastAttributeList>& pAttrList, sal_Int32 nArgs, ... );
+ /// Reference to the export, where to get the data from
+ DocxExport &m_rExport;
+
+ /// Fast serializer to output the data
+ ::sax_fastparser::FSHelperPtr m_pSerializer;
+
+ /// DrawingML access
+ oox::drawingml::DrawingML &m_rDrawingML;
rtl::Reference<sax_fastparser::FastAttributeList> m_pFontsAttrList;
rtl::Reference<sax_fastparser::FastAttributeList> m_pEastAsianLayoutAttrList;
rtl::Reference<sax_fastparser::FastAttributeList> m_pCharLangAttrList;
rtl::Reference<sax_fastparser::FastAttributeList> m_pSectionSpacingAttrList;
+ rtl::Reference<sax_fastparser::FastAttributeList> m_pLRSpaceAttrList;
rtl::Reference<sax_fastparser::FastAttributeList> m_pParagraphSpacingAttrList;
rtl::Reference<sax_fastparser::FastAttributeList> m_pHyperlinkAttrList;
+ std::shared_ptr<SwContentControl> m_pContentControl;
/// If the current SDT around runs should be ended before the current run.
bool m_bEndCharSdt;
- /// If an SDT around runs is currently open.
- bool m_bStartedCharSdt;
- /// If an SDT around paragraphs is currently open.
- bool m_bStartedParaSdt;
/// Attributes of the run color
rtl::Reference<sax_fastparser::FastAttributeList> m_pColorAttrList;
sal_uInt8 m_nCharTransparence = 0;
@@ -802,9 +881,18 @@ private:
OUString m_sRawText;
+ /// The first frame (anchored to the main text) is 0.
+ /// The second frame what is anchored to the previous in, is 1
+ /// The third anchored inside the second is the 2 etc.
+ sal_uInt32 m_nEmbedFlyLevel;
+
+ /// Stores the flys what are anchored inside a fly
+ std::vector<ww8::Frame> m_vPostponedFlys;
+
/// Bookmarks to output
std::vector<OUString> m_rBookmarksStart;
std::vector<OUString> m_rBookmarksEnd;
+ SwRedlineData* m_pMoveRedlineData;
/// Bookmarks to output at the end
std::vector<OUString> m_rFinalBookmarksStart;
@@ -819,24 +907,27 @@ private:
std::vector<OUString> m_rPermissionsEnd;
/// Annotation marks to output
- std::vector<OString> m_rAnnotationMarksStart;
- std::vector<OString> m_rAnnotationMarksEnd;
+ std::vector<OUString> m_rAnnotationMarksStart;
+ std::vector<OUString> m_rAnnotationMarksEnd;
/// Maps of the bookmarks ids
std::map<OUString, sal_Int32> m_rOpenedBookmarksIds;
/// Name of the last opened bookmark.
- OString m_sLastOpenedBookmark;
+ OUString m_sLastOpenedBookmark;
+
+ /// Set of ids of the saved bookmarks (used only for moveRange, yet)
+ std::unordered_set<sal_Int32> m_rSavedBookmarksIds;
/// Maps of the annotation marks ids
- std::map<OString, sal_Int32> m_rOpenedAnnotationMarksIds;
+ std::map<OUString, sal_Int32> m_rOpenedAnnotationMarksIds;
/// Name of the last opened annotation mark.
- OString m_sLastOpenedAnnotationMark;
+ OUString m_sLastOpenedAnnotationMark;
/// If there are bookmarks around sequence fields, this map contains the
/// names of these bookmarks for each sequence.
- std::map<OUString, std::vector<OString> > m_aSeqBookmarksNames;
+ std::map<OUString, std::vector<OUString> > m_aSeqBookmarksNames;
/// GrabBag for text effects like glow, shadow, ...
std::vector<css::beans::PropertyValue> m_aTextEffectsGrabBag;
@@ -844,7 +935,7 @@ private:
/// The current table helper
std::unique_ptr<SwWriteTable> m_xTableWrt;
- ww8::Frame* m_pCurrentFrame;
+ FramePrHelper m_aFramePr;
bool m_bParagraphOpened;
bool m_bParagraphFrameOpen;
@@ -870,9 +961,8 @@ private:
// close of hyperlink needed
bool m_closeHyperlinkInThisRun;
bool m_closeHyperlinkInPreviousRun;
- bool m_startedHyperlink;
// Count nested HyperLinks
- sal_Int32 m_nHyperLinkCount;
+ std::vector<sal_Int32> m_nHyperLinkCount;
sal_Int16 m_nFieldsInHyperlink;
// If the exported numbering rule defines the outlines
@@ -887,14 +977,14 @@ private:
Size size;
const SdrObject* pSdrObj;
};
- std::unique_ptr< std::vector<PostponedGraphic> > m_pPostponedGraphic;
+ std::optional< std::vector<PostponedGraphic> > m_oPostponedGraphic;
struct PostponedDiagram
{
PostponedDiagram( const SdrObject* o, const SwFrameFormat* frm ) : object( o ), frame( frm ) {};
const SdrObject* object;
const SwFrameFormat* frame;
};
- std::unique_ptr< std::vector<PostponedDiagram> > m_pPostponedDiagrams;
+ std::optional< std::vector<PostponedDiagram> > m_oPostponedDiagrams;
struct PostponedDrawing
{
@@ -902,8 +992,8 @@ private:
const SdrObject* object;
const SwFrameFormat* frame;
};
- std::unique_ptr< std::vector<PostponedDrawing> > m_pPostponedDMLDrawings;
- std::unique_ptr< std::vector<PostponedDrawing> > m_pPostponedCustomShape;
+ std::optional< std::vector<PostponedDrawing> > m_oPostponedDMLDrawings;
+ std::optional< std::vector<PostponedDrawing> > m_oPostponedCustomShape;
struct PostponedOLE
{
@@ -912,7 +1002,7 @@ private:
const Size size;
const SwFlyFrameFormat* frame;
};
- std::unique_ptr< std::vector<PostponedOLE> > m_pPostponedOLEs;
+ std::optional< std::vector<PostponedOLE> > m_oPostponedOLEs;
struct PostponedMathObjects
{
@@ -932,11 +1022,20 @@ private:
std::vector<PostponedChart> m_aPostponedCharts;
std::vector<const SdrObject*> m_aPostponedFormControls;
std::vector<PostponedDrawing> m_aPostponedActiveXControls;
- const SwField* pendingPlaceholder;
+ const SwField* m_PendingPlaceholder;
+ /// Used to store the parent status of a PostIt (parent/child/neither)
+ enum class ParentStatus
+ {
+ None,
+ IsParent,
+ HasParent
+ };
struct PostItDOCXData{
sal_Int32 id;
sal_Int32 lastParaId = 0; // [MS-DOCX] 2.5.3.1 CT_CommentEx needs paraId attribute
+ ParentStatus parentStatus = ParentStatus::None;
+ size_t parentIndex = 0;
};
/// Maps postit fields to ID's, used in commentRangeStart/End, commentReference and comment.xml.
std::vector<std::pair<const SwPostItField*, PostItDOCXData>> m_postitFields;
@@ -950,15 +1049,15 @@ private:
OString fontKey;
};
- std::unique_ptr<TableReference> m_tableReference;
+ TableReference m_tableReference;
- std::map< OUString, EmbeddedFontRef > fontFilesMap; // font file url to data
+ std::map< OUString, EmbeddedFontRef > m_FontFilesMap; // font file url to data
// Remember first cell (used for default borders/margins) of each table
- std::vector<ww8::WW8TableNodeInfoInner::Pointer_t> tableFirstCells;
+ std::vector<ww8::WW8TableNodeInfoInner::Pointer_t> m_TableFirstCells;
// Remember last open and closed cells on each level
- std::vector<sal_Int32> lastOpenCell;
- std::vector<sal_Int32> lastClosedCell;
+ std::vector<sal_Int32> m_LastOpenCell;
+ std::vector<sal_Int32> m_LastClosedCell;
std::optional<css::drawing::FillStyle> m_oFillStyle;
/// If FormatBox() already handled fill style / gradient.
@@ -972,36 +1071,19 @@ private:
// store hardcoded value which was set during import.
sal_Int32 m_nParaBeforeSpacing,m_nParaAfterSpacing;
- std::pair<OString, OUString> getExistingGraphicRelId(BitmapChecksum aChecksum);
- void cacheGraphicRelId(BitmapChecksum nChecksum, OString const & rRelId, OUString const & rFileName);
-
- /// RelId <-> Graphic* cache, so that in case of alternate content, the same graphic only gets written once.
- std::stack< std::map<BitmapChecksum, std::pair<OString, OUString>> > m_aRelIdCache;
-
- /// RelId <-> BitmapChecksum cache, similar to m_aRelIdCache, but used for non-Writer graphics, handled in oox.
- std::stack< std::map<BitmapChecksum, std::pair<OUString, OUString>> > m_aSdrRelIdCache;
+ SdtBlockHelper m_aParagraphSdt;
+ SdtBlockHelper m_aRunSdt;
- /// members to control the existence of grabbagged SDT properties in the paragraph
- sal_Int32 m_nParagraphSdtPrToken;
- rtl::Reference<sax_fastparser::FastAttributeList> m_pParagraphSdtPrTokenChildren;
- rtl::Reference<sax_fastparser::FastAttributeList> m_pParagraphSdtPrTokenAttributes;
- rtl::Reference<sax_fastparser::FastAttributeList> m_pParagraphSdtPrDataBindingAttrs;
- /// members to control the existence of grabbagged SDT properties in the text run
- sal_Int32 m_nRunSdtPrToken;
/// State of the Fly at current position
FlyProcessingState m_nStateOfFlyFrame;
- rtl::Reference<sax_fastparser::FastAttributeList> m_pRunSdtPrTokenChildren;
- rtl::Reference<sax_fastparser::FastAttributeList> m_pRunSdtPrDataBindingAttrs;
- /// Value of the <w:alias> paragraph SDT element.
- OUString m_aParagraphSdtPrAlias;
+
/// Same as m_aParagraphSdtPrAlias, but its content is available till the SDT is closed.
OUString m_aStartedParagraphSdtPrAlias;
- OUString m_aRunSdtPrAlias;
- /// Currently paragraph SDT has a <w:id> child element.
- bool m_bParagraphSdtHasId;
std::vector<std::map<SvxBoxItemLine, css::table::BorderLine2>> m_aTableStyleConfs;
+ std::optional<SwLineBreakClear> m_oLineBreakClear;
+
public:
DocxAttributeOutput( DocxExport &rExport, const ::sax_fastparser::FSHelperPtr& pSerializer, oox::drawingml::DrawingML* pDrawingML );
@@ -1030,8 +1112,8 @@ public:
static void WriteFootnoteEndnotePr( ::sax_fastparser::FSHelperPtr const & fs, int tag, const SwEndNoteInfo& info, int listtag );
bool HasPostitFields() const;
- enum class hasResolved { no, yes };
- hasResolved WritePostitFields();
+ enum class hasProperties { no, yes };
+ hasProperties WritePostitFields();
void WritePostItFieldsResolved();
/// VMLTextExport
@@ -1039,9 +1121,6 @@ public:
virtual void WriteVMLTextBox(css::uno::Reference<css::drawing::XShape> xShape) override;
/// DMLTextExport
virtual void WriteTextBox(css::uno::Reference<css::drawing::XShape> xShape) override;
- virtual OUString FindRelId(BitmapChecksum nChecksum) override;
- virtual OUString FindFileName(BitmapChecksum nChecksum) override;
- virtual void CacheRelId(BitmapChecksum nChecksum, const OUString& rRelId, const OUString& rFileName) override;
virtual css::uno::Reference<css::text::XTextFrame> GetUnoTextFrame(
css::uno::Reference<css::drawing::XShape> xShape) override;
virtual oox::drawingml::DrawingML& GetDrawingML() override;
@@ -1060,6 +1139,37 @@ public:
void pushToTableExportContext(DocxTableExportContext& rContext);
/// Restores from the remembered state.
void popFromTableExportContext(DocxTableExportContext const & rContext);
+
+ static OString convertToOOXMLHoriOrient(sal_Int16 nOrient, bool bIsPosToggle);
+ static OString convertToOOXMLVertOrient(sal_Int16 nOrient);
+ static OString convertToOOXMLVertOrientRel(sal_Int16 nOrientRel);
+ static OString convertToOOXMLHoriOrientRel(sal_Int16 nOrientRel);
+ static void ImplCellMargins( sax_fastparser::FSHelperPtr const & pSerializer, const SvxBoxItem& rBox, sal_Int32 tag, bool bUseStartEnd, const SvxBoxItem* pDefaultMargins = nullptr);
+ template <class... Args>
+ static void AddToAttrList(rtl::Reference<sax_fastparser::FastAttributeList>& pAttrList, Args&&... args)
+ {
+ if (!pAttrList)
+ pAttrList = sax_fastparser::FastSerializerHelper::createAttrList();
+ pAttrList->add(std::forward<Args>(args)...);
+ }
+
+ static const sal_Int32 Tag_StartParagraph_1 = 1;
+ static const sal_Int32 Tag_StartParagraph_2 = 2;
+ static const sal_Int32 Tag_WriteSdtBlock = 3;
+ static const sal_Int32 Tag_StartParagraphProperties = 4;
+ static const sal_Int32 Tag_InitCollectedParagraphProperties = 5;
+ static const sal_Int32 Tag_StartRun_1 = 6;
+ static const sal_Int32 Tag_StartRun_2 = 7;
+ static const sal_Int32 Tag_StartRun_3 = 8;
+ static const sal_Int32 Tag_EndRun_1 = 9;
+ static const sal_Int32 Tag_EndRun_2 = 10;
+ static const sal_Int32 Tag_StartRunProperties = 11;
+ static const sal_Int32 Tag_InitCollectedRunProperties = 12;
+ static const sal_Int32 Tag_Redline_1 = 13;
+ static const sal_Int32 Tag_Redline_2 = 14;
+ static const sal_Int32 Tag_TableDefinition = 15;
+ static const sal_Int32 Tag_OutputFlyFrame = 16;
+ static const sal_Int32 Tag_StartSection = 17;
};
/**
@@ -1072,7 +1182,9 @@ struct DocxTableExportContext
ww8::WW8TableInfo::Pointer_t m_pTableInfo;
bool m_bTableCellOpen;
bool m_bStartedParaSdt;
+ bool m_bStartedRunSdt;
sal_uInt32 m_nTableDepth;
+ sal_Int32 m_nHyperLinkCount = 0;
DocxTableExportContext(DocxAttributeOutput& rOutput) : m_rOutput(rOutput) { m_rOutput.pushToTableExportContext(*this); }
~DocxTableExportContext() { m_rOutput.popFromTableExportContext(*this); }
};
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 0590fea71d35..f1331ce4141e 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <config_wasm_strip.h>
+
#include "docxexport.hxx"
#include "docxexportfilter.hxx"
#include "docxattributeoutput.hxx"
@@ -34,9 +36,11 @@
#include <com/sun/star/xml/sax/Writer.hpp>
#include <com/sun/star/awt/XControlModel.hpp>
#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/io/XStreamListener.hpp>
#include <com/sun/star/sdb/CommandType.hpp>
#include <com/sun/star/text/XTextFieldsSupplier.hpp>
#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/xml/xslt/XSLTTransformer.hpp>
#include <oox/token/namespaces.hxx>
#include <oox/token/tokens.hxx>
@@ -44,18 +48,26 @@
#include <oox/export/vmlexport.hxx>
#include <oox/export/chartexport.hxx>
#include <oox/export/shapes.hxx>
+#include <oox/export/ThemeExport.hxx>
#include <oox/helper/propertyset.hxx>
#include <oox/token/relationship.hxx>
#include <oox/ole/olestorage.hxx>
#include <oox/ole/olehelper.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xflbmtit.hxx>
+
#include <map>
#include <algorithm>
+#include <condition_variable>
+#include <mutex>
#include <IMark.hxx>
#include <IDocumentSettingAccess.hxx>
#include <IDocumentLayoutAccess.hxx>
#include <IDocumentStylePoolAccess.hxx>
+#include <IDocumentDrawModelAccess.hxx>
#include <docsh.hxx>
#include <ndtxt.hxx>
#include "wrtww8.hxx"
@@ -66,7 +78,9 @@
#include <ftninfo.hxx>
#include <pagedesc.hxx>
#include <poolfmt.hxx>
+#include <redline.hxx>
#include <swdbdata.hxx>
+#include <drawdoc.hxx>
#include <editeng/unoprnms.hxx>
#include <editeng/editobj.hxx>
@@ -85,7 +99,7 @@
#include <o3tl/any.hxx>
#include <sal/log.hxx>
#include <unotools/ucbstreamhelper.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
using namespace sax_fastparser;
using namespace ::comphelper;
@@ -145,7 +159,7 @@ bool DocxExport::CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich
return true;
}
-void DocxExport::AppendBookmarks( const SwTextNode& rNode, sal_Int32 nCurrentPos, sal_Int32 nLen )
+void DocxExport::AppendBookmarks( const SwTextNode& rNode, sal_Int32 nCurrentPos, sal_Int32 nLen, const SwRedlineData* pRedlineData )
{
std::vector< OUString > aStarts;
std::vector< OUString > aEnds;
@@ -155,8 +169,8 @@ void DocxExport::AppendBookmarks( const SwTextNode& rNode, sal_Int32 nCurrentPos
{
for ( IMark* pMark : aMarks )
{
- const sal_Int32 nStart = pMark->GetMarkStart().nContent.GetIndex();
- const sal_Int32 nEnd = pMark->GetMarkEnd().nContent.GetIndex();
+ const sal_Int32 nStart = pMark->GetMarkStart().GetContentIndex();
+ const sal_Int32 nEnd = pMark->GetMarkEnd().GetContentIndex();
if ( nStart == nCurrentPos )
aStarts.push_back( pMark->GetName() );
@@ -172,16 +186,13 @@ void DocxExport::AppendBookmarks( const SwTextNode& rNode, sal_Int32 nCurrentPos
if ( nCurrentPos == nEnd )
m_pAttrOutput->WriteFinalBookmarks_Impl( aStarts, aEnds );
else
- m_pAttrOutput->WriteBookmarks_Impl( aStarts, aEnds );
+ m_pAttrOutput->WriteBookmarks_Impl( aStarts, aEnds, pRedlineData );
}
void DocxExport::AppendBookmark( const OUString& rName )
{
- std::vector< OUString > aStarts;
- std::vector< OUString > aEnds;
-
- aStarts.push_back( rName );
- aEnds.push_back( rName );
+ std::vector< OUString > aStarts { rName };
+ std::vector< OUString > aEnds { rName };
m_pAttrOutput->WriteBookmarks_Impl( aStarts, aEnds );
}
@@ -196,8 +207,8 @@ void DocxExport::AppendAnnotationMarks( const SwWW8AttrIter& rAttrs, sal_Int32 n
{
for ( IMark* pMark : aMarks )
{
- const sal_Int32 nStart = pMark->GetMarkStart().nContent.GetIndex();
- const sal_Int32 nEnd = pMark->GetMarkEnd().nContent.GetIndex();
+ const sal_Int32 nStart = pMark->GetMarkStart().GetContentIndex();
+ const sal_Int32 nEnd = pMark->GetMarkEnd().GetContentIndex();
if ( nStart == nCurrentPos )
aStarts.push_back( pMark->GetName() );
@@ -259,6 +270,10 @@ void DocxExport::WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
// Turn ON flag for 'Writing Headers \ Footers'
m_pAttrOutput->SetWritingHeaderFooter( true );
+ const bool bPrevSectionHadHeader = m_bHasHdr;
+ const bool bPrevSectionHadFooter = m_bHasFtr;
+ m_bHasHdr = m_bHasFtr = false;
+
// headers
if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_EVEN )
WriteHeaderFooter( &rLeftHeaderFormat, true, "even" );
@@ -266,22 +281,19 @@ void DocxExport::WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
{
if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_ODD )
WriteHeaderFooter( &rFormat, true, "even" );
- else if ( m_bHasHdr && nBreakCode == 2 )
+ else if (bPrevSectionHadHeader && nBreakCode == 2)
WriteHeaderFooter( nullptr, true, "even" );
}
if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_ODD )
WriteHeaderFooter( &rFormat, true, "default" );
+ else if (bPrevSectionHadHeader && nBreakCode == 2) // 2: nextPage
+ WriteHeaderFooter(nullptr, true, "default");
if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_FIRST )
WriteHeaderFooter( &rFirstPageFormat, true, "first" );
-
- if( (nHeadFootFlags & (nsHdFtFlags::WW8_HEADER_EVEN
- | nsHdFtFlags::WW8_HEADER_ODD
- | nsHdFtFlags::WW8_HEADER_FIRST)) == 0
- && m_bHasHdr && nBreakCode == 2 ) // 2: nexPage
- WriteHeaderFooter( nullptr, true, "default" );
-
+ else if (bPrevSectionHadHeader && nBreakCode == 2)
+ WriteHeaderFooter(nullptr, true, "first");
// footers
if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_EVEN )
@@ -290,21 +302,19 @@ void DocxExport::WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
{
if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_ODD )
WriteHeaderFooter( &rFormat, false, "even" );
- else if ( m_bHasFtr && nBreakCode == 2 )
+ else if (bPrevSectionHadFooter && nBreakCode == 2)
WriteHeaderFooter( nullptr, false, "even");
}
if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_ODD )
WriteHeaderFooter( &rFormat, false, "default" );
+ else if (bPrevSectionHadFooter && nBreakCode == 2)
+ WriteHeaderFooter(nullptr, false, "default");
if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_FIRST )
WriteHeaderFooter( &rFirstPageFormat, false, "first" );
-
- if( (nHeadFootFlags & (nsHdFtFlags::WW8_FOOTER_EVEN
- | nsHdFtFlags::WW8_FOOTER_ODD
- | nsHdFtFlags::WW8_FOOTER_FIRST)) == 0
- && m_bHasFtr && nBreakCode == 2 ) // 2: nexPage
- WriteHeaderFooter( nullptr, false, "default");
+ else if (bPrevSectionHadFooter && nBreakCode == 2)
+ WriteHeaderFooter(nullptr, false, "first");
// Turn OFF flag for 'Writing Headers \ Footers'
m_pAttrOutput->SetWritingHeaderFooter( false );
@@ -322,9 +332,7 @@ void DocxExport::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark )
void DocxExport::WriteHyperlinkData( const ::sw::mark::IFieldmark& /*rFieldmark*/ )
{
-#if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, "TODO DocxExport::WriteHyperlinkData()\n" );
-#endif
+ SAL_INFO("sw.ww8", "TODO DocxExport::WriteHyperlinkData().");
}
void DocxExport::DoComboBox(const OUString& rName,
@@ -385,6 +393,10 @@ OString DocxExport::OutputChart( uno::Reference< frame::XModel > const & xModel,
m_rFilter.openFragmentStreamWithSerializer( aFileName,
"application/vnd.openxmlformats-officedocument.drawingml.chart+xml" );
+#if !ENABLE_WASM_STRIP_CHART
+ // WASM_CHART change
+ // TODO: With Chart extracted this cannot really happen since
+ // no Chart could've been added at all
oox::drawingml::ChartExport aChartExport(XML_w, pChartFS, xModel, &m_rFilter, oox::drawingml::DOCUMENT_DOCX);
css::uno::Reference<css::util::XModifiable> xModifiable(xModel, css::uno::UNO_QUERY);
const bool bOldModified = xModifiable && xModifiable->isModified();
@@ -393,6 +405,10 @@ OString DocxExport::OutputChart( uno::Reference< frame::XModel > const & xModel,
// tdf#134973: the model could get modified: e.g., calling XChartDocument::getSubTitle(),
// which creates the object if absent, and sets the modified state.
xModifiable->setModified(bOldModified);
+#else
+ (void)xModel;
+#endif
+ pChartFS->endDocument();
return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 );
}
@@ -489,6 +505,8 @@ std::pair<OString, OString> DocxExport::WriteActiveXObject(const uno::Reference<
sXMLFileName.subView(sBinaryFileName.indexOf("/") + 1)),
RTL_TEXTENCODING_UTF8);
+ pActiveXFS->endDocument();
+
return std::pair<OString, OString>(sXMLId, sName);
}
@@ -515,8 +533,10 @@ ErrCode DocxExport::ExportDocument_Impl()
// init sections
m_pSections.reset(new MSWordSections( *this ));
+ auto& rGraphicExportCache = oox::drawingml::GraphicExportCache::get();
+
// Make sure images are counted from one, even when exporting multiple documents.
- oox::drawingml::DrawingML::ResetCounters();
+ rGraphicExportCache.push();
WriteMainText();
@@ -538,12 +558,15 @@ ErrCode DocxExport::ExportDocument_Impl()
WriteEmbeddings();
- WriteVBA();
+ if (m_bDocm)
+ WriteVBA();
m_aLinkedTextboxesHelper.clear(); //final cleanup
m_pStyles.reset();
m_pSections.reset();
+ rGraphicExportCache.pop();
+
return ERRCODE_NONE;
}
@@ -611,7 +634,7 @@ void DocxExport::OutputLinkedOLE( const OUString& )
// Nothing to implement here: WW8 only
}
-sal_uLong DocxExport::ReplaceCr( sal_uInt8 )
+sal_uInt64 DocxExport::ReplaceCr( sal_uInt8 )
{
// Completely unused for Docx export... only here for code sharing
// purpose with binary export
@@ -663,6 +686,8 @@ void DocxExport::InitStyles()
// switch the serializer back
m_pAttrOutput->SetSerializer( m_pDocumentFS );
+
+ pStylesFS->endDocument();
}
void DocxExport::WriteFootnotesEndnotes()
@@ -692,6 +717,8 @@ void DocxExport::WriteFootnotesEndnotes()
m_pVMLExport->SetFS(m_pDocumentFS);
m_pSdrExport->setSerializer( m_pDocumentFS );
m_pAttrOutput->SetSerializer( m_pDocumentFS );
+
+ pFootnotesFS->endDocument();
}
if ( !m_pAttrOutput->HasEndnotes() )
@@ -720,6 +747,8 @@ void DocxExport::WriteFootnotesEndnotes()
m_pVMLExport->SetFS(m_pDocumentFS);
m_pSdrExport->setSerializer( m_pDocumentFS );
m_pAttrOutput->SetSerializer( m_pDocumentFS );
+
+ pEndnotesFS->endDocument();
}
void DocxExport::WritePostitFields()
@@ -737,11 +766,12 @@ void DocxExport::WritePostitFields()
pPostitFS->startElementNS( XML_w, XML_comments, MainXmlNamespaces());
m_pAttrOutput->SetSerializer( pPostitFS );
- const auto eHasResolved = m_pAttrOutput->WritePostitFields();
+ const auto eHasProperties = m_pAttrOutput->WritePostitFields();
m_pAttrOutput->SetSerializer( m_pDocumentFS );
pPostitFS->endElementNS( XML_w, XML_comments );
+ pPostitFS->endDocument();
- if (eHasResolved != DocxAttributeOutput::hasResolved::yes)
+ if (eHasProperties != DocxAttributeOutput::hasProperties::yes)
return;
m_rFilter.addRelation(m_pDocumentFS->getOutputStream(),
@@ -760,6 +790,7 @@ void DocxExport::WritePostitFields()
m_pAttrOutput->WritePostItFieldsResolved();
m_pAttrOutput->SetSerializer(m_pDocumentFS);
pPostitFS->endElementNS(XML_w15, XML_commentsEx);
+ pPostitFS->endDocument();
}
void DocxExport::WriteNumbering()
@@ -798,6 +829,8 @@ void DocxExport::WriteNumbering()
// switch the serializer back
m_pDrawingML->SetFS( m_pDocumentFS );
m_pAttrOutput->SetSerializer( m_pDocumentFS );
+
+ pNumberingFS->endDocument();
}
void DocxExport::WriteHeaderFooter( const SwFormat* pFormat, bool bHeader, const char* pType )
@@ -870,6 +903,8 @@ void DocxExport::WriteHeaderFooter( const SwFormat* pFormat, bool bHeader, const
m_pDocumentFS->singleElementNS( XML_w, nReference,
FSNS( XML_w, XML_type ), pType,
FSNS( XML_r, XML_id ), aRelId );
+
+ pFS->endDocument();
}
void DocxExport::WriteFonts()
@@ -896,6 +931,8 @@ void DocxExport::WriteFonts()
m_pAttrOutput->SetSerializer( m_pDocumentFS );
pFS->endElementNS( XML_w, XML_fonts );
+
+ pFS->endDocument();
}
void DocxExport::WriteProperties( )
@@ -933,8 +970,8 @@ void DocxExport::WriteDocVars(const sax_fastparser::FSHelperPtr& pFS)
// Only write docVars if there will be at least a single docVar.
bool bStarted = false;
- constexpr OUStringLiteral aPrefix(u"com.sun.star.text.fieldmaster.User.");
- for (const auto& rMasterName : std::as_const(aMasterNames))
+ constexpr OUString aPrefix(u"com.sun.star.text.fieldmaster.User."_ustr);
+ for (const auto& rMasterName : aMasterNames)
{
if (!rMasterName.startsWith(aPrefix))
{
@@ -971,7 +1008,8 @@ static auto
WriteCompat(SwDoc const& rDoc, ::sax_fastparser::FSHelperPtr const& rpFS,
sal_Int32 & rTargetCompatibilityMode) -> void
{
- if (!rDoc.getIDocumentSettingAccess().get(DocumentSettingId::ADD_EXT_LEADING))
+ const IDocumentSettingAccess& rIDSA = rDoc.getIDocumentSettingAccess();
+ if (!rIDSA.get(DocumentSettingId::ADD_EXT_LEADING))
{
rpFS->singleElementNS(XML_w, XML_noLeading);
if (rTargetCompatibilityMode > 14)
@@ -980,10 +1018,19 @@ WriteCompat(SwDoc const& rDoc, ::sax_fastparser::FSHelperPtr const& rpFS,
}
}
// Do not justify lines with manual break
- if (rDoc.getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK))
+ if (rIDSA.get(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK))
{
rpFS->singleElementNS(XML_w, XML_doNotExpandShiftReturn);
}
+ // tdf#146515 export "Use printer metrics for document formatting"
+ if (!rIDSA.get(DocumentSettingId::USE_VIRTUAL_DEVICE))
+ rpFS->singleElementNS(XML_w, XML_usePrinterMetrics);
+
+ if (rIDSA.get(DocumentSettingId::DO_NOT_BREAK_WRAPPED_TABLES))
+ {
+ // Map the DoNotBreakWrappedTables compat flag to <w:doNotBreakWrappedTables>.
+ rpFS->singleElementNS(XML_w, XML_doNotBreakWrappedTables);
+ }
}
void DocxExport::WriteSettings()
@@ -992,6 +1039,8 @@ void DocxExport::WriteSettings()
if( !pViewShell && !m_aSettings.hasData() && !m_pAttrOutput->HasFootnotes() && !m_pAttrOutput->HasEndnotes())
return;
+ SwDocShell* pDocShell = m_rDoc.GetDocShell();
+
m_rFilter.addRelation( m_pDocumentFS->getOutputStream(),
oox::getRelationship(Relationship::SETTINGS),
u"settings.xml" );
@@ -1003,6 +1052,61 @@ void DocxExport::WriteSettings()
pFS->startElementNS( XML_w, XML_settings,
FSNS( XML_xmlns, XML_w ), m_rFilter.getNamespaceURL(OOX_NS(doc)) );
+ // Write protection
+ const uno::Sequence<beans::PropertyValue> aInfo = pDocShell->GetModifyPasswordInfo();
+ if (aInfo.hasElements())
+ {
+ OUString sAlgorithm, sSalt, sHash;
+ sal_Int32 nCount = 0;
+ for (const auto& prop : aInfo)
+ {
+ if (prop.Name == "algorithm-name")
+ prop.Value >>= sAlgorithm;
+ else if (prop.Name == "salt")
+ prop.Value >>= sSalt;
+ else if (prop.Name == "iteration-count")
+ prop.Value >>= nCount;
+ else if (prop.Name == "hash")
+ prop.Value >>= sHash;
+ }
+ if (!sAlgorithm.isEmpty() && !sSalt.isEmpty() && !sHash.isEmpty())
+ {
+ sal_Int32 nAlgorithmSid = 0;
+ if (sAlgorithm == "MD2")
+ nAlgorithmSid = 1;
+ else if (sAlgorithm == "MD4")
+ nAlgorithmSid = 2;
+ else if (sAlgorithm == "MD5")
+ nAlgorithmSid = 3;
+ else if (sAlgorithm == "SHA-1")
+ nAlgorithmSid = 4;
+ else if (sAlgorithm == "MAC")
+ nAlgorithmSid = 5;
+ else if (sAlgorithm == "RIPEMD")
+ nAlgorithmSid = 6;
+ else if (sAlgorithm == "RIPEMD-160")
+ nAlgorithmSid = 7;
+ else if (sAlgorithm == "HMAC")
+ nAlgorithmSid = 9;
+ else if (sAlgorithm == "SHA-256")
+ nAlgorithmSid = 12;
+ else if (sAlgorithm == "SHA-384")
+ nAlgorithmSid = 13;
+ else if (sAlgorithm == "SHA-512")
+ nAlgorithmSid = 14;
+
+ if (nAlgorithmSid != 0)
+ pFS->singleElementNS(XML_w, XML_writeProtection,
+ FSNS(XML_w, XML_cryptProviderType), "rsaAES",
+ FSNS(XML_w, XML_cryptAlgorithmClass), "hash",
+ FSNS(XML_w, XML_cryptAlgorithmType), "typeAny",
+ FSNS(XML_w, XML_cryptAlgorithmSid), OString::number(nAlgorithmSid),
+ FSNS(XML_w, XML_cryptSpinCount), OString::number(nCount),
+ FSNS(XML_w, XML_hash), sHash,
+ FSNS(XML_w, XML_salt), sSalt);
+ }
+ }
+
// View
if (pViewShell && pViewShell->GetViewOptions()->getBrowseMode())
{
@@ -1089,7 +1193,7 @@ void DocxExport::WriteSettings()
pFS->singleElementNS(XML_w, XML_dataType,
FSNS( XML_w, XML_val ), "textFile" );
pFS->singleElementNS( XML_w, XML_query,
- FSNS( XML_w, XML_val ), OUStringToOString( sDataSource, RTL_TEXTENCODING_UTF8 ).getStr() );
+ FSNS( XML_w, XML_val ), sDataSource );
pFS->endElementNS( XML_w, XML_mailMerge );
}
@@ -1099,11 +1203,15 @@ void DocxExport::WriteSettings()
// Hyphenation details set depending on default style
SwTextFormatColl* pColl = m_rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_STANDARD, /*bRegardLanguage=*/false);
- const SfxPoolItem* pItem;
- if (pColl && SfxItemState::SET == pColl->GetItemState(RES_PARATR_HYPHENZONE, false, &pItem))
+ const SvxHyphenZoneItem* pZoneItem;
+ if (pColl && (pZoneItem = pColl->GetItemIfSet(RES_PARATR_HYPHENZONE, false)))
{
- if (static_cast<const SvxHyphenZoneItem*>(pItem)->IsNoCapsHyphenation())
+ if (pZoneItem->IsNoCapsHyphenation())
pFS->singleElementNS(XML_w, XML_doNotHyphenateCaps);
+
+ if ( sal_Int16 nHyphenZone = pZoneItem->GetTextHyphenZone() )
+ pFS->singleElementNS(XML_w, XML_hyphenationZone, FSNS(XML_w, XML_val),
+ OString::number(nHyphenZone));
}
// Even and Odd Headers
@@ -1119,7 +1227,7 @@ void DocxExport::WriteSettings()
DocxAttributeOutput::WriteFootnoteEndnotePr( pFS, XML_endnotePr, m_rDoc.GetEndNoteInfo(), XML_endnote );
// Has themeFontLang information
- uno::Reference< beans::XPropertySet > xPropSet( m_rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xPropSet( pDocShell->GetBaseModel(), uno::UNO_QUERY_THROW );
bool bUseGrabBagProtection = false;
bool bWriterWantsToProtect = false;
@@ -1145,7 +1253,7 @@ void DocxExport::WriteSettings()
/* Compatibility Mode (tdf#131304)
* 11: .doc level [Word 97-2003]
- * 12: .docx default [Word 2007] [LO < 7.0]
+ * 12: .docx default [Word 2007] [LO < 7.0] [ECMA 376 1st ed.]
* 14: [Word 2010]
* 15: [Word 2013/2016/2019] [LO >= 7.0]
*
@@ -1158,7 +1266,9 @@ void DocxExport::WriteSettings()
* 2.) Many years later, change the TargetCompatilityMode for new documents, when we no longer care
* about working with perfect compatibility with older versions of MS Word.
*/
- sal_Int32 nTargetCompatibilityMode = 15; //older versions might not open our files well
+ sal_Int32 nTargetCompatibilityMode =
+ (GetFilter().getVersion() == oox::core::ECMA_376_1ST_EDITION)
+ ? 12 : 15; //older versions might not open our files well
bool bHasCompatibilityMode = false;
const OUString aGrabBagName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
if ( xPropSetInfo->hasPropertyByName( aGrabBagName ) )
@@ -1166,14 +1276,14 @@ void DocxExport::WriteSettings()
uno::Sequence< beans::PropertyValue > propList;
xPropSet->getPropertyValue( aGrabBagName ) >>= propList;
- for( const auto& rProp : std::as_const(propList) )
+ for (const auto& rProp : propList)
{
if ( rProp.Name == "ThemeFontLangProps" )
{
uno::Sequence< beans::PropertyValue > themeFontLangProps;
rProp.Value >>= themeFontLangProps;
OUString aValues[3];
- for( const auto& rThemeFontLangProp : std::as_const(themeFontLangProps) )
+ for (const auto& rThemeFontLangProp : themeFontLangProps)
{
if( rThemeFontLangProp.Name == "val" )
rThemeFontLangProp.Value >>= aValues[0];
@@ -1196,7 +1306,7 @@ void DocxExport::WriteSettings()
uno::Sequence< beans::PropertyValue > aCompatSettingsSequence;
rProp.Value >>= aCompatSettingsSequence;
- for(const auto& rCompatSetting : std::as_const(aCompatSettingsSequence))
+ for (const auto& rCompatSetting : aCompatSettingsSequence)
{
uno::Sequence< beans::PropertyValue > aCompatSetting;
rCompatSetting.Value >>= aCompatSetting;
@@ -1204,7 +1314,7 @@ void DocxExport::WriteSettings()
OUString aUri;
OUString aValue;
- for(const auto& rPropVal : std::as_const(aCompatSetting))
+ for (const auto& rPropVal : aCompatSetting)
{
if( rPropVal.Name == "name" )
rPropVal.Value >>= aName;
@@ -1253,7 +1363,7 @@ void DocxExport::WriteSettings()
bool bIsProtectionTrackChanges = false;
// if grabbag protection is not enforced, allow Writer protection to override
bool bEnforced = false;
- for (const auto& rAttribute : std::as_const(rAttributeList))
+ for (const auto& rAttribute : rAttributeList)
{
static DocxStringTokenMap const aTokens[] =
{
@@ -1279,7 +1389,7 @@ void DocxExport::WriteSettings()
else if ( nToken == XML_edit && sValue == "readOnly" )
{
// Ignore the case where read-only was not enforced, but now is. That is handled by _MarkAsFinal
- bReadOnlyStatusUnchanged = m_rDoc.GetDocShell()->IsSecurityOptOpenReadOnly();
+ bReadOnlyStatusUnchanged = pDocShell->IsSecurityOptOpenReadOnly();
}
else if ( nToken == XML_enforcement )
bEnforced = sValue.toBoolean();
@@ -1327,6 +1437,18 @@ void DocxExport::WriteSettings()
FSNS( XML_w, XML_name ), "compatibilityMode",
FSNS( XML_w, XML_uri ), "http://schemas.microsoft.com/office/word",
FSNS( XML_w, XML_val ), OString::number(nTargetCompatibilityMode));
+
+ const IDocumentSettingAccess& rIDSA = m_rDoc.getIDocumentSettingAccess();
+ if (rIDSA.get(DocumentSettingId::ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK))
+ {
+ // AllowTextAfterFloatingTableBreak doesn't have its own XML element, it's a
+ // <w:compatSetting> with a specific name.
+ pFS->singleElementNS(XML_w, XML_compatSetting,
+ FSNS(XML_w, XML_name), "allowTextAfterFloatingTableBreak",
+ FSNS(XML_w, XML_uri), "http://schemas.microsoft.com/office/word",
+ FSNS(XML_w, XML_val), "1");
+ }
+
pFS->endElementNS( XML_w, XML_compat );
}
@@ -1357,41 +1479,26 @@ void DocxExport::WriteSettings()
// finish settings.xml
pFS->endElementNS( XML_w, XML_settings );
+
+ pFS->endDocument();
}
void DocxExport::WriteTheme()
{
- uno::Reference< beans::XPropertySet > xPropSet( m_rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
-
- uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
- OUString aName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
- if ( !xPropSetInfo->hasPropertyByName( aName ) )
+ SdrModel* pModel = m_rDoc.getIDocumentDrawModelAccess().GetDrawModel();
+ if (!pModel)
return;
-
- uno::Reference<xml::dom::XDocument> themeDom;
- uno::Sequence< beans::PropertyValue > propList;
- xPropSet->getPropertyValue( aName ) >>= propList;
- auto pProp = std::find_if(propList.begin(), propList.end(),
- [](const beans::PropertyValue& rProp) { return rProp.Name == "OOXTheme"; });
- if (pProp != propList.end())
- pProp->Value >>= themeDom;
-
- // no theme dom to write
- if ( !themeDom.is() )
+ auto const& pTheme = pModel->getTheme();
+ if (!pTheme)
return;
- m_rFilter.addRelation( m_pDocumentFS->getOutputStream(),
- oox::getRelationship(Relationship::THEME),
- u"theme/theme1.xml" );
+ m_rFilter.addRelation(m_pDocumentFS->getOutputStream(), oox::getRelationship(Relationship::THEME), u"theme/theme1.xml" );
- uno::Reference< xml::sax::XSAXSerializable > serializer( themeDom, uno::UNO_QUERY );
- uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() );
- writer->setOutputStream( GetFilter().openFragmentStream( "word/theme/theme1.xml",
- "application/vnd.openxmlformats-officedocument.theme+xml" ) );
- serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
- uno::Sequence< beans::StringPair >() );
+ oox::ThemeExport aThemeExport(&m_rFilter, oox::drawingml::DOCUMENT_DOCX);
+ aThemeExport.write(u"word/theme/theme1.xml"_ustr, *pTheme);
}
+// See OOXMLDocumentImpl::resolveGlossaryStream
void DocxExport::WriteGlossary()
{
uno::Reference< beans::XPropertySet > xPropSet( m_rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
@@ -1402,11 +1509,11 @@ void DocxExport::WriteGlossary()
return;
uno::Reference<xml::dom::XDocument> glossaryDocDom;
- uno::Sequence< uno::Sequence< uno::Any> > glossaryDomList;
+ uno::Sequence< uno::Sequence<beans::NamedValue> > glossaryDomList;
uno::Sequence< beans::PropertyValue > propList;
xPropSet->getPropertyValue( aName ) >>= propList;
sal_Int32 collectedProperties = 0;
- for ( const auto& rProp : std::as_const(propList) )
+ for (const auto& rProp : propList)
{
OUString propName = rProp.Name;
if ( propName == "OOXGlossary" )
@@ -1440,20 +1547,43 @@ void DocxExport::WriteGlossary()
serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
uno::Sequence< beans::StringPair >() );
- for ( const uno::Sequence< uno::Any>& glossaryElement : std::as_const(glossaryDomList))
+ for (const uno::Sequence<beans::NamedValue>& glossaryElement : glossaryDomList)
{
- OUString gTarget, gType, gId, contentType;
+ OUString gTarget, gType, gId, contentType, targetMode;
uno::Reference<xml::dom::XDocument> xDom;
- glossaryElement[0] >>= xDom;
- glossaryElement[1] >>= gId;
- glossaryElement[2] >>= gType;
- glossaryElement[3] >>= gTarget;
- glossaryElement[4] >>= contentType;
+ for (const auto& [name, value] : glossaryElement)
+ {
+ if (name == "Id")
+ value >>= gId;
+ else if (name == "Type")
+ value >>= gType;
+ else if (name == "Target")
+ value >>= gTarget;
+ else if (name == "TargetMode")
+ value >>= targetMode;
+ else if (name == "_contentType")
+ value >>= contentType;
+ else if (name == "_relDom")
+ value >>= xDom;
+ }
+ if (gId.isEmpty() || gType.isEmpty() || gTarget.isEmpty())
+ continue;
+ const bool bExternal = targetMode == "External";
+ if (!bExternal && !xDom)
+ {
+ // Some internal relation, but we didn't create a DOM for it
+ // in OOXMLDocumentImpl::resolveGlossaryStream?
+ SAL_WARN("sw.ww8", "Glossary internal relation without DOM: Id=\"" + gId
+ + "\" Type=\"" + gType + "\" Target=\"" + gTarget + "\"");
+ continue;
+ }
gId = gId.copy(3); //"rId" only save the numeric value
PropertySet aProps(xOutputStream);
- aProps.setAnyProperty( PROP_RelId, uno::makeAny( gId.toInt32() ));
- m_rFilter.addRelation( xOutputStream, gType, gTarget);
+ aProps.setAnyProperty( PROP_RelId, uno::Any( gId.toInt32() ));
+ m_rFilter.addRelation(xOutputStream, gType, gTarget, bExternal);
+ if (!xDom)
+ continue; // External relation, no stream to write
uno::Reference< xml::sax::XSAXSerializable > gserializer( xDom, uno::UNO_QUERY );
writer->setOutputStream(GetFilter().openFragmentStream( "word/glossary/" + gTarget, contentType ) );
gserializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
@@ -1461,27 +1591,97 @@ void DocxExport::WriteGlossary()
}
}
+namespace {
+ class XsltTransformListener : public ::cppu::WeakImplHelper<io::XStreamListener>
+ {
+ public:
+ XsltTransformListener() : m_bDone(false) {}
+
+ void wait() {
+ std::unique_lock<std::mutex> g(m_mutex);
+ m_cond.wait(g, [this]() { return m_bDone; });
+ }
+
+ private:
+ std::mutex m_mutex;
+ std::condition_variable m_cond;
+ bool m_bDone;
+
+ virtual void SAL_CALL disposing(const lang::EventObject&) noexcept override {}
+ virtual void SAL_CALL started() noexcept override {}
+ virtual void SAL_CALL closed() noexcept override { notifyDone(); }
+ virtual void SAL_CALL terminated() noexcept override { notifyDone(); }
+ virtual void SAL_CALL error(const uno::Any& e) override
+ {
+ notifyDone(); // set on error too, otherwise main thread waits forever
+ SAL_WARN("sw.ww8", e);
+ }
+
+ void notifyDone() {
+ std::scoped_lock<std::mutex> g(m_mutex);
+ m_bDone = true;
+ m_cond.notify_all();
+ }
+ };
+}
+
+static void lcl_UpdateXmlValues(const SdtData& sdtData, const uno::Reference<css::io::XInputStream>& xInputStream, const uno::Reference<css::io::XOutputStream>& xOutputStream)
+{
+ uno::Sequence<uno::Any> aArgs{
+ // XSLT transformation stylesheet:
+ // - write all elements as is
+ // - but if element matches sdtData.xpath, replace its text content by sdtData.xpath
+ uno::Any(beans::NamedValue("StylesheetText", uno::Any(OUString("<?xml version=\"1.0\" encoding=\"UTF-8\"?> \
+<xsl:stylesheet\
+ xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"\
+ " + sdtData.namespaces + "\
+ version=\"1.0\">\
+ <xsl:template match=\"@* | node()\">\
+ <xsl:copy>\
+ <xsl:apply-templates select=\"@* | node()\"/>\
+ </xsl:copy>\
+ </xsl:template>\
+ <xsl:template match = \"" + sdtData.xpath + "\">\
+ <xsl:copy>\
+ <xsl:text>" + sdtData.data + "</xsl:text>\
+ </xsl:copy>\
+ </xsl:template>\
+</xsl:stylesheet>\
+"))))
+ };
+
+ css::uno::Reference<css::xml::xslt::XXSLTTransformer> xTransformer =
+ css::xml::xslt::XSLTTransformer::create(comphelper::getProcessComponentContext(), aArgs);
+ xTransformer->setInputStream(xInputStream);
+ xTransformer->setOutputStream(xOutputStream);
+
+ rtl::Reference<XsltTransformListener> xListener = new XsltTransformListener();
+ xTransformer->addListener(xListener);
+
+ xTransformer->start();
+ xListener->wait();
+}
+
void DocxExport::WriteCustomXml()
{
uno::Reference< beans::XPropertySet > xPropSet( m_rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
- static constexpr OUStringLiteral aName = u"" UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
- if ( !xPropSetInfo->hasPropertyByName( aName ) )
+ if ( !xPropSetInfo->hasPropertyByName( UNO_NAME_MISC_OBJ_INTEROPGRABBAG ) )
return;
uno::Sequence<uno::Reference<xml::dom::XDocument> > customXmlDomlist;
uno::Sequence<uno::Reference<xml::dom::XDocument> > customXmlDomPropslist;
uno::Sequence< beans::PropertyValue > propList;
- xPropSet->getPropertyValue( aName ) >>= propList;
- auto pProp = std::find_if(propList.begin(), propList.end(),
+ xPropSet->getPropertyValue( UNO_NAME_MISC_OBJ_INTEROPGRABBAG ) >>= propList;
+ auto pProp = std::find_if(std::cbegin(propList), std::cend(propList),
[](const beans::PropertyValue& rProp) { return rProp.Name == "OOXCustomXml"; });
- if (pProp != propList.end())
+ if (pProp != std::cend(propList))
pProp->Value >>= customXmlDomlist;
- pProp = std::find_if(propList.begin(), propList.end(),
+ pProp = std::find_if(std::cbegin(propList), std::cend(propList),
[](const beans::PropertyValue& rProp) { return rProp.Name == "OOXCustomXmlProps"; });
- if (pProp != propList.end())
+ if (pProp != std::cend(propList))
pProp->Value >>= customXmlDomPropslist;
for (sal_Int32 j = 0; j < customXmlDomlist.getLength(); j++)
@@ -1492,14 +1692,58 @@ void DocxExport::WriteCustomXml()
{
m_rFilter.addRelation( m_pDocumentFS->getOutputStream(),
oox::getRelationship(Relationship::CUSTOMXML),
- OUString("../customXml/item"+OUString::number(j+1)+".xml" ));
+ Concat2View("../customXml/item"+OUString::number(j+1)+".xml" ));
uno::Reference< xml::sax::XSAXSerializable > serializer( customXmlDom, uno::UNO_QUERY );
uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() );
- writer->setOutputStream( GetFilter().openFragmentStream( "customXml/item"+OUString::number(j+1)+".xml",
- "application/xml" ) );
- serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
- uno::Sequence< beans::StringPair >() );
+
+ uno::Reference < css::io::XOutputStream > xOutStream = GetFilter().openFragmentStream("customXml/item" + OUString::number(j + 1) + ".xml",
+ "application/xml");
+ if (m_SdtData.size())
+ {
+ // There are some SDT blocks data with data bindings which can update some custom xml values
+ uno::Reference< io::XStream > xMemStream(
+ comphelper::getProcessComponentContext()->getServiceManager()->createInstanceWithContext("com.sun.star.comp.MemoryStream",
+ comphelper::getProcessComponentContext()),
+ uno::UNO_QUERY_THROW);
+
+ writer->setOutputStream(xMemStream->getOutputStream());
+
+ serializer->serialize(uno::Reference< xml::sax::XDocumentHandler >(writer, uno::UNO_QUERY_THROW),
+ uno::Sequence< beans::StringPair >());
+
+ uno::Reference< io::XStream > xXSLTInStream = xMemStream;
+ uno::Reference< io::XStream > xXSLTOutStream;
+ // Apply XSLT transformations for each SDT data binding
+ // Seems it is not possible to do this as one transformation: each data binding
+ // can have different namespaces, but with conflicting names (ns0, ns1, etc..)
+ for (size_t i = 0; i < m_SdtData.size(); i++)
+ {
+ if (i == m_SdtData.size() - 1)
+ {
+ // last transformation
+ lcl_UpdateXmlValues(m_SdtData[i], xXSLTInStream->getInputStream(), xOutStream);
+ }
+ else
+ {
+ xXSLTOutStream.set(
+ comphelper::getProcessComponentContext()->getServiceManager()->createInstanceWithContext("com.sun.star.comp.MemoryStream",
+ comphelper::getProcessComponentContext()),
+ uno::UNO_QUERY_THROW);
+ lcl_UpdateXmlValues(m_SdtData[i], xXSLTInStream->getInputStream(), xXSLTOutStream->getOutputStream());
+ // Use previous output as an input for next run
+ xXSLTInStream.set( xXSLTOutStream );
+ }
+ }
+
+ }
+ else
+ {
+ writer->setOutputStream(xOutStream);
+
+ serializer->serialize(uno::Reference< xml::sax::XDocumentHandler >(writer, uno::UNO_QUERY_THROW),
+ uno::Sequence< beans::StringPair >());
+ }
}
if (customXmlDomProps.is())
@@ -1515,7 +1759,7 @@ void DocxExport::WriteCustomXml()
m_rFilter.addRelation( GetFilter().openFragmentStream( "customXml/item"+OUString::number(j+1)+".xml",
"application/xml" ) ,
oox::getRelationship(Relationship::CUSTOMXMLPROPS),
- OUString("itemProps"+OUString::number(j+1)+".xml" ));
+ Concat2View("itemProps"+OUString::number(j+1)+".xml" ));
}
}
}
@@ -1591,11 +1835,11 @@ void DocxExport::WriteEmbeddings()
uno::Sequence< beans::PropertyValue > embeddingsList;
uno::Sequence< beans::PropertyValue > propList;
xPropSet->getPropertyValue( aName ) >>= propList;
- auto pProp = std::find_if(propList.begin(), propList.end(),
+ auto pProp = std::find_if(std::cbegin(propList), std::cend(propList),
[](const beans::PropertyValue& rProp) { return rProp.Name == "OOXEmbeddings"; });
- if (pProp != propList.end())
+ if (pProp != std::cend(propList))
pProp->Value >>= embeddingsList;
- for (const auto& rEmbedding : std::as_const(embeddingsList))
+ for (const auto& rEmbedding : embeddingsList)
{
OUString embeddingPath = rEmbedding.Name;
uno::Reference<io::XInputStream> embeddingsStream;
@@ -1657,34 +1901,74 @@ bool DocxExport::isMirroredMargin()
return bMirroredMargins;
}
-void DocxExport::WriteMainText()
+void DocxExport::WriteDocumentBackgroundFill()
{
- // setup the namespaces
- m_pDocumentFS->startElementNS( XML_w, XML_document, MainXmlNamespaces());
+ const std::unique_ptr<SvxBrushItem> pBrush = getBackground();
+ if (!pBrush)
+ return;
+
+ m_pDocumentFS->startElementNS(XML_w, XML_background, FSNS(XML_w, XML_color),
+ msfilter::util::ConvertColor(pBrush->GetColor()));
+
+ const SwAttrSet& rPageStyleAttrSet = m_rDoc.GetPageDesc(0).GetMaster().GetAttrSet();
+ const drawing::FillStyle eFillType = rPageStyleAttrSet.Get(XATTR_FILLSTYLE).GetValue();
+ const GraphicObject* pGraphicObj = pBrush->GetGraphicObject();
+ if (pGraphicObj) // image/pattern/texture
+ {
+ const OUString aRelId = m_pDrawingML->writeGraphicToStorage(pGraphicObj->GetGraphic());
+ if (!aRelId.isEmpty())
+ {
+ m_pDocumentFS->startElementNS(XML_v, XML_background);
+
+ // Although MSO treats everything as tile, it is better for LO to not always tile
+ OString sType = "frame"_ostr; // single image
+ if (rPageStyleAttrSet.Get(XATTR_FILLBMP_TILE).GetValue())
+ sType = "tile"_ostr; // primarily for patterns / textures
+ m_pDocumentFS->singleElementNS(XML_v, XML_fill, FSNS(XML_r, XML_id), aRelId, XML_type,
+ sType);
- if ( getenv("SW_DEBUG_DOM") )
+ m_pDocumentFS->endElementNS(XML_v, XML_background);
+ }
+ }
+ else if (eFillType == drawing::FillStyle_GRADIENT)
{
- m_rDoc.dumpAsXml();
+ SfxItemSetFixed<XATTR_FILL_FIRST, XATTR_FILL_LAST> aSet(m_rDoc.GetAttrPool());
+ aSet.Set(rPageStyleAttrSet);
+
+ // Collect all of the gradient attributes into SdrExporter() AttrLists
+ m_pAttrOutput->OutputStyleItemSet(aSet, /*TestForDefault=*/true);
+ assert(SdrExporter().getFlyAttrList().is() && "type and fillcolor are always provided");
+ assert(SdrExporter().getFlyFillAttrList().is() && "color2 is always provided");
+
+ rtl::Reference<FastAttributeList> xFlyAttrList(SdrExporter().getFlyAttrList());
+ rtl::Reference<FastAttributeList> xFillAttrList(SdrExporter().getFlyFillAttrList());
+ m_pDocumentFS->startElementNS(XML_v, XML_background, xFlyAttrList);
+ m_pDocumentFS->singleElementNS(XML_v, XML_fill, xFillAttrList);
+ m_pDocumentFS->endElementNS(XML_v, XML_background);
+
+ SdrExporter().getFlyAttrList().clear();
+ SdrExporter().getFlyFillAttrList().clear();
}
+ m_pDocumentFS->endElementNS(XML_w, XML_background);
+}
+
+void DocxExport::WriteMainText()
+{
+ // setup the namespaces
+ m_pDocumentFS->startElementNS( XML_w, XML_document, MainXmlNamespaces());
+
// reset the incrementing linked-textboxes chain ID before re-saving.
m_nLinkedTextboxesChainId=0;
m_aLinkedTextboxesHelper.clear();
// Write background page color
- if (std::unique_ptr<SvxBrushItem> oBrush = getBackground(); oBrush)
- {
- Color backgroundColor = oBrush->GetColor();
- OString aBackgroundColorStr = msfilter::util::ConvertColor(backgroundColor);
-
- m_pDocumentFS->singleElementNS(XML_w, XML_background, FSNS(XML_w, XML_color),
- aBackgroundColorStr);
- }
+ WriteDocumentBackgroundFill();
// body
m_pDocumentFS->startElementNS(XML_w, XML_body);
- m_pCurPam->GetPoint()->nNode = m_rDoc.GetNodes().GetEndOfContent().StartOfSectionNode()->GetIndex();
+ m_pCurPam->GetPoint()->Assign(*m_rDoc.GetNodes().GetEndOfContent().StartOfSectionNode());
// the text
WriteText();
@@ -1717,7 +2001,8 @@ rtl::Reference<FastAttributeList> DocxExport::MainXmlNamespaces()
pAttr->add( FSNS( XML_xmlns, XML_mc ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(mce)), RTL_TEXTENCODING_UTF8) );
pAttr->add( FSNS( XML_xmlns, XML_wp14 ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(wp14)), RTL_TEXTENCODING_UTF8) );
pAttr->add( FSNS( XML_xmlns, XML_w14 ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(w14)), RTL_TEXTENCODING_UTF8) );
- pAttr->add( FSNS( XML_mc, XML_Ignorable ), "w14 wp14" );
+ pAttr->add( FSNS( XML_xmlns, XML_w15 ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(w15)), RTL_TEXTENCODING_UTF8));
+ pAttr->add( FSNS( XML_mc, XML_Ignorable ), "w14 wp14 w15" );
return pAttr;
}
@@ -1749,6 +2034,13 @@ sal_Int32 DocxExport::WriteOutliner(const OutlinerParaObject& rParaObj, sal_uInt
OUString aStr( rEditObj.GetText( n ));
sal_Int32 nCurrentPos = 0;
const sal_Int32 nEnd = aStr.getLength();
+
+ // Write paragraph properties.
+ AttrOutput().StartParagraphProperties();
+ aAttrIter.OutParaAttr(/*bCharAttr=*/false);
+ SfxItemSet aParagraphMarkerProperties(m_rDoc.GetAttrPool());
+ AttrOutput().EndParagraphProperties(aParagraphMarkerProperties, nullptr, nullptr, nullptr);
+
do {
AttrOutput().StartRun( nullptr, 0 );
const sal_Int32 nNextAttr = std::min(aAttrIter.WhereNext(), nEnd);
@@ -1773,15 +2065,67 @@ sal_Int32 DocxExport::WriteOutliner(const OutlinerParaObject& rParaObj, sal_uInt
eChrSet = eNextChrSet;
aAttrIter.NextPos();
- AttrOutput().EndRun( nullptr, 0 );
+ AttrOutput().EndRun( nullptr, 0, -1 );
} while( nCurrentPos < nEnd );
-// aAttrIter.OutParaAttr(false);
+
AttrOutput().EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t());
}
return nParaId;
}
+//Keep this function in-sync with the one in writerfilter/.../SettingsTable.cxx
+//Since this is not import code, "-1" needs to be handled as the mode that LO will save as.
+//To identify how your code should handle a "-1", look in DocxExport::WriteSettings().
+sal_Int32 DocxExport::getWordCompatibilityModeFromGrabBag() const
+{
+ sal_Int32 nWordCompatibilityMode = -1;
+ uno::Reference< beans::XPropertySet > xPropSet(m_rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW);
+ uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
+ if (xPropSetInfo->hasPropertyByName(UNO_NAME_MISC_OBJ_INTEROPGRABBAG))
+ {
+ uno::Sequence< beans::PropertyValue > propList;
+ xPropSet->getPropertyValue( UNO_NAME_MISC_OBJ_INTEROPGRABBAG ) >>= propList;
+
+ for (const auto& rProp : propList)
+ {
+ if (rProp.Name == "CompatSettings")
+ {
+ css::uno::Sequence< css::beans::PropertyValue > aCurrentCompatSettings;
+ rProp.Value >>= aCurrentCompatSettings;
+
+ for (const auto& rCurrentCompatSetting : aCurrentCompatSettings)
+ {
+ uno::Sequence< beans::PropertyValue > aCompatSetting;
+ rCurrentCompatSetting.Value >>= aCompatSetting;
+
+ OUString sName;
+ OUString sUri;
+ OUString sVal;
+
+ for (const auto& rPropVal : aCompatSetting)
+ {
+ if ( rPropVal.Name == "name" ) rPropVal.Value >>= sName;
+ if ( rPropVal.Name == "uri" ) rPropVal.Value >>= sUri;
+ if ( rPropVal.Name == "val" ) rPropVal.Value >>= sVal;
+ }
+
+ if (sName == "compatibilityMode" && sUri == "http://schemas.microsoft.com/office/word")
+ {
+ const sal_Int32 nValidMode = sVal.toInt32();
+ // if repeated, highest mode wins in MS Word. 11 is the first valid mode.
+ if (nValidMode > 10 && nValidMode > nWordCompatibilityMode)
+ nWordCompatibilityMode = nValidMode;
+
+ }
+ }
+ }
+ }
+ }
+
+ return nWordCompatibilityMode;
+}
+
void DocxExport::SetFS( ::sax_fastparser::FSHelperPtr const & pFS )
{
mpFS = pFS;
@@ -1798,7 +2142,8 @@ DocxExport::DocxExport(DocxExportFilter& rFilter, SwDoc& rDocument,
m_nActiveXControls( 0 ),
m_nHeadersFootersInSection(0),
m_bDocm(bDocm),
- m_bTemplate(bTemplate)
+ m_bTemplate(bTemplate),
+ m_pAuthorIDs(new SvtSecurityMapPersonalInfo)
{
// Write the document properties
WriteProperties( );
@@ -1853,6 +2198,7 @@ DocxExport::DocxExport(DocxExportFilter& rFilter, SwDoc& rDocument,
DocxExport::~DocxExport()
{
+ m_pDocumentFS->endDocument();
}
DocxSettingsData::DocxSettingsData()
diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx
index bc96ba187100..722e3b571291 100644
--- a/sw/source/filter/ww8/docxexport.hxx
+++ b/sw/source/filter/ww8/docxexport.hxx
@@ -28,6 +28,7 @@
#include <memory>
#include <ndole.hxx>
+#include <unotools/securityoptions.hxx>
class DocxAttributeOutput;
class DocxExportFilter;
@@ -61,6 +62,14 @@ struct DocxSettingsData
bool trackRevisions; // Should 'Track Revisions' be set
};
+/// Data to keep and write to XMLs
+struct SdtData
+{
+ OUString namespaces;
+ OUString xpath;
+ OUString data;
+};
+
/// The class that does all the actual DOCX export-related work.
class DocxExport : public MSWordExportBase
{
@@ -114,6 +123,12 @@ class DocxExport : public MSWordExportBase
/// Pointer to the Frame of a floating table it is nested in
const ww8::Frame *m_pFloatingTableFrame = nullptr;
+ /// Map authors to remove personal info
+ std::unique_ptr<SvtSecurityMapPersonalInfo> m_pAuthorIDs;
+
+ /// Storage for sdt data which need to be written to other XMLs
+ std::vector<SdtData> m_SdtData;
+
public:
DocxExportFilter& GetFilter() { return m_rFilter; };
@@ -141,7 +156,7 @@ public:
/// Guess the script (asian/western).
virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ) override;
- virtual void AppendBookmarks( const SwTextNode& rNode, sal_Int32 nCurrentPos, sal_Int32 nLen ) override;
+ virtual void AppendBookmarks( const SwTextNode& rNode, sal_Int32 nCurrentPos, sal_Int32 nLen, const SwRedlineData* pRedlineData = nullptr ) override;
virtual void AppendBookmark( const OUString& rName ) override;
@@ -179,7 +194,7 @@ public:
virtual void DoFormText(const SwInputField * pField) override;
- virtual sal_uLong ReplaceCr( sal_uInt8 nChar ) override;
+ virtual sal_uInt64 ReplaceCr( sal_uInt8 nChar ) override;
/// Returns the relationd id
OString OutputChart( css::uno::Reference< css::frame::XModel > const & xModel, sal_Int32 nCount, ::sax_fastparser::FSHelperPtr const & m_pSerializer );
@@ -194,6 +209,11 @@ public:
virtual ExportFormat GetExportFormat() const override { return ExportFormat::DOCX; }
+ void AddSdtData(const OUString & namespaces, const OUString & xpath, const OUString & data)
+ {
+ m_SdtData.push_back({ namespaces, xpath, data });
+ }
+
protected:
/// Format-dependent part of the actual export.
virtual ErrCode ExportDocument_Impl() override;
@@ -224,6 +244,9 @@ private:
/// Setup pStyles and write styles.xml
void InitStyles();
+ /// write optional w:background before the w:body of word/document.xml
+ void WriteDocumentBackgroundFill();
+
/// Write footnotes.xml and endnotes.xml.
void WriteFootnotesEndnotes();
@@ -296,6 +319,12 @@ public:
void SetFloatingTableFrame(const ww8::Frame* pF) { m_pFloatingTableFrame = pF; }
+ // Get author id to remove personal info
+ size_t GetInfoID( const OUString sPersonalInfo ) const { return m_pAuthorIDs->GetInfoID(sPersonalInfo); }
+
+ // needed in docxsdrexport.cxx and docxattributeoutput.cxx
+ sal_Int32 getWordCompatibilityModeFromGrabBag() const;
+
private:
DocxExport( const DocxExport& ) = delete;
diff --git a/sw/source/filter/ww8/docxexportfilter.cxx b/sw/source/filter/ww8/docxexportfilter.cxx
index b914cc1815ce..04a5d015050f 100644
--- a/sw/source/filter/ww8/docxexportfilter.cxx
+++ b/sw/source/filter/ww8/docxexportfilter.cxx
@@ -63,6 +63,37 @@ bool DocxExportFilter::exportDocument()
pViewShell->GetPostItMgr()->UpdateDataOnActiveSidebarWin();
}
+ OUString aFilterName;
+ auto& rMediaDescriptor = getMediaDescriptor();
+ rMediaDescriptor[utl::MediaDescriptor::PROP_FILTERNAME] >>= aFilterName;
+ bool bDocm = aFilterName.endsWith("VBA");
+
+ if (!bDocm)
+ {
+ // Check whether application is in headless mode
+ if (!Application::IsHeadlessModeEnabled())
+ {
+ uno::Reference<document::XStorageBasedDocument> xStorageBasedDocument(
+ pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY);
+ if (xStorageBasedDocument.is())
+ {
+ uno::Reference<embed::XStorage> xDocumentStorage =
+ xStorageBasedDocument->getDocumentStorage();
+ if (xDocumentStorage.is() && xDocumentStorage->hasByName(u"_MS_VBA_Macros"_ustr))
+ {
+ // Let user know that macros won't be saved in this format
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(
+ nullptr,
+ VclMessageType::Warning, VclButtonsType::OkCancel,
+ SwResId(STR_CANT_SAVE_MACROS))
+ );
+ if (xBox->run() == RET_CANCEL)
+ return false;
+ }
+ }
+ }
+ }
+
// get SwPaM*
// FIXME so far we get SwPaM for the entire document; probably we should
// be able to output just the selection as well - though no idea how to
@@ -75,10 +106,6 @@ bool DocxExportFilter::exportDocument()
pCurPam->SetMark();
*pCurPam->GetPoint() = *aPam.Start();
- OUString aFilterName;
- getMediaDescriptor()[utl::MediaDescriptor::PROP_FILTERNAME()] >>= aFilterName;
- bool bDocm = aFilterName.endsWith("VBA");
-
// export the document
// (in a separate block so that it's destructed before the commit)
{
diff --git a/sw/source/filter/ww8/docxhelper.hxx b/sw/source/filter/ww8/docxhelper.hxx
index e3f3609c615b..7807ec7aa5a8 100644
--- a/sw/source/filter/ww8/docxhelper.hxx
+++ b/sw/source/filter/ww8/docxhelper.hxx
@@ -14,7 +14,7 @@
#include <string_view>
-#include <rtl/ustring.hxx>
+#include <sal/types.h>
struct DocxStringTokenMap
{
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index 539eb63c20b1..4722e7ce4079 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -10,14 +10,19 @@
#include "docxsdrexport.hxx"
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/drawing/PointSequenceSequence.hpp>
-#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
#include <editeng/lrspitem.hxx>
#include <editeng/ulspitem.hxx>
#include <editeng/shaditem.hxx>
#include <editeng/opaqitem.hxx>
#include <editeng/boxitem.hxx>
+#include <svx/svdoashp.hxx>
#include <svx/svdogrp.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdobjkind.hxx>
+#include <svx/svditer.hxx>
+#include <svx/EnhancedCustomShape2d.hxx>
#include <oox/token/namespaces.hxx>
+#include <oox/token/relationship.hxx>
#include <textboxhelper.hxx>
#include <fmtanchr.hxx>
#include <fmtsrnd.hxx>
@@ -32,12 +37,11 @@
#include <comphelper/flagguard.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/sequenceashashmap.hxx>
-#include <sal/log.hxx>
#include <frmfmt.hxx>
#include <IDocumentDrawModelAccess.hxx>
-#include <tools/diagnose_ex.h>
-#include <svx/xlnwtit.hxx>
+#include <svx/svdtrans.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
using namespace com::sun::star;
using namespace oox;
@@ -74,7 +78,7 @@ OUString lclGetAnchorIdFromGrabBag(const SdrObject* pObj)
aGrabBagName = "FrameInteropGrabBag";
else
aGrabBagName = "InteropGrabBag";
- uno::Sequence<beans::PropertyValue> propList = lclGetProperty(xShape, aGrabBagName);
+ const uno::Sequence<beans::PropertyValue> propList = lclGetProperty(xShape, aGrabBagName);
auto pProp
= std::find_if(propList.begin(), propList.end(),
[](const beans::PropertyValue& rProp) { return rProp.Name == "AnchorId"; });
@@ -87,29 +91,39 @@ void lclMovePositionWithRotation(awt::Point& aPos, const Size& rSize, Degree100
{
// code from ImplEESdrWriter::ImplFlipBoundingBox (filter/source/msfilter/eschesdo.cxx)
// TODO: refactor
-
+ // MSO uses left|top of the unrotated object rectangle as position. When you rotate that rectangle
+ // around its center and build a snap rectangle S from it, then left|top of S has to be the
+ // position used in LO. This method converts LOs aPos to the position used by MSO.
+
+ // rSize has to be size of the logicRect of the object. For calculating the diff, we build a
+ // rectangle with left|top A = (-fWidthHalf | -fHeightHalf) and
+ // right|top B = (fWidthHalf | -fHeightHalf). The rotation matrix R is here
+ // fcos fsin
+ // -fsin fcos
+ // Left of rectangle S = X-coord of R * A, Top of rectangle S = Y-coord of R * B
+
+ // Use nRotation in [0;9000], for to have only one and not four cases.
if (nRotation100 == 0_deg100)
return;
- sal_Int64 nRotation = nRotation100.get();
- if (nRotation < 0)
- nRotation = (36000 + nRotation) % 36000;
- if (nRotation % 18000 == 0)
- nRotation = 0;
- while (nRotation > 9000)
- nRotation = (18000 - (nRotation % 18000));
-
- double fVal = static_cast<double>(nRotation) * F_PI18000;
- double fCos = cos(fVal);
+ if (nRotation100 < 0_deg100)
+ nRotation100 = (36000_deg100 + nRotation100) % 36000_deg100;
+ if (nRotation100 % 18000_deg100 == 0_deg100)
+ nRotation100 = 0_deg100; // prevents endless loop
+ while (nRotation100 > 9000_deg100)
+ nRotation100 = 18000_deg100 - (nRotation100 % 18000_deg100);
+
+ double fVal = toRadians(nRotation100);
+ double fCos = (nRotation100 == 9000_deg100) ? 0.0 : cos(fVal);
double fSin = sin(fVal);
- double nWidthHalf = static_cast<double>(rSize.Width()) / 2;
- double nHeightHalf = static_cast<double>(rSize.Height()) / 2;
+ double fWidthHalf = static_cast<double>(rSize.Width()) / 2.0;
+ double fHeightHalf = static_cast<double>(rSize.Height()) / 2.0;
- double nXDiff = fSin * nHeightHalf + fCos * nWidthHalf - nWidthHalf;
- double nYDiff = fSin * nWidthHalf + fCos * nHeightHalf - nHeightHalf;
+ double fXDiff = fSin * fHeightHalf + fCos * fWidthHalf - fWidthHalf;
+ double fYDiff = fSin * fWidthHalf + fCos * fHeightHalf - fHeightHalf;
- aPos.X += nXDiff;
- aPos.Y += nYDiff;
+ aPos.X += fXDiff + 0.5;
+ aPos.Y += fYDiff + 0.5;
}
/// Determines if the anchor is inside a paragraph.
@@ -118,10 +132,310 @@ bool IsAnchorTypeInsideParagraph(const ww8::Frame* pFrame)
const SwFormatAnchor& rAnchor = pFrame->GetFrameFormat().GetAttrSet().GetAnchor();
return rAnchor.GetAnchorId() != RndStdIds::FLY_AT_PAGE;
}
+
+bool lcl_IsRotateAngleValid(const SdrObject& rObj)
+{
+ // Some shape types report a rotation angle but are not actually rotated, because all rotation
+ // have been incorporated.
+ switch (rObj.GetObjIdentifier())
+ {
+ case SdrObjKind::Group:
+ case SdrObjKind::Line:
+ case SdrObjKind::PolyLine:
+ case SdrObjKind::PathLine:
+ case SdrObjKind::PathFill:
+ return false;
+ default:
+ return true;
+ }
+}
+
+void lcl_calculateMSOBaseRectangle(const SdrObject& rObj, double& rfMSOLeft, double& rfMSORight,
+ double& rfMSOTop, double& rfMSOBottom,
+ const bool bIsWord2007Image)
+{
+ // Word rotates around shape center, LO around left/top. Thus logic rectangle of LO is not
+ // directly usable as 'base rectangle'.
+ double fCenterX = (rObj.GetSnapRect().Left() + rObj.GetSnapRect().Right()) / 2.0;
+ double fCenterY = (rObj.GetSnapRect().Top() + rObj.GetSnapRect().Bottom()) / 2.0;
+ double fHalfWidth = rObj.GetLogicRect().getOpenWidth() / 2.0;
+ double fHalfHeight = rObj.GetLogicRect().getOpenHeight() / 2.0;
+
+ // MSO swaps width and height depending on rotation angle; exception: Word 2007 (vers 12) never
+ // swaps width and height for images.
+ double fRotation
+ = lcl_IsRotateAngleValid(rObj) ? toDegrees(NormAngle36000(rObj.GetRotateAngle())) : 0.0;
+ if (((fRotation > 45.0 && fRotation <= 135.0) || (fRotation > 225.0 && fRotation <= 315.0))
+ && !bIsWord2007Image)
+ {
+ rfMSOLeft = fCenterX - fHalfHeight;
+ rfMSORight = fCenterX + fHalfHeight;
+ rfMSOTop = fCenterY - fHalfWidth;
+ rfMSOBottom = fCenterY + fHalfWidth;
+ }
+ else
+ {
+ rfMSOLeft = fCenterX - fHalfWidth;
+ rfMSORight = fCenterX + fHalfWidth;
+ rfMSOTop = fCenterY - fHalfHeight;
+ rfMSOBottom = fCenterY + fHalfHeight;
+ }
+}
+
+void lcl_calculateRawEffectExtent(sal_Int32& rLeft, sal_Int32& rTop, sal_Int32& rRight,
+ sal_Int32& rBottom, const SdrObject& rObj,
+ const bool bUseBoundRect, const bool bIsWord2007Image)
+{
+ // This method calculates the extent needed, to let Word use the same outer area for the object
+ // as LO. Word uses as 'base rectangle' the unrotated shape rectangle, maybe having swapped width
+ // and height depending on rotation angle and version of Word.
+ double fMSOLeft;
+ double fMSORight;
+ double fMSOTop;
+ double fMSOBottom;
+ lcl_calculateMSOBaseRectangle(rObj, fMSOLeft, fMSORight, fMSOTop, fMSOBottom, bIsWord2007Image);
+
+ tools::Rectangle aLORect = bUseBoundRect ? rObj.GetCurrentBoundRect() : rObj.GetSnapRect();
+ rLeft = fMSOLeft - aLORect.Left();
+ rRight = aLORect.Right() - fMSORight;
+ rTop = fMSOTop - aLORect.Top();
+ rBottom = aLORect.Bottom() - fMSOBottom;
+ // Result values might be negative, e.g for a custom shape 'Arc'.
+ return;
+}
+
+bool lcl_makeSingleDistAndEffectExtentNonNegative(sal_Int64& rDist, sal_Int32& rExt)
+{
+ // A negative effectExtent is allowed in OOXML, but Word cannot handle it (bug in Word). It
+ // might occur, if the BoundRect in LO is smaller than the base rect in Word.
+ // A negative wrap distance from text is allowed in ODF. LO can currently only handle left and
+ // right negative values, see bug tdf#141880. Dist must be non-negative in OOXML.
+ // We try to compensate Dist vs effectExtent to get similar visual appearance.
+ if (rExt >= 0 && rDist >= 0)
+ return true;
+ if (rExt < 0 && rDist < 0)
+ {
+ rExt = 0;
+ rDist = 0;
+ return false;
+ }
+ if (rDist + static_cast<sal_Int64>(rExt) < 0) // different sign, so no overflow
+ {
+ rExt = 0;
+ rDist = 0;
+ return false;
+ }
+ // rDist + rExt >= 0
+ if (rDist < 0)
+ {
+ rExt += rDist;
+ rDist = 0;
+ }
+ else // rExt < 0
+ {
+ rDist += rExt;
+ rExt = 0;
+ }
+ return true;
+}
+
+bool lcl_makeDistAndExtentNonNegative(sal_Int64& rDistT, sal_Int64& rDistB, sal_Int64& rDistL,
+ sal_Int64& rDistR, sal_Int32& rLeftExt, sal_Int32& rTopExt,
+ sal_Int32& rRightExt, sal_Int32& rBottomExt)
+{
+ bool bLeft = lcl_makeSingleDistAndEffectExtentNonNegative(rDistL, rLeftExt);
+ bool bTop = lcl_makeSingleDistAndEffectExtentNonNegative(rDistT, rTopExt);
+ bool bRight = lcl_makeSingleDistAndEffectExtentNonNegative(rDistR, rRightExt);
+ bool bBottom = lcl_makeSingleDistAndEffectExtentNonNegative(rDistB, rBottomExt);
+ return bLeft && bTop && bRight && bBottom;
+}
+
+void lcl_makeSingleDistZeroAndExtentNonNegative(sal_Int64& rDist, sal_Int32& rExt)
+{
+ if (static_cast<double>(rDist) + static_cast<double>(rExt)
+ >= static_cast<double>(SAL_MAX_INT32))
+ rExt = SAL_MAX_INT32;
+ else if (static_cast<double>(rDist) + static_cast<double>(rExt) <= 0)
+ rExt = 0;
+ else // 0 < rDist + rExt < SAL_MAX_INT32
+ {
+ rExt = static_cast<sal_Int32>(rDist + rExt);
+ if (rExt < 0)
+ rExt = 0;
+ }
+ rDist = 0;
+}
+
+void lcl_makeDistZeroAndExtentNonNegative(sal_Int64& rDistT, sal_Int64& rDistB, sal_Int64& rDistL,
+ sal_Int64& rDistR, sal_Int32& rLeftExt,
+ sal_Int32& rTopExt, sal_Int32& rRightExt,
+ sal_Int32& rBottomExt)
+{
+ lcl_makeSingleDistZeroAndExtentNonNegative(rDistL, rLeftExt);
+ lcl_makeSingleDistZeroAndExtentNonNegative(rDistT, rTopExt);
+ lcl_makeSingleDistZeroAndExtentNonNegative(rDistR, rRightExt);
+ lcl_makeSingleDistZeroAndExtentNonNegative(rDistB, rBottomExt);
+}
+
+tools::Polygon lcl_CreateContourPolygon(SdrObject* pSdrObj)
+{
+ tools::Polygon aContour;
+ if (!pSdrObj)
+ {
+ // use rectangular default
+ aContour.Insert(0, Point(0, 0));
+ aContour.Insert(1, Point(21600, 0));
+ aContour.Insert(2, Point(21600, 21600));
+ aContour.Insert(3, Point(0, 21600));
+ aContour.Insert(4, Point(0, 0));
+ return aContour;
+ }
+
+ // Simple version for now: Use ready PolygonFromPolyPolygon().
+ // For that we first create a B2DPolyPolygon from the shape, that ideally contains
+ // the outline of the shape.
+ basegfx::B2DPolyPolygon aPolyPolygon;
+ switch (pSdrObj->GetObjIdentifier())
+ {
+ case SdrObjKind::CustomShape:
+ {
+ // EnhancedCustomShapeEngine::GetLineGeometry() is not directly usable, because the wrap
+ // polygon acts on the untransformed shape in Word. We do here similar as in
+ // GetLineGeometry(), but without transformations.
+ EnhancedCustomShape2d aCustomShape2d(*static_cast<SdrObjCustomShape*>(pSdrObj));
+ rtl::Reference<SdrObject> pLineGeometryObj = aCustomShape2d.CreateLineGeometry();
+ if (!pLineGeometryObj)
+ break;
+
+ // We might have got other object kinds than SdrPathObj, even groups.
+ SdrObjListIter aIter(*pLineGeometryObj, SdrIterMode::DeepWithGroups);
+ while (aIter.IsMore())
+ {
+ basegfx::B2DPolyPolygon aPP;
+ const SdrObject* pNext = aIter.Next();
+ if (auto pPathObj = dynamic_cast<const SdrPathObj*>(pNext))
+ aPP = pPathObj->GetPathPoly();
+ else
+ {
+ rtl::Reference<SdrObject> pNewObj
+ = pLineGeometryObj->ConvertToPolyObj(false, false);
+ SdrPathObj* pPath = dynamic_cast<SdrPathObj*>(pNewObj.get());
+ if (pPath)
+ aPP = pPath->GetPathPoly();
+ }
+ if (aPP.count())
+ aPolyPolygon.append(aPP);
+ }
+
+ if (!aPolyPolygon.count())
+ break;
+
+ // Make relative to range 0..21600, 0..21600
+ Point aCenter(pSdrObj->GetSnapRect().Center());
+ basegfx::B2DHomMatrix aTranslateToOrigin(
+ basegfx::utils::createTranslateB2DHomMatrix(-aCenter.X(), -aCenter.Y()));
+ aPolyPolygon.transform(aTranslateToOrigin);
+ const double fWidth(pSdrObj->GetLogicRect().getOpenWidth());
+ double fScaleX = fWidth == 0.0 ? 1.0 : 21600.0 / fWidth;
+ const double fHeight(pSdrObj->GetLogicRect().getOpenHeight());
+ double fScaleY = fHeight == 0.0 ? 1.0 : 21600.0 / fHeight;
+ basegfx::B2DHomMatrix aScale(basegfx::utils::createScaleB2DHomMatrix(fScaleX, fScaleY));
+ aPolyPolygon.transform(aScale);
+
+ basegfx::B2DHomMatrix aTranslateToCenter(
+ basegfx::utils::createTranslateB2DHomMatrix(10800.0, 10800.0));
+ aPolyPolygon.transform(aTranslateToCenter);
+ break;
+ } // end case OBJ_CUSTOMSHAPE
+ case SdrObjKind::Line:
+ {
+ aContour.Insert(0, Point(0, 0));
+ aContour.Insert(1, Point(21600, 21600));
+ aContour.Insert(2, Point(0, 0));
+ return aContour;
+ }
+ case SdrObjKind::PathFill:
+ case SdrObjKind::PathLine:
+ case SdrObjKind::FreehandFill:
+ case SdrObjKind::FreehandLine:
+ case SdrObjKind::PathPoly:
+ case SdrObjKind::PathPolyLine:
+ // case OBJ_POLY: FixMe: Creating wrap polygon would work, but export to DML is currently
+ // case OBJ_PLIN: disabled for unknown reason; related bug 75254.
+ {
+ // Includes removing any control points
+ rtl::Reference<SdrObject> pNewObj = pSdrObj->ConvertToPolyObj(false, false);
+ SdrPathObj* pConverted = dynamic_cast<SdrPathObj*>(pNewObj.get());
+ if (!pConverted)
+ break;
+ aPolyPolygon = pConverted->GetPathPoly();
+ pNewObj.clear();
+
+ // Word adds a line from last to first point. That will cut of indentations from being
+ // filled. To prevent this, the wrap polygon is lead along the path back to the first
+ // point and so indentation is kept.
+ if (!aPolyPolygon.isClosed())
+ {
+ basegfx::B2DPolyPolygon aReverse(aPolyPolygon);
+ aReverse.flip();
+ aPolyPolygon.append(aReverse);
+ }
+
+ // Make relative to range 0..21600, 0..21600
+ Point aCenter(pSdrObj->GetSnapRect().Center());
+ basegfx::B2DHomMatrix aTranslateToOrigin(
+ basegfx::utils::createTranslateB2DHomMatrix(-aCenter.X(), -aCenter.Y()));
+ aPolyPolygon.transform(aTranslateToOrigin);
+
+ const double fWidth(pSdrObj->GetLogicRect().getOpenWidth());
+ double fScaleX = fWidth == 0.0 ? 1.0 : 21600.0 / fWidth;
+ const double fHeight(pSdrObj->GetLogicRect().getOpenHeight());
+ double fScaleY = fHeight == 0.0 ? 1.0 : 21600.0 / fHeight;
+ basegfx::B2DHomMatrix aScale(
+ basegfx::utils::createScaleB2DHomMatrix(fScaleX, fScaleY));
+ aPolyPolygon.transform(aScale);
+
+ basegfx::B2DHomMatrix aTranslateToCenter(
+ basegfx::utils::createTranslateB2DHomMatrix(10800.0, 10800.0));
+ aPolyPolygon.transform(aTranslateToCenter);
+ break;
+ }
+ case SdrObjKind::NONE:
+ default:
+ break;
+ }
+
+ // Simple version for now: Use ready PolygonFromPolyPolygon()
+ const tools::PolyPolygon aToolsPolyPoly(aPolyPolygon);
+ aContour = sw::util::PolygonFromPolyPolygon(aToolsPolyPoly);
+
+ // The wrap polygon needs at least two points in OOXML and three points in Word.
+ switch (aContour.GetSize())
+ {
+ case 0:
+ // use rectangular default
+ aContour.Insert(0, Point(0, 0));
+ aContour.Insert(1, Point(21600, 0));
+ aContour.Insert(2, Point(21600, 21600));
+ aContour.Insert(3, Point(0, 21600));
+ aContour.Insert(4, Point(0, 0));
+ break;
+ case 1:
+ aContour.Insert(1, aContour.GetPoint(0));
+ aContour.Insert(2, aContour.GetPoint(0));
+ break;
+ case 2:
+ aContour.Insert(2, aContour.GetPoint(0));
+ break;
+ default:
+ break;
+ }
+ return aContour;
}
+} // end anonymous namespace
-ExportDataSaveRestore::ExportDataSaveRestore(DocxExport& rExport, sal_uLong nStt, sal_uLong nEnd,
- ww8::Frame const* pParentFrame)
+ExportDataSaveRestore::ExportDataSaveRestore(DocxExport& rExport, SwNodeOffset nStt,
+ SwNodeOffset nEnd, ww8::Frame const* pParentFrame)
: m_rExport(rExport)
{
m_rExport.SaveData(nStt, nEnd);
@@ -176,7 +490,8 @@ public:
/// Writes wp wrapper code around an SdrObject, which itself is written using drawingML syntax.
void textFrameShadow(const SwFrameFormat& rFrameFormat);
- static bool isSupportedDMLShape(const uno::Reference<drawing::XShape>& xShape);
+ static bool isSupportedDMLShape(const uno::Reference<drawing::XShape>& xShape,
+ const SdrObject* pSdrObject);
void setSerializer(const sax_fastparser::FSHelperPtr& pSerializer)
{
@@ -354,17 +669,22 @@ void DocxSdrExport::setFlyWrapAttrList(
void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, const Size& rSize)
{
+ const SwFormatSurround& rSurround(pFrameFormat->GetSurround());
+
+ // Word uses size excluding right edge. Caller writeDMLDrawing and writeDiagram are changed for
+ // now. ToDo: Look whether the other callers give the size this way.
m_pImpl->setDrawingOpen(true);
m_pImpl->setParagraphHasDrawing(true);
m_pImpl->getSerializer()->startElementNS(XML_w, XML_drawing);
+ const SdrObject* pObj = pFrameFormat->FindRealSdrObject();
- // tdf#135047: It must be allowed to find in parents too, but default value of bInP parameter
- // for GetLRSpace() and GetULSpace() is true, so no direct setting is required.
- const SvxLRSpaceItem& aLRSpaceItem = pFrameFormat->GetLRSpace();
- const SvxULSpaceItem& aULSpaceItem = pFrameFormat->GetULSpace();
-
- bool isAnchor;
+ // LO determines the place needed for the object from wrap type, wrap margin ('distance to text'),
+ // object type and anchor type. Word uses dist* for user set margins and effectExtent for place
+ // needed for effects like shadow and glow, for fat stroke and for rotation. We map the LO values
+ // to values needed by Word so that the appearance is the same as far as possible.
+ // All values in Twips, change to EMU is done immediately before writing out.
+ bool isAnchor; // true XML_anchor, false XML_inline
if (m_pImpl->getFlyFrameGraphic())
{
isAnchor = false; // make Graphic object inside DMLTextFrame & VMLTextFrame as Inline
@@ -374,55 +694,146 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
isAnchor = pFrameFormat->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR;
}
- // Count effectExtent values, their value is needed before dist{T,B,L,R} is written.
- SvxShadowItem aShadowItem = pFrameFormat->GetShadow();
- sal_Int32 nLeftExt = 0;
- sal_Int32 nRightExt = 0;
- sal_Int32 nTopExt = 0;
- sal_Int32 nBottomExt = 0;
- if (aShadowItem.GetLocation() != SvxShadowLocation::NONE)
+ // tdf#135047: It must be allowed to find in parents too, but default value of bInP parameter
+ // for GetLRSpace() and GetULSpace() is true, so no direct setting is required.
+ const SvxLRSpaceItem& aLRSpaceItem = pFrameFormat->GetLRSpace();
+ const SvxULSpaceItem& aULSpaceItem = pFrameFormat->GetULSpace();
+ sal_Int64 nDistT = aULSpaceItem.GetUpper();
+ sal_Int64 nDistB = aULSpaceItem.GetLower();
+ sal_Int64 nDistL = aLRSpaceItem.GetLeft();
+ sal_Int64 nDistR = aLRSpaceItem.GetRight();
+
+ // LibreOffice behaves different for frames and drawing objects, but MS Office treats frames
+ // as drawing objects too. Therefore we transform the values from frame so as if they come
+ // from a drawing object.
+ sal_Int32 nWidthDiff(0);
+ sal_Int32 nHeightDiff(0);
+ sal_Int32 nPosXDiff(0);
+ sal_Int32 nPosYDiff(0);
+ sal_Int32 nLeftExt(0);
+ sal_Int32 nRightExt(0);
+ sal_Int32 nTopExt(0);
+ sal_Int32 nBottomExt(0);
+
+ if ((!pObj) || (pObj && (pObj->GetObjIdentifier() == SdrObjKind::SwFlyDrawObjIdentifier)))
{
- sal_Int32 nShadowWidth(TwipsToEMU(aShadowItem.GetWidth()));
- switch (aShadowItem.GetLocation())
+ // Frame objects have a restricted shadow and no further effects. They have border instead of
+ // stroke. LO includes shadow and border in the object size, but Word not.
+ SvxShadowItem aShadowItem = pFrameFormat->GetShadow();
+ if (aShadowItem.GetLocation() != SvxShadowLocation::NONE)
{
- case SvxShadowLocation::TopLeft:
- nTopExt = nLeftExt = nShadowWidth;
- break;
- case SvxShadowLocation::TopRight:
- nTopExt = nRightExt = nShadowWidth;
- break;
- case SvxShadowLocation::BottomLeft:
- nBottomExt = nLeftExt = nShadowWidth;
- break;
- case SvxShadowLocation::BottomRight:
- nBottomExt = nRightExt = nShadowWidth;
- break;
- case SvxShadowLocation::NONE:
- case SvxShadowLocation::End:
- break;
+ sal_Int32 nShadowWidth(aShadowItem.GetWidth());
+ switch (aShadowItem.GetLocation())
+ {
+ case SvxShadowLocation::TopLeft:
+ nTopExt = nLeftExt = nShadowWidth;
+ nPosXDiff = nLeftExt; // actual move is postponed
+ nPosYDiff = nTopExt;
+ nWidthDiff = -nLeftExt; // actual size extent is postponed
+ nHeightDiff = -nTopExt;
+ break;
+ case SvxShadowLocation::TopRight:
+ nTopExt = nRightExt = nShadowWidth;
+ nPosYDiff = nTopExt;
+ nWidthDiff = -nRightExt;
+ nHeightDiff = -nTopExt;
+ break;
+ case SvxShadowLocation::BottomLeft:
+ nBottomExt = nLeftExt = nShadowWidth;
+ nPosXDiff = nLeftExt;
+ nWidthDiff = -nLeftExt;
+ nHeightDiff = -nBottomExt;
+ break;
+ case SvxShadowLocation::BottomRight:
+ nBottomExt = nRightExt = nShadowWidth;
+ nWidthDiff = -nRightExt;
+ nHeightDiff = -nBottomExt;
+ break;
+ case SvxShadowLocation::NONE:
+ case SvxShadowLocation::End:
+ break;
+ }
}
+ // ToDo: Position refers to outer edge of border in LO, but to center of border in Word.
+ // Adaption is missing here. Frames in LO have no stroke but border. The current conversion
+ // from border to line treats borders like table borders. That might give wrong values
+ // for drawing frames.
+
+ if (pObj && pObj->GetRotateAngle() != 0_deg100)
+ {
+ Degree100 nRotation = pObj->GetRotateAngle();
+ const SwRect aBoundRect(pFrameFormat->FindLayoutRect());
+ tools::Long nMSOWidth = rSize.Width();
+ tools::Long nMSOHeight = rSize.Height();
+ if ((nRotation > 4500_deg100 && nRotation <= 13500_deg100)
+ || (nRotation > 22500_deg100 && nRotation <= 31500_deg100))
+ std::swap(nMSOWidth, nMSOHeight);
+ nBottomExt += (aBoundRect.Height() - 1 - nMSOHeight) / 2;
+ nTopExt += (aBoundRect.Height() - 1 - nMSOHeight) / 2;
+ nLeftExt += (aBoundRect.Width() - nMSOWidth) / 2;
+ nRightExt += (aBoundRect.Width() - nMSOWidth) / 2;
+ }
+ lcl_makeDistAndExtentNonNegative(nDistT, nDistB, nDistL, nDistR, nLeftExt, nTopExt,
+ nRightExt, nBottomExt);
+
+ // ToDo: Inline rotated image fails because it would need wrapTight, what is not possible.
+ // ToDo: Image plus shadow fails because of wrong shadow direction.
}
- else if (const SdrObject* pObject = pFrameFormat->FindRealSdrObject())
+ else // other objects than frames. pObj exists.
{
- // No shadow, but we have an idea what was the original effectExtent.
- uno::Any aAny;
- pObject->GetGrabBagItem(aAny);
- comphelper::SequenceAsHashMap aGrabBag(aAny);
- auto it = aGrabBag.find("CT_EffectExtent");
- if (it != aGrabBag.end())
+ // Word 2007 makes no width-height-swap for images. Detect this situation.
+ sal_Int32 nMode = m_pImpl->getExport().getWordCompatibilityModeFromGrabBag();
+ bool bIsWord2007Image(nMode > 0 && nMode < 14
+ && pObj->GetObjIdentifier() == SdrObjKind::Graphic);
+
+ // Word cannot handle negative EffectExtent although allowed in OOXML, the 'dist' attributes
+ // may not be negative. Take care of that.
+ if (isAnchor)
{
- comphelper::SequenceAsHashMap aEffectExtent(it->second);
- for (const std::pair<const OUString, uno::Any>& rDirection : aEffectExtent)
+ lcl_calculateRawEffectExtent(nLeftExt, nTopExt, nRightExt, nBottomExt, *pObj, true,
+ bIsWord2007Image);
+ // We have calculated the effectExtent from boundRect, therefore half stroke width is
+ // already contained.
+ // ToDo: The other half of the stroke width needs to be subtracted from padding.
+ // Where is that?
+
+ // The import has added a difference to dist* in case of contour wrap for to give a
+ // rendering nearer to Word. In that case, we need to subtract it on export.
+ uno::Any aAny;
+ pObj->GetGrabBagItem(aAny);
+ comphelper::SequenceAsHashMap aGrabBag(aAny);
+ auto it = aGrabBag.find("AnchorDistDiff");
+ if (it != aGrabBag.end())
{
- if (rDirection.first == "l" && rDirection.second.has<sal_Int32>())
- nLeftExt = rDirection.second.get<sal_Int32>();
- else if (rDirection.first == "t" && rDirection.second.has<sal_Int32>())
- nTopExt = rDirection.second.get<sal_Int32>();
- else if (rDirection.first == "r" && rDirection.second.has<sal_Int32>())
- nRightExt = rDirection.second.get<sal_Int32>();
- else if (rDirection.first == "b" && rDirection.second.has<sal_Int32>())
- nBottomExt = rDirection.second.get<sal_Int32>();
+ comphelper::SequenceAsHashMap aAnchorDistDiff(it->second);
+ for (const std::pair<const comphelper::OUStringAndHashCode, uno::Any>& rDiff :
+ aAnchorDistDiff)
+ {
+ const OUString& rName = rDiff.first.maString;
+ if (rName == "distTDiff" && rDiff.second.has<sal_Int32>())
+ nDistT -= round(rDiff.second.get<sal_Int32>());
+ else if (rName == "distBDiff" && rDiff.second.has<sal_Int32>())
+ nDistB -= round(rDiff.second.get<sal_Int32>());
+ else if (rName == "distLDiff" && rDiff.second.has<sal_Int32>())
+ nDistL -= rDiff.second.get<sal_Int32>();
+ else if (rName == "distRDiff" && rDiff.second.has<sal_Int32>())
+ nDistR -= rDiff.second.get<sal_Int32>();
+ }
}
+ // ToDo: bool bCompansated = ... to be later able to switch from wrapSquare to wrapTight,
+ // if wrapSquare would require negative effectExtent.
+ lcl_makeDistAndExtentNonNegative(nDistT, nDistB, nDistL, nDistR, nLeftExt, nTopExt,
+ nRightExt, nBottomExt);
+ }
+ else
+ {
+ lcl_calculateRawEffectExtent(nLeftExt, nTopExt, nRightExt, nBottomExt, *pObj, false,
+ bIsWord2007Image);
+ // nDistT,... contain the needed distances from import or set by user. But Word
+ // ignores Dist attributes of inline shapes. So we move all needed distances to
+ // effectExtent and force effectExtent to non-negative.
+ lcl_makeDistZeroAndExtentNonNegative(nDistT, nDistB, nDistL, nDistR, nLeftExt, nTopExt,
+ nRightExt, nBottomExt);
}
}
@@ -430,12 +841,9 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
{
rtl::Reference<sax_fastparser::FastAttributeList> attrList
= sax_fastparser::FastSerializerHelper::createAttrList();
+
bool bOpaque = pFrameFormat->GetOpaque().GetValue();
- awt::Point aPos(pFrameFormat->GetHoriOrient().GetPos(),
- pFrameFormat->GetVertOrient().GetPos());
- const SdrObject* pObj = pFrameFormat->FindRealSdrObject();
- Degree100 nRotation(0);
- if (pObj != nullptr)
+ if (pObj)
{
// SdrObjects know their layer, consider that instead of the frame format.
bOpaque = pObj->GetLayer()
@@ -444,46 +852,17 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
!= pFrameFormat->GetDoc()
->getIDocumentDrawModelAccess()
.GetInvisibleHellId();
-
- // Do not do this with lines.
- if (pObj->GetObjIdentifier() != OBJ_LINE)
- {
- nRotation = pObj->GetRotateAngle();
- lclMovePositionWithRotation(aPos, rSize, nRotation);
- }
}
attrList->add(XML_behindDoc, bOpaque ? "0" : "1");
- sal_Int32 nLineWidth = 0;
- if (const SdrObject* pObject = pFrameFormat->FindRealSdrObject())
- {
- nLineWidth = pObject->GetMergedItem(XATTR_LINEWIDTH).GetValue();
- }
- // Extend distance with the effect extent if the shape is not rotated, which is the opposite
- // of the mapping done at import time.
- // The type of dist* attributes is unsigned, so make sure no negative value is written.
- sal_Int64 nTopExtDist = nRotation ? 0 : nTopExt;
- nTopExtDist -= TwipsToEMU(nLineWidth / 2);
- sal_Int64 nDistT = std::max(static_cast<sal_Int64>(0),
- TwipsToEMU(aULSpaceItem.GetUpper()) - nTopExtDist);
- attrList->add(XML_distT, OString::number(nDistT).getStr());
- sal_Int64 nBottomExtDist = nRotation ? 0 : nBottomExt;
- nBottomExtDist -= TwipsToEMU(nLineWidth / 2);
- sal_Int64 nDistB = std::max(static_cast<sal_Int64>(0),
- TwipsToEMU(aULSpaceItem.GetLower()) - nBottomExtDist);
- attrList->add(XML_distB, OString::number(nDistB).getStr());
- sal_Int64 nLeftExtDist = nRotation ? 0 : nLeftExt;
- nLeftExtDist -= TwipsToEMU(nLineWidth / 2);
- sal_Int64 nDistL = std::max(static_cast<sal_Int64>(0),
- TwipsToEMU(aLRSpaceItem.GetLeft()) - nLeftExtDist);
- attrList->add(XML_distL, OString::number(nDistL).getStr());
- sal_Int64 nRightExtDist = nRotation ? 0 : nRightExt;
- nRightExtDist -= TwipsToEMU(nLineWidth / 2);
- sal_Int64 nDistR = std::max(static_cast<sal_Int64>(0),
- TwipsToEMU(aLRSpaceItem.GetRight()) - nRightExtDist);
- attrList->add(XML_distR, OString::number(nDistR).getStr());
+ attrList->add(XML_distT, OString::number(TwipsToEMU(nDistT)));
+ attrList->add(XML_distB, OString::number(TwipsToEMU(nDistB)));
+ attrList->add(XML_distL, OString::number(TwipsToEMU(nDistL)));
+ attrList->add(XML_distR, OString::number(TwipsToEMU(nDistR)));
+
attrList->add(XML_simplePos, "0");
attrList->add(XML_locked, "0");
+
bool bLclInTabCell = true;
if (pObj)
{
@@ -493,33 +872,59 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
if (xShapeProps.is())
xShapeProps->getPropertyValue("IsFollowingTextFlow") >>= bLclInTabCell;
}
+
+ const SwFormatHoriOrient& rHoriOri(pFrameFormat->GetHoriOrient());
+ if (rSurround.GetValue() == text::WrapTextMode_THROUGH
+ && rHoriOri.GetRelationOrient() == text::RelOrientation::FRAME)
+ {
+ // "In front of text" and horizontal positioning relative to Column is ignored on
+ // import, add it back here.
+ bLclInTabCell = true;
+ }
+
if (bLclInTabCell)
attrList->add(XML_layoutInCell, "1");
else
attrList->add(XML_layoutInCell, "0");
+
bool bAllowOverlap = pFrameFormat->GetWrapInfluenceOnObjPos().GetAllowOverlap();
attrList->add(XML_allowOverlap, bAllowOverlap ? "1" : "0");
- if (pObj != nullptr)
+
+ if (pObj)
// It seems 0 and 1 have special meaning: just start counting from 2 to avoid issues with that.
attrList->add(XML_relativeHeight, OString::number(pObj->GetOrdNum() + 2));
else
// relativeHeight is mandatory attribute, if value is not present, we must write default value
attrList->add(XML_relativeHeight, "0");
- if (pObj != nullptr)
+
+ if (pObj)
{
OUString sAnchorId = lclGetAnchorIdFromGrabBag(pObj);
if (!sAnchorId.isEmpty())
- attrList->addNS(XML_wp14, XML_anchorId,
- OUStringToOString(sAnchorId, RTL_TEXTENCODING_UTF8));
+ attrList->addNS(XML_wp14, XML_anchorId, sAnchorId);
}
+
m_pImpl->getSerializer()->startElementNS(XML_wp, XML_anchor, attrList);
+
m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_simplePos, XML_x, "0", XML_y,
"0"); // required, unused
+
+ // Position is either determined by coordinates aPos or alignment keywords like 'center'.
+ // First prepare them.
+ const SwFormatVertOrient& rVertOri(pFrameFormat->GetVertOrient());
+ awt::Point aPos(rHoriOri.GetPos(), rVertOri.GetPos());
+
+ aPos.X += nPosXDiff; // Make the postponed position move of frames.
+ aPos.Y += nPosYDiff;
+ if (pObj && lcl_IsRotateAngleValid(*pObj)
+ && pObj->GetObjIdentifier() != SdrObjKind::SwFlyDrawObjIdentifier)
+ lclMovePositionWithRotation(aPos, rSize, pObj->GetRotateAngle());
+
const char* relativeFromH;
const char* relativeFromV;
const char* alignH = nullptr;
const char* alignV = nullptr;
- switch (pFrameFormat->GetVertOrient().GetRelationOrient())
+ switch (rVertOri.GetRelationOrient())
{
case text::RelOrientation::PAGE_PRINT_AREA:
relativeFromV = "margin";
@@ -537,17 +942,21 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
relativeFromV = "paragraph";
break;
case text::RelOrientation::TEXT_LINE:
+ relativeFromV = "line";
+ // Word's "line" is "below the bottom of the line", our TEXT_LINE is
+ // "towards top, from the bottom of the line", so invert the vertical position.
+ aPos.Y *= -1;
+ break;
default:
relativeFromV = "line";
break;
}
- switch (pFrameFormat->GetVertOrient().GetVertOrient())
+ switch (rVertOri.GetVertOrient())
{
case text::VertOrientation::TOP:
case text::VertOrientation::CHAR_TOP:
case text::VertOrientation::LINE_TOP:
- if (pFrameFormat->GetVertOrient().GetRelationOrient()
- == text::RelOrientation::TEXT_LINE)
+ if (rVertOri.GetRelationOrient() == text::RelOrientation::TEXT_LINE)
alignV = "bottom";
else
alignV = "top";
@@ -555,8 +964,7 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
case text::VertOrientation::BOTTOM:
case text::VertOrientation::CHAR_BOTTOM:
case text::VertOrientation::LINE_BOTTOM:
- if (pFrameFormat->GetVertOrient().GetRelationOrient()
- == text::RelOrientation::TEXT_LINE)
+ if (rVertOri.GetRelationOrient() == text::RelOrientation::TEXT_LINE)
alignV = "top";
else
alignV = "bottom";
@@ -569,7 +977,7 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
default:
break;
}
- switch (pFrameFormat->GetHoriOrient().GetRelationOrient())
+ switch (rHoriOri.GetRelationOrient())
{
case text::RelOrientation::PAGE_PRINT_AREA:
relativeFromH = "margin";
@@ -591,7 +999,7 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
relativeFromH = "column";
break;
}
- switch (pFrameFormat->GetHoriOrient().GetHoriOrient())
+ switch (rHoriOri.GetHoriOrient())
{
case text::HoriOrientation::LEFT:
alignH = "left";
@@ -611,8 +1019,11 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
default:
break;
}
+
+ // write out horizontal position
m_pImpl->getSerializer()->startElementNS(XML_wp, XML_positionH, XML_relativeFrom,
relativeFromH);
+
/**
* Sizes of integral types
* climits header defines constants with the limits of integral types for the specific system and compiler implementation used.
@@ -620,6 +1031,7 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
**/
const sal_Int64 MAX_INTEGER_VALUE = SAL_MAX_INT32;
const sal_Int64 MIN_INTEGER_VALUE = SAL_MIN_INT32;
+
if (alignH != nullptr)
{
m_pImpl->getSerializer()->startElementNS(XML_wp, XML_align);
@@ -654,9 +1066,10 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
m_pImpl->getSerializer()->endElementNS(XML_wp, XML_posOffset);
}
m_pImpl->getSerializer()->endElementNS(XML_wp, XML_positionH);
+
+ // write out vertical position
m_pImpl->getSerializer()->startElementNS(XML_wp, XML_positionV, XML_relativeFrom,
relativeFromV);
-
sal_Int64 nPosYEMU = TwipsToEMU(aPos.Y);
// tdf#93675, 0 below line/paragraph and/or top line/paragraph with
@@ -693,27 +1106,25 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
}
m_pImpl->getSerializer()->endElementNS(XML_wp, XML_positionV);
}
- else
+ else // inline
{
+ // nDist is forced to zero above and ignored by Word anyway, so write 0 directly.
rtl::Reference<sax_fastparser::FastAttributeList> aAttrList
= sax_fastparser::FastSerializerHelper::createAttrList();
- aAttrList->add(XML_distT, OString::number(TwipsToEMU(aULSpaceItem.GetUpper())).getStr());
- aAttrList->add(XML_distB, OString::number(TwipsToEMU(aULSpaceItem.GetLower())).getStr());
- aAttrList->add(XML_distL, OString::number(TwipsToEMU(aLRSpaceItem.GetLeft())).getStr());
- aAttrList->add(XML_distR, OString::number(TwipsToEMU(aLRSpaceItem.GetRight())).getStr());
- const SdrObject* pObj = pFrameFormat->FindRealSdrObject();
- if (pObj != nullptr)
+ aAttrList->add(XML_distT, OString::number(0));
+ aAttrList->add(XML_distB, OString::number(0));
+ aAttrList->add(XML_distL, OString::number(0));
+ aAttrList->add(XML_distR, OString::number(0));
+ if (pObj)
{
OUString sAnchorId = lclGetAnchorIdFromGrabBag(pObj);
if (!sAnchorId.isEmpty())
- aAttrList->addNS(XML_wp14, XML_anchorId,
- OUStringToOString(sAnchorId, RTL_TEXTENCODING_UTF8));
+ aAttrList->addNS(XML_wp14, XML_anchorId, sAnchorId);
}
m_pImpl->getSerializer()->startElementNS(XML_wp, XML_inline, aAttrList);
}
- // now the common parts
- // extent of the image
+ // now the common parts 'extent' and 'effectExtent'
/**
* Extent width is of type long ( i.e cx & cy ) as
*
@@ -731,188 +1142,203 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
* 2147483647( MAX_INTEGER_VALUE ).
* Therefore changing the following accordingly so that LO sync's up with MSO.
**/
- sal_uInt64 cx
- = TwipsToEMU(std::clamp(rSize.Width(), tools::Long(0), tools::Long(SAL_MAX_INT32)));
+ sal_uInt64 cx = TwipsToEMU(
+ std::clamp(rSize.Width() + nWidthDiff, tools::Long(0), tools::Long(SAL_MAX_INT32)));
OString aWidth(OString::number(std::min(cx, sal_uInt64(SAL_MAX_INT32))));
- sal_uInt64 cy
- = TwipsToEMU(std::clamp(rSize.Height(), tools::Long(0), tools::Long(SAL_MAX_INT32)));
+ sal_uInt64 cy = TwipsToEMU(
+ std::clamp(rSize.Height() + nHeightDiff, tools::Long(0), tools::Long(SAL_MAX_INT32)));
OString aHeight(OString::number(std::min(cy, sal_uInt64(SAL_MAX_INT32))));
m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_extent, XML_cx, aWidth, XML_cy, aHeight);
- // effectExtent, extent including the effect (shadow only for now)
- m_pImpl->getSerializer()->singleElementNS(
- XML_wp, XML_effectExtent, XML_l, OString::number(nLeftExt), XML_t, OString::number(nTopExt),
- XML_r, OString::number(nRightExt), XML_b, OString::number(nBottomExt));
-
- // See if we know the exact wrap type from grab-bag.
- sal_Int32 nWrapToken = 0;
- if (const SdrObject* pObject = pFrameFormat->FindRealSdrObject())
+ // XML_effectExtent, includes effects, fat stroke and rotation
+ // FixMe: tdf141880. Because LibreOffice currently cannot handle negative vertical margins, they
+ // were forced to zero on import. Especially bottom margin of inline anchored rotated objects are
+ // affected. If the object was not changed, it would be better to export the original values
+ // from grab-Bag. Unfortunately there exists no marker for "not changed", so a heuristic is used
+ // here: If current left, top and right margins do not differ more than 1Hmm = 635EMU from the
+ // values in grab-Bag, it is likely, that the object was not changed and we restore the values
+ // from grab-Bag.
+ sal_Int64 nLeftExtEMU = TwipsToEMU(nLeftExt);
+ sal_Int64 nTopExtEMU = TwipsToEMU(nTopExt);
+ sal_Int64 nRightExtEMU = TwipsToEMU(nRightExt);
+ sal_Int64 nBottomExtEMU = TwipsToEMU(nBottomExt);
+ if (pObj)
{
uno::Any aAny;
- pObject->GetGrabBagItem(aAny);
+ pObj->GetGrabBagItem(aAny);
comphelper::SequenceAsHashMap aGrabBag(aAny);
- auto it = aGrabBag.find("EG_WrapType");
+ auto it = aGrabBag.find("CT_EffectExtent");
if (it != aGrabBag.end())
{
- auto sType = it->second.get<OUString>();
- if (sType == "wrapTight")
- nWrapToken = XML_wrapTight;
- else if (sType == "wrapThrough")
- nWrapToken = XML_wrapThrough;
- else
- SAL_WARN("sw.ww8",
- "DocxSdrExport::startDMLAnchorInline: unexpected EG_WrapType value");
-
- m_pImpl->getSerializer()->startElementNS(XML_wp, nWrapToken, XML_wrapText, "bothSides");
-
- it = aGrabBag.find("CT_WrapPath");
- if (it != aGrabBag.end())
+ comphelper::SequenceAsHashMap aEffectExtent(it->second);
+ sal_Int64 nLeftExtGrabBag(0);
+ sal_Int64 nTopExtGrabBag(0);
+ sal_Int64 nRightExtGrabBag(0);
+ sal_Int64 nBottomExtGrabBag(0);
+ for (const std::pair<const comphelper::OUStringAndHashCode, uno::Any>& rDirection :
+ aEffectExtent)
{
- m_pImpl->getSerializer()->startElementNS(XML_wp, XML_wrapPolygon, XML_edited, "0");
- auto aSeqSeq = it->second.get<drawing::PointSequenceSequence>();
- auto aPoints(comphelper::sequenceToContainer<std::vector<awt::Point>>(aSeqSeq[0]));
- for (auto i = aPoints.begin(); i != aPoints.end(); ++i)
- {
- awt::Point& rPoint = *i;
- m_pImpl->getSerializer()->singleElementNS(
- XML_wp, (i == aPoints.begin() ? XML_start : XML_lineTo), XML_x,
- OString::number(rPoint.X), XML_y, OString::number(rPoint.Y));
- }
- m_pImpl->getSerializer()->endElementNS(XML_wp, XML_wrapPolygon);
+ const OUString& rName = rDirection.first.maString;
+ if (rName == "l" && rDirection.second.has<sal_Int32>())
+ nLeftExtGrabBag = rDirection.second.get<sal_Int32>();
+ else if (rName == "t" && rDirection.second.has<sal_Int32>())
+ nTopExtGrabBag = rDirection.second.get<sal_Int32>();
+ else if (rName == "r" && rDirection.second.has<sal_Int32>())
+ nRightExtGrabBag = rDirection.second.get<sal_Int32>();
+ else if (rName == "b" && rDirection.second.has<sal_Int32>())
+ nBottomExtGrabBag = rDirection.second.get<sal_Int32>();
+ }
+ if (abs(nLeftExtEMU - nLeftExtGrabBag) <= 635 && abs(nTopExtEMU - nTopExtGrabBag) <= 635
+ && abs(nRightExtEMU - nRightExtGrabBag) <= 635)
+ {
+ nLeftExtEMU = nLeftExtGrabBag;
+ nTopExtEMU = nTopExtGrabBag;
+ nRightExtEMU = nRightExtGrabBag;
+ nBottomExtEMU = nBottomExtGrabBag;
}
-
- m_pImpl->getSerializer()->endElementNS(XML_wp, nWrapToken);
}
}
+ m_pImpl->getSerializer()->singleElementNS(
+ XML_wp, XML_effectExtent, XML_l, OString::number(nLeftExtEMU), XML_t,
+ OString::number(nTopExtEMU), XML_r, OString::number(nRightExtEMU), XML_b,
+ OString::number(nBottomExtEMU));
+
+ if (!isAnchor)
+ return; // OOXML 'inline' has not wrap type at all
+
+ // XML_anchor has exact one of types wrapNone, wrapSquare, wrapTight, wrapThrough and
+ // WrapTopAndBottom. Map our own types to them as far as possible.
+
+ if (rSurround.GetValue() == css::text::WrapTextMode_THROUGH
+ || rSurround.GetValue() == css::text::WrapTextMode_THROUGHT)
+ {
+ m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapNone);
+ return;
+ }
- // Or if we have a contour.
- if (!nWrapToken && pFrameFormat->GetSurround().IsContour())
+ if (rSurround.GetValue() == css::text::WrapTextMode_NONE)
{
- if (const SwNoTextNode* pNd = sw::util::GetNoTextNodeFromSwFrameFormat(*pFrameFormat))
+ m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapTopAndBottom);
+ return;
+ }
+
+ // All remaining cases need attribute XML_wrapText
+ OUString sWrapType;
+ switch (rSurround.GetSurround())
+ {
+ case text::WrapTextMode_DYNAMIC:
+ sWrapType = OUString("largest");
+ break;
+ case text::WrapTextMode_LEFT:
+ sWrapType = OUString("left");
+ break;
+ case text::WrapTextMode_RIGHT:
+ sWrapType = OUString("right");
+ break;
+ case text::WrapTextMode_PARALLEL:
+ default:
+ sWrapType = OUString("bothSides");
+ break;
+ }
+
+ // ToDo: Exclude cases where LibreOffice wrap without contour is different
+ // from Word XML_wrapSquare or where direct use of distances not possible and workaround
+ // will be done using wrapPolygon.
+ // ToDo: handle case Writer frame, where contour can be set in LibreOffice but is not rendered.
+
+ // This case needs no wrapPolygon
+ if (!rSurround.IsContour())
+ {
+ m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapSquare, XML_wrapText, sWrapType);
+ return;
+ }
+
+ // Contour wrap.
+ const sal_Int32 nWrapToken = rSurround.IsOutside() ? XML_wrapTight : XML_wrapThrough;
+
+ // ToDo: cases where wrapPolygon is used as workaround.
+
+ // Own wrap polygon exists only for TextGraphicObject and TextEmbeddedObject. It might be edited
+ // by user. If such exists, we use it and we are done.
+ if (const SwNoTextNode* pNd = sw::util::GetNoTextNodeFromSwFrameFormat(*pFrameFormat))
+ {
+ const tools::PolyPolygon* pPolyPoly = pNd->HasContour();
+ if (pPolyPoly && pPolyPoly->Count())
{
- const tools::PolyPolygon* pPolyPoly = pNd->HasContour();
- if (pPolyPoly && pPolyPoly->Count())
+ tools::Polygon aPoly
+ = sw::util::CorrectWordWrapPolygonForExport(*pPolyPoly, pNd, /*bCorrectCrop=*/true);
+ if (aPoly.GetSize() >= 3)
{
- nWrapToken = XML_wrapTight;
m_pImpl->getSerializer()->startElementNS(XML_wp, nWrapToken, XML_wrapText,
- "bothSides");
-
+ sWrapType);
+ // ToDo: Test whether XML_edited true or false gives better results.
m_pImpl->getSerializer()->startElementNS(XML_wp, XML_wrapPolygon, XML_edited, "0");
- tools::Polygon aPoly = sw::util::CorrectWordWrapPolygonForExport(
- *pPolyPoly, pNd, /*bCorrectCrop=*/true);
- for (sal_uInt16 i = 0; i < aPoly.GetSize(); ++i)
- m_pImpl->getSerializer()->singleElementNS(
- XML_wp, (i == 0 ? XML_start : XML_lineTo), XML_x,
- OString::number(aPoly[i].X()), XML_y, OString::number(aPoly[i].Y()));
+ m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_start, XML_x,
+ OString::number(aPoly[0].X()), XML_y,
+ OString::number(aPoly[0].Y()));
+ for (sal_uInt16 i = 1; i < aPoly.GetSize(); ++i)
+ m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_lineTo, XML_x,
+ OString::number(aPoly[i].X()), XML_y,
+ OString::number(aPoly[i].Y()));
m_pImpl->getSerializer()->endElementNS(XML_wp, XML_wrapPolygon);
m_pImpl->getSerializer()->endElementNS(XML_wp, nWrapToken);
+ return;
}
}
- else if (SdrObject* pSdrObj = const_cast<SdrObject*>(pFrameFormat->FindRealSdrObject()))
+ }
+
+ // If this shape comes from ooxml import, there might be a wrap polygon in InteropGrabBag.
+ // Wrap polygons can be edited by users in Word. They are independent from changing shape size or
+ // rotation. So it is likely, that it is still usable.
+ if (pObj)
+ {
+ uno::Any aAny;
+ pObj->GetGrabBagItem(aAny);
+ comphelper::SequenceAsHashMap aGrabBag(aAny);
+ auto it = aGrabBag.find("CT_WrapPath");
+ if (it != aGrabBag.end())
{
- // In this case we likely had an odt document to be exported to docx.
- // There is no grab-bag or something else so for a workaround,
- // let's export the geometry of the shape...
- // First get the UNO-shape
- uno::Reference<drawing::XShape> xShape(pSdrObj->getUnoShape(), uno::UNO_QUERY);
+ m_pImpl->getSerializer()->startElementNS(XML_wp, nWrapToken, XML_wrapText, sWrapType);
- if (xShape && xShape->getShapeType() == u"com.sun.star.drawing.CustomShape")
+ m_pImpl->getSerializer()->startElementNS(XML_wp, XML_wrapPolygon, XML_edited, "0");
+ auto aSeqSeq = it->second.get<drawing::PointSequenceSequence>();
+ const auto& rPoints = aSeqSeq[0];
+ for (auto i = rPoints.begin(); i != rPoints.end(); ++i)
{
- try
- {
- // Get the properties of the Xshape
- uno::Reference<beans::XPropertySet> XProps(xShape, uno::UNO_QUERY);
- // Get the "CustomShapeGeometry" property and from its Any() make a hashMap
- comphelper::SequenceAsHashMap aCustomShapeGeometry(
- XProps->getPropertyValue("CustomShapeGeometry"));
- // Get the "Path" property and from its Any() make a hashMap
- comphelper::SequenceAsHashMap aPath(aCustomShapeGeometry.getValue("Path"));
- // From the Any() of the "Coordinates" property get the points
- uno::Sequence<css::drawing::EnhancedCustomShapeParameterPair> aCoords
- = aPath.getValue("Coordinates")
- .get<uno::Sequence<css::drawing::EnhancedCustomShapeParameterPair>>();
-
- // Check if only one side wrap allowed
- OUString sWrapType;
- switch (pFrameFormat->GetSurround().GetSurround())
- {
- case text::WrapTextMode_DYNAMIC:
- sWrapType = OUString("largest");
- break;
- case text::WrapTextMode_LEFT:
- sWrapType = OUString("left");
- break;
- case text::WrapTextMode_RIGHT:
- sWrapType = OUString("right");
- break;
- case text::WrapTextMode_PARALLEL:
- default:
- sWrapType = OUString("bothSides");
- break;
- }
-
- // And export:
- nWrapToken = XML_wrapTight;
- m_pImpl->getSerializer()->startElementNS(XML_wp, nWrapToken, XML_wrapText,
- sWrapType);
-
- m_pImpl->getSerializer()->startElementNS(XML_wp, XML_wrapPolygon, XML_edited,
- "0");
-
- try
- {
- // There are the coordinates
- for (sal_Int32 i = 0; i < aCoords.getLength(); i++)
- m_pImpl->getSerializer()->singleElementNS(
- XML_wp, (i == 0 ? XML_start : XML_lineTo), XML_x,
- OString::number(aCoords[i].First.Value.get<double>()), XML_y,
- OString::number(aCoords[i].Second.Value.get<double>()));
- }
- catch (const uno::Exception& e)
- {
- // e.g. on exporting first attachment of tdf#94591 to docx
- TOOLS_WARN_EXCEPTION(
- "sw.ww8",
- "DocxSdrExport::startDMLAnchorInline: bad coordinate: " << e.Message);
- }
-
- m_pImpl->getSerializer()->endElementNS(XML_wp, XML_wrapPolygon);
-
- m_pImpl->getSerializer()->endElementNS(XML_wp, nWrapToken);
- }
- catch (uno::Exception& e)
- {
- TOOLS_WARN_EXCEPTION(
- "sw.ww8", "DocxSdrExport::startDMLAnchorInline: exception: " << e.Message);
- }
+ const awt::Point& rPoint = *i;
+ m_pImpl->getSerializer()->singleElementNS(
+ XML_wp, (i == rPoints.begin() ? XML_start : XML_lineTo), XML_x,
+ OString::number(rPoint.X), XML_y, OString::number(rPoint.Y));
}
+ m_pImpl->getSerializer()->endElementNS(XML_wp, XML_wrapPolygon);
+
+ m_pImpl->getSerializer()->endElementNS(XML_wp, nWrapToken);
+ return;
}
}
- // No? Then just approximate based on what we have.
- if (!isAnchor || nWrapToken)
- return;
-
- switch (pFrameFormat->GetSurround().GetValue())
- {
- case css::text::WrapTextMode_NONE:
- m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapTopAndBottom);
- break;
- case css::text::WrapTextMode_THROUGH:
- m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapNone);
- break;
- case css::text::WrapTextMode_PARALLEL:
- m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapSquare, XML_wrapText,
- "bothSides");
- break;
- case css::text::WrapTextMode_DYNAMIC:
- default:
- m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapSquare, XML_wrapText,
- "largest");
- break;
- }
+ // In this case we likely had an odt document to be exported to docx. ODF does not know the
+ // concept of a wrap polygon and LibreOffice has no one internally. So as a workaround, we
+ // generate a wrap polygon from the shape geometry.
+ tools::Polygon aContour = lcl_CreateContourPolygon(const_cast<SdrObject*>(pObj));
+
+ // lcl_CreateContourPolygon() ensures at least three points
+ m_pImpl->getSerializer()->startElementNS(XML_wp, nWrapToken, XML_wrapText, sWrapType);
+
+ // ToDo: Test whether XML_edited true or false gives better results.
+ m_pImpl->getSerializer()->startElementNS(XML_wp, XML_wrapPolygon, XML_edited, "0");
+ m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_start, XML_x,
+ OString::number(aContour.GetPoint(0).getX()), XML_y,
+ OString::number(aContour.GetPoint(0).getY()));
+ for (sal_uInt32 i = 1; i < aContour.GetSize(); i++)
+ m_pImpl->getSerializer()->singleElementNS(
+ XML_wp, XML_lineTo, XML_x, OString::number(aContour.GetPoint(i).getX()), XML_y,
+ OString::number(aContour.GetPoint(i).getY()));
+ m_pImpl->getSerializer()->endElementNS(XML_wp, XML_wrapPolygon);
+
+ m_pImpl->getSerializer()->endElementNS(XML_wp, nWrapToken);
}
void DocxSdrExport::endDMLAnchorInline(const SwFrameFormat* pFrameFormat)
@@ -952,7 +1378,7 @@ void DocxSdrExport::writeVMLDrawing(const SdrObject* sdrObj, const SwFrameFormat
static bool lcl_isLockedCanvas(const uno::Reference<drawing::XShape>& xShape)
{
- uno::Sequence<beans::PropertyValue> propList = lclGetProperty(xShape, "InteropGrabBag");
+ const uno::Sequence<beans::PropertyValue> propList = lclGetProperty(xShape, "InteropGrabBag");
/*
* Export as Locked Canvas only if the property
* is in the PropertySet
@@ -962,35 +1388,69 @@ static bool lcl_isLockedCanvas(const uno::Reference<drawing::XShape>& xShape)
});
}
+void AddExtLst(sax_fastparser::FSHelperPtr const& pFS, DocxExport const& rExport,
+ uno::Reference<beans::XPropertySet> const& xShape)
+{
+ if (xShape->getPropertyValue("Decorative").get<bool>())
+ {
+ pFS->startElementNS(XML_a, XML_extLst,
+ // apparently for DOCX the namespace isn't declared on the root
+ FSNS(XML_xmlns, XML_a),
+ rExport.GetFilter().getNamespaceURL(OOX_NS(dml)));
+ pFS->startElementNS(XML_a, XML_ext,
+ // Word uses this "URI" which is obviously not a URI
+ XML_uri, "{C183D7F6-B498-43B3-948B-1728B52AA6E4}");
+ pFS->singleElementNS(XML_adec, XML_decorative, FSNS(XML_xmlns, XML_adec),
+ "http://schemas.microsoft.com/office/drawing/2017/decorative", XML_val,
+ "1");
+ pFS->endElementNS(XML_a, XML_ext);
+ pFS->endElementNS(XML_a, XML_extLst);
+ }
+}
+
void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrameFormat* pFrameFormat,
int nAnchorId)
{
- uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pSdrObject)->getUnoShape(),
- uno::UNO_QUERY_THROW);
- if (!Impl::isSupportedDMLShape(xShape))
+ uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pSdrObject)->getUnoShape());
+ if (!Impl::isSupportedDMLShape(xShape, pSdrObject))
return;
m_pImpl->getExport().DocxAttrOutput().GetSdtEndBefore(pSdrObject);
sax_fastparser::FSHelperPtr pFS = m_pImpl->getSerializer();
- Size aSize(pSdrObject->GetLogicRect().GetWidth(), pSdrObject->GetLogicRect().GetHeight());
+ Size aSize(pSdrObject->GetLogicRect().getOpenWidth(),
+ pSdrObject->GetLogicRect().getOpenHeight());
startDMLAnchorInline(pFrameFormat, aSize);
rtl::Reference<sax_fastparser::FastAttributeList> pDocPrAttrList
= sax_fastparser::FastSerializerHelper::createAttrList();
- pDocPrAttrList->add(XML_id, OString::number(nAnchorId).getStr());
- pDocPrAttrList->add(XML_name, OUStringToOString(pSdrObject->GetName(), RTL_TEXTENCODING_UTF8));
+ pDocPrAttrList->add(XML_id, OString::number(nAnchorId));
+ pDocPrAttrList->add(XML_name, pSdrObject->GetName());
if (!pSdrObject->GetTitle().isEmpty())
- pDocPrAttrList->add(XML_title,
- OUStringToOString(pSdrObject->GetTitle(), RTL_TEXTENCODING_UTF8));
+ pDocPrAttrList->add(XML_title, pSdrObject->GetTitle());
if (!pSdrObject->GetDescription().isEmpty())
- pDocPrAttrList->add(XML_descr,
- OUStringToOString(pSdrObject->GetDescription(), RTL_TEXTENCODING_UTF8));
+ pDocPrAttrList->add(XML_descr, pSdrObject->GetDescription());
if (!pSdrObject->IsVisible()
&& pFrameFormat->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR)
- pDocPrAttrList->add(XML_hidden, OString::number(1).getStr());
- pFS->singleElementNS(XML_wp, XML_docPr, pDocPrAttrList);
+ pDocPrAttrList->add(XML_hidden, OString::number(1));
+
+ pFS->startElementNS(XML_wp, XML_docPr, pDocPrAttrList);
+ OUString sHyperlink = pSdrObject->getHyperlink();
+ if (!sHyperlink.isEmpty())
+ {
+ OUString sRelId = m_pImpl->getExport().GetFilter().addRelation(
+ pFS->getOutputStream(), oox::getRelationship(Relationship::HYPERLINK),
+ oox::drawingml::URLTransformer().getTransformedString(sHyperlink),
+ oox::drawingml::URLTransformer().isExternalURL(sHyperlink));
+ pFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), sRelId,
+ FSNS(XML_xmlns, XML_a),
+ m_pImpl->getExport().GetFilter().getNamespaceURL(OOX_NS(dml)));
+ }
+ uno::Reference<beans::XPropertySet> const xShapeProps(xShape, uno::UNO_QUERY_THROW);
+ AddExtLst(pFS, m_pImpl->getExport(), xShapeProps);
+
+ pFS->endElementNS(XML_wp, XML_docPr);
uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY_THROW);
const char* pNamespace = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
@@ -1113,23 +1573,33 @@ void DocxSdrExport::Impl::textFrameShadow(const SwFrameFormat& rFrameFormat)
XML_offset, aOffset);
}
-bool DocxSdrExport::Impl::isSupportedDMLShape(const uno::Reference<drawing::XShape>& xShape)
+bool DocxSdrExport::Impl::isSupportedDMLShape(const uno::Reference<drawing::XShape>& xShape,
+ const SdrObject* pSdrObject)
{
uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY_THROW);
if (xServiceInfo->supportsService("com.sun.star.drawing.PolyPolygonShape")
|| xServiceInfo->supportsService("com.sun.star.drawing.PolyLineShape"))
return false;
+ uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
// For signature line shapes, we don't want DML, just the VML shape.
if (xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape"))
{
- uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
bool bIsSignatureLineShape = false;
xShapeProperties->getPropertyValue("IsSignatureLine") >>= bIsSignatureLineShape;
if (bIsSignatureLineShape)
return false;
}
+ // A FontWork shape with bitmap fill cannot be expressed as a modern 'abc transform'
+ // in Word. Only the legacy VML WordArt allows bitmap fill.
+ if (pSdrObject->IsTextPath())
+ {
+ css::drawing::FillStyle eFillStyle = css::drawing::FillStyle_SOLID;
+ xShapeProperties->getPropertyValue("FillStyle") >>= eFillStyle;
+ if (eFillStyle == css::drawing::FillStyle_BITMAP)
+ return false;
+ }
return true;
}
@@ -1142,15 +1612,14 @@ void DocxSdrExport::writeDMLAndVMLDrawing(const SdrObject* sdrObj,
// Depending on the shape type, we actually don't write the shape as DML.
OUString sShapeType;
ShapeFlag nMirrorFlags = ShapeFlag::NONE;
- uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(sdrObj)->getUnoShape(),
- uno::UNO_QUERY_THROW);
+ uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(sdrObj)->getUnoShape());
MSO_SPT eShapeType
= EscherPropertyContainer::GetCustomShapeType(xShape, nMirrorFlags, sShapeType);
// In case we are already inside a DML block, then write the shape only as VML, turn out that's allowed to do.
// A common service created in util to check for VML shapes which are allowed to have textbox in content
- if ((msfilter::util::HasTextBoxContent(eShapeType)) && Impl::isSupportedDMLShape(xShape)
+ if ((msfilter::util::HasTextBoxContent(eShapeType)) && Impl::isSupportedDMLShape(xShape, sdrObj)
&& (!bDMLAndVMLDrawingOpen || lcl_isLockedCanvas(xShape))) // Locked canvas is OK inside DML
{
m_pImpl->getSerializer()->startElementNS(XML_mc, XML_AlternateContent);
@@ -1242,9 +1711,10 @@ void DocxSdrExport::writeDiagram(const SdrObject* sdrObject, const SwFrameFormat
uno::UNO_QUERY);
// write necessary tags to document.xml
- Size aSize(sdrObject->GetSnapRect().GetWidth(), sdrObject->GetSnapRect().GetHeight());
+ Size aSize(sdrObject->GetSnapRect().getOpenWidth(), sdrObject->GetSnapRect().getOpenHeight());
startDMLAnchorInline(&rFrameFormat, aSize);
+ m_pImpl->getDrawingML()->SetFS(m_pImpl->getSerializer());
m_pImpl->getDrawingML()->WriteDiagram(xShape, nDiagramId);
endDMLAnchorInline(&rFrameFormat);
@@ -1255,8 +1725,8 @@ void DocxSdrExport::writeOnlyTextOfFrame(ww8::Frame const* pParentFrame)
const SwFrameFormat& rFrameFormat = pParentFrame->GetFrameFormat();
const SwNodeIndex* pNodeIndex = rFrameFormat.GetContent().GetContentIdx();
- sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex() + 1 : 0;
- sal_uLong nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0;
+ SwNodeOffset nStt = pNodeIndex ? pNodeIndex->GetIndex() + 1 : SwNodeOffset(0);
+ SwNodeOffset nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : SwNodeOffset(0);
//Save data here and restore when out of scope
ExportDataSaveRestore aDataGuard(m_pImpl->getExport(), nStt, nEnd, pParentFrame);
@@ -1294,10 +1764,15 @@ void DocxSdrExport::writeBoxItemLine(const SvxBoxItem& rBox)
}
sax_fastparser::FSHelperPtr pFS = m_pImpl->getSerializer();
- double fConverted(editeng::ConvertBorderWidthToWord(pBorderLine->GetBorderLineStyle(),
- pBorderLine->GetWidth()));
- OString sWidth(OString::number(TwipsToEMU(fConverted)));
- pFS->startElementNS(XML_a, XML_ln, XML_w, sWidth);
+ if (pBorderLine->GetWidth() == SvxBorderLineWidth::Hairline)
+ pFS->startElementNS(XML_a, XML_ln);
+ else
+ {
+ double fConverted(editeng::ConvertBorderWidthToWord(pBorderLine->GetBorderLineStyle(),
+ pBorderLine->GetWidth()));
+ OString sWidth(OString::number(TwipsToEMU(fConverted)));
+ pFS->startElementNS(XML_a, XML_ln, XML_w, sWidth);
+ }
pFS->startElementNS(XML_a, XML_solidFill);
OString sColor(msfilter::util::ConvertColor(pBorderLine->GetColor()));
@@ -1320,8 +1795,8 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho
const SwFrameFormat& rFrameFormat = pParentFrame->GetFrameFormat();
const SwNodeIndex* pNodeIndex = rFrameFormat.GetContent().GetContentIdx();
- sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex() + 1 : 0;
- sal_uLong nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0;
+ SwNodeOffset nStt = pNodeIndex ? pNodeIndex->GetIndex() + 1 : SwNodeOffset(0);
+ SwNodeOffset nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : SwNodeOffset(0);
//Save data here and restore when out of scope
ExportDataSaveRestore aDataGuard(m_pImpl->getExport(), nStt, nEnd, pParentFrame);
@@ -1354,10 +1829,26 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho
rtl::Reference<sax_fastparser::FastAttributeList> pDocPrAttrList
= sax_fastparser::FastSerializerHelper::createAttrList();
- pDocPrAttrList->add(XML_id, OString::number(nAnchorId).getStr());
- pDocPrAttrList->add(XML_name,
- OUStringToOString(rFrameFormat.GetName(), RTL_TEXTENCODING_UTF8));
- pFS->singleElementNS(XML_wp, XML_docPr, pDocPrAttrList);
+ pDocPrAttrList->add(XML_id, OString::number(nAnchorId));
+ pDocPrAttrList->add(XML_name, rFrameFormat.GetName());
+
+ pFS->startElementNS(XML_wp, XML_docPr, pDocPrAttrList);
+
+ OUString sHyperlink;
+ if (xPropertySet.is())
+ xPropertySet->getPropertyValue("HyperLinkURL") >>= sHyperlink;
+ if (!sHyperlink.isEmpty())
+ {
+ OUString sRelId = m_pImpl->getExport().GetFilter().addRelation(
+ pFS->getOutputStream(), oox::getRelationship(Relationship::HYPERLINK),
+ oox::drawingml::URLTransformer().getTransformedString(sHyperlink),
+ oox::drawingml::URLTransformer().isExternalURL(sHyperlink));
+ pFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), sRelId,
+ FSNS(XML_xmlns, XML_a),
+ m_pImpl->getExport().GetFilter().getNamespaceURL(OOX_NS(dml)));
+ }
+
+ pFS->endElementNS(XML_wp, XML_docPr);
pFS->startElementNS(XML_a, XML_graphic, FSNS(XML_xmlns, XML_a),
m_pImpl->getExport().GetFilter().getNamespaceURL(OOX_NS(dml)));
@@ -1372,11 +1863,11 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho
{
uno::Sequence<beans::PropertyValue> propList;
xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList;
- auto pProp = std::find_if(propList.begin(), propList.end(),
+ auto pProp = std::find_if(std::cbegin(propList), std::cend(propList),
[](const beans::PropertyValue& rProp) {
return rProp.Name == "mso-rotation-angle";
});
- if (pProp != propList.end())
+ if (pProp != std::cend(propList))
aRotation = pProp->Value;
}
sal_Int32 nTmp;
@@ -1404,11 +1895,11 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho
{
uno::Sequence<beans::PropertyValue> propList;
xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList;
- auto pProp = std::find_if(propList.begin(), propList.end(),
+ auto pProp = std::find_if(std::cbegin(propList), std::cend(propList),
[](const beans::PropertyValue& rProp) {
return rProp.Name == "mso-orig-shape-type";
});
- if (pProp != propList.end())
+ if (pProp != std::cend(propList))
pProp->Value >>= shapeType;
}
//Empty shapeType will lead to corruption so to avoid that shapeType is set to default i.e. "rect"
@@ -1517,7 +2008,10 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho
m_pImpl->getBodyPrAttrList()->add(XML_vert, "eaVert");
else if (rDirection.GetValue() == SvxFrameDirection::Vertical_LR_BT)
m_pImpl->getBodyPrAttrList()->add(XML_vert, "vert270");
-
+ else if (rDirection.GetValue() == SvxFrameDirection::Vertical_LR_TB)
+ m_pImpl->getBodyPrAttrList()->add(XML_vert, "mongolianVert");
+ else if (rDirection.GetValue() == SvxFrameDirection::Vertical_RL_TB90)
+ m_pImpl->getBodyPrAttrList()->add(XML_vert, "vert");
{
::comphelper::FlagRestorationGuard const g(m_pImpl->m_bFlyFrameGraphic, true);
comphelper::ValueRestorationGuard vg(m_pImpl->getExport().m_nTextTyp, TXT_TXTBOX);
@@ -1604,8 +2098,8 @@ void DocxSdrExport::writeVMLTextFrame(ww8::Frame const* pParentFrame, bool bText
const SwFrameFormat& rFrameFormat = pParentFrame->GetFrameFormat();
const SwNodeIndex* pNodeIndex = rFrameFormat.GetContent().GetContentIdx();
- sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex() + 1 : 0;
- sal_uLong nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0;
+ SwNodeOffset nStt = pNodeIndex ? pNodeIndex->GetIndex() + 1 : SwNodeOffset(0);
+ SwNodeOffset nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : SwNodeOffset(0);
//Save data here and restore when out of scope
ExportDataSaveRestore aDataGuard(m_pImpl->getExport(), nStt, nEnd, pParentFrame);
@@ -1621,7 +2115,7 @@ void DocxSdrExport::writeVMLTextFrame(ww8::Frame const* pParentFrame, bool bText
m_pImpl->getTextFrameStyle() = "position:absolute";
if (!bTextBoxOnly)
{
- OString sRotation(OString::number(m_pImpl->getDMLandVMLTextFrameRotation().get() / -100));
+ OString sRotation(OString::number(-toDegrees(m_pImpl->getDMLandVMLTextFrameRotation())));
m_pImpl->getExport().SdrExporter().getTextFrameStyle().append(";rotation:" + sRotation);
}
m_pImpl->getExport().OutputFormat(pParentFrame->GetFrameFormat(), false, false, true);
@@ -1632,8 +2126,16 @@ void DocxSdrExport::writeVMLTextFrame(ww8::Frame const* pParentFrame, bool bText
{
OUString sAnchorId = lclGetAnchorIdFromGrabBag(pObject);
if (!sAnchorId.isEmpty())
- m_pImpl->getFlyAttrList()->addNS(XML_w14, XML_anchorId,
- OUStringToOString(sAnchorId, RTL_TEXTENCODING_UTF8));
+ m_pImpl->getFlyAttrList()->addNS(XML_w14, XML_anchorId, sAnchorId);
+
+ uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pObject)->getUnoShape(),
+ uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
+ OUString sHyperlink;
+ if (xShapeProps.is())
+ xShapeProps->getPropertyValue("HyperLinkURL") >>= sHyperlink;
+ if (!sHyperlink.isEmpty())
+ m_pImpl->getFlyAttrList()->add(XML_href, sHyperlink);
}
rtl::Reference<FastAttributeList> xFlyAttrList(m_pImpl->getFlyAttrList());
m_pImpl->getFlyAttrList().clear();
@@ -1651,17 +2153,18 @@ void DocxSdrExport::writeVMLTextFrame(ww8::Frame const* pParentFrame, bool bText
if (m_pImpl->getFlyFillAttrList().is())
{
rtl::Reference<FastAttributeList> xFlyFillAttrList(m_pImpl->getFlyFillAttrList());
- m_pImpl->getFlyFillAttrList().clear();
pFS->singleElementNS(XML_v, XML_fill, xFlyFillAttrList);
}
if (m_pImpl->getDashLineStyleAttr().is())
{
rtl::Reference<FastAttributeList> xDashLineStyleAttr(m_pImpl->getDashLineStyleAttr());
- m_pImpl->getDashLineStyleAttr().clear();
pFS->singleElementNS(XML_v, XML_stroke, xDashLineStyleAttr);
}
pFS->startElementNS(XML_v, XML_textbox, xTextboxAttrList);
}
+ m_pImpl->getFlyFillAttrList().clear();
+ m_pImpl->getDashLineStyleAttr().clear();
+
pFS->startElementNS(XML_w, XML_txbxContent);
{
::comphelper::FlagRestorationGuard const g(m_pImpl->m_bFlyFrameGraphic, true);
diff --git a/sw/source/filter/ww8/docxsdrexport.hxx b/sw/source/filter/ww8/docxsdrexport.hxx
index f8c22167b11e..5ad93d51ad8e 100644
--- a/sw/source/filter/ww8/docxsdrexport.hxx
+++ b/sw/source/filter/ww8/docxsdrexport.hxx
@@ -14,7 +14,9 @@
#include <rtl/strbuf.hxx>
#include <sax/fshelper.hxx>
-#include <tools/solar.h>
+#include <nodeoffset.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
namespace rtl
{
@@ -39,7 +41,7 @@ class ExportDataSaveRestore
private:
DocxExport& m_rExport;
public:
- ExportDataSaveRestore(DocxExport& rExport, sal_uLong nStt, sal_uLong nEnd, ww8::Frame const* pParentFrame);
+ ExportDataSaveRestore(DocxExport& rExport, SwNodeOffset nStt, SwNodeOffset nEnd, ww8::Frame const* pParentFrame);
~ExportDataSaveRestore();
};
@@ -99,6 +101,9 @@ public:
void writeBoxItemLine(const SvxBoxItem& rBox);
};
+void AddExtLst(sax_fastparser::FSHelperPtr const& pFS, DocxExport const& rExport,
+ css::uno::Reference<css::beans::XPropertySet> const& xShape);
+
#endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXSDREXPORT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxtableexport.cxx b/sw/source/filter/ww8/docxtableexport.cxx
new file mode 100644
index 000000000000..f6bbef34dddc
--- /dev/null
+++ b/sw/source/filter/ww8/docxtableexport.cxx
@@ -0,0 +1,898 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "docxattributeoutput.hxx"
+
+#include <com/sun/star/text/XTextTable.hpp>
+
+#include <comphelper/sequence.hxx>
+#include <svl/grabbagitem.hxx>
+#include <sax/fshelper.hxx>
+#include <editeng/ulspitem.hxx>
+#include <comphelper/string.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/brushitem.hxx>
+#include <tools/datetimeutils.hxx>
+
+#include <fmtfsize.hxx>
+#include <unocoll.hxx>
+#include <formatflysplit.hxx>
+#include <IDocumentSettingAccess.hxx>
+#include <frmatr.hxx>
+#include <swmodule.hxx>
+#include <fmtrowsplt.hxx>
+#include <fmtwrapinfluenceonobjpos.hxx>
+
+#include "docxexportfilter.hxx"
+#include "docxhelper.hxx"
+
+using namespace com::sun::star;
+using namespace sax_fastparser;
+using namespace oox;
+
+namespace
+{
+/// Does the same as comphelper::string::padToLength(), but extends the start, not the end.
+OString lcl_padStartToLength(OString const& aString, sal_Int32 nLen, char cFill)
+{
+ if (nLen > aString.getLength())
+ {
+ sal_Int32 nDiff = nLen - aString.getLength();
+ OStringBuffer aBuffer;
+ comphelper::string::padToLength(aBuffer, nDiff, cFill);
+ aBuffer.append(aString);
+ return aBuffer.makeStringAndClear();
+ }
+ else
+ return aString;
+}
+
+//Keep this function in-sync with the one in writerfilter/.../SettingsTable.cxx
+//Since this is not import code, "-1" needs to be handled as the mode that LO will save as.
+//To identify how your code should handle a "-1", look in DocxExport::WriteSettings().
+sal_Int32 lcl_getWordCompatibilityMode(const DocxExport& rDocExport)
+{
+ sal_Int32 nWordCompatibilityMode = rDocExport.getWordCompatibilityModeFromGrabBag();
+
+ // TODO: this is duplicated, better store it in DocxExport member?
+ if (!rDocExport.m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::ADD_EXT_LEADING))
+ {
+ if (nWordCompatibilityMode == -1 || 14 < nWordCompatibilityMode)
+ {
+ nWordCompatibilityMode = 14;
+ }
+ }
+
+ return nWordCompatibilityMode;
+}
+
+void CollectFloatingTableAttributes(DocxExport& rExport, const ww8::Frame& rFrame,
+ ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner,
+ rtl::Reference<FastAttributeList>& pAttributes)
+{
+ // we export the values of the surrounding Frame
+ OString sOrientation;
+ sal_Int32 nValue;
+
+ // If tblpXSpec or tblpYSpec are present, we do not write tblpX or tblpY!
+ OString sTblpXSpec = DocxAttributeOutput::convertToOOXMLHoriOrient(
+ rFrame.GetFrameFormat().GetHoriOrient().GetHoriOrient(),
+ rFrame.GetFrameFormat().GetHoriOrient().IsPosToggle());
+ OString sTblpYSpec = DocxAttributeOutput::convertToOOXMLVertOrient(
+ rFrame.GetFrameFormat().GetVertOrient().GetVertOrient());
+
+ sOrientation = DocxAttributeOutput::convertToOOXMLVertOrientRel(
+ rFrame.GetFrameFormat().GetVertOrient().GetRelationOrient());
+ pAttributes->add(FSNS(XML_w, XML_vertAnchor), sOrientation);
+
+ if (!sTblpYSpec.isEmpty())
+ pAttributes->add(FSNS(XML_w, XML_tblpYSpec), sTblpYSpec);
+
+ sOrientation = DocxAttributeOutput::convertToOOXMLHoriOrientRel(
+ rFrame.GetFrameFormat().GetHoriOrient().GetRelationOrient());
+ pAttributes->add(FSNS(XML_w, XML_horzAnchor), sOrientation);
+
+ if (!sTblpXSpec.isEmpty())
+ pAttributes->add(FSNS(XML_w, XML_tblpXSpec), sTblpXSpec);
+
+ nValue = rFrame.GetFrameFormat().GetULSpace().GetLower();
+ if (nValue != 0)
+ pAttributes->add(FSNS(XML_w, XML_bottomFromText), OString::number(nValue));
+
+ nValue = rFrame.GetFrameFormat().GetLRSpace().GetLeft();
+ if (nValue != 0)
+ pAttributes->add(FSNS(XML_w, XML_leftFromText), OString::number(nValue));
+
+ nValue = rFrame.GetFrameFormat().GetLRSpace().GetRight();
+ if (nValue != 0)
+ pAttributes->add(FSNS(XML_w, XML_rightFromText), OString::number(nValue));
+
+ nValue = rFrame.GetFrameFormat().GetULSpace().GetUpper();
+ if (nValue != 0)
+ pAttributes->add(FSNS(XML_w, XML_topFromText), OString::number(nValue));
+
+ if (sTblpXSpec.isEmpty()) // do not write tblpX if tblpXSpec is present
+ {
+ nValue = rFrame.GetFrameFormat().GetHoriOrient().GetPos();
+ // we need to revert the additional shift introduced by
+ // lcl_DecrementHoriOrientPosition() in writerfilter
+ // 1st: left distance of the table
+ const SwTableBox* pTabBox = pTableTextNodeInfoInner->getTableBox();
+ const SwFrameFormat* pFrameFormat = pTabBox->GetFrameFormat();
+ const SvxBoxItem& rBox = pFrameFormat->GetBox();
+ sal_Int32 nMode = lcl_getWordCompatibilityMode(rExport);
+ if (nMode < 15)
+ {
+ sal_uInt16 nLeftDistance = rBox.GetDistance(SvxBoxItemLine::LEFT);
+ nValue += nLeftDistance;
+ }
+
+ // 2nd: if a left border is given, revert the shift by half the width
+ // from lcl_DecrementHoriOrientPosition() in writerfilter
+ if (const editeng::SvxBorderLine* pLeftBorder = rBox.GetLeft())
+ {
+ tools::Long nWidth = pLeftBorder->GetWidth();
+ nValue += (nWidth / 2);
+ }
+
+ pAttributes->add(FSNS(XML_w, XML_tblpX), OString::number(nValue));
+ }
+
+ if (sTblpYSpec.isEmpty()) // do not write tblpY if tblpYSpec is present
+ {
+ nValue = rFrame.GetFrameFormat().GetVertOrient().GetPos();
+ pAttributes->add(FSNS(XML_w, XML_tblpY), OString::number(nValue));
+ }
+}
+}
+
+void DocxAttributeOutput::TableInfoCell(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& /*pTableTextNodeInfoInner*/)
+{
+}
+
+void DocxAttributeOutput::TableInfoRow(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& /*pTableTextNodeInfo*/)
+{
+}
+
+void DocxAttributeOutput::TableDefinition(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
+{
+ bool const bEcma = GetExport().GetFilter().getVersion() == oox::core::ECMA_376_1ST_EDITION;
+
+ // Write the table properties
+ m_pSerializer->startElementNS(XML_w, XML_tblPr);
+
+ static const sal_Int32 aOrder[] = { FSNS(XML_w, XML_tblStyle),
+ FSNS(XML_w, XML_tblpPr),
+ FSNS(XML_w, XML_tblOverlap),
+ FSNS(XML_w, XML_bidiVisual),
+ FSNS(XML_w, XML_tblStyleRowBandSize),
+ FSNS(XML_w, XML_tblStyleColBandSize),
+ FSNS(XML_w, XML_tblW),
+ FSNS(XML_w, XML_jc),
+ FSNS(XML_w, XML_tblCellSpacing),
+ FSNS(XML_w, XML_tblInd),
+ FSNS(XML_w, XML_tblBorders),
+ FSNS(XML_w, XML_shd),
+ FSNS(XML_w, XML_tblLayout),
+ FSNS(XML_w, XML_tblCellMar),
+ FSNS(XML_w, XML_tblLook),
+ FSNS(XML_w, XML_tblPrChange) };
+
+ // postpone the output so that we can later []
+ // prepend the properties before the run
+ // coverity[overrun-buffer-arg : FALSE] - coverity has difficulty with css::uno::Sequence
+ m_pSerializer->mark(Tag_TableDefinition, comphelper::containerToSequence(aOrder));
+
+ tools::Long nPageSize = 0;
+ const char* widthType = "dxa";
+
+ // If actual width of table is relative it should export is as "pct".`
+ const SwTable* pTable = pTableTextNodeInfoInner->getTable();
+ SwFrameFormat* pTableFormat = pTable->GetFrameFormat();
+ const SwFormatFrameSize& rSize = pTableFormat->GetFrameSize();
+ int nWidthPercent = rSize.GetWidthPercent();
+ // If we export a floating table: we use the widthPercent of the surrounding frame
+ const ww8::Frame* pFloatingTableFrame = m_rExport.GetFloatingTableFrame();
+ if (pFloatingTableFrame)
+ {
+ const SwFormatFrameSize& rFrameSize = pFloatingTableFrame->GetFrameFormat().GetFrameSize();
+ nWidthPercent = rFrameSize.GetWidthPercent();
+ }
+
+ uno::Reference<beans::XPropertySet> xPropertySet(
+ SwXTextTables::GetObject(*pTable->GetFrameFormat()), uno::UNO_QUERY);
+ bool isWidthRelative = false;
+ xPropertySet->getPropertyValue("IsWidthRelative") >>= isWidthRelative;
+ if (!isWidthRelative && !nWidthPercent)
+ {
+ // The best fit for "automatic" table placement is relative 100%
+ short nHoriOrient = -1;
+ xPropertySet->getPropertyValue("HoriOrient") >>= nHoriOrient;
+ isWidthRelative = nHoriOrient == text::HoriOrientation::FULL;
+ if (isWidthRelative)
+ nWidthPercent = 100;
+ }
+
+ if (isWidthRelative)
+ {
+ /**
+ * As per ECMA Specification : ECMA-376, Second Edition, Part 1 - Fundamentals And Markup Language Reference [ 17.18.90 ST_TableWidth (Table Width Units)]
+ * http://www.schemacentral.com/sc/ooxml/a-w_type-7.html
+ *
+ * Fiftieths of a Percent :
+ * http://startbigthinksmall.wordpress.com/2010/01/04/points-inches-and-emus-measuring-units-in-office-open-xml/
+ * pct Width is in Fiftieths of a Percent
+ *
+ * ex. If the Table width is 50% then
+ * Width in Fiftieths of a percent is (50 * 50) % or 0.5 * 5000 = 2500pct
+ **/
+ nPageSize = nWidthPercent * 50;
+ widthType = "pct";
+ }
+ else
+ {
+ bool bRelBoxSize = false;
+ // Create the SwWriteTable instance to use col spans (and maybe other infos)
+ GetTablePageSize(pTableTextNodeInfoInner.get(), nPageSize, bRelBoxSize);
+ if (nPageSize == 0)
+ widthType = "auto";
+ }
+
+ // Output the table preferred width
+ m_pSerializer->singleElementNS(XML_w, XML_tblW, FSNS(XML_w, XML_w), OString::number(nPageSize),
+ FSNS(XML_w, XML_type), widthType);
+
+ // Disable layout autofit, as it does not exist in LibreOffice yet
+ m_pSerializer->singleElementNS(XML_w, XML_tblLayout, FSNS(XML_w, XML_type), "fixed");
+
+ // Look for the table style property in the table grab bag
+ const std::map<OUString, css::uno::Any>& rGrabBag
+ = pTableFormat->GetAttrSet().GetItem<SfxGrabBagItem>(RES_FRMATR_GRABBAG)->GetGrabBag();
+
+ // We should clear the TableStyle map. In case of Table inside multiple tables it contains the
+ // table border style of the previous table.
+ std::map<SvxBoxItemLine, css::table::BorderLine2>& rTableStyleConf = m_aTableStyleConfs.back();
+ rTableStyleConf.clear();
+
+ bool bFloatingTableWritten = false;
+ if (pFloatingTableFrame && pFloatingTableFrame->GetFrameFormat().GetFlySplit().GetValue())
+ {
+ rtl::Reference<FastAttributeList> pAttributes = FastSerializerHelper::createAttrList();
+ CollectFloatingTableAttributes(m_rExport, *pFloatingTableFrame, pTableTextNodeInfoInner,
+ pAttributes);
+ m_pSerializer->singleElementNS(XML_w, XML_tblpPr, pAttributes);
+ bFloatingTableWritten = true;
+ // The outer table was floating, make sure potential inner tables are not floating.
+ m_rExport.SetFloatingTableFrame(nullptr);
+
+ const SwFrameFormat& rFloatingTableFormat = pFloatingTableFrame->GetFrameFormat();
+ if (!rFloatingTableFormat.GetWrapInfluenceOnObjPos().GetAllowOverlap())
+ {
+ // Allowing overlap is the default, both in OOXML and in Writer.
+ m_pSerializer->singleElementNS(XML_w, XML_tblOverlap, FSNS(XML_w, XML_val), "never");
+ }
+ }
+
+ // Extract properties from grab bag
+ for (const auto& rGrabBagElement : rGrabBag)
+ {
+ if (rGrabBagElement.first == "TableStyleName")
+ {
+ OString sStyleName
+ = OUStringToOString(rGrabBagElement.second.get<OUString>(), RTL_TEXTENCODING_UTF8);
+ m_pSerializer->singleElementNS(XML_w, XML_tblStyle, FSNS(XML_w, XML_val), sStyleName);
+ }
+ else if (rGrabBagElement.first == "TableStyleTopBorder")
+ rTableStyleConf[SvxBoxItemLine::TOP] = rGrabBagElement.second.get<table::BorderLine2>();
+ else if (rGrabBagElement.first == "TableStyleBottomBorder")
+ rTableStyleConf[SvxBoxItemLine::BOTTOM]
+ = rGrabBagElement.second.get<table::BorderLine2>();
+ else if (rGrabBagElement.first == "TableStyleLeftBorder")
+ rTableStyleConf[SvxBoxItemLine::LEFT]
+ = rGrabBagElement.second.get<table::BorderLine2>();
+ else if (rGrabBagElement.first == "TableStyleRightBorder")
+ rTableStyleConf[SvxBoxItemLine::RIGHT]
+ = rGrabBagElement.second.get<table::BorderLine2>();
+ else if (rGrabBagElement.first == "TableStyleLook")
+ {
+ rtl::Reference<FastAttributeList> pAttributeList
+ = FastSerializerHelper::createAttrList();
+ const uno::Sequence<beans::PropertyValue> aAttributeList
+ = rGrabBagElement.second.get<uno::Sequence<beans::PropertyValue>>();
+
+ for (const auto& rAttribute : aAttributeList)
+ {
+ if (rAttribute.Name == "val")
+ pAttributeList->add(
+ FSNS(XML_w, XML_val),
+ lcl_padStartToLength(OString::number(rAttribute.Value.get<sal_Int32>(), 16),
+ 4, '0'));
+ else
+ {
+ static DocxStringTokenMap const aTokens[]
+ = { { "firstRow", XML_firstRow },
+ { "lastRow", XML_lastRow },
+ { "firstColumn", XML_firstColumn },
+ { "lastColumn", XML_lastColumn },
+ { "noHBand", XML_noHBand },
+ { "noVBand", XML_noVBand },
+ { nullptr, 0 } };
+
+ if (sal_Int32 nToken = DocxStringGetToken(aTokens, rAttribute.Name))
+ pAttributeList->add(FSNS(XML_w, nToken),
+ (rAttribute.Value.get<sal_Int32>() ? "1" : "0"));
+ }
+ }
+
+ m_pSerializer->singleElementNS(XML_w, XML_tblLook, pAttributeList);
+ }
+ else if (rGrabBagElement.first == "TablePosition" &&
+ // skip empty table position (tables in footnotes converted to
+ // floating tables temporarily, don't export this)
+ rGrabBagElement.second != uno::Any())
+ {
+ rtl::Reference<FastAttributeList> attrListTablePos
+ = FastSerializerHelper::createAttrList();
+ const uno::Sequence<beans::PropertyValue> aTablePosition
+ = rGrabBagElement.second.get<uno::Sequence<beans::PropertyValue>>();
+ // look for a surrounding frame and take it's position values
+ const ww8::Frame* pFrame = m_rExport.GetFloatingTableFrame();
+ if (pFrame)
+ {
+ CollectFloatingTableAttributes(m_rExport, *pFrame, pTableTextNodeInfoInner,
+ attrListTablePos);
+ }
+ else // ( pFrame = 0 )
+ {
+ // we export the values from the grabBag
+ for (const auto& rProp : aTablePosition)
+ {
+ if (rProp.Name == "vertAnchor" && !rProp.Value.get<OUString>().isEmpty())
+ {
+ OString sOrientation
+ = OUStringToOString(rProp.Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
+ attrListTablePos->add(FSNS(XML_w, XML_vertAnchor), sOrientation);
+ }
+ else if (rProp.Name == "tblpYSpec" && !rProp.Value.get<OUString>().isEmpty())
+ {
+ OString sOrientation
+ = OUStringToOString(rProp.Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
+ attrListTablePos->add(FSNS(XML_w, XML_tblpYSpec), sOrientation);
+ }
+ else if (rProp.Name == "horzAnchor" && !rProp.Value.get<OUString>().isEmpty())
+ {
+ OString sOrientation
+ = OUStringToOString(rProp.Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
+ attrListTablePos->add(FSNS(XML_w, XML_horzAnchor), sOrientation);
+ }
+ else if (rProp.Name == "tblpXSpec" && !rProp.Value.get<OUString>().isEmpty())
+ {
+ OString sOrientation
+ = OUStringToOString(rProp.Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
+ attrListTablePos->add(FSNS(XML_w, XML_tblpXSpec), sOrientation);
+ }
+ else if (rProp.Name == "bottomFromText")
+ {
+ sal_Int32 nValue = rProp.Value.get<sal_Int32>();
+ attrListTablePos->add(FSNS(XML_w, XML_bottomFromText),
+ OString::number(nValue));
+ }
+ else if (rProp.Name == "leftFromText")
+ {
+ sal_Int32 nValue = rProp.Value.get<sal_Int32>();
+ attrListTablePos->add(FSNS(XML_w, XML_leftFromText),
+ OString::number(nValue));
+ }
+ else if (rProp.Name == "rightFromText")
+ {
+ sal_Int32 nValue = rProp.Value.get<sal_Int32>();
+ attrListTablePos->add(FSNS(XML_w, XML_rightFromText),
+ OString::number(nValue));
+ }
+ else if (rProp.Name == "topFromText")
+ {
+ sal_Int32 nValue = rProp.Value.get<sal_Int32>();
+ attrListTablePos->add(FSNS(XML_w, XML_topFromText),
+ OString::number(nValue));
+ }
+ else if (rProp.Name == "tblpX")
+ {
+ sal_Int32 nValue = rProp.Value.get<sal_Int32>();
+ attrListTablePos->add(FSNS(XML_w, XML_tblpX), OString::number(nValue));
+ }
+ else if (rProp.Name == "tblpY")
+ {
+ sal_Int32 nValue = rProp.Value.get<sal_Int32>();
+ attrListTablePos->add(FSNS(XML_w, XML_tblpY), OString::number(nValue));
+ }
+ }
+ }
+
+ if (!bFloatingTableWritten)
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_tblpPr, attrListTablePos);
+ }
+ }
+ else
+ SAL_WARN("sw.ww8", "DocxAttributeOutput::TableDefinition: unhandled property: "
+ << rGrabBagElement.first);
+ }
+
+ // Output the table alignment
+ const char* pJcVal;
+ sal_Int32 nIndent = 0;
+ switch (pTableFormat->GetHoriOrient().GetHoriOrient())
+ {
+ case text::HoriOrientation::CENTER:
+ pJcVal = "center";
+ break;
+ case text::HoriOrientation::RIGHT:
+ if (bEcma)
+ pJcVal = "right";
+ else
+ pJcVal = "end";
+ break;
+ default:
+ case text::HoriOrientation::NONE:
+ case text::HoriOrientation::LEFT_AND_WIDTH:
+ {
+ if (bEcma)
+ pJcVal = "left";
+ else
+ pJcVal = "start";
+ nIndent = sal_Int32(pTableFormat->GetLRSpace().GetLeft());
+
+ // Table indentation has different meaning in Word, depending if the table is nested or not.
+ // If nested, tblInd is added to parent table's left spacing and defines left edge position
+ // If not nested, text position of left-most cell must be at absolute X = tblInd
+ // so, table_spacing + table_spacing_to_content = tblInd
+
+ // tdf#106742: since MS Word 2013 (compatibilityMode >= 15), top-level tables are handled the same as nested tables;
+ // if no compatibilityMode is defined (which now should only happen on a new export to .docx),
+ // LO uses a higher compatibility than 2010's 14.
+ sal_Int32 nMode = lcl_getWordCompatibilityMode(m_rExport);
+
+ const SwFrameFormat* pFrameFormat
+ = pTableTextNodeInfoInner->getTableBox()->GetFrameFormat();
+ if ((0 < nMode && nMode <= 14) && m_tableReference.m_nTableDepth == 0)
+ nIndent += pFrameFormat->GetBox().GetDistance(SvxBoxItemLine::LEFT);
+ else
+ {
+ // adjust for SW considering table to start mid-border instead of nested/2013's left-side-of-border.
+ nIndent -= pFrameFormat->GetBox().CalcLineWidth(SvxBoxItemLine::LEFT) / 2;
+ }
+
+ break;
+ }
+ }
+ m_pSerializer->singleElementNS(XML_w, XML_jc, FSNS(XML_w, XML_val), pJcVal);
+
+ // Output the table background color (although cell value still needs to be specified)
+ const SvxBrushItem* pColorProp
+ = pTableFormat->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
+ Color aColor = pColorProp ? pColorProp->GetColor() : COL_AUTO;
+ if (aColor != COL_AUTO)
+ {
+ OString sColor = msfilter::util::ConvertColor(aColor);
+ m_pSerializer->singleElementNS(XML_w, XML_shd, FSNS(XML_w, XML_fill), sColor,
+ FSNS(XML_w, XML_val), "clear");
+ }
+
+ // Output the table borders
+ TableDefaultBorders(pTableTextNodeInfoInner);
+
+ // Output the default cell margins
+ TableDefaultCellMargins(pTableTextNodeInfoInner);
+
+ TableBidi(pTableTextNodeInfoInner);
+
+ // Table indent (need to get written even if == 0)
+ m_pSerializer->singleElementNS(XML_w, XML_tblInd, FSNS(XML_w, XML_w), OString::number(nIndent),
+ FSNS(XML_w, XML_type), "dxa");
+
+ // Merge the marks for the ordered elements
+ m_pSerializer->mergeTopMarks(Tag_TableDefinition);
+
+ m_pSerializer->endElementNS(XML_w, XML_tblPr);
+
+ // Write the table grid infos
+ m_pSerializer->startElementNS(XML_w, XML_tblGrid);
+ sal_Int32 nPrv = 0;
+ ww8::WidthsPtr pColumnWidths = GetColumnWidths(pTableTextNodeInfoInner);
+ for (auto aColumnWidth : *pColumnWidths)
+ {
+ sal_Int32 nWidth = sal_Int32(aColumnWidth) - nPrv;
+ m_pSerializer->singleElementNS(XML_w, XML_gridCol, FSNS(XML_w, XML_w),
+ OString::number(nWidth));
+ nPrv = sal_Int32(aColumnWidth);
+ }
+
+ m_pSerializer->endElementNS(XML_w, XML_tblGrid);
+}
+
+void DocxAttributeOutput::TableDefaultBorders(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& /*pTableTextNodeInfoInner*/)
+{
+ // Table defaults should only be created IF m_aTableStyleConf contents haven't come from a table style.
+ // Previously this function wrote out Cell A1 as the table default, causing problems with no benefit.
+}
+
+void DocxAttributeOutput::TableDefaultCellMargins(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
+{
+ const SwTableBox* pTabBox = pTableTextNodeInfoInner->getTableBox();
+ const SwFrameFormat* pFrameFormat = pTabBox->GetFrameFormat();
+ const SvxBoxItem& rBox = pFrameFormat->GetBox();
+ const bool bEcma = GetExport().GetFilter().getVersion() == oox::core::ECMA_376_1ST_EDITION;
+
+ DocxAttributeOutput::ImplCellMargins(m_pSerializer, rBox, XML_tblCellMar, !bEcma);
+}
+
+void DocxAttributeOutput::TableBackgrounds(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
+{
+ const SwTable* pTable = pTableTextNodeInfoInner->getTable();
+ const SwTableBox* pTableBox = pTableTextNodeInfoInner->getTableBox();
+ const SwTableLine* pTableRow = pTableBox->GetUpper();
+ const SwFrameFormat* pFormat = pTableBox->GetFrameFormat();
+
+ const SvxBrushItem* pColorProp = pFormat->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
+ Color aColor = pColorProp ? pColorProp->GetColor() : COL_AUTO;
+
+ const SwFrameFormat* pRowFormat = pTableRow->GetFrameFormat();
+ const SvxBrushItem* pRowColorProp
+ = pRowFormat->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
+ if (pRowColorProp && aColor == COL_AUTO)
+ aColor = pRowColorProp->GetColor();
+
+ const SwFrameFormat* pTableFormat = pTable->GetFrameFormat();
+ const SvxBrushItem* pTableColorProp
+ = pTableFormat->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
+ if (pTableColorProp && aColor == COL_AUTO)
+ aColor = pTableColorProp->GetColor();
+
+ const OString sColor = msfilter::util::ConvertColor(aColor);
+
+ const std::map<OUString, css::uno::Any>& rGrabBag
+ = pFormat->GetAttrSet().GetItem<SfxGrabBagItem>(RES_FRMATR_GRABBAG)->GetGrabBag();
+
+ OString sOriginalColor;
+ auto aGrabBagIt = rGrabBag.find("originalColor");
+ if (aGrabBagIt != rGrabBag.end())
+ sOriginalColor
+ = OUStringToOString(aGrabBagIt->second.get<OUString>(), RTL_TEXTENCODING_UTF8);
+
+ if (sOriginalColor != sColor)
+ {
+ // color changed by the user, or no grab bag: write sColor
+ if (sColor != "auto")
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_shd, FSNS(XML_w, XML_fill), sColor,
+ FSNS(XML_w, XML_val), "clear");
+ }
+ }
+ else
+ {
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttrList;
+
+ for (const auto & [ name, val ] : rGrabBag)
+ {
+ if (!val.has<OUString>())
+ continue;
+
+ if (name == "themeFill")
+ AddToAttrList(pAttrList, FSNS(XML_w, XML_themeFill), val.get<OUString>());
+ else if (name == "themeFillTint")
+ AddToAttrList(pAttrList, FSNS(XML_w, XML_themeFillTint), val.get<OUString>());
+ else if (name == "themeFillShade")
+ AddToAttrList(pAttrList, FSNS(XML_w, XML_themeFillShade), val.get<OUString>());
+ else if (name == "fill")
+ AddToAttrList(pAttrList, FSNS(XML_w, XML_fill), val.get<OUString>());
+ else if (name == "themeColor")
+ AddToAttrList(pAttrList, FSNS(XML_w, XML_themeColor), val.get<OUString>());
+ else if (name == "themeTint")
+ AddToAttrList(pAttrList, FSNS(XML_w, XML_themeTint), val.get<OUString>());
+ else if (name == "themeShade")
+ AddToAttrList(pAttrList, FSNS(XML_w, XML_themeShade), val.get<OUString>());
+ else if (name == "color")
+ AddToAttrList(pAttrList, FSNS(XML_w, XML_color), val.get<OUString>());
+ else if (name == "val")
+ AddToAttrList(pAttrList, FSNS(XML_w, XML_val), val.get<OUString>());
+ }
+ m_pSerializer->singleElementNS(XML_w, XML_shd, pAttrList);
+ }
+}
+
+void DocxAttributeOutput::TableRowRedline(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
+{
+ const SwTableBox* pTabBox = pTableTextNodeInfoInner->getTableBox();
+ const SwTableLine* pTabLine = pTabBox->GetUpper();
+
+ bool bRemovePersonalInfo
+ = SvtSecurityOptions::IsOptionSet(SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo)
+ && !SvtSecurityOptions::IsOptionSet(SvtSecurityOptions::EOption::DocWarnKeepRedlineInfo);
+
+ // check table row property "HasTextChangesOnly"
+ SwRedlineTable::size_type nPos(0);
+ SwRedlineTable::size_type nChange = pTabLine->UpdateTextChangesOnly(nPos);
+ // tdf#150824 if no tracked table row, is the table in a single redline?
+ // if yes, convert the row to a tracked table row instead of losing its tracking
+ if (nChange == SwRedlineTable::npos)
+ nChange = pTabLine->GetTableRedline();
+ if (nChange != SwRedlineTable::npos)
+ {
+ const SwRedlineTable& aRedlineTable
+ = m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable();
+ const SwRangeRedline* pRedline = aRedlineTable[nChange];
+ SwTableRowRedline* pTableRowRedline = nullptr;
+ bool bIsInExtra = false;
+
+ // use the original DOCX redline data stored in ExtraRedlineTable,
+ // if it exists and its type wasn't changed
+ const SwExtraRedlineTable& aExtraRedlineTable
+ = m_rExport.m_rDoc.getIDocumentRedlineAccess().GetExtraRedlineTable();
+ for (sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < aExtraRedlineTable.GetSize();
+ ++nCurRedlinePos)
+ {
+ SwExtraRedline* pExtraRedline = aExtraRedlineTable.GetRedline(nCurRedlinePos);
+ pTableRowRedline = dynamic_cast<SwTableRowRedline*>(pExtraRedline);
+ if (pTableRowRedline && &pTableRowRedline->GetTableLine() == pTabLine)
+ {
+ bIsInExtra = true;
+ break;
+ }
+ }
+
+ const SwRedlineData& aRedlineData
+ = bIsInExtra &&
+ // still the same type (an inserted row could become a tracked deleted one)
+ pTableRowRedline->GetRedlineData().GetType()
+ == pRedline->GetRedlineData().GetType()
+ ? pTableRowRedline->GetRedlineData()
+ : pRedline->GetRedlineData();
+
+ // Note: all redline ranges and table row redline (with the same author and timestamp)
+ // use the same redline id in OOXML exported by MSO, but it seems, the recent solution
+ // (different IDs for different ranges, also row changes) is also portable.
+ OString aId(OString::number(m_nRedlineId++));
+ const OUString& rAuthor(SW_MOD()->GetRedlineAuthor(aRedlineData.GetAuthor()));
+ OString aAuthor(OUStringToOString(
+ bRemovePersonalInfo ? "Author" + OUString::number(GetExport().GetInfoID(rAuthor))
+ : rAuthor,
+ RTL_TEXTENCODING_UTF8));
+
+ const DateTime aDateTime = aRedlineData.GetTimeStamp();
+ bool bNoDate = bRemovePersonalInfo
+ || (aDateTime.GetYear() == 1970 && aDateTime.GetMonth() == 1
+ && aDateTime.GetDay() == 1);
+
+ if (bNoDate)
+ m_pSerializer->singleElementNS(
+ XML_w, RedlineType::Delete == pRedline->GetType() ? XML_del : XML_ins,
+ FSNS(XML_w, XML_id), aId, FSNS(XML_w, XML_author), aAuthor);
+ else
+ m_pSerializer->singleElementNS(
+ XML_w, RedlineType::Delete == pRedline->GetType() ? XML_del : XML_ins,
+ FSNS(XML_w, XML_id), aId, FSNS(XML_w, XML_author), aAuthor, FSNS(XML_w, XML_date),
+ DateTimeToOString(aDateTime));
+ return;
+ }
+}
+
+void DocxAttributeOutput::TableCellRedline(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
+{
+ const SwTableBox* pTabBox = pTableTextNodeInfoInner->getTableBox();
+
+ bool bRemovePersonalInfo
+ = SvtSecurityOptions::IsOptionSet(SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo)
+ && !SvtSecurityOptions::IsOptionSet(SvtSecurityOptions::EOption::DocWarnKeepRedlineInfo);
+
+ // check table row property "HasTextChangesOnly"
+ SwRedlineTable::size_type nChange = pTabBox->GetRedline();
+ if (nChange != SwRedlineTable::npos)
+ {
+ const SwRedlineTable& aRedlineTable
+ = m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable();
+ const SwRangeRedline* pRedline = aRedlineTable[nChange];
+ SwTableCellRedline* pTableCellRedline = nullptr;
+ bool bIsInExtra = false;
+
+ // use the original DOCX redline data stored in ExtraRedlineTable,
+ // if it exists and its type wasn't changed
+ const SwExtraRedlineTable& aExtraRedlineTable
+ = m_rExport.m_rDoc.getIDocumentRedlineAccess().GetExtraRedlineTable();
+ for (sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < aExtraRedlineTable.GetSize();
+ ++nCurRedlinePos)
+ {
+ SwExtraRedline* pExtraRedline = aExtraRedlineTable.GetRedline(nCurRedlinePos);
+ pTableCellRedline = dynamic_cast<SwTableCellRedline*>(pExtraRedline);
+ if (pTableCellRedline && &pTableCellRedline->GetTableBox() == pTabBox)
+ {
+ bIsInExtra = true;
+ break;
+ }
+ }
+
+ const SwRedlineData& aRedlineData
+ = bIsInExtra &&
+ // still the same type (an inserted cell could become a tracked deleted one)
+ pRedline->GetRedlineData().GetType() == pRedline->GetRedlineData().GetType()
+ ? pTableCellRedline->GetRedlineData()
+ : pRedline->GetRedlineData();
+
+ // Note: all redline ranges and table row redline (with the same author and timestamp)
+ // use the same redline id in OOXML exported by MSO, but it seems, the recent solution
+ // (different IDs for different ranges, also row changes) is also portable.
+ OString aId(OString::number(m_nRedlineId++));
+ const OUString& rAuthor(SW_MOD()->GetRedlineAuthor(aRedlineData.GetAuthor()));
+ OString aAuthor(OUStringToOString(
+ bRemovePersonalInfo ? "Author" + OUString::number(GetExport().GetInfoID(rAuthor))
+ : rAuthor,
+ RTL_TEXTENCODING_UTF8));
+
+ const DateTime aDateTime = aRedlineData.GetTimeStamp();
+ bool bNoDate = bRemovePersonalInfo
+ || (aDateTime.GetYear() == 1970 && aDateTime.GetMonth() == 1
+ && aDateTime.GetDay() == 1);
+
+ if (bNoDate)
+ m_pSerializer->singleElementNS(
+ XML_w, RedlineType::Delete == pRedline->GetType() ? XML_cellDel : XML_cellIns,
+ FSNS(XML_w, XML_id), aId, FSNS(XML_w, XML_author), aAuthor);
+ else
+ m_pSerializer->singleElementNS(
+ XML_w, RedlineType::Delete == pRedline->GetType() ? XML_cellDel : XML_cellIns,
+ FSNS(XML_w, XML_id), aId, FSNS(XML_w, XML_author), aAuthor, FSNS(XML_w, XML_date),
+ DateTimeToOString(aDateTime));
+ return;
+ }
+}
+
+void DocxAttributeOutput::TableHeight(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
+{
+ const SwTableBox* pTabBox = pTableTextNodeInfoInner->getTableBox();
+ const SwTableLine* pTabLine = pTabBox->GetUpper();
+ const SwFrameFormat* pLineFormat = pTabLine->GetFrameFormat();
+
+ const SwFormatFrameSize& rLSz = pLineFormat->GetFrameSize();
+ if (!(SwFrameSize::Variable != rLSz.GetHeightSizeType() && rLSz.GetHeight()))
+ return;
+
+ sal_Int32 nHeight = rLSz.GetHeight();
+ const char* pRule = nullptr;
+
+ switch (rLSz.GetHeightSizeType())
+ {
+ case SwFrameSize::Fixed:
+ pRule = "exact";
+ break;
+ case SwFrameSize::Minimum:
+ pRule = "atLeast";
+ break;
+ default:
+ break;
+ }
+
+ if (pRule)
+ m_pSerializer->singleElementNS(XML_w, XML_trHeight, FSNS(XML_w, XML_val),
+ OString::number(nHeight), FSNS(XML_w, XML_hRule), pRule);
+}
+
+void DocxAttributeOutput::TableCanSplit(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
+{
+ const SwTableBox* pTabBox = pTableTextNodeInfoInner->getTableBox();
+ const SwTableLine* pTabLine = pTabBox->GetUpper();
+ const SwFrameFormat* pLineFormat = pTabLine->GetFrameFormat();
+
+ const SwFormatRowSplit& rSplittable = pLineFormat->GetRowSplit();
+ // if rSplittable is true then no need to write <w:cantSplit w:val="false"/>
+ // as default row prop is allow row to break across page.
+ if (!rSplittable.GetValue())
+ m_pSerializer->singleElementNS(XML_w, XML_cantSplit, FSNS(XML_w, XML_val), "true");
+}
+
+void DocxAttributeOutput::TableBidi(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
+{
+ const SwTable* pTable = pTableTextNodeInfoInner->getTable();
+ const SwFrameFormat* pFrameFormat = pTable->GetFrameFormat();
+
+ if (m_rExport.TrueFrameDirection(*pFrameFormat) == SvxFrameDirection::Horizontal_RL_TB)
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_bidiVisual, FSNS(XML_w, XML_val), "true");
+ }
+}
+
+void DocxAttributeOutput::TableVerticalCell(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
+{
+ const SwTableBox* pTabBox = pTableTextNodeInfoInner->getTableBox();
+ const SwFrameFormat* pFrameFormat = pTabBox->GetFrameFormat();
+
+ if (SvxFrameDirection::Vertical_RL_TB == m_rExport.TrueFrameDirection(*pFrameFormat))
+ m_pSerializer->singleElementNS(XML_w, XML_textDirection, FSNS(XML_w, XML_val), "tbRl");
+ else if (SvxFrameDirection::Vertical_LR_BT == m_rExport.TrueFrameDirection(*pFrameFormat))
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_textDirection, FSNS(XML_w, XML_val), "btLr");
+ }
+
+ const SwWriteTableRows& rRows = m_xTableWrt->GetRows();
+ const auto nRow = pTableTextNodeInfoInner->getRow();
+ if (nRow >= rRows.size())
+ {
+ SAL_WARN("sw.ww8", "DocxAttributeOutput::TableCellProperties: out of range row: " << nRow);
+ return;
+ }
+ SwWriteTableRow* pRow = rRows[nRow].get();
+ sal_uInt32 nCell = pTableTextNodeInfoInner->getCell();
+ const SwWriteTableCells& rTableCells = pRow->GetCells();
+ if (nCell >= rTableCells.size())
+ return;
+
+ const SwWriteTableCell* const pCell = pRow->GetCells()[nCell].get();
+ switch (pCell->GetVertOri())
+ {
+ case text::VertOrientation::TOP:
+ break;
+ case text::VertOrientation::CENTER:
+ m_pSerializer->singleElementNS(XML_w, XML_vAlign, FSNS(XML_w, XML_val), "center");
+ break;
+ case text::VertOrientation::BOTTOM:
+ m_pSerializer->singleElementNS(XML_w, XML_vAlign, FSNS(XML_w, XML_val), "bottom");
+ break;
+ }
+}
+
+void DocxAttributeOutput::TableNodeInfoInner(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pNodeInfoInner)
+{
+ // This is called when the nested table ends in a cell, and there's no
+ // paragraph behind that; so we must check for the ends of cell, rows,
+ // tables
+ // ['true' to write an empty paragraph, MS Word insists on that]
+ FinishTableRowCell(pNodeInfoInner, true);
+}
+
+void DocxAttributeOutput::TableOrientation(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& /*pTableTextNodeInfoInner*/)
+{
+ SAL_INFO("sw.ww8", "TODO: DocxAttributeOutput::TableOrientation( "
+ "ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )");
+}
+
+void DocxAttributeOutput::TableSpacing(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& /*pTableTextNodeInfoInner*/)
+{
+ SAL_INFO("sw.ww8", "TODO: DocxAttributeOutput::TableSpacing( "
+ "ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )");
+}
+
+void DocxAttributeOutput::TableRowEnd(sal_uInt32 /*nDepth*/)
+{
+ SAL_INFO("sw.ww8", "TODO: DocxAttributeOutput::TableRowEnd( sal_uInt32 nDepth = 1 )");
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxtablestyleexport.cxx b/sw/source/filter/ww8/docxtablestyleexport.cxx
index 4ad89587eda1..0de587eaa400 100644
--- a/sw/source/filter/ww8/docxtablestyleexport.cxx
+++ b/sw/source/filter/ww8/docxtablestyleexport.cxx
@@ -49,7 +49,7 @@ public:
SwDoc& getDoc() const { return m_rDoc; }
/// Handles a boolean value.
- void handleBoolean(const OUString& aValue, sal_Int32 nToken);
+ void handleBoolean(std::u16string_view aValue, sal_Int32 nToken);
/// Export of w:pPr.
void tableStylePPr(const uno::Sequence<beans::PropertyValue>& rPPr);
@@ -95,7 +95,7 @@ void DocxTableStyleExport::CnfStyle(const uno::Sequence<beans::PropertyValue>& r
for (const auto& rAttribute : rAttributeList)
{
if (rAttribute.Name == "val")
- pAttributeList->add(FSNS(XML_w, XML_val), rAttribute.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_val), rAttribute.Value.get<OUString>());
else
{
static DocxStringTokenMap const aTokens[]
@@ -114,7 +114,7 @@ void DocxTableStyleExport::CnfStyle(const uno::Sequence<beans::PropertyValue>& r
{ nullptr, 0 } };
if (sal_Int32 nToken = DocxStringGetToken(aTokens, rAttribute.Name))
- pAttributeList->add(FSNS(XML_w, nToken), rAttribute.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, nToken), rAttribute.Value.get<OUString>());
}
}
@@ -130,9 +130,9 @@ void DocxTableStyleExport::TableStyles(sal_Int32 nCountStylesToWrite)
xPropertySet->getPropertyValue("InteropGrabBag") >>= aInteropGrabBag;
uno::Sequence<beans::PropertyValue> aTableStyles;
auto pProp = std::find_if(
- aInteropGrabBag.begin(), aInteropGrabBag.end(),
+ std::cbegin(aInteropGrabBag), std::cend(aInteropGrabBag),
[](const beans::PropertyValue& rProp) { return rProp.Name == "tableStyles"; });
- if (pProp != aInteropGrabBag.end())
+ if (pProp != std::cend(aInteropGrabBag))
pProp->Value >>= aTableStyles;
if (!aTableStyles.hasElements())
return;
@@ -192,7 +192,7 @@ void DocxTableStyleExport::Impl::tableStyleTcBorder(
= sax_fastparser::FastSerializerHelper::createAttrList();
for (const auto& rProp : rTcBorder)
if (sal_Int32 nAttrToken = DocxStringGetToken(aTcBorderTokens, rProp.Name))
- pAttributeList->add(FSNS(XML_w, nAttrToken), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, nAttrToken), rProp.Value.get<OUString>());
m_pSerializer->singleElementNS(XML_w, nToken, pAttributeList);
}
@@ -233,19 +233,17 @@ void DocxTableStyleExport::Impl::tableStyleShd(const uno::Sequence<beans::Proper
for (const auto& rProp : rShd)
{
if (rProp.Name == "val")
- pAttributeList->add(FSNS(XML_w, XML_val), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_val), rProp.Value.get<OUString>());
else if (rProp.Name == "color")
- pAttributeList->add(FSNS(XML_w, XML_color), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_color), rProp.Value.get<OUString>());
else if (rProp.Name == "fill")
- pAttributeList->add(FSNS(XML_w, XML_fill), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_fill), rProp.Value.get<OUString>());
else if (rProp.Name == "themeFill")
- pAttributeList->add(FSNS(XML_w, XML_themeFill), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_themeFill), rProp.Value.get<OUString>());
else if (rProp.Name == "themeFillShade")
- pAttributeList->add(FSNS(XML_w, XML_themeFillShade),
- rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_themeFillShade), rProp.Value.get<OUString>());
else if (rProp.Name == "themeFillTint")
- pAttributeList->add(FSNS(XML_w, XML_themeFillTint),
- rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_themeFillTint), rProp.Value.get<OUString>());
}
m_pSerializer->singleElementNS(XML_w, XML_shd, pAttributeList);
}
@@ -260,13 +258,13 @@ void DocxTableStyleExport::Impl::tableStyleRColor(const uno::Sequence<beans::Pro
for (const auto& rProp : rColor)
{
if (rProp.Name == "val")
- pAttributeList->add(FSNS(XML_w, XML_val), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_val), rProp.Value.get<OUString>());
else if (rProp.Name == "themeColor")
- pAttributeList->add(FSNS(XML_w, XML_themeColor), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_themeColor), rProp.Value.get<OUString>());
else if (rProp.Name == "themeTint")
- pAttributeList->add(FSNS(XML_w, XML_themeTint), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_themeTint), rProp.Value.get<OUString>());
else if (rProp.Name == "themeShade")
- pAttributeList->add(FSNS(XML_w, XML_themeShade), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_themeShade), rProp.Value.get<OUString>());
}
m_pSerializer->singleElementNS(XML_w, XML_color, pAttributeList);
}
@@ -281,11 +279,11 @@ void DocxTableStyleExport::Impl::tableStyleRLang(const uno::Sequence<beans::Prop
for (const auto& rProp : rLang)
{
if (rProp.Name == "eastAsia")
- pAttributeList->add(FSNS(XML_w, XML_eastAsia), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_eastAsia), rProp.Value.get<OUString>());
else if (rProp.Name == "val")
- pAttributeList->add(FSNS(XML_w, XML_val), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_val), rProp.Value.get<OUString>());
else if (rProp.Name == "bidi")
- pAttributeList->add(FSNS(XML_w, XML_bidi), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_bidi), rProp.Value.get<OUString>());
}
m_pSerializer->singleElementNS(XML_w, XML_lang, pAttributeList);
}
@@ -301,14 +299,13 @@ void DocxTableStyleExport::Impl::tableStyleRRFonts(
for (const auto& rRFont : rRFonts)
{
if (rRFont.Name == "eastAsiaTheme")
- pAttributeList->add(FSNS(XML_w, XML_eastAsiaTheme),
- rRFont.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_eastAsiaTheme), rRFont.Value.get<OUString>());
else if (rRFont.Name == "asciiTheme")
- pAttributeList->add(FSNS(XML_w, XML_asciiTheme), rRFont.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_asciiTheme), rRFont.Value.get<OUString>());
else if (rRFont.Name == "cstheme")
- pAttributeList->add(FSNS(XML_w, XML_cstheme), rRFont.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_cstheme), rRFont.Value.get<OUString>());
else if (rRFont.Name == "hAnsiTheme")
- pAttributeList->add(FSNS(XML_w, XML_hAnsiTheme), rRFont.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_hAnsiTheme), rRFont.Value.get<OUString>());
}
m_pSerializer->singleElementNS(XML_w, XML_rFonts, pAttributeList);
}
@@ -324,20 +321,20 @@ void DocxTableStyleExport::Impl::tableStylePSpacing(
for (const auto& rProp : rSpacing)
{
if (rProp.Name == "after")
- pAttributeList->add(FSNS(XML_w, XML_after), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_after), rProp.Value.get<OUString>());
else if (rProp.Name == "before")
- pAttributeList->add(FSNS(XML_w, XML_before), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_before), rProp.Value.get<OUString>());
else if (rProp.Name == "line")
- pAttributeList->add(FSNS(XML_w, XML_line), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_line), rProp.Value.get<OUString>());
else if (rProp.Name == "lineRule")
- pAttributeList->add(FSNS(XML_w, XML_lineRule), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_lineRule), rProp.Value.get<OUString>());
else if (rProp.Name == "beforeLines")
- pAttributeList->add(FSNS(XML_w, XML_beforeLines), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_beforeLines), rProp.Value.get<OUString>());
else if (rProp.Name == "ParaTopMarginBeforeAutoSpacing")
// Auto spacing will be available in grab bag only if it was set to true
pAttributeList->add(FSNS(XML_w, XML_beforeAutospacing), "1");
else if (rProp.Name == "afterLines")
- pAttributeList->add(FSNS(XML_w, XML_afterLines), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_afterLines), rProp.Value.get<OUString>());
else if (rProp.Name == "ParaBottomMarginAfterAutoSpacing")
// Auto spacing will be available in grab bag only if it was set to true
pAttributeList->add(FSNS(XML_w, XML_afterAutospacing), "1");
@@ -355,9 +352,9 @@ void DocxTableStyleExport::Impl::tableStylePInd(const uno::Sequence<beans::Prope
for (const auto& rProp : rInd)
{
if (rProp.Name == "rightChars")
- pAttributeList->add(FSNS(XML_w, XML_rightChars), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_rightChars), rProp.Value.get<OUString>());
else if (rProp.Name == "right")
- pAttributeList->add(FSNS(XML_w, XML_right), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_right), rProp.Value.get<OUString>());
}
m_pSerializer->singleElementNS(XML_w, XML_ind, pAttributeList);
}
@@ -375,19 +372,19 @@ void DocxTableStyleExport::Impl::tableStyleTableInd(
if (rProp.Name == "w")
pAttributeList->add(FSNS(XML_w, XML_w), OString::number(rProp.Value.get<sal_Int32>()));
else if (rProp.Name == "type")
- pAttributeList->add(FSNS(XML_w, XML_type), rProp.Value.get<OUString>().toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_type), rProp.Value.get<OUString>());
}
m_pSerializer->singleElementNS(XML_w, XML_tblInd, pAttributeList);
}
-void DocxTableStyleExport::Impl::handleBoolean(const OUString& aValue, sal_Int32 nToken)
+void DocxTableStyleExport::Impl::handleBoolean(std::u16string_view aValue, sal_Int32 nToken)
{
- if (aValue.isEmpty())
+ if (aValue.empty())
return;
rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
= sax_fastparser::FastSerializerHelper::createAttrList();
- if (aValue != "1")
- pAttributeList->add(FSNS(XML_w, XML_val), aValue.toUtf8());
+ if (aValue != u"1")
+ pAttributeList->add(FSNS(XML_w, XML_val), aValue);
m_pSerializer->singleElementNS(XML_w, nToken, pAttributeList);
}
@@ -695,7 +692,7 @@ void DocxTableStyleExport::Impl::TableStyle(const uno::Sequence<beans::PropertyV
if (bCustomStyle)
pAttributeList->add(FSNS(XML_w, XML_customStyle), "1");
if (!aStyleId.isEmpty())
- pAttributeList->add(FSNS(XML_w, XML_styleId), aStyleId.toUtf8());
+ pAttributeList->add(FSNS(XML_w, XML_styleId), aStyleId);
m_pSerializer->startElementNS(XML_w, XML_style, pAttributeList);
m_pSerializer->singleElementNS(XML_w, XML_name, FSNS(XML_w, XML_val), aName);
@@ -716,7 +713,7 @@ void DocxTableStyleExport::Impl::TableStyle(const uno::Sequence<beans::PropertyV
tableStyleRPr(aRPr);
tableStyleTablePr(aTablePr);
tableStyleTcPr(aTcPr);
- for (const uno::Sequence<beans::PropertyValue>& i : std::as_const(aTableStylePrs))
+ for (const uno::Sequence<beans::PropertyValue>& i : aTableStylePrs)
tableStyleTableStylePr(i);
m_pSerializer->endElementNS(XML_w, XML_style);
diff --git a/sw/source/filter/ww8/escher.hxx b/sw/source/filter/ww8/escher.hxx
index 91f90685a18e..179b3a16f3d3 100644
--- a/sw/source/filter/ww8/escher.hxx
+++ b/sw/source/filter/ww8/escher.hxx
@@ -68,6 +68,7 @@ public:
private:
bool mbInline;
+ sal_uInt32 mnGroupShapeBooleanProperties;
sal_uInt32 mnXAlign;
sal_uInt32 mnYAlign;
sal_uInt32 mnXRelTo;
@@ -94,8 +95,8 @@ class SwBasicEscherEx : public EscherEx
private:
void Init();
protected:
- WW8Export& rWrt;
- SvStream* pEscherStrm;
+ WW8Export& mrWrt;
+ SvStream* mpEscherStrm;
tools::Long mnEmuMul, mnEmuDiv;
virtual sal_Int32 WriteFlyFrameAttr(const SwFrameFormat& rFormat, MSO_SPT eShapeType,
@@ -140,10 +141,10 @@ private:
class SwEscherEx : public SwBasicEscherEx
{
private:
- std::vector<sal_uLong> aFollowShpIds;
- EscherExHostAppData aHostData;
- WinwordAnchoring aWinwordAnchoring;
- WW8_WrPlcTextBoxes *pTextBxs;
+ std::vector<sal_uLong> m_aFollowShpIds;
+ EscherExHostAppData m_aHostData;
+ WinwordAnchoring m_aWinwordAnchoring;
+ WW8_WrPlcTextBoxes *m_pTextBxs;
sal_uInt32 GetFlyShapeId(const SwFrameFormat& rFormat,
unsigned int nHdFtIndex, DrawObjPointerVector &rPVec);
@@ -170,7 +171,7 @@ public:
virtual void WriteFrameExtraData(const SwFrameFormat& rFormat) override;
- EscherExHostAppData* StartShape(const css::uno::Reference< css::drawing::XShape > &, const tools::Rectangle*) override {return &aHostData;}
+ EscherExHostAppData* StartShape(const css::uno::Reference< css::drawing::XShape > &, const tools::Rectangle*) override {return &m_aHostData;}
private:
SwEscherEx(const SwEscherEx&) = delete;
SwEscherEx &operator=(const SwEscherEx&) = delete;
diff --git a/sw/source/filter/ww8/fields.cxx b/sw/source/filter/ww8/fields.cxx
index 36f8e8690b82..4c7dd8760028 100644
--- a/sw/source/filter/ww8/fields.cxx
+++ b/sw/source/filter/ww8/fields.cxx
@@ -27,6 +27,8 @@ namespace ww
{
//0 Signifies the field names I can't find.
// #i43956# - field <eFOOTREF> = 5 should be mapped to "REF"
+ // See [MS-DOC] 2.9.90 flt
+ // https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-doc/28a8d2c2-6107-409d-8f6a-e345ab6d4179
static const char *aFieldNames[] =
{
/* 0*/ nullptr,
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 34e6cabd0591..b996446b01eb 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -28,7 +28,6 @@
#include <sal/log.hxx>
#include <sot/exchange.hxx>
#include <svtools/rtfkeywd.hxx>
-#include <tools/UnitConversion.hxx>
#include <editeng/fontitem.hxx>
#include <editeng/tstpitem.hxx>
#include <editeng/adjustitem.hxx>
@@ -67,7 +66,6 @@
#include <o3tl/unit_conversion.hxx>
#include <svx/svdouno.hxx>
#include <filter/msfilter/rtfutil.hxx>
-#include <sfx2/sfxbasemodel.hxx>
#include <svx/xfillit0.hxx>
#include <svx/xflgrit.hxx>
#include <docufld.hxx>
@@ -87,14 +85,18 @@
#include <lineinfo.hxx>
#include <redline.hxx>
#include <rtf.hxx>
-#include <IDocumentSettingAccess.hxx>
#include <vcl/cvtgrf.hxx>
-#include <oox/mathml/export.hxx>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <oox/mathml/imexport.hxx>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <svl/grabbagitem.hxx>
#include <frmatr.hxx>
#include <swtable.hxx>
+#include <formatflysplit.hxx>
+#include <fmtwrapinfluenceonobjpos.hxx>
#include "rtfexport.hxx"
+#include <IDocumentDeviceAccess.hxx>
+#include <sfx2/printer.hxx>
using namespace ::com::sun::star;
using namespace sw::util;
@@ -111,7 +113,7 @@ static OString OutTBLBorderLine(RtfExport const& rExport, const editeng::SvxBord
{
case SvxBorderLineStyle::SOLID:
{
- if (DEF_LINE_WIDTH_0 == pLine->GetWidth())
+ if (SvxBorderLineWidth::Hairline == pLine->GetWidth())
aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRHAIR);
else
aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRS);
@@ -182,12 +184,16 @@ static OString OutTBLBorderLine(RtfExport const& rExport, const editeng::SvxBord
else
{
// use \brdrth to double the value range...
- aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTH OOO_STRING_SVTOOLS_RTF_BRDRW);
- aRet.append(static_cast<sal_Int32>(fConverted) / 2);
+ aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTH OOO_STRING_SVTOOLS_RTF_BRDRW
+ + OString::number(static_cast<sal_Int32>(fConverted) / 2));
}
- aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRCF);
- aRet.append(static_cast<sal_Int32>(rExport.GetColor(pLine->GetColor())));
+ aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRCF
+ + OString::number(static_cast<sal_Int32>(rExport.GetColor(pLine->GetColor()))));
+ }
+ else // tdf#129758 "no border" may be needed to override style
+ {
+ aRet.append(OString::Concat(pStr) + OOO_STRING_SVTOOLS_RTF_BRDRNONE);
}
return aRet.makeStringAndClear();
}
@@ -196,10 +202,11 @@ static OString OutBorderLine(RtfExport const& rExport, const editeng::SvxBorderL
const char* pStr, sal_uInt16 nDist,
SvxShadowLocation eShadowLocation = SvxShadowLocation::NONE)
{
- OStringBuffer aRet;
- aRet.append(OutTBLBorderLine(rExport, pLine, pStr));
- aRet.append(OOO_STRING_SVTOOLS_RTF_BRSP);
- aRet.append(static_cast<sal_Int32>(nDist));
+ OStringBuffer aRet(OutTBLBorderLine(rExport, pLine, pStr));
+ if (pLine)
+ {
+ aRet.append(OOO_STRING_SVTOOLS_RTF_BRSP + OString::number(static_cast<sal_Int32>(nDist)));
+ }
if (eShadowLocation == SvxShadowLocation::BottomRight)
aRet.append(LO_STRING_SVTOOLS_RTF_BRDRSH);
return aRet.makeStringAndClear();
@@ -281,7 +288,7 @@ void RtfAttributeOutput::EndParagraph(ww8::WW8TableNodeInfoInner::Pointer_t pTex
// We're ending a paragraph that is the last paragraph of a footnote or endnote, or of clipboard.
bLastPara
= m_rExport.GetCurrentNodeIndex()
- && m_rExport.GetCurrentNodeIndex() == m_rExport.m_pCurPam->End()->nNode.GetIndex();
+ && m_rExport.GetCurrentNodeIndex() == m_rExport.m_pCurPam->End()->GetNodeIndex();
}
FinishTableRowCell(pTextNodeInfoInner);
@@ -289,7 +296,8 @@ void RtfAttributeOutput::EndParagraph(ww8::WW8TableNodeInfoInner::Pointer_t pTex
RtfStringBuffer aParagraph;
aParagraph.appendAndClear(m_aRun);
- aParagraph->append(m_aAfterRuns.makeStringAndClear());
+ aParagraph->append(m_aAfterRuns);
+ m_aAfterRuns.setLength(0);
if (m_bTableAfterCell)
m_bTableAfterCell = false;
else
@@ -317,8 +325,8 @@ void RtfAttributeOutput::EndParagraph(ww8::WW8TableNodeInfoInner::Pointer_t pTex
void RtfAttributeOutput::EmptyParagraph()
{
m_rExport.Strm()
- .WriteCharPtr(SAL_NEWLINE_STRING)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PAR)
+ .WriteOString(SAL_NEWLINE_STRING)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_PAR)
.WriteChar(' ');
}
@@ -330,12 +338,16 @@ void RtfAttributeOutput::SectionBreaks(const SwNode& rNode)
OSL_ENSURE(m_aStyles.getLength() == 0, "m_aStyles is not empty");
// output page/section breaks
- m_rExport.Strm().WriteOString(m_aSectionBreaks.makeStringAndClear());
+ m_rExport.Strm().WriteOString(m_aSectionBreaks);
+ m_aSectionBreaks.setLength(0);
m_bBufferSectionBreaks = true;
// output section headers / footers
if (!m_bBufferSectionHeaders)
- m_rExport.Strm().WriteOString(m_aSectionHeaders.makeStringAndClear());
+ {
+ m_rExport.Strm().WriteOString(m_aSectionHeaders);
+ m_aSectionHeaders.setLength(0);
+ }
if (aNextIndex.GetNode().IsTextNode())
{
@@ -370,12 +382,10 @@ void RtfAttributeOutput::StartParagraphProperties()
OStringBuffer aPar;
if (!m_rExport.GetRTFFlySyntax())
{
- aPar.append(OOO_STRING_SVTOOLS_RTF_PARD);
- aPar.append(OOO_STRING_SVTOOLS_RTF_PLAIN);
- aPar.append(' ');
+ aPar.append(OOO_STRING_SVTOOLS_RTF_PARD OOO_STRING_SVTOOLS_RTF_PLAIN " ");
}
if (!m_bBufferSectionHeaders)
- m_rExport.Strm().WriteOString(aPar.makeStringAndClear());
+ m_rExport.Strm().WriteOString(aPar);
else
m_aSectionHeaders.append(aPar);
}
@@ -385,7 +395,9 @@ void RtfAttributeOutput::EndParagraphProperties(
const SwRedlineData* /*pRedlineParagraphMarkerDeleted*/,
const SwRedlineData* /*pRedlineParagraphMarkerInserted*/)
{
- const OString aProperties = MoveCharacterProperties(true);
+ // Do not call MoveCharacterProperties(),
+ // Otherwise associate properties in the paragraph style are ruined.
+ const OString aProperties = m_aStyles.makeStringAndClear();
m_rExport.Strm().WriteOString(aProperties);
}
@@ -405,7 +417,8 @@ void RtfAttributeOutput::StartRun(const SwRedlineData* pRedlineData, sal_Int32 /
OSL_ENSURE(m_aRunText.getLength() == 0, "m_aRunText is not empty");
}
-void RtfAttributeOutput::EndRun(const SwTextNode* /*pNode*/, sal_Int32 /*nPos*/, bool /*bLastRun*/)
+void RtfAttributeOutput::EndRun(const SwTextNode* /*pNode*/, sal_Int32 /*nPos*/, sal_Int32 /*nLen*/,
+ bool /*bLastRun*/)
{
m_aRun->append(SAL_NEWLINE_STRING);
m_aRun.appendAndClear(m_aRunText);
@@ -429,7 +442,7 @@ void RtfAttributeOutput::StartRunProperties()
void RtfAttributeOutput::EndRunProperties(const SwRedlineData* /*pRedlineData*/)
{
const OString aProperties = MoveCharacterProperties(true);
- m_aRun->append(aProperties.getStr());
+ m_aRun->append(aProperties);
}
OString RtfAttributeOutput::MoveCharacterProperties(bool aAutoWriteRtlLtr)
@@ -500,7 +513,8 @@ OString RtfAttributeOutput::MoveCharacterProperties(bool aAutoWriteRtlLtr)
return aBuf.makeStringAndClear();
}
-void RtfAttributeOutput::RunText(const OUString& rText, rtl_TextEncoding /*eCharSet*/)
+void RtfAttributeOutput::RunText(const OUString& rText, rtl_TextEncoding /*eCharSet*/,
+ const OUString& /*rSymbolFont*/)
{
SAL_INFO("sw.rtf", __func__ << ", rText: " << rText);
RawText(rText, m_rExport.GetCurrentEncoding());
@@ -517,10 +531,9 @@ void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 /*nPos*/,
const SwFormatRuby& rRuby)
{
WW8Ruby aWW8Ruby(rNode, rRuby, GetExport());
- OUString aStr(FieldString(ww::eEQ) + "\\* jc");
- aStr += OUString::number(aWW8Ruby.GetJC()) + " \\* \"Font:";
- aStr += aWW8Ruby.GetFontFamily() + "\" \\* hps";
- aStr += OUString::number((aWW8Ruby.GetRubyHeight() + 5) / 10) + " \\o";
+ OUString aStr = FieldString(ww::eEQ) + "\\* jc" + OUString::number(aWW8Ruby.GetJC())
+ + " \\* \"Font:" + aWW8Ruby.GetFontFamily() + "\" \\* hps"
+ + OUString::number((aWW8Ruby.GetRubyHeight() + 5) / 10) + " \\o";
if (aWW8Ruby.GetDirective())
{
aStr += "\\a" + OUStringChar(aWW8Ruby.GetDirective());
@@ -551,7 +564,9 @@ bool RtfAttributeOutput::StartURL(const OUString& rUrl, const OUString& rTarget)
m_aRun->append(msfilter::rtfutil::OutString(rUrl, m_rExport.GetCurrentEncoding()));
m_aRun->append("\" ");
- if (!rTarget.isEmpty())
+ // Adding the target is likely a LO embellishment.
+ // Don't export it to clipboard, since editeng and other RTF readers won't understand it.
+ if (!rTarget.isEmpty() && !m_rExport.m_rDoc.IsClipBoard())
{
m_aRun->append("\\\\t \"");
m_aRun->append(msfilter::rtfutil::OutString(rTarget, m_rExport.GetCurrentEncoding()));
@@ -598,7 +613,7 @@ bool RtfAttributeOutput::EndURL(bool const isAtEndOfParagraph)
}
void RtfAttributeOutput::FieldVanish(const OUString& /*rText*/, ww::eField /*eType*/,
- OUString const*)
+ OUString const* /*pBookmarkName*/)
{
SAL_INFO("sw.rtf", "TODO: " << __func__);
}
@@ -639,19 +654,18 @@ void RtfAttributeOutput::FormatDrop(const SwTextNode& /*rNode*/,
void RtfAttributeOutput::ParagraphStyle(sal_uInt16 nStyle)
{
OString* pStyle = m_rExport.GetStyle(nStyle);
- OStringBuffer aStyle;
- aStyle.append(OOO_STRING_SVTOOLS_RTF_S);
- aStyle.append(static_cast<sal_Int32>(nStyle));
+ OStringBuffer aStyle(OOO_STRING_SVTOOLS_RTF_S
+ + OString::number(static_cast<sal_Int32>(nStyle)));
if (pStyle)
- aStyle.append(pStyle->getStr());
+ aStyle.append(*pStyle);
if (!m_bBufferSectionHeaders)
- m_rExport.Strm().WriteOString(aStyle.makeStringAndClear());
+ m_rExport.Strm().WriteOString(aStyle);
else
m_aSectionHeaders.append(aStyle);
}
void RtfAttributeOutput::TableInfoCell(
- ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/)
+ const ww8::WW8TableNodeInfoInner::Pointer_t& /*pTableTextNodeInfoInner*/)
{
m_aStyles.append(OOO_STRING_SVTOOLS_RTF_INTBL);
if (m_nTableDepth > 1)
@@ -662,13 +676,123 @@ void RtfAttributeOutput::TableInfoCell(
m_bWroteCellInfo = true;
}
-void RtfAttributeOutput::TableInfoRow(ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfo*/)
+void RtfAttributeOutput::TableInfoRow(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& /*pTableTextNodeInfo*/)
{
/* noop */
}
+void RtfAttributeOutput::TablePositioning(SwFrameFormat* pFlyFormat)
+{
+ if (!pFlyFormat || !pFlyFormat->GetFlySplit().GetValue())
+ {
+ return;
+ }
+
+ switch (pFlyFormat->GetVertOrient().GetRelationOrient())
+ {
+ case text::RelOrientation::PAGE_PRINT_AREA:
+ // relative to margin
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TPVMRG);
+ break;
+ case text::RelOrientation::PAGE_FRAME:
+ // relative to page
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TPVPG);
+ break;
+ default:
+ // text::RelOrientation::FRAME
+ // relative to text
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TPVPARA);
+ break;
+ }
+
+ switch (pFlyFormat->GetHoriOrient().GetRelationOrient())
+ {
+ case text::RelOrientation::FRAME:
+ // relative to column
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TPHCOL);
+ break;
+ case text::RelOrientation::PAGE_PRINT_AREA:
+ // relative to margin
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TPHMRG);
+ break;
+ default:
+ // text::RelOrientation::PAGE_FRAME
+ // relative to page
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TPHPG);
+ break;
+ }
+
+ // Similar to RtfAttributeOutput::FormatHorizOrientation(), but for tables.
+ switch (pFlyFormat->GetHoriOrient().GetHoriOrient())
+ {
+ case text::HoriOrientation::LEFT:
+ // left
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TPOSXL);
+ break;
+ case text::HoriOrientation::CENTER:
+ // centered
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TPOSXC);
+ break;
+ case text::HoriOrientation::RIGHT:
+ // right
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TPOSXR);
+ break;
+ default:
+ SwTwips nTPosX = pFlyFormat->GetHoriOrient().GetPos();
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TPOSX);
+ m_aRowDefs.append(static_cast<sal_Int32>(nTPosX));
+ break;
+ }
+
+ // Similar to RtfAttributeOutput::FormatVertOrientation(), but for tables.
+ switch (pFlyFormat->GetVertOrient().GetVertOrient())
+ {
+ case text::VertOrientation::TOP:
+ // up
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TPOSYT);
+ break;
+ case text::VertOrientation::CENTER:
+ // centered
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TPOSYC);
+ break;
+ case text::VertOrientation::BOTTOM:
+ // down
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TPOSYB);
+ break;
+ default:
+ SwTwips nTPosY = pFlyFormat->GetVertOrient().GetPos();
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TPOSY);
+ m_aRowDefs.append(static_cast<sal_Int32>(nTPosY));
+ break;
+ }
+
+ // Similar to RtfAttributeOutput::FormatULSpace(), but for tables.
+ sal_uInt16 nTdfrmtxtTop = pFlyFormat->GetULSpace().GetUpper();
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TDFRMTXTTOP);
+ m_aRowDefs.append(static_cast<sal_Int32>(nTdfrmtxtTop));
+ sal_uInt16 nTdfrmtxtBottom = pFlyFormat->GetULSpace().GetLower();
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TDFRMTXTBOTTOM);
+ m_aRowDefs.append(static_cast<sal_Int32>(nTdfrmtxtBottom));
+
+ // Similar to RtfAttributeOutput::FormatLRSpace(), but for tables.
+ sal_uInt16 nTdfrmtxtLeft = pFlyFormat->GetLRSpace().GetLeft();
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TDFRMTXTLEFT);
+ m_aRowDefs.append(static_cast<sal_Int32>(nTdfrmtxtLeft));
+ sal_uInt16 nTdfrmtxtRight = pFlyFormat->GetLRSpace().GetRight();
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TDFRMTXTRIGHT);
+ m_aRowDefs.append(static_cast<sal_Int32>(nTdfrmtxtRight));
+
+ if (!pFlyFormat->GetWrapInfluenceOnObjPos().GetAllowOverlap())
+ {
+ // Allowing overlap is the default in both Writer and in RTF.
+ m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TABSNOOVRLP);
+ m_aRowDefs.append(static_cast<sal_Int32>(1));
+ }
+}
+
void RtfAttributeOutput::TableDefinition(
- ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner)
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
InitTableHelper(pTableTextNodeInfoInner);
@@ -681,6 +805,9 @@ void RtfAttributeOutput::TableDefinition(
TableHeight(pTableTextNodeInfoInner);
TableCanSplit(pTableTextNodeInfoInner);
+ // Write table positioning properties in case this is a floating table.
+ TablePositioning(pTable->GetTableNode()->GetFlyFormat());
+
// Cell margins
const SvxBoxItem& rBox = pFormat->GetBox();
static const SvxBoxItemLine aBorders[] = { SvxBoxItemLine::TOP, SvxBoxItemLine::LEFT,
@@ -705,7 +832,13 @@ void RtfAttributeOutput::TableDefinition(
// The cell-dependent properties
const double fWidthRatio = m_pTableWrt->GetAbsWidthRatio();
const SwWriteTableRows& aRows = m_pTableWrt->GetRows();
- SwWriteTableRow* pRow = aRows[pTableTextNodeInfoInner->getRow()].get();
+ sal_uInt32 nRow = pTableTextNodeInfoInner->getRow();
+ if (nRow >= aRows.size())
+ {
+ SAL_WARN("sw.ww8", "RtfAttributeOutput::TableDefinition: out of range row: " << nRow);
+ return;
+ }
+ SwWriteTableRow* pRow = aRows[nRow].get();
SwTwips nSz = 0;
// Not using m_nTableDepth, which is not yet incremented here.
@@ -729,7 +862,7 @@ void RtfAttributeOutput::TableDefinition(
}
void RtfAttributeOutput::TableDefaultBorders(
- ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner)
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
/*
* The function name is a bit misleading: given that we write borders
@@ -743,11 +876,11 @@ void RtfAttributeOutput::TableDefaultBorders(
const SwWriteTableCell* const pCell
= pRow->GetCells()[pTableTextNodeInfoInner->getCell()].get();
const SwFrameFormat* pCellFormat = pCell->GetBox()->GetFrameFormat();
- const SfxPoolItem* pItem;
- if (!pCellFormat->GetAttrSet().HasItem(RES_BOX, &pItem))
+ const SvxBoxItem* pItem = pCellFormat->GetAttrSet().GetItemIfSet(RES_BOX);
+ if (!pItem)
return;
- auto& rBox = static_cast<const SvxBoxItem&>(*pItem);
+ auto& rBox = *pItem;
static const SvxBoxItemLine aBorders[] = { SvxBoxItemLine::TOP, SvxBoxItemLine::LEFT,
SvxBoxItemLine::BOTTOM, SvxBoxItemLine::RIGHT };
static const char* aBorderNames[]
@@ -776,7 +909,7 @@ void RtfAttributeOutput::TableDefaultBorders(
}
void RtfAttributeOutput::TableBackgrounds(
- ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner)
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
const SwTable* pTable = pTableTextNodeInfoInner->getTable();
const SwTableBox* pTableBox = pTableTextNodeInfoInner->getTableBox();
@@ -798,12 +931,10 @@ void RtfAttributeOutput::TableBackgrounds(
const SwWriteTableCell* const pCell
= pRow->GetCells()[pTableTextNodeInfoInner->getCell()].get();
const SwFrameFormat* pCellFormat = pCell->GetBox()->GetFrameFormat();
- const SfxPoolItem* pItem;
- if (pCellFormat->GetAttrSet().HasItem(RES_BACKGROUND, &pItem))
+ if (const SvxBrushItem* pBrushItem = pCellFormat->GetAttrSet().GetItemIfSet(RES_BACKGROUND))
{
- auto& rBack = static_cast<const SvxBrushItem&>(*pItem);
- if (rBack.GetColor() != COL_AUTO)
- aColor = rBack.GetColor();
+ if (pBrushItem->GetColor() != COL_AUTO)
+ aColor = pBrushItem->GetColor();
}
if (!aColor.IsTransparent())
@@ -814,16 +945,17 @@ void RtfAttributeOutput::TableBackgrounds(
}
void RtfAttributeOutput::TableRowRedline(
- ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/)
+ const ww8::WW8TableNodeInfoInner::Pointer_t& /*pTableTextNodeInfoInner*/)
{
}
void RtfAttributeOutput::TableCellRedline(
- ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/)
+ const ww8::WW8TableNodeInfoInner::Pointer_t& /*pTableTextNodeInfoInner*/)
{
}
-void RtfAttributeOutput::TableHeight(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner)
+void RtfAttributeOutput::TableHeight(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
const SwTableBox* pTabBox = pTableTextNodeInfoInner->getTableBox();
const SwTableLine* pTabLine = pTabBox->GetUpper();
@@ -855,7 +987,7 @@ void RtfAttributeOutput::TableHeight(ww8::WW8TableNodeInfoInner::Pointer_t pTabl
}
void RtfAttributeOutput::TableCanSplit(
- ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner)
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
const SwTableBox* pTabBox = pTableTextNodeInfoInner->getTableBox();
const SwTableLine* pTabLine = pTabBox->GetUpper();
@@ -867,7 +999,8 @@ void RtfAttributeOutput::TableCanSplit(
m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_TRKEEP);
}
-void RtfAttributeOutput::TableBidi(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner)
+void RtfAttributeOutput::TableBidi(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
const SwTable* pTable = pTableTextNodeInfoInner->getTable();
const SwFrameFormat* pFrameFormat = pTable->GetFrameFormat();
@@ -879,7 +1012,7 @@ void RtfAttributeOutput::TableBidi(ww8::WW8TableNodeInfoInner::Pointer_t pTableT
}
void RtfAttributeOutput::TableVerticalCell(
- ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner)
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
const SwWriteTableRows& aRows = m_pTableWrt->GetRows();
SwWriteTableRow* pRow = aRows[pTableTextNodeInfoInner->getRow()].get();
@@ -893,8 +1026,6 @@ void RtfAttributeOutput::TableVerticalCell(
else if (SvxFrameDirection::Vertical_LR_BT == m_rExport.TrueFrameDirection(*pCellFormat))
m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLTXBTLR);
- const SfxPoolItem* pItem;
-
// vertical merges
if (pCell->GetRowSpan() > 1)
m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVMGF);
@@ -902,10 +1033,12 @@ void RtfAttributeOutput::TableVerticalCell(
m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVMRG);
// vertical alignment
- if (!pCellFormat->GetAttrSet().HasItem(RES_VERT_ORIENT, &pItem))
+ const SwFormatVertOrient* pVertOrientItem
+ = pCellFormat->GetAttrSet().GetItemIfSet(RES_VERT_ORIENT);
+ if (!pVertOrientItem)
return;
- switch (static_cast<const SwFormatVertOrient*>(pItem)->GetVertOrient())
+ switch (pVertOrientItem->GetVertOrient())
{
case text::VertOrientation::CENTER:
m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALC);
@@ -919,7 +1052,8 @@ void RtfAttributeOutput::TableVerticalCell(
}
}
-void RtfAttributeOutput::TableNodeInfoInner(ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner)
+void RtfAttributeOutput::TableNodeInfoInner(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pNodeInfoInner)
{
// This is called when the nested table ends in a cell, and there's no
// paragraph behind that; so we must check for the ends of cell, rows,
@@ -928,7 +1062,7 @@ void RtfAttributeOutput::TableNodeInfoInner(ww8::WW8TableNodeInfoInner::Pointer_
}
void RtfAttributeOutput::TableOrientation(
- ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner)
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
const SwTable* pTable = pTableTextNodeInfoInner->getTable();
SwFrameFormat* pFormat = pTable->GetFrameFormat();
@@ -957,7 +1091,7 @@ void RtfAttributeOutput::TableOrientation(
}
void RtfAttributeOutput::TableSpacing(
- ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/)
+ const ww8::WW8TableNodeInfoInner::Pointer_t& /*pTableTextNodeInfoInner*/)
{
SAL_INFO("sw.rtf", "TODO: " << __func__);
}
@@ -1015,8 +1149,10 @@ void RtfAttributeOutput::StartTableRow(
return;
// Empty the previous row closing buffer before starting the new one,
// necessary for subtables.
- m_rExport.Strm().WriteOString(m_aAfterRuns.makeStringAndClear());
- m_rExport.Strm().WriteOString(m_aRowDefs.makeStringAndClear());
+ m_rExport.Strm().WriteOString(m_aAfterRuns);
+ m_aAfterRuns.setLength(0);
+ m_rExport.Strm().WriteOString(m_aRowDefs);
+ m_aRowDefs.setLength(0);
}
void RtfAttributeOutput::StartTableCell() { m_bTableCellOpen = true; }
@@ -1055,16 +1191,15 @@ void RtfAttributeOutput::EndTableRow()
{
SAL_INFO("sw.rtf", __func__ << ", (depth is " << m_nTableDepth << ")");
- // Trying to end the row without writing the required number of cells? Fill with empty ones.
- for (sal_uInt32 i = 0; i < m_aCells[m_nTableDepth]; i++)
- m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_CELL);
-
if (m_nTableDepth > 1)
{
m_aAfterRuns.append(
"{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_NESTTABLEPROPRS);
if (!m_aRowDefs.isEmpty())
- m_aAfterRuns.append(m_aRowDefs.makeStringAndClear());
+ {
+ m_aAfterRuns.append(m_aRowDefs);
+ m_aRowDefs.setLength(0);
+ }
else if (!m_aTables.empty())
{
m_aAfterRuns.append(m_aTables.back());
@@ -1081,7 +1216,9 @@ void RtfAttributeOutput::EndTableRow()
m_aAfterRuns.append(m_aTables.back());
m_aTables.pop_back();
}
- m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_ROW OOO_STRING_SVTOOLS_RTF_PARD);
+ // Make sure that the first word of the next paragraph is not merged with the last control
+ // word of this table row, happens with floating tables.
+ m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_ROW OOO_STRING_SVTOOLS_RTF_PARD " ");
}
m_bTableRowEnded = true;
}
@@ -1129,9 +1266,9 @@ void RtfAttributeOutput::FinishTableRowCell(const ww8::WW8TableNodeInfoInner::Po
void RtfAttributeOutput::StartStyles()
{
m_rExport.Strm()
- .WriteCharPtr(SAL_NEWLINE_STRING)
+ .WriteOString(SAL_NEWLINE_STRING)
.WriteChar('{')
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_COLORTBL);
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_COLORTBL);
m_rExport.OutColorTable();
OSL_ENSURE(m_aStylesheet.getLength() == 0, "m_aStylesheet is not empty");
m_aStylesheet.append(SAL_NEWLINE_STRING);
@@ -1142,15 +1279,16 @@ void RtfAttributeOutput::StartStyles()
void RtfAttributeOutput::EndStyles(sal_uInt16 /*nNumberOfStyles*/)
{
m_rExport.Strm().WriteChar('}');
- m_rExport.Strm().WriteOString(m_aStylesheet.makeStringAndClear());
+ m_rExport.Strm().WriteOString(m_aStylesheet);
+ m_aStylesheet.setLength(0);
m_rExport.Strm().WriteChar('}');
}
void RtfAttributeOutput::DefaultStyle() { /* noop, the default style is always 0 in RTF */}
void RtfAttributeOutput::StartStyle(const OUString& rName, StyleType eType, sal_uInt16 nBase,
- sal_uInt16 nNext, sal_uInt16 /*nWwId*/, sal_uInt16 nId,
- bool bAutoUpdate)
+ sal_uInt16 nNext, sal_uInt16 /*nLink*/, sal_uInt16 /*nWwId*/,
+ sal_uInt16 nSlot, bool bAutoUpdate)
{
SAL_INFO("sw.rtf", __func__ << ", rName = '" << rName << "'");
@@ -1159,7 +1297,7 @@ void RtfAttributeOutput::StartStyle(const OUString& rName, StyleType eType, sal_
m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_S);
else
m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_CS);
- m_aStylesheet.append(static_cast<sal_Int32>(nId));
+ m_aStylesheet.append(static_cast<sal_Int32>(nSlot));
if (nBase != 0x0FFF)
{
@@ -1174,7 +1312,7 @@ void RtfAttributeOutput::StartStyle(const OUString& rName, StyleType eType, sal_
m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_SAUTOUPD);
m_rStyleName = rName;
- m_nStyleId = nId;
+ m_nStyleId = nSlot;
}
void RtfAttributeOutput::EndStyle()
@@ -1211,7 +1349,7 @@ void RtfAttributeOutput::PageBreakBefore(bool bBreak)
{
if (bBreak)
{
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PAGEBB);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_PAGEBB);
}
}
@@ -1237,7 +1375,10 @@ void RtfAttributeOutput::StartSection()
m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_SECT OOO_STRING_SVTOOLS_RTF_SECTD);
if (!m_bBufferSectionBreaks)
- m_rExport.Strm().WriteOString(m_aSectionBreaks.makeStringAndClear());
+ {
+ m_rExport.Strm().WriteOString(m_aSectionBreaks);
+ m_aSectionBreaks.setLength(0);
+ }
}
void RtfAttributeOutput::EndSection()
@@ -1257,17 +1398,17 @@ void RtfAttributeOutput::SectionFormProtection(bool bProtected)
void RtfAttributeOutput::SectionLineNumbering(sal_uLong nRestartNo,
const SwLineNumberInfo& rLnNumInfo)
{
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LINEMOD);
- m_rExport.OutLong(rLnNumInfo.GetCountBy());
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LINEX);
- m_rExport.OutLong(rLnNumInfo.GetPosFromLeft());
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LINEMOD);
+ m_rExport.Strm().WriteNumberAsString(rLnNumInfo.GetCountBy());
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LINEX);
+ m_rExport.Strm().WriteNumberAsString(rLnNumInfo.GetPosFromLeft());
if (!rLnNumInfo.IsRestartEachPage())
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LINECONT);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LINECONT);
if (nRestartNo > 0)
{
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LINESTARTS);
- m_rExport.OutLong(nRestartNo);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LINESTARTS);
+ m_rExport.Strm().WriteNumberAsString(nRestartNo);
}
}
@@ -1282,27 +1423,37 @@ void RtfAttributeOutput::SectionPageBorders(const SwFrameFormat* pFormat,
const SwFrameFormat* /*pFirstPageFormat*/)
{
const SvxBoxItem& rBox = pFormat->GetBox();
+ editeng::WordBorderDistances aDistances;
+ editeng::BorderDistancesToWord(rBox, m_aPageMargins, aDistances);
+
+ if (aDistances.bFromEdge)
+ {
+ sal_uInt16 nOpt = (1 << 5);
+ m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGBRDROPT);
+ m_aSectionBreaks.append(static_cast<sal_Int32>(nOpt));
+ }
+
const editeng::SvxBorderLine* pLine = rBox.GetTop();
if (pLine)
- m_aSectionBreaks.append(OutBorderLine(m_rExport, pLine, OOO_STRING_SVTOOLS_RTF_PGBRDRT,
- rBox.GetDistance(SvxBoxItemLine::TOP)));
+ m_aSectionBreaks.append(
+ OutBorderLine(m_rExport, pLine, OOO_STRING_SVTOOLS_RTF_PGBRDRT, aDistances.nTop));
pLine = rBox.GetBottom();
if (pLine)
- m_aSectionBreaks.append(OutBorderLine(m_rExport, pLine, OOO_STRING_SVTOOLS_RTF_PGBRDRB,
- rBox.GetDistance(SvxBoxItemLine::BOTTOM)));
+ m_aSectionBreaks.append(
+ OutBorderLine(m_rExport, pLine, OOO_STRING_SVTOOLS_RTF_PGBRDRB, aDistances.nBottom));
pLine = rBox.GetLeft();
if (pLine)
- m_aSectionBreaks.append(OutBorderLine(m_rExport, pLine, OOO_STRING_SVTOOLS_RTF_PGBRDRL,
- rBox.GetDistance(SvxBoxItemLine::LEFT)));
+ m_aSectionBreaks.append(
+ OutBorderLine(m_rExport, pLine, OOO_STRING_SVTOOLS_RTF_PGBRDRL, aDistances.nLeft));
pLine = rBox.GetRight();
if (pLine)
- m_aSectionBreaks.append(OutBorderLine(m_rExport, pLine, OOO_STRING_SVTOOLS_RTF_PGBRDRR,
- rBox.GetDistance(SvxBoxItemLine::RIGHT)));
+ m_aSectionBreaks.append(
+ OutBorderLine(m_rExport, pLine, OOO_STRING_SVTOOLS_RTF_PGBRDRR, aDistances.nRight));
}
void RtfAttributeOutput::SectionBiDi(bool bBiDi)
{
- m_rExport.Strm().WriteCharPtr(bBiDi ? OOO_STRING_SVTOOLS_RTF_RTLSECT
+ m_rExport.Strm().WriteOString(bBiDi ? OOO_STRING_SVTOOLS_RTF_RTLSECT
: OOO_STRING_SVTOOLS_RTF_LTRSECT);
}
@@ -1371,7 +1522,10 @@ void RtfAttributeOutput::SectionType(sal_uInt8 nBreakCode)
}
m_aSectionBreaks.append(sType);
if (!m_bBufferSectionBreaks)
- m_rExport.Strm().WriteOString(m_aSectionBreaks.makeStringAndClear());
+ {
+ m_rExport.Strm().WriteOString(m_aSectionBreaks);
+ m_aSectionBreaks.setLength(0);
+ }
}
void RtfAttributeOutput::SectFootnoteEndnotePr()
@@ -1441,34 +1595,35 @@ void RtfAttributeOutput::WriteFootnoteEndnotePr(bool bFootnote, const SwEndNoteI
if (!m_bBufferSectionBreaks)
{
- m_rExport.Strm().WriteOString(m_aSectionBreaks.makeStringAndClear());
+ m_rExport.Strm().WriteOString(m_aSectionBreaks);
+ m_aSectionBreaks.setLength(0);
}
}
void RtfAttributeOutput::NumberingDefinition(sal_uInt16 nId, const SwNumRule& /*rRule*/)
{
- m_rExport.Strm().WriteChar('{').WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LISTOVERRIDE);
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LISTID);
- m_rExport.OutULong(nId);
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LISTOVERRIDECOUNT).WriteChar('0');
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LS);
- m_rExport.OutULong(nId).WriteChar('}');
+ m_rExport.Strm().WriteChar('{').WriteOString(OOO_STRING_SVTOOLS_RTF_LISTOVERRIDE);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LISTID);
+ m_rExport.Strm().WriteNumberAsString(nId);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LISTOVERRIDECOUNT).WriteChar('0');
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LS);
+ m_rExport.Strm().WriteNumberAsString(nId).WriteChar('}');
}
void RtfAttributeOutput::StartAbstractNumbering(sal_uInt16 nId)
{
m_rExport.Strm()
.WriteChar('{')
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LIST)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LISTTEMPLATEID);
- m_rExport.OutULong(nId);
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_LIST)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_LISTTEMPLATEID);
+ m_rExport.Strm().WriteNumberAsString(nId);
m_nListId = nId;
}
void RtfAttributeOutput::EndAbstractNumbering()
{
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LISTID);
- m_rExport.OutULong(m_nListId).WriteChar('}').WriteCharPtr(SAL_NEWLINE_STRING);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LISTID);
+ m_rExport.Strm().WriteNumberAsString(m_nListId).WriteChar('}').WriteOString(SAL_NEWLINE_STRING);
}
void RtfAttributeOutput::NumberingLevel(sal_uInt8 nLevel, sal_uInt16 nStart,
@@ -1477,15 +1632,15 @@ void RtfAttributeOutput::NumberingLevel(sal_uInt8 nLevel, sal_uInt16 nStart,
const wwFont* pFont, const SfxItemSet* pOutSet,
sal_Int16 nIndentAt, sal_Int16 nFirstLineIndex,
sal_Int16 /*nListTabPos*/, const OUString& rNumberingString,
- const SvxBrushItem* pBrush)
+ const SvxBrushItem* pBrush, bool isLegal)
{
- m_rExport.Strm().WriteCharPtr(SAL_NEWLINE_STRING);
+ m_rExport.Strm().WriteOString(SAL_NEWLINE_STRING);
if (nLevel > 8) // RTF knows only 9 levels
m_rExport.Strm()
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_IGNORE)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SOUTLVL);
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_IGNORE)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_SOUTLVL);
- m_rExport.Strm().WriteChar('{').WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LISTLEVEL);
+ m_rExport.Strm().WriteChar('{').WriteOString(OOO_STRING_SVTOOLS_RTF_LISTLEVEL);
sal_uInt16 nVal = 0;
switch (nNumberingType)
@@ -1561,10 +1716,16 @@ void RtfAttributeOutput::NumberingLevel(sal_uInt8 nLevel, sal_uInt16 nStart,
nVal = 25;
break;
case style::NumberingType::NUMBER_HANGUL_KO:
- nVal = 41;
+ nVal = 42;
+ break; // koreanCounting
+ case style::NumberingType::NUMBER_DIGITAL_KO:
+ nVal = 41; // koreanDigital
break;
- case style::NumberingType::NUMBER_UPPER_KO:
- nVal = 44;
+ case style::NumberingType::NUMBER_DIGITAL2_KO:
+ nVal = 44; // koreanDigital2
+ break;
+ case style::NumberingType::NUMBER_LEGAL_KO:
+ nVal = 43; // koreanLegal
break;
case SVX_NUM_BITMAP:
@@ -1578,8 +1739,8 @@ void RtfAttributeOutput::NumberingLevel(sal_uInt8 nLevel, sal_uInt16 nStart,
nVal = 22;
break;
}
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LEVELNFC);
- m_rExport.OutULong(nVal);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LEVELNFC);
+ m_rExport.Strm().WriteNumberAsString(nVal);
switch (eAdjust)
{
@@ -1593,8 +1754,8 @@ void RtfAttributeOutput::NumberingLevel(sal_uInt8 nLevel, sal_uInt16 nStart,
nVal = 0;
break;
}
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LEVELJC);
- m_rExport.OutULong(nVal);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LEVELJC);
+ m_rExport.Strm().WriteNumberAsString(nVal);
// bullet
if (nNumberingType == SVX_NUM_BITMAP && pBrush)
@@ -1602,55 +1763,59 @@ void RtfAttributeOutput::NumberingLevel(sal_uInt8 nLevel, sal_uInt16 nStart,
int nIndex = m_rExport.GetGrfIndex(*pBrush);
if (nIndex != -1)
{
- m_rExport.Strm().WriteCharPtr(LO_STRING_SVTOOLS_RTF_LEVELPICTURE);
- m_rExport.OutULong(nIndex);
+ m_rExport.Strm().WriteOString(LO_STRING_SVTOOLS_RTF_LEVELPICTURE);
+ m_rExport.Strm().WriteNumberAsString(nIndex);
}
}
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LEVELSTARTAT);
- m_rExport.OutULong(nStart);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LEVELSTARTAT);
+ m_rExport.Strm().WriteNumberAsString(nStart);
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LEVELFOLLOW);
- m_rExport.OutULong(nFollow);
+ if (isLegal)
+ {
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LEVELLEGAL);
+ }
+
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LEVELFOLLOW);
+ m_rExport.Strm().WriteNumberAsString(nFollow);
// leveltext group
- m_rExport.Strm().WriteChar('{').WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LEVELTEXT).WriteChar(' ');
+ m_rExport.Strm().WriteChar('{').WriteOString(OOO_STRING_SVTOOLS_RTF_LEVELTEXT).WriteChar(' ');
if (SVX_NUM_CHAR_SPECIAL == nNumberingType || SVX_NUM_BITMAP == nNumberingType)
{
- m_rExport.Strm().WriteCharPtr("\\'01");
+ m_rExport.Strm().WriteOString("\\'01");
sal_Unicode cChar = rNumberingString[0];
- m_rExport.Strm().WriteCharPtr("\\u");
- m_rExport.OutULong(cChar);
- m_rExport.Strm().WriteCharPtr(" ?");
+ m_rExport.Strm().WriteOString("\\u");
+ m_rExport.Strm().WriteNumberAsString(cChar);
+ m_rExport.Strm().WriteOString(" ?");
}
else
{
- m_rExport.Strm().WriteCharPtr("\\'").WriteCharPtr(
- msfilter::rtfutil::OutHex(rNumberingString.getLength(), 2).getStr());
- m_rExport.Strm().WriteCharPtr(msfilter::rtfutil::OutString(rNumberingString,
+ m_rExport.Strm().WriteOString("\\'").WriteOString(
+ msfilter::rtfutil::OutHex(rNumberingString.getLength(), 2));
+ m_rExport.Strm().WriteOString(msfilter::rtfutil::OutString(rNumberingString,
m_rExport.GetDefaultEncoding(),
- /*bUnicode =*/false)
- .getStr());
+ /*bUnicode =*/false));
}
- m_rExport.Strm().WriteCharPtr(";}");
+ m_rExport.Strm().WriteOString(";}");
// write the levelnumbers
- m_rExport.Strm().WriteCharPtr("{").WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LEVELNUMBERS);
+ m_rExport.Strm().WriteOString("{").WriteOString(OOO_STRING_SVTOOLS_RTF_LEVELNUMBERS);
for (sal_uInt8 i = 0; i <= nLevel && pNumLvlPos[i]; ++i)
{
- m_rExport.Strm().WriteCharPtr("\\'").WriteCharPtr(
- msfilter::rtfutil::OutHex(pNumLvlPos[i], 2).getStr());
+ m_rExport.Strm().WriteOString("\\'").WriteOString(
+ msfilter::rtfutil::OutHex(pNumLvlPos[i], 2));
}
- m_rExport.Strm().WriteCharPtr(";}");
+ m_rExport.Strm().WriteOString(";}");
if (pOutSet)
{
if (pFont)
{
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_F);
- m_rExport.OutULong(m_rExport.m_aFontHelper.GetId(*pFont));
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_F);
+ m_rExport.Strm().WriteNumberAsString(m_rExport.m_aFontHelper.GetId(*pFont));
}
m_rExport.OutputItemSet(*pOutSet, false, true, i18n::ScriptType::LATIN,
m_rExport.m_bExportModeRTF);
@@ -1658,9 +1823,9 @@ void RtfAttributeOutput::NumberingLevel(sal_uInt8 nLevel, sal_uInt16 nStart,
m_rExport.Strm().WriteOString(aProperties);
}
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_FI);
- m_rExport.OutLong(nFirstLineIndex).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LI);
- m_rExport.OutLong(nIndentAt);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_FI);
+ m_rExport.Strm().WriteNumberAsString(nFirstLineIndex).WriteOString(OOO_STRING_SVTOOLS_RTF_LI);
+ m_rExport.Strm().WriteNumberAsString(nIndentAt);
m_rExport.Strm().WriteChar('}');
if (nLevel > 8)
@@ -1668,10 +1833,10 @@ void RtfAttributeOutput::NumberingLevel(sal_uInt8 nLevel, sal_uInt16 nStart,
}
void RtfAttributeOutput::WriteField_Impl(const SwField* const pField, ww::eField /*eType*/,
- const OUString& rFieldCmd, FieldFlags nMode)
+ std::u16string_view rFieldCmd, FieldFlags nMode)
{
// If there are no field instructions, don't export it as a field.
- bool bHasInstructions = !rFieldCmd.isEmpty();
+ bool bHasInstructions = !rFieldCmd.empty();
if (FieldFlags::All == nMode)
{
if (bHasInstructions)
@@ -1705,7 +1870,13 @@ void RtfAttributeOutput::WriteField_Impl(const SwField* const pField, ww::eField
msfilter::rtfutil::OutString(rFieldCmd, m_rExport.GetCurrentEncoding()));
if (nMode & FieldFlags::CmdEnd)
{
- m_aRunText->append("}}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " {");
+ m_aRunText->append("}}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT);
+ // The fldrslt contains its own full copy of character formatting,
+ // but if the result is empty (nMode & FieldFlags::End) or field export is condensed
+ // in any way (multiple flags) then avoid spamming an unnecessary plain character reset.
+ if (nMode == FieldFlags::CmdEnd)
+ m_aRunText->append(OOO_STRING_SVTOOLS_RTF_PLAIN);
+ m_aRunText->append(" {");
}
if (nMode & FieldFlags::Close)
{
@@ -1719,17 +1890,17 @@ void RtfAttributeOutput::WriteBookmarks_Impl(std::vector<OUString>& rStarts,
{
for (const auto& rStart : rStarts)
{
- m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKSTART " ");
- m_aRun->append(msfilter::rtfutil::OutString(rStart, m_rExport.GetCurrentEncoding()));
- m_aRun->append('}');
+ m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKSTART " ");
+ m_aRunText->append(msfilter::rtfutil::OutString(rStart, m_rExport.GetCurrentEncoding()));
+ m_aRunText->append('}');
}
rStarts.clear();
for (const auto& rEnd : rEnds)
{
- m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKEND " ");
- m_aRun->append(msfilter::rtfutil::OutString(rEnd, m_rExport.GetCurrentEncoding()));
- m_aRun->append('}');
+ m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKEND " ");
+ m_aRunText->append(msfilter::rtfutil::OutString(rEnd, m_rExport.GetCurrentEncoding()));
+ m_aRunText->append('}');
}
rEnds.clear();
}
@@ -1745,7 +1916,7 @@ void RtfAttributeOutput::WriteAnnotationMarks_Impl(std::vector<OUString>& rStart
const sal_Int32 nId = m_nNextAnnotationMarkId++;
m_rOpenedAnnotationMarksIds[rName] = nId;
m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATRFSTART " ");
- m_aRun->append(OString::number(nId).getStr());
+ m_aRun->append(nId);
m_aRun->append('}');
}
rStarts.clear();
@@ -1760,7 +1931,7 @@ void RtfAttributeOutput::WriteAnnotationMarks_Impl(std::vector<OUString>& rStart
{
const sal_Int32 nId = it->second;
m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATRFEND " ");
- m_aRun->append(OString::number(nId).getStr());
+ m_aRun->append(nId);
m_aRun->append('}');
m_rOpenedAnnotationMarksIds.erase(rName);
@@ -1799,7 +1970,7 @@ void RtfAttributeOutput::WriteHeaderFooter_Impl(const SwFrameFormat& rFormat, bo
m_aSectionHeaders.append('}');
m_aSectionBreaks = aSectionBreaks;
- m_aRun = aRun;
+ m_aRun = std::move(aRun);
}
namespace
@@ -1811,12 +1982,12 @@ void lcl_TextFrameShadow(std::vector<std::pair<OString, OString>>& rFlyPropertie
if (aShadowItem.GetLocation() == SvxShadowLocation::NONE)
return;
- rFlyProperties.push_back(std::make_pair<OString, OString>("fShadow", OString::number(1)));
+ rFlyProperties.push_back(std::make_pair<OString, OString>("fShadow"_ostr, OString::number(1)));
const Color& rColor = aShadowItem.GetColor();
// We in fact need RGB to BGR, but the transformation is symmetric.
rFlyProperties.push_back(std::make_pair<OString, OString>(
- "shadowColor", OString::number(wwUtility::RGBToBGR(rColor))));
+ "shadowColor"_ostr, OString::number(wwUtility::RGBToBGR(rColor))));
// Twips -> points -> EMUs -- hacky, the intermediate step hides rounding errors on roundtrip.
OString aShadowWidth = OString::number(sal_Int32(aShadowItem.GetWidth() / 20) * 12700);
@@ -1860,16 +2031,16 @@ void lcl_TextFrameRelativeSize(std::vector<std::pair<OString, OString>>& rFlyPro
if (nWidthPercent && nWidthPercent != SwFormatFrameSize::SYNCED)
{
rFlyProperties.push_back(
- std::make_pair<OString, OString>("pctHoriz", OString::number(nWidthPercent * 10)));
+ std::make_pair<OString, OString>("pctHoriz"_ostr, OString::number(nWidthPercent * 10)));
OString aRelation;
switch (rSize.GetWidthPercentRelation())
{
case text::RelOrientation::PAGE_FRAME:
- aRelation = "1"; // page
+ aRelation = "1"_ostr; // page
break;
default:
- aRelation = "0"; // margin
+ aRelation = "0"_ostr; // margin
break;
}
rFlyProperties.emplace_back(std::make_pair("sizerelh", aRelation));
@@ -1879,16 +2050,16 @@ void lcl_TextFrameRelativeSize(std::vector<std::pair<OString, OString>>& rFlyPro
return;
rFlyProperties.push_back(
- std::make_pair<OString, OString>("pctVert", OString::number(nHeightPercent * 10)));
+ std::make_pair<OString, OString>("pctVert"_ostr, OString::number(nHeightPercent * 10)));
OString aRelation;
switch (rSize.GetHeightPercentRelation())
{
case text::RelOrientation::PAGE_FRAME:
- aRelation = "1"; // page
+ aRelation = "1"_ostr; // page
break;
default:
- aRelation = "0"; // margin
+ aRelation = "0"_ostr; // margin
break;
}
rFlyProperties.emplace_back(std::make_pair("sizerelv", aRelation));
@@ -1905,7 +2076,7 @@ void RtfAttributeOutput::writeTextFrame(const ww8::Frame& rFrame, bool bTextBox)
m_aRunText.clear();
}
- m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SHPTXT);
+ m_rExport.Strm().WriteOString("{" OOO_STRING_SVTOOLS_RTF_SHPTXT);
{
// Save table state, in case the inner text also contains a table.
@@ -1930,14 +2101,15 @@ void RtfAttributeOutput::writeTextFrame(const ww8::Frame& rFrame, bool bTextBox)
const SwFrameFormat& rFrameFormat = rFrame.GetFrameFormat();
const SwNodeIndex* pNodeIndex = rFrameFormat.GetContent().GetContentIdx();
- sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex() + 1 : 0;
- sal_uLong nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0;
+ SwNodeOffset nStt = pNodeIndex ? pNodeIndex->GetIndex() + 1 : SwNodeOffset(0);
+ SwNodeOffset nEnd
+ = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : SwNodeOffset(0);
m_rExport.SaveData(nStt, nEnd);
m_rExport.m_pParentFrame = &rFrame;
m_rExport.WriteText();
m_rExport.RestoreData();
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PARD);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_PARD);
m_rExport.SetRTFFlySyntax(false);
m_aRun->append(aSave);
m_aRunText.clear();
@@ -1945,7 +2117,7 @@ void RtfAttributeOutput::writeTextFrame(const ww8::Frame& rFrame, bool bTextBox)
m_bSingleEmptyRun = bSingleEmptyRunOrig;
// Restore table state.
- m_rExport.m_pTableInfo = pTableInfoOrig;
+ m_rExport.m_pTableInfo = std::move(pTableInfoOrig);
m_pTableWrt = std::move(pTableWrt);
m_nTableDepth = nTableDepth;
}
@@ -1999,6 +2171,22 @@ public:
void RtfAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Point& /*rNdTopLeft*/)
{
+ const SwFrameFormat& rFrameFormat = rFrame.GetFrameFormat();
+ if (rFrameFormat.GetFlySplit().GetValue())
+ {
+ // The frame can split: this was originally from a floating table, write it back as
+ // such.
+ SaveRunState aState(*this);
+ const SwNodeIndex* pNodeIndex = rFrameFormat.GetContent().GetContentIdx();
+ SwNodeOffset nStt = pNodeIndex ? pNodeIndex->GetIndex() + 1 : SwNodeOffset(0);
+ SwNodeOffset nEnd
+ = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : SwNodeOffset(0);
+ m_rExport.SaveData(nStt, nEnd);
+ GetExport().WriteText();
+ m_rExport.RestoreData();
+ return;
+ }
+
const SwNode* pNode = rFrame.GetContent();
const SwGrfNode* pGrfNode = pNode ? pNode->GetGrfNode() : nullptr;
@@ -2014,13 +2202,13 @@ void RtfAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Poi
m_rExport.m_pParentFrame = &rFrame;
- m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SHP);
- m_rExport.Strm().WriteCharPtr(
+ m_rExport.Strm().WriteOString("{" OOO_STRING_SVTOOLS_RTF_SHP);
+ m_rExport.Strm().WriteOString(
"{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPINST);
// Shape properties.
m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "shapeType", OString::number(ESCHER_ShpInst_TextBox)));
+ "shapeType"_ostr, OString::number(ESCHER_ShpInst_TextBox)));
// When a frame has some low height, but automatically expanded due
// to lots of contents, this size contains the real size.
@@ -2034,28 +2222,28 @@ void RtfAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Poi
// Write ZOrder.
if (const SdrObject* pObject = rFrame.GetFrameFormat().FindRealSdrObject())
{
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPZ);
- m_rExport.OutULong(pObject->GetOrdNum());
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_SHPZ);
+ m_rExport.Strm().WriteNumberAsString(pObject->GetOrdNum());
}
m_rExport.Strm().WriteOString(m_aRunText.makeStringAndClear());
- m_rExport.Strm().WriteOString(m_aStyles.makeStringAndClear());
+ m_rExport.Strm().WriteOString(m_aStyles);
+ m_aStyles.setLength(0);
m_rExport.m_bOutFlyFrameAttrs = false;
m_rExport.SetRTFFlySyntax(false);
m_pFlyFrameSize = nullptr;
- const SwFrameFormat& rFrameFormat = rFrame.GetFrameFormat();
lcl_TextFrameShadow(m_aFlyProperties, rFrameFormat);
lcl_TextFrameRelativeSize(m_aFlyProperties, rFrameFormat);
for (const std::pair<OString, OString>& rPair : m_aFlyProperties)
{
- m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SP "{");
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SN " ");
+ m_rExport.Strm().WriteOString("{" OOO_STRING_SVTOOLS_RTF_SP "{");
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_SN " ");
m_rExport.Strm().WriteOString(rPair.first);
- m_rExport.Strm().WriteCharPtr("}{" OOO_STRING_SVTOOLS_RTF_SV " ");
+ m_rExport.Strm().WriteOString("}{" OOO_STRING_SVTOOLS_RTF_SV " ");
m_rExport.Strm().WriteOString(rPair.second);
- m_rExport.Strm().WriteCharPtr("}}");
+ m_rExport.Strm().WriteOString("}}");
}
m_aFlyProperties.clear();
@@ -2064,7 +2252,7 @@ void RtfAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Poi
m_rExport.Strm().WriteChar('}'); // shpinst
m_rExport.Strm().WriteChar('}'); // shp
- m_rExport.Strm().WriteCharPtr(SAL_NEWLINE_STRING);
+ m_rExport.Strm().WriteOString(SAL_NEWLINE_STRING);
}
break;
case ww8::Frame::eGraphic:
@@ -2106,7 +2294,6 @@ void RtfAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Poi
break;
case ww8::Frame::eFormControl:
{
- const SwFrameFormat& rFrameFormat = rFrame.GetFrameFormat();
const SdrObject* pObject = rFrameFormat.FindRealSdrObject();
m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_FIELD);
@@ -2202,9 +2389,8 @@ void RtfAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Poi
aBuf.append(char(0x00));
xPropSet->getPropertyValue("Name") >>= aTmp;
aStr = OUStringToOString(aTmp, m_rExport.GetCurrentEncoding());
- aBuf.append(static_cast<char>(aStr.getLength()));
- aBuf.append(aStr);
- aBuf.append(char(0x00));
+ aBuf.append(OStringChar(static_cast<char>(aStr.getLength())) + aStr
+ + OStringChar(char(0x00)));
xPropSet->getPropertyValue("DefaultText") >>= aTmp;
aStr = OUStringToOString(aTmp, m_rExport.GetCurrentEncoding());
aBuf.append(static_cast<char>(aStr.getLength()));
@@ -2315,7 +2501,7 @@ void RtfAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Poi
}
xPropSet->getPropertyValue("StringItemList") >>= aStrSeq;
- for (const auto& rStr : std::as_const(aStrSeq))
+ for (const auto& rStr : aStrSeq)
m_aRun->append(
"{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFL " "
+ OUStringToOString(rStr, m_rExport.GetCurrentEncoding())
@@ -2339,7 +2525,6 @@ void RtfAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Poi
break;
case ww8::Frame::eOle:
{
- const SwFrameFormat& rFrameFormat = rFrame.GetFrameFormat();
const SdrObject* pSdrObj = rFrameFormat.FindRealSdrObject();
if (pSdrObj)
{
@@ -2559,6 +2744,8 @@ void RtfAttributeOutput::CharUnderline(const SvxUnderlineItem& rUnderline)
const char* pStr = nullptr;
const SfxPoolItem* pItem = m_rExport.HasItem(RES_CHRATR_WORDLINEMODE);
bool bWord = false;
+ // No StaticWhichCast(RES_CHRATR_WORDLINEMODE), this may be for a postit, where the which ids
+ // don't match.
if (pItem)
bWord = static_cast<const SvxWordLineModeItem*>(pItem)->GetValue();
switch (rUnderline.GetLineStyle())
@@ -2882,8 +3069,9 @@ void RtfAttributeOutput::TextFootnote_Impl(const SwFormatFootnote& rFootnote)
m_bBufferSectionHeaders = false;
m_bInRun = bInRunOrig;
m_bSingleEmptyRun = bSingleEmptyRunOrig;
- m_aRun = aRun;
- m_aRun->append(m_aSectionHeaders.makeStringAndClear());
+ m_aRun = std::move(aRun);
+ m_aRun->append(m_aSectionHeaders);
+ m_aSectionHeaders.setLength(0);
m_aRun->append("}");
m_aRun->append("}");
@@ -2940,11 +3128,7 @@ void RtfAttributeOutput::ParaWidows(const SvxWidowsItem& rWidows)
void RtfAttributeOutput::ParaTabStop(const SvxTabStopItem& rTabStop)
{
- tools::Long nOffset = 0;
- // Tabs are absolute by default.
- if (m_rExport.m_rDoc.getIDocumentSettingAccess().get(
- DocumentSettingId::TABS_RELATIVE_TO_INDENT))
- nOffset = m_rExport.GetItem(RES_LR_SPACE).GetTextLeft();
+ tools::Long nOffset = m_rExport.GetParaTabStopOffset();
for (sal_uInt16 n = 0; n < rTabStop.Count(); n++)
{
@@ -3035,9 +3219,10 @@ void RtfAttributeOutput::ParaNumRule_Impl(const SwTextNode* pTextNd, sal_Int32 n
m_aStyles.append(OOO_STRING_SVTOOLS_RTF_PLAIN);
m_aStyles.append(' ');
- SvxLRSpaceItem aLR(rNdSet.Get(RES_LR_SPACE));
- aLR.SetTextLeft(aLR.GetTextLeft() + pFormat->GetIndentAt());
- aLR.SetTextFirstLineOffset(pFormat->GetFirstLineOffset()); //TODO: overflow
+ SvxFirstLineIndentItem firstLine(rNdSet.Get(RES_MARGIN_FIRSTLINE));
+ SvxTextLeftMarginItem leftMargin(rNdSet.Get(RES_MARGIN_TEXTLEFT));
+ leftMargin.SetTextLeft(leftMargin.GetTextLeft() + pFormat->GetIndentAt());
+ firstLine.SetTextFirstLineOffset(pFormat->GetFirstLineOffset()); //TODO: overflow
sal_uInt16 nStyle = m_rExport.GetId(pFormat->GetCharFormat());
OString* pString = m_rExport.GetStyle(nStyle);
@@ -3083,7 +3268,8 @@ void RtfAttributeOutput::ParaNumRule_Impl(const SwTextNode* pTextNd, sal_Int32 n
m_aStyles.append(static_cast<sal_Int32>(m_rExport.GetNumberingId(*pRule)) + 1);
m_aStyles.append(' ');
}
- FormatLRSpace(aLR);
+ FormatFirstLineIndent(firstLine);
+ FormatTextLeftMargin(leftMargin);
}
void RtfAttributeOutput::ParaScriptSpace(const SfxBoolItem& rScriptSpace)
@@ -3143,13 +3329,49 @@ void RtfAttributeOutput::FormatFrameSize(const SwFormatFrameSize& rSize)
m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGHSXN);
m_aSectionBreaks.append(static_cast<sal_Int32>(rSize.GetHeight()));
if (!m_bBufferSectionBreaks)
- m_rExport.Strm().WriteOString(m_aSectionBreaks.makeStringAndClear());
+ {
+ m_rExport.Strm().WriteOString(m_aSectionBreaks);
+ m_aSectionBreaks.setLength(0);
+ }
}
}
-void RtfAttributeOutput::FormatPaperBin(const SvxPaperBinItem& /*rItem*/)
+void RtfAttributeOutput::FormatPaperBin(const SvxPaperBinItem& rItem)
{
- SAL_INFO("sw.rtf", "TODO: " << __func__);
+ SfxPrinter* pPrinter = m_rExport.m_rDoc.getIDocumentDeviceAccess().getPrinter(true);
+ sal_Int16 nPaperSource = pPrinter->GetSourceIndexByPaperBin(rItem.GetValue());
+ m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_BINFSXN);
+ m_aSectionBreaks.append(static_cast<sal_Int32>(nPaperSource));
+ m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_BINSXN);
+ m_aSectionBreaks.append(static_cast<sal_Int32>(nPaperSource));
+}
+
+void RtfAttributeOutput::FormatFirstLineIndent(SvxFirstLineIndentItem const& rFirstLine)
+{
+ m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FI);
+ m_aStyles.append(static_cast<sal_Int32>(rFirstLine.GetTextFirstLineOffset()));
+}
+
+void RtfAttributeOutput::FormatTextLeftMargin(SvxTextLeftMarginItem const& rTextLeftMargin)
+{
+ m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LI);
+ m_aStyles.append(static_cast<sal_Int32>(rTextLeftMargin.GetTextLeft()));
+ m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LIN);
+ m_aStyles.append(static_cast<sal_Int32>(rTextLeftMargin.GetTextLeft()));
+}
+
+void RtfAttributeOutput::FormatRightMargin(SvxRightMarginItem const& rRightMargin)
+{
+// (paragraph case, this will be an else branch once others are converted)
+#if 0
+ else
+#endif
+ {
+ m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RI);
+ m_aStyles.append(static_cast<sal_Int32>(rRightMargin.GetRight()));
+ m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RIN);
+ m_aStyles.append(static_cast<sal_Int32>(rRightMargin.GetRight()));
+ }
}
void RtfAttributeOutput::FormatLRSpace(const SvxLRSpaceItem& rLRSpace)
@@ -3158,15 +3380,29 @@ void RtfAttributeOutput::FormatLRSpace(const SvxLRSpaceItem& rLRSpace)
{
if (m_rExport.m_bOutPageDescs)
{
+ m_aPageMargins.nLeft = 0;
+ m_aPageMargins.nRight = 0;
+
+ if (const SvxBoxItem* pBoxItem = m_rExport.HasItem(RES_BOX))
+ {
+ m_aPageMargins.nLeft
+ = pBoxItem->CalcLineSpace(SvxBoxItemLine::LEFT, /*bEvenIfNoLine*/ true);
+ m_aPageMargins.nRight
+ = pBoxItem->CalcLineSpace(SvxBoxItemLine::RIGHT, /*bEvenIfNoLine*/ true);
+ }
+
+ m_aPageMargins.nLeft += sal::static_int_cast<sal_uInt16>(rLRSpace.GetLeft());
+ m_aPageMargins.nRight += sal::static_int_cast<sal_uInt16>(rLRSpace.GetRight());
+
if (rLRSpace.GetLeft())
{
m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGLSXN);
- m_aSectionBreaks.append(static_cast<sal_Int32>(rLRSpace.GetLeft()));
+ m_aSectionBreaks.append(static_cast<sal_Int32>(m_aPageMargins.nLeft));
}
if (rLRSpace.GetRight())
{
m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGRSXN);
- m_aSectionBreaks.append(static_cast<sal_Int32>(rLRSpace.GetRight()));
+ m_aSectionBreaks.append(static_cast<sal_Int32>(m_aPageMargins.nRight));
}
if (rLRSpace.GetGutterMargin())
{
@@ -3174,7 +3410,10 @@ void RtfAttributeOutput::FormatLRSpace(const SvxLRSpaceItem& rLRSpace)
m_aSectionBreaks.append(static_cast<sal_Int32>(rLRSpace.GetGutterMargin()));
}
if (!m_bBufferSectionBreaks)
- m_rExport.Strm().WriteOString(m_aSectionBreaks.makeStringAndClear());
+ {
+ m_rExport.Strm().WriteOString(m_aSectionBreaks);
+ m_aSectionBreaks.setLength(0);
+ }
}
else
{
@@ -3194,11 +3433,13 @@ void RtfAttributeOutput::FormatLRSpace(const SvxLRSpaceItem& rLRSpace)
{
// Wrap: top and bottom spacing, convert from twips to EMUs.
m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "dxWrapDistLeft", OString::number(o3tl::convert(rLRSpace.GetLeft(), o3tl::Length::twip,
- o3tl::Length::emu))));
+ "dxWrapDistLeft"_ostr,
+ OString::number(
+ o3tl::convert(rLRSpace.GetLeft(), o3tl::Length::twip, o3tl::Length::emu))));
m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "dxWrapDistRight", OString::number(o3tl::convert(
- rLRSpace.GetRight(), o3tl::Length::twip, o3tl::Length::emu))));
+ "dxWrapDistRight"_ostr,
+ OString::number(
+ o3tl::convert(rLRSpace.GetRight(), o3tl::Length::twip, o3tl::Length::emu))));
}
}
@@ -3221,29 +3462,34 @@ void RtfAttributeOutput::FormatULSpace(const SvxULSpaceItem& rULSpace)
? *m_rExport.GetFirstPageItemSet()
: *m_rExport.GetCurItemSet());
- if (aDistances.dyaTop)
+ if (aDistances.m_DyaTop)
{
m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGTSXN);
- m_aSectionBreaks.append(static_cast<sal_Int32>(aDistances.dyaTop));
+ m_aSectionBreaks.append(static_cast<sal_Int32>(aDistances.m_DyaTop));
+ m_aPageMargins.nTop = aDistances.m_DyaTop;
}
if (aDistances.HasHeader())
{
m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_HEADERY);
- m_aSectionBreaks.append(static_cast<sal_Int32>(aDistances.dyaHdrTop));
+ m_aSectionBreaks.append(static_cast<sal_Int32>(aDistances.m_DyaHdrTop));
}
- if (aDistances.dyaBottom)
+ if (aDistances.m_DyaBottom)
{
m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGBSXN);
- m_aSectionBreaks.append(static_cast<sal_Int32>(aDistances.dyaBottom));
+ m_aSectionBreaks.append(static_cast<sal_Int32>(aDistances.m_DyaBottom));
+ m_aPageMargins.nBottom = aDistances.m_DyaBottom;
}
if (aDistances.HasFooter())
{
m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_FOOTERY);
- m_aSectionBreaks.append(static_cast<sal_Int32>(aDistances.dyaHdrBottom));
+ m_aSectionBreaks.append(static_cast<sal_Int32>(aDistances.m_DyaHdrBottom));
}
if (!m_bBufferSectionBreaks)
- m_rExport.Strm().WriteOString(m_aSectionBreaks.makeStringAndClear());
+ {
+ m_rExport.Strm().WriteOString(m_aSectionBreaks);
+ m_aSectionBreaks.setLength(0);
+ }
}
else
{
@@ -3288,11 +3534,13 @@ void RtfAttributeOutput::FormatULSpace(const SvxULSpaceItem& rULSpace)
{
// Wrap: top and bottom spacing, convert from twips to EMUs.
m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "dyWrapDistTop", OString::number(o3tl::convert(rULSpace.GetUpper(), o3tl::Length::twip,
- o3tl::Length::emu))));
+ "dyWrapDistTop"_ostr,
+ OString::number(
+ o3tl::convert(rULSpace.GetUpper(), o3tl::Length::twip, o3tl::Length::emu))));
m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "dyWrapDistBottom", OString::number(o3tl::convert(
- rULSpace.GetLower(), o3tl::Length::twip, o3tl::Length::emu))));
+ "dyWrapDistBottom"_ostr,
+ OString::number(
+ o3tl::convert(rULSpace.GetLower(), o3tl::Length::twip, o3tl::Length::emu))));
}
}
@@ -3335,12 +3583,12 @@ void RtfAttributeOutput::FormatSurround(const SwFormatSurround& rSurround)
if (rSurround.IsContour())
nWr = 4; // tight
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPWR);
- m_rExport.OutLong(nWr);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_SHPWR);
+ m_rExport.Strm().WriteNumberAsString(nWr);
if (oWrk)
{
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPWRK);
- m_rExport.OutLong(*oWrk);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_SHPWRK);
+ m_rExport.Strm().WriteNumberAsString(*oWrk);
}
}
}
@@ -3354,14 +3602,14 @@ void RtfAttributeOutput::FormatVertOrientation(const SwFormatVertOrient& rFlyVer
{
case text::RelOrientation::PAGE_FRAME:
m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posrelv", OString::number(1)));
+ std::make_pair<OString, OString>("posrelv"_ostr, OString::number(1)));
break;
default:
m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posrelv", OString::number(2)));
+ std::make_pair<OString, OString>("posrelv"_ostr, OString::number(2)));
m_rExport.Strm()
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPBYPARA)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPBYIGNORE);
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_SHPBYPARA)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_SHPBYIGNORE);
break;
}
@@ -3370,28 +3618,28 @@ void RtfAttributeOutput::FormatVertOrientation(const SwFormatVertOrient& rFlyVer
case text::VertOrientation::TOP:
case text::VertOrientation::LINE_TOP:
m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posv", OString::number(1)));
+ std::make_pair<OString, OString>("posv"_ostr, OString::number(1)));
break;
case text::VertOrientation::BOTTOM:
case text::VertOrientation::LINE_BOTTOM:
m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posv", OString::number(3)));
+ std::make_pair<OString, OString>("posv"_ostr, OString::number(3)));
break;
case text::VertOrientation::CENTER:
case text::VertOrientation::LINE_CENTER:
m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posv", OString::number(2)));
+ std::make_pair<OString, OString>("posv"_ostr, OString::number(2)));
break;
default:
break;
}
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPTOP);
- m_rExport.OutLong(rFlyVert.GetPos());
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_SHPTOP);
+ m_rExport.Strm().WriteNumberAsString(rFlyVert.GetPos());
if (m_pFlyFrameSize)
{
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPBOTTOM);
- m_rExport.OutLong(rFlyVert.GetPos() + m_pFlyFrameSize->Height());
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_SHPBOTTOM);
+ m_rExport.Strm().WriteNumberAsString(rFlyVert.GetPos() + m_pFlyFrameSize->Height());
}
}
@@ -3404,14 +3652,14 @@ void RtfAttributeOutput::FormatHorizOrientation(const SwFormatHoriOrient& rFlyHo
{
case text::RelOrientation::PAGE_FRAME:
m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posrelh", OString::number(1)));
+ std::make_pair<OString, OString>("posrelh"_ostr, OString::number(1)));
break;
default:
m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posrelh", OString::number(2)));
+ std::make_pair<OString, OString>("posrelh"_ostr, OString::number(2)));
m_rExport.Strm()
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPBXCOLUMN)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPBXIGNORE);
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_SHPBXCOLUMN)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_SHPBXIGNORE);
break;
}
@@ -3419,26 +3667,26 @@ void RtfAttributeOutput::FormatHorizOrientation(const SwFormatHoriOrient& rFlyHo
{
case text::HoriOrientation::LEFT:
m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posh", OString::number(1)));
+ std::make_pair<OString, OString>("posh"_ostr, OString::number(1)));
break;
case text::HoriOrientation::CENTER:
m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posh", OString::number(2)));
+ std::make_pair<OString, OString>("posh"_ostr, OString::number(2)));
break;
case text::HoriOrientation::RIGHT:
m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posh", OString::number(3)));
+ std::make_pair<OString, OString>("posh"_ostr, OString::number(3)));
break;
default:
break;
}
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPLEFT);
- m_rExport.OutLong(rFlyHori.GetPos());
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_SHPLEFT);
+ m_rExport.Strm().WriteNumberAsString(rFlyHori.GetPos());
if (m_pFlyFrameSize)
{
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPRIGHT);
- m_rExport.OutLong(rFlyHori.GetPos() + m_pFlyFrameSize->Width());
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_SHPRIGHT);
+ m_rExport.Strm().WriteNumberAsString(rFlyHori.GetPos() + m_pFlyFrameSize->Width());
}
}
@@ -3472,7 +3720,7 @@ void RtfAttributeOutput::FormatBackground(const SvxBrushItem& rBrush)
const Color& rColor = rBrush.GetColor();
// We in fact need RGB to BGR, but the transformation is symmetric.
m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "fillColor", OString::number(wwUtility::RGBToBGR(rColor))));
+ "fillColor"_ostr, OString::number(wwUtility::RGBToBGR(rColor))));
}
else if (!rBrush.GetColor().IsTransparent())
{
@@ -3492,31 +3740,54 @@ void RtfAttributeOutput::FormatFillGradient(const XFillGradientItem& rFillGradie
return;
m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "fillType", OString::number(7))); // Shade using the fillAngle
+ "fillType"_ostr, OString::number(7))); // Shade using the fillAngle
+
+ const basegfx::BGradient& rGradient(rFillGradient.GetGradientValue());
+ const basegfx::BColorStops& rColorStops(rGradient.GetColorStops());
+
+ // MCGR: It would be best to export the full MCGR definition here
+ // with all ColorStops in rColorStops, but rtf does not support this.
+ // Best thing to do and to stay compatible is to export front/back
+ // colors as start/end and - when more than two ColorStops are defined -
+ // guess that GradientStyle_AXIAL is used and thus create a "fillFocus"
+ // entry
+
+ // LO does linear gradients top to bottom, while MSO does bottom to top.
+ // LO does axial gradients inner to outer, while MSO does outer to inner.
+ // Conclusion: swap start and end colors (and stop emulating this with 180deg rotations).
+ const Color aMSOStartColor(rColorStops.back().getStopColor());
+ Color aMSOEndColor(rColorStops.front().getStopColor());
+
+ const sal_Int32 nAngle = toDegrees(rGradient.GetAngle()) * oox::drawingml::PER_DEGREE;
+ if (nAngle != 0)
+ {
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("fillAngle"_ostr, OString::number(nAngle)));
+ }
- const XGradient& rGradient = rFillGradient.GetGradientValue();
- const Color& rStartColor = rGradient.GetStartColor();
- m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "fillBackColor", OString::number(wwUtility::RGBToBGR(rStartColor))));
+ bool bIsSymmetrical = true;
+ if (rColorStops.size() < 3)
+ {
+ if (rGradient.GetGradientStyle() != awt::GradientStyle_AXIAL)
+ bIsSymmetrical = false;
+ }
+ else
+ {
+ // assume what was formally GradientStyle_AXIAL, see above and also refer to
+ // FillModel::pushToPropMap 'fFocus' value and usage.
+ // The 2nd color is the in-between color, use it
+ aMSOEndColor = Color(rColorStops[1].getStopColor());
+ }
- const Color& rEndColor = rGradient.GetEndColor();
m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "fillColor", OString::number(wwUtility::RGBToBGR(rEndColor))));
+ "fillColor"_ostr, OString::number(wwUtility::RGBToBGR(aMSOStartColor))));
+ m_aFlyProperties.push_back(std::make_pair<OString, OString>(
+ "fillBackColor"_ostr, OString::number(wwUtility::RGBToBGR(aMSOEndColor))));
- switch (rGradient.GetGradientStyle())
+ if (bIsSymmetrical)
{
- case css::awt::GradientStyle_LINEAR:
- break;
- case css::awt::GradientStyle_AXIAL:
- m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("fillFocus", OString::number(50)));
- break;
- case css::awt::GradientStyle_RADIAL:
- case css::awt::GradientStyle_ELLIPTICAL:
- case css::awt::GradientStyle_SQUARE:
- case css::awt::GradientStyle_RECT:
- default:
- break;
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("fillFocus"_ostr, OString::number(50)));
}
}
@@ -3534,43 +3805,65 @@ void RtfAttributeOutput::FormatBox(const SvxBoxItem& rBox)
{
// Borders: spacing to contents, convert from twips to EMUs.
m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "dxTextLeft", OString::number(o3tl::convert(rBox.GetDistance(SvxBoxItemLine::LEFT),
- o3tl::Length::twip, o3tl::Length::emu))));
+ "dxTextLeft"_ostr,
+ OString::number(o3tl::convert(rBox.GetDistance(SvxBoxItemLine::LEFT),
+ o3tl::Length::twip, o3tl::Length::emu))));
m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "dyTextTop", OString::number(o3tl::convert(rBox.GetDistance(SvxBoxItemLine::TOP),
- o3tl::Length::twip, o3tl::Length::emu))));
+ "dyTextTop"_ostr,
+ OString::number(o3tl::convert(rBox.GetDistance(SvxBoxItemLine::TOP), o3tl::Length::twip,
+ o3tl::Length::emu))));
m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "dxTextRight", OString::number(o3tl::convert(rBox.GetDistance(SvxBoxItemLine::RIGHT),
- o3tl::Length::twip, o3tl::Length::emu))));
+ "dxTextRight"_ostr,
+ OString::number(o3tl::convert(rBox.GetDistance(SvxBoxItemLine::RIGHT),
+ o3tl::Length::twip, o3tl::Length::emu))));
m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "dyTextBottom", OString::number(o3tl::convert(rBox.GetDistance(SvxBoxItemLine::BOTTOM),
- o3tl::Length::twip, o3tl::Length::emu))));
+ "dyTextBottom"_ostr,
+ OString::number(o3tl::convert(rBox.GetDistance(SvxBoxItemLine::BOTTOM),
+ o3tl::Length::twip, o3tl::Length::emu))));
const editeng::SvxBorderLine* pLeft = rBox.GetLine(SvxBoxItemLine::LEFT);
const editeng::SvxBorderLine* pRight = rBox.GetLine(SvxBoxItemLine::RIGHT);
const editeng::SvxBorderLine* pTop = rBox.GetLine(SvxBoxItemLine::TOP);
const editeng::SvxBorderLine* pBottom = rBox.GetLine(SvxBoxItemLine::BOTTOM);
- if (pLeft && pRight && pTop && pBottom && *pLeft == *pRight && *pLeft == *pTop
- && *pLeft == *pBottom)
+
+ if (!pLeft && !pRight && !pBottom && !pTop)
{
- const Color& rColor = pTop->GetColor();
- // We in fact need RGB to BGR, but the transformation is symmetric.
- m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "lineColor", OString::number(wwUtility::RGBToBGR(rColor))));
+ // fLine has default 'true', so need to write it out in case of no border.
+ m_aFlyProperties.push_back(std::make_pair<OString, OString>("fLine"_ostr, "0"_ostr));
+ return;
+ }
- if (pTop->GetBorderLineStyle() != SvxBorderLineStyle::NONE)
- {
- double const fConverted(editeng::ConvertBorderWidthToWord(
- pTop->GetBorderLineStyle(), pTop->GetWidth()));
- sal_Int32 nWidth = o3tl::convert(fConverted, o3tl::Length::twip, o3tl::Length::emu);
- m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("lineWidth", OString::number(nWidth)));
- }
- else
- // No border: no line.
- m_aFlyProperties.push_back(std::make_pair<OString, OString>("fLine", "0"));
+ // RTF has the flags fTopLine, fBottomLine, fLeftLine and fRightLine to disable single border
+ // lines. But Word cannot disable single border lines. So we do not use them. In case of
+ // single border lines it is better to draw all four borders than drawing none. So we look
+ // whether a border line exists, which is effectively drawn.
+ const editeng::SvxBorderLine* pBorder = nullptr;
+ if (pTop && pTop->GetBorderLineStyle() != SvxBorderLineStyle::NONE)
+ pBorder = pTop;
+ else if (pBottom && pBottom->GetBorderLineStyle() != SvxBorderLineStyle::NONE)
+ pBorder = pBottom;
+ else if (pLeft && pLeft->GetBorderLineStyle() != SvxBorderLineStyle::NONE)
+ pBorder = pLeft;
+ else if (pRight && pRight->GetBorderLineStyle() != SvxBorderLineStyle::NONE)
+ pBorder = pRight;
+
+ if (!pBorder)
+ {
+ m_aFlyProperties.push_back(std::make_pair<OString, OString>("fLine"_ostr, "0"_ostr));
+ return;
}
+ const Color& rColor = pBorder->GetColor();
+ // We in fact need RGB to BGR, but the transformation is symmetric.
+ m_aFlyProperties.push_back(std::make_pair<OString, OString>(
+ "lineColor"_ostr, OString::number(wwUtility::RGBToBGR(rColor))));
+
+ double const fConverted(
+ editeng::ConvertBorderWidthToWord(pBorder->GetBorderLineStyle(), pBorder->GetWidth()));
+ sal_Int32 nWidth = o3tl::convert(fConverted, o3tl::Length::twip, o3tl::Length::emu);
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("lineWidth"_ostr, OString::number(nWidth)));
+
return;
}
@@ -3585,54 +3878,56 @@ void RtfAttributeOutput::FormatBox(const SvxBoxItem& rBox)
else
{
SvxShadowLocation eShadowLocation = SvxShadowLocation::NONE;
- if (const SfxPoolItem* pItem = GetExport().HasItem(RES_SHADOW))
- eShadowLocation = static_cast<const SvxShadowItem*>(pItem)->GetLocation();
+ if (const SvxShadowItem* pItem = GetExport().HasItem(RES_SHADOW))
+ eShadowLocation = pItem->GetLocation();
const SvxBoxItemLine* pBrd = aBorders;
const char** pBrdNms = aBorderNames;
for (int i = 0; i < 4; ++i, ++pBrd, ++pBrdNms)
{
- if (const editeng::SvxBorderLine* pLn = rBox.GetLine(*pBrd))
- {
- m_aSectionBreaks.append(OutBorderLine(m_rExport, pLn, *pBrdNms,
- rBox.GetDistance(*pBrd), eShadowLocation));
- }
+ editeng::SvxBorderLine const* const pLn = rBox.GetLine(*pBrd);
+ m_aSectionBreaks.append(
+ OutBorderLine(m_rExport, pLn, *pBrdNms, rBox.GetDistance(*pBrd), eShadowLocation));
}
}
if (!m_bBufferSectionBreaks)
- m_aStyles.append(m_aSectionBreaks.makeStringAndClear());
+ {
+ m_aStyles.append(m_aSectionBreaks);
+ m_aSectionBreaks.setLength(0);
+ }
}
void RtfAttributeOutput::FormatColumns_Impl(sal_uInt16 nCols, const SwFormatCol& rCol, bool bEven,
SwTwips nPageSize)
{
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_COLS);
- m_rExport.OutLong(nCols);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_COLS);
+ m_rExport.Strm().WriteNumberAsString(nCols);
if (rCol.GetLineAdj() != COLADJ_NONE)
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LINEBETCOL);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LINEBETCOL);
if (bEven)
{
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_COLSX);
- m_rExport.OutLong(rCol.GetGutterWidth(true));
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_COLSX);
+ m_rExport.Strm().WriteNumberAsString(rCol.GetGutterWidth(true));
}
else
{
const SwColumns& rColumns = rCol.GetColumns();
for (sal_uInt16 n = 0; n < nCols;)
{
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_COLNO);
- m_rExport.OutLong(n + 1);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_COLNO);
+ m_rExport.Strm().WriteNumberAsString(n + 1);
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_COLW);
- m_rExport.OutLong(rCol.CalcPrtColWidth(n, nPageSize));
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_COLW);
+ m_rExport.Strm().WriteNumberAsString(rCol.CalcPrtColWidth(n, nPageSize));
if (++n != nCols)
{
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_COLSR);
- m_rExport.OutLong(rColumns[n - 1].GetRight() + rColumns[n].GetLeft());
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_COLSR);
+ m_rExport.Strm().WriteNumberAsString(rColumns[n - 1].GetRight()
+ + rColumns[n].GetLeft());
}
}
}
@@ -3668,7 +3963,10 @@ void RtfAttributeOutput::FormatFrameDirection(const SvxFrameDirectionItem& rDire
m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_STEXTFLOW);
m_aSectionBreaks.append(static_cast<sal_Int32>(1));
if (!m_bBufferSectionBreaks)
- m_rExport.Strm().WriteOString(m_aSectionBreaks.makeStringAndClear());
+ {
+ m_rExport.Strm().WriteOString(m_aSectionBreaks);
+ m_aSectionBreaks.setLength(0);
+ }
}
return;
}
@@ -3678,12 +3976,14 @@ void RtfAttributeOutput::FormatFrameDirection(const SvxFrameDirectionItem& rDire
if (nDir == SvxFrameDirection::Vertical_RL_TB)
{
// Top to bottom non-ASCII font
- m_aFlyProperties.push_back(std::make_pair<OString, OString>("txflTextFlow", "3"));
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("txflTextFlow"_ostr, "3"_ostr));
}
else if (rDirection.GetValue() == SvxFrameDirection::Vertical_LR_BT)
{
// Bottom to top non-ASCII font
- m_aFlyProperties.push_back(std::make_pair<OString, OString>("txflTextFlow", "2"));
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("txflTextFlow"_ostr, "2"_ostr));
}
return;
}
@@ -3703,13 +4003,13 @@ void RtfAttributeOutput::ParaGrabBag(const SfxGrabBagItem& rItem)
{
m_bParaBeforeAutoSpacing = true;
rValue.second >>= m_nParaBeforeSpacing;
- m_nParaBeforeSpacing = convertMm100ToTwip(m_nParaBeforeSpacing);
+ m_nParaBeforeSpacing = o3tl::toTwips(m_nParaBeforeSpacing, o3tl::Length::mm100);
}
else if (rValue.first == "ParaBottomMarginAfterAutoSpacing")
{
m_bParaAfterAutoSpacing = true;
rValue.second >>= m_nParaAfterSpacing;
- m_nParaAfterSpacing = convertMm100ToTwip(m_nParaAfterSpacing);
+ m_nParaAfterSpacing = o3tl::toTwips(m_nParaAfterSpacing, o3tl::Length::mm100);
}
}
}
@@ -3843,42 +4143,41 @@ MSWordExportBase& RtfAttributeOutput::GetExport() { return m_rExport; }
// These are used by wwFont::WriteRtf()
/// Start the font.
-void RtfAttributeOutput::StartFont(const OUString& rFamilyName) const
+void RtfAttributeOutput::StartFont(std::u16string_view rFamilyName) const
{
// write the font name hex-encoded, but without Unicode - Word at least
// cannot read *both* Unicode and fallback as written by OutString
- m_rExport.Strm().WriteCharPtr(
- msfilter::rtfutil::OutString(rFamilyName, m_rExport.GetCurrentEncoding(), false).getStr());
+ m_rExport.Strm().WriteOString(
+ msfilter::rtfutil::OutString(rFamilyName, m_rExport.GetCurrentEncoding(), false));
}
/// End the font.
void RtfAttributeOutput::EndFont() const
{
- m_rExport.Strm().WriteCharPtr(";}");
+ m_rExport.Strm().WriteOString(";}");
m_rExport.SetCurrentEncoding(m_rExport.GetDefaultEncoding());
}
/// Alternate name for the font.
-void RtfAttributeOutput::FontAlternateName(const OUString& rName) const
+void RtfAttributeOutput::FontAlternateName(std::u16string_view rName) const
{
m_rExport.Strm()
.WriteChar('{')
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_IGNORE)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_FALT)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_IGNORE)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_FALT)
.WriteChar(' ');
// write the font name hex-encoded, but without Unicode - Word at least
// cannot read *both* Unicode and fallback as written by OutString
m_rExport.Strm()
- .WriteCharPtr(
- msfilter::rtfutil::OutString(rName, m_rExport.GetCurrentEncoding(), false).getStr())
+ .WriteOString(msfilter::rtfutil::OutString(rName, m_rExport.GetCurrentEncoding(), false))
.WriteChar('}');
}
/// Font charset.
void RtfAttributeOutput::FontCharset(sal_uInt8 nCharSet) const
{
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_FCHARSET);
- m_rExport.OutULong(nCharSet);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_FCHARSET);
+ m_rExport.Strm().WriteNumberAsString(nCharSet);
m_rExport.Strm().WriteChar(' ');
m_rExport.SetCurrentEncoding(rtl_getTextEncodingFromWindowsCharset(nCharSet));
}
@@ -3886,7 +4185,7 @@ void RtfAttributeOutput::FontCharset(sal_uInt8 nCharSet) const
/// Font family.
void RtfAttributeOutput::FontFamilyType(FontFamily eFamily, const wwFont& rFont) const
{
- m_rExport.Strm().WriteChar('{').WriteCharPtr(OOO_STRING_SVTOOLS_RTF_F);
+ m_rExport.Strm().WriteChar('{').WriteOString(OOO_STRING_SVTOOLS_RTF_F);
const char* pStr = OOO_STRING_SVTOOLS_RTF_FNIL;
switch (eFamily)
@@ -3909,13 +4208,13 @@ void RtfAttributeOutput::FontFamilyType(FontFamily eFamily, const wwFont& rFont)
default:
break;
}
- m_rExport.OutULong(m_rExport.m_aFontHelper.GetId(rFont)).WriteCharPtr(pStr);
+ m_rExport.Strm().WriteNumberAsString(m_rExport.m_aFontHelper.GetId(rFont)).WriteOString(pStr);
}
/// Font pitch.
void RtfAttributeOutput::FontPitchType(FontPitch ePitch) const
{
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_FPRQ);
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_FPRQ);
sal_uInt16 nVal = 0;
switch (ePitch)
@@ -3929,10 +4228,10 @@ void RtfAttributeOutput::FontPitchType(FontPitch ePitch) const
default:
break;
}
- m_rExport.OutULong(nVal);
+ m_rExport.Strm().WriteNumberAsString(nVal);
}
-static void lcl_AppendSP(OStringBuffer& rBuffer, const char cName[], const OUString& rValue,
+static void lcl_AppendSP(OStringBuffer& rBuffer, std::string_view cName, std::u16string_view rValue,
const RtfExport& rExport)
{
rBuffer.append("{" OOO_STRING_SVTOOLS_RTF_SP "{"); // "{\sp{"
@@ -3973,7 +4272,7 @@ static OString ExportPICT(const SwFlyFrameFormat* pFlyFrameFormat, const Size& r
MirrorGraph eMirror = pAttrSet->Get(RES_GRFATR_MIRRORGRF).GetValue();
if (eMirror == MirrorGraph::Vertical || eMirror == MirrorGraph::Both)
// Mirror on the vertical axis is a horizontal flip.
- lcl_AppendSP(aRet, "fFlipH", "1", rExport);
+ lcl_AppendSP(aRet, "fFlipH", u"1", rExport);
}
aRet.append("}"); //"}"
@@ -3990,31 +4289,27 @@ static OString ExportPICT(const SwFlyFrameFormat* pFlyFrameFormat, const Size& r
//Given the original size and taking cropping into account
//first, how much has the original been scaled to get the
//final rendered size
- aRet.append(OOO_STRING_SVTOOLS_RTF_PICSCALEX);
- aRet.append(static_cast<sal_Int32>((100 * rRendered.Width()) / nXCroppedSize));
- aRet.append(OOO_STRING_SVTOOLS_RTF_PICSCALEY);
- aRet.append(static_cast<sal_Int32>((100 * rRendered.Height()) / nYCroppedSize));
-
- aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPL);
- aRet.append(rCr.GetLeft());
- aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPR);
- aRet.append(rCr.GetRight());
- aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPT);
- aRet.append(rCr.GetTop());
- aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPB);
- aRet.append(rCr.GetBottom());
-
- aRet.append(OOO_STRING_SVTOOLS_RTF_PICW);
- aRet.append(static_cast<sal_Int32>(rMapped.Width()));
- aRet.append(OOO_STRING_SVTOOLS_RTF_PICH);
- aRet.append(static_cast<sal_Int32>(rMapped.Height()));
-
- aRet.append(OOO_STRING_SVTOOLS_RTF_PICWGOAL);
- aRet.append(static_cast<sal_Int32>(rOrig.Width()));
- aRet.append(OOO_STRING_SVTOOLS_RTF_PICHGOAL);
- aRet.append(static_cast<sal_Int32>(rOrig.Height()));
-
- aRet.append(pBLIPType);
+ aRet.append(
+ OOO_STRING_SVTOOLS_RTF_PICSCALEX
+ + OString::number(static_cast<sal_Int32>((100 * rRendered.Width()) / nXCroppedSize))
+ + OOO_STRING_SVTOOLS_RTF_PICSCALEY
+ + OString::number(static_cast<sal_Int32>((100 * rRendered.Height()) / nYCroppedSize))
+
+ + OOO_STRING_SVTOOLS_RTF_PICCROPL + OString::number(rCr.GetLeft())
+ + OOO_STRING_SVTOOLS_RTF_PICCROPR + OString::number(rCr.GetRight())
+ + OOO_STRING_SVTOOLS_RTF_PICCROPT + OString::number(rCr.GetTop())
+ + OOO_STRING_SVTOOLS_RTF_PICCROPB + OString::number(rCr.GetBottom())
+
+ + OOO_STRING_SVTOOLS_RTF_PICW + OString::number(static_cast<sal_Int32>(rMapped.Width()))
+ + OOO_STRING_SVTOOLS_RTF_PICH
+ + OString::number(static_cast<sal_Int32>(rMapped.Height()))
+
+ + OOO_STRING_SVTOOLS_RTF_PICWGOAL
+ + OString::number(static_cast<sal_Int32>(rOrig.Width()))
+ + OOO_STRING_SVTOOLS_RTF_PICHGOAL
+ + OString::number(static_cast<sal_Int32>(rOrig.Height()))
+
+ + pBLIPType);
if (bIsWMF)
{
aRet.append(sal_Int32(8));
@@ -4022,14 +4317,20 @@ static OString ExportPICT(const SwFlyFrameFormat* pFlyFrameFormat, const Size& r
}
aRet.append(SAL_NEWLINE_STRING);
if (pStream)
- pStream->WriteOString(aRet.makeStringAndClear());
+ {
+ pStream->WriteOString(aRet);
+ aRet.setLength(0);
+ }
if (pStream)
msfilter::rtfutil::WriteHex(pGraphicAry, nSize, pStream);
else
aRet.append(msfilter::rtfutil::WriteHex(pGraphicAry, nSize));
aRet.append('}');
if (pStream)
- pStream->WriteOString(aRet.makeStringAndClear());
+ {
+ pStream->WriteOString(aRet);
+ aRet.setLength(0);
+ }
}
return aRet.makeStringAndClear();
}
@@ -4044,13 +4345,13 @@ void RtfAttributeOutput::FlyFrameOLEReplacement(const SwFlyFrameFormat* pFlyFram
aRendered.setHeight(rSize.Height());
const Graphic* pGraphic = rOLENode.GetGraphic();
Size aMapped(pGraphic->GetPrefSize());
- auto& rCr = static_cast<const SwCropGrf&>(rOLENode.GetAttr(RES_GRFATR_CROPGRF));
+ auto& rCr = rOLENode.GetAttr(RES_GRFATR_CROPGRF);
const char* pBLIPType = OOO_STRING_SVTOOLS_RTF_PNGBLIP;
const sal_uInt8* pGraphicAry = nullptr;
SvMemoryStream aStream;
if (GraphicConverter::Export(aStream, *pGraphic, ConvertDataFormat::PNG) != ERRCODE_NONE)
SAL_WARN("sw.rtf", "failed to export the graphic");
- sal_uInt32 nSize = aStream.TellEnd();
+ sal_uInt64 nSize = aStream.TellEnd();
pGraphicAry = static_cast<sal_uInt8 const*>(aStream.GetData());
m_aRunText->append(ExportPICT(pFlyFrameFormat, aSize, aRendered, aMapped, rCr, pBLIPType,
pGraphicAry, nSize, m_rExport));
@@ -4082,16 +4383,15 @@ bool RtfAttributeOutput::FlyFrameOLEMath(const SwFlyFrameFormat* pFlyFrameFormat
uno::Reference<util::XCloseable> xClosable = xObj->getComponent();
if (!xClosable.is())
return false;
- // gcc4.4 (and 4.3 and possibly older) have a problem with dynamic_cast directly to the target class,
- // so help it with an intermediate cast. I'm not sure what exactly the problem is, seems to be unrelated
- // to RTLD_GLOBAL, so most probably a gcc bug.
- auto pBase
- = dynamic_cast<oox::FormulaExportBase*>(dynamic_cast<SfxBaseModel*>(xClosable.get()));
- assert(pBase != nullptr);
- OStringBuffer aBuf;
+ auto pBase = dynamic_cast<oox::FormulaImExportBase*>(xClosable.get());
+ SAL_WARN_IF(!pBase, "sw.rtf", "Math OLE object cannot write out RTF");
if (pBase)
+ {
+ OStringBuffer aBuf;
pBase->writeFormulaRtf(aBuf, m_rExport.GetCurrentEncoding());
- m_aRunText->append(aBuf);
+ m_aRunText->append(aBuf);
+ }
+
// Replacement graphic.
m_aRunText->append("{" LO_STRING_SVTOOLS_RTF_MMATHPICT " ");
FlyFrameOLEReplacement(pFlyFrameFormat, rOLENode, rSize);
@@ -4187,7 +4487,7 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat
Size aMapped(eGraphicType == GraphicType::Bitmap ? rGraphic.GetSizePixel()
: rGraphic.GetPrefSize());
- auto& rCr = static_cast<const SwCropGrf&>(pGrfNode->GetAttr(RES_GRFATR_CROPGRF));
+ auto& rCr = pGrfNode->GetAttr(RES_GRFATR_CROPGRF);
//Get original size in twips
Size aSize(pGrfNode->GetTwipSize());
@@ -4207,23 +4507,10 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat
}
}
- /*
- If the graphic is not of type WMF then we will have to store two
- graphics, one in the native format wrapped in shppict, and the other in
- the wmf format wrapped in nonshppict, so as to keep wordpad happy. If its
- a wmf already then we don't need any such wrapping
- */
- bool bIsWMF = pBLIPType && std::strcmp(pBLIPType, OOO_STRING_SVTOOLS_RTF_WMETAFILE) == 0;
const SwAttrSet* pAttrSet = pGrfNode->GetpSwAttrSet();
- if (!pFrame || pFrame->IsInline())
+ if (pFrame && !pFrame->IsInline())
{
- if (!bIsWMF)
- m_rExport.Strm().WriteCharPtr(
- "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
- }
- else
- {
- m_rExport.Strm().WriteCharPtr(
+ m_rExport.Strm().WriteOString(
"{" OOO_STRING_SVTOOLS_RTF_SHP
"{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPINST);
m_pFlyFrameSize = &aRendered;
@@ -4235,16 +4522,14 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat
m_rExport.SetRTFFlySyntax(false);
m_rExport.m_pParentFrame = nullptr;
m_pFlyFrameSize = nullptr;
+ std::vector<std::pair<OString, OString>> aFlyProperties{
+ { "shapeType", OString::number(ESCHER_ShpInst_PictureFrame) },
- std::vector<std::pair<OString, OString>> aFlyProperties;
- aFlyProperties.push_back(std::make_pair<OString, OString>(
- "shapeType", OString::number(ESCHER_ShpInst_PictureFrame)));
- aFlyProperties.push_back(std::make_pair<OString, OString>(
- "wzDescription", msfilter::rtfutil::OutString(pFlyFrameFormat->GetObjDescription(),
- m_rExport.GetCurrentEncoding())));
- aFlyProperties.push_back(std::make_pair<OString, OString>(
- "wzName", msfilter::rtfutil::OutString(pFlyFrameFormat->GetObjTitle(),
- m_rExport.GetCurrentEncoding())));
+ { "wzDescription", msfilter::rtfutil::OutString(pFlyFrameFormat->GetObjDescription(),
+ m_rExport.GetCurrentEncoding()) },
+ { "wzName", msfilter::rtfutil::OutString(pFlyFrameFormat->GetObjTitle(),
+ m_rExport.GetCurrentEncoding()) }
+ };
// If we have a wrap polygon, then handle that here.
if (pFlyFrameFormat->GetSurround().IsContour())
@@ -4262,15 +4547,16 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat
aVerticies.append(";(" + OString::number(aPoly[i].X()) + ","
+ OString::number(aPoly[i].Y()) + ")");
aFlyProperties.push_back(std::make_pair<OString, OString>(
- "pWrapPolygonVertices",
- "8;" + OString::number(aPoly.GetSize()) + aVerticies.makeStringAndClear()));
+ "pWrapPolygonVertices"_ostr,
+ "8;" + OString::number(aPoly.GetSize()) + aVerticies));
}
}
}
// Below text, behind document, opaque: they all refer to the same thing.
if (!pFlyFrameFormat->GetOpaque().GetValue())
- aFlyProperties.push_back(std::make_pair<OString, OString>("fBehindDocument", "1"));
+ aFlyProperties.push_back(
+ std::make_pair<OString, OString>("fBehindDocument"_ostr, "1"_ostr));
if (pAttrSet)
{
@@ -4287,14 +4573,14 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat
for (const std::pair<OString, OString>& rPair : aFlyProperties)
{
- m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SP "{");
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SN " ");
+ m_rExport.Strm().WriteOString("{" OOO_STRING_SVTOOLS_RTF_SP "{");
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_SN " ");
m_rExport.Strm().WriteOString(rPair.first);
- m_rExport.Strm().WriteCharPtr("}{" OOO_STRING_SVTOOLS_RTF_SV " ");
+ m_rExport.Strm().WriteOString("}{" OOO_STRING_SVTOOLS_RTF_SV " ");
m_rExport.Strm().WriteOString(rPair.second);
- m_rExport.Strm().WriteCharPtr("}}");
+ m_rExport.Strm().WriteOString("}}");
}
- m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SP "{" OOO_STRING_SVTOOLS_RTF_SN
+ m_rExport.Strm().WriteOString("{" OOO_STRING_SVTOOLS_RTF_SP "{" OOO_STRING_SVTOOLS_RTF_SN
" pib"
"}{" OOO_STRING_SVTOOLS_RTF_SV " ");
}
@@ -4316,51 +4602,31 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat
m_rExport, &m_rExport.Strm(), bWritePicProp, pAttrSet);
}
- if (!pFrame || pFrame->IsInline())
- {
- if (!bIsWMF)
- {
- m_rExport.Strm().WriteCharPtr("}"
- "{" OOO_STRING_SVTOOLS_RTF_NONSHPPICT);
+ if (pFrame && !pFrame->IsInline())
+ m_rExport.Strm().WriteOString("}}}}"); // Close SV, SP, SHPINST and SHP.
- aStream.Seek(0);
- if (GraphicConverter::Export(aStream, rGraphic, ConvertDataFormat::WMF) != ERRCODE_NONE)
- SAL_WARN("sw.rtf", "failed to export the graphic");
- pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
- nSize = aStream.TellEnd();
- pGraphicAry = static_cast<sal_uInt8 const*>(aStream.GetData());
-
- ExportPICT(pFlyFrameFormat, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry,
- nSize, m_rExport, &m_rExport.Strm());
-
- m_rExport.Strm().WriteChar('}');
- }
- }
- else
- m_rExport.Strm().WriteCharPtr("}}}}"); // Close SV, SP, SHPINST and SHP.
-
- m_rExport.Strm().WriteCharPtr(SAL_NEWLINE_STRING);
+ m_rExport.Strm().WriteOString(SAL_NEWLINE_STRING);
}
void RtfAttributeOutput::BulletDefinition(int /*nId*/, const Graphic& rGraphic, Size aSize)
{
- m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
- m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_PICT OOO_STRING_SVTOOLS_RTF_PNGBLIP);
+ m_rExport.Strm().WriteOString("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
+ m_rExport.Strm().WriteOString("{" OOO_STRING_SVTOOLS_RTF_PICT OOO_STRING_SVTOOLS_RTF_PNGBLIP);
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PICWGOAL);
- m_rExport.OutULong(aSize.Width());
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PICHGOAL);
- m_rExport.OutULong(aSize.Height());
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_PICWGOAL);
+ m_rExport.Strm().WriteNumberAsString(aSize.Width());
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_PICHGOAL);
+ m_rExport.Strm().WriteNumberAsString(aSize.Height());
- m_rExport.Strm().WriteCharPtr(SAL_NEWLINE_STRING);
+ m_rExport.Strm().WriteOString(SAL_NEWLINE_STRING);
const sal_uInt8* pGraphicAry = nullptr;
SvMemoryStream aStream;
if (GraphicConverter::Export(aStream, rGraphic, ConvertDataFormat::PNG) != ERRCODE_NONE)
SAL_WARN("sw.rtf", "failed to export the numbering picture bullet");
- sal_uInt32 nSize = aStream.TellEnd();
+ sal_uInt64 nSize = aStream.TellEnd();
pGraphicAry = static_cast<sal_uInt8 const*>(aStream.GetData());
msfilter::rtfutil::WriteHex(pGraphicAry, nSize, &m_rExport.Strm());
- m_rExport.Strm().WriteCharPtr("}}"); // pict, shppict
+ m_rExport.Strm().WriteOString("}}"); // pict, shppict
}
void RtfAttributeOutput::SectionRtlGutter(const SfxBoolItem& rRtlGutter)
@@ -4370,7 +4636,17 @@ void RtfAttributeOutput::SectionRtlGutter(const SfxBoolItem& rRtlGutter)
return;
}
- m_rExport.Strm().WriteCharPtr(LO_STRING_SVTOOLS_RTF_RTLGUTTER);
+ m_rExport.Strm().WriteOString(LO_STRING_SVTOOLS_RTF_RTLGUTTER);
+}
+
+void RtfAttributeOutput::TextLineBreak(const SwFormatLineBreak& rLineBreak)
+{
+ // Text wrapping break of type:
+ m_aStyles.append(LO_STRING_SVTOOLS_RTF_LBR);
+ m_aStyles.append(static_cast<sal_Int32>(rLineBreak.GetEnumValue()));
+
+ // Write the linebreak itself.
+ RunText("\x0b");
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index c3e20ddca49b..50ca3c0899b2 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -29,6 +29,7 @@
#include <wrtswtbl.hxx>
#include <rtl/strbuf.hxx>
+#include <editeng/boxitem.hxx>
#include <optional>
@@ -74,7 +75,8 @@ public:
bool bSingleEmptyRun = false) override;
/// End of the text run.
- void EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool bLastRun = false) override;
+ void EndRun(const SwTextNode* pNode, sal_Int32 nPos, sal_Int32 nLen,
+ bool bLastRun = false) override;
/// Called before we start outputting the attributes.
void StartRunProperties() override;
@@ -83,7 +85,8 @@ public:
void EndRunProperties(const SwRedlineData* pRedlineData) override;
/// Output text (inside a run).
- void RunText(const OUString& rText, rtl_TextEncoding eCharSet = RTL_TEXTENCODING_UTF8) override;
+ void RunText(const OUString& rText, rtl_TextEncoding eCharSet = RTL_TEXTENCODING_UTF8,
+ const OUString& rSymbolFont = OUString()) override;
// Access to (anyway) private buffers, used by the sdr exporter
OStringBuffer& RunText();
@@ -104,7 +107,8 @@ public:
/// Output URL end.
bool EndURL(bool isAtEndOfParagraph) override;
- void FieldVanish(const OUString& rText, ww::eField eType, OUString const*) override;
+ void FieldVanish(const OUString& rText, ww::eField eType,
+ OUString const* pBookmarkName) override;
/// Output redlining.
///
@@ -118,21 +122,32 @@ public:
/// Output style.
void ParagraphStyle(sal_uInt16 nStyle) override;
- void TableInfoCell(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) override;
- void TableInfoRow(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) override;
- void TableDefinition(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) override;
void
- TableDefaultBorders(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) override;
- void TableBackgrounds(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) override;
- void TableRowRedline(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) override;
- void TableCellRedline(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) override;
- void TableHeight(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) override;
- void TableCanSplit(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) override;
- void TableBidi(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) override;
- void TableVerticalCell(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) override;
- void TableNodeInfoInner(ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner) override;
- void TableOrientation(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) override;
- void TableSpacing(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) override;
+ TableInfoCell(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner) override;
+ void
+ TableInfoRow(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner) override;
+ void
+ TableDefinition(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner) override;
+ void TablePositioning(SwFrameFormat* pFlyFormat);
+ void TableDefaultBorders(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner) override;
+ void
+ TableBackgrounds(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner) override;
+ void
+ TableRowRedline(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner) override;
+ void
+ TableCellRedline(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner) override;
+ void TableHeight(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner) override;
+ void
+ TableCanSplit(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner) override;
+ void TableBidi(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner) override;
+ void TableVerticalCell(
+ const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner) override;
+ void TableNodeInfoInner(const ww8::WW8TableNodeInfoInner::Pointer_t& pNodeInfoInner) override;
+ void
+ TableOrientation(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner) override;
+ void
+ TableSpacing(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner) override;
void TableRowEnd(sal_uInt32 nDepth) override;
/// Start of the styles table.
@@ -146,7 +161,8 @@ public:
/// Start of a style in the styles table.
void StartStyle(const OUString& rName, StyleType eType, sal_uInt16 nBase, sal_uInt16 nNext,
- sal_uInt16 nWwId, sal_uInt16 nId, bool bAutoUpdate) override;
+ sal_uInt16 nLink, sal_uInt16 nWwId, sal_uInt16 nSlot,
+ bool bAutoUpdate) override;
/// End of a style in the styles table.
void EndStyle() override;
@@ -213,15 +229,15 @@ public:
void EndAbstractNumbering() override;
/// All the numbering level information.
- void
- NumberingLevel(sal_uInt8 nLevel, sal_uInt16 nStart, sal_uInt16 nNumberingType,
- SvxAdjust eAdjust, const sal_uInt8* pNumLvlPos, sal_uInt8 nFollow,
- const wwFont* pFont, const SfxItemSet* pOutSet, sal_Int16 nIndentAt,
- sal_Int16 nFirstLineIndex, sal_Int16 nListTabPos,
- const OUString& rNumberingString,
- const SvxBrushItem* pBrush) override; //For i120928,to export graphic of bullet
-
- void WriteField_Impl(const SwField* pField, ww::eField eType, const OUString& rFieldCmd,
+ void NumberingLevel(sal_uInt8 nLevel, sal_uInt16 nStart, sal_uInt16 nNumberingType,
+ SvxAdjust eAdjust, const sal_uInt8* pNumLvlPos, sal_uInt8 nFollow,
+ const wwFont* pFont, const SfxItemSet* pOutSet, sal_Int16 nIndentAt,
+ sal_Int16 nFirstLineIndex, sal_Int16 nListTabPos,
+ const OUString& rNumberingString,
+ const SvxBrushItem* pBrush, //For i120928,to export graphic of bullet
+ bool isLegal) override;
+
+ void WriteField_Impl(const SwField* pField, ww::eField eType, std::u16string_view rFieldCmd,
FieldFlags nMode);
void WriteBookmarks_Impl(std::vector<OUString>& rStarts, std::vector<OUString>& rEnds);
void WriteAnnotationMarks_Impl(std::vector<OUString>& rStarts, std::vector<OUString>& rEnds);
@@ -394,6 +410,13 @@ protected:
/// Sfx item RES_PAPER_BIN
void FormatPaperBin(const SvxPaperBinItem& rItem) override;
+ /// Sfx item RES_MARGIN_FIRSTLINE
+ virtual void FormatFirstLineIndent(const SvxFirstLineIndentItem& rFirstLine) override;
+ /// Sfx item RES_MARGIN_TEXTLEFT
+ virtual void FormatTextLeftMargin(const SvxTextLeftMarginItem& rTextLeftMargin) override;
+ /// Sfx item RES_MARGIN_RIGHT
+ virtual void FormatRightMargin(const SvxRightMarginItem& rRightMargin) override;
+
/// Sfx item RES_LR_SPACE
void FormatLRSpace(const SvxLRSpaceItem& rLRSpace) override;
@@ -461,6 +484,8 @@ protected:
void SectionRtlGutter(const SfxBoolItem& rRtlGutter) override;
+ void TextLineBreak(const SwFormatLineBreak& rLineBreak) override;
+
private:
/// Reference to the export, where to get the data from
RtfExport& m_rExport;
@@ -637,6 +662,8 @@ private:
/// If m_bParaBeforeAutoSpacing is set, value of \sa.
sal_Int32 m_nParaAfterSpacing;
+ editeng::WordPageMargins m_aPageMargins;
+
public:
explicit RtfAttributeOutput(RtfExport& rExport);
@@ -647,13 +674,13 @@ public:
// These are used by wwFont::WriteRtf()
/// Start the font.
- void StartFont(const OUString& rFamilyName) const;
+ void StartFont(std::u16string_view rFamilyName) const;
/// End the font.
void EndFont() const;
/// Alternate name for the font.
- void FontAlternateName(const OUString& rName) const;
+ void FontAlternateName(std::u16string_view rName) const;
/// Font charset.
void FontCharset(sal_uInt8 nCharSet) const;
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index c7be2d080d0a..ec2563088dfd 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -17,8 +17,12 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
#include "rtfexport.hxx"
+#include <string_view>
+
#include "rtfexportfilter.hxx"
#include "rtfsdrexport.hxx"
#include "rtfattributeoutput.hxx"
@@ -27,6 +31,7 @@
#include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/text/XTextFieldsSupplier.hpp>
#include <docsh.hxx>
#include <viewsh.hxx>
#include <viewopt.hxx>
@@ -51,12 +56,11 @@
#include <svtools/rtfkeywd.hxx>
#include <filter/msfilter/rtfutil.hxx>
#include <unotools/docinfohelper.hxx>
+#include <xmloff/odffields.hxx>
+#include <o3tl/string_view.hxx>
#include <osl/diagnose.h>
#include <rtl/tencinfo.h>
#include <sal/log.hxx>
-#if OSL_DEBUG_LEVEL > 1
-#include <iostream>
-#endif
#include <svx/xflclit.hxx>
#include <fmtmeta.hxx>
#include <IDocumentSettingAccess.hxx>
@@ -113,7 +117,8 @@ bool RtfExport::CollapseScriptsforWordOk(sal_uInt16 nScript, sal_uInt16 nWhich)
return true;
}
-void RtfExport::AppendBookmarks(const SwTextNode& rNode, sal_Int32 nCurrentPos, sal_Int32 nLen)
+void RtfExport::AppendBookmarks(const SwTextNode& rNode, sal_Int32 nCurrentPos, sal_Int32 nLen,
+ const SwRedlineData* /*pRedlineData*/)
{
std::vector<OUString> aStarts;
std::vector<OUString> aEnds;
@@ -123,8 +128,8 @@ void RtfExport::AppendBookmarks(const SwTextNode& rNode, sal_Int32 nCurrentPos,
{
for (const auto& pMark : aMarks)
{
- const sal_Int32 nStart = pMark->GetMarkStart().nContent.GetIndex();
- const sal_Int32 nEnd = pMark->GetMarkEnd().nContent.GetIndex();
+ const sal_Int32 nStart = pMark->GetMarkStart().GetContentIndex();
+ const sal_Int32 nEnd = pMark->GetMarkEnd().GetContentIndex();
if (nStart == nCurrentPos)
aStarts.push_back(pMark->GetName());
@@ -139,11 +144,8 @@ void RtfExport::AppendBookmarks(const SwTextNode& rNode, sal_Int32 nCurrentPos,
void RtfExport::AppendBookmark(const OUString& rName)
{
- std::vector<OUString> aStarts;
- std::vector<OUString> aEnds;
-
- aStarts.push_back(rName);
- aEnds.push_back(rName);
+ std::vector<OUString> aStarts{ rName };
+ std::vector<OUString> aEnds{ rName };
m_pAttrOutput->WriteBookmarks_Impl(aStarts, aEnds);
}
@@ -159,8 +161,8 @@ void RtfExport::AppendAnnotationMarks(const SwWW8AttrIter& rAttrs, sal_Int32 nCu
{
for (const auto& pMark : aMarks)
{
- const sal_Int32 nStart = pMark->GetMarkStart().nContent.GetIndex();
- const sal_Int32 nEnd = pMark->GetMarkEnd().nContent.GetIndex();
+ const sal_Int32 nStart = pMark->GetMarkStart().GetContentIndex();
+ const sal_Int32 nEnd = pMark->GetMarkEnd().GetContentIndex();
if (nStart == nCurrentPos)
aStarts.push_back(pMark->GetName());
@@ -229,15 +231,15 @@ void RtfExport::WriteNumbering()
Strm()
.WriteChar('{')
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_IGNORE)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LISTTABLE);
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_IGNORE)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_LISTTABLE);
CollectGrfsOfBullets();
if (!m_vecBulletPic.empty())
Strm()
.WriteChar('{')
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_IGNORE)
- .WriteCharPtr(LO_STRING_SVTOOLS_RTF_LISTPICTURE);
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_IGNORE)
+ .WriteOString(LO_STRING_SVTOOLS_RTF_LISTPICTURE);
BulletDefinitions();
if (!m_vecBulletPic.empty())
Strm().WriteChar('}');
@@ -245,7 +247,7 @@ void RtfExport::WriteNumbering()
AbstractNumberingDefinitions();
Strm().WriteChar('}');
- Strm().WriteChar('{').WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LISTOVERRIDETABLE);
+ Strm().WriteChar('{').WriteOString(OOO_STRING_SVTOOLS_RTF_LISTOVERRIDETABLE);
NumberingDefinitions();
Strm().WriteChar('}');
@@ -270,19 +272,18 @@ void RtfExport::WriteRevTab()
// Now write the table
Strm()
.WriteChar('{')
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_IGNORE)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_REVTBL)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_IGNORE)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_REVTBL)
.WriteChar(' ');
for (std::size_t i = 0; i < m_aRedlineTable.size(); ++i)
{
const OUString* pAuthor = GetRedline(i);
Strm().WriteChar('{');
if (pAuthor)
- Strm().WriteCharPtr(
- msfilter::rtfutil::OutString(*pAuthor, m_eDefaultEncoding).getStr());
- Strm().WriteCharPtr(";}");
+ Strm().WriteOString(msfilter::rtfutil::OutString(*pAuthor, m_eDefaultEncoding));
+ Strm().WriteOString(";}");
}
- Strm().WriteChar('}').WriteCharPtr(SAL_NEWLINE_STRING);
+ Strm().WriteChar('}').WriteOString(SAL_NEWLINE_STRING);
}
void RtfExport::WriteHeadersFooters(sal_uInt8 nHeadFootFlags, const SwFrameFormat& rFormat,
@@ -318,9 +319,62 @@ void RtfExport::OutputField(const SwField* pField, ww::eField eFieldType, const
m_pAttrOutput->WriteField_Impl(pField, eFieldType, rFieldCmd, nMode);
}
-void RtfExport::WriteFormData(const ::sw::mark::IFieldmark& /*rFieldmark*/)
+void RtfExport::WriteFormData(const ::sw::mark::IFieldmark& rFieldmark)
{
- SAL_INFO("sw.rtf", "TODO: " << __func__);
+ sal_Int32 nType;
+ if (rFieldmark.GetFieldname() == ODF_FORMDROPDOWN)
+ {
+ nType = 2;
+ }
+ /* TODO
+ else if (rFieldmark.GetFieldname() == ODF_FORMCHECKBOX)
+ {
+ nType = 1;
+ }
+ else if (rFieldmark.GetFieldname() == ODF_FORMTEXT)
+ {
+ nType = 0;
+ }
+*/
+ else
+ {
+ SAL_INFO("sw.rtf", "unknown field type");
+ return;
+ }
+ m_pAttrOutput->RunText().append(
+ "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD
+ "{" OOO_STRING_SVTOOLS_RTF_FFTYPE);
+ m_pAttrOutput->RunText().append(nType);
+ if (rFieldmark.GetFieldname() == ODF_FORMDROPDOWN)
+ {
+ m_pAttrOutput->RunText().append(OOO_STRING_SVTOOLS_RTF_FFHASLISTBOX "1");
+ uno::Sequence<OUString> entries;
+ if (auto const it = rFieldmark.GetParameters()->find(ODF_FORMDROPDOWN_LISTENTRY);
+ it != rFieldmark.GetParameters()->end())
+ {
+ it->second >>= entries;
+ }
+ if (auto const it = rFieldmark.GetParameters()->find(ODF_FORMDROPDOWN_RESULT);
+ it != rFieldmark.GetParameters()->end())
+ {
+ sal_Int32 result(-1);
+ it->second >>= result;
+ if (0 <= result && result < entries.getLength())
+ {
+ m_pAttrOutput->RunText().append(OOO_STRING_SVTOOLS_RTF_FFRES);
+ m_pAttrOutput->RunText().append(result);
+ }
+ }
+ for (OUString const& rEntry : entries)
+ {
+ m_pAttrOutput->RunText().append(
+ "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFL " ");
+ m_pAttrOutput->RunText().append(
+ msfilter::rtfutil::OutString(rEntry, m_eDefaultEncoding));
+ m_pAttrOutput->RunText().append("}");
+ }
+ }
+ m_pAttrOutput->RunText().append("}}"); // close FORMFIELD destination
}
void RtfExport::WriteHyperlinkData(const ::sw::mark::IFieldmark& /*rFieldmark*/)
@@ -373,7 +427,7 @@ void RtfExport::DoFormText(const SwInputField* pField)
+ "}}");
}
-sal_uLong RtfExport::ReplaceCr(sal_uInt8 /*nChar*/)
+sal_uInt64 RtfExport::ReplaceCr(sal_uInt8 /*nChar*/)
{
// Completely unused for Rtf export... only here for code sharing
// purpose with binary export
@@ -384,9 +438,9 @@ sal_uLong RtfExport::ReplaceCr(sal_uInt8 /*nChar*/)
void RtfExport::WriteFonts()
{
Strm()
- .WriteCharPtr(SAL_NEWLINE_STRING)
+ .WriteOString(SAL_NEWLINE_STRING)
.WriteChar('{')
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_FONTTBL);
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_FONTTBL);
m_aFontHelper.WriteFontTable(*m_pAttrOutput);
Strm().WriteChar('}');
}
@@ -406,10 +460,10 @@ void RtfExport::WriteFootnoteSettings()
Strm()
.WriteChar('{')
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_IGNORE)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_FTNSEP);
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_IGNORE)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_FTNSEP);
if (bSeparator)
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_CHFTNSEP);
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_CHFTNSEP);
Strm().WriteChar('}');
}
@@ -417,41 +471,41 @@ void RtfExport::WriteMainText()
{
SAL_INFO("sw.rtf", __func__ << " start");
- if (std::unique_ptr<SvxBrushItem> oBrush = getBackground(); oBrush)
+ const std::unique_ptr<SvxBrushItem> oBrush = getBackground();
+ if (oBrush && oBrush->GetColor() != COL_AUTO)
{
- Strm().WriteCharPtr(LO_STRING_SVTOOLS_RTF_VIEWBKSP).WriteChar('1');
- Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BACKGROUND);
- Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SHP);
- Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPINST);
-
- std::vector<std::pair<OString, OString>> aProperties;
- aProperties.push_back(std::make_pair<OString, OString>("shapeType", "1"));
- aProperties.push_back(std::make_pair<OString, OString>(
- "fillColor", OString::number(wwUtility::RGBToBGR(oBrush->GetColor()))));
+ Strm().WriteOString(LO_STRING_SVTOOLS_RTF_VIEWBKSP).WriteChar('1');
+ Strm().WriteOString("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BACKGROUND);
+ Strm().WriteOString("{" OOO_STRING_SVTOOLS_RTF_SHP);
+ Strm().WriteOString("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPINST);
+
+ std::vector<std::pair<OString, OString>> aProperties{
+ { "shapeType", "1" },
+ { "fillColor", OString::number(wwUtility::RGBToBGR(oBrush->GetColor())) }
+ };
for (const std::pair<OString, OString>& rPair : aProperties)
{
- Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SP "{");
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SN " ");
+ Strm().WriteOString("{" OOO_STRING_SVTOOLS_RTF_SP "{");
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_SN " ");
Strm().WriteOString(rPair.first);
- Strm().WriteCharPtr("}{" OOO_STRING_SVTOOLS_RTF_SV " ");
+ Strm().WriteOString("}{" OOO_STRING_SVTOOLS_RTF_SV " ");
Strm().WriteOString(rPair.second);
- Strm().WriteCharPtr("}}");
+ Strm().WriteOString("}}");
}
Strm().WriteChar('}'); // shpinst
Strm().WriteChar('}'); // shp
Strm().WriteChar('}'); // background
}
- SwTableNode* pTableNode = m_pCurPam->GetNode().FindTableNode();
+ SwTableNode* pTableNode = m_pCurPam->GetPointNode().FindTableNode();
if (m_pWriter && m_pWriter->m_bWriteOnlyFirstTable && pTableNode != nullptr)
{
- m_pCurPam->GetPoint()->nNode = *pTableNode;
- m_pCurPam->GetMark()->nNode = *(pTableNode->EndOfSectionNode());
+ m_pCurPam->GetPoint()->Assign(*pTableNode);
+ m_pCurPam->GetMark()->Assign(*pTableNode->EndOfSectionNode());
}
else
{
- m_pCurPam->GetPoint()->nNode
- = m_rDoc.GetNodes().GetEndOfContent().StartOfSectionNode()->GetIndex();
+ m_pCurPam->GetPoint()->Assign(*m_rDoc.GetNodes().GetEndOfContent().StartOfSectionNode());
}
WriteText();
@@ -464,10 +518,10 @@ void RtfExport::WriteInfo()
OString aGenerator
= OUStringToOString(utl::DocInfoHelper::GetGeneratorString(), RTL_TEXTENCODING_UTF8);
Strm()
- .WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_IGNORE LO_STRING_SVTOOLS_RTF_GENERATOR " ")
+ .WriteOString("{" OOO_STRING_SVTOOLS_RTF_IGNORE LO_STRING_SVTOOLS_RTF_GENERATOR " ")
.WriteOString(aGenerator)
.WriteChar('}');
- Strm().WriteChar('{').WriteCharPtr(OOO_STRING_SVTOOLS_RTF_INFO);
+ Strm().WriteChar('{').WriteOString(OOO_STRING_SVTOOLS_RTF_INFO);
SwDocShell* pDocShell(m_rDoc.GetDocShell());
uno::Reference<document::XDocumentProperties> xDocProps;
@@ -519,20 +573,19 @@ void RtfExport::WriteInfo()
void RtfExport::WriteUserPropType(int nType)
{
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PROPTYPE);
- OutULong(nType);
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_PROPTYPE).WriteNumberAsString(nType);
}
-void RtfExport::WriteUserPropValue(const OUString& rValue)
+void RtfExport::WriteUserPropValue(std::u16string_view rValue)
{
- Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_STATICVAL " ");
+ Strm().WriteOString("{" OOO_STRING_SVTOOLS_RTF_STATICVAL " ");
Strm().WriteOString(msfilter::rtfutil::OutString(rValue, m_eDefaultEncoding));
Strm().WriteChar('}');
}
void RtfExport::WriteUserProps()
{
- Strm().WriteChar('{').WriteCharPtr(
+ Strm().WriteChar('{').WriteOString(
OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_USERPROPS);
SwDocShell* pDocShell(m_rDoc.GetDocShell());
@@ -569,9 +622,9 @@ void RtfExport::WriteUserProps()
continue;
// Property name.
- Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_PROPNAME " ");
- Strm().WriteCharPtr(
- msfilter::rtfutil::OutString(rProperty.Name, m_eDefaultEncoding).getStr());
+ Strm().WriteOString("{" OOO_STRING_SVTOOLS_RTF_PROPNAME " ");
+ Strm().WriteOString(
+ msfilter::rtfutil::OutString(rProperty.Name, m_eDefaultEncoding));
Strm().WriteChar('}');
// Property value.
@@ -626,50 +679,55 @@ void RtfExport::WriteUserProps()
Strm().WriteChar('}');
}
-void RtfExport::WritePageDescTable()
+void RtfExport::WriteDocVars()
{
- // Write page descriptions (page styles)
- std::size_t nSize = m_rDoc.GetPageDescCnt();
- if (!nSize)
+ SwDocShell* pDocShell(m_rDoc.GetDocShell());
+ if (!pDocShell)
return;
- Strm().WriteCharPtr(SAL_NEWLINE_STRING);
- m_bOutPageDescs = true;
- Strm()
- .WriteChar('{')
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_IGNORE)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PGDSCTBL);
- for (std::size_t n = 0; n < nSize; ++n)
+ uno::Reference<text::XTextFieldsSupplier> xModel(pDocShell->GetModel(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xTextFieldMasters = xModel->getTextFieldMasters();
+ uno::Sequence<rtl::OUString> aMasterNames = xTextFieldMasters->getElementNames();
+ if (!aMasterNames.hasElements())
+ {
+ return;
+ }
+
+ // Only write docVars if there will be at least a single docVar.
+ constexpr OUString aPrefix(u"com.sun.star.text.fieldmaster.User."_ustr);
+ for (const auto& rMasterName : aMasterNames)
{
- const SwPageDesc& rPageDesc = m_rDoc.GetPageDesc(n);
+ if (!rMasterName.startsWith(aPrefix))
+ {
+ // Not a user field.
+ continue;
+ }
- Strm()
- .WriteCharPtr(SAL_NEWLINE_STRING)
- .WriteChar('{')
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PGDSC);
- OutULong(n).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PGDSCUSE);
- OutULong(static_cast<sal_uLong>(rPageDesc.ReadUseOn()));
+ uno::Reference<beans::XPropertySet> xField;
+ xTextFieldMasters->getByName(rMasterName) >>= xField;
+ if (!xField.is())
+ {
+ continue;
+ }
- OutPageDescription(rPageDesc, false);
+ OUString aKey = rMasterName.copy(aPrefix.getLength());
+ OUString aValue;
+ xField->getPropertyValue("Content") >>= aValue;
- // search for the next page description
- std::size_t i = nSize;
- while (i)
- if (rPageDesc.GetFollow() == &m_rDoc.GetPageDesc(--i))
- break;
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PGDSCNXT);
- OutULong(i).WriteChar(' ');
- Strm()
- .WriteCharPtr(
- msfilter::rtfutil::OutString(rPageDesc.GetName(), m_eDefaultEncoding).getStr())
- .WriteCharPtr(";}");
- }
- Strm().WriteChar('}').WriteCharPtr(SAL_NEWLINE_STRING);
- m_bOutPageDescs = false;
+ Strm().WriteChar('{').WriteOString(
+ OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_DOCVAR);
+ Strm().WriteChar(' ');
+
+ Strm().WriteChar('{');
+ Strm().WriteOString(msfilter::rtfutil::OutString(aKey, m_eDefaultEncoding));
+ Strm().WriteChar('}');
- // reset table infos, otherwise the depth of the cells will be incorrect,
- // in case the page style (header or footer) had tables
- m_pTableInfo = std::make_shared<ww8::WW8TableInfo>();
+ Strm().WriteChar('{');
+ Strm().WriteOString(msfilter::rtfutil::OutString(aValue, m_eDefaultEncoding));
+ Strm().WriteChar('}');
+
+ Strm().WriteChar('}');
+ }
}
ErrCode RtfExport::ExportDocument_Impl()
@@ -677,13 +735,14 @@ ErrCode RtfExport::ExportDocument_Impl()
// Make the header
Strm()
.WriteChar('{')
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_RTF)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_RTF)
.WriteChar('1')
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_ANSI);
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_DEFF);
- OutULong(m_aFontHelper.GetId(m_rDoc.GetAttrPool().GetDefaultItem(RES_CHRATR_FONT)));
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_ANSI);
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_DEFF);
+ Strm().WriteNumberAsString(
+ m_aFontHelper.GetId(m_rDoc.GetAttrPool().GetUserOrPoolDefaultItem(RES_CHRATR_FONT)));
// If this not exist, MS don't understand our ansi characters (0x80-0xff).
- Strm().WriteCharPtr("\\adeflang1025");
+ Strm().WriteOString("\\adeflang1025");
// Font table
WriteFonts();
@@ -700,41 +759,40 @@ ErrCode RtfExport::ExportDocument_Impl()
WriteInfo();
WriteUserProps();
+ WriteDocVars();
+
// Default TabSize
- Strm()
- .WriteOString(m_pAttrOutput->GetTabStop().makeStringAndClear())
- .WriteCharPtr(SAL_NEWLINE_STRING);
+ Strm().WriteOString(m_pAttrOutput->GetTabStop()).WriteOString(SAL_NEWLINE_STRING);
+ m_pAttrOutput->GetTabStop().setLength(0);
// Automatic hyphenation: it's a global setting in Word, it's a paragraph setting in Writer.
// Set it's value to "auto" and disable on paragraph level, if no hyphenation is used there.
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_HYPHAUTO);
- OutULong(1);
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_HYPHAUTO);
+ Strm().WriteOString("1");
// Zoom
SwViewShell* pViewShell(m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell());
if (pViewShell && pViewShell->GetViewOptions()->GetZoomType() == SvxZoomType::PERCENT)
{
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_VIEWSCALE);
- OutULong(pViewShell->GetViewOptions()->GetZoom());
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_VIEWSCALE);
+ Strm().WriteNumberAsString(pViewShell->GetViewOptions()->GetZoom());
}
// Record changes?
if (RedlineFlags::On & m_nOrigRedlineFlags)
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_REVISIONS);
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_REVISIONS);
// Mirror margins?
if ((UseOnPage::Mirror & m_rDoc.GetPageDesc(0).ReadUseOn()) == UseOnPage::Mirror)
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_MARGMIRROR);
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_MARGMIRROR);
// Gutter at top?
- if (m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::GUTTER_AT_TOP))
+ IDocumentSettingAccess& rIDSA = m_rDoc.getIDocumentSettingAccess();
+ if (rIDSA.get(DocumentSettingId::GUTTER_AT_TOP))
{
- Strm().WriteCharPtr(LO_STRING_SVTOOLS_RTF_GUTTERPRL);
+ Strm().WriteOString(LO_STRING_SVTOOLS_RTF_GUTTERPRL);
}
// Init sections
- m_pSections.reset(new MSWordSections(*this));
-
- // Page description
- WritePageDescTable();
+ m_pSections = std::make_unique<MSWordSections>(*this);
// Enable form protection by default if needed, as there is no switch to
// enable it on a per-section basis. OTOH don't always enable it as it
@@ -744,13 +802,20 @@ ErrCode RtfExport::ExportDocument_Impl()
{
if (!pSectionFormat->IsInUndo() && pSectionFormat->GetProtect().IsContentProtected())
{
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_FORMPROT);
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_FORMPROT);
break;
}
}
// enable form field shading
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_FORMSHADE);
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_FORMSHADE);
+
+ // Enable breaking wrapped tables across pages: the "no" in the control word's name is
+ // confusing.
+ if (!rIDSA.get(DocumentSettingId::DO_NOT_BREAK_WRAPPED_TABLES))
+ {
+ Strm().WriteOString(LO_STRING_SVTOOLS_RTF_NOBRKWRPTBL);
+ }
// size and empty margins of the page
if (m_rDoc.GetPageDescCnt())
@@ -780,9 +845,9 @@ ErrCode RtfExport::ExportDocument_Impl()
{
Strm()
.WriteChar('{')
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_IGNORE)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PGDSCNO);
- OutULong(nPosInDoc).WriteChar('}');
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_IGNORE)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_PGDSCNO);
+ Strm().WriteNumberAsString(nPosInDoc).WriteChar('}');
}
}
}
@@ -791,48 +856,50 @@ ErrCode RtfExport::ExportDocument_Impl()
{
if (rPageDesc.GetLandscape())
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LANDSCAPE);
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LANDSCAPE);
const SwFormatFrameSize& rSz = rFormatPage.GetFrameSize();
// Clipboard document is always created without a printer, then
// the size will be always LONG_MAX! Solution then is to use A4
if (LONG_MAX == rSz.GetHeight() || LONG_MAX == rSz.GetWidth())
{
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PAPERH);
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_PAPERH);
Size a4 = SvxPaperInfo::GetPaperSize(PAPER_A4);
- OutULong(a4.Height()).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PAPERW);
- OutULong(a4.Width());
+ Strm().WriteNumberAsString(a4.Height()).WriteOString(OOO_STRING_SVTOOLS_RTF_PAPERW);
+ Strm().WriteNumberAsString(a4.Width());
}
else
{
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PAPERH);
- OutULong(rSz.GetHeight()).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PAPERW);
- OutULong(rSz.GetWidth());
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_PAPERH);
+ Strm()
+ .WriteNumberAsString(rSz.GetHeight())
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_PAPERW);
+ Strm().WriteNumberAsString(rSz.GetWidth());
}
}
{
const SvxLRSpaceItem& rLR = rFormatPage.GetLRSpace();
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_MARGL);
- OutLong(rLR.GetLeft()).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_MARGR);
- OutLong(rLR.GetRight());
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_MARGL);
+ Strm().WriteNumberAsString(rLR.GetLeft()).WriteOString(OOO_STRING_SVTOOLS_RTF_MARGR);
+ Strm().WriteNumberAsString(rLR.GetRight());
}
{
const SvxULSpaceItem& rUL = rFormatPage.GetULSpace();
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_MARGT);
- OutLong(rUL.GetUpper()).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_MARGB);
- OutLong(rUL.GetLower());
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_MARGT);
+ Strm().WriteNumberAsString(rUL.GetUpper()).WriteOString(OOO_STRING_SVTOOLS_RTF_MARGB);
+ Strm().WriteNumberAsString(rUL.GetLower());
}
Strm()
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SECTD)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SBKNONE);
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_SECTD)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_SBKNONE);
m_pAttrOutput->SectFootnoteEndnotePr();
// All sections are unlocked by default
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SECTUNLOCKED);
- OutLong(1);
- OutPageDescription(rPageDesc, true); // Changed bCheckForFirstPage to true so headers
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_SECTUNLOCKED);
+ Strm().WriteOString("1");
+ OutPageDescription(rPageDesc); // Changed bCheckForFirstPage to true so headers
// following title page are correctly added - i13107
if (pSttPgDsc)
{
@@ -857,8 +924,8 @@ ErrCode RtfExport::ExportDocument_Impl()
const char* pOut = FTNPOS_CHAPTER == rFootnoteInfo.m_ePos ? OOO_STRING_SVTOOLS_RTF_ENDDOC
: OOO_STRING_SVTOOLS_RTF_FTNBJ;
- Strm().WriteCharPtr(pOut).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_FTNSTART);
- OutLong(rFootnoteInfo.m_nFootnoteOffset + 1);
+ Strm().WriteOString(pOut).WriteOString(OOO_STRING_SVTOOLS_RTF_FTNSTART);
+ Strm().WriteNumberAsString(rFootnoteInfo.m_nFootnoteOffset + 1);
switch (rFootnoteInfo.m_eNum)
{
@@ -872,7 +939,7 @@ ErrCode RtfExport::ExportDocument_Impl()
pOut = OOO_STRING_SVTOOLS_RTF_FTNRESTART;
break;
}
- Strm().WriteCharPtr(pOut);
+ Strm().WriteOString(pOut);
switch (rFootnoteInfo.m_aFormat.GetNumberingType())
{
@@ -897,15 +964,15 @@ ErrCode RtfExport::ExportDocument_Impl()
pOut = OOO_STRING_SVTOOLS_RTF_FTNNAR;
break;
}
- Strm().WriteCharPtr(pOut);
+ Strm().WriteOString(pOut);
const SwEndNoteInfo& rEndNoteInfo = m_rDoc.GetEndNoteInfo();
Strm()
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_AENDDOC)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_AFTNRSTCONT)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_AFTNSTART);
- OutLong(rEndNoteInfo.m_nFootnoteOffset + 1);
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_AENDDOC)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_AFTNRSTCONT)
+ .WriteOString(OOO_STRING_SVTOOLS_RTF_AFTNSTART);
+ Strm().WriteNumberAsString(rEndNoteInfo.m_nFootnoteOffset + 1);
switch (rEndNoteInfo.m_aFormat.GetNumberingType())
{
@@ -930,14 +997,14 @@ ErrCode RtfExport::ExportDocument_Impl()
pOut = OOO_STRING_SVTOOLS_RTF_AFTNNAR;
break;
}
- Strm().WriteCharPtr(pOut);
+ Strm().WriteOString(pOut);
}
if (!m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::PARA_SPACE_MAX))
// RTF default is true, so write compat flag if this should be false.
- Strm().WriteCharPtr(LO_STRING_SVTOOLS_RTF_HTMAUTSP);
+ Strm().WriteOString(LO_STRING_SVTOOLS_RTF_HTMAUTSP);
- Strm().WriteCharPtr(SAL_NEWLINE_STRING);
+ Strm().WriteOString(SAL_NEWLINE_STRING);
WriteFootnoteSettings();
@@ -981,7 +1048,7 @@ bool RtfExport::DisallowInheritingOutlineNumbering(const SwFormat& rFormat)
->IsAssignedToListLevelOfOutlineStyle())
{
// Level 9 disables the outline
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LEVEL).WriteInt32(9);
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LEVEL).WriteInt32(9);
bRet = true;
}
@@ -1015,7 +1082,7 @@ void RtfExport::OutputTextNode(SwTextNode& rNode)
m_nCurrentNodeIndex = rNode.GetIndex();
if (!m_bOutOutlineOnly || rNode.IsOutline())
MSWordExportBase::OutputTextNode(rNode);
- m_nCurrentNodeIndex = 0;
+ m_nCurrentNodeIndex = SwNodeOffset(0);
}
void RtfExport::AppendSection(const SwPageDesc* pPageDesc, const SwSectionFormat* pFormat,
@@ -1044,7 +1111,7 @@ RtfExport::RtfExport(RtfExportFilter* pFilter, SwDoc& rDocument,
// that just causes problems for RTF
m_bSubstituteBullets = false;
// needed to have a complete font table
- m_aFontHelper.bLoadAllFonts = true;
+ m_aFontHelper.m_bLoadAllFonts = true;
// the related SdrExport
m_pSdrExport = std::make_unique<RtfSdrExport>(*this);
@@ -1076,34 +1143,29 @@ OString RtfExport::getStream()
void RtfExport::resetStream() { m_pStream.reset(); }
-SvStream& RtfExport::OutULong(sal_uLong nVal) { return Writer::OutULong(Strm(), nVal); }
-
-SvStream& RtfExport::OutLong(tools::Long nVal) { return Writer::OutLong(Strm(), nVal); }
-
-void RtfExport::OutUnicode(const char* pToken, const OUString& rContent, bool bUpr)
+void RtfExport::OutUnicode(std::string_view pToken, std::u16string_view rContent, bool bUpr)
{
- if (rContent.isEmpty())
+ if (rContent.empty())
return;
if (!bUpr)
{
- Strm().WriteChar('{').WriteCharPtr(pToken).WriteChar(' ');
- Strm().WriteCharPtr(msfilter::rtfutil::OutString(rContent, m_eCurrentEncoding).getStr());
+ Strm().WriteChar('{').WriteOString(pToken).WriteChar(' ');
+ Strm().WriteOString(msfilter::rtfutil::OutString(rContent, m_eCurrentEncoding));
Strm().WriteChar('}');
}
else
- Strm().WriteCharPtr(
- msfilter::rtfutil::OutStringUpr(pToken, rContent, m_eCurrentEncoding).getStr());
+ Strm().WriteOString(msfilter::rtfutil::OutStringUpr(pToken, rContent, m_eCurrentEncoding));
}
-void RtfExport::OutDateTime(const char* pStr, const util::DateTime& rDT)
+void RtfExport::OutDateTime(std::string_view pStr, const util::DateTime& rDT)
{
- Strm().WriteChar('{').WriteCharPtr(pStr).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_YR);
- OutULong(rDT.Year).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_MO);
- OutULong(rDT.Month).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_DY);
- OutULong(rDT.Day).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_HR);
- OutULong(rDT.Hours).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_MIN);
- OutULong(rDT.Minutes).WriteChar('}');
+ Strm().WriteChar('{').WriteOString(pStr).WriteOString(OOO_STRING_SVTOOLS_RTF_YR);
+ Strm().WriteNumberAsString(rDT.Year).WriteOString(OOO_STRING_SVTOOLS_RTF_MO);
+ Strm().WriteNumberAsString(rDT.Month).WriteOString(OOO_STRING_SVTOOLS_RTF_DY);
+ Strm().WriteNumberAsString(rDT.Day).WriteOString(OOO_STRING_SVTOOLS_RTF_HR);
+ Strm().WriteNumberAsString(rDT.Hours).WriteOString(OOO_STRING_SVTOOLS_RTF_MIN);
+ Strm().WriteNumberAsString(rDT.Minutes).WriteChar('}');
}
sal_uInt16 RtfExport::GetColor(const Color& rColor) const
@@ -1191,15 +1253,17 @@ void RtfExport::OutColorTable()
InsColor(COL_BROWN);
InsColor(COL_GRAY);
InsColor(COL_LIGHTGRAY);
+ ItemSurrogates aSurrogates;
// char color
{
auto pCol = GetDfltAttr(RES_CHRATR_COLOR);
InsColor(pCol->GetValue());
- pCol = rPool.GetPoolDefaultItem(RES_CHRATR_COLOR);
+ pCol = rPool.GetUserDefaultItem(RES_CHRATR_COLOR);
if (pCol)
InsColor(pCol->GetValue());
- for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(RES_CHRATR_COLOR))
+ rPool.GetItemSurrogates(aSurrogates, RES_CHRATR_COLOR);
+ for (const SfxPoolItem* pItem : aSurrogates)
{
pCol = dynamic_cast<const SvxColorItem*>(pItem);
if (pCol)
@@ -1208,7 +1272,8 @@ void RtfExport::OutColorTable()
auto pUnder = GetDfltAttr(RES_CHRATR_UNDERLINE);
InsColor(pUnder->GetColor());
- for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(RES_CHRATR_UNDERLINE))
+ rPool.GetItemSurrogates(aSurrogates, RES_CHRATR_UNDERLINE);
+ for (const SfxPoolItem* pItem : aSurrogates)
{
pUnder = dynamic_cast<const SvxUnderlineItem*>(pItem);
if (pUnder)
@@ -1217,7 +1282,8 @@ void RtfExport::OutColorTable()
auto pOver = GetDfltAttr(RES_CHRATR_OVERLINE);
InsColor(pOver->GetColor());
- for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(RES_CHRATR_OVERLINE))
+ rPool.GetItemSurrogates(aSurrogates, RES_CHRATR_OVERLINE);
+ for (const SfxPoolItem* pItem : aSurrogates)
{
pOver = dynamic_cast<const SvxOverlineItem*>(pItem);
if (pOver)
@@ -1232,12 +1298,13 @@ void RtfExport::OutColorTable()
{
auto pBackground = static_cast<const SvxBrushItem*>(GetDfltAttr(*pIds));
InsColor(pBackground->GetColor());
- pBackground = static_cast<const SvxBrushItem*>(rPool.GetPoolDefaultItem(*pIds));
+ pBackground = static_cast<const SvxBrushItem*>(rPool.GetUserDefaultItem(*pIds));
if (pBackground)
{
InsColor(pBackground->GetColor());
}
- for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(*pIds))
+ rPool.GetItemSurrogates(aSurrogates, *pIds);
+ for (const SfxPoolItem* pItem : aSurrogates)
{
pBackground = static_cast<const SvxBrushItem*>(pItem);
if (pBackground)
@@ -1251,12 +1318,13 @@ void RtfExport::OutColorTable()
{
auto pShadow = GetDfltAttr(RES_SHADOW);
InsColor(pShadow->GetColor());
- pShadow = rPool.GetPoolDefaultItem(RES_SHADOW);
+ pShadow = rPool.GetUserDefaultItem(RES_SHADOW);
if (nullptr != pShadow)
{
InsColor(pShadow->GetColor());
}
- for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(RES_SHADOW))
+ rPool.GetItemSurrogates(aSurrogates, RES_SHADOW);
+ for (const SfxPoolItem* pItem : aSurrogates)
{
pShadow = dynamic_cast<const SvxShadowItem*>(pItem);
if (pShadow)
@@ -1268,10 +1336,11 @@ void RtfExport::OutColorTable()
// frame border color
{
- const SvxBoxItem* pBox = rPool.GetPoolDefaultItem(RES_BOX);
+ const SvxBoxItem* pBox = rPool.GetUserDefaultItem(RES_BOX);
if (nullptr != pBox)
InsColorLine(*pBox);
- for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(RES_BOX))
+ rPool.GetItemSurrogates(aSurrogates, RES_BOX);
+ for (const SfxPoolItem* pItem : aSurrogates)
{
pBox = dynamic_cast<const SvxBoxItem*>(pItem);
if (pBox)
@@ -1280,10 +1349,11 @@ void RtfExport::OutColorTable()
}
{
- const SvxBoxItem* pCharBox = rPool.GetPoolDefaultItem(RES_CHRATR_BOX);
+ const SvxBoxItem* pCharBox = rPool.GetUserDefaultItem(RES_CHRATR_BOX);
if (pCharBox)
InsColorLine(*pCharBox);
- for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(RES_CHRATR_BOX))
+ rPool.GetItemSurrogates(aSurrogates, RES_CHRATR_BOX);
+ for (const SfxPoolItem* pItem : aSurrogates)
{
pCharBox = dynamic_cast<const SvxBoxItem*>(pItem);
if (pCharBox)
@@ -1292,7 +1362,8 @@ void RtfExport::OutColorTable()
}
// TextFrame or paragraph background solid fill.
- for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(XATTR_FILLCOLOR))
+ rPool.GetItemSurrogates(aSurrogates, XATTR_FILLCOLOR);
+ for (const SfxPoolItem* pItem : aSurrogates)
{
if (auto pColorItem = dynamic_cast<const XFillColorItem*>(pItem))
InsColor(pColorItem->GetColorValue());
@@ -1303,10 +1374,10 @@ void RtfExport::OutColorTable()
const Color& rCol = m_aColTable[n];
if (n || COL_AUTO != rCol)
{
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_RED);
- OutULong(rCol.GetRed()).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_GREEN);
- OutULong(rCol.GetGreen()).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_BLUE);
- OutULong(rCol.GetBlue());
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_RED);
+ Strm().WriteNumberAsString(rCol.GetRed()).WriteOString(OOO_STRING_SVTOOLS_RTF_GREEN);
+ Strm().WriteNumberAsString(rCol.GetGreen()).WriteOString(OOO_STRING_SVTOOLS_RTF_BLUE);
+ Strm().WriteNumberAsString(rCol.GetBlue());
}
Strm().WriteChar(';');
}
@@ -1327,13 +1398,11 @@ OString* RtfExport::GetStyle(sal_uInt16 nId)
sal_uInt16 RtfExport::GetRedline(const OUString& rAuthor)
{
- auto it = m_aRedlineTable.find(rAuthor);
- if (it != m_aRedlineTable.end())
- return it->second;
-
const sal_uInt16 nId = m_aRedlineTable.size();
- m_aRedlineTable.insert(std::pair<OUString, sal_uInt16>(rAuthor, nId));
- return nId;
+ // insert if we don't already have one
+ auto[it, inserted] = m_aRedlineTable.insert(std::pair<OUString, sal_uInt16>(rAuthor, nId));
+ (void)inserted;
+ return it->second;
}
const OUString* RtfExport::GetRedline(sal_uInt16 nId)
@@ -1344,18 +1413,17 @@ const OUString* RtfExport::GetRedline(sal_uInt16 nId)
return nullptr;
}
-void RtfExport::OutPageDescription(const SwPageDesc& rPgDsc, bool bCheckForFirstPage)
+void RtfExport::OutPageDescription(const SwPageDesc& rPgDsc)
{
SAL_INFO("sw.rtf", __func__ << " start");
const SwPageDesc* pSave = m_pCurrentPageDesc;
m_pCurrentPageDesc = &rPgDsc;
- if (bCheckForFirstPage && m_pCurrentPageDesc->GetFollow()
- && m_pCurrentPageDesc->GetFollow() != m_pCurrentPageDesc)
+ if (m_pCurrentPageDesc->GetFollow() && m_pCurrentPageDesc->GetFollow() != m_pCurrentPageDesc)
m_pCurrentPageDesc = m_pCurrentPageDesc->GetFollow();
if (m_pCurrentPageDesc->GetLandscape())
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LNDSCPSXN);
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LNDSCPSXN);
const SwFormat* pFormat = &m_pCurrentPageDesc->GetMaster(); //GetLeft();
m_bOutPageDescs = true;
@@ -1377,7 +1445,7 @@ void RtfExport::OutPageDescription(const SwPageDesc& rPgDsc, bool bCheckForFirst
// title page
if (m_pCurrentPageDesc != &rPgDsc)
{
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_TITLEPG);
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_TITLEPG);
m_pCurrentPageDesc = &rPgDsc;
if (m_pCurrentPageDesc->GetMaster().GetAttrSet().GetItemState(RES_HEADER, false, &pItem)
== SfxItemState::SET)
@@ -1414,13 +1482,18 @@ void RtfExport::WriteHeaderFooter(const SfxPoolItem& rItem, bool bHeader)
const char* pStr = (bHeader ? OOO_STRING_SVTOOLS_RTF_HEADER : OOO_STRING_SVTOOLS_RTF_FOOTER);
/* is this a title page? */
- if (m_pCurrentPageDesc->GetFollow() && m_pCurrentPageDesc->GetFollow() != m_pCurrentPageDesc)
+ if ((m_pCurrentPageDesc->GetFollow() && m_pCurrentPageDesc->GetFollow() != m_pCurrentPageDesc)
+ || !m_pCurrentPageDesc->IsFirstShared())
{
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_TITLEPG);
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_TITLEPG);
pStr = (bHeader ? OOO_STRING_SVTOOLS_RTF_HEADERF : OOO_STRING_SVTOOLS_RTF_FOOTERF);
}
- Strm().WriteChar('{').WriteCharPtr(pStr);
- WriteHeaderFooterText(m_pCurrentPageDesc->GetMaster(), bHeader);
+
+ Strm().WriteChar('{').WriteOString(pStr);
+ WriteHeaderFooterText(m_pCurrentPageDesc->IsFirstShared()
+ ? m_pCurrentPageDesc->GetMaster()
+ : m_pCurrentPageDesc->GetFirstMaster(),
+ bHeader);
Strm().WriteChar('}');
SAL_INFO("sw.rtf", __func__ << " end");
@@ -1445,17 +1518,17 @@ private:
bool m_bOutOutlineOnly;
public:
- SwRTFWriter(const OUString& rFilterName, const OUString& rBaseURL);
+ SwRTFWriter(std::u16string_view rFilterName, const OUString& rBaseURL);
ErrCode WriteStream() override;
};
}
-SwRTFWriter::SwRTFWriter(const OUString& rFilterName, const OUString& rBaseURL)
+SwRTFWriter::SwRTFWriter(std::u16string_view rFilterName, const OUString& rBaseURL)
{
SetBaseURL(rBaseURL);
// export outline nodes, only (send outline to clipboard/presentation)
- m_bOutOutlineOnly = rFilterName.startsWith("O");
+ m_bOutOutlineOnly = o3tl::starts_with(rFilterName, u"O");
}
ErrCode SwRTFWriter::WriteStream()
@@ -1468,8 +1541,8 @@ ErrCode SwRTFWriter::WriteStream()
return ERRCODE_NONE;
}
-extern "C" SAL_DLLPUBLIC_EXPORT void ExportRTF(const OUString& rFltName, const OUString& rBaseURL,
- WriterRef& xRet)
+extern "C" SAL_DLLPUBLIC_EXPORT void ExportRTF(std::u16string_view rFltName,
+ const OUString& rBaseURL, WriterRef& xRet)
{
xRet = new SwRTFWriter(rFltName, rBaseURL);
}
diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx
index 105f6305eba2..1a24aaf3e151 100644
--- a/sw/source/filter/ww8/rtfexport.hxx
+++ b/sw/source/filter/ww8/rtfexport.hxx
@@ -67,7 +67,8 @@ public:
/// Guess the script (asian/western).
bool CollapseScriptsforWordOk(sal_uInt16 nScript, sal_uInt16 nWhich) override;
- void AppendBookmarks(const SwTextNode& rNode, sal_Int32 nCurrentPos, sal_Int32 nLen) override;
+ void AppendBookmarks(const SwTextNode& rNode, sal_Int32 nCurrentPos, sal_Int32 nLen,
+ const SwRedlineData* pSwRedlineData = nullptr) override;
void AppendBookmark(const OUString& rName) override;
@@ -113,7 +114,7 @@ public:
void DoFormText(const SwInputField* pField) override;
- sal_uLong ReplaceCr(sal_uInt8 nChar) override;
+ sal_uInt64 ReplaceCr(sal_uInt8 nChar) override;
ExportFormat GetExportFormat() const override { return ExportFormat::RTF; }
@@ -166,7 +167,7 @@ private:
/// This is used by OutputFlyFrame_Impl() to control the written syntax
bool m_bRTFFlySyntax;
/// Index of the current SwTextNode, if any.
- sal_uLong m_nCurrentNodeIndex;
+ SwNodeOffset m_nCurrentNodeIndex;
public:
rtl_TextEncoding GetDefaultEncoding() const { return m_eDefaultEncoding; }
@@ -177,7 +178,7 @@ public:
rtl_TextEncoding GetCurrentEncoding() const { return m_eCurrentEncoding; }
void SetRTFFlySyntax(bool bRTFFlySyntax) { m_bRTFFlySyntax = bRTFFlySyntax; }
bool GetRTFFlySyntax() const { return m_bRTFFlySyntax; }
- sal_uLong GetCurrentNodeIndex() const { return m_nCurrentNodeIndex; }
+ SwNodeOffset GetCurrentNodeIndex() const { return m_nCurrentNodeIndex; }
SvStream& Strm();
/// From now on, let Strm() return a memory stream, not a real one.
void setStream();
@@ -185,11 +186,9 @@ public:
OString getStream();
/// Return back to the real stream.
void resetStream();
- SvStream& OutULong(sal_uLong nVal);
- SvStream& OutLong(tools::Long nVal);
- void OutUnicode(const char* pToken, const OUString& rContent, bool bUpr = false);
- void OutDateTime(const char* pStr, const css::util::DateTime& rDT);
- void OutPageDescription(const SwPageDesc& rPgDsc, bool bCheckForFirstPage);
+ void OutUnicode(std::string_view pToken, std::u16string_view rContent, bool bUpr = false);
+ void OutDateTime(std::string_view pStr, const css::util::DateTime& rDT);
+ void OutPageDescription(const SwPageDesc& rPgDsc);
sal_uInt16 GetColor(const Color& rColor) const;
void InsColor(const Color& rCol);
@@ -212,11 +211,11 @@ private:
/// Writes a single user property type.
void WriteUserPropType(int nType);
/// Writes a single user property value.
- void WriteUserPropValue(const OUString& rValue);
+ void WriteUserPropValue(std::u16string_view rValue);
/// Writes the userprops group: user defined document properties.
void WriteUserProps();
- /// Writes the writer-specific \pgdsctbl group.
- void WritePageDescTable();
+ /// Writes document variables
+ void WriteDocVars();
/// This is necessary to have the numbering table ready before the main text is being processed.
void BuildNumbering();
void WriteHeaderFooter(const SfxPoolItem& rItem, bool bHeader);
diff --git a/sw/source/filter/ww8/rtfexportfilter.cxx b/sw/source/filter/ww8/rtfexportfilter.cxx
index 8ae2b1c50fc7..83016728901d 100644
--- a/sw/source/filter/ww8/rtfexportfilter.cxx
+++ b/sw/source/filter/ww8/rtfexportfilter.cxx
@@ -25,6 +25,7 @@
#include <unotxdoc.hxx>
#include <viewsh.hxx>
+#include <cppuhelper/supportsservice.hxx>
#include <unotools/mediadescriptor.hxx>
#include <unotools/ucbstreamhelper.hxx>
@@ -41,7 +42,7 @@ sal_Bool RtfExportFilter::filter(const uno::Sequence<beans::PropertyValue>& aDes
{
utl::MediaDescriptor aMediaDesc = aDescriptor;
uno::Reference<io::XStream> xStream = aMediaDesc.getUnpackedValueOrDefault(
- utl::MediaDescriptor::PROP_STREAMFOROUTPUT(), uno::Reference<io::XStream>());
+ utl::MediaDescriptor::PROP_STREAMFOROUTPUT, uno::Reference<io::XStream>());
std::unique_ptr<SvStream> pStream = utl::UcbStreamHelper::CreateStream(xStream, true);
m_aWriter.SetStream(pStream.get());
@@ -95,6 +96,18 @@ void RtfExportFilter::setSourceDocument(const uno::Reference<lang::XComponent>&
m_xSrcDoc = xDoc;
}
+OUString RtfExportFilter::getImplementationName() { return "com.sun.star.comp.Writer.RtfExport"; }
+
+sal_Bool RtfExportFilter::supportsService(OUString const& ServiceName)
+{
+ return cppu::supportsService(this, ServiceName);
+}
+
+css::uno::Sequence<OUString> RtfExportFilter::getSupportedServiceNames()
+{
+ return { "com.sun.star.comp.Writer.RtfExport" };
+}
+
// UNO helpers
extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
diff --git a/sw/source/filter/ww8/rtfexportfilter.hxx b/sw/source/filter/ww8/rtfexportfilter.hxx
index 7135f7602d34..d58a6be5a896 100644
--- a/sw/source/filter/ww8/rtfexportfilter.hxx
+++ b/sw/source/filter/ww8/rtfexportfilter.hxx
@@ -22,6 +22,7 @@
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
#include <cppuhelper/implbase.hxx>
#include <shellio.hxx>
@@ -39,7 +40,8 @@ protected:
/// The physical access to the RTF document (for writing).
class RtfExportFilter final
- : public cppu::WeakImplHelper<css::document::XFilter, css::document::XExporter>
+ : public cppu::WeakImplHelper<css::document::XFilter, css::document::XExporter,
+ css::lang::XServiceInfo>
{
css::uno::Reference<css::uno::XComponentContext> m_xCtx;
css::uno::Reference<css::lang::XComponent> m_xSrcDoc;
@@ -58,6 +60,10 @@ public:
void SAL_CALL
setSourceDocument(const css::uno::Reference<css::lang::XComponent>& xDoc) override;
+ OUString SAL_CALL getImplementationName() override;
+ sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override;
+ css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+
Writer& GetWriter() { return m_aWriter; }
};
diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx
index 320d8026ed33..d6427dd45f2c 100644
--- a/sw/source/filter/ww8/rtfsdrexport.cxx
+++ b/sw/source/filter/ww8/rtfsdrexport.cxx
@@ -32,7 +32,7 @@
#include <vcl/cvtgrf.hxx>
#include <textboxhelper.hxx>
#include <dcontact.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sal/log.hxx>
#include <algorithm>
#include "rtfexport.hxx"
@@ -56,11 +56,7 @@ RtfSdrExport::RtfSdrExport(RtfExport& rExport)
memset(m_pShapeTypeWritten.get(), 0, ESCHER_ShpInst_COUNT * sizeof(bool));
}
-RtfSdrExport::~RtfSdrExport()
-{
- delete mpOutStrm;
- mpOutStrm = nullptr;
-}
+RtfSdrExport::~RtfSdrExport() {}
void RtfSdrExport::OpenContainer(sal_uInt16 nEscherContainer, int nRecInstance)
{
@@ -305,7 +301,7 @@ void RtfSdrExport::Commit(EscherPropertyContainer& rProps, const tools::Rectangl
unsigned char nSegmentType = (nSeg & 0xE000) >> 13;
unsigned short nSegmentCount = nSeg & 0x03FF;
- aSegmentInfo.append(';').append(static_cast<sal_Int32>(nSeg));
+ aSegmentInfo.append(";" + OString::number(static_cast<sal_Int32>(nSeg)));
switch (nSegmentType)
{
case msopathLineTo:
@@ -369,8 +365,7 @@ void RtfSdrExport::Commit(EscherPropertyContainer& rProps, const tools::Rectangl
{
// We know the number of vertices at the end only, so we have to prepend them here.
m_aShapeProps.insert(std::pair<OString, OString>(
- "pVerticies",
- "8;" + OString::number(nVertices) + aVerticies.makeStringAndClear()));
+ "pVerticies", "8;" + OString::number(nVertices) + aVerticies));
}
if (!aSegmentInfo.isEmpty())
m_aShapeProps.insert(std::pair<OString, OString>(
@@ -427,16 +422,14 @@ void RtfSdrExport::Commit(EscherPropertyContainer& rProps, const tools::Rectangl
break;
case ESCHER_Prop_fillBlip:
{
- OStringBuffer aBuf;
- aBuf.append("{" OOO_STRING_SVTOOLS_RTF_PICT OOO_STRING_SVTOOLS_RTF_PNGBLIP
- SAL_NEWLINE_STRING);
int nHeaderSize
= 25; // The first bytes are WW8-specific, we're only interested in the PNG
- aBuf.append(msfilter::rtfutil::WriteHex(rOpt.nProp.data() + nHeaderSize,
- rOpt.nProp.size() - nHeaderSize));
- aBuf.append('}');
- m_aShapeProps.insert(
- std::pair<OString, OString>("fillBlip", aBuf.makeStringAndClear()));
+ OString aBuf = "{" OOO_STRING_SVTOOLS_RTF_PICT OOO_STRING_SVTOOLS_RTF_PNGBLIP
+ SAL_NEWLINE_STRING
+ + msfilter::rtfutil::WriteHex(rOpt.nProp.data() + nHeaderSize,
+ rOpt.nProp.size() - nHeaderSize)
+ + "}";
+ m_aShapeProps.insert(std::pair<OString, OString>("fillBlip", aBuf));
}
break;
default:
@@ -516,7 +509,7 @@ void RtfSdrExport::impl_writeGraphic()
// Export it to a stream.
SvMemoryStream aStream;
(void)GraphicConverter::Export(aStream, aGraphic, ConvertDataFormat::PNG);
- sal_uInt32 nSize = aStream.TellEnd();
+ sal_uInt64 nSize = aStream.TellEnd();
auto pGraphicAry = static_cast<sal_uInt8 const*>(aStream.GetData());
Size aMapped(aGraphic.GetPrefSize());
@@ -541,11 +534,12 @@ sal_Int32 RtfSdrExport::StartShape()
if (ESCHER_ShpInst_PictureFrame == m_nShapeType)
impl_writeGraphic();
- m_rAttrOutput.RunText().append('{').append(OOO_STRING_SVTOOLS_RTF_SHP);
+ m_rAttrOutput.RunText().append("{" OOO_STRING_SVTOOLS_RTF_SHP);
m_rAttrOutput.RunText().append(
"{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPINST);
- m_rAttrOutput.RunText().append(m_aShapeStyle.makeStringAndClear());
+ m_rAttrOutput.RunText().append(m_aShapeStyle);
+ m_aShapeStyle.setLength(0);
// Ignore \shpbxpage, \shpbxmargin, and \shpbxcolumn, in favor of the posrelh property.
m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_SHPBXIGNORE);
// Ignore \shpbypage, \shpbymargin, and \shpbycolumn, in favor of the posrelh property.
@@ -593,11 +587,11 @@ sal_Int32 RtfSdrExport::StartShape()
}
}
- auto pTextObj = dynamic_cast<const SdrTextObj*>(m_pSdrObject);
+ auto pTextObj = DynCastSdrTextObj(m_pSdrObject);
if (pTextObj)
{
const OutlinerParaObject* pParaObj = nullptr;
- std::unique_ptr<const OutlinerParaObject> pOwnedParaObj;
+ std::optional<OutlinerParaObject> pOwnedParaObj;
/*
#i13885#
@@ -607,7 +601,8 @@ sal_Int32 RtfSdrExport::StartShape()
if (pTextObj->IsTextEditActive())
{
pOwnedParaObj = pTextObj->CreateEditOutlinerParaObject();
- pParaObj = pOwnedParaObj.get();
+ if (pOwnedParaObj)
+ pParaObj = &*pOwnedParaObj;
}
else
{
@@ -629,8 +624,7 @@ sal_Int32 RtfSdrExport::StartShape()
msfilter::rtfutil::OutString(rEditObj.GetText(0),
m_rExport.GetCurrentEncoding()));
- auto pFontFamily
- = static_cast<const SvxFontItem*>(rItemSet.GetItem(SID_ATTR_CHAR_FONT));
+ const SvxFontItem* pFontFamily = rItemSet.GetItem(SID_ATTR_CHAR_FONT);
if (pFontFamily)
{
lcl_AppendSP(m_rAttrOutput.RunText(), "gtextFont",
@@ -638,8 +632,7 @@ sal_Int32 RtfSdrExport::StartShape()
m_rExport.GetCurrentEncoding()));
}
- auto pFontHeight = static_cast<const SvxFontHeightItem*>(
- rItemSet.GetItem(SID_ATTR_CHAR_FONTHEIGHT));
+ auto pFontHeight = rItemSet.GetItem(SID_ATTR_CHAR_FONTHEIGHT);
if (pFontHeight)
{
tools::Long nFontHeight = TransformMetric(pFontHeight->GetHeight(),
@@ -653,7 +646,7 @@ sal_Int32 RtfSdrExport::StartShape()
// RTF angle: 0-360 * 2^16 clockwise
// LO angle: 0-360 * 100 counter-clockwise
sal_Int32 nRotation
- = -1 * pTextObj->GetGeoStat().nRotationAngle.get() * RTF_MULTIPLIER / 100;
+ = -1 * pTextObj->GetGeoStat().m_nRotationAngle.get() * RTF_MULTIPLIER / 100;
lcl_AppendSP(m_rAttrOutput.RunText(), "rotation",
msfilter::rtfutil::OutString(OUString::number(nRotation),
m_rExport.GetCurrentEncoding()));
@@ -675,7 +668,7 @@ void RtfSdrExport::WriteOutliner(const OutlinerParaObject& rParaObj, TextTypes e
bool bShape = eType == TXT_HFTXTBOX;
if (bShape)
- m_rAttrOutput.RunText().append('{').append(OOO_STRING_SVTOOLS_RTF_SHPTXT).append(' ');
+ m_rAttrOutput.RunText().append("{" OOO_STRING_SVTOOLS_RTF_SHPTXT " ");
for (sal_Int32 n = 0; n < nPara; ++n)
{
if (n)
@@ -726,7 +719,7 @@ void RtfSdrExport::EndShape(sal_Int32 nShapeElement)
if (nShapeElement >= 0)
{
// end of the shape
- m_rAttrOutput.RunText().append('}').append('}');
+ m_rAttrOutput.RunText().append("}}");
}
}
diff --git a/sw/source/filter/ww8/rtfstringbuffer.cxx b/sw/source/filter/ww8/rtfstringbuffer.cxx
index f5d21d0b2bd4..ae491e45b4f0 100644
--- a/sw/source/filter/ww8/rtfstringbuffer.cxx
+++ b/sw/source/filter/ww8/rtfstringbuffer.cxx
@@ -22,7 +22,10 @@ RtfStringBufferValue::RtfStringBufferValue(const SwFlyFrameFormat* pFlyFrameForm
void RtfStringBufferValue::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
{
if (!isGraphic())
- pAttributeOutput->m_rExport.Strm().WriteOString(m_aBuffer.makeStringAndClear());
+ {
+ pAttributeOutput->m_rExport.Strm().WriteOString(m_aBuffer);
+ m_aBuffer.setLength(0);
+ }
else
pAttributeOutput->FlyFrameGraphic(m_pFlyFrameFormat, m_pGrfNode);
}
@@ -78,8 +81,7 @@ void RtfStringBuffer::append(const SwFlyFrameFormat* pFlyFrameFormat, const SwGr
void RtfStringBuffer::appendAndClear(RtfStringBuffer& rBuf)
{
- for (const auto& rValue : rBuf.m_aValues)
- m_aValues.push_back(rValue);
+ m_aValues.insert(m_aValues.end(), rBuf.m_aValues.begin(), rBuf.m_aValues.end());
rBuf.clear();
}
diff --git a/sw/source/filter/ww8/sortedarray.hxx b/sw/source/filter/ww8/sortedarray.hxx
index 7efec13aa9ff..40affc5a413d 100644
--- a/sw/source/filter/ww8/sortedarray.hxx
+++ b/sw/source/filter/ww8/sortedarray.hxx
@@ -49,7 +49,7 @@ namespace ww
if (aPair.first != aPair.second)
return aPair.first;
else
- return 0;
+ return nullptr;
}
SortedArray(C *pWwSprmTab, size_t nNoElems)
@@ -57,47 +57,6 @@ namespace ww
{
OSL_ENSURE(mnNoElems && pWwSprmTab, "WW8: empty Array: Don't do that");
std::sort(mpWwSprmTab, mpWwSprmTab + mnNoElems);
-#if OSL_DEBUG_LEVEL > 1
- bool bBroken=false;
- OUString sError;
- const C *pIter = mpWwSprmTab;
- const C *pBeforeEnd = mpWwSprmTab + mnNoElems - 1;
- while (pIter < pBeforeEnd)
- {
- if (pIter->nId == (pIter+1)->nId)
- {
- if (!bBroken)
- {
- sError =
- "WW8: Duplicate in list, almost certainly don't "
- "want that!\n"
- "(You will not see this message again unless you "
- "restart)\n"
- "Extra entries are...\n";
- bBroken=true;
- }
-
- size_t nSize = sizeof(C);
- const sal_uInt8 *pHack =
- reinterpret_cast<const sal_uInt8 *>(&(*pIter));
- for (size_t i=0; i < nSize; ++i)
- {
- sError += OUString::number(
- static_cast<sal_Int32>(pHack[i]), 16);
- sError += OUString(' ');
- }
- sError += OUString('\n');
- while (pIter->nId == (pIter+1)->nId && pIter < pBeforeEnd)
- ++pIter;
- }
- else
- ++pIter;
- }
- if (bBroken)
- {
- SAL_WARN( "sw", sError );
- }
-#endif
}
};
}
diff --git a/sw/source/filter/ww8/sprmids.hxx b/sw/source/filter/ww8/sprmids.hxx
index ac1d33cf8a80..1d023c3424a9 100644
--- a/sw/source/filter/ww8/sprmids.hxx
+++ b/sw/source/filter/ww8/sprmids.hxx
@@ -66,6 +66,7 @@ const sal_uInt16 LN_SGprfIhdt = 0x3014;
const sal_uInt16 LN_SBCustomize = 0x301e;
const sal_uInt16 LN_SPropRMark = 0xd227;
const sal_uInt16 LN_SFFacingCol = 0x3229;
+const sal_uInt16 LN_TDefTable = 0xd608;
const sal_uInt16 LN_TDefTable10 = 0xd606;
const sal_uInt16 LN_THTMLProps = 0x740c;
const sal_uInt16 LN_TSetBrc10 = 0xd626;
diff --git a/sw/source/filter/ww8/styles.cxx b/sw/source/filter/ww8/styles.cxx
index 4c8c9bc49555..33d0ad3dec5f 100644
--- a/sw/source/filter/ww8/styles.cxx
+++ b/sw/source/filter/ww8/styles.cxx
@@ -23,104 +23,106 @@
namespace
{
+ // Keep in sync with StyleSheetTable::ConvertStyleName
const char **GetStiNames() noexcept
{
+ // Matches enum ww::sti in sw/source/filter/inc/wwstyles.hxx
static const char *stiName[] =
{
- "Normal",
- "Heading 1",
- "Heading 2",
- "Heading 3",
- "Heading 4",
- "Heading 5",
- "Heading 6",
- "Heading 7",
- "Heading 8",
- "Heading 9",
- "Index 1",
- "Index 2",
- "Index 3",
- "Index 4",
- "Index 5",
- "Index 6",
- "Index 7",
- "Index 8",
- "Index 9",
- "TOC 1",
- "TOC 2",
- "TOC 3",
- "TOC 4",
- "TOC 5",
- "TOC 6",
- "TOC 7",
- "TOC 8",
- "TOC 9",
- "Normal Indent",
- "Footnote Text",
- "Annotation Text",
- "Header",
- "Footer",
- "Index Heading",
- "Caption",
- "Table of Figures",
- "Envelope Address",
- "Envelope Return",
- "Footnote Reference",
- "Annotation Reference",
- "Line Number",
- "Page Number",
- "Endnote Reference",
- "Endnote Text",
- "Table of Authorities",
- "Macro Text",
- "TOA Heading",
- "List",
- "List 2",
- "List 3",
- "List 4",
- "List 5",
- "List Bullet",
- "List Bullet 2",
- "List Bullet 3",
- "List Bullet 4",
- "List Bullet 5",
- "List Number",
- "List Number 2",
- "List Number 3",
- "List Number 4",
- "List Number 5",
- "Title",
- "Closing",
- "Signature",
- "Default Paragraph Font",
- "Body Text",
- "Body Text Indent",
- "List Continue",
- "List Continue 2",
- "List Continue 3",
- "List Continue 4",
- "List Continue 5",
- "Message Header",
- "Subtitle",
- "Salutation",
- "Date",
- "Body Text First Indent",
- "Body Text First Indent 2",
- "Note Heading",
- "Body Text 2",
- "Body Text 3",
- "Body Text Indent 2",
- "Body Text Indent 3",
- "Block Text",
- "Hyperlink",
- "Followed Hyperlink",
- "Strong",
- "Emphasis",
- "Document Map",
- "Plain Text"
+ "Normal", // stiNormal
+ "Heading 1", // stiLev1
+ "Heading 2", // stiLev2
+ "Heading 3", // stiLev3
+ "Heading 4", // stiLev4
+ "Heading 5", // stiLev5
+ "Heading 6", // stiLev6
+ "Heading 7", // stiLev7
+ "Heading 8", // stiLev8
+ "Heading 9", // stiLev9
+ "Index 1", // stiIndex1
+ "Index 2", // stiIndex2
+ "Index 3", // stiIndex3
+ "Index 4", // stiIndex4
+ "Index 5", // stiIndex5
+ "Index 6", // stiIndex6
+ "Index 7", // stiIndex7
+ "Index 8", // stiIndex8
+ "Index 9", // stiIndex9
+ "TOC 1", // stiToc1
+ "TOC 2", // stiToc2
+ "TOC 3", // stiToc3
+ "TOC 4", // stiToc4
+ "TOC 5", // stiToc5
+ "TOC 6", // stiToc6
+ "TOC 7", // stiToc7
+ "TOC 8", // stiToc8
+ "TOC 9", // stiToc9
+ "Normal Indent", // stiNormIndent
+ "Footnote Text", // stiFootnoteText
+ "Annotation Text", // stiAtnText
+ "Header", // stiHeader
+ "Footer", // stiFooter
+ "Index Heading", // stiIndexHeading
+ "Caption", // stiCaption
+ "Table of Figures", // stiToCaption
+ "Envelope Address", // stiEnvAddr
+ "Envelope Return", // stiEnvRet
+ "Footnote Reference", // stiFootnoteRef
+ "Annotation Reference", // stiAtnRef
+ "Line Number", // stiLnn
+ "Page Number", // stiPgn
+ "Endnote Reference", // stiEdnRef
+ "Endnote Text", // stiEdnText
+ "Table of Authorities", // stiToa
+ "Macro Text", // stiMacro
+ "TOC Heading", // stiToaHeading - tdf143726
+ "List", // stiList
+ "List Bullet", // stiListBullet
+ "List Number", // stiListNumber
+ "List 2", // stiList2
+ "List 3", // stiList3
+ "List 4", // stiList4
+ "List 5", // stiList5
+ "List Bullet 2", // stiListBullet2
+ "List Bullet 3", // stiListBullet3
+ "List Bullet 4", // stiListBullet4
+ "List Bullet 5", // stiListBullet5
+ "List Number 2", // stiListNumber2
+ "List Number 3", // stiListNumber3
+ "List Number 4", // stiListNumber4
+ "List Number 5", // stiListNumber5
+ "Title", // stiTitle
+ "Closing", // stiClosing
+ "Signature", // stiSignature
+ "Default Paragraph Font", // stiNormalChar
+ "Body Text", // stiBodyText
+ "Body Text Indent", // stiBodyTextInd1
+ "List Continue", // stiListCont
+ "List Continue 2", // stiListCont2
+ "List Continue 3", // stiListCont3
+ "List Continue 4", // stiListCont4
+ "List Continue 5", // stiListCont5
+ "Message Header", // stiMsgHeader
+ "Subtitle", // stiSubtitle
+ "Salutation", // stiSalutation
+ "Date", // stiDate
+ "Body Text First Indent", // stiBodyText1I
+ "Body Text First Indent 2", // stiBodyText1I2
+ "Note Heading", // stiNoteHeading
+ "Body Text 2", // stiBodyText2
+ "Body Text 3", // stiBodyText3
+ "Body Text Indent 2", // stiBodyTextInd2
+ "Body Text Indent 3", // stiBodyTextInd3
+ "Block Text", // stiBlockQuote
+ "Hyperlink", // stiHyperlink
+ "FollowedHyperlink", // stiHyperlinkFollowed
+ "Strong", // stiStrong
+ "Emphasis", // stiEmphasis
+ "Document Map", // stiNavPane
+ "Plain Text", // stiPlainText
};
- OSL_ENSURE( SAL_N_ELEMENTS(stiName) == ww::stiMax, "WrongSizeOfArray" );
+ static_assert(SAL_N_ELEMENTS(stiName) == ww::stiMax, "WrongSizeOfArray");
return stiName;
}
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index 7dc276264569..5db0319e2906 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -50,6 +50,7 @@
#include "types.hxx"
#include <svtools/embedhlp.hxx>
#include <numrule.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <IDocumentDrawModelAccess.hxx>
#include <IDocumentLayoutAccess.hxx>
@@ -109,43 +110,36 @@ namespace
{
ww8::Frames aRet;
- for(const auto& rpFly : rFlys)
+ for(const auto& rFly : rFlys)
{
- const SwFrameFormat &rEntry = rpFly->GetFormat();
+ const SwFrameFormat &rEntry = rFly.GetFormat();
- if (const SwPosition* pAnchor = rEntry.GetAnchor().GetContentAnchor())
+ if (const SwNode* pAnchor = rEntry.GetAnchor().GetAnchorNode())
{
// the anchor position will be invalidated by SetRedlineFlags
// so set a dummy position and fix it in UpdateFramePositions
- SwPosition const dummy(SwNodeIndex(
- const_cast<SwNodes&>(pAnchor->nNode.GetNodes())));
+ SwPosition const dummy(const_cast<SwNodes&>(pAnchor->GetNodes()));
aRet.emplace_back(rEntry, dummy);
}
else
{
- SwPosition aPos(rpFly->GetNdIndex());
-
- if (SwTextNode* pTextNd = aPos.nNode.GetNode().GetTextNode())
- {
- aPos.nContent.Assign(pTextNd, 0);
- }
-
+ SwPosition aPos(rFly.GetNode());
aRet.emplace_back(rEntry, aPos);
}
}
return aRet;
}
- //Utility to test if a frame is anchored at a given node index
+ //Utility to test if a frame is anchored at a given node
class anchoredto
{
private:
- sal_uLong mnNode;
+ const SwNode& mrNode;
public:
- explicit anchoredto(sal_uLong nNode) : mnNode(nNode) {}
+ explicit anchoredto(const SwNode& rNode) : mrNode(rNode) {}
bool operator()(const ww8::Frame &rFrame) const
{
- return (mnNode == rFrame.GetPosition().nNode.GetNode().GetIndex());
+ return (mrNode == rFrame.GetPosition().GetNode());
}
};
}
@@ -153,11 +147,9 @@ namespace
namespace ww8
{
//For i120928,size conversion before exporting graphic of bullet
- Frame::Frame(const Graphic &rGrf, const SwPosition &rPos)
+ Frame::Frame(const Graphic &rGrf, SwPosition aPos)
: mpFlyFrame(nullptr)
- , maPos(rPos)
- , maSize()
- , maLayoutSize()
+ , maPos(std::move(aPos))
, meWriterType(eBulletGrf)
, mpStartFrameContent(nullptr)
, mbIsInline(true)
@@ -178,18 +170,15 @@ namespace ww8
maLayoutSize = maSize;
}
- Frame::Frame(const SwFrameFormat &rFormat, const SwPosition &rPos)
+ Frame::Frame(const SwFrameFormat &rFormat, SwPosition aPos)
: mpFlyFrame(&rFormat)
- , maPos(rPos)
- , maSize()
- , maLayoutSize() // #i43447#
+ , maPos(std::move(aPos))
, meWriterType(eTextBox)
, mpStartFrameContent(nullptr)
// #i43447# - move to initialization list
, mbIsInline( (rFormat.GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR) )
// #i120928# - handle graphic of bullet within existing implementation
, mbForBullet(false)
- , maGrf()
{
switch (rFormat.Which())
{
@@ -270,7 +259,7 @@ namespace sw
{
sal_uInt16 nSlotId = rSrcPool.GetSlotId(nWhich);
if (IsValidSlotWhich(nSlotId, nWhich))
- nWhich = rDestPool.GetWhich(nSlotId);
+ nWhich = rDestPool.GetWhichIDFromSlotID(nSlotId);
else
nWhich = 0;
return nWhich;
@@ -279,7 +268,7 @@ namespace sw
sal_uInt16 GetSetWhichFromSwDocWhich(const SfxItemSet &rSet,
const SwDoc &rDoc, sal_uInt16 nWhich)
{
- if (RES_WHICHHINT_END < *(rSet.GetRanges()))
+ if (RES_WHICHHINT_END < rSet.GetRanges()[0].first)
{
nWhich = TransformWhichBetweenPools(*rSet.GetPool(),
rDoc.GetAttrPool(), nWhich);
@@ -396,7 +385,7 @@ namespace sw
for( sal_uInt16 nItem =0; nItem < nTotal; ++nItem )
{
const SfxPoolItem* pItem = nullptr;
- if( SfxItemState::SET == rSet.GetItemState( rSet.GetWhichByPos( nItem ), true, &pItem ) )
+ if( SfxItemState::SET == rSet.GetItemState( rSet.GetWhichByOffset( nItem ), true, &pItem ) )
{
rItems[pItem->Which()] = pItem;
}
@@ -412,6 +401,7 @@ namespace sw
while ((pItem = aIter.NextItem()));
}
}
+// DeduplicateItems(rItems);
}
const SfxPoolItem *SearchPoolItems(const ww8::PoolItems &rItems,
@@ -517,7 +507,7 @@ namespace sw
{
ww8::Frames aRet;
std::copy_if(rFrames.begin(), rFrames.end(),
- std::back_inserter(aRet), anchoredto(rNode.GetIndex()));
+ std::back_inserter(aRet), anchoredto(rNode));
return aRet;
}
@@ -594,10 +584,10 @@ namespace sw
const SwFrameFormat* pApply = rTable.GetFrameFormat();
OSL_ENSURE(pApply, "impossible");
if (pApply)
- pBreak = &(ItemGet<SvxFormatBreakItem>(*pApply, RES_BREAK));
+ pBreak = &pApply->GetFormatAttr(RES_BREAK);
}
else if (const SwContentNode *pNd = rNd.GetContentNode())
- pBreak = &(ItemGet<SvxFormatBreakItem>(*pNd, RES_BREAK));
+ pBreak = &pNd->GetAttr(RES_BREAK);
return pBreak && pBreak->GetBreak() == SvxBreak::PageBefore;
}
@@ -628,7 +618,7 @@ namespace sw
nPointCount = 0x0000ffff;
}
- tools::Polygon aRetval(static_cast<sal_uInt16>(nPointCount));
+ tools::Polygon aRetval(o3tl::narrowing<sal_uInt16>(nPointCount));
sal_uInt32 nAppendIndex(0);
for(a = 0; a < rPolyPoly.Count(); a++)
@@ -637,7 +627,7 @@ namespace sw
for(sal_uInt16 b(0); nAppendIndex <= nPointCount && b < rCandidate.GetSize(); b++)
{
- aRetval[static_cast<sal_uInt16>(nAppendIndex++)] = rCandidate[b];
+ aRetval[o3tl::narrowing<sal_uInt16>(nAppendIndex++)] = rCandidate[b];
}
}
@@ -713,8 +703,8 @@ namespace sw
bool operator()(const std::unique_ptr<SwFltStackEntry> & pEntry) const
{
const SwFltRedline *pTest = static_cast<const SwFltRedline *>
- (pEntry->pAttr.get());
- return (pEntry->bOpen && (pTest->eType == meType));
+ (pEntry->m_pAttr.get());
+ return (pEntry->m_bOpen && (pTest->m_eType == meType));
}
};
@@ -727,21 +717,21 @@ namespace sw
SameOpenRedlineType(eType));
if (aResult != maStack.rend())
{
- SwTextNode *const pNode(rPos.nNode.GetNode().GetTextNode());
- sal_Int32 const nIndex(rPos.nContent.GetIndex());
+ SwTextNode *const pNode(rPos.GetNode().GetTextNode());
+ sal_Int32 const nIndex(rPos.GetContentIndex());
// HACK to prevent overlap of field-mark and redline,
// which would destroy field-mark invariants when the redline
// is hidden: move the redline end one to the left
if (pNode && nIndex > 0
&& pNode->GetText()[nIndex - 1] == CH_TXT_ATR_FIELDEND)
{
- SwPosition const end(*rPos.nNode.GetNode().GetTextNode(),
+ SwPosition const end(*rPos.GetNode().GetTextNode(),
nIndex - 1);
sw::mark::IFieldmark *const pFieldMark(
rPos.GetDoc().getIDocumentMarkAccess()->getFieldmarkAt(end));
SAL_WARN_IF(!pFieldMark, "sw.ww8", "expected a field mark");
- if (pFieldMark && pFieldMark->GetMarkPos().nNode.GetIndex() == (*aResult)->m_aMkPos.m_nNode.GetIndex()+1
- && pFieldMark->GetMarkPos().nContent.GetIndex() < (*aResult)->m_aMkPos.m_nContent)
+ if (pFieldMark && pFieldMark->GetMarkPos().GetNodeIndex() == (*aResult)->m_aMkPos.m_nNode.GetIndex()+1
+ && pFieldMark->GetMarkPos().GetContentIndex() < (*aResult)->m_aMkPos.m_nContent)
{
(*aResult)->SetEndPos(end);
return true;
@@ -761,15 +751,15 @@ namespace sw
void MoveAttrFieldmarkInserted(SwFltPosition& rMkPos, SwFltPosition& rPtPos, const SwPosition& rPos)
{
sal_Int32 const nInserted = 2; // CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDSEP
- sal_uLong nPosNd = rPos.nNode.GetIndex();
- sal_Int32 nPosCt = rPos.nContent.GetIndex() - nInserted;
+ SwNodeOffset nPosNd = rPos.GetNodeIndex();
+ sal_Int32 nPosCt = rPos.GetContentIndex() - nInserted;
bool const isPoint(rMkPos == rPtPos);
if ((rMkPos.m_nNode.GetIndex()+1 == nPosNd) &&
(nPosCt <= rMkPos.m_nContent))
{
rMkPos.m_nContent += nInserted;
- SAL_WARN_IF(rMkPos.m_nContent > rPos.nNode.GetNodes()[nPosNd]->GetContentNode()->Len(),
+ SAL_WARN_IF(rMkPos.m_nContent > rPos.GetNodes()[nPosNd]->GetContentNode()->Len(),
"sw.ww8", "redline ends after end of line");
if (isPoint) // sigh ... important special case...
{
@@ -783,7 +773,7 @@ namespace sw
(nPosCt < rPtPos.m_nContent))
{
rPtPos.m_nContent += nInserted;
- SAL_WARN_IF(rPtPos.m_nContent > rPos.nNode.GetNodes()[nPosNd]->GetContentNode()->Len(),
+ SAL_WARN_IF(rPtPos.m_nContent > rPos.GetNodes()[nPosNd]->GetContentNode()->Len(),
"sw.ww8", "range ends after end of line");
}
}
@@ -800,7 +790,7 @@ namespace sw
void SetInDocAndDelete::operator()(std::unique_ptr<SwFltStackEntry>& pEntry)
{
SwPaM aRegion(pEntry->m_aMkPos.m_nNode);
- if (pEntry->MakeRegion(mrDoc, aRegion,
+ if (pEntry->MakeRegion(aRegion,
SwFltStackEntry::RegionMode::CheckNodes|SwFltStackEntry::RegionMode::CheckFieldmark) &&
(*aRegion.GetPoint() != *aRegion.GetMark())
)
@@ -808,16 +798,16 @@ namespace sw
mrDoc.getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowInsert |
RedlineFlags::ShowDelete);
const SwFltRedline *pFltRedline = static_cast<const SwFltRedline*>
- (pEntry->pAttr.get());
+ (pEntry->m_pAttr.get());
- SwRedlineData aData(pFltRedline->eType, pFltRedline->nAutorNo,
- pFltRedline->aStamp, OUString(), nullptr);
+ SwRedlineData aData(pFltRedline->m_eType, pFltRedline->m_nAutorNo,
+ pFltRedline->m_aStamp, 0, OUString(), nullptr);
SwRangeRedline *const pNewRedline(new SwRangeRedline(aData, aRegion));
// the point node may be deleted in AppendRedline, so park
// the PaM somewhere safe
aRegion.DeleteMark();
- *aRegion.GetPoint() = SwPosition(SwNodeIndex(mrDoc.GetNodes()));
+ aRegion.GetPoint()->Assign(*mrDoc.GetNodes()[SwNodeOffset(0)]);
mrDoc.getIDocumentRedlineAccess().AppendRedline(pNewRedline, true);
mrDoc.getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::NONE | RedlineFlags::ShowInsert |
RedlineFlags::ShowDelete );
@@ -829,24 +819,29 @@ namespace sw
const std::unique_ptr<SwFltStackEntry> & pTwoE) const
{
const SwFltRedline *pOne= static_cast<const SwFltRedline*>
- (pOneE->pAttr.get());
+ (pOneE->m_pAttr.get());
const SwFltRedline *pTwo= static_cast<const SwFltRedline*>
- (pTwoE->pAttr.get());
+ (pTwoE->m_pAttr.get());
//Return the earlier time, if two have the same time, prioritize
//inserts over deletes
- if (pOne->aStamp == pTwo->aStamp)
- return (pOne->eType == RedlineType::Insert && pTwo->eType != RedlineType::Insert);
+ if (pOne->m_aStamp == pTwo->m_aStamp)
+ return (pOne->m_eType == RedlineType::Insert && pTwo->m_eType != RedlineType::Insert);
else
- return (pOne->aStamp < pTwo->aStamp);
+ return (pOne->m_aStamp < pTwo->m_aStamp);
}
- RedlineStack::~RedlineStack()
+ void RedlineStack::ImplDestroy()
{
- std::sort(maStack.begin(), maStack.end(), CompareRedlines());
+ std::stable_sort(maStack.begin(), maStack.end(), CompareRedlines());
std::for_each(maStack.begin(), maStack.end(), SetInDocAndDelete(mrDoc));
}
+ RedlineStack::~RedlineStack()
+ {
+ suppress_fun_call_w_exception(ImplDestroy());
+ }
+
sal_uInt16 WrtRedlineAuthor::AddName( const OUString& rNm )
{
sal_uInt16 nRet;
@@ -898,7 +893,7 @@ namespace sw
if (pFrameFormat != nullptr)
{
- SwNodeIndex *pIndex = aTable.second;
+ SwPosition *pIndex = aTable.second;
pTable->DelFrames();
pTable->MakeOwnFrames(pIndex);
}
@@ -910,11 +905,11 @@ namespace sw
{
if (!mbHasRoot)
return;
- //Associate this tablenode with this after position, replace an //old
+ //Associate this tablenode with this after position, replace an old
//node association if necessary
maTables.emplace(
std::unique_ptr<InsertedTableListener>(new InsertedTableListener(rTableNode)),
- &(rPaM.GetPoint()->nNode));
+ rPaM.GetPoint());
}
}
diff --git a/sw/source/filter/ww8/writerhelper.hxx b/sw/source/filter/ww8/writerhelper.hxx
index 9ad16d0c2f14..632d1cb3a639 100644
--- a/sw/source/filter/ww8/writerhelper.hxx
+++ b/sw/source/filter/ww8/writerhelper.hxx
@@ -20,7 +20,6 @@
#ifndef INCLUDED_SW_SOURCE_FILTER_WW8_WRITERHELPER_HXX
#define INCLUDED_SW_SOURCE_FILTER_WW8_WRITERHELPER_HXX
-#include <typeinfo>
#include <vector>
#include <map>
#include <com/sun/star/embed/XEmbeddedObject.hpp>
@@ -29,7 +28,6 @@
#include <svl/itempool.hxx>
#include <svl/itemset.hxx>
#include <svx/svdtypes.hxx>
-#include <format.hxx>
#include <node.hxx>
#include <pam.hxx>
#include <tools/poly.hxx>
@@ -102,8 +100,8 @@ namespace ww8
bool mbForBullet:1;
Graphic maGrf;
public:
- Frame(const SwFrameFormat &rFlyFrame, const SwPosition &rPos);
- Frame(const Graphic&, const SwPosition &);
+ Frame(const SwFrameFormat &rFlyFrame, SwPosition aPos);
+ Frame(const Graphic&, SwPosition );
/** Get the writer SwFrameFormat that this object describes
@@ -126,7 +124,7 @@ namespace ww8
The SwTextNode this frame is anchored inside
*/
const SwContentNode *GetContentNode() const
- { return maPos.nNode.GetNode().GetContentNode(); }
+ { return maPos.GetNode().GetContentNode(); }
/** Get the type of frame that this wraps
@@ -224,8 +222,7 @@ namespace sw
*/
template<class T> const T & item_cast(const SfxPoolItem &rItem)
{
- if (dynamic_cast<const T *>(&rItem) == nullptr)
- throw std::bad_cast();
+ assert(dynamic_cast<const T *>(&rItem) && "bad type cast");
return static_cast<const T &>(rItem);
}
@@ -249,153 +246,6 @@ namespace sw
return dynamic_cast<const T *>(pItem);
}
- /** Extract a SfxPoolItem derived property from a SwContentNode
-
- Writer's attributes are retrieved by passing a numeric identifier
- and receiving a SfxPoolItem reference which must then typically be
- cast back to its original type which is both tedious and verbose.
-
- ItemGet uses item_cast () on the retrieved reference to test that the
- retrieved property is of the type that the developer thinks it is.
-
- @param rNode
- The SwContentNode to retrieve the property from
-
- @param eType
- The numeric identifier of the property to be retrieved
-
- @tplparam T
- A SfxPoolItem derived class of the retrieved property
-
- @exception std::bad_cast Thrown if the property was not a T
-
- @return The T requested
- */
- template<class T> const T & ItemGet(const SwContentNode &rNode,
- sal_uInt16 eType)
- {
- return item_cast<T>(rNode.GetAttr(eType));
- }
-
- /** Extract a SfxPoolItem derived property from a SwFormat
-
- Writer's attributes are retrieved by passing a numeric identifier
- and receiving a SfxPoolItem reference which must then typically be
- cast back to its original type which is both tedious and verbose.
-
- ItemGet uses item_cast () on the retrieved reference to test that the
- retrieved property is of the type that the developer thinks it is.
-
- @param rFormat
- The SwFormat to retrieve the property from
-
- @param eType
- The numeric identifier of the property to be retrieved
-
- @tplparam T
- A SfxPoolItem derived class of the retrieved property
-
- @exception std::bad_cast Thrown if the property was not a T
- */
- template<class T> const T & ItemGet(const SwFormat &rFormat,
- sal_uInt16 eType)
- {
- return item_cast<T>(rFormat.GetFormatAttr(eType));
- }
-
- /** Extract a SfxPoolItem derived property from a SfxItemSet
-
- Writer's attributes are retrieved by passing a numeric identifier
- and receiving a SfxPoolItem reference which must then typically be
- cast back to its original type which is both tedious and verbose.
-
- ItemGet uses item_cast () on the retrieved reference to test that the
- retrieved property is of the type that the developer thinks it is.
-
- @param rSet
- The SfxItemSet to retrieve the property from
-
- @param eType
- The numeric identifier of the property to be retrieved
-
- @tplparam T
- A SfxPoolItem derived class of the retrieved property
-
- @exception std::bad_cast Thrown if the property was not a T
-
- @return The T requested
- */
- template<class T> const T & ItemGet(const SfxItemSet &rSet,
- sal_uInt16 eType)
- {
- return item_cast<T>(rSet.Get(eType));
- }
-
- /** Extract a default SfxPoolItem derived property from a SfxItemPool
-
- Writer's attributes are retrieved by passing a numeric identifier
- and receiving a SfxPoolItem reference which must then typically be
- cast back to its original type which is both tedious and verbose.
-
- DefaultItemGet returns a reference to the default property of a
- given SfxItemPool for a given property id, e.g. default fontsize
-
- DefaultItemGet uses item_cast () on the retrieved reference to test
- that the retrieved property is of the type that the developer thinks
- it is.
-
- @param rPool
- The SfxItemPool whose default property we want
-
- @param eType
- The numeric identifier of the default property to be retrieved
-
- @tplparam T
- A SfxPoolItem derived class of the retrieved property
-
- @exception std::bad_cast Thrown if the property was not a T
-
- @return The T requested
- */
- template<class T> const T & DefaultItemGet(const SfxItemPool &rPool,
- sal_uInt16 eType)
- {
- return item_cast<T>(rPool.GetDefaultItem(eType));
- }
-
- /** Extract a default SfxPoolItem derived property from a SwDoc
-
- Writer's attributes are retrieved by passing a numeric identifier
- and receiving a SfxPoolItem reference which must then typically be
- cast back to its original type which is both tedious and verbose.
-
- DefaultItemGet returns a reference to the default property of a
- given SwDoc (Writer Document) for a given property id, e.g default
- fontsize
-
- DefaultItemGet uses item_cast () on the retrieved reference to test
- that the retrieved property is of the type that the developer thinks
- it is.
-
- @param rPool
- The SfxItemPool whose default property we want
-
- @param eType
- The numeric identifier of the default property to be retrieved
-
- @tplparam T
- A SfxPoolItem derived class of the retrieved property
-
- @exception std::bad_cast Thrown if the property was not a T
-
- @return The T requested
- */
- template<class T> const T & DefaultItemGet(const SwDoc &rDoc,
- sal_uInt16 eType)
- {
- return DefaultItemGet<T>(rDoc.GetAttrPool(), eType);
- }
-
/** Get the Paragraph Styles of a SwDoc
Writer's styles are in one of those dreaded macro based pre-STL
diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx
index ce38776ac52d..529100289737 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -25,8 +25,10 @@
#include <algorithm>
+#include <o3tl/string_view.hxx>
#include <rtl/tencinfo.h>
#include <sal/log.hxx>
+#include <svl/numformat.hxx>
#include <unicode/ubidi.h>
#include <tools/tenccvt.hxx>
@@ -69,8 +71,7 @@ namespace myImplHelpers
const SwFormatFrameSize& rSz = rFormat.GetFrameSize();
const SwHeaderAndFooterEatSpacingItem &rSpacingCtrl =
- sw::util::ItemGet<SwHeaderAndFooterEatSpacingItem>
- (rFormat, RES_HEADER_FOOTER_EAT_SPACING);
+ rFormat.GetFormatAttr(RES_HEADER_FOOTER_EAT_SPACING);
if (rSpacingCtrl.GetValue())
nDist += rSz.GetHeight();
else
@@ -241,16 +242,19 @@ namespace myImplHelpers
private:
MapperImpl<C> maHelper;
o3tl::sorted_vector<const C*> maUsedStyles;
- C* MakeNonCollidingStyle(const OUString& rName);
+ C* MakeNonCollidingStyle(const OUString& rName,
+ std::map<OUString, sal_Int32>& rCollisions);
public:
typedef std::pair<C*, bool> StyleResult;
explicit StyleMapperImpl(SwDoc &rDoc) : maHelper(rDoc) {}
- StyleResult GetStyle(const OUString& rName, ww::sti eSti);
+ StyleResult GetStyle(const OUString& rName, ww::sti eSti,
+ std::map<OUString, sal_Int32>& rCollisions);
};
template<class C>
typename StyleMapperImpl<C>::StyleResult
- StyleMapperImpl<C>::GetStyle(const OUString& rName, ww::sti eSti)
+ StyleMapperImpl<C>::GetStyle(const OUString& rName, ww::sti eSti,
+ std::map<OUString, sal_Int32>& rCollisions)
{
C *pRet = maHelper.GetBuiltInStyle(eSti);
@@ -275,7 +279,7 @@ namespace myImplHelpers
// No commas allow in SW style names
if (-1 != nIdx)
aName = rName.copy( 0, nIdx );
- pRet = MakeNonCollidingStyle( aName );
+ pRet = MakeNonCollidingStyle(aName, rCollisions);
}
if (pRet)
@@ -285,12 +289,13 @@ namespace myImplHelpers
}
template<class C>
- C* StyleMapperImpl<C>::MakeNonCollidingStyle(const OUString& rName)
+ C* StyleMapperImpl<C>::MakeNonCollidingStyle(const OUString& rName,
+ std::map<OUString, sal_Int32>& rCollisions)
{
OUString aName(rName);
- C* pColl = 0;
+ C* pColl = nullptr;
- if (0 != (pColl = maHelper.GetStyle(aName)))
+ if (nullptr != (pColl = maHelper.GetStyle(aName)))
{
//If the style collides first stick WW- in front of it, unless
//it already has it and then successively add a larger and
@@ -298,23 +303,32 @@ namespace myImplHelpers
if (!aName.startsWith("WW-"))
aName = "WW-" + aName;
- sal_Int32 nI = 1;
OUString aBaseName = aName;
+ sal_Int32 nI = 1;
+
+ // if we've seen this basename before then start at
+ // where we finished the last time
+ auto aFind = rCollisions.find(aBaseName);
+ if (aFind != rCollisions.end())
+ nI = aFind->second;
+
while (
- 0 != (pColl = maHelper.GetStyle(aName)) &&
+ nullptr != (pColl = maHelper.GetStyle(aName)) &&
(nI < SAL_MAX_INT32)
)
{
aName = aBaseName + OUString::number(nI++);
}
+
+ rCollisions.insert_or_assign(aBaseName, nI);
}
- return pColl ? 0 : maHelper.MakeStyle(aName);
+ return pColl ? nullptr : maHelper.MakeStyle(aName);
}
- static OUString FindBestMSSubstituteFont(const OUString &rFont)
+ static OUString FindBestMSSubstituteFont(std::u16string_view rFont)
{
- if (IsStarSymbol(rFont))
+ if (IsOpenSymbol(rFont))
return "Arial Unicode MS";
return GetSubsFontName(rFont, SubsFontFlags::ONLYONE | SubsFontFlags::MS);
}
@@ -396,26 +410,25 @@ namespace sw
{
if (const SvxBoxItem *pBox = rPage.GetItem<SvxBoxItem>(RES_BOX))
{
- dyaHdrTop = pBox->CalcLineSpace( SvxBoxItemLine::TOP, /*bEvenIfNoLine*/true );
- dyaHdrBottom = pBox->CalcLineSpace( SvxBoxItemLine::BOTTOM, /*bEvenIfNoLine*/true );
+ m_DyaHdrTop = pBox->CalcLineSpace( SvxBoxItemLine::TOP, /*bEvenIfNoLine*/true );
+ m_DyaHdrBottom = pBox->CalcLineSpace( SvxBoxItemLine::BOTTOM, /*bEvenIfNoLine*/true );
}
else
{
- dyaHdrTop = dyaHdrBottom = 0;
+ m_DyaHdrTop = m_DyaHdrBottom = 0;
}
- const SvxULSpaceItem &rUL =
- ItemGet<SvxULSpaceItem>(rPage, RES_UL_SPACE);
- dyaHdrTop += rUL.GetUpper();
- dyaHdrBottom += rUL.GetLower();
+ const SvxULSpaceItem &rUL = rPage.Get(RES_UL_SPACE);
+ m_DyaHdrTop += rUL.GetUpper();
+ m_DyaHdrBottom += rUL.GetLower();
- dyaTop = dyaHdrTop;
- dyaBottom = dyaHdrBottom;
+ m_DyaTop = m_DyaHdrTop;
+ m_DyaBottom = m_DyaHdrBottom;
const SwFormatHeader *pHd = rPage.GetItem<SwFormatHeader>(RES_HEADER);
if (pHd && pHd->IsActive() && pHd->GetHeaderFormat())
{
mbHasHeader = true;
- dyaTop = dyaTop + static_cast< sal_uInt16 >( (myImplHelpers::CalcHdDist(*(pHd->GetHeaderFormat()))) );
+ m_DyaTop = m_DyaTop + static_cast< sal_uInt16 >( (myImplHelpers::CalcHdDist(*(pHd->GetHeaderFormat()))) );
}
else
mbHasHeader = false;
@@ -424,7 +437,7 @@ namespace sw
if (pFt && pFt->IsActive() && pFt->GetFooterFormat())
{
mbHasFooter = true;
- dyaBottom = dyaBottom + static_cast< sal_uInt16 >( (myImplHelpers::CalcFtDist(*(pFt->GetFooterFormat()))) );
+ m_DyaBottom = m_DyaBottom + static_cast< sal_uInt16 >( (myImplHelpers::CalcFtDist(*(pFt->GetFooterFormat()))) );
}
else
mbHasFooter = false;
@@ -437,7 +450,7 @@ namespace sw
// both object don't have a header
if (HasHeader() == rOther.HasHeader())
{
- if (dyaTop != rOther.dyaTop)
+ if (m_DyaTop != rOther.m_DyaTop)
return false;
}
@@ -445,7 +458,7 @@ namespace sw
// both object don't have a footer
if (HasFooter() == rOther.HasFooter())
{
- if (dyaBottom != rOther.dyaBottom)
+ if (m_DyaBottom != rOther.m_DyaBottom)
return false;
}
@@ -462,9 +475,10 @@ namespace sw
}
ParaStyleMapper::StyleResult ParaStyleMapper::GetStyle(
- const OUString& rName, ww::sti eSti)
+ const OUString& rName, ww::sti eSti,
+ std::map<OUString, sal_Int32>& rCollisions)
{
- return mpImpl->GetStyle(rName, eSti);
+ return mpImpl->GetStyle(rName, eSti, rCollisions);
}
CharStyleMapper::CharStyleMapper(SwDoc &rDoc)
@@ -477,12 +491,13 @@ namespace sw
}
CharStyleMapper::StyleResult CharStyleMapper::GetStyle(
- const OUString& rName, ww::sti eSti)
+ const OUString& rName, ww::sti eSti,
+ std::map<OUString, sal_Int32>& rCollisions)
{
- return mpImpl->GetStyle(rName, eSti);
+ return mpImpl->GetStyle(rName, eSti, rCollisions);
}
- FontMapExport::FontMapExport(const OUString &rFamilyName)
+ FontMapExport::FontMapExport(std::u16string_view rFamilyName)
{
sal_Int32 nIndex = 0;
msPrimary = GetNextFontToken(rFamilyName, nIndex);
@@ -532,8 +547,8 @@ namespace sw
if (!rText.isEmpty())
nScript = g_pBreakIt->GetBreakIter()->getScriptType(rText, 0);
- rtl_TextEncoding eChrSet = ItemGet<SvxFontItem>(rTextNd,
- GetWhichOfScript(RES_CHRATR_FONT, nScript)).GetCharSet();
+ TypedWhichId<SvxFontItem> nFontWhichId = GetWhichOfScript(RES_CHRATR_FONT, nScript);
+ rtl_TextEncoding eChrSet = rTextNd.GetAttr(nFontWhichId).GetCharSet();
eChrSet = GetExtendedTextEncoding(eChrSet);
CharRuns aRunChanges;
@@ -640,8 +655,7 @@ namespace sw
}
}
- aRunChanges.erase(std::remove_if(aRunChanges.begin(),
- aRunChanges.end(), myImplHelpers::IfBeforeStart(0/*nTextStart*/)), aRunChanges.end());
+ std::erase_if(aRunChanges, myImplHelpers::IfBeforeStart(0/*nTextStart*/));
return aRunChanges;
}
@@ -748,14 +762,14 @@ namespace sw
/** Find cFind in rParams if not embedded in " double quotes.
Will NOT find '\\' or '"'.
*/
- static sal_Int32 findUnquoted( const OUString& rParams, sal_Unicode cFind, sal_Int32 nFromPos )
+ static sal_Int32 findUnquoted( std::u16string_view aParams, sal_Unicode cFind, sal_Int32 nFromPos )
{
- const sal_Int32 nLen = rParams.getLength();
+ const sal_Int32 nLen = aParams.size();
if (nFromPos < 0 || nLen <= nFromPos)
return -1;
for (sal_Int32 nI = nFromPos; nI < nLen; ++nI)
{
- const sal_Unicode c = rParams[nI];
+ const sal_Unicode c = aParams[nI];
if (c == '\\')
++nI;
else if (c == '\"')
@@ -764,7 +778,7 @@ namespace sw
// While not at the end and not at an unescaped end quote
while (nI < nLen)
{
- if (rParams[nI] == '\"' && rParams[nI-1] != '\\')
+ if (aParams[nI] == '\"' && aParams[nI-1] != '\\')
break;
++nI;
}
@@ -781,12 +795,12 @@ namespace sw
/** Find all rFind in rParams if not embedded in " double quotes and
replace with rReplace. Will NOT find '\\' or '"'.
*/
- static bool replaceUnquoted( OUString& rParams, const OUString& rFind, const OUString& rReplace )
+ static bool replaceUnquoted( OUString& rParams, std::u16string_view aFind, std::u16string_view aReplace )
{
bool bReplaced = false;
- if (rFind.isEmpty())
+ if (aFind.empty())
return bReplaced;
- const sal_Unicode cFirst = rFind[0];
+ const sal_Unicode cFirst = aFind[0];
sal_Int32 nLen = rParams.getLength();
for (sal_Int32 nI = 0; nI < nLen; ++nI)
@@ -807,11 +821,11 @@ namespace sw
}
else //normal unquoted section
{
- if (c == cFirst && rParams.match( rFind, nI))
+ if (c == cFirst && rParams.match( aFind, nI))
{
- const sal_Int32 nFindLen = rFind.getLength();
- const sal_Int32 nDiff = rReplace.getLength() - nFindLen;
- rParams = rParams.replaceAt( nI, nFindLen, rReplace);
+ const sal_Int32 nFindLen = aFind.size();
+ const sal_Int32 nDiff = aReplace.size() - nFindLen;
+ rParams = rParams.replaceAt( nI, nFindLen, aReplace);
nI += nFindLen + nDiff - 1;
nLen += nDiff;
bReplaced = true;
@@ -841,8 +855,8 @@ namespace sw
// effectively changes from Gengou to Gregorian calendar. Legacy
// because it wasn't supported a decade ago and now moot? Or is
// that a Word specialty?
- bForceJapanese |= replaceUnquoted( rParams, "ee", "yyyy");
- bForceJapanese |= replaceUnquoted( rParams, "EE", "YYYY");
+ bForceJapanese |= replaceUnquoted( rParams, u"ee", u"yyyy");
+ bForceJapanese |= replaceUnquoted( rParams, u"EE", u"YYYY");
if (LANGUAGE_FRENCH != nDocLang)
{
// Handle the 'a' case here
@@ -856,8 +870,8 @@ namespace sw
}
// Force to NatNum when finding one of 'oOA'
- bool bForceNatNum = replaceUnquoted( rParams, "o", "m")
- || replaceUnquoted( rParams, "O", "M");
+ bool bForceNatNum = replaceUnquoted( rParams, u"o", u"m")
+ || replaceUnquoted( rParams, u"O", u"M");
if (LANGUAGE_FRENCH != nDocLang)
{
// Handle the 'A' case here
@@ -868,7 +882,7 @@ namespace sw
bool bIsCharA = ( nPos != -1 && IsNotAM( rParams, nPos ) );
bForceNatNum |= bIsCharA;
if ( bIsCharA )
- rParams = rParams.replaceAt( nPos, 1, "D" );
+ rParams = rParams.replaceAt( nPos, 1, u"D" );
nLastPos = nPos;
} while ( -1 != nLastPos );
}
@@ -897,7 +911,7 @@ namespace sw
if ( nDocLang == LANGUAGE_FRENCH )
{
if ( ( nChar == 'a' || nChar == 'A' ) && IsNotAM(rParams, nI) )
- rParams = rParams.replaceAt(nI, 1, "Y");
+ rParams = rParams.replaceAt(nI, 1, u"Y");
}
if (nChar == '/')
{
@@ -905,7 +919,7 @@ namespace sw
// But not if it's a '/' inside AM/PM
if (!(IsPreviousAM(rParams, nI) && IsNextPM(rParams, nI)))
{
- rParams = rParams.replaceAt(nI, 1, "\\/");
+ rParams = rParams.replaceAt(nI, 1, u"\\/");
nLen++;
}
nI++;
@@ -921,13 +935,13 @@ namespace sw
if ( rLang == LANGUAGE_FINNISH )
{
if (nChar == 'y' || nChar == 'Y')
- rParams = rParams.replaceAt(nI, 1, "V");
+ rParams = rParams.replaceAt(nI, 1, u"V");
else if (nChar == 'm' || nChar == 'M')
- rParams = rParams.replaceAt(nI, 1, "K");
+ rParams = rParams.replaceAt(nI, 1, u"K");
else if (nChar == 'd' || nChar == 'D')
- rParams = rParams.replaceAt(nI, 1, "P");
+ rParams = rParams.replaceAt(nI, 1, u"P");
else if (nChar == 'h' || nChar == 'H')
- rParams = rParams.replaceAt(nI, 1, "T");
+ rParams = rParams.replaceAt(nI, 1, u"T");
}
else if ( rLang.anyOf(
LANGUAGE_DANISH,
@@ -938,7 +952,7 @@ namespace sw
LANGUAGE_SWEDISH_FINLAND))
{
if (nChar == 'h' || nChar == 'H')
- rParams = rParams.replaceAt(nI, 1, "T");
+ rParams = rParams.replaceAt(nI, 1, u"T");
}
else if ( rLang.anyOf(
LANGUAGE_PORTUGUESE,
@@ -965,31 +979,31 @@ namespace sw
LANGUAGE_SPANISH_PUERTO_RICO))
{
if (nChar == 'a' || nChar == 'A')
- rParams = rParams.replaceAt(nI, 1, "O");
+ rParams = rParams.replaceAt(nI, 1, u"O");
else if (nChar == 'y' || nChar == 'Y')
- rParams = rParams.replaceAt(nI, 1, "A");
+ rParams = rParams.replaceAt(nI, 1, u"A");
}
else if ( rLang.anyOf(
LANGUAGE_DUTCH,
LANGUAGE_DUTCH_BELGIAN))
{
if (nChar == 'y' || nChar == 'Y')
- rParams = rParams.replaceAt(nI, 1, "J");
+ rParams = rParams.replaceAt(nI, 1, u"J");
else if (nChar == 'u' || nChar == 'U')
- rParams = rParams.replaceAt(nI, 1, "H");
+ rParams = rParams.replaceAt(nI, 1, u"H");
}
else if ( rLang.anyOf(
LANGUAGE_ITALIAN,
LANGUAGE_ITALIAN_SWISS))
{
if (nChar == 'a' || nChar == 'A')
- rParams = rParams.replaceAt(nI, 1, "O");
+ rParams = rParams.replaceAt(nI, 1, u"O");
else if (nChar == 'g' || nChar == 'G')
- rParams = rParams.replaceAt(nI, 1, "X");
+ rParams = rParams.replaceAt(nI, 1, u"X");
else if (nChar == 'y' || nChar == 'Y')
- rParams = rParams.replaceAt(nI, 1, "A");
+ rParams = rParams.replaceAt(nI, 1, u"A");
else if (nChar == 'd' || nChar == 'D')
- rParams = rParams.replaceAt(nI, 1, "G");
+ rParams = rParams.replaceAt(nI, 1, u"G");
}
else if ( rLang.anyOf(
LANGUAGE_GERMAN,
@@ -999,9 +1013,9 @@ namespace sw
LANGUAGE_GERMAN_LIECHTENSTEIN))
{
if (nChar == 'y' || nChar == 'Y')
- rParams = rParams.replaceAt(nI, 1, "J");
+ rParams = rParams.replaceAt(nI, 1, u"J");
else if (nChar == 'd' || nChar == 'D')
- rParams = rParams.replaceAt(nI, 1, "T");
+ rParams = rParams.replaceAt(nI, 1, u"T");
}
else if ( rLang.anyOf(
LANGUAGE_FRENCH,
@@ -1012,9 +1026,9 @@ namespace sw
LANGUAGE_FRENCH_MONACO))
{
if (nChar == 'y' || nChar == 'Y' || nChar == 'a')
- rParams = rParams.replaceAt(nI, 1, "A");
+ rParams = rParams.replaceAt(nI, 1, u"A");
else if (nChar == 'd' || nChar == 'D' || nChar == 'j')
- rParams = rParams.replaceAt(nI, 1, "J");
+ rParams = rParams.replaceAt(nI, 1, u"J");
}
}
}
@@ -1037,18 +1051,18 @@ namespace sw
return nKey;
}
- bool IsPreviousAM(OUString const & rParams, sal_Int32 nPos)
+ bool IsPreviousAM(std::u16string_view rParams, sal_Int32 nPos)
{
- return nPos>=2 && rParams.matchIgnoreAsciiCase("am", nPos-2);
+ return nPos>=2 && o3tl::matchIgnoreAsciiCase(rParams, u"am", nPos-2);
}
- bool IsNextPM(OUString const & rParams, sal_Int32 nPos)
+ bool IsNextPM(std::u16string_view rParams, sal_Int32 nPos)
{
- return nPos+2<rParams.getLength() && rParams.matchIgnoreAsciiCase("pm", nPos+1);
+ return o3tl::make_unsigned(nPos+2)<rParams.size() && o3tl::matchIgnoreAsciiCase(rParams, u"pm", nPos+1);
}
- bool IsNotAM(OUString const & rParams, sal_Int32 nPos)
+ bool IsNotAM(std::u16string_view rParams, sal_Int32 nPos)
{
++nPos;
- return nPos>=rParams.getLength() || (rParams[nPos]!='M' && rParams[nPos]!='m');
+ return o3tl::make_unsigned(nPos)>=rParams.size() || (rParams[nPos]!='M' && rParams[nPos]!='m');
}
void SwapQuotesInField(OUString &rFormat)
@@ -1060,9 +1074,9 @@ namespace sw
if (!nI || rFormat[nI-1]!='\\')
{
if (rFormat[nI]=='\"')
- rFormat = rFormat.replaceAt(nI, 1, "\'");
+ rFormat = rFormat.replaceAt(nI, 1, u"\'");
else if (rFormat[nI]=='\'')
- rFormat = rFormat.replaceAt(nI, 1, "\"");
+ rFormat = rFormat.replaceAt(nI, 1, u"\"");
}
}
}
diff --git a/sw/source/filter/ww8/writerwordglue.hxx b/sw/source/filter/ww8/writerwordglue.hxx
index 3b532356602a..a6714e97276f 100644
--- a/sw/source/filter/ww8/writerwordglue.hxx
+++ b/sw/source/filter/ww8/writerwordglue.hxx
@@ -117,10 +117,10 @@ namespace sw
bool mbHasHeader;
bool mbHasFooter;
public:
- sal_uInt16 dyaHdrTop;
- sal_uInt16 dyaHdrBottom;
- sal_uInt16 dyaTop;
- sal_uInt16 dyaBottom;
+ sal_uInt16 m_DyaHdrTop;
+ sal_uInt16 m_DyaHdrBottom;
+ sal_uInt16 m_DyaTop;
+ sal_uInt16 m_DyaBottom;
explicit HdFtDistanceGlue(const SfxItemSet &rPage);
bool HasHeader() const { return mbHasHeader; }
bool HasFooter() const { return mbHasFooter; }
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index e65161558edb..c13d06106286 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -22,6 +22,7 @@
#include <hintids.hxx>
+#include <officecfg/Office/Common.hxx>
#include <o3tl/any.hxx>
#include <com/sun/star/drawing/XShape.hpp>
#include <vcl/svapp.hxx>
@@ -32,6 +33,7 @@
#include <svx/svdobj.hxx>
#include <svx/svdotext.hxx>
#include <svx/svdpage.hxx>
+#include <editeng/colritem.hxx>
#include <editeng/outlobj.hxx>
#include <editeng/editobj.hxx>
#include <editeng/brushitem.hxx>
@@ -45,9 +47,7 @@
#include <editeng/eeitem.hxx>
#include <editeng/formatbreakitem.hxx>
#include <svx/svdouno.hxx>
-#include <svx/unoapi.hxx>
#include <svx/svdview.hxx>
-#include <svx/unopage.hxx>
#include <fmtcnct.hxx>
#include <fmtanchr.hxx>
#include <fmtsrnd.hxx>
@@ -86,7 +86,6 @@
#include <fmturl.hxx>
#include <frameformats.hxx>
#include <sfx2/sfxsids.hrc>
-#include <unotools/saveopt.hxx>
#include <o3tl/enumrange.hxx>
#include <o3tl/enumarray.hxx>
#include <sfx2/docfile.hxx>
@@ -97,33 +96,29 @@
using ::editeng::SvxBorderLine;
using namespace com::sun::star;
using namespace sw::util;
-using namespace sw::types;
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::drawing::XShape;
bool SwBasicEscherEx::IsRelUrl() const
{
- SvtSaveOptions aSaveOpt;
bool bRelUrl = false;
- SfxMedium * pMedium = rWrt.GetWriter().GetMedia();
+ SfxMedium * pMedium = mrWrt.GetWriter().GetMedia();
if ( pMedium )
- bRelUrl = pMedium->IsRemote() ? aSaveOpt.IsSaveRelINet() : aSaveOpt.IsSaveRelFSys();
+ bRelUrl = pMedium->IsRemote()
+ ? officecfg::Office::Common::Save::URL::Internet::get()
+ : officecfg::Office::Common::Save::URL::FileSystem::get();
return bRelUrl;
}
OUString SwBasicEscherEx::GetBasePath() const
{
OUString sDocUrl;
- SfxMedium * pMedium = rWrt.GetWriter().GetMedia();
+ SfxMedium * pMedium = mrWrt.GetWriter().GetMedia();
if (pMedium)
{
- const SfxItemSet* pPItemSet = pMedium->GetItemSet();
- if( pPItemSet )
- {
- const SfxStringItem* pPItem = dynamic_cast< const SfxStringItem* >( pPItemSet->GetItem( SID_FILE_NAME ) );
- if ( pPItem )
- sDocUrl = pPItem->GetValue();
- }
+ const SfxStringItem* pPItem = pMedium->GetItemSet().GetItem( SID_FILE_NAME );
+ if ( pPItem )
+ sDocUrl = pPItem->GetValue();
}
return sDocUrl.copy(0, sDocUrl.lastIndexOf('/') + 1);
@@ -274,12 +269,8 @@ void SwBasicEscherEx::WriteHyperlinkWithinFly( SvMemoryStream& rStrm, const SwFo
}
void SwBasicEscherEx::PreWriteHyperlinkWithinFly(const SwFrameFormat& rFormat,EscherPropertyContainer& rPropOpt)
{
- const SfxPoolItem* pItem;
const SwAttrSet& rAttrSet = rFormat.GetAttrSet();
- if (SfxItemState::SET != rAttrSet.GetItemState(RES_URL, true, &pItem))
- return;
-
- const SwFormatURL *pINetFormat = dynamic_cast<const SwFormatURL*>(pItem);
+ const SwFormatURL* pINetFormat = rAttrSet.GetItemIfSet(RES_URL);
if (!pINetFormat || pINetFormat->GetURL().isEmpty())
return;
@@ -317,14 +308,14 @@ namespace
class CompareDrawObjs
{
private:
- const WW8Export& wrt;
+ const WW8Export& m_rWrt;
public:
- explicit CompareDrawObjs(const WW8Export& rWrt) : wrt(rWrt) {};
+ explicit CompareDrawObjs(const WW8Export& rWrt) : m_rWrt(rWrt) {};
bool operator()(DrawObj const *a, DrawObj const *b) const
{
- sal_uLong aSort = lcl_getSdrOrderNumber(wrt, a);
- sal_uLong bSort = lcl_getSdrOrderNumber(wrt, b);
+ sal_uLong aSort = lcl_getSdrOrderNumber(m_rWrt, a);
+ sal_uLong bSort = lcl_getSdrOrderNumber(m_rWrt, b);
return aSort < bSort;
}
};
@@ -431,7 +422,7 @@ void WW8Export::DoComboBox(const OUString &rName,
OutputField(nullptr, ww::eFORMDROPDOWN, FieldString(ww::eFORMDROPDOWN),
FieldFlags::Start | FieldFlags::CmdStart);
// write the reference to the "picture" structure
- sal_uLong nDataStt = pDataStrm->Tell();
+ sal_uInt64 nDataStt = m_pDataStrm->Tell();
m_pChpPlc->AppendFkpEntry( Strm().Tell() );
WriteChar( 0x01 );
@@ -467,7 +458,7 @@ void WW8Export::DoComboBox(const OUString &rName,
aFFData.addListboxEntry(rListItems[i]);
}
- aFFData.Write(pDataStrm);
+ aFFData.Write(m_pDataStrm);
}
void WW8Export::DoFormText(const SwInputField * pField)
@@ -475,7 +466,7 @@ void WW8Export::DoFormText(const SwInputField * pField)
OutputField(nullptr, ww::eFORMTEXT, FieldString(ww::eFORMTEXT),
FieldFlags::Start | FieldFlags::CmdStart);
// write the reference to the "picture" structure
- sal_uLong nDataStt = pDataStrm->Tell();
+ sal_uInt64 nDataStt = m_pDataStrm->Tell();
m_pChpPlc->AppendFkpEntry( Strm().Tell() );
WriteChar( 0x01 );
@@ -498,7 +489,7 @@ void WW8Export::DoFormText(const SwInputField * pField)
aFFData.setName(pField->GetPar2());
aFFData.setHelp(pField->GetHelp());
aFFData.setStatus(pField->GetToolTip());
- aFFData.Write(pDataStrm);
+ aFFData.Write(m_pDataStrm);
OutputField(nullptr, ww::eFORMTEXT, OUString(), FieldFlags::CmdEnd);
@@ -615,22 +606,22 @@ void WW8Export::MiserableRTLFrameFormatHack(SwTwips &rLeft, SwTwips &rRight,
void PlcDrawObj::WritePlc( WW8Export& rWrt ) const
{
- if (8 > rWrt.pFib->m_nVersion) // Cannot export drawobject in vers 7-
+ if (8 > rWrt.m_pFib->m_nVersion) // Cannot export drawobject in vers 7-
return;
- sal_uInt32 nFcStart = rWrt.pTableStrm->Tell();
+ sal_uInt32 nFcStart = rWrt.m_pTableStrm->Tell();
if (maDrawObjs.empty())
return;
// write CPs
- WW8Fib& rFib = *rWrt.pFib;
+ WW8Fib& rFib = *rWrt.m_pFib;
WW8_CP nCpOffs = GetCpOffset(rFib);
for (const auto& rDrawObj : maDrawObjs)
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, rDrawObj.mnCp - nCpOffs);
+ SwWW8Writer::WriteLong(*rWrt.m_pTableStrm, rDrawObj.mnCp - nCpOffs);
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, rFib.m_ccpText + rFib.m_ccpFootnote +
+ SwWW8Writer::WriteLong(*rWrt.m_pTableStrm, rFib.m_ccpText + rFib.m_ccpFootnote +
rFib.m_ccpHdr + rFib.m_ccpEdn + rFib.m_ccpTxbx + rFib.m_ccpHdrTxbx + 1);
for (const auto& rDrawObj : maDrawObjs)
@@ -678,11 +669,11 @@ void PlcDrawObj::WritePlc( WW8Export& rWrt ) const
// rotating to vertical means swapping height and width as seen in SvxMSDffManager::ImportShape
const Degree100 nAngle = NormAngle36000( pObj->GetRotateAngle() );
- const bool bAllowSwap = pObj->GetObjIdentifier() != OBJ_LINE && pObj->GetObjIdentifier() != OBJ_GRUP;
+ const bool bAllowSwap = pObj->GetObjIdentifier() != SdrObjKind::Line && pObj->GetObjIdentifier() != SdrObjKind::Group;
if ( bAllowSwap && (( nAngle > 4500_deg100 && nAngle <= 13500_deg100 ) || ( nAngle > 22500_deg100 && nAngle <= 31500_deg100 )) )
{
- const tools::Long nWidth = aRect.getWidth();
- const tools::Long nHeight = aRect.getHeight();
+ const tools::Long nWidth = aRect.getOpenWidth();
+ const tools::Long nHeight = aRect.getOpenHeight();
aRect.setWidth( nHeight );
aRect.setHeight( nWidth );
bHasHeightWidthSwapped = true;
@@ -726,7 +717,7 @@ void PlcDrawObj::WritePlc( WW8Export& rWrt ) const
}
// spid
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, rDrawObj.mnShapeId);
+ SwWW8Writer::WriteLong(*rWrt.m_pTableStrm, rDrawObj.mnShapeId);
SwTwips nLeft = aRect.Left() + nThick;
SwTwips nRight = aRect.Right() - nThick;
@@ -754,10 +745,10 @@ void PlcDrawObj::WritePlc( WW8Export& rWrt ) const
{
SwTwips nXOff;
SwTwips nYOff;
- SwTwips nSnapWidth = pObj->GetSnapRect().getWidth();
- SwTwips nSnapHeight = pObj->GetSnapRect().getHeight();
- SwTwips nLogicWidth = pObj->GetLogicRect().getWidth();
- SwTwips nLogicHeight = pObj->GetLogicRect().getHeight();
+ SwTwips nSnapWidth = pObj->GetSnapRect().getOpenWidth();
+ SwTwips nSnapHeight = pObj->GetSnapRect().getOpenHeight();
+ SwTwips nLogicWidth = pObj->GetLogicRect().getOpenWidth();
+ SwTwips nLogicHeight = pObj->GetLogicRect().getOpenHeight();
// +1 for to compensate integer arithmetic rounding errors
if(bHasHeightWidthSwapped)
{
@@ -778,10 +769,10 @@ void PlcDrawObj::WritePlc( WW8Export& rWrt ) const
//xaLeft/yaTop/xaRight/yaBottom - rel. to anchor
//(most of) the border is outside the graphic is word, so
//change dimensions to fit
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, nLeft);
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, nTop);
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, nRight);
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, nBottom);
+ SwWW8Writer::WriteLong(*rWrt.m_pTableStrm, nLeft);
+ SwWW8Writer::WriteLong(*rWrt.m_pTableStrm, nTop);
+ SwWW8Writer::WriteLong(*rWrt.m_pTableStrm, nRight);
+ SwWW8Writer::WriteLong(*rWrt.m_pTableStrm, nBottom);
//fHdr/bx/by/wr/wrk/fRcaSimple/fBelowText/fAnchorLock
sal_uInt16 nFlags=0;
@@ -841,13 +832,13 @@ void PlcDrawObj::WritePlc( WW8Export& rWrt ) const
if (rFrameFormat.IsInline())
nFlags |= 0x8000;
- SwWW8Writer::WriteShort(*rWrt.pTableStrm, nFlags);
+ SwWW8Writer::WriteShort(*rWrt.m_pTableStrm, nFlags);
// cTxbx
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, 0);
+ SwWW8Writer::WriteLong(*rWrt.m_pTableStrm, 0);
}
- RegisterWithFib(rFib, nFcStart, rWrt.pTableStrm->Tell() - nFcStart);
+ RegisterWithFib(rFib, nFcStart, rWrt.m_pTableStrm->Tell() - nFcStart);
}
void MainTextPlcDrawObj::RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
@@ -909,15 +900,15 @@ void DrawObj::SetShapeDetails(sal_uInt32 nId, sal_Int32 nThick)
bool WW8_WrPlcTextBoxes::WriteText( WW8Export& rWrt )
{
rWrt.m_bInWriteEscher = true;
- WW8_CP& rccp=TXT_TXTBOX == nTyp ? rWrt.pFib->m_ccpTxbx : rWrt.pFib->m_ccpHdrTxbx;
+ WW8_CP& rccp=TXT_TXTBOX == m_nTyp ? rWrt.m_pFib->m_ccpTxbx : rWrt.m_pFib->m_ccpHdrTxbx;
- bool bRet = WriteGenericText( rWrt, nTyp, rccp );
+ bool bRet = WriteGenericText( rWrt, m_nTyp, rccp );
WW8_CP nCP = rWrt.Fc2Cp( rWrt.Strm().Tell() );
- WW8Fib& rFib = *rWrt.pFib;
+ WW8Fib& rFib = *rWrt.m_pFib;
WW8_CP nMyOffset = rFib.m_ccpText + rFib.m_ccpFootnote + rFib.m_ccpHdr + rFib.m_ccpAtn
+ rFib.m_ccpEdn;
- if( TXT_TXTBOX == nTyp )
+ if( TXT_TXTBOX == m_nTyp )
rWrt.m_pFieldTextBxs->Finish( nCP, nMyOffset );
else
rWrt.m_pFieldHFTextBxs->Finish( nCP, nMyOffset + rFib.m_ccpTxbx );
@@ -927,23 +918,23 @@ bool WW8_WrPlcTextBoxes::WriteText( WW8Export& rWrt )
void WW8_WrPlcTextBoxes::Append( const SdrObject& rObj, sal_uInt32 nShapeId )
{
- aContent.push_back( &rObj );
- aShapeIds.push_back( nShapeId );
+ m_aContent.push_back( &rObj );
+ m_aShapeIds.push_back( nShapeId );
//save NULL, if we have an actual SdrObject
- aSpareFormats.push_back(nullptr);
+ m_aSpareFormats.push_back(nullptr);
}
void WW8_WrPlcTextBoxes::Append( const SwFrameFormat* pFormat, sal_uInt32 nShapeId )
{
//no sdr object, we insert a NULL in the aContent and save the real fmt in aSpareFormats.
- aContent.push_back( nullptr );
- aShapeIds.push_back( nShapeId );
- aSpareFormats.push_back(pFormat);
+ m_aContent.push_back( nullptr );
+ m_aShapeIds.push_back( nShapeId );
+ m_aSpareFormats.push_back(pFormat);
}
const std::vector<sal_uInt32>* WW8_WrPlcTextBoxes::GetShapeIdArr() const
{
- return &aShapeIds;
+ return &m_aShapeIds;
}
sal_uInt32 WW8Export::GetSdrOrdNum( const SwFrameFormat& rFormat ) const
@@ -957,7 +948,7 @@ sal_uInt32 WW8Export::GetSdrOrdNum( const SwFrameFormat& rFormat ) const
// no Layout for this format, then recalc the ordnum
SwFrameFormat* pFormat = const_cast<SwFrameFormat*>(&rFormat);
nOrdNum = std::distance(m_rDoc.GetSpzFrameFormats()->begin(),
- m_rDoc.GetSpzFrameFormats()->find( pFormat ) );
+ m_rDoc.GetSpzFrameFormats()->find(static_cast<sw::SpzFrameFormat*>(pFormat)));
const SwDrawModel* pModel = m_rDoc.getIDocumentDrawModelAccess().GetDrawModel();
if( pModel )
@@ -974,9 +965,9 @@ void WW8Export::AppendFlyInFlys(const ww8::Frame& rFrameFormat,
return ;
PlcDrawObj *pDrwO;
if (TXT_HDFT == m_nTextTyp)
- pDrwO = m_pHFSdrObjs;
+ pDrwO = m_pHFSdrObjs.get();
else
- pDrwO = m_pSdrObjs;
+ pDrwO = m_pSdrObjs.get();
if (rFrameFormat.IsInline())
{
@@ -1014,43 +1005,43 @@ void WW8Export::AppendFlyInFlys(const ww8::Frame& rFrameFormat,
MSWord_SdrAttrIter::MSWord_SdrAttrIter( MSWordExportBase& rWr,
const EditTextObject& rEditObj, sal_uInt8 nTyp )
- : MSWordAttrIter( rWr ), pEditObj(&rEditObj), pEditPool(nullptr), mnTyp(nTyp)
+ : MSWordAttrIter( rWr ), m_pEditObj(&rEditObj), m_pEditPool(nullptr), mnTyp(nTyp)
{
NextPara( 0 );
}
void MSWord_SdrAttrIter::NextPara( sal_Int32 nPar )
{
- nPara = nPar;
+ m_nPara = nPar;
// Ignore change of attribute at position 0, because we expect that
// the attributes are outputted at start of a paragraph anyway.
- aChrTextAtrArr.clear();
- aChrSetArr.clear();
- nCurrentSwPos = nTmpSwPos = 0;
+ m_aChrTextAtrArr.clear();
+ m_aChrSetArr.clear();
+ m_nCurrentSwPos = m_nTmpSwPos = 0;
- SfxItemSet aSet( pEditObj->GetParaAttribs( nPara ));
- pEditPool = aSet.GetPool();
- eNdChrSet = ItemGet<SvxFontItem>(aSet,EE_CHAR_FONTINFO).GetCharSet();
+ SfxItemSet aSet( m_pEditObj->GetParaAttribs( m_nPara ));
+ m_pEditPool = aSet.GetPool();
+ m_eNdChrSet = aSet.Get(EE_CHAR_FONTINFO).GetCharSet();
assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
- nScript = g_pBreakIt->GetBreakIter()->getScriptType( pEditObj->GetText(nPara), 0);
+ m_nScript = g_pBreakIt->GetBreakIter()->getScriptType( m_pEditObj->GetText(m_nPara), 0);
- pEditObj->GetCharAttribs( nPara, aTextAtrArr );
- nCurrentSwPos = SearchNext( 1 );
+ m_pEditObj->GetCharAttribs( m_nPara, m_aTextAtrArr );
+ m_nCurrentSwPos = SearchNext( 1 );
}
rtl_TextEncoding MSWord_SdrAttrIter::GetNextCharSet() const
{
- if( !aChrSetArr.empty() )
- return aChrSetArr.back();
- return eNdChrSet;
+ if( !m_aChrSetArr.empty() )
+ return m_aChrSetArr.back();
+ return m_eNdChrSet;
}
// the first parameter in SearchNext() returns if it's a TextAtr
sal_Int32 MSWord_SdrAttrIter::SearchNext( sal_Int32 nStartPos )
{
sal_Int32 nMinPos = SAL_MAX_INT32;
- for(const auto& rTextAtr : aTextAtrArr)
+ for(const auto& rTextAtr : m_aTextAtrArr)
{
sal_Int32 nPos = rTextAtr.nStart; // first character attribute
if( nPos >= nStartPos && nPos <= nMinPos )
@@ -1080,17 +1071,17 @@ void MSWord_SdrAttrIter::SetCharSet(const EECharAttrib& rAttr, bool bStart)
if( bStart )
{
rtl_TextEncoding eChrSet = static_cast<const SvxFontItem&>(rItem).GetCharSet();
- aChrSetArr.push_back( eChrSet );
- aChrTextAtrArr.push_back( &rAttr );
+ m_aChrSetArr.push_back( eChrSet );
+ m_aChrTextAtrArr.push_back( &rAttr );
}
else
{
std::vector<const EECharAttrib*>::iterator it =
- std::find( aChrTextAtrArr.begin(), aChrTextAtrArr.end(), &rAttr );
- if ( it != aChrTextAtrArr.end() )
+ std::find( m_aChrTextAtrArr.begin(), m_aChrTextAtrArr.end(), &rAttr );
+ if ( it != m_aChrTextAtrArr.end() )
{
- aChrSetArr.erase( aChrSetArr.begin() + (it - aChrTextAtrArr.begin()) );
- aChrTextAtrArr.erase( it );
+ m_aChrSetArr.erase( m_aChrSetArr.begin() + (it - m_aChrTextAtrArr.begin()) );
+ m_aChrTextAtrArr.erase( it );
}
}
}
@@ -1121,7 +1112,7 @@ void MSWord_SdrAttrIter::OutAttr( sal_Int32 nSwPos )
//duplicate attributes in docx export. Doesn't matter in doc
//export as later props just override earlier ones.
std::set<sal_uInt16> aUsedRunWhichs;
- for(const auto& rTextAtr : aTextAtrArr)
+ for(const auto& rTextAtr : m_aTextAtrArr)
{
if (nSwPos >= rTextAtr.nStart && nSwPos < rTextAtr.nEnd)
{
@@ -1135,19 +1126,19 @@ void MSWord_SdrAttrIter::OutAttr( sal_Int32 nSwPos )
OutParaAttr(true, &aUsedRunWhichs);
- if (aTextAtrArr.empty())
+ if (m_aTextAtrArr.empty())
return;
const sw::BroadcastingModify* pOldMod = m_rExport.m_pOutFormatNode;
m_rExport.m_pOutFormatNode = nullptr;
- const SfxItemPool* pSrcPool = pEditPool;
+ const SfxItemPool* pSrcPool = m_pEditPool;
const SfxItemPool& rDstPool = m_rExport.m_rDoc.GetAttrPool();
- nTmpSwPos = nSwPos;
+ m_nTmpSwPos = nSwPos;
// Did we already produce a <w:sz> element?
m_rExport.m_bFontSizeWritten = false;
- for(const auto& rTextAtr : aTextAtrArr)
+ for(const auto& rTextAtr : m_aTextAtrArr)
{
if (nSwPos >= rTextAtr.nStart && nSwPos < rTextAtr.nEnd)
{
@@ -1162,14 +1153,20 @@ void MSWord_SdrAttrIter::OutAttr( sal_Int32 nSwPos )
m_rExport.WriteChar(0x9);
continue;
}
+ if (nWhich == EE_CHAR_BKGCOLOR)
+ {
+ Color aColor(static_cast<const SvxColorItem*>(rTextAtr.pAttr)->GetValue());
+ m_rExport.AttrOutput().OutputItem(SvxBrushItem(aColor, RES_CHRATR_BACKGROUND));
+ continue;
+ }
const sal_uInt16 nSlotId = pSrcPool->GetSlotId(nWhich);
if (nSlotId && nWhich != nSlotId)
{
- nWhich = rDstPool.GetWhich(nSlotId);
+ nWhich = rDstPool.GetWhichIDFromSlotID(nSlotId);
if (nWhich && nWhich != nSlotId &&
nWhich < RES_UNKNOWNATR_BEGIN &&
- m_rExport.CollapseScriptsforWordOk(nScript,nWhich))
+ m_rExport.CollapseScriptsforWordOk(m_nScript,nWhich))
{
// use always the SW-Which Id !
std::unique_ptr<SfxPoolItem> pI(rTextAtr.pAttr->Clone());
@@ -1189,13 +1186,13 @@ void MSWord_SdrAttrIter::OutAttr( sal_Int32 nSwPos )
}
m_rExport.m_bFontSizeWritten = false;
- nTmpSwPos = 0; // HasTextItem only allowed in the above area
+ m_nTmpSwPos = 0; // HasTextItem only allowed in the above area
m_rExport.m_pOutFormatNode = pOldMod;
}
bool MSWord_SdrAttrIter::IsTextAttr(sal_Int32 nSwPos)
{
- return std::any_of(aTextAtrArr.begin(), aTextAtrArr.end(),
+ return std::any_of(m_aTextAtrArr.begin(), m_aTextAtrArr.end(),
[nSwPos](const EECharAttrib& rTextAtr) {
return (nSwPos >= rTextAtr.nStart && nSwPos < rTextAtr.nEnd) &&
(rTextAtr.pAttr->Which() == EE_FEATURE_FIELD ||
@@ -1211,15 +1208,15 @@ bool MSWord_SdrAttrIter::IsTextAttr(sal_Int32 nSwPos)
// The search is done with bDeep.
const SfxPoolItem* MSWord_SdrAttrIter::HasTextItem(sal_uInt16 nWhich) const
{
- nWhich = sw::hack::TransformWhichBetweenPools(*pEditPool,
+ nWhich = sw::hack::TransformWhichBetweenPools(*m_pEditPool,
m_rExport.m_rDoc.GetAttrPool(), nWhich);
if (nWhich)
{
- for (const auto& rTextAtr : aTextAtrArr)
+ for (const auto& rTextAtr : m_aTextAtrArr)
{
- if (nWhich == rTextAtr.pAttr->Which() && nTmpSwPos >= rTextAtr.nStart && nTmpSwPos < rTextAtr.nEnd)
+ if (nWhich == rTextAtr.pAttr->Which() && m_nTmpSwPos >= rTextAtr.nStart && m_nTmpSwPos < rTextAtr.nEnd)
return rTextAtr.pAttr; // Found
- if (nTmpSwPos < rTextAtr.nStart)
+ if (m_nTmpSwPos < rTextAtr.nStart)
return nullptr;
}
}
@@ -1232,7 +1229,7 @@ const SfxPoolItem& MSWord_SdrAttrIter::GetItem( sal_uInt16 nWhich ) const
const SfxPoolItem* pRet = HasTextItem(nWhich);
if (!pRet)
{
- SfxItemSet aSet(pEditObj->GetParaAttribs(nPara));
+ SfxItemSet aSet(m_pEditObj->GetParaAttribs(m_nPara));
nWhich = GetSetWhichFromSwDocWhich(aSet, m_rExport.m_rDoc, nWhich);
OSL_ENSURE(nWhich, "Impossible, catastrophic failure imminent");
pRet = &aSet.Get(nWhich);
@@ -1251,10 +1248,10 @@ void MSWord_SdrAttrIter::SetItemsThatDifferFromStandard(bool bCharAttr, SfxItemS
SfxWhichIter aWhichIter(rSet);
for (sal_uInt16 nEEWhich = aWhichIter.FirstWhich(); nEEWhich; nEEWhich = aWhichIter.NextWhich())
{
- if (SfxItemState::SET != rSet.GetItemState(nEEWhich, false))
+ if (SfxItemState::SET != aWhichIter.GetItemState(false))
{
sal_uInt16 nSwWhich = sw::hack::TransformWhichBetweenPools(m_rExport.m_rDoc.GetAttrPool(),
- *pEditPool, nEEWhich);
+ *m_pEditPool, nEEWhich);
if (!nSwWhich)
continue;
bool bWanted = ( bCharAttr ? ( nSwWhich >= RES_CHRATR_BEGIN && nSwWhich < RES_TXTATR_END )
@@ -1272,7 +1269,7 @@ void MSWord_SdrAttrIter::SetItemsThatDifferFromStandard(bool bCharAttr, SfxItemS
void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr, const std::set<sal_uInt16>* pWhichsToIgnore)
{
- SfxItemSet aSet( pEditObj->GetParaAttribs( nPara ));
+ SfxItemSet aSet( m_pEditObj->GetParaAttribs( m_nPara ));
SetItemsThatDifferFromStandard(bCharAttr, aSet);
@@ -1285,7 +1282,7 @@ void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr, const std::set<sal_uInt16>*
SfxItemIter aIter( aSet );
const SfxPoolItem* pItem = aIter.GetCurItem();
- const SfxItemPool* pSrcPool = pEditPool,
+ const SfxItemPool* pSrcPool = m_pEditPool,
* pDstPool = &m_rExport.m_rDoc.GetAttrPool();
do
@@ -1297,7 +1294,7 @@ void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr, const std::set<sal_uInt16>*
sal_uInt16 nSlotId = pSrcPool->GetSlotId(nWhich);
if ( nSlotId && nWhich != nSlotId &&
- 0 != ( nWhich = pDstPool->GetWhich( nSlotId ) ) &&
+ 0 != ( nWhich = pDstPool->GetWhichIDFromSlotID( nSlotId ) ) &&
nWhich != nSlotId &&
( bCharAttr ? ( nWhich >= RES_CHRATR_BEGIN && nWhich < RES_TXTATR_END )
: ( nWhich >= RES_PARATR_BEGIN && nWhich < RES_FRMATR_END ) ) )
@@ -1305,7 +1302,7 @@ void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr, const std::set<sal_uInt16>*
// use always the SW-Which Id !
std::unique_ptr<SfxPoolItem> pI(pItem->Clone());
pI->SetWhich( nWhich );
- if (m_rExport.CollapseScriptsforWordOk(nScript,nWhich))
+ if (m_rExport.CollapseScriptsforWordOk(m_nScript,nWhich))
m_rExport.AttrOutput().OutputItem(*pI);
}
} while ((pItem = aIter.NextItem()));
@@ -1314,8 +1311,7 @@ void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr, const std::set<sal_uInt16>*
void WW8Export::WriteSdrTextObj(const SdrTextObj& rTextObj, sal_uInt8 nTyp)
{
- const OutlinerParaObject* pParaObj = nullptr;
- bool bOwnParaObj = false;
+ std::optional<OutlinerParaObject> pParaObj;
/*
#i13885#
@@ -1324,19 +1320,16 @@ void WW8Export::WriteSdrTextObj(const SdrTextObj& rTextObj, sal_uInt8 nTyp)
*/
if (rTextObj.IsTextEditActive())
{
- pParaObj = rTextObj.CreateEditOutlinerParaObject().release();
- bOwnParaObj = true;
+ pParaObj = rTextObj.CreateEditOutlinerParaObject();
}
- else
+ else if (rTextObj.GetOutlinerParaObject())
{
- pParaObj = rTextObj.GetOutlinerParaObject();
+ pParaObj = *rTextObj.GetOutlinerParaObject();
}
if( pParaObj )
{
WriteOutliner(*pParaObj, nTyp);
- if( bOwnParaObj )
- delete pParaObj;
}
}
@@ -1353,7 +1346,7 @@ void WW8Export::WriteOutliner(const OutlinerParaObject& rParaObj, sal_uInt8 nTyp
if( n )
aAttrIter.NextPara( n );
- OSL_ENSURE( pO->empty(), " pO is not empty at start of line" );
+ OSL_ENSURE( m_pO->empty(), " pO is not empty at start of line" );
OUString aStr( rEditObj.GetText( n ));
sal_Int32 nCurrentPos = 0;
@@ -1361,10 +1354,9 @@ void WW8Export::WriteOutliner(const OutlinerParaObject& rParaObj, sal_uInt8 nTyp
const SfxItemSet& aSet(rEditObj.GetParaAttribs(n));
bool bIsRTLPara = false;
- const SfxPoolItem *pItem;
- if(SfxItemState::SET == aSet.GetItemState(EE_PARA_WRITINGDIR, true, &pItem))
+ if(const SvxFrameDirectionItem* pItem = aSet.GetItemIfSet(EE_PARA_WRITINGDIR))
{
- SvxFrameDirection nDir = static_cast<const SvxFrameDirectionItem*>(pItem)->GetValue();
+ SvxFrameDirection nDir = pItem->GetValue();
bIsRTLPara = SvxFrameDirection::Horizontal_RL_TB == nDir;
}
@@ -1394,8 +1386,8 @@ void WW8Export::WriteOutliner(const OutlinerParaObject& rParaObj, sal_uInt8 nTyp
}
m_pChpPlc->AppendFkpEntry( Strm().Tell(),
- pO->size(), pO->data() );
- pO->clear();
+ m_pO->size(), m_pO->data() );
+ m_pO->clear();
// exception: foot note at line end
if( nNextAttr == nEnd && bTextAtr )
@@ -1405,17 +1397,17 @@ void WW8Export::WriteOutliner(const OutlinerParaObject& rParaObj, sal_uInt8 nTyp
}
while( nCurrentPos < nEnd );
- OSL_ENSURE( pO->empty(), " pO is not empty at start of line" );
+ OSL_ENSURE( m_pO->empty(), " pO is not empty at start of line" );
- pO->push_back( bNul ); // Style # as short
- pO->push_back( bNul );
+ m_pO->push_back( bNul ); // Style # as short
+ m_pO->push_back( bNul );
aAttrIter.OutParaAttr(false);
- sal_uLong nPos = Strm().Tell();
+ sal_uInt64 nPos = Strm().Tell();
m_pPapPlc->AppendFkpEntry( Strm().Tell(),
- pO->size(), pO->data() );
- pO->clear();
+ m_pO->size(), m_pO->data() );
+ m_pO->clear();
m_pChpPlc->AppendFkpEntry( nPos );
}
@@ -1433,9 +1425,11 @@ void WinwordAnchoring::WriteData( EscherEx& rEx ) const
SvStream& rSt = rEx.GetStream();
//The last argument denotes the number of sub properties in this atom
+ int nSubProps = mnGroupShapeBooleanProperties ? 1 : 0;
if (mbInline)
{
- rEx.AddAtom(18, DFF_msofbtUDefProp, 3, 3); //Prop id is 0xF122
+ nSubProps += 3;
+ rEx.AddAtom(6 * nSubProps, DFF_msofbtUDefProp, 3, nSubProps); // Prop id is 0xF122
rSt.WriteUInt16( 0x0390 ).WriteUInt32( 3 );
rSt.WriteUInt16( 0x0392 ).WriteUInt32( 3 );
//This sub property is required to be in the dummy inline frame as
@@ -1444,12 +1438,15 @@ void WinwordAnchoring::WriteData( EscherEx& rEx ) const
}
else
{
- rEx.AddAtom(24, DFF_msofbtUDefProp, 3, 4 ); //Prop id is 0xF122
+ nSubProps += 4;
+ rEx.AddAtom(6 * nSubProps, DFF_msofbtUDefProp, 3, nSubProps); // Prop id is 0xF122
rSt.WriteUInt16( 0x038F ).WriteUInt32( mnXAlign );
rSt.WriteUInt16( 0x0390 ).WriteUInt32( mnXRelTo );
rSt.WriteUInt16( 0x0391 ).WriteUInt32( mnYAlign );
rSt.WriteUInt16( 0x0392 ).WriteUInt32( mnYRelTo );
}
+ if (mnGroupShapeBooleanProperties)
+ rSt.WriteUInt16(0x03BF).WriteUInt32(mnGroupShapeBooleanProperties);
}
void WW8Export::CreateEscher()
@@ -1469,13 +1466,13 @@ void WW8Export::WriteEscher()
{
if (m_pEscher)
{
- sal_uLong nStart = pTableStrm->Tell();
+ sal_uInt64 nStart = m_pTableStrm->Tell();
m_pEscher->WritePictures();
m_pEscher->FinishEscher();
- pFib->m_fcDggInfo = nStart;
- pFib->m_lcbDggInfo = pTableStrm->Tell() - nStart;
+ m_pFib->m_fcDggInfo = nStart;
+ m_pFib->m_lcbDggInfo = m_pTableStrm->Tell() - nStart;
delete m_pEscher;
m_pEscher = nullptr;
}
@@ -1486,11 +1483,11 @@ void SwEscherEx::WritePictures()
if( SvStream* pPicStrm = static_cast< SwEscherExGlobal& >( *mxGlobal ).GetPictureStream() )
{
// set the blip - entries to the correct stream pos
- sal_Int32 nEndPos = rWrt.Strm().Tell();
+ sal_uInt64 nEndPos = mrWrt.Strm().Tell();
mxGlobal->SetNewBlipStreamOffset( nEndPos );
pPicStrm->Seek( 0 );
- rWrt.Strm().WriteStream( *pPicStrm );
+ mrWrt.Strm().WriteStream( *pPicStrm );
}
Flush();
}
@@ -1514,7 +1511,7 @@ SvStream* SwEscherExGlobal::ImplQueryPictureStream()
}
SwBasicEscherEx::SwBasicEscherEx(SvStream* pStrm, WW8Export& rWW8Wrt)
- : EscherEx( std::make_shared<SwEscherExGlobal>(), pStrm), rWrt(rWW8Wrt), pEscherStrm(pStrm)
+ : EscherEx( std::make_shared<SwEscherExGlobal>(), pStrm), mrWrt(rWW8Wrt), mpEscherStrm(pStrm)
{
Init();
}
@@ -1588,7 +1585,7 @@ void SwBasicEscherEx::WriteGrfBullet(const Graphic& rGrf)
aPropOpt.AddOpt( ESCHER_Prop_dxTextRight, 0 );
const Color aTmpColor( COL_WHITE );
std::shared_ptr<SvxBrushItem> aBrush(std::make_shared<SvxBrushItem>(aTmpColor, RES_BACKGROUND));
- const SvxBrushItem* pRet = rWrt.GetCurrentPageBgBrush();
+ const SvxBrushItem* pRet = mrWrt.GetCurrentPageBgBrush();
if (pRet && (pRet->GetGraphic() ||( pRet->GetColor() != COL_TRANSPARENT)))
aBrush.reset(pRet->Clone());
WriteBrushAttr(*aBrush, aPropOpt);
@@ -1663,27 +1660,23 @@ sal_Int32 SwBasicEscherEx::WriteGrfFlyFrame(const SwFrameFormat& rFormat, sal_uI
void SwBasicEscherEx::WriteGrfAttr(const SwNoTextNode& rNd, const SwFrameFormat& rFormat,
EscherPropertyContainer& rPropOpt)
{
- const SfxPoolItem* pItem;
GraphicDrawMode nMode = GraphicDrawMode::Standard;
sal_Int32 nContrast = 0;
sal_Int16 nBrightness = 0;
- if (SfxItemState::SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_CONTRAST,
- true, &pItem))
+ if (const SfxInt16Item* pItem = rNd.GetSwAttrSet().GetItemIfSet(RES_GRFATR_CONTRAST))
{
- nContrast = static_cast<const SfxInt16Item*>(pItem)->GetValue();
+ nContrast = pItem->GetValue();
}
- if (SfxItemState::SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_LUMINANCE,
- true, &pItem))
+ if (const SfxInt16Item* pItem = rNd.GetSwAttrSet().GetItemIfSet(RES_GRFATR_LUMINANCE))
{
- nBrightness = static_cast<const SfxInt16Item*>(pItem)->GetValue();
+ nBrightness = pItem->GetValue();
}
- if (SfxItemState::SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_DRAWMODE,
- true, &pItem))
+ if (const SfxEnumItemInterface* pItem = rNd.GetSwAttrSet().GetItemIfSet(RES_GRFATR_DRAWMODE))
{
- nMode = static_cast<GraphicDrawMode>(static_cast<const SfxEnumItemInterface*>(pItem)->GetEnumValue());
+ nMode = static_cast<GraphicDrawMode>(pItem->GetEnumValue());
if (nMode == GraphicDrawMode::Watermark)
{
/*
@@ -1736,24 +1729,21 @@ void SwBasicEscherEx::WriteGrfAttr(const SwNoTextNode& rNd, const SwFrameFormat&
sal_Int32 nCropR = 0;
sal_Int32 nCropT = 0;
sal_Int32 nCropB = 0;
- if (SfxItemState::SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_CROPGRF,
- true, &pItem))
+ if (const SwCropGrf* pCropItem = rNd.GetSwAttrSet().GetItemIfSet(RES_GRFATR_CROPGRF))
{
- const SwCropGrf& rCrop = *static_cast<const SwCropGrf*>(pItem);
- nCropL += rCrop.GetLeft();
- nCropR += rCrop.GetRight();
- nCropT += rCrop.GetTop();
- nCropB += rCrop.GetBottom();
+ nCropL += pCropItem->GetLeft();
+ nCropR += pCropItem->GetRight();
+ nCropT += pCropItem->GetTop();
+ nCropB += pCropItem->GetBottom();
}
// simulate border padding as a negative crop.
- if (SfxItemState::SET == rFormat.GetItemState(RES_BOX, false, &pItem))
+ if (const SvxBoxItem* pBoxItem = rFormat.GetItemIfSet(RES_BOX, false))
{
- const SvxBoxItem& rBox = *static_cast<const SvxBoxItem*>(pItem);
- nCropL -= rBox.GetDistance( SvxBoxItemLine::LEFT );
- nCropR -= rBox.GetDistance( SvxBoxItemLine::RIGHT );
- nCropT -= rBox.GetDistance( SvxBoxItemLine::TOP );
- nCropB -= rBox.GetDistance( SvxBoxItemLine::BOTTOM );
+ nCropL -= pBoxItem->GetDistance( SvxBoxItemLine::LEFT );
+ nCropR -= pBoxItem->GetDistance( SvxBoxItemLine::RIGHT );
+ nCropT -= pBoxItem->GetDistance( SvxBoxItemLine::TOP );
+ nCropB -= pBoxItem->GetDistance( SvxBoxItemLine::BOTTOM );
}
const Size aSz( rNd.GetTwipSize() );
@@ -1775,8 +1765,8 @@ void SwBasicEscherEx::SetPicId(const SdrObject &, sal_uInt32,
void SwEscherEx::SetPicId(const SdrObject &rSdrObj, sal_uInt32 nShapeId,
EscherPropertyContainer &rPropOpt)
{
- pTextBxs->Append(rSdrObj, nShapeId);
- sal_uInt32 nPicId = pTextBxs->Count();
+ m_pTextBxs->Append(rSdrObj, nShapeId);
+ sal_uInt32 nPicId = m_pTextBxs->Count();
nPicId *= 0x10000;
rPropOpt.AddOpt( ESCHER_Prop_pictureId, nPicId );
}
@@ -1858,8 +1848,9 @@ void SwBasicEscherEx::WriteBrushAttr(const SvxBrushItem &rBrush,
nOpaque = 255 - pGraphicObject->GetAttr().GetAlpha();
if (0 != nOpaque)
bSetOpacity = true;
-
- rPropOpt.AddOpt( ESCHER_Prop_fillType, ESCHER_FillPicture );
+ const ESCHER_FillStyle eFillType
+ = rBrush.GetGraphicPos() == GPOS_TILED ? ESCHER_FillTexture : ESCHER_FillPicture;
+ rPropOpt.AddOpt(ESCHER_Prop_fillType, eFillType);
rPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x140014 );
rPropOpt.AddOpt( ESCHER_Prop_fillBackColor, 0 );
}
@@ -1887,20 +1878,19 @@ sal_Int32 SwBasicEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat,
MSO_SPT eShapeType, EscherPropertyContainer& rPropOpt)
{
sal_Int32 nLineWidth=0;
- const SfxPoolItem* pItem;
bool bFirstLine = true;
- if (SfxItemState::SET == rFormat.GetItemState(RES_BOX, true, &pItem))
+ if (const SvxBoxItem* pItem = rFormat.GetItemIfSet(RES_BOX))
{
static const o3tl::enumarray<SvxBoxItemLine, sal_uInt16> aExhperProp =
{
- ESCHER_Prop_dyTextTop, ESCHER_Prop_dyTextBottom,
- ESCHER_Prop_dxTextLeft, ESCHER_Prop_dxTextRight
+ sal_uInt16(ESCHER_Prop_dyTextTop), sal_uInt16(ESCHER_Prop_dyTextBottom),
+ sal_uInt16(ESCHER_Prop_dxTextLeft), sal_uInt16(ESCHER_Prop_dxTextRight)
};
const SvxBorderLine* pLine;
for( SvxBoxItemLine n : o3tl::enumrange<SvxBoxItemLine>() )
{
- pLine = static_cast<const SvxBoxItem*>(pItem)->GetLine( n );
+ pLine = pItem->GetLine( n );
if( nullptr != pLine )
{
if( bFirstLine )
@@ -1956,10 +1946,10 @@ sal_Int32 SwBasicEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat,
bFirstLine = false;
}
rPropOpt.AddOpt( aExhperProp[ n ], DrawModelToEmu(
- static_cast<const SvxBoxItem*>(pItem)->GetDistance( n ) ));
+ pItem->GetDistance( n ) ));
}
else
- rPropOpt.AddOpt( aExhperProp[ n ], DrawModelToEmu(static_cast<const SvxBoxItem*>(pItem)->GetDistance( n )) );
+ rPropOpt.AddOpt( aExhperProp[ n ], DrawModelToEmu(pItem->GetDistance( n )) );
}
}
else
@@ -1975,57 +1965,49 @@ sal_Int32 SwBasicEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat,
rPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
}
const SwAttrSet& rAttrSet = rFormat.GetAttrSet();
- if (SfxItemState::SET == rAttrSet.GetItemState(RES_BOX, false, &pItem))
+ if (rAttrSet.GetItemIfSet(RES_BOX, false))
{
- const SvxBoxItem* pBox = static_cast<const SvxBoxItem*>(pItem);
- if( pBox )
+ if (const SvxShadowItem* pSI =rAttrSet.GetItemIfSet(RES_SHADOW))
{
- const SfxPoolItem* pShadItem;
- if (SfxItemState::SET
- == rAttrSet.GetItemState(RES_SHADOW, true, &pShadItem))
- {
- const SvxShadowItem* pSI = static_cast<const SvxShadowItem*>(pShadItem);
+ constexpr sal_uInt32 nShadowType = 131074; // shadow type of ms word. need to set the default value.
- constexpr sal_uInt32 nShadowType = 131074; // shadow type of ms word. need to set the default value.
+ Color nColor = pSI->GetColor();
+ sal_Int32 nOffX
+ = o3tl::convert(pSI->GetWidth(), o3tl::Length::twip, o3tl::Length::emu);
+ sal_Int32 nOffY
+ = o3tl::convert(pSI->GetWidth(), o3tl::Length::twip, o3tl::Length::emu);
- Color nColor = pSI->GetColor();
- sal_Int32 nOffX
- = o3tl::convert(pSI->GetWidth(), o3tl::Length::twip, o3tl::Length::emu);
- sal_Int32 nOffY
- = o3tl::convert(pSI->GetWidth(), o3tl::Length::twip, o3tl::Length::emu);
-
- SvxShadowLocation eLocation = pSI->GetLocation();
- if( (eLocation!=SvxShadowLocation::NONE) && (pSI->GetWidth()!=0) )
+ SvxShadowLocation eLocation = pSI->GetLocation();
+ if( (eLocation!=SvxShadowLocation::NONE) && (pSI->GetWidth()!=0) )
+ {
+ switch( eLocation )
{
- switch( eLocation )
+ case SvxShadowLocation::TopLeft:
{
- case SvxShadowLocation::TopLeft:
- {
- nOffX = -nOffX;
- nOffY = -nOffY;
- }
- break;
- case SvxShadowLocation::TopRight:
- {
- nOffY = -nOffY;
- }
- break;
- case SvxShadowLocation::BottomLeft:
- {
- nOffX = -nOffX;
- }
- break;
- case SvxShadowLocation::BottomRight:
- break;
- default:
- break;
+ nOffX = -nOffX;
+ nOffY = -nOffY;
}
-
- rPropOpt.AddOpt( DFF_Prop_shadowColor, wwUtility::RGBToBGR(nColor));
- rPropOpt.AddOpt( DFF_Prop_shadowOffsetX, nOffX );
- rPropOpt.AddOpt( DFF_Prop_shadowOffsetY, nOffY );
- rPropOpt.AddOpt( DFF_Prop_fshadowObscured, nShadowType );
+ break;
+ case SvxShadowLocation::TopRight:
+ {
+ nOffY = -nOffY;
+ }
+ break;
+ case SvxShadowLocation::BottomLeft:
+ {
+ nOffX = -nOffX;
+ }
+ break;
+ case SvxShadowLocation::BottomRight:
+ break;
+ default:
+ break;
}
+
+ rPropOpt.AddOpt( DFF_Prop_shadowColor, wwUtility::RGBToBGR(nColor));
+ rPropOpt.AddOpt( DFF_Prop_shadowOffsetX, nOffX );
+ rPropOpt.AddOpt( DFF_Prop_shadowOffsetY, nOffY );
+ rPropOpt.AddOpt( DFF_Prop_fshadowObscured, nShadowType );
}
}
}
@@ -2040,16 +2022,12 @@ sal_Int32 SwBasicEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat,
if (bIsInHeader || bIsThrough)
{
std::unique_ptr<SvxBrushItem> aBrush(rFormat.makeBackgroundBrushItem());
-
- if(aBrush)
- {
- WriteBrushAttr(*aBrush, rPropOpt);
- }
+ WriteBrushAttr(*aBrush, rPropOpt);
}
else
{
// for unknown reasons, force exporting a non-transparent background on fly frames.
- std::shared_ptr<SvxBrushItem> aBrush(rWrt.TrueFrameBgBrush(rFormat));
+ std::shared_ptr<SvxBrushItem> aBrush(mrWrt.TrueFrameBgBrush(rFormat));
if(aBrush)
{
@@ -2082,13 +2060,12 @@ sal_Int32 SwEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat, MSO_SPT eS
way, perhaps we should actually draw in this space into the graphic we
are exporting!
*/
- const SfxPoolItem* pItem;
- if (SfxItemState::SET == rFormat.GetItemState(RES_LR_SPACE, true, &pItem))
+ if (const SvxLRSpaceItem* pItem = rFormat.GetItemIfSet(RES_LR_SPACE))
{
rPropOpt.AddOpt( ESCHER_Prop_dxWrapDistLeft,
- DrawModelToEmu( static_cast<const SvxLRSpaceItem*>(pItem)->GetLeft() ) );
+ DrawModelToEmu( pItem->GetLeft() ) );
rPropOpt.AddOpt( ESCHER_Prop_dxWrapDistRight,
- DrawModelToEmu( static_cast<const SvxLRSpaceItem*>(pItem)->GetRight() ) );
+ DrawModelToEmu( pItem->GetRight() ) );
}
else
{
@@ -2096,12 +2073,12 @@ sal_Int32 SwEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat, MSO_SPT eS
rPropOpt.AddOpt( ESCHER_Prop_dxWrapDistRight, 0 );
}
- if (SfxItemState::SET == rFormat.GetItemState(RES_UL_SPACE, true, &pItem))
+ if (const SvxULSpaceItem* pItem = rFormat.GetItemIfSet(RES_UL_SPACE))
{
rPropOpt.AddOpt( ESCHER_Prop_dyWrapDistTop,
- DrawModelToEmu( static_cast<const SvxULSpaceItem*>(pItem)->GetUpper() ) );
+ DrawModelToEmu( pItem->GetUpper() ) );
rPropOpt.AddOpt( ESCHER_Prop_dyWrapDistBottom,
- DrawModelToEmu( static_cast<const SvxULSpaceItem*>(pItem)->GetLower() ) );
+ DrawModelToEmu( pItem->GetLower() ) );
}
if (rFormat.GetSurround().IsContour())
@@ -2138,7 +2115,7 @@ sal_Int32 SwEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat, MSO_SPT eS
void SwBasicEscherEx::Init()
{
MapUnit eMap = MapUnit::MapTwip;
- if (SwDrawModel *pModel = rWrt.m_rDoc.getIDocumentDrawModelAccess().GetDrawModel())
+ if (SwDrawModel *pModel = mrWrt.m_rDoc.getIDocumentDrawModelAccess().GetDrawModel())
{
// PPT works only with units of 576DPI
// WW however is using twips, i.e 1440DPI.
@@ -2151,7 +2128,7 @@ void SwBasicEscherEx::Init()
mnEmuMul = aFact.GetNumerator();
mnEmuDiv = aFact.GetDenominator();
- SetHellLayerId(rWrt.m_rDoc.getIDocumentDrawModelAccess().GetHellId());
+ SetHellLayerId(mrWrt.m_rDoc.getIDocumentDrawModelAccess().GetHellId());
}
sal_Int32 SwBasicEscherEx::ToFract16(sal_Int32 nVal, sal_uInt32 nMax)
@@ -2177,7 +2154,7 @@ sal_Int32 SwBasicEscherEx::ToFract16(sal_Int32 nVal, sal_uInt32 nMax)
SdrLayerID SwBasicEscherEx::GetInvisibleHellId() const
{
- return rWrt.m_rDoc.getIDocumentDrawModelAccess().GetInvisibleHellId();
+ return mrWrt.m_rDoc.getIDocumentDrawModelAccess().GetInvisibleHellId();
}
void SwBasicEscherEx::WritePictures()
@@ -2185,19 +2162,19 @@ void SwBasicEscherEx::WritePictures()
if( SvStream* pPicStrm = static_cast< SwEscherExGlobal& >( *mxGlobal ).GetPictureStream() )
{
// set the blip - entries to the correct stream pos
- sal_Int32 nEndPos = pPicStrm->Tell();
- mxGlobal->WriteBlibStoreEntry(*pEscherStrm, 1, nEndPos);
+ sal_uInt64 nEndPos = pPicStrm->Tell();
+ mxGlobal->WriteBlibStoreEntry(*mpEscherStrm, 1, nEndPos);
pPicStrm->Seek(0);
- pEscherStrm->WriteStream( *pPicStrm );
+ mpEscherStrm->WriteStream( *pPicStrm );
}
}
SwEscherEx::SwEscherEx(SvStream* pStrm, WW8Export& rWW8Wrt)
: SwBasicEscherEx(pStrm, rWW8Wrt),
- pTextBxs(nullptr)
+ m_pTextBxs(nullptr)
{
- aHostData.SetClientData(&aWinwordAnchoring);
+ m_aHostData.SetClientData(&m_aWinwordAnchoring);
OpenContainer( ESCHER_DggContainer );
sal_uInt16 nColorCount = 4;
@@ -2212,18 +2189,18 @@ SwEscherEx::SwEscherEx(SvStream* pStrm, WW8Export& rWW8Wrt)
CloseContainer(); // ESCHER_DggContainer
sal_uInt8 i = 2; // for header/footer and the other
- PlcDrawObj *pSdrObjs = rWrt.m_pHFSdrObjs;
- pTextBxs = rWrt.m_pHFTextBxs;
+ PlcDrawObj *pSdrObjs = mrWrt.m_pHFSdrObjs.get();
+ m_pTextBxs = mrWrt.m_pHFTextBxs.get();
// if no header/footer -> skip over
if (!pSdrObjs->size())
{
--i;
- pSdrObjs = rWrt.m_pSdrObjs;
- pTextBxs = rWrt.m_pTextBxs;
+ pSdrObjs = mrWrt.m_pSdrObjs.get();
+ m_pTextBxs = mrWrt.m_pTextBxs.get();
}
- for( ; i--; pSdrObjs = rWrt.m_pSdrObjs, pTextBxs = rWrt.m_pTextBxs )
+ for( ; i--; pSdrObjs = mrWrt.m_pSdrObjs.get(), m_pTextBxs = mrWrt.m_pTextBxs.get() )
{
// "dummy char" (or any Count ?) - why? Only Microsoft knows it.
GetStream().WriteChar( i );
@@ -2232,7 +2209,7 @@ SwEscherEx::SwEscherEx(SvStream* pStrm, WW8Export& rWW8Wrt)
EnterGroup();
- sal_uLong nSecondShapeId = pSdrObjs == rWrt.m_pSdrObjs ? GenerateShapeId() : 0;
+ sal_uLong nSecondShapeId = pSdrObjs == mrWrt.m_pSdrObjs.get() ? GenerateShapeId() : 0;
// write now all Writer-/DrawObjects
DrawObjPointerVector aSorted;
@@ -2261,7 +2238,7 @@ SwEscherEx::SwEscherEx(SvStream* pStrm, WW8Export& rWW8Wrt)
break;
case ww8::Frame::eDrawing:
{
- aWinwordAnchoring.SetAnchoring(rFormat);
+ m_aWinwordAnchoring.SetAnchoring(rFormat);
const SdrObject* pSdrObj = rFormat.FindRealSdrObject();
if (pSdrObj)
{
@@ -2296,13 +2273,9 @@ SwEscherEx::SwEscherEx(SvStream* pStrm, WW8Export& rWW8Wrt)
nSecondShapeId );
EscherPropertyContainer aPropOpt;
- const SwFrameFormat &rFormat = rWrt.m_rDoc.GetPageDesc(0).GetMaster();
- const SfxPoolItem* pItem = nullptr;
- SfxItemState eState = rFormat.GetItemState(RES_BACKGROUND, true,
- &pItem);
- if (SfxItemState::SET == eState && pItem)
+ const SwFrameFormat &rFormat = mrWrt.m_rDoc.GetPageDesc(0).GetMaster();
+ if (const SvxBrushItem* pBrush = rFormat.GetItemIfSet(RES_BACKGROUND))
{
- const SvxBrushItem* pBrush = static_cast<const SvxBrushItem*>(pItem);
WriteBrushAttr(*pBrush, aPropOpt);
SvxGraphicPosition ePos = pBrush->GetGraphicPos();
@@ -2336,10 +2309,10 @@ SwEscherEx::~SwEscherEx()
void SwEscherEx::FinishEscher()
{
- pEscherStrm->Seek(0);
- rWrt.pTableStrm->WriteStream( *pEscherStrm );
- delete pEscherStrm;
- pEscherStrm = nullptr;
+ mpEscherStrm->Seek(0);
+ mrWrt.m_pTableStrm->WriteStream( *mpEscherStrm );
+ delete mpEscherStrm;
+ mpEscherStrm = nullptr;
}
@@ -2417,12 +2390,12 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri,
// break before" attribute
bool bConvDueToAnchoredAtColBreakPara( false );
if ( ( (eAnchor == RndStdIds::FLY_AT_PARA) || (eAnchor == RndStdIds::FLY_AT_CHAR) ) &&
- _rFrameFormat.GetAnchor().GetContentAnchor() &&
- _rFrameFormat.GetAnchor().GetContentAnchor()->nNode.GetNode().IsTextNode() )
+ _rFrameFormat.GetAnchor().GetAnchorNode() &&
+ _rFrameFormat.GetAnchor().GetAnchorNode()->IsTextNode() )
{
SwTextNode& rAnchorTextNode =
- dynamic_cast<SwTextNode&>(_rFrameFormat.GetAnchor().GetContentAnchor()->nNode.GetNode());
- const SvxFormatBreakItem& rBreak = ItemGet<SvxFormatBreakItem>(rAnchorTextNode, RES_BREAK);
+ dynamic_cast<SwTextNode&>(*_rFrameFormat.GetAnchor().GetAnchorNode());
+ const SvxFormatBreakItem& rBreak = rAnchorTextNode.GetAttr(RES_BREAK);
if (rBreak.GetBreak() == SvxBreak::ColumnBefore)
{
bConvDueToAnchoredAtColBreakPara = true;
@@ -2597,6 +2570,13 @@ void WinwordAnchoring::SetAnchoring(const SwFrameFormat& rFormat)
const RndStdIds eAnchor = rFormat.GetAnchor().GetAnchorId();
mbInline = (eAnchor == RndStdIds::FLY_AS_CHAR);
+ mnGroupShapeBooleanProperties = 0;
+ if (!rFormat.GetFollowTextFlow().GetValue())
+ {
+ // bit32: fUseLayoutInCell, bit16: fLayoutInCell
+ mnGroupShapeBooleanProperties |= 0x80000000;
+ }
+
SwFormatHoriOrient rHoriOri = rFormat.GetHoriOrient();
SwFormatVertOrient rVertOri = rFormat.GetVertOrient();
@@ -2729,8 +2709,8 @@ void WinwordAnchoring::SetAnchoring(const SwFrameFormat& rFormat)
void SwEscherEx::WriteFrameExtraData( const SwFrameFormat& rFormat )
{
- aWinwordAnchoring.SetAnchoring(rFormat);
- aWinwordAnchoring.WriteData(*this);
+ m_aWinwordAnchoring.SetAnchoring(rFormat);
+ m_aWinwordAnchoring.WriteData(*this);
AddAtom(4, ESCHER_ClientAnchor);
GetStream().WriteInt32( 0 );
@@ -2776,11 +2756,11 @@ sal_Int32 SwEscherEx::WriteFlyFrame(const DrawObj &rObj, sal_uInt32 &rShapeId,
rShapeId = GetFlyShapeId(rFormat, rObj.mnHdFtIndex, rPVec);
if( !nOff )
{
- nTextId = pTextBxs->GetPos( pObj );
+ nTextId = m_pTextBxs->GetPos( pObj );
if( USHRT_MAX == nTextId )
{
- pTextBxs->Append( *pObj, rShapeId );
- nTextId = pTextBxs->Count();
+ m_pTextBxs->Append( *pObj, rShapeId );
+ nTextId = m_pTextBxs->Count();
}
else
++nTextId;
@@ -2788,13 +2768,13 @@ sal_Int32 SwEscherEx::WriteFlyFrame(const DrawObj &rObj, sal_uInt32 &rShapeId,
else
{
const SdrObject* pPrevObj = pFormat->FindRealSdrObject();
- nTextId = pTextBxs->GetPos( pPrevObj );
+ nTextId = m_pTextBxs->GetPos( pPrevObj );
if( USHRT_MAX == nTextId )
{
sal_uInt32 nPrevShapeId =
GetFlyShapeId(*pFormat, rObj.mnHdFtIndex, rPVec);
- pTextBxs->Append( *pPrevObj, nPrevShapeId );
- nTextId = pTextBxs->Count();
+ m_pTextBxs->Append( *pPrevObj, nPrevShapeId );
+ nTextId = m_pTextBxs->Count();
}
else
++nTextId;
@@ -2814,8 +2794,8 @@ sal_Int32 SwEscherEx::WriteFlyFrame(const DrawObj &rObj, sal_uInt32 &rShapeId,
if( !rFormat.GetChain().GetPrev() )//obj in header/footer?
{
rShapeId = GetFlyShapeId(rFormat, rObj.mnHdFtIndex, rPVec);
- pTextBxs->Append( &rFormat, rShapeId );
- sal_uInt32 nTextId = pTextBxs->Count();
+ m_pTextBxs->Append( &rFormat, rShapeId );
+ sal_uInt32 nTextId = m_pTextBxs->Count();
nTextId *= 0x10000;
nBorderThick = WriteTextFlyFrame(rObj, rShapeId, nTextId, rPVec);
@@ -2857,8 +2837,8 @@ sal_Int32 SwEscherEx::WriteTextFlyFrame(const DrawObj &rObj, sal_uInt32 nShapeId
if (const SwFrameFormat *pNext = rFormat.GetChain().GetNext())
{
sal_uInt16 nPos = FindPos(*pNext, rObj.mnHdFtIndex, rPVec);
- if (USHRT_MAX != nPos && aFollowShpIds[nPos])
- aPropOpt.AddOpt(ESCHER_Prop_hspNext, aFollowShpIds[nPos]);
+ if (USHRT_MAX != nPos && m_aFollowShpIds[nPos])
+ aPropOpt.AddOpt(ESCHER_Prop_hspNext, m_aFollowShpIds[nPos]);
}
nBorderThick = WriteFlyFrameAttr( rFormat, mso_sptTextBox, aPropOpt );
@@ -2925,7 +2905,7 @@ void SwEscherEx::WriteOCXControl( const SwFrameFormat& rFormat, sal_uInt32 nShap
OpenContainer( ESCHER_SpContainer );
- SwDrawModel *pModel = rWrt.m_rDoc.getIDocumentDrawModelAccess().GetDrawModel();
+ SwDrawModel *pModel = mrWrt.m_rDoc.getIDocumentDrawModelAccess().GetDrawModel();
OutputDevice *pDevice = Application::GetDefaultDevice();
OSL_ENSURE(pModel && pDevice, "no model or device");
@@ -2951,10 +2931,10 @@ void SwEscherEx::WriteOCXControl( const SwFrameFormat& rFormat, sal_uInt32 nShap
void SwEscherEx::MakeZOrderArrAndFollowIds(
std::vector<DrawObj>& rSrcArr, DrawObjPointerVector&rDstArr)
{
- ::lcl_makeZOrderArray(rWrt, rSrcArr, rDstArr);
+ ::lcl_makeZOrderArray(mrWrt, rSrcArr, rDstArr);
//Now set up the follow IDs
- aFollowShpIds.clear();
+ m_aFollowShpIds.clear();
for (DrawObj* p : rDstArr)
{
@@ -2970,7 +2950,7 @@ void SwEscherEx::MakeZOrderArrAndFollowIds(
sal_uLong nShapeId = bNeedsShapeId ? GenerateShapeId() : 0;
- aFollowShpIds.push_back(nShapeId);
+ m_aFollowShpIds.push_back(nShapeId);
}
}
@@ -2981,11 +2961,11 @@ sal_uInt32 SwEscherEx::GetFlyShapeId(const SwFrameFormat& rFormat,
sal_uInt32 nShapeId;
if (USHRT_MAX != nPos)
{
- nShapeId = aFollowShpIds[nPos];
+ nShapeId = m_aFollowShpIds[nPos];
if (0 == nShapeId)
{
nShapeId = GenerateShapeId();
- aFollowShpIds[ nPos ] = nShapeId;
+ m_aFollowShpIds[ nPos ] = nShapeId;
}
}
else
@@ -2997,24 +2977,24 @@ sal_uInt32 SwEscherEx::QueryTextID(
const uno::Reference< drawing::XShape>& xXShapeRef, sal_uInt32 nShapeId )
{
sal_uInt32 nId = 0;
- if (SdrObject* pObj = GetSdrObjectFromXShape(xXShapeRef))
+ if (SdrObject* pObj = SdrObject::getSdrObjectFromXShape(xXShapeRef))
{
- pTextBxs->Append( *pObj, nShapeId );
- nId = pTextBxs->Count();
+ m_pTextBxs->Append( *pObj, nShapeId );
+ nId = m_pTextBxs->Count();
nId *= 0x10000;
}
return nId;
}
SwMSConvertControls::SwMSConvertControls( SfxObjectShell const *pDSh, SwPaM *pP ) : oox
-::ole::MSConvertOCXControls( pDSh ? pDSh->GetModel() : nullptr ), pPaM( pP ), mnObjectId(0)
+::ole::MSConvertOCXControls( pDSh ? pDSh->GetModel() : nullptr ), m_pPaM( pP ), mnObjectId(0)
{
}
// in transitioning away old filter for ole/ocx controls, ReadOCXStream has been made pure virtual in
// filter/source/msocximex.cxx, so... we need an implementation here
-bool SwMSConvertControls::ReadOCXStream( tools::SvRef<SotStorage> const & rSrc1,
+bool SwMSConvertControls::ReadOCXStream( rtl::Reference<SotStorage> const & rSrc1,
css::uno::Reference< css::drawing::XShape > *pShapeRef,
bool bFloatingCtrl )
{
@@ -3044,12 +3024,12 @@ void SwMSConvertControls::ExportControl(WW8Export &rWW8Wrt, const SdrUnoObj& rFo
aSize.Height = convertTwipToMm100(aRect.Bottom());
//Open the ObjectPool
- tools::SvRef<SotStorage> xObjPool = rWW8Wrt.GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool);
+ rtl::Reference<SotStorage> xObjPool = rWW8Wrt.GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool);
//Create a destination storage for the microsoft control
sal_uInt32 nObjId = ++mnObjectId;
OUString sStorageName = "_" + OUString::number( static_cast<sal_Int64>( nObjId ));
- tools::SvRef<SotStorage> xOleStg = xObjPool->OpenSotStorage(sStorageName);
+ rtl::Reference<SotStorage> xOleStg = xObjPool->OpenSotStorage(sStorageName);
if (!xOleStg.is())
return;
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index da5253f723b7..99dcd831492b 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -24,6 +24,7 @@
#include "docxexport.hxx"
+#include <officecfg/Office/Common.hxx>
#include <i18nlangtag/mslangid.hxx>
#include <hintids.hxx>
#include <tools/urlobj.hxx>
@@ -32,12 +33,18 @@
#include <editeng/svxfont.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/brushitem.hxx>
+#include <editeng/charhiddenitem.hxx>
+#include <editeng/charreliefitem.hxx>
+#include <editeng/contouritem.hxx>
+#include <editeng/crossedoutitem.hxx>
#include <editeng/fontitem.hxx>
#include <editeng/keepitem.hxx>
#include <editeng/fhgtitem.hxx>
#include <editeng/ulspitem.hxx>
#include <editeng/formatbreakitem.hxx>
#include <editeng/frmdiritem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/shdditem.hxx>
#include <editeng/tstpitem.hxx>
#include <editeng/wghtitem.hxx>
#include <svl/grabbagitem.hxx>
@@ -76,14 +83,18 @@
#include <txtatr.hxx>
#include <cellatr.hxx>
#include <fmtrowsplt.hxx>
+#include <com/sun/star/awt/FontRelief.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/i18n/BreakIterator.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/i18n/WordType.hpp>
#include <com/sun/star/text/RubyPosition.hpp>
+#include <com/sun/star/style/CaseMap.hpp>
#include <oox/export/vmlexport.hxx>
#include <sal/log.hxx>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/string.hxx>
#include "sprmids.hxx"
@@ -97,6 +108,7 @@
#include <ndgrf.hxx>
#include <ndole.hxx>
+#include <formatflysplit.hxx>
#include <cstdio>
@@ -166,14 +178,14 @@ lcl_getLinkChainName(const uno::Reference<beans::XPropertySet>& rPropertySet,
}
MSWordAttrIter::MSWordAttrIter( MSWordExportBase& rExport )
- : pOld( rExport.m_pChpIter ), m_rExport( rExport )
+ : m_pOld( rExport.m_pChpIter ), m_rExport( rExport )
{
m_rExport.m_pChpIter = this;
}
MSWordAttrIter::~MSWordAttrIter()
{
- m_rExport.m_pChpIter = pOld;
+ m_rExport.m_pChpIter = m_pOld;
}
namespace {
@@ -199,11 +211,11 @@ void SwWW8AttrIter::IterToCurrent()
SwWW8AttrIter::SwWW8AttrIter(MSWordExportBase& rWr, const SwTextNode& rTextNd) :
MSWordAttrIter(rWr),
- rNd(rTextNd),
+ m_rNode(rTextNd),
maCharRuns(GetPseudoCharRuns(rTextNd)),
- pCurRedline(nullptr),
- nCurrentSwPos(0),
- nCurRedlinePos(SwRedlineTable::npos),
+ m_pCurRedline(nullptr),
+ m_nCurrentSwPos(0),
+ m_nCurRedlinePos(SwRedlineTable::npos),
mrSwFormatDrop(rTextNd.GetSwAttrSet().GetDrop())
{
@@ -217,8 +229,8 @@ SwWW8AttrIter::SwWW8AttrIter(MSWordExportBase& rWr, const SwTextNode& rTextNd) :
#i2916#
Get list of any graphics which may be anchored from this paragraph.
*/
- maFlyFrames = GetFramesInNode(rWr.m_aFrames, rNd);
- std::sort(maFlyFrames.begin(), maFlyFrames.end(), sortswflys());
+ maFlyFrames = GetFramesInNode(rWr.m_aFrames, m_rNode);
+ std::stable_sort(maFlyFrames.begin(), maFlyFrames.end(), sortswflys());
/*
#i18480#
@@ -236,11 +248,11 @@ SwWW8AttrIter::SwWW8AttrIter(MSWordExportBase& rWr, const SwTextNode& rTextNd) :
if ( !m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().empty() )
{
- SwPosition aPosition( rNd, SwIndex( const_cast<SwTextNode*>(&rNd) ) );
- pCurRedline = m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedline( aPosition, &nCurRedlinePos );
+ SwPosition aPosition( m_rNode );
+ m_pCurRedline = m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedline( aPosition, &m_nCurRedlinePos );
}
- nCurrentSwPos = SearchNext(1);
+ m_nCurrentSwPos = SearchNext(1);
}
static sal_Int32 lcl_getMinPos( sal_Int32 pos1, sal_Int32 pos2 )
@@ -257,7 +269,7 @@ static sal_Int32 lcl_getMinPos( sal_Int32 pos1, sal_Int32 pos2 )
sal_Int32 SwWW8AttrIter::SearchNext( sal_Int32 nStartPos )
{
- const OUString aText = rNd.GetText();
+ const OUString aText = m_rNode.GetText();
sal_Int32 fieldEndPos = aText.indexOf(CH_TXT_ATR_FIELDEND, nStartPos - 1);
// HACK: for (so far) mysterious reasons the sdtContent element closes
// too late in testDateFormField() unless an empty run is exported at
@@ -282,12 +294,12 @@ sal_Int32 SwWW8AttrIter::SearchNext( sal_Int32 nStartPos )
sal_Int32 nMinPos = (pos>=0) ? pos : SAL_MAX_INT32;
// first the redline, then the attributes
- if( pCurRedline )
+ if( m_pCurRedline )
{
- const SwPosition* pEnd = pCurRedline->End();
- if (pEnd->nNode == rNd)
+ const SwPosition* pEnd = m_pCurRedline->End();
+ if (pEnd->GetNode() == m_rNode)
{
- const sal_Int32 i = pEnd->nContent.GetIndex();
+ const sal_Int32 i = pEnd->GetContentIndex();
if ( i >= nStartPos && i < nMinPos )
{
nMinPos = i;
@@ -295,34 +307,31 @@ sal_Int32 SwWW8AttrIter::SearchNext( sal_Int32 nStartPos )
}
}
- if ( nCurRedlinePos < m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().size() )
+ if ( m_nCurRedlinePos < m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().size() )
{
// nCurRedlinePos point to the next redline
- SwRedlineTable::size_type nRedLinePos = nCurRedlinePos;
- if( pCurRedline )
+ SwRedlineTable::size_type nRedLinePos = m_nCurRedlinePos;
+ if( m_pCurRedline )
++nRedLinePos;
for ( ; nRedLinePos < m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().size(); ++nRedLinePos )
{
const SwRangeRedline* pRedl = m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ nRedLinePos ];
- const SwPosition* pStt = pRedl->Start();
- const SwPosition* pEnd = pStt == pRedl->GetPoint()
- ? pRedl->GetMark()
- : pRedl->GetPoint();
+ auto [pStt, pEnd] = pRedl->StartEnd(); // SwPosition*
- if( pStt->nNode == rNd )
+ if( pStt->GetNode() == m_rNode )
{
- const sal_Int32 i = pStt->nContent.GetIndex();
+ const sal_Int32 i = pStt->GetContentIndex();
if( i >= nStartPos && i < nMinPos )
nMinPos = i;
}
else
break;
- if( pEnd->nNode == rNd )
+ if( pEnd->GetNode() == m_rNode )
{
- const sal_Int32 i = pEnd->nContent.GetIndex();
+ const sal_Int32 i = pEnd->GetContentIndex();
if( i >= nStartPos && i < nMinPos )
{
nMinPos = i;
@@ -331,12 +340,12 @@ sal_Int32 SwWW8AttrIter::SearchNext( sal_Int32 nStartPos )
}
}
- if (mrSwFormatDrop.GetWholeWord() && nStartPos <= rNd.GetDropLen(0))
- nMinPos = rNd.GetDropLen(0);
+ if (mrSwFormatDrop.GetWholeWord() && nStartPos <= m_rNode.GetDropLen(0))
+ nMinPos = m_rNode.GetDropLen(0);
else if(nStartPos <= mrSwFormatDrop.GetChars())
nMinPos = mrSwFormatDrop.GetChars();
- if(const SwpHints* pTextAttrs = rNd.GetpSwpHints())
+ if(const SwpHints* pTextAttrs = m_rNode.GetpSwpHints())
{
// can be optimized if we consider that the TextAttrs are sorted by start position.
@@ -377,7 +386,7 @@ sal_Int32 SwWW8AttrIter::SearchNext( sal_Int32 nStartPos )
while (aTmpFlyIter != maFlyFrames.end() && nNextFlyPos < nStartPos)
{
const SwPosition &rAnchor = aTmpFlyIter->GetPosition();
- nNextFlyPos = rAnchor.nContent.GetIndex();
+ nNextFlyPos = rAnchor.GetContentIndex();
++aTmpFlyIter;
}
@@ -395,7 +404,7 @@ sal_Int32 SwWW8AttrIter::SearchNext( sal_Int32 nStartPos )
return nMinPos;
}
-void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars, bool bPostponeSingleUse)
+void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars)
{
m_rExport.AttrOutput().RTLAndCJKState( mbCharIsRTL, GetScript() );
@@ -404,23 +413,22 @@ void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars, bool bPostpo
script, the idea is that the font that is actually in use to render this
range of text ends up in pFont
*/
- sal_uInt16 nFontId = GetWhichOfScript( RES_CHRATR_FONT, GetScript() );
+ TypedWhichId<SvxFontItem> nFontId = GetWhichOfScript( RES_CHRATR_FONT, GetScript() );
- const SvxFontItem &rParentFont = ItemGet<SvxFontItem>(
- static_cast<const SwTextFormatColl&>(rNd.GetAnyFormatColl()), nFontId);
+ const SvxFontItem &rParentFont =
+ static_cast<const SwTextFormatColl&>(m_rNode.GetAnyFormatColl()).GetFormatAttr(nFontId);
const SvxFontItem *pFont = &rParentFont;
const SfxPoolItem *pGrabBag = nullptr;
- SfxItemSet aExportSet(*rNd.GetSwAttrSet().GetPool(),
- svl::Items<RES_CHRATR_BEGIN, RES_TXTATR_END - 1>{});
+ SfxItemSetFixed<RES_CHRATR_BEGIN, RES_TXTATR_END - 1> aExportSet(*m_rNode.GetSwAttrSet().GetPool());
//The hard formatting properties that affect the entire paragraph
- if (rNd.HasSwAttrSet())
+ if (m_rNode.HasSwAttrSet())
{
// only copy hard attributes - bDeep = false
- aExportSet.Set(rNd.GetSwAttrSet(), false/*bDeep*/);
+ aExportSet.Set(m_rNode.GetSwAttrSet(), false/*bDeep*/);
// get the current font item. Use rNd.GetSwAttrSet instead of aExportSet:
- const SvxFontItem &rNdFont = ItemGet<SvxFontItem>(rNd.GetSwAttrSet(), nFontId);
+ const SvxFontItem &rNdFont = m_rNode.GetSwAttrSet().Get(nFontId);
pFont = &rNdFont;
aExportSet.ClearItem(nFontId);
}
@@ -428,7 +436,7 @@ void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars, bool bPostpo
//The additional hard formatting properties that affect this range in the
//paragraph
ww8::PoolItems aRangeItems;
- if (const SwpHints* pTextAttrs = rNd.GetpSwpHints())
+ if (const SwpHints* pTextAttrs = m_rNode.GetpSwpHints())
{
for( size_t i = 0; i < pTextAttrs->Count(); ++i )
{
@@ -448,7 +456,7 @@ void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars, bool bPostpo
sal_uInt16 nWhichId = aIter.FirstWhich();
while( nWhichId )
{
- if( SfxItemState::SET == pSet->GetItemState( nWhichId, false, &pItem ))
+ if( SfxItemState::SET == aIter.GetItemState( false, &pItem ))
{
if (nWhichId == nFontId)
pFont = &(item_cast<SvxFontItem>(*pItem));
@@ -460,13 +468,6 @@ void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars, bool bPostpo
nWhichId = aIter.NextWhich();
}
}
- else if (bPostponeSingleUse &&
- (nWhich == RES_TXTATR_FTN || nWhich == RES_TXTATR_ANNOTATION || nWhich == RES_TXTATR_FIELD))
- {
- // Do not duplicate these multiple times when the character run is split.
- // Skip this time - it will be attempted later.
- // ?? also RES_TXTATR_REFMARK: RES_TXTATR_TOXMARK: RES_TXTATR_META: RES_TXTATR_METAFIELD: ??
- }
else
aRangeItems[nWhich] = (&(pHt->GetAttr()));
}
@@ -474,6 +475,7 @@ void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars, bool bPostpo
break;
}
}
+// DeduplicateItems(aRangeItems);
/*
For #i24291# we need to explicitly remove any properties from the
@@ -486,9 +488,9 @@ void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars, bool bPostpo
ClearOverridesFromSet( *pCharFormatItem, aExportSet );
// check toggle properties in DOCX output
+ if (pCharFormatItem)
{
- SvxWeightItem aBoldProperty(WEIGHT_BOLD, RES_CHRATR_WEIGHT);
- handleToggleProperty(aExportSet, pCharFormatItem, RES_CHRATR_WEIGHT, &aBoldProperty);
+ handleToggleProperty(aExportSet, *pCharFormatItem);
}
// tdf#113790: AutoFormat style overwrites char style, so remove all
@@ -512,7 +514,7 @@ void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars, bool bPostpo
ww8::PoolItems aExportItems;
GetPoolItems( aExportSet, aExportItems, false );
- if( rNd.GetpSwpHints() == nullptr )
+ if( m_rNode.GetpSwpHints() == nullptr )
m_rExport.SetCurItemSet(&aExportSet);
for ( const auto& aRangeItem : aRangeItems )
@@ -523,7 +525,7 @@ void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars, bool bPostpo
if ( !aExportItems.empty() )
{
const sw::BroadcastingModify* pOldMod = m_rExport.m_pOutFormatNode;
- m_rExport.m_pOutFormatNode = &rNd;
+ m_rExport.m_pOutFormatNode = &m_rNode;
m_rExport.m_aCurrentCharPropStarts.push( nSwPos );
// tdf#38778 Fix output of the font in DOC run for fields
@@ -536,7 +538,7 @@ void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars, bool bPostpo
m_rExport.m_pOutFormatNode = pOldMod;
}
- if( rNd.GetpSwpHints() == nullptr )
+ if( m_rNode.GetpSwpHints() == nullptr )
m_rExport.SetCurItemSet(nullptr);
OSL_ENSURE( pFont, "must be *some* font associated with this txtnode" );
@@ -565,49 +567,142 @@ void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars, bool bPostpo
// i.e., the effective value to be applied to the content shall be true if its effective value is true for
// an odd number of levels of the style hierarchy.
//
-// To prevent such logic inside output, it is required to write inline w:b token on content level.
-void SwWW8AttrIter::handleToggleProperty(SfxItemSet& rExportSet, const SwFormatCharFormat* pCharFormatItem,
- sal_uInt16 nWhich, const SfxPoolItem* pValue)
-{
- if (rExportSet.HasItem(nWhich) || !pValue)
+// To prevent such logic inside output, it is required to write inline attribute tokens on content level.
+void SwWW8AttrIter::handleToggleProperty(SfxItemSet& rExportSet, const SwFormatCharFormat& rCharFormatItem)
+{
+ if (rExportSet.HasItem(RES_CHRATR_WEIGHT) || rExportSet.HasItem(RES_CHRATR_POSTURE) ||
+ rExportSet.HasItem(RES_CHRATR_CTL_WEIGHT) || rExportSet.HasItem(RES_CHRATR_CTL_POSTURE) ||
+ rExportSet.HasItem(RES_CHRATR_CONTOUR) || rExportSet.HasItem(RES_CHRATR_CASEMAP) ||
+ rExportSet.HasItem(RES_CHRATR_RELIEF) || rExportSet.HasItem(RES_CHRATR_SHADOWED) ||
+ rExportSet.HasItem(RES_CHRATR_CROSSEDOUT) || rExportSet.HasItem(RES_CHRATR_HIDDEN))
return;
- bool hasPropertyInCharStyle = false;
- bool hasPropertyInParaStyle = false;
+ SvxWeightItem aBoldProperty(WEIGHT_BOLD, RES_CHRATR_WEIGHT);
+ SvxPostureItem aPostureProperty(ITALIC_NORMAL, RES_CHRATR_POSTURE);
+ SvxContourItem aContouredProperty(true, RES_CHRATR_CONTOUR);
+ SvxCaseMapItem aCaseMapCapsProperty(SvxCaseMap::Uppercase, RES_CHRATR_CASEMAP);
+ SvxCaseMapItem aCaseMapSmallProperty(SvxCaseMap::SmallCaps, RES_CHRATR_CASEMAP);
+ SvxCharReliefItem aEmbossedProperty(FontRelief::Embossed, RES_CHRATR_RELIEF);
+ SvxCharReliefItem aImprintProperty(FontRelief::Engraved, RES_CHRATR_RELIEF);
+ SvxShadowedItem aShadowedProperty(true, RES_CHRATR_SHADOWED);
+ SvxCrossedOutItem aStrikeoutProperty(STRIKEOUT_SINGLE, RES_CHRATR_CROSSEDOUT);
+ SvxCharHiddenItem aHiddenProperty(true, RES_CHRATR_HIDDEN);
- // get bold flag from specified character style
- if (pCharFormatItem)
+ bool hasWeightPropertyInCharStyle = false;
+ bool hasWeightComplexPropertyInCharStyle = false;
+ bool hasPosturePropertyInCharStyle = false;
+ bool hasPostureComplexPropertyInCharStyle = false;
+ bool bHasCapsPropertyInCharStyle = false;
+ bool bHasSmallCapsPropertyInCharStyle = false;
+ bool bHasEmbossedPropertyInCharStyle = false;
+ bool bHasImprintPropertyInCharStyle = false;
+ bool hasContouredPropertyInCharStyle = false;
+ bool hasShadowedPropertyInCharStyle = false;
+ bool hasStrikeoutPropertyInCharStyle = false;
+ bool hasHiddenPropertyInCharStyle = false;
+
+
+ // get attribute flags from specified character style
+ if (const SwCharFormat* pCharFormat = rCharFormatItem.GetCharFormat())
{
- if (const SwCharFormat* pCharFormat = pCharFormatItem->GetCharFormat())
+ if (const SfxPoolItem* pWeightItem = pCharFormat->GetAttrSet().GetItem(RES_CHRATR_WEIGHT))
+ hasWeightPropertyInCharStyle = (*pWeightItem == aBoldProperty);
+
+ if (const SfxPoolItem* pWeightComplexItem = pCharFormat->GetAttrSet().GetItem(RES_CHRATR_CTL_WEIGHT))
+ hasWeightComplexPropertyInCharStyle = (*pWeightComplexItem == aBoldProperty);
+
+ if (const SfxPoolItem* pPostureItem = pCharFormat->GetAttrSet().GetItem(RES_CHRATR_POSTURE))
+ hasPosturePropertyInCharStyle = (*pPostureItem == aPostureProperty);
+
+ if (const SfxPoolItem* pPostureComplexItem = pCharFormat->GetAttrSet().GetItem(RES_CHRATR_CTL_POSTURE))
+ hasPostureComplexPropertyInCharStyle = (*pPostureComplexItem == aPostureProperty);
+
+ if (const SfxPoolItem* pContouredItem = pCharFormat->GetAttrSet().GetItem(RES_CHRATR_CONTOUR))
+ hasContouredPropertyInCharStyle = (*pContouredItem == aContouredProperty);
+
+ if (const SfxPoolItem* pShadowedItem = pCharFormat->GetAttrSet().GetItem(RES_CHRATR_SHADOWED))
+ hasShadowedPropertyInCharStyle = (*pShadowedItem == aShadowedProperty);
+
+ if (const SfxPoolItem* pStrikeoutItem = pCharFormat->GetAttrSet().GetItem(RES_CHRATR_CROSSEDOUT))
+ hasStrikeoutPropertyInCharStyle = (*pStrikeoutItem == aStrikeoutProperty);
+
+ if (const SfxPoolItem* pHiddenItem = pCharFormat->GetAttrSet().GetItem(RES_CHRATR_HIDDEN))
+ hasHiddenPropertyInCharStyle = (*pHiddenItem == aHiddenProperty);
+
+ if (const SfxPoolItem* pCaseMapItem = pCharFormat->GetAttrSet().GetItem(RES_CHRATR_CASEMAP))
{
- const SfxPoolItem* pItem = nullptr;
- if (pCharFormat->GetAttrSet().HasItem(nWhich, &pItem))
- {
- hasPropertyInCharStyle = (*pItem == *pValue);
- }
+ bHasCapsPropertyInCharStyle = (*pCaseMapItem == aCaseMapCapsProperty);
+ bHasSmallCapsPropertyInCharStyle = (*pCaseMapItem == aCaseMapSmallProperty);
+ }
+
+ if (const SfxPoolItem* pReliefItem = pCharFormat->GetAttrSet().GetItem(RES_CHRATR_RELIEF))
+ {
+ bHasEmbossedPropertyInCharStyle = (*pReliefItem == aEmbossedProperty);
+ bHasImprintPropertyInCharStyle = (*pReliefItem == aImprintProperty);
}
}
- // get bold flag from specified paragraph style
+ // get attribute flags from specified paragraph style and apply properties if they are set in character and paragraph style
{
- SwTextFormatColl& rTextColl = static_cast<SwTextFormatColl&>( rNd.GetAnyFormatColl() );
+ SwTextFormatColl& rTextColl = static_cast<SwTextFormatColl&>( m_rNode.GetAnyFormatColl() );
sal_uInt16 nStyle = m_rExport.m_pStyles->GetSlot( &rTextColl );
nStyle = ( nStyle != 0xfff ) ? nStyle : 0;
const SwFormat* pFormat = m_rExport.m_pStyles->GetSwFormat(nStyle);
if (pFormat)
{
- const SfxPoolItem* pItem = nullptr;
- if (pFormat->GetAttrSet().HasItem(nWhich, &pItem))
+ const SfxPoolItem* pItem;
+ if (hasWeightPropertyInCharStyle && (pItem = pFormat->GetAttrSet().GetItem(RES_CHRATR_WEIGHT)) &&
+ (*pItem == aBoldProperty))
+ rExportSet.Put(aBoldProperty);
+
+ if (hasWeightComplexPropertyInCharStyle && (pItem = pFormat->GetAttrSet().GetItem(RES_CHRATR_CTL_WEIGHT)) &&
+ *pItem == aBoldProperty)
+ {
+ rExportSet.PutAsTargetWhich(aBoldProperty, RES_CHRATR_CTL_WEIGHT);
+ }
+
+ if (hasPosturePropertyInCharStyle && (pItem = pFormat->GetAttrSet().GetItem(RES_CHRATR_POSTURE)) &&
+ *pItem == aPostureProperty)
+ rExportSet.Put(aPostureProperty);
+
+ if (hasPostureComplexPropertyInCharStyle && (pItem = pFormat->GetAttrSet().GetItem(RES_CHRATR_CTL_POSTURE)) &&
+ *pItem == aPostureProperty)
+ {
+ rExportSet.PutAsTargetWhich(aPostureProperty, RES_CHRATR_CTL_POSTURE);
+ }
+
+ if (hasContouredPropertyInCharStyle && (pItem = pFormat->GetAttrSet().GetItem(RES_CHRATR_CONTOUR)) && *pItem == aContouredProperty)
+ rExportSet.Put(aContouredProperty);
+
+ if (hasShadowedPropertyInCharStyle && (pItem = pFormat->GetAttrSet().GetItem(RES_CHRATR_SHADOWED)) &&
+ *pItem == aShadowedProperty)
+ rExportSet.Put(aShadowedProperty);
+
+ if (hasStrikeoutPropertyInCharStyle && (pItem = pFormat->GetAttrSet().GetItem(RES_CHRATR_CROSSEDOUT)) &&
+ *pItem == aStrikeoutProperty)
+ rExportSet.Put(aStrikeoutProperty);
+
+ if (hasHiddenPropertyInCharStyle && (pItem = pFormat->GetAttrSet().GetItem(RES_CHRATR_HIDDEN)) &&
+ (*pItem == aHiddenProperty))
+ rExportSet.Put(aHiddenProperty);
+
+ if ((bHasCapsPropertyInCharStyle||bHasSmallCapsPropertyInCharStyle) && (pItem = pFormat->GetAttrSet().GetItem(RES_CHRATR_CASEMAP)))
+ {
+ if (bHasCapsPropertyInCharStyle && *pItem == aCaseMapCapsProperty)
+ rExportSet.Put(aCaseMapCapsProperty);
+ else if (bHasSmallCapsPropertyInCharStyle && *pItem == aCaseMapSmallProperty)
+ rExportSet.Put(aCaseMapSmallProperty);
+ }
+
+ if ((bHasEmbossedPropertyInCharStyle||bHasImprintPropertyInCharStyle) && (pItem = pFormat->GetAttrSet().GetItem(RES_CHRATR_RELIEF)))
{
- hasPropertyInParaStyle = (*pItem == *pValue);
+ if (bHasEmbossedPropertyInCharStyle && *pItem == aEmbossedProperty)
+ rExportSet.Put(aEmbossedProperty);
+ else if (bHasImprintPropertyInCharStyle && *pItem == aImprintProperty)
+ rExportSet.Put(aImprintProperty);
}
}
- }
- // add inline property
- if (hasPropertyInCharStyle && hasPropertyInParaStyle)
- {
- rExportSet.Put(*pValue);
}
}
@@ -631,7 +726,7 @@ bool SwWW8AttrIter::IsWatermarkFrame()
return false;
}
-bool SwWW8AttrIter::IsAnchorLinkedToThisNode( sal_uLong nNodePos )
+bool SwWW8AttrIter::IsAnchorLinkedToThisNode( SwNodeOffset nNodePos )
{
if ( maFlyIter == maFlyFrames.end() )
return false;
@@ -639,7 +734,7 @@ bool SwWW8AttrIter::IsAnchorLinkedToThisNode( sal_uLong nNodePos )
/* if current node position and the anchor position are the same
then the frame anchor is linked to this node
*/
- return nNodePos == maFlyIter->GetPosition().nNode.GetIndex();
+ return nNodePos == maFlyIter->GetPosition().GetNodeIndex();
}
bool SwWW8AttrIter::HasFlysAt(sal_Int32 nSwPos) const
@@ -647,7 +742,7 @@ bool SwWW8AttrIter::HasFlysAt(sal_Int32 nSwPos) const
for (const auto& rFly : maFlyFrames)
{
const SwPosition& rAnchor = rFly.GetPosition();
- const sal_Int32 nPos = rAnchor.nContent.GetIndex();
+ const sal_Int32 nPos = rAnchor.GetContentIndex();
if (nPos == nSwPos)
{
return true;
@@ -719,7 +814,8 @@ FlyProcessingState SwWW8AttrIter::OutFlys(sal_Int32 nSwPos)
if (maFlyIter == maFlyFrames.end())
{
- return FLY_NONE;
+ // tdf#143039 postponed prevents fly duplication at end of paragraph
+ return m_rExport.AttrOutput().IsFlyProcessingPostponed() ? FLY_POSTPONED : FLY_NONE;
}
/*
@@ -730,7 +826,7 @@ FlyProcessingState SwWW8AttrIter::OutFlys(sal_Int32 nSwPos)
while ( maFlyIter != maFlyFrames.end() )
{
const SwPosition &rAnchor = maFlyIter->GetPosition();
- const sal_Int32 nPos = rAnchor.nContent.GetIndex();
+ const sal_Int32 nPos = rAnchor.GetContentIndex();
assert(nPos >= nSwPos && "a fly must get flagged as a nextAttr/CurrentPos");
if ( nPos != nSwPos )
@@ -772,7 +868,7 @@ FlyProcessingState SwWW8AttrIter::OutFlys(sal_Int32 nSwPos)
bool SwWW8AttrIter::IsTextAttr( sal_Int32 nSwPos ) const
{
// search for attrs with dummy character or content
- if (const SwpHints* pTextAttrs = rNd.GetpSwpHints())
+ if (const SwpHints* pTextAttrs = m_rNode.GetpSwpHints())
{
for (size_t i = 0; i < pTextAttrs->Count(); ++i)
{
@@ -796,7 +892,7 @@ bool SwWW8AttrIter::IsTextAttr( sal_Int32 nSwPos ) const
bool SwWW8AttrIter::IsExportableAttr(sal_Int32 nSwPos) const
{
- if (const SwpHints* pTextAttrs = rNd.GetpSwpHints())
+ if (const SwpHints* pTextAttrs = m_rNode.GetpSwpHints())
{
for (size_t i = 0; i < pTextAttrs->Count(); ++i)
{
@@ -825,7 +921,7 @@ bool SwWW8AttrIter::IsDropCap( int nSwPos )
bool bWholeWord = mrSwFormatDrop.GetWholeWord();
if (bWholeWord)
{
- const sal_Int32 nWordLen = rNd.GetDropLen(0);
+ const sal_Int32 nWordLen = m_rNode.GetDropLen(0);
if(nSwPos == nWordLen && nSwPos != 0)
return true;
}
@@ -840,7 +936,7 @@ bool SwWW8AttrIter::IsDropCap( int nSwPos )
bool SwWW8AttrIter::RequiresImplicitBookmark()
{
return std::any_of(m_rExport.m_aImplicitBookmarks.begin(), m_rExport.m_aImplicitBookmarks.end(),
- [this](const aBookmarkPair& rBookmarkPair) { return rBookmarkPair.second == rNd.GetIndex(); });
+ [this](const aBookmarkPair& rBookmarkPair) { return rBookmarkPair.second == m_rNode.GetIndex(); });
}
//HasItem is for the summary of the double attributes: Underline and WordlineMode as TextItems.
@@ -850,7 +946,7 @@ bool SwWW8AttrIter::RequiresImplicitBookmark()
const SfxPoolItem* SwWW8AttrIter::HasTextItem( sal_uInt16 nWhich ) const
{
const SfxPoolItem* pRet = nullptr;
- const SwpHints* pTextAttrs = rNd.GetpSwpHints();
+ const SwpHints* pTextAttrs = m_rNode.GetpSwpHints();
if (pTextAttrs && !m_rExport.m_aCurrentCharPropStarts.empty())
{
const sal_Int32 nTmpSwPos = m_rExport.m_aCurrentCharPropStarts.top();
@@ -890,22 +986,27 @@ const SfxPoolItem* SwWW8AttrIter::HasTextItem( sal_uInt16 nWhich ) const
void WW8Export::GetCurrentItems(ww::bytes &rItems) const
{
- rItems.insert(rItems.end(), pO->begin(), pO->end());
+ rItems.insert(rItems.end(), m_pO->begin(), m_pO->end());
}
const SfxPoolItem& SwWW8AttrIter::GetItem(sal_uInt16 nWhich) const
{
const SfxPoolItem* pRet = HasTextItem(nWhich);
- return pRet ? *pRet : rNd.SwContentNode::GetAttr(nWhich);
+ return pRet ? *pRet : m_rNode.SwContentNode::GetAttr(nWhich);
}
void WW8AttributeOutput::StartRuby( const SwTextNode& rNode, sal_Int32 /*nPos*/, const SwFormatRuby& rRuby )
{
WW8Ruby aWW8Ruby(rNode, rRuby, GetExport());
- OUString aStr( FieldString( ww::eEQ ) + "\\* jc" );
- aStr += OUString::number(aWW8Ruby.GetJC()) + " \\* \"Font:";
- aStr += aWW8Ruby.GetFontFamily() + "\" \\* hps";
- aStr += OUString::number((aWW8Ruby.GetRubyHeight() + 5) / 10) + " \\o";
+ OUString aStr =
+ FieldString( ww::eEQ )
+ + "\\* jc"
+ + OUString::number(aWW8Ruby.GetJC())
+ + " \\* \"Font:"
+ + aWW8Ruby.GetFontFamily()
+ + "\" \\* hps"
+ + OUString::number((aWW8Ruby.GetRubyHeight() + 5) / 10)
+ + " \\o";
if (aWW8Ruby.GetDirective())
{
aStr += OUString::Concat(u"\\a") + OUStringChar(aWW8Ruby.GetDirective());
@@ -914,7 +1015,7 @@ void WW8AttributeOutput::StartRuby( const SwTextNode& rNode, sal_Int32 /*nPos*/,
aStr += rRuby.GetText() + ")";
// The parameter separator depends on the FIB.lid
- if ( m_rWW8Export.pFib->getNumDecimalSep() == '.' )
+ if ( m_rWW8Export.m_pFib->getNumDecimalSep() == '.' )
aStr += ",";
else
aStr += ";";
@@ -929,15 +1030,6 @@ void WW8AttributeOutput::EndRuby(const SwTextNode& /*rNode*/, sal_Int32 /*nPos*/
m_rWW8Export.OutputField( nullptr, ww::eEQ, OUString(), FieldFlags::End | FieldFlags::Close );
}
-/*#i15387# Better ideas welcome*/
-static OUString &TruncateBookmark( OUString &rRet )
-{
- if ( rRet.getLength() > 40 )
- rRet = rRet.copy( 0, 40 );
- OSL_ENSURE( rRet.getLength() <= 40, "Word cannot have bookmarks longer than 40 chars" );
- return rRet;
-}
-
OUString AttributeOutputBase::ConvertURL( const OUString& rUrl, bool bAbsoluteOut )
{
OUString sURL = rUrl;
@@ -991,7 +1083,7 @@ bool AttributeOutputBase::AnalyzeURL( const OUString& rUrl, const OUString& /*rT
{
if ( rBookmarkPair.first == sMark )
{
- sMark = "_toc" + OUString::number( rBookmarkPair.second );
+ sMark = "_toc" + OUString::number( sal_Int32(rBookmarkPair.second) );
break;
}
}
@@ -1000,14 +1092,14 @@ bool AttributeOutputBase::AnalyzeURL( const OUString& rUrl, const OUString& /*rT
else
{
INetURLObject aURL( rUrl, INetProtocol::NotValid );
- sURL = aURL.GetURLNoMark( INetURLObject::DecodeMechanism::Unambiguous );
- sMark = aURL.GetMark( INetURLObject::DecodeMechanism::Unambiguous );
+ sURL = aURL.GetURLNoMark( INetURLObject::DecodeMechanism::NONE );
+ sMark = aURL.GetMark( INetURLObject::DecodeMechanism::NONE );
INetProtocol aProtocol = aURL.GetProtocol();
if ( aProtocol == INetProtocol::File || aProtocol == INetProtocol::NotValid )
{
// INetProtocol::NotValid - may be a relative link
- bool bExportRelative = m_aSaveOpt.IsSaveRelFSys();
+ bool bExportRelative = officecfg::Office::Common::Save::URL::FileSystem::get();
sURL = ConvertURL( rUrl, !bExportRelative );
}
}
@@ -1029,8 +1121,11 @@ bool WW8AttributeOutput::AnalyzeURL( const OUString& rUrl, const OUString& rTarg
if ( !sURL.isEmpty() )
sURL = URIHelper::simpleNormalizedMakeRelative( m_rWW8Export.GetWriter().GetBaseURL(), sURL );
- if ( bBookMarkOnly )
- sURL = FieldString( ww::eHYPERLINK );
+ if (bBookMarkOnly)
+ {
+ sURL = FieldString(ww::eHYPERLINK);
+ *pMark = GetExport().BookmarkToWord(*pMark);
+ }
else
sURL = FieldString( ww::eHYPERLINK ) + "\"" + sURL + "\"";
@@ -1062,7 +1157,7 @@ bool WW8AttributeOutput::StartURL( const OUString &rUrl, const OUString &rTarget
m_rWW8Export.OutputField( nullptr, ww::eHYPERLINK, sURL, FieldFlags::Start | FieldFlags::CmdStart );
// write the reference to the "picture" structure
- sal_uLong nDataStt = m_rWW8Export.pDataStrm->Tell();
+ sal_uInt64 nDataStt = m_rWW8Export.m_pDataStrm->Tell();
m_rWW8Export.m_pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell() );
// WinWord 2000 doesn't write this - so it's a temp solution by W97 ?
@@ -1107,22 +1202,22 @@ bool WW8AttributeOutput::StartURL( const OUString &rUrl, const OUString &rTarget
0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B
};
- m_rWW8Export.pDataStrm->WriteBytes(aURLData1, sizeof(aURLData1));
+ m_rWW8Export.m_pDataStrm->WriteBytes(aURLData1, sizeof(aURLData1));
/* Write HFD Structure */
sal_uInt8 nAnchor = 0x00;
if ( !sMark.isEmpty() )
nAnchor = 0x08;
- m_rWW8Export.pDataStrm->WriteUChar(nAnchor); // HFDBits
- m_rWW8Export.pDataStrm->WriteBytes(MAGIC_A, sizeof(MAGIC_A)); //clsid
+ m_rWW8Export.m_pDataStrm->WriteUChar(nAnchor); // HFDBits
+ m_rWW8Export.m_pDataStrm->WriteBytes(MAGIC_A, sizeof(MAGIC_A)); //clsid
/* Write Hyperlink Object see [MS-OSHARED] spec*/
- SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, 0x00000002);
+ SwWW8Writer::WriteLong( *m_rWW8Export.m_pDataStrm, 0x00000002);
sal_uInt32 nFlag = bBookMarkOnly ? 0 : 0x01;
if ( bAbsolute )
nFlag |= 0x02;
if ( !sMark.isEmpty() )
nFlag |= 0x08;
- SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, nFlag );
+ SwWW8Writer::WriteLong( *m_rWW8Export.m_pDataStrm, nFlag );
INetProtocol eProto = aURL.GetProtocol();
if ( eProto == INetProtocol::File || eProto == INetProtocol::Smb )
@@ -1165,16 +1260,16 @@ bool WW8AttributeOutput::StartURL( const OUString &rUrl, const OUString &rTarget
sURL = sURL.copy( sizeof(pSmb)-3 ).replaceAll( "/", "\\" );
}
- m_rWW8Export.pDataStrm->WriteBytes(MAGIC_C, sizeof(MAGIC_C));
- SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, sURL.getLength()+1 );
- SwWW8Writer::WriteString8( *m_rWW8Export.pDataStrm, sURL, true,
+ m_rWW8Export.m_pDataStrm->WriteBytes(MAGIC_C, sizeof(MAGIC_C));
+ SwWW8Writer::WriteLong( *m_rWW8Export.m_pDataStrm, sURL.getLength()+1 );
+ SwWW8Writer::WriteString8( *m_rWW8Export.m_pDataStrm, sURL, true,
RTL_TEXTENCODING_MS_1252 );
- m_rWW8Export.pDataStrm->WriteBytes(MAGIC_D, sizeof(MAGIC_D));
+ m_rWW8Export.m_pDataStrm->WriteBytes(MAGIC_D, sizeof(MAGIC_D));
- SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, 2*sURL.getLength() + 6 );
- SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, 2*sURL.getLength() );
- SwWW8Writer::WriteShort( *m_rWW8Export.pDataStrm, 3 );
- SwWW8Writer::WriteString16( *m_rWW8Export.pDataStrm, sURL, false );
+ SwWW8Writer::WriteLong( *m_rWW8Export.m_pDataStrm, 2*sURL.getLength() + 6 );
+ SwWW8Writer::WriteLong( *m_rWW8Export.m_pDataStrm, 2*sURL.getLength() );
+ SwWW8Writer::WriteShort( *m_rWW8Export.m_pDataStrm, 3 );
+ SwWW8Writer::WriteString16( *m_rWW8Export.m_pDataStrm, sURL, false );
}
else if ( eProto != INetProtocol::NotValid )
{
@@ -1187,18 +1282,18 @@ bool WW8AttributeOutput::StartURL( const OUString &rUrl, const OUString &rTarget
0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B
};
- m_rWW8Export.pDataStrm->WriteBytes(MAGIC_B, sizeof(MAGIC_B));
- SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, 2 * ( sURL.getLength() + 1 ) );
- SwWW8Writer::WriteString16( *m_rWW8Export.pDataStrm, sURL, true );
+ m_rWW8Export.m_pDataStrm->WriteBytes(MAGIC_B, sizeof(MAGIC_B));
+ SwWW8Writer::WriteLong( *m_rWW8Export.m_pDataStrm, 2 * ( sURL.getLength() + 1 ) );
+ SwWW8Writer::WriteString16( *m_rWW8Export.m_pDataStrm, sURL, true );
}
if ( !sMark.isEmpty() )
{
- SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, sMark.getLength()+1 );
- SwWW8Writer::WriteString16( *m_rWW8Export.pDataStrm, sMark, true );
+ SwWW8Writer::WriteLong( *m_rWW8Export.m_pDataStrm, sMark.getLength()+1 );
+ SwWW8Writer::WriteString16( *m_rWW8Export.m_pDataStrm, sMark, true );
}
- SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, nDataStt,
- m_rWW8Export.pDataStrm->Tell() - nDataStt );
+ SwWW8Writer::WriteLong( *m_rWW8Export.m_pDataStrm, nDataStt,
+ m_rWW8Export.m_pDataStrm->Tell() - nDataStt );
return true;
}
@@ -1210,17 +1305,6 @@ bool WW8AttributeOutput::EndURL(bool const)
return true;
}
-OUString BookmarkToWord(const OUString &rBookmark)
-{
- OUString sRet(INetURLObject::encode(
- rBookmark.replace(' ', '_'), // Spaces are prohibited in bookmark name
- INetURLObject::PART_REL_SEGMENT_EXTRA,
- INetURLObject::EncodeMechanism::All, RTL_TEXTENCODING_ASCII_US));
- // Unicode letters are allowed
- sRet = INetURLObject::decode(sRet, INetURLObject::DecodeMechanism::Unambiguous, RTL_TEXTENCODING_UTF8);
- return TruncateBookmark(sRet);
-}
-
OUString BookmarkToWriter(std::u16string_view rBookmark)
{
return INetURLObject::decode(rBookmark,
@@ -1230,7 +1314,7 @@ OUString BookmarkToWriter(std::u16string_view rBookmark)
void SwWW8AttrIter::OutSwFormatRefMark(const SwFormatRefMark& rAttr)
{
if(m_rExport.HasRefToAttr(rAttr.GetRefName()))
- m_rExport.AppendBookmark( MSWordExportBase::GetBookmarkName( REF_SETREFATTR,
+ m_rExport.AppendBookmark( m_rExport.GetBookmarkName( REF_SETREFATTR,
&rAttr.GetRefName(), 0 ));
}
@@ -1246,10 +1330,10 @@ void SwWW8AttrIter::SplitRun( sal_Int32 nSplitEndPos )
maCharRuns.insert( ++aIter, aNewEntry);
maCharRunIter = maCharRuns.begin();
IterToCurrent();
- nCurrentSwPos = SearchNext(1);
+ m_nCurrentSwPos = SearchNext(1);
}
-void WW8AttributeOutput::FieldVanish(const OUString& rText, ww::eField /*eType*/, OUString const*const)
+void WW8AttributeOutput::FieldVanish(const OUString& rText, ww::eField /*eType*/, OUString const*const /*pBookmarkName*/)
{
ww::bytes aItems;
m_rWW8Export.GetCurrentItems( aItems );
@@ -1291,7 +1375,17 @@ void AttributeOutputBase::TOXMark( const SwTextNode& rNode, const SwTOXMark& rAt
else
sText = rAttr.GetAlternativeText();
- switch ( rAttr.GetTOXType()->GetType() )
+ OUString sUserTypeName;
+ auto aType = rAttr.GetTOXType()->GetType();
+ // user index mark, it needs XE with \f
+ if ( TOX_USER == aType )
+ {
+ sUserTypeName = rAttr.GetTOXType()->GetTypeName();
+ if ( !sUserTypeName.isEmpty() )
+ aType = TOX_INDEX;
+ }
+
+ switch ( aType )
{
case TOX_INDEX:
eType = ww::eXE;
@@ -1305,6 +1399,11 @@ void AttributeOutputBase::TOXMark( const SwTextNode& rNode, const SwTOXMark& rAt
sText = rAttr.GetPrimaryKey() + ":" + sText;
}
sText = " XE \"" + sText + "\" ";
+
+ if (!sUserTypeName.isEmpty())
+ {
+ sText += "\\f \"" + sUserTypeName + "\" ";
+ }
break;
case TOX_USER:
@@ -1341,7 +1440,7 @@ void AttributeOutputBase::TOXMark( const SwTextNode& rNode, const SwTOXMark& rAt
int SwWW8AttrIter::OutAttrWithRange(const SwTextNode& rNode, sal_Int32 nPos)
{
int nRet = 0;
- if ( const SwpHints* pTextAttrs = rNd.GetpSwpHints() )
+ if ( const SwpHints* pTextAttrs = m_rNode.GetpSwpHints() )
{
m_rExport.m_aCurrentCharPropStarts.push( nPos );
const sal_Int32* pEnd;
@@ -1356,7 +1455,7 @@ int SwWW8AttrIter::OutAttrWithRange(const SwTextNode& rNode, sal_Int32 nPos)
pEnd = pHt->End();
if (nPos == *pEnd && nPos != pHt->GetStart())
{
- if (m_rExport.AttrOutput().EndURL(nPos == rNd.Len()))
+ if (m_rExport.AttrOutput().EndURL(nPos == m_rNode.Len()))
--nRet;
}
break;
@@ -1396,7 +1495,7 @@ int SwWW8AttrIter::OutAttrWithRange(const SwTextNode& rNode, sal_Int32 nPos)
pEnd = pHt->End();
if (nPos == *pEnd && nPos == pHt->GetStart())
{ // special case: empty must be handled here
- if (m_rExport.AttrOutput().EndURL(nPos == rNd.Len()))
+ if (m_rExport.AttrOutput().EndURL(nPos == m_rNode.Len()))
--nRet;
}
break;
@@ -1415,18 +1514,18 @@ int SwWW8AttrIter::OutAttrWithRange(const SwTextNode& rNode, sal_Int32 nPos)
break;
case RES_TXTATR_TOXMARK:
if ( nPos == pHt->GetStart() )
- m_rExport.AttrOutput().TOXMark( rNd, *static_cast< const SwTOXMark* >( pItem ) );
+ m_rExport.AttrOutput().TOXMark( m_rNode, *static_cast< const SwTOXMark* >( pItem ) );
break;
case RES_TXTATR_CJK_RUBY:
if ( nPos == pHt->GetStart() )
{
- m_rExport.AttrOutput().StartRuby( rNd, nPos, *static_cast< const SwFormatRuby* >( pItem ) );
+ m_rExport.AttrOutput().StartRuby( m_rNode, nPos, *static_cast< const SwFormatRuby* >( pItem ) );
++nRet;
}
pEnd = pHt->End();
if (nPos == *pEnd && nPos == pHt->GetStart())
{ // special case: empty must be handled here
- m_rExport.AttrOutput().EndRuby( rNd, nPos );
+ m_rExport.AttrOutput().EndRuby( m_rNode, nPos );
--nRet;
}
break;
@@ -1442,7 +1541,7 @@ int SwWW8AttrIter::OutAttrWithRange(const SwTextNode& rNode, sal_Int32 nPos)
bool SwWW8AttrIter::IncludeEndOfParaCRInRedlineProperties( sal_Int32 nEnd ) const
{
// search next Redline
- for( SwRedlineTable::size_type nPos = nCurRedlinePos;
+ for( SwRedlineTable::size_type nPos = m_nCurRedlinePos;
nPos < m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().size(); ++nPos )
{
const SwRangeRedline *pRange = m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[nPos];
@@ -1453,9 +1552,9 @@ bool SwWW8AttrIter::IncludeEndOfParaCRInRedlineProperties( sal_Int32 nEnd ) cons
// Here we find out if the para end marker we will emit is affected by
// redlining, in which case it must be included by the range of character
// attributes that contains the redlining information.
- if (pEnd->nNode == rNd)
+ if (pEnd->GetNode() == m_rNode)
{
- if (pEnd->nContent.GetIndex() == nEnd)
+ if (pEnd->GetContentIndex() == nEnd)
{
// This condition detects if the pseudo-char we will export
// should be explicitly included by the redlining char
@@ -1465,9 +1564,9 @@ bool SwWW8AttrIter::IncludeEndOfParaCRInRedlineProperties( sal_Int32 nEnd ) cons
}
bBreak = false;
}
- if (pStart->nNode == rNd)
+ if (pStart->GetNode() == m_rNode)
{
- if (pStart->nContent.GetIndex() == nEnd)
+ if (pStart->GetContentIndex() == nEnd)
{
// This condition detects if the pseudo-char we will export
// should be explicitly included by the redlining char
@@ -1477,9 +1576,9 @@ bool SwWW8AttrIter::IncludeEndOfParaCRInRedlineProperties( sal_Int32 nEnd ) cons
}
bBreak = false;
}
- if (pStart->nNode.GetIndex()-1 == rNd.GetIndex())
+ if (pStart->GetNodeIndex()-1 == m_rNode.GetIndex())
{
- if (pStart->nContent.GetIndex() == 0)
+ if (pStart->GetContentIndex() == 0)
{
// This condition detects if the pseudo-char we will export
// should be implicitly excluded by the redlining char
@@ -1497,14 +1596,14 @@ bool SwWW8AttrIter::IncludeEndOfParaCRInRedlineProperties( sal_Int32 nEnd ) cons
const SwRedlineData* SwWW8AttrIter::GetParagraphLevelRedline( )
{
- pCurRedline = nullptr;
+ m_pCurRedline = nullptr;
// ToDo : this is not the most ideal ... should start maybe from 'nCurRedlinePos'
for(SwRangeRedline* pRedl : m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable())
{
const SwPosition* pCheckedStt = pRedl->Start();
- if( pCheckedStt->nNode == rNd )
+ if( pCheckedStt->GetNode() == m_rNode )
{
// Maybe add here a check that also the start & end of the redline is the entire paragraph
@@ -1512,8 +1611,8 @@ const SwRedlineData* SwWW8AttrIter::GetParagraphLevelRedline( )
if (pRedl->GetType() == RedlineType::ParagraphFormat)
{
// write data of this redline
- pCurRedline = pRedl;
- return &( pCurRedline->GetRedlineData() );
+ m_pCurRedline = pRedl;
+ return &( m_pCurRedline->GetRedlineData() );
}
}
}
@@ -1522,43 +1621,40 @@ const SwRedlineData* SwWW8AttrIter::GetParagraphLevelRedline( )
const SwRedlineData* SwWW8AttrIter::GetRunLevelRedline( sal_Int32 nPos )
{
- if( pCurRedline )
+ if( m_pCurRedline )
{
- const SwPosition* pEnd = pCurRedline->End();
- if (pEnd->nNode != rNd || pEnd->nContent.GetIndex() > nPos)
+ const SwPosition* pEnd = m_pCurRedline->End();
+ if (pEnd->GetNode() != m_rNode || pEnd->GetContentIndex() > nPos)
{
- switch( pCurRedline->GetType() )
+ switch( m_pCurRedline->GetType() )
{
case RedlineType::Insert:
case RedlineType::Delete:
case RedlineType::Format:
// write data of this redline
- return &( pCurRedline->GetRedlineData() );
+ return &( m_pCurRedline->GetRedlineData() );
default:
break;
}
}
- pCurRedline = nullptr;
- ++nCurRedlinePos;
+ m_pCurRedline = nullptr;
+ ++m_nCurRedlinePos;
}
- assert(!pCurRedline);
+ assert(!m_pCurRedline);
// search next Redline
- for( ; nCurRedlinePos < m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().size();
- ++nCurRedlinePos )
+ for( ; m_nCurRedlinePos < m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().size();
+ ++m_nCurRedlinePos )
{
- const SwRangeRedline* pRedl = m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ nCurRedlinePos ];
+ const SwRangeRedline* pRedl = m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ m_nCurRedlinePos ];
- const SwPosition* pStt = pRedl->Start();
- const SwPosition* pEnd = pStt == pRedl->GetPoint()
- ? pRedl->GetMark()
- : pRedl->GetPoint();
+ auto [pStt, pEnd] = pRedl->StartEnd(); // SwPosition*
- if( pStt->nNode == rNd )
+ if( pStt->GetNode() == m_rNode )
{
- if( pStt->nContent.GetIndex() >= nPos )
+ if( pStt->GetContentIndex() >= nPos )
{
- if( pStt->nContent.GetIndex() == nPos )
+ if( pStt->GetContentIndex() == nPos )
{
switch( pRedl->GetType() )
{
@@ -1566,8 +1662,8 @@ const SwRedlineData* SwWW8AttrIter::GetRunLevelRedline( sal_Int32 nPos )
case RedlineType::Delete:
case RedlineType::Format:
// write data of this redline
- pCurRedline = pRedl;
- return &( pCurRedline->GetRedlineData() );
+ m_pCurRedline = pRedl;
+ return &( m_pCurRedline->GetRedlineData() );
default:
break;
}
@@ -1580,10 +1676,10 @@ const SwRedlineData* SwWW8AttrIter::GetRunLevelRedline( sal_Int32 nPos )
break;
}
- if( pEnd->nNode == rNd &&
- pEnd->nContent.GetIndex() < nPos )
+ if( pEnd->GetNode() == m_rNode &&
+ pEnd->GetContentIndex() < nPos )
{
- pCurRedline = pRedl;
+ m_pCurRedline = pRedl;
break;
}
}
@@ -1648,9 +1744,9 @@ SvxFrameDirection MSWordExportBase::TrueFrameDirection( const SwFrameFormat &rFl
pItem = nullptr;
const SwFormatAnchor* pAnchor = &pFlyFormat->GetAnchor();
if ((RndStdIds::FLY_AT_PAGE != pAnchor->GetAnchorId()) &&
- pAnchor->GetContentAnchor() )
+ pAnchor->GetAnchorNode() )
{
- pFlyFormat = pAnchor->GetContentAnchor()->nNode.GetNode().GetFlyFormat();
+ pFlyFormat = pAnchor->GetAnchorNode()->GetFlyFormat();
}
else
pFlyFormat = nullptr;
@@ -1675,15 +1771,13 @@ const SvxBrushItem* WW8Export::GetCurrentPageBgBrush() const
? m_pCurrentPageDesc->GetMaster()
: m_rDoc.GetPageDesc(0).GetMaster();
- const SfxPoolItem* pItem = nullptr;
//If not set, or "no fill", get real bg
- SfxItemState eState = rFormat.GetItemState(RES_BACKGROUND, true, &pItem);
+ const SvxBrushItem* pRet = rFormat.GetItemIfSet(RES_BACKGROUND);
- const SvxBrushItem* pRet = static_cast<const SvxBrushItem*>(pItem);
- if (SfxItemState::SET != eState || !pRet || (!pRet->GetGraphic() &&
- pRet->GetColor() == COL_TRANSPARENT))
+ if (!pRet ||
+ (!pRet->GetGraphic() && pRet->GetColor() == COL_TRANSPARENT))
{
- pRet = &(DefaultItemGet<SvxBrushItem>(m_rDoc,RES_BACKGROUND));
+ pRet = &m_rDoc.GetAttrPool().GetUserOrPoolDefaultItem(RES_BACKGROUND);
}
return pRet;
}
@@ -1696,20 +1790,17 @@ std::shared_ptr<SvxBrushItem> WW8Export::TrueFrameBgBrush(const SwFrameFormat &r
while (pFlyFormat)
{
//If not set, or "no fill", get real bg
- const SfxPoolItem* pItem = nullptr;
- SfxItemState eState =
- pFlyFormat->GetItemState(RES_BACKGROUND, true, &pItem);
- pRet = static_cast<const SvxBrushItem*>(pItem);
- if (SfxItemState::SET != eState || !pRet || (!pRet->GetGraphic() &&
+ pRet = pFlyFormat->GetItemIfSet(RES_BACKGROUND);
+ if (!pRet || (!pRet->GetGraphic() &&
pRet->GetColor() == COL_TRANSPARENT))
{
pRet = nullptr;
const SwFormatAnchor* pAnchor = &pFlyFormat->GetAnchor();
if ((RndStdIds::FLY_AT_PAGE != pAnchor->GetAnchorId()) &&
- pAnchor->GetContentAnchor())
+ pAnchor->GetAnchorNode())
{
pFlyFormat =
- pAnchor->GetContentAnchor()->nNode.GetNode().GetFlyFormat();
+ pAnchor->GetAnchorNode()->GetFlyFormat();
}
else
pFlyFormat = nullptr;
@@ -1750,6 +1841,12 @@ OUString SwWW8AttrIter::GetSnippet(const OUString &rStr, sal_Int32 nCurrentPos,
aSnippet = aSnippet.replace(0x0A, 0x0B);
aSnippet = aSnippet.replace(CHAR_HARDHYPHEN, 0x1e);
aSnippet = aSnippet.replace(CHAR_SOFTHYPHEN, 0x1f);
+ // Ignore the dummy character at the end of content controls.
+ static sal_Unicode const aForbidden[] = {
+ CH_TXTATR_BREAKWORD,
+ 0
+ };
+ aSnippet = comphelper::string::removeAny(aSnippet, aForbidden);
m_rExport.m_aCurrentCharPropStarts.push( nCurrentPos );
const SfxPoolItem &rItem = GetItem(RES_CHRATR_CASEMAP);
@@ -1807,16 +1904,13 @@ static SwTextFormatColl& lcl_getFormatCollection( MSWordExportBase& rExport, con
while( nPos < nMax )
{
const SwRangeRedline* pRedl = rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ nPos++ ];
- const SwPosition* pStt = pRedl->Start();
- const SwPosition* pEnd = pStt == pRedl->GetPoint()
- ? pRedl->GetMark()
- : pRedl->GetPoint();
+ auto [pStt, pEnd] = pRedl->StartEnd(); // SwPosition*
// Looking for deletions, which ends in current pTextNode
if( RedlineType::Delete == pRedl->GetRedlineData().GetType() &&
- pEnd->nNode == *pTextNode && pStt->nNode != *pTextNode &&
- pStt->nNode.GetNode().IsTextNode() )
+ pEnd->GetNode() == *pTextNode && pStt->GetNode() != *pTextNode &&
+ pStt->GetNode().IsTextNode() )
{
- pTextNode = pStt->nNode.GetNode().GetTextNode();
+ pTextNode = pStt->GetNode().GetTextNode();
nMax = nPos;
nPos = 0;
}
@@ -1833,13 +1927,13 @@ void WW8AttributeOutput::FormatDrop( const SwTextNode& rNode, const SwFormatDrop
SVBT16 nSty;
ShortToSVBT16( nStyle, nSty );
- m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), nSty, nSty+2 ); // Style #
+ m_rWW8Export.m_pO->insert( m_rWW8Export.m_pO->end(), nSty, nSty+2 ); // Style #
m_rWW8Export.InsUInt16( NS_sprm::PPc::val ); // Alignment (sprmPPc)
- m_rWW8Export.pO->push_back( 0x20 );
+ m_rWW8Export.m_pO->push_back( 0x20 );
m_rWW8Export.InsUInt16( NS_sprm::PWr::val ); // Wrapping (sprmPWr)
- m_rWW8Export.pO->push_back( 0x02 );
+ m_rWW8Export.m_pO->push_back( 0x02 );
m_rWW8Export.InsUInt16( NS_sprm::PDcs::val ); // Dropcap (sprmPDcs)
int nDCS = ( nDropLines << 3 ) | 0x01;
@@ -1865,8 +1959,8 @@ void WW8AttributeOutput::FormatDrop( const SwTextNode& rNode, const SwFormatDrop
TableInfoCell( pTextNodeInfoInner );
}
- m_rWW8Export.m_pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
- m_rWW8Export.pO->clear();
+ m_rWW8Export.m_pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.m_pO->size(), m_rWW8Export.m_pO->data() );
+ m_rWW8Export.m_pO->clear();
if ( rNode.GetDropSize( rFontHeight, rDropHeight, rDropDescent ) )
{
@@ -1884,8 +1978,8 @@ void WW8AttributeOutput::FormatDrop( const SwTextNode& rNode, const SwFormatDrop
m_rWW8Export.InsUInt16( static_cast< sal_uInt16 >( rFontHeight / 10 ) );
}
- m_rWW8Export.m_pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
- m_rWW8Export.pO->clear();
+ m_rWW8Export.m_pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.m_pO->size(), m_rWW8Export.m_pO->data() );
+ m_rWW8Export.m_pO->clear();
}
sal_Int32 MSWordExportBase::GetNextPos( SwWW8AttrIter const * aAttrIter, const SwTextNode& rNode, sal_Int32 nCurrentPos )
@@ -1921,7 +2015,6 @@ bool MSWordExportBase::GetBookmarks( const SwTextNode& rNd, sal_Int32 nStt,
sal_Int32 nEnd, IMarkVector& rArr )
{
IDocumentMarkAccess* const pMarkAccess = m_rDoc.getIDocumentMarkAccess();
- sal_uLong nNd = rNd.GetIndex( );
const sal_Int32 nMarks = pMarkAccess->getAllMarksCount();
for ( sal_Int32 i = 0; i < nMarks; i++ )
@@ -1946,15 +2039,15 @@ bool MSWordExportBase::GetBookmarks( const SwTextNode& rNd, sal_Int32 nStt,
}
// Only keep the bookmarks starting or ending in this node
- if ( pMark->GetMarkStart().nNode == nNd ||
- pMark->GetMarkEnd().nNode == nNd )
+ if ( pMark->GetMarkStart().GetNode() == rNd ||
+ pMark->GetMarkEnd().GetNode() == rNd )
{
- const sal_Int32 nBStart = pMark->GetMarkStart().nContent.GetIndex();
- const sal_Int32 nBEnd = pMark->GetMarkEnd().nContent.GetIndex();
+ const sal_Int32 nBStart = pMark->GetMarkStart().GetContentIndex();
+ const sal_Int32 nBEnd = pMark->GetMarkEnd().GetContentIndex();
// Keep only the bookmarks starting or ending in the snippet
- bool bIsStartOk = ( pMark->GetMarkStart().nNode == nNd ) && ( nBStart >= nStt ) && ( nBStart <= nEnd );
- bool bIsEndOk = ( pMark->GetMarkEnd().nNode == nNd ) && ( nBEnd >= nStt ) && ( nBEnd <= nEnd );
+ bool bIsStartOk = ( pMark->GetMarkStart().GetNode() == rNd ) && ( nBStart >= nStt ) && ( nBStart <= nEnd );
+ bool bIsEndOk = ( pMark->GetMarkEnd().GetNode() == rNd ) && ( nBEnd >= nStt ) && ( nBEnd <= nEnd );
if ( bIsStartOk || bIsEndOk )
{
@@ -1969,7 +2062,7 @@ bool MSWordExportBase::GetAnnotationMarks( const SwWW8AttrIter& rAttrs, sal_Int3
sal_Int32 nEnd, IMarkVector& rArr )
{
IDocumentMarkAccess* const pMarkAccess = m_rDoc.getIDocumentMarkAccess();
- sal_uLong nNd = rAttrs.GetNode().GetIndex();
+ const SwNode& rNd = rAttrs.GetNode();
const sal_Int32 nMarks = pMarkAccess->getAnnotationMarksCount();
for ( sal_Int32 i = 0; i < nMarks; i++ )
@@ -1977,20 +2070,20 @@ bool MSWordExportBase::GetAnnotationMarks( const SwWW8AttrIter& rAttrs, sal_Int3
IMark* pMark = pMarkAccess->getAnnotationMarksBegin()[i];
// Only keep the bookmarks starting or ending in this node
- if ( pMark->GetMarkStart().nNode == nNd ||
- pMark->GetMarkEnd().nNode == nNd )
+ if ( pMark->GetMarkStart().GetNode() == rNd ||
+ pMark->GetMarkEnd().GetNode() == rNd )
{
- const sal_Int32 nBStart = pMark->GetMarkStart().nContent.GetIndex();
- const sal_Int32 nBEnd = pMark->GetMarkEnd().nContent.GetIndex();
+ const sal_Int32 nBStart = pMark->GetMarkStart().GetContentIndex();
+ const sal_Int32 nBEnd = pMark->GetMarkEnd().GetContentIndex();
// Keep only the bookmarks starting or ending in the snippet
- bool bIsStartOk = ( pMark->GetMarkStart().nNode == nNd ) && ( nBStart >= nStt ) && ( nBStart <= nEnd );
- bool bIsEndOk = ( pMark->GetMarkEnd().nNode == nNd ) && ( nBEnd >= nStt ) && ( nBEnd <= nEnd );
+ bool bIsStartOk = ( pMark->GetMarkStart().GetNode() == rNd ) && ( nBStart >= nStt ) && ( nBStart <= nEnd );
+ bool bIsEndOk = ( pMark->GetMarkEnd().GetNode() == rNd ) && ( nBEnd >= nStt ) && ( nBEnd <= nEnd );
// Annotation marks always have at least one character: the anchor
// point of the comment field. In this case Word wants only the
// comment field, so ignore the annotation mark itself.
- bool bSingleChar = pMark->GetMarkStart().nNode == pMark->GetMarkEnd().nNode && nBStart + 1 == nBEnd;
+ bool bSingleChar = pMark->GetMarkStart().GetNode() == pMark->GetMarkEnd().GetNode() && nBStart + 1 == nBEnd;
if (bSingleChar)
{
@@ -2018,8 +2111,8 @@ class CompareMarksEnd
public:
bool operator() ( const IMark * pOneB, const IMark * pTwoB ) const
{
- const sal_Int32 nOEnd = pOneB->GetMarkEnd().nContent.GetIndex();
- const sal_Int32 nTEnd = pTwoB->GetMarkEnd().nContent.GetIndex();
+ const sal_Int32 nOEnd = pOneB->GetMarkEnd().GetContentIndex();
+ const sal_Int32 nTEnd = pTwoB->GetMarkEnd().GetContentIndex();
return nOEnd < nTEnd;
}
@@ -2034,7 +2127,7 @@ bool MSWordExportBase::NearestBookmark( sal_Int32& rNearest, const sal_Int32 nCu
if ( !m_rSortedBookmarksStart.empty() )
{
IMark* pMarkStart = m_rSortedBookmarksStart.front();
- const sal_Int32 nNext = pMarkStart->GetMarkStart().nContent.GetIndex();
+ const sal_Int32 nNext = pMarkStart->GetMarkStart().GetContentIndex();
if( !bNextPositionOnly || (nNext > nCurrentPos ))
{
rNearest = nNext;
@@ -2045,7 +2138,7 @@ bool MSWordExportBase::NearestBookmark( sal_Int32& rNearest, const sal_Int32 nCu
if ( !m_rSortedBookmarksEnd.empty() )
{
IMark* pMarkEnd = m_rSortedBookmarksEnd[0];
- const sal_Int32 nNext = pMarkEnd->GetMarkEnd().nContent.GetIndex();
+ const sal_Int32 nNext = pMarkEnd->GetMarkEnd().GetContentIndex();
if( !bNextPositionOnly || nNext > nCurrentPos )
{
if ( !bHasBookmark )
@@ -2066,7 +2159,7 @@ void MSWordExportBase::NearestAnnotationMark( sal_Int32& rNearest, const sal_Int
if ( !m_rSortedAnnotationMarksStart.empty() )
{
IMark* pMarkStart = m_rSortedAnnotationMarksStart.front();
- const sal_Int32 nNext = pMarkStart->GetMarkStart().nContent.GetIndex();
+ const sal_Int32 nNext = pMarkStart->GetMarkStart().GetContentIndex();
if( !bNextPositionOnly || (nNext > nCurrentPos ))
{
rNearest = nNext;
@@ -2077,7 +2170,7 @@ void MSWordExportBase::NearestAnnotationMark( sal_Int32& rNearest, const sal_Int
if ( !m_rSortedAnnotationMarksEnd.empty() )
{
IMark* pMarkEnd = m_rSortedAnnotationMarksEnd[0];
- const sal_Int32 nNext = pMarkEnd->GetMarkEnd().nContent.GetIndex();
+ const sal_Int32 nNext = pMarkEnd->GetMarkEnd().GetContentIndex();
if( !bNextPositionOnly || nNext > nCurrentPos )
{
if ( !bHasAnnotationMark )
@@ -2098,14 +2191,14 @@ void MSWordExportBase::GetSortedAnnotationMarks( const SwWW8AttrIter& rAttrs, sa
for ( IMark* pMark : aMarksStart )
{
// Remove the positions equal to the current pos
- const sal_Int32 nStart = pMark->GetMarkStart().nContent.GetIndex();
- const sal_Int32 nEnd = pMark->GetMarkEnd().nContent.GetIndex();
+ const sal_Int32 nStart = pMark->GetMarkStart().GetContentIndex();
+ const sal_Int32 nEnd = pMark->GetMarkEnd().GetContentIndex();
const SwTextNode& rNode = rAttrs.GetNode();
- if ( nStart > nCurrentPos && ( pMark->GetMarkStart().nNode == rNode.GetIndex()) )
+ if ( nStart > nCurrentPos && ( pMark->GetMarkStart().GetNode() == rNode) )
aSortedStart.push_back( pMark );
- if ( nEnd > nCurrentPos && nEnd <= ( nCurrentPos + nLen ) && (pMark->GetMarkEnd().nNode == rNode.GetIndex()) )
+ if ( nEnd > nCurrentPos && nEnd <= ( nCurrentPos + nLen ) && (pMark->GetMarkEnd().GetNode() == rNode) )
aSortedEnd.push_back( pMark );
}
@@ -2132,13 +2225,13 @@ void MSWordExportBase::GetSortedBookmarks( const SwTextNode& rNode, sal_Int32 nC
for ( IMark* pMark : aMarksStart )
{
// Remove the positions equal to the current pos
- const sal_Int32 nStart = pMark->GetMarkStart().nContent.GetIndex();
- const sal_Int32 nEnd = pMark->GetMarkEnd().nContent.GetIndex();
+ const sal_Int32 nStart = pMark->GetMarkStart().GetContentIndex();
+ const sal_Int32 nEnd = pMark->GetMarkEnd().GetContentIndex();
- if ( nStart > nCurrentPos && ( pMark->GetMarkStart().nNode == rNode.GetIndex()) )
+ if ( nStart > nCurrentPos && (pMark->GetMarkStart().GetNode() == rNode) )
aSortedStart.push_back( pMark );
- if ( nEnd > nCurrentPos && nEnd <= ( nCurrentPos + nLen ) && (pMark->GetMarkEnd().nNode == rNode.GetIndex()) )
+ if ( nEnd > nCurrentPos && nEnd <= ( nCurrentPos + nLen ) && (pMark->GetMarkEnd().GetNode() == rNode) )
aSortedEnd.push_back( pMark );
}
@@ -2186,14 +2279,14 @@ bool MSWordExportBase::NeedTextNodeSplit( const SwTextNode& rNd, SwSoftPageBreak
if (pos < it) // previous one might have skipped over it
{
pos = it;
- while (auto const*const pMark = rIDMA.getFieldmarkFor(SwPosition(const_cast<SwTextNode&>(rNd), pos)))
+ while (auto const*const pMark = rIDMA.getInnerFieldmarkFor(SwPosition(rNd, pos)))
{
- if (pMark->GetMarkEnd().nNode != rNd)
+ if (pMark->GetMarkEnd().GetNode() != rNd)
{
pos = rNd.Len(); // skip everything
break;
}
- pos = pMark->GetMarkEnd().nContent.GetIndex(); // no +1, it's behind the char
+ pos = pMark->GetMarkEnd().GetContentIndex(); // no +1, it's behind the char
}
pList.insert(pos);
}
@@ -2203,6 +2296,25 @@ bool MSWordExportBase::NeedTextNodeSplit( const SwTextNode& rNd, SwSoftPageBreak
return pList.size() > 2 && NeedSectionBreak( rNd );
}
+namespace {
+OUString lcl_GetSymbolFont(SwAttrPool& rPool, const SwTextNode* pTextNode, int nStart, int nEnd)
+{
+ SfxItemSetFixed<RES_CHRATR_FONT, RES_CHRATR_FONT> aSet( rPool );
+ if ( pTextNode && pTextNode->GetParaAttr(aSet, nStart, nEnd) )
+ {
+ SfxPoolItem const* pPoolItem = aSet.GetItem(RES_CHRATR_FONT);
+ if (pPoolItem)
+ {
+ const SvxFontItem* pFontItem = static_cast<const SvxFontItem*>(pPoolItem);
+ if (pFontItem->GetCharSet() == RTL_TEXTENCODING_SYMBOL)
+ return pFontItem->GetFamilyName();
+ }
+ }
+
+ return OUString();
+}
+}
+
void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
{
SAL_INFO( "sw.ww8", "<OutWW8_SwTextNode>" );
@@ -2284,7 +2396,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
if ( 0 == pLine->GetBoxPos( pBox ) && pBox->GetSttNd() )
{
// check if paragraph is first in that line:
- if ( 1 == ( rNode.GetIndex() - pBox->GetSttNd()->GetIndex() ) )
+ if ( SwNodeOffset(1) == ( rNode.GetIndex() - pBox->GetSttNd()->GetIndex() ) )
pLine->GetFrameFormat()->SetFormatAttr(SwFormatRowSplit(!bDontSplit));
}
}
@@ -2327,7 +2439,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
{
pTOXSect = &pTOXSectNd->GetSection();
- const SwNode* pNxt = rNode.GetNodes().GoNext( &aIdx );
+ const SwNode* pNxt = SwNodes::GoNext(&aIdx);
if( pNxt && pNxt->FindSectionNode() == pTOXSectNd )
pTOXSect = nullptr;
}
@@ -2336,7 +2448,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
if ( aAttrIter.RequiresImplicitBookmark() )
{
- OUString sBkmkName = "_toc" + OUString::number( rNode.GetIndex() );
+ OUString sBkmkName = "_toc" + OUString::number( sal_Int32(rNode.GetIndex()) );
// Add a bookmark converted to a Word name.
AppendBookmark( BookmarkToWord( sBkmkName ) );
}
@@ -2347,6 +2459,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
const OUString& aStr( rNode.GetText() );
sal_Int32 const nEnd = bNeedParaSplit ? *aBreakIt : aStr.getLength();
+ bool bIsEndOfCell = false;
bool bIncludeEndOfParaCRInRedlineProperties = false;
sal_Int32 nOpenAttrWithRange = 0;
@@ -2354,14 +2467,25 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
if ( pTextNodeInfo )
{
pTextNodeInfoInner = pTextNodeInfo->getFirstInner();
+ if (pTextNodeInfoInner && pTextNodeInfoInner->isEndOfCell())
+ bIsEndOfCell = true;
}
do {
const SwRedlineData* pRedlineData = aAttrIter.GetRunLevelRedline( nCurrentPos );
bool bPostponeWritingText = false ;
+ bool bStartedPostponedRunProperties = false;
OUString aSavedSnippet ;
+ // Don't redline content-controls--Word doesn't do them.
+ SwTextAttr* pAttr = rNode.GetTextAttrAt(nCurrentPos, RES_TXTATR_CONTENTCONTROL,
+ sw::GetTextAttrMode::Default);
+ if (pAttr && pAttr->GetStart() == nCurrentPos)
+ {
+ pRedlineData = nullptr;
+ }
+
sal_Int32 nNextAttr = GetNextPos( &aAttrIter, rNode, nCurrentPos );
// Skip un-exportable attributes.
@@ -2384,7 +2508,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
{
if( AttrOutput().FootnoteEndnoteRefTag() )
{
- AttrOutput().EndRun( &rNode, nCurrentPos, nNextAttr == nEnd );
+ AttrOutput().EndRun( &rNode, nCurrentPos, -1, nNextAttr == nEnd );
AttrOutput().StartRun( pRedlineData, nCurrentPos, bSingleEmptyRun );
}
}
@@ -2409,7 +2533,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
AttrOutput().SetAnchorIsLinkedToNode( bPostponeWritingText && (FLY_POSTPONED != nStateOfFlyFrame) );
// Append bookmarks in this range after flys, exclusive of final
// position of this range
- AppendBookmarks( rNode, nCurrentPos, nNextAttr - nCurrentPos );
+ AppendBookmarks( rNode, nCurrentPos, nNextAttr - nCurrentPos, pRedlineData );
// Sadly only possible for main or glossary document parts: ECMA-376 Part 1 sect. 11.3.2
if ( m_nTextTyp == TXT_MAINTEXT )
AppendAnnotationMarks(aAttrIter, nCurrentPos, nNextAttr - nCurrentPos);
@@ -2422,6 +2546,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
bool bTextAtr = aAttrIter.IsTextAttr( nCurrentPos );
nOpenAttrWithRange += aAttrIter.OutAttrWithRange( rNode, nCurrentPos );
+ OUString aSymbolFont;
sal_Int32 nLen = nNextAttr - nCurrentPos;
if ( !bTextAtr && nLen )
{
@@ -2438,14 +2563,14 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
&& nStateOfFlyFrame == FLY_PROCESSED)
{
// write flys in a separate run before field character
- AttrOutput().EndRun(&rNode, nCurrentPos, nNextAttr == nEnd);
+ AttrOutput().EndRun(&rNode, nCurrentPos, -1, nNextAttr == nEnd);
AttrOutput().StartRun(pRedlineData, nCurrentPos, bSingleEmptyRun);
}
IDocumentMarkAccess* const pMarkAccess = m_rDoc.getIDocumentMarkAccess();
if ( ch == CH_TXT_ATR_FIELDSTART )
{
- SwPosition aPosition( rNode, SwIndex( &rNode, nCurrentPos ) );
+ SwPosition aPosition( rNode, nCurrentPos );
::sw::mark::IFieldmark const*const pFieldmark = pMarkAccess->getFieldmarkAt(aPosition);
assert(pFieldmark);
@@ -2497,14 +2622,19 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
}
else if (ch == CH_TXT_ATR_FIELDSEP)
{
- SwPosition aPosition(rNode, SwIndex(&rNode, nCurrentPos));
+ SwPosition aPosition(rNode, nCurrentPos);
// the innermost field is the correct one
- ::sw::mark::IFieldmark const*const pFieldmark = pMarkAccess->getFieldmarkFor(aPosition);
+ sw::mark::IFieldmark const*const pFieldmark = pMarkAccess->getInnerFieldmarkFor(aPosition);
assert(pFieldmark);
// DateFieldmark / ODF_FORMDATE is not a field...
if (pFieldmark->GetFieldname() != ODF_FORMDATE)
{
- OutputField( nullptr, lcl_getFieldId( pFieldmark ), OUString(), FieldFlags::CmdEnd );
+ FieldFlags nFlags = FieldFlags::CmdEnd;
+ // send hint that fldrslt is empty, to avoid spamming RTF CharProp reset.
+ // ::End does nothing when sending rFieldCmd=OUString(), so safe to do.
+ if (pFieldmark->GetContent().isEmpty())
+ nFlags |= FieldFlags::End;
+ OutputField(nullptr, lcl_getFieldId(pFieldmark), OUString(), nFlags);
if (pFieldmark->GetFieldname() == ODF_UNHANDLED)
{
@@ -2523,44 +2653,47 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
}
else if ( ch == CH_TXT_ATR_FIELDEND )
{
- SwPosition aPosition( rNode, SwIndex( &rNode, nCurrentPos ) );
+ SwPosition aPosition( rNode, nCurrentPos );
::sw::mark::IFieldmark const*const pFieldmark = pMarkAccess->getFieldmarkAt(aPosition);
assert(pFieldmark);
- if (pFieldmark->GetFieldname() == ODF_FORMDATE)
+ if (pFieldmark)
{
- if(GetExportFormat() == MSWordExportBase::ExportFormat::DOCX) // supported by DOCX only
+ if (pFieldmark->GetFieldname() == ODF_FORMDATE)
{
- OutputField( nullptr, ww::eFORMDATE, OUString(), FieldFlags::Close );
+ if(GetExportFormat() == MSWordExportBase::ExportFormat::DOCX) // supported by DOCX only
+ {
+ OutputField( nullptr, ww::eFORMDATE, OUString(), FieldFlags::Close );
+ }
}
- }
- else
- {
- ww::eField eFieldId = lcl_getFieldId( pFieldmark );
- if (pFieldmark->GetFieldname() == ODF_UNHANDLED)
+ else
{
- IFieldmark::parameter_map_t::const_iterator it = pFieldmark->GetParameters()->find( ODF_ID_PARAM );
- if ( it != pFieldmark->GetParameters()->end() )
+ ww::eField eFieldId = lcl_getFieldId( pFieldmark );
+ if (pFieldmark->GetFieldname() == ODF_UNHANDLED)
{
- OUString sFieldId;
- it->second >>= sFieldId;
- eFieldId = static_cast<ww::eField>(sFieldId.toInt32());
+ IFieldmark::parameter_map_t::const_iterator it = pFieldmark->GetParameters()->find( ODF_ID_PARAM );
+ if ( it != pFieldmark->GetParameters()->end() )
+ {
+ OUString sFieldId;
+ it->second >>= sFieldId;
+ eFieldId = static_cast<ww::eField>(sFieldId.toInt32());
+ }
}
- }
- OutputField( nullptr, eFieldId, OUString(), FieldFlags::Close );
+ OutputField( nullptr, eFieldId, OUString(), FieldFlags::Close );
- if (pFieldmark->GetFieldname() == ODF_FORMTEXT
- && GetExportFormat() != MSWordExportBase::ExportFormat::DOCX )
- {
- AppendBookmark( pFieldmark->GetName() );
+ if (pFieldmark->GetFieldname() == ODF_FORMTEXT
+ && GetExportFormat() != MSWordExportBase::ExportFormat::DOCX )
+ {
+ AppendBookmark( pFieldmark->GetName() );
+ }
}
}
}
else if ( ch == CH_TXT_ATR_FORMELEMENT )
{
- SwPosition aPosition( rNode, SwIndex( &rNode, nCurrentPos ) );
+ SwPosition aPosition( rNode, nCurrentPos );
::sw::mark::IFieldmark const*const pFieldmark = pMarkAccess->getFieldmarkAt(aPosition);
assert(pFieldmark);
@@ -2588,17 +2721,18 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
assert(0 <= nLen);
OUString aSnippet( aAttrIter.GetSnippet( aStr, nCurrentPos + ofs, nLen ) );
+ const SwTextNode* pTextNode( rNode.GetTextNode() );
if ( ( m_nTextTyp == TXT_EDN || m_nTextTyp == TXT_FTN ) && nCurrentPos == 0 && nLen > 0 )
{
// Allow MSO to emulate LO footnote text starting at left margin - only meaningful with hanging indent
sal_Int32 nFirstLineIndent=0;
- SfxItemSet aSet( m_rDoc.GetAttrPool(), svl::Items<RES_LR_SPACE, RES_LR_SPACE>{} );
- const SwTextNode* pTextNode( rNode.GetTextNode() );
+ SfxItemSetFixed<RES_MARGIN_FIRSTLINE, RES_MARGIN_FIRSTLINE> aSet( m_rDoc.GetAttrPool() );
+
if ( pTextNode && pTextNode->GetAttr(aSet) )
{
- const SvxLRSpaceItem* pLRSpace = aSet.GetItem<SvxLRSpaceItem>(RES_LR_SPACE);
- if ( pLRSpace )
- nFirstLineIndent = pLRSpace->GetTextFirstLineOffset();
+ const SvxFirstLineIndentItem *const pFirstLine(aSet.GetItem<SvxFirstLineIndentItem>(RES_MARGIN_FIRSTLINE));
+ if (pFirstLine)
+ nFirstLineIndent = pFirstLine->GetTextFirstLineOffset();
}
// Insert tab for aesthetic purposes #i24762#
@@ -2607,6 +2741,8 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
m_bAddFootnoteTab = false;
}
+ aSymbolFont = lcl_GetSymbolFont(m_rDoc.GetAttrPool(), pTextNode, nCurrentPos + ofs, nCurrentPos + ofs + nLen);
+
if ( bPostponeWritingText && ( FLY_POSTPONED != nStateOfFlyFrame ) )
{
aSavedSnippet = aSnippet ;
@@ -2614,7 +2750,15 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
else
{
bPostponeWritingText = false ;
- AttrOutput().RunText( aSnippet, eChrSet );
+ AttrOutput().RunText( aSnippet, eChrSet, aSymbolFont );
+ }
+
+ if (ofs == 1 && nNextAttr == nEnd)
+ {
+ // tdf#152200: There could be flys anchored after the last position; make sure
+ // to provide a separate run after field character to write them
+ AttrOutput().EndRun(&rNode, nCurrentPos, -1, nNextAttr == nEnd);
+ AttrOutput().StartRun(pRedlineData, nCurrentPos, bSingleEmptyRun);
}
}
@@ -2627,8 +2771,9 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
{
// Output the character attributes
// #i51277# do this before writing flys at end of paragraph
+ bStartedPostponedRunProperties = true;
AttrOutput().StartRunProperties();
- aAttrIter.OutAttr(nCurrentPos, false, bPostponeWritingText);
+ aAttrIter.OutAttr(nCurrentPos, false);
AttrOutput().EndRunProperties( pRedlineData );
}
@@ -2661,6 +2806,9 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
}
WriteCR( pTextNodeInfoInner );
+
+ if (0 != nEnd && bIsEndOfCell)
+ AttrOutput().OutputFKP(/*bforce=*/true);
}
}
}
@@ -2688,15 +2836,12 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
"odd to see this happening, expected 0");
}
- // !bIncludeEndOfParaCRInRedlineProperties implies we have just
- // emitted a CR, in which case we want to pass force=true to
- // OutputFKP to ensure that an FKP entry for direct character
- // formatting is written even if empty, so that the next one will
- // start after the CR.
- AttrOutput().OutputFKP(!bIncludeEndOfParaCRInRedlineProperties);
+ AttrOutput().OutputFKP(/*bForce=*/false);
if (bTextAtr || bAttrWithRange || bIncludeEndOfParaCRInRedlineProperties)
{
+ AttrOutput().WritePostitFieldReference();
+
// insert final graphic anchors if any before CR
nStateOfFlyFrame = aAttrIter.OutFlys( nEnd );
// insert final bookmarks if any before CR and after flys
@@ -2730,31 +2875,34 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
AttrOutput().WritePostitFieldReference();
- if (bPostponeWritingText
- && (FLY_PROCESSED == nStateOfFlyFrame || FLY_NONE == nStateOfFlyFrame))
+ aSymbolFont = lcl_GetSymbolFont(m_rDoc.GetAttrPool(), &rNode, nCurrentPos, nCurrentPos + nLen);
+
+ if (bPostponeWritingText)
{
- AttrOutput().EndRun(&rNode, nCurrentPos, nNextAttr == nEnd);
- //write the postponed text run
- AttrOutput().StartRun( pRedlineData, nCurrentPos, bSingleEmptyRun );
- AttrOutput().SetAnchorIsLinkedToNode( false );
- AttrOutput().ResetFlyProcessingFlag();
- if (0 != nEnd)
+ if (FLY_PROCESSED == nStateOfFlyFrame || FLY_NONE == nStateOfFlyFrame)
+ {
+ AttrOutput().EndRun(&rNode, nCurrentPos, -1, /*bLastRun=*/false);
+ if (!aSavedSnippet.isEmpty())
+ bStartedPostponedRunProperties = false;
+
+ AttrOutput().StartRun( pRedlineData, nCurrentPos, bSingleEmptyRun );
+ AttrOutput().SetAnchorIsLinkedToNode( false );
+ AttrOutput().ResetFlyProcessingFlag();
+ }
+ if (0 != nEnd && !bStartedPostponedRunProperties)
{
AttrOutput().StartRunProperties();
aAttrIter.OutAttr( nCurrentPos, false );
AttrOutput().EndRunProperties( pRedlineData );
+
+ // OutAttr may have introduced new comments, so write them out now
+ AttrOutput().WritePostitFieldReference();
}
- AttrOutput().RunText( aSavedSnippet, eChrSet );
- AttrOutput().EndRun(&rNode, nCurrentPos, nNextAttr == nEnd);
- }
- else if( bPostponeWritingText && !aSavedSnippet.isEmpty() )
- {
- //write the postponed text run
- AttrOutput().RunText( aSavedSnippet, eChrSet );
- AttrOutput().EndRun(&rNode, nCurrentPos, nNextAttr == nEnd);
+ AttrOutput().RunText( aSavedSnippet, eChrSet, aSymbolFont );
+ AttrOutput().EndRun(&rNode, nCurrentPos, nLen, nNextAttr == nEnd);
}
else
- AttrOutput().EndRun(&rNode, nCurrentPos, nNextAttr == nEnd);
+ AttrOutput().EndRun(&rNode, nCurrentPos, nLen, nNextAttr == nEnd);
nCurrentPos = nNextAttr;
UpdatePosition( &aAttrIter, nCurrentPos );
@@ -2783,7 +2931,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
if ( !bCheckSectionBreak )
{
- auto rBreak = ItemGet<SvxFormatBreakItem>(rNode.GetSwAttrSet(), RES_BREAK);
+ const SvxFormatBreakItem& rBreak = rNode.GetSwAttrSet().Get(RES_BREAK);
if ( rBreak.GetBreak() == SvxBreak::PageAfter )
{
if ( pNextNode && pNextNode->FindPageDesc() != pNextSplitParaPageDesc )
@@ -2812,7 +2960,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
#endif
AttrOutput().TableInfoCell( pTextNodeInfoInner );
- if (pTextNodeInfoInner->isFirstInTable())
+ if (pTextNodeInfoInner && pTextNodeInfoInner->isFirstInTable())
{
const SwTable * pTable = pTextNodeInfoInner->getTable();
@@ -2827,21 +2975,19 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
if ( !bFlyInTable )
{
- SfxItemSet* pTmpSet = nullptr;
+ std::optional<SfxItemSet> oTmpSet;
const sal_uInt8 nPrvNxtNd = rNode.HasPrevNextLayNode();
if( (ND_HAS_PREV_LAYNODE|ND_HAS_NEXT_LAYNODE ) != nPrvNxtNd )
{
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == rNode.GetSwAttrSet().GetItemState(
- RES_UL_SPACE, true, &pItem ) &&
- ( ( !( ND_HAS_PREV_LAYNODE & nPrvNxtNd ) &&
- static_cast<const SvxULSpaceItem*>(pItem)->GetUpper()) ||
- ( !( ND_HAS_NEXT_LAYNODE & nPrvNxtNd ) &&
- static_cast<const SvxULSpaceItem*>(pItem)->GetLower()) ))
+ const SvxULSpaceItem* pSpaceItem = rNode.GetSwAttrSet().GetItemIfSet(
+ RES_UL_SPACE );
+ if( pSpaceItem &&
+ ( ( !( ND_HAS_PREV_LAYNODE & nPrvNxtNd ) && pSpaceItem->GetUpper()) ||
+ ( !( ND_HAS_NEXT_LAYNODE & nPrvNxtNd ) && pSpaceItem->GetLower()) ))
{
- pTmpSet = new SfxItemSet( rNode.GetSwAttrSet() );
- SvxULSpaceItem aUL( *static_cast<const SvxULSpaceItem*>(pItem) );
+ oTmpSet.emplace( rNode.GetSwAttrSet() );
+ SvxULSpaceItem aUL( *pSpaceItem );
// #i25901#- consider compatibility option
if (!m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::PARA_SPACE_MAX_AT_PAGES))
{
@@ -2854,7 +3000,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
if( !(ND_HAS_NEXT_LAYNODE & nPrvNxtNd ))
aUL.SetLower( 0 );
}
- pTmpSet->Put( aUL );
+ oTmpSet->Put( aUL );
}
}
@@ -2871,15 +3017,16 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
if( !pFormat )
pFormat = &pRule->Get( nLvl );
- if( !pTmpSet )
- pTmpSet = new SfxItemSet( rNode.GetSwAttrSet() );
+ if( !oTmpSet )
+ oTmpSet.emplace( rNode.GetSwAttrSet() );
- SvxLRSpaceItem aLR(ItemGet<SvxLRSpaceItem>(*pTmpSet, RES_LR_SPACE));
+ SvxFirstLineIndentItem firstLine(oTmpSet->Get(RES_MARGIN_FIRSTLINE));
+ SvxTextLeftMarginItem leftMargin(oTmpSet->Get(RES_MARGIN_TEXTLEFT));
// #i86652#
if ( pFormat->GetPositionAndSpaceMode() ==
SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
{
- aLR.SetTextLeft( aLR.GetTextLeft() + pFormat->GetAbsLSpace() );
+ leftMargin.SetTextLeft(leftMargin.GetTextLeft() + pFormat->GetAbsLSpace());
}
if( rNode.IsNumbered() && rNode.IsCountedInList() )
@@ -2890,51 +3037,58 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
{
if (bParaRTL)
{
- aLR.SetTextFirstLineOffsetValue(aLR.GetTextFirstLineOffset() + pFormat->GetAbsLSpace() - pFormat->GetFirstLineOffset()); //TODO: overflow
+ firstLine.SetTextFirstLineOffsetValue(firstLine.GetTextFirstLineOffset() + pFormat->GetAbsLSpace() - pFormat->GetFirstLineOffset()); //TODO: overflow
}
else
{
- aLR.SetTextFirstLineOffset(aLR.GetTextFirstLineOffset() + GetWordFirstLineOffset(*pFormat));
+ firstLine.SetTextFirstLineOffset(firstLine.GetTextFirstLineOffset() + GetWordFirstLineOffset(*pFormat));
}
}
// correct fix for issue i94187
if (SfxItemState::SET !=
- pTmpSet->GetItemState(RES_PARATR_NUMRULE, false) )
+ oTmpSet->GetItemState(RES_PARATR_NUMRULE, false) )
{
// List style set via paragraph style - then put it into the itemset.
// This is needed to get list level and list id exported for
// the paragraph.
- pTmpSet->Put( SwNumRuleItem( pRule->GetName() ));
+ oTmpSet->Put( SwNumRuleItem( pRule->GetName() ));
// Put indent values into the itemset in case that the list
// style is applied via paragraph style and the list level
// indent values are not applicable.
if ( pFormat->GetPositionAndSpaceMode() ==
- SvxNumberFormat::LABEL_ALIGNMENT &&
- !rNode.AreListLevelIndentsApplicable() )
+ SvxNumberFormat::LABEL_ALIGNMENT)
{
- pTmpSet->Put( aLR );
+ ::sw::ListLevelIndents const indents(rNode.AreListLevelIndentsApplicable());
+ if (indents & ::sw::ListLevelIndents::FirstLine)
+ {
+ oTmpSet->Put(firstLine);
+ }
+ if (indents & ::sw::ListLevelIndents::LeftMargin)
+ {
+ oTmpSet->Put(leftMargin);
+ }
}
}
}
else
- pTmpSet->ClearItem(RES_PARATR_NUMRULE);
+ oTmpSet->ClearItem(RES_PARATR_NUMRULE);
// #i86652#
if ( pFormat->GetPositionAndSpaceMode() ==
SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
{
- pTmpSet->Put(aLR);
+ oTmpSet->Put(firstLine);
+ oTmpSet->Put(leftMargin);
//#i21847#
- SvxTabStopItem aItem(
- ItemGet<SvxTabStopItem>(*pTmpSet, RES_PARATR_TABSTOP));
+ SvxTabStopItem aItem(oTmpSet->Get(RES_PARATR_TABSTOP));
SvxTabStop aTabStop(pFormat->GetAbsLSpace());
aItem.Insert(aTabStop);
- pTmpSet->Put(aItem);
+ oTmpSet->Put(aItem);
- MSWordExportBase::CorrectTabStopInSet(*pTmpSet, pFormat->GetAbsLSpace());
+ MSWordExportBase::CorrectTabStopInSet(*oTmpSet, pFormat->GetAbsLSpace());
}
}
@@ -2951,43 +3105,45 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
rTextColl.GetFrameDir().GetValue() == SvxFrameDirection::Environment
)
{
- if ( !pTmpSet )
- pTmpSet = new SfxItemSet(rNode.GetSwAttrSet());
+ if ( !oTmpSet )
+ oTmpSet.emplace(rNode.GetSwAttrSet());
if ( bParaRTL )
- pTmpSet->Put(SvxFrameDirectionItem(SvxFrameDirection::Horizontal_RL_TB, RES_FRAMEDIR));
+ oTmpSet->Put(SvxFrameDirectionItem(SvxFrameDirection::Horizontal_RL_TB, RES_FRAMEDIR));
else
- pTmpSet->Put(SvxFrameDirectionItem(SvxFrameDirection::Horizontal_LR_TB, RES_FRAMEDIR));
+ oTmpSet->Put(SvxFrameDirectionItem(SvxFrameDirection::Horizontal_LR_TB, RES_FRAMEDIR));
const SvxAdjustItem* pAdjust = rNode.GetSwAttrSet().GetItem(RES_PARATR_ADJUST);
if ( pAdjust && (pAdjust->GetAdjust() == SvxAdjust::Left || pAdjust->GetAdjust() == SvxAdjust::Right ) )
- pTmpSet->Put( *pAdjust, RES_PARATR_ADJUST );
+ oTmpSet->Put( *pAdjust );
}
// move code for handling of numbered,
// but not counted paragraphs to this place. Otherwise, the paragraph
// isn't exported as numbered, but not counted, if no other attribute
// is found in <pTmpSet>
// #i44815# adjust numbering/indents for numbered paragraphs
- // without number (NO_NUMLEVEL)
+ // without number
// #i47013# need to check rNode.GetNumRule()!=NULL as well.
if ( ! rNode.IsCountedInList() && rNode.GetNumRule()!=nullptr )
{
// WW8 does not know numbered paragraphs without number
- // (NO_NUMLEVEL). In WW8AttributeOutput::ParaNumRule(), we will export
+ // In WW8AttributeOutput::ParaNumRule(), we will export
// the RES_PARATR_NUMRULE as list-id 0, which in WW8 means
// no numbering. Here, we will adjust the indents to match
// visually.
- if ( !pTmpSet )
- pTmpSet = new SfxItemSet(rNode.GetSwAttrSet());
+ if ( !oTmpSet )
+ oTmpSet.emplace(rNode.GetSwAttrSet());
// create new LRSpace item, based on the current (if present)
- const SfxPoolItem* pPoolItem = nullptr;
- pTmpSet->GetItemState(RES_LR_SPACE, true, &pPoolItem);
- SvxLRSpaceItem aLRSpace(
- ( pPoolItem == nullptr )
- ? SvxLRSpaceItem(0, 0, 0, 0, RES_LR_SPACE)
- : *static_cast<const SvxLRSpaceItem*>( pPoolItem ) );
+ const SvxFirstLineIndentItem *const pFirstLineIndent(oTmpSet->GetItemIfSet(RES_MARGIN_FIRSTLINE));
+ const SvxTextLeftMarginItem *const pTextLeftMargin(oTmpSet->GetItemIfSet(RES_MARGIN_TEXTLEFT));
+ SvxFirstLineIndentItem firstLine(pFirstLineIndent
+ ? *pFirstLineIndent
+ : SvxFirstLineIndentItem(0, RES_MARGIN_FIRSTLINE));
+ SvxTextLeftMarginItem leftMargin(pTextLeftMargin
+ ? *pTextLeftMargin
+ : SvxTextLeftMarginItem(0, RES_MARGIN_TEXTLEFT));
// new left margin = old left + label space
const SwNumRule* pRule = rNode.GetNumRule();
@@ -3005,25 +3161,28 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
if ( rNumFormat.GetPositionAndSpaceMode() ==
SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
{
- aLRSpace.SetTextLeft( aLRSpace.GetLeft() + rNumFormat.GetAbsLSpace() );
+ leftMargin.SetTextLeft(leftMargin.GetLeft(firstLine) + rNumFormat.GetAbsLSpace());
}
else
{
- aLRSpace.SetTextLeft( aLRSpace.GetLeft() + rNumFormat.GetIndentAt() );
+ leftMargin.SetTextLeft(leftMargin.GetLeft(firstLine) + rNumFormat.GetIndentAt());
}
// new first line indent = 0
- // (first line indent is ignored for NO_NUMLEVEL)
+ // (first line indent is ignored)
if (!bParaRTL)
- aLRSpace.SetTextFirstLineOffset( 0 );
+ {
+ firstLine.SetTextFirstLineOffset(0);
+ }
// put back the new item
- pTmpSet->Put( aLRSpace );
+ oTmpSet->Put(firstLine);
+ oTmpSet->Put(leftMargin);
- // assure that numbering rule is in <pTmpSet>
- if (SfxItemState::SET != pTmpSet->GetItemState(RES_PARATR_NUMRULE, false) )
+ // assure that numbering rule is in <oTmpSet>
+ if (SfxItemState::SET != oTmpSet->GetItemState(RES_PARATR_NUMRULE, false) )
{
- pTmpSet->Put( SwNumRuleItem( pRule->GetName() ));
+ oTmpSet->Put( SwNumRuleItem( pRule->GetName() ));
}
}
@@ -3035,22 +3194,20 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
SfxItemState::SET != rNode.GetpSwAttrSet()->GetItemState(RES_BREAK, false) )
{
const SvxFormatBreakItem& rBreakAtParaStyle
- = ItemGet<SvxFormatBreakItem>(rNode.GetSwAttrSet(), RES_BREAK);
+ = rNode.GetSwAttrSet().Get(RES_BREAK);
if (rBreakAtParaStyle.GetBreak() == SvxBreak::PageAfter)
{
- if ( !pTmpSet )
- {
- pTmpSet = new SfxItemSet(rNode.GetSwAttrSet());
- }
- pTmpSet->Put(rBreakAtParaStyle);
+ if ( !oTmpSet )
+ oTmpSet.emplace(rNode.GetSwAttrSet());
+ oTmpSet->Put(rBreakAtParaStyle);
}
- else if( pTmpSet )
+ else if( oTmpSet )
{ // Even a pagedesc item is set, the break item can be set 'NONE',
// this has to be overruled.
const SwFormatPageDesc& rPageDescAtParaStyle =
- ItemGet<SwFormatPageDesc>( rNode, RES_PAGEDESC );
+ rNode.GetAttr( RES_PAGEDESC );
if( rPageDescAtParaStyle.KnowsPageDesc() )
- pTmpSet->ClearItem( RES_BREAK );
+ oTmpSet->ClearItem( RES_BREAK );
}
}
@@ -3081,7 +3238,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
if ( 0 == pLine->GetBoxPos( pBox ) && pBox->GetSttNd() )
{
// check if paragraph is first in that line:
- if ( 1 == ( rNode.GetIndex() - pBox->GetSttNd()->GetIndex() ) )
+ if ( SwNodeOffset(1) == ( rNode.GetIndex() - pBox->GetSttNd()->GetIndex() ) )
{
bool bSetAtPara = false;
if ( bKeep )
@@ -3095,11 +3252,11 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
if ( bSetAtPara )
{
- if ( !pTmpSet )
- pTmpSet = new SfxItemSet(rNode.GetSwAttrSet());
+ if ( !oTmpSet )
+ oTmpSet.emplace(rNode.GetSwAttrSet());
const SvxFormatKeepItem aKeepItem( true, RES_KEEP );
- pTmpSet->Put( aKeepItem );
+ oTmpSet->Put( aKeepItem );
}
}
}
@@ -3108,7 +3265,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
}
}
- const SfxItemSet* pNewSet = pTmpSet ? pTmpSet : rNode.GetpSwAttrSet();
+ const SfxItemSet* pNewSet = oTmpSet ? &*oTmpSet : rNode.GetpSwAttrSet();
if( pNewSet )
{ // Para-Attrs
m_pStyAttr = &rNode.GetAnyFormatColl().GetAttrSet();
@@ -3121,9 +3278,6 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
m_pStyAttr = nullptr;
m_pOutFormatNode = pOldMod;
-
- if( pNewSet != rNode.GetpSwAttrSet() )
- delete pNewSet;
}
}
@@ -3136,10 +3290,10 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
// Exception: if there is a character style hint at the end of the
// paragraph only, then still go with 2), as RES_TXTATR_CHARFMT is always
// set as a hint.
- SfxItemSet aParagraphMarkerProperties(m_rDoc.GetAttrPool(), svl::Items<RES_CHRATR_BEGIN, RES_TXTATR_END>{});
+ SfxItemSetFixed<RES_CHRATR_BEGIN, RES_TXTATR_END> aParagraphMarkerProperties(m_rDoc.GetAttrPool());
bool bCharFormatOnly = true;
- SwFormatAutoFormat const& rListAutoFormat(static_cast<SwFormatAutoFormat const&>(rNode.GetAttr(RES_PARATR_LIST_AUTOFMT)));
+ SwFormatAutoFormat const& rListAutoFormat(rNode.GetAttr(RES_PARATR_LIST_AUTOFMT));
if (std::shared_ptr<SfxItemSet> const& pSet = rListAutoFormat.GetStyleHandle())
{
aParagraphMarkerProperties.Put(*pSet);
@@ -3195,21 +3349,20 @@ void WW8AttributeOutput::EmptyParagraph()
bool MSWordExportBase::NoPageBreakSection( const SfxItemSet* pSet )
{
bool bRet = false;
- const SfxPoolItem* pI;
if( pSet)
{
bool bNoPageBreak = false;
- if ( SfxItemState::SET != pSet->GetItemState(RES_PAGEDESC, true, &pI)
- || nullptr == static_cast<const SwFormatPageDesc*>(pI)->GetPageDesc() )
+ const SwFormatPageDesc* pDescItem = pSet->GetItemIfSet(RES_PAGEDESC);
+ if ( !pDescItem || nullptr == pDescItem->GetPageDesc() )
{
bNoPageBreak = true;
}
if (bNoPageBreak)
{
- if (SfxItemState::SET == pSet->GetItemState(RES_BREAK, true, &pI))
+ if (const SvxFormatBreakItem* pBreakItem = pSet->GetItemIfSet(RES_BREAK))
{
- SvxBreak eBreak = static_cast<const SvxFormatBreakItem*>(pI)->GetBreak();
+ SvxBreak eBreak = pBreakItem->GetBreak();
switch (eBreak)
{
case SvxBreak::PageBefore:
@@ -3324,13 +3477,13 @@ void MSWordExportBase::UpdateTocSectionNodeProperties(const SwSectionNode& rSect
{
uno::Sequence<beans::PropertyValue> aDocPropertyValues(comphelper::InitPropertySequence(
{
- {"ooxml:CT_SdtDocPart_docPartGallery", uno::makeAny(OUString("Table of Contents"))},
- {"ooxml:CT_SdtDocPart_docPartUnique", uno::makeAny(OUString("true"))},
+ {"ooxml:CT_SdtDocPart_docPartGallery", uno::Any(OUString("Table of Contents"))},
+ {"ooxml:CT_SdtDocPart_docPartUnique", uno::Any(OUString("true"))},
}));
uno::Sequence<beans::PropertyValue> aSdtPrPropertyValues(comphelper::InitPropertySequence(
{
- {"ooxml:CT_SdtPr_docPartObj", uno::makeAny(aDocPropertyValues)},
+ {"ooxml:CT_SdtPr_docPartObj", uno::Any(aDocPropertyValues)},
}));
SfxGrabBagItem aGrabBag(RES_PARATR_GRABBAG);
@@ -3368,7 +3521,7 @@ void MSWordExportBase::UpdateTocSectionNodeProperties(const SwSectionNode& rSect
void WW8Export::AppendSection( const SwPageDesc *pPageDesc, const SwSectionFormat* pFormat, sal_uLong nLnNum )
{
- pSepx->AppendSep(Fc2Cp(Strm().Tell()), pPageDesc, pFormat, nLnNum);
+ m_pSepx->AppendSep(Fc2Cp(Strm().Tell()), pPageDesc, pFormat, nLnNum);
}
// Flys
@@ -3399,7 +3552,21 @@ void WW8AttributeOutput::OutputFlyFrame_Impl( const ww8::Frame& rFormat, const P
if (bUseEscher)
{
// write as escher
- m_rWW8Export.AppendFlyInFlys(rFormat, rNdTopLeft);
+ if (rFrameFormat.GetFlySplit().GetValue())
+ {
+ // The frame can split: this was originally from a floating table, write it back as
+ // such.
+ const SwNodeIndex* pNodeIndex = rFrameFormat.GetContent().GetContentIdx();
+ SwNodeOffset nStt = pNodeIndex ? pNodeIndex->GetIndex() + 1 : SwNodeOffset(0);
+ SwNodeOffset nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : SwNodeOffset(0);
+ m_rWW8Export.SaveData(nStt, nEnd);
+ GetExport().WriteText();
+ m_rWW8Export.RestoreData();
+ }
+ else
+ {
+ m_rWW8Export.AppendFlyInFlys(rFormat, rNdTopLeft);
+ }
}
else
{
@@ -3408,8 +3575,8 @@ void WW8AttributeOutput::OutputFlyFrame_Impl( const ww8::Frame& rFormat, const P
// Fetch from node and last node the position in the section
const SwNodeIndex* pNodeIndex = rFrameFormat.GetContent().GetContentIdx();
- sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex()+1 : 0;
- sal_uLong nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0;
+ SwNodeOffset nStt = pNodeIndex ? pNodeIndex->GetIndex()+1 : SwNodeOffset(0);
+ SwNodeOffset nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : SwNodeOffset(0);
if( nStt >= nEnd ) // no range, hence no valid node
return;
@@ -3417,7 +3584,7 @@ void WW8AttributeOutput::OutputFlyFrame_Impl( const ww8::Frame& rFormat, const P
if ( !m_rWW8Export.IsInTable() && rFormat.IsInline() )
{
//Test to see if this textbox contains only a single graphic/ole
- SwTextNode* pParTextNode = rAnch.GetContentAnchor()->nNode.GetNode().GetTextNode();
+ SwTextNode* pParTextNode = rAnch.GetAnchorNode()->GetTextNode();
if ( pParTextNode && !m_rWW8Export.m_rDoc.GetNodes()[ nStt ]->IsNoTextNode() )
bDone = true;
}
@@ -3430,7 +3597,7 @@ void WW8AttributeOutput::OutputFlyFrame_Impl( const ww8::Frame& rFormat, const P
if ( m_rWW8Export.m_pParentFrame )
{
/* Munge flys in fly into absolutely positioned elements for word 6 */
- const SwTextNode* pParTextNode = rAnch.GetContentAnchor()->nNode.GetNode().GetTextNode();
+ const SwTextNode* pParTextNode = rAnch.GetAnchorNode()->GetTextNode();
const SwRect aPageRect = pParTextNode->FindPageFrameRect();
aOffset = rFrameFormat.FindLayoutRect().Pos();
@@ -3514,8 +3681,8 @@ void WW8AttributeOutput::Redline( const SwRedlineData* pRedline )
case RedlineType::Format:
m_rWW8Export.InsUInt16( NS_sprm::CPropRMark90::val );
- m_rWW8Export.pO->push_back( 7 ); // len
- m_rWW8Export.pO->push_back( 1 );
+ m_rWW8Export.m_pO->push_back( 7 ); // len
+ m_rWW8Export.m_pO->push_back( 1 );
m_rWW8Export.InsUInt16( m_rWW8Export.AddRedlineAuthor( pRedline->GetAuthor() ) );
m_rWW8Export.InsUInt32( sw::ms::DateTime2DTTM( pRedline->GetTimeStamp() ));
break;
@@ -3527,7 +3694,7 @@ void WW8AttributeOutput::Redline( const SwRedlineData* pRedline )
if ( pSprmIds )
{
m_rWW8Export.InsUInt16( pSprmIds[0] );
- m_rWW8Export.pO->push_back( 1 );
+ m_rWW8Export.m_pO->push_back( 1 );
m_rWW8Export.InsUInt16( pSprmIds[1] );
m_rWW8Export.InsUInt16( m_rWW8Export.AddRedlineAuthor( pRedline->GetAuthor() ) );
@@ -3611,11 +3778,11 @@ WW8Ruby::WW8Ruby(const SwTextNode& rNode, const SwFormatRuby& rRuby, const MSWor
if (pFormat)
{
const auto& rFont
- = ItemGet<SvxFontItem>(*pFormat, GetWhichOfScript(RES_CHRATR_FONT, nRubyScript));
+ = pFormat->GetFormatAttr( GetWhichOfScript(RES_CHRATR_FONT, nRubyScript) );
m_sFontFamily = rFont.GetFamilyName();
- const auto& rHeight = ItemGet<SvxFontHeightItem>(
- *pFormat, GetWhichOfScript(RES_CHRATR_FONTSIZE, nRubyScript));
+ const auto& rHeight =
+ pFormat->GetFormatAttr( GetWhichOfScript(RES_CHRATR_FONTSIZE, nRubyScript) );
m_nRubyHeight = rHeight.GetHeight();
}
else
@@ -3626,12 +3793,12 @@ WW8Ruby::WW8Ruby(const SwTextNode& rNode, const SwFormatRuby& rRuby, const MSWor
pPool = pPool ? pPool : &rExport.m_rDoc.GetAttrPool();
- const auto& rFont
- = DefaultItemGet<SvxFontItem>(*pPool, GetWhichOfScript(RES_CHRATR_FONT, nRubyScript));
+ const SvxFontItem& rFont
+ = pPool->GetUserOrPoolDefaultItem( GetWhichOfScript(RES_CHRATR_FONT, nRubyScript) );
m_sFontFamily = rFont.GetFamilyName();
- const auto& rHeight = DefaultItemGet<SvxFontHeightItem>(
- *pPool, GetWhichOfScript(RES_CHRATR_FONTSIZE, nRubyScript));
+ const SvxFontHeightItem& rHeight =
+ pPool->GetUserOrPoolDefaultItem( GetWhichOfScript(RES_CHRATR_FONTSIZE, nRubyScript));
m_nRubyHeight = rHeight.GetHeight();
}
@@ -3641,8 +3808,8 @@ WW8Ruby::WW8Ruby(const SwTextNode& rNode, const SwFormatRuby& rRuby, const MSWor
if (!rText.isEmpty())
nScript = g_pBreakIt->GetBreakIter()->getScriptType(rText, 0);
- sal_uInt16 nWhich = GetWhichOfScript(RES_CHRATR_FONTSIZE, nScript);
- auto& rHeightItem = static_cast<const SvxFontHeightItem&>(rExport.GetItem(nWhich));
+ TypedWhichId<SvxFontHeightItem> nWhich = GetWhichOfScript(RES_CHRATR_FONTSIZE, nScript);
+ const SvxFontHeightItem& rHeightItem = rExport.GetItem(nWhich);
m_nBaseHeight = rHeightItem.GetHeight();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx
index c3f8eabe9fd9..4c56472bb6b3 100644
--- a/sw/source/filter/ww8/wrtw8num.cxx
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -34,11 +34,7 @@
#include "wrtww8.hxx"
#include "ww8par.hxx"
-#include <numeric>
-
using namespace ::com::sun::star;
-using namespace sw::types;
-using namespace sw::util;
SwNumRule* MSWordExportBase::DuplicateNumRuleImpl(const SwNumRule *pRule)
{
@@ -56,6 +52,17 @@ SwNumRule* MSWordExportBase::DuplicateNumRuleImpl(const SwNumRule *pRule)
return pMyNumRule;
}
+sal_uInt16 MSWordExportBase::DuplicateNumRule(const SwNumRule* pRule, sal_uInt8 nLevel, sal_uInt16 nVal)
+{
+ SwNumRule* const pMyNumRule = DuplicateNumRuleImpl(pRule);
+
+ SwNumFormat aNumFormat(pMyNumRule->Get(nLevel));
+ aNumFormat.SetStart(nVal);
+ pMyNumRule->Set(nLevel, aNumFormat);
+
+ return GetNumberingId(*pMyNumRule);
+}
+
// multiple SwList can be based on the same SwNumRule; ensure one w:abstractNum
// per SwList
sal_uInt16 MSWordExportBase::DuplicateAbsNum(OUString const& rListId,
@@ -140,7 +147,7 @@ sal_uInt16 MSWordExportBase::GetNumberingId( const SwNumRule& rNumRule )
}
}
SwNumRule* p = const_cast<SwNumRule*>(&rNumRule);
- sal_uInt16 nRet = static_cast<sal_uInt16>(m_pUsedNumTable->GetPos(p));
+ sal_uInt16 nRet = o3tl::narrowing<sal_uInt16>(m_pUsedNumTable->GetPos(p));
return nRet;
}
@@ -166,11 +173,11 @@ void WW8Export::WriteNumbering()
return; // no numbering is used
// list formats - LSTF
- pFib->m_fcPlcfLst = pTableStrm->Tell();
- SwWW8Writer::WriteShort( *pTableStrm, m_pUsedNumTable->size() );
+ m_pFib->m_fcPlcfLst = m_pTableStrm->Tell();
+ m_pTableStrm->WriteUInt16( m_pUsedNumTable->size() );
NumberingDefinitions();
// set len to FIB
- pFib->m_lcbPlcfLst = pTableStrm->Tell() - pFib->m_fcPlcfLst;
+ m_pFib->m_lcbPlcfLst = m_pTableStrm->Tell() - m_pFib->m_fcPlcfLst;
// list formats - LVLF
AbstractNumberingDefinitions();
@@ -184,18 +191,18 @@ void WW8Export::WriteNumbering()
void WW8AttributeOutput::NumberingDefinition( sal_uInt16 nId, const SwNumRule &rRule )
{
- SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, nId );
- SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, nId );
+ m_rWW8Export.m_pTableStrm->WriteUInt32( nId );
+ m_rWW8Export.m_pTableStrm->WriteUInt32( nId );
// not associated with a Style
for ( int i = 0; i < WW8ListManager::nMaxLevel; ++i )
- SwWW8Writer::WriteShort( *m_rWW8Export.pTableStrm, 0xFFF );
+ m_rWW8Export.m_pTableStrm->WriteUInt16( 0xFFF );
sal_uInt8 nFlags = 0;
if ( rRule.IsContinusNum() )
nFlags |= 0x1;
- m_rWW8Export.pTableStrm->WriteUChar( nFlags ).WriteUChar( 0/*nDummy*/ );
+ m_rWW8Export.m_pTableStrm->WriteUChar( nFlags ).WriteUChar( 0/*nDummy*/ );
}
void MSWordExportBase::NumberingDefinitions()
@@ -227,24 +234,13 @@ void MSWordExportBase::NumberingDefinitions()
/**
* Converts the SVX numbering type to MSONFC.
*
- * This is used for paragraph numbering purposes.
+ * This is used for special paragraph numbering considerations.
*/
-static sal_uInt8 GetLevelNFC( sal_uInt16 eNumType, const SfxItemSet *pOutSet)
+static sal_uInt8 GetLevelNFC(sal_uInt16 eNumType, const SfxItemSet* pOutSet, sal_uInt8 nDefault)
{
- sal_uInt8 nRet = 0;
+ sal_uInt8 nRet = nDefault;
switch( eNumType )
{
- case SVX_NUM_CHARS_UPPER_LETTER:
- case SVX_NUM_CHARS_UPPER_LETTER_N: nRet = 3; break;
- case SVX_NUM_CHARS_LOWER_LETTER:
- case SVX_NUM_CHARS_LOWER_LETTER_N: nRet = 4; break;
- case SVX_NUM_ROMAN_UPPER: nRet = 1; break;
- case SVX_NUM_ROMAN_LOWER: nRet = 2; break;
-
- case SVX_NUM_BITMAP:
- case SVX_NUM_CHAR_SPECIAL: nRet = 23; break;
- case SVX_NUM_FULL_WIDTH_ARABIC: nRet = 14; break;
- case SVX_NUM_CIRCLE_NUMBER: nRet = 18;break;
case SVX_NUM_NUMBER_LOWER_ZH:
nRet = 35;
if ( pOutSet ) {
@@ -255,27 +251,14 @@ static sal_uInt8 GetLevelNFC( sal_uInt16 eNumType, const SfxItemSet *pOutSet)
}
}
break;
- case SVX_NUM_NUMBER_UPPER_ZH: nRet = 38; break;
- case SVX_NUM_NUMBER_UPPER_ZH_TW: nRet = 34;break;
- case SVX_NUM_TIAN_GAN_ZH: nRet = 30; break;
- case SVX_NUM_DI_ZI_ZH: nRet = 31; break;
- case SVX_NUM_NUMBER_TRADITIONAL_JA: nRet = 16; break;
- case SVX_NUM_AIU_FULLWIDTH_JA: nRet = 20; break;
- case SVX_NUM_AIU_HALFWIDTH_JA: nRet = 12; break;
- case SVX_NUM_IROHA_FULLWIDTH_JA: nRet = 21; break;
- case SVX_NUM_IROHA_HALFWIDTH_JA: nRet = 13; break;
- case style::NumberingType::HANGUL_SYLLABLE_KO: nRet = 24; break;// ganada
- case style::NumberingType::HANGUL_JAMO_KO: nRet = 25; break;// chosung
- case style::NumberingType::HANGUL_CIRCLED_SYLLABLE_KO: nRet = 24; break;
- case style::NumberingType::HANGUL_CIRCLED_JAMO_KO: nRet = 25; break;
- case style::NumberingType::NUMBER_HANGUL_KO: nRet = 41; break;
- case style::NumberingType::NUMBER_UPPER_KO: nRet = 44; break;
- case SVX_NUM_NUMBER_NONE: nRet = 0xff; break;
- // No SVX_NUM_SYMBOL_CHICAGO here: LVLF can't contain 0x09, msonfcChiManSty.
- case SVX_NUM_ARABIC_ZERO:
- // 0x16, msonfcArabicLZ
- nRet = 22;
+
+ // LVLF can't contain 0x08, msonfcHex.
+ case style::NumberingType::SYMBOL_CHICAGO:
+ // No SVX_NUM_SYMBOL_CHICAGO here: LVLF can't contain 0x09, msonfcChiManSty.
+ nRet = 0;
break;
+ // LVLF can't contain 0x0F / 15, msonfcSbChar / decimalHalfWidth.
+ // LVLF can't contain 0x13 / 19, msonfcDArabic / decimalFullWidth2
}
return nRet;
}
@@ -293,14 +276,16 @@ void WW8AttributeOutput::NumberingLevel( sal_uInt8 /*nLevel*/,
sal_Int16 nFirstLineIndex,
sal_Int16 nListTabPos,
const OUString &rNumberingString,
- const SvxBrushItem* pBrush //For i120928,to transfer graphic of bullet
+ const SvxBrushItem* pBrush, //For i120928,to transfer graphic of bullet
+ bool isLegal
)
{
// Start value
- SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, nStart );
+ m_rWW8Export.m_pTableStrm->WriteUInt32( nStart );
// Type
- m_rWW8Export.pTableStrm->WriteUChar( GetLevelNFC( nNumberingType ,pOutSet) );
+ sal_uInt8 nNumId = GetLevelNFC(nNumberingType, pOutSet, WW8Export::GetNumId(nNumberingType));
+ m_rWW8Export.m_pTableStrm->WriteUChar(nNumId);
// Justification
sal_uInt8 nAlign;
@@ -316,25 +301,32 @@ void WW8AttributeOutput::NumberingLevel( sal_uInt8 /*nLevel*/,
nAlign = 0;
break;
}
- m_rWW8Export.pTableStrm->WriteUChar( nAlign );
+
+ if (isLegal)
+ {
+ // 3rd bit.
+ nAlign |= 0x04;
+ }
+
+ m_rWW8Export.m_pTableStrm->WriteUChar( nAlign );
// Write the rgbxchNums[9], positions of placeholders for paragraph
// numbers in the text
- m_rWW8Export.pTableStrm->WriteBytes(pNumLvlPos, WW8ListManager::nMaxLevel);
+ m_rWW8Export.m_pTableStrm->WriteBytes(pNumLvlPos, WW8ListManager::nMaxLevel);
// Type of the character between the bullet and the text
- m_rWW8Export.pTableStrm->WriteUChar( nFollow );
+ m_rWW8Export.m_pTableStrm->WriteUChar( nFollow );
// dxaSoace/dxaIndent (Word 6 compatibility)
- SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, 0 );
- SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, 0 );
+ m_rWW8Export.m_pTableStrm->WriteUInt32( 0 );
+ m_rWW8Export.m_pTableStrm->WriteUInt32( 0 );
// cbGrpprlChpx
std::unique_ptr<ww::bytes> pCharAtrs;
if ( pOutSet )
{
- std::unique_ptr<ww::bytes> pOldpO = std::move(m_rWW8Export.pO);
- m_rWW8Export.pO.reset(new ww::bytes);
+ std::unique_ptr<ww::bytes> pOldpO = std::move(m_rWW8Export.m_pO);
+ m_rWW8Export.m_pO.reset(new ww::bytes);
if ( pFont )
{
sal_uInt16 nFontID = m_rWW8Export.m_aFontHelper.GetId( *pFont );
@@ -359,10 +351,10 @@ void WW8AttributeOutput::NumberingLevel( sal_uInt8 /*nLevel*/,
}
}
- pCharAtrs = std::move(m_rWW8Export.pO);
- m_rWW8Export.pO = std::move(pOldpO);
+ pCharAtrs = std::move(m_rWW8Export.m_pO);
+ m_rWW8Export.m_pO = std::move(pOldpO);
}
- m_rWW8Export.pTableStrm->WriteUChar(sal_uInt8(pCharAtrs ? pCharAtrs->size() : 0));
+ m_rWW8Export.m_pTableStrm->WriteUChar(sal_uInt8(pCharAtrs ? pCharAtrs->size() : 0));
// cbGrpprlPapx
sal_uInt8 aPapSprms [] = {
@@ -370,10 +362,10 @@ void WW8AttributeOutput::NumberingLevel( sal_uInt8 /*nLevel*/,
0x60, 0x84, 0, 0, // sprmPDxaLeft1
0x15, 0xc6, 0x05, 0x00, 0x01, 0, 0, 0x06
};
- m_rWW8Export.pTableStrm->WriteUChar( sal_uInt8( sizeof( aPapSprms ) ) );
+ m_rWW8Export.m_pTableStrm->WriteUChar( sal_uInt8( sizeof( aPapSprms ) ) );
// reserved
- SwWW8Writer::WriteShort( *m_rWW8Export.pTableStrm, 0 );
+ m_rWW8Export.m_pTableStrm->WriteUInt16( 0 );
// pap sprms
sal_uInt8* pData = aPapSprms + 2;
@@ -383,15 +375,15 @@ void WW8AttributeOutput::NumberingLevel( sal_uInt8 /*nLevel*/,
pData += 5;
Set_UInt16( pData, nListTabPos );
- m_rWW8Export.pTableStrm->WriteBytes(aPapSprms, sizeof(aPapSprms));
+ m_rWW8Export.m_pTableStrm->WriteBytes(aPapSprms, sizeof(aPapSprms));
// write Chpx
if (pCharAtrs && !pCharAtrs->empty())
- m_rWW8Export.pTableStrm->WriteBytes(pCharAtrs->data(), pCharAtrs->size());
+ m_rWW8Export.m_pTableStrm->WriteBytes(pCharAtrs->data(), pCharAtrs->size());
// write the num string
- SwWW8Writer::WriteShort( *m_rWW8Export.pTableStrm, rNumberingString.getLength() );
- SwWW8Writer::WriteString16( *m_rWW8Export.pTableStrm, rNumberingString, false );
+ m_rWW8Export.m_pTableStrm->WriteUInt16( rNumberingString.getLength() );
+ SwWW8Writer::WriteString16( *m_rWW8Export.m_pTableStrm, rNumberingString, false );
}
void MSWordExportBase::AbstractNumberingDefinitions()
@@ -424,13 +416,6 @@ void MSWordExportBase::AbstractNumberingDefinitions()
void MSWordExportBase::NumberingLevel(
SwNumRule const& rRule, sal_uInt8 const nLvl)
{
- // prepare the NodeNum to generate the NumString
- static const SwNumberTree::tNumberVector aNumVector = [] {
- SwNumberTree::tNumberVector vec(WW8ListManager::nMaxLevel);
- std::iota(vec.begin(), vec.end(), 0);
- return vec;
- }();
-
// write the static data of the SwNumFormat of this level
sal_uInt8 aNumLvlPos[WW8ListManager::nMaxLevel] = { 0,0,0,0,0,0,0,0,0 };
@@ -479,7 +464,7 @@ void MSWordExportBase::NumberingLevel(
OUString sNumStr;
OUString sFontName;
bool bWriteBullet = false;
- const vcl::Font* pBulletFont=nullptr;
+ std::optional<vcl::Font> pBulletFont;
rtl_TextEncoding eChrSet=0;
FontFamily eFamily=FAMILY_DECORATIVE;
if (SVX_NUM_CHAR_SPECIAL == rFormat.GetNumberingType() ||
@@ -492,35 +477,26 @@ void MSWordExportBase::NumberingLevel(
else
{
// Create level string
- // For docx it is not the best way: we can just take it from rRule.Get(nLvl).GetListFormat()
- // But for compatibility with doc we follow same routine
- if (SVX_NUM_NUMBER_NONE != rFormat.GetNumberingType())
+ if (rFormat.HasListFormat())
{
sal_uInt8* pLvlPos = aNumLvlPos;
- // the numbering string has to be restrict
- // to the level currently working on.
- sNumStr = rRule.MakeNumString(aNumVector, false, true, nLvl);
+ sNumStr = rFormat.GetListFormat();
// now search the nums in the string
for (sal_uInt8 i = 0; i <= nLvl; ++i)
{
- OUString sSrch(OUString::number(i));
+ OUString sSrch("%" + OUString::number(i+1) + "%");
sal_Int32 nFnd = sNumStr.indexOf(sSrch);
if (-1 != nFnd)
{
- *pLvlPos = static_cast<sal_uInt8>(nFnd + rFormat.GetPrefix().getLength() + 1);
+ *pLvlPos = static_cast<sal_uInt8>(nFnd + 1);
++pLvlPos;
- sNumStr = sNumStr.replaceAt(nFnd, 1, OUString(static_cast<char>(i)));
+ sNumStr = sNumStr.replaceAt(nFnd, sSrch.getLength(), rtl::OUStringChar(static_cast<char>(i)));
}
}
}
-
- if (!rRule.Get(nLvl).HasListFormat())
- {
- if (!rFormat.GetPrefix().isEmpty())
- sNumStr = rFormat.GetPrefix() + sNumStr;
- sNumStr += rFormat.GetSuffix();
- }
+ else if (rFormat.GetNumberingType() != SVX_NUM_NUMBER_NONE)
+ assert(false && "deprecated format still exists and is unhandled. Inform Vasily or Justin");
}
if (SVX_NUM_CHAR_SPECIAL == rFormat.GetNumberingType() ||
@@ -531,14 +507,14 @@ void MSWordExportBase::NumberingLevel(
pBulletFont = rFormat.GetBulletFont();
if (!pBulletFont)
{
- pBulletFont = &numfunc::GetDefBulletFont();
+ pBulletFont = numfunc::GetDefBulletFont();
}
eChrSet = pBulletFont->GetCharSet();
sFontName = pBulletFont->GetFamilyName();
eFamily = pBulletFont->GetFamilyType();
- if (IsStarSymbol(sFontName))
+ if (IsOpenSymbol(sFontName))
SubstituteBullet(sNumStr, eChrSet, sFontName);
}
@@ -547,8 +523,7 @@ void MSWordExportBase::NumberingLevel(
const SfxItemSet* pOutSet = nullptr;
// cbGrpprlChpx
- SfxItemSet aSet( m_rDoc.GetAttrPool(), svl::Items<RES_CHRATR_BEGIN,
- RES_CHRATR_END>{} );
+ SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END> aSet( m_rDoc.GetAttrPool() );
if (rFormat.GetCharFormat() || bWriteBullet)
{
if (bWriteBullet)
@@ -597,7 +572,7 @@ void MSWordExportBase::NumberingLevel(
pPseudoFont.get(), pOutSet,
nIndentAt, nFirstLineIndex, nListTabPos,
sNumStr,
- rFormat.GetNumberingType()==SVX_NUM_BITMAP ? rFormat.GetBrush() : nullptr);
+ rFormat.GetNumberingType()==SVX_NUM_BITMAP ? rFormat.GetBrush() : nullptr, rFormat.GetIsLegal());
}
void WW8Export::OutOverrideListTab()
@@ -609,19 +584,21 @@ void WW8Export::OutOverrideListTab()
sal_uInt16 nCount = m_pUsedNumTable->size();
sal_uInt16 n;
- pFib->m_fcPlfLfo = pTableStrm->Tell();
- SwWW8Writer::WriteLong( *pTableStrm, nCount );
+ m_pFib->m_fcPlfLfo = m_pTableStrm->Tell();
+ m_pTableStrm->WriteUInt32( nCount );
+ // LFO ([MS-DOC] 2.9.131)
for( n = 0; n < nCount; ++n )
{
- SwWW8Writer::WriteLong( *pTableStrm, n + 1 );
- SwWW8Writer::FillCount( *pTableStrm, 12 );
+ m_pTableStrm->WriteUInt32( n + 1 );
+ SwWW8Writer::FillCount( *m_pTableStrm, 12 );
}
+ // LFOData ([MS-DOC] 2.9.132)
for( n = 0; n < nCount; ++n )
- SwWW8Writer::WriteLong( *pTableStrm, -1 ); // no overwrite
+ m_pTableStrm->WriteInt32( -1 ); // no overwrite
// set len to FIB
- pFib->m_lcbPlfLfo = pTableStrm->Tell() - pFib->m_fcPlfLfo;
+ m_pFib->m_lcbPlfLfo = m_pTableStrm->Tell() - m_pFib->m_fcPlfLfo;
}
void WW8Export::OutListNamesTab()
@@ -632,9 +609,9 @@ void WW8Export::OutListNamesTab()
// write the "list format override" - LFO
sal_uInt16 nNms = 0, nCount = m_pUsedNumTable->size();
- pFib->m_fcSttbListNames = pTableStrm->Tell();
- SwWW8Writer::WriteShort( *pTableStrm, -1 );
- SwWW8Writer::WriteLong( *pTableStrm, nCount );
+ m_pFib->m_fcSttbListNames = m_pTableStrm->Tell();
+ m_pTableStrm->WriteInt16( -1 );
+ m_pTableStrm->WriteUInt32( nCount );
for( ; nNms < nCount; ++nNms )
{
@@ -643,14 +620,14 @@ void WW8Export::OutListNamesTab()
if( !rRule.IsAutoRule() )
sNm = rRule.GetName();
- SwWW8Writer::WriteShort( *pTableStrm, sNm.getLength() );
+ m_pTableStrm->WriteUInt16( sNm.getLength() );
if (!sNm.isEmpty())
- SwWW8Writer::WriteString16(*pTableStrm, sNm, false);
+ SwWW8Writer::WriteString16(*m_pTableStrm, sNm, false);
}
- SwWW8Writer::WriteLong( *pTableStrm, pFib->m_fcSttbListNames + 2, nNms );
+ SwWW8Writer::WriteLong( *m_pTableStrm, m_pFib->m_fcSttbListNames + 2, nNms );
// set len to FIB
- pFib->m_lcbSttbListNames = pTableStrm->Tell() - pFib->m_fcSttbListNames;
+ m_pFib->m_lcbSttbListNames = m_pTableStrm->Tell() - m_pFib->m_fcSttbListNames;
}
void MSWordExportBase::SubstituteBullet( OUString& rNumStr,
@@ -663,7 +640,7 @@ void MSWordExportBase::SubstituteBullet( OUString& rNumStr,
// If Bullet char is "", don't change
if (rNumStr[0] != u'\0')
{
- rNumStr = rNumStr.replaceAt(0, 1, OUString(
+ rNumStr = rNumStr.replaceAt(0, 1, rtl::OUStringChar(
msfilter::util::bestFitOpenSymbolToMSFont(rNumStr[0], rChrSet, sFontName)));
}
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 08e54ab628cf..42a12b7567bd 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -30,6 +30,8 @@
#include <svx/svdouno.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/fhgtitem.hxx>
+#include <rtl/character.hxx>
+
#include <doc.hxx>
#include "wrtww8.hxx"
#include <docary.hxx>
@@ -104,21 +106,62 @@ struct WW8_SED
class WW8_WrPlc0
{
private:
- std::vector<sal_uLong> aPos; // PTRARR of CPs / FCs
- sal_uLong nOfs;
+ std::vector<sal_uLong> m_aPos; // PTRARR of CPs / FCs
+ sal_uLong m_nOfs;
WW8_WrPlc0(WW8_WrPlc0 const&) = delete;
WW8_WrPlc0& operator=(WW8_WrPlc0 const&) = delete;
public:
explicit WW8_WrPlc0( sal_uLong nOffset );
- sal_uInt16 Count() const { return aPos.size(); }
+ sal_uInt16 Count() const { return m_aPos.size(); }
void Append( sal_uLong nStartCpOrFc );
void Write( SvStream& rStrm );
};
// Styles
+// According to [MS-DOC] v20221115 2.9.271 STSH,
+// "The beginning of the rglpstd array is reserved for specific "fixed-index" application-defined
+// styles. A particular fixed-index, application-defined style has the same istd value in every
+// stylesheet. The rglpstd MUST contain an LPStd for each of these fixed-index styles and the order
+// MUST match the order in the following table.
+//
+// istd sti of application-defined style (see sti in StdfBase)
+// 0 0
+// 1 1
+// 2 2
+// 3 3
+// 4 4
+// 5 5
+// 6 6
+// 7 7
+// 8 8
+// 9 9
+// 10 65
+// 11 105
+// 12 107
+// 13 Reserved for future use
+// 14 Reserved for future use"
+//
+// And [MS-OE376] v20220816 2.1.236 Part 4 Section 2.7.3.9, name (Primary Style Name)
+// specifies the following mapping:
+//
+// sti Style name Style type
+// 0 Normal paragraph
+// 1 heading 1 paragraph
+// 2 heading 2 paragraph
+// 3 heading 3 paragraph
+// 4 heading 4 paragraph
+// 5 heading 5 paragraph
+// 6 heading 6 paragraph
+// 7 heading 7 paragraph
+// 8 heading 8 paragraph
+// 9 heading 9 paragraph
+// 65 Default Paragraph Font character
+// 105 Normal Table table
+// 107 No List numbering
+
#define WW8_RESERVED_SLOTS 15
// GetId( SwCharFormat ) for use in text -> zero is not allowed,
@@ -151,16 +194,11 @@ MSWordStyles::MSWordStyles( MSWordExportBase& rExport, bool bListStyles )
m_rExport.m_rDoc.GetFootnoteInfo().GetAnchorCharFormat( m_rExport.m_rDoc );
m_rExport.m_rDoc.GetFootnoteInfo().GetCharFormat( m_rExport.m_rDoc );
}
- sal_uInt16 nAlloc = WW8_RESERVED_SLOTS + m_rExport.m_rDoc.GetCharFormats()->size() - 1 +
- m_rExport.m_rDoc.GetTextFormatColls()->size() - 1 +
- (bListStyles ? m_rExport.m_rDoc.GetNumRuleTable().size() - 1 : 0);
- // somewhat generous ( free for up to 15 )
- m_pFormatA.reset( new SwFormat*[ nAlloc ] );
- memset( m_pFormatA.get(), 0, nAlloc * sizeof( SwFormat* ) );
memset( m_aHeadingParagraphStyles, -1 , MAXLEVEL * sizeof( sal_uInt16));
BuildStylesTable();
+ BuildWwNames();
BuildStyleIds();
}
@@ -171,21 +209,19 @@ MSWordStyles::~MSWordStyles()
// Sty_SetWWSlot() dependencies for the styles -> zero is allowed
sal_uInt16 MSWordStyles::GetSlot( const SwFormat* pFormat ) const
{
- sal_uInt16 n;
- for ( n = 0; n < m_nUsedSlots; n++ )
- if ( m_pFormatA[n] == pFormat )
- return n;
+ for (size_t slot = 0; slot < m_aStyles.size(); ++slot)
+ if (m_aStyles[slot].format == pFormat)
+ return slot;
return 0xfff; // 0xfff: WW: zero
}
-sal_uInt16 MSWordStyles::BuildGetSlot( const SwFormat& rFormat )
+/// Get reserved slot number during building the style table.
+static sal_uInt16 BuildGetSlot(const SwFormat& rFormat)
{
- sal_uInt16 nRet = rFormat.GetPoolFormatId();
- switch ( nRet )
+ switch (sal_uInt16 nRet = rFormat.GetPoolFormatId())
{
case RES_POOLCOLL_STANDARD:
- nRet = 0;
- break;
+ return 0;
case RES_POOLCOLL_HEADLINE1:
case RES_POOLCOLL_HEADLINE2:
@@ -197,110 +233,117 @@ sal_uInt16 MSWordStyles::BuildGetSlot( const SwFormat& rFormat )
case RES_POOLCOLL_HEADLINE8:
case RES_POOLCOLL_HEADLINE9:
nRet -= RES_POOLCOLL_HEADLINE1-1;
- break;
-
- default:
- nRet = m_nUsedSlots++;
- break;
+ assert(nRet < WW8_RESERVED_SLOTS);
+ return nRet;
}
- return nRet;
+ return 0xfff;
}
+// Keep in sync with StyleSheetTable::ConvertStyleName
sal_uInt16 MSWordStyles::GetWWId( const SwFormat& rFormat )
{
sal_uInt16 nRet = ww::stiUser; // user style as default
sal_uInt16 nPoolId = rFormat.GetPoolFormatId();
if( nPoolId == RES_POOLCOLL_STANDARD )
- nRet = 0;
+ nRet = ww::stiNormal;
else if( nPoolId >= RES_POOLCOLL_HEADLINE1 &&
nPoolId <= RES_POOLCOLL_HEADLINE9 )
- nRet = static_cast< sal_uInt16 >(nPoolId + 1 - RES_POOLCOLL_HEADLINE1);
+ nRet = static_cast< sal_uInt16 >(nPoolId + ww::stiLevFirst - RES_POOLCOLL_HEADLINE1);
else if( nPoolId >= RES_POOLCOLL_TOX_IDX1 &&
nPoolId <= RES_POOLCOLL_TOX_IDX3 )
- nRet = static_cast< sal_uInt16 >(nPoolId + 10 - RES_POOLCOLL_TOX_IDX1);
+ nRet = static_cast< sal_uInt16 >(nPoolId + ww::stiIndexFirst - RES_POOLCOLL_TOX_IDX1);
else if( nPoolId >= RES_POOLCOLL_TOX_CNTNT1 &&
nPoolId <= RES_POOLCOLL_TOX_CNTNT5 )
- nRet = static_cast< sal_uInt16 >(nPoolId + 19 - RES_POOLCOLL_TOX_CNTNT1);
+ nRet = static_cast< sal_uInt16 >(nPoolId + ww::stiToc1 - RES_POOLCOLL_TOX_CNTNT1);
else if( nPoolId >= RES_POOLCOLL_TOX_CNTNT6 &&
nPoolId <= RES_POOLCOLL_TOX_CNTNT9 )
- nRet = static_cast< sal_uInt16 >(nPoolId + 24 - RES_POOLCOLL_TOX_CNTNT6);
+ nRet = static_cast< sal_uInt16 >(nPoolId + ww::stiToc6 - RES_POOLCOLL_TOX_CNTNT6);
else
switch( nPoolId )
{
- case RES_POOLCOLL_FOOTNOTE: nRet = 29; break;
- case RES_POOLCOLL_MARGINAL: nRet = 30; break;
- case RES_POOLCOLL_HEADER: nRet = 31; break;
- case RES_POOLCOLL_FOOTER: nRet = 32; break;
- case RES_POOLCOLL_TOX_IDXH: nRet = 33; break;
- case RES_POOLCOLL_LABEL: nRet = 34; break;
- case RES_POOLCOLL_LABEL_DRAWING: nRet = 35; break;
- case RES_POOLCOLL_ENVELOPE_ADDRESS: nRet = 36; break;
- case RES_POOLCOLL_SEND_ADDRESS: nRet = 37; break;
- case RES_POOLCOLL_ENDNOTE: nRet = 43; break;
- case RES_POOLCOLL_TOX_AUTHORITIESH: nRet = 44; break;
- case RES_POOLCOLL_TOX_CNTNTH: nRet = 46; break;
- case RES_POOLCOLL_BULLET_LEVEL1: nRet = 48; break;
- case RES_POOLCOLL_LISTS_BEGIN: nRet = 47; break;
- case RES_POOLCOLL_NUM_LEVEL1: nRet = 49; break;
- case RES_POOLCOLL_BULLET_LEVEL2: nRet = 54; break;
- case RES_POOLCOLL_BULLET_LEVEL3: nRet = 55; break;
- case RES_POOLCOLL_BULLET_LEVEL4: nRet = 56; break;
- case RES_POOLCOLL_BULLET_LEVEL5: nRet = 57; break;
- case RES_POOLCOLL_NUM_LEVEL2: nRet = 58; break;
- case RES_POOLCOLL_NUM_LEVEL3: nRet = 59; break;
- case RES_POOLCOLL_NUM_LEVEL4: nRet = 60; break;
- case RES_POOLCOLL_NUM_LEVEL5: nRet = 61; break;
- case RES_POOLCOLL_DOC_TITLE: nRet = 62; break;
- case RES_POOLCOLL_DOC_APPENDIX: nRet = 63; break;
- case RES_POOLCOLL_SIGNATURE: nRet = 64; break;
- case RES_POOLCOLL_TEXT: nRet = 66; break;
- case RES_POOLCOLL_TEXT_MOVE: nRet = 67; break;
- case RES_POOLCOLL_BULLET_NONUM1: nRet = 68; break;
- case RES_POOLCOLL_BULLET_NONUM2: nRet = 69; break;
- case RES_POOLCOLL_BULLET_NONUM3: nRet = 70; break;
- case RES_POOLCOLL_BULLET_NONUM4: nRet = 71; break;
- case RES_POOLCOLL_BULLET_NONUM5: nRet = 72; break;
- case RES_POOLCOLL_DOC_SUBTITLE: nRet = 74; break;
- case RES_POOLCOLL_GREETING: nRet = 75; break;
- case RES_POOLCOLL_TEXT_IDENT: nRet = 77; break;
-
- case RES_POOLCHR_FOOTNOTE_ANCHOR: nRet = 38; break;
- case RES_POOLCHR_ENDNOTE_ANCHOR: nRet = 42; break;
- case RES_POOLCHR_INET_NORMAL: nRet = 85; break;
- case RES_POOLCHR_INET_VISIT: nRet = 86; break;
- case RES_POOLCHR_HTML_STRONG: nRet = 87; break;
- case RES_POOLCHR_HTML_EMPHASIS: nRet = 88; break;
- case RES_POOLCHR_LINENUM: nRet = 40; break;
- case RES_POOLCHR_PAGENO: nRet = 41; break;
+ case RES_POOLCOLL_FOOTNOTE: nRet = ww::stiFootnoteText; break;
+ case RES_POOLCOLL_MARGINAL: nRet = ww::stiAtnText; break;
+ case RES_POOLCOLL_HEADER: nRet = ww::stiHeader; break;
+ case RES_POOLCOLL_FOOTER: nRet = ww::stiFooter; break;
+ case RES_POOLCOLL_TOX_IDXH: nRet = ww::stiIndexHeading; break;
+ case RES_POOLCOLL_LABEL: nRet = ww::stiCaption; break;
+ case RES_POOLCOLL_TOX_ILLUS1: nRet = ww::stiToCaption; break;
+ case RES_POOLCOLL_ENVELOPE_ADDRESS: nRet = ww::stiEnvAddr; break;
+ case RES_POOLCOLL_SEND_ADDRESS: nRet = ww::stiEnvRet; break;
+ case RES_POOLCHR_FOOTNOTE_ANCHOR: nRet = ww::stiFootnoteRef; break;
+ case RES_POOLCHR_LINENUM: nRet = ww::stiLnn; break;
+ case RES_POOLCHR_PAGENO: nRet = ww::stiPgn; break;
+ case RES_POOLCHR_ENDNOTE_ANCHOR: nRet = ww::stiEdnRef; break;
+ case RES_POOLCOLL_ENDNOTE: nRet = ww::stiEdnText; break;
+ case RES_POOLCOLL_TOX_AUTHORITIESH: nRet = ww::stiToa; break;
+ case RES_POOLCOLL_TOX_CNTNTH: nRet = ww::stiToaHeading; break;
+ case RES_POOLCOLL_LISTS_BEGIN: nRet = ww::stiList; break;
+ case RES_POOLCOLL_BULLET_LEVEL1: nRet = ww::stiListBullet; break;
+ case RES_POOLCOLL_NUM_LEVEL1: nRet = ww::stiListNumber; break;
+ case RES_POOLCOLL_BULLET_LEVEL2: nRet = ww::stiListBullet2; break;
+ case RES_POOLCOLL_BULLET_LEVEL3: nRet = ww::stiListBullet3; break;
+ case RES_POOLCOLL_BULLET_LEVEL4: nRet = ww::stiListBullet4; break;
+ case RES_POOLCOLL_BULLET_LEVEL5: nRet = ww::stiListBullet5; break;
+ case RES_POOLCOLL_NUM_LEVEL2: nRet = ww::stiListNumber2; break;
+ case RES_POOLCOLL_NUM_LEVEL3: nRet = ww::stiListNumber3; break;
+ case RES_POOLCOLL_NUM_LEVEL4: nRet = ww::stiListNumber4; break;
+ case RES_POOLCOLL_NUM_LEVEL5: nRet = ww::stiListNumber5; break;
+ case RES_POOLCOLL_DOC_TITLE: nRet = ww::stiTitle; break;
+ case RES_POOLCOLL_DOC_APPENDIX: nRet = ww::stiClosing; break;
+ case RES_POOLCOLL_SIGNATURE: nRet = ww::stiSignature; break;
+ case RES_POOLCOLL_TEXT: nRet = ww::stiBodyText; break;
+ case RES_POOLCOLL_TEXT_MOVE: nRet = ww::stiBodyTextInd1; break;
+ case RES_POOLCOLL_BULLET_NONUM1: nRet = ww::stiListCont; break;
+ case RES_POOLCOLL_BULLET_NONUM2: nRet = ww::stiListCont2; break;
+ case RES_POOLCOLL_BULLET_NONUM3: nRet = ww::stiListCont3; break;
+ case RES_POOLCOLL_BULLET_NONUM4: nRet = ww::stiListCont4; break;
+ case RES_POOLCOLL_BULLET_NONUM5: nRet = ww::stiListCont5; break;
+ case RES_POOLCOLL_DOC_SUBTITLE: nRet = ww::stiSubtitle; break;
+ case RES_POOLCOLL_GREETING: nRet = ww::stiSalutation; break;
+ case RES_POOLCOLL_TEXT_IDENT: nRet = ww::stiBodyText1I; break;
+ case RES_POOLCHR_INET_NORMAL: nRet = ww::stiHyperlink; break;
+ case RES_POOLCHR_INET_VISIT: nRet = ww::stiHyperlinkFollowed; break;
+ case RES_POOLCHR_HTML_STRONG: nRet = ww::stiStrong; break;
+ case RES_POOLCHR_HTML_EMPHASIS: nRet = ww::stiEmphasis; break;
}
return nRet;
}
void MSWordStyles::BuildStylesTable()
{
- m_nUsedSlots = WW8_RESERVED_SLOTS; // reserved slots for standard, headingX, and others
+ assert(m_aStyles.empty());
+ // Put reserved slots first, then character styles, then paragraph styles
+ m_aStyles.resize(WW8_RESERVED_SLOTS);
const SwCharFormats& rArr = *m_rExport.m_rDoc.GetCharFormats(); // first CharFormat
// the default character style ( 0 ) will not be outputted !
- for( size_t n = 1; n < rArr.size(); n++ )
- {
- SwCharFormat* pFormat = rArr[n];
- m_pFormatA[ BuildGetSlot( *pFormat ) ] = pFormat;
- }
+ for (size_t n = 1; n < rArr.size() && m_aStyles.size() < MSWORD_MAX_STYLES_LIMIT; ++n)
+ m_aStyles.emplace_back(rArr[n]);
const SwTextFormatColls& rArr2 = *m_rExport.m_rDoc.GetTextFormatColls(); // then TextFormatColls
- // the default character style ( 0 ) will not be outputted !
- for( size_t n = 1; n < rArr2.size(); n++ )
+ // the default paragraph style ( 0 ) will not be outputted !
+ for (size_t n = 1; n < rArr2.size(); ++n)
{
SwTextFormatColl* pFormat = rArr2[n];
- sal_uInt16 nId = BuildGetSlot( *pFormat ) ;
- m_pFormatA[ nId ] = pFormat;
+
+ sal_uInt16 nSlot = BuildGetSlot(*pFormat);
+ if (nSlot != 0xfff)
+ {
+ m_aStyles[nSlot] = { pFormat };
+ }
+ else
+ {
+ if (m_aStyles.size() >= MSWORD_MAX_STYLES_LIMIT)
+ continue;
+ m_aStyles.emplace_back(pFormat);
+ nSlot = m_aStyles.size() - 1;
+ }
if ( pFormat->IsAssignedToListLevelOfOutlineStyle() )
{
int nLvl = pFormat->GetAssignedOutlineStyleLevel() ;
if (nLvl >= 0 && nLvl < MAXLEVEL)
- m_aHeadingParagraphStyles[nLvl] = nId ;
+ m_aHeadingParagraphStyles[nLvl] = nSlot;
}
}
@@ -308,77 +351,121 @@ void MSWordStyles::BuildStylesTable()
return;
const SwNumRuleTable& rNumRuleTable = m_rExport.m_rDoc.GetNumRuleTable();
- for (size_t i = 0; i < rNumRuleTable.size(); ++i)
+ for (size_t i = 0; i < rNumRuleTable.size() && m_aStyles.size() < MSWORD_MAX_STYLES_LIMIT; ++i)
{
const SwNumRule* pNumRule = rNumRuleTable[i];
if (pNumRule->IsAutoRule() || pNumRule->GetName().startsWith("WWNum"))
continue;
- sal_uInt16 nSlot = BuildGetSlot(*pNumRule);
- m_aNumRules[nSlot] = pNumRule;
+ m_aStyles.emplace_back(pNumRule);
}
}
-OString MSWordStyles::CreateStyleId(const OUString &rName)
+// StyleSheetTable::ConvertStyleName appends the suffix do disambiguate conflicting style names
+static OUString StripWWSuffix(const OUString& s)
{
- OStringBuffer aStyleIdBuf(rName.getLength());
- for (int i = 0; i < rName.getLength(); ++i)
- {
- sal_Unicode nChar = rName[i];
- if (('0' <= nChar && nChar <= '9') ||
- ('a' <= nChar && nChar <= 'z') ||
- ('A' <= nChar && nChar <= 'Z'))
+ OUString ret = s;
+ (void)ret.endsWith(" (WW)", &ret);
+ return ret;
+}
+
+void MSWordStyles::BuildWwNames()
+{
+ std::unordered_set<OUString> aUsed;
+
+ auto makeUniqueName = [&aUsed](OUString& name) {
+ // toAsciiLowerCase rules out e.g. user's "normal"; no problem if there are non-ASCII chars
+ OUString lower(name.toAsciiLowerCase());
+ if (!aUsed.insert(lower).second)
{
- // first letter should be uppercase
- if (aStyleIdBuf.isEmpty() && 'a' <= nChar && nChar <= 'z')
- aStyleIdBuf.append(char(nChar - ('a' - 'A')));
- else
- aStyleIdBuf.append(char(nChar));
+ int nFree = 1;
+ while (!aUsed.insert(lower + OUString::number(nFree)).second)
+ ++nFree;
+
+ name += OUString::number(nFree);
}
+ };
+
+ // We want to map LO's default style to Word's "Normal" style.
+ // Word looks for this specific style name when reading docx files.
+ // (It must be the English word regardless of languages and locales)
+ assert(!m_aStyles.empty());
+ assert(!m_aStyles[0].format || m_aStyles[0].ww_id == ww::stiNormal);
+ m_aStyles[0].ww_name = "Normal";
+ aUsed.insert("normal");
+
+ // 1. Handle styles having special wwIds, and thus pre-defined names
+ for (auto& entry : m_aStyles)
+ {
+ if (!entry.ww_name.isEmpty())
+ continue; // "Normal" is already added
+ if (entry.ww_id >= ww::stiMax)
+ continue; // Not a format with special name
+ assert(entry.format);
+
+ entry.ww_name = OUString::createFromAscii(ww::GetEnglishNameFromSti(static_cast<ww::sti>(entry.ww_id)));
+ makeUniqueName(entry.ww_name);
+ }
+
+ // 2. Now handle other styles
+ for (auto& entry : m_aStyles)
+ {
+ if (!entry.ww_name.isEmpty())
+ continue;
+ if (entry.format)
+ entry.ww_name = StripWWSuffix(entry.format->GetName());
+ else if (entry.num_rule)
+ entry.ww_name = StripWWSuffix(entry.num_rule->GetName());
+ else
+ continue;
+ makeUniqueName(entry.ww_name);
}
- return aStyleIdBuf.makeStringAndClear();
+}
+
+OString MSWordStyles::CreateStyleId(std::u16string_view aName)
+{
+ return OUStringToOString(msfilter::util::CreateDOCXStyleId(aName), RTL_TEXTENCODING_UTF8);
}
void MSWordStyles::BuildStyleIds()
{
std::unordered_set<OString> aUsed;
- m_aStyleIds.emplace_back("Normal");
- aUsed.insert("normal");
-
- for (sal_uInt16 n = 1; n < m_nUsedSlots; ++n)
+ for (auto& entry : m_aStyles)
{
- OUString aName;
- if(m_pFormatA[n])
- aName = m_pFormatA[n]->GetName();
- else if (m_aNumRules.find(n) != m_aNumRules.end())
- aName = m_aNumRules[n]->GetName();
-
- OString aStyleId = CreateStyleId(aName);
+ OString aStyleId = CreateStyleId(entry.ww_name);
if (aStyleId.isEmpty())
- aStyleId = "Style";
+ aStyleId = "Style"_ostr;
OString aLower(aStyleId.toAsciiLowerCase());
// check for uniqueness & construct something unique if we have to
- if (aUsed.insert(aLower).second)
- {
- m_aStyleIds.push_back(aStyleId);
- }
- else
+ if (!aUsed.insert(aLower).second)
{
int nFree = 1;
while (!aUsed.insert(aLower + OString::number(nFree)).second)
++nFree;
- m_aStyleIds.emplace_back(aStyleId + OString::number(nFree));
+ aStyleId += OString::number(nFree);
}
+ entry.style_id = aStyleId;
}
}
-OString const & MSWordStyles::GetStyleId(sal_uInt16 nId) const
+OString const & MSWordStyles::GetStyleId(sal_uInt16 nSlot) const
+{
+ assert(!m_aStyles[nSlot].style_id.isEmpty());
+ return m_aStyles[nSlot].style_id;
+}
+
+OUString MSWordStyles::GetStyleWWName(SwFormat const*const pFormat) const
{
- return m_aStyleIds[nId];
+ if (auto slot = m_rExport.m_pStyles->GetSlot(pFormat); slot != 0xfff)
+ {
+ assert(!m_aStyles[slot].ww_name.isEmpty());
+ return m_aStyles[slot].ww_name;
+ }
+ return OUString();
}
/// For WW8 only - extend pO so that the size of pTableStrm is even.
@@ -390,20 +477,20 @@ static void impl_SkipOdd(std::unique_ptr<ww::bytes> const& pO, std::size_t nTabl
void WW8AttributeOutput::EndStyle()
{
- impl_SkipOdd( m_rWW8Export.pO, m_rWW8Export.pTableStrm->Tell() );
+ impl_SkipOdd( m_rWW8Export.m_pO, m_rWW8Export.m_pTableStrm->Tell() );
- short nLen = m_rWW8Export.pO->size() - 2; // length of the style
- sal_uInt8* p = m_rWW8Export.pO->data() + nPOPosStdLen1;
+ short nLen = m_rWW8Export.m_pO->size() - 2; // length of the style
+ sal_uInt8* p = m_rWW8Export.m_pO->data() + m_nPOPosStdLen1;
ShortToSVBT16( nLen, p ); // add
- p = m_rWW8Export.pO->data() + nPOPosStdLen2;
+ p = m_rWW8Export.m_pO->data() + m_nPOPosStdLen2;
ShortToSVBT16( nLen, p ); // also
- m_rWW8Export.pTableStrm->WriteBytes(m_rWW8Export.pO->data(), m_rWW8Export.pO->size());
- m_rWW8Export.pO->clear();
+ m_rWW8Export.m_pTableStrm->WriteBytes(m_rWW8Export.m_pO->data(), m_rWW8Export.m_pO->size());
+ m_rWW8Export.m_pO->clear();
}
void WW8AttributeOutput::StartStyle( const OUString& rName, StyleType eType, sal_uInt16 nWwBase,
- sal_uInt16 nWwNext, sal_uInt16 nWwId, sal_uInt16 /*nId*/, bool bAutoUpdate )
+ sal_uInt16 nWwNext, sal_uInt16 /*nWwLink*/, sal_uInt16 nWwId, sal_uInt16 /*nSlot*/, bool bAutoUpdate )
{
sal_uInt8 aWW8_STD[ sizeof( WW8_STD ) ] = {};
sal_uInt8* pData = aWW8_STD;
@@ -432,17 +519,17 @@ void WW8AttributeOutput::StartStyle( const OUString& rName, StyleType eType, sal
sal_uInt16 nLen = static_cast< sal_uInt16 >( ( pData - aWW8_STD ) + 1 +
(2 * (rName.getLength() + 1)) ); // temporary
- nPOPosStdLen1 = m_rWW8Export.pO->size(); // Adr1 for adding the length
+ m_nPOPosStdLen1 = m_rWW8Export.m_pO->size(); // Adr1 for adding the length
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, nLen );
- m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), aWW8_STD, pData );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, nLen );
+ m_rWW8Export.m_pO->insert( m_rWW8Export.m_pO->end(), aWW8_STD, pData );
- nPOPosStdLen2 = nPOPosStdLen1 + 8; // Adr2 for adding of "end of upx"
+ m_nPOPosStdLen2 = m_nPOPosStdLen1 + 8; // Adr2 for adding of "end of upx"
// write names
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, rName.getLength() ); // length
- SwWW8Writer::InsAsString16( *m_rWW8Export.pO, rName );
- m_rWW8Export.pO->push_back( sal_uInt8(0) ); // Despite P-String 0 at the end!
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, rName.getLength() ); // length
+ SwWW8Writer::InsAsString16( *m_rWW8Export.m_pO, rName );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0) ); // Despite P-String 0 at the end!
}
void MSWordStyles::SetStyleDefaults( const SwFormat& rFormat, bool bPap )
@@ -465,7 +552,7 @@ void MSWordStyles::SetStyleDefaults( const SwFormat& rFormat, bool bPap )
// dynamic defaults
const SfxItemPool& rPool = *rFormat.GetAttrSet().GetPool();
for( n = nStt; n < nEnd; ++n )
- aFlags[ n - RES_CHRATR_BEGIN ] = nullptr != rPool.GetPoolDefaultItem( n )
+ aFlags[ n - RES_CHRATR_BEGIN ] = nullptr != rPool.GetUserDefaultItem( n )
|| SfxItemState::SET == m_rExport.m_rDoc.GetDfltTextFormatColl()->GetItemState( n, false );
// static defaults, that differs between WinWord and SO
@@ -507,19 +594,19 @@ void MSWordStyles::SetStyleDefaults( const SwFormat& rFormat, bool bPap )
void WW8AttributeOutput::StartStyleProperties( bool bParProp, sal_uInt16 nStyle )
{
- impl_SkipOdd( m_rWW8Export.pO, m_rWW8Export.pTableStrm->Tell() );
+ impl_SkipOdd( m_rWW8Export.m_pO, m_rWW8Export.m_pTableStrm->Tell() );
sal_uInt16 nLen = bParProp ? 2 : 0; // default length
- m_nStyleLenPos = m_rWW8Export.pO->size(); // adding length
+ m_nStyleLenPos = m_rWW8Export.m_pO->size(); // adding length
// Don't save pointer, because it
// changes by _grow!
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, nLen ); // Style-Len
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, nLen ); // Style-Len
- m_nStyleStartSize = m_rWW8Export.pO->size();
+ m_nStyleStartSize = m_rWW8Export.m_pO->size();
if ( bParProp )
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, nStyle ); // Style-Number
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, nStyle ); // Style-Number
}
void MSWordStyles::WriteProperties( const SwFormat* pFormat, bool bParProp, sal_uInt16 nPos,
@@ -544,12 +631,12 @@ void MSWordStyles::WriteProperties( const SwFormat* pFormat, bool bParProp, sal_
void WW8AttributeOutput::EndStyleProperties( bool /*bParProp*/ )
{
- sal_uInt16 nLen = m_rWW8Export.pO->size() - m_nStyleStartSize;
- sal_uInt8* pUpxLen = m_rWW8Export.pO->data() + m_nStyleLenPos; // adding length
+ sal_uInt16 nLen = m_rWW8Export.m_pO->size() - m_nStyleStartSize;
+ sal_uInt8* pUpxLen = m_rWW8Export.m_pO->data() + m_nStyleLenPos; // adding length
ShortToSVBT16( nLen, pUpxLen ); // add default length
}
-void MSWordStyles::GetStyleData( SwFormat* pFormat, bool& bFormatColl, sal_uInt16& nBase, sal_uInt16& nNext )
+void MSWordStyles::GetStyleData( const SwFormat* pFormat, bool& bFormatColl, sal_uInt16& nBase, sal_uInt16& nNext, sal_uInt16& nLink )
{
bFormatColl = pFormat->Which() == RES_TXTFMTCOLL || pFormat->Which() == RES_CONDTXTFMTCOLL;
@@ -560,94 +647,73 @@ void MSWordStyles::GetStyleData( SwFormat* pFormat, bool& bFormatColl, sal_uInt1
if ( !pFormat->IsDefault() )
nBase = GetSlot( pFormat->DerivedFrom() );
- SwFormat* pNext;
+ const SwFormat* pNext;
+ const SwFormat* pLink = nullptr;
if ( bFormatColl )
- pNext = &static_cast<SwTextFormatColl*>(pFormat)->GetNextTextFormatColl();
+ {
+ auto pFormatColl = static_cast<const SwTextFormatColl*>(pFormat);
+ pNext = &pFormatColl->GetNextTextFormatColl();
+ pLink = pFormatColl->GetLinkedCharFormat();
+ }
else
+ {
pNext = pFormat; // CharFormat: next CharFormat == self
+ auto pCharFormat = static_cast<const SwCharFormat*>(pFormat);
+ pLink = pCharFormat->GetLinkedParaFormat();
+ }
nNext = GetSlot( pNext );
+
+ if (pLink)
+ {
+ nLink = GetSlot(pLink);
+ }
}
void WW8AttributeOutput::DefaultStyle()
{
- m_rWW8Export.pTableStrm->WriteUInt16(0); // empty Style
+ m_rWW8Export.m_pTableStrm->WriteUInt16(0); // empty Style
}
-void MSWordStyles::OutputStyle(const SwNumRule* pNumRule, sal_uInt16 nPos)
+void MSWordStyles::OutputStyle(sal_uInt16 nSlot)
{
- m_rExport.AttrOutput().StartStyle( pNumRule->GetName(), STYLE_TYPE_LIST,
- /*nBase =*/ 0, /*nWwNext =*/ 0, /*nWWId =*/ 0, nPos,
- /*bAutoUpdateFormat =*/ false );
+ const auto& entry = m_aStyles[nSlot];
- m_rExport.AttrOutput().EndStyle();
-}
+ if (entry.num_rule)
+ {
+ m_rExport.AttrOutput().StartStyle( entry.ww_name, STYLE_TYPE_LIST,
+ /*nBase =*/ 0, /*nWwNext =*/ 0, /*nWwLink =*/ 0, /*nWWId =*/ 0, nSlot,
+ /*bAutoUpdateFormat =*/ false );
-// OutputStyle applies for TextFormatColls and CharFormats
-void MSWordStyles::OutputStyle( SwFormat* pFormat, sal_uInt16 nPos )
-{
- if ( !pFormat )
+ m_rExport.AttrOutput().EndStyle();
+ }
+ else if (!entry.format)
+ {
m_rExport.AttrOutput().DefaultStyle();
+ }
else
{
bool bFormatColl;
sal_uInt16 nBase, nWwNext;
+ sal_uInt16 nWwLink = 0x0FFF;
- GetStyleData( pFormat, bFormatColl, nBase, nWwNext );
+ GetStyleData(entry.format, bFormatColl, nBase, nWwNext, nWwLink);
- OUString aName = pFormat->GetName();
- // We want to map LO's default style to Word's "Normal" style.
- // Word looks for this specific style name when reading docx files.
- // (It must be the English word regardless of language settings)
- if ( nPos == 0 )
- {
- assert( pFormat->GetPoolFormatId() == RES_POOLCOLL_STANDARD );
- aName = "Normal";
- }
- else if (aName.equalsIgnoreAsciiCase("Normal"))
- {
- // If LO has a style named "Normal"(!) rename it to something unique
- const OUString aBaseName = "LO-" + aName;
- aName = aBaseName;
- // Check if we still have a clash, in which case we add a suffix
- for ( int nSuffix = 0; ; ++nSuffix ) {
- bool clash=false;
- for ( sal_uInt16 n = 1; n < m_nUsedSlots; ++n )
- if ( m_pFormatA[n] &&
- m_pFormatA[n]->GetName().equalsIgnoreAsciiCase(aName) )
- {
- clash = true;
- break;
- }
- if (!clash)
- break;
- // TODO: verify if we really need to increment nSuffix in 2 places
- aName = aBaseName + OUString::number(++nSuffix);
- }
- }
- else if (!bFormatColl && m_rExport.GetExportFormat() == MSWordExportBase::DOCX &&
- m_rExport.m_pStyles->GetStyleId(nPos).startsWith("ListLabel"))
+ if (!bFormatColl && m_rExport.GetExportFormat() == MSWordExportBase::DOCX &&
+ entry.style_id.startsWith("ListLabel"))
{
// tdf#92335 don't export redundant DOCX import style "ListLabel"
return;
}
- else if (aName.equalsIgnoreAsciiCase("Internet Link"))
- {
- aName = "Hyperlink";
- }
- else if (aName.equalsIgnoreAsciiCase("Visited Internet Link"))
- {
- aName = "FollowedHyperlink";
- }
- m_rExport.AttrOutput().StartStyle( aName, (bFormatColl ? STYLE_TYPE_PARA : STYLE_TYPE_CHAR),
- nBase, nWwNext, GetWWId( *pFormat ), nPos,
- pFormat->IsAutoUpdateFormat() );
+ m_rExport.AttrOutput().StartStyle(entry.ww_name, (bFormatColl ? STYLE_TYPE_PARA : STYLE_TYPE_CHAR),
+ nBase, nWwNext, nWwLink, m_aStyles[nSlot].ww_id, nSlot,
+ entry.format->IsAutoUpdateOnDirectFormat() );
if ( bFormatColl )
- WriteProperties( pFormat, true, nPos, nBase==0xfff ); // UPX.papx
+ WriteProperties( entry.format, true, nSlot, nBase==0xfff ); // UPX.papx
- WriteProperties( pFormat, false, nPos, bFormatColl && nBase==0xfff ); // UPX.chpx
+ WriteProperties( entry.format, false, nSlot, bFormatColl && nBase==0xfff ); // UPX.chpx
m_rExport.AttrOutput().EndStyle();
}
@@ -655,12 +721,12 @@ void MSWordStyles::OutputStyle( SwFormat* pFormat, sal_uInt16 nPos )
void WW8AttributeOutput::StartStyles()
{
- WW8Fib& rFib = *m_rWW8Export.pFib;
+ WW8Fib& rFib = *m_rWW8Export.m_pFib;
- sal_uLong nCurPos = m_rWW8Export.pTableStrm->Tell();
+ sal_uInt64 nCurPos = m_rWW8Export.m_pTableStrm->Tell();
if ( nCurPos & 1 ) // start on even
{
- m_rWW8Export.pTableStrm->WriteChar( char(0) ); // Address
+ m_rWW8Export.m_pTableStrm->WriteChar( char(0) ); // Address
++nCurPos;
}
rFib.m_fcStshfOrig = rFib.m_fcStshf = nCurPos;
@@ -672,15 +738,15 @@ void WW8AttributeOutput::StartStyles()
0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00 };
- m_rWW8Export.pTableStrm->WriteBytes(&aStShi, sizeof(aStShi));
+ m_rWW8Export.m_pTableStrm->WriteBytes(&aStShi, sizeof(aStShi));
}
void WW8AttributeOutput::EndStyles( sal_uInt16 nNumberOfStyles )
{
- WW8Fib& rFib = *m_rWW8Export.pFib;
+ WW8Fib& rFib = *m_rWW8Export.m_pFib;
- rFib.m_lcbStshfOrig = rFib.m_lcbStshf = m_rWW8Export.pTableStrm->Tell() - rFib.m_fcStshf;
- SwWW8Writer::WriteShort( *m_rWW8Export.pTableStrm, m_nStyleCountPos, nNumberOfStyles );
+ rFib.m_lcbStshfOrig = rFib.m_lcbStshf = m_rWW8Export.m_pTableStrm->Tell() - rFib.m_fcStshf;
+ SwWW8Writer::WriteShort( *m_rWW8Export.m_pTableStrm, m_nStyleCountPos, nNumberOfStyles );
}
void MSWordStyles::OutputStylesTable()
@@ -689,38 +755,23 @@ void MSWordStyles::OutputStylesTable()
m_rExport.AttrOutput().StartStyles();
- sal_uInt16 n;
// HACK
// Ms Office seems to have an internal limitation of 4091 styles
// and refuses to load .docx with more, even though the spec seems to allow that;
// so simply if there are more styles, don't export those
// Implementing check for all exports DOCX, DOC, RTF
- sal_uInt16 const nLimit = MSWORD_MAX_STYLES_LIMIT;
- m_nUsedSlots = std::min(nLimit, m_nUsedSlots);
-
- for ( n = 0; n < m_nUsedSlots; n++ )
- {
- if (m_aNumRules.find(n) != m_aNumRules.end())
- OutputStyle(m_aNumRules[n], n);
- else
- OutputStyle( m_pFormatA[n], n );
- }
+ assert(m_aStyles.size() <= MSWORD_MAX_STYLES_LIMIT);
+ for (size_t slot = 0; slot < m_aStyles.size(); ++slot)
+ OutputStyle(slot);
- m_rExport.AttrOutput().EndStyles( m_nUsedSlots );
+ m_rExport.AttrOutput().EndStyles(m_aStyles.size());
m_rExport.m_bStyDef = false;
}
-const SwNumRule* MSWordStyles::GetSwNumRule(sal_uInt16 nId) const
-{
- std::map<sal_uInt16, const SwNumRule*>::const_iterator it = m_aNumRules.find(nId);
- assert(it != m_aNumRules.end());
- return it->second;
-}
-
// Fonts
-wwFont::wwFont(const OUString &rFamilyName, FontPitch ePitch, FontFamily eFamily,
+wwFont::wwFont(std::u16string_view rFamilyName, FontPitch ePitch, FontFamily eFamily,
rtl_TextEncoding eChrSet)
: mbAlt(false), mePitch(ePitch), meFamily(eFamily), meChrSet(eChrSet)
{
@@ -859,13 +910,13 @@ sal_uInt16 wwFontHelper::GetId(const wwFont &rFont)
void wwFontHelper::InitFontTable(const SwDoc& rDoc)
{
- GetId(wwFont("Times New Roman", PITCH_VARIABLE,
+ GetId(wwFont(u"Times New Roman", PITCH_VARIABLE,
FAMILY_ROMAN, RTL_TEXTENCODING_MS_1252));
- GetId(wwFont("Symbol", PITCH_VARIABLE, FAMILY_ROMAN,
+ GetId(wwFont(u"Symbol", PITCH_VARIABLE, FAMILY_ROMAN,
RTL_TEXTENCODING_SYMBOL));
- GetId(wwFont("Arial", PITCH_VARIABLE, FAMILY_SWISS,
+ GetId(wwFont(u"Arial", PITCH_VARIABLE, FAMILY_SWISS,
RTL_TEXTENCODING_MS_1252));
const SvxFontItem* pFont = GetDfltAttr(RES_CHRATR_FONT);
@@ -874,20 +925,22 @@ void wwFontHelper::InitFontTable(const SwDoc& rDoc)
pFont->GetFamily(), pFont->GetCharSet()));
const SfxItemPool& rPool = rDoc.GetAttrPool();
- pFont = rPool.GetPoolDefaultItem(RES_CHRATR_FONT);
+ pFont = rPool.GetUserDefaultItem(RES_CHRATR_FONT);
if (nullptr != pFont)
{
GetId(wwFont(pFont->GetFamilyName(), pFont->GetPitch(),
pFont->GetFamily(), pFont->GetCharSet()));
}
- if (!bLoadAllFonts)
+ if (!m_bLoadAllFonts)
return;
const sal_uInt16 aTypes[] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_FONT, 0 };
for (const sal_uInt16* pId = aTypes; *pId; ++pId)
{
- for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(*pId))
+ ItemSurrogates aSurrogates;
+ rPool.GetItemSurrogates(aSurrogates, *pId);
+ for (const SfxPoolItem* pItem : aSurrogates)
{
pFont = static_cast<const SvxFontItem*>(pItem);
GetId(wwFont(pFont->GetFamilyName(), pFont->GetPitch(),
@@ -957,18 +1010,18 @@ void wwFontHelper::WriteFontTable( const RtfAttributeOutput& rAttrOutput )
}
WW8_WrPlc0::WW8_WrPlc0( sal_uLong nOffset )
- : nOfs( nOffset )
+ : m_nOfs( nOffset )
{
}
void WW8_WrPlc0::Append( sal_uLong nStartCpOrFc )
{
- aPos.push_back( nStartCpOrFc - nOfs );
+ m_aPos.push_back( nStartCpOrFc - m_nOfs );
}
void WW8_WrPlc0::Write( SvStream& rStrm )
{
- for( const auto& rPos : aPos )
+ for( const auto& rPos : m_aPos )
{
rStrm.WriteUInt32(rPos);
}
@@ -983,13 +1036,12 @@ MSWordSections::MSWordSections( MSWordExportBase& rExport )
const SwSectionFormat *pFormat = nullptr;
rExport.m_pCurrentPageDesc = &rExport.m_rDoc.GetPageDesc( 0 );
- const SfxPoolItem* pI;
- const SwNode* pNd = rExport.m_pCurPam->GetContentNode();
+ const SwNode* pNd = rExport.m_pCurPam->GetPointContentNode();
const SfxItemSet* pSet = pNd ? &static_cast<const SwContentNode*>(pNd)->GetSwAttrSet() : nullptr;
sal_uLong nRstLnNum = pSet ? pSet->Get( RES_LINENUMBER ).GetStartValue() : 0;
- const SwTableNode* pTableNd = rExport.m_pCurPam->GetNode().FindTableNode();
+ const SwTableNode* pTableNd = rExport.m_pCurPam->GetPointNode().FindTableNode();
const SwSectionNode* pSectNd = nullptr;
if ( pTableNd )
{
@@ -1007,7 +1059,7 @@ MSWordSections::MSWordSections( MSWordExportBase& rExport )
if ( SectionType::ToxContent == pSectNd->GetSection().GetType() )
{
pNd = pSectNd;
- rExport.m_pCurPam->GetPoint()->nNode = *pNd;
+ rExport.m_pCurPam->GetPoint()->Assign(*pNd);
}
if ( SectionType::Content == pSectNd->GetSection().GetType() )
@@ -1020,11 +1072,12 @@ MSWordSections::MSWordSections( MSWordExportBase& rExport )
SectionType::ToxContent == pSectNd->GetSection().GetType() );
// Try to get page descriptor of the first node
+ const SwFormatPageDesc* pDescItem;
if ( pSet &&
- SfxItemState::SET == pSet->GetItemState( RES_PAGEDESC, true, &pI ) &&
- static_cast<const SwFormatPageDesc*>(pI)->GetPageDesc() )
+ (pDescItem = pSet->GetItemIfSet( RES_PAGEDESC )) &&
+ pDescItem->GetPageDesc() )
{
- AppendSection( *static_cast<const SwFormatPageDesc*>(pI), *pNd, pFormat, nRstLnNum );
+ AppendSection( *pDescItem, *pNd, pFormat, nRstLnNum );
}
else
AppendSection( rExport.m_pCurrentPageDesc, pFormat, nRstLnNum, /*bIsFirstParagraph=*/true );
@@ -1036,7 +1089,7 @@ WW8_WrPlcSepx::WW8_WrPlcSepx( MSWordExportBase& rExport )
{
// to be in sync with the AppendSection() call in the MSWordSections
// constructor
- aCps.push_back( 0 );
+ m_aCps.push_back( 0 );
}
MSWordSections::~MSWordSections()
@@ -1059,36 +1112,34 @@ bool WW8_WrPlcSepx::HeaderFooterWritten()
sal_uInt16 MSWordSections::CurrentNumberOfColumns( const SwDoc &rDoc ) const
{
- OSL_ENSURE( !aSects.empty(), "no segment inserted yet" );
- if ( aSects.empty() )
+ OSL_ENSURE( !m_aSects.empty(), "no segment inserted yet" );
+ if ( m_aSects.empty() )
return 1;
- return NumberOfColumns( rDoc, aSects.back() );
+ return GetFormatCol(rDoc, m_aSects.back()).GetNumCols();
}
-sal_uInt16 MSWordSections::NumberOfColumns( const SwDoc &rDoc, const WW8_SepInfo& rInfo )
+const SwFormatCol& MSWordSections::GetFormatCol(const SwDoc &rDoc, const WW8_SepInfo& rInfo)
{
const SwPageDesc* pPd = rInfo.pPageDesc;
if ( !pPd )
pPd = &rDoc.GetPageDesc( 0 );
const SfxItemSet &rSet = pPd->GetMaster().GetAttrSet();
- SfxItemSet aSet( *rSet.GetPool(), svl::Items<RES_COL, RES_COL>{} );
+ SfxItemSetFixed<RES_COL, RES_COL> aSet( *rSet.GetPool() );
aSet.SetParent( &rSet );
//0xffffffff, what the hell is going on with that!, fixme most terribly
if ( rInfo.pSectionFormat && reinterpret_cast<SwSectionFormat*>(sal_IntPtr(-1)) != rInfo.pSectionFormat )
aSet.Put( rInfo.pSectionFormat->GetFormatAttr( RES_COL ) );
- const SwFormatCol& rCol = aSet.Get( RES_COL );
- const SwColumns& rColumns = rCol.GetColumns();
- return rColumns.size();
+ return aSet.Get(RES_COL);
}
const WW8_SepInfo* MSWordSections::CurrentSectionInfo()
{
- if ( !aSects.empty() )
- return &aSects.back();
+ if ( !m_aSects.empty() )
+ return &m_aSects.back();
return nullptr;
}
@@ -1099,8 +1150,8 @@ void MSWordSections::AppendSection( const SwPageDesc* pPd,
if (HeaderFooterWritten()) {
return; // #i117955# prevent new sections in endnotes
}
- aSects.emplace_back( pPd, pSectionFormat, nLnNumRestartNo, std::nullopt, nullptr, bIsFirstParagraph );
- NeedsDocumentProtected( aSects.back() );
+ m_aSects.emplace_back( pPd, pSectionFormat, nLnNumRestartNo, std::nullopt, nullptr, bIsFirstParagraph );
+ NeedsDocumentProtected( m_aSects.back() );
}
void WW8_WrPlcSepx::AppendSep( WW8_CP nStartCp, const SwPageDesc* pPd,
@@ -1109,7 +1160,7 @@ void WW8_WrPlcSepx::AppendSep( WW8_CP nStartCp, const SwPageDesc* pPd,
if (HeaderFooterWritten()) {
return; // #i117955# prevent new sections in endnotes
}
- aCps.push_back( nStartCp );
+ m_aCps.push_back( nStartCp );
AppendSection( pPd, pSectionFormat, nLnNumRestartNo );
}
@@ -1122,7 +1173,7 @@ void MSWordSections::AppendSection( const SwFormatPageDesc& rPD,
WW8_SepInfo aI( rPD.GetPageDesc(), pSectionFormat, nLnNumRestartNo, rPD.GetNumOffset(), &rNd );
- aSects.push_back( aI );
+ m_aSects.push_back( aI );
NeedsDocumentProtected( aI );
}
@@ -1132,7 +1183,7 @@ void WW8_WrPlcSepx::AppendSep( WW8_CP nStartCp, const SwFormatPageDesc& rPD,
if (HeaderFooterWritten()) {
return; // #i117955# prevent new sections in endnotes
}
- aCps.push_back( nStartCp );
+ m_aCps.push_back( nStartCp );
AppendSection( rPD, rNd, pSectionFormat, nLnNumRestartNo );
}
@@ -1146,36 +1197,36 @@ void WW8_WrPlcSepx::WriteFootnoteEndText( WW8Export& rWrt, sal_uLong nCpStt )
sal_uInt8 nEmptyStt = 0;
if( nInfoFlags )
{
- pTextPos->Append( nCpStt ); // empty footnote separator
+ m_pTextPos->Append( nCpStt ); // empty footnote separator
if( 0x02 & nInfoFlags ) // Footnote continuation separator
{
- pTextPos->Append( nCpStt );
+ m_pTextPos->Append( nCpStt );
rWrt.WriteStringAsPara( rInfo.m_aErgoSum );
rWrt.WriteStringAsPara( OUString() );
nCpStt = rWrt.Fc2Cp( rWrt.Strm().Tell() );
}
else
- pTextPos->Append( nCpStt );
+ m_pTextPos->Append( nCpStt );
if( 0x04 & nInfoFlags ) // Footnote continuation notice
{
- pTextPos->Append( nCpStt );
+ m_pTextPos->Append( nCpStt );
rWrt.WriteStringAsPara( rInfo.m_aQuoVadis );
rWrt.WriteStringAsPara( OUString() );
nCpStt = rWrt.Fc2Cp( rWrt.Strm().Tell() );
}
else
- pTextPos->Append( nCpStt );
+ m_pTextPos->Append( nCpStt );
nEmptyStt = 3;
}
while( 6 > nEmptyStt++ )
- pTextPos->Append( nCpStt );
+ m_pTextPos->Append( nCpStt );
// set the flags at the Dop right away
- WW8Dop& rDop = *rWrt.pDop;
+ WW8Dop& rDop = *rWrt.m_pDop;
// Footnote Info
switch( rInfo.m_eNum )
{
@@ -1198,20 +1249,16 @@ void WW8_WrPlcSepx::WriteFootnoteEndText( WW8Export& rWrt, sal_uLong nCpStt )
void MSWordSections::SetHeaderFlag( sal_uInt8& rHeadFootFlags, const SwFormat& rFormat,
sal_uInt8 nFlag )
{
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == rFormat.GetItemState(RES_HEADER, true, &pItem)
- && static_cast<const SwFormatHeader*>(pItem)->IsActive() &&
- static_cast<const SwFormatHeader*>(pItem)->GetHeaderFormat() )
+ const SwFormatHeader* pItem = rFormat.GetItemIfSet(RES_HEADER);
+ if( pItem && pItem->IsActive() && pItem->GetHeaderFormat() )
rHeadFootFlags |= nFlag;
}
void MSWordSections::SetFooterFlag( sal_uInt8& rHeadFootFlags, const SwFormat& rFormat,
sal_uInt8 nFlag )
{
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == rFormat.GetItemState(RES_FOOTER, true, &pItem)
- && static_cast<const SwFormatFooter*>(pItem)->IsActive() &&
- static_cast<const SwFormatFooter*>(pItem)->GetFooterFormat() )
+ const SwFormatFooter* pItem = rFormat.GetItemIfSet(RES_FOOTER);
+ if( pItem && pItem->IsActive() && pItem->GetFooterFormat() )
rHeadFootFlags |= nFlag;
}
@@ -1221,14 +1268,14 @@ void WW8_WrPlcSepx::OutHeaderFooter( WW8Export& rWrt, bool bHeader,
{
if ( nFlag & nHFFlags )
{
- pTextPos->Append( rCpPos );
+ m_pTextPos->Append( rCpPos );
rWrt.WriteHeaderFooterText( rFormat, bHeader);
rWrt.WriteStringAsPara( OUString() ); // CR to the end ( otherwise WW complains )
rCpPos = rWrt.Fc2Cp( rWrt.Strm().Tell() );
}
else
{
- pTextPos->Append( rCpPos );
+ m_pTextPos->Append( rCpPos );
if ((bHeader? rWrt.m_bHasHdr : rWrt.m_bHasFtr) && nBreakCode!=0)
{
rWrt.WriteStringAsPara( OUString() ); // Empty paragraph for empty header/footer
@@ -1267,7 +1314,7 @@ void MSWordSections::CheckForFacinPg( const WW8Export& rWrt ) const
// Dop.fFacingPages == Header and Footer different
// Dop.fSwapBordersFacingPgs == mirrored borders
sal_uInt16 nEnd = 0;
- for( const WW8_SepInfo& rSepInfo : aSects )
+ for( const WW8_SepInfo& rSepInfo : m_aSects )
{
if( !rSepInfo.pSectionFormat )
{
@@ -1288,21 +1335,21 @@ void MSWordSections::CheckForFacinPg( const WW8Export& rWrt ) const
( UseOnPage::Right == ( UseOnPage::All & pPd->ReadUseOn() ) &&
UseOnPage::Left == ( UseOnPage::All & pPd->GetFollow()->ReadUseOn() )) ))
{
- rWrt.pDop->fFacingPages = rWrt.pDop->fMirrorMargins = true;
+ rWrt.m_pDop->fFacingPages = rWrt.m_pDop->fMirrorMargins = true;
nEnd |= 1;
}
if( !( 1 & nEnd ) &&
( !pPd->IsHeaderShared() || !pPd->IsFooterShared() ))
{
- rWrt.pDop->fFacingPages = true;
+ rWrt.m_pDop->fFacingPages = true;
nEnd |= 1;
}
if( !( 2 & nEnd ) &&
UseOnPage::Mirror == ( UseOnPage::Mirror & pPd->ReadUseOn() ))
{
- rWrt.pDop->fSwapBordersFacingPgs =
- rWrt.pDop->fMirrorMargins = true;
+ rWrt.m_pDop->fSwapBordersFacingPgs =
+ rWrt.m_pDop->fMirrorMargins = true;
nEnd |= 2;
}
@@ -1314,17 +1361,17 @@ void MSWordSections::CheckForFacinPg( const WW8Export& rWrt ) const
bool MSWordSections::HasBorderItem( const SwFormat& rFormat )
{
- const SfxPoolItem* pItem;
- return SfxItemState::SET == rFormat.GetItemState(RES_BOX, true, &pItem) &&
- ( static_cast<const SvxBoxItem*>(pItem)->GetTop() ||
- static_cast<const SvxBoxItem*>(pItem)->GetBottom() ||
- static_cast<const SvxBoxItem*>(pItem)->GetLeft() ||
- static_cast<const SvxBoxItem*>(pItem)->GetRight() );
+ const SvxBoxItem* pItem = rFormat.GetItemIfSet(RES_BOX);
+ return pItem &&
+ ( pItem->GetTop() ||
+ pItem->GetBottom() ||
+ pItem->GetLeft() ||
+ pItem->GetRight() );
}
void WW8AttributeOutput::StartSection()
{
- m_rWW8Export.pO->clear();
+ m_rWW8Export.m_pO->clear();
}
void WW8AttributeOutput::SectFootnoteEndnotePr()
@@ -1334,60 +1381,60 @@ void WW8AttributeOutput::SectFootnoteEndnotePr()
m_rWW8Export.InsUInt16( NS_sprm::SRncFtn::val );
switch( rInfo.m_eNum )
{
- case FTNNUM_PAGE: m_rWW8Export.pO->push_back( sal_uInt8/*rncRstPage*/ (2) ); break;
- case FTNNUM_CHAPTER: m_rWW8Export.pO->push_back( sal_uInt8/*rncRstSect*/ (1) ); break;
- default: m_rWW8Export.pO->push_back( sal_uInt8/*rncCont*/ (0) ); break;
+ case FTNNUM_PAGE: m_rWW8Export.m_pO->push_back( sal_uInt8/*rncRstPage*/ (2) ); break;
+ case FTNNUM_CHAPTER: m_rWW8Export.m_pO->push_back( sal_uInt8/*rncRstSect*/ (1) ); break;
+ default: m_rWW8Export.m_pO->push_back( sal_uInt8/*rncCont*/ (0) ); break;
}
m_rWW8Export.InsUInt16(NS_sprm::SNfcFtnRef::val);
sal_uInt8 nId = WW8Export::GetNumId(rInfo.m_aFormat.GetNumberingType());
- SwWW8Writer::InsUInt16(*m_rWW8Export.pO, nId);
+ SwWW8Writer::InsUInt16(*m_rWW8Export.m_pO, nId);
m_rWW8Export.InsUInt16(NS_sprm::SNfcEdnRef::val);
nId = WW8Export::GetNumId(rEndNoteInfo.m_aFormat.GetNumberingType());
- SwWW8Writer::InsUInt16(*m_rWW8Export.pO, nId);
+ SwWW8Writer::InsUInt16(*m_rWW8Export.m_pO, nId);
}
void WW8AttributeOutput::SectionFormProtection( bool bProtected )
{
//If the document is to be exported as protected, then if a segment
//is not protected, set the unlocked flag
- if ( m_rWW8Export.pSepx->DocumentIsProtected() && !bProtected )
+ if ( m_rWW8Export.m_pSepx->DocumentIsProtected() && !bProtected )
{
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::SFProtected::val );
- m_rWW8Export.pO->push_back( 1 );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::SFProtected::val );
+ m_rWW8Export.m_pO->push_back( 1 );
}
}
void WW8AttributeOutput::SectionLineNumbering( sal_uLong nRestartNo, const SwLineNumberInfo& rLnNumInfo )
{
// sprmSNLnnMod - activate Line Numbering and define Modulo
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::SNLnnMod::val );
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, rLnNumInfo.GetCountBy() );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::SNLnnMod::val );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, rLnNumInfo.GetCountBy() );
// sprmSDxaLnn - xPosition of Line Number
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::SDxaLnn::val );
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, rLnNumInfo.GetPosFromLeft() );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::SDxaLnn::val );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, rLnNumInfo.GetPosFromLeft() );
// sprmSLnc - restart number: 0 per page, 1 per section, 2 never restart
if ( nRestartNo || !rLnNumInfo.IsRestartEachPage() )
{
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::SLnc::val );
- m_rWW8Export.pO->push_back( nRestartNo ? 1 : 2 );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::SLnc::val );
+ m_rWW8Export.m_pO->push_back( nRestartNo ? 1 : 2 );
}
// sprmSLnnMin - Restart the Line Number with given value
if ( nRestartNo )
{
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::SLnnMin::val );
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, static_cast<sal_uInt16>(nRestartNo) - 1 );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::SLnnMin::val );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, o3tl::narrowing<sal_uInt16>(nRestartNo) - 1 );
}
}
void WW8AttributeOutput::SectionTitlePage()
{
// sprmSFTitlePage
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::SFTitlePage::val );
- m_rWW8Export.pO->push_back( 1 );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::SFTitlePage::val );
+ m_rWW8Export.m_pO->push_back( 1 );
}
void WW8AttributeOutput::SectionPageBorders( const SwFrameFormat* pPdFormat, const SwFrameFormat* pPdFirstPgFormat )
@@ -1417,33 +1464,33 @@ void WW8AttributeOutput::SectionPageBorders( const SwFrameFormat* pPdFormat, con
if ( USHRT_MAX != nPgBorder )
{
// write the Flag and Border Attribute
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::SPgbProp::val );
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, nPgBorder );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::SPgbProp::val );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, nPgBorder );
}
}
void WW8AttributeOutput::SectionBiDi( bool bBiDi )
{
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::SFBiDi::val );
- m_rWW8Export.pO->push_back( bBiDi? 1: 0 );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::SFBiDi::val );
+ m_rWW8Export.m_pO->push_back( bBiDi? 1: 0 );
}
void WW8AttributeOutput::SectionPageNumbering( sal_uInt16 nNumType, const ::std::optional<sal_uInt16>& oPageRestartNumber )
{
// sprmSNfcPgn
sal_uInt8 nb = WW8Export::GetNumId( nNumType );
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::SNfcPgn::val );
- m_rWW8Export.pO->push_back( nb );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::SNfcPgn::val );
+ m_rWW8Export.m_pO->push_back( nb );
if ( oPageRestartNumber )
{
// sprmSFPgnRestart
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::SFPgnRestart::val );
- m_rWW8Export.pO->push_back( 1 );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::SFPgnRestart::val );
+ m_rWW8Export.m_pO->push_back( 1 );
// sprmSPgnStart
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::SPgnStart97::val );
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, *oPageRestartNumber );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::SPgnStart97::val );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, *oPageRestartNumber );
}
}
@@ -1451,8 +1498,8 @@ void WW8AttributeOutput::SectionType( sal_uInt8 nBreakCode )
{
if ( 2 != nBreakCode ) // new page is the default
{
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::SBkc::val );
- m_rWW8Export.pO->push_back( nBreakCode );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::SBkc::val );
+ m_rWW8Export.m_pO->push_back( nBreakCode );
}
}
@@ -1461,13 +1508,13 @@ void WW8Export::SetupSectionPositions( WW8_PdAttrDesc* pA )
if ( !pA )
return;
- if ( !pO->empty() ) // are there attributes ?
+ if ( !m_pO->empty() ) // are there attributes ?
{
- pA->m_nLen = pO->size();
- pA->m_pData.reset(new sal_uInt8 [pO->size()]);
+ pA->m_nLen = m_pO->size();
+ pA->m_pData.reset(new sal_uInt8 [m_pO->size()]);
// store for later
- memcpy( pA->m_pData.get(), pO->data(), pO->size() );
- pO->clear(); // clear HdFt-Text
+ memcpy( pA->m_pData.get(), m_pO->data(), m_pO->size() );
+ m_pO->clear(); // clear HdFt-Text
}
else // no attributes there
{
@@ -1496,8 +1543,8 @@ void WW8AttributeOutput::TextVerticalAdjustment( const drawing::TextVerticalAdju
default:
break;
}
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::SVjc::val );
- m_rWW8Export.pO->push_back( nMSVA );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::SVjc::val );
+ m_rWW8Export.m_pO->push_back( nMSVA );
}
void WW8Export::WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
@@ -1506,26 +1553,26 @@ void WW8Export::WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
sal_uLong nCpPos = Fc2Cp( Strm().Tell() );
IncrementHdFtIndex();
- if ( !(nHeadFootFlags & WW8_HEADER_EVEN) && pDop->fFacingPages )
- pSepx->OutHeaderFooter( *this, true, rFormat, nCpPos, nHeadFootFlags, WW8_HEADER_ODD, nBreakCode );
+ if ( !(nHeadFootFlags & WW8_HEADER_EVEN) && m_pDop->fFacingPages )
+ m_pSepx->OutHeaderFooter( *this, true, rFormat, nCpPos, nHeadFootFlags, WW8_HEADER_ODD, nBreakCode );
else
- pSepx->OutHeaderFooter( *this, true, rLeftHeaderFormat, nCpPos, nHeadFootFlags, WW8_HEADER_EVEN, nBreakCode );
+ m_pSepx->OutHeaderFooter( *this, true, rLeftHeaderFormat, nCpPos, nHeadFootFlags, WW8_HEADER_EVEN, nBreakCode );
IncrementHdFtIndex();
- pSepx->OutHeaderFooter( *this, true, rFormat, nCpPos, nHeadFootFlags, WW8_HEADER_ODD, nBreakCode );
+ m_pSepx->OutHeaderFooter( *this, true, rFormat, nCpPos, nHeadFootFlags, WW8_HEADER_ODD, nBreakCode );
IncrementHdFtIndex();
- if ( !(nHeadFootFlags & WW8_FOOTER_EVEN) && pDop->fFacingPages )
- pSepx->OutHeaderFooter( *this, false, rFormat, nCpPos, nHeadFootFlags, WW8_FOOTER_ODD, nBreakCode );
+ if ( !(nHeadFootFlags & WW8_FOOTER_EVEN) && m_pDop->fFacingPages )
+ m_pSepx->OutHeaderFooter( *this, false, rFormat, nCpPos, nHeadFootFlags, WW8_FOOTER_ODD, nBreakCode );
else
- pSepx->OutHeaderFooter( *this, false, rLeftFooterFormat, nCpPos, nHeadFootFlags, WW8_FOOTER_EVEN, nBreakCode );
+ m_pSepx->OutHeaderFooter( *this, false, rLeftFooterFormat, nCpPos, nHeadFootFlags, WW8_FOOTER_EVEN, nBreakCode );
IncrementHdFtIndex();
- pSepx->OutHeaderFooter( *this, false, rFormat, nCpPos, nHeadFootFlags, WW8_FOOTER_ODD, nBreakCode );
+ m_pSepx->OutHeaderFooter( *this, false, rFormat, nCpPos, nHeadFootFlags, WW8_FOOTER_ODD, nBreakCode );
//#i24344# Drawing objects cannot be directly shared between main hd/ft
//and title hd/ft so we need to differentiate them
IncrementHdFtIndex();
- pSepx->OutHeaderFooter( *this, true, rFirstPageFormat, nCpPos, nHeadFootFlags, WW8_HEADER_FIRST, nBreakCode );
- pSepx->OutHeaderFooter( *this, false, rFirstPageFormat, nCpPos, nHeadFootFlags, WW8_FOOTER_FIRST, nBreakCode );
+ m_pSepx->OutHeaderFooter( *this, true, rFirstPageFormat, nCpPos, nHeadFootFlags, WW8_HEADER_FIRST, nBreakCode );
+ m_pSepx->OutHeaderFooter( *this, false, rFirstPageFormat, nCpPos, nHeadFootFlags, WW8_FOOTER_FIRST, nBreakCode );
}
namespace
@@ -1567,12 +1614,12 @@ bool UsePrevSectionNextStyle(sal_uInt8 nBreakCode, const SwPageDesc* pPd,
SwPaM aPaM(*pSectionStart);
aPaM.Move(fnMoveBackward);
- if (!aPaM.GetNode().IsTextNode())
+ if (!aPaM.GetPointNode().IsTextNode())
{
return false;
}
- SwTextNode* pTextNode = aPaM.GetNode().GetTextNode();
+ SwTextNode* pTextNode = aPaM.GetPointNode().GetTextNode();
const SwAttrSet* pParaProps = &pTextNode->GetSwAttrSet();
sal_uInt32 nCharHeight = pParaProps->GetSize().GetHeight();
if (nCharHeight > 20)
@@ -1581,12 +1628,12 @@ bool UsePrevSectionNextStyle(sal_uInt8 nBreakCode, const SwPageDesc* pPd,
}
aPaM.Move(fnMoveBackward);
- if (!aPaM.GetNode().IsTextNode())
+ if (!aPaM.GetPointNode().IsTextNode())
{
return false;
}
- pTextNode = aPaM.GetNode().GetTextNode();
+ pTextNode = aPaM.GetPointNode().GetTextNode();
pParaProps = &pTextNode->GetSwAttrSet();
return pParaProps->HasItem(RES_PAGEDESC);
}
@@ -1606,6 +1653,7 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
bool bOldPg = m_bOutPageDescs;
m_bOutPageDescs = true;
+ const SwPageDesc* pSavedPageDesc = pPd;
AttrOutput().StartSection();
@@ -1624,7 +1672,6 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
*/
sal_uInt8 nBreakCode = 2; // default start new page
bool bOutPgDscSet = true, bLeftRightPgChain = false, bOutputStyleItemSet = false;
- bool bEnsureHeaderFooterWritten = rSepInfo.pSectionFormat && rSepInfo.bIsFirstParagraph;
const SwFrameFormat* pPdFormat = &pPd->GetMaster();
bool bUsePrevSectionNextStyle = false;
if ( rSepInfo.pSectionFormat )
@@ -1634,17 +1681,18 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
// 0xfff -> Section terminated
nBreakCode = 0; // consecutive section
- if ( rSepInfo.pPDNd && rSepInfo.pPDNd->IsContentNode() )
+ if (rSepInfo.pPDNd && (rSepInfo.pPDNd->IsContentNode() || rSepInfo.pPDNd->IsTableNode()))
{
- if ( !NoPageBreakSection( &rSepInfo.pPDNd->GetContentNode()->GetSwAttrSet() ) )
- {
+ const SfxItemSet* pSet
+ = rSepInfo.pPDNd->IsContentNode()
+ ? &rSepInfo.pPDNd->GetContentNode()->GetSwAttrSet()
+ : &rSepInfo.pPDNd->GetTableNode()->GetTable().GetFrameFormat()->GetAttrSet();
+
+ if (!NoPageBreakSection(pSet))
nBreakCode = 2;
- }
}
- if ( reinterpret_cast<SwSectionFormat*>(sal_IntPtr(-1)) == rSepInfo.pSectionFormat )
- bEnsureHeaderFooterWritten |= !rSepInfo.pPDNd && GetExportFormat() != ExportFormat::RTF;
- else
+ if (reinterpret_cast<SwSectionFormat*>(sal_IntPtr(-1)) != rSepInfo.pSectionFormat)
{
if ( nBreakCode == 0 )
bOutPgDscSet = false;
@@ -1667,17 +1715,17 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
// at the child ONLY change column structure according to Sect-Attr.
const SvxLRSpaceItem &rSectionLR =
- ItemGet<SvxLRSpaceItem>( *(rSepInfo.pSectionFormat), RES_LR_SPACE );
+ rSepInfo.pSectionFormat->GetFormatAttr( RES_LR_SPACE );
const SvxLRSpaceItem &rPageLR =
- ItemGet<SvxLRSpaceItem>( *pPdFormat, RES_LR_SPACE );
+ pPdFormat->GetFormatAttr( RES_LR_SPACE );
SvxLRSpaceItem aResultLR( rPageLR.GetLeft() +
rSectionLR.GetLeft(), rPageLR.GetRight() +
- rSectionLR.GetRight(), 0, 0, RES_LR_SPACE );
+ rSectionLR.GetRight(), 0, RES_LR_SPACE );
//i120133: The Section width should consider section indent value.
if (rSectionLR.GetLeft()+rSectionLR.GetRight()!=0)
{
- const SwFormatCol& rCol = dynamic_cast<const SwFormatCol&>(rSepInfo.pSectionFormat->GetFormatAttr(RES_COL));
+ const SwFormatCol& rCol = rSepInfo.pSectionFormat->GetFormatAttr(RES_COL);
SwFormatCol aCol(rCol);
aCol.SetAdjustValue(rSectionLR.GetLeft()+rSectionLR.GetRight());
aSet.Put(aCol);
@@ -1721,9 +1769,7 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
// it as title page.
// With Left/Right changes it's different - we have to detect where
// the change of pages is, but here it's too late for that!
- // tdf#101814 if there is already an explicit first-page, no point
- // in checking heuristics here.
- if ( !titlePage && pPd->GetFollow() && pPd != pPd->GetFollow() &&
+ if ( pPd->GetFollow() && pPd != pPd->GetFollow() &&
pPd->GetFollow()->GetFollow() == pPd->GetFollow() &&
pPd->IsHeaderShared() && pPd->IsFooterShared() &&
( !rSepInfo.pPDNd || pPd->IsFollowNextPageOfNode( *rSepInfo.pPDNd ) ) )
@@ -1732,7 +1778,11 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
const SwFrameFormat& rFollowFormat = pFollow->GetMaster();
if (sw::util::IsPlausableSingleWordSection(*pPdFirstPgFormat, rFollowFormat))
{
- if (rSepInfo.pPDNd)
+ if (titlePage)
+ {
+ // Do nothing. First format is already set.
+ }
+ else if (rSepInfo.pPDNd)
pPdFirstPgFormat = pPd->GetPageFormatOfNode( *rSepInfo.pPDNd );
else
pPdFirstPgFormat = &pPd->GetMaster();
@@ -1744,6 +1794,11 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
titlePage = true;
}
}
+ else if (nBreakCode == 2 && pPd == m_pPreviousSectionPageDesc && pPd->GetFollow() == pPd)
+ {
+ // The first title page has already been displayed in the previous section. Drop it.
+ titlePage = false;
+ }
const SfxItemSet* pOldI = m_pISet;
@@ -1876,7 +1931,7 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
}
// Ensure that headers are written if section is first paragraph
- if ( nBreakCode != 0 || bEnsureHeaderFooterWritten )
+ if (nBreakCode != 0 || (rSepInfo.pSectionFormat && rSepInfo.bIsFirstParagraph))
{
if ( titlePage )
{
@@ -1956,14 +2011,15 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
// outside of the section properties again
m_bOutPageDescs = bOldPg;
+ m_pPreviousSectionPageDesc = pSavedPageDesc;
}
bool WW8_WrPlcSepx::WriteKFText( WW8Export& rWrt )
{
sal_uLong nCpStart = rWrt.Fc2Cp( rWrt.Strm().Tell() );
- OSL_ENSURE( !pTextPos, "who set the pointer?" );
- pTextPos.reset( new WW8_WrPlc0( nCpStart ) );
+ OSL_ENSURE( !m_pTextPos, "who set the pointer?" );
+ m_pTextPos.reset( new WW8_WrPlc0( nCpStart ) );
WriteFootnoteEndText( rWrt, nCpStart );
CheckForFacinPg( rWrt );
@@ -1971,7 +2027,7 @@ bool WW8_WrPlcSepx::WriteKFText( WW8Export& rWrt )
unsigned int nOldIndex = rWrt.GetHdFtIndex();
rWrt.SetHdFtIndex( 0 );
- for (const WW8_SepInfo & rSepInfo : aSects)
+ for (const WW8_SepInfo & rSepInfo : m_aSects)
{
auto pAttrDesc = std::make_shared<WW8_PdAttrDesc>();
m_SectionAttributes.push_back(pAttrDesc);
@@ -1985,33 +2041,33 @@ bool WW8_WrPlcSepx::WriteKFText( WW8Export& rWrt )
}
rWrt.SetHdFtIndex( nOldIndex ); //0
- if ( pTextPos->Count() )
+ if ( m_pTextPos->Count() )
{
// HdFt available?
sal_uLong nCpEnd = rWrt.Fc2Cp( rWrt.Strm().Tell() );
- pTextPos->Append( nCpEnd ); // End of last Header/Footer for PlcfHdd
+ m_pTextPos->Append( nCpEnd ); // End of last Header/Footer for PlcfHdd
if ( nCpEnd > nCpStart )
{
++nCpEnd;
- pTextPos->Append( nCpEnd + 1 ); // End of last Header/Footer for PlcfHdd
+ m_pTextPos->Append( nCpEnd + 1 ); // End of last Header/Footer for PlcfHdd
rWrt.WriteStringAsPara( OUString() ); // CR to the end ( otherwise WW complains )
}
- rWrt.m_pFieldHdFt->Finish( nCpEnd, rWrt.pFib->m_ccpText + rWrt.pFib->m_ccpFootnote );
- rWrt.pFib->m_ccpHdr = nCpEnd - nCpStart;
+ rWrt.m_pFieldHdFt->Finish( nCpEnd, rWrt.m_pFib->m_ccpText + rWrt.m_pFib->m_ccpFootnote );
+ rWrt.m_pFib->m_ccpHdr = nCpEnd - nCpStart;
}
else
{
- pTextPos.reset();
+ m_pTextPos.reset();
}
- return rWrt.pFib->m_ccpHdr != 0;
+ return rWrt.m_pFib->m_ccpHdr != 0;
}
void WW8_WrPlcSepx::WriteSepx( SvStream& rStrm ) const
{
- OSL_ENSURE(m_SectionAttributes.size() == static_cast<size_t>(aSects.size())
+ OSL_ENSURE(m_SectionAttributes.size() == static_cast<size_t>(m_aSects.size())
, "WriteSepx(): arrays out of sync!");
for (const auto & rSectionAttribute : m_SectionAttributes) // all sections
{
@@ -2027,15 +2083,15 @@ void WW8_WrPlcSepx::WriteSepx( SvStream& rStrm ) const
void WW8_WrPlcSepx::WritePlcSed( WW8Export& rWrt ) const
{
- OSL_ENSURE(m_SectionAttributes.size() == static_cast<size_t>(aSects.size())
+ OSL_ENSURE(m_SectionAttributes.size() == static_cast<size_t>(m_aSects.size())
, "WritePlcSed(): arrays out of sync!");
- OSL_ENSURE( aCps.size() == aSects.size() + 1, "WrPlcSepx: DeSync" );
- sal_uLong nFcStart = rWrt.pTableStrm->Tell();
+ OSL_ENSURE( m_aCps.size() == m_aSects.size() + 1, "WrPlcSepx: DeSync" );
+ sal_uInt64 nFcStart = rWrt.m_pTableStrm->Tell();
- for( decltype(aSects)::size_type i = 0; i <= aSects.size(); i++ )
+ for( decltype(m_aSects)::size_type i = 0; i <= m_aSects.size(); i++ )
{
- sal_uInt32 nP = aCps[i];
- rWrt.pTableStrm->WriteUInt32(nP);
+ sal_uInt32 nP = m_aCps[i];
+ rWrt.m_pTableStrm->WriteUInt32(nP);
}
static WW8_SED aSed = {{4, 0},{0, 0, 0, 0},{0, 0},{0xff, 0xff, 0xff, 0xff}};
@@ -2044,21 +2100,21 @@ void WW8_WrPlcSepx::WritePlcSed( WW8Export& rWrt ) const
{
// Sepx-Pos
UInt32ToSVBT32( rSectionAttribute->m_nSepxFcPos, aSed.fcSepx );
- rWrt.pTableStrm->WriteBytes(&aSed, sizeof(aSed));
+ rWrt.m_pTableStrm->WriteBytes(&aSed, sizeof(aSed));
}
- rWrt.pFib->m_fcPlcfsed = nFcStart;
- rWrt.pFib->m_lcbPlcfsed = rWrt.pTableStrm->Tell() - nFcStart;
+ rWrt.m_pFib->m_fcPlcfsed = nFcStart;
+ rWrt.m_pFib->m_lcbPlcfsed = rWrt.m_pTableStrm->Tell() - nFcStart;
}
void WW8_WrPlcSepx::WritePlcHdd( WW8Export& rWrt ) const
{
// Don't write out the PlcfHdd if ccpHdd is 0: it's a validation failure case.
- if( rWrt.pFib->m_ccpHdr != 0 && pTextPos && pTextPos->Count() )
+ if( rWrt.m_pFib->m_ccpHdr != 0 && m_pTextPos && m_pTextPos->Count() )
{
- rWrt.pFib->m_fcPlcfhdd = rWrt.pTableStrm->Tell();
- pTextPos->Write( *rWrt.pTableStrm ); // Plc0
- rWrt.pFib->m_lcbPlcfhdd = rWrt.pTableStrm->Tell() -
- rWrt.pFib->m_fcPlcfhdd;
+ rWrt.m_pFib->m_fcPlcfhdd = rWrt.m_pTableStrm->Tell();
+ m_pTextPos->Write( *rWrt.m_pTableStrm ); // Plc0
+ rWrt.m_pFib->m_lcbPlcfhdd = rWrt.m_pTableStrm->Tell() -
+ rWrt.m_pFib->m_fcPlcfhdd;
}
}
@@ -2070,6 +2126,10 @@ void MSWordExportBase::WriteHeaderFooterText( const SwFormat& rFormat, bool bHea
m_bHasHdr = true;
const SwFormatHeader& rHd = rFormat.GetHeader();
OSL_ENSURE( rHd.GetHeaderFormat(), "Header text is not here" );
+
+ if ( !rHd.GetHeaderFormat() )
+ return;
+
pContent = &rHd.GetHeaderFormat()->GetContent();
}
else
@@ -2077,6 +2137,10 @@ void MSWordExportBase::WriteHeaderFooterText( const SwFormat& rFormat, bool bHea
m_bHasFtr = true;
const SwFormatFooter& rFt = rFormat.GetFooter();
OSL_ENSURE( rFt.GetFooterFormat(), "Footer text is not here" );
+
+ if ( !rFt.GetFooterFormat() )
+ return;
+
pContent = &rFt.GetFooterFormat()->GetContent();
}
@@ -2086,8 +2150,8 @@ void MSWordExportBase::WriteHeaderFooterText( const SwFormat& rFormat, bool bHea
{
SwNodeIndex aIdx( *pSttIdx, 1 ),
aEnd( *pSttIdx->GetNode().EndOfSectionNode() );
- sal_uLong nStart = aIdx.GetIndex();
- sal_uLong nEnd = aEnd.GetIndex();
+ SwNodeOffset nStart = aIdx.GetIndex();
+ SwNodeOffset nEnd = aEnd.GetIndex();
// range, i.e. valid node
if ( nStart < nEnd )
@@ -2123,8 +2187,8 @@ WW8_WrPlcSubDoc::~WW8_WrPlcSubDoc()
void WW8_WrPlcFootnoteEdn::Append( WW8_CP nCp, const SwFormatFootnote& rFootnote )
{
- aCps.push_back( nCp );
- aContent.push_back( &rFootnote );
+ m_aCps.push_back( nCp );
+ m_aContent.push_back( &rFootnote );
}
WW8_Annotation::WW8_Annotation(const SwPostItField* pPostIt, WW8_CP nRangeStart, WW8_CP nRangeEnd)
@@ -2170,7 +2234,7 @@ void WW8_WrPlcAnnotations::AddRangeStartPosition(const OUString& rName, WW8_CP n
void WW8_WrPlcAnnotations::Append( WW8_CP nCp, const SwPostItField *pPostIt )
{
- aCps.push_back( nCp );
+ m_aCps.push_back( nCp );
WW8_Annotation* p;
if( m_aRangeStartPositions.find(pPostIt->GetName()) != m_aRangeStartPositions.end() )
{
@@ -2183,15 +2247,15 @@ void WW8_WrPlcAnnotations::Append( WW8_CP nCp, const SwPostItField *pPostIt )
{
p = new WW8_Annotation(pPostIt, nCp, nCp);
}
- aContent.push_back( p );
+ m_aContent.push_back( p );
}
void WW8_WrPlcAnnotations::Append( WW8_CP nCp, const SwRedlineData *pRedline )
{
maProcessedRedlines.insert(pRedline);
- aCps.push_back( nCp );
+ m_aCps.push_back( nCp );
WW8_Annotation* p = new WW8_Annotation(pRedline);
- aContent.push_back( p );
+ m_aContent.push_back( p );
}
bool WW8_WrPlcAnnotations::IsNewRedlineComment( const SwRedlineData *pRedline )
@@ -2201,19 +2265,19 @@ bool WW8_WrPlcAnnotations::IsNewRedlineComment( const SwRedlineData *pRedline )
WW8_WrPlcAnnotations::~WW8_WrPlcAnnotations()
{
- for(const void * p : aContent)
+ for(const void * p : m_aContent)
delete static_cast<WW8_Annotation const *>(p);
}
bool WW8_WrPlcSubDoc::WriteGenericText( WW8Export& rWrt, sal_uInt8 nTTyp,
WW8_CP& rCount )
{
- sal_uInt16 nLen = aContent.size();
+ sal_uInt16 nLen = m_aContent.size();
if ( !nLen )
return false;
sal_uLong nCpStart = rWrt.Fc2Cp( rWrt.Strm().Tell() );
- pTextPos.reset( new WW8_WrPlc0( nCpStart ) );
+ m_pTextPos.reset( new WW8_WrPlc0( nCpStart ) );
sal_uInt16 i;
switch ( nTTyp )
@@ -2222,10 +2286,10 @@ bool WW8_WrPlcSubDoc::WriteGenericText( WW8Export& rWrt, sal_uInt8 nTTyp,
for ( i = 0; i < nLen; i++ )
{
// beginning for PlcfAtnText
- pTextPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() ));
+ m_pTextPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() ));
rWrt.WritePostItBegin();
- const WW8_Annotation& rAtn = *static_cast<const WW8_Annotation*>(aContent[i]);
+ const WW8_Annotation& rAtn = *static_cast<const WW8_Annotation*>(m_aContent[i]);
if (rAtn.mpRichText)
rWrt.WriteOutliner(*rAtn.mpRichText, nTTyp);
else
@@ -2242,13 +2306,13 @@ bool WW8_WrPlcSubDoc::WriteGenericText( WW8Export& rWrt, sal_uInt8 nTTyp,
{
// textbox content
WW8_CP nCP = rWrt.Fc2Cp( rWrt.Strm().Tell() );
- aCps.insert( aCps.begin()+i, nCP );
- pTextPos->Append( nCP );
+ m_aCps.insert( m_aCps.begin()+i, nCP );
+ m_pTextPos->Append( nCP );
- if( aContent[ i ] != nullptr )
+ if( m_aContent[ i ] != nullptr )
{
// is it a writer or sdr - textbox?
- const SdrObject& rObj = *static_cast<SdrObject const *>(aContent[ i ]);
+ const SdrObject& rObj = *static_cast<SdrObject const *>(m_aContent[ i ]);
if (rObj.GetObjInventor() == SdrInventor::FmForm)
{
sal_uInt8 nOldTyp = rWrt.m_nTextTyp;
@@ -2256,8 +2320,8 @@ bool WW8_WrPlcSubDoc::WriteGenericText( WW8Export& rWrt, sal_uInt8 nTTyp,
rWrt.GetOCXExp().ExportControl(rWrt, dynamic_cast<const SdrUnoObj&>(rObj));
rWrt.m_nTextTyp = nOldTyp;
}
- else if( dynamic_cast<const SdrTextObj*>( &rObj) != nullptr )
- rWrt.WriteSdrTextObj(dynamic_cast<const SdrTextObj&>(rObj), nTTyp);
+ else if( auto pText = DynCastSdrTextObj(&rObj) )
+ rWrt.WriteSdrTextObj(*pText, nTTyp);
else
{
const SwFrameFormat* pFormat = ::FindFrameFormat( &rObj );
@@ -2294,9 +2358,9 @@ bool WW8_WrPlcSubDoc::WriteGenericText( WW8Export& rWrt, sal_uInt8 nTTyp,
}
}
}
- else if (i < aSpareFormats.size() && aSpareFormats[i])
+ else if (i < m_aSpareFormats.size() && m_aSpareFormats[i])
{
- const SwFrameFormat& rFormat = *aSpareFormats[i];
+ const SwFrameFormat& rFormat = *m_aSpareFormats[i];
const SwNodeIndex* pNdIdx = rFormat.GetContent().GetContentIdx();
rWrt.WriteSpecialText( pNdIdx->GetIndex() + 1,
pNdIdx->GetNode().EndOfSectionIndex(), nTTyp );
@@ -2312,10 +2376,10 @@ bool WW8_WrPlcSubDoc::WriteGenericText( WW8Export& rWrt, sal_uInt8 nTTyp,
for ( i = 0; i < nLen; i++ )
{
// beginning for PlcfFootnoteText/PlcfEdnText
- pTextPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() ));
+ m_pTextPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() ));
// Note content
- const SwFormatFootnote* pFootnote = static_cast<SwFormatFootnote const *>(aContent[ i ]);
+ const SwFormatFootnote* pFootnote = static_cast<SwFormatFootnote const *>(m_aContent[ i ]);
rWrt.WriteFootnoteBegin( *pFootnote );
const SwNodeIndex* pIdx = pFootnote->GetTextFootnote()->GetStartNode();
OSL_ENSURE( pIdx, "Where is the start node of Foot-/Endnote?" );
@@ -2329,12 +2393,12 @@ bool WW8_WrPlcSubDoc::WriteGenericText( WW8Export& rWrt, sal_uInt8 nTTyp,
OSL_ENSURE( false, "What kind of SubDocType is that?" );
}
- pTextPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() ));
+ m_pTextPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() ));
// CR to the end ( otherwise WW complains )
rWrt.WriteStringAsPara( OUString() );
WW8_CP nCpEnd = rWrt.Fc2Cp( rWrt.Strm().Tell() );
- pTextPos->Append( nCpEnd );
+ m_pTextPos->Append( nCpEnd );
rCount = nCpEnd - nCpStart;
return ( rCount != 0 );
@@ -2354,15 +2418,15 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
WW8_FC& rTextStart, sal_Int32& rTextCount, WW8_FC& rRefStart, sal_Int32& rRefCount ) const
{
- sal_uLong nFcStart = rWrt.pTableStrm->Tell();
- sal_uInt16 nLen = aCps.size();
+ sal_uInt64 nFcStart = rWrt.m_pTableStrm->Tell();
+ sal_uInt16 nLen = m_aCps.size();
if ( !nLen )
return;
- OSL_ENSURE( aCps.size() + 2 == pTextPos->Count(), "WritePlc: DeSync" );
+ OSL_ENSURE( m_aCps.size() + 2 == m_pTextPos->Count(), "WritePlc: DeSync" );
std::vector<std::pair<OUString,OUString> > aStrArr;
- WW8Fib& rFib = *rWrt.pFib; // n+1-th CP-Pos according to the manual
+ WW8Fib& rFib = *rWrt.m_pFib; // n+1-th CP-Pos according to the manual
bool bWriteCP = true;
switch ( nTTyp )
@@ -2378,7 +2442,7 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
int nIdx = 0;
for ( sal_uInt16 i = 0; i < nLen; ++i )
{
- const WW8_Annotation& rAtn = *static_cast<const WW8_Annotation*>(aContent[i]);
+ const WW8_Annotation& rAtn = *static_cast<const WW8_Annotation*>(m_aContent[i]);
aStrArr.emplace_back(rAtn.msOwner,rAtn.m_sInitials);
// record start and end positions for ranges
if (rAtn.HasRange())
@@ -2411,13 +2475,13 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
for ( decltype(aStrArr)::size_type i = 0; i < aStrArr.size(); ++i )
{
const OUString& sAuthor = aStrArr[i].first;
- SwWW8Writer::WriteShort(*rWrt.pTableStrm, sAuthor.getLength());
- SwWW8Writer::WriteString16(*rWrt.pTableStrm, sAuthor,
+ SwWW8Writer::WriteShort(*rWrt.m_pTableStrm, sAuthor.getLength());
+ SwWW8Writer::WriteString16(*rWrt.m_pTableStrm, sAuthor,
false);
}
rFib.m_fcGrpStAtnOwners = nFcStart;
- nFcStart = rWrt.pTableStrm->Tell();
+ nFcStart = rWrt.m_pTableStrm->Tell();
rFib.m_lcbGrpStAtnOwners = nFcStart - rFib.m_fcGrpStAtnOwners;
// Commented text ranges
@@ -2427,66 +2491,66 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
rFib.m_fcPlcfAtnbkf = nFcStart;
for ( decltype(aRangeStartPos)::size_type i = 0; i < aRangeStartPos.size(); ++i )
{
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeStartPos[i].first );
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, aRangeStartPos[i].first );
}
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, rFib.m_ccpText + 1);
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, rFib.m_ccpText + 1);
// Commented text ranges additional information (Plcfbkf.aFBKF)
for ( decltype(aRangeStartPos)::size_type i = 0; i < aRangeStartPos.size(); ++i )
{
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, aStartEndMap[i] ); // FBKF.ibkl
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); // FBKF.bkc
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, aStartEndMap[i] ); // FBKF.ibkl
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, 0 ); // FBKF.bkc
}
- nFcStart = rWrt.pTableStrm->Tell();
+ nFcStart = rWrt.m_pTableStrm->Tell();
rFib.m_lcbPlcfAtnbkf = nFcStart - rFib.m_fcPlcfAtnbkf;
// Commented text ranges ending positions (PlcfBkl.aCP)
rFib.m_fcPlcfAtnbkl = nFcStart;
for ( decltype(aRangeEndPos)::size_type i = 0; i < aRangeEndPos.size(); ++i )
{
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeEndPos[i].first );
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, aRangeEndPos[i].first );
}
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, rFib.m_ccpText + 1);
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, rFib.m_ccpText + 1);
- nFcStart = rWrt.pTableStrm->Tell();
+ nFcStart = rWrt.m_pTableStrm->Tell();
rFib.m_lcbPlcfAtnbkl = nFcStart - rFib.m_fcPlcfAtnbkl;
// Commented text ranges as bookmarks (SttbfAtnBkmk)
rFib.m_fcSttbfAtnbkmk = nFcStart;
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, sal_Int16(sal_uInt16(0xFFFF)) ); // SttbfAtnBkmk.fExtend
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, aRangeStartPos.size() ); // SttbfAtnBkmk.cData
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0xA ); // SttbfAtnBkmk.cbExtra
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, sal_Int16(sal_uInt16(0xFFFF)) ); // SttbfAtnBkmk.fExtend
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, aRangeStartPos.size() ); // SttbfAtnBkmk.cData
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, 0xA ); // SttbfAtnBkmk.cbExtra
for ( decltype(aRangeStartPos)::size_type i = 0; i < aRangeStartPos.size(); ++i )
{
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); // SttbfAtnBkmk.cchData
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, 0 ); // SttbfAtnBkmk.cchData
// One ATNBE structure for all text ranges
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0x0100 ); // ATNBE.bmc
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, aStartAtnMap[i] ); // ATNBE.lTag
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 ); // ATNBE.lTagOld
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, 0x0100 ); // ATNBE.bmc
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, aStartAtnMap[i] ); // ATNBE.lTag
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, -1 ); // ATNBE.lTagOld
}
- nFcStart = rWrt.pTableStrm->Tell();
+ nFcStart = rWrt.m_pTableStrm->Tell();
rFib.m_lcbSttbfAtnbkmk = nFcStart - rFib.m_fcSttbfAtnbkmk;
}
// Write the extended >= Word XP ATRD records
for( sal_uInt16 i = 0; i < nLen; ++i )
{
- const WW8_Annotation& rAtn = *static_cast<const WW8_Annotation*>(aContent[i]);
+ const WW8_Annotation& rAtn = *static_cast<const WW8_Annotation*>(m_aContent[i]);
sal_uInt32 nDTTM = sw::ms::DateTime2DTTM(rAtn.maDateTime);
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, nDTTM );
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 );
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 );
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 );
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, nDTTM );
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, 0 );
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, 0 );
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, 0 );
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, 0 );
}
rFib.m_fcAtrdExtra = nFcStart;
- nFcStart = rWrt.pTableStrm->Tell();
+ nFcStart = rWrt.m_pTableStrm->Tell();
rFib.m_lcbAtrdExtra = nFcStart - rFib.m_fcAtrdExtra;
rFib.m_fcHplxsdr = 0x01010002; //WTF, but apparently necessary
rFib.m_lcbHplxsdr = 0;
@@ -2495,7 +2559,7 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
case TXT_TXTBOX:
case TXT_HFTXTBOX:
{
- pTextPos->Write( *rWrt.pTableStrm );
+ m_pTextPos->Write( *rWrt.m_pTableStrm );
const std::vector<sal_uInt32>* pShapeIds = GetShapeIdArr();
OSL_ENSURE( pShapeIds, "Where are the ShapeIds?" );
@@ -2503,9 +2567,9 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
{
// write textbox story - FTXBXS
// is it a writer or sdr - textbox?
- const SdrObject* pObj = static_cast<SdrObject const *>(aContent[ i ]);
+ const SdrObject* pObj = static_cast<SdrObject const *>(m_aContent[ i ]);
sal_Int32 nCnt = 1;
- if (dynamic_cast< const SdrTextObj *>( pObj ))
+ if (DynCastSdrTextObj( pObj ))
{
// find the "highest" SdrObject of this
const SwFrameFormat& rFormat = *::FindFrameFormat( pObj );
@@ -2521,9 +2585,9 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
}
if( nullptr == pObj )
{
- if (i < aSpareFormats.size() && aSpareFormats[i])
+ if (i < m_aSpareFormats.size() && m_aSpareFormats[i])
{
- const SwFrameFormat& rFormat = *aSpareFormats[i];
+ const SwFrameFormat& rFormat = *m_aSpareFormats[i];
const SwFormatChain* pChn = &rFormat.GetChain();
while( pChn->GetNext() )
@@ -2536,20 +2600,20 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
}
}
// long cTxbx / iNextReuse
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, nCnt );
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, nCnt );
// long cReusable
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 );
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, 0 );
// short fReusable
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, 0 );
// long reserved
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 );
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, -1 );
// long lid
- SwWW8Writer::WriteLong( *rWrt.pTableStrm,
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm,
(*pShapeIds)[i]);
// long txidUndo
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 );
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, 0 );
}
- SwWW8Writer::FillCount( *rWrt.pTableStrm, 22 );
+ SwWW8Writer::FillCount( *rWrt.m_pTableStrm, 22 );
bWriteCP = false;
}
break;
@@ -2559,10 +2623,10 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
{
// write CP Positions
for ( sal_uInt16 i = 0; i < nLen; i++ )
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, aCps[ i ] );
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, m_aCps[ i ] );
// n+1-th CP-Pos according to the manual
- SwWW8Writer::WriteLong( *rWrt.pTableStrm,
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm,
rFib.m_ccpText + rFib.m_ccpFootnote + rFib.m_ccpHdr + rFib.m_ccpEdn +
rFib.m_ccpTxbx + rFib.m_ccpHdrTxbx + 1 );
@@ -2571,7 +2635,7 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
sal_uInt16 nlTag = 0;
for ( sal_uInt16 i = 0; i < nLen; ++i )
{
- const WW8_Annotation& rAtn = *static_cast<const WW8_Annotation*>(aContent[i]);
+ const WW8_Annotation& rAtn = *static_cast<const WW8_Annotation*>(m_aContent[i]);
//aStrArr is sorted
auto aIter = std::lower_bound(aStrArr.begin(),
@@ -2590,10 +2654,10 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
// xstUsrInitl[ 10 ] pascal-style String holding initials
// of annotation author
- SwWW8Writer::WriteShort(*rWrt.pTableStrm, nInitialsLen);
- SwWW8Writer::WriteString16(*rWrt.pTableStrm, sInitials,
+ SwWW8Writer::WriteShort(*rWrt.m_pTableStrm, nInitialsLen);
+ SwWW8Writer::WriteString16(*rWrt.m_pTableStrm, sInitials,
false);
- SwWW8Writer::FillCount( *rWrt.pTableStrm,
+ SwWW8Writer::FillCount( *rWrt.m_pTableStrm,
(9 - nInitialsLen) * 2 );
// documents layout of WriteShort's below:
@@ -2603,16 +2667,16 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
// SVBT16 grfbmc; // not used
// SVBT32 ITagBkmk; // when not -1, this tag identifies the ATNBE
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, nFndPos );
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, nFndPos );
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, 0 );
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, 0 );
if (rAtn.HasRange())
{
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, nlTag );
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, nlTag );
++nlTag;
}
else
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 );
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, -1 );
}
}
else
@@ -2620,17 +2684,17 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
sal_uInt16 nNo = 0;
for ( sal_uInt16 i = 0; i < nLen; ++i ) // write Flags
{
- const SwFormatFootnote* pFootnote = static_cast<SwFormatFootnote const *>(aContent[ i ]);
- SwWW8Writer::WriteShort( *rWrt.pTableStrm,
+ const SwFormatFootnote* pFootnote = static_cast<SwFormatFootnote const *>(m_aContent[ i ]);
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm,
!pFootnote->GetNumStr().isEmpty() ? 0 : ++nNo );
}
}
}
rRefStart = nFcStart;
- nFcStart = rWrt.pTableStrm->Tell();
+ nFcStart = rWrt.m_pTableStrm->Tell();
rRefCount = nFcStart - rRefStart;
- pTextPos->Write( *rWrt.pTableStrm );
+ m_pTextPos->Write( *rWrt.m_pTableStrm );
switch ( nTTyp )
{
@@ -2640,19 +2704,19 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
{
// write break descriptor (BKD)
// short itxbxs
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, i );
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, i );
// short dcpDepend
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, 0 );
// short flags : icol/fTableBreak/fColumnBreak/fMarked/
// fUnk/fTextOverflow
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0x800 );
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, 0x800 );
}
- SwWW8Writer::FillCount( *rWrt.pTableStrm, 6 );
+ SwWW8Writer::FillCount( *rWrt.m_pTableStrm, 6 );
break;
}
rTextStart = nFcStart;
- rTextCount = rWrt.pTableStrm->Tell() - nFcStart;
+ rTextCount = rWrt.m_pTableStrm->Tell() - nFcStart;
}
const std::vector<sal_uInt32>* WW8_WrPlcSubDoc::GetShapeIdArr() const
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index d8e4241422c8..b252e4d1533d 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -37,7 +37,6 @@
#include <docsh.hxx>
#include <drawdoc.hxx>
-#include <unotools/fltrcfg.hxx>
#include <sot/storage.hxx>
#include <sfx2/docinf.hxx>
#include <editeng/tstpitem.hxx>
@@ -87,6 +86,7 @@
#include <strings.hrc>
#include <fmtline.hxx>
#include <fmtfsize.hxx>
+#include <formatflysplit.hxx>
#include "sprmids.hxx"
#include <comphelper/sequenceashashmap.hxx>
@@ -116,6 +116,9 @@
#include <rdfhelper.hxx>
#include <fmtclbl.hxx>
#include <iodetect.hxx>
+#include <fmtwrapinfluenceonobjpos.hxx>
+#include <officecfg/Office/Common.hxx>
+#include <fmtanchr.hxx>
using namespace css;
using namespace sw::util;
@@ -125,15 +128,15 @@ using namespace sw::types;
*/
class WW8_WrFkp
{
- sal_uInt8* pFkp; // Fkp total ( first and only FCs and Sprms )
- sal_uInt8* pOfs; // pointer to the offset area, later copied to pFkp
- ePLCFT ePlc;
- short nStartGrp; // from here on grpprls
- short nOldStartGrp;
- sal_uInt8 nItemSize;
- sal_uInt8 nIMax; // number of entry pairs
- sal_uInt8 nOldVarLen;
- bool bCombined; // true : paste not allowed
+ sal_uInt8* m_pFkp; // Fkp total ( first and only FCs and Sprms )
+ sal_uInt8* m_pOfs; // pointer to the offset area, later copied to pFkp
+ ePLCFT m_ePlc;
+ short m_nStartGrp; // from here on grpprls
+ short m_nOldStartGrp;
+ sal_uInt8 m_nItemSize;
+ sal_uInt8 m_nIMax; // number of entry pairs
+ sal_uInt8 m_nOldVarLen;
+ bool m_bCombined; // true : paste not allowed
sal_uInt8 SearchSameSprm( sal_uInt16 nVarLen, const sal_uInt8* pSprms );
@@ -148,12 +151,12 @@ public:
void Write( SvStream& rStrm, SwWW8WrGrf& rGrf );
bool IsEqualPos(WW8_FC nEndFc) const
- { return !bCombined && nIMax && nEndFc == reinterpret_cast<sal_Int32*>(pFkp)[nIMax]; }
+ { return !m_bCombined && m_nIMax && nEndFc == reinterpret_cast<sal_Int32*>(m_pFkp)[m_nIMax]; }
void MergeToNew( short& rVarLen, sal_uInt8 *& pNewSprms );
bool IsEmptySprm() const
- { return !bCombined && nIMax && !nOldVarLen; }
+ { return !m_bCombined && m_nIMax && !m_nOldVarLen; }
void SetNewEnd( WW8_FC nEnd )
- { reinterpret_cast<sal_Int32*>(pFkp)[nIMax] = nEnd; }
+ { reinterpret_cast<sal_Int32*>(m_pFkp)[m_nIMax] = nEnd; }
WW8_FC GetStartFc() const;
WW8_FC GetEndFc() const;
@@ -164,19 +167,19 @@ public:
// class WW8_WrPc collects all piece entries for one piece
class WW8_WrPc
{
- WW8_CP nStartCp; // Starting character position of the text
- WW8_FC nStartFc; // Starting file position of the text
- sal_uInt16 nStatus; // End of paragraph inside the piece?
+ WW8_CP m_nStartCp; // Starting character position of the text
+ WW8_FC m_nStartFc; // Starting file position of the text
+ sal_uInt16 m_nStatus; // End of paragraph inside the piece?
public:
WW8_WrPc(WW8_FC nSFc, WW8_CP nSCp )
- : nStartCp( nSCp ), nStartFc( nSFc ), nStatus( 0x0040 )
+ : m_nStartCp( nSCp ), m_nStartFc( nSFc ), m_nStatus( 0x0040 )
{}
- void SetStatus() { nStatus = 0x0050; }
- sal_uInt16 GetStatus() const { return nStatus; }
- WW8_CP GetStartCp() const { return nStartCp; }
- WW8_FC GetStartFc() const { return nStartFc; }
+ void SetStatus() { m_nStatus = 0x0050; }
+ sal_uInt16 GetStatus() const { return m_nStatus; }
+ WW8_CP GetStartCp() const { return m_nStartCp; }
+ WW8_FC GetStartFc() const { return m_nStartFc; }
};
typedef std::map<OUString,tools::Long> BKMKNames;
@@ -189,7 +192,7 @@ class WW8_WrtBookmarks
{
private:
/// Structure of one item inside this map: (startPos, (endPos, (a bool value?, bookmarkName)))
- BKMKCPs aSttCps;
+ BKMKCPs maSttCps;
BKMKNames maSwBkmkNms;
WW8_WrtBookmarks(WW8_WrtBookmarks const&) = delete;
@@ -211,7 +214,7 @@ WW8_WrtBookmarks::WW8_WrtBookmarks()
WW8_WrtBookmarks::~WW8_WrtBookmarks()
{
- for (auto& rEntry : aSttCps)
+ for (auto& rEntry : maSttCps)
{
if (rEntry.second)
{
@@ -228,12 +231,12 @@ void WW8_WrtBookmarks::Append( WW8_CP nStartCp, const OUString& rNm)
{
BKMK aBK(false,rNm);
BKMKCP* pBKCP = new BKMKCP(static_cast<tools::Long>(nStartCp),aBK);
- aSttCps.insert(std::pair<tools::Long,BKMKCP*>(nStartCp,pBKCP));
+ maSttCps.insert(std::pair<tools::Long,BKMKCP*>(nStartCp,pBKCP));
aResult.first->second = static_cast<tools::Long>(nStartCp);
}
else
{
- std::pair<CPItr,CPItr> aRange = aSttCps.equal_range(aResult.first->second);
+ std::pair<CPItr,CPItr> aRange = maSttCps.equal_range(aResult.first->second);
for (CPItr aItr = aRange.first;aItr != aRange.second;++aItr)
{
if (aItr->second && aItr->second->second.second == rNm)
@@ -249,7 +252,7 @@ void WW8_WrtBookmarks::Append( WW8_CP nStartCp, const OUString& rNm)
void WW8_WrtBookmarks::Write( WW8Export& rWrt)
{
- if (aSttCps.empty())
+ if (maSttCps.empty())
return;
tools::Long n;
std::vector<OUString> aNames;
@@ -257,7 +260,7 @@ void WW8_WrtBookmarks::Write( WW8Export& rWrt)
SvMemoryStream aTempStrm2(65535,65535);
BKMKCPs aEndCps;
- for (const auto& rEntry : aSttCps)
+ for (const auto& rEntry : maSttCps)
{
if (rEntry.second)
{
@@ -280,28 +283,28 @@ void WW8_WrtBookmarks::Write( WW8Export& rWrt)
}
aTempStrm2.Seek(0);
- rWrt.WriteAsStringTable(aNames, rWrt.pFib->m_fcSttbfbkmk,rWrt.pFib->m_lcbSttbfbkmk);
- SvStream& rStrm = *rWrt.pTableStrm;
- rWrt.pFib->m_fcPlcfbkf = rStrm.Tell();
+ rWrt.WriteAsStringTable(aNames, rWrt.m_pFib->m_fcSttbfbkmk,rWrt.m_pFib->m_lcbSttbfbkmk);
+ SvStream& rStrm = *rWrt.m_pTableStrm;
+ rWrt.m_pFib->m_fcPlcfbkf = rStrm.Tell();
rStrm.WriteStream( aTempStrm1 );
- SwWW8Writer::WriteLong(rStrm, rWrt.pFib->m_ccpText + rWrt.pFib->m_ccpTxbx);
- for (const auto& rEntry : aSttCps)
+ SwWW8Writer::WriteLong(rStrm, rWrt.m_pFib->m_ccpText + rWrt.m_pFib->m_ccpTxbx);
+ for (const auto& rEntry : maSttCps)
{
if (rEntry.second)
{
SwWW8Writer::WriteLong(rStrm, rEntry.second->first);
}
}
- rWrt.pFib->m_lcbPlcfbkf = rStrm.Tell() - rWrt.pFib->m_fcPlcfbkf;
- rWrt.pFib->m_fcPlcfbkl = rStrm.Tell();
+ rWrt.m_pFib->m_lcbPlcfbkf = rStrm.Tell() - rWrt.m_pFib->m_fcPlcfbkf;
+ rWrt.m_pFib->m_fcPlcfbkl = rStrm.Tell();
rStrm.WriteStream( aTempStrm2 );
- SwWW8Writer::WriteLong(rStrm, rWrt.pFib->m_ccpText + rWrt.pFib->m_ccpTxbx);
- rWrt.pFib->m_lcbPlcfbkl = rStrm.Tell() - rWrt.pFib->m_fcPlcfbkl;
+ SwWW8Writer::WriteLong(rStrm, rWrt.m_pFib->m_ccpText + rWrt.m_pFib->m_ccpTxbx);
+ rWrt.m_pFib->m_lcbPlcfbkl = rStrm.Tell() - rWrt.m_pFib->m_fcPlcfbkl;
}
void WW8_WrtBookmarks::MoveFieldMarks(WW8_CP nFrom, WW8_CP nTo)
{
- std::pair<CPItr,CPItr> aRange = aSttCps.equal_range(nFrom);
+ std::pair<CPItr,CPItr> aRange = maSttCps.equal_range(nFrom);
CPItr aItr = aRange.first;
while (aItr != aRange.second)
{
@@ -312,9 +315,9 @@ void WW8_WrtBookmarks::MoveFieldMarks(WW8_CP nFrom, WW8_CP nTo)
aItr->second->second.first = true;
aItr->second->first = nTo;
}
- aSttCps.insert(std::pair<tools::Long,BKMKCP*>(nTo,aItr->second));
+ maSttCps.insert(std::pair<tools::Long,BKMKCP*>(nTo,aItr->second));
aItr->second = nullptr;
- aRange = aSttCps.equal_range(nFrom);
+ aRange = maSttCps.equal_range(nFrom);
aItr = aRange.first;
continue;
}
@@ -355,11 +358,11 @@ void WW8_WrtFactoids::Write(WW8Export& rExport)
return;
// Smart tags are otherwise removed by Word on saving.
- rExport.pDop->fEmbedFactoids = true;
+ rExport.m_pDop->fEmbedFactoids = true;
- SvStream& rStream = *rExport.pTableStrm;
+ SvStream& rStream = *rExport.m_pTableStrm;
- rExport.pFib->m_fcSttbfBkmkFactoid = rStream.Tell();
+ rExport.m_pFib->m_fcSttbfBkmkFactoid = rStream.Tell();
// Write SttbfBkmkFactoid.
rStream.WriteUInt16(0xffff); // fExtend
rStream.WriteUInt16(m_aStartCPs.size()); // cData
@@ -374,12 +377,12 @@ void WW8_WrtFactoids::Write(WW8Export& rExport)
rStream.WriteUInt16(0); // fto
rStream.WriteUInt32(0); // pfpb
}
- rExport.pFib->m_lcbSttbfBkmkFactoid = rStream.Tell() - rExport.pFib->m_fcSttbfBkmkFactoid;
+ rExport.m_pFib->m_lcbSttbfBkmkFactoid = rStream.Tell() - rExport.m_pFib->m_fcSttbfBkmkFactoid;
- rExport.pFib->m_fcPlcfBkfFactoid = rStream.Tell();
+ rExport.m_pFib->m_fcPlcfBkfFactoid = rStream.Tell();
for (const WW8_CP& rCP : m_aStartCPs)
rStream.WriteInt32(rCP);
- rStream.WriteInt32(rExport.pFib->m_ccpText + rExport.pFib->m_ccpTxbx);
+ rStream.WriteInt32(rExport.m_pFib->m_ccpText + rExport.m_pFib->m_ccpTxbx);
// Write FBKFD.
for (size_t i = 0; i < m_aStartCPs.size(); ++i)
@@ -389,12 +392,12 @@ void WW8_WrtFactoids::Write(WW8Export& rExport)
rStream.WriteInt16(1); // cDepth, 1 as start and end is the same.
}
- rExport.pFib->m_lcbPlcfBkfFactoid = rStream.Tell() - rExport.pFib->m_fcPlcfBkfFactoid;
+ rExport.m_pFib->m_lcbPlcfBkfFactoid = rStream.Tell() - rExport.m_pFib->m_fcPlcfBkfFactoid;
- rExport.pFib->m_fcPlcfBklFactoid = rStream.Tell();
+ rExport.m_pFib->m_fcPlcfBklFactoid = rStream.Tell();
for (const WW8_CP& rCP : m_aEndCPs)
rStream.WriteInt32(rCP);
- rStream.WriteInt32(rExport.pFib->m_ccpText + rExport.pFib->m_ccpTxbx);
+ rStream.WriteInt32(rExport.m_pFib->m_ccpText + rExport.m_pFib->m_ccpTxbx);
// Write FBKLD.
for (size_t i = 0; i < m_aEndCPs.size(); ++i)
@@ -402,9 +405,9 @@ void WW8_WrtFactoids::Write(WW8Export& rExport)
rStream.WriteInt16(i); // ibkf
rStream.WriteInt16(0); // cDepth, 0 as does not overlap with any other smart tag.
}
- rExport.pFib->m_lcbPlcfBklFactoid = rStream.Tell() - rExport.pFib->m_fcPlcfBklFactoid;
+ rExport.m_pFib->m_lcbPlcfBklFactoid = rStream.Tell() - rExport.m_pFib->m_fcPlcfBklFactoid;
- rExport.pFib->m_fcFactoidData = rStream.Tell();
+ rExport.m_pFib->m_fcFactoidData = rStream.Tell();
// Write SmartTagData.
MSOFactoidType aFactoidType;
aFactoidType.m_nId = 1;
@@ -439,18 +442,18 @@ void WW8_WrtFactoids::Write(WW8Export& rExport)
}
aSmartTagData.Write(rExport);
- rExport.pFib->m_lcbFactoidData = rStream.Tell() - rExport.pFib->m_fcFactoidData;
+ rExport.m_pFib->m_lcbFactoidData = rStream.Tell() - rExport.m_pFib->m_fcFactoidData;
}
#define DEFAULT_STYLES_COUNT 16
// Names of the storage streams
constexpr OUStringLiteral sMainStream = u"WordDocument";
-#define sCompObj "\1CompObj"
+constexpr OUStringLiteral sCompObj = u"\1CompObj";
static void WriteDop( WW8Export& rWrt )
{
- WW8Dop& rDop = *rWrt.pDop;
+ WW8Dop& rDop = *rWrt.m_pDop;
// i#78951#, store the value of unknown compatibility options
rDop.SetCompatibilityOptions( rWrt.m_rDoc.getIDocumentSettingAccess().Getn32DummyCompatibilityOptions1());
@@ -461,8 +464,8 @@ static void WriteDop( WW8Export& rWrt )
// write default TabStop
const SvxTabStopItem& rTabStop =
- DefaultItemGet<SvxTabStopItem>(rWrt.m_rDoc, RES_PARATR_TABSTOP);
- rDop.dxaTab = static_cast<sal_uInt16>(rTabStop[0].GetTabPos());
+ rWrt.m_rDoc.GetAttrPool().GetUserOrPoolDefaultItem(RES_PARATR_TABSTOP);
+ rDop.dxaTab = o3tl::narrowing<sal_uInt16>(rTabStop[0].GetTabPos());
// Zoom factor and type
SwViewShell *pViewShell(rWrt.m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell());
@@ -505,7 +508,7 @@ static void WriteDop( WW8Export& rWrt )
rDop.lKeyProtDoc = pDocShell->GetModifyPasswordHash();
}
- if ((rWrt.pSepx && rWrt.pSepx->DocumentIsProtected()) ||
+ if ((rWrt.m_pSepx && rWrt.m_pSepx->DocumentIsProtected()) ||
rWrt.m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_FORM ) ||
rDop.lKeyProtDoc != 0)
{
@@ -556,7 +559,10 @@ static void WriteDop( WW8Export& rWrt )
rDop.fExpShRtn = !rWrt.m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK); // #i56856#
- rDop.Write( *rWrt.pTableStrm, *rWrt.pFib );
+ IDocumentSettingAccess& rIDSA = rWrt.m_rDoc.getIDocumentSettingAccess();
+ rDop.fDontBreakWrappedTables = rIDSA.get(DocumentSettingId::DO_NOT_BREAK_WRAPPED_TABLES);
+
+ rDop.Write( *rWrt.m_pTableStrm, *rWrt.m_pFib );
}
static int lcl_CmpBeginEndChars( const OUString& rSWStr,
@@ -698,14 +704,14 @@ void WW8Export::ExportDopTypography(WW8DopTypography &rTypo)
!lcl_CmpBeginEndChars
(
pForbidden->endLine,
- OUString(WW8DopTypography::JapanNotEndLevel1).getStr(),
+ WW8DopTypography::JapanNotEndLevel1.getStr(),
WW8DopTypography::nMaxLeading * sizeof(sal_Unicode)
)
&&
!lcl_CmpBeginEndChars
(
pForbidden->beginLine,
- OUString(WW8DopTypography::JapanNotBeginLevel1).getStr(),
+ WW8DopTypography::JapanNotBeginLevel1.getStr(),
WW8DopTypography::nMaxFollowing * sizeof(sal_Unicode)
)
)
@@ -793,9 +799,9 @@ const SfxPoolItem& MSWordExportBase::GetItem(sal_uInt16 nWhich) const
}
WW8_WrPlc1::WW8_WrPlc1( sal_uInt16 nStructSz )
- : pData( new sal_uInt8[ 16 * nStructSz ] ),
- nDataLen(16 * nStructSz),
- nStructSiz( nStructSz )
+ : m_pData( new sal_uInt8[ 16 * nStructSz ] ),
+ m_nDataLen(16 * nStructSz),
+ m_nStructSiz( nStructSz )
{
}
@@ -805,43 +811,43 @@ WW8_WrPlc1::~WW8_WrPlc1()
WW8_CP WW8_WrPlc1::Prev() const
{
- bool b = !aPos.empty();
+ bool b = !m_aPos.empty();
OSL_ENSURE(b,"Prev called on empty list");
- return b ? aPos.back() : 0;
+ return b ? m_aPos.back() : 0;
}
void WW8_WrPlc1::Append( WW8_CP nCp, const void* pNewData )
{
- sal_uLong nInsPos = aPos.size() * nStructSiz;
- aPos.push_back( nCp );
- if( nDataLen < nInsPos + nStructSiz )
+ sal_uLong nInsPos = m_aPos.size() * m_nStructSiz;
+ m_aPos.push_back( nCp );
+ if( m_nDataLen < nInsPos + m_nStructSiz )
{
- sal_uInt8* pNew = new sal_uInt8[ 2 * nDataLen ];
- memcpy( pNew, pData.get(), nDataLen );
- pData.reset(pNew);
- nDataLen *= 2;
+ sal_uInt8* pNew = new sal_uInt8[ 2 * m_nDataLen ];
+ memcpy( pNew, m_pData.get(), m_nDataLen );
+ m_pData.reset(pNew);
+ m_nDataLen *= 2;
}
- memcpy( pData.get() + nInsPos, pNewData, nStructSiz );
+ memcpy( m_pData.get() + nInsPos, pNewData, m_nStructSiz );
}
void WW8_WrPlc1::Finish( sal_uLong nLastCp, sal_uLong nSttCp )
{
- if( !aPos.empty() )
+ if( !m_aPos.empty() )
{
- aPos.push_back( nLastCp );
+ m_aPos.push_back( nLastCp );
if( nSttCp )
- for(WW8_CP & rCp : aPos)
+ for(WW8_CP & rCp : m_aPos)
rCp -= nSttCp;
}
}
void WW8_WrPlc1::Write( SvStream& rStrm )
{
- decltype(aPos)::size_type i;
- for( i = 0; i < aPos.size(); ++i )
- SwWW8Writer::WriteLong( rStrm, aPos[i] );
+ decltype(m_aPos)::size_type i;
+ for( i = 0; i < m_aPos.size(); ++i )
+ SwWW8Writer::WriteLong( rStrm, m_aPos[i] );
if( i )
- rStrm.WriteBytes(pData.get(), (i-1) * nStructSiz);
+ rStrm.WriteBytes(m_pData.get(), (i-1) * m_nStructSiz);
}
// Class WW8_WrPlcField for fields
@@ -853,40 +859,40 @@ void WW8_WrPlcField::Write( WW8Export& rWrt )
WW8_FC *pfc;
sal_Int32 *plc;
- switch (nTextTyp)
+ switch (m_nTextTyp)
{
case TXT_MAINTEXT:
- pfc = &rWrt.pFib->m_fcPlcffldMom;
- plc = &rWrt.pFib->m_lcbPlcffldMom;
+ pfc = &rWrt.m_pFib->m_fcPlcffldMom;
+ plc = &rWrt.m_pFib->m_lcbPlcffldMom;
break;
case TXT_HDFT:
- pfc = &rWrt.pFib->m_fcPlcffldHdr;
- plc = &rWrt.pFib->m_lcbPlcffldHdr;
+ pfc = &rWrt.m_pFib->m_fcPlcffldHdr;
+ plc = &rWrt.m_pFib->m_lcbPlcffldHdr;
break;
case TXT_FTN:
- pfc = &rWrt.pFib->m_fcPlcffldFootnote;
- plc = &rWrt.pFib->m_lcbPlcffldFootnote;
+ pfc = &rWrt.m_pFib->m_fcPlcffldFootnote;
+ plc = &rWrt.m_pFib->m_lcbPlcffldFootnote;
break;
case TXT_EDN:
- pfc = &rWrt.pFib->m_fcPlcffldEdn;
- plc = &rWrt.pFib->m_lcbPlcffldEdn;
+ pfc = &rWrt.m_pFib->m_fcPlcffldEdn;
+ plc = &rWrt.m_pFib->m_lcbPlcffldEdn;
break;
case TXT_ATN:
- pfc = &rWrt.pFib->m_fcPlcffldAtn;
- plc = &rWrt.pFib->m_lcbPlcffldAtn;
+ pfc = &rWrt.m_pFib->m_fcPlcffldAtn;
+ plc = &rWrt.m_pFib->m_lcbPlcffldAtn;
break;
case TXT_TXTBOX:
- pfc = &rWrt.pFib->m_fcPlcffldTxbx;
- plc = &rWrt.pFib->m_lcbPlcffldTxbx;
+ pfc = &rWrt.m_pFib->m_fcPlcffldTxbx;
+ plc = &rWrt.m_pFib->m_lcbPlcffldTxbx;
break;
case TXT_HFTXTBOX:
- pfc = &rWrt.pFib->m_fcPlcffldHdrTxbx;
- plc = &rWrt.pFib->m_lcbPlcffldHdrTxbx;
+ pfc = &rWrt.m_pFib->m_fcPlcffldHdrTxbx;
+ plc = &rWrt.m_pFib->m_lcbPlcffldHdrTxbx;
break;
default:
@@ -896,10 +902,10 @@ void WW8_WrPlcField::Write( WW8Export& rWrt )
if( pfc && plc )
{
- sal_uInt64 nFcStart = rWrt.pTableStrm->Tell();
- WW8_WrPlc1::Write( *rWrt.pTableStrm );
+ sal_uInt64 nFcStart = rWrt.m_pTableStrm->Tell();
+ WW8_WrPlc1::Write( *rWrt.m_pTableStrm );
*pfc = nFcStart;
- *plc = rWrt.pTableStrm->Tell() - nFcStart;
+ *plc = rWrt.m_pTableStrm->Tell() - nFcStart;
}
}
@@ -907,10 +913,10 @@ void WW8_WrMagicTable::Write( WW8Export& rWrt )
{
if( WW8_WrPlc1::Count() <= 1 )
return;
- sal_uLong nFcStart = rWrt.pTableStrm->Tell();
- WW8_WrPlc1::Write( *rWrt.pTableStrm );
- rWrt.pFib->m_fcPlcfTch = nFcStart;
- rWrt.pFib->m_lcbPlcfTch = rWrt.pTableStrm->Tell() - nFcStart;
+ sal_uInt64 nFcStart = rWrt.m_pTableStrm->Tell();
+ WW8_WrPlc1::Write( *rWrt.m_pTableStrm );
+ rWrt.m_pFib->m_fcPlcfTch = nFcStart;
+ rWrt.m_pFib->m_lcbPlcfTch = rWrt.m_pTableStrm->Tell() - nFcStart;
}
void WW8_WrMagicTable::Append( WW8_CP nCp, sal_uLong nData)
@@ -959,11 +965,11 @@ sal_uLong SwWW8Writer::FillUntil( SvStream& rStrm, sal_uLong nEndPos )
}
WW8_WrPlcPn::WW8_WrPlcPn(WW8Export& rWr, ePLCFT ePl, WW8_FC nStartFc)
- : rWrt(rWr)
- , nFkpStartPage(0)
- , ePlc(ePl)
+ : m_rWrt(rWr)
+ , m_nFkpStartPage(0)
+ , m_ePlc(ePl)
{
- m_Fkps.push_back(std::make_unique<WW8_WrFkp>(ePlc, nStartFc));
+ m_Fkps.push_back(std::make_unique<WW8_WrFkp>(m_ePlc, nStartFc));
}
WW8_WrPlcPn::~WW8_WrPlcPn()
@@ -983,16 +989,16 @@ void WW8_WrPlcPn::AppendFkpEntry(WW8_FC nEndFc,short nVarLen,const sal_uInt8* pS
// big sprm? build the sprmPHugePapx
sal_uInt8* pNewSprms = const_cast<sal_uInt8*>(pSprms);
sal_uInt8 aHugePapx[ 8 ];
- if (PAP == ePlc && 488 <= nVarLen)
+ if (PAP == m_ePlc && 488 <= nVarLen)
{
sal_uInt8* p = aHugePapx;
*p++ = *pSprms++; // set style Id
*p++ = *pSprms++;
nVarLen -= 2;
- tools::Long nDataPos = rWrt.pDataStrm->Tell();
- SwWW8Writer::WriteShort( *rWrt.pDataStrm, nVarLen );
- rWrt.pDataStrm->WriteBytes(pSprms, nVarLen);
+ sal_uInt64 nDataPos = m_rWrt.m_pDataStrm->Tell();
+ SwWW8Writer::WriteShort( *m_rWrt.m_pDataStrm, nVarLen );
+ m_rWrt.m_pDataStrm->WriteBytes(pSprms, nVarLen);
Set_UInt16( p, 0x6646 ); // set SprmCode
Set_UInt32( p, nDataPos ); // set startpos (FC) in the datastream
@@ -1015,7 +1021,7 @@ void WW8_WrPlcPn::AppendFkpEntry(WW8_FC nEndFc,short nVarLen,const sal_uInt8* pS
if( !bOk )
{
pF->Combine();
- pF = new WW8_WrFkp(ePlc, pF->GetEndFc()); // Start new Fkp == end of old Fkp
+ pF = new WW8_WrFkp(m_ePlc, pF->GetEndFc()); // Start new Fkp == end of old Fkp
m_Fkps.push_back(std::unique_ptr<WW8_WrFkp>(pF));
if( !pF->Append( nEndFc, nVarLen, pNewSprms ) )
@@ -1029,73 +1035,73 @@ void WW8_WrPlcPn::AppendFkpEntry(WW8_FC nEndFc,short nVarLen,const sal_uInt8* pS
void WW8_WrPlcPn::WriteFkps()
{
- nFkpStartPage = static_cast<sal_uInt16>( SwWW8Writer::FillUntil( rWrt.Strm() ) >> 9 );
+ m_nFkpStartPage = o3tl::narrowing<sal_uInt16>( SwWW8Writer::FillUntil( m_rWrt.Strm() ) >> 9 );
for(const std::unique_ptr<WW8_WrFkp> & rp : m_Fkps)
{
- rp->Write( rWrt.Strm(), *rWrt.m_pGrf );
+ rp->Write( m_rWrt.Strm(), *m_rWrt.m_pGrf );
}
- if( CHP == ePlc )
+ if( CHP == m_ePlc )
{
- rWrt.pFib->m_pnChpFirst = nFkpStartPage;
- rWrt.pFib->m_cpnBteChp = m_Fkps.size();
+ m_rWrt.m_pFib->m_pnChpFirst = m_nFkpStartPage;
+ m_rWrt.m_pFib->m_cpnBteChp = m_Fkps.size();
}
else
{
- rWrt.pFib->m_pnPapFirst = nFkpStartPage;
- rWrt.pFib->m_cpnBtePap = m_Fkps.size();
+ m_rWrt.m_pFib->m_pnPapFirst = m_nFkpStartPage;
+ m_rWrt.m_pFib->m_cpnBtePap = m_Fkps.size();
}
}
void WW8_WrPlcPn::WritePlc()
{
- sal_uInt64 nFcStart = rWrt.pTableStrm->Tell();
+ sal_uInt64 nFcStart = m_rWrt.m_pTableStrm->Tell();
decltype(m_Fkps)::size_type i;
for (i = 0; i < m_Fkps.size(); ++i)
{
- SwWW8Writer::WriteLong( *rWrt.pTableStrm,
+ SwWW8Writer::WriteLong( *m_rWrt.m_pTableStrm,
m_Fkps[ i ]->GetStartFc() );
}
- SwWW8Writer::WriteLong( *rWrt.pTableStrm,
+ SwWW8Writer::WriteLong( *m_rWrt.m_pTableStrm,
m_Fkps[ i - 1 ]->GetEndFc() );
// for every FKP output the page
for (i = 0; i < m_Fkps.size(); ++i)
{
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, i + nFkpStartPage );
+ SwWW8Writer::WriteLong( *m_rWrt.m_pTableStrm, i + m_nFkpStartPage );
}
- if( CHP == ePlc )
+ if( CHP == m_ePlc )
{
- rWrt.pFib->m_fcPlcfbteChpx = nFcStart;
- rWrt.pFib->m_lcbPlcfbteChpx = rWrt.pTableStrm->Tell() - nFcStart;
+ m_rWrt.m_pFib->m_fcPlcfbteChpx = nFcStart;
+ m_rWrt.m_pFib->m_lcbPlcfbteChpx = m_rWrt.m_pTableStrm->Tell() - nFcStart;
}
else
{
- rWrt.pFib->m_fcPlcfbtePapx = nFcStart;
- rWrt.pFib->m_lcbPlcfbtePapx = rWrt.pTableStrm->Tell() - nFcStart;
+ m_rWrt.m_pFib->m_fcPlcfbtePapx = nFcStart;
+ m_rWrt.m_pFib->m_lcbPlcfbtePapx = m_rWrt.m_pTableStrm->Tell() - nFcStart;
}
}
WW8_WrFkp::WW8_WrFkp(ePLCFT ePl, WW8_FC nStartFc)
- : ePlc(ePl), nStartGrp(511), nOldStartGrp(511),
- nItemSize( ( CHP == ePl ) ? 1 : 13 ),
- nIMax(0), nOldVarLen(0), bCombined(false)
+ : m_ePlc(ePl), m_nStartGrp(511), m_nOldStartGrp(511),
+ m_nItemSize( ( CHP == ePl ) ? 1 : 13 ),
+ m_nIMax(0), m_nOldVarLen(0), m_bCombined(false)
{
- pFkp = reinterpret_cast<sal_uInt8*>(new sal_Int32[128]); // 512 Byte
- pOfs = reinterpret_cast<sal_uInt8*>(new sal_Int32[128]); // 512 Byte
- memset( pFkp, 0, 4 * 128 );
- memset( pOfs, 0, 4 * 128 );
- reinterpret_cast<sal_Int32*>(pFkp)[0] = nStartFc; // 0th entry FC at nStartFc
+ m_pFkp = reinterpret_cast<sal_uInt8*>(new sal_Int32[128]); // 512 Byte
+ m_pOfs = reinterpret_cast<sal_uInt8*>(new sal_Int32[128]); // 512 Byte
+ memset( m_pFkp, 0, 4 * 128 );
+ memset( m_pOfs, 0, 4 * 128 );
+ reinterpret_cast<sal_Int32*>(m_pFkp)[0] = nStartFc; // 0th entry FC at nStartFc
}
WW8_WrFkp::~WW8_WrFkp()
{
- delete[] reinterpret_cast<sal_Int32 *>(pFkp);
- delete[] reinterpret_cast<sal_Int32 *>(pOfs);
+ delete[] reinterpret_cast<sal_Int32 *>(m_pFkp);
+ delete[] reinterpret_cast<sal_Int32 *>(m_pOfs);
}
sal_uInt8 WW8_WrFkp::SearchSameSprm( sal_uInt16 nVarLen, const sal_uInt8* pSprms )
@@ -1111,15 +1117,15 @@ sal_uInt8 WW8_WrFkp::SearchSameSprm( sal_uInt16 nVarLen, const sal_uInt8* pSprms
}
short i;
- for( i = 0; i < nIMax; i++ )
+ for( i = 0; i < m_nIMax; i++ )
{
- sal_uInt8 nStart = pOfs[i * nItemSize];
+ sal_uInt8 nStart = m_pOfs[i * m_nItemSize];
if( nStart )
{ // has Sprms
- const sal_uInt8* p = pFkp + ( static_cast<sal_uInt16>(nStart) << 1 );
- if( ( CHP == ePlc
+ const sal_uInt8* p = m_pFkp + ( o3tl::narrowing<sal_uInt16>(nStart) << 1 );
+ if( ( CHP == m_ePlc
? (*p++ == nVarLen)
- : ((static_cast<sal_uInt16>(*p++) << 1 ) == (( nVarLen+1) & 0xfffe)) )
+ : ((o3tl::narrowing<sal_uInt16>(*p++) << 1 ) == (( nVarLen+1) & 0xfffe)) )
&& !memcmp( p, pSprms, nVarLen ) )
return nStart; // found it
}
@@ -1132,14 +1138,14 @@ sal_uInt8 *WW8_WrFkp::CopyLastSprms(sal_uInt8 &rLen)
rLen=0;
sal_uInt8 *pStart=nullptr,*pRet=nullptr;
- if (!bCombined)
- pStart = pOfs;
+ if (!m_bCombined)
+ pStart = m_pOfs;
else
- pStart = pFkp + ( nIMax + 1 ) * 4;
+ pStart = m_pFkp + ( m_nIMax + 1 ) * 4;
- sal_uInt8 nStart = *(pStart + (nIMax-1) * nItemSize);
+ sal_uInt8 nStart = *(pStart + (m_nIMax-1) * m_nItemSize);
- const sal_uInt8* p = pFkp + ( static_cast<sal_uInt16>(nStart) << 1 );
+ const sal_uInt8* p = m_pFkp + ( o3tl::narrowing<sal_uInt16>(nStart) << 1 );
if (!*p)
p++;
@@ -1147,7 +1153,7 @@ sal_uInt8 *WW8_WrFkp::CopyLastSprms(sal_uInt8 &rLen)
if (*p)
{
rLen = *p++;
- if (PAP == ePlc)
+ if (PAP == m_ePlc)
rLen *= 2;
pRet = new sal_uInt8[rLen];
memcpy(pRet,p,rLen);
@@ -1159,14 +1165,14 @@ bool WW8_WrFkp::Append( WW8_FC nEndFc, sal_uInt16 nVarLen, const sal_uInt8* pSpr
{
assert((!nVarLen || pSprms) && "Item pointer missing");
- OSL_ENSURE( nVarLen < ( ( ePlc == PAP ) ? 497U : 502U ), "Sprms too long !" );
+ OSL_ENSURE( nVarLen < ( ( m_ePlc == PAP ) ? 497U : 502U ), "Sprms too long !" );
- if( bCombined )
+ if( m_bCombined )
{
OSL_ENSURE( false, "Fkp::Append: Fkp is already combined" );
return false;
}
- sal_Int32 n = reinterpret_cast<sal_Int32*>(pFkp)[nIMax]; // last entry
+ sal_Int32 n = reinterpret_cast<sal_Int32*>(m_pFkp)[m_nIMax]; // last entry
if( nEndFc <= n )
{
OSL_ENSURE( nEndFc >= n, "+Fkp: FC backwards" );
@@ -1179,67 +1185,67 @@ bool WW8_WrFkp::Append( WW8_FC nEndFc, sal_uInt16 nVarLen, const sal_uInt8* pSpr
sal_uInt8 nOldP = nVarLen ? SearchSameSprm( nVarLen, pSprms ) : 0;
// Combine equal entries
- short nOffset=0, nPos = nStartGrp;
+ short nOffset=0, nPos = m_nStartGrp;
if (nVarLen && !nOldP)
{
- nPos = PAP == ePlc
- ? ( 13 == nItemSize // HACK: PAP and bWrtWW8 !!
- ? (nStartGrp & 0xFFFE ) - nVarLen - 1
- : (nStartGrp - (((nVarLen + 1) & 0xFFFE)+1)) & 0xFFFE )
- : ((nStartGrp - nVarLen - 1) & 0xFFFE);
+ nPos = PAP == m_ePlc
+ ? ( 13 == m_nItemSize // HACK: PAP and bWrtWW8 !!
+ ? (m_nStartGrp & 0xFFFE ) - nVarLen - 1
+ : (m_nStartGrp - (((nVarLen + 1) & 0xFFFE)+1)) & 0xFFFE )
+ : ((m_nStartGrp - nVarLen - 1) & 0xFFFE);
if( nPos < 0 )
return false; // doesn't fit at all
nOffset = nPos; // save offset (can also be uneven!)
nPos &= 0xFFFE; // Pos for Sprms ( gerade Pos )
}
- if( o3tl::make_unsigned(nPos) <= ( nIMax + 2U ) * 4U + ( nIMax + 1U ) * nItemSize )
+ if( o3tl::make_unsigned(nPos) <= ( m_nIMax + 2U ) * 4U + ( m_nIMax + 1U ) * m_nItemSize )
// does it fits after the CPs and offsets?
return false; // no
- reinterpret_cast<sal_Int32*>(pFkp)[nIMax + 1] = nEndFc; // insert FC
+ reinterpret_cast<sal_Int32*>(m_pFkp)[m_nIMax + 1] = nEndFc; // insert FC
- nOldVarLen = static_cast<sal_uInt8>(nVarLen);
+ m_nOldVarLen = static_cast<sal_uInt8>(nVarLen);
if( nVarLen && !nOldP )
{ // insert it for real
- nOldStartGrp = nStartGrp;
+ m_nOldStartGrp = m_nStartGrp;
- nStartGrp = nPos;
- pOfs[nIMax * nItemSize] = static_cast<sal_uInt8>( nStartGrp >> 1 );
+ m_nStartGrp = nPos;
+ m_pOfs[m_nIMax * m_nItemSize] = static_cast<sal_uInt8>( m_nStartGrp >> 1 );
// insert (start-of-data >> 1)
- sal_uInt8 nCnt = static_cast< sal_uInt8 >(CHP == ePlc
+ sal_uInt8 nCnt = static_cast< sal_uInt8 >(CHP == m_ePlc
? ( nVarLen < 256 ) ? static_cast<sal_uInt8>(nVarLen) : 255
: ( ( nVarLen + 1 ) >> 1 ));
- pFkp[ nOffset ] = nCnt; // Enter data length
- memcpy( pFkp + nOffset + 1, pSprms, nVarLen ); // store Sprms
+ m_pFkp[ nOffset ] = nCnt; // Enter data length
+ memcpy( m_pFkp + nOffset + 1, pSprms, nVarLen ); // store Sprms
}
else
{
// do not enter for real ( no Sprms or recurrence )
// start-of-data 0 ( no data ) or recurrence
- pOfs[nIMax * nItemSize] = nOldP;
+ m_pOfs[m_nIMax * m_nItemSize] = nOldP;
}
- nIMax++;
+ m_nIMax++;
return true;
}
void WW8_WrFkp::Combine()
{
- if( bCombined )
+ if( m_bCombined )
return;
- if( nIMax )
- memcpy( pFkp + ( nIMax + 1 ) * 4, pOfs, nIMax * nItemSize );
- delete[] pOfs;
- pOfs = nullptr;
- pFkp[511] = nIMax;
- bCombined = true;
+ if( m_nIMax )
+ memcpy( m_pFkp + ( m_nIMax + 1 ) * 4, m_pOfs, m_nIMax * m_nItemSize );
+ delete[] m_pOfs;
+ m_pOfs = nullptr;
+ m_pFkp[511] = m_nIMax;
+ m_bCombined = true;
#if defined OSL_BIGENDIAN // only the FCs will be rotated here
sal_uInt16 i; // the Sprms must be rotated elsewhere
sal_uInt32* p;
- for( i = 0, p = (sal_uInt32*)pFkp; i <= nIMax; i++, p++ )
+ for( i = 0, p = (sal_uInt32*)m_pFkp; i <= m_nIMax; i++, p++ )
*p = OSL_SWAPDWORD( *p );
#endif // ifdef OSL_BIGENDIAN
}
@@ -1249,8 +1255,8 @@ void WW8_WrFkp::Write( SvStream& rStrm, SwWW8WrGrf& rGrf )
Combine(); // If not already combined
sal_uInt8* p; // search magic for nPicLocFc
- sal_uInt8* pEnd = pFkp + nStartGrp;
- for( p = pFkp + 511 - 4; p >= pEnd; p-- )
+ sal_uInt8* pEnd = m_pFkp + m_nStartGrp;
+ for( p = m_pFkp + 511 - 4; p >= pEnd; p-- )
{
if( *p != GRF_MAGIC_1 ) // search for signature 0x12 0x34 0x56 0xXX
continue;
@@ -1263,40 +1269,40 @@ void WW8_WrFkp::Write( SvStream& rStrm, SwWW8WrGrf& rGrf )
UInt32ToSVBT32( rGrf.GetFPos(), nPos ); // FilePos the graphics
memcpy( p, nPos, 4 ); // patch FilePos over the signature
}
- rStrm.WriteBytes(pFkp, 512);
+ rStrm.WriteBytes(m_pFkp, 512);
}
void WW8_WrFkp::MergeToNew( short& rVarLen, sal_uInt8 *& rpNewSprms )
{
- sal_uInt8 nStart = pOfs[ (nIMax-1) * nItemSize ];
+ sal_uInt8 nStart = m_pOfs[ (m_nIMax-1) * m_nItemSize ];
if( !nStart )
return;
// has Sprms
- sal_uInt8* p = pFkp + ( static_cast<sal_uInt16>(nStart) << 1 );
+ sal_uInt8* p = m_pFkp + ( o3tl::narrowing<sal_uInt16>(nStart) << 1 );
// old and new equal? Then copy only one into the new sprms
- if( nOldVarLen == rVarLen && !memcmp( p+1, rpNewSprms, nOldVarLen ))
+ if( m_nOldVarLen == rVarLen && !memcmp( p+1, rpNewSprms, m_nOldVarLen ))
{
- sal_uInt8* pNew = new sal_uInt8[ nOldVarLen ];
- memcpy( pNew, p+1, nOldVarLen );
+ sal_uInt8* pNew = new sal_uInt8[ m_nOldVarLen ];
+ memcpy( pNew, p+1, m_nOldVarLen );
rpNewSprms = pNew;
}
else
{
- sal_uInt8* pNew = new sal_uInt8[ nOldVarLen + rVarLen ];
- memcpy( pNew, p+1, nOldVarLen );
- memcpy( pNew + nOldVarLen, rpNewSprms, rVarLen );
+ sal_uInt8* pNew = new sal_uInt8[ m_nOldVarLen + rVarLen ];
+ memcpy( pNew, p+1, m_nOldVarLen );
+ memcpy( pNew + m_nOldVarLen, rpNewSprms, rVarLen );
rpNewSprms = pNew;
- rVarLen = rVarLen + nOldVarLen;
+ rVarLen = rVarLen + m_nOldVarLen;
}
- --nIMax;
+ --m_nIMax;
// if this Sprms don't used from others, remove it
bool bFnd = false;
- for (sal_uInt16 n = 0; n < nIMax; ++n)
+ for (sal_uInt16 n = 0; n < m_nIMax; ++n)
{
- if (nStart == pOfs[n * nItemSize])
+ if (nStart == m_pOfs[n * m_nItemSize])
{
bFnd = true;
break;
@@ -1304,8 +1310,8 @@ void WW8_WrFkp::MergeToNew( short& rVarLen, sal_uInt8 *& rpNewSprms )
}
if (!bFnd)
{
- nStartGrp = nOldStartGrp;
- memset( p, 0, nOldVarLen+1 );
+ m_nStartGrp = m_nOldStartGrp;
+ memset( p, 0, m_nOldVarLen+1 );
}
}
@@ -1314,23 +1320,23 @@ WW8_FC WW8_WrFkp::GetStartFc() const
// when bCombined, then the array beginning with pFkp is already byte-swapped
// to LittleEndian, so to extract the start and end positions they must
// be swapped back.
- if( bCombined )
- return SVBT32ToUInt32( pFkp ); // 0. Element
- return reinterpret_cast<sal_Int32*>(pFkp)[0];
+ if( m_bCombined )
+ return SVBT32ToUInt32( m_pFkp ); // 0. Element
+ return reinterpret_cast<sal_Int32*>(m_pFkp)[0];
}
WW8_FC WW8_WrFkp::GetEndFc() const
{
- if( bCombined )
- return SVBT32ToUInt32( &(pFkp[nIMax*4]) ); // nIMax-th SVBT32-Element
- return reinterpret_cast<sal_Int32*>(pFkp)[nIMax];
+ if( m_bCombined )
+ return SVBT32ToUInt32( &(m_pFkp[m_nIMax*4]) ); // nIMax-th SVBT32-Element
+ return reinterpret_cast<sal_Int32*>(m_pFkp)[m_nIMax];
}
// Method for managing the piece table
WW8_WrPct::WW8_WrPct(WW8_FC nfcMin)
- : nOldFc(nfcMin)
+ : m_nOldFc(nfcMin)
{
- AppendPc(nOldFc);
+ AppendPc(m_nOldFc);
}
WW8_WrPct::~WW8_WrPct()
@@ -1340,14 +1346,14 @@ WW8_WrPct::~WW8_WrPct()
// Fill the piece and create a new one
void WW8_WrPct::AppendPc(WW8_FC nStartFc)
{
- WW8_CP nStartCp = nStartFc - nOldFc; // subtract the beginning of the text
+ WW8_CP nStartCp = nStartFc - m_nOldFc; // subtract the beginning of the text
if ( !nStartCp && !m_Pcts.empty())
{
OSL_ENSURE(1 == m_Pcts.size(), "empty Piece!");
m_Pcts.pop_back();
}
- nOldFc = nStartFc; // remember StartFc as old
+ m_nOldFc = nStartFc; // remember StartFc as old
nStartCp >>= 1; // for Unicode: number of characters / 2
@@ -1364,37 +1370,37 @@ void WW8_WrPct::WritePc( WW8Export& rWrt )
sal_uInt64 nPctStart;
sal_uLong nOldPos, nEndPos;
- nPctStart = rWrt.pTableStrm->Tell(); // Start piece table
- rWrt.pTableStrm->WriteChar( char(0x02) ); // Status byte PCT
+ nPctStart = rWrt.m_pTableStrm->Tell(); // Start piece table
+ rWrt.m_pTableStrm->WriteChar( char(0x02) ); // Status byte PCT
nOldPos = nPctStart + 1; // remember Position
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 ); // then the length
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, 0 ); // then the length
for (auto const& it : m_Pcts) // ranges
{
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, it->GetStartCp() );
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, it->GetStartCp() );
}
// calculate the last Pos
- sal_uLong nStartCp = rWrt.pFib->m_fcMac - nOldFc;
+ sal_uLong nStartCp = rWrt.m_pFib->m_fcMac - m_nOldFc;
nStartCp >>= 1; // For Unicode: number of characters / 2
nStartCp += m_Pcts.back()->GetStartCp();
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, nStartCp );
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, nStartCp );
// piece references
for (auto const& it : m_Pcts)
{
- SwWW8Writer::WriteShort(*rWrt.pTableStrm, it->GetStatus());
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, it->GetStartFc());
- SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0); // PRM=0
+ SwWW8Writer::WriteShort(*rWrt.m_pTableStrm, it->GetStatus());
+ SwWW8Writer::WriteLong(*rWrt.m_pTableStrm, it->GetStartFc());
+ SwWW8Writer::WriteShort( *rWrt.m_pTableStrm, 0); // PRM=0
}
// entries in the FIB
- rWrt.pFib->m_fcClx = nPctStart;
- nEndPos = rWrt.pTableStrm->Tell();
- rWrt.pFib->m_lcbClx = nEndPos - nPctStart;
+ rWrt.m_pFib->m_fcClx = nPctStart;
+ nEndPos = rWrt.m_pTableStrm->Tell();
+ rWrt.m_pFib->m_lcbClx = nEndPos - nPctStart;
// and register the length as well
- SwWW8Writer::WriteLong( *rWrt.pTableStrm, nOldPos,
+ SwWW8Writer::WriteLong( *rWrt.m_pTableStrm, nOldPos,
nEndPos - nPctStart-5 );
}
@@ -1407,23 +1413,24 @@ void WW8_WrPct::SetParaBreak()
WW8_CP WW8_WrPct::Fc2Cp( sal_uLong nFc ) const
{
- OSL_ENSURE( nFc >= o3tl::make_unsigned(nOldFc), "FilePos lies in front of last piece" );
+ OSL_ENSURE( nFc >= o3tl::make_unsigned(m_nOldFc), "FilePos lies in front of last piece" );
OSL_ENSURE( ! m_Pcts.empty(), "Fc2Cp no piece available" );
- nFc -= nOldFc;
+ nFc -= m_nOldFc;
nFc /= 2; // Unicode
return nFc + m_Pcts.back()->GetStartCp();
}
-void WW8Export::AppendBookmarks( const SwTextNode& rNd, sal_Int32 nCurrentPos, sal_Int32 nLen )
+void WW8Export::AppendBookmarks( const SwTextNode& rNd, sal_Int32 nCurrentPos, sal_Int32 nLen, const SwRedlineData* /*pRedlineData*/ )
{
std::vector< const ::sw::mark::IMark* > aArr;
- sal_uInt16 nContent;
+ sal_Int32 nContent;
const sal_Int32 nCurrentEnd = nCurrentPos + nLen;
if( !GetWriter().GetBookmarks( rNd, nCurrentPos, nCurrentEnd, aArr ))
return;
- sal_uLong nNd = rNd.GetIndex(), nSttCP = Fc2Cp( Strm().Tell() );
+ SwNodeOffset nNd = rNd.GetIndex();
+ sal_uLong nSttCP = Fc2Cp( Strm().Tell() );
for(const ::sw::mark::IMark* p : aArr)
{
const ::sw::mark::IMark& rBkmk = *p;
@@ -1434,25 +1441,25 @@ void WW8Export::AppendBookmarks( const SwTextNode& rNd, sal_Int32 nCurrentPos, s
const SwPosition* pOPos = nullptr;
if(rBkmk.IsExpanded())
pOPos = &rBkmk.GetOtherMarkPos();
- if( pOPos && pOPos->nNode == pPos->nNode &&
- pOPos->nContent < pPos->nContent )
+ if( pOPos && pOPos->GetNode() == pPos->GetNode() &&
+ pOPos->GetContentIndex() < pPos->GetContentIndex() )
{
pPos = pOPos;
pOPos = &rBkmk.GetMarkPos();
}
- if( !pOPos || ( nNd == pPos->nNode.GetIndex() &&
- ( nContent = pPos->nContent.GetIndex() ) >= nCurrentPos &&
+ if( !pOPos || ( nNd == pPos->GetNodeIndex() &&
+ ( nContent = pPos->GetContentIndex() ) >= nCurrentPos &&
nContent < nCurrentEnd ) )
{
- sal_uLong nCp = nSttCP + pPos->nContent.GetIndex() - nCurrentPos;
+ sal_uLong nCp = nSttCP + pPos->GetContentIndex() - nCurrentPos;
m_pBkmks->Append(nCp, BookmarkToWord(rBkmk.GetName()));
}
- if( pOPos && nNd == pOPos->nNode.GetIndex() &&
- ( nContent = pOPos->nContent.GetIndex() ) >= nCurrentPos &&
+ if( pOPos && nNd == pOPos->GetNodeIndex() &&
+ ( nContent = pOPos->GetContentIndex() ) >= nCurrentPos &&
nContent < nCurrentEnd )
{
- sal_uLong nCp = nSttCP + pOPos->nContent.GetIndex() - nCurrentPos;
+ sal_uLong nCp = nSttCP + pOPos->GetContentIndex() - nCurrentPos;
m_pBkmks->Append(nCp, BookmarkToWord(rBkmk.GetName()));
}
}
@@ -1465,7 +1472,7 @@ void WW8Export::AppendAnnotationMarks(const SwWW8AttrIter& rAttrs, sal_Int32 nCu
{
for (const sw::mark::IMark* pMark : aMarks)
{
- const sal_Int32 nStart = pMark->GetMarkStart().nContent.GetIndex();
+ const sal_Int32 nStart = pMark->GetMarkStart().GetContentIndex();
if (nStart == nCurrentPos)
{
m_pAtn->AddRangeStartPosition(pMark->GetName(), Fc2Cp(Strm().Tell()),
@@ -1492,13 +1499,13 @@ void WW8Export::MoveFieldMarks(WW8_CP nFrom, WW8_CP nTo)
void WW8Export::AppendBookmark( const OUString& rName )
{
- sal_uLong nSttCP = Fc2Cp( Strm().Tell() );
+ sal_uInt64 nSttCP = Fc2Cp( Strm().Tell() );
m_pBkmks->Append( nSttCP, rName );
}
void WW8Export::AppendBookmarkEndWithCorrection( const OUString& rName )
{
- sal_uLong nEndCP = Fc2Cp( Strm().Tell() );
+ sal_uInt64 nEndCP = Fc2Cp( Strm().Tell() );
m_pBkmks->Append( nEndCP - 1, rName );
}
@@ -1511,7 +1518,7 @@ std::unique_ptr<SvxBrushItem> MSWordExportBase::getBackground()
if (SfxItemState::SET == eState)
{
// The 'color' is set for the first page style - take it and use it as the background color of the entire DOCX
- if (aBrush->GetColor() != COL_AUTO)
+ if (aBrush->GetColor() != COL_AUTO || aBrush->GetGraphicObject())
return aBrush;
}
return nullptr;
@@ -1597,12 +1604,12 @@ void WW8Export::ExportGrfBullet(const SwTextNode& rNd)
static sal_uInt8 nAttrMagicIdx = 0;
void WW8Export::OutGrfBullets(const ww8::Frame & rFrame)
{
- if ( !m_pGrf || !m_pChpPlc || !pO )
+ if ( !m_pGrf || !m_pChpPlc || !m_pO )
return;
m_pGrf->Insert(rFrame);
- m_pChpPlc->AppendFkpEntry( Strm().Tell(), pO->size(), pO->data() );
- pO->clear();
+ m_pChpPlc->AppendFkpEntry( Strm().Tell(), m_pO->size(), m_pO->data() );
+ m_pO->clear();
// if links...
WriteChar( char(1) );
@@ -1649,15 +1656,15 @@ int MSWordExportBase::GetGrfIndex(const SvxBrushItem& rBrush)
void WW8_WrtRedlineAuthor::Write( Writer& rWrt )
{
WW8Export & rWW8Wrt = *(static_cast<SwWW8Writer&>(rWrt).m_pExport);
- rWW8Wrt.WriteAsStringTable(maAuthors, rWW8Wrt.pFib->m_fcSttbfRMark,
- rWW8Wrt.pFib->m_lcbSttbfRMark);
+ rWW8Wrt.WriteAsStringTable(maAuthors, rWW8Wrt.m_pFib->m_fcSttbfRMark,
+ rWW8Wrt.m_pFib->m_lcbSttbfRMark);
}
sal_uInt16 WW8Export::AddRedlineAuthor( std::size_t nId )
{
if( !m_pRedlAuthors )
{
- m_pRedlAuthors = new WW8_WrtRedlineAuthor;
+ m_pRedlAuthors.reset(new WW8_WrtRedlineAuthor);
m_pRedlAuthors->AddName("Unknown");
}
return m_pRedlAuthors->AddName( SW_MOD()->GetRedlineAuthor( nId ) );
@@ -1672,7 +1679,7 @@ void WW8Export::WriteAsStringTable(const std::vector<OUString>& rStrings,
// we have some Redlines found in the document -> the
// Author Name Stringtable
- SvStream& rStrm = *pTableStrm;
+ SvStream& rStrm = *m_pTableStrm;
rfcSttbf = rStrm.Tell();
SwWW8Writer::WriteShort( rStrm, -1 );
SwWW8Writer::WriteLong( rStrm, nCount );
@@ -1794,13 +1801,13 @@ void WW8Export::WriteStringAsPara( const OUString& rText )
m_pChpPlc->AppendFkpEntry( nPos );
}
-void MSWordExportBase::WriteSpecialText( sal_uLong nStart, sal_uLong nEnd, sal_uInt8 nTTyp )
+void MSWordExportBase::WriteSpecialText( SwNodeOffset nStart, SwNodeOffset nEnd, sal_uInt8 nTTyp )
{
sal_uInt8 nOldTyp = m_nTextTyp;
m_nTextTyp = nTTyp;
auto const pOldPam = m_pCurPam; //!! Simply shifting the PaM without restoring should do the job too
- sal_uLong nOldStart = m_nCurStart;
- sal_uLong nOldEnd = m_nCurEnd;
+ SwNodeOffset nOldStart = m_nCurStart;
+ SwNodeOffset nOldEnd = m_nCurEnd;
SwPaM* pOldEnd = m_pOrigPam;
bool bOldPageDescs = m_bOutPageDescs;
m_bOutPageDescs = false;
@@ -1815,12 +1822,12 @@ void MSWordExportBase::WriteSpecialText( sal_uLong nStart, sal_uLong nEnd, sal_u
// tdf#106261 Reset table infos, otherwise the depth of the cells will be
// incorrect, in case the header/footer had table(s) and we try to export
// the same table second time.
- ww8::WW8TableInfo::Pointer_t pOldTableInfo = m_pTableInfo;
+ ww8::WW8TableInfo::Pointer_t xOldTableInfo(m_pTableInfo);
m_pTableInfo = std::make_shared<ww8::WW8TableInfo>();
WriteText();
- m_pTableInfo = pOldTableInfo;
+ m_pTableInfo = std::move(xOldTableInfo);
m_bOutPageDescs = bOldPageDescs;
m_pCurPam = pOldPam; // delete Pam
@@ -1872,24 +1879,24 @@ void WW8Export::WriteChar( sal_Unicode c )
Strm().WriteUInt16( c );
}
-void MSWordExportBase::SetCurPam(sal_uLong nStt, sal_uLong nEnd)
+void MSWordExportBase::SetCurPam(SwNodeOffset nStt, SwNodeOffset nEnd)
{
m_nCurStart = nStt;
m_nCurEnd = nEnd;
m_pCurPam = Writer::NewUnoCursor( m_rDoc, nStt, nEnd );
// Recognize tables in special cases
- if ( nStt != m_pCurPam->GetMark()->nNode.GetIndex() &&
+ if ( nStt != m_pCurPam->GetMark()->GetNodeIndex() &&
m_rDoc.GetNodes()[ nStt ]->IsTableNode() )
{
- m_pCurPam->GetMark()->nNode = nStt;
+ m_pCurPam->GetMark()->Assign(nStt);
}
m_pOrigPam = m_pCurPam.get(); // ???
m_pCurPam->Exchange();
}
-void MSWordExportBase::SaveData( sal_uLong nStt, sal_uLong nEnd )
+void MSWordExportBase::SaveData( SwNodeOffset nStt, SwNodeOffset nEnd )
{
MSWordSaveData aData;
@@ -1905,6 +1912,7 @@ void MSWordExportBase::SaveData( sal_uLong nStt, sal_uLong nEnd )
aData.pOldFlyOffset = m_pFlyOffset;
aData.eOldAnchorType = m_eNewAnchorType;
+ aData.bOldWriteAll = false;
aData.bOldOutTable = m_bOutTable;
aData.bOldFlyFrameAttrs = m_bOutFlyFrameAttrs;
aData.bOldStartTOX = m_bStartTOX;
@@ -1944,16 +1952,16 @@ void MSWordExportBase::RestoreData()
m_aSaveData.pop();
}
-void WW8Export::SaveData( sal_uLong nStt, sal_uLong nEnd )
+void WW8Export::SaveData( SwNodeOffset nStt, SwNodeOffset nEnd )
{
MSWordExportBase::SaveData( nStt, nEnd );
MSWordSaveData &rData = m_aSaveData.top();
- if ( !pO->empty() )
+ if ( !m_pO->empty() )
{
- rData.pOOld = std::move(pO);
- pO.reset(new ww::bytes);
+ rData.pOOld = std::move(m_pO);
+ m_pO.reset(new ww::bytes);
}
else
rData.pOOld = nullptr; // reuse pO
@@ -1968,16 +1976,16 @@ void WW8Export::RestoreData()
GetWriter().m_bWriteAll = rData.bOldWriteAll;
- OSL_ENSURE( pO->empty(), "pO is not empty in WW8Export::RestoreData()" );
+ OSL_ENSURE( m_pO->empty(), "pO is not empty in WW8Export::RestoreData()" );
if ( rData.pOOld )
{
- pO = std::move(rData.pOOld);
+ m_pO = std::move(rData.pOOld);
}
MSWordExportBase::RestoreData();
}
-void WW8AttributeOutput::TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
+void WW8AttributeOutput::TableInfoCell(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
sal_uInt32 nDepth = pTableTextNodeInfoInner->getDepth();
@@ -1986,18 +1994,18 @@ void WW8AttributeOutput::TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t pT
/* Cell */
m_rWW8Export.InsUInt16( NS_sprm::PFInTable::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0x1) );
m_rWW8Export.InsUInt16( NS_sprm::PItap::val );
m_rWW8Export.InsUInt32( nDepth );
if ( nDepth > 1 && pTableTextNodeInfoInner->isEndOfCell() )
{
m_rWW8Export.InsUInt16( NS_sprm::PFInnerTableCell::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0x1) );
}
}
-void WW8AttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
+void WW8AttributeOutput::TableInfoRow(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
sal_uInt32 nDepth = pTableTextNodeInfoInner->getDepth();
@@ -2009,12 +2017,12 @@ void WW8AttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTa
return;
m_rWW8Export.InsUInt16( NS_sprm::PFInTable::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0x1) );
if ( nDepth == 1 )
{
m_rWW8Export.InsUInt16( NS_sprm::PFTtp::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0x1) );
}
m_rWW8Export.InsUInt16( NS_sprm::PItap::val );
@@ -2023,9 +2031,9 @@ void WW8AttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTa
if ( nDepth > 1 )
{
m_rWW8Export.InsUInt16( NS_sprm::PFInnerTableCell::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0x1) );
m_rWW8Export.InsUInt16( NS_sprm::PFInnerTtp::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0x1) );
}
// Most of these are per-row definitions, not per-table.
@@ -2071,16 +2079,14 @@ static sal_uInt16 lcl_TCFlags(SwDoc &rDoc, const SwTableBox * pBox, sal_Int32 nR
if(pSttNd)
{
SwNodeIndex aIdx( *pSttNd );
- const SwContentNode * pCNd = pSttNd->GetNodes().GoNext( &aIdx );
+ const SwContentNode* pCNd = SwNodes::GoNext(&aIdx);
if( pCNd && pCNd->IsTextNode())
{
- SfxItemSet aCoreSet(rDoc.GetAttrPool(), svl::Items<RES_CHRATR_ROTATE, RES_CHRATR_ROTATE>{});
+ SfxItemSetFixed<RES_CHRATR_ROTATE, RES_CHRATR_ROTATE> aCoreSet(rDoc.GetAttrPool());
static_cast<const SwTextNode*>(pCNd)->GetParaAttr(aCoreSet,
0, static_cast<const SwTextNode*>(pCNd)->GetText().getLength());
- const SfxPoolItem * pRotItem;
- if ( SfxItemState::SET == aCoreSet.GetItemState(RES_CHRATR_ROTATE, true, &pRotItem))
+ if ( const SvxCharRotateItem * pRotate = aCoreSet.GetItemIfSet(RES_CHRATR_ROTATE))
{
- const SvxCharRotateItem * pRotate = static_cast<const SvxCharRotateItem*>(pRotItem);
if(pRotate && pRotate->GetValue() == 900_deg10)
{
nFlags = nFlags | 0x0004 | 0x0008;
@@ -2097,7 +2103,7 @@ static sal_uInt16 lcl_TCFlags(SwDoc &rDoc, const SwTableBox * pBox, sal_Int32 nR
return nFlags;
}
-void WW8AttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
+void WW8AttributeOutput::TableVerticalCell(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
const SwTableLine * pTabLine = pTabBox->GetUpper();
@@ -2126,14 +2132,14 @@ void WW8AttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_
if (nTextFlow != 0)
{
m_rWW8Export.InsUInt16( NS_sprm::TTextFlow::val );
- m_rWW8Export.pO->push_back( n ); //start range
- m_rWW8Export.pO->push_back( sal_uInt8(n + 1) ); //end range
+ m_rWW8Export.m_pO->push_back( n ); //start range
+ m_rWW8Export.m_pO->push_back( sal_uInt8(n + 1) ); //end range
m_rWW8Export.InsUInt16(nTextFlow);
}
}
}
-void WW8AttributeOutput::TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
+void WW8AttributeOutput::TableCanSplit(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner )
{
const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
const SwTableLine * pTabLine = pTabBox->GetUpper();
@@ -2148,12 +2154,12 @@ void WW8AttributeOutput::TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pT
const SwFormatRowSplit& rSplittable = pLineFormat->GetRowSplit();
sal_uInt8 nCantSplit = (!rSplittable.GetValue()) ? 1 : 0;
m_rWW8Export.InsUInt16( NS_sprm::TFCantSplit::val );
- m_rWW8Export.pO->push_back( nCantSplit );
+ m_rWW8Export.m_pO->push_back( nCantSplit );
m_rWW8Export.InsUInt16( NS_sprm::TFCantSplit90::val ); // also write fCantSplit90
- m_rWW8Export.pO->push_back( nCantSplit );
+ m_rWW8Export.m_pO->push_back( nCantSplit );
}
-void WW8AttributeOutput::TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
+void WW8AttributeOutput::TableBidi(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
const SwTable * pTable = pTableTextNodeInfoInner->getTable();
const SwFrameFormat * pFrameFormat = pTable->GetFrameFormat();
@@ -2165,15 +2171,15 @@ void WW8AttributeOutput::TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTable
}
}
-void WW8AttributeOutput::TableRowRedline( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
+void WW8AttributeOutput::TableRowRedline(const ww8::WW8TableNodeInfoInner::Pointer_t& /*pTableTextNodeInfoInner*/)
{
}
-void WW8AttributeOutput::TableCellRedline( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
+void WW8AttributeOutput::TableCellRedline(const ww8::WW8TableNodeInfoInner::Pointer_t& /*pTableTextNodeInfoInner*/)
{
}
-void WW8AttributeOutput::TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
+void WW8AttributeOutput::TableHeight(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
const SwTableLine * pTabLine = pTabBox->GetUpper();
@@ -2193,12 +2199,12 @@ void WW8AttributeOutput::TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTab
if ( nHeight )
{
m_rWW8Export.InsUInt16( NS_sprm::TDyaRowHeight::val );
- m_rWW8Export.InsUInt16( static_cast<sal_uInt16>(nHeight) );
+ m_rWW8Export.InsUInt16( o3tl::narrowing<sal_uInt16>(nHeight) );
}
}
-void WW8AttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
+void WW8AttributeOutput::TableOrientation(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
const SwTable * pTable = pTableTextNodeInfoInner->getTable();
@@ -2260,7 +2266,7 @@ void WW8AttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t
}
}
-void WW8AttributeOutput::TableSpacing(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner)
+void WW8AttributeOutput::TableSpacing(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
const SwTable * pTable = pTableTextNodeInfoInner->getTable();
const SwTableFormat* pTableFormat = pTable->GetFrameFormat();
@@ -2282,7 +2288,7 @@ void WW8AttributeOutput::TableSpacing(ww8::WW8TableNodeInfoInner::Pointer_t pTab
sal_uInt8 const nTPc = (nPadding << 4) | (nPcVert << 2) | nPcHorz;
m_rWW8Export.InsUInt16(NS_sprm::TPc::val);
- m_rWW8Export.pO->push_back( nTPc );
+ m_rWW8Export.m_pO->push_back( nTPc );
m_rWW8Export.InsUInt16(NS_sprm::TDyaAbs::val);
m_rWW8Export.InsUInt16(rUL.GetUpper());
@@ -2298,14 +2304,129 @@ void WW8AttributeOutput::TableSpacing(ww8::WW8TableNodeInfoInner::Pointer_t pTab
}
}
-void WW8AttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
+void WW8AttributeOutput::TablePositioning(SwFrameFormat* pFlyFormat)
+{
+ if (!pFlyFormat || !pFlyFormat->GetFlySplit().GetValue())
+ {
+ return;
+ }
+
+ sal_uInt8 nPcVert = 0;
+ switch (pFlyFormat->GetVertOrient().GetRelationOrient())
+ {
+ case text::RelOrientation::PAGE_PRINT_AREA:
+ // relative to margin
+ nPcVert = 0;
+ break;
+ case text::RelOrientation::PAGE_FRAME:
+ // relative to page
+ nPcVert = 1;
+ break;
+ default:
+ // text::RelOrientation::FRAME
+ // relative to text
+ nPcVert = 2;
+ break;
+ }
+ sal_uInt8 nPcHorz = 0;
+ switch (pFlyFormat->GetHoriOrient().GetRelationOrient())
+ {
+ case text::RelOrientation::FRAME:
+ // relative to column
+ nPcHorz = 0;
+ break;
+ case text::RelOrientation::PAGE_PRINT_AREA:
+ // relative to margin
+ nPcHorz = 1;
+ break;
+ default:
+ // text::RelOrientation::PAGE_FRAME
+ // relative to page
+ nPcHorz = 2;
+ break;
+ }
+ sal_uInt8 nTPc = (nPcVert << 4) | (nPcHorz << 6);
+ m_rWW8Export.InsUInt16(NS_sprm::TPc::val);
+ m_rWW8Export.m_pO->push_back(nTPc);
+
+ // Similar to WW8AttributeOutput::FormatHorizOrientation(), but for tables.
+ sal_Int16 nTDxaAbs = 0;
+ switch (pFlyFormat->GetHoriOrient().GetHoriOrient())
+ {
+ case text::HoriOrientation::LEFT:
+ // left
+ nTDxaAbs = 0;
+ break;
+ case text::HoriOrientation::CENTER:
+ // centered
+ nTDxaAbs = -4;
+ break;
+ case text::HoriOrientation::RIGHT:
+ // right
+ nTDxaAbs = -8;
+ break;
+ default:
+ nTDxaAbs = pFlyFormat->GetHoriOrient().GetPos();
+ break;
+ }
+ m_rWW8Export.InsUInt16(NS_sprm::TDxaAbs::val);
+ m_rWW8Export.InsInt16(nTDxaAbs);
+
+ // Similar to WW8AttributeOutput::FormatVertOrientation(), but for tables.
+ sal_Int16 nTDyaAbs = 0;
+ switch (pFlyFormat->GetVertOrient().GetVertOrient())
+ {
+ case text::VertOrientation::TOP:
+ // up
+ nTDyaAbs = -4;
+ break;
+ case text::VertOrientation::CENTER:
+ // centered
+ nTDyaAbs = -8;
+ break;
+ case text::VertOrientation::BOTTOM:
+ // down
+ nTDyaAbs = -12;
+ break;
+ default:
+ nTDyaAbs = pFlyFormat->GetVertOrient().GetPos();
+ break;
+ }
+ m_rWW8Export.InsUInt16(NS_sprm::TDyaAbs::val);
+ m_rWW8Export.InsInt16(nTDyaAbs);
+
+ // Similar to WW8AttributeOutput::FormatULSpace(), but for tables.
+ sal_uInt16 nDyaFromText = pFlyFormat->GetULSpace().GetUpper();
+ m_rWW8Export.InsUInt16(NS_sprm::TDyaFromText::val);
+ m_rWW8Export.InsUInt16(nDyaFromText);
+ sal_uInt16 nDyaFromTextBottom = pFlyFormat->GetULSpace().GetLower();
+ m_rWW8Export.InsUInt16(NS_sprm::TDyaFromTextBottom::val);
+ m_rWW8Export.InsUInt16(nDyaFromTextBottom);
+
+ // Similar to WW8AttributeOutput::FormatLRSpace(), but for tables.
+ sal_uInt16 nDxaFromText = pFlyFormat->GetLRSpace().GetLeft();
+ m_rWW8Export.InsUInt16(NS_sprm::TDxaFromText::val);
+ m_rWW8Export.InsUInt16(nDxaFromText);
+ sal_uInt16 nDxaFromTextRight = pFlyFormat->GetLRSpace().GetRight();
+ m_rWW8Export.InsUInt16(NS_sprm::TDxaFromTextRight::val);
+ m_rWW8Export.InsUInt16(nDxaFromTextRight);
+
+ if (!pFlyFormat->GetWrapInfluenceOnObjPos().GetAllowOverlap())
+ {
+ // Allowing overlap is the default in both Writer and in WW8.
+ m_rWW8Export.InsUInt16(NS_sprm::TFNoAllowOverlap::val);
+ m_rWW8Export.m_pO->push_back(1);
+ }
+}
+
+void WW8AttributeOutput::TableDefinition(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
const SwTable * pTable = pTableTextNodeInfoInner->getTable();
if ( pTable->GetRowsToRepeat() > pTableTextNodeInfoInner->getRow() )
{
m_rWW8Export.InsUInt16( NS_sprm::TTableHeader::val );
- m_rWW8Export.pO->push_back( 1 );
+ m_rWW8Export.m_pO->push_back( 1 );
}
ww8::TableBoxVectorPtr pTableBoxes =
@@ -2320,7 +2441,7 @@ void WW8AttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
m_rWW8Export.InsUInt16( nSprmSize ); // length
// number of boxes
- m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(nBoxes) );
+ m_rWW8Export.m_pO->push_back( static_cast<sal_uInt8>(nBoxes) );
/* cells */
/*
@@ -2378,9 +2499,9 @@ void WW8AttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
ww8::GridColsPtr pGridCols = GetGridCols( pTableTextNodeInfoInner );
for ( const auto nCol : *pGridCols )
- {
- m_rWW8Export.InsUInt16( static_cast<sal_uInt16>(nCol) + nTableOffset );
- }
+ {
+ m_rWW8Export.InsUInt16( o3tl::narrowing<sal_uInt16>(nCol) + nTableOffset );
+ }
/* TCs */
ww8::RowSpansPtr pRowSpans = pTableTextNodeInfoInner->getRowSpansOfRow();
@@ -2388,7 +2509,7 @@ void WW8AttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
for (const SwTableBox * pTabBox1 : *pTableBoxes)
{
- sal_uInt16 npOCount = m_rWW8Export.pO->size();
+ sal_uInt16 npOCount = m_rWW8Export.m_pO->size();
const SwFrameFormat * pBoxFormat = nullptr;
if (pTabBox1 != nullptr)
@@ -2400,28 +2521,36 @@ void WW8AttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
static sal_uInt8 aNullBytes[] = { 0x0, 0x0 };
- m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), aNullBytes, aNullBytes+2 ); // dummy
+ m_rWW8Export.m_pO->insert( m_rWW8Export.m_pO->end(), aNullBytes, aNullBytes+2 ); // dummy
if (pBoxFormat != nullptr)
{
const SvxBoxItem & rBoxItem = pBoxFormat->GetBox();
- WW8Export::Out_SwFormatTableBox( *m_rWW8Export.pO, &rBoxItem ); // 8/16 Byte
+ WW8Export::Out_SwFormatTableBox( *m_rWW8Export.m_pO, &rBoxItem ); // 8/16 Byte
}
else
- WW8Export::Out_SwFormatTableBox( *m_rWW8Export.pO, nullptr); // 8/16 Byte
+ WW8Export::Out_SwFormatTableBox( *m_rWW8Export.m_pO, nullptr); // 8/16 Byte
- SAL_INFO( "sw.ww8.level2", "<tclength>" << ( m_rWW8Export.pO->size() - npOCount ) << "</tclength>" );
+ SAL_INFO( "sw.ww8.level2", "<tclength>" << ( m_rWW8Export.m_pO->size() - npOCount ) << "</tclength>" );
++aItRowSpans;
}
int nWidthPercent = pFormat->GetFrameSize().GetWidthPercent();
+
+ // The best fit for "automatic" table placement is relative 100%
+ if (!nWidthPercent && rHori.GetHoriOrient() == text::HoriOrientation::FULL)
+ nWidthPercent = 100;
+
// Width is in fiftieths of a percent. For sprmTTableWidth, must be non-negative and 600% max
if ( nWidthPercent > 0 && nWidthPercent <= 600 )
{
m_rWW8Export.InsUInt16( NS_sprm::TTableWidth::val );
- m_rWW8Export.pO->push_back( sal_uInt8/*ftsPercent*/ (2) );
- m_rWW8Export.InsUInt16( static_cast<sal_uInt16>(nWidthPercent) * 50 );
+ m_rWW8Export.m_pO->push_back( sal_uInt8/*ftsPercent*/ (2) );
+ m_rWW8Export.InsUInt16( o3tl::narrowing<sal_uInt16>(nWidthPercent) * 50 );
}
+
+ // Write table positioning properties in case this is a floating table.
+ TablePositioning(pTable->GetTableNode()->GetFlyFormat());
}
ww8::GridColsPtr AttributeOutputBase::GetGridCols( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner )
@@ -2512,7 +2641,7 @@ void AttributeOutputBase::GetTablePageSize( ww8::WW8TableNodeInfoInner const * p
rRelBoxSize = bRelBoxSize;
}
-void WW8AttributeOutput::TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
+void WW8AttributeOutput::TableDefaultBorders( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner )
{
// This function name is misleading because it is not a table default, but a row default,
// and it also only sets default cell margins (aka border padding).
@@ -2529,14 +2658,14 @@ void WW8AttributeOutput::TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointe
// Set row default cell margins using this last cell in the row
for ( int i = 0; i < 4; ++i )
{
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::TCellPaddingDefault::val );
- m_rWW8Export.pO->push_back( sal_uInt8(6) );
- m_rWW8Export.pO->push_back( sal_uInt8(0) );
- m_rWW8Export.pO->push_back( sal_uInt8(1) );
- m_rWW8Export.pO->push_back( sal_uInt8(1 << i) );
- m_rWW8Export.pO->push_back( sal_uInt8(3) );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::TCellPaddingDefault::val );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(6) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(1) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(1 << i) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(3) );
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO,
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO,
pFrameFormat->GetBox().GetDistance( aBorders[i] ) );
}
}
@@ -2590,7 +2719,7 @@ void WW8AttributeOutput::TableCellBorders(
sal_uInt8 nSideBits[4] = {0, 0, 0, 0}; // 0001:top, 0010:left, 0100:bottom, 1000:right
for ( int i = 0; i < 4; ++i ) // sides: top, left, bottom, right
{
- nMargin[i] = std::min(sal_uInt16(31680), pLastBox->GetDistance( aBorders[i] ));
+ nMargin[i] = std::min(sal_Int16(31680), pLastBox->GetDistance( aBorders[i] ));
if ( nMargin[i] == nDefaultMargin[i] )
continue;
@@ -2610,13 +2739,13 @@ void WW8AttributeOutput::TableCellBorders(
{
if ( nSideBits[i] )
{
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::TCellPadding::val );
- m_rWW8Export.pO->push_back( sal_uInt8(6) ); // 6 bytes
- m_rWW8Export.pO->push_back( sal_uInt8(nSeqStart) ); // first cell: apply margin
- m_rWW8Export.pO->push_back( sal_uInt8(n) ); // end cell: do not apply margin
- m_rWW8Export.pO->push_back( sal_uInt8(nSideBits[i]) );
- m_rWW8Export.pO->push_back( sal_uInt8(3) ); // FtsDxa: size in twips
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, nMargin[i] );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::TCellPadding::val );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(6) ); // 6 bytes
+ m_rWW8Export.m_pO->push_back( sal_uInt8(nSeqStart) ); // first cell: apply margin
+ m_rWW8Export.m_pO->push_back( sal_uInt8(n) ); // end cell: do not apply margin
+ m_rWW8Export.m_pO->push_back( sal_uInt8(nSideBits[i]) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(3) ); // FtsDxa: size in twips
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, nMargin[i] );
}
}
@@ -2626,7 +2755,7 @@ void WW8AttributeOutput::TableCellBorders(
}
}
-void WW8AttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
+void WW8AttributeOutput::TableBackgrounds(const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner)
{
const SwTable * pTab = pTableTextNodeInfoInner->getTable();
const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
@@ -2635,7 +2764,7 @@ void WW8AttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t
sal_uInt8 nBoxes = rTabBoxes.size();
m_rWW8Export.InsUInt16( NS_sprm::TDefTableShd80::val );
- m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(nBoxes * 2) ); // Len
+ m_rWW8Export.m_pO->push_back( static_cast<sal_uInt8>(nBoxes * 2) ); // Len
Color aRowColor = COL_AUTO;
const SvxBrushItem *pTableColorProp = pTab->GetFrameFormat()->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
@@ -2701,7 +2830,7 @@ void WW8AttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t
break;
m_rWW8Export.InsUInt16( m );
- m_rWW8Export.pO->push_back( static_cast<sal_uInt8>((nStop-nStart) * 10) );
+ m_rWW8Export.m_pO->push_back( static_cast<sal_uInt8>((nStop-nStart) * 10) );
for ( sal_uInt8 n = nStart; n < nStop; n++ )
{
@@ -2738,9 +2867,9 @@ class TrackContentToExport
{
private:
SwPaM *m_pCurPam;
- sal_uLong m_nStart, m_nEnd;
+ SwNodeOffset m_nStart, m_nEnd;
public:
- TrackContentToExport(SwPaM *pCurPam, sal_uLong nCurStart, sal_uLong nCurEnd)
+ TrackContentToExport(SwPaM *pCurPam, SwNodeOffset nCurStart, SwNodeOffset nCurEnd)
: m_pCurPam(pCurPam)
, m_nStart(nCurStart)
, m_nEnd(nCurEnd)
@@ -2749,9 +2878,9 @@ public:
bool contentRemainsToExport(ww8::WW8TableInfo *pTableInfo)
{
- bool bSimpleContentRemains = m_pCurPam->GetPoint()->nNode < m_pCurPam->GetMark()->nNode ||
- (m_pCurPam->GetPoint()->nNode == m_pCurPam->GetMark()->nNode &&
- m_pCurPam->GetPoint()->nContent.GetIndex() <= m_pCurPam->GetMark()->nContent.GetIndex());
+ bool bSimpleContentRemains = m_pCurPam->GetPoint()->GetNode() < m_pCurPam->GetMark()->GetNode() ||
+ (m_pCurPam->GetPoint()->GetNode() == m_pCurPam->GetMark()->GetNode() &&
+ m_pCurPam->GetPoint()->GetContentIndex() <= m_pCurPam->GetMark()->GetContentIndex());
if (bSimpleContentRemains)
return true;
@@ -2763,7 +2892,7 @@ public:
//skipped cell to output it in a sane sequence. See ooo47778-3.sxw for one of these
//horrors. So if we are at the end of the selection, but this end point is a table
//cell whose next cell is in the selection allow jumping back to it
- const SwNode* pCurrentNode = &m_pCurPam->GetPoint()->nNode.GetNode();
+ const SwNode* pCurrentNode = &m_pCurPam->GetPoint()->GetNode();
const SwNode* pNextNode = pTableInfo->getNextNode(pCurrentNode);
if (pNextNode && pCurrentNode != pNextNode)
@@ -2783,7 +2912,7 @@ void MSWordExportBase::WriteText()
TrackContentToExport aContentTracking(m_pCurPam.get(), m_nCurStart, m_nCurEnd);
while (aContentTracking.contentRemainsToExport(m_pTableInfo.get()))
{
- SwNode& rNd = m_pCurPam->GetNode();
+ SwNode& rNd = m_pCurPam->GetPointNode();
// no section breaks exported for Endnotes
if ( rNd.IsTextNode() && m_nTextTyp != TXT_EDN && m_nTextTyp != TXT_FTN )
@@ -2805,7 +2934,7 @@ void MSWordExportBase::WriteText()
if ( pTemp )
m_pCurrentPageDesc = pTemp;
- m_pCurPam->GetPoint()->nContent.Assign( pCNd, 0 );
+ m_pCurPam->GetPoint()->SetContent( 0 );
OutputContentNode( *pCNd );
}
else if ( rNd.IsTableNode() )
@@ -2838,9 +2967,10 @@ void MSWordExportBase::WriteText()
SwTextNode *pTempNext = aIdx.GetNode().GetTextNode();
if ( pTempNext )
{
- const SfxPoolItem * pTempItem = nullptr;
- if (pTempNext->GetpSwAttrSet() && SfxItemState::SET == pTempNext->GetpSwAttrSet()->GetItemState(RES_PAGEDESC, false, &pTempItem)
- && pTempItem && static_cast<const SwFormatPageDesc*>(pTempItem)->GetRegisteredIn())
+ const SwFormatPageDesc * pTempItem = nullptr;
+ if (pTempNext->GetpSwAttrSet()
+ && (pTempItem = pTempNext->GetpSwAttrSet()->GetItemIfSet(RES_PAGEDESC, false))
+ && pTempItem->GetRegisteredIn())
{
//Next node has a new page style which means this node is a section end. Do not insert another page/section break here
bNeedExportBreakHere = false;
@@ -2902,7 +3032,7 @@ void MSWordExportBase::WriteText()
if ( &rNd == &rNd.GetNodes().GetEndOfContent() )
break;
- const SwNode * pCurrentNode = &m_pCurPam->GetPoint()->nNode.GetNode();
+ const SwNode * pCurrentNode = &m_pCurPam->GetPoint()->GetNode();
const SwNode * pNextNode = m_pTableInfo->getNextNode(pCurrentNode);
if (pCurrentNode == pNextNode)
@@ -2912,12 +3042,12 @@ void MSWordExportBase::WriteText()
}
if (pNextNode != nullptr)
- m_pCurPam->GetPoint()->nNode.Assign(*pNextNode);
+ m_pCurPam->GetPoint()->Assign(*pNextNode);
else
- ++m_pCurPam->GetPoint()->nNode;
+ m_pCurPam->GetPoint()->Adjust(SwNodeOffset(1));
- sal_uLong nPos = m_pCurPam->GetPoint()->nNode.GetIndex();
- ::SetProgressState( nPos, m_pCurPam->GetDoc().GetDocShell() );
+ SwNodeOffset nPos = m_pCurPam->GetPoint()->GetNodeIndex();
+ ::SetProgressState( sal_Int32(nPos), m_pCurPam->GetDoc().GetDocShell() );
}
SAL_INFO( "sw.ww8.level2", "</WriteText>" );
@@ -2927,24 +3057,24 @@ void WW8Export::WriteMainText()
{
SAL_INFO( "sw.ww8.level2", "<WriteMainText>" );
- pFib->m_fcMin = Strm().Tell();
+ m_pFib->m_fcMin = Strm().Tell();
- m_pCurPam->GetPoint()->nNode = m_rDoc.GetNodes().GetEndOfContent().StartOfSectionNode()->GetIndex();
+ m_pCurPam->GetPoint()->Assign(*m_rDoc.GetNodes().GetEndOfContent().StartOfSectionNode());
WriteText();
- if( 0 == Strm().Tell() - pFib->m_fcMin ) // no text ?
+ if( 0 == Strm().Tell() - m_pFib->m_fcMin ) // no text ?
WriteCR(); // then CR at the end ( otherwise WW will complain )
- pFib->m_ccpText = Fc2Cp( Strm().Tell() );
- m_pFieldMain->Finish( pFib->m_ccpText, 0 );
+ m_pFib->m_ccpText = Fc2Cp( Strm().Tell() );
+ m_pFieldMain->Finish( m_pFib->m_ccpText, 0 );
// ccpText includes Footnote and KF-text
// therefore pFib->ccpText may get updated as well
// save the StyleId of the last paragraph. Because WW97 take the style
// from the last CR, that will be written after footer/Header/footnotes/
// annotation etc.
- const SwTextNode* pLastNd = m_pCurPam->GetMark()->nNode.GetNode().GetTextNode();
+ const SwTextNode* pLastNd = m_pCurPam->GetMark()->GetNode().GetTextNode();
if( pLastNd )
m_nLastFormatId = GetId( static_cast<SwTextFormatColl&>(pLastNd->GetAnyFormatColl()) );
@@ -2957,7 +3087,7 @@ bool MSWordExportBase::IsInTable() const
if (m_pCurPam != nullptr)
{
- SwNode& rNode = m_pCurPam->GetNode();
+ SwNode& rNode = m_pCurPam->GetPointNode();
if (m_pTableInfo)
{
@@ -2983,18 +3113,18 @@ void WW8Export::WriteFkpPlcUsw()
// output into WordDocument stream
m_pChpPlc->WriteFkps(); // Fkp.Chpx
m_pPapPlc->WriteFkps(); // Fkp.Papx
- pSepx->WriteSepx( Strm() ); // Sepx
+ m_pSepx->WriteSepx( Strm() ); // Sepx
// output into Table stream
m_pStyles->OutputStylesTable(); // for WW8 StyleTab
- pFootnote->WritePlc( *this ); // Footnote-Ref & Text Plc
- pEdn->WritePlc( *this ); // Endnote-Ref & Text Plc
+ m_pFootnote->WritePlc( *this ); // Footnote-Ref & Text Plc
+ m_pEdn->WritePlc( *this ); // Endnote-Ref & Text Plc
m_pTextBxs->WritePlc( *this ); // Textbox Text Plc
m_pHFTextBxs->WritePlc( *this ); // Head/Foot-Textbox Text Plc
m_pAtn->WritePlc( *this ); // Annotation-Ref & Text Plc
- pSepx->WritePlcSed( *this ); // Slcx.PlcSed
- pSepx->WritePlcHdd( *this ); // Slcx.PlcHdd
+ m_pSepx->WritePlcSed( *this ); // Slcx.PlcSed
+ m_pSepx->WritePlcHdd( *this ); // Slcx.PlcHdd
m_pChpPlc->WritePlc(); // Plcx.Chpx
m_pPapPlc->WritePlc(); // Plcx.Papx
@@ -3028,7 +3158,7 @@ void WW8Export::WriteFkpPlcUsw()
some magic.
*/
// avoid memory leak #i120098#, the unnamed obj will be released in destructor.
- xEscherStg = GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool);
+ m_xEscherStg = GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool);
}
// dggInfo - escher stream
@@ -3050,10 +3180,10 @@ void WW8Export::WriteFkpPlcUsw()
m_pMagicTable->Write( *this );
m_pPiece->WritePc( *this ); // Piece-Table
- m_aFontHelper.WriteFontTable(pTableStrm, *pFib); // FFNs
+ m_aFontHelper.WriteFontTable(m_pTableStrm, *m_pFib); // FFNs
//Convert OOo asian typography into MS typography structure
- ExportDopTypography(pDop->doptypography);
+ ExportDopTypography(m_pDop->doptypography);
WriteDop( *this ); // Document-Properties
@@ -3064,8 +3194,8 @@ void WW8Export::WriteFkpPlcUsw()
if ( pSttbfAssoc ) // #i106057#
{
std::vector<OUString> aStrings(pSttbfAssoc->getStrings());
- WriteAsStringTable(aStrings, pFib->m_fcSttbfAssoc,
- pFib->m_lcbSttbfAssoc);
+ WriteAsStringTable(aStrings, m_pFib->m_fcSttbfAssoc,
+ m_pFib->m_lcbSttbfAssoc);
}
Strm().Seek( 0 );
@@ -3076,29 +3206,29 @@ void WW8Export::WriteFkpPlcUsw()
if ( pFibData )
{
- pFib->m_fReadOnlyRecommended =
- pFibData->getReadOnlyRecommended();
- pFib->m_fWriteReservation =
- pFibData->getWriteReservation();
+ m_pFib->m_fReadOnlyRecommended =
+ pFibData->getReadOnlyRecommended();
+ m_pFib->m_fWriteReservation =
+ pFibData->getWriteReservation();
}
- pFib->Write( Strm() ); // FIB
+ m_pFib->Write( Strm() ); // FIB
}
void WW8Export::StoreDoc1()
{
bool bNeedsFinalPara = false;
// Start of Text ( overwrite )
- SwWW8Writer::FillUntil( Strm(), pFib->m_fcMin );
+ SwWW8Writer::FillUntil( Strm(), m_pFib->m_fcMin );
WriteMainText(); // main text
sal_uInt8 nSprmsLen;
sal_uInt8 *pLastSprms = m_pPapPlc->CopyLastSprms(nSprmsLen);
- bNeedsFinalPara |= pFootnote->WriteText( *this ); // Footnote-Text
- bNeedsFinalPara |= pSepx->WriteKFText( *this ); // K/F-Text
+ bNeedsFinalPara |= m_pFootnote->WriteText( *this ); // Footnote-Text
+ bNeedsFinalPara |= m_pSepx->WriteKFText( *this ); // K/F-Text
bNeedsFinalPara |= m_pAtn->WriteText( *this ); // Annotation-Text
- bNeedsFinalPara |= pEdn->WriteText( *this ); // EndNote-Text
+ bNeedsFinalPara |= m_pEdn->WriteText( *this ); // EndNote-Text
// create the escher streams
CreateEscher();
@@ -3113,10 +3243,10 @@ void WW8Export::StoreDoc1()
}
delete[] pLastSprms;
- pSepx->Finish( Fc2Cp( Strm().Tell() ));// Text + Footnote + HdFt as section end
+ m_pSepx->Finish( Fc2Cp( Strm().Tell() ));// Text + Footnote + HdFt as section end
m_pMagicTable->Finish( Fc2Cp( Strm().Tell() ),0);
- pFib->m_fcMac = Strm().Tell(); // End of all texts
+ m_pFib->m_fcMac = Strm().Tell(); // End of all texts
WriteFkpPlcUsw(); // FKP, PLC, ...
}
@@ -3137,9 +3267,6 @@ void MSWordExportBase::AddLinkTarget(std::u16string_view rURL)
return;
sCmp = sCmp.toAsciiLowerCase();
- sal_uLong nIdx = 0;
- bool noBookmark = false;
-
if( sCmp == "outline" )
{
SwPosition aPos(*m_pCurPam->GetPoint());
@@ -3148,106 +3275,83 @@ void MSWordExportBase::AddLinkTarget(std::u16string_view rURL)
// save the name of the bookmark and the
// node index number of where it points to
if( m_rDoc.GotoOutline( aPos, aName ) )
- {
- nIdx = aPos.nNode.GetIndex();
- noBookmark = true;
- }
+ m_aImplicitBookmarks.emplace_back(aURL, aPos.GetNodeIndex());
}
else if( sCmp == "graphic" )
{
- SwNodeIndex* pIdx;
OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
- const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, SwNodeType::Grf);
- if (pFormat && nullptr != (pIdx = const_cast<SwNodeIndex*>(pFormat->GetContent().GetContentIdx())))
+ if (const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, SwNodeType::Grf))
{
- nIdx = pIdx->GetNext()->GetIndex();
- noBookmark = true;
+ const SwFormatAnchor& rFormatAnchor = pFormat->GetAnchor();
+ if (SwNode* pAnchorNode = rFormatAnchor.GetAnchorNode())
+ m_aImplicitBookmarks.emplace_back(aURL, pAnchorNode->GetIndex());
}
}
else if( sCmp == "frame" )
{
- SwNodeIndex* pIdx;
OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
- const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, SwNodeType::Text);
- if (pFormat && nullptr != (pIdx = const_cast<SwNodeIndex*>(pFormat->GetContent().GetContentIdx())))
- {
- nIdx = pIdx->GetIndex() + 1;
- noBookmark = true;
- }
+ if (const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, SwNodeType::Text))
+ if (const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx())
+ m_aImplicitBookmarks.emplace_back(aURL, pIdx->GetIndex() + 1);
}
else if( sCmp == "ole" )
{
- SwNodeIndex* pIdx;
OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
- const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, SwNodeType::Ole);
- if (pFormat && nullptr != (pIdx = const_cast<SwNodeIndex*>(pFormat->GetContent().GetContentIdx())))
+ if (const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, SwNodeType::Ole))
{
- nIdx = pIdx->GetNext()->GetIndex();
- noBookmark = true;
+ const SwFormatAnchor& rFormatAnchor = pFormat->GetAnchor();
+ if (SwNode* pAnchorNode = rFormatAnchor.GetAnchorNode())
+ m_aImplicitBookmarks.emplace_back(aURL, pAnchorNode->GetIndex());
}
}
else if( sCmp == "region" )
{
- SwNodeIndex* pIdx;
OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
for (const SwSectionFormat* pFormat : m_rDoc.GetSections())
{
- if (aName == pFormat->GetSection()->GetSectionName()
- && nullptr != (pIdx = const_cast<SwNodeIndex*>(pFormat->GetContent().GetContentIdx())))
+ if (aName == pFormat->GetSection()->GetSectionName())
{
- nIdx = pIdx->GetIndex() + 1;
- noBookmark = true;
- break;
+ if (const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx())
+ {
+ m_aImplicitBookmarks.emplace_back(aURL, pIdx->GetIndex() + 1);
+ break;
+ }
}
}
}
else if( sCmp == "table" )
{
OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
- const SwTable* pTable = SwTable::FindTable(m_rDoc.FindTableFormatByName(aName));
- if (pTable)
- {
- SwTableNode* pTableNode = const_cast<SwTableNode*>(pTable->GetTabSortBoxes()[1]->GetSttNd()->FindTableNode());
- if (pTableNode)
- {
- nIdx = pTableNode->GetIndex() + 2;
- noBookmark = true;
- }
- }
+ if (const SwTable* pTable = SwTable::FindTable(m_rDoc.FindTableFormatByName(aName)))
+ if (const SwTableNode* pTableNode = pTable->GetTabSortBoxes()[1]->GetSttNd()->FindTableNode())
+ m_aImplicitBookmarks.emplace_back(aURL, pTableNode->GetIndex() + 2);
}
else if (sCmp == "toxmark")
{
OUString const name(aURL.copy(0, nPos));
OUString const nameDecoded(INetURLObject::decode(name,
INetURLObject::DecodeMechanism::WithCharset));
- std::optional<std::pair<SwTOXMark, sal_Int32>> const tmp(
- sw::PrepareJumpToTOXMark(m_rDoc, nameDecoded));
- if (tmp)
+ if (const auto tmp = sw::PrepareJumpToTOXMark(m_rDoc, nameDecoded))
{
SwTOXMark const* pMark(&tmp->first);
for (sal_Int32 i = 0; i < tmp->second; ++i)
{
pMark = &m_rDoc.GotoTOXMark(*pMark, TOX_SAME_NXT, true);
}
- if (pMark != &tmp->first)
+ if (!SfxPoolItem::areSame(pMark, &tmp->first))
{
m_TOXMarkBookmarksByURL.emplace(aURL, name);
m_TOXMarkBookmarksByTOXMark.emplace(pMark, nameDecoded);
}
}
}
- if (noBookmark)
- {
- aBookmarkPair aImplicitBookmark;
- aImplicitBookmark.first = aURL;
- aImplicitBookmark.second = nIdx;
- m_aImplicitBookmarks.push_back(aImplicitBookmark);
- }
}
void MSWordExportBase::CollectOutlineBookmarks(const SwDoc &rDoc)
{
- for (const SfxPoolItem* pItem : rDoc.GetAttrPool().GetItemSurrogates(RES_TXTATR_INETFMT))
+ ItemSurrogates aSurrogates;
+ rDoc.GetAttrPool().GetItemSurrogates(aSurrogates, RES_TXTATR_INETFMT);
+ for (const SfxPoolItem* pItem : aSurrogates)
{
auto pINetFormat = dynamic_cast<const SwFormatINetFormat*>(pItem);
if (!pINetFormat)
@@ -3267,7 +3371,8 @@ void MSWordExportBase::CollectOutlineBookmarks(const SwDoc &rDoc)
AddLinkTarget( pINetFormat->GetValue() );
}
- for (const SfxPoolItem* pItem : rDoc.GetAttrPool().GetItemSurrogates(RES_URL))
+ rDoc.GetAttrPool().GetItemSurrogates(aSurrogates, RES_URL);
+ for (const SfxPoolItem* pItem : aSurrogates)
{
auto pURL = dynamic_cast<const SwFormatURL*>(pItem);
if (!pURL)
@@ -3290,11 +3395,11 @@ void MSWordExportBase::CollectOutlineBookmarks(const SwDoc &rDoc)
namespace
{
- const sal_uLong WW_BLOCKSIZE = 0x200;
+ const sal_uInt64 WW_BLOCKSIZE = 0x200;
ErrCode EncryptRC4(msfilter::MSCodec_Std97& rCtx, SvStream &rIn, SvStream &rOut)
{
- sal_uLong nLen = rIn.TellEnd();
+ sal_uInt64 nLen = rIn.TellEnd();
rIn.Seek(0);
sal_uInt8 in[WW_BLOCKSIZE];
@@ -3336,20 +3441,19 @@ ErrCode MSWordExportBase::ExportDocument( bool bWriteAll )
m_pRedlAuthors = nullptr;
m_aTOXArr.clear();
- if ( !m_pOLEExp )
+ if ( !m_oOLEExp )
{
sal_uInt32 nSvxMSDffOLEConvFlags = 0;
- const SvtFilterOptions& rOpt = SvtFilterOptions::Get();
- if ( rOpt.IsMath2MathType() )
+ if (officecfg::Office::Common::Filter::Microsoft::Export::MathToMathType::get())
nSvxMSDffOLEConvFlags |= OLE_STARMATH_2_MATHTYPE;
- if ( rOpt.IsWriter2WinWord() )
+ if (officecfg::Office::Common::Filter::Microsoft::Export::WriterToWinWord::get())
nSvxMSDffOLEConvFlags |= OLE_STARWRITER_2_WINWORD;
- if ( rOpt.IsCalc2Excel() )
+ if (officecfg::Office::Common::Filter::Microsoft::Export::CalcToExcel::get())
nSvxMSDffOLEConvFlags |= OLE_STARCALC_2_EXCEL;
- if ( rOpt.IsImpress2PowerPoint() )
+ if (officecfg::Office::Common::Filter::Microsoft::Export::ImpressToPowerPoint::get())
nSvxMSDffOLEConvFlags |= OLE_STARIMPRESS_2_POWERPOINT;
- m_pOLEExp.reset(new SvxMSExportOLEObjects( nSvxMSDffOLEConvFlags ));
+ m_oOLEExp.emplace( nSvxMSDffOLEConvFlags );
}
if ( !m_pOCXExp && m_rDoc.GetDocShell() )
@@ -3388,11 +3492,11 @@ ErrCode MSWordExportBase::ExportDocument( bool bWriteAll )
m_aFrames.clear();
// park m_pCurPam in a "safe place" now that document is fully exported
- // before toggling redline mode to avoid ~SwIndexReg assert e.g. export
+ // before toggling redline mode to avoid ~SwContentIndexReg assert e.g. export
// ooo103014-1.odt to .doc
// park m_pOrigPam as well, as needed for exporting abi9915-1.odt to doc
m_pOrigPam->DeleteMark();
- *m_pOrigPam->GetPoint() = SwPosition(m_rDoc.GetNodes().GetEndOfContent());
+ m_pOrigPam->GetPoint()->Assign(m_rDoc.GetNodes().GetEndOfContent());
static_cast<SwPaM&>(*m_pCurPam) = *m_pOrigPam;
m_rDoc.getIDocumentRedlineAccess().SetRedlineFlags(m_nOrigRedlineFlags);
@@ -3406,7 +3510,7 @@ bool SwWW8Writer::InitStd97CodecUpdateMedium( ::msfilter::MSCodec_Std97& rCodec
if ( mpMedium )
{
- const SfxUnoAnyItem* pEncryptionDataItem = SfxItemSet::GetItem<SfxUnoAnyItem>(mpMedium->GetItemSet(), SID_ENCRYPTIONDATA, false);
+ const SfxUnoAnyItem* pEncryptionDataItem = mpMedium->GetItemSet().GetItem(SID_ENCRYPTIONDATA, false);
if ( pEncryptionDataItem && ( pEncryptionDataItem->GetValue() >>= aEncryptionData ) && !rCodec.InitCodec( aEncryptionData ) )
{
OSL_ENSURE( false, "Unexpected EncryptionData!" );
@@ -3416,14 +3520,16 @@ bool SwWW8Writer::InitStd97CodecUpdateMedium( ::msfilter::MSCodec_Std97& rCodec
if ( !aEncryptionData.hasElements() )
{
// try to generate the encryption data based on password
- const SfxStringItem* pPasswordItem = SfxItemSet::GetItem<SfxStringItem>(mpMedium->GetItemSet(), SID_PASSWORD, false);
+ const SfxStringItem* pPasswordItem = mpMedium->GetItemSet().GetItem(SID_PASSWORD, false);
if ( pPasswordItem && !pPasswordItem->GetValue().isEmpty() && pPasswordItem->GetValue().getLength() <= 15 )
{
// Generate random number with a seed of time as salt.
rtlRandomPool aRandomPool = rtl_random_createPool ();
sal_uInt8 pDocId[ 16 ];
- rtl_random_getBytes( aRandomPool, pDocId, 16 );
-
+ if (rtl_random_getBytes(aRandomPool, pDocId, 16) != rtl_Random_E_None)
+ {
+ throw uno::RuntimeException("rtl_random_getBytes failed");
+ }
rtl_random_destroyPool( aRandomPool );
sal_uInt16 aPassword[16] = {};
@@ -3435,12 +3541,12 @@ bool SwWW8Writer::InitStd97CodecUpdateMedium( ::msfilter::MSCodec_Std97& rCodec
rCodec.InitKey( aPassword, pDocId );
aEncryptionData = rCodec.GetEncryptionData();
- mpMedium->GetItemSet()->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) ) );
+ mpMedium->GetItemSet().Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::Any( aEncryptionData ) ) );
}
}
if ( aEncryptionData.hasElements() )
- mpMedium->GetItemSet()->ClearItem( SID_PASSWORD );
+ mpMedium->GetItemSet().ClearItem( SID_PASSWORD );
}
// nonempty encryption data means here that the codec was successfully initialized
@@ -3451,13 +3557,16 @@ ErrCode WW8Export::ExportDocument_Impl()
{
PrepareStorage();
- pFib.reset(new WW8Fib(8, m_bDot));
+ m_pFib.reset(new WW8Fib(8, m_bDot));
- tools::SvRef<SotStorageStream> xWwStrm( GetWriter().GetStorage().OpenSotStream( m_aMainStg ) );
- tools::SvRef<SotStorageStream> xTableStrm( xWwStrm ), xDataStrm( xWwStrm );
+ rtl::Reference<SotStorageStream> xWwStrm(GetWriter().GetStorage().OpenSotStream(m_aMainStg));
+ if (!xWwStrm->IsWritable())
+ return ERRCODE_IO_ACCESSDENIED;
+
+ rtl::Reference<SotStorageStream> xTableStrm(xWwStrm), xDataStrm(xWwStrm);
xWwStrm->SetBufferSize( 32768 );
- pFib->m_fWhichTableStm = true;
+ m_pFib->m_fWhichTableStm = true;
xTableStrm = GetWriter().GetStorage().OpenSotStream(SL::a1Table, StreamMode::STD_WRITE);
xDataStrm = GetWriter().GetStorage().OpenSotStream(SL::aData, StreamMode::STD_WRITE);
@@ -3468,17 +3577,14 @@ ErrCode WW8Export::ExportDocument_Impl()
xDataStrm->SetEndian( SvStreamEndian::LITTLE );
GetWriter().SetStream( xWwStrm.get() );
- pTableStrm = xTableStrm.get();
- pDataStrm = xDataStrm.get();
+ m_pTableStrm = xTableStrm.get();
+ m_pDataStrm = xDataStrm.get();
Strm().SetEndian( SvStreamEndian::LITTLE );
- utl::TempFile aTempMain;
- aTempMain.EnableKillingFile();
- utl::TempFile aTempTable;
- aTempTable.EnableKillingFile();
- utl::TempFile aTempData;
- aTempData.EnableKillingFile();
+ utl::TempFileFast aTempMain;
+ utl::TempFileFast aTempTable;
+ utl::TempFileFast aTempData;
msfilter::MSCodec_Std97 aCtx;
bool bEncrypt = GetWriter().InitStd97CodecUpdateMedium(aCtx);
@@ -3487,33 +3593,33 @@ ErrCode WW8Export::ExportDocument_Impl()
GetWriter().SetStream(
aTempMain.GetStream( StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE ) );
- pTableStrm = aTempTable.GetStream( StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE );
+ m_pTableStrm = aTempTable.GetStream( StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE );
- pDataStrm = aTempData.GetStream( StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE );
+ m_pDataStrm = aTempData.GetStream( StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE );
sal_uInt8 const aRC4EncryptionHeader[ 52 ] = {0};
- pTableStrm->WriteBytes(aRC4EncryptionHeader, 52);
+ m_pTableStrm->WriteBytes(aRC4EncryptionHeader, 52);
}
// Default: "Standard"
- pSepx.reset(new WW8_WrPlcSepx( *this )); // Sections/headers/footers
+ m_pSepx.reset(new WW8_WrPlcSepx( *this )); // Sections/headers/footers
- pFootnote.reset(new WW8_WrPlcFootnoteEdn( TXT_FTN )); // Footnotes
- pEdn.reset(new WW8_WrPlcFootnoteEdn( TXT_EDN )); // Endnotes
- m_pAtn = new WW8_WrPlcAnnotations; // PostIts
+ m_pFootnote.reset(new WW8_WrPlcFootnoteEdn( TXT_FTN )); // Footnotes
+ m_pEdn.reset(new WW8_WrPlcFootnoteEdn( TXT_EDN )); // Endnotes
+ m_pAtn.reset(new WW8_WrPlcAnnotations); // PostIts
m_pFactoids.reset(new WW8_WrtFactoids); // Smart tags.
- m_pTextBxs = new WW8_WrPlcTextBoxes( TXT_TXTBOX );
- m_pHFTextBxs = new WW8_WrPlcTextBoxes( TXT_HFTXTBOX );
+ m_pTextBxs.reset(new WW8_WrPlcTextBoxes( TXT_TXTBOX ));
+ m_pHFTextBxs.reset(new WW8_WrPlcTextBoxes( TXT_HFTXTBOX ));
- m_pSdrObjs = new MainTextPlcDrawObj; // Draw-/Fly-Objects for main text
- m_pHFSdrObjs = new HdFtPlcDrawObj; // Draw-/Fly-Objects for header/footer
+ m_pSdrObjs.reset(new MainTextPlcDrawObj); // Draw-/Fly-Objects for main text
+ m_pHFSdrObjs.reset(new HdFtPlcDrawObj); // Draw-/Fly-Objects for header/footer
- m_pBkmks = new WW8_WrtBookmarks; // Bookmarks
+ m_pBkmks.reset(new WW8_WrtBookmarks); // Bookmarks
GetWriter().CreateBookmarkTable();
- m_pPapPlc.reset(new WW8_WrPlcPn( *this, PAP, pFib->m_fcMin ));
- m_pChpPlc.reset(new WW8_WrPlcPn( *this, CHP, pFib->m_fcMin ));
- pO.reset(new ww::bytes);
+ m_pPapPlc.reset(new WW8_WrPlcPn( *this, PAP, m_pFib->m_fcMin ));
+ m_pChpPlc.reset(new WW8_WrPlcPn( *this, CHP, m_pFib->m_fcMin ));
+ m_pO.reset(new ww::bytes);
m_pStyles.reset(new MSWordStyles( *this ));
m_pFieldMain.reset(new WW8_WrPlcField( 2, TXT_MAINTEXT ));
m_pFieldHdFt.reset(new WW8_WrPlcField( 2, TXT_HDFT ));
@@ -3526,22 +3632,22 @@ ErrCode WW8Export::ExportDocument_Impl()
m_pMagicTable.reset(new WW8_WrMagicTable);
m_pGrf.reset(new SwWW8WrGrf( *this ));
- m_pPiece = new WW8_WrPct( pFib->m_fcMin );
- pDop.reset(new WW8Dop);
+ m_pPiece.reset(new WW8_WrPct( m_pFib->m_fcMin ));
+ m_pDop.reset(new WW8Dop);
- pDop->fRevMarking = bool( RedlineFlags::On & m_nOrigRedlineFlags );
+ m_pDop->fRevMarking = bool( RedlineFlags::On & m_nOrigRedlineFlags );
SwRootFrame const*const pLayout(m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout());
- pDop->fRMView = pLayout == nullptr || !pLayout->IsHideRedlines();
- pDop->fRMPrint = pDop->fRMView;
+ m_pDop->fRMView = pLayout == nullptr || !pLayout->IsHideRedlines();
+ m_pDop->fRMPrint = m_pDop->fRMView;
// set AutoHyphenation flag if found in default para style
- const SfxPoolItem* pItem;
+ const SvxHyphenZoneItem* pItem;
SwTextFormatColl* pStdTextFormatColl =
m_rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_STANDARD, false);
- if (pStdTextFormatColl && SfxItemState::SET == pStdTextFormatColl->GetItemState(
- RES_PARATR_HYPHENZONE, false, &pItem))
+ if (pStdTextFormatColl && (pItem = pStdTextFormatColl->GetItemIfSet(
+ RES_PARATR_HYPHENZONE, false)))
{
- pDop->fAutoHyphen = static_cast<const SvxHyphenZoneItem*>(pItem)->IsHyphen();
+ m_pDop->fAutoHyphen = pItem->IsHyphen();
}
StoreDoc1();
@@ -3555,13 +3661,13 @@ ErrCode WW8Export::ExportDocument_Impl()
pDataStrmTemp = xDataStrm.get();
if ( pDataStrmTemp && pDataStrmTemp != pStrmTemp) {
- err = EncryptRC4(aCtx, *pDataStrm, *pDataStrmTemp);
+ err = EncryptRC4(aCtx, *m_pDataStrm, *pDataStrmTemp);
if (err != ERRCODE_NONE) {
goto done;
}
}
- err = EncryptRC4(aCtx, *pTableStrm, *pTableStrmTemp);
+ err = EncryptRC4(aCtx, *m_pTableStrm, *pTableStrmTemp);
if (err != ERRCODE_NONE) {
goto done;
}
@@ -3588,13 +3694,13 @@ ErrCode WW8Export::ExportDocument_Impl()
}
// Write Unencrypted Fib 68 bytes to the start of the workdocument stream
- pFib->m_fEncrypted = true; // fEncrypted indicates the document is encrypted.
- pFib->m_fObfuscated = false; // Must be 0 for RC4.
- pFib->m_nHash = 0x34; // encrypt header bytes count of table stream.
- pFib->m_nKey = 0; // lkey2 must be 0 for RC4.
+ m_pFib->m_fEncrypted = true; // fEncrypted indicates the document is encrypted.
+ m_pFib->m_fObfuscated = false; // Must be 0 for RC4.
+ m_pFib->m_nHash = 0x34; // encrypt header bytes count of table stream.
+ m_pFib->m_nKey = 0; // lkey2 must be 0 for RC4.
pStrmTemp->Seek( 0 );
- pFib->WriteHeader( *pStrmTemp );
+ m_pFib->WriteHeader( *pStrmTemp );
done:;
}
@@ -3608,32 +3714,32 @@ ErrCode WW8Export::ExportDocument_Impl()
m_pFieldHdFt.reset();
m_pFieldMain.reset();
m_pStyles.reset();
- pO.reset();
+ m_pO.reset();
m_pChpPlc.reset();
m_pPapPlc.reset();
- pSepx.reset();
-
- delete m_pRedlAuthors;
- delete m_pSdrObjs;
- delete m_pHFSdrObjs;
- delete m_pTextBxs;
- delete m_pHFTextBxs;
- delete m_pAtn;
- pEdn.reset();
- pFootnote.reset();
- delete m_pBkmks;
- delete m_pPiece;
- pDop.reset();
- pFib.reset();
+ m_pSepx.reset();
+
+ m_pRedlAuthors.reset();
+ m_pSdrObjs.reset();
+ m_pHFSdrObjs.reset();
+ m_pTextBxs.reset();
+ m_pHFTextBxs.reset();
+ m_pAtn.reset();
+ m_pEdn.reset();
+ m_pFootnote.reset();
+ m_pBkmks.reset();
+ m_pPiece.reset();
+ m_pDop.reset();
+ m_pFib.reset();
GetWriter().SetStream( nullptr );
xWwStrm->SetBufferSize( 0 );
xTableStrm->SetBufferSize( 0 );
xDataStrm->SetBufferSize( 0 );
- if( 0 == pDataStrm->Seek( STREAM_SEEK_TO_END ))
+ if( 0 == m_pDataStrm->Seek( STREAM_SEEK_TO_END ))
{
xDataStrm.clear();
- pDataStrm = nullptr;
+ m_pDataStrm = nullptr;
GetWriter().GetStorage().Remove(SL::aData);
}
@@ -3669,7 +3775,7 @@ void WW8Export::PrepareStorage()
SvGlobalName aGName(MSO_WW8_CLASSID);
GetWriter().GetStorage().SetClass(
aGName, SotClipboardFormatId::NONE, "Microsoft Word-Document");
- tools::SvRef<SotStorageStream> xStor( GetWriter().GetStorage().OpenSotStream(sCompObj) );
+ rtl::Reference<SotStorageStream> xStor(GetWriter().GetStorage().OpenSotStream(sCompObj));
xStor->WriteBytes(pData, sizeof(pData));
SwDocShell* pDocShell = m_rDoc.GetDocShell ();
@@ -3686,7 +3792,7 @@ void WW8Export::PrepareStorage()
if (!xDocProps.is())
return;
- if ( SvtFilterOptions::Get().IsEnableWordPreview() )
+ if (officecfg::Office::Common::Filter::Microsoft::Export::EnableWordPreview::get())
{
std::shared_ptr<GDIMetaFile> xMetaFile =
pDocShell->GetPreviewMetaFile();
@@ -3698,16 +3804,16 @@ void WW8Export::PrepareStorage()
sfx2::SaveOlePropertySet( xDocProps, &GetWriter().GetStorage() );
}
-ErrCode SwWW8Writer::WriteStorage()
+ErrCodeMsg SwWW8Writer::WriteStorage()
{
- tools::SvRef<SotStorage> pOrigStg;
+ rtl::Reference<SotStorage> pOrigStg;
uno::Reference< packages::XPackageEncryption > xPackageEncryption;
std::shared_ptr<SvStream> pSotStorageStream;
uno::Sequence< beans::NamedValue > aEncryptionData;
if (mpMedium)
{
// Check for specific encryption requests
- const SfxUnoAnyItem* pEncryptionDataItem = SfxItemSet::GetItem<SfxUnoAnyItem>(mpMedium->GetItemSet(), SID_ENCRYPTIONDATA, false);
+ const SfxUnoAnyItem* pEncryptionDataItem = mpMedium->GetItemSet().GetItem(SID_ENCRYPTIONDATA, false);
if (pEncryptionDataItem && (pEncryptionDataItem->GetValue() >>= aEncryptionData))
{
::comphelper::SequenceAsHashMap aHashData(aEncryptionData);
@@ -3717,12 +3823,12 @@ ErrCode SwWW8Writer::WriteStorage()
{
uno::Reference<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
uno::Sequence<uno::Any> aArguments{
- uno::makeAny(beans::NamedValue("Binary", uno::makeAny(true))) };
+ uno::Any(beans::NamedValue("Binary", uno::Any(true))) };
xPackageEncryption.set(
xComponentContext->getServiceManager()->createInstanceWithArgumentsAndContext(
"com.sun.star.comp.oox.crypto." + sCryptoType, aArguments, xComponentContext), uno::UNO_QUERY);
- if (xPackageEncryption.is())
+ if (xPackageEncryption)
{
// We have an encryptor
// Create new temporary storage for content
@@ -3736,8 +3842,10 @@ ErrCode SwWW8Writer::WriteStorage()
ErrCode nErrorCode = WriteStorageImpl();
- if (xPackageEncryption.is())
+ if (xPackageEncryption)
{
+ assert(pSotStorageStream && m_pStg && "because always set if xPackageEncryption was set");
+
m_pStg->Commit();
pSotStorageStream->Seek(0);
@@ -3748,11 +3856,11 @@ ErrCode SwWW8Writer::WriteStorage()
uno::Sequence<beans::NamedValue> aStreams = xPackageEncryption->encrypt(xInputStream);
m_pStg = pOrigStg;
- for (const beans::NamedValue & aStreamData : std::as_const(aStreams))
+ for (const beans::NamedValue& aStreamData : aStreams)
{
// To avoid long paths split and open substorages recursively
// Splitting paths manually, since comphelper::string::split is trimming special characters like \0x01, \0x09
- tools::SvRef<SotStorage> pStorage = m_pStg.get();
+ rtl::Reference<SotStorage> pStorage = m_pStg;
OUString sFileName;
sal_Int32 idx = 0;
while (pStorage && idx >= 0)
@@ -3779,7 +3887,7 @@ ErrCode SwWW8Writer::WriteStorage()
break;
}
- tools::SvRef<SotStorageStream> pStream = pStorage->OpenSotStream(sFileName);
+ rtl::Reference<SotStorageStream> pStream = pStorage->OpenSotStream(sFileName);
if (!pStream)
{
nErrorCode = ERRCODE_IO_GENERAL;
@@ -3805,15 +3913,15 @@ ErrCode SwWW8Writer::WriteStorageImpl()
if( pViewShell != nullptr )
pViewShell->CalcLayout();
- tools::Long nMaxNode = m_pDoc->GetNodes().Count();
- ::StartProgress( STR_STATSTR_W4WWRITE, 0, nMaxNode, m_pDoc->GetDocShell() );
+ SwNodeOffset nMaxNode = m_pDoc->GetNodes().Count();
+ ::StartProgress( STR_STATSTR_W4WWRITE, 0, sal_Int32(nMaxNode), m_pDoc->GetDocShell() );
// Respect table at the beginning of the document
{
- SwTableNode* pTNd = m_pCurrentPam->GetNode().FindTableNode();
+ SwTableNode* pTNd = m_pCurrentPam->GetPointNode().FindTableNode();
if( pTNd && m_bWriteAll )
// start with the table node !!
- m_pCurrentPam->GetPoint()->nNode = *pTNd;
+ m_pCurrentPam->GetPoint()->Assign(*pTNd);
}
// Do the actual export
@@ -3830,16 +3938,16 @@ ErrCode SwWW8Writer::WriteStorageImpl()
return err;
}
-ErrCode SwWW8Writer::WriteMedium( SfxMedium& )
+ErrCodeMsg SwWW8Writer::WriteMedium( SfxMedium& )
{
return WriteStorage();
}
-ErrCode SwWW8Writer::Write( SwPaM& rPaM, SfxMedium& rMed,
+ErrCodeMsg SwWW8Writer::Write( SwPaM& rPaM, SfxMedium& rMed,
const OUString* pFileName )
{
mpMedium = &rMed;
- ErrCode nRet = StgWriter::Write( rPaM, rMed, pFileName );
+ ErrCodeMsg nRet = StgWriter::Write( rPaM, rMed, pFileName );
mpMedium = nullptr;
return nRet;
}
@@ -3847,10 +3955,7 @@ ErrCode SwWW8Writer::Write( SwPaM& rPaM, SfxMedium& rMed,
MSWordExportBase::MSWordExportBase( SwDoc& rDocument, std::shared_ptr<SwUnoCursor> & pCurrentPam, SwPaM* pOriginalPam )
: m_aMainStg(sMainStream)
, m_pISet(nullptr)
- , m_pPiece(nullptr)
, m_pTopNodeOfHdFtPage(nullptr)
- , m_pBkmks(nullptr)
- , m_pRedlAuthors(nullptr)
, m_pTableInfo(std::make_shared<ww8::WW8TableInfo>())
, m_nCharFormatStart(0)
, m_nFormatCollStart(0)
@@ -3861,19 +3966,15 @@ MSWordExportBase::MSWordExportBase( SwDoc& rDocument, std::shared_ptr<SwUnoCurso
, m_nOrigRedlineFlags(RedlineFlags::NONE)
, m_bOrigShowChanges(true)
, m_pCurrentPageDesc(nullptr)
+ , m_pPreviousSectionPageDesc(nullptr)
, m_bFirstTOCNodeWithSection(false)
, m_pChpIter(nullptr)
- , m_pAtn(nullptr)
- , m_pTextBxs(nullptr)
- , m_pHFTextBxs(nullptr)
, m_pParentFrame(nullptr)
, m_pFlyOffset(nullptr)
, m_eNewAnchorType(RndStdIds::FLY_AS_CHAR)
, m_pStyAttr(nullptr)
, m_pOutFormatNode(nullptr)
, m_pCurrentStyle(nullptr)
- , m_pSdrObjs(nullptr)
- , m_pHFSdrObjs(nullptr)
, m_pEscher(nullptr)
, m_nTextTyp(0)
, m_bStyDef(false)
@@ -3898,8 +3999,8 @@ MSWordExportBase::MSWordExportBase( SwDoc& rDocument, std::shared_ptr<SwUnoCurso
, m_bFontSizeWritten(false)
, m_bAddFootnoteTab(false)
, m_rDoc(rDocument)
- , m_nCurStart(pCurrentPam->GetPoint()->nNode.GetIndex())
- , m_nCurEnd(pCurrentPam->GetMark()->nNode.GetIndex())
+ , m_nCurStart(pCurrentPam->GetPoint()->GetNodeIndex())
+ , m_nCurEnd(pCurrentPam->GetMark()->GetNodeIndex())
, m_pCurPam(pCurrentPam)
, m_pOrigPam(pOriginalPam)
{
@@ -3915,7 +4016,7 @@ MSWordExportBase::~MSWordExportBase()
m_pUsedNumTable->erase(m_pUsedNumTable->begin(), m_pUsedNumTable->begin() + m_pUsedNumTable->size() - m_nUniqueList);
m_pUsedNumTable.reset();
}
- m_pOLEExp.reset();
+ m_oOLEExp.reset();
m_pOCXExp.reset();
}
@@ -3923,8 +4024,8 @@ WW8Export::WW8Export( SwWW8Writer *pWriter,
SwDoc& rDocument, std::shared_ptr<SwUnoCursor> & pCurrentPam, SwPaM* pOriginalPam,
bool bDot )
: MSWordExportBase( rDocument, pCurrentPam, pOriginalPam )
- , pTableStrm(nullptr)
- , pDataStrm(nullptr)
+ , m_pTableStrm(nullptr)
+ , m_pDataStrm(nullptr)
, m_bDot(bDot)
, m_pWriter(pWriter)
, m_pAttrOutput(new WW8AttributeOutput(*this))
@@ -3942,12 +4043,11 @@ AttributeOutputBase& WW8Export::AttrOutput() const
MSWordSections& WW8Export::Sections() const
{
- return *pSepx;
+ return *m_pSepx;
}
-SwWW8Writer::SwWW8Writer(const OUString& rFltName, const OUString& rBaseURL)
- : StgWriter(),
- m_pExport( nullptr ),
+SwWW8Writer::SwWW8Writer(std::u16string_view rFltName, const OUString& rBaseURL)
+ : m_pExport( nullptr ),
mpMedium( nullptr )
{
assert(rFltName == FILTER_WW8); // WW6/7 export was removed
@@ -3965,7 +4065,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT sal_uInt32 SaveOrDelMSVBAStorage_ww8( SfxObjectS
return sal_uInt32(aTmp.SaveOrDelMSVBAStorage( bSaveInto, rStorageName ));
}
-extern "C" SAL_DLLPUBLIC_EXPORT void ExportDOC( const OUString& rFltName, const OUString& rBaseURL, WriterRef& xRet )
+extern "C" SAL_DLLPUBLIC_EXPORT void ExportDOC( std::u16string_view rFltName, const OUString& rBaseURL, WriterRef& xRet )
{
xRet = new SwWW8Writer( rFltName, rBaseURL );
}
@@ -3978,73 +4078,73 @@ extern "C" SAL_DLLPUBLIC_EXPORT sal_uInt32 GetSaveWarningOfMSVBAStorage_ww8( Sf
bool WW8_WrPlcFootnoteEdn::WriteText( WW8Export& rWrt )
{
bool bRet = false;
- if (TXT_FTN == nTyp)
+ if (TXT_FTN == m_nTyp)
{
- bRet = WriteGenericText( rWrt, TXT_FTN, rWrt.pFib->m_ccpFootnote );
+ bRet = WriteGenericText( rWrt, TXT_FTN, rWrt.m_pFib->m_ccpFootnote );
rWrt.m_pFieldFootnote->Finish( rWrt.Fc2Cp( rWrt.Strm().Tell() ),
- rWrt.pFib->m_ccpText );
+ rWrt.m_pFib->m_ccpText );
}
else
{
- bRet = WriteGenericText( rWrt, TXT_EDN, rWrt.pFib->m_ccpEdn );
+ bRet = WriteGenericText( rWrt, TXT_EDN, rWrt.m_pFib->m_ccpEdn );
rWrt.m_pFieldEdn->Finish( rWrt.Fc2Cp( rWrt.Strm().Tell() ),
- rWrt.pFib->m_ccpText + rWrt.pFib->m_ccpFootnote
- + rWrt.pFib->m_ccpHdr + rWrt.pFib->m_ccpAtn );
+ rWrt.m_pFib->m_ccpText + rWrt.m_pFib->m_ccpFootnote
+ + rWrt.m_pFib->m_ccpHdr + rWrt.m_pFib->m_ccpAtn );
}
return bRet;
}
void WW8_WrPlcFootnoteEdn::WritePlc( WW8Export& rWrt ) const
{
- if( TXT_FTN == nTyp )
+ if( TXT_FTN == m_nTyp )
{
- WriteGenericPlc( rWrt, TXT_FTN, rWrt.pFib->m_fcPlcffndText,
- rWrt.pFib->m_lcbPlcffndText, rWrt.pFib->m_fcPlcffndRef,
- rWrt.pFib->m_lcbPlcffndRef );
+ WriteGenericPlc( rWrt, TXT_FTN, rWrt.m_pFib->m_fcPlcffndText,
+ rWrt.m_pFib->m_lcbPlcffndText, rWrt.m_pFib->m_fcPlcffndRef,
+ rWrt.m_pFib->m_lcbPlcffndRef );
}
else
{
- WriteGenericPlc( rWrt, TXT_EDN, rWrt.pFib->m_fcPlcfendText,
- rWrt.pFib->m_lcbPlcfendText, rWrt.pFib->m_fcPlcfendRef,
- rWrt.pFib->m_lcbPlcfendRef );
+ WriteGenericPlc( rWrt, TXT_EDN, rWrt.m_pFib->m_fcPlcfendText,
+ rWrt.m_pFib->m_lcbPlcfendText, rWrt.m_pFib->m_fcPlcfendRef,
+ rWrt.m_pFib->m_lcbPlcfendRef );
}
}
bool WW8_WrPlcAnnotations::WriteText( WW8Export& rWrt )
{
- bool bRet = WriteGenericText( rWrt, TXT_ATN, rWrt.pFib->m_ccpAtn );
+ bool bRet = WriteGenericText( rWrt, TXT_ATN, rWrt.m_pFib->m_ccpAtn );
rWrt.m_pFieldAtn->Finish( rWrt.Fc2Cp( rWrt.Strm().Tell() ),
- rWrt.pFib->m_ccpText + rWrt.pFib->m_ccpFootnote
- + rWrt.pFib->m_ccpHdr );
+ rWrt.m_pFib->m_ccpText + rWrt.m_pFib->m_ccpFootnote
+ + rWrt.m_pFib->m_ccpHdr );
return bRet;
}
void WW8_WrPlcAnnotations::WritePlc( WW8Export& rWrt ) const
{
- WriteGenericPlc( rWrt, TXT_ATN, rWrt.pFib->m_fcPlcfandText,
- rWrt.pFib->m_lcbPlcfandText, rWrt.pFib->m_fcPlcfandRef,
- rWrt.pFib->m_lcbPlcfandRef );
+ WriteGenericPlc( rWrt, TXT_ATN, rWrt.m_pFib->m_fcPlcfandText,
+ rWrt.m_pFib->m_lcbPlcfandText, rWrt.m_pFib->m_fcPlcfandRef,
+ rWrt.m_pFib->m_lcbPlcfandRef );
}
void WW8_WrPlcTextBoxes::WritePlc( WW8Export& rWrt ) const
{
- if( TXT_TXTBOX == nTyp )
+ if( TXT_TXTBOX == m_nTyp )
{
- WriteGenericPlc( rWrt, nTyp, rWrt.pFib->m_fcPlcftxbxBkd,
- rWrt.pFib->m_lcbPlcftxbxBkd, rWrt.pFib->m_fcPlcftxbxText,
- rWrt.pFib->m_lcbPlcftxbxText );
+ WriteGenericPlc( rWrt, m_nTyp, rWrt.m_pFib->m_fcPlcftxbxBkd,
+ rWrt.m_pFib->m_lcbPlcftxbxBkd, rWrt.m_pFib->m_fcPlcftxbxText,
+ rWrt.m_pFib->m_lcbPlcftxbxText );
}
else
{
- WriteGenericPlc( rWrt, nTyp, rWrt.pFib->m_fcPlcfHdrtxbxBkd,
- rWrt.pFib->m_lcbPlcfHdrtxbxBkd, rWrt.pFib->m_fcPlcfHdrtxbxText,
- rWrt.pFib->m_lcbPlcfHdrtxbxText );
+ WriteGenericPlc( rWrt, m_nTyp, rWrt.m_pFib->m_fcPlcfHdrtxbxBkd,
+ rWrt.m_pFib->m_lcbPlcfHdrtxbxBkd, rWrt.m_pFib->m_fcPlcfHdrtxbxText,
+ rWrt.m_pFib->m_lcbPlcfHdrtxbxText );
}
}
void WW8Export::RestoreMacroCmds()
{
- pFib->m_fcCmds = pTableStrm->Tell();
+ m_pFib->m_fcCmds = m_pTableStrm->Tell();
uno::Reference < embed::XStorage > xSrcRoot(m_rDoc.GetDocShell()->GetStorage());
try
@@ -4055,13 +4155,13 @@ void WW8Export::RestoreMacroCmds()
if ( pStream && ERRCODE_NONE == pStream->GetError())
{
- pFib->m_lcbCmds = pStream->TellEnd();
+ m_pFib->m_lcbCmds = pStream->TellEnd();
pStream->Seek(0);
- std::unique_ptr<sal_uInt8[]> pBuffer( new sal_uInt8[pFib->m_lcbCmds] );
- bool bReadOk = checkRead(*pStream, pBuffer.get(), pFib->m_lcbCmds);
+ std::unique_ptr<sal_uInt8[]> pBuffer( new sal_uInt8[m_pFib->m_lcbCmds] );
+ bool bReadOk = checkRead(*pStream, pBuffer.get(), m_pFib->m_lcbCmds);
if (bReadOk)
- pTableStrm->WriteBytes(pBuffer.get(), pFib->m_lcbCmds);
+ m_pTableStrm->WriteBytes(pBuffer.get(), m_pFib->m_lcbCmds);
}
}
catch ( const uno::Exception& )
@@ -4069,7 +4169,7 @@ void WW8Export::RestoreMacroCmds()
}
// set len to FIB
- pFib->m_lcbCmds = pTableStrm->Tell() - pFib->m_fcCmds;
+ m_pFib->m_lcbCmds = m_pTableStrm->Tell() - m_pFib->m_fcCmds;
}
void WW8SHDLong::Write( WW8Export& rExport )
@@ -4098,17 +4198,11 @@ void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark )
if ( rFieldmark.GetFieldname() == ODF_FORMDROPDOWN )
type=2;
- ::sw::mark::IFieldmark::parameter_map_t::const_iterator pParameter = rFieldmark.GetParameters()->find("name");
- OUString ffname;
- if ( pParameter != rFieldmark.GetParameters()->end() )
- {
- OUString aName;
- pParameter->second >>= aName;
- const sal_Int32 nLen = std::min( sal_Int32(20), aName.getLength() );
- ffname = aName.copy(0, nLen);
- }
+ OUString ffname = rFieldmark.GetName();
+ if (ffname.getLength() > 20)
+ ffname = ffname.copy(0, 20);
- sal_uInt64 nDataStt = pDataStrm->Tell();
+ sal_uInt64 nDataStt = m_pDataStrm->Tell();
m_pChpPlc->AppendFkpEntry(Strm().Tell());
WriteChar(0x01);
@@ -4158,10 +4252,12 @@ void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark )
OUString ffstattext;
OUString ffentrymcr;
OUString ffexitmcr;
+
+ ::sw::mark::IFieldmark::parameter_map_t::const_iterator pParameter
+ = rFieldmark.GetParameters()->find("Type");
if (type == 0) // iTypeText
{
sal_uInt16 nType = 0;
- pParameter = rFieldmark.GetParameters()->find("Type");
if ( pParameter != rFieldmark.GetParameters()->end() )
{
OUString aType;
@@ -4257,7 +4353,8 @@ void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark )
{
uno::Sequence< OUString > vListEntries;
pListEntries->second >>= vListEntries;
- copy(vListEntries.begin(), vListEntries.end(), back_inserter(aListItems));
+ aListItems.reserve(vListEntries.getLength());
+ copy(std::cbegin(vListEntries), std::cend(vListEntries), back_inserter(aListItems));
}
}
@@ -4293,33 +4390,33 @@ void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark )
}
}
- pDataStrm->WriteUInt32( slen );
+ m_pDataStrm->WriteUInt32( slen );
int len = sizeof( aFieldData );
OSL_ENSURE( len == 0x44-sizeof(sal_uInt32), "SwWW8Writer::WriteFormData(..) - wrong aFieldData length" );
- pDataStrm->WriteBytes( aFieldData, len );
+ m_pDataStrm->WriteBytes( aFieldData, len );
- pDataStrm->WriteUInt32( aFieldHeader.version ).WriteUInt16( aFieldHeader.bits ).WriteUInt16( aFieldHeader.cch ).WriteUInt16( aFieldHeader.hps );
+ m_pDataStrm->WriteUInt32( aFieldHeader.version ).WriteUInt16( aFieldHeader.bits ).WriteUInt16( aFieldHeader.cch ).WriteUInt16( aFieldHeader.hps );
- SwWW8Writer::WriteString_xstz( *pDataStrm, ffname, true ); // Form field name
+ SwWW8Writer::WriteString_xstz( *m_pDataStrm, ffname, true ); // Form field name
if ( !type )
- SwWW8Writer::WriteString_xstz( *pDataStrm, ffdeftext, true );
+ SwWW8Writer::WriteString_xstz( *m_pDataStrm, ffdeftext, true );
if ( type )
- pDataStrm->WriteUInt16( 0 );
+ m_pDataStrm->WriteUInt16( 0 );
- SwWW8Writer::WriteString_xstz( *pDataStrm, ffformat, true );
- SwWW8Writer::WriteString_xstz( *pDataStrm, ffhelptext, true );
- SwWW8Writer::WriteString_xstz( *pDataStrm, ffstattext, true );
- SwWW8Writer::WriteString_xstz( *pDataStrm, ffentrymcr, true );
- SwWW8Writer::WriteString_xstz( *pDataStrm, ffexitmcr, true );
+ SwWW8Writer::WriteString_xstz( *m_pDataStrm, ffformat, true );
+ SwWW8Writer::WriteString_xstz( *m_pDataStrm, ffhelptext, true );
+ SwWW8Writer::WriteString_xstz( *m_pDataStrm, ffstattext, true );
+ SwWW8Writer::WriteString_xstz( *m_pDataStrm, ffentrymcr, true );
+ SwWW8Writer::WriteString_xstz( *m_pDataStrm, ffexitmcr, true );
if (type==2) {
- pDataStrm->WriteUInt16( 0xFFFF );
+ m_pDataStrm->WriteUInt16( 0xFFFF );
const int items=aListItems.size();
- pDataStrm->WriteUInt32( items );
+ m_pDataStrm->WriteUInt32( items );
for(int i=0;i<items;i++) {
OUString item=aListItems[i];
- SwWW8Writer::WriteString_xstz( *pDataStrm, item, false );
+ SwWW8Writer::WriteString_xstz( *m_pDataStrm, item, false );
}
}
}
@@ -4329,7 +4426,7 @@ void WW8Export::WriteHyperlinkData( const sw::mark::IFieldmark& /*rFieldmark*/ )
//@TODO implement me !!!
}
-void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner )
+void WW8AttributeOutput::TableNodeInfoInner(const ww8::WW8TableNodeInfoInner::Pointer_t& pNodeInfoInner)
{
SVBT16 nStyle;
ShortToSVBT16( m_rWW8Export.m_nStyleBeforeFly, nStyle );
@@ -4338,7 +4435,7 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer
SAL_INFO( "sw.ww8", "<OutWW8_TableNodeInfoInner>" << pNodeInfoInner->toString());
#endif
- m_rWW8Export.pO->clear();
+ m_rWW8Export.m_pO->clear();
sal_uInt32 nShadowsBefore = pNodeInfoInner->getShadowsBefore();
if (nShadowsBefore > 0)
@@ -4353,12 +4450,12 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer
{
m_rWW8Export.WriteCR(pTmpNodeInfoInner);
- m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), nStyle, nStyle+2 ); // Style #
+ m_rWW8Export.m_pO->insert( m_rWW8Export.m_pO->end(), nStyle, nStyle+2 ); // Style #
TableInfoCell(pTmpNodeInfoInner);
m_rWW8Export.m_pPapPlc->AppendFkpEntry
- ( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
+ ( m_rWW8Export.Strm().Tell(), m_rWW8Export.m_pO->size(), m_rWW8Export.m_pO->data() );
- m_rWW8Export.pO->clear();
+ m_rWW8Export.m_pO->clear();
}
}
@@ -4368,11 +4465,11 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer
m_rWW8Export.WriteCR(pNodeInfoInner);
- m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), nStyle, nStyle+2 ); // Style #
+ m_rWW8Export.m_pO->insert( m_rWW8Export.m_pO->end(), nStyle, nStyle+2 ); // Style #
TableInfoCell(pNodeInfoInner);
- m_rWW8Export.m_pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
+ m_rWW8Export.m_pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.m_pO->size(), m_rWW8Export.m_pO->data() );
- m_rWW8Export.pO->clear();
+ m_rWW8Export.m_pO->clear();
}
sal_uInt32 nShadowsAfter = pNodeInfoInner->getShadowsAfter();
@@ -4388,11 +4485,11 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer
{
m_rWW8Export.WriteCR(pTmpNodeInfoInner);
- m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), nStyle, nStyle+2 ); // Style #
+ m_rWW8Export.m_pO->insert( m_rWW8Export.m_pO->end(), nStyle, nStyle+2 ); // Style #
TableInfoCell(pTmpNodeInfoInner);
- m_rWW8Export.m_pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
+ m_rWW8Export.m_pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.m_pO->size(), m_rWW8Export.m_pO->data() );
- m_rWW8Export.pO->clear();
+ m_rWW8Export.m_pO->clear();
}
}
@@ -4403,11 +4500,11 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer
TableRowEnd(pNodeInfoInner->getDepth());
ShortToSVBT16(0, nStyle);
- m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), nStyle, nStyle+2 ); // Style #
+ m_rWW8Export.m_pO->insert( m_rWW8Export.m_pO->end(), nStyle, nStyle+2 ); // Style #
TableInfoRow(pNodeInfoInner);
- m_rWW8Export.m_pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
+ m_rWW8Export.m_pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.m_pO->size(), m_rWW8Export.m_pO->data() );
- m_rWW8Export.pO->clear();
+ m_rWW8Export.m_pO->clear();
}
SAL_INFO( "sw.ww8", "</OutWW8_TableNodeInfoInner>" );
}
@@ -4491,4 +4588,53 @@ const NfKeywordTable & MSWordExportBase::GetNfKeywordTable()
return *m_pKeyMap;
}
+OUString MSWordExportBase::BookmarkToWord(const OUString& rBookmark, bool* pIsMove, bool* pIsFrom)
+{
+ OUString sLookup = rBookmark;
+ if (pIsMove)
+ {
+ static constexpr OUStringLiteral MoveFrom_Bookmark_NamePrefix = u"__RefMoveFrom__";
+ static constexpr OUStringLiteral MoveTo_Bookmark_NamePrefix = u"__RefMoveTo__";
+ if (rBookmark.startsWith(MoveFrom_Bookmark_NamePrefix, &sLookup))
+ {
+ *pIsMove = true;
+ *pIsFrom = true;
+ }
+ else if (rBookmark.startsWith(MoveTo_Bookmark_NamePrefix, &sLookup))
+ {
+ *pIsMove = true;
+ *pIsFrom = false;
+ }
+ }
+ if (auto it = m_aBookmarkToWord.find(sLookup); it != m_aBookmarkToWord.end())
+ return it->second;
+
+ OUString sRet
+ = INetURLObject::encode(sLookup.replace(' ', '_'), // Spaces are prohibited in bookmark name
+ INetURLObject::PART_REL_SEGMENT_EXTRA,
+ INetURLObject::EncodeMechanism::All, RTL_TEXTENCODING_ASCII_US);
+ // Unicode letters are allowed
+ sRet = INetURLObject::decode(sRet, INetURLObject::DecodeMechanism::Unambiguous,
+ RTL_TEXTENCODING_UTF8);
+
+ /*#i15387#*/
+ // Word has 40 character limit for bookmarks: [MS-OE376] Part 4 Sect. 2.13.6.2, bookmarkStart
+ if (sRet.getLength() > 40)
+ {
+ // Generate a unique bookmark name
+ sRet = sRet.copy(0, 40);
+ for (sal_uInt32 n = 1; n; ++n)
+ {
+ if (m_aWordBookmarks.find(sRet) == m_aWordBookmarks.end())
+ break;
+ auto num = OUString::number(n, 36);
+ sRet = sRet.subView(0, 40 - num.length) + num;
+ }
+ }
+
+ m_aBookmarkToWord[sLookup] = sRet;
+ m_aWordBookmarks.insert(sRet);
+ return sRet;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index c18a221fad00..e69d35e07c7a 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -21,10 +21,12 @@
#define INCLUDED_SW_SOURCE_FILTER_WW8_WRTWW8_HXX
#include <sot/storage.hxx>
+#include <svl/nfkeytab.hxx>
#include <tools/solar.h>
#include <tools/gen.hxx>
#include <editeng/editdata.hxx>
#include <filter/msfilter/ww8fields.hxx>
+#include <filter/msfilter/msoleexp.hxx>
#include <shellio.hxx>
@@ -49,6 +51,7 @@
#include <map>
#include <string_view>
#include <vector>
+#include <unordered_map>
class SvxBrushItem;
@@ -120,7 +123,6 @@ class WW8_WrPlcTextBoxes;
class WW8_WrPct; // administration
class WW8_WrtBookmarks;
class WW8_WrtRedlineAuthor;
-class SvxMSExportOLEObjects;
class SwMSConvertControls;
class WW8_WrPc;
struct WW8_PdAttrDesc;
@@ -195,7 +197,7 @@ class MSWordSections
{
protected:
bool mbDocumentIsProtected;
- std::vector<WW8_SepInfo> aSects;
+ std::vector<WW8_SepInfo> m_aSects;
void CheckForFacinPg( const WW8Export& rWrt ) const;
void NeedsDocumentProtected(const WW8_SepInfo &rInfo);
@@ -222,7 +224,7 @@ public:
sal_uInt16 CurrentNumberOfColumns( const SwDoc &rDoc ) const;
/// Number of columns of the provided WW8_SepInfo.
- static sal_uInt16 NumberOfColumns( const SwDoc &rDoc, const WW8_SepInfo& rInfo );
+ static const SwFormatCol& GetFormatCol(const SwDoc &rDoc, const WW8_SepInfo& rInfo);
bool DocumentIsProtected() const { return mbDocumentIsProtected; }
@@ -240,11 +242,11 @@ public:
class WW8_WrPlcSepx : public MSWordSections
{
- std::vector<WW8_CP> aCps;
+ std::vector<WW8_CP> m_aCps;
std::vector< std::shared_ptr<WW8_PdAttrDesc> > m_SectionAttributes;
// hack to prevent adding sections in endnotes
bool m_bHeaderFooterWritten;
- std::unique_ptr<WW8_WrPlc0> pTextPos; // Position of the headers/footers
+ std::unique_ptr<WW8_WrPlc0> m_pTextPos; // Position of the headers/footers
WW8_WrPlcSepx( const WW8_WrPlcSepx& ) = delete;
WW8_WrPlcSepx& operator=( const WW8_WrPlcSepx& ) = delete;
@@ -263,7 +265,7 @@ public:
const SwNode& rNd,
const SwSectionFormat* pSectionFormat,
sal_uLong nLnNumRestartNo );
- void Finish( WW8_CP nEndCp ) { aCps.push_back( nEndCp ); }
+ void Finish( WW8_CP nEndCp ) { m_aCps.push_back( nEndCp ); }
bool WriteKFText( WW8Export& rWrt );
void WriteSepx( SvStream& rStrm ) const;
@@ -281,7 +283,7 @@ public:
class WW8_WrPct
{
std::vector<std::unique_ptr<WW8_WrPc>> m_Pcts;
- WW8_FC nOldFc;
+ WW8_FC m_nOldFc;
public:
explicit WW8_WrPct(WW8_FC nStartFc);
~WW8_WrPct();
@@ -305,7 +307,7 @@ private:
FontFamily meFamily;
rtl_TextEncoding meChrSet;
public:
- wwFont( const OUString &rFamilyName, FontPitch ePitch, FontFamily eFamily,
+ wwFont( std::u16string_view rFamilyName, FontPitch ePitch, FontFamily eFamily,
rtl_TextEncoding eChrSet);
void Write( SvStream *pTableStram ) const;
void WriteDocx( DocxAttributeOutput* rAttrOutput ) const;
@@ -324,7 +326,7 @@ private:
std::vector< const wwFont* > AsVector() const;
public:
- wwFontHelper() : bLoadAllFonts(false) {}
+ wwFontHelper() : m_bLoadAllFonts(false) {}
/// rDoc used only to get the initial standard font(s) in use.
void InitFontTable(const SwDoc& rDoc);
sal_uInt16 GetId(const SvxFontItem& rFont);
@@ -334,7 +336,7 @@ public:
void WriteFontTable( const RtfAttributeOutput& rAttrOutput );
/// If true, all fonts are loaded before processing the document.
- bool bLoadAllFonts: 1;
+ bool m_bLoadAllFonts: 1;
};
class DrawObj
@@ -406,7 +408,7 @@ private:
HdFtPlcDrawObj& operator=(const HdFtPlcDrawObj&) = delete;
};
-typedef std::pair<OUString, sal_uLong> aBookmarkPair;
+typedef std::pair<OUString, SwNodeOffset> aBookmarkPair;
class WW8_WrtRedlineAuthor : public sw::util::WrtRedlineAuthor
{
@@ -432,7 +434,7 @@ struct MSWordSaveData
std::unique_ptr<ww::bytes> pOOld; ///< WW8Export only
std::shared_ptr<SwUnoCursor> pOldPam;
SwPaM* pOldEnd;
- sal_uLong nOldStart, nOldEnd;
+ SwNodeOffset nOldStart, nOldEnd;
const ww8::Frame* pOldFlyFormat;
const SwPageDesc* pOldPageDesc;
@@ -450,12 +452,12 @@ class MSWordExportBase
{
public:
wwFontHelper m_aFontHelper;
- std::vector<sal_uLong> m_aChapterFieldLocs;
+ std::vector<SwNodeOffset> m_aChapterFieldLocs;
OUString m_aMainStg;
std::vector<const SwTOXType*> m_aTOXArr;
const SfxItemSet* m_pISet; // for double attributes
const SwFrameFormat* m_pFirstPageFormat = nullptr;
- WW8_WrPct* m_pPiece; // Pointer to Piece-Table
+ std::unique_ptr<WW8_WrPct> m_pPiece; // Pointer to Piece-Table
std::unique_ptr<SwNumRuleTable> m_pUsedNumTable; // all used NumRules
/// overriding numdef index -> (existing numdef index, abstractnumdef index)
std::map<size_t, std::pair<size_t, size_t>> m_OverridingNums;
@@ -468,10 +470,10 @@ public:
const SwTextNode *m_pTopNodeOfHdFtPage; ///< Top node of host page when in hd/ft
std::stack< sal_Int32 > m_aCurrentCharPropStarts; ///< To remember the position in a run.
- WW8_WrtBookmarks* m_pBkmks;
- WW8_WrtRedlineAuthor* m_pRedlAuthors;
+ std::unique_ptr<WW8_WrtBookmarks> m_pBkmks;
+ std::unique_ptr<WW8_WrtRedlineAuthor> m_pRedlAuthors;
std::shared_ptr<NfKeywordTable> m_pKeyMap;
- std::unique_ptr<SvxMSExportOLEObjects> m_pOLEExp;
+ std::optional<SvxMSExportOLEObjects> m_oOLEExp;
std::unique_ptr<SwMSConvertControls> m_pOCXExp;
WW8OleMap m_aOleMap; // To remember all already exported ole objects
ww8::WW8TableInfo::Pointer_t m_pTableInfo;
@@ -494,14 +496,15 @@ public:
std::unordered_map<SwTOXMark const*, OUString> m_TOXMarkBookmarksByTOXMark;
ww8::Frames m_aFrames; // The floating frames in this document
const SwPageDesc *m_pCurrentPageDesc;
+ const SwPageDesc* m_pPreviousSectionPageDesc;
bool m_bFirstTOCNodeWithSection;
std::unique_ptr<WW8_WrPlcPn> m_pPapPlc;
std::unique_ptr<WW8_WrPlcPn> m_pChpPlc;
MSWordAttrIter* m_pChpIter;
std::unique_ptr<MSWordStyles> m_pStyles;
- WW8_WrPlcAnnotations* m_pAtn;
+ std::unique_ptr<WW8_WrPlcAnnotations> m_pAtn;
std::unique_ptr<WW8_WrtFactoids> m_pFactoids;
- WW8_WrPlcTextBoxes *m_pTextBxs, *m_pHFTextBxs;
+ std::unique_ptr<WW8_WrPlcTextBoxes> m_pTextBxs, m_pHFTextBxs;
struct LinkedTextboxInfo //help analyze textbox flow links
{
@@ -537,8 +540,8 @@ public:
const sw::BroadcastingModify* m_pOutFormatNode; // write Format or Node
const SwFormat *m_pCurrentStyle; // iff bStyDef=true, then this store the current style
- MainTextPlcDrawObj *m_pSdrObjs; // Draw-/Fly-Objects
- HdFtPlcDrawObj *m_pHFSdrObjs; // Draw-/Fly-Objects in header or footer
+ std::unique_ptr<MainTextPlcDrawObj> m_pSdrObjs; // Draw-/Fly-Objects
+ std::unique_ptr<HdFtPlcDrawObj> m_pHFSdrObjs; // Draw-/Fly-Objects in header or footer
SwEscherEx* m_pEscher; // escher export class
// #i43447# - removed
@@ -572,7 +575,7 @@ public:
bool m_bAddFootnoteTab; // only one aesthetic spacing tab per footnote
SwDoc& m_rDoc;
- sal_uLong m_nCurStart, m_nCurEnd;
+ SwNodeOffset m_nCurStart, m_nCurEnd;
std::shared_ptr<SwUnoCursor> & m_pCurPam;
SwPaM *m_pOrigPam;
@@ -599,7 +602,7 @@ public:
/// Set the pCurPam appropriately and call WriteText().
///
/// Used to export paragraphs in footnotes/endnotes/etc.
- void WriteSpecialText( sal_uLong nStart, sal_uLong nEnd, sal_uInt8 nTTyp );
+ void WriteSpecialText( SwNodeOffset nStart, SwNodeOffset nEnd, sal_uInt8 nTTyp );
/// Export the pool items to attributes (through an attribute output class).
void ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16 nScript, const SvxFontItem *pFont, bool bWriteCombChars = false );
@@ -637,7 +640,10 @@ public:
bool HasRefToFootOrEndnote(const bool isEndNote, const sal_uInt16 nSeqNo);
/// Find the bookmark name.
- static OUString GetBookmarkName( sal_uInt16 nTyp, const OUString* pName, sal_uInt16 nSeqNo );
+ OUString GetBookmarkName( sal_uInt16 nTyp, const OUString* pName, sal_uInt16 nSeqNo );
+
+ /// Find out which style we should use in OOXML
+ OUString GetStyleRefName(const OUString& rName);
/// Use OutputItem() on an item set according to the parameters.
void OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, bool bChpFormat, sal_uInt16 nScript, bool bExportParentItemSet );
@@ -655,6 +661,7 @@ public:
/// List is set to restart at a particular value so for export make a
/// completely new list based on this one and export that instead,
/// which duplicates words behaviour in this respect.
+ sal_uInt16 DuplicateNumRule(const SwNumRule* pRule, sal_uInt8 nLevel, sal_uInt16 nVal);
SwNumRule * DuplicateNumRuleImpl(const SwNumRule *pRule);
/// check if a new abstractNum is needed for this list
@@ -703,7 +710,7 @@ public:
/// has two
virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ) = 0;
- virtual void AppendBookmarks( const SwTextNode& rNd, sal_Int32 nCurrentPos, sal_Int32 nLen ) = 0;
+ virtual void AppendBookmarks( const SwTextNode& rNd, sal_Int32 nCurrentPos, sal_Int32 nLen, const SwRedlineData* pSwRedline = nullptr ) = 0;
virtual void AppendBookmark( const OUString& rName ) = 0;
@@ -731,7 +738,7 @@ public:
void SetCurItemSet( const SfxItemSet* pS ) { m_pISet = pS; }
/// Remember some of the members so that we can recurse in WriteText().
- virtual void SaveData( sal_uLong nStt, sal_uLong nEnd );
+ virtual void SaveData( SwNodeOffset nStt, SwNodeOffset nEnd );
/// Restore what was saved in SaveData().
virtual void RestoreData();
@@ -808,13 +815,19 @@ public:
// Compute the number format for WW dates
bool GetNumberFormat(const SwField& rField, OUString& rStr);
- virtual sal_uLong ReplaceCr( sal_uInt8 nChar ) = 0;
+ virtual sal_uInt64 ReplaceCr( sal_uInt8 nChar ) = 0;
const SfxPoolItem* HasItem( sal_uInt16 nWhich ) const;
+ template<class T> const T* HasItem(TypedWhichId<T> nWhich) const
+ {
+ return static_cast<const T*>(HasItem(sal_uInt16(nWhich)));
+ }
/// Returns the index of a picture bullet, used in numberings.
int GetGrfIndex(const SvxBrushItem& rBrush);
+ tools::Long GetParaTabStopOffset() const;
+
enum ExportFormat { DOC = 0, RTF = 1, DOCX = 2};
virtual ExportFormat GetExportFormat() const = 0;
@@ -898,7 +911,7 @@ protected:
const NfKeywordTable & GetNfKeywordTable();
- void SetCurPam(sal_uLong nStt, sal_uLong nEnd);
+ void SetCurPam(SwNodeOffset nStt, SwNodeOffset nEnd);
/// Get background color of the document, if there is one.
std::unique_ptr<SvxBrushItem> getBackground();
@@ -920,9 +933,15 @@ public:
static void CorrectTabStopInSet( SfxItemSet& rSet, sal_Int32 nAbsLeft );
+ OUString BookmarkToWord(const OUString& rBookmark, bool* pIsMove = nullptr,
+ bool* pIsFrom = nullptr);
+
private:
MSWordExportBase( const MSWordExportBase& ) = delete;
MSWordExportBase& operator=( const MSWordExportBase& ) = delete;
+
+ std::unordered_map<OUString, OUString> m_aBookmarkToWord;
+ o3tl::sorted_vector<OUString> m_aWordBookmarks;
};
/// The writer class that gets called for the WW8 filter.
@@ -937,11 +956,11 @@ friend void WW8_WrtRedlineAuthor::Write(Writer &rWrt);
SfxMedium *mpMedium;
public:
- SwWW8Writer(const OUString& rFltName, const OUString& rBaseURL);
+ SwWW8Writer(std::u16string_view rFltName, const OUString& rBaseURL);
virtual ~SwWW8Writer() override;
- virtual ErrCode WriteStorage() override;
- virtual ErrCode WriteMedium( SfxMedium& ) override;
+ virtual ErrCodeMsg WriteStorage() override;
+ virtual ErrCodeMsg WriteMedium( SfxMedium& ) override;
// TODO most probably we want to be able to get these in
// MSExportFilterBase
@@ -973,7 +992,7 @@ public:
bool InitStd97CodecUpdateMedium( ::msfilter::MSCodec_Std97& rCodec );
using StgWriter::Write;
- virtual ErrCode Write( SwPaM&, SfxMedium&, const OUString* ) override;
+ virtual ErrCodeMsg Write( SwPaM&, SfxMedium&, const OUString* ) override;
//Seems not an expected to provide method to access the private member
SfxMedium* GetMedia() { return mpMedium; }
@@ -987,15 +1006,15 @@ private:
class WW8Export : public MSWordExportBase
{
public:
- std::unique_ptr<ww::bytes> pO; ///< Buffer
+ std::unique_ptr<ww::bytes> m_pO; ///< Buffer
- SvStream *pTableStrm, *pDataStrm; ///< Streams for WW97 Export
+ SvStream *m_pTableStrm, *m_pDataStrm; ///< Streams for WW97 Export
- std::unique_ptr<WW8Fib> pFib; ///< File Information Block
- std::unique_ptr<WW8Dop> pDop; ///< Document Properties
- std::unique_ptr<WW8_WrPlcFootnoteEdn> pFootnote; ///< Footnotes - structure to remember them, and output
- std::unique_ptr<WW8_WrPlcFootnoteEdn> pEdn; ///< Endnotes - structure to remember them, and output
- std::unique_ptr<WW8_WrPlcSepx> pSepx; ///< Sections/headers/footers
+ std::unique_ptr<WW8Fib> m_pFib; ///< File Information Block
+ std::unique_ptr<WW8Dop> m_pDop; ///< Document Properties
+ std::unique_ptr<WW8_WrPlcFootnoteEdn> m_pFootnote; ///< Footnotes - structure to remember them, and output
+ std::unique_ptr<WW8_WrPlcFootnoteEdn> m_pEdn; ///< Endnotes - structure to remember them, and output
+ std::unique_ptr<WW8_WrPlcSepx> m_pSepx; ///< Sections/headers/footers
bool m_bDot; ///< Template or document.
@@ -1004,7 +1023,7 @@ protected:
std::unique_ptr<WW8AttributeOutput> m_pAttrOutput; ///< Converting attributes to stream data
private:
- tools::SvRef<SotStorage> xEscherStg; /// memory leak #i120098#, to hold the reference to unnamed SotStorage obj
+ rtl::Reference<SotStorage> m_xEscherStg; /// memory leak #i120098#, to hold the reference to unnamed SotStorage obj
public:
/// Access to the attribute output class.
@@ -1069,11 +1088,11 @@ public:
void StartCommentOutput( std::u16string_view rName );
void EndCommentOutput( std::u16string_view rName );
void OutGrf(const ww8::Frame &rFrame);
- bool TestOleNeedsGraphic(const SwAttrSet& rSet, tools::SvRef<SotStorage> const& xOleStg,
- const tools::SvRef<SotStorage>& xObjStg, OUString const& rStorageName,
+ bool TestOleNeedsGraphic(const SwAttrSet& rSet, rtl::Reference<SotStorage> const& xOleStg,
+ const rtl::Reference<SotStorage>& xObjStg, OUString const& rStorageName,
SwOLENode* pOLENd);
- virtual void AppendBookmarks( const SwTextNode& rNd, sal_Int32 nCurrentPos, sal_Int32 nLen ) override;
+ virtual void AppendBookmarks( const SwTextNode& rNd, sal_Int32 nCurrentPos, sal_Int32 nLen, const SwRedlineData* pRedlineData = nullptr ) override;
virtual void AppendBookmark( const OUString& rName ) override;
void AppendBookmarkEndWithCorrection( const OUString& rName );
@@ -1089,7 +1108,7 @@ public:
void WriteAsStringTable(const std::vector<OUString>&, sal_Int32& rfcSttbf,
sal_Int32& rlcbSttbf);
- virtual sal_uLong ReplaceCr( sal_uInt8 nChar ) override;
+ virtual sal_uInt64 ReplaceCr( sal_uInt8 nChar ) override;
virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t() ) override;
void WriteChar( sal_Unicode c ) override;
@@ -1101,7 +1120,7 @@ public:
// some partly static semi-internal function declarations
void OutSprmBytes( sal_uInt8* pBytes, sal_uInt16 nSiz )
- { pO->insert( pO->end(), pBytes, pBytes+nSiz ); }
+ { m_pO->insert( m_pO->end(), pBytes, pBytes+nSiz ); }
virtual void SectionBreaksAndFrames( const SwTextNode& rNode ) override;
@@ -1148,9 +1167,9 @@ public:
void MiserableRTLFrameFormatHack(SwTwips &rLeft, SwTwips &rRight,
const ww8::Frame &rFrameFormat);
- void InsUInt16( sal_uInt16 n ) { SwWW8Writer::InsUInt16( *pO, n ); }
+ void InsUInt16( sal_uInt16 n ) { SwWW8Writer::InsUInt16( *m_pO, n ); }
void InsInt16(sal_Int16 n) { InsUInt16(sal_uInt16(n)); }
- void InsUInt32( sal_uInt32 n ) { SwWW8Writer::InsUInt32( *pO, n ); }
+ void InsUInt32( sal_uInt32 n ) { SwWW8Writer::InsUInt32( *m_pO, n ); }
void WriteStringAsPara( const OUString& rText );
/// Setup the exporter.
@@ -1180,7 +1199,7 @@ public:
SvStream& Strm() const { return m_pWriter->Strm(); }
/// Remember some of the members so that we can recurse in WriteText().
- virtual void SaveData( sal_uLong nStt, sal_uLong nEnd ) override;
+ virtual void SaveData( SwNodeOffset nStt, SwNodeOffset nEnd ) override;
/// Restore what was saved in SaveData().
virtual void RestoreData() override;
@@ -1214,10 +1233,10 @@ private:
WW8_WrPlcSubDoc(const WW8_WrPlcSubDoc&) = delete;
WW8_WrPlcSubDoc& operator=(const WW8_WrPlcSubDoc&) = delete;
protected:
- std::vector<WW8_CP> aCps;
- std::vector<const void*> aContent; // PTRARR of SwFormatFootnote/PostIts/..
- std::vector<const SwFrameFormat*> aSpareFormats; // a backup for aContent: if there's no SdrObject, stores the fmt directly here
- std::unique_ptr<WW8_WrPlc0> pTextPos; // positions of the individual texts
+ std::vector<WW8_CP> m_aCps;
+ std::vector<const void*> m_aContent; // PTRARR of SwFormatFootnote/PostIts/..
+ std::vector<const SwFrameFormat*> m_aSpareFormats; // a backup for aContent: if there's no SdrObject, stores the fmt directly here
+ std::unique_ptr<WW8_WrPlc0> m_pTextPos; // positions of the individual texts
WW8_WrPlcSubDoc();
virtual ~WW8_WrPlcSubDoc();
@@ -1233,12 +1252,12 @@ protected:
class WW8_WrPlcFootnoteEdn : public WW8_WrPlcSubDoc
{
private:
- sal_uInt8 nTyp;
+ sal_uInt8 m_nTyp;
WW8_WrPlcFootnoteEdn(const WW8_WrPlcFootnoteEdn&) = delete;
WW8_WrPlcFootnoteEdn& operator=(WW8_WrPlcFootnoteEdn const &) = delete;
public:
- explicit WW8_WrPlcFootnoteEdn( sal_uInt8 nTTyp ) : nTyp( nTTyp ) {}
+ explicit WW8_WrPlcFootnoteEdn( sal_uInt8 nTTyp ) : m_nTyp( nTTyp ) {}
bool WriteText( WW8Export& rWrt );
void WritePlc( WW8Export& rWrt ) const;
@@ -1284,36 +1303,36 @@ public:
class WW8_WrPlcTextBoxes : public WW8_WrPlcSubDoc // double Plc for Textboxes
{ // Frame/DrawTextboxes!
private:
- sal_uInt8 nTyp;
- std::vector<sal_uInt32> aShapeIds; // VARARR of ShapeIds for the SwFrameFormats
+ sal_uInt8 m_nTyp;
+ std::vector<sal_uInt32> m_aShapeIds; // VARARR of ShapeIds for the SwFrameFormats
virtual const std::vector<sal_uInt32>* GetShapeIdArr() const override;
WW8_WrPlcTextBoxes(const WW8_WrPlcTextBoxes&) = delete;
WW8_WrPlcTextBoxes& operator=(WW8_WrPlcTextBoxes const &) = delete;
public:
- explicit WW8_WrPlcTextBoxes( sal_uInt8 nTTyp ) : nTyp( nTTyp ) {}
+ explicit WW8_WrPlcTextBoxes( sal_uInt8 nTTyp ) : m_nTyp( nTTyp ) {}
bool WriteText( WW8Export& rWrt );
void WritePlc( WW8Export& rWrt ) const;
void Append( const SdrObject& rObj, sal_uInt32 nShapeId );
void Append( const SwFrameFormat* pFormat, sal_uInt32 nShapeId );
- sal_uInt16 Count() const { return aContent.size(); }
+ sal_uInt16 Count() const { return m_aContent.size(); }
sal_uInt16 GetPos( const void* p ) const
{
std::vector<const void*>::const_iterator it
- = std::find( aContent.begin(), aContent.end(), p );
- return it == aContent.end() ? USHRT_MAX : it - aContent.begin();
+ = std::find( m_aContent.begin(), m_aContent.end(), p );
+ return it == m_aContent.end() ? USHRT_MAX : it - m_aContent.begin();
}
};
class WW8_WrPlcPn // Plc for Page Numbers
{
private:
- WW8Export& rWrt;
+ WW8Export& m_rWrt;
// Plc for Chpx and Papx ( incl PN-Plc )
std::vector<std::unique_ptr<WW8_WrFkp>> m_Fkps;
- sal_uInt16 nFkpStartPage;
- ePLCFT ePlc;
+ sal_uInt16 m_nFkpStartPage;
+ ePLCFT m_ePlc;
WW8_WrPlcPn(const WW8_WrPlcPn&) = delete;
WW8_WrPlcPn& operator=(const WW8_WrPlcPn&) = delete;
@@ -1330,15 +1349,15 @@ public:
class WW8_WrPlc1
{
private:
- std::vector<WW8_CP> aPos;
- std::unique_ptr<sal_uInt8[]> pData; // content ( structures )
- sal_uLong nDataLen;
- sal_uInt16 nStructSiz;
+ std::vector<WW8_CP> m_aPos;
+ std::unique_ptr<sal_uInt8[]> m_pData; // content ( structures )
+ sal_uLong m_nDataLen;
+ sal_uInt16 m_nStructSiz;
WW8_WrPlc1(const WW8_WrPlc1&) = delete;
WW8_WrPlc1& operator=(const WW8_WrPlc1&) = delete;
protected:
- sal_uInt16 Count() const { return aPos.size(); }
+ sal_uInt16 Count() const { return m_aPos.size(); }
void Write( SvStream& rStrm );
WW8_CP Prev() const;
public:
@@ -1352,18 +1371,18 @@ public:
class WW8_WrPlcField : public WW8_WrPlc1
{
private:
- sal_uInt8 nTextTyp;
- sal_uInt16 nResults;
+ sal_uInt8 m_nTextTyp;
+ sal_uInt16 m_nResults;
WW8_WrPlcField(const WW8_WrPlcField&) = delete;
WW8_WrPlcField& operator=(const WW8_WrPlcField&) = delete;
public:
WW8_WrPlcField( sal_uInt16 nStructSz, sal_uInt8 nTTyp )
- : WW8_WrPlc1( nStructSz ), nTextTyp( nTTyp ), nResults(0)
+ : WW8_WrPlc1( nStructSz ), m_nTextTyp( nTTyp ), m_nResults(0)
{}
void Write( WW8Export& rWrt );
- void ResultAdded() { ++nResults; }
- sal_uInt16 ResultCount() const { return nResults; }
+ void ResultAdded() { ++m_nResults; }
+ sal_uInt16 ResultCount() const { return m_nResults; }
};
class WW8_WrMagicTable : public WW8_WrPlc1
@@ -1381,7 +1400,7 @@ class GraphicDetails
{
public:
ww8::Frame maFly; // surrounding FlyFrames
- sal_uLong mnPos; // FilePos of the graphics
+ sal_uInt64 mnPos; // FilePos of the graphics
sal_uInt16 mnWid; // Width of the graphics
sal_uInt16 mnHei; // Height of the graphics
@@ -1403,7 +1422,7 @@ class SwWW8WrGrf
{
private:
/// for access to the variables
- WW8Export& rWrt;
+ WW8Export& m_rWrt;
std::vector<GraphicDetails> maDetails;
sal_uInt16 mnIdx; // index in file positions
@@ -1421,7 +1440,7 @@ private:
SwWW8WrGrf(const SwWW8WrGrf&) = delete;
SwWW8WrGrf& operator=(const SwWW8WrGrf&) = delete;
public:
- explicit SwWW8WrGrf( WW8Export& rW ) : rWrt( rW ), mnIdx( 0 ) {}
+ explicit SwWW8WrGrf( WW8Export& rW ) : m_rWrt( rW ), mnIdx( 0 ) {}
void Insert(const ww8::Frame &rFly);
void Write();
sal_uLong GetFPos()
@@ -1434,7 +1453,7 @@ public:
class MSWordAttrIter
{
private:
- MSWordAttrIter* pOld;
+ MSWordAttrIter* m_pOld;
MSWordAttrIter(const MSWordAttrIter&) = delete;
MSWordAttrIter& operator=(const MSWordAttrIter&) = delete;
protected:
@@ -1444,23 +1463,27 @@ public:
virtual ~MSWordAttrIter();
virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const = 0;
+ template<class T> const T* HasTextItem( TypedWhichId<T> nWhich ) const
+ {
+ return static_cast<const T*>(HasTextItem(sal_uInt16(nWhich)));
+ }
virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const = 0;
- };
+};
/// Used to export formatted text associated to drawings.
class MSWord_SdrAttrIter : public MSWordAttrIter
{
private:
- const EditTextObject* pEditObj;
- const SfxItemPool* pEditPool;
- std::vector<EECharAttrib> aTextAtrArr;
- std::vector<const EECharAttrib*> aChrTextAtrArr;
- std::vector<rtl_TextEncoding> aChrSetArr;
- sal_Int32 nPara;
- sal_Int32 nCurrentSwPos;
- sal_Int32 nTmpSwPos; // for HasItem()
- rtl_TextEncoding eNdChrSet;
- sal_uInt16 nScript;
+ const EditTextObject* m_pEditObj;
+ const SfxItemPool* m_pEditPool;
+ std::vector<EECharAttrib> m_aTextAtrArr;
+ std::vector<const EECharAttrib*> m_aChrTextAtrArr;
+ std::vector<rtl_TextEncoding> m_aChrSetArr;
+ sal_Int32 m_nPara;
+ sal_Int32 m_nCurrentSwPos;
+ sal_Int32 m_nTmpSwPos; // for HasItem()
+ rtl_TextEncoding m_eNdChrSet;
+ sal_uInt16 m_nScript;
sal_uInt8 mnTyp;
sal_Int32 SearchNext( sal_Int32 nStartPos );
@@ -1479,14 +1502,14 @@ public:
bool IsTextAttr(sal_Int32 nSwPos);
- void NextPos() { if ( nCurrentSwPos < SAL_MAX_INT32 ) nCurrentSwPos = SearchNext( nCurrentSwPos + 1 ); }
+ void NextPos() { if ( m_nCurrentSwPos < SAL_MAX_INT32 ) m_nCurrentSwPos = SearchNext( m_nCurrentSwPos + 1 ); }
void OutAttr( sal_Int32 nSwPos );
virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const override;
virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const override;
- sal_Int32 WhereNext() const { return nCurrentSwPos; }
+ sal_Int32 WhereNext() const { return m_nCurrentSwPos; }
rtl_TextEncoding GetNextCharSet() const;
- rtl_TextEncoding GetNodeCharSet() const { return eNdChrSet; }
+ rtl_TextEncoding GetNodeCharSet() const { return m_eNdChrSet; }
};
// class SwWW8AttrIter is a helper for constructing the Fkp.chpx.
@@ -1499,7 +1522,7 @@ public:
class SwWW8AttrIter : public MSWordAttrIter
{
private:
- const SwTextNode& rNd;
+ const SwTextNode& m_rNode;
sw::util::CharRuns maCharRuns;
sw::util::CharRuns::const_iterator maCharRunIter;
@@ -1508,9 +1531,9 @@ private:
sal_uInt16 mnScript;
bool mbCharIsRTL;
- const SwRangeRedline* pCurRedline;
- sal_Int32 nCurrentSwPos;
- SwRedlineTable::size_type nCurRedlinePos;
+ const SwRangeRedline* m_pCurRedline;
+ sal_Int32 m_nCurrentSwPos;
+ SwRedlineTable::size_type m_nCurRedlinePos;
bool mbParaIsRTL;
@@ -1528,7 +1551,7 @@ private:
SwWW8AttrIter(const SwWW8AttrIter&) = delete;
SwWW8AttrIter& operator=(const SwWW8AttrIter&) = delete;
- void handleToggleProperty(SfxItemSet& rExportSet, const SwFormatCharFormat* pCharFormatItem, sal_uInt16 nWhich, const SfxPoolItem* pValue);
+ void handleToggleProperty(SfxItemSet& rExportSet, const SwFormatCharFormat& rCharFormatItem);
public:
SwWW8AttrIter( MSWordExportBase& rWr, const SwTextNode& rNd );
@@ -1538,9 +1561,9 @@ public:
bool IsDropCap( int nSwPos );
bool RequiresImplicitBookmark();
- void NextPos() { if ( nCurrentSwPos < SAL_MAX_INT32 ) nCurrentSwPos = SearchNext( nCurrentSwPos + 1 ); }
+ void NextPos() { if ( m_nCurrentSwPos < SAL_MAX_INT32 ) m_nCurrentSwPos = SearchNext( m_nCurrentSwPos + 1 ); }
- void OutAttr(sal_Int32 nSwPos, bool bWriteCombinedChars, bool bPostponeSingleUse = false);
+ void OutAttr(sal_Int32 nSwPos, bool bWriteCombinedChars);
virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const override;
virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const override;
int OutAttrWithRange(const SwTextNode& rNode, sal_Int32 nPos);
@@ -1549,7 +1572,7 @@ public:
FlyProcessingState OutFlys(sal_Int32 nSwPos);
bool HasFlysAt(sal_Int32 nSwPos) const;
- sal_Int32 WhereNext() const { return nCurrentSwPos; }
+ sal_Int32 WhereNext() const { return m_nCurrentSwPos; }
sal_uInt16 GetScript() const { return mnScript; }
bool IsParaRTL() const { return mbParaIsRTL; }
rtl_TextEncoding GetCharSet() const { return meChrSet; }
@@ -1558,11 +1581,11 @@ public:
const SwFormatDrop& GetSwFormatDrop() const { return mrSwFormatDrop; }
bool IsWatermarkFrame();
- bool IsAnchorLinkedToThisNode( sal_uLong nNodePos );
+ bool IsAnchorLinkedToThisNode( SwNodeOffset nNodePos );
void SplitRun( sal_Int32 nSplitEndPos );
- const SwTextNode& GetNode() const { return rNd; }
+ const SwTextNode& GetNode() const { return m_rNode; }
};
/// Class to collect and output the styles table.
@@ -1570,26 +1593,34 @@ class MSWordStyles
{
MSWordExportBase& m_rExport;
sal_uInt16 m_aHeadingParagraphStyles[MAXLEVEL];
- std::unique_ptr<SwFormat*[]> m_pFormatA; ///< Slot <-> Character and paragraph style array (0 for list styles).
- sal_uInt16 m_nUsedSlots;
- bool m_bListStyles; ///< If list styles are requested to be exported as well.
- std::map<sal_uInt16, const SwNumRule*> m_aNumRules; ///< Slot <-> List style map.
- /// We need to build style id's for DOCX export; ideally we should roundtrip that, but this is good enough.
- std::vector<OString> m_aStyleIds;
+ struct MapEntry
+ {
+ const SwFormat* format = nullptr;
+ const SwNumRule* num_rule = nullptr;
+ /// We need to build style id's for DOCX export; ideally we should roundtrip that, but this is good enough.
+ sal_uInt16 ww_id = ww::stiUser;
+ OUString ww_name;
+ OString style_id;
+
+ MapEntry() = default;
+ MapEntry(const SwFormat* f) : format(f) { if (f) ww_id = GetWWId(*f); }
+ MapEntry(const SwNumRule* r) : num_rule(r) {}
+ };
+ std::vector<MapEntry> m_aStyles; ///< Slot <-> Character/paragraph/list style array.
+ bool m_bListStyles; ///< If list styles are requested to be exported as well.
/// Create the style table, called from the constructor.
void BuildStylesTable();
- /// Based on pFormatA, fill in m_aStyleIds with unique, MS-like names.
- void BuildStyleIds();
+ /// Generate proper Word names, taking mapping between special types into account
+ void BuildWwNames();
- /// Get slot number during building the style table.
- sal_uInt16 BuildGetSlot( const SwFormat& rFormat );
- sal_uInt16 BuildGetSlot( const SwNumRule& /*rNumRule*/ ) { return m_nUsedSlots++;}
+ /// Based on style names, fill in unique, MS-like names.
+ void BuildStyleIds();
/// Return information about one style.
- void GetStyleData( SwFormat* pFormat, bool& bFormatColl, sal_uInt16& nBase, sal_uInt16& nNext );
+ void GetStyleData( const SwFormat* pFormat, bool& bFormatColl, sal_uInt16& nBase, sal_uInt16& nNext, sal_uInt16& nLink );
/// Outputs attributes of one style.
void WriteProperties( const SwFormat* pFormat, bool bPap, sal_uInt16 nPos, bool bInsDefCharSiz );
@@ -1599,8 +1630,7 @@ class MSWordStyles
void SetStyleDefaults( const SwFormat& rFormat, bool bPap );
/// Outputs one style - called (in a loop) from OutputStylesTable().
- void OutputStyle( SwFormat* pFormat, sal_uInt16 nPos );
- void OutputStyle( const SwNumRule* pNumRule, sal_uInt16 nPos );
+ void OutputStyle( sal_uInt16 nSlot );
MSWordStyles( const MSWordStyles& ) = delete;
MSWordStyles& operator=( const MSWordStyles& ) = delete;
@@ -1612,18 +1642,20 @@ public:
/// Output the styles table.
void OutputStylesTable();
- /// Get id of the style (rFormat).
+ /// Get slot of the style (rFormat).
sal_uInt16 GetSlot( const SwFormat* pFormat ) const;
/// create style id using only ASCII characters of the style name
- static OString CreateStyleId(const OUString &rName);
+ static OString CreateStyleId(std::u16string_view aName);
- /// Get styleId of the nId-th style (nId is its position in pFormatA).
- OString const & GetStyleId(sal_uInt16 nId) const;
+ /// Get styleId of the nSlot-th style (nSlot is its position in m_aStyles).
+ OString const & GetStyleId(sal_uInt16 nSlot) const;
+ /// the awful TOC field references names, not styleIds
+ OUString GetStyleWWName(SwFormat const* pFormat) const;
- const SwFormat* GetSwFormat(sal_uInt16 nId) const { return m_pFormatA[nId]; }
- /// Get numbering rule of the nId-th style
- const SwNumRule* GetSwNumRule(sal_uInt16 nId) const;
+ const SwFormat* GetSwFormat(sal_uInt16 nSlot) const { return m_aStyles[nSlot].format; }
+ /// Get numbering rule of the nSlot-th style
+ const SwNumRule* GetSwNumRule(sal_uInt16 nSlot) const { return m_aStyles[nSlot].num_rule; }
sal_uInt16 GetHeadingParagraphStyleId(sal_uInt16 nLevel) const { return m_aHeadingParagraphStyles[ nLevel ]; }
};
@@ -1632,7 +1664,6 @@ public:
sal_Int16 GetWordFirstLineOffset(const SwNumFormat &rFormat);
// A bit of a bag on the side for now
OUString FieldString(ww::eField eIndex);
-OUString BookmarkToWord(const OUString &rBookmark);
class WW8SHDLong
{
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index b79641c5372a..9b041e4a5c32 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -60,6 +60,7 @@
#include <IDocumentDrawModelAccess.hxx>
#include <drawdoc.hxx>
+#include <o3tl/string_view.hxx>
using namespace ::com::sun::star;
@@ -78,12 +79,12 @@ void WW8Export::OutputGrfNode( const SwGrfNode& /*rNode*/ )
if ( m_pParentFrame )
{
OutGrf( *m_pParentFrame );
- pFib->m_fHasPic = true;
+ m_pFib->m_fHasPic = true;
}
}
-bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, tools::SvRef<SotStorage> const& xOleStg,
- const tools::SvRef<SotStorage>& xObjStg,
+bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, rtl::Reference<SotStorage> const& xOleStg,
+ const rtl::Reference<SotStorage>& xObjStg,
OUString const& rStorageName, SwOLENode* pOLENd)
{
bool bGraphicNeeded = false;
@@ -129,7 +130,7 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, tools::SvRef<SotStora
sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
if ( pOLENd )
nAspect = pOLENd->GetAspect();
- SdrOle2Obj *pRet = SvxMSDffManager::CreateSdrOLEFromStorage(
+ rtl::Reference<SdrOle2Obj> pRet = SvxMSDffManager::CreateSdrOLEFromStorage(
*m_rDoc.getIDocumentDrawModelAccess().GetOrCreateDrawModel(),
rStorageName,
xObjStg,
@@ -169,12 +170,12 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, tools::SvRef<SotStora
{
Graphic aGr1;
GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
- if( rGF.ImportGraphic( aGr1, OUString(), *pGraphicStream ) == ERRCODE_NONE )
+ if( rGF.ImportGraphic( aGr1, u"", *pGraphicStream ) == ERRCODE_NONE )
{
Graphic aGr2;
pGraphicStream =
::utl::UcbStreamHelper::CreateStream( aCnt.GetGraphicStream( pRet->GetObjRef() ) );
- if( pGraphicStream && rGF.ImportGraphic( aGr2, OUString(), *pGraphicStream ) == ERRCODE_NONE )
+ if( pGraphicStream && rGF.ImportGraphic( aGr2, u"", *pGraphicStream ) == ERRCODE_NONE )
{
if ( aGr1 == aGr2 )
bGraphicNeeded = false;
@@ -182,10 +183,6 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, tools::SvRef<SotStora
}
}
}
-
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(pRet);
- SdrObject::Free(pTemp);
}
}
else
@@ -209,7 +206,7 @@ void WW8Export::OutputOLENode( const SwOLENode& rOLENode )
nSize = sizeof( aSpecOLE_WW8 );
pDataAdr = pSpecOLE + 2; //WW6 sprm is 1 but has 1 byte len as well.
- tools::SvRef<SotStorage> xObjStg = GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool);
+ rtl::Reference<SotStorage> xObjStg = GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool);
if( !xObjStg.is() )
return;
@@ -230,7 +227,7 @@ void WW8Export::OutputOLENode( const SwOLENode& rOLENode )
nPictureId = aRes.first->second;
Set_UInt32(pDataAdr, nPictureId);
OUString sStorageName = "_" + OUString::number( nPictureId );
- tools::SvRef<SotStorage> xOleStg = xObjStg->OpenSotStorage( sStorageName );
+ rtl::Reference<SotStorage> xOleStg = xObjStg->OpenSotStorage(sStorageName);
if( !xOleStg.is() )
return;
@@ -242,14 +239,14 @@ void WW8Export::OutputOLENode( const SwOLENode& rOLENode )
{
sal_Int64 nAspect = rOLENode.GetAspect();
svt::EmbeddedObjectRef aObjRef( xObj, nAspect );
- m_pOLEExp->ExportOLEObject( aObjRef, *xOleStg );
+ m_oOLEExp->ExportOLEObject( aObjRef, *xOleStg );
if ( nAspect == embed::Aspects::MSOLE_ICON )
{
OUString aObjInfo( "\3ObjInfo" );
if ( !xOleStg->IsStream( aObjInfo ) )
{
const sal_uInt8 pObjInfoData[] = { 0x40, 0x00, 0x03, 0x00 };
- tools::SvRef<SotStorageStream> rObjInfoStream = xOleStg->OpenSotStream( aObjInfo );
+ rtl::Reference<SotStorageStream> rObjInfoStream = xOleStg->OpenSotStream(aObjInfo);
if ( rObjInfoStream.is() && !rObjInfoStream->GetError() )
{
rObjInfoStream->WriteBytes(pObjInfoData, sizeof(pObjInfoData));
@@ -320,14 +317,14 @@ void WW8Export::OutputLinkedOLE( const OUString& rOleId )
{
uno::Reference< embed::XStorage > xDocStg = m_rDoc.GetDocStorage();
uno::Reference< embed::XStorage > xOleStg = xDocStg->openStorageElement( "OLELinks", embed::ElementModes::READ );
- tools::SvRef<SotStorage> xObjSrc = SotStorage::OpenOLEStorage( xOleStg, rOleId, StreamMode::READ );
+ rtl::Reference<SotStorage> xObjSrc = SotStorage::OpenOLEStorage( xOleStg, rOleId, StreamMode::READ );
- tools::SvRef<SotStorage> xObjStg = GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool);
+ rtl::Reference<SotStorage> xObjStg = GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool);
if( !(xObjStg.is() && xObjSrc.is()) )
return;
- tools::SvRef<SotStorage> xOleDst = xObjStg->OpenSotStorage( rOleId );
+ rtl::Reference<SotStorage> xOleDst = xObjStg->OpenSotStorage(rOleId);
if ( xOleDst.is() )
xObjSrc->CopyTo( xOleDst.get() );
@@ -339,7 +336,7 @@ void WW8Export::OutputLinkedOLE( const OUString& rOleId )
// Output the cPicLocation attribute
std::unique_ptr<ww::bytes> pBuf( new ww::bytes );
SwWW8Writer::InsUInt16( *pBuf, NS_sprm::CPicLocation::val );
- SwWW8Writer::InsUInt32( *pBuf, rOleId.copy( 1 ).toInt32() );
+ SwWW8Writer::InsUInt32( *pBuf, o3tl::toInt32(rOleId.subView( 1 )) );
SwWW8Writer::InsUInt16( *pBuf, NS_sprm::CFOle2::val );
pBuf->push_back( 1 );
@@ -368,8 +365,8 @@ void WW8Export::OutGrf(const ww8::Frame &rFrame)
// Store the graphic settings in GrfNode so they may be written-out later
m_pGrf->Insert(rFrame);
- m_pChpPlc->AppendFkpEntry( Strm().Tell(), pO->size(), pO->data() );
- pO->clear();
+ m_pChpPlc->AppendFkpEntry( Strm().Tell(), m_pO->size(), m_pO->data() );
+ m_pO->clear();
// #i29408#
// linked, as-character anchored graphics have to be exported as fields.
@@ -444,15 +441,15 @@ void WW8Export::OutGrf(const ww8::Frame &rFrame)
WriteChar( char(0x0d) ); // close the surrounding frame with CR
static sal_uInt8 nSty[2] = { 0, 0 };
- pO->insert( pO->end(), nSty, nSty+2 ); // Style #0
+ m_pO->insert( m_pO->end(), nSty, nSty+2 ); // Style #0
bool bOldGrf = m_bOutGrf;
m_bOutGrf = true;
OutputFormat( rFrame.GetFrameFormat(), false, false, true ); // Fly-Attrs
m_bOutGrf = bOldGrf;
- m_pPapPlc->AppendFkpEntry( Strm().Tell(), pO->size(), pO->data() );
- pO->clear();
+ m_pPapPlc->AppendFkpEntry( Strm().Tell(), m_pO->size(), m_pO->data() );
+ m_pO->clear();
}
// #i29408#
// linked, as-character anchored graphics have to be exported as fields.
@@ -481,17 +478,16 @@ void SwWW8WrGrf::WritePICFHeader(SvStream& rStrm, const ww8::Frame &rFly,
sal_Int16 nCropL = 0, nCropR = 0, nCropT = 0, nCropB = 0;
// write Crop-Attribute content in Header ( if available )
- const SfxPoolItem* pItem;
- if (pAttrSet && (SfxItemState::SET
- == pAttrSet->GetItemState(RES_GRFATR_CROPGRF, false, &pItem)))
+ const SwCropGrf* pCropItem;
+ if (pAttrSet && (pCropItem
+ = pAttrSet->GetItemIfSet(RES_GRFATR_CROPGRF, false)))
{
- const SwCropGrf& rCr = *static_cast<const SwCropGrf*>(pItem);
- nCropL = static_cast<sal_Int16>(rCr.GetLeft());
- nCropR = static_cast<sal_Int16>(rCr.GetRight());
- nCropT = static_cast<sal_Int16>(rCr.GetTop());
- nCropB = static_cast<sal_Int16>(rCr.GetBottom());
- nXSizeAdd = nXSizeAdd - static_cast<sal_Int16>( rCr.GetLeft() + rCr.GetRight() );
- nYSizeAdd = nYSizeAdd - static_cast<sal_Int16>( rCr.GetTop() + rCr.GetBottom() );
+ nCropL = static_cast<sal_Int16>(pCropItem->GetLeft());
+ nCropR = static_cast<sal_Int16>(pCropItem->GetRight());
+ nCropT = static_cast<sal_Int16>(pCropItem->GetTop());
+ nCropB = static_cast<sal_Int16>(pCropItem->GetBottom());
+ nXSizeAdd = nXSizeAdd - static_cast<sal_Int16>( pCropItem->GetLeft() + pCropItem->GetRight() );
+ nYSizeAdd = nYSizeAdd - static_cast<sal_Int16>( pCropItem->GetTop() + pCropItem->GetBottom() );
}
Size aGrTwipSz(rFly.GetSize());
@@ -502,58 +498,54 @@ void SwWW8WrGrf::WritePICFHeader(SvStream& rStrm, const ww8::Frame &rFly,
sal_uInt8* pArr = aArr + 0x2E; // Do borders first
const SwAttrSet& rAttrSet = rFly.GetFrameFormat().GetAttrSet();
- if (SfxItemState::SET == rAttrSet.GetItemState(RES_BOX, false, &pItem))
+ if (const SvxBoxItem* pBox = rAttrSet.GetItemIfSet(RES_BOX, false))
{
- const SvxBoxItem* pBox = static_cast<const SvxBoxItem*>(pItem);
- if( pBox )
+ bool bShadow = false; // Shadow ?
+ if (const SvxShadowItem* pSI = rAttrSet.GetItem<SvxShadowItem>(RES_SHADOW))
+ {
+ bShadow = (pSI->GetLocation() != SvxShadowLocation::NONE) &&
+ (pSI->GetWidth() != 0);
+ }
+
+ static const SvxBoxItemLine aLnArr[4] = { SvxBoxItemLine::TOP, SvxBoxItemLine::LEFT,
+ SvxBoxItemLine::BOTTOM, SvxBoxItemLine::RIGHT };
+ for(const SvxBoxItemLine & i : aLnArr)
{
- bool bShadow = false; // Shadow ?
- if (const SvxShadowItem* pSI = rAttrSet.GetItem<SvxShadowItem>(RES_SHADOW))
+ const ::editeng::SvxBorderLine* pLn = pBox->GetLine( i );
+ WW8_BRC aBrc;
+ if (pLn)
{
- bShadow = (pSI->GetLocation() != SvxShadowLocation::NONE) &&
- (pSI->GetWidth() != 0);
+ WW8_BRCVer9 aBrc90 = WW8Export::TranslateBorderLine( *pLn,
+ pBox->GetDistance( i ), bShadow );
+ sal_uInt8 ico = msfilter::util::TransColToIco(msfilter::util::BGRToRGB(
+ aBrc90.cv()));
+ aBrc = WW8_BRC(aBrc90.dptLineWidth(), aBrc90.brcType(), ico,
+ aBrc90.dptSpace(), aBrc90.fShadow(), aBrc90.fFrame());
}
- static const SvxBoxItemLine aLnArr[4] = { SvxBoxItemLine::TOP, SvxBoxItemLine::LEFT,
- SvxBoxItemLine::BOTTOM, SvxBoxItemLine::RIGHT };
- for(const SvxBoxItemLine & i : aLnArr)
+ // use importer logic to determine how large the exported
+ // border will really be in word and adjust accordingly
+ short nSpacing;
+ short nThick = aBrc.DetermineBorderProperties(&nSpacing);
+ switch (i)
{
- const ::editeng::SvxBorderLine* pLn = pBox->GetLine( i );
- WW8_BRC aBrc;
- if (pLn)
- {
- WW8_BRCVer9 aBrc90 = WW8Export::TranslateBorderLine( *pLn,
- pBox->GetDistance( i ), bShadow );
- sal_uInt8 ico = msfilter::util::TransColToIco(msfilter::util::BGRToRGB(
- aBrc90.cv()));
- aBrc = WW8_BRC(aBrc90.dptLineWidth(), aBrc90.brcType(), ico,
- aBrc90.dptSpace(), aBrc90.fShadow(), aBrc90.fFrame());
- }
-
- // use importer logic to determine how large the exported
- // border will really be in word and adjust accordingly
- short nSpacing;
- short nThick = aBrc.DetermineBorderProperties(&nSpacing);
- switch (i)
- {
- case SvxBoxItemLine::TOP:
- case SvxBoxItemLine::BOTTOM:
- nHeight -= bShadow ? nThick*2 : nThick;
- nHeight = nHeight - nSpacing;
- break;
- case SvxBoxItemLine::LEFT:
- case SvxBoxItemLine::RIGHT:
- default:
- nWidth -= bShadow ? nThick*2 : nThick;
- nWidth = nWidth - nSpacing;
- break;
- }
- memcpy( pArr, &aBrc.aBits1, 2);
- pArr+=2;
-
- memcpy( pArr, &aBrc.aBits2, 2);
- pArr+=2;
+ case SvxBoxItemLine::TOP:
+ case SvxBoxItemLine::BOTTOM:
+ nHeight -= bShadow ? nThick*2 : nThick;
+ nHeight = nHeight - nSpacing;
+ break;
+ case SvxBoxItemLine::LEFT:
+ case SvxBoxItemLine::RIGHT:
+ default:
+ nWidth -= bShadow ? nThick*2 : nThick;
+ nWidth = nWidth - nSpacing;
+ break;
}
+ memcpy( pArr, &aBrc.aBits1, 2);
+ pArr+=2;
+
+ memcpy( pArr, &aBrc.aBits2, 2);
+ pArr+=2;
}
}
@@ -589,7 +581,7 @@ void SwWW8WrGrf::WritePICFHeader(SvStream& rStrm, const ww8::Frame &rFly,
if ( !bIsSubstitutedSize )
{
const double fVal = nWidth * 1000.0 / (aGrTwipSz.Width() + nXSizeAdd );
- Set_UInt16( pArr, static_cast<sal_uInt16>(::rtl::math::round(fVal)) );
+ Set_UInt16( pArr, o3tl::narrowing<sal_uInt16>(::rtl::math::round(fVal)) );
}
else
{
@@ -606,7 +598,7 @@ void SwWW8WrGrf::WritePICFHeader(SvStream& rStrm, const ww8::Frame &rFly,
if ( !bIsSubstitutedSize )
{
const double fVal = nHeight * 1000.0 / (aGrTwipSz.Height() + nYSizeAdd);
- Set_UInt16( pArr, static_cast<sal_uInt16>(::rtl::math::round(fVal)) );
+ Set_UInt16( pArr, o3tl::narrowing<sal_uInt16>(::rtl::math::round(fVal)) );
}
else
{
@@ -649,7 +641,7 @@ void SwWW8WrGrf::WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rGrfNd,
{
WritePICFHeader(rStrm, rFly, 0x64, nWidth, nHeight,
rGrfNd.GetpSwAttrSet());
- SwBasicEscherEx aInlineEscher(&rStrm, rWrt);
+ SwBasicEscherEx aInlineEscher(&rStrm, m_rWrt);
aInlineEscher.WriteGrfFlyFrame(rFly.GetFrameFormat(), 0x401);
aInlineEscher.WritePictures();
}
@@ -720,7 +712,7 @@ void SwWW8WrGrf::WritePICBulletFHeader(SvStream& rStrm, const Graphic &rGrf,
if( aGrTwipSz.Width() + nXSizeAdd ) // set mx
{
double fVal = nWidth * 1000.0 / (aGrTwipSz.Width() + nXSizeAdd);
- Set_UInt16( pArr, static_cast<sal_uInt16>(::rtl::math::round(fVal)) );
+ Set_UInt16( pArr, o3tl::narrowing<sal_uInt16>(::rtl::math::round(fVal)) );
}
else
pArr += 2;
@@ -728,7 +720,7 @@ void SwWW8WrGrf::WritePICBulletFHeader(SvStream& rStrm, const Graphic &rGrf,
if( aGrTwipSz.Height() + nYSizeAdd ) // set my
{
double fVal = nHeight * 1000.0 / (aGrTwipSz.Height() + nYSizeAdd);
- Set_UInt16( pArr, static_cast<sal_uInt16>(::rtl::math::round(fVal)) );
+ Set_UInt16( pArr, o3tl::narrowing<sal_uInt16>(::rtl::math::round(fVal)) );
}
else
pArr += 2;
@@ -744,7 +736,7 @@ void SwWW8WrGrf::WritePICBulletFHeader(SvStream& rStrm, const Graphic &rGrf,
void SwWW8WrGrf::WriteGrfForBullet(SvStream& rStrm, const Graphic &rGrf, sal_uInt16 nWidth, sal_uInt16 nHeight)
{
WritePICBulletFHeader(rStrm,rGrf, 0x64,nWidth,nHeight);
- SwBasicEscherEx aInlineEscher(&rStrm, rWrt);
+ SwBasicEscherEx aInlineEscher(&rStrm, m_rWrt);
aInlineEscher.WriteGrfBullet(rGrf);
aInlineEscher.WritePictures();
}
@@ -753,7 +745,7 @@ void SwWW8WrGrf::WriteGraphicNode(SvStream& rStrm, const GraphicDetails &rItem)
{
sal_uInt16 nWidth = rItem.mnWid;
sal_uInt16 nHeight = rItem.mnHei;
- sal_uInt32 nPos = rStrm.Tell(); // store start of graphic
+ sal_uInt64 nPos = rStrm.Tell(); // store start of graphic
const ww8::Frame &rFly = rItem.maFly;
switch (rFly.GetWriterType())
@@ -792,7 +784,7 @@ void SwWW8WrGrf::WriteGraphicNode(SvStream& rStrm, const GraphicDetails &rItem)
//documents.
WritePICFHeader(rStrm, rFly, 0x64, nWidth, nHeight,
pNd->GetpSwAttrSet());
- SwBasicEscherEx aInlineEscher(&rStrm, rWrt);
+ SwBasicEscherEx aInlineEscher(&rStrm, m_rWrt);
aInlineEscher.WriteOLEFlyFrame(rFly.GetFrameFormat(), 0x401);
aInlineEscher.WritePictures();
#else
@@ -833,7 +825,7 @@ void SwWW8WrGrf::WriteGraphicNode(SvStream& rStrm, const GraphicDetails &rItem)
*/
{
WritePICFHeader(rStrm, rFly, 0x64, nWidth, nHeight);
- SwBasicEscherEx aInlineEscher(&rStrm, rWrt);
+ SwBasicEscherEx aInlineEscher(&rStrm, m_rWrt);
aInlineEscher.WriteEmptyFlyFrame(rFly.GetFrameFormat(), 0x401);
}
break;
@@ -842,7 +834,7 @@ void SwWW8WrGrf::WriteGraphicNode(SvStream& rStrm, const GraphicDetails &rItem)
break;
}
- sal_uInt32 nPos2 = rStrm.Tell(); // store the end
+ sal_uInt64 nPos2 = rStrm.Tell(); // store the end
rStrm.Seek( nPos );
rStrm.WriteUInt32(nPos2 - nPos); // patch graphic length in the header
rStrm.Seek( nPos2 ); // restore Pos
@@ -856,11 +848,11 @@ void SwWW8WrGrf::WriteGraphicNode(SvStream& rStrm, const GraphicDetails &rItem)
// GetFPos() sequentially the positions
void SwWW8WrGrf::Write()
{
- SvStream& rStrm = *rWrt.pDataStrm;
+ SvStream& rStrm = *m_rWrt.m_pDataStrm;
auto aEnd = maDetails.end();
for (auto aIter = maDetails.begin(); aIter != aEnd; ++aIter)
{
- sal_uInt32 nPos = rStrm.Tell(); // align to 4 Bytes
+ sal_uInt64 nPos = rStrm.Tell(); // align to 4 Bytes
if( nPos & 0x3 )
SwWW8Writer::FillCount( rStrm, 4 - ( nPos & 0x3 ) );
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 5d120613e4d5..30fbebc4fbc3 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -31,6 +31,7 @@
#include <vcl/settings.hxx>
#include <sal/log.hxx>
+#include <svl/numformat.hxx>
#include <svl/zformat.hxx>
#include <svl/itemiter.hxx>
#include <svl/whiter.hxx>
@@ -77,6 +78,7 @@
#include <editeng/paperinf.hxx>
#include <svx/xfillit0.hxx>
#include <svx/xflgrit.hxx>
+#include <o3tl/string_view.hxx>
#include <fmtfld.hxx>
#include <fchrfmt.hxx>
#include <fmtfsize.hxx>
@@ -126,6 +128,7 @@
#include <fmthdft.hxx>
#include <authfld.hxx>
#include <dbfld.hxx>
+#include <docsh.hxx>
#include "sprmids.hxx"
@@ -136,8 +139,9 @@
#include "ww8par.hxx"
#include "ww8attributeoutput.hxx"
#include "fields.hxx"
+#include <i18nlangtag/mslangid.hxx>
#include <i18nlangtag/languagetag.hxx>
-#include <unotools/fltrcfg.hxx>
+#include <officecfg/Office/Common.hxx>
using ::editeng::SvxBorderLine;
@@ -314,7 +318,6 @@ void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, b
if( !(bExportParentItemSet || rSet.Count()) )
return;
- const SfxPoolItem* pItem;
m_pISet = &rSet; // for double attributes
// If frame dir is set, but not adjust, then force adjust as well
@@ -323,7 +326,7 @@ void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, b
// No explicit adjust set ?
if ( SfxItemState::SET != rSet.GetItemState( RES_PARATR_ADJUST, bExportParentItemSet ) )
{
- pItem = rSet.GetItem( RES_PARATR_ADJUST, bExportParentItemSet );
+ const SvxAdjustItem* pItem = rSet.GetItem( RES_PARATR_ADJUST, bExportParentItemSet );
if ( nullptr != pItem )
{
// then set the adjust used by the parent format
@@ -332,17 +335,26 @@ void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, b
}
}
- if ( bPapFormat && SfxItemState::SET == rSet.GetItemState( RES_PARATR_NUMRULE, bExportParentItemSet, &pItem ) )
+ const SwNumRuleItem* pRuleItem;
+ if ( bPapFormat && (pRuleItem = rSet.GetItemIfSet( RES_PARATR_NUMRULE, bExportParentItemSet )) )
{
- AttrOutput().OutputItem( *pItem );
+ AttrOutput().OutputItem( *pRuleItem );
// switch off the numbering?
- if ( pItem->StaticWhichCast(RES_PARATR_NUMRULE).GetValue().isEmpty() &&
- SfxItemState::SET != rSet.GetItemState( RES_LR_SPACE, false) &&
- SfxItemState::SET == rSet.GetItemState( RES_LR_SPACE, true, &pItem ) )
+ const SfxPoolItem* pLRItem;
+ if ( pRuleItem->GetValue().isEmpty() &&
+ SfxItemState::SET != rSet.GetItemState(RES_MARGIN_FIRSTLINE, false) &&
+ (pLRItem = rSet.GetItemIfSet(RES_MARGIN_FIRSTLINE)) )
+ {
+ // set the LR-Space of the parentformat!
+ AttrOutput().OutputItem( *pLRItem );
+ }
+ if ( pRuleItem->GetValue().isEmpty() &&
+ SfxItemState::SET != rSet.GetItemState(RES_MARGIN_TEXTLEFT, false) &&
+ (pLRItem = rSet.GetItemIfSet(RES_MARGIN_TEXTLEFT)) )
{
- // the set the LR-Space of the parentformat!
- AttrOutput().OutputItem( *pItem );
+ // set the LR-Space of the parentformat!
+ AttrOutput().OutputItem( *pLRItem );
}
}
@@ -356,7 +368,7 @@ void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, b
for ( const auto& rItem : aItems )
{
- pItem = rItem.second;
+ const SfxPoolItem* pItem = rItem.second;
sal_uInt16 nWhich = pItem->Which();
// Handle fill attributes just like frame attributes for now.
if ( (nWhich >= RES_PARATR_BEGIN && nWhich < RES_FRMATR_END && nWhich != RES_PARATR_NUMRULE ) ||
@@ -410,11 +422,11 @@ bool MSWordExportBase::ContentContainsChapterField(const SwFormatContent &rConte
{
SwNodeIndex aIdx( *pSttIdx, 1 );
SwNodeIndex aEnd( *pSttIdx->GetNode().EndOfSectionNode() );
- sal_uLong nStart = aIdx.GetIndex();
- sal_uLong nEnd = aEnd.GetIndex();
+ SwNodeOffset nStart = aIdx.GetIndex();
+ SwNodeOffset nEnd = aEnd.GetIndex();
//If the header/footer contains a chapter field
bRet = std::any_of(m_aChapterFieldLocs.cbegin(), m_aChapterFieldLocs.cend(),
- [nStart, nEnd](sal_uLong i) { return ( nStart <= i ) && ( i <= nEnd ); });
+ [nStart, nEnd](SwNodeOffset i) { return ( nStart <= i ) && ( i <= nEnd ); });
}
return bRet;
}
@@ -481,7 +493,6 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode
m_bBreakBefore = true;
bool bNewPageDesc = false;
- const SfxPoolItem* pItem=nullptr;
const SwFormatPageDesc *pPgDesc=nullptr;
bool bExtraPageBreakBeforeSectionBreak = false;
@@ -514,23 +525,43 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode
if ( pSet && pSet->Count() )
{
- if ( SfxItemState::SET == pSet->GetItemState( RES_PAGEDESC, false, &pItem ) &&
- pItem->StaticWhichCast(RES_PAGEDESC).GetRegisteredIn() != nullptr)
+ const SwFormatPageDesc * pItem = pSet->GetItemIfSet( RES_PAGEDESC, false );
+ if ( pItem && pItem->GetRegisteredIn() != nullptr)
{
bBreakSet = true;
- bNewPageDesc = true;
- pPgDesc = static_cast<const SwFormatPageDesc*>(pItem);
+ // Avoid unnecessary section breaks if possible. LO can't notice identical
+ // sections during import, so minimize unnecessary duplication
+ // by substituting a simple page break when the resulting section is identical,
+ // unless this is needed to re-number the page.
+ // DOCX only.
+ if (!bNewPageDesc && !pItem->GetNumOffset() && !PreferPageBreakBefore()
+ && m_pCurrentPageDesc && m_pCurrentPageDesc->GetFollow() == pItem->GetPageDesc())
+ {
+ // A section break on the very first paragraph is ignored by LO/Word
+ // and should NOT be turned into a page break.
+ SwNodeIndex aDocEnd(m_rDoc.GetNodes().GetEndOfContent());
+ SwNodeIndex aStart(*aDocEnd.GetNode().StartOfSectionNode());
+ // Set aStart to the first content node in the section
+ SwNodes::GoNext(&aStart);
+ assert(aStart <= aDocEnd && "impossible: end section must have one content node");
+ if (rNd.GetIndex() > aStart.GetNode().GetIndex())
+ AttrOutput().OutputItem(SvxFormatBreakItem(SvxBreak::PageBefore, RES_BREAK));
+ }
+ else
+ bNewPageDesc = true;
+
+ pPgDesc = pItem;
m_pCurrentPageDesc = pPgDesc->GetPageDesc();
// tdf#121666: nodes that have pagebreak + sectionbreak may need to export both breaks
// tested / implemented with docx format only.
// If other formats (rtf /doc) need similar fix, then that may can be done similar way.
- if (SfxItemState::SET == pSet->GetItemState(RES_BREAK, false, &pItem))
+ if (SfxItemState::SET == pSet->GetItemState(RES_BREAK, false))
{
bExtraPageBreakBeforeSectionBreak = true;
}
}
- else if ( SfxItemState::SET == pSet->GetItemState( RES_BREAK, false, &pItem ) )
+ else if ( const SvxFormatBreakItem* pBreak = pSet->GetItemIfSet( RES_BREAK, false ) )
{
// Word does not like hard break attributes in some table cells
bool bRemoveHardBreakInsideTable = false;
@@ -568,15 +599,38 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode
if ( m_pCurrentPageDesc )
{
// #i76301# - assure that there is a page break before set at the node.
- const SvxFormatBreakItem* pBreak = dynamic_cast<const SvxFormatBreakItem*>(pItem);
- if ( pBreak &&
- pBreak->GetBreak() == SvxBreak::PageBefore )
+ if ( pBreak->GetBreak() == SvxBreak::PageBefore )
{
bNewPageDesc |= SetCurrentPageDescFromNode( rNd );
}
}
+
+ // If the columns are different in LO's adjacent sections, create a new MS section
+ if (!bNewPageDesc && pBreak->GetBreak() == SvxBreak::PageBefore
+ && Sections().CurrentSectionInfo())
+ {
+ const SwSectionFormat* pSectionFormat = MSWordExportBase::GetSectionFormat(rNd);
+ if (pSectionFormat)
+ {
+ const SwFormatCol& rNewSect = pSectionFormat->GetFormatAttr(RES_COL);
+ const SwFormatCol& rPrevSect
+ = MSWordSections::GetFormatCol(m_rDoc,
+ *Sections().CurrentSectionInfo());
+ if (rNewSect.GetNumCols() != rPrevSect.GetNumCols()
+ || !rNewSect.IsOrtho() || !rPrevSect.IsOrtho()
+ || rNewSect.GetLineStyle() != rPrevSect.GetLineStyle()
+ || rNewSect.GetLineWidth() != rPrevSect.GetLineWidth()
+ || rNewSect.GetLineColor() != rPrevSect.GetLineColor()
+ || rNewSect.GetLineHeight() != rPrevSect.GetLineHeight()
+ || rNewSect.GetLineAdj() != rPrevSect.GetLineAdj())
+ {
+ bNewPageDesc = true;
+ }
+ }
+ }
+
if ( !bNewPageDesc )
- AttrOutput().OutputItem( *pItem );
+ AttrOutput().OutputItem( *pBreak );
}
}
}
@@ -593,15 +647,13 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode
{
if ( const SwContentNode *pNd = rNd.GetContentNode() )
{
- const SvxFormatBreakItem &rBreak =
- ItemGet<SvxFormatBreakItem>( *pNd, RES_BREAK );
+ const SvxFormatBreakItem &rBreak = pNd->GetAttr( RES_BREAK );
if ( rBreak.GetBreak() == SvxBreak::PageBefore )
bHackInBreak = true;
else
{ // Even a pagedesc item is set, the break item can be set 'NONE',
// but a pagedesc item is an implicit page break before...
- const SwFormatPageDesc &rPageDesc =
- ItemGet<SwFormatPageDesc>( *pNd, RES_PAGEDESC );
+ const SwFormatPageDesc &rPageDesc = pNd->GetAttr( RES_PAGEDESC );
if ( rPageDesc.KnowsPageDesc() )
bHackInBreak = true;
}
@@ -656,11 +708,11 @@ sal_uLong MSWordExportBase::GetSectionLineNo( const SfxItemSet* pSet, const SwNo
const SwFormatLineNumber* pNItem = nullptr;
if ( pSet )
{
- pNItem = &( ItemGet<SwFormatLineNumber>( *pSet, RES_LINENUMBER ) );
+ pNItem = & pSet->Get( RES_LINENUMBER );
}
else if ( const SwContentNode *pNd = rNd.GetContentNode() )
{
- pNItem = &( ItemGet<SwFormatLineNumber>( *pNd, RES_LINENUMBER ) );
+ pNItem = &pNd->GetAttr( RES_LINENUMBER );
}
return pNItem? pNItem->GetStartValue() : 0;
@@ -691,11 +743,11 @@ void WW8Export::PrepareNewPageDesc( const SfxItemSet*pSet,
if ( pNewPgDescFormat )
{
- pSepx->AppendSep( Fc2Cp( nFcPos ), *pNewPgDescFormat, rNd, pFormat, nLnNm );
+ m_pSepx->AppendSep( Fc2Cp( nFcPos ), *pNewPgDescFormat, rNd, pFormat, nLnNm );
}
else if ( pNewPgDesc )
{
- pSepx->AppendSep( Fc2Cp( nFcPos ), pNewPgDesc, rNd, pFormat, nLnNm );
+ m_pSepx->AppendSep( Fc2Cp( nFcPos ), pNewPgDesc, rNd, pFormat, nLnNm );
}
}
@@ -724,6 +776,21 @@ void MSWordExportBase::CorrectTabStopInSet( SfxItemSet& rSet, sal_Int32 nAbsLeft
rSet.Put( aTStop );
}
+tools::Long MSWordExportBase::GetParaTabStopOffset() const
+{
+ tools::Long nOffset = 0;
+ // Tabs are absolute by default.
+ if (m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::TABS_RELATIVE_TO_INDENT))
+ {
+ // don't do it for editengine text, it doesn't implement this anyway
+ if (!m_pISet || m_pISet->GetRanges()[0].first < RES_WHICHHINT_END)
+ {
+ nOffset = GetItem(RES_MARGIN_TEXTLEFT).GetTextLeft();
+ }
+ }
+ return nOffset;
+}
+
sal_uInt8 WW8Export::GetNumId( sal_uInt16 eNumType )
{
sal_uInt8 nRet = 0;
@@ -735,10 +802,42 @@ sal_uInt8 WW8Export::GetNumId( sal_uInt16 eNumType )
case SVX_NUM_CHARS_LOWER_LETTER_N: nRet = 4; break;
case SVX_NUM_ROMAN_UPPER: nRet = 1; break;
case SVX_NUM_ROMAN_LOWER: nRet = 2; break;
+ case style::NumberingType::TEXT_NUMBER: nRet = 5; break;
+ case style::NumberingType::TEXT_CARDINAL: nRet = 6; break;
+ case style::NumberingType::TEXT_ORDINAL: nRet = 7; break;
+ case style::NumberingType::AIU_HALFWIDTH_JA: nRet = 12; break;
+ case style::NumberingType::IROHA_HALFWIDTH_JA: nRet = 13; break;
+ case style::NumberingType::FULLWIDTH_ARABIC: nRet = 14; break;
+ case style::NumberingType::NUMBER_TRADITIONAL_JA: nRet = 16; break;
+ case style::NumberingType::CIRCLE_NUMBER: nRet = 18; break;
+ case style::NumberingType::AIU_FULLWIDTH_JA: nRet = 20; break;
+ case style::NumberingType::IROHA_FULLWIDTH_JA: nRet = 21; break;
case SVX_NUM_BITMAP:
case SVX_NUM_CHAR_SPECIAL: nRet = 23; break;
-
+ case style::NumberingType::HANGUL_SYLLABLE_KO: nRet = 24; break;// ganada
+ case style::NumberingType::HANGUL_JAMO_KO: nRet = 25; break;// chosung
+ case style::NumberingType::HANGUL_CIRCLED_SYLLABLE_KO: nRet = 24; break;
+ case style::NumberingType::HANGUL_CIRCLED_JAMO_KO: nRet = 25; break;
+ case style::NumberingType::TIAN_GAN_ZH: nRet = 30; break;
+ case style::NumberingType::DI_ZI_ZH: nRet = 31; break;
+ case style::NumberingType::NUMBER_UPPER_ZH_TW: nRet = 34;break;
+ case style::NumberingType::NUMBER_UPPER_ZH: nRet = 38; break;
+ case style::NumberingType::NUMBER_DIGITAL_KO: nRet = 41; break;
+ case style::NumberingType::NUMBER_HANGUL_KO: nRet = 42; break;
+ case style::NumberingType::NUMBER_LEGAL_KO: nRet = 43; break;
+ case style::NumberingType::NUMBER_DIGITAL2_KO: nRet = 44; break;
+ case style::NumberingType::NUMBER_HEBREW: nRet = 45; break;
+ case style::NumberingType::CHARS_ARABIC: nRet = 46; break;
+ case style::NumberingType::CHARS_HEBREW: nRet = 47; break;
+ case style::NumberingType::CHARS_ARABIC_ABJAD: nRet = 48; break;
+ case style::NumberingType::CHARS_PERSIAN:
+ case style::NumberingType::CHARS_NEPALI: nRet = 49; break;
+ case style::NumberingType::CHARS_THAI: nRet = 53; break;
+ case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_N_RU:
+ case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_RU: nRet = 58; break;
+ case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_N_RU:
+ case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_RU: nRet = 59; break;
// nothing, WW does the same (undocumented)
case SVX_NUM_NUMBER_NONE: nRet = 0xff; break;
case SVX_NUM_SYMBOL_CHICAGO:
@@ -753,18 +852,9 @@ sal_uInt8 WW8Export::GetNumId( sal_uInt16 eNumType )
return nRet;
}
-void WW8AttributeOutput::OutlineNumbering(sal_uInt8 nLvl)
+void WW8AttributeOutput::OutlineNumbering(sal_uInt8 /*nLvl*/)
{
- if ( nLvl >= WW8ListManager::nMaxLevel )
- nLvl = WW8ListManager::nMaxLevel-1;
-
- // write sprmPIlvl and sprmPIlfo
- // (sprmPOutLvl now handled by ParaOutlineLevel)
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::PIlvl::val );
- m_rWW8Export.pO->push_back( nLvl );
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::PIlfo::val );
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO,
- 1 + m_rWW8Export.GetNumberingId(*m_rWW8Export.m_rDoc.GetOutlineNumRule()) );
+ // Handled by ParaOutlineLevel and ParaNumRule
}
// #i77805#
@@ -782,10 +872,10 @@ bool WW8Export::DisallowInheritingOutlineNumbering(const SwFormat &rFormat)
{
if (static_cast<const SwTextFormatColl*>(pParent)->IsAssignedToListLevelOfOutlineStyle())
{
- SwWW8Writer::InsUInt16(*pO, NS_sprm::POutLvl::val);
- pO->push_back(sal_uInt8(9));
- SwWW8Writer::InsUInt16(*pO, NS_sprm::PIlfo::val);
- SwWW8Writer::InsUInt16(*pO, 0);
+ SwWW8Writer::InsUInt16(*m_pO, NS_sprm::POutLvl::val);
+ m_pO->push_back(sal_uInt8(9));
+ SwWW8Writer::InsUInt16(*m_pO, NS_sprm::PIlfo::val);
+ SwWW8Writer::InsUInt16(*m_pO, 0);
bRet = true;
}
@@ -816,7 +906,7 @@ void MSWordExportBase::OutputFormat( const SwFormat& rFormat, bool bPapFormat, b
{
//if outline numbered
// if Write StyleDefinition then write the OutlineRule
- const SwNumFormat& rNFormat = m_rDoc.GetOutlineNumRule()->Get( static_cast<sal_uInt16>( nLvl ) );
+ const SwNumFormat& rNFormat = m_rDoc.GetOutlineNumRule()->Get( o3tl::narrowing<sal_uInt16>( nLvl ) );
if ( m_bStyDef )
AttrOutput().OutlineNumbering(static_cast<sal_uInt8>(nLvl));
@@ -825,13 +915,14 @@ void MSWordExportBase::OutputFormat( const SwFormat& rFormat, bool bPapFormat, b
rNFormat.GetAbsLSpace() )
{
SfxItemSet aSet( rFormat.GetAttrSet() );
- SvxLRSpaceItem aLR(
- ItemGet<SvxLRSpaceItem>(aSet, RES_LR_SPACE));
+ SvxFirstLineIndentItem firstLine(aSet.Get(RES_MARGIN_FIRSTLINE));
+ SvxTextLeftMarginItem leftMargin(aSet.Get(RES_MARGIN_TEXTLEFT));
- aLR.SetTextLeft( aLR.GetTextLeft() + rNFormat.GetAbsLSpace() );
- aLR.SetTextFirstLineOffset( GetWordFirstLineOffset(rNFormat));
+ leftMargin.SetTextLeft(leftMargin.GetTextLeft() + rNFormat.GetAbsLSpace());
+ firstLine.SetTextFirstLineOffset(GetWordFirstLineOffset(rNFormat));
- aSet.Put( aLR );
+ aSet.Put(firstLine);
+ aSet.Put(leftMargin);
CorrectTabStopInSet( aSet, rNFormat.GetAbsLSpace() );
OutputItemSet( aSet, bPapFormat, bChpFormat,
i18n::ScriptType::LATIN, m_bExportModeRTF);
@@ -848,9 +939,10 @@ void MSWordExportBase::OutputFormat( const SwFormat& rFormat, bool bPapFormat, b
if ( m_bStyDef && DisallowInheritingOutlineNumbering(rFormat) )
{
SfxItemSet aSet( rFormat.GetAttrSet() );
- const SvxLRSpaceItem& aLR(
- ItemGet<SvxLRSpaceItem>(aSet, RES_LR_SPACE));
- aSet.Put( aLR );
+ SvxFirstLineIndentItem const& rFirstLine(aSet.Get(RES_MARGIN_FIRSTLINE));
+ SvxTextLeftMarginItem const& rLeftMargin(aSet.Get(RES_MARGIN_TEXTLEFT));
+ aSet.Put(rFirstLine);
+ aSet.Put(rLeftMargin);
OutputItemSet( aSet, bPapFormat, bChpFormat,
css::i18n::ScriptType::LATIN, m_bExportModeRTF);
bCallOutSet = false;
@@ -870,9 +962,8 @@ void MSWordExportBase::OutputFormat( const SwFormat& rFormat, bool bPapFormat, b
{
const SwFrameFormat &rFrameFormat = m_pParentFrame->GetFrameFormat();
- SfxItemSet aSet(m_rDoc.GetAttrPool(), svl::Items<RES_FRMATR_BEGIN,
- RES_FRMATR_END-1,
- XATTR_FILL_FIRST, XATTR_FILL_LAST>{});
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ XATTR_FILL_FIRST, XATTR_FILL_LAST> aSet(m_rDoc.GetAttrPool());
aSet.Set(rFrameFormat.GetAttrSet());
// Fly as character becomes a paragraph bound
@@ -899,8 +990,7 @@ void MSWordExportBase::OutputFormat( const SwFormat& rFormat, bool bPapFormat, b
case drawing::FillStyle_SOLID:
{
// Construct an SvxBrushItem, as expected by the exporters.
- std::unique_ptr<SvxBrushItem> aBrush(getSvxBrushItemFromSourceSet(rFrameFormat.GetAttrSet(), RES_BACKGROUND));
- aSet.Put(*aBrush);
+ aSet.Put(getSvxBrushItemFromSourceSet(rFrameFormat.GetAttrSet(), RES_BACKGROUND));
break;
}
default:
@@ -982,6 +1072,18 @@ OUString MSWordExportBase::GetBookmarkName( sal_uInt16 nTyp, const OUString* pNa
return BookmarkToWord( sRet ); // #i43956# - encode bookmark accordingly
}
+OUString MSWordExportBase::GetStyleRefName(const OUString& rName)
+{
+ SwTextFormatColls* pTextFormatColls = m_rDoc.GetTextFormatColls();
+ SwTextFormatColl* pTextFormat = pTextFormatColls->FindFormatByName(rName);
+
+ if (pTextFormat == nullptr)
+ return "\"" + rName + "\"";
+ // Didn't find the style, just keep the original name
+
+ return "\"" + m_pStyles->GetStyleWWName(pTextFormat) + "\"";
+}
+
/* File CHRATR.HXX: */
void WW8AttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript )
{
@@ -990,7 +1092,7 @@ void WW8AttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript )
if( m_rWW8Export.m_rDoc.GetDocumentType() != SwDoc::DOCTYPE_MSWORD )
{
m_rWW8Export.InsUInt16( NS_sprm::CFBiDi::val );
- m_rWW8Export.pO->push_back( sal_uInt8(1) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(1) );
}
}
@@ -998,16 +1100,16 @@ void WW8AttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript )
if (nScript == i18n::ScriptType::COMPLEX && !bIsRTL)
{
m_rWW8Export.InsUInt16( NS_sprm::CFComplexScripts::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x81) );
- m_rWW8Export.pDop->bUseThaiLineBreakingRules = true;
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0x81) );
+ m_rWW8Export.m_pDop->bUseThaiLineBreakingRules = true;
}
}
void WW8AttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner )
{
- m_rWW8Export.m_pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell() - (mbOnTOXEnding?2:0), m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
+ m_rWW8Export.m_pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell() - (mbOnTOXEnding?2:0), m_rWW8Export.m_pO->size(), m_rWW8Export.m_pO->data() );
mbOnTOXEnding = false;
- m_rWW8Export.pO->clear();
+ m_rWW8Export.m_pO->clear();
if ( pTextNodeInfoInner )
{
@@ -1017,10 +1119,12 @@ void WW8AttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTe
SVBT16 nSty;
ShortToSVBT16( 0, nSty );
- m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), nSty, nSty+2 ); // Style #
+ m_rWW8Export.m_pO->insert( m_rWW8Export.m_pO->end(), nSty, nSty+2 ); // Style #
TableInfoRow( pTextNodeInfoInner );
- m_rWW8Export.m_pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->size(), m_rWW8Export.pO->data());
- m_rWW8Export.pO->clear();
+ m_rWW8Export.m_pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.m_pO->size(), m_rWW8Export.m_pO->data());
+ m_rWW8Export.m_pO->clear();
+ //For Bug 119650, should break the properties of CHP PLC after a paragraph end.
+ m_rWW8Export.m_pChpPlc->AppendFkpEntry(m_rWW8Export.Strm().Tell(), m_rWW8Export.m_pO->size(), m_rWW8Export.m_pO->data());
}
}
@@ -1041,12 +1145,15 @@ void WW8AttributeOutput::StartRun( const SwRedlineData* pRedlineData, sal_Int32
{
const OUString &rComment = pRedlineData->GetComment();
//Only possible to export to main text
- if (!rComment.isEmpty() && (m_rWW8Export.m_nTextTyp == TXT_MAINTEXT))
+ if (!rComment.isEmpty() && (m_rWW8Export.m_nTextTyp == TXT_MAINTEXT) &&
+ // tdf#153016 don't export the new automatic comments added by tdf#148032
+ rComment != SwResId(STR_REDLINE_COMMENT_DELETED) &&
+ rComment != SwResId(STR_REDLINE_COMMENT_ADDED))
{
if (m_rWW8Export.m_pAtn->IsNewRedlineComment(pRedlineData))
{
m_rWW8Export.m_pAtn->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), pRedlineData );
- m_rWW8Export.WritePostItBegin( m_rWW8Export.pO.get() );
+ m_rWW8Export.WritePostItBegin( m_rWW8Export.m_pO.get() );
}
}
}
@@ -1055,7 +1162,7 @@ void WW8AttributeOutput::StartRun( const SwRedlineData* pRedlineData, sal_Int32
auto aRange = m_aBookmarksOfParagraphStart.equal_range(nPos);
for( auto aIter = aRange.first; aIter != aRange.second; ++aIter)
{
- GetExport().AppendBookmark(BookmarkToWord(aIter->second));
+ GetExport().AppendBookmark(GetExport().BookmarkToWord(aIter->second));
}
}
@@ -1064,16 +1171,16 @@ void WW8AttributeOutput::OnTOXEnding()
mbOnTOXEnding = true;
}
-void WW8AttributeOutput::EndRun( const SwTextNode* /*pNode*/, sal_Int32 nPos, bool bLastRun )
+void WW8AttributeOutput::EndRun( const SwTextNode* /*pNode*/, sal_Int32 nPos, sal_Int32 /*nLen*/, bool bLastRun )
{
/// Insert bookmarks ended after this run
auto aRange = m_aBookmarksOfParagraphEnd.equal_range(nPos);
for( auto aIter = aRange.first; aIter != aRange.second; ++aIter)
{
if(bLastRun)
- GetExport().AppendBookmarkEndWithCorrection(BookmarkToWord(aIter->second));
+ GetExport().AppendBookmarkEndWithCorrection(GetExport().BookmarkToWord(aIter->second));
else
- GetExport().AppendBookmark(BookmarkToWord(aIter->second));
+ GetExport().AppendBookmark(GetExport().BookmarkToWord(aIter->second));
}
}
@@ -1093,12 +1200,12 @@ void WW8AttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData )
if ( !bExportedFieldResult )
{
m_rWW8Export.m_pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(),
- m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
+ m_rWW8Export.m_pO->size(), m_rWW8Export.m_pO->data() );
}
- m_rWW8Export.pO->clear();
+ m_rWW8Export.m_pO->clear();
}
-void WW8AttributeOutput::RunText( const OUString& rText, rtl_TextEncoding eCharSet )
+void WW8AttributeOutput::RunText( const OUString& rText, rtl_TextEncoding eCharSet, const OUString& /*rSymbolFont*/ )
{
RawText(rText, eCharSet);
}
@@ -1110,28 +1217,28 @@ void WW8AttributeOutput::RawText(const OUString& rText, rtl_TextEncoding)
void WW8AttributeOutput::OutputFKP(bool bForce)
{
- if (!m_rWW8Export.pO->empty() || bForce)
+ if (!m_rWW8Export.m_pO->empty() || bForce)
{
m_rWW8Export.m_pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(),
- m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
- m_rWW8Export.pO->clear();
+ m_rWW8Export.m_pO->size(), m_rWW8Export.m_pO->data() );
+ m_rWW8Export.m_pO->clear();
}
}
void WW8AttributeOutput::ParagraphStyle( sal_uInt16 nStyle )
{
- OSL_ENSURE( m_rWW8Export.pO->empty(), " pO is not empty at line end" );
+ OSL_ENSURE( m_rWW8Export.m_pO->empty(), " pO is not empty at line end" );
SVBT16 nSty;
ShortToSVBT16( nStyle, nSty );
- m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), nSty, nSty+2 ); // style #
+ m_rWW8Export.m_pO->insert( m_rWW8Export.m_pO->end(), nSty, nSty+2 ); // style #
}
void WW8AttributeOutput::OutputWW8Attribute( sal_uInt8 nId, bool bVal )
{
m_rWW8Export.InsUInt16( 8 == nId ? NS_sprm::CFDStrike::val : NS_sprm::CFBold::val + nId );
- m_rWW8Export.pO->push_back( bVal ? 1 : 0 );
+ m_rWW8Export.m_pO->push_back( bVal ? 1 : 0 );
}
void WW8AttributeOutput::OutputWW8AttributeCTL( sal_uInt8 nId, bool bVal )
@@ -1141,7 +1248,7 @@ void WW8AttributeOutput::OutputWW8AttributeCTL( sal_uInt8 nId, bool bVal )
return;
m_rWW8Export.InsUInt16( NS_sprm::CFBoldBi::val + nId );
- m_rWW8Export.pO->push_back( bVal ? 1 : 0 );
+ m_rWW8Export.m_pO->push_back( bVal ? 1 : 0 );
}
void WW8AttributeOutput::CharFont( const SvxFontItem& rFont )
@@ -1218,7 +1325,7 @@ void WW8AttributeOutput::CharAnimatedText( const SvxBlinkItem& rBlink )
{
m_rWW8Export.InsUInt16( NS_sprm::CSfxText::val );
// At the moment the only animated text effect we support is blinking
- m_rWW8Export.pO->push_back( rBlink.GetValue() ? 2 : 0 );
+ m_rWW8Export.m_pO->push_back( rBlink.GetValue() ? 2 : 0 );
}
void WW8AttributeOutput::CharCrossedOut( const SvxCrossedOutItem& rCrossed )
@@ -1269,14 +1376,14 @@ void WW8AttributeOutput::CharHidden( const SvxCharHiddenItem& rHidden )
void WW8AttributeOutput::CharBorder( const SvxBorderLine* pAllBorder, const sal_uInt16 /*nDist*/, const bool bShadow )
{
- WW8Export::Out_BorderLine( *m_rWW8Export.pO, pAllBorder, 0, NS_sprm::CBrc80::val, NS_sprm::CBrc::val, bShadow );
+ WW8Export::Out_BorderLine( *m_rWW8Export.m_pO, pAllBorder, 0, NS_sprm::CBrc80::val, NS_sprm::CBrc::val, bShadow );
}
void WW8AttributeOutput::CharHighlight( const SvxBrushItem& rBrush )
{
sal_uInt8 nColor = msfilter::util::TransColToIco( rBrush.GetColor() );
m_rWW8Export.InsUInt16( NS_sprm::CHighlight::val );
- m_rWW8Export.pO->push_back( nColor );
+ m_rWW8Export.m_pO->push_back( nColor );
}
void WW8AttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline )
@@ -1292,7 +1399,7 @@ void WW8AttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline )
if(pWordline)
bWord = pWordline->GetValue();
else
- SAL_WARN("sw.ww8", "m_rWW8Export has an RES_CHRATR_WORDLINEMODE item, but its of the wrong type.");
+ SAL_WARN("sw.ww8", "m_rWW8Export has an RES_CHRATR_WORDLINEMODE item, but it's of the wrong type.");
}
// WW95 - parameters: 0 = none, 1 = single, 2 = by Word,
@@ -1360,7 +1467,7 @@ void WW8AttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline )
break;
}
- m_rWW8Export.pO->push_back( b );
+ m_rWW8Export.m_pO->push_back( b );
Color aColor = rUnderline.GetColor();
if( aColor != COL_TRANSPARENT )
{
@@ -1443,7 +1550,7 @@ void WW8AttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement )
{
m_rWW8Export.InsUInt16( NS_sprm::CIss::val );
- m_rWW8Export.pO->push_back( b );
+ m_rWW8Export.m_pO->push_back( b );
}
if ( 0 != b && 0xFF != b )
@@ -1479,7 +1586,7 @@ void WW8AttributeOutput::CharFontSize( const SvxFontHeightItem& rHeight )
{
m_rWW8Export.InsUInt16( nId );
- m_rWW8Export.InsUInt16( static_cast<sal_uInt16>(( rHeight.GetHeight() + 5 ) / 10 ) );
+ m_rWW8Export.InsUInt16( o3tl::narrowing<sal_uInt16>(( rHeight.GetHeight() + 5 ) / 10 ) );
}
}
@@ -1502,15 +1609,15 @@ void WW8AttributeOutput::CharRelief( const SvxCharReliefItem& rRelief )
if( nId )
{
m_rWW8Export.InsUInt16( nId );
- m_rWW8Export.pO->push_back( sal_uInt8(0x81) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0x81) );
}
else
{
// switch both flags off
m_rWW8Export.InsUInt16( NS_sprm::CFEmboss::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x0) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0x0) );
m_rWW8Export.InsUInt16( NS_sprm::CFImprint::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x0) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0x0) );
}
}
@@ -1520,7 +1627,7 @@ void WW8AttributeOutput::CharBidiRTL( const SfxPoolItem& rHt )
if( rAttr.GetValue() == 1 )
{
m_rWW8Export.InsUInt16(0x85a);
- m_rWW8Export.pO->push_back(sal_uInt8(1));
+ m_rWW8Export.m_pO->push_back(sal_uInt8(1));
}
}
@@ -1528,7 +1635,7 @@ void WW8AttributeOutput::CharIdctHint( const SfxPoolItem& rHt )
{
const SfxInt16Item& rAttr = static_cast<const SfxInt16Item&>(rHt);
m_rWW8Export.InsUInt16(0x286F);
- m_rWW8Export.pO->push_back(static_cast<sal_uInt8>(rAttr.GetValue()));
+ m_rWW8Export.m_pO->push_back(static_cast<sal_uInt8>(rAttr.GetValue()));
}
void WW8AttributeOutput::CharRotate( const SvxCharRotateItem& rRotate )
@@ -1545,12 +1652,12 @@ void WW8AttributeOutput::CharRotate( const SvxCharRotateItem& rRotate )
// here corrupts the table, hence !m_rWW8Export.bIsInTable
m_rWW8Export.InsUInt16( NS_sprm::CFELayout::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x06) ); //len 6
- m_rWW8Export.pO->push_back( sal_uInt8(0x01) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0x06) ); //len 6
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0x01) );
m_rWW8Export.InsUInt16( rRotate.IsFitToLine() ? 1 : 0 );
static const sal_uInt8 aZeroArr[ 3 ] = { 0, 0, 0 };
- m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), aZeroArr, aZeroArr+3);
+ m_rWW8Export.m_pO->insert( m_rWW8Export.m_pO->end(), aZeroArr, aZeroArr+3);
}
void WW8AttributeOutput::CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark )
@@ -1570,7 +1677,7 @@ void WW8AttributeOutput::CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisM
nVal = 1;
m_rWW8Export.InsUInt16( NS_sprm::CKcd::val );
- m_rWW8Export.pO->push_back( nVal );
+ m_rWW8Export.m_pO->push_back( nVal );
}
/**
@@ -1606,7 +1713,7 @@ void WW8AttributeOutput::CharColor( const SvxColorItem& rColor )
m_rWW8Export.InsUInt16( NS_sprm::CIco::val );
sal_uInt8 nColor = msfilter::util::TransColToIco( rColor.GetValue() );
- m_rWW8Export.pO->push_back( nColor );
+ m_rWW8Export.m_pO->push_back( nColor );
if (nColor)
{
@@ -1627,7 +1734,7 @@ void WW8AttributeOutput::CharBackground( const SvxBrushItem& rBrush )
//Quite a few unknowns, some might be transparency or something
//of that nature...
m_rWW8Export.InsUInt16( NS_sprm::CShd::val );
- m_rWW8Export.pO->push_back( 10 );
+ m_rWW8Export.m_pO->push_back( 10 );
m_rWW8Export.InsUInt32( 0xFF000000 );
m_rWW8Export.InsUInt32( SuitableBGColor( rBrush.GetColor() ) );
m_rWW8Export.InsUInt16( 0x0000);
@@ -1696,9 +1803,9 @@ static void InsertSpecialChar( WW8Export& rWrt, sal_uInt8 c,
if ( c == 0x01 && pLinkStr)
{
// write hyperlink data to data stream
- SvStream& rStrm = *rWrt.pDataStrm;
+ SvStream& rStrm = *rWrt.m_pDataStrm;
// position of hyperlink data
- const sal_uInt32 nLinkPosInDataStrm = rStrm.Tell();
+ const sal_uInt64 nLinkPosInDataStrm = rStrm.Tell();
// write empty header
const sal_uInt16 nEmptyHdrLen = 0x44;
sal_uInt8 aEmptyHeader[ nEmptyHdrLen ] = { 0 };
@@ -1721,7 +1828,7 @@ static void InsertSpecialChar( WW8Export& rWrt, sal_uInt8 c,
// write additional two NULL Bytes
SwWW8Writer::WriteLong( rStrm, 0 );
// write length of hyperlink data
- const sal_uInt32 nCurrPos = rStrm.Tell();
+ const sal_uInt64 nCurrPos = rStrm.Tell();
rStrm.Seek( nLinkPosInDataStrm );
rStrm.WriteUInt32(nCurrPos - nLinkPosInDataStrm);
rStrm.Seek( nCurrPos );
@@ -1798,7 +1905,7 @@ void WW8Export::OutputField( const SwField* pField, ww::eField eFieldType,
break;
case ww::eCITATION:
eFieldType = ww::eQUOTE;
- assert(rFieldCmd.trim().startsWith("CITATION"));
+ assert(o3tl::starts_with(o3tl::trim(rFieldCmd), u"CITATION"));
sFieldCmd = rFieldCmd.replaceFirst(FieldString(ww::eCITATION),
FieldString(ww::eQUOTE));
break;
@@ -2014,7 +2121,7 @@ static int lcl_CheckForm( const SwForm& rForm, sal_uInt8 nLvl, OUString& rText )
static bool lcl_IsHyperlinked(const SwForm& rForm, sal_uInt16 nTOXLvl)
{
bool bRes = false;
- for (sal_uInt16 nI = 1; nI < nTOXLvl; ++nI)
+ for (sal_uInt16 nI = 1; nI <= nTOXLvl; ++nI)
{
// #i21237#
SwFormTokens aPattern = rForm.GetPattern(nI);
@@ -2214,6 +2321,21 @@ void AttributeOutputBase::GenerateBookmarksForSequenceField(const SwTextNode& rN
}
}
+static auto GetSeparatorForLocale() -> OUString
+{
+ switch (sal_uInt16(MsLangId::getSystemLanguage()))
+ {
+ case sal_uInt16(LANGUAGE_GERMAN):
+ case sal_uInt16(LANGUAGE_GERMAN_AUSTRIAN):
+ case sal_uInt16(LANGUAGE_GERMAN_LIECHTENSTEIN):
+ case sal_uInt16(LANGUAGE_GERMAN_LUXEMBOURG):
+ case sal_uInt16(LANGUAGE_GERMAN_SWISS):
+ return ";";
+ default:
+ return ",";
+ }
+}
+
void AttributeOutputBase::StartTOX( const SwSection& rSect )
{
if ( const SwTOXBase* pTOX = rSect.GetTOXBase() )
@@ -2224,7 +2346,16 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect )
OUString sStr = pTOX ->GetMSTOCExpression();
if ( sStr.isEmpty() )
{
- switch (pTOX->GetType())
+ OUString sUserTypeName;
+ auto aType = pTOX->GetType();
+ // user index, it needs INDEX with \f
+ if ( TOX_USER == aType )
+ {
+ sUserTypeName = pTOX->GetTOXType()->GetTypeName();
+ if ( !sUserTypeName.isEmpty() )
+ aType = TOX_INDEX;
+ }
+ switch (aType)
{
case TOX_INDEX:
eCode = ww::eINDEX;
@@ -2256,14 +2387,9 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect )
if (SwTOIOptions::AlphaDelimiter & pTOX->GetOptions())
sStr += "\\h \"A\" ";
- if(SwTOXElement::IndexEntryType & pTOX->GetCreateType())
+ if (!sUserTypeName.isEmpty())
{
- sStr += "\\f ";
- const OUString& sName = pTOX->GetEntryTypeName();
- if(!sName.isEmpty())
- {
- sStr += sName + sEntryEnd;
- }
+ sStr += "\\f \"" + sUserTypeName + "\"";
}
if (!pTOX->GetTOXForm().IsCommaSeparated())
@@ -2306,6 +2432,24 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect )
sStr += "\\p \"" + aText + sEntryEnd;
}
}
+ if (lcl_IsHyperlinked(pTOX->GetTOXForm(), 1))
+ {
+ sStr += "\\h ";
+ }
+ if (pTOX->GetCreateType() & SwTOXElement::Template)
+ {
+ OUString const& rStyle(pTOX->GetStyleNames(0));
+ assert(rStyle.indexOf(TOX_STYLE_DELIMITER) == -1);
+ SwTextFormatColl const*const pColl = GetExport().m_rDoc.FindTextFormatCollByName(rStyle);
+ if (pColl)
+ {
+ OUString const converted(GetExport().m_pStyles->GetStyleWWName(pColl));
+ if (!converted.isEmpty())
+ {
+ sStr += "\\t \"" + converted + sEntryEnd;
+ }
+ }
+ }
break;
case TOX_AUTHORITIES:
@@ -2319,6 +2463,9 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect )
sStr = FieldString(eCode);
OUString sTOption;
+ // tdf#153082 Word's separator interpretation in DOCX
+ // fields varies by system locale.
+ auto const tsep(GetSeparatorForLocale());
sal_uInt16 n, nTOXLvl = pTOX->GetLevel();
if( !nTOXLvl )
++nTOXLvl;
@@ -2420,8 +2567,8 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect )
if (nTestLvl < nTOXLvl && nTestLvl >= nMaxMSAutoEvaluate)
{
if (!sTOption.isEmpty())
- sTOption += ",";
- sTOption += pColl->GetName() + "," + OUString::number( nTestLvl + 1 );
+ sTOption += tsep;
+ sTOption += pColl->GetName() + tsep + OUString::number(nTestLvl + 1);
}
}
}
@@ -2441,7 +2588,7 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect )
if( !rStyles.isEmpty() )
{
sal_Int32 nPos = 0;
- const OUString sLvl{ "," + OUString::number( n + 1 ) };
+ const OUString sLvl{tsep + OUString::number(n + 1)};
do {
const OUString sStyle( rStyles.getToken( 0, TOX_STYLE_DELIMITER, nPos ));
if( !sStyle.isEmpty() )
@@ -2449,11 +2596,14 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect )
SwTextFormatColl* pColl = GetExport().m_rDoc.FindTextFormatCollByName(sStyle);
if (pColl)
{
- if (!pColl->IsAssignedToListLevelOfOutlineStyle() || pColl->GetAssignedOutlineStyleLevel() < nTOXLvl)
+ OUString const converted(GetExport().m_pStyles->GetStyleWWName(pColl));
+ if (!converted.isEmpty() &&
+ (!pColl->IsAssignedToListLevelOfOutlineStyle()
+ || pColl->GetAssignedOutlineStyleLevel() < nTOXLvl))
{
if( !sTOption.isEmpty() )
- sTOption += ",";
- sTOption += sStyle + sLvl;
+ sTOption += tsep;
+ sTOption += converted + sLvl;
}
}
}
@@ -2534,7 +2684,7 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect )
FieldFlags::CmdEnd );
if (GetExport().GetExportFormat() == MSWordExportBase::ExportFormat::RTF)
{
- EndRun(nullptr, -42, true);
+ EndRun(nullptr, -42, -1, true);
}
}
}
@@ -2579,6 +2729,11 @@ bool MSWordExportBase::GetNumberFormat(const SwField& rField, OUString& rStr)
if( pNumFormat )
{
LanguageType nLng = rField.GetLanguage();
+ SAL_WARN_IF(nLng == LANGUAGE_DONTKNOW, "sw.ww8", "unexpected LANGUAGE_DONTKNOW");
+ if (nLng == LANGUAGE_NONE || nLng == LANGUAGE_DONTKNOW)
+ {
+ nLng = pNumFormat->GetLanguage();
+ }
LocaleDataWrapper aLocDat(pNFormatr->GetComponentContext(),
LanguageTag(nLng));
@@ -2614,6 +2769,15 @@ void AttributeOutputBase::GetNumberPara( OUString& rStr, const SwField& rField )
case SVX_NUM_ROMAN_LOWER:
rStr += "\\* roman ";
break;
+ case SVX_NUM_TEXT_NUMBER:
+ rStr += "\\* Ordinal ";
+ break;
+ case SVX_NUM_TEXT_ORDINAL:
+ rStr += "\\* Ordtext ";
+ break;
+ case SVX_NUM_TEXT_CARDINAL:
+ rStr += "\\* Cardtext ";
+ break;
default:
OSL_ENSURE(rField.GetFormat() == SVX_NUM_ARABIC,
"Unknown numbering type exported as default of Arabic");
@@ -2697,7 +2861,7 @@ void WW8AttributeOutput::PostitField( const SwField* pField )
{
const SwPostItField *pPField = static_cast<const SwPostItField*>(pField);
m_rWW8Export.m_pAtn->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), pPField );
- m_rWW8Export.WritePostItBegin( m_rWW8Export.pO.get() );
+ m_rWW8Export.WritePostItBegin( m_rWW8Export.m_pO.get() );
}
bool WW8AttributeOutput::DropdownField( const SwField* pField )
@@ -2880,7 +3044,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
case SwFieldIds::DocInfo: // Last printed, last edited,...
if( DI_SUB_FIXED & nSubType )
bWriteExpand = true;
- else
+
{
OUString sStr;
ww::eField eField(ww::eNONE);
@@ -2901,32 +3065,34 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
case DI_DOCNO:
eField = ww::eREVNUM;
break;
+ case DI_EDIT:
+ eField = ww::eEDITTIME;
+ break;
case DI_CREATE:
if (DI_SUB_AUTHOR == (nSubType & DI_SUB_MASK))
eField = ww::eAUTHOR;
- else if (GetExport().GetNumberFormat(*pField, sStr))
+ else if (GetExport().GetNumberFormat(*pField, sStr) || sStr.isEmpty())
eField = ww::eCREATEDATE;
+
+ // Create author/time are always imported as fixed. Safe to ignore on export
+ bWriteExpand = false;
break;
case DI_CHANGE:
if (DI_SUB_AUTHOR == (nSubType & DI_SUB_MASK))
+ {
eField = ww::eLASTSAVEDBY;
- else if (GetExport().GetNumberFormat(*pField, sStr))
+ bWriteExpand=false;
+ }
+ else if (GetExport().GetNumberFormat(*pField, sStr) || sStr.isEmpty())
eField = ww::eSAVEDATE;
break;
case DI_PRINT:
if (DI_SUB_AUTHOR != (nSubType & DI_SUB_MASK) &&
- GetExport().GetNumberFormat(*pField, sStr))
+ (GetExport().GetNumberFormat(*pField, sStr) || sStr.isEmpty()))
eField = ww::ePRINTDATE;
break;
- case DI_EDIT:
- if( DI_SUB_AUTHOR != (nSubType & DI_SUB_MASK ) &&
- GetExport().GetNumberFormat( *pField, sStr ))
- eField = ww::eSAVEDATE;
- else
- eField = ww::eEDITTIME;
- break;
case DI_CUSTOM:
eField = ww::eDOCPROPERTY;
{
@@ -2934,22 +3100,16 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
dynamic_cast<const SwDocInfoField *> (pField);
if (pDocInfoField != nullptr)
- {
- OUString sFieldname = pDocInfoField->GetFieldName();
+ sStr = "\"" + pDocInfoField->GetName() + "\"";
- const sal_Int32 nIndex = sFieldname.indexOf(':');
- if (nIndex >= 0)
- sFieldname = sFieldname.copy(nIndex + 1);
-
- sStr = "\"" + sFieldname + "\"";
- }
+ bWriteExpand = false;
}
break;
default:
break;
}
- if (eField != ww::eNONE)
+ if (!bWriteExpand && eField != ww::eNONE)
{
GetExport().OutputField(pField, eField, FieldString(eField) + sStr);
}
@@ -3031,7 +3191,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
// FIXME: DomainMapper_Impl::CloseFieldCommand() stuffs fully formed
// field instructions in here, but if the field doesn't originate
// from those filters it won't have that
- if (!sRet.trim().startsWith("CITATION"))
+ if (!o3tl::starts_with(o3tl::trim(sRet), u"CITATION"))
{
sRet = FieldString(ww::eCITATION) + " \"" + sRet + "\"";
}
@@ -3082,7 +3242,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
{
const OUString& aRefName(rRField.GetSetRefName());
sStr = FieldString(eField)
- + MSWordExportBase::GetBookmarkName(nSubType, &aRefName, 0);
+ + GetExport().GetBookmarkName(nSubType, &aRefName, 0);
}
switch (pField->GetFormat())
{
@@ -3137,7 +3297,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
eField = ww::eNONE;
break;
}
- sStr = FieldString(eField) + MSWordExportBase::GetBookmarkName(nSubType, &sName, 0);
+ sStr = FieldString(eField) + GetExport().GetBookmarkName(nSubType, &sName, 0);
}
switch (pField->GetFormat())
{
@@ -3170,28 +3330,58 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
break;
}
sStr = FieldString(eField)
- + MSWordExportBase::GetBookmarkName(nSubType, nullptr, rRField.GetSeqNo());
+ + GetExport().GetBookmarkName(nSubType, nullptr, rRField.GetSeqNo());
+ break;
+ case REF_STYLE:
+ sStr = FieldString(ww::eSTYLEREF)
+ + GetExport().GetStyleRefName(pField->GetPar1());
+ eField = ww::eSTYLEREF;
break;
}
- if (eField != ww::eNONE)
+ OUString sExtraFlags = "\\h "; // by default, include a hyperlink
+
+ switch (eField)
{
- switch (pField->GetFormat())
- {
- case REF_UPDOWN:
- sStr += " \\p \\h "; // with hyperlink
- break;
- case REF_CHAPTER:
- sStr += " \\n \\h "; // with hyperlink
- break;
- default:
- sStr += " \\h "; // insert hyperlink
- break;
- }
- GetExport().OutputField(pField, eField, sStr);
+ case ww::eNONE:
+ bWriteExpand = true;
+ break;
+ case ww::eSTYLEREF:
+ sExtraFlags = ""; // styleref fields do not work if they have a hyperlink
+
+ {
+ sal_uInt16 stylerefFlags = static_cast<const SwGetRefField*>(pField)->GetFlags();
+ if ((stylerefFlags & REFFLDFLAG_STYLE_FROM_BOTTOM) == REFFLDFLAG_STYLE_FROM_BOTTOM) {
+ sExtraFlags += "\\l ";
+ }
+ if ((stylerefFlags & REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL) == REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL) {
+ sExtraFlags += "\\t ";
+ }
+ }
+
+ [[fallthrough]];
+ default:
+ switch (pField->GetFormat())
+ {
+ case REF_NUMBER:
+ sStr += " \\r " + sExtraFlags;
+ break;
+ case REF_NUMBER_FULL_CONTEXT:
+ sStr += " \\w " + sExtraFlags;
+ break;
+ case REF_UPDOWN:
+ sStr += " \\p " + sExtraFlags;
+ break;
+ case REF_NUMBER_NO_CONTEXT:
+ case REF_CHAPTER:
+ sStr += " \\n " + sExtraFlags;
+ break;
+ default:
+ sStr += " " + sExtraFlags;
+ break;
+ }
+ GetExport().OutputField(pField, eField, sStr);
}
- else
- bWriteExpand = true;
}
break;
case SwFieldIds::CombinedChars:
@@ -3212,8 +3402,8 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
sal_uInt16 nScript = g_pBreakIt->GetBreakIter()->getScriptType( pField->GetPar1(), 0);
- tools::Long nHeight = static_cast<const SvxFontHeightItem&>((GetExport().GetItem(
- GetWhichOfScript(RES_CHRATR_FONTSIZE,nScript)))).GetHeight();
+ TypedWhichId<SvxFontHeightItem> nFontHeightWhich = GetWhichOfScript(RES_CHRATR_FONTSIZE,nScript);
+ tools::Long nHeight = GetExport().GetItem(nFontHeightWhich).GetHeight();
nHeight = (nHeight + 10) / 20; //Font Size in points;
@@ -3241,22 +3431,38 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
break;
case SwFieldIds::Chapter:
bWriteExpand = true;
- if (GetExport().m_bOutKF && rField.GetTextField())
+
+ if (rField.GetTextField())
{
const SwTextNode *pTextNd = GetExport().GetHdFtPageRoot();
if (!pTextNd)
{
- pTextNd = GetExport().m_pCurPam->GetNode().GetTextNode();
+ pTextNd = GetExport().m_pCurPam->GetPointNode().GetTextNode();
}
if (pTextNd)
{
SwChapterField aCopy(*static_cast<const SwChapterField*>(pField));
aCopy.ChangeExpansion(*pTextNd, false);
- const OUString sStr = FieldString(ww::eSTYLEREF)
- + " "
- + OUString::number(aCopy.GetLevel() + 1)
- + " \\* MERGEFORMAT ";
+
+ OUString sStr;
+ if (GetExport().m_bOutKF) {
+ // In headers and footers, use the chapter number as the style name
+ sStr = FieldString(ww::eSTYLEREF)
+ + " "
+ + OUString::number(aCopy.GetLevel() + 1)
+ + " \\* MERGEFORMAT ";
+ } else {
+ // Otherwise, get the style of the text and use it as the style name
+ const SwTextNode* pOutlineNd = pTextNd->FindOutlineNodeOfLevel(aCopy.GetLevel());
+
+ if (!pOutlineNd) break;
+ // Sometimes we can't find the outline node, in that case let's just fallback to exporting the text
+
+ sStr = FieldString(ww::eSTYLEREF)
+ + GetExport().GetStyleRefName(pOutlineNd->GetFormatColl()->GetName());
+ }
+
GetExport().OutputField(pField, ww::eSTYLEREF, sStr);
bWriteExpand = false;
}
@@ -3267,7 +3473,36 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
OUString sExpand(pField->GetPar2());
if (!sExpand.isEmpty())
{
- HiddenField( *pField );
+ auto eSubType = static_cast<SwFieldTypesEnum>(pField->GetSubType());
+ if (eSubType == SwFieldTypesEnum::ConditionalText)
+ {
+ OUString aCond = pField->GetPar1();
+ OUString aTrueFalse = pField->GetPar2();
+ sal_Int32 nPos = aTrueFalse.indexOf('|');
+ OUString aTrue;
+ OUString aFalse;
+ if (nPos == -1)
+ {
+ aTrue = aTrueFalse;
+ }
+ else
+ {
+ aTrue = aTrueFalse.subView(0, nPos);
+ aFalse = aTrueFalse.subView(nPos + 1);
+ }
+ if (aTrue.getLength() > 1 && aTrue.startsWith("\"") && aTrue.endsWith("\""))
+ aTrue = aTrue.copy(1, aTrue.getLength() - 2);
+ if (aFalse.getLength() > 1 && aFalse.startsWith("\"") && aFalse.endsWith("\""))
+ aFalse = aFalse.copy(1, aFalse.getLength() - 2);
+
+ // Substitute a single quote for an illegal double quote if one exists
+ OUString aCmd = FieldString(ww::eIF) + aCond + " \""
+ + aTrue.replaceAll("\"", "'") + "\" \"" + aFalse.replaceAll("\"", "'")
+ + "\"";
+ GetExport().OutputField(pField, ww::eIF, aCmd);
+ }
+ else
+ HiddenField(*pField);
}
}
break;
@@ -3276,8 +3511,8 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
break;
case SwFieldIds::Macro:
{
- const OUString sStr = " MACROBUTTON"
- + pField->GetPar1().replaceFirst("StarOffice.Standard.Modul1.", " ")
+ const OUString sStr = " MACROBUTTON "
+ + pField->GetPar1().replaceFirst("StarOffice.Standard.Modul1.", "")
+ " "
+ lcl_GetExpandedField(*pField);
GetExport().OutputField( pField, ww::eMACROBUTTON, sStr );
@@ -3286,7 +3521,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
case SwFieldIds::Table:
{
ww::eField eField = ww::eEquals;
- OUString aExpand = " =" + pField->GetFieldName().trim();
+ OUString aExpand = OUString::Concat(" =") + o3tl::trim(pField->GetFieldName());
GetExport().OutputField(pField, eField, aExpand);
}
break;
@@ -3314,7 +3549,7 @@ void AttributeOutputBase::TextFlyContent( const SwFormatFlyCnt& rFlyContent )
Point aLayPos = pTextNd->FindLayoutRect( false, &origin ).Pos();
SwPosition aPos( *pTextNd );
- ww8::Frame aFrame( *rFlyContent.GetFrameFormat(), aPos );
+ ww8::Frame aFrame( *rFlyContent.GetFrameFormat(), std::move(aPos) );
OutputFlyFrame_Impl( aFrame, aLayPos );
}
@@ -3333,25 +3568,25 @@ void WW8AttributeOutput::ParaHyphenZone( const SvxHyphenZoneItem& rHyphenZone )
// sprmPFNoAutoHyph
m_rWW8Export.InsUInt16( NS_sprm::PFNoAutoHyph::val );
- m_rWW8Export.pO->push_back( rHyphenZone.IsHyphen() ? 0 : 1 );
+ m_rWW8Export.m_pO->push_back( rHyphenZone.IsHyphen() ? 0 : 1 );
}
void WW8AttributeOutput::ParaScriptSpace( const SfxBoolItem& rScriptSpace )
{
m_rWW8Export.InsUInt16( NS_sprm::PFAutoSpaceDE::val );
- m_rWW8Export.pO->push_back( rScriptSpace.GetValue() ? 1 : 0 );
+ m_rWW8Export.m_pO->push_back( rScriptSpace.GetValue() ? 1 : 0 );
}
void WW8AttributeOutput::ParaHangingPunctuation( const SfxBoolItem& rItem )
{
m_rWW8Export.InsUInt16( NS_sprm::PFOverflowPunct::val );
- m_rWW8Export.pO->push_back( rItem.GetValue() ? 1 : 0 );
+ m_rWW8Export.m_pO->push_back( rItem.GetValue() ? 1 : 0 );
}
void WW8AttributeOutput::ParaForbiddenRules( const SfxBoolItem& rItem )
{
m_rWW8Export.InsUInt16( NS_sprm::PFKinsoku::val );
- m_rWW8Export.pO->push_back( rItem.GetValue() ? 1 : 0 );
+ m_rWW8Export.m_pO->push_back( rItem.GetValue() ? 1 : 0 );
}
void WW8AttributeOutput::ParaSnapToGrid( const SvxParaGridItem& rGrid )
@@ -3359,7 +3594,7 @@ void WW8AttributeOutput::ParaSnapToGrid( const SvxParaGridItem& rGrid )
// sprmPFUsePgsuSettings
m_rWW8Export.InsUInt16( NS_sprm::PFUsePgsuSettings::val );
- m_rWW8Export.pO->push_back( rGrid.GetValue() ? 1 : 0 );
+ m_rWW8Export.m_pO->push_back( rGrid.GetValue() ? 1 : 0 );
}
void WW8AttributeOutput::ParaVerticalAlign( const SvxParaVertAlignItem& rAlign )
@@ -3454,10 +3689,9 @@ void WW8Export::WriteFootnoteBegin( const SwFormatFootnote& rFootnote, ww::bytes
const SwTextFootnote* pTextFootnote = rFootnote.GetTextFootnote();
if( pTextFootnote )
{
- std::unique_ptr<ww::bytes> pOld = std::move(pO);
- pO = std::move(pOwnOutArr);
- SfxItemSet aSet( m_rDoc.GetAttrPool(), svl::Items<RES_CHRATR_FONT,
- RES_CHRATR_FONT>{} );
+ std::unique_ptr<ww::bytes> pOld = std::move(m_pO);
+ m_pO = std::move(pOwnOutArr);
+ SfxItemSetFixed<RES_CHRATR_FONT, RES_CHRATR_FONT> aSet( m_rDoc.GetAttrPool() );
pCFormat = pInfo->GetCharFormat( m_rDoc );
@@ -3471,8 +3705,8 @@ void WW8Export::WriteFootnoteBegin( const SwFormatFootnote& rFootnote, ww::bytes
{
m_pAttrOutput->OutputItem( pCFormat->GetAttrSet().Get(RES_CHRATR_FONT) );
}
- pOwnOutArr = std::move(pO);
- pO = std::move(pOld);
+ pOwnOutArr = std::move(m_pO);
+ m_pO = std::move(pOld);
}
m_pChpPlc->AppendFkpEntry( Strm().Tell(), pOwnOutArr->size(),
pOwnOutArr->data() );
@@ -3520,7 +3754,7 @@ void AttributeOutputBase::TextFootnote( const SwFormatFootnote& rFootnote )
OUString sBkmkNm;
if ( GetExport().HasRefToFootOrEndnote( rFootnote.IsEndNote(), rFootnote.GetTextFootnote()->GetSeqRefNo()))
{
- sBkmkNm = MSWordExportBase::GetBookmarkName( nTyp, nullptr,
+ sBkmkNm = GetExport().GetBookmarkName(nTyp, nullptr,
rFootnote.GetTextFootnote()->GetSeqRefNo() );
GetExport().AppendBookmark( sBkmkNm );
}
@@ -3535,12 +3769,12 @@ void WW8AttributeOutput::TextFootnote_Impl( const SwFormatFootnote& rFootnote )
{
WW8_WrPlcFootnoteEdn* pFootnoteEnd;
if ( rFootnote.IsEndNote() || GetExport().m_rDoc.GetFootnoteInfo().m_ePos == FTNPOS_CHAPTER )
- pFootnoteEnd = m_rWW8Export.pEdn.get();
+ pFootnoteEnd = m_rWW8Export.m_pEdn.get();
else
- pFootnoteEnd = m_rWW8Export.pFootnote.get();
+ pFootnoteEnd = m_rWW8Export.m_pFootnote.get();
pFootnoteEnd->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), rFootnote );
- m_rWW8Export.WriteFootnoteBegin( rFootnote, m_rWW8Export.pO.get() );
+ m_rWW8Export.WriteFootnoteBegin( rFootnote, m_rWW8Export.m_pO.get() );
}
void WW8AttributeOutput::TextCharFormat( const SwFormatCharFormat& rCharFormat )
@@ -3563,8 +3797,8 @@ void WW8AttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines )
return;
m_rWW8Export.InsUInt16( NS_sprm::CFELayout::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x06) ); //len 6
- m_rWW8Export.pO->push_back( sal_uInt8(0x02) );
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0x06) ); //len 6
+ m_rWW8Export.m_pO->push_back( sal_uInt8(0x02) );
sal_Unicode cStart = rTwoLines.GetStartBracket();
sal_Unicode cEnd = rTwoLines.GetEndBracket();
@@ -3596,7 +3830,41 @@ void WW8AttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines )
nType = 1;
m_rWW8Export.InsUInt16( nType );
static const sal_uInt8 aZeroArr[ 3 ] = { 0, 0, 0 };
- m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), aZeroArr, aZeroArr+3);
+ m_rWW8Export.m_pO->insert( m_rWW8Export.m_pO->end(), aZeroArr, aZeroArr+3);
+}
+
+void AttributeOutputBase::FormatLineNumberingBase(const SwFormatLineNumber& rNumbering)
+{
+ // always write out suppressLineNumberings - even if it matches the parent,
+ // so that even if the parent is modified, special styles/situations won't lose that suppression
+ if (!rNumbering.IsCount())
+ {
+ FormatLineNumbering(rNumbering);
+ return;
+ }
+
+ // Don't spam suppressLineNumberings = false - that is the default when not specified at all
+ if (auto pNd = dynamic_cast<const SwContentNode*>(GetExport().m_pOutFormatNode)) //paragraph
+ {
+ // useless IsCount can be added to paragraph when specifying MID_LINENUMBER_STARTVALUE
+ const auto& rSet = static_cast<SwTextFormatColl&>(pNd->GetAnyFormatColl()).GetAttrSet();
+ const SwFormatLineNumber& rInherited = rSet.GetLineNumber();
+ if (rInherited.IsCount() && rInherited.GetStartValue() != rNumbering.GetStartValue())
+ return; // same IsCount as parent style
+ }
+ else if (GetExport().m_bStyDef) //style
+ {
+ if (GetExport().m_pCurrentStyle && GetExport().m_pCurrentStyle->DerivedFrom())
+ {
+ const auto& rSet = GetExport().m_pCurrentStyle->DerivedFrom()->GetAttrSet();
+ if (rSet.GetLineNumber().IsCount())
+ return; // same as parent style
+ }
+ else
+ return; // same as default value
+ }
+
+ FormatLineNumbering(rNumbering);
}
void AttributeOutputBase::ParaOutlineLevelBase( const SfxUInt16Item& rItem )
@@ -3618,10 +3886,9 @@ void AttributeOutputBase::ParaOutlineLevelBase( const SfxUInt16Item& rItem )
void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule )
{
- const SwTextNode* pTextNd = nullptr;
if (rNumRule.GetValue().isEmpty())
{
- ParaNumRule_Impl(pTextNd, 0, 0);
+ ParaNumRule_Impl(nullptr, 0, 0);
return;
}
const SwNumRule* pRule = GetExport().m_rDoc.FindNumRulePtr(
@@ -3632,27 +3899,13 @@ void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule )
sal_uInt16 nNumId = GetExport().GetNumberingId(*pRule) + 1;
sal_uInt8 nLvl = 0;
- if (!GetExport().m_pOutFormatNode)
+ const SwTextNode* pTextNd = dynamic_cast<const SwTextNode*>(GetExport().m_pOutFormatNode);
+ if (pTextNd)
{
- ParaNumRule_Impl(pTextNd, nLvl, nNumId);
- return;
- }
-
- if ( dynamic_cast< const SwContentNode *>( GetExport().m_pOutFormatNode ) != nullptr )
- {
- pTextNd = static_cast<const SwTextNode*>(GetExport().m_pOutFormatNode);
-
if( pTextNd->IsCountedInList())
{
- int nLevel = pTextNd->GetActualListLevel();
-
- if (nLevel < 0)
- nLevel = 0;
-
- if (nLevel >= MAXLEVEL)
- nLevel = MAXLEVEL - 1;
-
- nLvl = static_cast< sal_uInt8 >(nLevel);
+ nLvl = std::clamp(pTextNd->GetActualListLevel(), 0, MAXLEVEL - 1);
+ const bool bListRestart = pTextNd->IsListRestart();
if (GetExport().GetExportFormat() == MSWordExportBase::DOCX) // FIXME
{
@@ -3660,7 +3913,7 @@ void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule )
OUString const listId(pTextNd->GetListId());
if (!listId.isEmpty()
&& (listId != pRule->GetDefaultListId() // default list id uses the 1:1 mapping
- || pTextNd->IsListRestart()) // or restarting previous list
+ || bListRestart) // or restarting previous list
)
{
SwList const*const pList(
@@ -3671,7 +3924,7 @@ void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule )
GetExport().m_rDoc.FindNumRulePtr(
pList->GetDefaultListStyleName()));
assert(pAbstractRule);
- if (pAbstractRule == pRule && !pTextNd->IsListRestart())
+ if (pAbstractRule == pRule && !bListRestart)
{
// different list, but no override
nNumId = GetExport().DuplicateAbsNum(listId, *pAbstractRule) + 1;
@@ -3681,7 +3934,7 @@ void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule )
nNumId = GetExport().OverrideNumRule(
*pRule, listId, *pAbstractRule) + 1;
- if (pTextNd->IsListRestart())
+ if (bListRestart)
{
// For restarted lists we should also keep value for
// future w:lvlOverride / w:startOverride
@@ -3692,20 +3945,35 @@ void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule )
}
}
}
+ else if (bListRestart)
+ {
+ sal_uInt16 nStartWith = static_cast<sal_uInt16>(pTextNd->GetActualListStartValue());
+ nNumId = GetExport().DuplicateNumRule(pRule, nLvl, nStartWith);
+ if (USHRT_MAX != nNumId)
+ ++nNumId;
+ }
}
else
{
// #i44815# adjust numbering for numbered paragraphs
- // without number (NO_NUMLEVEL). These paragraphs
- // will receive a list id 0, which WW interprets as
- // 'no number'.
+ // without number. These paragraphs will receive a
+ // list id 0, which WW interprets as 'no number'.
nNumId = 0;
}
}
else if ( auto pC = dynamic_cast< const SwTextFormatColl *>( GetExport().m_pOutFormatNode ) )
{
- if ( pC && pC->IsAssignedToListLevelOfOutlineStyle() )
+ if (pC->IsAssignedToListLevelOfOutlineStyle())
nLvl = static_cast< sal_uInt8 >( pC->GetAssignedOutlineStyleLevel() );
+ else
+ {
+ const SfxItemSet* pSet = GetExport().m_pISet;
+ if (pSet && pSet->HasItem(RES_PARATR_LIST_LEVEL))
+ {
+ const SfxInt16Item* pItem = pSet->GetItem(RES_PARATR_LIST_LEVEL);
+ nLvl = pItem->GetValue();
+ }
+ }
}
if ( nLvl >= WW8ListManager::nMaxLevel )
@@ -3721,10 +3989,10 @@ void WW8AttributeOutput::ParaNumRule_Impl(const SwTextNode* /*pTextNd*/,
return;
// write sprmPIlvl and sprmPIlfo
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::PIlvl::val );
- m_rWW8Export.pO->push_back( ::sal::static_int_cast<sal_uInt8>(nLvl) );
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::PIlfo::val );
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, ::sal::static_int_cast<sal_uInt16>(nNumId) );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::PIlvl::val );
+ m_rWW8Export.m_pO->push_back( ::sal::static_int_cast<sal_uInt8>(nLvl) );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, NS_sprm::PIlfo::val );
+ SwWW8Writer::InsUInt16( *m_rWW8Export.m_pO, ::sal::static_int_cast<sal_uInt16>(nNumId) );
}
/* File FRMATR.HXX */
@@ -3741,7 +4009,7 @@ void WW8AttributeOutput::FormatFrameSize( const SwFormatFrameSize& rSize )
{
//"sprmPDxaWidth"
m_rWW8Export.InsUInt16( NS_sprm::PDxaWidth::val );
- m_rWW8Export.InsUInt16( static_cast<sal_uInt16>(rSize.GetWidth()) );
+ m_rWW8Export.InsUInt16( o3tl::narrowing<sal_uInt16>(rSize.GetWidth()) );
}
if ( rSize.GetHeight() )
@@ -3753,8 +4021,8 @@ void WW8AttributeOutput::FormatFrameSize( const SwFormatFrameSize& rSize )
switch ( rSize.GetHeightSizeType() )
{
case SwFrameSize::Variable: break;
- case SwFrameSize::Fixed: nH = static_cast<sal_uInt16>(rSize.GetHeight()) & 0x7fff; break;
- default: nH = static_cast<sal_uInt16>(rSize.GetHeight()) | 0x8000; break;
+ case SwFrameSize::Fixed: nH = o3tl::narrowing<sal_uInt16>(rSize.GetHeight()) & 0x7fff; break;
+ default: nH = o3tl::narrowing<sal_uInt16>(rSize.GetHeight()) | 0x8000; break;
}
m_rWW8Export.InsUInt16( nH );
}
@@ -3765,7 +4033,7 @@ void WW8AttributeOutput::FormatFrameSize( const SwFormatFrameSize& rSize )
{
/*sprmSBOrientation*/
m_rWW8Export.InsUInt16( NS_sprm::SBOrientation::val );
- m_rWW8Export.pO->push_back( 2 );
+ m_rWW8Export.m_pO->push_back( 2 );
}
/*sprmSXaPage*/
@@ -3789,15 +4057,15 @@ void WW8AttributeOutput::FormatFrameSize( const SwFormatFrameSize& rSize )
*
* @return FilePos + 1 of the replaced CR or 0 if nothing was replaced.
*/
-sal_uLong WW8Export::ReplaceCr( sal_uInt8 nChar )
+sal_uInt64 WW8Export::ReplaceCr( sal_uInt8 nChar )
{
OSL_ENSURE( nChar, "replaced with 0 crashes WW97/95" );
bool bReplaced = false;
SvStream& rStrm = Strm();
- sal_uLong nRetPos = 0, nPos = rStrm.Tell();
+ sal_uInt64 nRetPos = 0, nPos = rStrm.Tell();
//If there is at least two characters already output
- if (nPos - 2 >= o3tl::make_unsigned(pFib->m_fcMin))
+ if (nPos - 2 >= o3tl::make_unsigned(m_pFib->m_fcMin))
{
sal_uInt16 nUCode=0;
@@ -3807,7 +4075,7 @@ sal_uLong WW8Export::ReplaceCr( sal_uInt8 nChar )
if (nUCode == 0x0d) // CR ?
{
if ((nChar == 0x0c) &&
- (nPos - 4 >= o3tl::make_unsigned(pFib->m_fcMin)))
+ (nPos - 4 >= o3tl::make_unsigned(m_pFib->m_fcMin)))
{
rStrm.SeekRel(-4);
rStrm.ReadUInt16( nUCode );
@@ -3878,7 +4146,7 @@ void WW8AttributeOutput::PageBreakBefore( bool bBreak )
// sprmPPageBreakBefore/sprmPFPageBreakBefore
m_rWW8Export.InsUInt16( NS_sprm::PFPageBreakBefore::val );
- m_rWW8Export.pO->push_back( bBreak ? 1 : 0 );
+ m_rWW8Export.m_pO->push_back( bBreak ? 1 : 0 );
}
/**
@@ -3991,8 +4259,7 @@ sal_uInt32 AttributeOutputBase::GridCharacterPitch( const SwTextGridItem& rGrid
if (pSwFormat != nullptr)
{
- nPageCharSize = ItemGet<SvxFontHeightItem>
- (*pSwFormat, RES_CHRATR_FONTSIZE).GetHeight();
+ nPageCharSize = pSwFormat->GetFormatAttr(RES_CHRATR_FONTSIZE).GetHeight();
}
sal_uInt16 nPitch = rGrid.IsSquaredMode() ? rGrid.GetBaseHeight() :
rGrid.GetBaseWidth( );
@@ -4071,6 +4338,33 @@ void WW8AttributeOutput::FormatPaperBin( const SvxPaperBinItem& rPaperBin )
}
}
+void WW8AttributeOutput::FormatFirstLineIndent(SvxFirstLineIndentItem const& rFirstLine)
+{
+ // sprmPDxaLeft1
+ m_rWW8Export.InsUInt16( 0x8460 ); //asian version ?
+ m_rWW8Export.InsUInt16( rFirstLine.GetTextFirstLineOffset() );
+}
+
+void WW8AttributeOutput::FormatTextLeftMargin(SvxTextLeftMarginItem const& rTextLeftMargin)
+{ // normal paragraphs
+ // sprmPDxaLeft
+ m_rWW8Export.InsUInt16( 0x845E ); //asian version ?
+ m_rWW8Export.InsUInt16( o3tl::narrowing<sal_uInt16>(rTextLeftMargin.GetTextLeft()) );
+}
+
+void WW8AttributeOutput::FormatRightMargin(SvxRightMarginItem const& rRightMargin)
+{
+ // (paragraph case, this will be an else branch once others are converted)
+#if 0
+ else
+#endif
+ { // normal paragraphs
+ // sprmPDxaRight
+ m_rWW8Export.InsUInt16( 0x845D ); //asian version ?
+ m_rWW8Export.InsUInt16( o3tl::narrowing<sal_uInt16>(rRightMargin.GetRight()) );
+ }
+}
+
void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR )
{
// Flys are still missing ( see RTF )
@@ -4080,14 +4374,14 @@ void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR )
// sprmPDxaFromText10
m_rWW8Export.InsUInt16( NS_sprm::LN_PDxaFromText10 );
// use average, since WW only knows one value
- m_rWW8Export.InsUInt16( static_cast<sal_uInt16>( ( rLR.GetLeft() + rLR.GetRight() ) / 2 ) );
+ m_rWW8Export.InsUInt16( o3tl::narrowing<sal_uInt16>( ( rLR.GetLeft() + rLR.GetRight() ) / 2 ) );
}
else if ( m_rWW8Export.m_bOutPageDescs ) // PageDescs
{
m_pageMargins.nLeft = 0;
m_pageMargins.nRight = 0;
- if ( auto pBoxItem = static_cast<const SvxBoxItem*>(m_rWW8Export.HasItem( RES_BOX )) )
+ if ( const SvxBoxItem* pBoxItem = m_rWW8Export.HasItem( RES_BOX ) )
{
m_pageMargins.nLeft = pBoxItem->CalcLineSpace( SvxBoxItemLine::LEFT, /*bEvenIfNoLine*/true );
m_pageMargins.nRight = pBoxItem->CalcLineSpace( SvxBoxItemLine::RIGHT, /*bEvenIfNoLine*/true );
@@ -4116,11 +4410,11 @@ void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR )
{ // normal paragraphs
// sprmPDxaLeft
m_rWW8Export.InsUInt16( 0x845E ); //asian version ?
- m_rWW8Export.InsUInt16( static_cast<sal_uInt16>(rLR.GetTextLeft()) );
+ m_rWW8Export.InsUInt16( o3tl::narrowing<sal_uInt16>(rLR.GetTextLeft()) );
// sprmPDxaRight
m_rWW8Export.InsUInt16( 0x845D ); //asian version ?
- m_rWW8Export.InsUInt16( static_cast<sal_uInt16>(rLR.GetRight()) );
+ m_rWW8Export.InsUInt16( o3tl::narrowing<sal_uInt16>(rLR.GetRight()) );
// sprmPDxaLeft1
m_rWW8Export.InsUInt16( 0x8460 ); //asian version ?
@@ -4137,7 +4431,17 @@ void WW8AttributeOutput::SectionRtlGutter(const SfxBoolItem& rRtlGutter)
// sprmSFRTLGutter
m_rWW8Export.InsUInt16(NS_sprm::SFRTLGutter::val);
- m_rWW8Export.pO->push_back(1);
+ m_rWW8Export.m_pO->push_back(1);
+}
+
+void WW8AttributeOutput::TextLineBreak(const SwFormatLineBreak& rLineBreak)
+{
+ // Write the linebreak itself.
+ m_rWW8Export.WriteChar(0x0b);
+
+ // sprmCLbcCRJ
+ m_rWW8Export.InsUInt16(NS_sprm::CLbcCRJ::val);
+ m_rWW8Export.m_pO->push_back(rLineBreak.GetEnumValue());
}
void WW8AttributeOutput::FormatULSpace( const SvxULSpaceItem& rUL )
@@ -4149,7 +4453,7 @@ void WW8AttributeOutput::FormatULSpace( const SvxULSpaceItem& rUL )
// sprmPDyaFromText
m_rWW8Export.InsUInt16( NS_sprm::PDyaFromText::val );
// use average, since WW only knows one value
- m_rWW8Export.InsUInt16( static_cast<sal_uInt16>( ( rUL.GetUpper() + rUL.GetLower() ) / 2 ) );
+ m_rWW8Export.InsUInt16( o3tl::narrowing<sal_uInt16>( ( rUL.GetUpper() + rUL.GetLower() ) / 2 ) );
}
else if ( m_rWW8Export.m_bOutPageDescs ) // Page-UL
{
@@ -4163,25 +4467,25 @@ void WW8AttributeOutput::FormatULSpace( const SvxULSpaceItem& rUL )
{
//sprmSDyaHdrTop
m_rWW8Export.InsUInt16( NS_sprm::SDyaHdrTop::val );
- m_rWW8Export.InsUInt16( aDistances.dyaHdrTop );
+ m_rWW8Export.InsUInt16( aDistances.m_DyaHdrTop );
}
// sprmSDyaTop
m_rWW8Export.InsUInt16( NS_sprm::SDyaTop::val );
- m_rWW8Export.InsUInt16( aDistances.dyaTop );
- m_pageMargins.nTop = aDistances.dyaTop;
+ m_rWW8Export.InsUInt16( aDistances.m_DyaTop );
+ m_pageMargins.nTop = aDistances.m_DyaTop;
if ( aDistances.HasFooter() )
{
//sprmSDyaHdrBottom
m_rWW8Export.InsUInt16( NS_sprm::SDyaHdrBottom::val );
- m_rWW8Export.InsUInt16( aDistances.dyaHdrBottom );
+ m_rWW8Export.InsUInt16( aDistances.m_DyaHdrBottom );
}
//sprmSDyaBottom
m_rWW8Export.InsUInt16( NS_sprm::SDyaBottom::val );
- m_rWW8Export.InsUInt16( aDistances.dyaBottom );
- m_pageMargins.nBottom = aDistances.dyaBottom;
+ m_rWW8Export.InsUInt16( aDistances.m_DyaBottom );
+ m_pageMargins.nBottom = aDistances.m_DyaBottom;
}
else
{
@@ -4205,7 +4509,7 @@ void WW8AttributeOutput::FormatULSpace( const SvxULSpaceItem& rUL )
if (rUL.GetContext() || (pInherited && pInherited->GetContext()))
{
m_rWW8Export.InsUInt16(NS_sprm::PFContextualSpacing::val);
- m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(rUL.GetContext()) );
+ m_rWW8Export.m_pO->push_back( static_cast<sal_uInt8>(rUL.GetContext()) );
}
}
}
@@ -4218,7 +4522,7 @@ void WW8AttributeOutput::FormatSurround( const SwFormatSurround& rSurround )
{
m_rWW8Export.InsUInt16( NS_sprm::PWr::val );
- m_rWW8Export.pO->push_back(
+ m_rWW8Export.m_pO->push_back(
( css::text::WrapTextMode_NONE != rSurround.GetSurround() ) ? 2 : 1 );
}
}
@@ -4322,7 +4626,7 @@ void WW8AttributeOutput::FormatAnchor( const SwFormatAnchor& rAnchor )
// sprmPPc
m_rWW8Export.InsUInt16( NS_sprm::PPc::val );
- m_rWW8Export.pO->push_back( nP );
+ m_rWW8Export.m_pO->push_back( nP );
}
void WW8AttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
@@ -4338,7 +4642,7 @@ void WW8AttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
m_rWW8Export.InsUInt16( aSHD.GetValue() );
m_rWW8Export.InsUInt16( NS_sprm::PShd::val );
- m_rWW8Export.pO->push_back( 10 ); //size of operand: MUST be 10
+ m_rWW8Export.m_pO->push_back( 10 ); //size of operand: MUST be 10
m_rWW8Export.InsUInt32( 0xFF000000 ); //cvFore: Foreground BGR = cvAuto
m_rWW8Export.InsUInt32( SuitableBGColor( rBrush.GetColor() ) ); //cvBack
m_rWW8Export.InsUInt16( 0x0000 ); //iPat: specifies the pattern used for shading = clear/100% background
@@ -4360,7 +4664,7 @@ void WW8AttributeOutput::FormatFillStyle( const XFillStyleItem& rFillStyle )
//cvAuto
m_rWW8Export.InsUInt16( NS_sprm::PShd::val );
- m_rWW8Export.pO->push_back( 10 );
+ m_rWW8Export.m_pO->push_back( 10 );
m_rWW8Export.InsUInt32( 0xFF000000 );
m_rWW8Export.InsUInt32( 0xFF000000 );
m_rWW8Export.InsUInt16( 0x0000 );
@@ -4388,7 +4692,7 @@ WW8_BRCVer9 WW8Export::TranslateBorderLine(const SvxBorderLine& rLine,
{
case SvxBorderLineStyle::SOLID:
{
- if ( rLine.GetWidth( ) == DEF_LINE_WIDTH_0 )
+ if ( rLine.GetWidth( ) == SvxBorderLineWidth::Hairline )
brcType = 5;
else
brcType = 1;
@@ -4558,7 +4862,7 @@ void WW8Export::Out_SwFormatBox(const SvxBoxItem& rBox, bool bShadow)
nSprmNoVer9 = aPBrc[i+4];
}
- Out_BorderLine( *pO, pLn, rBox.GetDistance( *pBrd ), nSprmNo,
+ Out_BorderLine( *m_pO, pLn, rBox.GetDistance( *pBrd ), nSprmNo,
nSprmNoVer9, bShadow );
}
}
@@ -4610,12 +4914,12 @@ void WW8Export::Out_CellRangeBorders( const SvxBoxItem * pBox, sal_uInt8 nStart,
continue;
InsUInt16( NS_sprm::TSetBrc::val );
- pO->push_back( 11 );
- pO->push_back( nStart );
- pO->push_back( nLimit );
- pO->push_back( 1<<i );
+ m_pO->push_back( 11 );
+ m_pO->push_back( nStart );
+ m_pO->push_back( nLimit );
+ m_pO->push_back( 1<<i );
WW8_BRCVer9 aBrcVer9 = TranslateBorderLine( *pLn, 0, false );
- pO->insert( pO->end(), aBrcVer9.aBits1, aBrcVer9.aBits2+4 );
+ m_pO->insert( m_pO->end(), aBrcVer9.aBits1, aBrcVer9.aBits2+4 );
}
}
@@ -4627,12 +4931,11 @@ void WW8AttributeOutput::FormatBox( const SvxBoxItem& rBox )
return;
bool bShadow = false;
- const SfxPoolItem* pItem = m_rWW8Export.HasItem( RES_SHADOW );
- if ( pItem )
+ const SvxShadowItem* pShadowItem = m_rWW8Export.HasItem( RES_SHADOW );
+ if ( pShadowItem )
{
- const SvxShadowItem& rShadow = pItem->StaticWhichCast(RES_SHADOW);
- bShadow = ( rShadow.GetLocation() != SvxShadowLocation::NONE )
- && ( rShadow.GetWidth() != 0 );
+ bShadow = ( pShadowItem->GetLocation() != SvxShadowLocation::NONE )
+ && ( pShadowItem->GetWidth() != 0 );
}
SvxBoxItem aBox(rBox);
@@ -4676,13 +4979,13 @@ void WW8AttributeOutput::FormatColumns_Impl( sal_uInt16 nCols, const SwFormatCol
// LBetween
m_rWW8Export.InsUInt16( NS_sprm::SLBetween::val );
- m_rWW8Export.pO->push_back( COLADJ_NONE == rCol.GetLineAdj( )? 0 : 1 );
+ m_rWW8Export.m_pO->push_back( COLADJ_NONE == rCol.GetLineAdj( )? 0 : 1 );
const SwColumns & rColumns = rCol.GetColumns( );
// FEvenlySpaced
m_rWW8Export.InsUInt16( NS_sprm::SFEvenlySpaced::val );
- m_rWW8Export.pO->push_back( bEven ? 1 : 0 );
+ m_rWW8Export.m_pO->push_back( bEven ? 1 : 0 );
if ( bEven )
return;
@@ -4691,16 +4994,16 @@ void WW8AttributeOutput::FormatColumns_Impl( sal_uInt16 nCols, const SwFormatCol
{
//sprmSDxaColWidth
m_rWW8Export.InsUInt16( NS_sprm::SDxaColWidth::val );
- m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(n) );
+ m_rWW8Export.m_pO->push_back( static_cast<sal_uInt8>(n) );
m_rWW8Export.InsUInt16( rCol.
CalcPrtColWidth( n,
- static_cast<sal_uInt16>(nPageSize) ) );
+ o3tl::narrowing<sal_uInt16>(nPageSize) ) );
if ( n + 1 != nCols )
{
//sprmSDxaColSpacing
m_rWW8Export.InsUInt16( NS_sprm::SDxaColSpacing::val );
- m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(n) );
+ m_rWW8Export.m_pO->push_back( static_cast<sal_uInt8>(n) );
m_rWW8Export.InsUInt16( rColumns[n].GetRight( ) +
rColumns[n + 1].GetLeft( ) );
}
@@ -4761,11 +5064,11 @@ void AttributeOutputBase::FormatColumns( const SwFormatCol& rCol )
{
bEven = true;
sal_uInt16 n;
- sal_uInt16 nColWidth = rCol.CalcPrtColWidth( 0, static_cast<sal_uInt16>(nPageSize) );
+ sal_uInt16 nColWidth = rCol.CalcPrtColWidth( 0, o3tl::narrowing<sal_uInt16>(nPageSize) );
for ( n = 1; n < nCols; n++ )
{
short nDiff = nColWidth -
- rCol.CalcPrtColWidth( n, static_cast<sal_uInt16>(nPageSize) );
+ rCol.CalcPrtColWidth( n, o3tl::narrowing<sal_uInt16>(nPageSize) );
if ( nDiff > 10 || nDiff < -10 ) // Tolerance: 10 tw
{
@@ -4784,7 +5087,7 @@ void WW8AttributeOutput::FormatKeep( const SvxFormatKeepItem& rKeep )
// sprmFKeepFollow
m_rWW8Export.InsUInt16( NS_sprm::PFKeepFollow::val );
- m_rWW8Export.pO->push_back( rKeep.GetValue() ? 1 : 0 );
+ m_rWW8Export.m_pO->push_back( rKeep.GetValue() ? 1 : 0 );
}
// exclude a paragraph from Line Numbering
@@ -4793,7 +5096,7 @@ void WW8AttributeOutput::FormatLineNumbering( const SwFormatLineNumber& rNumberi
// sprmPFNoLineNumb
m_rWW8Export.InsUInt16( NS_sprm::PFNoLineNumb::val );
- m_rWW8Export.pO->push_back( rNumbering.IsCount() ? 0 : 1 );
+ m_rWW8Export.m_pO->push_back( rNumbering.IsCount() ? 0 : 1 );
}
/* File PARATR.HXX */
@@ -4878,7 +5181,7 @@ void WW8AttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
break;
case SvxAdjust::BlockLine:
case SvxAdjust::Block:
- nAdj = nAdjBiDi = 3;
+ nAdj = nAdjBiDi = rAdjust.GetLastBlock() == SvxAdjust::Block ? 4 : 3;
break;
case SvxAdjust::Center:
nAdj = nAdjBiDi = 1;
@@ -4888,7 +5191,7 @@ void WW8AttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
}
m_rWW8Export.InsUInt16(NS_sprm::PJc80::val);
- m_rWW8Export.pO->push_back(nAdj);
+ m_rWW8Export.m_pO->push_back(nAdj);
/*
Sadly for left to right paragraphs both these values are the same,
@@ -4907,8 +5210,7 @@ void WW8AttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
}
else if (auto pC = dynamic_cast<const SwTextFormatColl*>(m_rWW8Export.m_pOutFormatNode))
{
- const SvxFrameDirectionItem &rItem =
- ItemGet<SvxFrameDirectionItem>(*pC, RES_FRAMEDIR);
+ const SvxFrameDirectionItem &rItem = pC->GetFormatAttr(RES_FRAMEDIR);
nDirection = rItem.GetValue();
}
if ( ( nDirection == SvxFrameDirection::Horizontal_RL_TB ) ||
@@ -4919,9 +5221,9 @@ void WW8AttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
}
if (bBiDiSwap)
- m_rWW8Export.pO->push_back(nAdjBiDi);
+ m_rWW8Export.m_pO->push_back(nAdjBiDi);
else
- m_rWW8Export.pO->push_back(nAdj);
+ m_rWW8Export.m_pO->push_back(nAdj);
}
void WW8AttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDirection )
@@ -4958,12 +5260,12 @@ void WW8AttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDir
m_rWW8Export.InsUInt16( NS_sprm::STextFlow::val );
m_rWW8Export.InsUInt16( nTextFlow );
m_rWW8Export.InsUInt16( NS_sprm::SFBiDi::val );
- m_rWW8Export.pO->push_back( bBiDi ? 1 : 0 );
+ m_rWW8Export.m_pO->push_back( bBiDi ? 1 : 0 );
}
else if ( !m_rWW8Export.m_bOutFlyFrameAttrs ) //paragraph/style
{
m_rWW8Export.InsUInt16( NS_sprm::PFBiDi::val );
- m_rWW8Export.pO->push_back( bBiDi ? 1 : 0 );
+ m_rWW8Export.m_pO->push_back( bBiDi ? 1 : 0 );
}
}
@@ -4981,7 +5283,7 @@ void WW8AttributeOutput::ParaOutlineLevel(const SfxUInt16Item& rItem)
// Outline Level: in LO Body Text = 0, in MS Body Text = 9
nOutLvl = nOutLvl ? nOutLvl - 1 : 9;
m_rWW8Export.InsUInt16( NS_sprm::POutLvl::val );
- m_rWW8Export.pO->push_back( nOutLvl );
+ m_rWW8Export.m_pO->push_back( nOutLvl );
}
// "Separate paragraphs"
@@ -4989,7 +5291,7 @@ void WW8AttributeOutput::ParaSplit( const SvxFormatSplitItem& rSplit )
{
// sprmPFKeep
m_rWW8Export.InsUInt16( NS_sprm::PFKeep::val );
- m_rWW8Export.pO->push_back( rSplit.GetValue() ? 0 : 1 );
+ m_rWW8Export.m_pO->push_back( rSplit.GetValue() ? 0 : 1 );
}
/**
@@ -5001,18 +5303,18 @@ void WW8AttributeOutput::ParaWidows( const SvxWidowsItem& rWidows )
{
// sprmPFWidowControl
m_rWW8Export.InsUInt16( NS_sprm::PFWidowControl::val );
- m_rWW8Export.pO->push_back( rWidows.GetValue() ? 1 : 0 );
+ m_rWW8Export.m_pO->push_back( rWidows.GetValue() ? 1 : 0 );
}
namespace {
class SwWW8WrTabu
{
- std::unique_ptr<sal_uInt8[]> pDel; // DelArray
- std::unique_ptr<sal_uInt8[]> pAddPos; // AddPos-Array
- std::unique_ptr<sal_uInt8[]> pAddTyp; // AddTyp-Array
- sal_uInt16 nAdd; // number of tabs to be added
- sal_uInt16 nDel; // number of tabs to be deleted
+ std::unique_ptr<sal_uInt8[]> m_pDel; // DelArray
+ std::unique_ptr<sal_uInt8[]> m_pAddPos; // AddPos-Array
+ std::unique_ptr<sal_uInt8[]> m_pAddTyp; // AddTyp-Array
+ sal_uInt16 m_nAdd; // number of tabs to be added
+ sal_uInt16 m_nDel; // number of tabs to be deleted
SwWW8WrTabu(const SwWW8WrTabu&) = delete;
SwWW8WrTabu& operator=(const SwWW8WrTabu&) = delete;
@@ -5028,12 +5330,12 @@ public:
}
SwWW8WrTabu::SwWW8WrTabu(sal_uInt16 nDelMax, sal_uInt16 nAddMax)
- : nAdd(0), nDel(0)
+ : m_nAdd(0), m_nDel(0)
{
if (nDelMax)
- pDel.reset( new sal_uInt8[nDelMax * 2] );
- pAddPos.reset( new sal_uInt8[nAddMax * 2] );
- pAddTyp.reset( new sal_uInt8[nAddMax] );
+ m_pDel.reset( new sal_uInt8[nDelMax * 2] );
+ m_pAddPos.reset( new sal_uInt8[nAddMax * 2] );
+ m_pAddTyp.reset( new sal_uInt8[nAddMax] );
}
/**
@@ -5043,7 +5345,7 @@ void SwWW8WrTabu::Add(const SvxTabStop & rTS, tools::Long nAdjustment)
{
// insert tab position
ShortToSVBT16(msword_cast<sal_Int16>(rTS.GetTabPos() + nAdjustment),
- pAddPos.get() + (nAdd * 2));
+ m_pAddPos.get() + (m_nAdd * 2));
// insert tab type
sal_uInt8 nPara = 0;
@@ -5084,8 +5386,8 @@ void SwWW8WrTabu::Add(const SvxTabStop & rTS, tools::Long nAdjustment)
break;
}
- pAddTyp[nAdd] = nPara;
- ++nAdd;
+ m_pAddTyp[m_nAdd] = nPara;
+ ++m_nAdd;
}
/**
@@ -5095,8 +5397,8 @@ void SwWW8WrTabu::Del(const SvxTabStop &rTS, tools::Long nAdjustment)
{
// insert tab position
ShortToSVBT16(msword_cast<sal_Int16>(rTS.GetTabPos() + nAdjustment),
- pDel.get() + (nDel * 2));
- ++nDel;
+ m_pDel.get() + (m_nDel * 2));
+ ++m_nDel;
}
/**
@@ -5104,29 +5406,29 @@ void SwWW8WrTabu::Del(const SvxTabStop &rTS, tools::Long nAdjustment)
*/
void SwWW8WrTabu::PutAll(WW8Export& rWrt)
{
- if (!nAdd && !nDel) //If it's a no-op
+ if (!m_nAdd && !m_nDel) //If it's a no-op
return;
- OSL_ENSURE(nAdd <= 255, "more than 255 added tabstops?");
- OSL_ENSURE(nDel <= 255, "more than 244 removed tabstops?");
- if (nAdd > 255)
- nAdd = 255;
- if (nDel > 255)
- nDel = 255;
-
- sal_uInt16 nSiz = 2 * nDel + 3 * nAdd + 2;
+ OSL_ENSURE(m_nAdd <= 255, "more than 255 added tabstops?");
+ OSL_ENSURE(m_nDel <= 255, "more than 244 removed tabstops?");
+ if (m_nAdd > 255)
+ m_nAdd = 255;
+ if (m_nDel > 255)
+ m_nDel = 255;
+
+ sal_uInt16 nSiz = 2 * m_nDel + 3 * m_nAdd + 2;
if (nSiz > 255)
nSiz = 255;
rWrt.InsUInt16(NS_sprm::PChgTabsPapx::val);
// insert cch
- rWrt.pO->push_back(msword_cast<sal_uInt8>(nSiz));
+ rWrt.m_pO->push_back(msword_cast<sal_uInt8>(nSiz));
// write DelArr
- rWrt.pO->push_back(msword_cast<sal_uInt8>(nDel));
- rWrt.OutSprmBytes(pDel.get(), nDel * 2);
+ rWrt.m_pO->push_back(msword_cast<sal_uInt8>(m_nDel));
+ rWrt.OutSprmBytes(m_pDel.get(), m_nDel * 2);
// write InsArr
- rWrt.pO->push_back(msword_cast<sal_uInt8>(nAdd));
- rWrt.OutSprmBytes(pAddPos.get(), 2 * nAdd); // AddPosArray
- rWrt.OutSprmBytes(pAddTyp.get(), nAdd); // AddTypArray
+ rWrt.m_pO->push_back(msword_cast<sal_uInt8>(m_nAdd));
+ rWrt.OutSprmBytes(m_pAddPos.get(), 2 * m_nAdd); // AddPosArray
+ rWrt.OutSprmBytes(m_pAddTyp.get(), m_nAdd); // AddTypArray
}
static void ParaTabStopAdd( WW8Export& rWrt,
@@ -5243,13 +5545,15 @@ void WW8AttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStops )
tools::Long nCurrentLeft = 0;
if ( bTabsRelativeToIndex )
{
- if(const SfxPoolItem* pItem = m_rWW8Export.HasItem( RES_LR_SPACE ))
+ if (const SfxPoolItem* pItem = m_rWW8Export.HasItem(RES_MARGIN_TEXTLEFT))
{
- if(const auto pLR = pItem->DynamicWhichCast(RES_LR_SPACE))
- nCurrentLeft = pLR->GetTextLeft();
+ if (const auto pLeft = pItem->DynamicWhichCast(RES_MARGIN_TEXTLEFT))
+ {
+ nCurrentLeft = pLeft->GetTextLeft();
+ }
else
// FIXME: This fails in sw.ww8export/testCommentExport::Load_Verify_Reload_Verify
- SAL_WARN("sw.ww8", "m_rWW8Export has an RES_LR_SPACE item, but its of the wrong type.");
+ SAL_WARN("sw.ww8", "m_rWW8Export has an RES_LR_SPACE item, but it's of the wrong type.");
}
}
@@ -5271,8 +5575,8 @@ void WW8AttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStops )
tools::Long nParentLeft = 0;
if ( bTabsRelativeToIndex )
{
- const SvxLRSpaceItem &rStyleLR = ItemGet<SvxLRSpaceItem>( pParentStyle->GetAttrSet(), RES_LR_SPACE );
- nParentLeft = rStyleLR.GetTextLeft();
+ SvxTextLeftMarginItem const& rLeftMargin(pParentStyle->GetAttrSet().Get(RES_MARGIN_TEXTLEFT));
+ nParentLeft = rLeftMargin.GetTextLeft();
}
ParaTabStopDelAdd( m_rWW8Export, aParentTabs, nParentLeft, rTabStops, nCurrentLeft );
@@ -5294,8 +5598,8 @@ void WW8AttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStops )
tools::Long nStyleLeft = 0;
if ( bTabsRelativeToIndex )
{
- const SvxLRSpaceItem &rStyleLR = ItemGet<SvxLRSpaceItem>(*m_rWW8Export.m_pStyAttr, RES_LR_SPACE);
- nStyleLeft = rStyleLR.GetTextLeft();
+ SvxTextLeftMarginItem const& rLeftMargin(m_rWW8Export.m_pStyAttr->Get(RES_MARGIN_TEXTLEFT));
+ nStyleLeft = rLeftMargin.GetTextLeft();
}
ParaTabStopDelAdd( m_rWW8Export,
@@ -5322,40 +5626,40 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt )
CharCrossedOut(rHt.StaticWhichCast(RES_CHRATR_CROSSEDOUT));
break;
case RES_CHRATR_ESCAPEMENT:
- CharEscapement( static_cast< const SvxEscapementItem& >( rHt ) );
+ CharEscapement(rHt.StaticWhichCast(RES_CHRATR_ESCAPEMENT));
break;
case RES_CHRATR_FONT:
- CharFont( static_cast< const SvxFontItem& >( rHt ) );
+ CharFont(rHt.StaticWhichCast(RES_CHRATR_FONT));
break;
case RES_CHRATR_FONTSIZE:
- CharFontSize( static_cast< const SvxFontHeightItem& >( rHt ) );
+ CharFontSize(rHt.StaticWhichCast(RES_CHRATR_FONTSIZE));
break;
case RES_CHRATR_KERNING:
- CharKerning( static_cast< const SvxKerningItem& >( rHt ) );
+ CharKerning(rHt.StaticWhichCast(RES_CHRATR_KERNING));
break;
case RES_CHRATR_LANGUAGE:
- CharLanguage( static_cast< const SvxLanguageItem& >( rHt ) );
+ CharLanguage(rHt.StaticWhichCast(RES_CHRATR_LANGUAGE));
break;
case RES_CHRATR_POSTURE:
- CharPosture( static_cast< const SvxPostureItem& >( rHt ) );
+ CharPosture(rHt.StaticWhichCast(RES_CHRATR_POSTURE));
break;
case RES_CHRATR_SHADOWED:
- CharShadow( static_cast< const SvxShadowedItem& >( rHt ) );
+ CharShadow(rHt.StaticWhichCast(RES_CHRATR_SHADOWED));
break;
case RES_CHRATR_UNDERLINE:
- CharUnderline( static_cast< const SvxUnderlineItem& >( rHt ) );
+ CharUnderline(rHt.StaticWhichCast(RES_CHRATR_UNDERLINE));
break;
case RES_CHRATR_WEIGHT:
- CharWeight( static_cast< const SvxWeightItem& >( rHt ) );
+ CharWeight(rHt.StaticWhichCast(RES_CHRATR_WEIGHT));
break;
case RES_CHRATR_AUTOKERN:
- CharAutoKern( static_cast< const SvxAutoKernItem& >( rHt ) );
+ CharAutoKern(rHt.StaticWhichCast(RES_CHRATR_AUTOKERN));
break;
case RES_CHRATR_BLINK:
- CharAnimatedText( static_cast< const SvxBlinkItem& >( rHt ) );
+ CharAnimatedText(rHt.StaticWhichCast(RES_CHRATR_BLINK));
break;
case RES_CHRATR_BACKGROUND:
- CharBackgroundBase( static_cast< const SvxBrushItem& >( rHt ) );
+ CharBackgroundBase(rHt.StaticWhichCast(RES_CHRATR_BACKGROUND));
break;
case RES_CHRATR_CJK_FONT:
@@ -5391,28 +5695,28 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt )
break;
case RES_CHRATR_ROTATE:
- CharRotate( static_cast< const SvxCharRotateItem& >( rHt ) );
+ CharRotate(rHt.StaticWhichCast(RES_CHRATR_ROTATE));
break;
case RES_CHRATR_EMPHASIS_MARK:
- CharEmphasisMark( static_cast< const SvxEmphasisMarkItem& >( rHt ) );
+ CharEmphasisMark(rHt.StaticWhichCast(RES_CHRATR_EMPHASIS_MARK));
break;
case RES_CHRATR_TWO_LINES:
- CharTwoLines( static_cast< const SvxTwoLinesItem& >( rHt ) );
+ CharTwoLines(rHt.StaticWhichCast(RES_CHRATR_TWO_LINES));
break;
case RES_CHRATR_SCALEW:
- CharScaleWidth( static_cast< const SvxCharScaleWidthItem& >( rHt ) );
+ CharScaleWidth(rHt.StaticWhichCast(RES_CHRATR_SCALEW));
break;
case RES_CHRATR_RELIEF:
- CharRelief( static_cast< const SvxCharReliefItem& >( rHt ) );
+ CharRelief(rHt.StaticWhichCast(RES_CHRATR_RELIEF));
break;
case RES_CHRATR_HIDDEN:
- CharHidden( static_cast< const SvxCharHiddenItem& >( rHt ) );
+ CharHidden(rHt.StaticWhichCast(RES_CHRATR_HIDDEN));
break;
case RES_CHRATR_BOX:
- FormatCharBorder( static_cast< const SvxBoxItem& >( rHt ) );
+ FormatCharBorder(rHt.StaticWhichCast(RES_CHRATR_BOX));
break;
case RES_CHRATR_HIGHLIGHT:
- CharHighlight( static_cast< const SvxBrushItem& >( rHt ) );
+ CharHighlight(rHt.StaticWhichCast(RES_CHRATR_HIGHLIGHT));
break;
case RES_CHRATR_BIDIRTL:
CharBidiRTL( rHt );
@@ -5483,6 +5787,15 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt )
case RES_PAPER_BIN:
FormatPaperBin( static_cast< const SvxPaperBinItem& >( rHt ) );
break;
+ case RES_MARGIN_FIRSTLINE:
+ FormatFirstLineIndent(static_cast<const SvxFirstLineIndentItem &>(rHt));
+ break;
+ case RES_MARGIN_TEXTLEFT:
+ FormatTextLeftMargin(static_cast<const SvxTextLeftMarginItem &>(rHt));
+ break;
+ case RES_MARGIN_RIGHT:
+ FormatRightMargin(static_cast<const SvxRightMarginItem &>(rHt));
+ break;
case RES_LR_SPACE:
FormatLRSpace( static_cast< const SvxLRSpaceItem& >( rHt ) );
break;
@@ -5529,7 +5842,7 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt )
FormatTextGrid( static_cast< const SwTextGridItem& >( rHt ) );
break;
case RES_LINENUMBER:
- FormatLineNumbering( static_cast< const SwFormatLineNumber& >( rHt ) );
+ FormatLineNumberingBase(static_cast<const SwFormatLineNumber&>(rHt));
break;
case RES_FRAMEDIR:
FormatFrameDirection( static_cast< const SvxFrameDirectionItem& >( rHt ) );
@@ -5546,6 +5859,9 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt )
case RES_RTL_GUTTER:
SectionRtlGutter(static_cast<const SfxBoolItem&>(rHt));
break;
+ case RES_TXTATR_LINEBREAK:
+ TextLineBreak(static_cast<const SwFormatLineBreak&>(rHt));
+ break;
default:
SAL_INFO("sw.ww8", "Unhandled SfxPoolItem with id " << rHt.Which() );
@@ -5584,11 +5900,11 @@ void AttributeOutputBase::OutputStyleItemSet( const SfxItemSet& rSet, bool bTest
sal_uInt16 nWhich = aIter.FirstWhich();
while ( nWhich )
{
- if ( SfxItemState::SET == pSet->GetItemState( nWhich, true/*bDeep*/, &pItem ) &&
+ if ( SfxItemState::SET == aIter.GetItemState( true/*bDeep*/, &pItem ) &&
( !bTestForDefault ||
nWhich == RES_UL_SPACE ||
nWhich == RES_LR_SPACE ||
- *pItem != rPool.GetDefaultItem( nWhich ) ||
+ *pItem != rPool.GetUserOrPoolDefaultItem( nWhich ) ||
( pSet->GetParent() && *pItem != pSet->GetParent()->Get( nWhich ) ) ) )
{
OutputItem( *pItem );
@@ -5653,9 +5969,9 @@ const SwRedlineData* AttributeOutputBase::GetParagraphMarkerRedline( const SwTex
if ( pRedl->GetRedlineData().GetType() != aRedlineType )
continue;
- sal_uLong uStartNodeIndex = pRedl->Start()->nNode.GetIndex();
- sal_uLong uEndNodeIndex = pRedl->End()->nNode.GetIndex();
- sal_uLong uNodeIndex = rNode.GetIndex();
+ SwNodeOffset uStartNodeIndex = pRedl->Start()->GetNodeIndex();
+ SwNodeOffset uEndNodeIndex = pRedl->End()->GetNodeIndex();
+ SwNodeOffset uNodeIndex = rNode.GetIndex();
if( uStartNodeIndex <= uNodeIndex && uNodeIndex < uEndNodeIndex )
return &( pRedl->GetRedlineData() );
@@ -5665,7 +5981,7 @@ const SwRedlineData* AttributeOutputBase::GetParagraphMarkerRedline( const SwTex
void AttributeOutputBase::CharBackgroundBase( const SvxBrushItem& rBrush )
{
- bool bConvertToShading = SvtFilterOptions::Get().IsCharBackground2Shading();
+ bool bConvertToShading = !officecfg::Office::Common::Filter::Microsoft::Export::CharBackgroundToHighlighting::get();
bool bHasShadingMarker = false;
// MS Word doesn't support highlight in character styles. Always export those as shading.
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index f601cd361303..7a0d13a2bc62 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -58,7 +58,7 @@ public:
/// End of the text run.
///
/// No-op for binary filters.
- virtual void EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool bLastRun = false) override;
+ virtual void EndRun(const SwTextNode* pNode, sal_Int32 nPos, sal_Int32 nLen, bool bLastRun = false) override;
/// Before we start outputting the attributes.
virtual void StartRunProperties() override;
@@ -67,7 +67,7 @@ public:
virtual void EndRunProperties( const SwRedlineData* pRedlineData ) override;
/// Output text.
- virtual void RunText( const OUString& rText, rtl_TextEncoding eCharSet = RTL_TEXTENCODING_UTF8 ) override;
+ virtual void RunText( const OUString& rText, rtl_TextEncoding eCharSet = RTL_TEXTENCODING_UTF8, const OUString& rSymbolFont = OUString() ) override;
/// Output text (without markup).
virtual void RawText(const OUString& rText, rtl_TextEncoding eCharSet) override;
@@ -84,7 +84,7 @@ public:
/// Output URL end.
virtual bool EndURL(bool) override;
- virtual void FieldVanish(const OUString& rText, ww::eField eType, OUString const*) override;
+ virtual void FieldVanish(const OUString& rText, ww::eField eType, OUString const* pBookmarkName) override;
/// Output redlining.
virtual void Redline( const SwRedlineData* pRedline ) override;
@@ -99,20 +99,21 @@ public:
/// Output style.
virtual void ParagraphStyle( sal_uInt16 nStyle ) override;
- virtual void TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) override;
- virtual void TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) override;
- virtual void TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) override;
- virtual void TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) override;
- virtual void TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) override;
- virtual void TableRowRedline( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) override;
- virtual void TableCellRedline( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) override;
- virtual void TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) override;
- virtual void TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) override;
- virtual void TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) override;
- virtual void TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) override;
- virtual void TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner ) override;
- virtual void TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
- virtual void TableSpacing( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
+ virtual void TableInfoCell( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) override;
+ virtual void TableInfoRow( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) override;
+ virtual void TableDefinition( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) override;
+ void TablePositioning(SwFrameFormat* pFlyFormat);
+ virtual void TableDefaultBorders( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) override;
+ virtual void TableBackgrounds( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) override;
+ virtual void TableRowRedline( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) override;
+ virtual void TableCellRedline( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) override;
+ virtual void TableHeight( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) override;
+ virtual void TableCanSplit( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) override;
+ virtual void TableBidi( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) override;
+ virtual void TableVerticalCell( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfo ) override;
+ virtual void TableNodeInfoInner( const ww8::WW8TableNodeInfoInner::Pointer_t& pNodeInfoInner ) override;
+ virtual void TableOrientation( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) override;
+ virtual void TableSpacing( const ww8::WW8TableNodeInfoInner::Pointer_t& pTableTextNodeInfoInner ) override;
virtual void TableRowEnd( sal_uInt32 nDepth ) override;
/// Start of the styles table.
@@ -126,7 +127,7 @@ public:
/// Start of a style in the styles table.
virtual void StartStyle( const OUString& rName, StyleType eType,
- sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 nWwIdi, sal_uInt16 nId,
+ sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 nLink, sal_uInt16 nWwIdi, sal_uInt16 nSlot,
bool bAutoUpdate ) override;
/// End of a style in the styles table.
@@ -201,7 +202,8 @@ public:
sal_Int16 nFirstLineIndex,
sal_Int16 nListTabPos,
const OUString &rNumberingString,
- const SvxBrushItem* pBrush) override; //For i120928,transfer graphic of bullet
+ const SvxBrushItem* pBrush, //For i120928,transfer graphic of bullet
+ bool isLegal) override;
protected:
/// Output frames - the implementation.
@@ -366,6 +368,13 @@ protected:
/// Sfx item RES_PAPER_BIN
virtual void FormatPaperBin( const SvxPaperBinItem& ) override;
+ /// Sfx item RES_MARGIN_FIRSTLINE
+ virtual void FormatFirstLineIndent(const SvxFirstLineIndentItem & rFirstLine) override;
+ /// Sfx item RES_MARGIN_TEXTLEFT
+ virtual void FormatTextLeftMargin(const SvxTextLeftMarginItem & rTextLeftMargin) override;
+ /// Sfx item RES_MARGIN_RIGHT
+ virtual void FormatRightMargin(const SvxRightMarginItem & rRightMargin) override;
+
/// Sfx item RES_LR_SPACE
virtual void FormatLRSpace( const SvxLRSpaceItem& ) override;
@@ -436,6 +445,38 @@ protected:
void SectionRtlGutter( const SfxBoolItem& rRtlGutter) override;
+ void TextLineBreak(const SwFormatLineBreak& rLineBreak) override;
+
+public:
+ explicit WW8AttributeOutput( WW8Export &rWW8Export )
+ : AttributeOutputBase(rWW8Export.GetWriter().GetMedia()->GetURLObject().GetMainURL(
+ INetURLObject::DecodeMechanism::NONE))
+ , m_rWW8Export(rWW8Export)
+ , m_nPOPosStdLen1(0)
+ , m_nPOPosStdLen2(0)
+ , m_nStyleStartSize(0)
+ , m_nStyleLenPos(0)
+ , m_nStyleCountPos(0)
+ , m_nFieldResults(0)
+ , mbOnTOXEnding(false)
+ {
+ }
+
+ /// Return the right export class.
+ virtual WW8Export& GetExport() override { return m_rWW8Export; }
+
+protected:
+ /// Output the bold etc. attributes
+ void OutputWW8Attribute( sal_uInt8 nId, bool bVal );
+
+ /// Output the bold etc. attributes, the Complex Text Layout version
+ void OutputWW8AttributeCTL( sal_uInt8 nId, bool bVal );
+
+ void TableCellBorders(
+ ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner );
+
+private:
+
/// Reference to the export, where to get the data from
WW8Export &m_rWW8Export;
@@ -443,7 +484,7 @@ protected:
///
/// We have to remember these positions between the StartStyle() and
/// EndStyle().
- sal_uInt16 nPOPosStdLen1, nPOPosStdLen2;
+ sal_uInt16 m_nPOPosStdLen1, m_nPOPosStdLen2;
/// For output of styles.
///
@@ -468,39 +509,8 @@ protected:
std::multimap<sal_Int32, OUString> m_aBookmarksOfParagraphStart;
std::multimap<sal_Int32, OUString> m_aBookmarksOfParagraphEnd;
-public:
- explicit WW8AttributeOutput( WW8Export &rWW8Export )
- : AttributeOutputBase(rWW8Export.GetWriter().GetMedia()->GetURLObject().GetMainURL(
- INetURLObject::DecodeMechanism::NONE))
- , m_rWW8Export(rWW8Export)
- , nPOPosStdLen1(0)
- , nPOPosStdLen2(0)
- , m_nStyleStartSize(0)
- , m_nStyleLenPos(0)
- , m_nStyleCountPos(0)
- , m_nFieldResults(0)
- , mbOnTOXEnding(false)
- {
- }
-
- /// Return the right export class.
- virtual WW8Export& GetExport() override { return m_rWW8Export; }
-
-protected:
- /// Output the bold etc. attributes
- void OutputWW8Attribute( sal_uInt8 nId, bool bVal );
-
- /// Output the bold etc. attributes, the Complex Text Layout version
- void OutputWW8AttributeCTL( sal_uInt8 nId, bool bVal );
-
- void TableCellBorders(
- ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner );
-
-private:
-
editeng::WordPageMargins m_pageMargins;
bool m_bFromEdge = false;
-
};
#endif // INCLUDED_SW_SOURCE_FILTER_WW8_WW8ATTRIBUTEOUTPUT_HXX
diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx
index 012a4c4075f9..ac4338b7921b 100644
--- a/sw/source/filter/ww8/ww8glsy.cxx
+++ b/sw/source/filter/ww8/ww8glsy.cxx
@@ -34,29 +34,29 @@
#include "ww8glsy.hxx"
#include "ww8par.hxx"
-WW8Glossary::WW8Glossary(tools::SvRef<SotStorageStream> &refStrm, sal_uInt8 nVersion, SotStorage *pStg)
- : rStrm(refStrm)
- , xStg(pStg)
- , nStrings(0)
+WW8Glossary::WW8Glossary(rtl::Reference<SotStorageStream> &refStrm, sal_uInt8 nVersion, SotStorage *pStg)
+ : m_rStrm(refStrm)
+ , m_xStg(pStg)
+ , m_nStrings(0)
{
refStrm->SetEndian(SvStreamEndian::LITTLE);
WW8Fib aWwFib(*refStrm, nVersion);
if (aWwFib.m_nFibBack >= 0x6A) //Word97
{
- xTableStream = pStg->OpenSotStream(
- aWwFib.m_fWhichTableStm ? OUString(SL::a1Table) : OUString(SL::a0Table),
+ m_xTableStream = pStg->OpenSotStream(
+ aWwFib.m_fWhichTableStm ? SL::a1Table : SL::a0Table,
StreamMode::STD_READ);
- if (xTableStream.is() && ERRCODE_NONE == xTableStream->GetError())
+ if (m_xTableStream.is() && ERRCODE_NONE == m_xTableStream->GetError())
{
- xTableStream->SetEndian(SvStreamEndian::LITTLE);
- xGlossary = std::make_shared<WW8GlossaryFib>(*refStrm, nVersion, aWwFib);
+ m_xTableStream->SetEndian(SvStreamEndian::LITTLE);
+ m_xGlossary = std::make_shared<WW8GlossaryFib>(*refStrm, nVersion, aWwFib);
}
}
}
-bool WW8Glossary::HasBareGraphicEnd(SwDoc *pDoc,SwNodeIndex const &rIdx)
+bool WW8Glossary::HasBareGraphicEnd(SwDoc *pDoc, SwNode const &rIdx)
{
bool bRet=false;
for( sal_uInt16 nCnt = pDoc->GetSpzFrameFormats()->size(); nCnt; )
@@ -66,15 +66,15 @@ bool WW8Glossary::HasBareGraphicEnd(SwDoc *pDoc,SwNodeIndex const &rIdx)
RES_DRAWFRMFMT != pFrameFormat->Which() )
continue;
const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor();
- SwPosition const*const pAPos = rAnchor.GetContentAnchor();
- if (pAPos &&
+ SwNode const*const pAnchorNode = rAnchor.GetAnchorNode();
+ if (pAnchorNode &&
((RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId()) ||
(RndStdIds::FLY_AT_CHAR == rAnchor.GetAnchorId())) &&
- rIdx == pAPos->nNode.GetIndex() )
- {
- bRet=true;
- break;
- }
+ rIdx == *pAnchorNode )
+ {
+ bRet=true;
+ break;
+ }
}
return bRet;
}
@@ -115,29 +115,28 @@ bool WW8Glossary::MakeEntries(SwDoc *pD, SwTextBlocks &rBlocks,
do {
SwPaM aPam( aStart );
{
- SwNodeIndex& rIdx = aPam.GetPoint()->nNode;
- ++rIdx;
- pCNd = rIdx.GetNode().GetTextNode();
+ SwPosition& rPos = *aPam.GetPoint();
+ rPos.Adjust(SwNodeOffset(1));
+ pCNd = rPos.GetNode().GetTextNode();
if( nullptr == pCNd )
{
- pCNd = pD->GetNodes().MakeTextNode( rIdx, pColl );
- rIdx = *pCNd;
+ pCNd = pD->GetNodes().MakeTextNode( rPos.GetNode(), pColl );
+ rPos.Assign(*pCNd);
}
}
- aPam.GetPoint()->nContent.Assign( pCNd, 0 );
aPam.SetMark();
{
- SwNodeIndex& rIdx = aPam.GetPoint()->nNode;
- rIdx = aStart.GetNode().EndOfSectionIndex() - 1;
- if(( nullptr == ( pCNd = rIdx.GetNode().GetContentNode() ) )
- || HasBareGraphicEnd(pD,rIdx))
+ SwPosition& rPos = *aPam.GetPoint();
+ rPos.Assign(aStart.GetNode().EndOfSectionIndex() - 1);
+ if(( nullptr == ( pCNd = rPos.GetNode().GetContentNode() ) )
+ || HasBareGraphicEnd(pD,rPos.GetNode()))
{
- ++rIdx;
- pCNd = pD->GetNodes().MakeTextNode( rIdx, pColl );
- rIdx = *pCNd;
+ rPos.Adjust(SwNodeOffset(1));
+ pCNd = pD->GetNodes().MakeTextNode( rPos.GetNode(), pColl );
+ rPos.Assign(*pCNd);
}
}
- aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
+ aPam.GetPoint()->SetContent( pCNd->Len() );
// now we have the right selection for one entry. Copy this to
// the defined TextBlock, but only if it is not an autocorrection
@@ -169,7 +168,7 @@ bool WW8Glossary::MakeEntries(SwDoc *pD, SwTextBlocks &rBlocks,
SwNodeIndex aIdx( pGlDoc->GetNodes().GetEndOfContent(),
-1 );
pCNd = aIdx.GetNode().GetContentNode();
- SwPosition aPos(aIdx, SwIndex(pCNd, pCNd ? pCNd->Len() : 0));
+ SwPosition aPos(aIdx, pCNd, pCNd ? pCNd->Len() : 0);
pD->getIDocumentContentOperations().CopyRange(aPam, aPos, SwCopyFlags::CheckPosInFly);
rBlocks.PutDoc();
}
@@ -191,22 +190,22 @@ bool WW8Glossary::MakeEntries(SwDoc *pD, SwTextBlocks &rBlocks,
bool WW8Glossary::Load( SwTextBlocks &rBlocks, bool bSaveRelFile )
{
bool bRet=false;
- if (xGlossary && xGlossary->IsGlossaryFib() && rBlocks.StartPutMuchBlockEntries())
+ if (m_xGlossary && m_xGlossary->IsGlossaryFib() && rBlocks.StartPutMuchBlockEntries())
{
//read the names of the autotext entries
std::vector<OUString> aStrings;
std::vector<ww::bytes> aData;
rtl_TextEncoding eStructCharSet =
- WW8Fib::GetFIBCharset(xGlossary->m_chseTables, xGlossary->m_lid);
+ WW8Fib::GetFIBCharset(m_xGlossary->m_chseTables, m_xGlossary->m_lid);
- WW8ReadSTTBF(true, *xTableStream, xGlossary->m_fcSttbfglsy,
- xGlossary->m_lcbSttbfglsy, 0, eStructCharSet, aStrings, &aData );
+ WW8ReadSTTBF(true, *m_xTableStream, m_xGlossary->m_fcSttbfglsy,
+ m_xGlossary->m_lcbSttbfglsy, 0, eStructCharSet, aStrings, &aData );
- rStrm->Seek(0);
+ m_rStrm->Seek(0);
- nStrings = static_cast< sal_uInt16 >(aStrings.size());
- if ( 0 != nStrings )
+ m_nStrings = static_cast< sal_uInt16 >(aStrings.size());
+ if ( 0 != m_nStrings )
{
SfxObjectShellLock xDocSh(new SwDocShell(SfxObjectCreateMode::INTERNAL));
if (xDocSh->DoInitNew())
@@ -218,13 +217,11 @@ bool WW8Glossary::Load( SwTextBlocks &rBlocks, bool bSaveRelFile )
if( !aIdx.GetNode().IsTextNode() )
{
OSL_ENSURE( false, "Where is the TextNode?" );
- pD->GetNodes().GoNext( &aIdx );
+ SwNodes::GoNext(&aIdx);
}
SwPaM aPamo( aIdx );
- aPamo.GetPoint()->nContent.Assign(aIdx.GetNode().GetContentNode(),
- 0);
std::unique_ptr<SwWW8ImplReader> xRdr(new SwWW8ImplReader(
- xGlossary->m_nVersion, xStg.get(), rStrm.get(), *pD, rBlocks.GetBaseURL(),
+ m_xGlossary->m_nVersion, m_xStg.get(), m_rStrm.get(), *pD, rBlocks.GetBaseURL(),
true, false, *aPamo.GetPoint()));
xRdr->LoadDoc(this);
bRet = MakeEntries(pD, rBlocks, bSaveRelFile, aStrings, aData);
diff --git a/sw/source/filter/ww8/ww8glsy.hxx b/sw/source/filter/ww8/ww8glsy.hxx
index fd847de71269..65dfc328effc 100644
--- a/sw/source/filter/ww8/ww8glsy.hxx
+++ b/sw/source/filter/ww8/ww8glsy.hxx
@@ -60,28 +60,28 @@ private:
class WW8Glossary
{
public:
- WW8Glossary( tools::SvRef<SotStorageStream> &refStrm, sal_uInt8 nVersion, SotStorage *pStg);
+ WW8Glossary(rtl::Reference<SotStorageStream>& refStrm, sal_uInt8 nVersion, SotStorage* pStg);
bool Load( SwTextBlocks &rBlocks, bool bSaveRelFile );
std::shared_ptr<WW8GlossaryFib>& GetFib()
{
- return xGlossary;
+ return m_xGlossary;
}
sal_uInt16 GetNoStrings() const
{
- return nStrings;
+ return m_nStrings;
}
private:
- std::shared_ptr<WW8GlossaryFib> xGlossary;
- tools::SvRef<SotStorageStream> xTableStream;
- tools::SvRef<SotStorageStream> &rStrm;
- tools::SvRef<SotStorage> xStg;
- sal_uInt16 nStrings;
+ std::shared_ptr<WW8GlossaryFib> m_xGlossary;
+ rtl::Reference<SotStorageStream> m_xTableStream;
+ rtl::Reference<SotStorageStream> &m_rStrm;
+ rtl::Reference<SotStorage> m_xStg;
+ sal_uInt16 m_nStrings;
static bool MakeEntries(SwDoc *pD, SwTextBlocks &rBlocks, bool bSaveRelFile,
const std::vector<OUString>& rStrings,
const std::vector<ww::bytes>& rExtra);
- static bool HasBareGraphicEnd(SwDoc *pD,SwNodeIndex const &rIdx);
+ static bool HasBareGraphicEnd(SwDoc *pD, SwNode const &rIdx);
WW8Glossary(const WW8Glossary&) = delete;
WW8Glossary& operator=(const WW8Glossary&) = delete;
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index c4ea188cf03f..28b1211683d1 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -23,6 +23,7 @@
#include <osl/endian.h>
#include <sal/log.hxx>
#include <editeng/lrspitem.hxx>
+#include <svx/xflbmtit.hxx>
#include <svx/xfillit0.hxx>
#include <svx/xlineit0.hxx>
#include <svx/xlnclit.hxx>
@@ -57,6 +58,7 @@
#include <svx/svdogrp.hxx>
#include <svx/svdograf.hxx>
#include <svx/svdoole2.hxx>
+#include <editeng/colritem.hxx>
#include <editeng/ulspitem.hxx>
#include <editeng/brushitem.hxx>
#include <editeng/opaqitem.hxx>
@@ -98,7 +100,9 @@
#include <o3tl/enumrange.hxx>
#include <o3tl/safeint.hxx>
#include <memory>
+#include <optional>
#include <filter/msfilter/escherex.hxx>
+#include <utility>
#include "sprmids.hxx"
using ::editeng::SvxBorderLine;
@@ -164,7 +168,7 @@ void wwFrameNamer::SetUniqueGraphName(SwFrameFormat *pFrameFormat, std::u16strin
if (mbIsDisabled || rFixed.empty())
return;
- pFrameFormat->SetName(msSeed+OUString::number(++mnImportedGraphicsCount) + ": " + rFixed);
+ pFrameFormat->SetFormatName(msSeed+OUString::number(++mnImportedGraphicsCount) + ": " + rFixed);
}
// ReadGrafStart reads object data and if necessary creates an anchor
@@ -305,7 +309,7 @@ static void SetLineEndAttr( SfxItemSet& rSet, WW8_DP_LINEEND const & rLe,
}
// start of routines for the different objects
-SdrObject* SwWW8ImplReader::ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
WW8_DP_LINE aLine;
@@ -329,9 +333,9 @@ SdrObject* SwWW8ImplReader::ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet
::basegfx::B2DPolygon aPolygon;
aPolygon.append(::basegfx::B2DPoint(aP[0].X(), aP[0].Y()));
aPolygon.append(::basegfx::B2DPoint(aP[1].X(), aP[1].Y()));
- SdrObject* pObj = new SdrPathObj(
+ rtl::Reference<SdrObject> pObj = new SdrPathObj(
*m_pDrawModel,
- OBJ_LINE,
+ SdrObjKind::Line,
::basegfx::B2DPolyPolygon(aPolygon));
SetStdAttr( rSet, aLine.aLnt, aLine.aShd );
@@ -340,7 +344,7 @@ SdrObject* SwWW8ImplReader::ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
WW8_DP_RECT aRect;
@@ -353,7 +357,7 @@ SdrObject* SwWW8ImplReader::ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet
aP1.AdjustX(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dxa )) );
aP1.AdjustY(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dya )) );
- SdrObject* pObj = new SdrRectObj(
+ rtl::Reference<SdrObject> pObj = new SdrRectObj(
*m_pDrawModel,
tools::Rectangle(aP0, aP1));
@@ -363,7 +367,7 @@ SdrObject* SwWW8ImplReader::ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
WW8_DP_ELLIPSE aEllipse;
@@ -376,7 +380,7 @@ SdrObject* SwWW8ImplReader::ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &r
aP1.AdjustX(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dxa )) );
aP1.AdjustY(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dya )) );
- SdrObject* pObj = new SdrCircObj(
+ rtl::Reference<SdrObject> pObj = new SdrCircObj(
*m_pDrawModel,
SdrCircKind::Full,
tools::Rectangle(aP0, aP1));
@@ -387,7 +391,7 @@ SdrObject* SwWW8ImplReader::ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &r
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
WW8_DP_ARC aArc;
@@ -411,7 +415,7 @@ SdrObject* SwWW8ImplReader::ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
aP1.AdjustX( -static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dxa )) );
}
- SdrObject* pObj = new SdrCircObj(
+ rtl::Reference<SdrObject> pObj = new SdrCircObj(
*m_pDrawModel,
SdrCircKind::Section,
tools::Rectangle(aP0, aP1),
@@ -424,7 +428,7 @@ SdrObject* SwWW8ImplReader::ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
WW8_DP_POLYLINE aPoly;
@@ -451,9 +455,9 @@ SdrObject* SwWW8ImplReader::ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &
}
xP.reset();
- SdrObject* pObj = new SdrPathObj(
+ rtl::Reference<SdrObject> pObj = new SdrPathObj(
*m_pDrawModel,
- (SVBT16ToUInt16(aPoly.aBits1) & 0x1) ? OBJ_POLY : OBJ_PLIN,
+ (SVBT16ToUInt16(aPoly.aBits1) & 0x1) ? SdrObjKind::Polygon : SdrObjKind::PolyLine,
::basegfx::B2DPolyPolygon(aP.getB2DPolygon()));
SetStdAttr( rSet, aPoly.aLnt, aPoly.aShd );
@@ -510,7 +514,7 @@ void SwWW8ImplReader::InsertTxbxStyAttrs( SfxItemSet& rS, sal_uInt16 nColl )
sal_uInt16 nSlotId = m_rDoc.GetAttrPool().GetSlotId(nWhich);
if (
nSlotId && nWhich != nSlotId &&
- 0 != (nWhich = pEditPool->GetWhich(nSlotId)) &&
+ 0 != (nWhich = pEditPool->GetWhichIDFromSlotID(nSlotId)) &&
nWhich != nSlotId &&
( SfxItemState::SET != rS.GetItemState(nWhich, false) )
)
@@ -541,7 +545,7 @@ static void lcl_StripFields(OUString &rString, WW8_CP &rNewStartCp)
}
const bool was0x14 = rString[nStopPos]==0x14;
- rString = rString.replaceAt(nStartPos, nStopPos+1-nStartPos, "");
+ rString = rString.replaceAt(nStartPos, nStopPos+1-nStartPos, u"");
rNewStartCp += nStopPos-nStartPos;
if (was0x14)
@@ -550,7 +554,7 @@ static void lcl_StripFields(OUString &rString, WW8_CP &rNewStartCp)
nStartPos = rString.indexOf(0x15, nStartPos);
if (nStartPos<0)
return;
- rString = rString.replaceAt(nStartPos, 1, "");
+ rString = rString.replaceAt(nStartPos, 1, u"");
}
}
}
@@ -564,8 +568,8 @@ private:
tools::Long mnStartPos; // 0x13
tools::Long mnEndPos; // 0x15
public:
- explicit Chunk(tools::Long nStart, const OUString &rURL)
- : msURL(rURL), mnStartPos(nStart), mnEndPos(0) {}
+ explicit Chunk(tools::Long nStart, OUString aURL)
+ : msURL(std::move(aURL)), mnStartPos(nStart), mnEndPos(0) {}
void SetEndPos(tools::Long nEnd) { mnEndPos = nEnd; }
tools::Long GetStartPos() const {return mnStartPos;}
@@ -608,7 +612,7 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(WW8_CP nStartCp, WW8_CP nEndCp,
bool bDoingSymbol = false;
sal_Unicode cReplaceSymbol = m_cSymbol;
- std::unique_ptr<SfxItemSet> pS(new SfxItemSet(m_pDrawEditEngine->GetEmptyItemSet()));
+ std::optional<SfxItemSet> pS(m_pDrawEditEngine->GetEmptyItemSet());
WW8PLCFManResult aRes;
std::deque<Chunk> aChunks;
@@ -633,7 +637,7 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(WW8_CP nStartCp, WW8_CP nEndCp,
if ( (68 == aRes.nSprmId) || (0x6A03 == aRes.nSprmId) )
{
Read_PicLoc(aRes.nSprmId, aRes.pMemPos +
- m_xSprmParser->DistanceToData(aRes.nSprmId), 4);
+ m_oSprmParser->DistanceToData(aRes.nSprmId), 4);
// Ok, that's what we were looking for. Now let's get
// out of here!
break;
@@ -659,12 +663,22 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(WW8_CP nStartCp, WW8_CP nEndCp,
if (!m_bSymbol && bDoingSymbol)
{
bDoingSymbol = false;
- OUStringBuffer sTemp;
- comphelper::string::padToLength(sTemp,
- nTextStart - nStartReplace, cReplaceSymbol);
- m_pDrawEditEngine->QuickInsertText(sTemp.makeStringAndClear(),
- GetESelection(*m_pDrawEditEngine, nStartReplace - nStartCp,
- nTextStart - nStartCp ) );
+
+ ESelection aReplaceSel(GetESelection(*m_pDrawEditEngine, nStartReplace - nStartCp,
+ nTextStart - nStartCp));
+
+ sal_Int32 nParaCount = m_pDrawEditEngine->GetParagraphCount();
+ bool bBadSelection = aReplaceSel.nStartPara >= nParaCount || aReplaceSel.nEndPara >= nParaCount;
+
+ SAL_WARN_IF(bBadSelection, "sw.ww8", "editengine has different amount of text than expected");
+
+ if (!bBadSelection)
+ {
+ sal_Int32 nCount = nTextStart - nStartReplace;
+ OUStringBuffer sTemp(nCount);
+ comphelper::string::padToLength(sTemp, nCount, cReplaceSymbol);
+ m_pDrawEditEngine->QuickInsertText(sTemp.makeStringAndClear(), aReplaceSel);
+ }
}
}
}
@@ -678,7 +692,7 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(WW8_CP nStartCp, WW8_CP nEndCp,
OUString sURL;
for (size_t nI = m_xCtrlStck->size(); nI > nCount; --nI)
{
- const SfxPoolItem *pItem = ((*m_xCtrlStck)[nI-1]).pAttr.get();
+ const SfxPoolItem *pItem = ((*m_xCtrlStck)[nI-1]).m_pAttr.get();
sal_uInt16 nWhich = pItem->Which();
if (nWhich == RES_TXTATR_INETFMT)
{
@@ -714,15 +728,20 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(WW8_CP nStartCp, WW8_CP nEndCp,
{
for (size_t i = nCurrentCount; i < m_xCtrlStck->size(); ++i)
{
- const SfxPoolItem *pItem = ((*m_xCtrlStck)[i]).pAttr.get();
+ const SfxPoolItem *pItem = ((*m_xCtrlStck)[i]).m_pAttr.get();
sal_uInt16 nWhich = pItem->Which();
if( nWhich < RES_FLTRATTR_BEGIN ||
nWhich >= RES_FLTRATTR_END )
{
sal_uInt16 nSlotId = m_rDoc.GetAttrPool().GetSlotId(nWhich);
- if (
+ if (nWhich == RES_CHRATR_BACKGROUND || nWhich == RES_CHRATR_HIGHLIGHT)
+ {
+ Color aColor(static_cast<const SvxBrushItem*>(pItem)->GetColor());
+ pS->Put(SvxColorItem(aColor, EE_CHAR_BKGCOLOR));
+ }
+ else if (
nSlotId && nWhich != nSlotId &&
- 0 != (nWhich = pEditPool->GetWhich(nSlotId)) &&
+ 0 != (nWhich = pEditPool->GetWhichIDFromSlotID(nSlotId)) &&
nWhich != nSlotId
)
{
@@ -738,7 +757,7 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(WW8_CP nStartCp, WW8_CP nEndCp,
{
m_pDrawEditEngine->QuickSetAttribs( *pS,
GetESelection(*m_pDrawEditEngine, nTextStart - nStartCp, nEnd - nStartCp ) );
- pS.reset( new SfxItemSet(m_pDrawEditEngine->GetEmptyItemSet()) );
+ pS.emplace(m_pDrawEditEngine->GetEmptyItemSet());
}
}
nStart = nNext;
@@ -949,13 +968,19 @@ static void removePositions(EditEngine &rDrawEditEngine, const std::vector<sal_I
}
}
-std::unique_ptr<OutlinerParaObject> SwWW8ImplReader::ImportAsOutliner(OUString &rString, WW8_CP nStartCp, WW8_CP nEndCp, ManTypes eType)
+std::optional<OutlinerParaObject> SwWW8ImplReader::ImportAsOutliner(OUString &rString, WW8_CP nStartCp, WW8_CP nEndCp, ManTypes eType)
{
- std::unique_ptr<OutlinerParaObject> pRet;
+ std::optional<OutlinerParaObject> pRet;
sal_Int32 nLen = GetRangeAsDrawingString(rString, nStartCp, nEndCp, eType);
if (nLen > 0)
{
+ if (m_bFuzzing && rString.getLength() > 1024)
+ {
+ SAL_WARN("sw.ww8", "Truncating long EditEngine strings when fuzzing for performance");
+ rString = rString.copy(0, 1024);
+ }
+
if (!m_pDrawEditEngine)
{
m_pDrawEditEngine.reset(new EditEngine(nullptr));
@@ -981,7 +1006,7 @@ std::unique_ptr<OutlinerParaObject> SwWW8ImplReader::ImportAsOutliner(OUString &
}
std::unique_ptr<EditTextObject> pTemporaryText = m_pDrawEditEngine->CreateTextObject();
- pRet.reset( new OutlinerParaObject( std::move(pTemporaryText) ) );
+ pRet.emplace( std::move(pTemporaryText) );
pRet->SetOutlinerMode( OutlinerMode::TextObject );
m_pDrawEditEngine->SetText( OUString() );
@@ -1009,7 +1034,7 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj,
bool* pbContainsGraphics, SvxMSDffImportRec const * pRecord)
{
SwFrameFormat* pFlyFormat = nullptr;
- sal_uLong nOld = m_pStrm->Tell();
+ sal_uInt64 nOld = m_pStrm->Tell();
ManTypes eType = m_xPlcxMan->GetManType() == MAN_HDFT ? MAN_TXBX_HDFT : MAN_TXBX;
@@ -1028,6 +1053,12 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj,
if( pObjSiz )
m_pDrawEditEngine->SetPaperSize( *pObjSiz );
+ if (m_bFuzzing && aString.getLength() > 1024)
+ {
+ SAL_WARN("sw.ww8", "Truncating long EditEngine strings when fuzzing for performance");
+ aString = aString.copy(0, 1024);
+ }
+
const OUString aOrigString(aString);
if( bTextWasRead )
{
@@ -1056,7 +1087,7 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj,
WW8PLCFx_Cp_FKP* pChp = m_xPlcxMan->GetChpPLCF();
WW8PLCFxDesc aDesc;
pChp->GetSprms( &aDesc );
- WW8SprmIter aSprmIter(aDesc.pMemPos, aDesc.nSprmsLen, *m_xSprmParser);
+ WW8SprmIter aSprmIter(aDesc.pMemPos, aDesc.nSprmsLen, *m_oSprmParser);
for( int nLoop = 0; nLoop < 2; ++nLoop )
{
@@ -1103,12 +1134,12 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj,
// SdrTextObj in this Group
Graphic aGraph;
- SdrObject* pNew = ImportOleBase(aGraph);
+ rtl::Reference<SdrObject> pNew = ImportOleBase(aGraph);
if( !pNew )
{
pNew = new SdrGrafObj(*m_pDrawModel);
- static_cast<SdrGrafObj*>(pNew)->SetGraphic(aGraph);
+ static_cast<SdrGrafObj*>(pNew.get())->SetGraphic(aGraph);
}
GraphicCtor();
@@ -1117,7 +1148,7 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj,
pNew->SetLayer( pTextObj->GetLayer() );
pTextObj->getParentSdrObjectFromSdrObject()->GetSubList()->
- ReplaceObject(pNew, pTextObj->GetOrdNum());
+ ReplaceObject(pNew.get(), pTextObj->GetOrdNum());
}
else
pFlyFormat = ImportOle();
@@ -1145,8 +1176,8 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj,
{
if( pFlyFormat && pRecord )
{
- SfxItemSet aFlySet( m_rDoc.GetAttrPool(),
- svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1, XATTR_START, XATTR_END>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1, XATTR_START, XATTR_END>
+ aFlySet( m_rDoc.GetAttrPool() );
tools::Rectangle aInnerDist( pRecord->nDxTextLeft,
pRecord->nDyTextTop,
@@ -1185,10 +1216,10 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj,
}
bool bVertical = pTextObj->IsVerticalWriting();
- std::unique_ptr<OutlinerParaObject> pOp(new OutlinerParaObject(m_pDrawEditEngine->CreateTextObject()));
- pOp->SetOutlinerMode( OutlinerMode::TextObject );
- pOp->SetVertical( bVertical );
- pTextObj->NbcSetOutlinerParaObject( std::move(pOp) );
+ OutlinerParaObject aOp(m_pDrawEditEngine->CreateTextObject());
+ aOp.SetOutlinerMode( OutlinerMode::TextObject );
+ aOp.SetVertical( bVertical );
+ pTextObj->NbcSetOutlinerParaObject( std::move(aOp) );
pTextObj->SetVerticalWriting(bVertical);
// For the next TextBox also remove the old paragraph attributes
@@ -1216,7 +1247,7 @@ bool SwWW8ImplReader::TxbxChainContainsRealText(sal_uInt16 nTxBxS, tools::Long&
}
// TextBoxes only for Ver67 !!
-SdrObject* SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
bool bDummy;
WW8_DP_TXTBOX aTextB;
@@ -1230,9 +1261,9 @@ SdrObject* SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &r
aP1.AdjustX(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dxa )) );
aP1.AdjustY(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dya )) );
- SdrRectObj* pObj = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pObj = new SdrRectObj(
*m_pDrawModel,
- OBJ_TEXT,
+ SdrObjKind::Text,
tools::Rectangle(aP0, aP1));
pObj->NbcSetSnapRect(tools::Rectangle(aP0, aP1));
@@ -1241,7 +1272,7 @@ SdrObject* SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &r
tools::Long nStartCpFly,nEndCpFly;
bool bContainsGraphics;
- InsertTxbxText(pObj, &aSize, 0, 0, 0, nullptr, false,
+ InsertTxbxText(pObj.get(), &aSize, 0, 0, 0, nullptr, false,
bDummy,nullptr,&nStartCpFly,&nEndCpFly,&bContainsGraphics);
SetStdAttr( rSet, aTextB.aLnt, aTextB.aShd );
@@ -1258,7 +1289,7 @@ SdrObject* SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &r
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
static const SdrCaptionType aCaptA[] = { SdrCaptionType::Type1, SdrCaptionType::Type2,
SdrCaptionType::Type3, SdrCaptionType::Type4 };
@@ -1303,7 +1334,7 @@ SdrObject* SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet
+ m_nDrawYOfs2 + static_cast<sal_Int16>(SVBT16ToUInt16( xP[1] )) );
xP.reset();
- SdrCaptionObj* pObj = new SdrCaptionObj(
+ rtl::Reference<SdrCaptionObj> pObj = new SdrCaptionObj(
*m_pDrawModel,
tools::Rectangle(aP0, aP1),
aP2);
@@ -1313,7 +1344,7 @@ SdrObject* SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet
static_cast<sal_Int16>(SVBT16ToUInt16( aCallB.dpheadTxbx.dya )) );
bool bEraseThisObject;
- InsertTxbxText(pObj, &aSize, 0, 0, 0, nullptr, false, bEraseThisObject );
+ InsertTxbxText(pObj.get(), &aSize, 0, 0, 0, nullptr, false, bEraseThisObject );
if( SVBT16ToUInt16( aCallB.dptxbx.aLnt.lnps ) != 5 ) // Is border visible ?
SetStdAttr( rSet, aCallB.dptxbx.aLnt, aCallB.dptxbx.aShd );
@@ -1325,7 +1356,7 @@ SdrObject* SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet
return pObj;
}
-SdrObject *SwWW8ImplReader::ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
sal_Int16 nGrouped;
@@ -1339,19 +1370,19 @@ SdrObject *SwWW8ImplReader::ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSe
m_nDrawXOfs = m_nDrawXOfs + static_cast<sal_Int16>(SVBT16ToUInt16( pHd->xa ));
m_nDrawYOfs = m_nDrawYOfs + static_cast<sal_Int16>(SVBT16ToUInt16( pHd->ya ));
- SdrObject* pObj = new SdrObjGroup(*m_pDrawModel);
+ rtl::Reference<SdrObject> pObj = new SdrObjGroup(*m_pDrawModel);
short nLeft = static_cast<sal_Int16>(SVBT16ToUInt16( pHd->cb )) - sizeof( WW8_DPHEAD );
for (int i = 0; i < nGrouped && nLeft >= static_cast<short>(sizeof(WW8_DPHEAD)); ++i)
{
SfxAllItemSet aSet(m_pDrawModel->GetItemPool());
- if (SdrObject *pObject = ReadGrafPrimitive(nLeft, aSet))
+ if (rtl::Reference<SdrObject> pObject = ReadGrafPrimitive(nLeft, aSet))
{
// first add and then set ItemSet
SdrObjList *pSubGroup = pObj->GetSubList();
OSL_ENSURE(pSubGroup, "Why no sublist available?");
if (pSubGroup)
- pSubGroup->InsertObject(pObject, 0);
+ pSubGroup->InsertObject(pObject.get(), 0);
pObject->SetMergedItemSetAndBroadcast(aSet);
}
}
@@ -1362,11 +1393,11 @@ SdrObject *SwWW8ImplReader::ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSe
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadGrafPrimitive(short& rLeft, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadGrafPrimitive(short& rLeft, SfxAllItemSet &rSet)
{
// This whole archaic word 6 graphic import can probably be refactored
// into an object hierarchy with a little effort.
- SdrObject *pRet=nullptr;
+ rtl::Reference<SdrObject> pRet;
WW8_DPHEAD aHd; // Read Draw-Primitive-Header
bool bCouldRead = checkRead(*m_pStrm, &aHd, sizeof(WW8_DPHEAD)) &&
SVBT16ToUInt16(aHd.cb) >= sizeof(WW8_DPHEAD);
@@ -1436,7 +1467,16 @@ void SwWW8ImplReader::ReadGrafLayer1(WW8PLCFspecial& rPF, tools::Long nGrafAncho
return;
}
- bool bCouldSeek = checkSeek(*m_pStrm, SVBT32ToUInt32(pF->fc));
+ sal_uInt32 nPosFc = SVBT32ToUInt32(pF->fc);
+
+ //skip duplicate graphics when fuzzing
+ if (m_bFuzzing)
+ {
+ if (!m_aGrafPosSet.insert(nPosFc).second)
+ return;
+ }
+
+ bool bCouldSeek = checkSeek(*m_pStrm, nPosFc);
OSL_ENSURE(bCouldSeek, "Invalid graphic offset");
if (!bCouldSeek)
return;
@@ -1452,9 +1492,9 @@ void SwWW8ImplReader::ReadGrafLayer1(WW8PLCFspecial& rPF, tools::Long nGrafAncho
while (nLeft > static_cast<short>(sizeof(WW8_DPHEAD)))
{
SfxAllItemSet aSet( m_pDrawModel->GetItemPool() );
- if (SdrObject *pObject = ReadGrafPrimitive(nLeft, aSet))
+ if (rtl::Reference<SdrObject> pObject = ReadGrafPrimitive(nLeft, aSet))
{
- m_xWWZOrder->InsertDrawingObject(pObject, SVBT16ToUInt16(aDo.dhgt));
+ m_xWWZOrder->InsertDrawingObject(pObject.get(), SVBT16ToUInt16(aDo.dhgt));
tools::Rectangle aRect(pObject->GetSnapRect());
@@ -1709,15 +1749,14 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject const * pSdrObj,
// now calculate the borders and build the box: The unit is needed for the
// frame SIZE!
- SvxBoxItem aBox(sw::util::ItemGet<SvxBoxItem>(rFlySet, RES_BOX));
+ SvxBoxItem aBox(rFlySet.Get(RES_BOX));
// dashed or solid becomes solid
// WW-default: 0.75 pt = 15 twips
sal_Int32 nLineThick = 15, nOutside=0;
// check if LineStyle is *really* set!
- const SfxPoolItem* pItem;
- SfxItemState eState = rOldSet.GetItemState(XATTR_LINESTYLE,true,&pItem);
+ SfxItemState eState = rOldSet.GetItemState(XATTR_LINESTYLE);
if( eState == SfxItemState::SET )
{
// Now, that we know there is a line style we will make use the
@@ -1744,13 +1783,13 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject const * pSdrObj,
// set distances from box's border to text contained within the box
if( 0 < rInnerDist.Left() )
- aBox.SetDistance( static_cast<sal_uInt16>(rInnerDist.Left()), SvxBoxItemLine::LEFT );
+ aBox.SetDistance( o3tl::narrowing<sal_uInt16>(rInnerDist.Left()), SvxBoxItemLine::LEFT );
if( 0 < rInnerDist.Top() )
- aBox.SetDistance( static_cast<sal_uInt16>(rInnerDist.Top()), SvxBoxItemLine::TOP );
+ aBox.SetDistance( o3tl::narrowing<sal_uInt16>(rInnerDist.Top()), SvxBoxItemLine::TOP );
if( 0 < rInnerDist.Right() )
- aBox.SetDistance( static_cast<sal_uInt16>(rInnerDist.Right()), SvxBoxItemLine::RIGHT );
+ aBox.SetDistance( o3tl::narrowing<sal_uInt16>(rInnerDist.Right()), SvxBoxItemLine::RIGHT );
if( 0 < rInnerDist.Bottom() )
- aBox.SetDistance( static_cast<sal_uInt16>(rInnerDist.Bottom()), SvxBoxItemLine::BOTTOM );
+ aBox.SetDistance( o3tl::narrowing<sal_uInt16>(rInnerDist.Bottom()), SvxBoxItemLine::BOTTOM );
bool bFixSize = !(WW8ITEMVALUE(rOldSet, SDRATTR_TEXT_AUTOGROWHEIGHT,
SdrOnOffItem));
@@ -1832,7 +1871,7 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject const * pSdrObj,
sal_uInt8 nTrans = 0;
// Separate transparency
- eState = rOldSet.GetItemState(XATTR_FILLTRANSPARENCE, true, &pItem);
+ eState = rOldSet.GetItemState(XATTR_FILLTRANSPARENCE);
if (!bSkipResBackground && eState == SfxItemState::SET)
{
sal_uInt16 nRes = WW8ITEMVALUE(rOldSet, XATTR_FILLTRANSPARENCE,
@@ -1843,10 +1882,10 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject const * pSdrObj,
}
// Background: SvxBrushItem
- eState = rOldSet.GetItemState(XATTR_FILLSTYLE, true, &pItem);
- if (!bSkipResBackground && eState == SfxItemState::SET)
+ const XFillStyleItem* pFillStyleItem = rOldSet.GetItemIfSet(XATTR_FILLSTYLE);
+ if (!bSkipResBackground && pFillStyleItem)
{
- const drawing::FillStyle eFill = static_cast<const XFillStyleItem*>(pItem)->GetValue();
+ const drawing::FillStyle eFill = pFillStyleItem->GetValue();
switch (eFill)
{
@@ -1877,7 +1916,7 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject const * pSdrObj,
case drawing::FillStyle_BITMAP:
{
GraphicObject aGrfObj(rOldSet.Get(XATTR_FILLBITMAP).GetGraphicObject());
- const bool bTile(WW8ITEMVALUE(rOldSet, XATTR_FILLBMP_TILE, SfxBoolItem));
+ const bool bTile(WW8ITEMVALUE(rOldSet, XATTR_FILLBMP_TILE, XFillBmpTileItem));
if(bBrushItemOk) // has trans
{
@@ -1973,7 +2012,7 @@ void SwWW8ImplReader::MapWrapIntoFlyFormat(const SvxMSDffImportRec& rRecord,
if (rRecord.nDxWrapDistLeft || rRecord.nDxWrapDistRight)
{
SvxLRSpaceItem aLR(writer_cast<sal_uInt16>(rRecord.nDxWrapDistLeft),
- writer_cast<sal_uInt16>(rRecord.nDxWrapDistRight), 0, 0, RES_LR_SPACE);
+ writer_cast<sal_uInt16>(rRecord.nDxWrapDistRight), 0, RES_LR_SPACE);
AdjustLRWrapForWordMargins(rRecord, aLR);
rFlyFormat.SetFormatAttr(aLR);
}
@@ -2066,11 +2105,22 @@ void SwWW8ImplReader::MapWrapIntoFlyFormat(const SvxMSDffImportRec& rRecord,
}
else if (rFlyFormat.GetSurround().IsContour())
{
- // Contour is enabled, but no polygon is set: disable contour, because Word does not
- // Writer-style auto-contour in that case.
- SwFormatSurround aSurround(rFlyFormat.GetSurround());
- aSurround.SetContour(false);
- rFlyFormat.SetFormatAttr(aSurround);
+ const SdrObject* pSdrObj = rFlyFormat.FindSdrObject();
+ SdrObjKind eKind = pSdrObj ? pSdrObj->GetObjIdentifier() : SdrObjKind::Graphic;
+ switch (eKind)
+ {
+ case SdrObjKind::Text:
+ break;
+ case SdrObjKind::SwFlyDrawObjIdentifier:
+ default:
+ {
+ // Contour is enabled, but no polygon is set: disable contour, because Word does not
+ // Writer-style auto-contour in that case.
+ SwFormatSurround aSurround(rFlyFormat.GetSurround());
+ aSurround.SetContour(false);
+ rFlyFormat.SetFormatAttr(aSurround);
+ }
+ }
}
}
@@ -2324,8 +2374,12 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec& rRecord, WW8_FS
text::RelOrientation::TEXT_LINE // 3 is relative to line
};
- sal_Int16 eHoriOri = aHoriOriTab[ nXAlign ];
- sal_Int16 eHoriRel = aHoriRelOriTab[ nXRelTo ];
+ // If the image is inline, then the relative orientation means nothing,
+ // so set it up so that if the user changes it into an anchor, it positions usefully.
+ sal_Int16 eHoriOri
+ = IsInlineEscherHack() ? text::HoriOrientation::CENTER : aHoriOriTab[ nXAlign ];
+ sal_Int16 eHoriRel
+ = IsInlineEscherHack() ? text::RelOrientation::FRAME : aHoriRelOriTab[nXRelTo];
// #i36649# - adjustments for certain alignments
if (eHoriOri == text::HoriOrientation::LEFT && eHoriRel == text::RelOrientation::PAGE_FRAME)
@@ -2346,6 +2400,12 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec& rRecord, WW8_FS
rFSPA.nXaLeft = 0;
rFSPA.nXaRight = nWidth;
}
+ else if ((eHoriOri == text::HoriOrientation::LEFT || eHoriOri == text::HoriOrientation::RIGHT)
+ && eHoriRel == text::RelOrientation::FRAME)
+ {
+ // relative left/right honors paragraph margins, but not with center or none/absolute offset
+ eHoriRel = text::RelOrientation::PRINT_AREA;
+ }
// #i24255# - position of floating screen objects in
// R2L layout are given in L2R layout, thus convert them of all
@@ -2369,7 +2429,7 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec& rRecord, WW8_FS
if (m_nInTable &&
(eHoriRel == text::RelOrientation::FRAME || eHoriRel == text::RelOrientation::CHAR) &&
rFSPA.nwr == 3 &&
- !IsObjectLayoutInTableCell(rRecord.nLayoutInTableCell))
+ !IsObjectLayoutInTableCell(rRecord.nGroupShapeBooleanProperties))
{
eHoriRel = text::RelOrientation::PAGE_PRINT_AREA;
}
@@ -2419,7 +2479,7 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec& rRecord, WW8_FS
}
// #i84783#
-bool SwWW8ImplReader::IsObjectLayoutInTableCell( const sal_uInt32 nLayoutInTableCell ) const
+bool SwWW8ImplReader::IsObjectLayoutInTableCell(const sal_uInt32 nGroupShapeBooleanProperties) const
{
bool bIsObjectLayoutInTableCell = false;
@@ -2441,7 +2501,7 @@ bool SwWW8ImplReader::IsObjectLayoutInTableCell( const sal_uInt32 nLayoutInTable
case 0x0000: // version 8 aka Microsoft Word 97
{
bIsObjectLayoutInTableCell = false;
- OSL_ENSURE( nLayoutInTableCell == 0xFFFFFFFF,
+ OSL_ENSURE(nGroupShapeBooleanProperties == 0,
"no explicit object attribute layout in table cell expected." );
}
break;
@@ -2452,23 +2512,11 @@ bool SwWW8ImplReader::IsObjectLayoutInTableCell( const sal_uInt32 nLayoutInTable
case 0xC000: // version 14 aka Microsoft Word 2010
case 0xE000: // version 15 aka Microsoft Word 2013
{
- // #i98037#
- // adjustment of conditions needed after deeper analysis of
- // certain test cases.
- if ( nLayoutInTableCell == 0xFFFFFFFF || // no explicit attribute value given
- nLayoutInTableCell == 0x80008000 ||
- ( nLayoutInTableCell & 0x02000000 &&
- !(nLayoutInTableCell & 0x80000000 ) ) )
- {
- bIsObjectLayoutInTableCell = true;
- }
- else
- {
- // Documented in [MS-ODRAW], 2.3.4.44 "Group Shape Boolean Properties".
- bool fUsefLayoutInCell = (nLayoutInTableCell & 0x80000000) >> 31;
- bool fLayoutInCell = (nLayoutInTableCell & 0x8000) >> 15;
- bIsObjectLayoutInTableCell = fUsefLayoutInCell && fLayoutInCell;
- }
+ // Documented in [MS-ODRAW], 2.3.4.44 "Group Shape Boolean Properties".
+ bool fUsefLayoutInCell = (nGroupShapeBooleanProperties & 0x80000000) >> 31;
+ bool fLayoutInCell = (nGroupShapeBooleanProperties & 0x8000) >> 15;
+ // If unspecified, defaults to true
+ bIsObjectLayoutInTableCell = !fUsefLayoutInCell || fLayoutInCell;
}
break;
default:
@@ -2502,7 +2550,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
if( m_bVer67 )
{
- tools::Long nOldPos = m_pStrm->Tell();
+ sal_uInt64 nOldPos = m_pStrm->Tell();
m_nDrawXOfs = m_nDrawYOfs = 0;
ReadGrafLayer1(*pPF, nGrafAnchorCp);
@@ -2537,19 +2585,9 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
tools::Rectangle aRect(aFSFA.nXaLeft, aFSFA.nYaTop, aFSFA.nXaRight, aFSFA.nYaBottom);
SvxMSDffImportData aData( aRect );
- /*
- #i20540#
- The SdrOle2Obj will try and manage any ole objects it finds, causing all
- sorts of trouble later on
- */
- SwDocShell* pPersist = m_rDoc.GetDocShell();
- m_rDoc.SetDocShell(nullptr); // #i20540# Persist guard
-
- SdrObject* pObject = nullptr;
+ rtl::Reference<SdrObject> pObject;
bool bOk = (m_xMSDffManager->GetShape(aFSFA.nSpId, pObject, aData) && pObject);
- m_rDoc.SetDocShell(pPersist); // #i20540# Persist guard
-
if (!bOk)
{
OSL_ENSURE( false, "Where is the Shape ?" );
@@ -2568,16 +2606,16 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
}
bool bDone = false;
- SdrObject* pOurNewObject = nullptr;
+ rtl::Reference<SdrObject> pOurNewObject;
bool bReplaceable = false;
switch (pObject->GetObjIdentifier())
{
- case OBJ_GRAF:
+ case SdrObjKind::Graphic:
bReplaceable = true;
bDone = true;
break;
- case OBJ_OLE2:
+ case SdrObjKind::OLE2:
bReplaceable = true;
break;
default:
@@ -2588,7 +2626,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
// when in a header or footer word appears to treat all elements as wrap through
// determine wrapping mode
- SfxItemSet aFlySet(m_rDoc.GetAttrPool(), svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1, XATTR_START, XATTR_END>{});
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1, XATTR_START, XATTR_END> aFlySet(m_rDoc.GetAttrPool());
Reader::ResetFrameFormatAttrs(aFlySet); // tdf#122425: Explicitly remove borders and spacing
css::text::WrapTextMode eSurround = css::text::WrapTextMode_PARALLEL;
bool bContour = false;
@@ -2602,7 +2640,11 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
eSurround = css::text::WrapTextMode_NONE;
break;
case 3: // 3 wrap as if no object present
- eSurround = css::text::WrapTextMode_THROUGH;
+ // Special case: on export, inline images are wrapped through as a hack for old formats.
+ // That is irrelevant for Writer, so instead use the default wrap in that case,
+ // so that when the user changes it into an anchor, it wraps nicely, and not through.
+ if (!IsInlineEscherHack())
+ eSurround = css::text::WrapTextMode_THROUGH;
break;
case 4: // 4 wrap tightly around object
case 5: // 5 wrap tightly, but allow holes
@@ -2652,18 +2694,16 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
Get the record for top level object, so we can get the word anchoring
and wrapping information for it.
*/
- SvxMSDffImportRec* pRecord = aData.find(pObject);
+ SvxMSDffImportRec* pRecord = aData.find(pObject.get());
OSL_ENSURE(pRecord, "how did that happen?");
if (!pRecord)
{
// remove old object from the Z-Order list
- m_xMSDffManager->RemoveFromShapeOrder(pObject);
- // and delete the object
- SdrObject::Free(pObject);
+ m_xMSDffManager->RemoveFromShapeOrder(pObject.get());
return nullptr;
}
const bool bLayoutInTableCell =
- m_nInTable && IsObjectLayoutInTableCell( pRecord->nLayoutInTableCell );
+ m_nInTable && IsObjectLayoutInTableCell(pRecord->nGroupShapeBooleanProperties);
// #i18732# - Switch on 'follow text flow', if object is laid out
// inside table cell
@@ -2678,9 +2718,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
if (pRecord->bHidden)
{
// remove old object from the Z-Order list
- m_xMSDffManager->RemoveFromShapeOrder(pObject);
- // and delete the object
- SdrObject::Free(pObject);
+ m_xMSDffManager->RemoveFromShapeOrder(pObject.get());
return nullptr;
}
@@ -2704,14 +2742,14 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
}
}
}
- SwFormatURL* pFormatURL = new SwFormatURL();
+ std::unique_ptr<SwFormatURL> pFormatURL(new SwFormatURL());
pFormatURL->SetURL( lnName, false );
if (!aObjName.isEmpty())
pFormatURL->SetName(aObjName);
if (!aTarFrame.isEmpty())
pFormatURL->SetTargetFrameName(aTarFrame);
pFormatURL->SetMap(nullptr);
- aFlySet.Put(*pFormatURL);
+ aFlySet.Put(std::move(pFormatURL));
}
// If we are to be "below text" then we are not to be opaque
@@ -2720,9 +2758,9 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
// both flags <bBelowText> and <bDrawHell> have to be set to move object into the background.
// #i46794# - it reveals that value of flag <bBelowText> can be neglected.
- const bool bMoveToBackgrd = pRecord->bDrawHell ||
+ const bool bMoveToBackground = pRecord->bDrawHell ||
((m_bIsHeader || m_bIsFooter) && aFSFA.nwr == 3);
- if ( bMoveToBackgrd )
+ if ( bMoveToBackground )
aFlySet.Put(SvxOpaqueItem(RES_OPAQUE,false));
OUString aObjName = pObject->GetName();
@@ -2765,7 +2803,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
if (!bDone)
{
sw::util::SetLayer aSetLayer(m_rDoc);
- if ( bMoveToBackgrd )
+ if ( bMoveToBackground )
aSetLayer.SendObjectToHell(*pObject);
else
aSetLayer.SendObjectToHeaven(*pObject);
@@ -2774,12 +2812,12 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
{
/* Need to make sure that the correct layer ordering is applied. */
// pass information, if object is in page header|footer to method.
- m_xWWZOrder->InsertEscherObject(pObject, aFSFA.nSpId, pRecord->bDrawHell,
+ m_xWWZOrder->InsertEscherObject(pObject.get(), aFSFA.nSpId, pRecord->bDrawHell,
m_bIsHeader || m_bIsFooter);
}
else
{
- m_xWWZOrder->InsertTextLayerObject(pObject);
+ m_xWWZOrder->InsertTextLayerObject(pObject.get());
}
pRetFrameFormat = m_rDoc.getIDocumentContentOperations().InsertDrawObj(*m_pPaM, *pObject, aFlySet );
@@ -2813,13 +2851,13 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
if (pRetFrameFormat /*#i52825# */)
{
if (!aObjName.isEmpty())
- pRetFrameFormat->SetName( aObjName );
+ pRetFrameFormat->SetFormatName( aObjName );
if (pRetFrameFormat->GetName().isEmpty())
{
if (bDrawObj)
- pRetFrameFormat->SetName(m_rDoc.GetUniqueDrawObjectName());
+ pRetFrameFormat->SetFormatName(m_rDoc.GetUniqueDrawObjectName());
else if (bFrame)
- pRetFrameFormat->SetName(m_rDoc.GetUniqueFrameName());
+ pRetFrameFormat->SetFormatName(m_rDoc.GetUniqueFrameName());
}
}
return AddAutoAnchor(pRetFrameFormat);
@@ -2843,18 +2881,18 @@ SwFrameFormat *SwWW8ImplReader::AddAutoAnchor(SwFrameFormat *pFormat)
SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
tools::Long nGrafAnchorCp, SwFrameFormat* pRetFrameFormat)
{
- SdrObject* pTrueObject = rRecord.pObj;
+ rtl::Reference<SdrObject> pTrueObject = rRecord.pObj;
- SdrTextObj* pSdrTextObj;
+ rtl::Reference<SdrTextObj> pSdrTextObj;
// check for group object (e.g. two parentheses)
- if (SdrObjGroup* pThisGroup = dynamic_cast<SdrObjGroup*>(rRecord.pObj))
+ if (SdrObjGroup* pThisGroup = dynamic_cast<SdrObjGroup*>(rRecord.pObj.get()))
{
// Group objects don't have text. Insert a text object into
// the group for holding the text.
pSdrTextObj = new SdrRectObj(
*m_pDrawModel,
- OBJ_TEXT,
+ SdrObjKind::Text,
pThisGroup->GetCurrentBoundRect());
SfxItemSet aSet(m_pDrawModel->GetItemPool());
@@ -2865,10 +2903,10 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
aSet.Put(makeSdrTextAutoGrowWidthItem(false));
pSdrTextObj->SetMergedItemSet(aSet);
pSdrTextObj->NbcSetLayer( pThisGroup->GetLayer() );
- pThisGroup->GetSubList()->NbcInsertObject(pSdrTextObj);
+ pThisGroup->GetSubList()->NbcInsertObject(pSdrTextObj.get());
}
else
- pSdrTextObj = dynamic_cast<SdrTextObj*>(rRecord.pObj);
+ pSdrTextObj = DynCastSdrTextObj(rRecord.pObj.get());
if( pSdrTextObj )
{
@@ -2880,27 +2918,25 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
const size_t nOrdNum = pSdrTextObj->GetOrdNum();
bool bEraseThisObject;
- InsertTxbxText(pSdrTextObj, &aObjSize, rRecord.aTextId.nTxBxS, rRecord.aTextId.nSequence,
+ InsertTxbxText(pSdrTextObj.get(), &aObjSize, rRecord.aTextId.nTxBxS, rRecord.aTextId.nSequence,
nGrafAnchorCp, pRetFrameFormat,
- (pSdrTextObj != pTrueObject) || (nullptr != pGroupObject), bEraseThisObject,
+ (pSdrTextObj.get() != pTrueObject.get()) || (nullptr != pGroupObject), bEraseThisObject,
nullptr, nullptr, nullptr, nullptr, &rRecord);
// was this object replaced ??
if (bEraseThisObject)
{
- if( pGroupObject || (pSdrTextObj != pTrueObject) )
+ if( pGroupObject || (pSdrTextObj.get() != pTrueObject.get()) )
{
// Object is already replaced by a new SdrGrafObj (in the group
// and) the Drawing-Page.
SdrObject* pNewObj = pGroupObject ?
- pGroupObject->GetSubList()->GetObj(nOrdNum) : pTrueObject;
- if (pSdrTextObj != pNewObj)
+ pGroupObject->GetSubList()->GetObj(nOrdNum) : pTrueObject.get();
+ if (pSdrTextObj.get() != pNewObj)
{
// Replace object in the Z-Order-List
- m_xMSDffManager->ExchangeInShapeOrder(pSdrTextObj, 0, pNewObj);
- // now delete object
- SdrObject::Free(rRecord.pObj);
+ m_xMSDffManager->ExchangeInShapeOrder(pSdrTextObj.get(), 0, pNewObj);
// and save the new object.
rRecord.pObj = pNewObj;
}
@@ -2908,7 +2944,7 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
else
{
// remove the object from Z-Order list
- m_xMSDffManager->RemoveFromShapeOrder( pSdrTextObj );
+ m_xMSDffManager->RemoveFromShapeOrder( pSdrTextObj.get() );
// take the object from the drawing page
if( pSdrTextObj->getSdrPageFromSdrObject() )
m_pDrawPg->RemoveObject( pSdrTextObj->GetOrdNum() );
@@ -2923,8 +2959,8 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
else
{
// use ww8-default border distance
- SfxItemSet aItemSet(m_pDrawModel->GetItemPool(),
- svl::Items<SDRATTR_TEXT_LEFTDIST, SDRATTR_TEXT_LOWERDIST>{});
+ SfxItemSetFixed<SDRATTR_TEXT_LEFTDIST, SDRATTR_TEXT_LOWERDIST>
+ aItemSet(m_pDrawModel->GetItemPool());
aItemSet.Put(makeSdrTextLeftDistItem(rRecord.nDxTextLeft));
aItemSet.Put(makeSdrTextRightDistItem(rRecord.nDxTextRight));
aItemSet.Put(makeSdrTextUpperDistItem(rRecord.nDyTextTop));
@@ -2935,8 +2971,8 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
return pRetFrameFormat;
}
-SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject*& rpObject,
- SdrObject*& rpOurNewObject,
+SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(rtl::Reference<SdrObject>& rpObject,
+ rtl::Reference<SdrObject>& rpOurNewObject,
const SvxMSDffImportRec& rRecord,
RndStdIds eAnchor, const WW8_FSPA& rF,
SfxItemSet &rFlySet)
@@ -2963,10 +2999,10 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject*& rpObject,
: SwFrameSize::Fixed);
rFlySet.Put(aFrameSize);
- MatchSdrItemsIntoFlySet(rpObject, rFlySet, rRecord.eLineStyle, rRecord.eLineDashing,
+ MatchSdrItemsIntoFlySet(rpObject.get(), rFlySet, rRecord.eLineStyle, rRecord.eLineDashing,
rRecord.eShapeType, aInnerDist);
- SdrTextObj *pSdrTextObj = dynamic_cast<SdrTextObj*>(rpObject);
+ SdrTextObj *pSdrTextObj = DynCastSdrTextObj(rpObject.get());
if (pSdrTextObj && pSdrTextObj->IsVerticalWriting())
rFlySet.Put(SvxFrameDirectionItem(SvxFrameDirection::Vertical_RL_TB, RES_FRAMEDIR));
@@ -2979,10 +3015,10 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject*& rpObject,
rpOurNewObject = CreateContactObject(pRetFrameFormat);
// remove old object from the Z-Order list
- m_xMSDffManager->RemoveFromShapeOrder( rpObject );
+ m_xMSDffManager->RemoveFromShapeOrder( rpObject.get() );
// and delete the object
- SdrObject::Free( rpObject );
+ rpObject.clear();
/*
NB: only query pOrgShapeObject starting here!
*/
@@ -3009,7 +3045,7 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject*& rpObject,
if (!rpOurNewObject->IsInserted())
{
// pass information, if object is in page header|footer to method.
- m_xWWZOrder->InsertEscherObject(rpOurNewObject, rF.nSpId, rRecord.bDrawHell,
+ m_xWWZOrder->InsertEscherObject(rpOurNewObject.get(), rF.nSpId, rRecord.bDrawHell,
m_bIsHeader || m_bIsFooter);
}
}
@@ -3058,8 +3094,8 @@ void MatchEscherMirrorIntoFlySet(const SvxMSDffImportRec &rRecord, SfxItemSet &r
}
}
-SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(SdrObject* &rpObject,
- SdrObject* &rpOurNewObject,
+SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(rtl::Reference<SdrObject> &rpObject,
+ rtl::Reference<SdrObject> &rpOurNewObject,
SvxMSDffImportRec& rRecord,
WW8_FSPA& rF,
SfxItemSet &rFlySet )
@@ -3076,23 +3112,23 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(SdrObject* &rpObje
rFlySet.Put(SwFormatFrameSize(SwFrameSize::Fixed, nWidthTw, nHeightTw));
- SfxItemSet aGrSet(m_rDoc.GetAttrPool(), svl::Items<RES_GRFATR_BEGIN, RES_GRFATR_END-1>{});
+ SfxItemSetFixed<RES_GRFATR_BEGIN, RES_GRFATR_END-1> aGrSet(m_rDoc.GetAttrPool());
// Note that the escher inner distance only seems to be honoured in
// word for textboxes, not for graphics and ole objects.
tools::Rectangle aInnerDist(0, 0, 0, 0);
- MatchSdrItemsIntoFlySet(rpObject, rFlySet, rRecord.eLineStyle, rRecord.eLineDashing,
+ MatchSdrItemsIntoFlySet(rpObject.get(), rFlySet, rRecord.eLineStyle, rRecord.eLineDashing,
rRecord.eShapeType, aInnerDist);
MatchEscherMirrorIntoFlySet(rRecord, aGrSet);
OUString aObjectName(rpObject->GetName());
- if (OBJ_OLE2 == rpObject->GetObjIdentifier())
- pRetFrameFormat = InsertOle(*static_cast<SdrOle2Obj*>(rpObject), rFlySet, &aGrSet);
+ if (SdrObjKind::OLE2 == rpObject->GetObjIdentifier())
+ pRetFrameFormat = InsertOle(*static_cast<SdrOle2Obj*>(rpObject.get()), rFlySet, &aGrSet);
else
{
- const SdrGrafObj *pGrf = static_cast<const SdrGrafObj*>(rpObject);
+ const SdrGrafObj *pGrf = static_cast<const SdrGrafObj*>(rpObject.get());
bool bDone = false;
if (pGrf->IsLinkedGraphic() && !pGrf->GetFileName().isEmpty())
{
@@ -3123,7 +3159,7 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(SdrObject* &rpObje
if (pRetFrameFormat)
{
- if (OBJ_OLE2 != rpObject->GetObjIdentifier())
+ if (SdrObjKind::OLE2 != rpObject->GetObjIdentifier())
SetAttributesAtGrfNode(rRecord, *pRetFrameFormat, &rF);
// avoid multiple occurrences of the same graphic name
m_aGrfNameGenerator.SetUniqueGraphName(pRetFrameFormat, aObjectName);
@@ -3133,13 +3169,14 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(SdrObject* &rpObje
rpOurNewObject = CreateContactObject(pRetFrameFormat);
// remove old object from Z-Order-List
- m_xMSDffManager->RemoveFromShapeOrder( rpObject );
+ m_xMSDffManager->RemoveFromShapeOrder( rpObject.get() );
// remove from Drawing-Page
if( rpObject->getSdrPageFromSdrObject() )
m_pDrawPg->RemoveObject( rpObject->GetOrdNum() );
// and delete the object
- SdrObject::Free( rpObject );
+ rpObject.clear();
+
/*
Warning: from now on query only pOrgShapeObject!
*/
@@ -3148,14 +3185,14 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(SdrObject* &rpObje
if (rpOurNewObject)
{
if (!m_bHdFtFootnoteEdn)
- m_xMSDffManager->StoreShapeOrder(rF.nSpId, 0, rpOurNewObject);
+ m_xMSDffManager->StoreShapeOrder(rF.nSpId, 0, rpOurNewObject.get());
// The Contact-Object MUST be set in the Draw-Page, so that in
// SwWW8ImplReader::LoadDoc1() the Z-Order can be defined !!!
if (!rpOurNewObject->IsInserted())
{
// pass information, if object is in page header|footer to method.
- m_xWWZOrder->InsertEscherObject(rpOurNewObject, rF.nSpId, rRecord.bDrawHell,
+ m_xWWZOrder->InsertEscherObject(rpOurNewObject.get(), rF.nSpId, rRecord.bDrawHell,
m_bIsHeader || m_bIsFooter);
}
}
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index cf1572f35ede..35219922db83 100644
--- a/sw/source/filter/ww8/ww8graf2.cxx
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -25,7 +25,6 @@
#include <svx/svdograf.hxx>
#include <svx/svdoole2.hxx>
#include <filter/msfilter/msdffimp.hxx>
-#include <unotools/configmgr.hxx>
#include <grfatr.hxx>
#include <fmtanchr.hxx>
#include <fmtcntnt.hxx>
@@ -233,10 +232,10 @@ static void WW8PicShadowToReal( WW8_PIC_SHADOW const * pPicS, WW8_PIC* pPic
bool SwWW8ImplReader::GetPictGrafFromStream(Graphic& rGraphic, SvStream& rSrc)
{
- return ERRCODE_NONE == GraphicFilter::GetGraphicFilter().ImportGraphic(rGraphic, OUString(), rSrc);
+ return ERRCODE_NONE == GraphicFilter::GetGraphicFilter().ImportGraphic(rGraphic, u"", rSrc);
}
-bool SwWW8ImplReader::ReadGrafFile(OUString& rFileName, std::unique_ptr<Graphic>& rpGraphic,
+bool SwWW8ImplReader::ReadGrafFile(OUString& rFileName, std::optional<Graphic>& roGraphic,
const WW8_PIC& rPic, SvStream* pSt, sal_uLong nFilePos, bool* pbInDoc)
{ // Write the graphic to the file
*pbInDoc = true; // default
@@ -258,22 +257,22 @@ bool SwWW8ImplReader::ReadGrafFile(OUString& rFileName, std::unique_ptr<Graphic>
return !rFileName.isEmpty(); // read was successful
}
- GDIMetaFile aWMF;
- bool bOk = checkSeek(*pSt, nPosFc) && ReadWindowMetafile( *pSt, aWMF );
-
- if (!bOk || pSt->GetError() || !aWMF.GetActionSize())
- return false;
-
//skip duplicate graphics when fuzzing
- if (utl::ConfigManager::IsFuzzing())
+ if (m_bFuzzing)
{
if (!m_aGrafPosSet.insert(nPosFc).second)
return false;
}
+ GDIMetaFile aWMF;
+ bool bOk = checkSeek(*pSt, nPosFc) && ReadWindowMetafile( *pSt, aWMF );
+
+ if (!bOk || pSt->GetError() || !aWMF.GetActionSize())
+ return false;
+
if (m_xWwFib->m_envr != 1) // !MAC as creator
{
- rpGraphic.reset(new Graphic(aWMF));
+ roGraphic.emplace(aWMF);
return true;
}
@@ -285,10 +284,10 @@ bool SwWW8ImplReader::ReadGrafFile(OUString& rFileName, std::unique_ptr<Graphic>
tools::Long nData = rPic.lcb - ( pSt->Tell() - nPosFc );
if (nData > 0)
{
- rpGraphic.reset(new Graphic());
- bOk = SwWW8ImplReader::GetPictGrafFromStream(*rpGraphic, *pSt);
+ roGraphic.emplace();
+ bOk = SwWW8ImplReader::GetPictGrafFromStream(*roGraphic, *pSt);
if (!bOk)
- rpGraphic.reset();
+ roGraphic.reset();
}
return bOk; // Contains graphic
}
@@ -356,7 +355,7 @@ SwFlyFrameFormat* SwWW8ImplReader::MakeGrafNotInContent(const WW8PicDesc& rPD,
sal_Int32 nNetHeight = nHeight + rPD.nCT + rPD.nCB;
if (m_xSFlyPara->nLineSpace && m_xSFlyPara->nLineSpace > nNetHeight)
m_xSFlyPara->nYPos =
- static_cast<sal_uInt16>( m_xSFlyPara->nYPos + m_xSFlyPara->nLineSpace - nNetHeight );
+ o3tl::narrowing<sal_uInt16>( m_xSFlyPara->nYPos + m_xSFlyPara->nLineSpace - nNetHeight );
WW8FlySet aFlySet(*this, m_xWFlyPara.get(), m_xSFlyPara.get(), true);
@@ -416,8 +415,8 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf1(WW8_PIC const & rPic, SvStream* pSt,
OUString aFileName;
bool bInDoc;
- std::unique_ptr<Graphic> pGraph;
- bool bOk = ReadGrafFile(aFileName, pGraph, rPic, pSt, nFilePos, &bInDoc);
+ std::optional<Graphic> oGraph;
+ bool bOk = ReadGrafFile(aFileName, oGraph, rPic, pSt, nFilePos, &bInDoc);
if (!bOk)
{
@@ -434,25 +433,27 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf1(WW8_PIC const & rPic, SvStream* pSt,
}
if (m_xWFlyPara && m_xWFlyPara->bGrafApo)
- pRet = MakeGrafNotInContent(aPD, pGraph.get(), aFileName, aGrfSet);
+ pRet = MakeGrafNotInContent(aPD, oGraph ? &*oGraph : nullptr, aFileName, aGrfSet);
else
- pRet = MakeGrafInContent(rPic, aPD, pGraph.get(), aFileName, aGrfSet);
+ pRet = MakeGrafInContent(rPic, aPD, oGraph ? &*oGraph : nullptr, aFileName, aGrfSet);
return pRet;
}
-void SwWW8ImplReader::PicRead(SvStream *pDataStream, WW8_PIC *pPic,
+bool SwWW8ImplReader::PicRead(SvStream *pDataStream, WW8_PIC *pPic,
bool bVer67)
{
//Only the first 0x2e bytes are the same between version 6/7 and 8+
- WW8_PIC_SHADOW aPicS;
+ WW8_PIC_SHADOW aPicS{};
pDataStream->ReadBytes( &aPicS, sizeof( aPicS ) );
WW8PicShadowToReal( &aPicS, pPic );
for (WW8_BRC & i : pPic->rgbrc)
pDataStream->ReadBytes(&i, bVer67 ? 2 : 4);
pDataStream->ReadInt16( pPic->dxaOrigin );
pDataStream->ReadInt16( pPic->dyaOrigin );
+ bool bOk = pDataStream->good();
if (!bVer67)
pDataStream->SeekRel(2); //cProps
+ return bOk;
}
namespace
@@ -463,7 +464,7 @@ namespace
if (!pNodeIndex)
return SwNodeType::NONE;
const SwNode& rCSttNd = pNodeIndex->GetNode();
- SwNodeRange aRg(rCSttNd, 1, *rCSttNd.EndOfSectionNode());
+ SwNodeRange aRg(rCSttNd, SwNodeOffset(1), *rCSttNd.EndOfSectionNode());
return aRg.aStart.GetNode().GetNodeType();
}
}
@@ -491,14 +492,12 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
*/
auto nOldPos = m_pDataStream->Tell();
WW8_PIC aPic;
- bool bValid = checkSeek(*m_pDataStream, m_nPicLocFc);
-
- if (bValid)
- PicRead( m_pDataStream, &aPic, m_bVer67);
+ bool bValid = checkSeek(*m_pDataStream, m_nPicLocFc) &&
+ PicRead(m_pDataStream, &aPic, m_bVer67);
// Sanity check is needed because for example check boxes in field results
// contain a WMF-like struct
- if (bValid && m_pDataStream->good() && (aPic.lcb >= 58))
+ if (bValid && aPic.lcb >= 58)
{
if( m_pFlyFormatOfJustInsertedGraphic )
{
@@ -525,7 +524,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
else if((0x64 == aPic.MFP.mm) || (0x66 == aPic.MFP.mm))
{
// linked graphic in ESCHER-Object
- SdrObject* pObject = nullptr;
+ rtl::Reference<SdrObject> pObject;
WW8PicDesc aPD( aPic );
if (!m_xMSDffManager)
@@ -555,8 +554,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
if (pObject)
{
// for the frame
- SfxItemSet aAttrSet( m_rDoc.GetAttrPool(), svl::Items<RES_FRMATR_BEGIN,
- RES_FRMATR_END-1>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aAttrSet( m_rDoc.GetAttrPool() );
SvxMSDffImportRec const*const pRecord = (1 == aData.size())
? aData.begin()->get() : nullptr;
@@ -610,7 +608,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
// Modified for i120716,for graf importing from MS Word 2003
// binary format, there is no border distance.
tools::Rectangle aInnerDist(0,0,0,0);
- MatchSdrItemsIntoFlySet( pObject, aAttrSet,
+ MatchSdrItemsIntoFlySet( pObject.get(), aAttrSet,
pRecord->eLineStyle, pRecord->eLineDashing,
pRecord->eShapeType, aInnerDist );
@@ -621,8 +619,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
}
// for the graphic
- SfxItemSet aGrSet( m_rDoc.GetAttrPool(), svl::Items<RES_GRFATR_BEGIN,
- RES_GRFATR_END-1>{} );
+ SfxItemSetFixed<RES_GRFATR_BEGIN, RES_GRFATR_END-1> aGrSet( m_rDoc.GetAttrPool() );
if( aPD.nCL || aPD.nCR || aPD.nCT || aPD.nCB )
{
@@ -654,14 +651,14 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
ReplaceObj(*pTextObj, *pObject);
else
{
- if (sal_uInt16(OBJ_OLE2) == pObject->GetObjIdentifier())
+ if (SdrObjKind::OLE2 == pObject->GetObjIdentifier())
{
// the size from BLIP, if there is any, should be already set
- pRet = InsertOle(*static_cast<SdrOle2Obj*>(pObject), aAttrSet, &aGrSet);
+ pRet = InsertOle(*static_cast<SdrOle2Obj*>(pObject.get()), aAttrSet, &aGrSet);
}
else
{
- if (SdrGrafObj* pGraphObject = dynamic_cast<SdrGrafObj*>( pObject) )
+ if (SdrGrafObj* pGraphObject = dynamic_cast<SdrGrafObj*>( pObject.get()) )
{
// Now add the link or rather the graphic to the doc
const Graphic& rGraph = pGraphObject->GetGraphic();
@@ -689,7 +686,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
OUString aObjectName(pObject->GetName());
if (aObjectName.isEmpty() || !m_rDoc.FindFlyByName(aObjectName, GetNodeType(*pRet)))
- pRet->SetName(aObjectName);
+ pRet->SetFormatName(aObjectName);
else
m_aGrfNameGenerator.SetUniqueGraphName(pRet, aObjectName);
@@ -697,22 +694,22 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
// Z-order-list accordingly (or delete entry)
if (SdrObject* pOurNewObject = CreateContactObject(pRet))
{
- if (pOurNewObject != pObject)
+ if (pOurNewObject != pObject.get())
{
- m_xMSDffManager->ExchangeInShapeOrder( pObject, 0,
+ m_xMSDffManager->ExchangeInShapeOrder( pObject.get(), 0,
pOurNewObject );
// delete and destroy old SdrGrafObj from page
if (pObject->getSdrPageFromSdrObject())
m_pDrawPg->RemoveObject(pObject->GetOrdNum());
- SdrObject::Free( pObject );
+ pObject.clear();
}
}
else
- m_xMSDffManager->RemoveFromShapeOrder( pObject );
+ m_xMSDffManager->RemoveFromShapeOrder( pObject.get() );
}
else
- m_xMSDffManager->RemoveFromShapeOrder( pObject );
+ m_xMSDffManager->RemoveFromShapeOrder( pObject.get() );
// also delete this from the page if not grouped
if (pTextObj && !bTextObjWasGrouped && pTextObj->getSdrPageFromSdrObject())
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 83995b2d5ffc..958396d2d54d 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -27,10 +27,12 @@
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/packages/XPackageEncryption.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/text/XTextFieldsSupplier.hpp>
#include <i18nlangtag/languagetag.hxx>
-#include <unotools/configmgr.hxx>
+#include <comphelper/configuration.hxx>
+#include <comphelper/string.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <unotools/streamwrap.hxx>
#include <rtl/random.h>
@@ -57,7 +59,6 @@
#include <editeng/charhiddenitem.hxx>
#include <editeng/fontitem.hxx>
#include <editeng/editeng.hxx>
-#include <svx/unoapi.hxx>
#include <svx/svdoole2.hxx>
#include <svx/svdoashp.hxx>
#include <svx/svxerr.hxx>
@@ -69,7 +70,6 @@
#include <svx/sdtcfitm.hxx>
#include <svx/sdtditm.hxx>
#include <svx/sdtmfitm.hxx>
-#include <unotools/fltrcfg.hxx>
#include <fmtfld.hxx>
#include <fmturl.hxx>
#include <fmtinfmt.hxx>
@@ -97,12 +97,14 @@
#include <../../core/inc/DocumentRedlineManager.hxx>
#include <docufld.hxx>
#include <swfltopt.hxx>
+#include <utility>
#include <viewsh.hxx>
#include <shellres.hxx>
#include <swerror.h>
#include <swtable.hxx>
#include <fchrfmt.hxx>
#include <charfmt.hxx>
+#include <fmtautofmt.hxx>
#include <IDocumentSettingAccess.hxx>
#include "sprmids.hxx"
@@ -118,11 +120,12 @@
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/document/XViewDataSupplier.hpp>
-#include <com/sun/star/document/IndexedPropertyValues.hpp>
#include <svl/lngmisc.hxx>
#include <svl/itemiter.hxx>
+#include <svl/whiter.hxx>
+#include <comphelper/indexedpropertyvalues.hxx>
#include <comphelper/processfactory.hxx>
#include <basic/basmgr.hxx>
@@ -133,11 +136,6 @@
#include <breakit.hxx>
-#if OSL_DEBUG_LEVEL > 1
-#include <iostream>
-#include <dbgoutsw.hxx>
-#endif
-
#include <sfx2/docfile.hxx>
#include <swdll.hxx>
#include "WW8Sttbf.hxx"
@@ -145,11 +143,6 @@
#include <unordered_set>
#include <memory>
-using namespace ::com::sun::star;
-using namespace sw::util;
-using namespace sw::types;
-using namespace nsHdFtFlags;
-
#include <com/sun/star/i18n/XBreakIterator.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <unotools/pathoptions.hxx>
@@ -161,7 +154,13 @@ using namespace nsHdFtFlags;
#include <oox/ole/olestorage.hxx>
#include <comphelper/storagehelper.hxx>
#include <sfx2/DocumentMetadataAccess.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+#include <officecfg/Office/Common.hxx>
+
+using namespace ::com::sun::star;
+using namespace sw::util;
+using namespace sw::types;
+using namespace nsHdFtFlags;
static SwMacroInfo* GetMacroInfo( SdrObject* pObj )
{
@@ -269,8 +268,8 @@ void SwWW8ImplReader::ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocS
{
xLongName.reset(new OUString(read_uInt16s_ToOUString(rStrm, nStrLen - 1)));
rStrm.SeekRel(sizeof(sal_Unicode)); // skip null-byte at end
+ lclGetAbsPath( *xLongName, 0 , pDocShell);
}
- lclGetAbsPath( *xLongName, 0 , pDocShell);
}
// file link or URL
else if( ::get_flag( nFlags, WW8_HLINK_BODY ) )
@@ -285,7 +284,9 @@ void SwWW8ImplReader::ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocS
// ANSI characters in ansiPath, including the terminating NULL character
sal_uInt32 nUnits = 0;
rStrm.ReadUInt32(nUnits);
- if (nUnits)
+ if (!nUnits)
+ xShortName.reset(new OUString);
+ else
{
OString sStr(read_uInt8s_ToOString(rStrm, nUnits - 1));
rStrm.SeekRel(sizeof(sal_uInt8)); // skip null-byte at end
@@ -317,7 +318,9 @@ void SwWW8ImplReader::ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocS
sal_uInt32 nStrLen(0);
rStrm.ReadUInt32( nStrLen );
nStrLen /= 2;
- if (nStrLen)
+ if (!nStrLen)
+ xLongName.reset(new OUString);
+ else
{
xLongName.reset(new OUString(read_uInt16s_ToOUString(rStrm, nStrLen - 1)));
rStrm.SeekRel(sizeof(sal_Unicode)); // skip null-byte at end
@@ -338,10 +341,7 @@ void SwWW8ImplReader::ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocS
}
if (!xLongName && xShortName)
- {
- xLongName.reset( new OUString );
- *xLongName += *xShortName;
- }
+ xLongName.reset(new OUString(*xShortName));
else if (!xLongName && xTextMark)
xLongName.reset( new OUString );
@@ -423,11 +423,11 @@ struct SBBItem
OUString data;
SBBItem() : cchData(0){}
};
- sal_uInt16 fExtend;
- sal_uInt16 cData;
- sal_uInt16 cbExtra;
+ sal_uInt16 m_fExtend;
+ sal_uInt16 m_cData;
+ sal_uInt16 m_cbExtra;
- std::vector< SBBItem > dataItems;
+ std::vector< SBBItem > m_dataItems;
Sttb(Sttb const&) = delete;
Sttb& operator=(Sttb const&) = delete;
@@ -442,9 +442,9 @@ public:
}
Sttb::Sttb()
- : fExtend(0)
- , cData(0)
- , cbExtra(0)
+ : m_fExtend(0)
+ , m_cData(0)
+ , m_cbExtra(0)
{
}
@@ -452,19 +452,19 @@ bool Sttb::Read( SvStream& rS )
{
SAL_INFO("sw.ww8", "stream pos " << rS.Tell());
nOffSet = rS.Tell();
- rS.ReadUInt16( fExtend ).ReadUInt16( cData ).ReadUInt16( cbExtra );
- if ( cData )
+ rS.ReadUInt16( m_fExtend ).ReadUInt16( m_cData ).ReadUInt16( m_cbExtra );
+ if ( m_cData )
{
//if they are all going to be empty strings, how many could there be
const size_t nMaxPossibleRecords = rS.remainingSize() / sizeof(sal_uInt16);
- if (cData > nMaxPossibleRecords)
+ if (m_cData > nMaxPossibleRecords)
return false;
- for ( sal_Int32 index = 0; index < cData; ++index )
+ for ( sal_Int32 index = 0; index < m_cData; ++index )
{
SBBItem aItem;
rS.ReadUInt16( aItem.cchData );
aItem.data = read_uInt16s_ToOUString(rS, aItem.cchData);
- dataItems.push_back( aItem );
+ m_dataItems.push_back( aItem );
}
}
return true;
@@ -474,8 +474,8 @@ OUString
Sttb::getStringAtIndex( sal_uInt32 index )
{
OUString aRet;
- if ( index < dataItems.size() )
- aRet = dataItems[ index ].data;
+ if ( index < m_dataItems.size() )
+ aRet = m_dataItems[ index ].data;
return aRet;
}
@@ -483,7 +483,7 @@ Sttb::getStringAtIndex( sal_uInt32 index )
SwMSDffManager::SwMSDffManager( SwWW8ImplReader& rRdr, bool bSkipImages )
: SvxMSDffManager(*rRdr.m_pTableStream, rRdr.GetBaseURL(), rRdr.m_xWwFib->m_fcDggInfo,
rRdr.m_pDataStream, nullptr, 0, COL_WHITE, rRdr.m_pStrm, bSkipImages),
- rReader(rRdr), pFallbackStream(nullptr)
+ m_rReader(rRdr), m_pFallbackStream(nullptr)
{
SetSvxMSDffSettings( GetSvxMSDffSettings() );
nSvxMSDffOLEConvFlags = SwMSDffManager::GetFilterFlags();
@@ -492,14 +492,13 @@ SwMSDffManager::SwMSDffManager( SwWW8ImplReader& rRdr, bool bSkipImages )
sal_uInt32 SwMSDffManager::GetFilterFlags()
{
sal_uInt32 nFlags(0);
- const SvtFilterOptions& rOpt = SvtFilterOptions::Get();
- if (rOpt.IsMathType2Math())
+ if (officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::get())
nFlags |= OLE_MATHTYPE_2_STARMATH;
- if (rOpt.IsExcel2Calc())
+ if (officecfg::Office::Common::Filter::Microsoft::Import::ExcelToCalc::get())
nFlags |= OLE_EXCEL_2_STARCALC;
- if (rOpt.IsPowerPoint2Impress())
+ if (officecfg::Office::Common::Filter::Microsoft::Import::PowerPointToImpress::get())
nFlags |= OLE_POWERPOINT_2_STARIMPRESS;
- if (rOpt.IsWinWord2Writer())
+ if (officecfg::Office::Common::Filter::Microsoft::Import::WinWordToWriter::get())
nFlags |= OLE_WINWORD_2_STARWRITER;
return nFlags;
}
@@ -510,7 +509,7 @@ sal_uInt32 SwMSDffManager::GetFilterFlags()
* native nonOLE Form Control Objects.
*/
// #i32596# - consider new parameter <_nCalledByGroup>
-SdrObject* SwMSDffManager::ImportOLE( sal_uInt32 nOLEId,
+rtl::Reference<SdrObject> SwMSDffManager::ImportOLE( sal_uInt32 nOLEId,
const Graphic& rGrf,
const tools::Rectangle& rBoundRect,
const tools::Rectangle& rVisArea,
@@ -524,19 +523,19 @@ SdrObject* SwMSDffManager::ImportOLE( sal_uInt32 nOLEId,
return nullptr;
}
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
OUString sStorageName;
- tools::SvRef<SotStorage> xSrcStg;
+ rtl::Reference<SotStorage> xSrcStg;
uno::Reference < embed::XStorage > xDstStg;
if( GetOLEStorageName( nOLEId, sStorageName, xSrcStg, xDstStg ))
{
- tools::SvRef<SotStorage> xSrc = xSrcStg->OpenSotStorage( sStorageName );
- OSL_ENSURE(rReader.m_xFormImpl, "No Form Implementation!");
+ rtl::Reference<SotStorage> xSrc = xSrcStg->OpenSotStorage(sStorageName);
+ OSL_ENSURE(m_rReader.m_xFormImpl, "No Form Implementation!");
css::uno::Reference< css::drawing::XShape > xShape;
- if ( (!(rReader.m_bIsHeader || rReader.m_bIsFooter)) &&
- rReader.m_xFormImpl->ReadOCXStream(xSrc,&xShape,true))
+ if ( (!(m_rReader.m_bIsHeader || m_rReader.m_bIsFooter)) &&
+ m_rReader.m_xFormImpl->ReadOCXStream(xSrc,&xShape,true))
{
- pRet = GetSdrObjectFromXShape(xShape);
+ pRet = SdrObject::getSdrObjectFromXShape(xShape);
}
else
{
@@ -553,7 +552,7 @@ SdrObject* SwMSDffManager::ImportOLE( sal_uInt32 nOLEId,
nError,
nSvxMSDffOLEConvFlags,
css::embed::Aspects::MSOLE_CONTENT,
- rReader.GetBaseURL());
+ m_rReader.GetBaseURL());
}
}
return pRet;
@@ -561,20 +560,20 @@ SdrObject* SwMSDffManager::ImportOLE( sal_uInt32 nOLEId,
void SwMSDffManager::DisableFallbackStream()
{
- OSL_ENSURE(!pFallbackStream,
+ OSL_ENSURE(!m_pFallbackStream,
"if you're recursive, you're broken");
- pFallbackStream = pStData2;
- aOldEscherBlipCache = aEscherBlipCache;
+ m_pFallbackStream = pStData2;
+ m_aOldEscherBlipCache = aEscherBlipCache;
aEscherBlipCache.clear();
pStData2 = nullptr;
}
void SwMSDffManager::EnableFallbackStream()
{
- pStData2 = pFallbackStream;
- aEscherBlipCache = aOldEscherBlipCache;
- aOldEscherBlipCache.clear();
- pFallbackStream = nullptr;
+ pStData2 = m_pFallbackStream;
+ aEscherBlipCache = m_aOldEscherBlipCache;
+ m_aOldEscherBlipCache.clear();
+ m_pFallbackStream = nullptr;
}
sal_uInt16 SwWW8ImplReader::GetToggleAttrFlags() const
@@ -599,13 +598,14 @@ void SwWW8ImplReader::SetToggleBiDiAttrFlags(sal_uInt16 nFlags)
m_xCtrlStck->SetToggleBiDiAttrFlags(nFlags);
}
-SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
+rtl::Reference<SdrObject> SwMSDffManager::ProcessObj(SvStream& rSt,
DffObjData& rObjData,
SvxMSDffClientData& rData,
tools::Rectangle& rTextRect,
- SdrObject* pObj
+ SdrObject* pObj1
)
{
+ rtl::Reference<SdrObject> pObj = pObj1;
if( !rTextRect.IsEmpty() )
{
SvxMSDffImportData& rImportData = static_cast<SvxMSDffImportData&>(rData);
@@ -631,9 +631,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
maShapeRecords.Current()->nRecLen,
pImpRec->pClientDataBuffer, pImpRec->nClientDataLen );
- // process user (== Winword) defined parameters in 0xF122 record
- // #i84783# - set special value to determine, if property is provided or not.
- pImpRec->nLayoutInTableCell = 0xFFFFFFFF;
+ pImpRec->nGroupShapeBooleanProperties = 0;
if( maShapeRecords.SeekToContent( rSt,
DFF_msofbtUDefProp,
@@ -665,7 +663,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
case 0x0392:
pImpRec->nYRelTo = nUDData;
break;
- case 0x03BF: pImpRec->nLayoutInTableCell = nUDData; break;
+ case 0x03BF: pImpRec->nGroupShapeBooleanProperties = nUDData; break;
case 0x0393:
// This seems to correspond to o:hrpct from .docx (even including
// the difference that it's in 0.1% even though the .docx spec
@@ -786,10 +784,9 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
if (bIsSimpleDrawingTextBox)
{
- SdrObject::Free( pObj );
pObj = new SdrRectObj(
*pSdrModel,
- OBJ_TEXT,
+ SdrObjKind::Text,
rTextRect);
}
@@ -916,7 +913,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
if (bVerticalText)
{
- SdrTextObj *pTextObj = dynamic_cast< SdrTextObj* >(pObj);
+ SdrTextObj *pTextObj = DynCastSdrTextObj(pObj.get());
if (pTextObj)
pTextObj->SetVerticalWriting(true);
}
@@ -935,9 +932,9 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
}
}
- if ( ( ( rObjData.nSpFlags & ShapeFlag::FlipV ) || mnFix16Angle || nTextRotationAngle ) && dynamic_cast< SdrObjCustomShape* >( pObj ) )
+ if ( ( ( rObjData.nSpFlags & ShapeFlag::FlipV ) || mnFix16Angle || nTextRotationAngle ) && dynamic_cast< SdrObjCustomShape* >( pObj.get() ) )
{
- SdrObjCustomShape* pCustomShape = dynamic_cast< SdrObjCustomShape* >( pObj );
+ SdrObjCustomShape* pCustomShape = dynamic_cast< SdrObjCustomShape* >( pObj.get() );
if (pCustomShape)
{
double fExtraTextRotation = 0.0;
@@ -981,9 +978,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
SfxItemSet aSet( pSdrModel->GetItemPool() );
ApplyAttributes( rSt, aSet, rObjData );
- const SfxPoolItem* pPoolItem=nullptr;
- SfxItemState eState = aSet.GetItemState( XATTR_FILLCOLOR,
- false, &pPoolItem );
+ SfxItemState eState = aSet.GetItemState( XATTR_FILLCOLOR, false );
if( SfxItemState::DEFAULT == eState )
aSet.Put( XFillColorItem( OUString(), mnDefaultColor ) );
pObj->SetMergedItemSet(aSet);
@@ -1000,8 +995,8 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
if ( nTextId )
{
- pImpRec->aTextId.nTxBxS = static_cast<sal_uInt16>( nTextId >> 16 );
- pImpRec->aTextId.nSequence = static_cast<sal_uInt16>(nTextId);
+ pImpRec->aTextId.nTxBxS = o3tl::narrowing<sal_uInt16>( nTextId >> 16 );
+ pImpRec->aTextId.nSequence = o3tl::narrowing<sal_uInt16>(nTextId);
}
pImpRec->nDxWrapDistLeft = o3tl::convert(GetPropertyValue(DFF_Prop_dxWrapDistLeft, 114935),
@@ -1022,15 +1017,16 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
sal_uInt16 nNumElemVert(0), nNumElemMemVert(0), nElemSizeVert(0);
rSt.ReadUInt16( nNumElemVert ).ReadUInt16( nNumElemMemVert ).ReadUInt16( nElemSizeVert );
bool bOk = false;
- if (nNumElemVert && ((nElemSizeVert == 8) || (nElemSizeVert == 4)))
+ if (nNumElemVert && (nElemSizeVert == 8 || nElemSizeVert == 4))
{
//check if there is enough data in the file to make the
//record sane
+ // coverity[tainted_data : FALSE] - nElemSizeVert is either 8 or 4 so it has been sanitized
bOk = rSt.remainingSize() / nElemSizeVert >= nNumElemVert;
}
if (bOk)
{
- pImpRec->pWrapPolygon.reset( new tools::Polygon(nNumElemVert) );
+ pImpRec->pWrapPolygon = tools::Polygon(nNumElemVert);
for (sal_uInt16 i = 0; i < nNumElemVert; ++i)
{
sal_Int32 nX(0), nY(0);
@@ -1093,7 +1089,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
&& (rObjData.nCalledByGroup < 2) )
)
{
- StoreShapeOrder(nShapeId, nShapeOrder, pObj);
+ StoreShapeOrder(nShapeId, nShapeOrder, pObj.get());
}
}
else
@@ -1112,22 +1108,22 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
if (rSt.ReadBytes(aBuffer.data(), nBufferSize) == nBufferSize)
{
aMemStream.WriteBytes(aBuffer.data(), nBufferSize);
- sal_uInt8 nStreamSize = aMemStream.TellEnd();
+ sal_uInt64 nStreamSize = aMemStream.TellEnd();
aMemStream.Seek( STREAM_SEEK_TO_BEGIN );
bool bRet = 4 <= nStreamSize;
sal_uInt16 nRawRecId,nRawRecSize;
if( bRet )
aMemStream.ReadUInt16( nRawRecId ).ReadUInt16( nRawRecSize );
- SwDocShell* pDocShell = rReader.m_pDocShell;
+ SwDocShell* pDocShell = m_rReader.m_pDocShell;
if (pDocShell)
{
- rReader.ReadEmbeddedData(aMemStream, pDocShell, hlStr);
+ m_rReader.ReadEmbeddedData(aMemStream, pDocShell, hlStr);
}
}
if (pObj && !hlStr.hLinkAddr.isEmpty())
{
- SwMacroInfo* pInfo = GetMacroInfo( pObj );
+ SwMacroInfo* pInfo = GetMacroInfo( pObj.get() );
if( pInfo )
{
pInfo->SetShapeId( rObjData.nShapeId );
@@ -1197,13 +1193,13 @@ SwFltStackEntry* SwWW8FltControlStack::SetAttr(const SwPosition& rPos, sal_uInt1
// Doing a textbox, and using the control stack only as a temporary
// collection point for properties which will are not to be set into
// the real document
- if (rReader.m_xPlcxMan && rReader.m_xPlcxMan->GetDoingDrawTextBox())
+ if (m_rReader.m_xPlcxMan && m_rReader.m_xPlcxMan->GetDoingDrawTextBox())
{
size_t nCnt = size();
for (size_t i=0; i < nCnt; ++i)
{
SwFltStackEntry& rEntry = (*this)[i];
- if (nAttrId == rEntry.pAttr->Which())
+ if (nAttrId == rEntry.m_pAttr->Which())
{
DeleteAndDestroy(i--);
--nCnt;
@@ -1231,14 +1227,15 @@ tools::Long GetListFirstLineIndent(const SwNumFormat &rFormat)
return nReverseListIndented;
}
-static tools::Long lcl_GetTrueMargin(const SvxLRSpaceItem &rLR, const SwNumFormat &rFormat,
+static tools::Long lcl_GetTrueMargin(SvxFirstLineIndentItem const& rFirstLine,
+ SvxTextLeftMarginItem const& rLeftMargin, const SwNumFormat &rFormat,
tools::Long &rFirstLinePos)
{
OSL_ENSURE( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION,
"<lcl_GetTrueMargin> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION" );
- const tools::Long nBodyIndent = rLR.GetTextLeft();
- const tools::Long nFirstLineDiff = rLR.GetTextFirstLineOffset();
+ const tools::Long nBodyIndent = rLeftMargin.GetTextLeft();
+ const tools::Long nFirstLineDiff = rFirstLine.GetTextFirstLineOffset();
rFirstLinePos = nBodyIndent + nFirstLineDiff;
const auto nPseudoListBodyIndent = rFormat.GetAbsLSpace();
@@ -1250,7 +1247,8 @@ static tools::Long lcl_GetTrueMargin(const SvxLRSpaceItem &rLR, const SwNumForma
// #i103711#
// #i105414#
-void SyncIndentWithList( SvxLRSpaceItem &rLR,
+void SyncIndentWithList( SvxFirstLineIndentItem & rFirstLine,
+ SvxTextLeftMarginItem & rLeftMargin,
const SwNumFormat &rFormat,
const bool bFirstLineOfstSet,
const bool bLeftIndentSet )
@@ -1258,31 +1256,31 @@ void SyncIndentWithList( SvxLRSpaceItem &rLR,
if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
{
tools::Long nWantedFirstLinePos;
- tools::Long nExtraListIndent = lcl_GetTrueMargin(rLR, rFormat, nWantedFirstLinePos);
- rLR.SetTextLeft(nWantedFirstLinePos - nExtraListIndent);
- rLR.SetTextFirstLineOffset(0);
+ tools::Long nExtraListIndent = lcl_GetTrueMargin(rFirstLine, rLeftMargin, rFormat, nWantedFirstLinePos);
+ rLeftMargin.SetTextLeft(nWantedFirstLinePos - nExtraListIndent);
+ rFirstLine.SetTextFirstLineOffset(0);
}
else if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
{
if ( !bFirstLineOfstSet && bLeftIndentSet &&
rFormat.GetFirstLineIndent() != 0 )
{
- rLR.SetTextFirstLineOffset( rFormat.GetFirstLineIndent() );
+ rFirstLine.SetTextFirstLineOffset(rFormat.GetFirstLineIndent());
}
else if ( bFirstLineOfstSet && !bLeftIndentSet &&
rFormat.GetIndentAt() != 0 )
{
- rLR.SetTextLeft( rFormat.GetIndentAt() );
+ rLeftMargin.SetTextLeft(rFormat.GetIndentAt());
}
else if (!bFirstLineOfstSet && !bLeftIndentSet )
{
if ( rFormat.GetFirstLineIndent() != 0 )
{
- rLR.SetTextFirstLineOffset( rFormat.GetFirstLineIndent() );
+ rFirstLine.SetTextFirstLineOffset(rFormat.GetFirstLineIndent());
}
if ( rFormat.GetIndentAt() != 0 )
{
- rLR.SetTextLeft( rFormat.GetIndentAt() );
+ rLeftMargin.SetTextLeft(rFormat.GetIndentAt());
}
}
}
@@ -1298,7 +1296,7 @@ const SwNumFormat* SwWW8FltControlStack::GetNumFormatFromStack(const SwPosition
if (rTextNode.IsCountedInList())
{
OUString sName(static_cast<const SfxStringItem*>(pItem)->GetValue());
- const SwNumRule *pRule = rDoc.FindNumRulePtr(sName);
+ const SwNumRule *pRule = m_rDoc.FindNumRulePtr(sName);
if (pRule)
pRet = GetNumFormatFromSwNumRuleLevel(*pRule, rTextNode.GetActualListLevel());
}
@@ -1306,37 +1304,10 @@ const SwNumFormat* SwWW8FltControlStack::GetNumFormatFromStack(const SwPosition
return pRet;
}
-sal_Int32 SwWW8FltControlStack::GetCurrAttrCP() const
-{
- return rReader.GetCurrAttrCP();
-}
-
-bool SwWW8FltControlStack::IsParaEndInCPs(sal_Int32 nStart,sal_Int32 nEnd,bool bSdOD) const
-{
- return rReader.IsParaEndInCPs(nStart,nEnd,bSdOD);
-}
-
-/**
- * Clear the para end position recorded in reader intermittently
- * for the least impact on loading performance.
- */
-void SwWW8FltControlStack::ClearParaEndPosition()
-{
- if ( !empty() )
- return;
-
- rReader.ClearParaEndPosition();
-}
-
-bool SwWW8FltControlStack::CheckSdOD(sal_Int32 nStart,sal_Int32 nEnd)
-{
- return rReader.IsParaEndInCPs(nStart,nEnd);
-}
-
void SwWW8ReferencedFltEndStack::SetAttrInDoc( const SwPosition& rTmpPos,
SwFltStackEntry& rEntry )
{
- switch( rEntry.pAttr->Which() )
+ switch( rEntry.m_pAttr->Which() )
{
case RES_FLTR_BOOKMARK:
{
@@ -1344,12 +1315,12 @@ void SwWW8ReferencedFltEndStack::SetAttrInDoc( const SwPosition& rTmpPos,
// and which is not referenced.
bool bInsertBookmarkIntoDoc = true;
- SwFltBookmark* pFltBookmark = dynamic_cast<SwFltBookmark*>(rEntry.pAttr.get());
+ SwFltBookmark* pFltBookmark = dynamic_cast<SwFltBookmark*>(rEntry.m_pAttr.get());
if ( pFltBookmark != nullptr && pFltBookmark->IsTOCBookmark() )
{
const OUString& rName = pFltBookmark->GetName();
- std::set< OUString, SwWW8::ltstr >::const_iterator aResult = aReferencedTOCBookmarks.find(rName);
- if ( aResult == aReferencedTOCBookmarks.end() )
+ std::set< OUString, SwWW8::ltstr >::const_iterator aResult = m_aReferencedTOCBookmarks.find(rName);
+ if ( aResult == m_aReferencedTOCBookmarks.end() )
{
bInsertBookmarkIntoDoc = false;
}
@@ -1370,9 +1341,13 @@ void SwWW8ReferencedFltEndStack::SetAttrInDoc( const SwPosition& rTmpPos,
void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
SwFltStackEntry& rEntry)
{
- switch (rEntry.pAttr->Which())
+ switch (rEntry.m_pAttr->Which())
{
case RES_LR_SPACE:
+ assert(false);
+ break;
+ case RES_MARGIN_FIRSTLINE:
+ case RES_MARGIN_TEXTLEFT:
{
/*
Loop over the affected nodes and
@@ -1382,19 +1357,41 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
paragraph indent to be relative to the new paragraph indent
*/
SwPaM aRegion(rTmpPos);
- if (rEntry.MakeRegion(rDoc, aRegion, SwFltStackEntry::RegionMode::NoCheck))
+ if (rEntry.MakeRegion(aRegion, SwFltStackEntry::RegionMode::NoCheck))
{
- SvxLRSpaceItem aNewLR( *static_cast<SvxLRSpaceItem*>(rEntry.pAttr.get()) );
- sal_uLong nStart = aRegion.Start()->nNode.GetIndex();
- sal_uLong nEnd = aRegion.End()->nNode.GetIndex();
+ SvxFirstLineIndentItem firstLineNew(RES_MARGIN_FIRSTLINE);
+ SvxTextLeftMarginItem leftMarginNew(RES_MARGIN_TEXTLEFT);
+ if (rEntry.m_pAttr->Which() == RES_MARGIN_FIRSTLINE)
+ {
+ SvxFirstLineIndentItem const firstLineEntry(*static_cast<SvxFirstLineIndentItem*>(rEntry.m_pAttr.get()));
+ firstLineNew.SetTextFirstLineOffset(firstLineEntry.GetTextFirstLineOffset(), firstLineEntry.GetPropTextFirstLineOffset());
+ firstLineNew.SetAutoFirst(firstLineEntry.IsAutoFirst());
+ }
+ else
+ {
+ SvxTextLeftMarginItem const leftMarginEntry(*static_cast<SvxTextLeftMarginItem*>(rEntry.m_pAttr.get()));
+ leftMarginNew.SetTextLeft(leftMarginEntry.GetTextLeft(), leftMarginEntry.GetPropLeft());
+ }
+ SwNodeOffset nStart = aRegion.Start()->GetNodeIndex();
+ SwNodeOffset nEnd = aRegion.End()->GetNodeIndex();
for(; nStart <= nEnd; ++nStart)
{
- SwNode* pNode = rDoc.GetNodes()[ nStart ];
+ SwNode* pNode = m_rDoc.GetNodes()[ nStart ];
if (!pNode || !pNode->IsTextNode())
continue;
SwContentNode* pNd = static_cast<SwContentNode*>(pNode);
- SvxLRSpaceItem aOldLR = static_cast<const SvxLRSpaceItem&>(pNd->GetAttr(RES_LR_SPACE));
+ SvxFirstLineIndentItem firstLineOld(pNd->GetAttr(RES_MARGIN_FIRSTLINE));
+ SvxTextLeftMarginItem leftMarginOld(pNd->GetAttr(RES_MARGIN_TEXTLEFT));
+ if (rEntry.m_pAttr->Which() == RES_MARGIN_FIRSTLINE)
+ {
+ leftMarginNew.SetTextLeft(leftMarginOld.GetTextLeft(), leftMarginOld.GetPropLeft());
+ }
+ else
+ {
+ firstLineNew.SetTextFirstLineOffset(firstLineOld.GetTextFirstLineOffset(), firstLineOld.GetPropTextFirstLineOffset());
+ firstLineNew.SetAutoFirst(firstLineOld.IsAutoFirst());
+ }
SwTextNode *pTextNode = static_cast<SwTextNode*>(pNode);
@@ -1409,22 +1406,28 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
{
// #i103711#
const bool bFirstLineIndentSet =
- ( rReader.m_aTextNodesHavingFirstLineOfstSet.end() !=
- rReader.m_aTextNodesHavingFirstLineOfstSet.find( pNode ) );
+ ( m_rReader.m_aTextNodesHavingFirstLineOfstSet.end() !=
+ m_rReader.m_aTextNodesHavingFirstLineOfstSet.find( pNode ) );
// #i105414#
const bool bLeftIndentSet =
- ( rReader.m_aTextNodesHavingLeftIndentSet.end() !=
- rReader.m_aTextNodesHavingLeftIndentSet.find( pNode ) );
- SyncIndentWithList( aNewLR, *pNum,
+ ( m_rReader.m_aTextNodesHavingLeftIndentSet.end() !=
+ m_rReader.m_aTextNodesHavingLeftIndentSet.find( pNode ) );
+ SyncIndentWithList(firstLineNew, leftMarginNew, *pNum,
bFirstLineIndentSet,
bLeftIndentSet );
}
- if (aNewLR == aOldLR)
- continue;
-
- pNd->SetAttr(aNewLR);
-
+ if (firstLineNew != firstLineOld)
+ {
+ if (nStart == aRegion.Start()->GetNodeIndex())
+ {
+ pNd->SetAttr(firstLineNew);
+ }
+ }
+ if (leftMarginNew != leftMarginOld)
+ {
+ pNd->SetAttr(leftMarginNew);
+ }
}
}
}
@@ -1448,7 +1451,7 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
case RES_TXTATR_INETFMT:
{
SwPaM aRegion(rTmpPos);
- if (rEntry.MakeRegion(rDoc, aRegion, SwFltStackEntry::RegionMode::NoCheck))
+ if (rEntry.MakeRegion(aRegion, SwFltStackEntry::RegionMode::NoCheck))
{
SwFrameFormat *pFrame;
// If we have just one single inline graphic then
@@ -1458,7 +1461,7 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
if (nullptr != pFrame)
{
const SwFormatINetFormat *pAttr = static_cast<const SwFormatINetFormat *>(
- rEntry.pAttr.get());
+ rEntry.m_pAttr.get());
SwFormatURL aURL;
aURL.SetURL(pAttr->GetValue(), false);
aURL.SetTargetFrameName(pAttr->GetTargetFrame());
@@ -1466,7 +1469,7 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
}
else
{
- rDoc.getIDocumentContentOperations().InsertPoolItem(aRegion, *rEntry.pAttr);
+ m_rDoc.getIDocumentContentOperations().InsertPoolItem(aRegion, *rEntry.m_pAttr);
}
}
}
@@ -1483,9 +1486,9 @@ const SfxPoolItem* SwWW8FltControlStack::GetFormatAttr(const SwPosition& rPos,
const SfxPoolItem *pItem = GetStackAttr(rPos, nWhich);
if (!pItem)
{
- SwContentNode const*const pNd = rPos.nNode.GetNode().GetContentNode();
+ SwContentNode const*const pNd = rPos.GetNode().GetContentNode();
if (!pNd)
- pItem = &rDoc.GetAttrPool().GetDefaultItem(nWhich);
+ pItem = &m_rDoc.GetAttrPool().GetUserOrPoolDefaultItem(nWhich);
else
{
/*
@@ -1494,13 +1497,28 @@ const SfxPoolItem* SwWW8FltControlStack::GetFormatAttr(const SwPosition& rPos,
not writer format, because that's the style that the filter works
in (naturally)
*/
- if (nWhich == RES_LR_SPACE)
+ if (nWhich == RES_MARGIN_FIRSTLINE
+ || nWhich == RES_MARGIN_TEXTLEFT
+ || nWhich == RES_MARGIN_RIGHT)
{
SfxItemState eState = SfxItemState::DEFAULT;
if (const SfxItemSet *pSet = pNd->GetpSwAttrSet())
- eState = pSet->GetItemState(RES_LR_SPACE, false);
- if (eState != SfxItemState::SET && rReader.m_nCurrentColl < rReader.m_vColl.size())
- pItem = rReader.m_vColl[rReader.m_nCurrentColl].maWordLR.get();
+ eState = pSet->GetItemState(nWhich, false);
+ if (eState != SfxItemState::SET && m_rReader.m_nCurrentColl < m_rReader.m_vColl.size())
+ {
+ switch (nWhich)
+ {
+ case RES_MARGIN_FIRSTLINE:
+ pItem = m_rReader.m_vColl[m_rReader.m_nCurrentColl].m_pWordFirstLine.get();
+ break;
+ case RES_MARGIN_TEXTLEFT:
+ pItem = m_rReader.m_vColl[m_rReader.m_nCurrentColl].m_pWordLeftMargin.get();
+ break;
+ case RES_MARGIN_RIGHT:
+ pItem = m_rReader.m_vColl[m_rReader.m_nCurrentColl].m_pWordRightMargin.get();
+ break;
+ }
+ }
}
/*
@@ -1509,8 +1527,8 @@ const SfxPoolItem* SwWW8FltControlStack::GetFormatAttr(const SwPosition& rPos,
*/
if (pNd->IsTextNode())
{
- const sal_Int32 nPos = rPos.nContent.GetIndex();
- m_xScratchSet.reset(new SfxItemSet(rDoc.GetAttrPool(), {{nWhich, nWhich}}));
+ const sal_Int32 nPos = rPos.GetContentIndex();
+ m_xScratchSet.reset(new SfxItemSet(m_rDoc.GetAttrPool(), nWhich, nWhich));
if (pNd->GetTextNode()->GetParaAttr(*m_xScratchSet, nPos, nPos))
pItem = m_xScratchSet->GetItem(nWhich);
}
@@ -1531,9 +1549,9 @@ const SfxPoolItem* SwWW8FltControlStack::GetStackAttr(const SwPosition& rPos,
while (nSize)
{
const SwFltStackEntry& rEntry = (*this)[ --nSize ];
- if (rEntry.pAttr->Which() == nWhich)
+ if (rEntry.m_pAttr->Which() == nWhich)
{
- if ( (rEntry.bOpen) ||
+ if ( (rEntry.m_bOpen) ||
(
(rEntry.m_aMkPos.m_nNode <= aFltPos.m_nNode) &&
(rEntry.m_aPtPos.m_nNode >= aFltPos.m_nNode) &&
@@ -1546,7 +1564,7 @@ const SfxPoolItem* SwWW8FltControlStack::GetStackAttr(const SwPosition& rPos,
* means props that end at 3 are not included
*/
{
- return rEntry.pAttr.get();
+ return rEntry.m_pAttr.get();
}
}
}
@@ -1563,7 +1581,7 @@ bool SwWW8FltRefStack::IsFootnoteEdnBkmField(
&& ((REF_FOOTNOTE == (nSubType = pField->GetSubType())) || (REF_ENDNOTE == nSubType))
&& !static_cast<const SwGetRefField*>(pField)->GetSetRefName().isEmpty())
{
- const IDocumentMarkAccess* const pMarkAccess = rDoc.getIDocumentMarkAccess();
+ const IDocumentMarkAccess* const pMarkAccess = m_rDoc.getIDocumentMarkAccess();
IDocumentMarkAccess::const_iterator_t ppBkmk =
pMarkAccess->findMark( static_cast<const SwGetRefField*>(pField)->GetSetRefName() );
if(ppBkmk != pMarkAccess->getAllMarksEnd())
@@ -1579,7 +1597,7 @@ bool SwWW8FltRefStack::IsFootnoteEdnBkmField(
void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos,
SwFltStackEntry& rEntry)
{
- switch (rEntry.pAttr->Which())
+ switch (rEntry.m_pAttr->Which())
{
/*
Look up these in our lists of bookmarks that were changed to
@@ -1590,10 +1608,9 @@ void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos,
case RES_TXTATR_ANNOTATION:
case RES_TXTATR_INPUTFIELD:
{
- SwNodeIndex aIdx(rEntry.m_aMkPos.m_nNode, 1);
- SwPaM aPaM(aIdx, rEntry.m_aMkPos.m_nContent);
+ SwPaM aPaM(rEntry.m_aMkPos.m_nNode.GetNode(), SwNodeOffset(1), rEntry.m_aMkPos.m_nContent);
- SwFormatField& rFormatField = *static_cast<SwFormatField*>(rEntry.pAttr.get());
+ SwFormatField& rFormatField = *static_cast<SwFormatField*>(rEntry.m_pAttr.get());
SwField* pField = rFormatField.GetField();
if (!RefToVar(pField, rEntry))
@@ -1601,15 +1618,15 @@ void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos,
sal_uInt16 nBkmNo;
if( IsFootnoteEdnBkmField(rFormatField, nBkmNo) )
{
- ::sw::mark::IMark const * const pMark = rDoc.getIDocumentMarkAccess()->getAllMarksBegin()[nBkmNo];
+ ::sw::mark::IMark const * const pMark = m_rDoc.getIDocumentMarkAccess()->getAllMarksBegin()[nBkmNo];
const SwPosition& rBkMrkPos = pMark->GetMarkPos();
- SwTextNode* pText = rBkMrkPos.nNode.GetNode().GetTextNode();
- if( pText && rBkMrkPos.nContent.GetIndex() )
+ SwTextNode* pText = rBkMrkPos.GetNode().GetTextNode();
+ if( pText && rBkMrkPos.GetContentIndex() )
{
SwTextAttr* const pFootnote = pText->GetTextAttrForCharAt(
- rBkMrkPos.nContent.GetIndex()-1, RES_TXTATR_FTN );
+ rBkMrkPos.GetContentIndex()-1, RES_TXTATR_FTN );
if( pFootnote )
{
sal_uInt16 nRefNo = static_cast<SwTextFootnote*>(pFootnote)->GetSeqRefNo();
@@ -1623,7 +1640,7 @@ void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos,
}
}
- rDoc.getIDocumentContentOperations().InsertPoolItem(aPaM, *rEntry.pAttr);
+ m_rDoc.getIDocumentContentOperations().InsertPoolItem(aPaM, *rEntry.m_pAttr);
MoveAttrs(*aPaM.GetPoint());
}
break;
@@ -1695,12 +1712,12 @@ void SwWW8ImplReader::Read_Tab(sal_uInt16 , const sal_uInt8* pData, short nLen)
std::unordered_set<size_t> aLoopWatch;
while (pSty && !bFound)
{
- const SfxPoolItem* pTabs;
+ const SvxTabStopItem* pTabs;
bFound = pSty->GetAttrSet().GetItemState(RES_PARATR_TABSTOP, false,
&pTabs) == SfxItemState::SET;
if( bFound )
{
- aAttr.reset(static_cast<SvxTabStopItem*>(pTabs->Clone()));
+ aAttr.reset(pTabs->Clone());
}
else
{
@@ -1798,8 +1815,8 @@ void SwWW8ImplReader::Read_Tab(sal_uInt16 , const sal_uInt8* pData, short nLen)
if (!m_pCurrentColl) // not importing into a style
{
SvxTabStopItem aOrig = pSty ?
- ItemGet<SvxTabStopItem>(*pSty, RES_PARATR_TABSTOP) :
- DefaultItemGet<SvxTabStopItem>(m_rDoc, RES_PARATR_TABSTOP);
+ pSty->GetFormatAttr(RES_PARATR_TABSTOP) :
+ m_rDoc.GetAttrPool().GetUserOrPoolDefaultItem(RES_PARATR_TABSTOP);
NewAttr(aOrig);
}
}
@@ -1849,6 +1866,8 @@ void SwWW8ImplReader::ImportDop()
DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA, true);
m_rDoc.getIDocumentSettingAccess().set(
DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA, true);
+ m_rDoc.getIDocumentSettingAccess().set(
+ DocumentSettingId::FOOTNOTE_IN_COLUMN_TO_PAGEEND, true);
// Import Default Tabs
tools::Long nDefTabSiz = m_xWDop->dxaTab;
@@ -1859,7 +1878,7 @@ void SwWW8ImplReader::ImportDop()
SvxTabStopItem aNewTab( 1, sal_uInt16(nDefTabSiz), SvxTabAdjust::Default, RES_PARATR_TABSTOP );
const_cast<SvxTabStop&>(aNewTab[0]).GetAdjustment() = SvxTabAdjust::Default;
- m_rDoc.GetAttrPool().SetPoolDefaultItem( aNewTab );
+ m_rDoc.GetAttrPool().SetUserDefaultItem( aNewTab );
// Import zoom factor
if (m_xWDop->wScaleSaved)
@@ -1878,9 +1897,8 @@ void SwWW8ImplReader::ImportDop()
{ "ZoomType", uno::Any(nZoomType) }
}));
- uno::Reference< uno::XComponentContext > xComponentContext(comphelper::getProcessComponentContext());
- uno::Reference<container::XIndexContainer> xBox = document::IndexedPropertyValues::create(xComponentContext);
- xBox->insertByIndex(sal_Int32(0), uno::makeAny(aViewProps));
+ rtl::Reference< comphelper::IndexedPropertyValuesContainer > xBox = new comphelper::IndexedPropertyValuesContainer();
+ xBox->insertByIndex(sal_Int32(0), uno::Any(aViewProps));
uno::Reference<document::XViewDataSupplier> xViewDataSupplier(m_pDocShell->GetModel(), uno::UNO_QUERY);
xViewDataSupplier->setViewData(xBox);
}
@@ -1888,9 +1906,14 @@ void SwWW8ImplReader::ImportDop()
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::USE_VIRTUAL_DEVICE, !m_xWDop->fUsePrinterMetrics);
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::USE_HIRES_VIRTUAL_DEVICE, true);
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::ADD_FLY_OFFSETS, true );
+
+ // No vertical offsets would lead to e.g. overlap of table and fly frames.
+ m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS, true );
+
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::ADD_EXT_LEADING, !m_xWDop->fNoLeading);
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::OLD_NUMBERING, false);
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, false); // #i47448#
+ m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::NO_GAP_AFTER_NOTE_NUMBER, true); // tdf#159382
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, !m_xWDop->fExpShRtn); // #i49277#, #i56856#
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, false); // #i53199#
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::OLD_LINE_SPACING, false);
@@ -1916,17 +1939,24 @@ void SwWW8ImplReader::ImportDop()
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::INVERT_BORDER_SPACING, true);
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::COLLAPSE_EMPTY_CELL_PARA, true);
- m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::TAB_OVERFLOW, true);
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::UNBREAKABLE_NUMBERINGS, true);
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::CLIPPED_PICTURES, true);
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::TAB_OVER_MARGIN, true);
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::SURROUND_TEXT_WRAP_SMALL, true);
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::PROP_LINE_SPACING_SHRINKS_FIRST_LINE, true);
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::CONTINUOUS_ENDNOTES, true);
+ // rely on default for HYPHENATE_URLS=false
+ // rely on default for APPLY_TEXT_ATTR_TO_EMPTY_LINE_AT_END_OF_PARAGRAPH=true
+
+ IDocumentSettingAccess& rIDSA = m_rDoc.getIDocumentSettingAccess();
+ if (m_xWDop->fDontBreakWrappedTables)
+ {
+ rIDSA.set(DocumentSettingId::DO_NOT_BREAK_WRAPPED_TABLES, true);
+ }
// COMPATIBILITY FLAGS END
- // Import magic doptypography information, if its there
+ // Import magic doptypography information, if it's there
if (m_xWwFib->m_nFib > 105)
ImportDopTypography(m_xWDop->doptypography);
@@ -1939,8 +1969,23 @@ void SwWW8ImplReader::ImportDop()
if (xInfo.is())
{
if (xInfo->hasPropertyByName("ApplyFormDesignMode"))
- xDocProps->setPropertyValue("ApplyFormDesignMode", css::uno::makeAny(false));
+ xDocProps->setPropertyValue("ApplyFormDesignMode", css::uno::Any(false));
}
+
+ // for the benefit of DOCX - if this is ever saved in that format.
+ comphelper::SequenceAsHashMap aGrabBag(xDocProps->getPropertyValue("InteropGrabBag"));
+ uno::Sequence<beans::PropertyValue> aCompatSetting( comphelper::InitPropertySequence({
+ { "name", uno::Any(OUString("compatibilityMode")) },
+ { "uri", uno::Any(OUString("http://schemas.microsoft.com/office/word")) },
+ { "val", uno::Any(OUString("11")) } //11: Use features specified in MS-DOC.
+ }));
+
+ uno::Sequence< beans::PropertyValue > aValue(comphelper::InitPropertySequence({
+ { "compatSetting", uno::Any(aCompatSetting) }
+ }));
+
+ aGrabBag["CompatSettings"] <<= aValue;
+ xDocProps->setPropertyValue("InteropGrabBag", uno::Any(aGrabBag.getAsConstPropertyValueList()));
}
// The password can force read-only, comments-only, fill-in-form-only, or require track-changes.
@@ -1956,8 +2001,7 @@ void SwWW8ImplReader::ImportDop()
xDocProps->setPropertyValue("InteropGrabBag", uno::Any(aGrabBag.getAsConstPropertyValueList()));
}
- const SvtFilterOptions& rOpt = SvtFilterOptions::Get();
- if (rOpt.IsUseEnhancedFields())
+ if (officecfg::Office::Common::Filter::Microsoft::Import::ImportWWFieldsAsEnhancedFields::get())
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::PROTECT_FORM, m_xWDop->fProtEnabled );
if (m_xWDop->iGutterPos)
@@ -1974,7 +2018,7 @@ void SwWW8ImplReader::ImportDopTypography(const WW8DopTypography &rTypo)
{
i18n::ForbiddenCharacters aForbidden(OUString(+rTypo.m_rgxchFPunct),
OUString(+rTypo.m_rgxchLPunct));
- // unary + makes sure not to accidentally call the
+ // unary + makes sure not to accidentally call the deleted
// OUString(ConstCharArrayDetector<...>::TypeUtf16) ctor that takes the full
// m_rgxchFPunct, m_rgxchLPunct arrays with embedded NULs, instead of just the
// prefix leading up to the first NUL
@@ -2011,7 +2055,7 @@ void SwWW8ImplReader::ImportDopTypography(const WW8DopTypography &rTypo)
* Footnotes and Endnotes
*/
WW8ReaderSave::WW8ReaderSave(SwWW8ImplReader* pRdr ,WW8_CP nStartCp) :
- maTmpPos(*pRdr->m_pPaM->GetPoint()),
+ mxTmpPos(pRdr->m_rDoc.CreateUnoCursor(*pRdr->m_pPaM->GetPoint())),
mxOldStck(std::move(pRdr->m_xCtrlStck)),
mxOldAnchorStck(std::move(pRdr->m_xAnchorStck)),
mxOldRedlines(std::move(pRdr->m_xRedlineStack)),
@@ -2094,13 +2138,21 @@ void WW8ReaderSave::Restore( SwWW8ImplReader* pRdr )
pRdr->m_xCtrlStck = std::move(mxOldStck);
pRdr->m_xRedlineStack->closeall(*pRdr->m_pPaM->GetPoint());
- pRdr->m_aFrameRedlines.emplace(std::move(pRdr->m_xRedlineStack));
+
+ // ofz#37322 drop m_oLastAnchorPos during RedlineStack dtor and restore it afterwards to the same
+ // place, or somewhere close if that place got destroyed
+ std::shared_ptr<SwUnoCursor> xLastAnchorCursor(pRdr->m_oLastAnchorPos ? pRdr->m_rDoc.CreateUnoCursor(*pRdr->m_oLastAnchorPos) : nullptr);
+ pRdr->m_oLastAnchorPos.reset();
+
pRdr->m_xRedlineStack = std::move(mxOldRedlines);
+ if (xLastAnchorCursor)
+ pRdr->m_oLastAnchorPos.emplace(*xLastAnchorCursor->GetPoint());
+
pRdr->DeleteAnchorStack();
pRdr->m_xAnchorStck = std::move(mxOldAnchorStck);
- *pRdr->m_pPaM->GetPoint() = maTmpPos;
+ *pRdr->m_pPaM->GetPoint() = GetStartPos();
if (mxOldPlcxMan != pRdr->m_xPlcxMan)
pRdr->m_xPlcxMan = mxOldPlcxMan;
@@ -2119,8 +2171,7 @@ void SwWW8ImplReader::Read_HdFtFootnoteText( const SwNodeIndex* pSttIdx,
// Saves Flags (amongst other things) and resets them
WW8ReaderSave aSave( this );
- m_pPaM->GetPoint()->nNode = pSttIdx->GetIndex() + 1;
- m_pPaM->GetPoint()->nContent.Assign( m_pPaM->GetContentNode(), 0 );
+ m_pPaM->GetPoint()->Assign( pSttIdx->GetIndex() + 1 );
// Read Text for Header, Footer or Footnote
ReadText( nStartCp, nLen, nType ); // Ignore Sepx when doing so
@@ -2186,7 +2237,7 @@ tools::Long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
DateTime aDate = msfilter::util::DTTM2DateTime(nDateTime);
OUString sText;
- std::unique_ptr<OutlinerParaObject> pOutliner = ImportAsOutliner( sText, pRes->nCp2OrIdx,
+ std::optional<OutlinerParaObject> pOutliner = ImportAsOutliner( sText, pRes->nCp2OrIdx,
pRes->nCp2OrIdx + pRes->nMemLen, MAN_AND );
m_xFormatOfJustInsertedApo.reset();
@@ -2215,11 +2266,10 @@ void SwWW8ImplReader::Read_HdFtTextAsHackedFrame(WW8_CP nStart, WW8_CP nLen,
SwPosition aTmpPos(*m_pPaM->GetPoint());
- m_pPaM->GetPoint()->nNode = pSttIdx->GetIndex() + 1;
- m_pPaM->GetPoint()->nContent.Assign(m_pPaM->GetContentNode(), 0);
+ m_pPaM->GetPoint()->Assign( pSttIdx->GetIndex() + 1 );
// tdf#122425: Explicitly remove borders and spacing
- SfxItemSet aFlySet(m_rDoc.GetAttrPool(), svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END - 1>{});
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END - 1> aFlySet(m_rDoc.GetAttrPool());
Reader::ResetFrameFormatAttrs(aFlySet);
SwFlyFrameFormat* pFrame
@@ -2264,7 +2314,7 @@ void SwWW8ImplReader::Read_HdFtText(WW8_CP nStart, WW8_CP nLen, SwFrameFormat co
Read_HdFtFootnoteText(pSttIdx, nStart, nLen - 1, MAN_HDFT);
- *m_pPaM->GetPoint() = aTmpPos;
+ *m_pPaM->GetPoint() = std::move(aTmpPos);
}
bool SwWW8ImplReader::isValid_HdFt_CP(WW8_CP nHeaderCP) const
@@ -2427,15 +2477,36 @@ void wwSectionManager::SetHdFt(wwSection const &rSection, int nSect,
}
-void SwWW8ImplReader::AppendTextNode(SwPosition& rPos)
+void SwWW8ImplReader::FinalizeTextNode(SwPosition& rPos, bool bAddNew)
{
- SwTextNode* pText = m_pPaM->GetNode().GetTextNode();
+ SwTextNode* pText = m_pPaM->GetPointNode().GetTextNode();
const SwNumRule* pRule = nullptr;
if (pText != nullptr)
pRule = sw::util::GetNumRuleFromTextNode(*pText);
+ // tdf#64222 / tdf#150613 filter out the "paragraph marker" formatting and
+ // set it as a separate paragraph property, just like we do for DOCX.
+ // This is only being used for numbering currently, so limiting to that context.
+ if (pRule)
+ {
+ SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END - 1, RES_TXTATR_CHARFMT,
+ RES_TXTATR_CHARFMT, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END - 1>
+ items(m_pPaM->GetDoc().GetAttrPool());
+
+ SfxWhichIter aIter(items);
+ for (sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich())
+ {
+ const SfxPoolItem* pItem = m_xCtrlStck->GetStackAttr(rPos, nWhich);
+ if (pItem)
+ items.Put(*pItem);
+ }
+ SwFormatAutoFormat item(RES_PARATR_LIST_AUTOFMT);
+ item.SetStyleHandle(std::make_shared<SfxItemSet>(items));
+ pText->SetAttr(item);
+ }
+
if (
pRule && !m_xWDop->fDontUseHTMLAutoSpacing &&
(m_bParaAutoBefore || m_bParaAutoAfter)
@@ -2493,7 +2564,8 @@ void SwWW8ImplReader::AppendTextNode(SwPosition& rPos)
m_bFirstPara = false;
- m_rDoc.getIDocumentContentOperations().AppendTextNode(rPos);
+ if (bAddNew)
+ m_rDoc.getIDocumentContentOperations().AppendTextNode(rPos);
// We can flush all anchored graphics at the end of a paragraph.
m_xAnchorStck->Flush();
@@ -2515,10 +2587,10 @@ bool SwWW8ImplReader::SetSpacing(SwPaM &rMyPam, int nSpace, bool bIsUpper )
else
aUL.SetLower( static_cast< sal_uInt16 >(nSpace) );
- const sal_Int32 nEnd = pSpacingPos->nContent.GetIndex();
- rMyPam.GetPoint()->nContent.Assign(rMyPam.GetContentNode(), 0);
+ const sal_Int32 nEnd = pSpacingPos->GetContentIndex();
+ rMyPam.GetPoint()->SetContent(0);
m_xCtrlStck->NewAttr(*pSpacingPos, aUL);
- rMyPam.GetPoint()->nContent.Assign(rMyPam.GetContentNode(), nEnd);
+ rMyPam.GetPoint()->SetContent(nEnd);
m_xCtrlStck->SetAttr(*pSpacingPos, RES_UL_SPACE);
bRet = true;
}
@@ -2563,90 +2635,6 @@ void SwWW8ImplReader::EndSpecial()
OSL_ENSURE(!m_nInTable, "unclosed table!");
}
-bool SwWW8ImplReader::FloatingTableConversion(WW8PLCFx_Cp_FKP* pPap)
-{
- // This is ww8 version of the code deciding if the table needs to be
- // in a floating frame.
- // For OOXML code, see SectionPropertyMap::FloatingTableConversion in
- // writerfilter/source/dmapper/PropertyMap.cxx
- // The two should do ~same, so if you make changes here, please check
- // that the other is in sync.
-
- // Note that this is just a list of heuristics till sw core can have a
- // table that is floating and can span over multiple pages at the same
- // time.
-
- // If the floating table is in a header or footer, then it won't be a
- // multi-page one, so can always do the conversion.
- if (m_bIsHeader || m_bIsFooter)
- {
- return true;
- }
-
- bool bResult = true;
-
- SprmResult aRes = pPap->HasSprm(NS_sprm::TDefTable::val);
- if (nullptr != aRes.pSprm)
- {
- bResult = false;
- WW8TabBandDesc aDesc;
- aDesc.ReadDef(false, aRes.pSprm, aRes.nRemainingData);
- int nTextAreaWidth = m_aSectionManager.GetTextAreaWidth();
- int nTableWidth = aDesc.nCenter[aDesc.nWwCols] - aDesc.nCenter[0];
-
- // It seems Word has a limit here, so that in case the table width is quite
- // close to the text area width, then it won't perform a wrapping, even in
- // case the content (e.g. an empty paragraph) would fit. The magic constant
- // here represents this limit.
- const int nMagicNumber = 469;
-
- // If the table is wider than the text area, then don't create a fly
- // for the table: no wrapping will be performed anyway, but multi-page
- // tables will be broken.
- if ((nTableWidth + nMagicNumber) < nTextAreaWidth)
- bResult = true;
-
- // If there are columns, do create a fly, as the flow of the columns
- // would otherwise restrict the table.
- if (!bResult && (m_aSectionManager.CurrentSectionColCount() >= 2))
- bResult = true;
- }
-
- if (bResult)
- {
- WW8PLCFxSave1 aSave;
- pPap->Save(aSave);
- if (SearchTableEnd(pPap))
- {
- // Table is considered to be imported into a fly frame and we
- // know where the end of the table is.
- bool bIsUnicode;
- WW8_FC nFc = m_xSBase->WW8Cp2Fc(pPap->Where(), &bIsUnicode);
- sal_uInt64 nPos = m_pStrm->Tell();
- m_pStrm->Seek(nFc);
- sal_uInt16 nUChar = 0;
- if (bIsUnicode)
- m_pStrm->ReadUInt16(nUChar);
- else
- {
- sal_uInt8 nChar = 0;
- m_pStrm->ReadUChar(nChar);
- nUChar = nChar;
- }
- m_pStrm->Seek(nPos);
- if (nUChar == 0xc)
- // The pap after the table starts with a page break, so
- // there will be no wrapping around the float-table.
- // Request no fly in this case, so the table can properly
- // be a multi-page one if necessary.
- bResult = false;
- }
- pPap->Restore(aSave);
- }
-
- return bResult;
-}
-
bool SwWW8ImplReader::ProcessSpecial(bool &rbReSync, WW8_CP nStartCp)
{
// Frame/Table/Anl
@@ -2824,7 +2812,7 @@ rtl_TextEncoding SwWW8ImplReader::GetCharSetFromLanguage()
correctly set in the character runs involved, so it's hard to reproduce
documents that require this to be sure of the process involved.
*/
- const SvxLanguageItem *pLang = static_cast<const SvxLanguageItem*>(GetFormatAttr(RES_CHRATR_LANGUAGE));
+ const SvxLanguageItem *pLang = GetFormatAttr(RES_CHRATR_LANGUAGE);
LanguageType eLang = pLang ? pLang->GetLanguage() : LANGUAGE_SYSTEM;
css::lang::Locale aLocale(LanguageTag::convertToLocale(eLang));
return msfilter::util::getBestTextEncodingFromLocale(aLocale);
@@ -2842,7 +2830,7 @@ rtl_TextEncoding SwWW8ImplReader::GetCJKCharSetFromLanguage()
correctly set in the character runs involved, so it's hard to reproduce
documents that require this to be sure of the process involved.
*/
- const SvxLanguageItem *pLang = static_cast<const SvxLanguageItem*>(GetFormatAttr(RES_CHRATR_CJK_LANGUAGE));
+ const SvxLanguageItem *pLang = GetFormatAttr(RES_CHRATR_CJK_LANGUAGE);
LanguageType eLang = pLang ? pLang->GetLanguage() : LANGUAGE_SYSTEM;
css::lang::Locale aLocale(LanguageTag::convertToLocale(eLang));
return msfilter::util::getBestTextEncodingFromLocale(aLocale);
@@ -3042,7 +3030,15 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, sal_Int32 nEnd, sal_Int32 nCp
if (nRequestedStrLen <= 0)
return true;
- sal_Int32 nRequestedPos = m_xSBase->WW8Cp2Fc(nCpOfs+rPos, &m_bIsUnicode);
+ WW8_CP nCp;
+ const bool bFail = o3tl::checked_add(nCpOfs, rPos, nCp);
+ if (bFail)
+ {
+ rPos+=nRequestedStrLen;
+ return true;
+ }
+
+ sal_Int32 nRequestedPos = m_xSBase->WW8Cp2Fc(nCp, &m_bIsUnicode);
bool bValidPos = checkSeek(*m_pStrm, nRequestedPos);
OSL_ENSURE(bValidPos, "Document claimed to have more text than available");
if (!bValidPos)
@@ -3106,8 +3102,8 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, sal_Int32 nEnd, sal_Int32 nCp
the language is not Japanese
*/
- const SfxPoolItem * pItem = GetFormatAttr(RES_CHRATR_CJK_LANGUAGE);
- if (pItem != nullptr && LANGUAGE_JAPANESE != static_cast<const SvxLanguageItem *>(pItem)->GetLanguage())
+ const SvxLanguageItem * pItem = GetFormatAttr(RES_CHRATR_CJK_LANGUAGE);
+ if (pItem != nullptr && LANGUAGE_JAPANESE != pItem->GetLanguage())
{
SAL_WARN("sw.ww8", "discarding word95 RTL_TEXTENCODING_MS_932 encoding");
eSrcCharSet = GetCharSetFromLanguage();
@@ -3136,9 +3132,9 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, sal_Int32 nEnd, sal_Int32 nCp
sal_uInt16 nUCode;
LanguageType nCTLLang = LANGUAGE_SYSTEM;
- const SfxPoolItem * pItem = GetFormatAttr(RES_CHRATR_CTL_LANGUAGE);
+ const SvxLanguageItem * pItem = GetFormatAttr(RES_CHRATR_CTL_LANGUAGE);
if (pItem != nullptr)
- nCTLLang = static_cast<const SvxLanguageItem *>(pItem)->GetLanguage();
+ nCTLLang = pItem->GetLanguage();
sal_Int32 nL2;
for (nL2 = 0; nL2 < nStrLen; ++nL2)
@@ -3151,7 +3147,7 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, sal_Int32 nEnd, sal_Int32 nCp
nUCode = nBCode;
}
- if (m_pStrm->GetError())
+ if (!m_pStrm->good())
{
rPos = WW8_CP_MAX-10; // -> eof or other error
return true;
@@ -3309,6 +3305,12 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const OUString& rAddString
if (rAddString.isEmpty())
return;
+ if (m_bFuzzing)
+ {
+ simpleAddTextToParagraph(rAddString);
+ return;
+ }
+
uno::Reference<i18n::XBreakIterator> xBI(g_pBreakIt->GetBreakIter());
assert(xBI.is());
@@ -3316,7 +3318,7 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const OUString& rAddString
sal_Int32 nLen = rAddString.getLength();
OUString sParagraphText;
- const SwContentNode *pCntNd = m_pPaM->GetContentNode();
+ const SwContentNode *pCntNd = m_pPaM->GetPointContentNode();
const SwTextNode* pNd = pCntNd ? pCntNd->GetTextNode() : nullptr;
if (pNd)
sParagraphText = pNd->GetText();
@@ -3331,20 +3333,20 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const OUString& rAddString
break;
OUString sChunk(rAddString.copy(nPos, nEnd-nPos));
- const sal_uInt16 aIds[] = {RES_CHRATR_FONT, RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_FONT};
+ const TypedWhichId<SvxFontItem> aIds[] = {RES_CHRATR_FONT, RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_FONT};
const SvxFontItem *pOverriddenItems[] = {nullptr, nullptr, nullptr};
bool aForced[] = {false, false, false};
int nLclIdctHint = 0xFF;
if (nScript == i18n::ScriptType::WEAK)
{
- const SfxInt16Item *pIdctHint = static_cast<const SfxInt16Item*>(GetFormatAttr(RES_CHRATR_IDCTHINT));
+ const SfxInt16Item *pIdctHint = GetFormatAttr(RES_CHRATR_IDCTHINT);
nLclIdctHint = pIdctHint->GetValue();
}
else if (nScript == MSASCII) // Force weak chars in ascii range to use LATIN font
nLclIdctHint = 0;
- sal_uInt16 nForceFromFontId = 0;
+ TypedWhichId<SvxFontItem> nForceFromFontId(0);
if (nLclIdctHint != 0xFF)
{
switch (nLclIdctHint)
@@ -3363,7 +3365,7 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const OUString& rAddString
}
}
- if (nForceFromFontId != 0)
+ if (sal_uInt16(nForceFromFontId) != 0)
{
// Now we know that word would use the nForceFromFontId font for this range
// Try and determine what script writer would assign this range to
@@ -3385,9 +3387,9 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const OUString& rAddString
}
else
{
- const SvxFontItem *pSourceFont = static_cast<const SvxFontItem*>(GetFormatAttr(nForceFromFontId));
- sal_uInt16 nDestId = aIds[nWriterScript-1];
- const SvxFontItem *pDestFont = static_cast<const SvxFontItem*>(GetFormatAttr(nDestId));
+ const SvxFontItem *pSourceFont = GetFormatAttr(nForceFromFontId);
+ TypedWhichId<SvxFontItem> nDestId = aIds[nWriterScript-1];
+ const SvxFontItem *pDestFont = GetFormatAttr(nDestId);
bWriterWillUseSameFontAsWordAutomatically = sameFontIgnoringIrrelevantFields(*pSourceFont, *pDestFont);
}
}
@@ -3395,11 +3397,11 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const OUString& rAddString
// Writer won't use the same font as word, so force the issue
if (!bWriterWillUseSameFontAsWordAutomatically)
{
- const SvxFontItem *pSourceFont = static_cast<const SvxFontItem*>(GetFormatAttr(nForceFromFontId));
+ const SvxFontItem *pSourceFont = GetFormatAttr(nForceFromFontId);
for (size_t i = 0; i < SAL_N_ELEMENTS(aIds); ++i)
{
- const SvxFontItem *pDestFont = static_cast<const SvxFontItem*>(GetFormatAttr(aIds[i]));
+ const SvxFontItem *pDestFont = GetFormatAttr(aIds[i]);
aForced[i] = aIds[i] != nForceFromFontId && *pSourceFont != *pDestFont;
if (aForced[i])
{
@@ -3434,12 +3436,12 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const OUString& rAddString
namespace sw {
-auto FilterControlChars(OUString const& rString) -> OUString
+auto FilterControlChars(std::u16string_view aString) -> OUString
{
- OUStringBuffer buf(rString.getLength());
- for (sal_Int32 i = 0; i < rString.getLength(); ++i)
+ OUStringBuffer buf(aString.size());
+ for (size_t i = 0; i < aString.size(); ++i)
{
- sal_Unicode const ch(rString[i]);
+ sal_Unicode const ch(aString[i]);
if (!linguistic::IsControlChar(ch) || ch == '\r' || ch == '\n' || ch == '\t')
{
buf.append(ch);
@@ -3454,18 +3456,14 @@ auto FilterControlChars(OUString const& rString) -> OUString
} // namespace sw
-void SwWW8ImplReader::simpleAddTextToParagraph(const OUString& rAddString)
+void SwWW8ImplReader::simpleAddTextToParagraph(std::u16string_view aAddString)
{
- OUString const addString(sw::FilterControlChars(rAddString));
+ OUString const addString(sw::FilterControlChars(aAddString));
if (addString.isEmpty())
return;
-#if OSL_DEBUG_LEVEL > 1
- SAL_INFO("sw.ww8", "<addTextToParagraph>" << addString << "</addTextToParagraph>");
-#endif
-
- const SwContentNode *pCntNd = m_pPaM->GetContentNode();
+ const SwContentNode *pCntNd = m_pPaM->GetPointContentNode();
const SwTextNode* pNd = pCntNd ? pCntNd->GetTextNode() : nullptr;
OSL_ENSURE(pNd, "What the hell, where's my text node");
@@ -3483,13 +3481,13 @@ void SwWW8ImplReader::simpleAddTextToParagraph(const OUString& rAddString)
else
{
m_rDoc.getIDocumentContentOperations().InsertString(*m_pPaM, addString.copy(0, nCharsLeft));
- AppendTextNode(*m_pPaM->GetPoint());
+ FinalizeTextNode(*m_pPaM->GetPoint());
m_rDoc.getIDocumentContentOperations().InsertString(*m_pPaM, addString.copy(nCharsLeft));
}
}
else
{
- AppendTextNode(*m_pPaM->GetPoint());
+ FinalizeTextNode(*m_pPaM->GetPoint());
m_rDoc.getIDocumentContentOperations().InsertString(*m_pPaM, addString);
}
@@ -3555,12 +3553,12 @@ bool SwWW8ImplReader::HandlePageBreakChar()
if (!m_nInTable)
{
bool IsTemp=true;
- SwTextNode* pTemp = m_pPaM->GetNode().GetTextNode();
+ SwTextNode* pTemp = m_pPaM->GetPointNode().GetTextNode();
if (pTemp && pTemp->GetText().isEmpty()
&& (m_bFirstPara || m_bFirstParaOfPage))
{
IsTemp = false;
- AppendTextNode(*m_pPaM->GetPoint());
+ FinalizeTextNode(*m_pPaM->GetPoint());
pTemp->SetAttr(*GetDfltAttr(RES_PARATR_NUMRULE));
}
@@ -3574,9 +3572,9 @@ bool SwWW8ImplReader::HandlePageBreakChar()
if (!m_bWasParaEnd && IsTemp)
{
bParaEndAdded = true;
- if (0 >= m_pPaM->GetPoint()->nContent.GetIndex())
+ if (0 >= m_pPaM->GetPoint()->GetContentIndex())
{
- if (SwTextNode* pTextNode = m_pPaM->GetNode().GetTextNode())
+ if (SwTextNode* pTextNode = m_pPaM->GetPointNode().GetTextNode())
{
pTextNode->SetAttr(
*GetDfltAttr(RES_PARATR_NUMRULE));
@@ -3616,6 +3614,7 @@ bool SwWW8ImplReader::ReadChar(tools::Long nPosCp, tools::Long nCpOfs)
switch (nWCharVal)
{
case 0:
+ if (!m_bFuzzing)
{
// Page number
SwPageNumberField aField(
@@ -3623,6 +3622,11 @@ bool SwWW8ImplReader::ReadChar(tools::Long nPosCp, tools::Long nCpOfs)
SwFieldIds::PageNumber )), PG_RANDOM, SVX_NUM_ARABIC);
m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM, SwFormatField(aField));
}
+ else
+ {
+ // extremely slow, so skip for fuzzing, and insert a space instead
+ cInsert = ' ';
+ }
break;
case 0xe:
// if there is only one column word treats a column break like a pagebreak.
@@ -3631,9 +3635,9 @@ bool SwWW8ImplReader::ReadChar(tools::Long nPosCp, tools::Long nCpOfs)
else if (!m_nInTable)
{
// Always insert a txtnode for a column break, e.g. ##
- SwContentNode *pCntNd=m_pPaM->GetContentNode();
+ SwContentNode *pCntNd=m_pPaM->GetPointContentNode();
if (pCntNd!=nullptr && pCntNd->Len()>0) // if par is empty not break is needed
- AppendTextNode(*m_pPaM->GetPoint());
+ FinalizeTextNode(*m_pPaM->GetPoint());
m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM, SvxFormatBreakItem(SvxBreak::ColumnBefore, RES_BREAK));
}
break;
@@ -3709,7 +3713,7 @@ bool SwWW8ImplReader::ReadChar(tools::Long nPosCp, tools::Long nCpOfs)
bool bReadObj = IsInlineEscherHack();
if( bReadObj )
{
- tools::Long nCurPos = m_pStrm->Tell();
+ sal_uInt64 nCurPos = m_pStrm->Tell();
sal_uInt16 nWordCode(0);
if( m_bIsUnicode )
@@ -3730,7 +3734,15 @@ bool SwWW8ImplReader::ReadChar(tools::Long nPosCp, tools::Long nCpOfs)
if (m_bObj)
pResult = ImportOle();
else if (m_bSpec)
- pResult = ImportGraf();
+ {
+ SwFrameFormat* pAsCharFlyFormat =
+ m_rDoc.MakeFrameFormat(OUString(), m_rDoc.GetDfltFrameFormat());
+ SwFormatAnchor aAnchor(RndStdIds::FLY_AS_CHAR);
+ pAsCharFlyFormat->SetFormatAttr(aAnchor);
+ pResult = ImportGraf(nullptr, pAsCharFlyFormat);
+ m_rDoc.DelFrameFormat(pAsCharFlyFormat);
+ }
+
// If we have a bad 0x1 insert a space instead.
if (!pResult)
@@ -3859,20 +3871,20 @@ tools::Long SwWW8ImplReader::ReadTextAttr(WW8_CP& rTextPos, tools::Long nTextEnd
tools::Long nSkipChars = 0;
WW8PLCFManResult aRes;
- OSL_ENSURE(m_pPaM->GetNode().GetTextNode(), "Missing txtnode");
+ OSL_ENSURE(m_pPaM->GetPointNode().GetTextNode(), "Missing txtnode");
bool bStartAttr = m_xPlcxMan->Get(&aRes); // Get Attribute position again
aRes.nCurrentCp = rTextPos; // Current Cp position
bool bNewSection = (aRes.nFlags & MAN_MASK_NEW_SEP) && !m_bIgnoreText;
if ( bNewSection ) // New Section
{
- OSL_ENSURE(m_pPaM->GetNode().GetTextNode(), "Missing txtnode");
+ OSL_ENSURE(m_pPaM->GetPointNode().GetTextNode(), "Missing txtnode");
// Create PageDesc and fill it
m_aSectionManager.CreateSep(rTextPos);
// -> 0xc was a Sectionbreak, but not a Pagebreak;
// Create PageDesc and fill it
m_bPgSecBreak = false;
- OSL_ENSURE(m_pPaM->GetNode().GetTextNode(), "Missing txtnode");
+ OSL_ENSURE(m_pPaM->GetPointNode().GetTextNode(), "Missing txtnode");
}
// New paragraph over Plcx.Fkp.papx
@@ -3975,31 +3987,6 @@ tools::Long SwWW8ImplReader::ReadTextAttr(WW8_CP& rTextPos, tools::Long nTextEnd
return nNext;
}
-//Revised 2012.8.16 for the complex attribute presentation of 0x0D in MS
-bool SwWW8ImplReader::IsParaEndInCPs(sal_Int32 nStart, sal_Int32 nEnd,bool bSdOD) const
-{
- //Revised for performance consideration
- if (nStart == -1 || nEnd == -1 || nEnd < nStart )
- return false;
-
- return std::any_of(m_aEndParaPos.rbegin(), m_aEndParaPos.rend(),
- [=](const WW8_CP& rPos) {
- //Revised 2012.8.16,to the 0x0D,the attribute will have two situations
- //*********within***********exact******
- //*********but also sample with only left and the position of 0x0d is the edge of the right side***********
- return (bSdOD && ((nStart < rPos && nEnd > rPos) || (nStart == nEnd && rPos == nStart))) ||
- (!bSdOD && (nStart < rPos && nEnd >= rPos));
- }
- );
-}
-
-//Clear the para end position recorded in reader intermittently for the least impact on loading performance
-void SwWW8ImplReader::ClearParaEndPosition()
-{
- if ( !m_aEndParaPos.empty() )
- m_aEndParaPos.clear();
-}
-
void SwWW8ImplReader::ReadAttrs(WW8_CP& rTextPos, WW8_CP& rNext, tools::Long nTextEnd, bool& rbStartLine)
{
// Do we have attributes?
@@ -4007,7 +3994,6 @@ void SwWW8ImplReader::ReadAttrs(WW8_CP& rTextPos, WW8_CP& rNext, tools::Long nTe
{
do
{
- m_aCurrAttrCP = rTextPos;
rNext = ReadTextAttr(rTextPos, nTextEnd, rbStartLine);
if (rTextPos == rNext && rTextPos >= nTextEnd)
break;
@@ -4071,7 +4057,7 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
tools::Long nCpOfs = m_xPlcxMan->GetCpOfs(); // Offset for Header/Footer, Footnote
WW8_CP nNext = m_xPlcxMan->Where();
- m_pPreviousNode = nullptr;
+ m_xPreviousNode.reset();
sal_uInt8 nDropLines = 0;
SwCharFormat* pNewSwCharFormat = nullptr;
const SwCharFormat* pFormat = nullptr;
@@ -4091,7 +4077,7 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
while (l < nTextEnd)
{
ReadAttrs( l, nNext, nTextEnd, bStartLine );// Takes SectionBreaks into account, too
- OSL_ENSURE(m_pPaM->GetNode().GetTextNode(), "Missing txtnode");
+ OSL_ENSURE(m_pPaM->GetPointNode().GetTextNode(), "Missing txtnode");
if (m_pPostProcessAttrsInfo != nullptr)
PostProcessAttrs();
@@ -4103,66 +4089,66 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
// If the previous paragraph was a dropcap then do not
// create a new txtnode and join the two paragraphs together
- if (bStartLine && !m_pPreviousNode) // Line end
+ if (bStartLine && !m_xPreviousNode) // Line end
{
bool bSplit = true;
if (m_bCareFirstParaEndInToc)
{
m_bCareFirstParaEndInToc = false;
- if (m_pPaM->End() && m_pPaM->End()->nNode.GetNode().GetTextNode() && m_pPaM->End()->nNode.GetNode().GetTextNode()->Len() == 0)
+ if (m_pPaM->End() && m_pPaM->End()->GetNode().GetTextNode() && m_pPaM->End()->GetNode().GetTextNode()->Len() == 0)
bSplit = false;
}
if (m_bCareLastParaEndInToc)
{
m_bCareLastParaEndInToc = false;
- if (m_pPaM->End() && m_pPaM->End()->nNode.GetNode().GetTextNode() && m_pPaM->End()->nNode.GetNode().GetTextNode()->Len() == 0)
+ if (m_pPaM->End() && m_pPaM->End()->GetNode().GetTextNode() && m_pPaM->End()->GetNode().GetTextNode()->Len() == 0)
bSplit = false;
}
if (bSplit)
{
- // We will record the CP of a paragraph end ('0x0D'), if current loading contents is from main stream;
- if (m_bOnLoadingMain)
- m_aEndParaPos.push_back(l-1);
- AppendTextNode(*m_pPaM->GetPoint());
+ FinalizeTextNode(*m_pPaM->GetPoint());
}
}
- if (m_pPreviousNode && bStartLine)
+ if (SwTextNode* pPreviousNode = (bStartLine && m_xPreviousNode) ? m_xPreviousNode->GetTextNode() : nullptr)
{
- SwTextNode* pEndNd = m_pPaM->GetNode().GetTextNode();
- const sal_Int32 nDropCapLen = m_pPreviousNode->GetText().getLength();
-
- // Need to reset the font size and text position for the dropcap
+ SwTextNode* pEndNd = m_pPaM->GetPointNode().GetTextNode();
+ SAL_WARN_IF(!pEndNd, "sw.ww8", "didn't find textnode for dropcap");
+ if (pEndNd)
{
- SwPaM aTmp(*pEndNd, 0, *pEndNd, nDropCapLen+1);
- m_xCtrlStck->Delete(aTmp);
- }
+ const sal_Int32 nDropCapLen = pPreviousNode->GetText().getLength();
+
+ // Need to reset the font size and text position for the dropcap
+ {
+ SwPaM aTmp(*pEndNd, 0, *pEndNd, nDropCapLen+1);
+ m_xCtrlStck->Delete(aTmp);
+ }
- // Get the default document dropcap which we can use as our template
- const SwFormatDrop* defaultDrop =
- static_cast<const SwFormatDrop*>( GetFormatAttr(RES_PARATR_DROP));
- SwFormatDrop aDrop(*defaultDrop);
+ // Get the default document dropcap which we can use as our template
+ const SwFormatDrop* defaultDrop = GetFormatAttr(RES_PARATR_DROP);
+ SwFormatDrop aDrop(*defaultDrop);
- aDrop.GetLines() = nDropLines;
- aDrop.GetDistance() = nDistance;
- aDrop.GetChars() = writer_cast<sal_uInt8>(nDropCapLen);
- // Word has no concept of a "whole word dropcap"
- aDrop.GetWholeWord() = false;
+ aDrop.GetLines() = nDropLines;
+ aDrop.GetDistance() = nDistance;
+ aDrop.GetChars() = writer_cast<sal_uInt8>(nDropCapLen);
+ // Word has no concept of a "whole word dropcap"
+ aDrop.GetWholeWord() = false;
- if (pFormat)
- aDrop.SetCharFormat(const_cast<SwCharFormat*>(pFormat));
- else if(pNewSwCharFormat)
- aDrop.SetCharFormat(pNewSwCharFormat);
+ if (pFormat)
+ aDrop.SetCharFormat(const_cast<SwCharFormat*>(pFormat));
+ else if(pNewSwCharFormat)
+ aDrop.SetCharFormat(pNewSwCharFormat);
- SwPosition aStart(*pEndNd);
- m_xCtrlStck->NewAttr(aStart, aDrop);
- m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_PARATR_DROP);
- m_pPreviousNode = nullptr;
+ SwPosition aStart(*pEndNd);
+ m_xCtrlStck->NewAttr(aStart, aDrop);
+ m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_PARATR_DROP);
+ }
+ m_xPreviousNode.reset();
}
else if (m_bDropCap)
{
// If we have found a dropcap store the textnode
- m_pPreviousNode = m_pPaM->GetNode().GetTextNode();
+ m_xPreviousNode.reset(new TextNodeListener(m_pPaM->GetPointNode().GetTextNode()));
SprmResult aDCS;
if (m_bVer67)
@@ -4173,7 +4159,7 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
if (aDCS.pSprm && aDCS.nRemainingData >= 1)
nDropLines = (*aDCS.pSprm) >> 3;
else // There is no Drop Cap Specifier hence no dropcap
- m_pPreviousNode = nullptr;
+ m_xPreviousNode.reset();
SprmResult aDistance = m_xPlcxMan->GetPapPLCF()->HasSprm(0x842F);
if (aDistance.pSprm && aDistance.nRemainingData >= 2)
@@ -4184,7 +4170,7 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
const SwFormatCharFormat *pSwFormatCharFormat = nullptr;
if (m_xCurrentItemSet)
- pSwFormatCharFormat = &(ItemGet<SwFormatCharFormat>(*m_xCurrentItemSet, RES_TXTATR_CHARFMT));
+ pSwFormatCharFormat = &(m_xCurrentItemSet->Get(RES_TXTATR_CHARFMT));
if (pSwFormatCharFormat)
pFormat = pSwFormatCharFormat->GetCharFormat();
@@ -4207,9 +4193,9 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
if ((nCrCount++ & 0x40) == 0 && nType == MAN_MAINTEXT && l <= nTextLen)
{
if (nTextLen < WW8_CP_MAX/100)
- m_nProgress = static_cast<sal_uInt16>(l * 100 / nTextLen);
+ m_nProgress = o3tl::narrowing<sal_uInt16>(l * 100 / nTextLen);
else
- m_nProgress = static_cast<sal_uInt16>(l / nTextLen * 100);
+ m_nProgress = o3tl::narrowing<sal_uInt16>(l / nTextLen * 100);
m_xProgress->Update(m_nProgress); // Update
}
}
@@ -4235,7 +4221,7 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
// to insert a text node.
if (!bStartLine && !m_xAnchorStck->empty())
{
- AppendTextNode(*m_pPaM->GetPoint());
+ FinalizeTextNode(*m_pPaM->GetPoint());
}
m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM,
SvxFormatBreakItem(SvxBreak::PageBefore, RES_BREAK));
@@ -4245,10 +4231,10 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
}
}
- m_pPreviousNode = nullptr;
+ m_xPreviousNode.reset();
- if (m_pPaM->GetPoint()->nContent.GetIndex())
- AppendTextNode(*m_pPaM->GetPoint());
+ if (m_pPaM->GetPoint()->GetContentIndex())
+ FinalizeTextNode(*m_pPaM->GetPoint());
if (!m_bInHyperlink)
bJoined = JoinNode(*m_pPaM);
@@ -4260,7 +4246,7 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
}
SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SotStorage* pStorage,
- SvStream* pSt, SwDoc& rD, const OUString& rBaseURL, bool bNewDoc, bool bSkipImages, SwPosition const &rPos)
+ SvStream* pSt, SwDoc& rD, OUString aBaseURL, bool bNewDoc, bool bSkipImages, SwPosition const &rPos)
: m_pDocShell(rD.GetDocShell())
, m_pStg(pStorage)
, m_pStrm(pSt)
@@ -4278,15 +4264,13 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SotStorage* pStorage,
, m_pFlyFormatOfJustInsertedGraphic(nullptr)
, m_pPreviousNumPaM(nullptr)
, m_pPrevNumRule(nullptr)
- , m_aTextNodesHavingFirstLineOfstSet()
- , m_aTextNodesHavingLeftIndentSet()
, m_pCurrentColl(nullptr)
, m_pDfltTextFormatColl(nullptr)
, m_pStandardFormatColl(nullptr)
, m_pDrawModel(nullptr)
, m_pDrawPg(nullptr)
, m_pNumFieldType(nullptr)
- , m_sBaseURL(rBaseURL)
+ , m_sBaseURL(std::move(aBaseURL))
, m_nIniFlags(0)
, m_nIniFlags1(0)
, m_nFieldFlags(0)
@@ -4358,13 +4342,10 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SotStorage* pStorage,
, m_bLoadingTOXCache(false)
, m_nEmbeddedTOXLevel(0)
, m_bLoadingTOXHyperlink(false)
- , m_pPreviousNode(nullptr)
, m_bCareFirstParaEndInToc(false)
, m_bCareLastParaEndInToc(false)
- , m_aTOXEndCps()
- , m_aCurrAttrCP(-1)
- , m_bOnLoadingMain(false)
, m_bNotifyMacroEventRead(false)
+ , m_bFuzzing(comphelper::IsFuzzing())
{
m_pStrm->SetEndian( SvStreamEndian::LITTLE );
m_aApos.push_back(false);
@@ -4405,15 +4386,15 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
{
tools::Rectangle aRect(0, 0, 100, 100); // A dummy, we don't care about the size
SvxMSDffImportData aData(aRect);
- SdrObject* pObject = nullptr;
+ rtl::Reference<SdrObject> pObject;
if (mrReader.m_xMSDffManager->GetShape(0x401, pObject, aData) && !aData.empty())
{
// Only handle shape if it is a background shape
if (aData.begin()->get()->nFlags & ShapeFlag::Background)
{
- SfxItemSet aSet(rFormat.GetDoc()->GetAttrPool(),
- svl::Items<RES_BACKGROUND, RES_BACKGROUND,XATTR_START, XATTR_END>{});
- mrReader.MatchSdrItemsIntoFlySet(pObject, aSet, mso_lineSimple,
+ SfxItemSetFixed<RES_BACKGROUND, RES_BACKGROUND,XATTR_START, XATTR_END>
+ aSet(rFormat.GetDoc()->GetAttrPool());
+ mrReader.MatchSdrItemsIntoFlySet(pObject.get(), aSet, mso_lineSimple,
mso_lineSolid, mso_sptRectangle, aRect);
if ( aSet.HasItem(RES_BACKGROUND) )
rFormat.SetFormatAttr(aSet.Get(RES_BACKGROUND));
@@ -4421,7 +4402,6 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
rFormat.SetFormatAttr(aSet);
}
}
- SdrObject::Free(pObject);
}
wwULSpaceData aULData;
GetPageULData(rSection, aULData);
@@ -4479,11 +4459,7 @@ static void GiveNodePageDesc(SwNodeIndex const &rIdx, const SwFormatPageDesc &rP
}
else
{
- SwPosition aPamStart(rIdx);
- aPamStart.nContent.Assign(
- rIdx.GetNode().GetContentNode(), 0);
- SwPaM aPage(aPamStart);
-
+ SwPaM aPage(rIdx);
rDoc.getIDocumentContentOperations().InsertPoolItem(aPage, rPgDesc);
}
}
@@ -4556,9 +4532,6 @@ void wwSectionManager::InsertSegments()
bool bInsertSection = (aIter != aStart) && aIter->IsContinuous() && bThisAndPreviousAreCompatible;
bool bInsertPageDesc = !bInsertSection;
- // HACK Force new pagedesc if left/right margins change, otherwise e.g. floating tables may be anchored improperly.
- if( aIter->maSep.dxaLeft != aPrev->maSep.dxaLeft || aIter->maSep.dxaRight != aPrev->maSep.dxaRight )
- bInsertPageDesc = true;
bool bProtected = SectionIsProtected(*aIter); // do we really need this ?? I guess I have a different logic in editshell which disables this...
if (bInsertPageDesc)
@@ -4605,7 +4578,7 @@ void wwSectionManager::InsertSegments()
// create a new following page style
SwFormatPageDesc aFollow(SetSwFormatPageDesc(aIter, aStart, bIgnoreCols));
// restore any contents of aIter trashed by SetSwFormatPageDesc
- *aIter = aTmpSection;
+ *aIter = std::move(aTmpSection);
// Handle the section break
UseOnPage eUseOnPage = UseOnPage::Left;
@@ -4628,35 +4601,29 @@ void wwSectionManager::InsertSegments()
{
// Start getting the bounds of this section
SwPaM aSectPaM(*mrReader.m_pPaM, mrReader.m_pPaM);
- SwNodeIndex aAnchor(aSectPaM.GetPoint()->nNode);
+ SwNodeIndex aAnchor(aSectPaM.GetPoint()->GetNode());
if (aNext != aEnd)
{
aAnchor = aNext->maStart;
- aSectPaM.GetPoint()->nNode = aAnchor;
- aSectPaM.GetPoint()->nContent.Assign(
- aNext->maStart.GetNode().GetContentNode(), 0);
+ aSectPaM.GetPoint()->Assign(aAnchor);
aSectPaM.Move(fnMoveBackward);
}
const SwPosition* pPos = aSectPaM.GetPoint();
- SwTextNode const*const pSttNd = pPos->nNode.GetNode().GetTextNode();
+ SwTextNode const*const pSttNd = pPos->GetNode().GetTextNode();
const SwTableNode* pTableNd = pSttNd ? pSttNd->FindTableNode() : nullptr;
if (pTableNd)
{
pTextNd =
- mrReader.m_rDoc.GetNodes().MakeTextNode(aAnchor,
+ mrReader.m_rDoc.GetNodes().MakeTextNode(aAnchor.GetNode(),
mrReader.m_rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_TEXT ));
- aSectPaM.GetPoint()->nNode.Assign(*pTextNd);
- aSectPaM.GetPoint()->nContent.Assign(
- aSectPaM.GetContentNode(), 0);
+ aSectPaM.GetPoint()->Assign(*pTextNd, 0);
}
aSectPaM.SetMark();
- aSectPaM.GetPoint()->nNode = aIter->maStart;
- aSectPaM.GetPoint()->nContent.Assign(
- aSectPaM.GetContentNode(), 0);
+ aSectPaM.GetPoint()->Assign(aIter->maStart);
bool bHasOwnHdFt = false;
/*
@@ -4682,8 +4649,8 @@ void wwSectionManager::InsertSegments()
SwFormatPageDesc aDesc(SetSwFormatPageDesc(aIter, aStart, true));
if (aDesc.GetPageDesc())
{
- sal_uLong nStart = aSectPaM.Start()->nNode.GetIndex();
- sal_uLong nEnd = aSectPaM.End()->nNode.GetIndex();
+ SwNodeOffset nStart = aSectPaM.Start()->GetNodeIndex();
+ SwNodeOffset nEnd = aSectPaM.End()->GetNodeIndex();
for(; nStart <= nEnd; ++nStart)
{
SwNode* pNode = mrReader.m_rDoc.GetNodes()[nStart];
@@ -4725,8 +4692,7 @@ void wwSectionManager::InsertSegments()
if (pTextNd)
{
- SwNodeIndex aIdx(*pTextNd);
- SwPaM aTest(aIdx);
+ SwPaM aTest(*pTextNd);
mrReader.m_rDoc.getIDocumentContentOperations().DelFullPara(aTest);
pTextNd = nullptr;
}
@@ -4738,14 +4704,72 @@ void wwExtraneousParas::delete_all_from_doc()
auto aEnd = m_aTextNodes.rend();
for (auto aI = m_aTextNodes.rbegin(); aI != aEnd; ++aI)
{
- SwTextNode *pTextNode = *aI;
- SwNodeIndex aIdx(*pTextNode);
- SwPaM aTest(aIdx);
+ ExtraTextNodeListener& rListener = const_cast<ExtraTextNodeListener&>(*aI);
+ SwTextNode* pTextNode = rListener.GetTextNode();
+ rListener.StopListening(pTextNode);
+
+ SwPaM aTest(*pTextNode);
m_rDoc.getIDocumentContentOperations().DelFullPara(aTest);
}
m_aTextNodes.clear();
}
+void wwExtraneousParas::insert(SwTextNode *pTextNode)
+{
+ m_aTextNodes.emplace(pTextNode, this);
+}
+
+void wwExtraneousParas::remove_if_present(SwModify* pModify)
+{
+ auto it = std::find_if(m_aTextNodes.begin(), m_aTextNodes.end(),
+ [pModify](const ExtraTextNodeListener& rEntry) { return rEntry.GetTextNode() == pModify; });
+ if (it == m_aTextNodes.end())
+ return;
+ SAL_WARN("sw.ww8", "It is unexpected to drop a para scheduled for removal");
+ m_aTextNodes.erase(it);
+}
+
+TextNodeListener::TextNodeListener(SwTextNode* pTextNode)
+ : m_pTextNode(pTextNode)
+{
+ m_pTextNode->Add(*this);
+}
+
+TextNodeListener::~TextNodeListener()
+{
+ if (!m_pTextNode)
+ return;
+ StopListening(m_pTextNode);
+}
+
+void TextNodeListener::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
+{
+ if (rHint.GetId() != SfxHintId::SwLegacyModify)
+ return;
+ auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
+ // ofz#41398 drop a para scheduled for deletion if something else deletes it
+ // before wwExtraneousParas gets its chance to do so. Not the usual scenario,
+ // indicates an underlying bug.
+ if (pLegacy->GetWhich() == RES_OBJECTDYING)
+ removed(const_cast<SwModify*>(&rModify));
+}
+
+void TextNodeListener::StopListening(SwModify* pTextNode)
+{
+ pTextNode->Remove(*this);
+ m_pTextNode = nullptr;
+}
+
+void TextNodeListener::removed(SwModify* pTextNode)
+{
+ StopListening(pTextNode);
+}
+
+void wwExtraneousParas::ExtraTextNodeListener::removed(SwModify* pTextNode)
+{
+ m_pOwner->remove_if_present(pTextNode);
+}
+
void SwWW8ImplReader::StoreMacroCmds()
{
if (!m_xWwFib->m_lcbCmds)
@@ -4786,27 +4810,36 @@ void SwWW8ImplReader::ReadDocVars()
aDocVarStrings, &aDocVarStringIds, &aDocValueStrings);
if (m_bVer67) return;
- uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
- m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
- uno::Reference<document::XDocumentProperties> xDocProps(
- xDPS->getDocumentProperties());
- OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
- uno::Reference<beans::XPropertyContainer> xUserDefinedProps =
- xDocProps->getUserDefinedProperties();
- OSL_ENSURE(xUserDefinedProps.is(), "UserDefinedProperties is null");
-
- for(size_t i=0; i<aDocVarStrings.size(); i++)
+ uno::Reference< text::XTextFieldsSupplier > xFieldsSupplier(m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<css::lang::XMultiServiceFactory> xTextFactory(m_pDocShell->GetModel(), uno::UNO_QUERY);
+ uno::Reference< container::XNameAccess > xFieldMasterAccess = xFieldsSupplier->getTextFieldMasters();
+ for(size_t i = 0; i < aDocVarStrings.size(); i++)
{
const OUString &rName = aDocVarStrings[i];
uno::Any aValue;
- aValue <<= rName;
- try {
- xUserDefinedProps->addProperty( rName,
- beans::PropertyAttribute::REMOVABLE,
- aValue );
- } catch (const uno::Exception &) {
- // ignore
+ if (aDocValueStrings.size() > i)
+ {
+ OUString value = aDocValueStrings[i];
+ value = value.replaceAll("\r\n", "\n");
+ value = value.replaceAll("\r", "\n");
+ // fdo48097-1.doc is an example of a case needing sanitizeStringSurrogates
+ aValue <<= comphelper::string::sanitizeStringSurrogates(value);
+ }
+
+ uno::Reference< beans::XPropertySet > xMaster;
+ OUString sFieldMasterService("com.sun.star.text.FieldMaster.User." + rName);
+
+ // Find or create Field Master
+ if (xFieldMasterAccess->hasByName(sFieldMasterService))
+ {
+ xMaster.set(xFieldMasterAccess->getByName(sFieldMasterService), uno::UNO_QUERY_THROW);
+ }
+ else
+ {
+ xMaster.set(xTextFactory->createInstance("com.sun.star.text.FieldMaster.User"), uno::UNO_QUERY_THROW);
+ xMaster->setPropertyValue("Name", uno::Any(rName));
}
+ xMaster->setPropertyValue("Content", aValue);
}
}
@@ -4884,7 +4917,7 @@ static void lcl_createTemplateToProjectEntry( const uno::Reference< container::X
if ( nIndex != -1 )
{
OUString templateName = templateNameWithExt.copy( 0, nIndex );
- xPrjNameCache->insertByName( templateName, uno::makeAny( sVBAProjName ) );
+ xPrjNameCache->insertByName( templateName, uno::Any( sVBAProjName ) );
}
}
catch( const uno::Exception& )
@@ -4916,7 +4949,7 @@ void WW8Customizations::Import( SwDocShell* pShell )
try
{
Tcg aTCG;
- tools::Long nCur = mpTableStream->Tell();
+ sal_uInt64 nCur = mpTableStream->Tell();
if (!checkSeek(*mpTableStream, mWw8Fib.m_fcCmds)) // point at tgc record
{
SAL_WARN("sw.ww8", "** Seek to Customization data failed!!!! ");
@@ -4939,7 +4972,7 @@ void WW8Customizations::Import( SwDocShell* pShell )
void SwWW8ImplReader::ReadGlobalTemplateSettings( std::u16string_view sCreatedFrom, const uno::Reference< container::XNameContainer >& xPrjNameCache )
{
- if (utl::ConfigManager::IsFuzzing())
+ if (m_bFuzzing)
return;
SvtPathOptions aPathOpt;
@@ -4952,7 +4985,7 @@ void SwWW8ImplReader::ReadGlobalTemplateSettings( std::u16string_view sCreatedFr
if( xSFA->isFolder( aAddinPath ) )
sGlobalTemplates = xSFA->getFolderContents( aAddinPath, false );
- for ( const auto& rGlobalTemplate : std::as_const(sGlobalTemplates) )
+ for (const auto& rGlobalTemplate : sGlobalTemplates)
{
INetURLObject aObj;
aObj.SetURL( rGlobalTemplate );
@@ -4965,18 +4998,18 @@ void SwWW8ImplReader::ReadGlobalTemplateSettings( std::u16string_view sCreatedFr
if ( !aURL.endsWithIgnoreAsciiCase( ".dot" ) || ( !sCreatedFrom.empty() && sCreatedFrom == aURL ) )
continue; // don't try and read the same document as ourselves
- tools::SvRef<SotStorage> rRoot = new SotStorage( aURL, StreamMode::STD_READWRITE );
+ rtl::Reference<SotStorage> rRoot = new SotStorage(aURL, StreamMode::STD_READWRITE);
BasicProjImportHelper aBasicImporter( *m_pDocShell );
// Import vba via oox filter
aBasicImporter.import( m_pDocShell->GetMedium()->GetInputStream() );
lcl_createTemplateToProjectEntry( xPrjNameCache, aURL, aBasicImporter.getProjectName() );
// Read toolbars & menus
- tools::SvRef<SotStorageStream> refMainStream = rRoot->OpenSotStream( "WordDocument");
+ rtl::Reference<SotStorageStream> refMainStream = rRoot->OpenSotStream("WordDocument");
refMainStream->SetEndian(SvStreamEndian::LITTLE);
WW8Fib aWwFib( *refMainStream, 8 );
- tools::SvRef<SotStorageStream> xTableStream =
- rRoot->OpenSotStream(aWwFib.m_fWhichTableStm ? OUString(SL::a1Table) : OUString(SL::a0Table), StreamMode::STD_READ);
+ rtl::Reference<SotStorageStream> xTableStream =
+ rRoot->OpenSotStream(aWwFib.m_fWhichTableStm ? SL::a1Table : SL::a0Table, StreamMode::STD_READ);
if (xTableStream.is() && ERRCODE_NONE == xTableStream->GetError())
{
@@ -5053,11 +5086,9 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
size_t nPageDescOffset = m_rDoc.GetPageDescCnt();
- SwNodeIndex aSttNdIdx( m_rDoc.GetNodes() );
-
RedlineFlags eMode = RedlineFlags::ShowInsert | RedlineFlags::ShowDelete;
- m_xSprmParser.reset(new wwSprmParser(*m_xWwFib));
+ m_oSprmParser.emplace(*m_xWwFib);
// Set handy helper variables
m_bVer6 = (6 == m_xWwFib->m_nVersion);
@@ -5070,9 +5101,6 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
m_bWWBugNormal = m_xWwFib->m_nProduct == 0xc03d;
- if (!m_bNewDoc)
- aSttNdIdx = m_pPaM->GetPoint()->nNode;
-
m_xProgress.reset(new ImportProgress(m_pDocShell, 0, 100));
// read Font Table
@@ -5168,6 +5196,13 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
if( m_xWDop->nEdn )
aInfo.m_nFootnoteOffset = m_xWDop->nEdn - 1;
m_rDoc.SetEndNoteInfo( aInfo );
+
+ if (m_xSBase->GetEndnoteCount() > 2)
+ {
+ // This compatibility flag only works in easy cases, disable it for anything non-trivial
+ // for now.
+ m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::CONTINUOUS_ENDNOTES, false);
+ }
}
if (m_xWwFib->m_lcbPlcfhdd)
@@ -5184,7 +5219,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
m_rDoc.getIDocumentContentOperations().SplitNode( *pPos, false );
// another split, if insertion position was not at the end of the current paragraph.
- SwTextNode const*const pTextNd = pPos->nNode.GetNode().GetTextNode();
+ SwTextNode const*const pTextNd = pPos->GetNode().GetTextNode();
if ( pTextNd->GetText().getLength() )
{
m_rDoc.getIDocumentContentOperations().SplitNode( *pPos, false );
@@ -5193,7 +5228,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
}
// suppress insertion of tables inside footnotes.
- const sal_uLong nNd = pPos->nNode.GetIndex();
+ const SwNodeOffset nNd = pPos->GetNodeIndex();
m_bReadNoTable = ( nNd < m_rDoc.GetNodes().GetEndOfInserts().GetIndex() &&
m_rDoc.GetNodes().GetEndOfInserts().StartOfSectionIndex() < nNd );
}
@@ -5215,10 +5250,9 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
m_rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_STANDARD,
false);
SwStartNode *pNode =
- m_rDoc.GetNodes().MakeTextSection(aIdx,
+ m_rDoc.GetNodes().MakeTextSection(aIdx.GetNode(),
SwNormalStartNode,pColl);
- m_pPaM->GetPoint()->nNode = pNode->GetIndex()+1;
- m_pPaM->GetPoint()->nContent.Assign(m_pPaM->GetContentNode(),0);
+ m_pPaM->GetPoint()->Assign( pNode->GetIndex()+1 );
aPlc.Get( nStart, nEnd, pDummy );
ReadText(nStart,nEnd-nStart-1,MAN_MAINTEXT);
}
@@ -5243,8 +5277,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
// Create and insert Word vba Globals
uno::Any aGlobs;
- uno::Sequence< uno::Any > aArgs(1);
- aArgs[ 0 ] <<= m_pDocShell->GetModel();
+ uno::Sequence< uno::Any > aArgs{ uno::Any(m_pDocShell->GetModel()) };
try
{
aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( "ooo.vba.word.Globals", aArgs );
@@ -5255,7 +5288,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
}
#if HAVE_FEATURE_SCRIPTING
- if (!utl::ConfigManager::IsFuzzing())
+ if (!m_bFuzzing)
{
BasicManager *pBasicMan = m_pDocShell->GetBasicManager();
if (pBasicMan)
@@ -5275,9 +5308,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
StoreMacroCmds();
}
- m_bOnLoadingMain = true;
ReadText(0, m_xWwFib->m_ccpText, MAN_MAINTEXT);
- m_bOnLoadingMain = false;
}
m_xProgress->Update(m_nProgress); // Update
@@ -5366,8 +5397,8 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
m_xSBase.reset();
m_xWDop.reset();
m_xFonts.reset();
- m_pAtnNames.reset();
- m_xSprmParser.reset();
+ m_xAtnNames.reset();
+ m_oSprmParser.reset();
m_xProgress.reset();
m_pDataStream = nullptr;
@@ -5376,7 +5407,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
DeleteCtrlStack();
DeleteAnchorStack();
DeleteRefStacks();
- m_pLastAnchorPos.reset();//ensure this is deleted before UpdatePageDescs
+ m_oLastAnchorPos.reset();//ensure this is deleted before UpdatePageDescs
// ofz#10994 remove any trailing fly paras before processing redlines
m_xWFlyPara.reset();
// ofz#12660 remove any trailing fly paras before deleting extra paras
@@ -5386,8 +5417,6 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
// are updated
m_aExtraneousParas.delete_all_from_doc();
m_xRedlineStack->closeall(*m_pPaM->GetPoint());
- while (!m_aFrameRedlines.empty())
- m_aFrameRedlines.pop();
// For i120928,achieve the graphics from the special bookmark with is for graphic bullet
{
@@ -5401,7 +5430,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
if ( ppBkmk != pMarkAccess->getBookmarksEnd() &&
IDocumentMarkAccess::GetType(**ppBkmk) == IDocumentMarkAccess::MarkType::BOOKMARK )
{
- SwTextNode* pTextNode = (*ppBkmk)->GetMarkStart().nNode.GetNode().GetTextNode();
+ SwTextNode* pTextNode = (*ppBkmk)->GetMarkStart().GetNode().GetTextNode();
if ( pTextNode )
{
@@ -5412,7 +5441,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
if (pHt->Which() != RES_TXTATR_FLYCNT)
continue;
const sal_Int32 st = pHt->GetStart();
- if (st >= (*ppBkmk)->GetMarkStart().nContent.GetIndex())
+ if (st >= (*ppBkmk)->GetMarkStart().GetContentIndex())
{
SwFrameFormat* pFrameFormat = pHt->GetFlyCnt().GetFrameFormat();
vecFrameFormat.push_back(pFrameFormat);
@@ -5421,7 +5450,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
? &(pNdIdx->GetNodes())
: nullptr;
const SwGrfNode *pGrf = (pNodesArray != nullptr)
- ? dynamic_cast<const SwGrfNode*>((*pNodesArray)[pNdIdx->GetIndex() + 1])
+ ? (*pNodesArray)[pNdIdx->GetIndex() + 1]->GetGrfNode()
: nullptr;
vecBulletGrf.push_back(pGrf);
}
@@ -5471,7 +5500,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
m_xLstManager.reset();
}
- m_pPosAfterTOC.reset();
+ m_oPosAfterTOC.reset();
m_xRedlineStack.reset();
mpCursor.reset();
m_pPaM = nullptr;
@@ -5490,8 +5519,8 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
return ERRCODE_NONE;
}
-ErrCode SwWW8ImplReader::SetSubStreams(tools::SvRef<SotStorageStream> &rTableStream,
- tools::SvRef<SotStorageStream> &rDataStream)
+ErrCode SwWW8ImplReader::SetSubStreams(rtl::Reference<SotStorageStream>& rTableStream,
+ rtl::Reference<SotStorageStream>& rDataStream)
{
ErrCode nErrRet = ERRCODE_NONE;
// 6 stands for "6 OR 7", 7 stands for "ONLY 7"
@@ -5511,7 +5540,7 @@ ErrCode SwWW8ImplReader::SetSubStreams(tools::SvRef<SotStorageStream> &rTableStr
}
rTableStream = m_pStg->OpenSotStream(
- m_xWwFib->m_fWhichTableStm ? OUString(SL::a1Table) : OUString(SL::a0Table),
+ m_xWwFib->m_fWhichTableStm ? SL::a1Table : SL::a0Table,
StreamMode::STD_READ);
m_pTableStream = rTableStream.get();
@@ -5538,12 +5567,10 @@ ErrCode SwWW8ImplReader::SetSubStreams(tools::SvRef<SotStorageStream> &rTableStr
namespace
{
- std::unique_ptr<utl::TempFile> MakeTemp(SvFileStream &rSt)
+ SvStream* MakeTemp(std::optional<utl::TempFileFast>& roTempFile)
{
- std::unique_ptr<utl::TempFile> pT(new utl::TempFile);
- pT->EnableKillingFile();
- rSt.Open(pT->GetFileName(), StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE);
- return pT;
+ roTempFile.emplace();
+ return roTempFile->GetStream(StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE);
}
#define WW_BLOCKSIZE 0x200
@@ -5587,11 +5614,8 @@ namespace
{
OUString aPassw;
- const SfxItemSet* pSet = rMedium.GetItemSet();
- const SfxPoolItem *pPasswordItem;
-
- if(pSet && SfxItemState::SET == pSet->GetItemState(SID_PASSWORD, true, &pPasswordItem))
- aPassw = static_cast<const SfxStringItem *>(pPasswordItem)->GetValue();
+ if (const SfxStringItem* pPasswordItem = rMedium.GetItemSet().GetItemIfSet(SID_PASSWORD))
+ aPassw = pPasswordItem->GetValue();
else
{
try
@@ -5621,7 +5645,7 @@ namespace
uno::Sequence< beans::NamedValue > InitXorWord95Codec( ::msfilter::MSCodec_XorWord95& rCodec, SfxMedium& rMedium, WW8Fib const * pWwFib )
{
uno::Sequence< beans::NamedValue > aEncryptionData;
- const SfxUnoAnyItem* pEncryptionData = SfxItemSet::GetItem<SfxUnoAnyItem>(rMedium.GetItemSet(), SID_ENCRYPTIONDATA, false);
+ const SfxUnoAnyItem* pEncryptionData = rMedium.GetItemSet().GetItem(SID_ENCRYPTIONDATA, false);
if ( pEncryptionData && ( pEncryptionData->GetValue() >>= aEncryptionData ) && !rCodec.InitCodec( aEncryptionData ) )
aEncryptionData.realloc( 0 );
@@ -5651,8 +5675,10 @@ namespace
rtlRandomPool aRandomPool = rtl_random_createPool();
sal_uInt8 pDocId[ 16 ];
- rtl_random_getBytes( aRandomPool, pDocId, 16 );
-
+ if (rtl_random_getBytes(aRandomPool, pDocId, 16) != rtl_Random_E_None)
+ {
+ throw uno::RuntimeException("rtl_random_getBytes failed");
+ }
rtl_random_destroyPool( aRandomPool );
sal_uInt16 pStd97Pass[16] = {};
@@ -5674,7 +5700,7 @@ namespace
uno::Sequence< beans::NamedValue > Init97Codec(msfilter::MSCodec97& rCodec, sal_uInt8 const pDocId[16], SfxMedium& rMedium)
{
uno::Sequence< beans::NamedValue > aEncryptionData;
- const SfxUnoAnyItem* pEncryptionData = SfxItemSet::GetItem<SfxUnoAnyItem>(rMedium.GetItemSet(), SID_ENCRYPTIONDATA, false);
+ const SfxUnoAnyItem* pEncryptionData = rMedium.GetItemSet().GetItem(SID_ENCRYPTIONDATA, false);
if ( pEncryptionData && ( pEncryptionData->GetValue() >>= aEncryptionData ) && !rCodec.InitCodec( aEncryptionData ) )
aEncryptionData.realloc( 0 );
@@ -5766,17 +5792,17 @@ ErrCode SwWW8ImplReader::LoadThroughDecryption(WW8Glossary *pGloss)
if (m_xWwFib->m_nFibError)
nErrRet = ERR_SWG_READ_ERROR;
- tools::SvRef<SotStorageStream> xTableStream, xDataStream;
+ rtl::Reference<SotStorageStream> xTableStream, xDataStream;
if (!nErrRet)
nErrRet = SetSubStreams(xTableStream, xDataStream);
- std::unique_ptr<utl::TempFile> pTempMain;
- std::unique_ptr<utl::TempFile> pTempTable;
- std::unique_ptr<utl::TempFile> pTempData;
- SvFileStream aDecryptMain;
- SvFileStream aDecryptTable;
- SvFileStream aDecryptData;
+ std::optional<utl::TempFileFast> oTempMain;
+ std::optional<utl::TempFileFast> oTempTable;
+ std::optional<utl::TempFileFast> oTempData;
+ SvStream* pDecryptMain = nullptr;
+ SvStream* pDecryptTable = nullptr;
+ SvStream* pDecryptData = nullptr;
bool bDecrypt = false;
enum {RC4CryptoAPI, RC4, XOR, Other} eAlgo = Other;
@@ -5826,38 +5852,38 @@ ErrCode SwWW8ImplReader::LoadThroughDecryption(WW8Glossary *pGloss)
if (aEncryptionData.hasElements() && aCtx.VerifyKey(m_xWwFib->m_nKey, m_xWwFib->m_nHash))
{
nErrRet = ERRCODE_NONE;
- pTempMain = MakeTemp(aDecryptMain);
+ pDecryptMain = MakeTemp(oTempMain);
m_pStrm->Seek(0);
size_t nUnencryptedHdr =
(8 == m_xWwFib->m_nVersion) ? 0x44 : 0x34;
std::unique_ptr<sal_uInt8[]> pIn(new sal_uInt8[nUnencryptedHdr]);
nUnencryptedHdr = m_pStrm->ReadBytes(pIn.get(), nUnencryptedHdr);
- aDecryptMain.WriteBytes(pIn.get(), nUnencryptedHdr);
+ pDecryptMain->WriteBytes(pIn.get(), nUnencryptedHdr);
pIn.reset();
- DecryptXOR(aCtx, *m_pStrm, aDecryptMain);
+ DecryptXOR(aCtx, *m_pStrm, *pDecryptMain);
if (!m_pTableStream || m_pTableStream == m_pStrm)
- m_pTableStream = &aDecryptMain;
+ m_pTableStream = pDecryptMain;
else
{
- pTempTable = MakeTemp(aDecryptTable);
- DecryptXOR(aCtx, *m_pTableStream, aDecryptTable);
- m_pTableStream = &aDecryptTable;
+ pDecryptTable = MakeTemp(oTempTable);
+ DecryptXOR(aCtx, *m_pTableStream, *pDecryptTable);
+ m_pTableStream = pDecryptTable;
}
if (!m_pDataStream || m_pDataStream == m_pStrm)
- m_pDataStream = &aDecryptMain;
+ m_pDataStream = pDecryptMain;
else
{
- pTempData = MakeTemp(aDecryptData);
- DecryptXOR(aCtx, *m_pDataStream, aDecryptData);
- m_pDataStream = &aDecryptData;
+ pDecryptData = MakeTemp(oTempData);
+ DecryptXOR(aCtx, *m_pDataStream, *pDecryptData);
+ m_pDataStream = pDecryptData;
}
- pMedium->GetItemSet()->ClearItem( SID_PASSWORD );
- pMedium->GetItemSet()->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) ) );
+ pMedium->GetItemSet().ClearItem( SID_PASSWORD );
+ pMedium->GetItemSet().Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::Any( aEncryptionData ) ) );
}
}
break;
@@ -5894,34 +5920,34 @@ ErrCode SwWW8ImplReader::LoadThroughDecryption(WW8Glossary *pGloss)
{
nErrRet = ERRCODE_NONE;
- pTempMain = MakeTemp(aDecryptMain);
+ pDecryptMain = MakeTemp(oTempMain);
m_pStrm->Seek(0);
std::size_t nUnencryptedHdr = 0x44;
std::unique_ptr<sal_uInt8[]> pIn(new sal_uInt8[nUnencryptedHdr]);
nUnencryptedHdr = m_pStrm->ReadBytes(pIn.get(), nUnencryptedHdr);
- DecryptRC4(*xCtx, *m_pStrm, aDecryptMain);
+ DecryptRC4(*xCtx, *m_pStrm, *pDecryptMain);
- aDecryptMain.Seek(0);
- aDecryptMain.WriteBytes(pIn.get(), nUnencryptedHdr);
+ pDecryptMain->Seek(0);
+ pDecryptMain->WriteBytes(pIn.get(), nUnencryptedHdr);
pIn.reset();
- pTempTable = MakeTemp(aDecryptTable);
- DecryptRC4(*xCtx, *m_pTableStream, aDecryptTable);
- m_pTableStream = &aDecryptTable;
+ pDecryptTable = MakeTemp(oTempTable);
+ DecryptRC4(*xCtx, *m_pTableStream, *pDecryptTable);
+ m_pTableStream = pDecryptTable;
if (!m_pDataStream || m_pDataStream == m_pStrm)
- m_pDataStream = &aDecryptMain;
+ m_pDataStream = pDecryptMain;
else
{
- pTempData = MakeTemp(aDecryptData);
- DecryptRC4(*xCtx, *m_pDataStream, aDecryptData);
- m_pDataStream = &aDecryptData;
+ pDecryptData = MakeTemp(oTempData);
+ DecryptRC4(*xCtx, *m_pDataStream, *pDecryptData);
+ m_pDataStream = pDecryptData;
}
- pMedium->GetItemSet()->ClearItem( SID_PASSWORD );
- pMedium->GetItemSet()->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) ) );
+ pMedium->GetItemSet().ClearItem( SID_PASSWORD );
+ pMedium->GetItemSet().Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::Any( aEncryptionData ) ) );
}
}
break;
@@ -5930,7 +5956,7 @@ ErrCode SwWW8ImplReader::LoadThroughDecryption(WW8Glossary *pGloss)
if (nErrRet == ERRCODE_NONE)
{
- m_pStrm = &aDecryptMain;
+ m_pStrm = pDecryptMain;
m_xWwFib = std::make_shared<WW8Fib>(*m_pStrm, m_nWantedVersion);
if (m_xWwFib->m_nFibError)
@@ -5941,9 +5967,9 @@ ErrCode SwWW8ImplReader::LoadThroughDecryption(WW8Glossary *pGloss)
if (!nErrRet)
nErrRet = CoreLoad(pGloss);
- pTempMain.reset();
- pTempTable.reset();
- pTempData.reset();
+ oTempMain.reset();
+ oTempTable.reset();
+ oTempData.reset();
m_xWwFib.reset();
return nErrRet;
@@ -5975,14 +6001,60 @@ void SwWW8ImplReader::SetOutlineStyles()
// iteration
std::vector<SwWW8StyInf*> aWW8BuiltInHeadingStyles;
{
+ sal_uInt16 nStyle = 0;
std::map<const SwNumRule*, int> aWW8ListStyleCounts;
- for (SwWW8StyInf & rSI : m_vColl)
- {
- if (!rSI.IsWW8BuiltInHeadingStyle() || !rSI.HasWW8OutlineLevel())
+ std::map<const SwNumRule*, bool> aPreventUseAsChapterNumbering;
+ for (SwWW8StyInf& rSI : m_vColl)
+ {
+ // Copy inherited numbering info since LO drops inheritance after ChapterNumbering
+ // and only applies listLevel via style with the selected ChapterNumbering LFO.
+ bool bReRegister = false;
+ if (rSI.m_nBase && rSI.m_nBase < m_vColl.size()
+ && m_vColl[rSI.m_nBase].HasWW8OutlineLevel())
+ {
+ if (rSI.m_nLFOIndex == USHRT_MAX)
+ {
+ rSI.m_nLFOIndex = m_vColl[rSI.m_nBase].m_nLFOIndex;
+
+ // When ANYTHING is wrong or strange, prohibit eligibility for ChapterNumbering.
+ // A style never inherits numbering from Chapter Numbering.
+ if (rSI.m_nLFOIndex != USHRT_MAX)
+ {
+ const SwNumRule* pNumRule = m_vColl[rSI.m_nBase].m_pOutlineNumrule;
+ if (pNumRule)
+ aPreventUseAsChapterNumbering[pNumRule] = true;
+ }
+ }
+ if (rSI.m_nListLevel == MAXLEVEL)
+ rSI.m_nListLevel = m_vColl[rSI.m_nBase].m_nListLevel;
+ if (rSI.mnWW8OutlineLevel == MAXLEVEL)
+ rSI.mnWW8OutlineLevel = m_vColl[rSI.m_nBase].mnWW8OutlineLevel;
+ bReRegister = true;
+ }
+
+ // Undefined listLevel is treated as the first level with valid numbering rule.
+ if (rSI.m_nLFOIndex < USHRT_MAX && rSI.m_nListLevel == MAXLEVEL)
+ {
+ rSI.m_nListLevel = 0;
+ bReRegister = true;
+ }
+
+ if (bReRegister)
+ RegisterNumFormatOnStyle(nStyle);
+
+ ++nStyle; // increment before the first "continue";
+
+ if (!rSI.m_bColl || !rSI.IsWW8BuiltInHeadingStyle() || !rSI.HasWW8OutlineLevel())
{
continue;
}
+ // When ANYTHING is wrong or strange, prohibit eligibility for ChapterNumbering.
+ if (rSI.IsOutlineNumbered() && rSI.m_nListLevel != rSI.mnWW8OutlineLevel)
+ {
+ aPreventUseAsChapterNumbering[rSI.m_pOutlineNumrule] = true;
+ }
+
aWW8BuiltInHeadingStyles.push_back(&rSI);
const SwNumRule* pWW8ListStyle = rSI.GetOutlineNumrule();
@@ -6004,6 +6076,9 @@ void SwWW8ImplReader::SetOutlineStyles()
int nCurrentMaxCount = 0;
for (const auto& rEntry : aWW8ListStyleCounts)
{
+ if (aPreventUseAsChapterNumbering[rEntry.first])
+ continue;
+
if (rEntry.second > nCurrentMaxCount)
{
nCurrentMaxCount = rEntry.second;
@@ -6023,12 +6098,19 @@ void SwWW8ImplReader::SetOutlineStyles()
// assigned directly and
// its default outline level is applied.
SwNumRule aOutlineRule(*m_rDoc.GetOutlineNumRule());
- bool bAppliedChangedOutlineStyle = false;
- for (const SwWW8StyInf* pStyleInf : aWW8BuiltInHeadingStyles)
+ if (m_pChosenWW8OutlineStyle)
{
- if (!pStyleInf->m_bColl) //Character Style
- continue;
+ for (int i = 0; i < WW8ListManager::nMaxLevel; ++i)
+ {
+ // Don't clobber existing outline levels.
+ const sal_uInt16 nLevel = 1 << i;
+ if (!(nOutlineStyleListLevelWithAssignment & nLevel))
+ aOutlineRule.Set(i, m_pChosenWW8OutlineStyle->Get(i));
+ }
+ }
+ for (const SwWW8StyInf* pStyleInf : aWW8BuiltInHeadingStyles)
+ {
const sal_uInt16 nOutlineStyleListLevelOfWW8BuiltInHeadingStyle
= 1 << pStyleInf->mnWW8OutlineLevel;
if (nOutlineStyleListLevelOfWW8BuiltInHeadingStyle
@@ -6037,17 +6119,6 @@ void SwWW8ImplReader::SetOutlineStyles()
continue;
}
- if (m_pChosenWW8OutlineStyle != nullptr
- && pStyleInf->mnWW8OutlineLevel < WW8ListManager::nMaxLevel
- && pStyleInf->mnWW8OutlineLevel == pStyleInf->m_nListLevel)
- {
- // LibreOffice's Chapter Numbering only works when outlineLevel == listLevel
- const SwNumFormat& rRule
- = m_pChosenWW8OutlineStyle->Get(pStyleInf->mnWW8OutlineLevel);
- aOutlineRule.Set(pStyleInf->mnWW8OutlineLevel, rRule);
- bAppliedChangedOutlineStyle = true;
- }
-
// in case that there are more styles on this level ignore them
nOutlineStyleListLevelWithAssignment
|= nOutlineStyleListLevelOfWW8BuiltInHeadingStyle;
@@ -6082,7 +6153,7 @@ void SwWW8ImplReader::SetOutlineStyles()
}
}
- if (bAppliedChangedOutlineStyle)
+ if (m_pChosenWW8OutlineStyle)
{
m_rDoc.SetOutlineNumRule(aOutlineRule);
}
@@ -6090,37 +6161,39 @@ void SwWW8ImplReader::SetOutlineStyles()
const OUString* SwWW8ImplReader::GetAnnotationAuthor(sal_uInt16 nIdx)
{
- if (!m_pAtnNames && m_xWwFib->m_lcbGrpStAtnOwners)
+ if (!m_xAtnNames && m_xWwFib->m_lcbGrpStAtnOwners)
{
// Determine authors: can be found in the TableStream
- m_pAtnNames.reset(new std::vector<OUString>);
+ m_xAtnNames.emplace();
SvStream& rStrm = *m_pTableStream;
- tools::Long nOldPos = rStrm.Tell();
- rStrm.Seek( m_xWwFib->m_fcGrpStAtnOwners );
-
- tools::Long nRead = 0, nCount = m_xWwFib->m_lcbGrpStAtnOwners;
- while (nRead < nCount && rStrm.good())
+ auto nOldPos = rStrm.Tell();
+ bool bValidPos = checkSeek(rStrm, m_xWwFib->m_fcGrpStAtnOwners);
+ if (bValidPos)
{
- if( m_bVer67 )
- {
- m_pAtnNames->push_back(read_uInt8_PascalString(rStrm,
- RTL_TEXTENCODING_MS_1252));
- nRead += m_pAtnNames->rbegin()->getLength() + 1; // Length + sal_uInt8 count
- }
- else
+ tools::Long nRead = 0, nCount = m_xWwFib->m_lcbGrpStAtnOwners;
+ while (nRead < nCount && rStrm.good())
{
- m_pAtnNames->push_back(read_uInt16_PascalString(rStrm));
- // Unicode: double the length + sal_uInt16 count
- nRead += (m_pAtnNames->rbegin()->getLength() + 1)*2;
+ if( m_bVer67 )
+ {
+ m_xAtnNames->push_back(read_uInt8_PascalString(rStrm,
+ RTL_TEXTENCODING_MS_1252));
+ nRead += m_xAtnNames->rbegin()->getLength() + 1; // Length + sal_uInt8 count
+ }
+ else
+ {
+ m_xAtnNames->push_back(read_uInt16_PascalString(rStrm));
+ // Unicode: double the length + sal_uInt16 count
+ nRead += (m_xAtnNames->rbegin()->getLength() + 1)*2;
+ }
}
}
rStrm.Seek( nOldPos );
}
const OUString *pRet = nullptr;
- if (m_pAtnNames && nIdx < m_pAtnNames->size())
- pRet = &((*m_pAtnNames)[nIdx]);
+ if (m_xAtnNames && nIdx < m_xAtnNames->size())
+ pRet = &((*m_xAtnNames)[nIdx]);
return pRet;
}
@@ -6166,7 +6239,7 @@ void SwWW8ImplReader::GetSmartTagInfo(SwFltRDFMark& rMark)
if (!aKey.isEmpty() && !aValue.isEmpty())
aAttributes.emplace_back(aKey, aValue);
}
- rMark.SetAttributes(aAttributes);
+ rMark.SetAttributes(std::move(aAttributes));
}
ErrCode SwWW8ImplReader::LoadDoc(WW8Glossary *pGloss)
@@ -6219,10 +6292,10 @@ ErrCode SwWW8ImplReader::LoadDoc(WW8Glossary *pGloss)
// Test for own 97 fake!
if (m_pStg && 0xa5ec == nMagic)
{
- sal_uLong nCurPos = m_pStrm->Tell();
- if (m_pStrm->Seek(nCurPos + 22))
+ sal_uInt64 nCurPos = m_pStrm->Tell();
+ if (checkSeek(*m_pStrm, nCurPos + 2))
{
- sal_uInt32 nfcMin;
+ sal_uInt32 nfcMin(0);
m_pStrm->ReadUInt32( nfcMin );
if (0x300 != nfcMin)
nErrRet = ERR_WW6_NO_WW6_FILE_ERR;
@@ -6273,13 +6346,13 @@ bool TestImportDOC(SvStream &rStream, const OUString &rFltName)
FontCacheGuard aFontCacheGuard;
std::unique_ptr<Reader> xReader(ImportDOC());
- tools::SvRef<SotStorage> xStorage;
+ rtl::Reference<SotStorage> xStorage;
xReader->m_pStream = &rStream;
if (rFltName != "WW6")
{
try
{
- xStorage = tools::SvRef<SotStorage>(new SotStorage(rStream));
+ xStorage.set(new SotStorage(rStream));
if (xStorage->GetError())
return false;
}
@@ -6297,9 +6370,7 @@ bool TestImportDOC(SvStream &rStream, const OUString &rFltName)
xDocSh->DoInitNew();
SwDoc *pD = static_cast<SwDocShell*>((&xDocSh))->GetDoc();
- SwNodeIndex aIdx(pD->GetNodes().GetEndOfContent(), -1);
- SwPaM aPaM(aIdx);
- aPaM.GetPoint()->nContent.Assign(aIdx.GetNode().GetContentNode(), 0);
+ SwPaM aPaM(pD->GetNodes().GetEndOfContent(), SwNodeOffset(-1));
pD->SetInReading(true);
bool bRet = xReader->Read(*pD, OUString(), aPaM, OUString()) == ERRCODE_NONE;
pD->SetInReading(false);
@@ -6322,7 +6393,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportWW2(SvStream &rStream)
return TestImportDOC(rStream, "WW6");
}
-ErrCode WW8Reader::OpenMainStream( tools::SvRef<SotStorageStream>& rRef, sal_uInt16& rBuffSize )
+ErrCode WW8Reader::OpenMainStream(rtl::Reference<SotStorageStream>& rRef, sal_uInt16& rBuffSize)
{
ErrCode nRet = ERR_SWG_READ_ERROR;
OSL_ENSURE(m_pStorage, "Where is my Storage?");
@@ -6343,22 +6414,22 @@ ErrCode WW8Reader::OpenMainStream( tools::SvRef<SotStorageStream>& rRef, sal_uIn
return nRet;
}
-static void lcl_getListOfStreams(SotStorage * pStorage, comphelper::SequenceAsHashMap& aStreamsData, const OUString& sPrefix)
+static void lcl_getListOfStreams(SotStorage * pStorage, comphelper::SequenceAsHashMap& aStreamsData, std::u16string_view sPrefix)
{
SvStorageInfoList aElements;
pStorage->FillInfoList(&aElements);
for (const auto & aElement : aElements)
{
- OUString sStreamFullName = sPrefix.getLength() ? sPrefix + "/" + aElement.GetName() : aElement.GetName();
+ OUString sStreamFullName = sPrefix.size() ? OUString::Concat(sPrefix) + "/" + aElement.GetName() : aElement.GetName();
if (aElement.IsStorage())
{
- tools::SvRef<SotStorage> xSubStorage = pStorage->OpenSotStorage(aElement.GetName(), StreamMode::STD_READ | StreamMode::SHARE_DENYALL);
+ rtl::Reference<SotStorage> xSubStorage = pStorage->OpenSotStorage(aElement.GetName(), StreamMode::STD_READ | StreamMode::SHARE_DENYALL);
lcl_getListOfStreams(xSubStorage.get(), aStreamsData, sStreamFullName);
}
else
{
// Read stream
- tools::SvRef<SotStorageStream> rStream = pStorage->OpenSotStream(aElement.GetName(), StreamMode::READ | StreamMode::SHARE_DENYALL);
+ rtl::Reference<SotStorageStream> rStream = pStorage->OpenSotStream(aElement.GetName(), StreamMode::READ | StreamMode::SHARE_DENYALL);
if (rStream.is())
{
sal_Int32 nStreamSize = rStream->GetSize();
@@ -6388,7 +6459,7 @@ ErrCode WW8Reader::DecryptDRMPackage()
}
comphelper::SequenceAsHashMap aStreamsData;
- lcl_getListOfStreams(m_pStorage.get(), aStreamsData, "");
+ lcl_getListOfStreams(m_pStorage.get(), aStreamsData, u"");
try {
uno::Sequence<beans::NamedValue> aStreams = aStreamsData.getAsConstNamedValueList();
@@ -6398,7 +6469,7 @@ ErrCode WW8Reader::DecryptDRMPackage()
return ERRCODE_IO_ACCESSDENIED;
}
- tools::SvRef<SotStorageStream> rContentStream = m_pStorage->OpenSotStream("\011DRMContent", StreamMode::READ | StreamMode::SHARE_DENYALL);
+ rtl::Reference<SotStorageStream> rContentStream = m_pStorage->OpenSotStream("\011DRMContent", StreamMode::READ | StreamMode::SHARE_DENYALL);
if (!rContentStream.is())
{
return ERRCODE_IO_NOTEXISTS;
@@ -6422,7 +6493,7 @@ ErrCode WW8Reader::DecryptDRMPackage()
// Set the media descriptor data
uno::Sequence<beans::NamedValue> aEncryptionData = xPackageEncryption->createEncryptionData("");
- m_pMedium->GetItemSet()->Put(SfxUnoAnyItem(SID_ENCRYPTIONDATA, uno::makeAny(aEncryptionData)));
+ m_pMedium->GetItemSet().Put(SfxUnoAnyItem(SID_ENCRYPTIONDATA, uno::Any(aEncryptionData)));
}
catch (const std::exception&)
{
@@ -6432,12 +6503,12 @@ ErrCode WW8Reader::DecryptDRMPackage()
return ERRCODE_NONE;
}
-ErrCode WW8Reader::Read(SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, const OUString & /* FileName */)
+ErrCodeMsg WW8Reader::Read(SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, const OUString & /* FileName */)
{
sal_uInt16 nOldBuffSize = 32768;
bool bNew = !m_bInsertMode; // New Doc (no inserting)
- tools::SvRef<SotStorageStream> refStrm; // So that no one else can steal the Stream
+ rtl::Reference<SotStorageStream> refStrm; // So that no one else can steal the Stream
SvStream* pIn = m_pStream;
ErrCode nRet = ERRCODE_NONE;
@@ -6464,7 +6535,7 @@ ErrCode WW8Reader::Read(SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, cons
if( m_pStorage.is() )
{
// Check if we have special encrypted content
- tools::SvRef<SotStorageStream> rRef = m_pStorage->OpenSotStream("\006DataSpaces/DataSpaceInfo/\011DRMDataSpace", StreamMode::READ | StreamMode::SHARE_DENYALL);
+ rtl::Reference<SotStorageStream> rRef = m_pStorage->OpenSotStream("\006DataSpaces/DataSpaceInfo/\011DRMDataSpace", StreamMode::READ | StreamMode::SHARE_DENYALL);
if (rRef.is())
{
nRet = DecryptDRMPackage();
@@ -6528,7 +6599,7 @@ bool WW8Reader::ReadGlossaries(SwTextBlocks& rBlocks, bool bSaveRelFiles) const
WW8Reader *pThis = const_cast<WW8Reader *>(this);
sal_uInt16 nOldBuffSize = 32768;
- tools::SvRef<SotStorageStream> refStrm;
+ rtl::Reference<SotStorageStream> refStrm;
if (!pThis->OpenMainStream(refStrm, nOldBuffSize))
{
WW8Glossary aGloss( refStrm, 8, m_pStorage.get() );
@@ -6538,18 +6609,18 @@ bool WW8Reader::ReadGlossaries(SwTextBlocks& rBlocks, bool bSaveRelFiles) const
}
bool SwMSDffManager::GetOLEStorageName(sal_uInt32 nOLEId, OUString& rStorageName,
- tools::SvRef<SotStorage>& rSrcStorage, uno::Reference < embed::XStorage >& rDestStorage) const
+ rtl::Reference<SotStorage>& rSrcStorage, uno::Reference < embed::XStorage >& rDestStorage) const
{
bool bRet = false;
sal_Int32 nPictureId = 0;
- if (rReader.m_pStg)
+ if (m_rReader.m_pStg)
{
// Via the TextBox-PLCF we get the right char Start-End positions
// We should then find the EmbeddedField and the corresponding Sprms
// in that Area.
// We only need the Sprm for the Picture Id.
- tools::Long nOldPos = rReader.m_pStrm->Tell();
+ sal_uInt64 nOldPos = m_rReader.m_pStrm->Tell();
{
// #i32596# - consider return value of method
// <rReader.GetTxbxTextSttEndCp(..)>. If it returns false, method
@@ -6557,17 +6628,17 @@ bool SwMSDffManager::GetOLEStorageName(sal_uInt32 nOLEId, OUString& rStorageName
// Note: Ask MM for initialization of <nStartCp> and <nEndCp>.
// Note: Ask MM about assertions in method <rReader.GetTxbxTextSttEndCp(..)>.
WW8_CP nStartCp, nEndCp;
- if ( rReader.m_bDrawCpOValid && rReader.GetTxbxTextSttEndCp(nStartCp, nEndCp,
- static_cast<sal_uInt16>((nOLEId >> 16) & 0xFFFF),
- static_cast<sal_uInt16>(nOLEId & 0xFFFF)) )
+ if ( m_rReader.m_bDrawCpOValid && m_rReader.GetTxbxTextSttEndCp(nStartCp, nEndCp,
+ o3tl::narrowing<sal_uInt16>((nOLEId >> 16) & 0xFFFF),
+ o3tl::narrowing<sal_uInt16>(nOLEId & 0xFFFF)) )
{
WW8PLCFxSaveAll aSave;
- rReader.m_xPlcxMan->SaveAllPLCFx( aSave );
+ m_rReader.m_xPlcxMan->SaveAllPLCFx( aSave );
- nStartCp += rReader.m_nDrawCpO;
- nEndCp += rReader.m_nDrawCpO;
- WW8PLCFx_Cp_FKP* pChp = rReader.m_xPlcxMan->GetChpPLCF();
- wwSprmParser aSprmParser(*rReader.m_xWwFib);
+ nStartCp += m_rReader.m_nDrawCpO;
+ nEndCp += m_rReader.m_nDrawCpO;
+ WW8PLCFx_Cp_FKP* pChp = m_rReader.m_xPlcxMan->GetChpPLCF();
+ wwSprmParser aSprmParser(*m_rReader.m_xWwFib);
while (nStartCp <= nEndCp && !nPictureId)
{
if (!pChp->SeekPos( nStartCp))
@@ -6601,21 +6672,21 @@ bool SwMSDffManager::GetOLEStorageName(sal_uInt32 nOLEId, OUString& rStorageName
nStartCp = aDesc.nEndPos;
}
- rReader.m_xPlcxMan->RestoreAllPLCFx( aSave );
+ m_rReader.m_xPlcxMan->RestoreAllPLCFx( aSave );
}
}
- rReader.m_pStrm->Seek( nOldPos );
+ m_rReader.m_pStrm->Seek( nOldPos );
}
if( bRet )
{
rStorageName = "_";
rStorageName += OUString::number(nPictureId);
- rSrcStorage = rReader.m_pStg->OpenSotStorage(SL::aObjectPool);
- if (!rReader.m_pDocShell)
+ rSrcStorage = m_rReader.m_pStg->OpenSotStorage(SL::aObjectPool);
+ if (!m_rReader.m_pDocShell)
bRet=false;
else
- rDestStorage = rReader.m_pDocShell->GetStorage();
+ rDestStorage = m_rReader.m_pDocShell->GetStorage();
}
return bRet;
}
@@ -6658,15 +6729,13 @@ bool SwWW8ImplReader::InEqualApo(int nLvl) const
namespace sw::hack
{
Position::Position(const SwPosition &rPos)
- : maPtNode(rPos.nNode), mnPtContent(rPos.nContent.GetIndex())
+ : maPtNode(rPos.GetNode()), mnPtContent(rPos.GetContentIndex())
{
}
Position::operator SwPosition() const
{
- SwPosition aRet(maPtNode);
- aRet.nContent.Assign(maPtNode.GetNode().GetContentNode(), mnPtContent);
- return aRet;
+ return SwPosition(maPtNode, maPtNode.GetNode().GetContentNode(), mnPtContent);
}
}
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 575841ffbeee..6f0c260f1966 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -24,17 +24,19 @@
#include <filter/msfilter/msdffimp.hxx>
#include <filter/msfilter/util.hxx>
#include <editeng/frmdir.hxx>
+#include <svl/zforlist.hxx>
#include <fltshell.hxx>
#include <svx/svdobj.hxx>
+#include <utility>
#include <vector>
#include <stack>
#include <string_view>
#include <deque>
#include <map>
-#include <utility>
#include <memory>
+#include <optional>
#include "ww8struc.hxx"
#include "ww8scan.hxx"
@@ -52,7 +54,6 @@
#include <fmtsrnd.hxx>
#include <ndtxt.hxx>
#include <editeng/lrspitem.hxx>
-#include <o3tl/deleter.hxx>
#include <o3tl/sorted_vector.hxx>
#include <oox/ole/olehelper.hxx>
@@ -108,6 +109,7 @@ class GDIMetaFile;
struct ESelection;
class SfxItemSet;
class OutlinerParaObject;
+enum class SwLineBreakClear;
namespace com::sun::star{
namespace beans{ class XPropertySet;}
@@ -134,8 +136,8 @@ struct WW8LFOInfo;
class WW8Reader : public StgReader
{
std::shared_ptr<SvStream> mDecodedStream;
- virtual ErrCode Read(SwDoc &, const OUString& rBaseURL, SwPaM &, const OUString &) override;
- ErrCode OpenMainStream( tools::SvRef<SotStorageStream>& rRef, sal_uInt16& rBuffSize );
+ virtual ErrCodeMsg Read(SwDoc &, const OUString& rBaseURL, SwPaM &, const OUString &) override;
+ ErrCode OpenMainStream(rtl::Reference<SotStorageStream>& rRef, sal_uInt16& rBuffSize);
ErrCode DecryptDRMPackage();
public:
WW8Reader() {}
@@ -158,20 +160,20 @@ public:
SwNumRule* GetNumRuleForActivation(sal_uInt16 nLFOPosition, const sal_uInt8 nLevel,
std::vector<sal_uInt8> &rParaSprms, SwTextNode *pNode=nullptr);
SwNumRule* CreateNextRule(bool bSimple);
- ~WW8ListManager() COVERITY_NOEXCEPT_FALSE;
+ ~WW8ListManager();
SwNumRule* GetNumRule(size_t i);
size_t GetWW8LSTInfoNum() const{return maLSTInfos.size();}
static SvxNumType GetSvxNumTypeFromMSONFC(sal_uInt16 nMSONFC);
private:
wwSprmParser maSprmParser;
- SwWW8ImplReader& rReader;
- SwDoc& rDoc;
- const WW8Fib& rFib;
- SvStream& rSt;
+ SwWW8ImplReader& m_rReader;
+ SwDoc& m_rDoc;
+ const WW8Fib& m_rFib;
+ SvStream& m_rSt;
std::vector<std::unique_ptr<WW8LSTInfo>> maLSTInfos;
std::vector<std::unique_ptr<WW8LFOInfo>> m_LFOInfos;// D. from PLF LFO, sorted exactly like in the WW8 Stream
- sal_uInt16 nUniqueList; // current number for creating unique list names
+ sal_uInt16 m_nUniqueList; // current number for creating unique list names
SprmResult GrpprlHasSprm(sal_uInt16 nId, sal_uInt8& rSprms, sal_uInt8 nLen);
WW8LSTInfo* GetLSTByListId( sal_uInt32 nIdLst ) const;
//the rParaSprms returns back the original word paragraph indent
@@ -188,9 +190,11 @@ private:
WW8aCFormat& aCharFormat, bool& bNewCharFormatCreated,
const OUString& aPrefix = OUString());
+ void ImplDestroy();
+
WW8ListManager(const WW8ListManager&) = delete;
WW8ListManager& operator=(const WW8ListManager&) = delete;
- sal_uInt16 nLastLFOPosition;
+ sal_uInt16 m_nLastLFOPosition;
};
struct WW8FlyPara
@@ -198,11 +202,11 @@ struct WW8FlyPara
// Attention: *DO NOT* reorder, since parts will be
// compared using memcmp
bool bVer67;
- sal_Int16 nSp26, nSp27; // raw position
+ sal_Int16 nTDxaAbs, nTDyaAbs; // raw position
sal_Int16 nSp45, nSp28; // width / height
- sal_Int16 nLeMgn, nRiMgn, nUpMgn, nLoMgn; // borders
- sal_uInt8 nSp29; // raw binding + alignment
- sal_uInt8 nSp37; // Wrap-Mode ( 1 / 2; 0 = no Apo ? )
+ sal_Int16 nLeftMargin, nRightMargin, nUpperMargin, nLowerMargin; // borders
+ sal_uInt8 nTPc; // raw binding + alignment
+ sal_uInt8 nPWr; // Wrap-Mode ( 1 / 2; 0 = no Apo ? )
WW8_BRCVer9_5 brc; // borders Top, Left, Bottom, Right, Between
bool bBorderLines; // border lines
bool bGrafApo; // true: this frame is only used to position
@@ -211,9 +215,9 @@ struct WW8FlyPara
WW8FlyPara(bool bIsVer67, const WW8FlyPara* pSrc = nullptr);
bool operator==(const WW8FlyPara& rSrc) const;
- void Read(sal_uInt8 nSprm29, WW8PLCFx_Cp_FKP* pPap);
- void ReadFull(sal_uInt8 nSprm29, SwWW8ImplReader* pIo);
- void Read(sal_uInt8 nSprm29, WW8RStyle const * pStyle);
+ void Read(sal_uInt8 nSprmTPc, WW8PLCFx_Cp_FKP* pPap);
+ void ReadFull(sal_uInt8 nOrigSprmTPc, SwWW8ImplReader* pIo);
+ void Read(sal_uInt8 nSprmTPc, WW8RStyle const * pStyle);
void ApplyTabPos(const WW8_TablePos *pTabPos);
bool IsEmpty() const;
};
@@ -245,7 +249,9 @@ public:
sal_uInt16 m_n81Flags; // for bold, italic, ...
sal_uInt16 m_n81BiDiFlags; // for bold, italic, ...
- std::shared_ptr<SvxLRSpaceItem> maWordLR;
+ std::shared_ptr<SvxFirstLineIndentItem> m_pWordFirstLine;
+ std::shared_ptr<SvxTextLeftMarginItem> m_pWordLeftMargin;
+ std::shared_ptr<SvxRightMarginItem> m_pWordRightMargin;
bool m_bValid; // empty of valid
bool m_bImported; // for recursive imports
bool m_bColl; // true-> pFormat is SwTextFormatColl
@@ -277,7 +283,9 @@ public:
mnWW8OutlineLevel( MAXLEVEL ),
m_n81Flags( 0 ),
m_n81BiDiFlags(0),
- maWordLR(std::make_shared<SvxLRSpaceItem>(RES_LR_SPACE)),
+ m_pWordFirstLine(std::make_shared<SvxFirstLineIndentItem>(RES_MARGIN_FIRSTLINE)),
+ m_pWordLeftMargin(std::make_shared<SvxTextLeftMarginItem>(RES_MARGIN_TEXTLEFT)),
+ m_pWordRightMargin(std::make_shared<SvxRightMarginItem>(RES_MARGIN_RIGHT)),
m_bValid(false),
m_bImported(false),
m_bColl(false),
@@ -364,10 +372,10 @@ public:
class SwWW8FltControlStack : public SwFltControlStack
{
private:
- SwWW8ImplReader& rReader;
+ SwWW8ImplReader& m_rReader;
std::unique_ptr<SfxItemSet> m_xScratchSet;
- sal_uInt16 nToggleAttrFlags;
- sal_uInt16 nToggleBiDiAttrFlags;
+ sal_uInt16 m_nToggleAttrFlags;
+ sal_uInt16 m_nToggleBiDiAttrFlags;
SwWW8FltControlStack(const SwWW8FltControlStack&) = delete;
SwWW8FltControlStack& operator=(const SwWW8FltControlStack&) = delete;
const SwNumFormat* GetNumFormatFromStack(const SwPosition &rPos,
@@ -376,16 +384,10 @@ protected:
virtual void SetAttrInDoc(const SwPosition& rTmpPos,
SwFltStackEntry& rEntry) override;
- virtual sal_Int32 GetCurrAttrCP() const override;
- virtual bool IsParaEndInCPs(sal_Int32 nStart, sal_Int32 nEnd, bool bSdOD) const override;
- //Clear the para end position recorded in reader intermittently for the least impact on loading performance
- virtual void ClearParaEndPosition() override;
- virtual bool CheckSdOD(sal_Int32 nStart,sal_Int32 nEnd) override;
-
public:
SwWW8FltControlStack(SwDoc& rDo, sal_uLong nFieldFl, SwWW8ImplReader& rReader_ )
- : SwFltControlStack( rDo, nFieldFl ), rReader( rReader_ ),
- nToggleAttrFlags(0), nToggleBiDiAttrFlags(0)
+ : SwFltControlStack( rDo, nFieldFl ), m_rReader( rReader_ ),
+ m_nToggleAttrFlags(0), m_nToggleBiDiAttrFlags(0)
{}
void NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr);
@@ -395,24 +397,24 @@ public:
void SetToggleAttr(sal_uInt8 nId, bool bOn)
{
if( bOn )
- nToggleAttrFlags |= (1 << nId);
+ m_nToggleAttrFlags |= (1 << nId);
else
- nToggleAttrFlags &= ~(1 << nId);
+ m_nToggleAttrFlags &= ~(1 << nId);
}
- sal_uInt16 GetToggleAttrFlags() const { return nToggleAttrFlags; }
+ sal_uInt16 GetToggleAttrFlags() const { return m_nToggleAttrFlags; }
void SetToggleBiDiAttr(sal_uInt8 nId, bool bOn)
{
if( bOn )
- nToggleBiDiAttrFlags |= (1 << nId);
+ m_nToggleBiDiAttrFlags |= (1 << nId);
else
- nToggleBiDiAttrFlags &= ~(1 << nId);
+ m_nToggleBiDiAttrFlags &= ~(1 << nId);
}
- sal_uInt16 GetToggleBiDiAttrFlags() const { return nToggleBiDiAttrFlags; }
- void SetToggleAttrFlags(sal_uInt16 nFlags) { nToggleAttrFlags = nFlags; }
- void SetToggleBiDiAttrFlags(sal_uInt16 nFlags) {nToggleBiDiAttrFlags = nFlags;}
+ sal_uInt16 GetToggleBiDiAttrFlags() const { return m_nToggleBiDiAttrFlags; }
+ void SetToggleAttrFlags(sal_uInt16 nFlags) { m_nToggleAttrFlags = nFlags; }
+ void SetToggleBiDiAttrFlags(sal_uInt16 nFlags) {m_nToggleBiDiAttrFlags = nFlags;}
const SfxPoolItem* GetFormatAttr(const SwPosition& rPos, sal_uInt16 nWhich);
template<class T> const T* GetFormatAttr( const SwPosition& rPos, TypedWhichId<T> nWhich )
@@ -442,17 +444,9 @@ namespace SwWW8
{
struct ltstr
{
- bool operator()(const OUString &r1, std::u16string_view r2) const
- {
- return r1.compareToIgnoreAsciiCase(r2)<0;
- }
- };
-
- struct ltnode
- {
- bool operator()(const SwTextNode *r1, const SwTextNode *r2) const
+ bool operator()(std::u16string_view r1, std::u16string_view r2) const
{
- return r1->GetIndex() < r2->GetIndex();
+ return o3tl::compareToIgnoreAsciiCase(r1, r2)<0;
}
};
};
@@ -462,12 +456,12 @@ class SwWW8ReferencedFltEndStack : public SwFltEndStack
public:
SwWW8ReferencedFltEndStack( SwDoc& rDo, sal_uLong nFieldFl )
: SwFltEndStack( rDo, nFieldFl )
- , aReferencedTOCBookmarks()
+ , m_aReferencedTOCBookmarks()
{}
// Keep track of referenced TOC bookmarks in order to suppress the import
// of unreferenced ones.
- std::set<OUString, SwWW8::ltstr> aReferencedTOCBookmarks;
+ std::set<OUString, SwWW8::ltstr> m_aReferencedTOCBookmarks;
protected:
virtual void SetAttrInDoc( const SwPosition& rTmpPos,
SwFltStackEntry& rEntry ) override;
@@ -478,14 +472,14 @@ class SwWW8FltRefStack final : public SwFltEndStack
public:
SwWW8FltRefStack(SwDoc& rDo, sal_uLong nFieldFl)
: SwFltEndStack( rDo, nFieldFl )
- , aFieldVarNames()
+ , m_aFieldVarNames()
{}
bool IsFootnoteEdnBkmField(const SwFormatField& rFormatField, sal_uInt16& rBkmNo);
//Keep track of variable names created with fields, and the bookmark
//mapped to their position, hopefully the same, but very possibly
//an additional pseudo bookmark
- std::map<OUString, OUString, SwWW8::ltstr> aFieldVarNames;
+ std::map<OUString, OUString, SwWW8::ltstr> m_aFieldVarNames;
private:
SwFltStackEntry *RefToVar(const SwField* pField,SwFltStackEntry& rEntry);
virtual void SetAttrInDoc(const SwPosition& rTmpPos,
@@ -558,7 +552,7 @@ namespace sw
};
}
- auto FilterControlChars(OUString const& rString) -> OUString;
+ auto FilterControlChars(std::u16string_view aString) -> OUString;
}
class WW8FieldEntry
@@ -578,7 +572,7 @@ class WW8FieldEntry
WW8FieldEntry &operator=(const WW8FieldEntry &rOther) noexcept;
void Swap(WW8FieldEntry &rOther) noexcept;
- SwNodeIndex GetPtNode() const { return maStartPos.GetPtNode(); };
+ const SwNodeIndex& GetPtNode() const { return maStartPos.GetPtNode(); };
sal_Int32 GetPtContent() const { return maStartPos.GetPtContent(); };
const OUString& GetBookmarkName() const { return msBookmarkName;}
@@ -595,7 +589,7 @@ class WW8ReaderSave
{
private:
WW8PLCFxSaveAll maPLCFxSave;
- SwPosition maTmpPos;
+ std::shared_ptr<SwUnoCursor> mxTmpPos;
std::deque<bool> maOldApos;
std::deque<WW8FieldEntry> maOldFieldStack;
std::unique_ptr<SwWW8FltControlStack> mxOldStck;
@@ -623,7 +617,7 @@ private:
public:
WW8ReaderSave(SwWW8ImplReader* pRdr, WW8_CP nStart=-1);
void Restore(SwWW8ImplReader* pRdr);
- const SwPosition &GetStartPos() const { return maTmpPos; }
+ const SwPosition &GetStartPos() const { return *mxTmpPos->GetPoint(); }
};
enum class eF_ResT { OK, TEXT, TAGIGN, READ_FSPA };
@@ -631,7 +625,7 @@ enum class eF_ResT { OK, TEXT, TAGIGN, READ_FSPA };
class SwWW8Shade
{
public:
- Color aColor;
+ Color m_aColor;
SwWW8Shade(bool bVer67, const WW8_SHD& rSHD);
SwWW8Shade(Color nFore, Color nBack, sal_uInt16 nIndex)
{
@@ -659,11 +653,11 @@ protected:
WW8FormulaControl& operator=(WW8FormulaControl const&) = delete;
public:
- WW8FormulaControl(const OUString& rN, SwWW8ImplReader &rRdr)
+ WW8FormulaControl(OUString aN, SwWW8ImplReader &rRdr)
: mrRdr(rRdr), mfUnknown(0), mfDropdownIndex(0),
mfToolTip(0), mfNoMark(0), mfType(0),
mfUnused(0), mhpsCheckBox(20), mnChecked(0), mnMaxLen(0),
- mbHelp(false), msName( rN )
+ mbHelp(false), msName(std::move( aN ))
{
}
sal_uInt8 mfUnknown:2;
@@ -745,27 +739,27 @@ public:
const css::awt::Size& rSize,
css::uno::Reference< css::drawing::XShape > *pShape, bool bFloatingCtrl) override;
void ExportControl(WW8Export &rWrt, const SdrUnoObj& rFormObj);
- bool ReadOCXStream( tools::SvRef<SotStorage> const & rSrc1,
+ bool ReadOCXStream(rtl::Reference<SotStorage> const& rSrc1,
css::uno::Reference< css::drawing::XShape > *pShapeRef,
bool bFloatingCtrl=false );
private:
- SwPaM *pPaM;
+ SwPaM *m_pPaM;
sal_uInt32 mnObjectId;
};
class SwMSDffManager : public SvxMSDffManager
{
private:
- SwWW8ImplReader& rReader;
- SvStream *pFallbackStream;
- std::unordered_map<sal_uInt32, Graphic> aOldEscherBlipCache;
+ SwWW8ImplReader& m_rReader;
+ SvStream *m_pFallbackStream;
+ std::unordered_map<sal_uInt32, Graphic> m_aOldEscherBlipCache;
virtual bool GetOLEStorageName( sal_uInt32 nOLEId, OUString& rStorageName,
- tools::SvRef<SotStorage>& rSrcStorage, css::uno::Reference < css::embed::XStorage >& rDestStorage ) const override;
+ rtl::Reference<SotStorage>& rSrcStorage, css::uno::Reference < css::embed::XStorage >& rDestStorage ) const override;
virtual bool ShapeHasText( sal_uLong nShapeId, sal_uLong nFilePos ) const override;
// #i32596# - new parameter <_nCalledByGroup>, which
// indicates, if the OLE object is imported inside a group object
- virtual SdrObject* ImportOLE( sal_uInt32 nOLEId,
+ virtual rtl::Reference<SdrObject> ImportOLE( sal_uInt32 nOLEId,
const Graphic& rGrf,
const tools::Rectangle& rBoundRect,
const tools::Rectangle& rVisArea,
@@ -781,7 +775,7 @@ public:
void DisableFallbackStream();
void EnableFallbackStream();
protected:
- virtual SdrObject* ProcessObj( SvStream& rSt, DffObjData& rObjData, SvxMSDffClientData& rData, tools::Rectangle& rTextRect, SdrObject* pObj ) override;
+ virtual rtl::Reference<SdrObject> ProcessObj( SvStream& rSt, DffObjData& rObjData, SvxMSDffClientData& rData, tools::Rectangle& rTextRect, SdrObject* pObj ) override;
};
class wwSection
@@ -789,16 +783,16 @@ class wwSection
public:
explicit wwSection(const SwPosition &rPos);
SEPr maSep;
- WW8_BRCVer9 brc[4];
+ WW8_BRCVer9 m_brc[4];
SwNodeIndex maStart;
SwSection *mpSection;
SwPageDesc *mpPage;
SvxFrameDirection meDir;
- sal_uInt32 nPgWidth;
- sal_uInt32 nPgLeft;
- sal_uInt32 nPgRight;
- sal_uInt32 nPgGutter;
+ sal_uInt32 m_nPgWidth;
+ sal_uInt32 m_nPgLeft;
+ sal_uInt32 m_nPgRight;
+ sal_uInt32 m_nPgGutter;
bool m_bRtlGutter = false;
css::drawing::TextVerticalAdjust mnVerticalAdjustment;
@@ -814,12 +808,12 @@ public:
sal_uInt16 PageStartAt() const { return maSep.pgnStart; }
bool PageRestartNo() const { return maSep.fPgnRestart != 0; }
bool IsBiDi() const { return maSep.fBiDi != 0; }
- sal_uInt32 GetPageWidth() const { return nPgWidth; }
+ sal_uInt32 GetPageWidth() const { return m_nPgWidth; }
sal_uInt32 GetTextAreaWidth() const
- { return GetPageWidth() - GetPageLeft() - nPgGutter - GetPageRight(); }
+ { return GetPageWidth() - GetPageLeft() - m_nPgGutter - GetPageRight(); }
sal_uInt32 GetPageHeight() const { return maSep.yaPage; }
- sal_uInt32 GetPageLeft() const { return nPgLeft; }
- sal_uInt32 GetPageRight() const { return nPgRight; }
+ sal_uInt32 GetPageLeft() const { return m_nPgLeft; }
+ sal_uInt32 GetPageRight() const { return m_nPgRight; }
bool IsLandScape() const { return maSep.dmOrientPage != 0; }
bool IsFixedHeightHeader() const { return maSep.dyaTop < 0; }
bool IsFixedHeightFooter() const { return maSep.dyaBottom < 0; }
@@ -891,7 +885,7 @@ public:
bool CurrentSectionIsProtected() const;
void PrependedInlineNode(const SwPosition &rPos, const SwNode &rNode);
sal_uInt16 CurrentSectionColCount() const;
- bool WillHavePageDescHere(const SwNodeIndex& rIdx) const;
+ bool WillHavePageDescHere(const SwNode&) const;
void CreateSep(const tools::Long nTextPos);
void InsertSegments();
void JoinNode(const SwPosition &rPos, const SwNode &rNode);
@@ -902,6 +896,25 @@ public:
sal_uInt32 GetTextAreaWidth() const;
};
+class TextNodeListener : public SwClient
+{
+ SwTextNode *m_pTextNode;
+
+protected:
+ virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
+
+public:
+ TextNodeListener(SwTextNode* pTextNode);
+ bool operator<(const TextNodeListener& rOther) const
+ {
+ return m_pTextNode->GetIndex() < rOther.m_pTextNode->GetIndex();
+ }
+ void StopListening(SwModify* pTextNode);
+ SwTextNode* GetTextNode() const { return m_pTextNode; }
+ virtual void removed(SwModify* pTextNode);
+ virtual ~TextNodeListener() override;
+};
+
//Various writer elements like frames start off containing a blank paragraph,
//sometimes this paragraph turns out to be extraneous, e.g. the frame should
//only contain a table with no trailing paragraph.
@@ -917,19 +930,37 @@ public:
class wwExtraneousParas
{
private:
+ class ExtraTextNodeListener : public TextNodeListener
+ {
+ private:
+ wwExtraneousParas* m_pOwner;
+ public:
+ ExtraTextNodeListener(SwTextNode* pTextNode, wwExtraneousParas* pOwner)
+ : TextNodeListener(pTextNode)
+ , m_pOwner(pOwner)
+ {
+ }
+ virtual void removed(SwModify* pTextNode) override;
+ };
+
/*
A vector of SwTextNodes to erase from a document after import is complete
*/
- std::set<SwTextNode*, SwWW8::ltnode> m_aTextNodes;
+ std::set<ExtraTextNodeListener> m_aTextNodes;
SwDoc& m_rDoc;
+ void remove_if_present(SwModify* pModify);
+
wwExtraneousParas(wwExtraneousParas const&) = delete;
wwExtraneousParas& operator=(wwExtraneousParas const&) = delete;
-
public:
explicit wwExtraneousParas(SwDoc &rDoc) : m_rDoc(rDoc) {}
~wwExtraneousParas() { delete_all_from_doc(); }
- void insert(SwTextNode *pTextNode) { m_aTextNodes.insert(pTextNode); }
+ void insert(SwTextNode *pTextNode);
+ void remove_if_present(SwTextNode *pTextNode)
+ {
+ remove_if_present(static_cast<SwModify*>(pTextNode));
+ }
void delete_all_from_doc();
};
@@ -945,8 +976,8 @@ private:
public:
void SetUniqueGraphName(SwFrameFormat *pFrameFormat, std::u16string_view rFixedPart);
- wwFrameNamer(bool bIsDisabled, const OUString &rSeed)
- : msSeed(rSeed), mnImportedGraphicsCount(0), mbIsDisabled(bIsDisabled)
+ wwFrameNamer(bool bIsDisabled, OUString aSeed)
+ : msSeed(std::move(aSeed)), mnImportedGraphicsCount(0), mbIsDisabled(bIsDisabled)
{
}
};
@@ -961,8 +992,8 @@ private:
wwSectionNamer& operator=(const wwSectionNamer&) = delete;
public:
OUString UniqueName();
- wwSectionNamer(const SwDoc &rDoc, const OUString &rSeed)
- : mrDoc(rDoc), msFileLinkSeed(rSeed), mnFileSectionNo(0)
+ wwSectionNamer(const SwDoc &rDoc, OUString aSeed)
+ : mrDoc(rDoc), msFileLinkSeed(std::move(aSeed)), mnFileSectionNo(0)
{ }
};
@@ -979,15 +1010,16 @@ struct ApoTestResults
{
bool mbStartApo;
bool mbStopApo;
- bool m_bHasSprm37;
- bool m_bHasSprm29;
- sal_uInt8 m_nSprm29;
+ bool m_bHasSprmPWr;
+ bool m_bHasSprmPPc;
+ /// sprmPPc if m_bHasSprmPPc is true, sprmTPc otherwise.
+ sal_uInt8 m_nSprmPPc;
WW8FlyPara* mpStyleApo;
ApoTestResults()
- : mbStartApo(false), mbStopApo(false), m_bHasSprm37(false)
- , m_bHasSprm29(false), m_nSprm29(0), mpStyleApo(nullptr) {}
+ : mbStartApo(false), mbStopApo(false), m_bHasSprmPWr(false)
+ , m_bHasSprmPPc(false), m_nSprmPPc(0), mpStyleApo(nullptr) {}
bool HasStartStop() const { return (mbStartApo || mbStopApo); }
- bool HasFrame() const { return (m_bHasSprm29 || m_bHasSprm37 || mpStyleApo); }
+ bool HasFrame() const { return (m_bHasSprmPPc || m_bHasSprmPWr || mpStyleApo); }
};
struct ANLDRuleMap
@@ -1032,7 +1064,6 @@ struct WW8TabBandDesc
bool bLEmptyCol; // SW: an additional empty column at the left
bool bREmptyCol; // SW: same at the right
bool bCantSplit;
- bool bCantSplit90;
WW8_TCell* pTCs;
sal_uInt8 nOverrideSpacing[MAX_COL + 1];
short nOverrideValues[MAX_COL + 1][4];
@@ -1107,8 +1138,7 @@ private:
This stack is for redlines, because their sequence of discovery can
be out of order of their order of insertion into the document.
*/
- std::stack<std::unique_ptr<sw::util::RedlineStack>> m_aFrameRedlines; //inside frames, tables, etc
- std::unique_ptr<sw::util::RedlineStack> m_xRedlineStack; //main document
+ std::unique_ptr<sw::util::RedlineStack> m_xRedlineStack;
/*
This stack is for fields that get referenced later, e.g. BookMarks and TOX.
@@ -1150,6 +1180,8 @@ private:
*/
std::deque<FootnoteDescriptor> m_aFootnoteStack;
+ std::optional<SwLineBreakClear> m_oLineBreakClear;
+
/*
A queue of the ms sections in the document
*/
@@ -1176,7 +1208,7 @@ private:
/*
Knows how to split a series of bytes into sprms and their arguments
*/
- std::unique_ptr<wwSprmParser> m_xSprmParser;
+ std::optional<wwSprmParser> m_oSprmParser;
/*
Creates unique names to give to graphics
@@ -1225,7 +1257,7 @@ private:
std::shared_ptr<WW8Fib> m_xWwFib;
std::unique_ptr<WW8Fonts> m_xFonts;
std::unique_ptr<WW8Dop> m_xWDop;
- std::unique_ptr<WW8ListManager, o3tl::default_delete<WW8ListManager>> m_xLstManager;
+ std::unique_ptr<WW8ListManager> m_xLstManager;
std::unique_ptr<WW8ScannerBase> m_xSBase;
std::shared_ptr<WW8PLCFMan> m_xPlcxMan;
std::map<short, OUString> m_aLinkStringMap;
@@ -1259,11 +1291,11 @@ private:
std::unique_ptr<EditEngine> m_pDrawEditEngine;
std::unique_ptr<wwZOrderer> m_xWWZOrder;
- SwFieldType* m_pNumFieldType; // for number circle
+ SwSetExpFieldType* m_pNumFieldType; // for number circle
std::unique_ptr<SwMSDffManager> m_xMSDffManager;
- std::unique_ptr<std::vector<OUString>> m_pAtnNames;
+ std::optional<std::vector<OUString>> m_xAtnNames;
std::unique_ptr<WW8SmartTagData> m_pSmartTagData;
@@ -1372,26 +1404,24 @@ private:
// Indicate that current on loading a hyperlink, which is inside a TOC; Managed by Read_F_Hyperlink() and End_Field()
bool m_bLoadingTOXHyperlink;
// a document position recorded the after-position of TOC section, managed by Read_F_TOX() and End_Field()
- std::unique_ptr<SwPaM> m_pPosAfterTOC;
+ std::optional<SwPaM> m_oPosAfterTOC;
// used for some dropcap tweaking
- SwTextNode* m_pPreviousNode;
+ std::unique_ptr<TextNodeListener> m_xPreviousNode;
- std::unique_ptr< SwPosition > m_pLastAnchorPos;
+ std::optional< SwPosition > m_oLastAnchorPos;
bool m_bCareFirstParaEndInToc;
bool m_bCareLastParaEndInToc;
cp_set m_aTOXEndCps;
- std::vector<WW8_CP> m_aEndParaPos;
- WW8_CP m_aCurrAttrCP;
- bool m_bOnLoadingMain:1;
- bool m_bNotifyMacroEventRead:1;
+ bool m_bNotifyMacroEventRead;
+ bool m_bFuzzing;
const SprmReadInfo& GetSprmReadInfo(sal_uInt16 nId) const;
bool StyleExists(unsigned int nColl) const { return (nColl < m_vColl.size()); }
SwWW8StyInf *GetStyle(sal_uInt16 nColl) const;
- void AppendTextNode(SwPosition& rPos);
+ void FinalizeTextNode(SwPosition& rPos, bool bAddNew = true);
void Read_HdFt(int nSect, const SwPageDesc *pPrev,
const wwSection &rSection);
@@ -1423,7 +1453,7 @@ private:
DeleteStack(std::move(m_xAnchorStck));
}
void emulateMSWordAddTextToParagraph(const OUString& rAddString);
- void simpleAddTextToParagraph(const OUString& rAddString);
+ void simpleAddTextToParagraph(std::u16string_view aAddString);
bool HandlePageBreakChar();
bool ReadChar(tools::Long nPosCp, tools::Long nCpOfs);
bool ReadPlainChars(WW8_CP& rPos, sal_Int32 nEnd, sal_Int32 nCpOfs);
@@ -1462,6 +1492,11 @@ private:
void ResetCJKCharSetVars();
const SfxPoolItem* GetFormatAttr( sal_uInt16 nWhich );
+ template<class T> const T* GetFormatAttr( TypedWhichId<T> nWhich )
+ {
+ return static_cast<const T*>(GetFormatAttr(sal_uInt16(nWhich)));
+ }
+
bool JoinNode(SwPaM &rPam, bool bStealAttr = false);
static bool IsBorder(const WW8_BRCVer9* pbrc, bool bChkBtwn = false);
@@ -1516,7 +1551,7 @@ private:
bool ProcessSpecial(bool &rbReSync, WW8_CP nStartCp);
sal_uInt16 TabRowSprm(int nLevel) const;
- bool ReadGrafFile(OUString& rFileName, std::unique_ptr<Graphic>& rpGraphic,
+ bool ReadGrafFile(OUString& rFileName, std::optional<Graphic>& rpGraphic,
const WW8_PIC& rPic, SvStream* pSt, sal_uLong nFilePos, bool* pDelIt);
static void ReplaceObj(const SdrObject &rReplaceTextObj,
@@ -1534,7 +1569,7 @@ private:
SwFrameFormat* ImportGraf1(WW8_PIC const & rPic, SvStream* pSt, sal_uLong nFilePos);
SwFrameFormat* ImportGraf(SdrTextObj const * pTextObj = nullptr, SwFrameFormat const * pFlyFormat = nullptr);
- SdrObject* ImportOleBase( Graphic& rGraph, const Graphic* pGrf=nullptr,
+ rtl::Reference<SdrObject> ImportOleBase( Graphic& rGraph, const Graphic* pGrf=nullptr,
const SfxItemSet* pFlySet=nullptr, const tools::Rectangle& aVisArea = tools::Rectangle() );
SwFrameFormat* ImportOle( const Graphic* = nullptr, const SfxItemSet* pFlySet = nullptr,
@@ -1551,7 +1586,7 @@ private:
void ImportDopTypography(const WW8DopTypography &rTypo);
ErrCode LoadThroughDecryption(WW8Glossary *pGloss);
- ErrCode SetSubStreams(tools::SvRef<SotStorageStream> &rTableStream, tools::SvRef<SotStorageStream> &rDataStream);
+ ErrCode SetSubStreams(rtl::Reference<SotStorageStream> &rTableStream, rtl::Reference<SotStorageStream> &rDataStream);
ErrCode CoreLoad(WW8Glossary const *pGloss);
void ReadDocVars();
@@ -1573,7 +1608,7 @@ private:
// rglst, hpllfo and hsttbListNames
// the corresponding structures are: LSTF, LVLF, LFO LFOLVL
- void SetAnlvStrings(SwNumFormat &rNum, WW8_ANLV const &rAV, const sal_uInt8* pText,
+ void SetAnlvStrings(SwNumFormat &rNum, int nLevel, WW8_ANLV const &rAV, const sal_uInt8* pText,
size_t nStart, size_t nElements, bool bOutline);
void SetAnld(SwNumRule* pNumR, WW8_ANLD const * pAD, sal_uInt8 nSwLevel, bool bOutLine);
void SetNumOlst( SwNumRule* pNumR, WW8_OLST* pO, sal_uInt8 nSwLevel );
@@ -1588,18 +1623,18 @@ private:
bool ReadGrafStart(void* pData, short nDataSiz, WW8_DPHEAD const * pHd,
SfxAllItemSet &rSet);
- SdrObject *ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
void InsertTxbxStyAttrs( SfxItemSet& rS, sal_uInt16 nColl );
void InsertAttrsAsDrawingAttrs(WW8_CP nStartCp, WW8_CP nEndCp, ManTypes eType, bool bONLYnPicLocFc=false);
bool GetTxbxTextSttEndCp(WW8_CP& rStartCp, WW8_CP& rEndCp, sal_uInt16 nTxBxS,
sal_uInt16 nSequence);
sal_Int32 GetRangeAsDrawingString(OUString& rString, tools::Long StartCp, tools::Long nEndCp, ManTypes eType);
- std::unique_ptr<OutlinerParaObject> ImportAsOutliner(OUString &rString, WW8_CP nStartCp, WW8_CP nEndCp, ManTypes eType);
+ std::optional<OutlinerParaObject> ImportAsOutliner(OUString &rString, WW8_CP nStartCp, WW8_CP nEndCp, ManTypes eType);
void InsertTxbxText(SdrTextObj* pTextObj, Size const * pObjSiz,
sal_uInt16 nTxBxS, sal_uInt16 nSequence, tools::Long nPosCp, SwFrameFormat const * pFlyFormat,
bool bMakeSdrGrafObj, bool& rbEraseTextObj,
@@ -1609,20 +1644,20 @@ private:
bool TxbxChainContainsRealText( sal_uInt16 nTxBxS,
tools::Long& rStartCp,
tools::Long& rEndCp );
- SdrObject *ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadGrafPrimitive(short& rLeft, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadGrafPrimitive(short& rLeft, SfxAllItemSet &rSet);
void ReadGrafLayer1(WW8PLCFspecial& rPF, tools::Long nGrafAnchorCp);
SdrObject* CreateContactObject(SwFrameFormat* pFlyFormat);
RndStdIds ProcessEscherAlign(SvxMSDffImportRec& rRecord, WW8_FSPA& rFSPA, SfxItemSet& rFlySet);
bool MiserableRTLGraphicsHack(SwTwips &rLeft, SwTwips nWidth,
sal_Int16 eHoriOri, sal_Int16 eHoriRel);
SwFrameFormat* Read_GrafLayer( tools::Long nGrafAnchorCp );
- SwFlyFrameFormat* ImportReplaceableDrawables(SdrObject*& rpObject, SdrObject*& rpOurNewObject,
+ SwFlyFrameFormat* ImportReplaceableDrawables(rtl::Reference<SdrObject>& rpObject, rtl::Reference<SdrObject>& rpOurNewObject,
SvxMSDffImportRec& rRecord, WW8_FSPA& rF,
SfxItemSet& rFlySet);
- SwFlyFrameFormat* ConvertDrawTextToFly(SdrObject*& rpObject, SdrObject*& rpOurNewObject,
+ SwFlyFrameFormat* ConvertDrawTextToFly(rtl::Reference<SdrObject>& rpObject, rtl::Reference<SdrObject>& rpOurNewObject,
const SvxMSDffImportRec& rRecord, RndStdIds eAnchor,
const WW8_FSPA& rF, SfxItemSet& rFlySet);
SwFrameFormat* MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord, tools::Long nGrafAnchorCp,
@@ -1697,7 +1732,7 @@ private:
// #i84783#
// determine object attribute "Layout in Table Cell"
- bool IsObjectLayoutInTableCell( const sal_uInt32 nLayoutInTableCell ) const;
+ bool IsObjectLayoutInTableCell(const sal_uInt32 nGroupShapeBooleanProperties) const;
void ReadGlobalTemplateSettings( std::u16string_view sCreatedFrom, const css::uno::Reference< css::container::XNameContainer >& xPrjNameMap );
SwWW8ImplReader(const SwWW8ImplReader &) = delete;
SwWW8ImplReader& operator=(const SwWW8ImplReader&) = delete;
@@ -1707,10 +1742,6 @@ public: // really private, but can only be done public
sal_uInt16 GetToggleBiDiAttrFlags() const;
void SetToggleAttrFlags(sal_uInt16 nFlags);
void SetToggleBiDiAttrFlags(sal_uInt16 nFlags);
- WW8_CP GetCurrAttrCP() const {return m_aCurrAttrCP;}
- bool IsParaEndInCPs(sal_Int32 , sal_Int32,bool bSdOD=true) const;
- //Clear the para end position recorded in reader intermittently for the least impact on loading performance
- void ClearParaEndPosition();
tools::Long Read_Footnote(WW8PLCFManResult* pRes);
sal_uInt16 End_Footnote();
@@ -1757,6 +1788,7 @@ public: // really private, but can only be done public
void Read_ParaAutoBefore(sal_uInt16 , const sal_uInt8 *pData, short nLen);
void Read_ParaAutoAfter(sal_uInt16 , const sal_uInt8 *pData, short nLen);
void Read_ParaContextualSpacing( sal_uInt16 nId, const sal_uInt8* pData, short nLen );
+ void Read_LineBreakClear(sal_uInt16 nId, const sal_uInt8* pData, short nLen);
void Read_LineSpace( sal_uInt16, const sal_uInt8*, short nLen );
void SetRelativeJustify( bool bRel );
@@ -1797,7 +1829,7 @@ public: // really private, but can only be done public
void Read_TabRowEnd( sal_uInt16, const sal_uInt8* pData, short nLen );
void Read_TabCellEnd( sal_uInt16, const sal_uInt8* pData, short nLen );
- bool ParseTabPos(WW8_TablePos *aTabPos, WW8PLCFx_Cp_FKP* pPap);
+ static bool ParseTabPos(WW8_TablePos *aTabPos, WW8PLCFx_Cp_FKP* pPap);
void Read_Shade( sal_uInt16, const sal_uInt8* pData, short nLen );
void Read_ANLevelNo( sal_uInt16, const sal_uInt8* pData, short nLen );
void Read_ANLevelDesc( sal_uInt16, const sal_uInt8* pData, short nLen );
@@ -1847,7 +1879,7 @@ public: // really private, but can only be done public
eF_ResT Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr );
eF_ResT Read_F_Author( WW8FieldDesc*, OUString& );
eF_ResT Read_F_TemplName( WW8FieldDesc*, OUString& );
- SvNumFormatType GetTimeDatePara(OUString const & rStr, sal_uInt32& rFormat, LanguageType &rLang,
+ SvNumFormatType GetTimeDatePara(std::u16string_view aStr, sal_uInt32& rFormat, LanguageType &rLang,
int nWhichDefault, bool bHijri = false);
bool ForceFieldLanguage(SwField &rField, LanguageType nLang);
eF_ResT Read_F_DateTime( WW8FieldDesc*, OUString& rStr );
@@ -1889,9 +1921,6 @@ public: // really private, but can only be done public
short ImportSprm(const sal_uInt8* pPos, sal_Int32 nMemLen, sal_uInt16 nId = 0);
bool SearchRowEnd(WW8PLCFx_Cp_FKP* pPap,WW8_CP &rStartCp, int nLevel) const;
- /// Seek to the end of the table with pPap, returns true on success.
- bool SearchTableEnd(WW8PLCFx_Cp_FKP* pPap) const;
- bool FloatingTableConversion(WW8PLCFx_Cp_FKP* pPap);
const WW8Fib& GetFib() const { return *m_xWwFib; }
SwDoc& GetDoc() const { return m_rDoc; }
@@ -1902,13 +1931,13 @@ public: // really private, but can only be done public
const SwFormat* GetStyleWithOrgWWName( std::u16string_view rName ) const ;
static bool GetPictGrafFromStream(Graphic& rGraphic, SvStream& rSrc);
- static void PicRead( SvStream *pDataStream, WW8_PIC *pPic, bool bVer67);
- static bool ImportOleWMF(const tools::SvRef<SotStorage>& xSrc1, GDIMetaFile& rWMF, tools::Long& rX,
+ SAL_WARN_UNUSED_RESULT static bool PicRead(SvStream *pDataStream, WW8_PIC *pPic, bool bVer67);
+ static bool ImportOleWMF(const rtl::Reference<SotStorage>& xSrc1, GDIMetaFile& rWMF, tools::Long& rX,
tools::Long& rY);
static Color GetCol(sal_uInt8 nIco);
SwWW8ImplReader( sal_uInt8 nVersionPara, SotStorage* pStorage, SvStream* pSt,
- SwDoc& rD, const OUString& rBaseURL, bool bNewDoc, bool bSkipImages, SwPosition const &rPos );
+ SwDoc& rD, OUString aBaseURL, bool bNewDoc, bool bSkipImages, SwPosition const &rPos );
const OUString& GetBaseURL() const { return m_sBaseURL; }
// load a complete doc file
@@ -1928,7 +1957,8 @@ void UseListIndent(SwWW8StyInf &rStyle, const SwNumFormat &rFormat);
void SetStyleIndent(SwWW8StyInf &rStyleInfo, const SwNumFormat &rFormat);
// #i103711#
// #i105414#
-void SyncIndentWithList( SvxLRSpaceItem &rLR,
+void SyncIndentWithList( SvxFirstLineIndentItem & rFirstLine,
+ SvxTextLeftMarginItem & rLeftMargin,
const SwNumFormat &rFormat,
const bool bFirstLineOfStSet,
const bool bLeftIndentSet );
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index facee87ec980..c1e80efd2d38 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -39,6 +39,7 @@
#include <editeng/pgrditem.hxx>
#include <msfilter.hxx>
#include <pam.hxx>
+#include <deletelistener.hxx>
#include <doc.hxx>
#include <IDocumentStylePoolAccess.hxx>
#include <docary.hxx>
@@ -57,10 +58,10 @@
#include <fmtanchr.hxx>
#include <fmtrowsplt.hxx>
#include <fmtfollowtextflow.hxx>
+#include <formatflysplit.hxx>
#include <numrule.hxx>
#include "sprmids.hxx"
#include <wwstyles.hxx>
-#include "writerhelper.hxx"
#include "ww8struc.hxx"
#include "ww8par.hxx"
#include "ww8par2.hxx"
@@ -78,7 +79,7 @@ WW8TabBandDesc::WW8TabBandDesc():
pNextBand(nullptr), nGapHalf(0), mnDefaultLeft(0), mnDefaultTop(0), mnDefaultRight(0),
mnDefaultBottom(0), mbHasSpacing(false), nLineHeight(0), nRows(0), nCenter{}, nWidth{},
nWwCols(0), nSwCols(0), bLEmptyCol(false), bREmptyCol(false), bCantSplit(false),
- bCantSplit90(false), pTCs(nullptr), nOverrideSpacing{}, nOverrideValues{}, pSHDs(nullptr),
+ pTCs(nullptr), nOverrideSpacing{}, nOverrideValues{}, pSHDs(nullptr),
pNewSHDs(nullptr), bExist{}, nTransCell{}
{
for (sal_uInt16 & rn : maDirections)
@@ -144,12 +145,12 @@ bool wwSectionManager::CurrentSectionIsProtected() const
sal_uInt32 wwSectionManager::GetPageLeft() const
{
- return !maSegments.empty() ? maSegments.back().nPgLeft : 0;
+ return !maSegments.empty() ? maSegments.back().m_nPgLeft : 0;
}
sal_uInt32 wwSectionManager::GetPageRight() const
{
- return !maSegments.empty() ? maSegments.back().nPgRight : 0;
+ return !maSegments.empty() ? maSegments.back().m_nPgRight : 0;
}
sal_uInt32 wwSectionManager::GetPageWidth() const
@@ -167,14 +168,38 @@ sal_uInt32 wwSectionManager::GetWWPageTopMargin() const
return !maSegments.empty() ? maSegments.back().maSep.dyaTop : 0;
}
+namespace
+{
+bool IsInSplitFly(SwPaM& rPaM)
+{
+ SwNode& rNode = rPaM.GetPoint()->GetNode();
+ SwNodeOffset nNodeIndex = rNode.GetIndex();
+ SwNodes& rNodes = rNode.GetNodes();
+ if (nNodeIndex >= rNodes.GetEndOfAutotext().GetIndex()
+ || nNodeIndex < rNodes.GetEndOfInserts().GetIndex())
+ {
+ return false;
+ }
+
+ SwFrameFormat* pFlyFormat = rNode.StartOfSectionNode()->GetFlyFormat();
+ if (!pFlyFormat)
+ {
+ return false;
+ }
+
+ return pFlyFormat->GetFlySplit().GetValue();
+}
+}
+
sal_uInt16 SwWW8ImplReader::End_Footnote()
{
/*
Ignoring Footnote outside of the normal Text. People will put footnotes
into field results and field commands.
*/
- if (m_bIgnoreText ||
- m_pPaM->GetPoint()->nNode < m_rDoc.GetNodes().GetEndOfExtras().GetIndex())
+ bool bSplitFly = IsInSplitFly(*m_pPaM);
+ if (m_bIgnoreText
+ || (m_pPaM->GetPoint()->GetNode() < m_rDoc.GetNodes().GetEndOfExtras() && !bSplitFly))
{
return 0;
}
@@ -188,94 +213,105 @@ sal_uInt16 SwWW8ImplReader::End_Footnote()
//Get the footnote character and remove it from the txtnode. We'll
//replace it with the footnote
- SwTextNode* pText = m_pPaM->GetNode().GetTextNode();
- sal_Int32 nPos = m_pPaM->GetPoint()->nContent.GetIndex();
+ SwTextNode* pText = m_pPaM->GetPointNode().GetTextNode();
+ sal_Int32 nPos = m_pPaM->GetPoint()->GetContentIndex();
OUString sChar;
- SwTextAttr* pFN = nullptr;
+ SwTextFootnote* pFN = nullptr;
//There should have been a footnote char, we will replace this.
if (pText && nPos)
{
sChar += OUStringChar(pText->GetText()[--nPos]);
m_pPaM->SetMark();
- --m_pPaM->GetMark()->nContent;
- std::shared_ptr<SwUnoCursor> xLastAnchorCursor(m_pLastAnchorPos ? m_rDoc.CreateUnoCursor(*m_pLastAnchorPos) : nullptr);
- m_pLastAnchorPos.reset();
+ m_pPaM->GetMark()->AdjustContent(-1);
+ std::shared_ptr<SwUnoCursor> xLastAnchorCursor(m_oLastAnchorPos ? m_rDoc.CreateUnoCursor(*m_oLastAnchorPos) : nullptr);
+ m_oLastAnchorPos.reset();
m_rDoc.getIDocumentContentOperations().DeleteRange( *m_pPaM );
m_pPaM->DeleteMark();
if (xLastAnchorCursor)
- m_pLastAnchorPos.reset(new SwPosition(*xLastAnchorCursor->GetPoint()));
+ m_oLastAnchorPos.emplace(*xLastAnchorCursor->GetPoint());
SwFormatFootnote aFootnote(rDesc.meType == MAN_EDN);
- pFN = pText->InsertItem(aFootnote, nPos, nPos);
+ pFN = static_cast<SwTextFootnote*>(pText->InsertItem(aFootnote, nPos, nPos));
}
OSL_ENSURE(pFN, "Problems creating the footnote text");
if (pFN)
{
-
SwPosition aTmpPos( *m_pPaM->GetPoint() ); // remember old cursor position
WW8PLCFxSaveAll aSave;
m_xPlcxMan->SaveAllPLCFx( aSave );
std::shared_ptr<WW8PLCFMan> xOldPlcxMan = m_xPlcxMan;
- const SwNodeIndex* pSttIdx = static_cast<SwTextFootnote*>(pFN)->GetStartNode();
- OSL_ENSURE(pSttIdx, "Problems creating footnote text");
+ const SwNodeIndex* pSttIdx = pFN->GetStartNode();
+ assert(pSttIdx && "Problems creating footnote text");
- static_cast<SwTextFootnote*>(pFN)->SetSeqNo( m_rDoc.GetFootnoteIdxs().size() );
+ pFN->SetSeqNo(m_rDoc.GetFootnoteIdxs().size());
bool bOld = m_bFootnoteEdn;
m_bFootnoteEdn = true;
+ SwFormatFootnote& rFormatFootnote = static_cast<SwFormatFootnote&>(pFN->GetAttr());
+
+ SvtDeleteListener aDeleteListener(rFormatFootnote.GetNotifier());
+
// read content of Ft-/End-Note
Read_HdFtFootnoteText( pSttIdx, rDesc.mnStartCp, rDesc.mnLen, rDesc.meType);
- bFtEdOk = true;
+
m_bFootnoteEdn = bOld;
- OSL_ENSURE(sChar.getLength()==1 && ((rDesc.mbAutoNum == (sChar[0] == 2))),
- "footnote autonumbering must be 0x02, and everything else must not be");
+ SAL_WARN_IF(aDeleteListener.WasDeleted(), "sw.ww8", "Footnode deleted during its import");
+ if (!aDeleteListener.WasDeleted())
+ {
+ bFtEdOk = true;
+
+ OSL_ENSURE(sChar.getLength()==1 && ((rDesc.mbAutoNum == (sChar[0] == 2))),
+ "footnote autonumbering must be 0x02, and everything else must not be");
- // If no automatic numbering use the following char from the main text
- // as the footnote number
- if (!rDesc.mbAutoNum)
- static_cast<SwTextFootnote*>(pFN)->SetNumber(0, 0, sChar);
+ // If no automatic numbering use the following char from the main text
+ // as the footnote number
+ if (!rDesc.mbAutoNum)
+ pFN->SetNumber(0, 0, sChar);
- /*
- Delete the footnote char from the footnote if its at the beginning
- as usual. Might not be if the user has already deleted it, e.g.
- #i14737#
- */
- SwNodeIndex& rNIdx = m_pPaM->GetPoint()->nNode;
- rNIdx = pSttIdx->GetIndex() + 1;
- SwTextNode* pTNd = rNIdx.GetNode().GetTextNode();
- if (pTNd && !pTNd->GetText().isEmpty() && !sChar.isEmpty())
- {
- const OUString &rText = pTNd->GetText();
- if (rText[0] == sChar[0])
+ /*
+ Delete the footnote char from the footnote if it's at the beginning
+ as usual. Might not be if the user has already deleted it, e.g.
+ #i14737#
+ */
+ SwPosition& rPaMPointPos = *m_pPaM->GetPoint();
+ rPaMPointPos.Assign(pSttIdx->GetIndex() + 1);
+ SwTextNode* pTNd = rPaMPointPos.GetNode().GetTextNode();
+ if (pTNd && !pTNd->GetText().isEmpty() && !sChar.isEmpty())
{
- // Allow MSO to emulate LO footnote text starting at left margin - only meaningful with hanging indent
- sal_Int32 nFirstLineIndent=0;
- SfxItemSet aSet( m_rDoc.GetAttrPool(), svl::Items<RES_LR_SPACE, RES_LR_SPACE>{} );
- if ( pTNd->GetAttr(aSet) )
+ const OUString &rText = pTNd->GetText();
+ if (rText[0] == sChar[0])
{
- const SvxLRSpaceItem* pLRSpace = aSet.GetItem<SvxLRSpaceItem>(RES_LR_SPACE);
- if ( pLRSpace )
- nFirstLineIndent = pLRSpace->GetTextFirstLineOffset();
- }
+ // Allow MSO to emulate LO footnote text starting at left margin - only meaningful with hanging indent
+ sal_Int32 nFirstLineIndent=0;
+ SfxItemSetFixed<RES_MARGIN_FIRSTLINE, RES_MARGIN_FIRSTLINE> aSet(m_rDoc.GetAttrPool());
+ if ( pTNd->GetAttr(aSet) )
+ {
+ const SvxFirstLineIndentItem *const pFirstLine(aSet.GetItem<SvxFirstLineIndentItem>(RES_MARGIN_FIRSTLINE));
+ if (pFirstLine)
+ {
+ nFirstLineIndent = pFirstLine->GetTextFirstLineOffset();
+ }
+ }
- m_pPaM->GetPoint()->nContent.Assign( pTNd, 0 );
- m_pPaM->SetMark();
- // Strip out aesthetic tabs we may have inserted on export #i24762#
- if (nFirstLineIndent < 0 && rText.getLength() > 1 && rText[1] == 0x09)
- ++m_pPaM->GetMark()->nContent;
- ++m_pPaM->GetMark()->nContent;
- m_xReffingStck->Delete(*m_pPaM);
- m_rDoc.getIDocumentContentOperations().DeleteRange( *m_pPaM );
- m_pPaM->DeleteMark();
+ rPaMPointPos.SetContent(0);
+ m_pPaM->SetMark();
+ // Strip out aesthetic tabs we may have inserted on export #i24762#
+ if (nFirstLineIndent < 0 && rText.getLength() > 1 && rText[1] == 0x09)
+ m_pPaM->GetMark()->AdjustContent(1);
+ m_pPaM->GetMark()->AdjustContent(1);
+ m_xReffingStck->Delete(*m_pPaM);
+ m_rDoc.getIDocumentContentOperations().DeleteRange( *m_pPaM );
+ m_pPaM->DeleteMark();
+ }
}
}
- *m_pPaM->GetPoint() = aTmpPos; // restore Cursor
+ *m_pPaM->GetPoint() = std::move(aTmpPos); // restore Cursor
- m_xPlcxMan = xOldPlcxMan; // Restore attributes
+ m_xPlcxMan = std::move(xOldPlcxMan); // Restore attributes
m_xPlcxMan->RestoreAllPLCFx( aSave );
}
@@ -292,8 +328,9 @@ tools::Long SwWW8ImplReader::Read_Footnote(WW8PLCFManResult* pRes)
Ignoring Footnote outside of the normal Text. People will put footnotes
into field results and field commands.
*/
- if (m_bIgnoreText ||
- m_pPaM->GetPoint()->nNode < m_rDoc.GetNodes().GetEndOfExtras().GetIndex())
+ bool bSplitFly = IsInSplitFly(*m_pPaM);
+ if (m_bIgnoreText
+ || (m_pPaM->GetPoint()->GetNode() < m_rDoc.GetNodes().GetEndOfExtras() && !bSplitFly))
{
return 0;
}
@@ -377,45 +414,6 @@ bool SwWW8ImplReader::SearchRowEnd(WW8PLCFx_Cp_FKP* pPap, WW8_CP &rStartCp,
return false;
}
-bool SwWW8ImplReader::SearchTableEnd(WW8PLCFx_Cp_FKP* pPap) const
-{
- if (m_bVer67)
- // The below SPRM is for WW8 only.
- return false;
-
- WW8PLCFxDesc aRes;
- aRes.pMemPos = nullptr;
- aRes.nEndPos = pPap->Where();
- std::set<std::pair<WW8_CP, WW8_CP>> aPrevRes;
-
- while (pPap->HasFkp() && pPap->Where() != WW8_CP_MAX)
- {
- // See if the current pap is outside the table.
- SprmResult aSprmRes = pPap->HasSprm(NS_sprm::PFInTable::val);
- const sal_uInt8* pB = aSprmRes.pSprm;
- if (!pB || aSprmRes.nRemainingData < 1 || *pB != 1)
- // Yes, this is the position after the end of the table.
- return true;
-
- // It is, so seek to the next pap.
- aRes.nStartPos = aRes.nEndPos;
- aRes.pMemPos = nullptr;
- if (!pPap->SeekPos(aRes.nStartPos))
- return false;
-
- // Read the sprms and make sure we moved forward to avoid infinite loops.
- pPap->GetSprms(&aRes);
- auto aBounds(std::make_pair(aRes.nStartPos, aRes.nEndPos));
- if (!aPrevRes.insert(aBounds).second) //already seen these bounds, infinite loop
- {
- SAL_WARN("sw.ww8", "SearchTableEnd, loop in paragraph property chain");
- break;
- }
- }
-
- return false;
-}
-
ApoTestResults SwWW8ImplReader::TestApo(int nCellLevel, bool bTableRowEnd,
const WW8_TablePos *pTabPos)
{
@@ -446,11 +444,12 @@ ApoTestResults SwWW8ImplReader::TestApo(int nCellLevel, bool bTableRowEnd,
to see if we are still in that frame.
*/
- aRet.m_bHasSprm37 = m_xPlcxMan->HasParaSprm(m_bVer67 ? 37 : 0x2423).pSprm != nullptr;
- SprmResult aSrpm29 = m_xPlcxMan->HasParaSprm(m_bVer67 ? 29 : 0x261B);
- const sal_uInt8 *pSrpm29 = aSrpm29.pSprm;
- aRet.m_bHasSprm29 = pSrpm29 != nullptr;
- aRet.m_nSprm29 = (pSrpm29 && aSrpm29.nRemainingData >= 1) ? *pSrpm29 : 0;
+ aRet.m_bHasSprmPWr = m_xPlcxMan->HasParaSprm(m_bVer67 ? 37 : 0x2423).pSprm != nullptr; // sprmPWr
+ SprmResult aSrpmPPc = m_xPlcxMan->HasParaSprm(m_bVer67 ? 29 : 0x261B); // sprmPPc
+ const sal_uInt8 *pSrpmPPc = aSrpmPPc.pSprm;
+ aRet.m_bHasSprmPPc = pSrpmPPc != nullptr;
+ const sal_Int16 nTPc = aRet.mpStyleApo ? aRet.mpStyleApo->nTPc : 0;
+ aRet.m_nSprmPPc = (pSrpmPPc && aSrpmPPc.nRemainingData >= 1) ? *pSrpmPPc : nTPc;
// Is there some frame data here
bool bNowApo = aRet.HasFrame() || pTopLevelTable;
@@ -581,11 +580,13 @@ static void SetBaseAnlv(SwNumFormat &rNum, WW8_ANLV const &rAV, sal_uInt8 nSwLev
if( rAV.nfc == 5 || rAV.nfc == 7 )
{
OUString sP = "." + rNum.GetSuffix();
- rNum.SetSuffix( sP ); // ordinal number
+ rNum.SetListFormat("", sP, nSwLevel); // ordinal number
}
+ else
+ rNum.SetListFormat("", "", nSwLevel);
}
-void SwWW8ImplReader::SetAnlvStrings(SwNumFormat &rNum, WW8_ANLV const &rAV,
+void SwWW8ImplReader::SetAnlvStrings(SwNumFormat &rNum, int nLevel, WW8_ANLV const &rAV,
const sal_uInt8* pText, size_t nStart, size_t nElements, bool bOutline)
{
if (nStart > nElements)
@@ -600,8 +601,8 @@ void SwWW8ImplReader::SetAnlvStrings(SwNumFormat &rNum, WW8_ANLV const &rAV,
const WW8_FFN* pF = m_xFonts->GetFont(SVBT16ToUInt16(rAV.ftc)); // FontInfo
bool bListSymbol = pF && ( pF->aFFNBase.chs == 2 ); // Symbol/WingDings/...
- OUStringBuffer sText;
sal_uInt32 nLen = rAV.cbTextBefore + rAV.cbTextAfter;
+ OUStringBuffer sText(static_cast<sal_Int32>(nLen));
if (m_bVer67)
{
if (nLen > nElements)
@@ -641,10 +642,9 @@ void SwWW8ImplReader::SetAnlvStrings(SwNumFormat &rNum, WW8_ANLV const &rAV,
if( bListSymbol )
{
// use cBulletChar for correct mapping on MAC
- OUStringBuffer aBuf;
- comphelper::string::padToLength(aBuf, rAV.cbTextBefore
+ sText.setLength(0);
+ comphelper::string::padToLength(sText, rAV.cbTextBefore
+ rAV.cbTextAfter, cBulletChar);
- sText = aBuf;
}
}
}
@@ -673,7 +673,7 @@ void SwWW8ImplReader::SetAnlvStrings(SwNumFormat &rNum, WW8_ANLV const &rAV,
if (rAV.cbTextBefore || rAV.cbTextAfter)
{
rNum.SetBulletChar(
- sText.toString().iterateCodePoints(&o3tl::temporary(sal_Int32(0))));
+ OUString::unacquired(sText).iterateCodePoints(&o3tl::temporary(sal_Int32(0))));
}
else
rNum.SetBulletChar( 0x2190 );
@@ -683,17 +683,19 @@ void SwWW8ImplReader::SetAnlvStrings(SwNumFormat &rNum, WW8_ANLV const &rAV,
if( !bInsert )
return;
+ OUString sPrefix;
+ OUString sSuffix;
if (rAV.cbTextBefore)
{
- OUString sP( sText.copy( 0, rAV.cbTextBefore ).makeStringAndClear() );
- rNum.SetPrefix( sP );
+ sPrefix = sText.copy( 0, rAV.cbTextBefore ).makeStringAndClear();
}
if( rAV.cbTextAfter )
{
- OUString sP( rNum.GetSuffix() );
- sP += sText.copy( rAV.cbTextBefore, rAV.cbTextAfter).makeStringAndClear();
- rNum.SetSuffix( sP );
+ sSuffix = rNum.GetSuffix() + sText.subView( rAV.cbTextBefore, rAV.cbTextAfter);
}
+
+ rNum.SetListFormat(sPrefix, sSuffix, nLevel);
+
// The characters before and after multiple digits do not apply because
// those are handled differently by the writer and the result is in most
// cases worse than without.
@@ -706,12 +708,13 @@ void SwWW8ImplReader::SetAnld(SwNumRule* pNumR, WW8_ANLD const * pAD, sal_uInt8
bool bOutLine)
{
SwNumFormat aNF;
+ aNF.SetListFormat("", "", nSwLevel);
if (pAD)
{ // there is an Anld-Sprm
m_bCurrentAND_fNumberAcross = 0 != pAD->fNumberAcross;
WW8_ANLV const &rAV = pAD->eAnlv;
SetBaseAnlv(aNF, rAV, nSwLevel); // set the base format
- SetAnlvStrings(aNF, rAV, pAD->rgchAnld, 0, SAL_N_ELEMENTS(pAD->rgchAnld), bOutLine); // set the rest
+ SetAnlvStrings(aNF, nSwLevel, rAV, pAD->rgchAnld, 0, SAL_N_ELEMENTS(pAD->rgchAnld), bOutLine); // set the rest
}
pNumR->Set(nSwLevel, aNF);
}
@@ -726,7 +729,7 @@ SwNumRule* SwWW8ImplReader::GetStyRule()
if( m_xStyles->mpStyRule ) // Bullet-Style already present
return m_xStyles->mpStyRule;
- const OUString aBaseName("WW8StyleNum");
+ constexpr OUString aBaseName(u"WW8StyleNum"_ustr);
const OUString aName( m_rDoc.GetUniqueNumRuleName( &aBaseName, false) );
// #i86652#
@@ -808,7 +811,7 @@ void SwWW8ImplReader::Read_ANLevelDesc( sal_uInt16, const sal_uInt8* pData, shor
// If NumRuleItems were set, either directly or through inheritance, disable them now
m_pCurrentColl->SetFormatAttr( SwNumRuleItem() );
- const OUString aName("Outline");
+ constexpr OUString aName(u"Outline"_ustr);
SwNumRule aNR( m_rDoc.GetUniqueNumRuleName( &aName ),
SvxNumberFormat::LABEL_WIDTH_AND_POSITION,
OUTLINE_RULE );
@@ -849,7 +852,7 @@ void SwWW8ImplReader::SetNumOlst(SwNumRule* pNumR, WW8_OLST* pO, sal_uInt8 nSwLe
if (!m_bVer67)
nTextOfs *= 2;
- SetAnlvStrings(aNF, rAV, pO->rgch, nTextOfs, SAL_N_ELEMENTS(pO->rgch), true); // and apply
+ SetAnlvStrings(aNF, nSwLevel, rAV, pO->rgch, nTextOfs, SAL_N_ELEMENTS(pO->rgch), true); // and apply
pNumR->Set(nSwLevel, aNF);
}
@@ -1028,7 +1031,7 @@ void SwWW8ImplReader::NextAnlLine(const sal_uInt8* pSprm13)
else
m_nSwNumLevel = 0xff; // no number
- SwTextNode* pNd = m_pPaM->GetNode().GetTextNode();
+ SwTextNode* pNd = m_pPaM->GetPointNode().GetTextNode();
if (!pNd)
return;
@@ -1055,7 +1058,7 @@ void SwWW8ImplReader::StopAnlToRestart(sal_uInt8 nNewType, bool bGoBack)
SwPosition aTmpPos(*m_pPaM->GetPoint());
m_pPaM->Move(fnMoveBackward, GoInContent);
m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_FLTR_NUMRULE);
- *m_pPaM->GetPoint() = aTmpPos;
+ *m_pPaM->GetPoint() = std::move(aTmpPos);
}
else
m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_FLTR_NUMRULE);
@@ -1102,14 +1105,6 @@ WW8TabBandDesc::WW8TabBandDesc( WW8TabBandDesc const & rBand )
// ReadDef reads the cell position and the borders of a band
void WW8TabBandDesc::ReadDef(bool bVer67, const sal_uInt8* pS, short nLen)
{
- if (!bVer67)
- {
- //the ww8 version of this is unusual in masquerading as a srpm with a
- //single byte len arg while it really has a word len arg, after this
- //increment nLen is correct to describe the remaining amount of data
- pS++;
- }
-
--nLen; //reduce len by expected nCols arg
if (nLen < 0)
return;
@@ -1792,7 +1787,7 @@ WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp) :
m_pTable(nullptr),
m_pParentPos(nullptr),
m_pFlyFormat(nullptr),
- m_aItemSet(m_pIo->m_rDoc.GetAttrPool(),svl::Items<RES_FRMATR_BEGIN,RES_FRMATR_END-1>{})
+ m_aItemSet(m_pIo->m_rDoc.GetAttrPool(),svl::Items<RES_FRMATR_BEGIN,RES_FRMATR_END-1>)
{
m_pIo->m_bCurrentAND_fNumberAcross = false;
@@ -1813,6 +1808,8 @@ WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp) :
wwSprmParser aSprmParser(m_pIo->GetFib());
+ std::set<std::pair<WW8_CP, WW8_CP>> aPrevRes;
+
// process pPap until end of table found
do
{
@@ -2060,7 +2057,7 @@ WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp) :
//Get the end of row new table positioning data
WW8_CP nMyStartCp=nStartCp;
if (m_pIo->SearchRowEnd(pPap, nMyStartCp, m_pIo->m_nInTable))
- if (m_pIo->ParseTabPos(&aTabPos, pPap))
+ if (SwWW8ImplReader::ParseTabPos(&aTabPos, pPap))
pTabPos = &aTabPos;
//Move back to this cell
@@ -2098,9 +2095,10 @@ WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp) :
break;
}
- if (nStartCp == aRes.nEndPos)
+ auto aBounds(std::make_pair(aRes.nStartPos, aRes.nEndPos));
+ if (!aPrevRes.insert(aBounds).second) //already seen these bounds, infinite loop
{
- SAL_WARN("sw.ww8", "WW8TabDesc End same as Start, abandoning to avoid looping");
+ SAL_WARN("sw.ww8", "WW8TabDesc, loop in paragraph property chain");
break;
}
nStartCp = aRes.nEndPos;
@@ -2358,7 +2356,7 @@ void wwSectionManager::PrependedInlineNode(const SwPosition &rPos,
{
OSL_ENSURE(!maSegments.empty(),
"should not be possible, must be at least one segment");
- if ((!maSegments.empty()) && (maSegments.back().maStart == rPos.nNode))
+ if ((!maSegments.empty()) && (maSegments.back().maStart == rPos.GetNode()))
maSegments.back().maStart.Assign(rNode);
}
@@ -2369,7 +2367,7 @@ void WW8TabDesc::CreateSwTable()
// if there is already some content on the Node append new node to ensure
// that this content remains ABOVE the table
SwPosition* pPoint = m_pIo->m_pPaM->GetPoint();
- bool bInsNode = pPoint->nContent.GetIndex() != 0;
+ bool bInsNode = pPoint->GetContentIndex() != 0;
bool bSetMinHeight = false;
/*
@@ -2381,9 +2379,9 @@ void WW8TabDesc::CreateSwTable()
? m_pIo->m_xFormatOfJustInsertedApo->GetFormat() : nullptr;
if (pFormat)
{
- const SwPosition* pAPos =
- pFormat->GetAnchor().GetContentAnchor();
- if (pAPos && &pAPos->nNode.GetNode() == &pPoint->nNode.GetNode())
+ const SwNode* pAnchorNode =
+ pFormat->GetAnchor().GetAnchorNode();
+ if (pAnchorNode && *pAnchorNode == pPoint->GetNode())
{
bInsNode = true;
bSetMinHeight = true;
@@ -2404,14 +2402,14 @@ void WW8TabDesc::CreateSwTable()
}
if (bInsNode)
- m_pIo->AppendTextNode(*pPoint);
+ m_pIo->FinalizeTextNode(*pPoint);
- m_xTmpPos.reset(new SwPosition(*m_pIo->m_pPaM->GetPoint()));
+ m_xTmpPos = m_pIo->m_rDoc.CreateUnoCursor(*m_pIo->m_pPaM->GetPoint());
// Because SW cannot handle multi-page floating frames,
// _any unnecessary_ floating tables have been converted to inline.
tools::Long nLeft = 0;
- if ( m_pIo->m_xSFlyPara && !m_pIo->m_xSFlyPara->pFlyFormat )
+ if (m_pIo->m_xSFlyPara && !m_pIo->m_xSFlyPara->GetFlyFormat())
{
// Get the table orientation from the fly
// Do we also need to check m_pIo->m_xSFlyPara->bTogglePos/IsPosToggle()? [Probably not - layout-only concern]
@@ -2441,7 +2439,7 @@ void WW8TabDesc::CreateSwTable()
// rows of a band can be duplicated easy.
m_pTable = m_pIo->m_rDoc.InsertTable(
SwInsertTableOptions( SwInsertTableFlags::HeadlineNoBorder, 0 ),
- *m_xTmpPos, m_nBands, m_nDefaultSwCols, m_eOri );
+ *m_xTmpPos->GetPoint(), m_nBands, m_nDefaultSwCols, m_eOri );
OSL_ENSURE(m_pTable && m_pTable->GetFrameFormat(), "insert table failed");
if (!m_pTable || !m_pTable->GetFrameFormat())
@@ -2459,23 +2457,22 @@ void WW8TabDesc::CreateSwTable()
// contains a Pagedesc. If so that Pagedesc would be moved to the
// row after the table, that would be wrong. So delete and
// set later to the table format.
- if (SwTextNode *const pNd = m_xTmpPos->nNode.GetNode().GetTextNode())
+ if (SwTextNode *const pNd = m_xTmpPos->GetPoint()->GetNode().GetTextNode())
{
if (const SfxItemSet* pSet = pNd->GetpSwAttrSet())
{
- SfxPoolItem *pSetAttr = nullptr;
- const SfxPoolItem* pItem;
- if (SfxItemState::SET == pSet->GetItemState(RES_BREAK, false, &pItem))
+ std::unique_ptr<SfxPoolItem> pSetAttr;
+
+ if (const SvxFormatBreakItem* pBreakItem = pSet->GetItemIfSet(RES_BREAK, false))
{
- pSetAttr = new SvxFormatBreakItem( *static_cast<const SvxFormatBreakItem*>(pItem) );
+ pSetAttr.reset(new SvxFormatBreakItem( *pBreakItem ));
pNd->ResetAttr( RES_BREAK );
}
// eventually set the PageDesc/Break now to the table
if (pSetAttr)
{
- m_aItemSet.Put(*pSetAttr);
- delete pSetAttr;
+ m_aItemSet.Put(std::move(pSetAttr));
}
}
}
@@ -2485,7 +2482,7 @@ void WW8TabDesc::CreateSwTable()
{
SwFormatFrameSize aFrameSize(SwFrameSize::Fixed, m_nSwWidth);
// Don't set relative width if the table is in a floating frame
- if ( m_nPercentWidth && (!m_pIo->m_xSFlyPara || !m_pIo->m_xSFlyPara->pFlyFormat) )
+ if ( m_nPercentWidth && (!m_pIo->m_xSFlyPara || !m_pIo->m_xSFlyPara->GetFlyFormat()) )
aFrameSize.SetWidthPercent(m_nPercentWidth);
m_pTable->GetFrameFormat()->SetFormatAttr(aFrameSize);
m_aItemSet.Put(aFrameSize);
@@ -2498,12 +2495,12 @@ void WW8TabDesc::CreateSwTable()
if (text::HoriOrientation::LEFT_AND_WIDTH == m_eOri)
{
if (!m_pIo->m_nInTable && m_pIo->InLocalApo() && m_pIo->m_xSFlyPara &&
- m_pIo->m_xSFlyPara->pFlyFormat && GetMinLeft())
+ m_pIo->m_xSFlyPara->GetFlyFormat() && GetMinLeft())
{
//If we are inside a frame and we have a border, the frames
//placement does not consider the tables border, which word
//displays outside the frame, so adjust here.
- SwFormatHoriOrient aHori(m_pIo->m_xSFlyPara->pFlyFormat->GetHoriOrient());
+ SwFormatHoriOrient aHori(m_pIo->m_xSFlyPara->GetFlyFormat()->GetHoriOrient());
sal_Int16 eHori = aHori.GetHoriOrient();
if ((eHori == text::HoriOrientation::NONE) || (eHori == text::HoriOrientation::LEFT) ||
(eHori == text::HoriOrientation::LEFT_AND_WIDTH))
@@ -2512,7 +2509,7 @@ void WW8TabDesc::CreateSwTable()
//the maximum is what word does ?
aHori.SetPos(m_pIo->m_xSFlyPara->nXPos + GetMinLeft());
aHori.SetHoriOrient(text::HoriOrientation::NONE);
- m_pIo->m_xSFlyPara->pFlyFormat->SetFormatAttr(aHori);
+ m_pIo->m_xSFlyPara->GetFlyFormat()->SetFormatAttr(aHori);
}
}
else // Not directly in a floating frame.
@@ -2553,7 +2550,7 @@ void WW8TabDesc::UseSwTable()
OSL_ENSURE( m_pTableNd, "Where is my table node" );
// #i69519# - Restrict rows to repeat to a decent value
- if ( m_nRowsToRepeat == static_cast<sal_uInt16>(m_nRows) )
+ if ( m_nRowsToRepeat == o3tl::narrowing<sal_uInt16>(m_nRows) )
m_nRowsToRepeat = 1;
m_pTableNd->GetTable().SetRowsToRepeat( m_nRowsToRepeat );
@@ -2588,9 +2585,9 @@ void WW8TabDesc::MergeCells()
// start a new merge group if appropriate
- OSL_ENSURE(nRow < static_cast<sal_uInt16>(m_pTabLines->size()),
+ OSL_ENSURE(nRow < o3tl::narrowing<sal_uInt16>(m_pTabLines->size()),
"Too few lines, table ended early");
- if (nRow >= static_cast<sal_uInt16>(m_pTabLines->size()))
+ if (nRow >= o3tl::narrowing<sal_uInt16>(m_pTabLines->size()))
return;
m_pTabLine = (*m_pTabLines)[ nRow ];
m_pTabBoxes = &m_pTabLine->GetTabBoxes();
@@ -2642,14 +2639,14 @@ void WW8TabDesc::MergeCells()
if( rCell.bVertMerge && !rCell.bVertRestart )
{
SwPaM aPam( *m_pTabBox->GetSttNd(), 0 );
- aPam.GetPoint()->nNode++;
- SwTextNode* pNd = aPam.GetNode().GetTextNode();
+ aPam.GetPoint()->Adjust(SwNodeOffset(1));
+ SwTextNode* pNd = aPam.GetPointNode().GetTextNode();
while( pNd )
{
pNd->SetCountedInList( false );
- aPam.GetPoint()->nNode++;
- pNd = aPam.GetNode().GetTextNode();
+ aPam.GetPoint()->Adjust(SwNodeOffset(1));
+ pNd = aPam.GetPointNode().GetTextNode();
}
}
@@ -2674,7 +2671,7 @@ void WW8TabDesc::MergeCells()
}
else
break;
- pActMGroup->nGroupWidth = nSizCell;
+ pActMGroup->m_nGroupWidth = nSizCell;
// locked previously created merge groups,
// after determining the size for the new merge group.
@@ -2683,12 +2680,12 @@ void WW8TabDesc::MergeCells()
for (;;)
{
WW8SelBoxInfo* p = FindMergeGroup(
- nX1, pActMGroup->nGroupWidth, false );
+ nX1, pActMGroup->m_nGroupWidth, false );
if (p == nullptr)
{
break;
}
- p->bGroupLocked = true;
+ p->m_bGroupLocked = true;
}
// 3. push to group array
@@ -2699,7 +2696,7 @@ void WW8TabDesc::MergeCells()
// (that can be a newly created or another group)
UpdateTableMergeGroup( rCell, pActMGroup, m_pTabBox, i );
}
- }
+ }
}
}
@@ -2711,7 +2708,7 @@ void WW8TabDesc::ParkPaM()
{
SwTableBox *pTabBox2 = nullptr;
short nRow = m_nCurrentRow + 1;
- if (nRow < static_cast<sal_uInt16>(m_pTabLines->size()))
+ if (nRow < o3tl::narrowing<sal_uInt16>(m_pTabLines->size()))
{
if (SwTableLine *pLine = (*m_pTabLines)[nRow])
{
@@ -2726,18 +2723,18 @@ void WW8TabDesc::ParkPaM()
return;
}
- sal_uLong nSttNd = pTabBox2->GetSttIdx() + 1,
+ SwNodeOffset nSttNd = pTabBox2->GetSttIdx() + 1,
nEndNd = pTabBox2->GetSttNd()->EndOfSectionIndex();
- if (m_pIo->m_pPaM->GetPoint()->nNode != nSttNd)
+ if (m_pIo->m_pPaM->GetPoint()->GetNodeIndex() != nSttNd)
{
do
{
- m_pIo->m_pPaM->GetPoint()->nNode = nSttNd;
+ m_pIo->m_pPaM->GetPoint()->Assign(nSttNd);
}
- while (m_pIo->m_pPaM->GetNode().GetNodeType() != SwNodeType::Text && ++nSttNd < nEndNd);
+ while (m_pIo->m_pPaM->GetPointNode().GetNodeType() != SwNodeType::Text && ++nSttNd < nEndNd);
- m_pIo->m_pPaM->GetPoint()->nContent.Assign(m_pIo->m_pPaM->GetContentNode(), 0);
+ m_pIo->m_pPaM->GetPoint()->SetContent(0);
m_pIo->m_rDoc.SetTextFormatColl(*m_pIo->m_pPaM, const_cast<SwTextFormatColl*>(m_pIo->m_pDfltTextFormatColl));
}
}
@@ -2746,15 +2743,25 @@ void WW8TabDesc::MoveOutsideTable()
{
OSL_ENSURE(m_xTmpPos && m_pIo, "I've forgotten where the table is anchored");
if (m_xTmpPos && m_pIo)
- *m_pIo->m_pPaM->GetPoint() = *m_xTmpPos;
+ *m_pIo->m_pPaM->GetPoint() = *m_xTmpPos->GetPoint();
}
void WW8TabDesc::FinishSwTable()
{
m_pIo->m_xRedlineStack->closeall(*m_pIo->m_pPaM->GetPoint());
- m_pIo->m_aFrameRedlines.emplace(std::move(m_pIo->m_xRedlineStack));
+
+ // ofz#38011 drop m_pLastAnchorPos during RedlineStack dtor and restore it afterwards to the same
+ // place, or somewhere close if that place got destroyed
+ std::shared_ptr<SwUnoCursor> xLastAnchorCursor(m_pIo->m_oLastAnchorPos ? m_pIo->m_rDoc.CreateUnoCursor(*m_pIo->m_oLastAnchorPos) : nullptr);
+ m_pIo->m_oLastAnchorPos.reset();
+
+ SwTableNode* pTableNode = m_pTable->GetTableNode();
+ SwDeleteListener aListener(*pTableNode);
m_pIo->m_xRedlineStack = std::move(mxOldRedlineStack);
+ if (xLastAnchorCursor)
+ m_pIo->m_oLastAnchorPos.emplace(*xLastAnchorCursor->GetPoint());
+
WW8DupProperties aDup(m_pIo->m_rDoc,m_pIo->m_xCtrlStck.get());
m_pIo->m_xCtrlStck->SetAttr( *m_pIo->m_pPaM->GetPoint(), 0, false);
@@ -2768,6 +2775,9 @@ void WW8TabDesc::FinishSwTable()
m_pIo->m_aInsertedTables.InsertTable(*m_pTableNd, *m_pIo->m_pPaM);
+ if (aListener.WasDeleted())
+ throw std::runtime_error("table unexpectedly destroyed by applying redlines");
+
MergeCells();
// if needed group cells together that should be merged
@@ -2780,7 +2790,7 @@ void WW8TabDesc::FinishSwTable()
if((1 < groupIt->size()) && groupIt->row(0)[0])
{
SwFrameFormat* pNewFormat = groupIt->row(0)[0]->ClaimFrameFormat();
- pNewFormat->SetFormatAttr(SwFormatFrameSize(SwFrameSize::Variable, groupIt->nGroupWidth, 0));
+ pNewFormat->SetFormatAttr(SwFormatFrameSize(SwFrameSize::Variable, groupIt->m_nGroupWidth, 0));
const sal_uInt16 nRowSpan = groupIt->rowsCount();
for (sal_uInt16 n = 0; n < nRowSpan; ++n)
{
@@ -2832,12 +2842,12 @@ WW8SelBoxInfo* WW8TabDesc::FindMergeGroup(short nX1, short nWidth, bool bExact)
{
// the currently inspected group
WW8SelBoxInfo& rActGroup = *m_MergeGroups[ iGr ];
- if (!rActGroup.bGroupLocked)
+ if (!rActGroup.m_bGroupLocked)
{
// approximate group boundary with room (tolerance) to the *outside*
- nGrX1 = rActGroup.nGroupXStart - nTolerance;
- nGrX2 = rActGroup.nGroupXStart
- + rActGroup.nGroupWidth + nTolerance;
+ nGrX1 = rActGroup.m_nGroupXStart - nTolerance;
+ nGrX2 = rActGroup.m_nGroupXStart
+ + rActGroup.m_nGroupWidth + nTolerance;
// If box fits report success
@@ -2887,7 +2897,7 @@ bool WW8TabDesc::InFirstParaInCell() const
if (!IsValidCell(GetCurrentCol()))
return false;
- return m_pIo->m_pPaM->GetPoint()->nNode == m_pTabBox->GetSttIdx() + 1;
+ return m_pIo->m_pPaM->GetPoint()->GetNodeIndex() == m_pTabBox->GetSttIdx() + 1;
}
void WW8TabDesc::SetPamInCell(short nWwCol, bool bPam)
@@ -2957,16 +2967,16 @@ void WW8TabDesc::SetPamInCell(short nWwCol, bool bPam)
//or not so that we can collect paragraph properties over
//all the cells, but in that case on the valid cell we do not
//want to reset the fmt properties
- sal_uLong nSttNd = m_pTabBox->GetSttIdx() + 1,
+ SwNodeOffset nSttNd = m_pTabBox->GetSttIdx() + 1,
nEndNd = m_pTabBox->GetSttNd()->EndOfSectionIndex();
- if (m_pIo->m_pPaM->GetPoint()->nNode != nSttNd)
+ if (m_pIo->m_pPaM->GetPoint()->GetNodeIndex() != nSttNd)
{
do
{
- m_pIo->m_pPaM->GetPoint()->nNode = nSttNd;
+ m_pIo->m_pPaM->GetPoint()->Assign(nSttNd);
}
- while (m_pIo->m_pPaM->GetNode().GetNodeType() != SwNodeType::Text && ++nSttNd < nEndNd);
- m_pIo->m_pPaM->GetPoint()->nContent.Assign(m_pIo->m_pPaM->GetContentNode(), 0);
+ while (m_pIo->m_pPaM->GetPointNode().GetNodeType() != SwNodeType::Text && ++nSttNd < nEndNd);
+ m_pIo->m_pPaM->GetPoint()->SetContent(0);
// Precautionally set now, otherwise the style is not set for cells
// that are inserted for margin balancing.
m_pIo->m_rDoc.SetTextFormatColl(*m_pIo->m_pPaM, const_cast<SwTextFormatColl*>(m_pIo->m_pDfltTextFormatColl));
@@ -2975,7 +2985,8 @@ void WW8TabDesc::SetPamInCell(short nWwCol, bool bPam)
}
// Better to turn Snap to Grid off for all paragraphs in tables
- SwTextNode *pNd = m_pIo->m_pPaM->GetNode().GetTextNode();
+ SwPosition* pGridPos = m_pIo->m_pPaM->GetPoint();
+ SwTextNode *pNd = pGridPos->GetNode().GetTextNode();
if(!pNd)
return;
@@ -2988,12 +2999,10 @@ void WW8TabDesc::SetPamInCell(short nWwCol, bool bPam)
SvxParaGridItem aGridItem( rSnapToGrid );
aGridItem.SetValue(false);
- SwPosition* pGridPos = m_pIo->m_pPaM->GetPoint();
-
- const sal_Int32 nEnd = pGridPos->nContent.GetIndex();
- pGridPos->nContent.Assign(m_pIo->m_pPaM->GetContentNode(), 0);
+ const sal_Int32 nEnd = pGridPos->GetContentIndex();
+ pGridPos->SetContent(0);
m_pIo->m_xCtrlStck->NewAttr(*pGridPos, aGridItem);
- pGridPos->nContent.Assign(m_pIo->m_pPaM->GetContentNode(), nEnd);
+ pGridPos->SetContent(nEnd);
m_pIo->m_xCtrlStck->SetAttr(*pGridPos, RES_PARATR_SNAPTOGRID);
}
@@ -3085,7 +3094,7 @@ void WW8TabDesc::SetTabShades( SwTableBox* pBox, short nWwIdx )
return;
SwWW8Shade aSh( m_pIo->m_bVer67, rSHD );
- pBox->GetFrameFormat()->SetFormatAttr(SvxBrushItem(aSh.aColor, RES_BACKGROUND));
+ pBox->GetFrameFormat()->SetFormatAttr(SvxBrushItem(aSh.m_aColor, RES_BACKGROUND));
}
}
@@ -3159,7 +3168,7 @@ void WW8TabDesc::AdjustNewBand()
InsertCells( m_pActBand->nSwCols - m_nDefaultSwCols );
SetPamInCell( 0, false);
- OSL_ENSURE( m_pTabBoxes && m_pTabBoxes->size() == static_cast<sal_uInt16>(m_pActBand->nSwCols),
+ OSL_ENSURE( m_pTabBoxes && m_pTabBoxes->size() == o3tl::narrowing<sal_uInt16>(m_pActBand->nSwCols),
"Wrong column count in table" );
if( m_bClaimLineFormat )
@@ -3223,7 +3232,7 @@ void WW8TabDesc::AdjustNewBand()
SetTabBorders(pBox, j);
- SvxBoxItem aCurrentBox(sw::util::ItemGet<SvxBoxItem>(*(pBox->GetFrameFormat()), RES_BOX));
+ SvxBoxItem aCurrentBox(pBox->GetFrameFormat()->GetFormatAttr(RES_BOX));
pBox->GetFrameFormat()->SetFormatAttr(aCurrentBox);
SetTabVertAlign(pBox, j);
@@ -3410,8 +3419,8 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp)
m_aSectionManager.GetTextAreaWidth(),
m_nIniFlyDx, m_nIniFlyDy);
- // #i45301# - anchor nested table Writer fly frame at-character
- eAnchor = RndStdIds::FLY_AT_CHAR;
+ // #i45301# - anchor nested table Writer fly frame
+ eAnchor = RndStdIds::FLY_AT_PARA;
}
}
}
@@ -3429,12 +3438,11 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp)
{
int nNewInTable = m_nInTable + 1;
- if ((eAnchor == RndStdIds::FLY_AT_CHAR)
+ if ((eAnchor == RndStdIds::FLY_AT_PARA)
&& !m_aTableStack.empty() && !InEqualApo(nNewInTable) )
{
m_xTableDesc->m_pParentPos = new SwPosition(*m_pPaM->GetPoint());
- SfxItemSet aItemSet(m_rDoc.GetAttrPool(),
- svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1>{});
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aItemSet(m_rDoc.GetAttrPool());
// #i33818# - anchor the Writer fly frame for the nested table at-character.
// #i45301#
SwFormatAnchor aAnchor( eAnchor );
@@ -3455,9 +3463,12 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp)
if ( pTableWFlyPara && pTableSFlyPara )
{
WW8FlySet aFlySet( *this, pTableWFlyPara.get(), pTableSFlyPara, false );
- SwFormatAnchor aAnchor( RndStdIds::FLY_AT_CHAR );
+ // At-para, so it can split in the multi-page case.
+ SwFormatAnchor aAnchor(RndStdIds::FLY_AT_PARA);
aAnchor.SetAnchor( m_xTableDesc->m_pParentPos );
aFlySet.Put( aAnchor );
+ // Map a positioned inner table to a split fly.
+ aFlySet.Put(SwFormatFlySplit(true));
m_xTableDesc->m_pFlyFormat->SetFormatAttr( aFlySet );
}
else
@@ -3486,6 +3497,8 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp)
void SwWW8ImplReader::TabCellEnd()
{
+ FinalizeTextNode(*m_pPaM->GetPoint(), false);
+
if (m_nInTable && m_xTableDesc)
m_xTableDesc->TableCellEnd();
@@ -3607,9 +3620,6 @@ void WW8RStyle::ImportSprms(sal_uInt8 *pSprms, short nLen, bool bPap)
WW8SprmIter aSprmIter(pSprms, nLen, maSprmParser);
while (const sal_uInt8* pSprm = aSprmIter.GetSprms())
{
-#ifdef DEBUGSPRMREADER
- fprintf(stderr, "id is %x\n", aIter.GetCurrentId());
-#endif
mpIo->ImportSprm(pSprm, aSprmIter.GetRemLen(), aSprmIter.GetCurrentId());
aSprmIter.advance();
}
@@ -3782,7 +3792,10 @@ void WW8RStyle::Set1StyleDefaults()
}
}
-bool WW8RStyle::PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle)
+bool WW8RStyle::PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle,
+ sal_uInt16 nNextStyle,
+ std::map<OUString, sal_Int32>& rParaCollisions,
+ std::map<OUString, sal_Int32>& rCharCollisions)
{
SwFormat* pColl;
bool bStyExist;
@@ -3791,7 +3804,7 @@ bool WW8RStyle::PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisSty
{
// Para-Style
sw::util::ParaStyleMapper::StyleResult aResult =
- mpIo->m_aParaStyleMapper.GetStyle(rSI.GetOrgWWName(), eSti);
+ mpIo->m_aParaStyleMapper.GetStyle(rSI.GetOrgWWName(), eSti, rParaCollisions);
pColl = aResult.first;
bStyExist = aResult.second;
}
@@ -3799,7 +3812,7 @@ bool WW8RStyle::PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisSty
{
// Char-Style
sw::util::CharStyleMapper::StyleResult aResult =
- mpIo->m_aCharStyleMapper.GetStyle(rSI.GetOrgWWName(), eSti);
+ mpIo->m_aCharStyleMapper.GetStyle(rSI.GetOrgWWName(), eSti, rCharCollisions);
pColl = aResult.first;
bStyExist = aResult.second;
}
@@ -3888,7 +3901,9 @@ void WW8RStyle::PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp)
mpIo->m_nListLevel = MAXLEVEL;
}
-void WW8RStyle::Import1Style( sal_uInt16 nNr )
+void WW8RStyle::Import1Style(sal_uInt16 nNr,
+ std::map<OUString, sal_Int32>& rParaCollisions,
+ std::map<OUString, sal_Int32>& rCharCollisions)
{
if (nNr >= mpIo->m_vColl.size())
return;
@@ -3903,14 +3918,14 @@ void WW8RStyle::Import1Style( sal_uInt16 nNr )
// valid and not NUL and not yet imported
if( rSI.m_nBase < m_cstd && !mpIo->m_vColl[rSI.m_nBase].m_bImported )
- Import1Style( rSI.m_nBase );
+ Import1Style(rSI.m_nBase, rParaCollisions, rCharCollisions);
mpStStrm->Seek( rSI.m_nFilePos );
sal_uInt16 nSkip;
OUString sName;
- std::unique_ptr<WW8_STD> xStd(Read1Style(nSkip, &sName));// read Style
+ std::unique_ptr<WW8_STD> xStd(Read1Style(nSkip, &sName)); // read Style
if (xStd)
rSI.SetOrgWWIdent( sName, xStd->sti );
@@ -3924,10 +3939,12 @@ void WW8RStyle::Import1Style( sal_uInt16 nNr )
return;
}
- bool bOldNoImp = PrepareStyle(rSI, static_cast<ww::sti>(xStd->sti), nNr, xStd->istdNext);
+ bool bOldNoImp = PrepareStyle(rSI, static_cast<ww::sti>(xStd->sti),
+ nNr, xStd->istdNext,
+ rParaCollisions, rCharCollisions);
// if something is interpreted wrong, this should make it work again
- tools::Long nPos = mpStStrm->Tell();
+ sal_uInt64 nPos = mpStStrm->Tell();
//Variable parts of the STD start at even byte offsets, but "inside
//the STD", which I take to meaning even in relation to the starting
@@ -4022,29 +4039,29 @@ void WW8RStyle::ScanStyles() // investigate style dependencies
std::vector<sal_uInt8> ChpxToSprms(const Word2CHPX &rChpx)
{
- std::vector<sal_uInt8> aRet;
-
- aRet.push_back(60);
- aRet.push_back( static_cast< sal_uInt8 >(128 + rChpx.fBold) );
-
- aRet.push_back(61);
- aRet.push_back( static_cast< sal_uInt8 >(128 + rChpx.fItalic) );
+ std::vector<sal_uInt8> aRet
+ {
+ 60,
+ static_cast< sal_uInt8 >(128 + rChpx.fBold),
- aRet.push_back(62);
- aRet.push_back( static_cast< sal_uInt8 >(128 + rChpx.fStrike) );
+ 61,
+ static_cast< sal_uInt8 >(128 + rChpx.fItalic),
- aRet.push_back(63);
- aRet.push_back( static_cast< sal_uInt8 >(128 + rChpx.fOutline) );
+ 62,
+ static_cast< sal_uInt8 >(128 + rChpx.fStrike),
- aRet.push_back(65);
- aRet.push_back( static_cast< sal_uInt8 >(128 + rChpx.fSmallCaps) );
+ 63,
+ static_cast< sal_uInt8 >(128 + rChpx.fOutline),
- aRet.push_back(66);
- aRet.push_back( static_cast< sal_uInt8 >(128 + rChpx.fCaps) );
+ 65,
+ static_cast< sal_uInt8 >(128 + rChpx.fSmallCaps),
- aRet.push_back(67);
- aRet.push_back( static_cast< sal_uInt8 >(128 + rChpx.fVanish) );
+ 66,
+ static_cast< sal_uInt8 >(128 + rChpx.fCaps),
+ 67,
+ static_cast< sal_uInt8 >(128 + rChpx.fVanish)
+ };
if (rChpx.fsFtc)
{
aRet.push_back(68);
@@ -4136,10 +4153,19 @@ Word2CHPX ReadWord2Chpx(SvStream &rSt, std::size_t nOffset, sal_uInt8 nSize)
{
Word2CHPX aChpx;
- if (!nSize)
+ if (!nSize || !checkSeek(rSt, nOffset))
return aChpx;
- rSt.Seek(nOffset);
+ const size_t nMaxByteCount = rSt.remainingSize();
+ if (!nMaxByteCount)
+ return aChpx;
+
+ if (nSize > nMaxByteCount)
+ {
+ SAL_WARN("sw.ww8", "ReadWord2Chpx: truncating out of range "
+ << nSize << " to " << nMaxByteCount);
+ nSize = nMaxByteCount;
+ }
sal_uInt8 nCount=0;
@@ -4149,6 +4175,9 @@ Word2CHPX ReadWord2Chpx(SvStream &rSt, std::size_t nOffset, sal_uInt8 nSize)
rSt.ReadUChar( nFlags8 );
nCount++;
+ if (!rSt.good())
+ break;
+
aChpx.fBold = nFlags8 & 0x01;
aChpx.fItalic = (nFlags8 & 0x02) >> 1;
aChpx.fRMarkDel = (nFlags8 & 0x04) >> 2;
@@ -4162,6 +4191,9 @@ Word2CHPX ReadWord2Chpx(SvStream &rSt, std::size_t nOffset, sal_uInt8 nSize)
rSt.ReadUChar( nFlags8 );
nCount++;
+ if (!rSt.good())
+ break;
+
aChpx.fRMark = nFlags8 & 0x01;
aChpx.fSpec = (nFlags8 & 0x02) >> 1;
aChpx.fStrike = (nFlags8 & 0x04) >> 2;
@@ -4175,6 +4207,9 @@ Word2CHPX ReadWord2Chpx(SvStream &rSt, std::size_t nOffset, sal_uInt8 nSize)
rSt.ReadUChar( nFlags8 );
nCount++;
+ if (!rSt.good())
+ break;
+
aChpx.fsIco = nFlags8 & 0x01;
aChpx.fsFtc = (nFlags8 & 0x02) >> 1;
aChpx.fsHps = (nFlags8 & 0x04) >> 2;
@@ -4188,6 +4223,9 @@ Word2CHPX ReadWord2Chpx(SvStream &rSt, std::size_t nOffset, sal_uInt8 nSize)
rSt.ReadUChar( nFlags8 );
nCount++;
+ if (!rSt.good())
+ break;
+
aChpx.fsFtcBi = nFlags8 & 0x01;
aChpx.fsHpsBi = (nFlags8 & 0x02) >> 1;
aChpx.fsLidBi = (nFlags8 & 0x04) >> 2;
@@ -4204,6 +4242,9 @@ Word2CHPX ReadWord2Chpx(SvStream &rSt, std::size_t nOffset, sal_uInt8 nSize)
rSt.ReadUChar( nFlags8 );
nCount++;
+ if (!rSt.good())
+ break;
+
aChpx.qpsSpace = nFlags8 & 0x3F;
aChpx.fSysVanish = (nFlags8 & 0x40) >> 6;
aChpx.fNumRun = (nFlags8 & 0x80) >> 7;
@@ -4212,6 +4253,9 @@ Word2CHPX ReadWord2Chpx(SvStream &rSt, std::size_t nOffset, sal_uInt8 nSize)
rSt.ReadUChar( nFlags8 );
nCount++;
+ if (!rSt.good())
+ break;
+
aChpx.ico = nFlags8 & 0x1F;
aChpx.kul = (nFlags8 & 0xE0) >> 5;
@@ -4417,6 +4461,9 @@ void WW8RStyle::ImportOldFormatStyles()
if (iMac > nStyles) iMac = nStyles;
+ std::map<OUString, sal_Int32> aParaCollisions;
+ std::map<OUString, sal_Int32> aCharCollisions;
+
for (stcp = 0; stcp < iMac; ++stcp)
{
sal_uInt8 stcNext(0), stcBase(0);
@@ -4448,7 +4495,9 @@ void WW8RStyle::ImportOldFormatStyles()
if (ww::StandardStiIsCharStyle(eSti) && !aPAPXOffsets[stcp].mnSize)
mpIo->m_vColl[stc].m_bColl = false;
- bool bOldNoImp = PrepareStyle(rSI, eSti, stc, stcNext);
+ bool bOldNoImp = PrepareStyle(rSI, eSti, stc, stcNext,
+ aParaCollisions,
+ aCharCollisions);
ImportSprms(aPAPXOffsets[stcp].mnOffset, aPAPXOffsets[stcp].mnSize,
true);
@@ -4466,9 +4515,12 @@ void WW8RStyle::ImportNewFormatStyles()
{
ScanStyles(); // Scan Based On
+ std::map<OUString, sal_Int32> aParaCollisions;
+ std::map<OUString, sal_Int32> aCharCollisions;
+
for (sal_uInt16 i = 0; i < m_cstd; ++i) // import Styles
if (mpIo->m_vColl[i].m_bValid)
- Import1Style( i );
+ Import1Style(i, aParaCollisions, aCharCollisions);
}
void WW8RStyle::Import()
diff --git a/sw/source/filter/ww8/ww8par2.hxx b/sw/source/filter/ww8/ww8par2.hxx
index ac35b4813b8f..db7f70447694 100644
--- a/sw/source/filter/ww8/ww8par2.hxx
+++ b/sw/source/filter/ww8/ww8par2.hxx
@@ -38,18 +38,19 @@ public:
private:
WW8DupProperties(const WW8DupProperties&) = delete;
WW8DupProperties& operator=(const WW8DupProperties&) = delete;
- SwWW8FltControlStack* pCtrlStck;
- SfxItemSet aChrSet,aParSet;
+ SwWW8FltControlStack* m_pCtrlStck;
+ SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END - 1> m_aChrSet,m_aParSet;
};
struct WW8SwFlyPara
{
- SwFlyFrameFormat* pFlyFormat;
-
+private:
+ std::unique_ptr<FrameDeleteWatch> m_xFlyFormat;
+public:
// part 1: directly derived Sw attributes
sal_Int16 nXPos, nYPos; // Position
- sal_Int16 nLeMgn, nRiMgn; // borders
- sal_Int16 nUpMgn, nLoMgn; // borders
+ sal_Int16 nLeftMargin, nRightMargin; // borders
+ sal_Int16 nUpperMargin, nLowerMargin; // borders
sal_Int16 nWidth, nHeight; // size
sal_Int16 nNetWidth;
@@ -66,7 +67,7 @@ struct WW8SwFlyPara
// part 2: changes found during reading
tools::Long nNewNetWidth;
- std::unique_ptr<SwPosition> xMainTextPos; // to return to main text after apo
+ std::shared_ptr<SwUnoCursor> xMainTextPos; // to return to main text after apo
sal_uInt16 nLineSpace; // line space in tw for graf apos
bool bAutoWidth;
bool bTogglePos;
@@ -81,6 +82,9 @@ struct WW8SwFlyPara
const sal_Int32 nIniFlyDy );
void BoxUpWidth( tools::Long nWidth );
+ SwFlyFrameFormat* GetFlyFormat() const;
+ void SetFlyFormat(SwFlyFrameFormat* pNewFlyFormat);
+
std::unique_ptr<SwWW8FltAnchorStack> xOldAnchorStck;
};
@@ -113,14 +117,18 @@ friend class SwWW8ImplReader;
short ImportUPX(short nLen, bool bPAP, bool bOdd);
void Set1StyleDefaults();
- void Import1Style(sal_uInt16 nNr);
+ void Import1Style(sal_uInt16 nNr,
+ std::map<OUString, sal_Int32>& rParaCollisions,
+ std::map<OUString, sal_Int32>& rCharCollisions);
void RecursiveReg(sal_uInt16 nNr);
void ImportNewFormatStyles();
void ScanStyles();
void ImportOldFormatStyles();
- bool PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle);
+ bool PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle,
+ std::map<OUString, sal_Int32>& rParaCollisions,
+ std::map<OUString, sal_Int32>& rCharCollisions);
void PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp);
WW8RStyle(const WW8RStyle&) = delete;
@@ -132,7 +140,7 @@ public:
SprmResult HasParaSprm(sal_uInt16 nId) const;
};
-class WW8FlySet: public SfxItemSet
+class WW8FlySet: public SfxItemSetFixed<RES_FRMATR_BEGIN,RES_FRMATR_END-1>
{
private:
const WW8FlySet& operator=(const WW8FlySet&) = delete;
@@ -155,12 +163,12 @@ private:
WW8SelBoxInfo& operator=(WW8SelBoxInfo const&) = delete;
public:
- short nGroupXStart;
- short nGroupWidth;
- bool bGroupLocked;
+ short m_nGroupXStart;
+ short m_nGroupWidth;
+ bool m_bGroupLocked;
WW8SelBoxInfo(short nXCenter, short nWidth)
- : nGroupXStart( nXCenter ), nGroupWidth( nWidth ), bGroupLocked(false)
+ : m_nGroupXStart( nXCenter ), m_nGroupWidth( nWidth ), m_bGroupLocked(false)
{}
size_t size() const
@@ -204,7 +212,7 @@ class WW8TabDesc
WW8TabBandDesc* m_pFirstBand;
WW8TabBandDesc* m_pActBand;
- std::unique_ptr<SwPosition> m_xTmpPos;
+ std::shared_ptr<SwUnoCursor> m_xTmpPos;
SwTableNode* m_pTableNd; // table node
const SwTableLines* m_pTabLines; // row array of node
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 678b9bb40183..83436369d75c 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -18,6 +18,7 @@
*/
#include <memory>
+#include <string_view>
#include <svl/itemiter.hxx>
#include <vcl/svapp.hxx>
#include <vcl/outdev.hxx>
@@ -68,13 +69,12 @@
#include "ww8par2.hxx"
#include <IMark.hxx>
-#include <unotools/fltrcfg.hxx>
#include <rtl/character.hxx>
#include <xmloff/odffields.hxx>
#include <comphelper/string.hxx>
+#include <officecfg/Office/Common.hxx>
using namespace com::sun::star;
-using namespace sw::util;
using namespace sw::types;
using namespace sw::mark;
@@ -109,8 +109,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormTextBox( WW8FieldDesc* pF, OUString& rStr )
text.
*/
- const SvtFilterOptions& rOpt = SvtFilterOptions::Get();
- const bool bUseEnhFields = rOpt.IsUseEnhancedFields();
+ const bool bUseEnhFields = m_bFuzzing || officecfg::Office::Common::Filter::Microsoft::Import::ImportWWFieldsAsEnhancedFields::get();
if (!bUseEnhFields)
{
@@ -191,8 +190,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormCheckBox( WW8FieldDesc* pF, OUString& rStr )
if (rStr[pF->nLCode-1]==0x01)
ImportFormulaControl(aFormula,pF->nSCode+pF->nLCode-1, WW8_CT_CHECKBOX);
- const SvtFilterOptions& rOpt = SvtFilterOptions::Get();
- const bool bUseEnhFields = rOpt.IsUseEnhancedFields();
+ const bool bUseEnhFields = m_bFuzzing || officecfg::Office::Common::Filter::Microsoft::Import::ImportWWFieldsAsEnhancedFields::get();
if (!bUseEnhFields)
{
@@ -230,7 +228,6 @@ eF_ResT SwWW8ImplReader::Read_F_FormCheckBox( WW8FieldDesc* pF, OUString& rStr )
if (pFieldmark!=nullptr) {
IFieldmark::parameter_map_t* const pParameters = pFieldmark->GetParameters();
ICheckboxFieldmark* pCheckboxFm = dynamic_cast<ICheckboxFieldmark*>(pFieldmark);
- (*pParameters)[ODF_FORMCHECKBOX_NAME] <<= aFormula.msTitle;
(*pParameters)[ODF_FORMCHECKBOX_HELPTEXT] <<= aFormula.msToolTip;
if(pCheckboxFm)
@@ -248,8 +245,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormListBox( WW8FieldDesc* pF, OUString& rStr)
if (pF->nLCode > 0 && rStr.getLength() >= pF->nLCode && rStr[pF->nLCode-1] == 0x01)
ImportFormulaControl(aFormula,pF->nSCode+pF->nLCode-1, WW8_CT_DROPDOWN);
- const SvtFilterOptions& rOpt = SvtFilterOptions::Get();
- bool bUseEnhFields = rOpt.IsUseEnhancedFields();
+ const bool bUseEnhFields = m_bFuzzing || officecfg::Office::Common::Filter::Microsoft::Import::ImportWWFieldsAsEnhancedFields::get();
if (!bUseEnhFields)
{
@@ -261,7 +257,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormListBox( WW8FieldDesc* pF, OUString& rStr)
if (!aFormula.maListEntries.empty())
{
- aField.SetItems(aFormula.maListEntries);
+ aField.SetItems(std::vector(aFormula.maListEntries));
int nIndex = aFormula.mfDropdownIndex < aFormula.maListEntries.size() ? aFormula.mfDropdownIndex : 0;
aField.SetSelectedItem(aFormula.maListEntries[nIndex]);
}
@@ -302,10 +298,11 @@ eF_ResT SwWW8ImplReader::Read_F_FormListBox( WW8FieldDesc* pF, OUString& rStr)
if ( pFieldmark != nullptr )
{
uno::Sequence< OUString > vListEntries(aFormula.maListEntries.size());
- std::copy(aFormula.maListEntries.begin(), aFormula.maListEntries.end(), vListEntries.begin());
+ std::copy(aFormula.maListEntries.begin(), aFormula.maListEntries.end(), vListEntries.getArray());
(*pFieldmark->GetParameters())[ODF_FORMDROPDOWN_LISTENTRY] <<= vListEntries;
- sal_Int32 nIndex = aFormula.mfDropdownIndex < aFormula.maListEntries.size() ? aFormula.mfDropdownIndex : 0;
- (*pFieldmark->GetParameters())[ODF_FORMDROPDOWN_RESULT] <<= nIndex;
+ sal_Int32 nIndex = aFormula.mfDropdownIndex < aFormula.maListEntries.size() ? aFormula.mfDropdownIndex : -1;
+ if (nIndex >= 0)
+ (*pFieldmark->GetParameters())[ODF_FORMDROPDOWN_RESULT] <<= nIndex;
// set field data here...
}
}
@@ -367,6 +364,8 @@ struct WW8LVL // only THE entries, WE need!
short nDxaLeft1; // first line indent
sal_uInt8 nNFC; // number format code
+ /// Legal numbering: whether this level overrides the nfc of all inherited level numbers.
+ bool fLegal;
// Offset of fieldcodes in Num-X-String
sal_uInt8 aOfsNumsXCH[WW8ListManager::nMaxLevel];
sal_uInt8 nLenGrpprlChpx; // length, in bytes, of the LVL's grpprlChpx
@@ -488,32 +487,6 @@ WW8LSTInfo* WW8ListManager::GetLSTByListId( sal_uInt32 nIdLst ) const
return aResult->get();
}
-static OUString sanitizeString(const OUString& rString)
-{
- sal_Int32 i=0;
- while (i < rString.getLength())
- {
- sal_Unicode c = rString[i];
- if (rtl::isHighSurrogate(c))
- {
- if (i+1 == rString.getLength()
- || !rtl::isLowSurrogate(rString[i+1]))
- {
- SAL_WARN("sw.ww8", "Surrogate error: high without low");
- return rString.copy(0, i);
- }
- ++i; //skip correct low
- }
- if (rtl::isLowSurrogate(c)) //bare low without preceding high
- {
- SAL_WARN("sw.ww8", "Surrogate error: low without high");
- return rString.copy(0, i);
- }
- ++i;
- }
- return rString;
-}
-
SvxNumType WW8ListManager::GetSvxNumTypeFromMSONFC(sal_uInt16 nNFC)
{
SvxNumType nType(SVX_NUM_ARABIC);
@@ -535,14 +508,29 @@ SvxNumType WW8ListManager::GetSvxNumTypeFromMSONFC(sal_uInt16 nNFC)
case 4:
nType = SVX_NUM_CHARS_LOWER_LETTER_N;
break;
- case 5:
- // actually: ORDINAL
- nType = SVX_NUM_ARABIC;
+ case 5: // ordinal
+ nType = SVX_NUM_TEXT_NUMBER;
+ break;
+ case 6: // cardinalText
+ nType = SVX_NUM_TEXT_CARDINAL;
break;
+ case 7: // ordinalText
+ nType = SVX_NUM_TEXT_ORDINAL;
+ break;
+ //case 8: // hex
+
case 9:
// 0x09, msonfcChiManSty
nType = SVX_NUM_SYMBOL_CHICAGO;
break;
+ //case 15: // decimalHalfWidth
+ //case 17: // japaneseDigitalTenThousand
+
+ case 18: // decimalEnclosedCircle
+ case 28: // decimalEnclosedCircleChinese
+ case 29: // ideographEnclosedCircle
+ nType = SVX_NUM_CIRCLE_NUMBER;
+ break;
case 22:
// 0x16, msonfcArabicLZ
nType = SVX_NUM_ARABIC_ZERO;
@@ -561,9 +549,11 @@ SvxNumType WW8ListManager::GetSvxNumTypeFromMSONFC(sal_uInt16 nNFC)
case 30:
nType = SVX_NUM_TIAN_GAN_ZH;
break;
- case 31:
+ case 31: // ideographZodiac
+ case 32: // ideographZodiacTraditional
nType = SVX_NUM_DI_ZI_ZH;
break;
+ case 33: // taiwaneseCounting
case 35:
case 36:
case 37:
@@ -578,6 +568,7 @@ SvxNumType WW8ListManager::GetSvxNumTypeFromMSONFC(sal_uInt16 nNFC)
nType = SVX_NUM_NUMBER_UPPER_ZH;
break;
case 10:
+ case 16: // japaneseLegal
nType = SVX_NUM_NUMBER_TRADITIONAL_JA;
break;
case 20:
@@ -598,14 +589,51 @@ SvxNumType WW8ListManager::GetSvxNumTypeFromMSONFC(sal_uInt16 nNFC)
case 25:
nType = SVX_NUM_HANGUL_JAMO_KO;
break;
- case 41:
+ //case 26: // decimalEnclosedFullstop
+ //case 27: // decimalEnclosedParen
+ //case 40: // decimal (Chinese)
+
+ case 41: // koreanDigital
+ case 42: // koreanCounting
+ case 43: // koreanLegal
nType = SVX_NUM_NUMBER_HANGUL_KO;
break;
- //case 42:
- //case 43:
- case 44:
+ case 44: // koreanDigital2
nType = SVX_NUM_NUMBER_UPPER_KO;
break;
+ case 45: // hebrew1
+ nType = SVX_NUM_NUMBER_HEBREW;
+ break;
+ case 46: // arabicAlpha
+ nType = SVX_NUM_CHARS_ARABIC;
+ break;
+ case 47: // hebrew2
+ nType = SVX_NUM_CHARS_HEBREW;
+ break;
+ case 48: // arabicAbjad
+ nType = SVX_NUM_CHARS_ARABIC_ABJAD;
+ break;
+ case 49: // hindiVowels
+ nType = SVX_NUM_CHARS_NEPALI;
+ break;
+ //case 50: // hindiConsonants
+ //case 51: // hindiNumbers
+ //case 52: // hindiCounting
+
+ case 53: // thaiLetters
+ nType = SVX_NUM_CHARS_THAI;
+ break;
+ //case 54: // thaiNumbers
+ //case 55: // thaiCounting
+ //case 56: // vietnameseCounting
+ //case 57: // numberInDash
+
+ case 58: // russianLower
+ nType = SVX_NUM_CHARS_CYRILLIC_LOWER_LETTER_RU;
+ break;
+ case 59: // russianUpper
+ nType =SVX_NUM_CHARS_CYRILLIC_UPPER_LETTER_RU;
+ break;
default:
nType = SVX_NUM_ARABIC;
break;
@@ -628,19 +656,27 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet
// 1. read LVLF
- rSt.ReadInt32( aLVL.nStartAt );
- rSt.ReadUChar( aLVL.nNFC );
- rSt.ReadUChar( aBits1 );
- if( ERRCODE_NONE != rSt.GetError() ) return false;
+ m_rSt.ReadInt32( aLVL.nStartAt );
+ m_rSt.ReadUChar( aLVL.nNFC );
+ m_rSt.ReadUChar( aBits1 );
+ if( ERRCODE_NONE != m_rSt.GetError() ) return false;
+ // 1st..2nd bits.
aLVL.nAlign = (aBits1 & 0x03);
+
+ if (aBits1 & 0x04)
+ {
+ // 3rd bit.
+ aLVL.fLegal = true;
+ }
+
if( aBits1 & 0x10 ) aLVL.bV6Prev = true;
if( aBits1 & 0x20 ) aLVL.bV6PrSp = true;
if( aBits1 & 0x40 ) aLVL.bV6 = true;
bool bLVLOkB = true;
for(sal_uInt8 nLevelB = 0; nLevelB < nMaxLevel; ++nLevelB)
{
- rSt.ReadUChar( aLVL.aOfsNumsXCH[ nLevelB ] );
- if( ERRCODE_NONE != rSt.GetError() )
+ m_rSt.ReadUChar( aLVL.aOfsNumsXCH[ nLevelB ] );
+ if( ERRCODE_NONE != m_rSt.GetError() )
{
bLVLOkB = false;
break;
@@ -651,13 +687,13 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet
return false;
sal_uInt8 ixchFollow(0);
- rSt.ReadUChar( ixchFollow );
- rSt.ReadInt32( aLVL.nV6DxaSpace );
- rSt.ReadInt32( aLVL.nV6Indent );
- rSt.ReadUChar( aLVL.nLenGrpprlChpx );
- rSt.ReadUChar( aLVL.nLenGrpprlPapx );
- rSt.SeekRel( 2 );
- if( ERRCODE_NONE != rSt.GetError()) return false;
+ m_rSt.ReadUChar( ixchFollow );
+ m_rSt.ReadInt32( aLVL.nV6DxaSpace );
+ m_rSt.ReadInt32( aLVL.nV6Indent );
+ m_rSt.ReadUChar( aLVL.nLenGrpprlChpx );
+ m_rSt.ReadUChar( aLVL.nLenGrpprlPapx );
+ m_rSt.SeekRel( 2 );
+ if( ERRCODE_NONE != m_rSt.GetError()) return false;
// 2. read PAPx if needed and search for indent values
@@ -665,7 +701,7 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet
if( aLVL.nLenGrpprlPapx )
{
sal_uInt8 aGrpprlPapx[ 255 ];
- if (aLVL.nLenGrpprlPapx != rSt.ReadBytes(&aGrpprlPapx, aLVL.nLenGrpprlPapx))
+ if (aLVL.nLenGrpprlPapx != m_rSt.ReadBytes(&aGrpprlPapx, aLVL.nLenGrpprlPapx))
return false;
// "sprmPDxaLeft" pap.dxaLeft;dxa;word;
SprmResult aSprm = GrpprlHasSprm(0x840F,aGrpprlPapx[0],aLVL.nLenGrpprlPapx);
@@ -678,8 +714,8 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet
for(int i=0;i<4;++i)
rParaSprms.push_back(*pBegin++);
short nDxaLeft = SVBT16ToUInt16(aSprm.pSprm);
- aLVL.nDxaLeft = (0 < nDxaLeft) ? static_cast<sal_uInt16>(nDxaLeft)
- : static_cast<sal_uInt16>(-nDxaLeft);
+ aLVL.nDxaLeft = (0 < nDxaLeft) ? o3tl::narrowing<sal_uInt16>(nDxaLeft)
+ : o3tl::narrowing<sal_uInt16>(-nDxaLeft);
}
// "sprmPDxaLeft1" pap.dxaLeft1;dxa;word;
@@ -749,8 +785,8 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet
if (bDoAdjust)
{
aLVL.nDxaLeft = (0 < nTabPos)
- ? static_cast<sal_uInt16>(nTabPos)
- : static_cast<sal_uInt16>(-nTabPos);
+ ? o3tl::narrowing<sal_uInt16>(nTabPos)
+ : o3tl::narrowing<sal_uInt16>(-nTabPos);
aLVL.nDxaLeft1 = nDesired - aLVL.nDxaLeft;
}
@@ -766,7 +802,7 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet
if( aLVL.nLenGrpprlChpx )
{
sal_uInt8 aGrpprlChpx[ 255 ] = {};
- if (aLVL.nLenGrpprlChpx != rSt.ReadBytes(&aGrpprlChpx, aLVL.nLenGrpprlChpx))
+ if (aLVL.nLenGrpprlChpx != m_rSt.ReadBytes(&aGrpprlChpx, aLVL.nLenGrpprlChpx))
return false;
//For i120928,parse the graphic info of bullets
@@ -782,42 +818,42 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet
}
// create new Itemset for character attributes
- rpItemSet.reset(new SfxItemSet( rDoc.GetAttrPool(), svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END - 1>{}));
+ rpItemSet.reset(new SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END - 1>( m_rDoc.GetAttrPool() ));
// Set Reader-ItemSet-Pointer to the newly created set
- rReader.SetCurrentItemSet(std::move(rpItemSet));
+ m_rReader.SetCurrentItemSet(std::move(rpItemSet));
// Set Reader-Style to Style of this Level
- sal_uInt16 nOldColl = rReader.GetCurrentColl();
+ sal_uInt16 nOldColl = m_rReader.GetCurrentColl();
sal_uInt16 nNewColl = nLevelStyle;
if (ww::stiNil == nNewColl)
nNewColl = 0;
- rReader.SetNCurrentColl( nNewColl );
+ m_rReader.SetNCurrentColl( nNewColl );
// The Read_xy() methods in WW8PAR6.cxx are calling their respective
// NewAttr() or GetFormatAttr() which can determine, by using the assigned
// Reader-ItemSet-Pointer, whether this specific ItemSet is relevant
// and not a Stack or Style!
- sal_uInt16 nOldFlags1 = rReader.GetToggleAttrFlags();
- sal_uInt16 nOldFlags2 = rReader.GetToggleBiDiAttrFlags();
+ sal_uInt16 nOldFlags1 = m_rReader.GetToggleAttrFlags();
+ sal_uInt16 nOldFlags2 = m_rReader.GetToggleBiDiAttrFlags();
WW8SprmIter aSprmIter(&aGrpprlChpx[0], aLVL.nLenGrpprlChpx,
maSprmParser);
while (const sal_uInt8* pSprm = aSprmIter.GetSprms())
{
- rReader.ImportSprm(pSprm, aSprmIter.GetRemLen(), aSprmIter.GetCurrentId());
+ m_rReader.ImportSprm(pSprm, aSprmIter.GetRemLen(), aSprmIter.GetCurrentId());
aSprmIter.advance();
}
// Reset Reader-ItemSet-Pointer and Reader-Style
- rpItemSet = rReader.SetCurrentItemSet(nullptr);
- rReader.SetNCurrentColl( nOldColl );
- rReader.SetToggleAttrFlags(nOldFlags1);
- rReader.SetToggleBiDiAttrFlags(nOldFlags2);
+ rpItemSet = m_rReader.SetCurrentItemSet(nullptr);
+ m_rReader.SetNCurrentColl( nOldColl );
+ m_rReader.SetToggleAttrFlags(nOldFlags1);
+ m_rReader.SetToggleBiDiAttrFlags(nOldFlags2);
}
// 4. Read numbering String. Results in prefix and postfix
- OUString sNumString(sanitizeString(read_uInt16_PascalString(rSt)));
+ OUString sNumString(comphelper::string::sanitizeStringSurrogates(read_uInt16_PascalString(m_rSt)));
// 5. convert read values into Writer syntax
@@ -866,8 +902,9 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet
// 6. Configure NumFormat
if( bSetStartNo && 0 <= aLVL.nStartAt)
- rNumFormat.SetStart(static_cast<sal_uInt16>(aLVL.nStartAt));
+ rNumFormat.SetStart(o3tl::narrowing<sal_uInt16>(aLVL.nStartAt));
rNumFormat.SetNumberingType( nType );
+ rNumFormat.SetIsLegal(aLVL.fLegal);
rNumFormat.SetNumAdjust( eAdj );
if( style::NumberingType::CHAR_SPECIAL == nType )
@@ -884,7 +921,7 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet
}
else
{
- // Replace symbols at aOfsNumsXCH offsets to %1, %2 as supported by DOCX and LO
+ // Replace symbols at aOfsNumsXCH offsets to %1%, %2% as supported by LO
OUString sListFormat = sNumString;
if (sListFormat.getLength())
{
@@ -902,7 +939,7 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet
}
sal_uInt8 nReplacement = sListFormat[nOffset] + 1;
- OUString sReplacement("%" + OUString::number(nReplacement));
+ OUString sReplacement("%" + OUString::number(nReplacement) + "%");
sListFormat = sListFormat.replaceAt(nOffset, 1, sReplacement);
// We need also update an offset, since we are replacing one symbol by at least two
@@ -1021,7 +1058,7 @@ void WW8ListManager::AdjustLVL( sal_uInt8 nLevel, SwNumRule& rNumRule,
+ "z" + OUString::number( nLevel ) );
// remove const by casting
- pFormat = rDoc.MakeCharFormat(aName, rDoc.GetDfltCharFormat());
+ pFormat = m_rDoc.MakeCharFormat(aName, m_rDoc.GetDfltCharFormat());
bNewCharFormatCreated = true;
// Set Attributes
pFormat->SetFormatAttr( *pThisLevelItemSet );
@@ -1039,21 +1076,6 @@ void WW8ListManager::AdjustLVL( sal_uInt8 nLevel, SwNumRule& rNumRule,
aNumFormat.SetCharFormat( pFormat );
}
- //Ensure the default char fmt is initialized for any level of num ruler if no customized attr
- else
- {
- SwCharFormat* pFormat = aNumFormat.GetCharFormat();
- if ( !pFormat)
- {
- const OUString aName( (!sPrefix.isEmpty() ? sPrefix : rNumRule.GetName())
- + "z" + OUString::number( nLevel ) );
-
- pFormat = rDoc.MakeCharFormat(aName, rDoc.GetDfltCharFormat());
- bNewCharFormatCreated = true;
- rCharFormat[ nLevel ] = pFormat;
- aNumFormat.SetCharFormat( pFormat );
- }
- }
// if necessary: Append Bullet Font to NumFormat
@@ -1085,12 +1107,12 @@ void WW8ListManager::AdjustLVL( sal_uInt8 nLevel, SwNumRule& rNumRule,
SwNumRule* WW8ListManager::CreateNextRule(bool bSimple)
{
// Used to build the Style Name
- const OUString sPrefix("WW8Num" + OUString::number(nUniqueList++));
+ const OUString sPrefix("WW8Num" + OUString::number(m_nUniqueList++));
// #i86652#
sal_uInt16 nRul =
- rDoc.MakeNumRule( rDoc.GetUniqueNumRuleName(&sPrefix), nullptr, false,
+ m_rDoc.MakeNumRule( m_rDoc.GetUniqueNumRuleName(&sPrefix), nullptr, false,
SvxNumberFormat::LABEL_ALIGNMENT );
- SwNumRule* pMyNumRule = rDoc.GetNumRuleTable()[nRul];
+ SwNumRule* pMyNumRule = m_rDoc.GetNumRuleTable()[nRul];
pMyNumRule->SetAutoRule(false);
pMyNumRule->SetContinusNum(bSimple);
return pMyNumRule;
@@ -1107,35 +1129,35 @@ SwNumRule* WW8ListManager::GetNumRule(size_t i)
// public methods
WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
- : maSprmParser(rReader_.GetFib()), rReader(rReader_)
- , rDoc(rReader.GetDoc())
- , rFib(rReader.GetFib()), rSt(rSt_)
- , nUniqueList(1)
- , nLastLFOPosition(USHRT_MAX)
+ : maSprmParser(rReader_.GetFib()), m_rReader(rReader_)
+ , m_rDoc(m_rReader.GetDoc())
+ , m_rFib(m_rReader.GetFib()), m_rSt(rSt_)
+ , m_nUniqueList(1)
+ , m_nLastLFOPosition(USHRT_MAX)
{
// LST and LFO only since WW8
- if( ( 8 > rFib.m_nVersion )
- || ( rFib.m_fcPlcfLst == rFib.m_fcPlfLfo )
- || ( rFib.m_lcbPlcfLst < 2 )
- || ( rFib.m_lcbPlfLfo < 2) ) return; // no public lists
+ if( ( 8 > m_rFib.m_nVersion )
+ || ( m_rFib.m_fcPlcfLst == m_rFib.m_fcPlfLfo )
+ || ( m_rFib.m_lcbPlcfLst < 2 )
+ || ( m_rFib.m_lcbPlfLfo < 2) ) return; // no public lists
// create Arrays
bool bLVLOk = true;
- tools::Long nOriginalPos = rSt.Tell();
+ sal_uInt64 nOriginalPos = m_rSt.Tell();
// 1. read PLCF LST and create list templates in Writer
- bool bOk = checkSeek(rSt, rFib.m_fcPlcfLst);
+ bool bOk = checkSeek(m_rSt, m_rFib.m_fcPlcfLst);
if (!bOk)
return;
- sal_uInt32 nRemainingPlcfLst = rFib.m_lcbPlcfLst;
+ sal_uInt32 nRemainingPlcfLst = m_rFib.m_lcbPlcfLst;
sal_uInt16 nListCount(0);
- rSt.ReadUInt16( nListCount );
+ m_rSt.ReadUInt16( nListCount );
nRemainingPlcfLst -= 2;
bOk = nListCount > 0;
@@ -1144,7 +1166,7 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
// 1.1 read all LST
const size_t nMinRecordSize = 10 + 2*nMaxLevel;
- const size_t nMaxRecords = rSt.remainingSize() / nMinRecordSize;
+ const size_t nMaxRecords = m_rSt.remainingSize() / nMinRecordSize;
if (nListCount > nMaxRecords)
{
SAL_WARN("sw.ww8", "Parsing error: " << nMaxRecords <<
@@ -1160,15 +1182,15 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
// 1.1.1 read Data
- rSt.ReadUInt32( aLST.nIdLst );
- rSt.ReadUInt32( aLST.nTplC );
+ m_rSt.ReadUInt32( aLST.nIdLst );
+ m_rSt.ReadUInt32( aLST.nTplC );
for (sal_uInt16 & nLevel : aLST.aIdSty)
- rSt.ReadUInt16( nLevel );
+ m_rSt.ReadUInt16( nLevel );
sal_uInt8 aBits1(0);
- rSt.ReadUChar( aBits1 );
+ m_rSt.ReadUChar( aBits1 );
- rSt.SeekRel( 1 );
+ m_rSt.SeekRel( 1 );
if( aBits1 & 0x01 )
aLST.bSimpleList = true;
@@ -1243,13 +1265,13 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
// 2. read and save PLF LFO
- bOk = checkSeek(rSt, rFib.m_fcPlfLfo);
+ bOk = checkSeek(m_rSt, m_rFib.m_fcPlfLfo);
if (!bOk)
return;
sal_Int32 nLfoCount(0);
- rSt.ReadInt32( nLfoCount );
+ m_rSt.ReadInt32( nLfoCount );
bOk = nLfoCount > 0;
if (!bOk)
@@ -1263,14 +1285,14 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
WW8LFO aLFO = {};
- rSt.ReadUInt32( aLFO.nIdLst );
- rSt.SeekRel( 8 );
- rSt.ReadUChar( aLFO.nLfoLvl );
- if (!rSt.good())
+ m_rSt.ReadUInt32( aLFO.nIdLst );
+ m_rSt.SeekRel( 8 );
+ m_rSt.ReadUChar( aLFO.nLfoLvl );
+ if (!m_rSt.good())
break;
- rSt.SeekRel( 3 );
+ m_rSt.SeekRel( 3 );
// as many Overrides as there are
- if ((nMaxLevel < aLFO.nLfoLvl) || rSt.GetError())
+ if ((nMaxLevel < aLFO.nLfoLvl) || m_rSt.GetError())
break;
// get the Parent NumRule of the current List
@@ -1327,18 +1349,18 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
// (it contained the parent NumRule up to this point)
// check if a Style is referencing this LFO
- if( USHRT_MAX > rReader.StyleUsingLFO( nLfo ) )
+ if( USHRT_MAX > m_rReader.StyleUsingLFO( nLfo ) )
{
- sal_uInt16 nRul = rDoc.MakeNumRule(
- rDoc.GetUniqueNumRuleName( &sPrefix ), pParentNumRule);
- rLFOInfo.pNumRule = rDoc.GetNumRuleTable()[ nRul ];
+ sal_uInt16 nRul = m_rDoc.MakeNumRule(
+ m_rDoc.GetUniqueNumRuleName( &sPrefix ), pParentNumRule);
+ rLFOInfo.pNumRule = m_rDoc.GetNumRuleTable()[ nRul ];
rLFOInfo.pNumRule->SetAutoRule(false);
}
else
{
- sal_uInt16 nRul = rDoc.MakeNumRule(
- rDoc.GetUniqueNumRuleName(), pParentNumRule);
- rLFOInfo.pNumRule = rDoc.GetNumRuleTable()[ nRul ];
+ sal_uInt16 nRul = m_rDoc.MakeNumRule(
+ m_rDoc.GetUniqueNumRuleName(), pParentNumRule);
+ rLFOInfo.pNumRule = m_rDoc.GetNumRuleTable()[ nRul ];
rLFOInfo.pNumRule->SetAutoRule(true); // = default
}
@@ -1354,14 +1376,14 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
//4 byte header, there might be more than one if
//that header was 0xFFFFFFFF, e.g. #114412# ?
sal_uInt32 nTest;
- rSt.ReadUInt32( nTest );
+ m_rSt.ReadUInt32( nTest );
do
{
nTest = 0;
- rSt.ReadUInt32( nTest );
+ m_rSt.ReadUInt32( nTest );
}
while (nTest == 0xFFFFFFFF);
- rSt.SeekRel(-4);
+ m_rSt.SeekRel(-4);
for (sal_uInt8 nLevel = 0; nLevel < rLFOInfo.nLfoLvl; ++nLevel)
{
@@ -1370,11 +1392,11 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
// 2.2.2.1 read LFOLVL
- rSt.ReadInt32( aLFOLVL.nStartAt );
+ m_rSt.ReadInt32( aLFOLVL.nStartAt );
sal_uInt8 aBits1(0);
- rSt.ReadUChar( aBits1 );
- rSt.SeekRel( 3 );
- if (rSt.GetError())
+ m_rSt.ReadUChar( aBits1 );
+ m_rSt.SeekRel( 3 );
+ if (m_rSt.GetError())
break;
// Note: MS writes the Override-Level-Number into 4 bit.
@@ -1436,10 +1458,10 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
}
}
// and we're done!
- rSt.Seek( nOriginalPos );
+ m_rSt.Seek( nOriginalPos );
}
-WW8ListManager::~WW8ListManager() COVERITY_NOEXCEPT_FALSE
+void WW8ListManager::ImplDestroy()
{
/*
named lists remain in document
@@ -1450,7 +1472,7 @@ WW8ListManager::~WW8ListManager() COVERITY_NOEXCEPT_FALSE
if (rpInfo->pNumRule && !rpInfo->bUsedInDoc &&
rpInfo->pNumRule->IsAutoRule())
{
- rDoc.DelNumRule(rpInfo->pNumRule->GetName());
+ m_rDoc.DelNumRule(rpInfo->pNumRule->GetName());
}
rpInfo.reset();
}
@@ -1461,11 +1483,16 @@ WW8ListManager::~WW8ListManager() COVERITY_NOEXCEPT_FALSE
&& !(*aIter)->bUsedInDoc
&& (*aIter)->pNumRule->IsAutoRule())
{
- rDoc.DelNumRule( (*aIter)->pNumRule->GetName() );
+ m_rDoc.DelNumRule( (*aIter)->pNumRule->GetName() );
}
}
}
+WW8ListManager::~WW8ListManager()
+{
+ suppress_fun_call_w_exception(ImplDestroy());
+}
+
static bool IsEqualFormatting(const SwNumRule &rOne, const SwNumRule &rTwo)
{
bool bRet =
@@ -1513,14 +1540,14 @@ SwNumRule* WW8ListManager::GetNumRuleForActivation(sal_uInt16 nLFOPosition,
// #i100132# - a number format does not have to exist on given list level
SwNumFormat aFormat(rLFOInfo.pNumRule->Get(nLevel));
- if (rReader.IsRightToLeft() && nLastLFOPosition != nLFOPosition) {
+ if (m_rReader.IsRightToLeft() && m_nLastLFOPosition != nLFOPosition) {
if ( aFormat.GetNumAdjust() == SvxAdjust::Right)
aFormat.SetNumAdjust(SvxAdjust::Left);
else if ( aFormat.GetNumAdjust() == SvxAdjust::Left)
aFormat.SetNumAdjust(SvxAdjust::Right);
rLFOInfo.pNumRule->Set(nLevel, aFormat);
}
- nLastLFOPosition = nLFOPosition;
+ m_nLastLFOPosition = nLFOPosition;
/*
#i1869#
If this list has had its bits set in word 2000 to pretend that it is a
@@ -1619,7 +1646,7 @@ bool SwWW8ImplReader::SetTextFormatCollAndListLevel(const SwPaM& rRg,
if( rStyleInfo.m_pFormat && rStyleInfo.m_bColl )
{
bRes = m_rDoc.SetTextFormatColl(rRg, static_cast<SwTextFormatColl*>(rStyleInfo.m_pFormat));
- SwTextNode* pTextNode = m_pPaM->GetNode().GetTextNode();
+ SwTextNode* pTextNode = m_pPaM->GetPointNode().GetTextNode();
OSL_ENSURE( pTextNode, "No Text-Node at PaM-Position" );
if ( !pTextNode )
{
@@ -1653,10 +1680,12 @@ void UseListIndent(SwWW8StyInf &rStyle, const SwNumFormat &rFormat)
{
const auto nAbsLSpace = rFormat.GetAbsLSpace();
const tools::Long nListFirstLineIndent = GetListFirstLineIndent(rFormat);
- SvxLRSpaceItem aLR(ItemGet<SvxLRSpaceItem>(*rStyle.m_pFormat, RES_LR_SPACE));
- aLR.SetTextLeft(nAbsLSpace);
- aLR.SetTextFirstLineOffset(writer_cast<short>(nListFirstLineIndent));
- rStyle.m_pFormat->SetFormatAttr(aLR);
+ SvxFirstLineIndentItem firstLine(rStyle.m_pFormat->GetFormatAttr(RES_MARGIN_FIRSTLINE));
+ SvxTextLeftMarginItem leftMargin(rStyle.m_pFormat->GetFormatAttr(RES_MARGIN_TEXTLEFT));
+ leftMargin.SetTextLeft(nAbsLSpace);
+ firstLine.SetTextFirstLineOffset(writer_cast<short>(nListFirstLineIndent));
+ rStyle.m_pFormat->SetFormatAttr(firstLine);
+ rStyle.m_pFormat->SetFormatAttr(leftMargin);
rStyle.m_bListRelevantIndentSet = true;
}
}
@@ -1666,18 +1695,20 @@ void SetStyleIndent(SwWW8StyInf &rStyle, const SwNumFormat &rFormat)
if ( rFormat.GetPositionAndSpaceMode() != SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) // #i86652#
return;
- SvxLRSpaceItem aLR(ItemGet<SvxLRSpaceItem>(*rStyle.m_pFormat, RES_LR_SPACE));
+ SvxFirstLineIndentItem firstLine(rStyle.m_pFormat->GetFormatAttr(RES_MARGIN_FIRSTLINE));
+ SvxTextLeftMarginItem leftMargin(rStyle.m_pFormat->GetFormatAttr(RES_MARGIN_TEXTLEFT));
if (rStyle.m_bListRelevantIndentSet)
{
- SyncIndentWithList( aLR, rFormat, false, false ); // #i103711#, #i105414#
+ SyncIndentWithList(firstLine, leftMargin, rFormat, false, false); // #i103711#, #i105414#
}
else
{
- aLR.SetTextLeft(0);
- aLR.SetTextFirstLineOffset(0);
+ leftMargin.SetTextLeft(0);
+ firstLine.SetTextFirstLineOffset(0);
}
- rStyle.m_pFormat->SetFormatAttr(aLR);
+ rStyle.m_pFormat->SetFormatAttr(firstLine);
+ rStyle.m_pFormat->SetFormatAttr(leftMargin);
}
void SwWW8ImplReader::SetStylesList(sal_uInt16 nStyle, sal_uInt16 nCurrentLFO,
@@ -1695,21 +1726,20 @@ void SwWW8ImplReader::SetStylesList(sal_uInt16 nStyle, sal_uInt16 nCurrentLFO,
if( !m_pCurrentColl )
return;
- // only save the Parameters for now. The actual List will be appended
- // at a later point, when the Listdefinitions is read...
- if (
- (USHRT_MAX > nCurrentLFO) &&
- (WW8ListManager::nMaxLevel > nCurrentLevel)
- )
- {
+ if (nCurrentLFO < USHRT_MAX)
rStyleInf.m_nLFOIndex = nCurrentLFO;
+ if (nCurrentLevel < MAXLEVEL)
rStyleInf.m_nListLevel = nCurrentLevel;
+ // only save the Parameters for now. The actual List will be appended
+ // at a later point, when the Listdefinitions is read...
+ if (rStyleInf.m_nLFOIndex < USHRT_MAX && rStyleInf.m_nListLevel < WW8ListManager::nMaxLevel)
+ {
std::vector<sal_uInt8> aParaSprms;
SwNumRule* pNmRule = m_xLstManager->GetNumRuleForActivation(
- nCurrentLFO, nCurrentLevel, aParaSprms);
+ rStyleInf.m_nLFOIndex, rStyleInf.m_nListLevel, aParaSprms);
if (pNmRule)
- UseListIndent(rStyleInf, pNmRule->Get(nCurrentLevel));
+ UseListIndent(rStyleInf, pNmRule->Get(rStyleInf.m_nListLevel));
}
}
@@ -1724,39 +1754,34 @@ void SwWW8ImplReader::RegisterNumFormatOnStyle(sal_uInt16 nStyle)
return;
//Save old pre-list modified indent, which are the word indent values
- rStyleInf.maWordLR.reset(ItemGet<SvxLRSpaceItem>(*rStyleInf.m_pFormat, RES_LR_SPACE).Clone());
+ rStyleInf.m_pWordFirstLine.reset(rStyleInf.m_pFormat->GetFormatAttr(RES_MARGIN_FIRSTLINE).Clone());
+ rStyleInf.m_pWordLeftMargin.reset(rStyleInf.m_pFormat->GetFormatAttr(RES_MARGIN_TEXTLEFT).Clone());
+ rStyleInf.m_pWordRightMargin.reset(rStyleInf.m_pFormat->GetFormatAttr(RES_MARGIN_RIGHT).Clone());
// Phase 2: refresh StyleDef after reading all Lists
- SwNumRule* pNmRule = nullptr;
- const sal_uInt16 nLFO = rStyleInf.m_nLFOIndex;
- const sal_uInt8 nLevel = rStyleInf.m_nListLevel;
- if (
- (USHRT_MAX > nLFO) &&
- (WW8ListManager::nMaxLevel > nLevel)
- )
- {
- std::vector<sal_uInt8> aParaSprms;
- pNmRule = m_xLstManager->GetNumRuleForActivation(nLFO, nLevel,
- aParaSprms);
+ if (rStyleInf.m_nLFOIndex >= USHRT_MAX || rStyleInf.m_nListLevel >= WW8ListManager::nMaxLevel)
+ return;
+
+ std::vector<sal_uInt8> aParaSprms;
+ SwNumRule* pNmRule = m_xLstManager->GetNumRuleForActivation(
+ rStyleInf.m_nLFOIndex, rStyleInf.m_nListLevel, aParaSprms);
- if (pNmRule != nullptr)
+ if (pNmRule != nullptr)
+ {
+ if (rStyleInf.IsWW8BuiltInHeadingStyle()
+ && rStyleInf.HasWW8OutlineLevel())
{
- if (rStyleInf.IsWW8BuiltInHeadingStyle()
- && rStyleInf.HasWW8OutlineLevel())
- {
- rStyleInf.m_pOutlineNumrule = pNmRule;
- }
- else
- {
- rStyleInf.m_pFormat->SetFormatAttr(
- SwNumRuleItem(pNmRule->GetName()));
- rStyleInf.m_bHasStyNumRule = true;
- }
+ rStyleInf.m_pOutlineNumrule = pNmRule;
+ }
+ else
+ {
+ rStyleInf.m_pFormat->SetFormatAttr(
+ SwNumRuleItem(pNmRule->GetName()));
+ rStyleInf.m_bHasStyNumRule = true;
}
- }
- if (pNmRule)
- SetStyleIndent(rStyleInf, pNmRule->Get(nLevel));
+ SetStyleIndent(rStyleInf, pNmRule->Get(rStyleInf.m_nListLevel));
+ }
}
void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nCurrentLFO,
@@ -1771,11 +1796,23 @@ void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nCurrentLFO,
if (!m_xLstManager) // are all list declarations read?
return;
- SwTextNode* pTextNd = m_pPaM->GetNode().GetTextNode();
+ SwTextNode* pTextNd = m_pPaM->GetPointNode().GetTextNode();
OSL_ENSURE(pTextNd, "No Text-Node at PaM-Position");
if (!pTextNd)
return;
+ // WW8ListManager::nMaxLevel indicates body text, cancelling an inherited numbering.
+ if (nCurrentLFO < USHRT_MAX && nCurrentLevel == WW8ListManager::nMaxLevel)
+ {
+ pTextNd->SetAttr(SwNumRuleItem(OUString()));
+ return;
+ }
+
+ // Undefined listLevel is treated as the first level with valid numbering rule.
+ // TODO:This doesn't allow for inheriting from a style(HOW?), but it matches previous behaviour.
+ if (nCurrentLFO < USHRT_MAX && nCurrentLevel == MAXLEVEL)
+ nCurrentLevel = 0;
+
std::vector<sal_uInt8> aParaSprms;
const SwNumRule* pRule = bSetAttr ?
m_xLstManager->GetNumRuleForActivation( nCurrentLFO, nCurrentLevel,
@@ -1790,7 +1827,9 @@ void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nCurrentLFO,
{
// Now this is either not a part of Chapter Numbering,
// or else it is using a different numRule than the one copied to Chapter Numbering.
- pTextNd->SetAttr(SwNumRuleItem(pRule->GetName()));
+ OUString sName = pRule == m_pChosenWW8OutlineStyle ? m_rDoc.GetOutlineNumRule()->GetName()
+ : pRule->GetName();
+ pTextNd->SetAttr(SwNumRuleItem(sName));
}
pTextNd->SetAttrListLevel(nCurrentLevel);
@@ -1819,13 +1858,15 @@ void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nCurrentLFO,
if (!bApplyListLevelIndentDirectlyAtPara)
return;
- std::unique_ptr<SfxItemSet> xListIndent(new SfxItemSet(m_rDoc.GetAttrPool(), svl::Items<RES_LR_SPACE,
- RES_LR_SPACE>{}));
- const SvxLRSpaceItem *pItem = static_cast<const SvxLRSpaceItem*>(
- GetFormatAttr(RES_LR_SPACE));
+ auto pListIndent = std::make_unique<SfxItemSet>(m_rDoc.GetAttrPool(), svl::Items<RES_MARGIN_FIRSTLINE, RES_MARGIN_TEXTLEFT>);
+ const SfxPoolItem *pItem;
+ pItem = GetFormatAttr(RES_MARGIN_FIRSTLINE);
OSL_ENSURE(pItem, "impossible");
if (pItem)
- xListIndent->Put(*pItem);
+ pListIndent->Put(*pItem);
+ pItem = GetFormatAttr(RES_MARGIN_TEXTLEFT);
+ if (pItem)
+ pListIndent->Put(*pItem);
/*
Take the original paragraph sprms attached to this list level
@@ -1834,7 +1875,7 @@ void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nCurrentLFO,
*/
if (short nLen = static_cast< short >(aParaSprms.size()))
{
- std::unique_ptr<SfxItemSet> xOldCurrentItemSet(SetCurrentItemSet(std::move(xListIndent)));
+ std::unique_ptr<SfxItemSet> pOldCurrentItemSet(SetCurrentItemSet(std::move(pListIndent)));
sal_uInt8* pSprms1 = aParaSprms.data();
while (0 < nLen)
@@ -1844,13 +1885,18 @@ void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nCurrentLFO,
pSprms1 += nL1;
}
- xListIndent = SetCurrentItemSet(std::move(xOldCurrentItemSet));
+ pListIndent = SetCurrentItemSet(std::move(pOldCurrentItemSet));
}
- if (const SvxLRSpaceItem *pLR = xListIndent->GetItem<SvxLRSpaceItem>(RES_LR_SPACE))
+ if (const SvxFirstLineIndentItem *const pFirstLine = pListIndent->GetItem<SvxFirstLineIndentItem>(RES_MARGIN_FIRSTLINE))
+ {
+ m_xCtrlStck->NewAttr(*m_pPaM->GetPoint(), *pFirstLine);
+ m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_MARGIN_FIRSTLINE);
+ }
+ if (const SvxTextLeftMarginItem *const pLeftMargin = pListIndent->GetItem<SvxTextLeftMarginItem>(RES_MARGIN_TEXTLEFT))
{
- m_xCtrlStck->NewAttr(*m_pPaM->GetPoint(), *pLR);
- m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_LR_SPACE);
+ m_xCtrlStck->NewAttr(*m_pPaM->GetPoint(), *pLeftMargin);
+ m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_MARGIN_TEXTLEFT);
}
}
@@ -1896,11 +1942,14 @@ void SwWW8ImplReader::Read_ListLevel(sal_uInt16, const sal_uInt8* pData,
m_xStyles->mnWwNumLevel = m_nListLevel;
}
- if (WW8ListManager::nMaxLevel <= m_nListLevel )
+ // Treat an invalid level as body-level
+ if (WW8ListManager::nMaxLevel < m_nListLevel)
m_nListLevel = WW8ListManager::nMaxLevel;
- else if (USHRT_MAX > m_nLFOPosition)
+
+ RegisterNumFormat(m_nLFOPosition, m_nListLevel);
+ if (USHRT_MAX > m_nLFOPosition)
{
- RegisterNumFormat(m_nLFOPosition, m_nListLevel);
+ assert(false && "m_nLFOPosition is usually reset immediately, so we rarely ever get here.");
m_nLFOPosition = USHRT_MAX;
m_nListLevel = MAXLEVEL;
}
@@ -1948,9 +1997,17 @@ void SwWW8ImplReader::Read_LFOPosition(sal_uInt16, const sal_uInt8* pData,
m_pCurrentColl->SetFormatAttr(*GetDfltAttr(RES_PARATR_NUMRULE));
// reset/blank the indent
- m_pCurrentColl->SetFormatAttr(SvxLRSpaceItem(RES_LR_SPACE));
+ m_pCurrentColl->SetFormatAttr(SvxFirstLineIndentItem(RES_MARGIN_FIRSTLINE));
+ m_pCurrentColl->SetFormatAttr(SvxTextLeftMarginItem(RES_MARGIN_TEXTLEFT));
+ m_pCurrentColl->SetFormatAttr(SvxRightMarginItem(RES_MARGIN_RIGHT));
+
+ // These sprmPIlfos are supposed to indicate "cancel" numbering.
+ // Since m_nLFOPosition is "data - 1", then zero becomes USHRT_MAX
+ // which is no good since that indicates "unspecified, available for inheritance".
+ // So instead use USHRT_MAX-1 for indicating an explicit "cancel numbering".
+ RegisterNumFormat(USHRT_MAX-1, MAXLEVEL);
}
- else if (SwTextNode* pTextNode = m_pPaM->GetNode().GetTextNode())
+ else if (SwTextNode* pTextNode = m_pPaM->GetPointNode().GetTextNode())
{
// here a paragraph is being directly formatted
@@ -1959,26 +2016,26 @@ void SwWW8ImplReader::Read_LFOPosition(sal_uInt16, const sal_uInt8* pData,
pTextNode->SetAttr( aEmptyRule );
// create an empty SvxLRSpaceItem
- std::shared_ptr<SvxLRSpaceItem> aLR(std::make_shared<SvxLRSpaceItem>(RES_LR_SPACE));
+ std::shared_ptr<SvxFirstLineIndentItem> pFirstLine(std::make_shared<SvxFirstLineIndentItem>(RES_MARGIN_FIRSTLINE));
// replace it with the one of the current node if it exist
- const SfxPoolItem* pLR = GetFormatAttr(RES_LR_SPACE);
- if( pLR )
- aLR.reset(static_cast<SvxLRSpaceItem*>(pLR->Clone()));
+ if (const SvxFirstLineIndentItem * pItem = GetFormatAttr(RES_MARGIN_FIRSTLINE))
+ pFirstLine.reset(pItem->Clone());
// reset/blank the left indent (and only the left)
- aLR->SetTextLeft(0);
- aLR->SetTextFirstLineOffset(0);
+ pFirstLine->SetTextFirstLineOffset(0);
+ SvxTextLeftMarginItem leftMargin(0, RES_MARGIN_TEXTLEFT);
// apply the modified SvxLRSpaceItem to the current paragraph
- pTextNode->SetAttr( *aLR );
+ pTextNode->SetAttr(*pFirstLine);
+ pTextNode->SetAttr(leftMargin);
}
m_nLFOPosition = USHRT_MAX;
}
else // nData in (0..0x7FFF]
{
- m_nLFOPosition = static_cast<sal_uInt16>(nData)-1; // m_nLFOPosition in [0..0x7FFF)
+ m_nLFOPosition = o3tl::narrowing<sal_uInt16>(nData)-1; // m_nLFOPosition in [0..0x7FFF)
/*
If we are a ww8+ style with ww7- style lists then there is a
bizarre broken word bug where when the list is removed from a para
@@ -1992,21 +2049,9 @@ void SwWW8ImplReader::Read_LFOPosition(sal_uInt16, const sal_uInt8* pData,
// here the stream data is 1-based, we subtract ONE
if (m_nLFOPosition != 2047-1) //Normal ww8+ list behaviour
{
- if (WW8ListManager::nMaxLevel <= m_nListLevel)
- {
- // This looks like a mistake. What should happen here?
- // If iLvl is undefined, then treat as level 1? (yes - list-nolevel.doc)
- // What about inheritance? (good question - inheritance completely ignored)
- // What about if iLvl is specified as Body Text(nMaxLevel)?
- assert(MAXLEVEL == m_nListLevel && "Looking for proof document showing a specified body text level should not become numbered.");
- m_nListLevel = 0;
- }
- if (WW8ListManager::nMaxLevel > m_nListLevel)
- {
- RegisterNumFormat(m_nLFOPosition, m_nListLevel);
- m_nLFOPosition = USHRT_MAX;
- m_nListLevel = MAXLEVEL;
- }
+ RegisterNumFormat(m_nLFOPosition, m_nListLevel);
+ m_nLFOPosition = USHRT_MAX;
+ m_nListLevel = MAXLEVEL;
}
else if (m_xPlcxMan && m_xPlcxMan->HasParaSprm(NS_sprm::LN_PAnld).pSprm)
{
@@ -2047,7 +2092,7 @@ bool SwWW8ImplReader::ImportFormulaControl(WW8FormulaControl &aFormula,
if ( (68 == aRes.nSprmId) || (0x6A03 == aRes.nSprmId) )
{
Read_PicLoc( aRes.nSprmId, aRes.pMemPos +
- m_xSprmParser->DistanceToData(aRes.nSprmId), 4);
+ m_oSprmParser->DistanceToData(aRes.nSprmId), 4);
break;
}
}
@@ -2057,12 +2102,12 @@ bool SwWW8ImplReader::ImportFormulaControl(WW8FormulaControl &aFormula,
sal_uLong nOffset = m_nPicLocFc;
aSave.Restore(this);
- sal_uLong nOldPos = m_pDataStream->Tell();
+ sal_uInt64 nOldPos = m_pDataStream->Tell();
WW8_PIC aPic;
- m_pDataStream->Seek( nOffset);
- PicRead( m_pDataStream, &aPic, m_bVer67);
+ bool bValid = checkSeek(*m_pDataStream, nOffset) &&
+ PicRead(m_pDataStream, &aPic, m_bVer67);
- if((aPic.lcb > 0x3A) && !m_pDataStream->GetError() )
+ if (bValid && aPic.lcb > 0x3A)
{
aFormula.FormulaRead(nWhich,m_pDataStream);
bRet = true;
@@ -2152,7 +2197,7 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
{
if ( iRes != 25 )
mnChecked = iRes;
- msDefault = ( wDef == 0 ) ? OUStringLiteral( u"0" ) : OUStringLiteral( u"1" );
+ msDefault = ( wDef == 0 ) ? std::u16string_view( u"0" ) : std::u16string_view( u"1" );
}
}
// xstzTextFormat
@@ -2308,8 +2353,7 @@ awt::Size SwWW8ImplReader::MiserableDropDownFormHack(const OUString &rString,
static_cast<const SvxFontHeightItem*>(pItem)->GetHeight() );
aTmp <<= static_cast<float>(aSize.Height()) / 20.0;
- aFont.SetFontSize(OutputDevice::LogicToLogic(aSize,
- MapMode(MapUnit::MapTwip), MapMode(MapUnit::Map100thMM)));
+ aFont.SetFontSize(o3tl::convert(aSize, o3tl::Length::twip, o3tl::Length::mm100));
}
break;
@@ -2347,7 +2391,7 @@ awt::Size SwWW8ImplReader::MiserableDropDownFormHack(const OUString &rString,
OSL_ENSURE(pOut, "Impossible");
if (pOut)
{
- pOut->Push( PushFlags::FONT | PushFlags::MAPMODE );
+ pOut->Push( vcl::PushFlags::FONT | vcl::PushFlags::MAPMODE );
pOut->SetMapMode( MapMode( MapUnit::Map100thMM ));
pOut->SetFont( aFont );
aRet.Width = pOut->GetTextWidth(rString);
@@ -2385,14 +2429,15 @@ bool WW8FormulaListBox::Import(const uno::Reference <
xPropSet->setPropertyValue("HelpText", aTmp );
}
- xPropSet->setPropertyValue("Dropdown", css::uno::makeAny(true));
+ xPropSet->setPropertyValue("Dropdown", css::uno::Any(true));
if (!maListEntries.empty())
{
sal_uInt32 nLen = maListEntries.size();
uno::Sequence< OUString > aListSource(nLen);
+ auto aListSourceRange = asNonConstRange(aListSource);
for (sal_uInt32 nI = 0; nI < nLen; ++nI)
- aListSource[nI] = maListEntries[nI];
+ aListSourceRange[nI] = maListEntries[nI];
aTmp <<= aListSource;
xPropSet->setPropertyValue("StringItemList", aTmp );
@@ -2530,7 +2575,7 @@ bool SwMSConvertControls::InsertControl(
uno::Reference< text::XText > xDummyTextRef;
uno::Reference< text::XTextRange > xTextRg =
- new SwXTextRange( *pPaM, xDummyTextRef );
+ new SwXTextRange( *m_pPaM, xDummyTextRef );
aTmp <<= xTextRg;
xShapePropSet->setPropertyValue("TextRange", aTmp );
diff --git a/sw/source/filter/ww8/ww8par4.cxx b/sw/source/filter/ww8/ww8par4.cxx
index 6c72ed5321eb..981cc95faffa 100644
--- a/sw/source/filter/ww8/ww8par4.cxx
+++ b/sw/source/filter/ww8/ww8par4.cxx
@@ -31,7 +31,6 @@
#include <svx/svdoole2.hxx>
#include <filter/msfilter/msdffimp.hxx>
#include "sprmids.hxx"
-#include <svx/unoapi.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
@@ -65,7 +64,7 @@ struct OLE_MFP
using namespace ::com::sun::star;
-static bool SwWw8ReadScaling(tools::Long& rX, tools::Long& rY, tools::SvRef<SotStorage> const & rSrc1)
+static bool SwWw8ReadScaling(tools::Long& rX, tools::Long& rY, rtl::Reference<SotStorage> const & rSrc1)
{
// Getting the scaling factor:
// Information in the PIC-stream (by trying out)
@@ -80,13 +79,12 @@ static bool SwWw8ReadScaling(tools::Long& rX, tools::Long& rY, tools::SvRef<SotS
// 0x2c, 0x30 scaling x,y in per thousand
// 0x34, 0x38, 0x3c, 0x40 Crop Left, Top, Right, Bot in tw
- tools::SvRef<SotStorageStream> xSrc3 = rSrc1->OpenSotStream( "\3PIC",
+ rtl::Reference<SotStorageStream> xSrc3 = rSrc1->OpenSotStream( "\3PIC",
StreamMode::STD_READ );
SotStorageStream* pS = xSrc3.get();
pS->SetEndian( SvStreamEndian::LITTLE );
- pS->Seek( STREAM_SEEK_TO_END );
- OSL_ENSURE( pS->Tell() >= 76, "+OLE-PIC-Stream is shorter than 76 Byte" );
+ OSL_ENSURE( pS->TellEnd() >= 76, "+OLE-PIC-Stream is shorter than 76 Byte" );
sal_Int32 nOrgWidth,
nOrgHeight,
@@ -123,9 +121,9 @@ static bool SwWw8ReadScaling(tools::Long& rX, tools::Long& rY, tools::SvRef<SotS
}
static bool SwWw6ReadMetaStream(GDIMetaFile& rWMF, OLE_MFP* pMfp,
- tools::SvRef<SotStorage> const & rSrc1)
+ rtl::Reference<SotStorage> const& rSrc1)
{
- tools::SvRef<SotStorageStream> xSrc2 = rSrc1->OpenSotStream( "\3META",
+ rtl::Reference<SotStorageStream> xSrc2 = rSrc1->OpenSotStream( "\3META",
StreamMode::STD_READ );
SotStorageStream* pSt = xSrc2.get();
pSt->SetEndian( SvStreamEndian::LITTLE );
@@ -176,10 +174,10 @@ static bool SwWw6ReadMetaStream(GDIMetaFile& rWMF, OLE_MFP* pMfp,
return true;
}
-static bool SwWw6ReadMacPICTStream(Graphic& rGraph, tools::SvRef<SotStorage> const & rSrc1)
+static bool SwWw6ReadMacPICTStream(Graphic& rGraph, rtl::Reference<SotStorage> const& rSrc1)
{
// 03-META-stream does not exist. Maybe a 03-PICT?
- tools::SvRef<SotStorageStream> xSrc4 = rSrc1->OpenSotStream("\3PICT");
+ rtl::Reference<SotStorageStream> xSrc4 = rSrc1->OpenSotStream("\3PICT");
SotStorageStream* pStp = xSrc4.get();
pStp->SetEndian( SvStreamEndian::LITTLE );
sal_uInt8 aTestA[10]; // Does the 01Ole-stream even exist?
@@ -204,7 +202,7 @@ SwFlyFrameFormat* SwWW8ImplReader::InsertOle(SdrOle2Obj &rObject,
SwFlyFrameFormat *pRet = nullptr;
- std::unique_ptr<SfxItemSet> pMathFlySet;
+ std::optional<SfxItemSet> pMathFlySet;
uno::Reference < embed::XClassifiedObject > xClass = rObject.GetObjRef();
if( xClass.is() )
{
@@ -213,7 +211,7 @@ SwFlyFrameFormat* SwWW8ImplReader::InsertOle(SdrOle2Obj &rObject,
{
// StarMath sets it own fixed size, so its counter productive to use
// the size Word says it is. i.e. Don't attempt to override its size.
- pMathFlySet.reset(new SfxItemSet(rFlySet));
+ pMathFlySet.emplace(rFlySet);
pMathFlySet->ClearItem(RES_FRM_SIZE);
}
}
@@ -232,7 +230,7 @@ SwFlyFrameFormat* SwWW8ImplReader::InsertOle(SdrOle2Obj &rObject,
OSL_ENSURE(bSuccess, "Insert OLE failed");
if (bSuccess)
{
- const SfxItemSet *pFlySet = pMathFlySet ? pMathFlySet.get() : &rFlySet;
+ const SfxItemSet *pFlySet = pMathFlySet ? &*pMathFlySet : &rFlySet;
pRet = m_rDoc.getIDocumentContentOperations().InsertOLE(*m_pPaM, sNewName, rObject.GetAspect(), pFlySet, rGrfSet);
}
return pRet;
@@ -247,16 +245,16 @@ SwFrameFormat* SwWW8ImplReader::ImportOle(const Graphic* pGrf,
GraphicCtor();
Graphic aGraph;
- SdrObject* pRet = ImportOleBase(aGraph, pGrf, pFlySet, aVisArea );
+ rtl::Reference<SdrObject> pRet = ImportOleBase(aGraph, pGrf, pFlySet, aVisArea );
// create flyset
- std::unique_ptr<SfxItemSet> pTempSet;
+ std::optional<SfxItemSet> pTempSet;
if( !pFlySet )
{
- pTempSet.reset( new SfxItemSet( m_rDoc.GetAttrPool(), svl::Items<RES_FRMATR_BEGIN,
- RES_FRMATR_END-1>{}) );
+ pTempSet.emplace( m_rDoc.GetAttrPool(), svl::Items<RES_FRMATR_BEGIN,
+ RES_FRMATR_END-1> );
- pFlySet = pTempSet.get();
+ pFlySet = &*pTempSet;
// Remove distance/borders
Reader::ResetFrameFormatAttrs( *pTempSet );
@@ -282,10 +280,10 @@ SwFrameFormat* SwWW8ImplReader::ImportOle(const Graphic* pGrf,
if (pRet) // OLE object was inserted
{
- if (SdrOle2Obj *pOleObj = dynamic_cast<SdrOle2Obj*>(pRet))
+ if (SdrOle2Obj *pOleObj = dynamic_cast<SdrOle2Obj*>(pRet.get()))
{
pFormat = InsertOle(*pOleObj, *pFlySet, pGrfSet);
- SdrObject::Free(pRet); // we don't need this anymore
+ pRet.clear(); // we don't need this anymore
}
else
pFormat = m_rDoc.getIDocumentContentOperations().InsertDrawObj(*m_pPaM, *pRet, *pFlySet );
@@ -302,7 +300,7 @@ SwFrameFormat* SwWW8ImplReader::ImportOle(const Graphic* pGrf,
return pFormat;
}
-bool SwWW8ImplReader::ImportOleWMF(const tools::SvRef<SotStorage>& xSrc1, GDIMetaFile& rWMF,
+bool SwWW8ImplReader::ImportOleWMF(const rtl::Reference<SotStorage>& xSrc1, GDIMetaFile& rWMF,
tools::Long& rX, tools::Long& rY)
{
bool bOk = false;
@@ -325,7 +323,7 @@ bool SwWW8ImplReader::ImportOleWMF(const tools::SvRef<SotStorage>& xSrc1, GDIMet
return bOk;
}
-SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
+rtl::Reference<SdrObject> SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
const Graphic* pGrf, const SfxItemSet* pFlySet, const tools::Rectangle& aVisArea )
{
if (!m_pStg)
@@ -342,8 +340,8 @@ SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
// results in the name "_4711"
OUString aSrcStgName = "_" + OUString::number( m_nObjLocFc );
- tools::SvRef<SotStorage> xSrc0 = m_pStg->OpenSotStorage(SL::aObjectPool);
- tools::SvRef<SotStorage> xSrc1 = xSrc0->OpenSotStorage( aSrcStgName );
+ rtl::Reference<SotStorage> xSrc0 = m_pStg->OpenSotStorage(SL::aObjectPool);
+ rtl::Reference<SotStorage> xSrc1 = xSrc0->OpenSotStorage(aSrcStgName);
if (pGrf)
{
@@ -381,7 +379,7 @@ SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
}
}
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
if (!(m_bIsHeader || m_bIsFooter))
{
@@ -390,7 +388,7 @@ SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
OSL_ENSURE(m_xFormImpl, "Impossible");
if (m_xFormImpl && m_xFormImpl->ReadOCXStream(xSrc1, &xRef))
{
- pRet = GetSdrObjectFromXShape(xRef);
+ pRet = SdrObject::getSdrObjectFromXShape(xRef);
OSL_ENSURE(pRet, "Impossible");
if (pRet)
pRet->SetLogicRect(aRect);
@@ -405,10 +403,9 @@ SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
if (bOleOk)
{
- sal_uLong nOldPos = m_pDataStream->Tell();
- m_pDataStream->Seek(STREAM_SEEK_TO_END);
+ sal_uInt64 nOldPos = m_pDataStream->Tell();
SvStream *pTmpData = nullptr;
- if (m_nObjLocFc < m_pDataStream->Tell())
+ if (m_nObjLocFc < m_pDataStream->TellEnd())
{
pTmpData = m_pDataStream;
pTmpData->Seek( m_nObjLocFc );
@@ -417,7 +414,7 @@ SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
{
- tools::SvRef<SotStorageStream> xObjInfoSrc = xSrc1->OpenSotStream("\3ObjInfo",
+ rtl::Reference<SotStorageStream> xObjInfoSrc = xSrc1->OpenSotStream("\3ObjInfo",
StreamMode::STD_READ );
if ( xObjInfoSrc.is() && !xObjInfoSrc->GetError() )
{
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 3aa79d63e707..f34f5996caa9 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -18,6 +18,7 @@
*/
#include <config_features.h>
+#include <config_fuzzers.h>
#include <sal/types.h>
#include <tools/solar.h>
@@ -33,6 +34,7 @@
#include <svl/cintitem.hxx>
#include <svl/lngmisc.hxx>
#include <svl/urihelper.hxx>
+#include <svl/numformat.hxx>
#include <svl/zforlist.hxx>
#include <svl/zformat.hxx>
#include <sfx2/linkmgr.hxx>
@@ -56,6 +58,7 @@
#include <IDocumentState.hxx>
#include <flddat.hxx>
#include <docufld.hxx>
+#include <usrfld.hxx>
#include <reffld.hxx>
#include <IMark.hxx>
#include <expfld.hxx>
@@ -76,11 +79,13 @@
#include "ww8par.hxx"
#include "writerhelper.hxx"
#include <o3tl/safeint.hxx>
-#include <unotools/fltrcfg.hxx>
+#include <o3tl/string_view.hxx>
#include <xmloff/odffields.hxx>
#include <osl/diagnose.h>
+#include <officecfg/Office/Common.hxx>
#include <algorithm>
+#include <string_view>
#define MAX_FIELDLEN 64000
@@ -90,16 +95,15 @@ using namespace ::com::sun::star;
using namespace msfilter::util;
using namespace sw::util;
using namespace sw::mark;
-using namespace std; // #i24377#
using namespace nsSwDocInfoSubType;
// Bookmarks
namespace
{
// #120879# - helper method to identify a bookmark name to match the internal TOC bookmark naming convention
- bool IsTOCBookmarkName(const OUString& rName)
+ bool IsTOCBookmarkName(std::u16string_view rName)
{
- return rName.startsWith("_Toc") || rName.startsWith(OUString(IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix()+"_Toc"));
+ return o3tl::starts_with(rName, u"_Toc") || o3tl::starts_with(rName, Concat2View(IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix()+"_Toc"));
}
OUString EnsureTOCBookmarkName(const OUString& rName)
@@ -155,7 +159,7 @@ tools::Long SwWW8ImplReader::Read_Book(WW8PLCFManResult*)
if( nLen > MAX_FIELDLEN )
nLen = MAX_FIELDLEN;
- tools::Long nOldPos = m_pStrm->Tell();
+ sal_uInt64 nOldPos = m_pStrm->Tell();
m_xSBase->WW8ReadString( *m_pStrm, aVal, pB->GetStartPos(), nLen,
m_eStructCharSet );
m_pStrm->Seek( nOldPos );
@@ -181,7 +185,7 @@ tools::Long SwWW8ImplReader::Read_Book(WW8PLCFManResult*)
case 0x0d:
if( bAllowCr )
{
- aVal = aVal.replaceAt( nI, 1, "\n" );
+ aVal = aVal.replaceAt( nI, 1, u"\n" );
bSetAsHex = false;
}
else
@@ -299,27 +303,27 @@ static void lcl_ConvertSequenceName(OUString& rSequenceName)
// FindParaStart() finds 1st Parameter that follows '\' and cToken
// and returns start of this parameter or -1
-static sal_Int32 FindParaStart( const OUString& rStr, sal_Unicode cToken, sal_Unicode cToken2 )
+static sal_Int32 FindParaStart( std::u16string_view aStr, sal_Unicode cToken, sal_Unicode cToken2 )
{
bool bStr = false; // ignore inside a string
- for( sal_Int32 nBuf = 0; nBuf+1 < rStr.getLength(); nBuf++ )
+ for( size_t nBuf = 0; nBuf+1 < aStr.size(); nBuf++ )
{
- if( rStr[ nBuf ] == '"' )
+ if( aStr[ nBuf ] == '"' )
bStr = !bStr;
if( !bStr
- && rStr[ nBuf ] == '\\'
- && ( rStr[ nBuf + 1 ] == cToken
- || rStr[ nBuf + 1 ] == cToken2 ) )
+ && aStr[ nBuf ] == '\\'
+ && ( aStr[ nBuf + 1 ] == cToken
+ || aStr[ nBuf + 1 ] == cToken2 ) )
{
nBuf += 2;
// skip spaces between cToken and its parameters
- while( nBuf < rStr.getLength()
- && rStr[ nBuf ] == ' ' )
+ while( nBuf < aStr.size()
+ && aStr[ nBuf ] == ' ' )
nBuf++;
// return start of parameters
- return nBuf < rStr.getLength() ? nBuf : -1;
+ return nBuf < aStr.size() ? nBuf : -1;
}
}
return -1;
@@ -328,37 +332,40 @@ static sal_Int32 FindParaStart( const OUString& rStr, sal_Unicode cToken, sal_Un
// FindPara() finds the first parameter including '\' and cToken.
// A new String will be allocated (has to be deallocated by the caller)
// and everything that is part of the parameter will be returned.
-static OUString FindPara( const OUString& rStr, sal_Unicode cToken, sal_Unicode cToken2 )
+static OUString FindPara( std::u16string_view aStr, sal_Unicode cToken, sal_Unicode cToken2 )
{
sal_Int32 n2; // end
- sal_Int32 n = FindParaStart( rStr, cToken, cToken2 ); // start
+ sal_Int32 n = FindParaStart( aStr, cToken, cToken2 ); // start
if( n == -1)
return OUString();
- if( rStr[ n ] == '"'
- || rStr[ n ] == 132 )
+ if( aStr[ n ] == '"'
+ || aStr[ n ] == 132 )
{ // Quotationmark in front of parameter
n++; // Skip quotationmark
n2 = n; // search for the end starting from here
- while( n2 < rStr.getLength()
- && rStr[ n2 ] != 147
- && rStr[ n2 ] != '"' )
+ while( n2 < sal_Int32(aStr.size())
+ && aStr[ n2 ] != 147
+ && aStr[ n2 ] != '"' )
n2++; // search end of parameter
}
else
{ // no quotationmarks
n2 = n; // search for the end starting from here
- while( n2 < rStr.getLength()
- && rStr[ n2 ] != ' ' )
+ while( n2 < sal_Int32(aStr.size())
+ && aStr[ n2 ] != ' ' )
n2++; // search end of parameter
}
- return rStr.copy( n, n2-n );
+ return OUString(aStr.substr( n, n2-n ));
}
static SvxNumType GetNumTypeFromName(const OUString& rStr,
bool bAllowPageDesc = false)
{
SvxNumType eTyp = bAllowPageDesc ? SVX_NUM_PAGEDESC : SVX_NUM_ARABIC;
+ if (rStr.isEmpty())
+ return eTyp;
+
if( rStr.startsWithIgnoreAsciiCase( "Arabi" ) ) // Arabisch, Arabic
eTyp = SVX_NUM_ARABIC;
else if( rStr.startsWith( "misch" ) ) // r"omisch
@@ -376,9 +383,9 @@ static SvxNumType GetNumTypeFromName(const OUString& rStr,
return eTyp;
}
-static SvxNumType GetNumberPara(const OUString& rStr, bool bAllowPageDesc = false)
+static SvxNumType GetNumberPara(std::u16string_view aStr, bool bAllowPageDesc = false)
{
- OUString s( FindPara( rStr, '*', '*' ) ); // Type of number
+ OUString s( FindPara( aStr, '*', '*' ) ); // Type of number
SvxNumType aType = GetNumTypeFromName( s, bAllowPageDesc );
return aType;
}
@@ -387,8 +394,7 @@ bool SwWW8ImplReader::ForceFieldLanguage(SwField &rField, LanguageType nLang)
{
bool bRet(false);
- const SvxLanguageItem *pLang =
- static_cast<const SvxLanguageItem*>(GetFormatAttr(RES_CHRATR_LANGUAGE));
+ const SvxLanguageItem *pLang = GetFormatAttr(RES_CHRATR_LANGUAGE);
OSL_ENSURE(pLang, "impossible");
LanguageType nDefault = pLang ? pLang->GetValue() : LANGUAGE_ENGLISH_US;
@@ -424,7 +430,7 @@ static OUString GetWordDefaultDateStringAsUS(SvNumberFormatter* pFormatter, Lang
return sParams;
}
-SvNumFormatType SwWW8ImplReader::GetTimeDatePara(OUString const & rStr, sal_uInt32& rFormat,
+SvNumFormatType SwWW8ImplReader::GetTimeDatePara(std::u16string_view aStr, sal_uInt32& rFormat,
LanguageType &rLang, int nWhichDefault, bool bHijri)
{
bool bRTL = false;
@@ -434,13 +440,13 @@ SvNumFormatType SwWW8ImplReader::GetTimeDatePara(OUString const & rStr, sal_uInt
if (aResult.pSprm && aResult.nRemainingData >= 1 && *aResult.pSprm)
bRTL = true;
}
- sal_uInt16 eLang = bRTL ? RES_CHRATR_CTL_LANGUAGE : RES_CHRATR_LANGUAGE;
- const SvxLanguageItem *pLang = static_cast<const SvxLanguageItem*>(GetFormatAttr(eLang));
+ TypedWhichId<SvxLanguageItem> eLang = bRTL ? RES_CHRATR_CTL_LANGUAGE : RES_CHRATR_LANGUAGE;
+ const SvxLanguageItem *pLang = GetFormatAttr(eLang);
OSL_ENSURE(pLang, "impossible");
rLang = pLang ? pLang->GetValue() : LANGUAGE_ENGLISH_US;
SvNumberFormatter* pFormatter = m_rDoc.GetNumberFormatter();
- OUString sParams( FindPara( rStr, '@', '@' ) );// Date/Time
+ OUString sParams( FindPara( aStr, '@', '@' ) );// Date/Time
if (sParams.isEmpty())
{
bool bHasTime = false;
@@ -497,6 +503,20 @@ void SwWW8ImplReader::UpdateFields()
m_rDoc.SetInitDBFields(true); // Also update fields in the database
}
+// Sanity check the PaM to see if it makes sense wrt sw::CalcBreaks
+static bool SanityCheck(const SwPaM& rFieldPam)
+{
+ SwNodeOffset const nEndNode(rFieldPam.End()->GetNodeIndex());
+ SwNodes const& rNodes(rFieldPam.GetPoint()->GetNodes());
+ SwNode *const pFinalNode(rNodes[nEndNode]);
+ if (pFinalNode->IsTextNode())
+ {
+ SwTextNode & rTextNode(*pFinalNode->GetTextNode());
+ return (rTextNode.Len() >= rFieldPam.End()->GetContentIndex());
+ }
+ return true;
+}
+
sal_uInt16 SwWW8ImplReader::End_Field()
{
sal_uInt16 nRet = 0;
@@ -506,8 +526,7 @@ sal_uInt16 SwWW8ImplReader::End_Field()
if (!pF || !pF->EndPosIsFieldEnd(nCP))
return nRet;
- const SvtFilterOptions &rOpt = SvtFilterOptions::Get();
- bool bUseEnhFields = rOpt.IsUseEnhancedFields();
+ bool bUseEnhFields = officecfg::Office::Common::Filter::Microsoft::Import::ImportWWFieldsAsEnhancedFields::get();
OSL_ENSURE(!m_aFieldStack.empty(), "Empty field stack");
if (!m_aFieldStack.empty())
@@ -523,11 +542,12 @@ sal_uInt16 SwWW8ImplReader::End_Field()
case ww::eFORMTEXT:
if (bUseEnhFields && m_pPaM!=nullptr && m_pPaM->GetPoint()!=nullptr) {
SwPosition aEndPos = *m_pPaM->GetPoint();
- SwPaM aFieldPam( m_aFieldStack.back().GetPtNode(), m_aFieldStack.back().GetPtContent(), aEndPos.nNode, aEndPos.nContent.GetIndex());
+ SwPaM aFieldPam( m_aFieldStack.back().GetPtNode().GetNode(), m_aFieldStack.back().GetPtContent(), aEndPos.GetNode(), aEndPos.GetContentIndex());
+
IDocumentMarkAccess* pMarksAccess = m_rDoc.getIDocumentMarkAccess( );
- IFieldmark *pFieldmark = pMarksAccess->makeFieldBookmark(
+ IFieldmark *pFieldmark = SanityCheck(aFieldPam) ? pMarksAccess->makeFieldBookmark(
aFieldPam, m_aFieldStack.back().GetBookmarkName(), ODF_FORMTEXT,
- aFieldPam.Start() /*same pos as start!*/ );
+ aFieldPam.Start() /*same pos as start!*/ ) : nullptr;
OSL_ENSURE(pFieldmark!=nullptr, "hmmm; why was the bookmark not created?");
if (pFieldmark!=nullptr) {
// adapt redline positions to inserted field mark start
@@ -553,8 +573,8 @@ sal_uInt16 SwWW8ImplReader::End_Field()
m_aTOXEndCps.insert(nCP);
m_bLoadingTOXCache = false;
if ( m_pPaM->End() &&
- m_pPaM->End()->nNode.GetNode().GetTextNode() &&
- m_pPaM->End()->nNode.GetNode().GetTextNode()->Len() == 0 )
+ m_pPaM->End()->GetNode().GetTextNode() &&
+ m_pPaM->End()->GetNode().GetTextNode()->Len() == 0 )
{
JoinNode(*m_pPaM);
}
@@ -563,10 +583,10 @@ sal_uInt16 SwWW8ImplReader::End_Field()
m_bCareLastParaEndInToc = true;
}
- if (m_pPosAfterTOC)
+ if (m_oPosAfterTOC)
{
- *m_pPaM = *m_pPosAfterTOC;
- m_pPosAfterTOC.reset();
+ *m_pPaM = *m_oPosAfterTOC;
+ m_oPosAfterTOC.reset();
}
}
}
@@ -584,18 +604,46 @@ sal_uInt16 SwWW8ImplReader::End_Field()
break;
case ww::eMERGEINC:
case ww::eINCLUDETEXT:
+ {
//Move outside the section associated with this type of field
- *m_pPaM->GetPoint() = m_aFieldStack.back().maStartPos;
+ SwPosition aRestorePos(m_aFieldStack.back().maStartPos);
+
+ SwContentNode* pNd = aRestorePos.GetNode().GetContentNode();
+ sal_Int32 nMaxValidIndex = pNd ? pNd->Len() : 0;
+ if (aRestorePos.GetContentIndex() > nMaxValidIndex)
+ {
+ SAL_WARN("sw.ww8", "Attempt to restore to invalid content position");
+ aRestorePos.SetContent(nMaxValidIndex);
+ }
+
+ *m_pPaM->GetPoint() = aRestorePos;
break;
+ }
case ww::eIF: // IF-field
{
// conditional field parameters
- const OUString& fieldDefinition = m_aFieldStack.back().GetBookmarkCode();
+ OUString fieldDefinition = m_aFieldStack.back().GetBookmarkCode();
OUString paramCondition;
OUString paramTrue;
OUString paramFalse;
+ // ParseIfFieldDefinition expects: IF <some condition> "true result" "false result"
+ // while many fields include '\* MERGEFORMAT' after that.
+ // So first trim off the switches that are not supported anyway
+ sal_Int32 nLastIndex = fieldDefinition.lastIndexOf("\\*");
+ sal_Int32 nOtherIndex = fieldDefinition.lastIndexOf("\\#"); //number format
+ if (nOtherIndex > 0 && (nOtherIndex < nLastIndex || nLastIndex < 0))
+ nLastIndex = nOtherIndex;
+ nOtherIndex = fieldDefinition.lastIndexOf("\\@"); //date format
+ if (nOtherIndex > 0 && (nOtherIndex < nLastIndex || nLastIndex < 0))
+ nLastIndex = nOtherIndex;
+ nOtherIndex = fieldDefinition.lastIndexOf("\\!"); //locked result
+ if (nOtherIndex > 0 && (nOtherIndex < nLastIndex || nLastIndex < 0))
+ nLastIndex = nOtherIndex;
+ if (nLastIndex > 0)
+ fieldDefinition = fieldDefinition.copy(0, nLastIndex);
+
SwHiddenTextField::ParseIfFieldDefinition(fieldDefinition, paramCondition, paramTrue, paramFalse);
// create new field
@@ -613,13 +661,13 @@ sal_uInt16 SwWW8ImplReader::End_Field()
}
default:
OUString aCode = m_aFieldStack.back().GetBookmarkCode();
- if (!aCode.isEmpty() && !aCode.trim().startsWith("SHAPE"))
+ if (!aCode.isEmpty() && !o3tl::starts_with(o3tl::trim(aCode), u"SHAPE"))
{
// Unhandled field with stored code
SwPosition aEndPos = *m_pPaM->GetPoint();
SwPaM aFieldPam(
- m_aFieldStack.back().GetPtNode(), m_aFieldStack.back().GetPtContent(),
- aEndPos.nNode, aEndPos.nContent.GetIndex());
+ m_aFieldStack.back().GetPtNode().GetNode(), m_aFieldStack.back().GetPtContent(),
+ aEndPos.GetNode(), aEndPos.GetContentIndex());
IDocumentMarkAccess* pMarksAccess = m_rDoc.getIDocumentMarkAccess( );
@@ -639,11 +687,11 @@ sal_uInt16 SwWW8ImplReader::End_Field()
pFieldmark->GetParameters()->insert(
std::pair< OUString, uno::Any > (
ODF_ID_PARAM,
- uno::makeAny( sFieldId ) ) );
+ uno::Any( sFieldId ) ) );
pFieldmark->GetParameters()->insert(
std::pair< OUString, uno::Any > (
ODF_CODE_PARAM,
- uno::makeAny( aCode ) ) );
+ uno::Any( aCode ) ) );
if ( m_aFieldStack.back().mnObjLocFc > 0 )
{
@@ -651,8 +699,8 @@ sal_uInt16 SwWW8ImplReader::End_Field()
OUString sOleId = "_" +
OUString::number( m_aFieldStack.back().mnObjLocFc );
- tools::SvRef<SotStorage> xSrc0 = m_pStg->OpenSotStorage(SL::aObjectPool);
- tools::SvRef<SotStorage> xSrc1 = xSrc0->OpenSotStorage( sOleId, StreamMode::READ );
+ rtl::Reference<SotStorage> xSrc0 = m_pStg->OpenSotStorage(SL::aObjectPool);
+ rtl::Reference<SotStorage> xSrc1 = xSrc0->OpenSotStorage( sOleId, StreamMode::READ );
// Store it now!
uno::Reference< embed::XStorage > xDocStg = GetDoc().GetDocStorage();
@@ -660,7 +708,7 @@ sal_uInt16 SwWW8ImplReader::End_Field()
{
uno::Reference< embed::XStorage > xOleStg = xDocStg->openStorageElement(
"OLELinks", embed::ElementModes::WRITE );
- tools::SvRef<SotStorage> xObjDst = SotStorage::OpenOLEStorage( xOleStg, sOleId );
+ rtl::Reference<SotStorage> xObjDst = SotStorage::OpenOLEStorage( xOleStg, sOleId );
if ( xObjDst.is() )
{
@@ -678,7 +726,7 @@ sal_uInt16 SwWW8ImplReader::End_Field()
// Store the OLE Id as a parameter
pFieldmark->GetParameters()->insert(
std::pair< OUString, uno::Any >(
- ODF_OLE_PARAM, uno::makeAny( sOleId ) ) );
+ ODF_OLE_PARAM, uno::Any( sOleId ) ) );
}
}
}
@@ -889,7 +937,7 @@ tools::Long SwWW8ImplReader::Read_Field(WW8PLCFManResult* pRes)
if (bNested)
return 0;
- sal_uInt16 n = (aF.nId <= eMax) ? aF.nId : static_cast<sal_uInt16>(eMax);
+ sal_uInt16 n = (aF.nId <= eMax) ? aF.nId : o3tl::narrowing<sal_uInt16>(eMax);
sal_uInt16 nI = n / 32; // # of sal_uInt32
sal_uInt32 nMask = 1 << ( n % 32 ); // Mask for bits
@@ -920,8 +968,7 @@ tools::Long SwWW8ImplReader::Read_Field(WW8PLCFManResult* pRes)
bool bHasHandler = aWW8FieldTab[aF.nId] != nullptr;
if (aF.nId == 10) // STYLEREF
{
- // STYLEREF, by default these are not handled.
- bHasHandler = false;
+ bool bHandledByChapter = false;
sal_uInt64 nOldPos = m_pStrm->Tell();
OUString aStr;
aF.nLCode = m_xSBase->WW8ReadString(*m_pStrm, aStr, m_xPlcxMan->GetCpOfs() + aF.nSCode, aF.nLCode, m_eTextCharSet);
@@ -931,9 +978,9 @@ tools::Long SwWW8ImplReader::Read_Field(WW8PLCFManResult* pRes)
sal_Int32 nRet = aReadParam.SkipToNextToken();
if (nRet == -2 && !aReadParam.GetResult().isEmpty())
// Single numeric argument: this can be handled by SwChapterField.
- bHasHandler = rtl::isAsciiDigit(aReadParam.GetResult()[0]);
+ bHandledByChapter = rtl::isAsciiDigit(aReadParam.GetResult()[0]);
- if (bHasHandler)
+ if (bHandledByChapter)
{
nRet = aReadParam.SkipToNextToken();
// Handle using SwChapterField only in case there is no \[a-z]
@@ -951,7 +998,7 @@ tools::Long SwWW8ImplReader::Read_Field(WW8PLCFManResult* pRes)
if (aF.bResNest && !AcceptableNestedField(aF.nId))
return aF.nLen; // Result nested -> unusable
- tools::Long nOldPos = m_pStrm->Tell();
+ sal_uInt64 nOldPos = m_pStrm->Tell();
OUString aStr;
aF.nLCode = m_xSBase->WW8ReadString( *m_pStrm, aStr, m_xPlcxMan->GetCpOfs()+
aF.nSCode, aF.nLCode, m_eTextCharSet );
@@ -977,6 +1024,16 @@ tools::Long SwWW8ImplReader::Read_Field(WW8PLCFManResult* pRes)
m_bEmbeddObj = true;
// Field not supported: store the field code for later use
m_aFieldStack.back().SetBookmarkCode( aStr );
+
+ if (aF.nId == ww::eIF)
+ {
+ // In MS Word, the IF field is editable and requires a manual refresh
+ // so the last, saved result might not match either of the true or false options.
+ // But in LO the field is automatically updated and not editable,
+ // so the previous result is of no value to import since it could never be seen.
+ return aF.nLen;
+ }
+
return aF.nLen - aF.nLRes - 1; // skipped too many, the resulted field will be read like main text
}
}
@@ -1052,29 +1109,29 @@ void SwWW8ImplReader::MakeTagString( OUString& rStr, const OUString& rOrg )
case 132: // Exchange typographical quotation marks for normal ones
case 148:
case 147:
- rStr = rStr.replaceAt( nI, 1, "\"" );
+ rStr = rStr.replaceAt( nI, 1, u"\"" );
break;
case 19:
- rStr = rStr.replaceAt( nI, 1, "{" );
+ rStr = rStr.replaceAt( nI, 1, u"{" );
break; // 19..21 to {|}
case 20:
- rStr = rStr.replaceAt( nI, 1, "|" );
+ rStr = rStr.replaceAt( nI, 1, u"|" );
break;
case 21:
- rStr = rStr.replaceAt( nI, 1, "}" );
+ rStr = rStr.replaceAt( nI, 1, u"}" );
break;
case '\\': // Tag \{|} with \ ...
case '{':
case '|':
case '}':
- rStr = rStr.replaceAt( nI, 0, "\\" );
+ rStr = rStr.replaceAt( nI, 0, u"\\" );
++nI;
break;
case 0x0b:
case 0x0c:
case 0x0d:
if( bAllowCr )
- rStr = rStr.replaceAt( nI, 1, "\n" );
+ rStr = rStr.replaceAt( nI, 1, u"\n" );
else
bSetAsHex = true;
break;
@@ -1130,7 +1187,7 @@ void SwWW8ImplReader::InsertTagField( const sal_uInt16 nId, const OUString& rTag
WW8_CP SwWW8ImplReader::Read_F_Tag( WW8FieldDesc* pF )
{
- tools::Long nOldPos = m_pStrm->Tell();
+ sal_uInt64 nOldPos = m_pStrm->Tell();
WW8_CP nStart = pF->nSCode - 1; // starting with 0x19
WW8_CP nL = pF->nLen; // Total length with result and nest
@@ -1190,7 +1247,7 @@ eF_ResT SwWW8ImplReader::Read_F_Input( WW8FieldDesc* pF, OUString& rStr )
// GetFieldResult allocates a string and reads the resulted field
OUString SwWW8ImplReader::GetFieldResult( WW8FieldDesc const * pF )
{
- tools::Long nOldPos = m_pStrm->Tell();
+ sal_uInt64 nOldPos = m_pStrm->Tell();
WW8_CP nStart = pF->nSRes; // result start
WW8_CP nL = pF->nLRes; // result length
@@ -1298,13 +1355,13 @@ tools::Long SwWW8ImplReader::MapBookmarkVariables(const WW8FieldDesc* pF,
}
else
{
- nNo = m_xReffingStck->aFieldVarNames.size()+1;
+ nNo = m_xReffingStck->m_aFieldVarNames.size()+1;
sName = "WWSetBkmk" + OUString::number(nNo);
nNo += m_xPlcxMan->GetBook()->GetIMax();
}
m_xReffedStck->NewAttr(*m_pPaM->GetPoint(),
SwFltBookmark( BookmarkToWriter(sName), rData, nNo ));
- m_xReffingStck->aFieldVarNames[rOrigName] = sName;
+ m_xReffingStck->m_aFieldVarNames[rOrigName] = sName;
return nNo;
}
@@ -1327,14 +1384,14 @@ SwFltStackEntry *SwWW8FltRefStack::RefToVar(const SwField* pField,
//Get the name of the ref field, and see if actually a variable
const OUString sName = pField->GetPar1();
std::map<OUString, OUString, SwWW8::ltstr>::const_iterator
- aResult = aFieldVarNames.find(sName);
+ aResult = m_aFieldVarNames.find(sName);
- if (aResult != aFieldVarNames.end())
+ if (aResult != m_aFieldVarNames.end())
{
SwGetExpField aField( static_cast<SwGetExpFieldType*>(
- rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::GetExp)), sName, nsSwGetSetExpType::GSE_STRING, 0);
+ m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::GetExp)), sName, nsSwGetSetExpType::GSE_STRING, 0);
SwFormatField aTmp(aField);
- rEntry.pAttr.reset( aTmp.Clone() );
+ rEntry.m_pAttr.reset( aTmp.Clone() );
pRet = &rEntry;
}
}
@@ -1350,9 +1407,9 @@ OUString SwWW8ImplReader::GetMappedBookmark(std::u16string_view rOrigName)
//See if there has been a variable set with this name, if so get
//the pseudo bookmark name that was set with it.
std::map<OUString, OUString, SwWW8::ltstr>::const_iterator aResult =
- m_xReffingStck->aFieldVarNames.find(sName);
+ m_xReffingStck->m_aFieldVarNames.find(sName);
- return (aResult == m_xReffingStck->aFieldVarNames.end())
+ return (aResult == m_xReffingStck->m_aFieldVarNames.end())
? sName : (*aResult).second;
}
@@ -1417,10 +1474,9 @@ eF_ResT SwWW8ImplReader::Read_F_ANumber( WW8FieldDesc*, OUString& rStr )
{
if( !m_pNumFieldType ){ // 1st time
SwSetExpFieldType aT( &m_rDoc, "AutoNr", nsSwGetSetExpType::GSE_SEQ );
- m_pNumFieldType = m_rDoc.getIDocumentFieldsAccess().InsertFieldType( aT );
+ m_pNumFieldType = static_cast<SwSetExpFieldType*>(m_rDoc.getIDocumentFieldsAccess().InsertFieldType( aT ));
}
- SwSetExpField aField( static_cast<SwSetExpFieldType*>(m_pNumFieldType), OUString(),
- GetNumberPara( rStr ) );
+ SwSetExpField aField( m_pNumFieldType, OUString(), GetNumberPara( rStr ) );
aField.SetValue( ++m_nFieldNum, nullptr );
m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) );
return eF_ResT::OK;
@@ -1530,6 +1586,7 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr )
// RegInfoFormat, DefaultFormat for DocInfoFields
sal_uInt16 nReg = DI_SUB_AUTHOR;
bool bDateTime = false;
+ const sal_uInt16 nFldLock = (pF->nOpt & 0x10) ? DI_SUB_FIXED : 0;
if( 85 == pF->nId )
{
@@ -1639,9 +1696,35 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr )
if( !bFieldFound )
{
- SwDocInfoField aField( static_cast<SwDocInfoFieldType*>(
- m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::DocInfo )), DI_CUSTOM|nReg, aDocProperty, GetFieldResult( pF ) );
- m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM, SwFormatField(aField));
+ // LO always automatically updates a DocInfo field from the File-Properties-Custom Prop
+ // while MS Word requires the user to manually refresh the field (with F9).
+ // In other words, Word lets the field to be out of sync with the controlling variable.
+ // Marking as FIXEDFLD solves the automatic replacement problem, but of course prevents
+ // Writer from making any changes, even on an F9 refresh.
+ // TODO: Extend LO to allow a linked field that doesn't automatically update.
+ IDocumentContentOperations& rIDCO(m_rDoc.getIDocumentContentOperations());
+ const auto pType(static_cast<SwDocInfoFieldType*>(
+ m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DocInfo)));
+ const OUString sDisplayed = GetFieldResult(pF);
+ SwDocInfoField aField(pType, DI_CUSTOM | nReg, aDocProperty);
+
+ // If text already matches the DocProperty var, then safe to treat as refreshable field.
+ OUString sVariable = aField.ExpandField(/*bCache=*/false, nullptr);
+ if (sDisplayed.getLength() != sVariable.getLength())
+ {
+ sal_Int32 nLen = sVariable.indexOf('\x0');
+ if (nLen >= 0)
+ sVariable = sVariable.copy(0, nLen);
+ }
+ if (sDisplayed == sVariable)
+ rIDCO.InsertPoolItem(*m_pPaM, SwFormatField(aField));
+ else
+ {
+ // They don't match, so use a fixed field to prevent LO from altering the contents.
+ SwDocInfoField aFixedField(pType, DI_CUSTOM | DI_SUB_FIXED | nReg, aDocProperty,
+ sDisplayed);
+ rIDCO.InsertPoolItem(*m_pPaM, SwFormatField(aFixedField));
+ }
return eF_ResT::OK;
}
@@ -1666,16 +1749,18 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr )
nSub = DI_COMMENT;
break;
case 20:
- nSub = DI_CHANGE;
+ // MS Word never updates this automatically, so mark as fixed for best compatibility
+ nSub = DI_CHANGE | DI_SUB_FIXED;
nReg = DI_SUB_AUTHOR;
break;
case 21:
- nSub = DI_CREATE;
+ // The real create date can never change, so mark as fixed for best compatibility
+ nSub = DI_CREATE | DI_SUB_FIXED;
nReg = DI_SUB_DATE;
bDateTime = true;
break;
case 23:
- nSub = DI_PRINT;
+ nSub = DI_PRINT | nFldLock;
nReg = DI_SUB_DATE;
bDateTime = true;
break;
@@ -1683,12 +1768,12 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr )
nSub = DI_DOCNO;
break;
case 22:
- nSub = DI_CHANGE;
+ nSub = DI_CHANGE | nFldLock;
nReg = DI_SUB_DATE;
bDateTime = true;
break;
case 25:
- nSub = DI_CHANGE;
+ nSub = DI_CHANGE | nFldLock;
nReg = DI_SUB_TIME;
bDateTime = true;
break;
@@ -1746,21 +1831,39 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr )
aData = aData.replaceAll("\"", "");
}
- SwDocInfoField aField( static_cast<SwDocInfoFieldType*>(
- m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::DocInfo )), nSub|nReg, aData, nFormat );
- if (bDateTime)
- ForceFieldLanguage(aField, nLang);
- m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM, SwFormatField(aField));
+ bool bDone = false;
+ if (DI_CUSTOM == nSub)
+ {
+ const auto pType(static_cast<SwUserFieldType*>(
+ m_rDoc.getIDocumentFieldsAccess().GetFieldType(SwFieldIds::User, aData, false)));
+ if (pType)
+ {
+ SwUserField aField(pType, 0, nFormat);
+ if (bDateTime)
+ ForceFieldLanguage(aField, nLang);
+ m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM, SwFormatField(aField));
+ bDone = true;
+ }
+ }
+ if (!bDone)
+ {
+ const auto pType(static_cast<SwDocInfoFieldType*>(
+ m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DocInfo)));
+ SwDocInfoField aField(pType, nSub|nReg, aData, GetFieldResult(pF), nFormat);
+ if (bDateTime)
+ ForceFieldLanguage(aField, nLang);
+ m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM, SwFormatField(aField));
+ }
return eF_ResT::OK;
}
-eF_ResT SwWW8ImplReader::Read_F_Author( WW8FieldDesc*, OUString& )
+eF_ResT SwWW8ImplReader::Read_F_Author(WW8FieldDesc* pF, OUString&)
{
// SH: The SwAuthorField refers not to the original author but to the current user, better use DocInfo
SwDocInfoField aField( static_cast<SwDocInfoFieldType*>(
m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::DocInfo )),
- DI_CREATE|DI_SUB_AUTHOR, OUString() );
+ DI_CREATE|DI_SUB_AUTHOR|DI_SUB_FIXED, OUString(), GetFieldResult(pF));
m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) );
return eF_ResT::OK;
}
@@ -1819,31 +1922,22 @@ eF_ResT SwWW8ImplReader::Read_F_DateTime( WW8FieldDesc*pF, OUString& rStr )
}
}
- sal_uInt16 nDoNotRecalculate = (pF->nOpt & 0x10) ? FIXEDFLD : 0;
- if (nDoNotRecalculate)
- {
- // TODO: Doing this properly would require setting the field to the original date/time.
- // Unfortunately, none of the plumbing to do this exists AFAICS
- //SAL_WARN("DEBUG","Need to aField.SetDateTime() to ["<<GetFieldResult(pF)<<"] based on format string["<<aReadParam.GetResult()<<"]");
- // So instead, just drop the field and insert the plain text.
- // That is at least better than having the current date/time.
- return eF_ResT::TEXT;
- }
- if (nDT & SvNumFormatType::DATE)
+ if (nDT & SvNumFormatType::DATE || nDT == SvNumFormatType::TIME)
{
SwDateTimeField aField(static_cast<SwDateTimeFieldType*>(
m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DateTime)),
- (DATEFLD | nDoNotRecalculate),
- nFormat);
- ForceFieldLanguage(aField, nLang);
- m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) );
- }
- else if (nDT == SvNumFormatType::TIME)
- {
- SwDateTimeField aField(static_cast<SwDateTimeFieldType*>(
- m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DateTime)),
- (TIMEFLD | nDoNotRecalculate),
- nFormat);
+ nDT & SvNumFormatType::DATE ? DATEFLD : TIMEFLD, nFormat);
+ if (pF->nOpt & 0x10) // Fixed field
+ {
+ double fSerial;
+ if (!m_rDoc.GetNumberFormatter()->IsNumberFormat(GetFieldResult(pF), nFormat, fSerial,
+ SvNumInputOptions::LAX_TIME))
+ return eF_ResT::TEXT; // just drop the field and insert the plain text.
+ aField.SetSubType(aField.GetSubType() | FIXEDFLD);
+ DateTime aSetDateTime(m_rDoc.GetNumberFormatter()->GetNullDate());
+ aSetDateTime.AddTime(fSerial);
+ aField.SetDateTime(aSetDateTime);
+ }
ForceFieldLanguage(aField, nLang);
m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) );
}
@@ -2099,12 +2193,12 @@ eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, OUString& rStr )
{
sBkmName = EnsureTOCBookmarkName(sBkmName);
// track <sBookmarkName> as referenced TOC bookmark.
- m_xReffedStck->aReferencedTOCBookmarks.insert( sBkmName );
+ m_xReffedStck->m_aReferencedTOCBookmarks.insert( sBkmName );
}
SwGetRefField aField(
static_cast<SwGetRefFieldType*>(m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::GetRef )),
- sBkmName,"",REF_BOOKMARK,0,eFormat);
+ sBkmName,"",REF_BOOKMARK,0,0,eFormat);
if (eFormat == REF_CONTENT)
{
@@ -2159,14 +2253,14 @@ eF_ResT SwWW8ImplReader::Read_F_NoteReference( WW8FieldDesc*, OUString& rStr )
// set Sequence No of corresponding Foot-/Endnote to Zero
// (will be corrected in
SwGetRefField aField( static_cast<SwGetRefFieldType*>(
- m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::GetRef )), aBkmName, "", REF_FOOTNOTE, 0,
+ m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::GetRef )), aBkmName, "", REF_FOOTNOTE, 0, 0,
REF_ONLYNUMBER );
m_xReffingStck->NewAttr(*m_pPaM->GetPoint(), SwFormatField(aField));
m_xReffingStck->SetAttr(*m_pPaM->GetPoint(), RES_TXTATR_FIELD);
if (bAboveBelow)
{
SwGetRefField aField2( static_cast<SwGetRefFieldType*>(
- m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::GetRef )),aBkmName, "", REF_FOOTNOTE, 0,
+ m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::GetRef )),aBkmName, "", REF_FOOTNOTE, 0, 0,
REF_UPDOWN );
m_xReffingStck->NewAttr(*m_pPaM->GetPoint(), SwFormatField(aField2));
m_xReffingStck->SetAttr(*m_pPaM->GetPoint(), RES_TXTATR_FIELD);
@@ -2207,7 +2301,7 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, OUString& rStr )
{
sBookmarkName = EnsureTOCBookmarkName(sName);
// track <sBookmarkName> as referenced TOC bookmark.
- m_xReffedStck->aReferencedTOCBookmarks.insert( sBookmarkName );
+ m_xReffedStck->m_aReferencedTOCBookmarks.insert( sBookmarkName );
}
else
{
@@ -2215,7 +2309,7 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, OUString& rStr )
}
OUString sURL = "#" + sBookmarkName;
SwFormatINetFormat aURL( sURL, "" );
- static const OUStringLiteral sLinkStyle(u"Index Link");
+ static constexpr OUString sLinkStyle(u"Index Link"_ustr);
const sal_uInt16 nPoolId =
SwStyleNameMapper::GetPoolIdFromUIName( sLinkStyle, SwGetPoolIdFromName::ChrFmt );
aURL.SetVisitedFormatAndId( sLinkStyle, nPoolId);
@@ -2232,14 +2326,14 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, OUString& rStr )
{
sPageRefBookmarkName = EnsureTOCBookmarkName(sName);
// track <sPageRefBookmarkName> as referenced TOC bookmark.
- m_xReffedStck->aReferencedTOCBookmarks.insert( sPageRefBookmarkName );
+ m_xReffedStck->m_aReferencedTOCBookmarks.insert( sPageRefBookmarkName );
}
else
{
sPageRefBookmarkName = sName;
}
SwGetRefField aField( static_cast<SwGetRefFieldType*>(m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::GetRef )),
- sPageRefBookmarkName, "", REF_BOOKMARK, 0, REF_PAGE );
+ sPageRefBookmarkName, "", REF_BOOKMARK, 0, 0, REF_PAGE );
m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) );
return eF_ResT::OK;
@@ -2280,8 +2374,6 @@ eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, OUString& rStr)
bool bBracket = false;
WW8ReadFieldParams aReadParam( rStr );
- sal_Int32 nOffset = 0;
-
for (;;)
{
const sal_Int32 nRet = aReadParam.SkipToNextToken();
@@ -2294,8 +2386,6 @@ eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, OUString& rStr)
aName = aReadParam.GetResult();
else if( aVText.isEmpty() || bBracket )
{
- nOffset = aReadParam.GetTokenSttPtr() + 1;
-
if( bBracket )
aVText += " ";
aVText += aReadParam.GetResult();
@@ -2323,19 +2413,7 @@ eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, OUString& rStr)
m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Macro )), aName, aVText );
if( !bApplyWingdings )
- {
-
m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) );
- WW8_CP nOldCp = m_xPlcxMan->Where();
- WW8_CP nCp = nOldCp + nOffset;
-
- SwPaM aPaM(*m_pPaM, m_pPaM);
- aPaM.SetMark();
- aPaM.Move(fnMoveBackward);
- aPaM.Exchange();
-
- m_pPostProcessAttrsInfo.reset(new WW8PostProcessAttrsInfo(nCp, nCp, aPaM));
- }
else
{
//set Wingdings font
@@ -2366,16 +2444,6 @@ eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, OUString& rStr)
return eF_ResT::OK;
}
-WW8PostProcessAttrsInfo::WW8PostProcessAttrsInfo(WW8_CP nCpStart, WW8_CP nCpEnd,
- SwPaM & rPaM)
- : mbCopy(false)
- , mnCpStart(nCpStart)
- , mnCpEnd(nCpEnd)
- , mPaM(*rPaM.GetMark(), *rPaM.GetPoint())
- , mItemSet(rPaM.GetDoc().GetAttrPool(), svl::Items<RES_CHRATR_BEGIN, RES_PARATR_END - 1>{})
-{
-}
-
bool CanUseRemoteLink(const OUString &rGrfName)
{
bool bUseRemote = false;
@@ -2461,8 +2529,7 @@ eF_ResT SwWW8ImplReader::Read_F_IncludePicture( WW8FieldDesc*, OUString& rStr )
that we have inserted a graphic link and the suiting SwAttrSet will be
inserted into the frame format.
*/
- SfxItemSet aFlySet( m_rDoc.GetAttrPool(), svl::Items<RES_FRMATR_BEGIN,
- RES_FRMATR_END-1>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aFlySet( m_rDoc.GetAttrPool() );
aFlySet.Put( SwFormatAnchor( RndStdIds::FLY_AS_CHAR ) );
aFlySet.Put( SwFormatVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ));
m_pFlyFormatOfJustInsertedGraphic =
@@ -2542,12 +2609,11 @@ eF_ResT SwWW8ImplReader::Read_F_IncludeText( WW8FieldDesc* /*pF*/, OUString& rSt
if (!pSectionNode)
return eF_ResT::TEXT;
- m_pPaM->GetPoint()->nNode = pSectionNode->GetIndex()+1;
- m_pPaM->GetPoint()->nContent.Assign(m_pPaM->GetContentNode(), 0 );
+ m_pPaM->GetPoint()->Assign( pSectionNode->GetIndex()+1 );
//we have inserted a section before this point, so adjust pos
//for future page/section segment insertion
- m_aSectionManager.PrependedInlineNode(aTmpPos, m_pPaM->GetNode());
+ m_aSectionManager.PrependedInlineNode(aTmpPos, m_pPaM->GetPointNode());
return eF_ResT::TEXT;
}
@@ -2555,7 +2621,7 @@ eF_ResT SwWW8ImplReader::Read_F_IncludeText( WW8FieldDesc* /*pF*/, OUString& rSt
// "SERIALPRINT"
eF_ResT SwWW8ImplReader::Read_F_DBField( WW8FieldDesc* pF, OUString& rStr )
{
-#if !HAVE_FEATURE_DBCONNECTIVITY
+#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
(void) pF;
(void) rStr;
#else
@@ -2596,7 +2662,7 @@ eF_ResT SwWW8ImplReader::Read_F_DBField( WW8FieldDesc* pF, OUString& rStr )
// "NEXT"
eF_ResT SwWW8ImplReader::Read_F_DBNext( WW8FieldDesc*, OUString& )
{
-#if HAVE_FEATURE_DBCONNECTIVITY
+#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
SwDBNextSetFieldType aN;
SwFieldType* pFT = m_rDoc.getIDocumentFieldsAccess().InsertFieldType( aN );
SwDBNextSetField aField( static_cast<SwDBNextSetFieldType*>(pFT), OUString(),
@@ -2609,7 +2675,7 @@ eF_ResT SwWW8ImplReader::Read_F_DBNext( WW8FieldDesc*, OUString& )
// "DATASET"
eF_ResT SwWW8ImplReader::Read_F_DBNum( WW8FieldDesc*, OUString& )
{
-#if HAVE_FEATURE_DBCONNECTIVITY
+#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
SwDBSetNumberFieldType aN;
SwFieldType* pFT = m_rDoc.getIDocumentFieldsAccess().InsertFieldType( aN );
SwDBSetNumberField aField( static_cast<SwDBSetNumberFieldType*>(pFT),
@@ -2675,7 +2741,7 @@ void SwWW8ImplReader::Read_SubF_Ruby( WW8ReadFieldParams& rReadParam)
if( sTemp.startsWithIgnoreAsciiCase( "jc" ) )
{
sTemp = sTemp.copy(2);
- nJustificationCode = static_cast<sal_uInt16>(sTemp.toInt32());
+ nJustificationCode = o3tl::narrowing<sal_uInt16>(sTemp.toInt32());
}
else if( sTemp.startsWithIgnoreAsciiCase( "hps" ) )
{
@@ -2772,11 +2838,11 @@ void SwWW8ImplReader::Read_SubF_Ruby( WW8ReadFieldParams& rReadParam)
for(const auto& rpCharFormat : m_aRubyCharFormats)
{
const SvxFontHeightItem &rFH =
- ItemGet<SvxFontHeightItem>(*rpCharFormat,
- GetWhichOfScript(RES_CHRATR_FONTSIZE,nScript));
+ rpCharFormat->GetFormatAttr(
+ GetWhichOfScript(RES_CHRATR_FONTSIZE,nScript));
if (rFH.GetHeight() == nFontSize*10)
{
- const SvxFontItem &rF = ItemGet<SvxFontItem>(*rpCharFormat,
+ const SvxFontItem &rF = rpCharFormat->GetFormatAttr(
GetWhichOfScript(RES_CHRATR_FONT,nScript));
if (rF.GetFamilyName() == sFontName)
{
@@ -2887,13 +2953,13 @@ static void lcl_toxMatchTSwitch(SwWW8ImplReader const & rReader, SwTOXBase& rBas
else while( -1 != nIndex )
{
sal_Int32 nOldIndex=nIndex;
- sal_uInt16 nLevel = static_cast<sal_uInt16>(
- sParams.getToken(0, ';', nIndex).toInt32());
+ sal_uInt16 nLevel = o3tl::narrowing<sal_uInt16>(
+ o3tl::toInt32(o3tl::getToken(sParams, 0, ';', nIndex)));
if( -1 == nIndex )
{
nIndex = nOldIndex;
- nLevel = static_cast<sal_uInt16>(
- sParams.getToken(0, ',', nIndex).toInt32());
+ nLevel = o3tl::narrowing<sal_uInt16>(
+ o3tl::toInt32(o3tl::getToken(sParams, 0, ',', nIndex)));
}
if( (0 < nLevel) && (MAXLEVEL >= nLevel) )
@@ -2933,13 +2999,13 @@ sal_uInt16 wwSectionManager::CurrentSectionColCount() const
//Will there be a new pagebreak at this position (don't know what type
//until later)
-bool wwSectionManager::WillHavePageDescHere(const SwNodeIndex& rIdx) const
+bool wwSectionManager::WillHavePageDescHere(const SwNode& rNd) const
{
bool bRet = false;
if (!maSegments.empty())
{
if (!maSegments.back().IsContinuous() &&
- maSegments.back().maStart == rIdx)
+ maSegments.back().maStart == rNd)
{
bRet = true;
}
@@ -3023,7 +3089,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
// if NO OUString just ignore the \c
if( !sParams.isEmpty() )
{
- nIndexCols = static_cast<sal_uInt16>(sParams.toInt32());
+ nIndexCols = o3tl::narrowing<sal_uInt16>(sParams.toInt32());
}
}
break;
@@ -3070,7 +3136,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
aToken.sText = sDelimiter;
*aIt = aToken;
}
- aForm.SetPattern(nLevel, aPattern);
+ aForm.SetPattern(nLevel, std::move(aPattern));
}
eType = TOKEN_END;
@@ -3192,7 +3258,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
*aIt = aToken;
aForm.SetPattern(nLevel,
- aPattern);
+ std::move(aPattern));
}
eType = TOKEN_END;
}
@@ -3244,7 +3310,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
)
{
aPattern.erase(aIt);
- aForm.SetPattern(nLevel, aPattern);
+ aForm.SetPattern(nLevel, std::move(aPattern));
}
eType = TOKEN_END;
}
@@ -3291,7 +3357,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
aPattern.insert(aItr, aLinkStart);
}
aPattern.push_back(aLinkEnd);
- aForm.SetPattern(nLevel, aPattern);
+ aForm.SetPattern(nLevel, std::move(aPattern));
}
pBase->SetTOXForm(aForm);
@@ -3337,7 +3403,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
SwFormToken aNumberEntrySeparator( TOKEN_TEXT );
aNumberEntrySeparator.sText = " ";
aPattern.insert( ++aIt, aNumberEntrySeparator );
- pForm->SetPattern( nStyleLevel, aPattern );
+ pForm->SetPattern( nStyleLevel, std::move(aPattern) );
}
}
}
@@ -3379,7 +3445,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
SwFormTokens::iterator new_end =
remove_if(aPattern.begin(), aPattern.end(), SwFormTokenEqualToFormTokenType(TOKEN_ENTRY_NO));
aPattern.erase(new_end, aPattern.end() ); // table index imported with wrong page number format
- aForm.SetPattern( nLevel, aPattern );
+ aForm.SetPattern( nLevel, std::move(aPattern) );
aForm.SetTemplate( nLevel, aOldForm.GetTemplate(nLevel) );
}
@@ -3404,21 +3470,21 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
//#i10028# inserting a toc implicitly acts like a parabreak in word and writer
if ( m_pPaM->End() &&
- m_pPaM->End()->nNode.GetNode().GetTextNode() &&
- m_pPaM->End()->nNode.GetNode().GetTextNode()->Len() != 0 )
+ m_pPaM->End()->GetNode().GetTextNode() &&
+ m_pPaM->End()->GetNode().GetTextNode()->Len() != 0 )
{
m_bCareFirstParaEndInToc = true;
}
- if (m_pPaM->GetPoint()->nContent.GetIndex())
- AppendTextNode(*m_pPaM->GetPoint());
+ if (m_pPaM->GetPoint()->GetContentIndex())
+ FinalizeTextNode(*m_pPaM->GetPoint());
const SwPosition* pPos = m_pPaM->GetPoint();
SwFltTOX aFltTOX( pBase );
// test if there is already a break item on this node
- if(SwContentNode* pNd = pPos->nNode.GetNode().GetContentNode())
+ if(SwContentNode* pNd = pPos->GetNode().GetContentNode())
{
const SfxItemSet* pSet = pNd->GetpSwAttrSet();
if( pSet )
@@ -3432,7 +3498,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
//Will there be a new pagebreak at this position (don't know what type
//until later)
- if (m_aSectionManager.WillHavePageDescHere(pPos->nNode))
+ if (m_aSectionManager.WillHavePageDescHere(pPos->GetNode()))
aFltTOX.SetHadPageDescItem(true);
// Set start in stack
@@ -3442,7 +3508,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
//The TOC field representation contents should be inserted into TOC section, but not after TOC section.
//So we need update the document position when loading TOC representation and after loading TOC;
- m_pPosAfterTOC.reset(new SwPaM(*m_pPaM, m_pPaM));
+ m_oPosAfterTOC.emplace(*m_pPaM, m_pPaM);
(*m_pPaM).Move(fnMoveBackward);
SwPaM aRegion(*m_pPaM, m_pPaM);
@@ -3454,7 +3520,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
if ( nIndexCols > 1 )
{
// Set the column number for index
- SfxItemSet aSet( m_rDoc.GetAttrPool(), svl::Items<RES_COL, RES_COL>{} );
+ SfxItemSetFixed<RES_COL, RES_COL> aSet( m_rDoc.GetAttrPool() );
SwFormatCol aCol;
aCol.Init( nIndexCols, 708, USHRT_MAX );
aSet.Put( aCol );
@@ -3463,7 +3529,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
// inserting a toc inserts a section before this point, so adjust pos
// for future page/section segment insertion
- m_aSectionManager.PrependedInlineNode( *m_pPosAfterTOC->GetPoint(), aRegion.GetNode() );
+ m_aSectionManager.PrependedInlineNode( *m_oPosAfterTOC->GetPoint(), aRegion.GetPointNode() );
}
// Set end in stack
@@ -3528,7 +3594,7 @@ eF_ResT SwWW8ImplReader::Read_F_Hyperlink( WW8FieldDesc* /*pF*/, OUString& rStr
{
sMark = EnsureTOCBookmarkName(sMark);
// track <sMark> as referenced TOC bookmark.
- m_xReffedStck->aReferencedTOCBookmarks.insert( sMark );
+ m_xReffedStck->m_aReferencedTOCBookmarks.insert( sMark );
}
if (m_bLoadingTOXCache)
@@ -3616,7 +3682,7 @@ static void lcl_ImportTox(SwDoc &rDoc, SwPaM const &rPaM, const OUString &rStr,
// if NO String just ignore the \l
if( !sParams.isEmpty() && sParams[0]>'0' && sParams[0]<='9' )
{
- nLevel = static_cast<sal_uInt16>(sParams.toInt32());
+ nLevel = o3tl::narrowing<sal_uInt16>(sParams.toInt32());
}
}
break;
@@ -3684,7 +3750,7 @@ void SwWW8ImplReader::Read_FieldVanish( sal_uInt16, const sal_uInt8*, short nLen
return;
m_bIgnoreText = true;
- tools::Long nOldPos = m_pStrm->Tell();
+ sal_uInt64 nOldPos = m_pStrm->Tell();
WW8_CP nStartCp = m_xPlcxMan->Where() + m_xPlcxMan->GetCpOfs();
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 16572f2905cb..bc89199c4904 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -68,6 +68,7 @@
#include <i18nlangtag/mslangid.hxx>
#include <svx/xfillit0.hxx>
#include <svx/xflclit.hxx>
+#include <officecfg/Office/Writer.hxx>
#include "sortedarray.hxx"
#include "sprmids.hxx"
#include <node.hxx>
@@ -99,6 +100,7 @@
#include "ww8graf.hxx"
#include <fmtwrapinfluenceonobjpos.hxx>
+#include <formatflysplit.hxx>
using namespace sw::util;
using namespace sw::types;
@@ -219,12 +221,12 @@ void SwWW8ImplReader::SetDocumentGrid(SwFrameFormat &rFormat, const wwSection &r
rFormat.SetFormatAttr(SvxFrameDirectionItem(rSection.meDir, RES_FRAMEDIR));
SwTwips nTextareaHeight = rFormat.GetFrameSize().GetHeight();
- const SvxULSpaceItem &rUL = ItemGet<SvxULSpaceItem>(rFormat, RES_UL_SPACE);
+ const SvxULSpaceItem &rUL = rFormat.GetFormatAttr(RES_UL_SPACE);
nTextareaHeight -= rUL.GetUpper();
nTextareaHeight -= rUL.GetLower();
SwTwips nTextareaWidth = rFormat.GetFrameSize().GetWidth();
- const SvxLRSpaceItem &rLR = ItemGet<SvxLRSpaceItem>(rFormat, RES_LR_SPACE);
+ const SvxLRSpaceItem &rLR = rFormat.GetFormatAttr(RES_LR_SPACE);
nTextareaWidth -= rLR.GetLeft();
nTextareaWidth -= rLR.GetRight();
@@ -261,6 +263,7 @@ void SwWW8ImplReader::SetDocumentGrid(SwFrameFormat &rFormat, const wwSection &r
// seem to not add external leading in word, or the character would run across
// two line in some cases.
+ // TODO: tdf#85435 suggests that this is wrong
if (eType != GRID_NONE)
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::ADD_EXT_LEADING, false);
@@ -276,8 +279,9 @@ void SwWW8ImplReader::SetDocumentGrid(SwFrameFormat &rFormat, const wwSection &r
if (m_vColl[nI].m_bValid && m_vColl[nI].m_pFormat &&
m_vColl[nI].IsWW8BuiltInDefaultStyle())
{
- nCharWidth = ItemGet<SvxFontHeightItem>(*(m_vColl[nI].m_pFormat),
- RES_CHRATR_CJK_FONTSIZE).GetHeight();
+ const SvxFontHeightItem& rFontHeightItem =
+ m_vColl[nI].m_pFormat->GetFormatAttr(RES_CHRATR_CJK_FONTSIZE);
+ nCharWidth = rFontHeightItem.GetHeight();
break;
}
}
@@ -392,7 +396,7 @@ void SwWW8ImplReader::Read_ParaBiDi(sal_uInt16, const sal_uInt8* pData, short nL
if ( bBiDiSwap )
{
- const SvxAdjustItem* pItem = static_cast<const SvxAdjustItem*>(GetFormatAttr(RES_PARATR_ADJUST));
+ const SvxAdjustItem* pItem = GetFormatAttr(RES_PARATR_ADJUST);
if ( !pItem )
{
// no previous adjust: set appropriate default
@@ -490,7 +494,7 @@ void wwSectionManager::SetLeftRight(wwSection &rSection)
}
// Left / Right
- if ((rSection.nPgWidth - nWWLe - nWWRi) < MINLAY)
+ if ((rSection.m_nPgWidth - nWWLe - nWWRi) < MINLAY)
{
/*
There are some label templates which are "broken", they specify
@@ -505,12 +509,12 @@ void wwSectionManager::SetLeftRight(wwSection &rSection)
it will add up the values to give a wider page than is actually being
used.
*/
- nWWRi = rSection.nPgWidth - nWWLe - MINLAY;
+ nWWRi = rSection.m_nPgWidth - nWWLe - MINLAY;
}
- rSection.nPgLeft = nWWLe;
- rSection.nPgRight = nWWRi;
- rSection.nPgGutter = nWWGu;
+ rSection.m_nPgLeft = nWWLe;
+ rSection.m_nPgRight = nWWRi;
+ rSection.m_nPgGutter = nWWGu;
}
void wwSectionManager::SetPage(SwPageDesc &rInPageDesc, SwFrameFormat &rFormat,
@@ -525,8 +529,8 @@ void wwSectionManager::SetPage(SwPageDesc &rInPageDesc, SwFrameFormat &rFormat,
aSz.SetHeight(SvxPaperInfo::GetSloppyPaperDimension(rSection.GetPageHeight()));
rFormat.SetFormatAttr(aSz);
- SvxLRSpaceItem aLR(rSection.GetPageLeft(), rSection.GetPageRight(), 0, 0, RES_LR_SPACE);
- aLR.SetGutterMargin(rSection.nPgGutter);
+ SvxLRSpaceItem aLR(rSection.GetPageLeft(), rSection.GetPageRight(), 0, RES_LR_SPACE);
+ aLR.SetGutterMargin(rSection.m_nPgGutter);
rFormat.SetFormatAttr(aLR);
SfxBoolItem aRtlGutter(RES_RTL_GUTTER, rSection.m_bRtlGutter);
@@ -556,15 +560,15 @@ tools::Long SetBorderDistance(bool bFromEdge, SvxBoxItem& aBox, SvxBoxItemLine e
void SwWW8ImplReader::SetPageBorder(SwFrameFormat &rFormat, const wwSection &rSection)
{
- if (!IsBorder(rSection.brc))
+ if (!IsBorder(rSection.m_brc))
return;
SfxItemSet aSet(rFormat.GetAttrSet());
short aSizeArray[5]={0};
- SetFlyBordersShadow(aSet, rSection.brc, &aSizeArray[0]);
- SvxLRSpaceItem aLR(ItemGet<SvxLRSpaceItem>(aSet, RES_LR_SPACE));
- SvxULSpaceItem aUL(ItemGet<SvxULSpaceItem>(aSet, RES_UL_SPACE));
- SvxBoxItem aBox(ItemGet<SvxBoxItem>(aSet, RES_BOX));
+ SetFlyBordersShadow(aSet, rSection.m_brc, &aSizeArray[0]);
+ SvxLRSpaceItem aLR(aSet.Get(RES_LR_SPACE));
+ SvxULSpaceItem aUL(aSet.Get(RES_UL_SPACE));
+ SvxBoxItem aBox(aSet.Get(RES_BOX));
bool bFromEdge = rSection.maSep.pgbOffsetFrom == 1;
aLR.SetLeft(SetBorderDistance(bFromEdge, aBox, SvxBoxItemLine::LEFT, aLR.GetLeft()));
@@ -763,7 +767,7 @@ SwSectionFormat *wwSectionManager::InsertSection(
tools::Long nSectionRight = rSection.GetPageRight() - nPageRight;
if ((nSectionLeft != 0) || (nSectionRight != 0))
{
- SvxLRSpaceItem aLR(nSectionLeft, nSectionRight, 0, 0, RES_LR_SPACE);
+ SvxLRSpaceItem aLR(nSectionLeft, nSectionRight, 0, RES_LR_SPACE);
pFormat->SetFormatAttr(aLR);
}
@@ -809,8 +813,7 @@ void SwWW8ImplReader::HandleLineNumbering(const wwSection &rSection)
if ((0 < rSection.maSep.lnnMin) || bRestartLnNumPerSection)
{
SwFormatLineNumber aLN;
- if (const SwFormatLineNumber* pLN
- = static_cast<const SwFormatLineNumber*>(GetFormatAttr(RES_LINENUMBER)))
+ if (const SwFormatLineNumber* pLN = GetFormatAttr(RES_LINENUMBER))
{
aLN.SetCountLines( pLN->IsCount() );
}
@@ -820,14 +823,14 @@ void SwWW8ImplReader::HandleLineNumbering(const wwSection &rSection)
}
}
-wwSection::wwSection(const SwPosition &rPos) : maStart(rPos.nNode)
+wwSection::wwSection(const SwPosition &rPos) : maStart(rPos.GetNode())
, mpSection(nullptr)
, mpPage(nullptr)
, meDir(SvxFrameDirection::Horizontal_LR_TB)
- , nPgWidth(SvxPaperInfo::GetPaperSize(PAPER_A4).Width())
- , nPgLeft(MM_250)
- , nPgRight(MM_250)
- , nPgGutter(0)
+ , m_nPgWidth(SvxPaperInfo::GetPaperSize(PAPER_A4).Width())
+ , m_nPgLeft(MM_250)
+ , m_nPgRight(MM_250)
+ , m_nPgGutter(0)
, mnVerticalAdjustment(drawing::TextVerticalAdjust_TOP)
, mnBorders(0)
, mbHasFootnote(false)
@@ -869,16 +872,16 @@ void wwSectionManager::CreateSep(const tools::Long nTextPos)
if (!pSep)
return;
- if (!maSegments.empty() && mrReader.m_pLastAnchorPos && *mrReader.m_pLastAnchorPos == *mrReader.m_pPaM->GetPoint())
+ if (!maSegments.empty() && mrReader.m_oLastAnchorPos && *mrReader.m_oLastAnchorPos == *mrReader.m_pPaM->GetPoint())
{
bool insert = true;
- SwPaM pam( *mrReader.m_pLastAnchorPos );
+ SwPaM pam( *mrReader.m_oLastAnchorPos );
if( pam.Move(fnMoveBackward, GoInNode))
- if( SwTextNode* txtNode = pam.GetPoint()->nNode.GetNode().GetTextNode())
+ if( SwTextNode* txtNode = pam.GetPoint()->GetNode().GetTextNode())
if( txtNode->Len() == 0 )
insert = false;
if( insert )
- mrReader.AppendTextNode(*mrReader.m_pPaM->GetPoint());
+ mrReader.FinalizeTextNode(*mrReader.m_pPaM->GetPoint());
}
ww::WordVersion eVer = mrReader.GetFib().GetFIBVersion();
@@ -1079,7 +1082,7 @@ void wwSectionManager::CreateSep(const tools::Long nTextPos)
// 2. paper size
aNewSection.maSep.xaPage = ReadUSprm(pSep, pIds[1], lLetterWidth);
- aNewSection.nPgWidth = SvxPaperInfo::GetSloppyPaperDimension(aNewSection.maSep.xaPage);
+ aNewSection.m_nPgWidth = SvxPaperInfo::GetSloppyPaperDimension(aNewSection.maSep.xaPage);
aNewSection.maSep.yaPage = ReadUSprm(pSep, pIds[2], lLetterHeight);
@@ -1197,7 +1200,7 @@ void wwSectionManager::CreateSep(const tools::Long nTextPos)
aNewSection.maSep.pgbPageDepth = (pgbProp & 0x0018) >> 3;
aNewSection.maSep.pgbOffsetFrom = (pgbProp & 0x00E0) >> 5;
- aNewSection.mnBorders = ::lcl_ReadBorders(false, aNewSection.brc, nullptr, nullptr, pSep);
+ aNewSection.mnBorders = ::lcl_ReadBorders(false, aNewSection.m_brc, nullptr, nullptr, pSep);
}
// check if Line Numbering must be activated or reset
@@ -1637,14 +1640,14 @@ void WW8FlyPara::ApplyTabPos(const WW8_TablePos *pTabPos)
{
if (pTabPos)
{
- nSp26 = pTabPos->nSp26;
- nSp27 = pTabPos->nSp27;
- nSp29 = pTabPos->nSp29;
- nLeMgn = pTabPos->nLeMgn;
- nRiMgn = pTabPos->nRiMgn;
- nUpMgn = pTabPos->nUpMgn;
- nLoMgn = pTabPos->nLoMgn;
- nSp37 = pTabPos->nSp37;
+ nTDxaAbs = pTabPos->nTDxaAbs;
+ nTDyaAbs = pTabPos->nTDyaAbs;
+ nTPc = pTabPos->nTPc;
+ nLeftMargin = pTabPos->nLeftMargin;
+ nRightMargin = pTabPos->nRightMargin;
+ nUpperMargin = pTabPos->nUpperMargin;
+ nLowerMargin = pTabPos->nLowerMargin;
+ nPWr = pTabPos->nPWr;
}
}
@@ -1654,16 +1657,16 @@ WW8FlyPara::WW8FlyPara(bool bIsVer67, const WW8FlyPara* pSrc /* = 0 */)
memcpy( this, pSrc, sizeof( WW8FlyPara ) ); // Copy-Ctor
else
{
- nSp26 = 0;
- nSp27 = 0;
+ nTDxaAbs = 0;
+ nTDyaAbs = 0;
nSp45 = 0;
nSp28 = 0;
- nLeMgn = 0;
- nRiMgn = 0;
- nUpMgn = 0;
- nLoMgn = 0;
- nSp29 = 0;
- nSp37 = 2; // Default: wrapping
+ nLeftMargin = 0;
+ nRightMargin = 0;
+ nUpperMargin = 0;
+ nLowerMargin = 0;
+ nTPc = 0;
+ nPWr = 2; // Default: wrapping
bBorderLines = false;
bGrafApo = false;
mbVertSet = false;
@@ -1680,53 +1683,53 @@ bool WW8FlyPara::operator==(const WW8FlyPara& rSrc) const
*/
return
(
- (nSp26 == rSrc.nSp26) &&
- (nSp27 == rSrc.nSp27) &&
+ (nTDxaAbs == rSrc.nTDxaAbs) &&
+ (nTDyaAbs == rSrc.nTDyaAbs) &&
((nSp45 & 0x7fff) == (rSrc.nSp45 & 0x7fff)) &&
(nSp28 == rSrc.nSp28) &&
- (nLeMgn == rSrc.nLeMgn) &&
- (nRiMgn == rSrc.nRiMgn) &&
- (nUpMgn == rSrc.nUpMgn) &&
- (nLoMgn == rSrc.nLoMgn) &&
- (nSp29 == rSrc.nSp29) &&
- (nSp37 == rSrc.nSp37)
+ (nLeftMargin == rSrc.nLeftMargin) &&
+ (nRightMargin == rSrc.nRightMargin) &&
+ (nUpperMargin == rSrc.nUpperMargin) &&
+ (nLowerMargin == rSrc.nLowerMargin) &&
+ (nTPc == rSrc.nTPc) &&
+ (nPWr == rSrc.nPWr)
);
}
// Read for normal text
-void WW8FlyPara::Read(sal_uInt8 nOrigSp29, WW8PLCFx_Cp_FKP* pPap)
+void WW8FlyPara::Read(sal_uInt8 nOrigSprmTPc, WW8PLCFx_Cp_FKP* pPap)
{
if( bVer67 )
{
- SetValSprm( &nSp26, pPap, 26 ); // X-position //sprmPDxaAbs
+ SetValSprm( &nTDxaAbs, pPap, 26 ); // X-position //sprmPDxaAbs
//set in me or in parent style
- mbVertSet |= SetValSprm( &nSp27, pPap, 27 ); // Y-position //sprmPDyaAbs
+ mbVertSet |= SetValSprm( &nTDyaAbs, pPap, 27 ); // Y-position //sprmPDyaAbs
SetValSprm( &nSp45, pPap, 45 ); // height //sprmPWHeightAbs
SetValSprm( &nSp28, pPap, 28 ); // width //sprmPDxaWidth
- SetValSprm( &nLeMgn, pPap, 49 ); // L-border //sprmPDxaFromText
- SetValSprm( &nRiMgn, pPap, 49 ); // R-border //sprmPDxaFromText
- SetValSprm( &nUpMgn, pPap, 48 ); // U-border //sprmPDyaFromText
- SetValSprm( &nLoMgn, pPap, 48 ); // D-border //sprmPDyaFromText
+ SetValSprm( &nLeftMargin, pPap, 49 ); // L-border //sprmPDxaFromText
+ SetValSprm( &nRightMargin, pPap, 49 ); // R-border //sprmPDxaFromText
+ SetValSprm( &nUpperMargin, pPap, 48 ); // U-border //sprmPDyaFromText
+ SetValSprm( &nLowerMargin, pPap, 48 ); // D-border //sprmPDyaFromText
SprmResult aS = pPap->HasSprm(NS_sprm::v6::sprmPWr);
if (aS.pSprm && aS.nRemainingData >= 1)
- nSp37 = *aS.pSprm;
+ nPWr = *aS.pSprm;
}
else
{
- SetValSprm( &nSp26, pPap, NS_sprm::PDxaAbs::val ); // X-position
+ SetValSprm( &nTDxaAbs, pPap, NS_sprm::PDxaAbs::val ); // X-position
//set in me or in parent style
- mbVertSet |= SetValSprm( &nSp27, pPap, NS_sprm::PDyaAbs::val ); // Y-position
+ mbVertSet |= SetValSprm( &nTDyaAbs, pPap, NS_sprm::PDyaAbs::val ); // Y-position
SetValSprm( &nSp45, pPap, NS_sprm::PWHeightAbs::val ); // height
SetValSprm( &nSp28, pPap, NS_sprm::PDxaWidth::val ); // width
- SetValSprm( &nLeMgn, pPap, NS_sprm::PDxaFromText::val ); // L-border
- SetValSprm( &nRiMgn, pPap, NS_sprm::PDxaFromText::val ); // R-border
- SetValSprm( &nUpMgn, pPap, NS_sprm::PDyaFromText::val ); // U-border
- SetValSprm( &nLoMgn, pPap, NS_sprm::PDyaFromText::val ); // D-border
+ SetValSprm( &nLeftMargin, pPap, NS_sprm::PDxaFromText::val ); // L-border
+ SetValSprm( &nRightMargin, pPap, NS_sprm::PDxaFromText::val ); // R-border
+ SetValSprm( &nUpperMargin, pPap, NS_sprm::PDyaFromText::val ); // U-border
+ SetValSprm( &nLowerMargin, pPap, NS_sprm::PDyaFromText::val ); // D-border
SprmResult aS = pPap->HasSprm(NS_sprm::PWr::val); // wrapping
if (aS.pSprm && aS.nRemainingData >= 1)
- nSp37 = *aS.pSprm;
+ nPWr = *aS.pSprm;
}
if( ::lcl_ReadBorders( bVer67, brc, pPap )) // borders
@@ -1740,17 +1743,17 @@ void WW8FlyPara::Read(sal_uInt8 nOrigSp29, WW8PLCFx_Cp_FKP* pPap)
anchoring
*/
if (!mbVertSet)
- nSp29 = (nOrigSp29 & 0xCF) | 0x20;
+ nTPc = (nOrigSprmTPc & 0xCF) | 0x20;
else
- nSp29 = nOrigSp29;
+ nTPc = nOrigSprmTPc;
}
-void WW8FlyPara::ReadFull(sal_uInt8 nOrigSp29, SwWW8ImplReader* pIo)
+void WW8FlyPara::ReadFull(sal_uInt8 nOrigSprmTPc, SwWW8ImplReader* pIo)
{
std::shared_ptr<WW8PLCFMan> xPlcxMan = pIo->m_xPlcxMan;
WW8PLCFx_Cp_FKP* pPap = xPlcxMan->GetPapPLCF();
- Read(nOrigSp29, pPap); // read Apo parameter
+ Read(nOrigSprmTPc, pPap); // read Apo parameter
do{ // block for quick exit
if( nSp45 != 0 /* || nSp28 != 0 */ )
@@ -1759,7 +1762,7 @@ void WW8FlyPara::ReadFull(sal_uInt8 nOrigSp29, SwWW8ImplReader* pIo)
break; // (*pPap)++ does not work for FastSave
// -> for FastSave, no test for graphics APO
SvStream* pIoStrm = pIo->m_pStrm;
- sal_uLong nPos = pIoStrm->Tell();
+ sal_uInt64 nPos = pIoStrm->Tell();
WW8PLCFxSave1 aSave;
xPlcxMan->GetPap()->Save( aSave );
bGrafApo = false;
@@ -1789,11 +1792,22 @@ void WW8FlyPara::ReadFull(sal_uInt8 nOrigSp29, SwWW8ImplReader* pIo)
ww::WordVersion eVer = pIo->GetFib().GetFIBVersion();
WW8FlyPara *pNowStyleApo=nullptr;
sal_uInt16 nColl = pPap->GetIstd();
- ww::sti eSti = eVer < ww::eWW6 ? ww::GetCanonicalStiFromStc( static_cast< sal_uInt8 >(nColl) ) : static_cast<ww::sti>(nColl);
- while (eSti != ww::stiNil && sal::static_int_cast<size_t>(nColl) < pIo->m_vColl.size() && nullptr == (pNowStyleApo = pIo->m_vColl[nColl].m_xWWFly.get()))
+
+ o3tl::sorted_vector<sal_uInt16> aSeenStyles;
+ ww::sti eSti = eVer < ww::eWW6 ? ww::GetCanonicalStiFromStc(nColl) : static_cast<ww::sti>(nColl);
+ while (eSti != ww::stiNil && static_cast<size_t>(nColl) < pIo->m_vColl.size() && nullptr == (pNowStyleApo = pIo->m_vColl[nColl].m_xWWFly.get()))
{
+ aSeenStyles.insert(nColl);
+
nColl = pIo->m_vColl[nColl].m_nBase;
- eSti = eVer < ww::eWW6 ? ww::GetCanonicalStiFromStc( static_cast< sal_uInt8 >(nColl) ) : static_cast<ww::sti>(nColl);
+
+ if (aSeenStyles.find(nColl) != aSeenStyles.end())
+ {
+ SAL_WARN("sw.ww8", "loop in style chain");
+ break;
+ }
+
+ eSti = eVer < ww::eWW6 ? ww::GetCanonicalStiFromStc(nColl) : static_cast<ww::sti>(nColl);
}
WW8FlyPara aF(bVer67, pNowStyleApo);
@@ -1811,39 +1825,39 @@ void WW8FlyPara::ReadFull(sal_uInt8 nOrigSp29, SwWW8ImplReader* pIo)
}
// read for Apo definitions in Styledefs
-void WW8FlyPara::Read(sal_uInt8 nOrigSp29, WW8RStyle const * pStyle)
+void WW8FlyPara::Read(sal_uInt8 nOrigSprmTPc, WW8RStyle const * pStyle)
{
if (bVer67)
{
- SetValSprm( &nSp26, pStyle, NS_sprm::v6::sprmPDxaAbs ); // X-position
+ SetValSprm( &nTDxaAbs, pStyle, NS_sprm::v6::sprmPDxaAbs ); // X-position
//set in me or in parent style
- mbVertSet |= SetValSprm(&nSp27, pStyle, NS_sprm::v6::sprmPDyaAbs); // Y-position
+ mbVertSet |= SetValSprm(&nTDyaAbs, pStyle, NS_sprm::v6::sprmPDyaAbs); // Y-position
SetValSprm( &nSp45, pStyle, NS_sprm::v6::sprmPWHeightAbs ); // height
SetValSprm( &nSp28, pStyle, NS_sprm::v6::sprmPDxaWidth ); // width
- SetValSprm( &nLeMgn, pStyle, NS_sprm::v6::sprmPDxaFromText ); // L-border
- SetValSprm( &nRiMgn, pStyle, NS_sprm::v6::sprmPDxaFromText ); // R-border
- SetValSprm( &nUpMgn, pStyle, NS_sprm::v6::sprmPDyaFromText ); // U-border
- SetValSprm( &nLoMgn, pStyle, NS_sprm::v6::sprmPDyaFromText ); // D-border
+ SetValSprm( &nLeftMargin, pStyle, NS_sprm::v6::sprmPDxaFromText ); // L-border
+ SetValSprm( &nRightMargin, pStyle, NS_sprm::v6::sprmPDxaFromText ); // R-border
+ SetValSprm( &nUpperMargin, pStyle, NS_sprm::v6::sprmPDyaFromText ); // U-border
+ SetValSprm( &nLowerMargin, pStyle, NS_sprm::v6::sprmPDyaFromText ); // D-border
SprmResult aS = pStyle->HasParaSprm( NS_sprm::v6::sprmPWr ); // wrapping
if (aS.pSprm && aS.nRemainingData >= 1)
- nSp37 = *aS.pSprm;
+ nPWr = *aS.pSprm;
}
else
{
- SetValSprm( &nSp26, pStyle, NS_sprm::PDxaAbs::val ); // X-position
+ SetValSprm( &nTDxaAbs, pStyle, NS_sprm::PDxaAbs::val ); // X-position
//set in me or in parent style
- mbVertSet |= SetValSprm(&nSp27, pStyle, NS_sprm::PDyaAbs::val); // Y-position
+ mbVertSet |= SetValSprm(&nTDyaAbs, pStyle, NS_sprm::PDyaAbs::val); // Y-position
SetValSprm( &nSp45, pStyle, NS_sprm::PWHeightAbs::val ); // height
SetValSprm( &nSp28, pStyle, NS_sprm::PDxaWidth::val ); // width
- SetValSprm( &nLeMgn, pStyle, NS_sprm::PDxaFromText::val ); // L-border
- SetValSprm( &nRiMgn, pStyle, NS_sprm::PDxaFromText::val ); // R-border
- SetValSprm( &nUpMgn, pStyle, NS_sprm::PDyaFromText::val ); // U-border
- SetValSprm( &nLoMgn, pStyle, NS_sprm::PDyaFromText::val ); // D-border
+ SetValSprm( &nLeftMargin, pStyle, NS_sprm::PDxaFromText::val ); // L-border
+ SetValSprm( &nRightMargin, pStyle, NS_sprm::PDxaFromText::val ); // R-border
+ SetValSprm( &nUpperMargin, pStyle, NS_sprm::PDyaFromText::val ); // U-border
+ SetValSprm( &nLowerMargin, pStyle, NS_sprm::PDyaFromText::val ); // D-border
SprmResult aS = pStyle->HasParaSprm( NS_sprm::PWr::val ); // wrapping
if (aS.pSprm && aS.nRemainingData >= 1)
- nSp37 = *aS.pSprm;
+ nPWr = *aS.pSprm;
}
if (::lcl_ReadBorders(bVer67, brc, nullptr, pStyle)) // border
@@ -1857,9 +1871,9 @@ void WW8FlyPara::Read(sal_uInt8 nOrigSp29, WW8RStyle const * pStyle)
anchoring
*/
if (!mbVertSet)
- nSp29 = (nOrigSp29 & 0xCF) | 0x20;
+ nTPc = (nOrigSprmTPc & 0xCF) | 0x20;
else
- nSp29 = nOrigSp29;
+ nTPc = nOrigSprmTPc;
}
bool WW8FlyPara::IsEmpty() const
@@ -1870,9 +1884,9 @@ bool WW8FlyPara::IsEmpty() const
#107103# if wrong, so given that the empty is 2, if we are 0 then set
empty to 0 to make 0 equiv to 2 for empty checking
*/
- OSL_ENSURE(aEmpty.nSp37 == 2, "this is not what we expect for nSp37");
- if (this->nSp37 == 0)
- aEmpty.nSp37 = 0;
+ OSL_ENSURE(aEmpty.nPWr == 2, "this is not what we expect for nPWr");
+ if (this->nPWr == 0)
+ aEmpty.nPWr = 0;
return aEmpty == *this;
}
@@ -1884,13 +1898,12 @@ WW8SwFlyPara::WW8SwFlyPara( SwPaM& rPaM,
const sal_uInt32 nPgWidth,
const sal_Int32 nIniFlyDx,
const sal_Int32 nIniFlyDy ):
-pFlyFormat(nullptr),
nXPos(0),
nYPos(0),
-nLeMgn(rWW.nLeMgn),
-nRiMgn(rWW.nRiMgn),
-nUpMgn(rWW.nUpMgn),
-nLoMgn(rWW.nLoMgn),
+nLeftMargin(rWW.nLeftMargin),
+nRightMargin(rWW.nRightMargin),
+nUpperMargin(rWW.nUpperMargin),
+nLowerMargin(rWW.nLowerMargin),
nWidth(rWW.nSp28),
nHeight(rWW.nSp45),
nNetWidth(rWW.nSp28),
@@ -1899,18 +1912,32 @@ eHRel(text::RelOrientation::PAGE_FRAME),
eVRel(text::RelOrientation::FRAME),
eVAlign(text::VertOrientation::NONE),
eHAlign(text::HoriOrientation::NONE),
-eSurround(( rWW.nSp37 > 1 ) ? css::text::WrapTextMode_DYNAMIC : css::text::WrapTextMode_NONE),
-nXBind(( rWW.nSp29 & 0xc0 ) >> 6),
-nYBind(( rWW.nSp29 & 0x30 ) >> 4),
+nXBind(( rWW.nTPc & 0xc0 ) >> 6),
+nYBind(( rWW.nTPc & 0x30 ) >> 4),
nNewNetWidth(MINFLY),
nLineSpace(0),
bAutoWidth(false),
bTogglePos(false)
{
- //#i119466 mapping "Around" wrap setting to "Parallel" for table
- const bool bIsTable = rIo.m_xPlcxMan->HasParaSprm(NS_sprm::PFInTable::val).pSprm;
- if (bIsTable && rWW.nSp37 == 2)
- eSurround = css::text::WrapTextMode_PARALLEL;
+ switch(rWW.nPWr)
+ {
+ case 0: // ST_Wrap: auto
+ eSurround = css::text::WrapTextMode_DYNAMIC;
+ break;
+ case 1: // ST_Wrap: notBeside
+ case 3: // ST_Wrap: none
+ eSurround = css::text::WrapTextMode_NONE;
+ break;
+ case 2: // ST_Wrap: around
+ case 4: // ST_Wrap: tight
+ eSurround = css::text::WrapTextMode_PARALLEL;
+ break;
+ case 5: // St_Wrap: through
+ eSurround = css::text::WrapTextMode_THROUGH;
+ break;
+ default:
+ eSurround = css::text::WrapTextMode_DYNAMIC;
+ }
/*
#95905#, #83307# seems to have gone away now, so re-enable parallel
@@ -1951,7 +1978,7 @@ bTogglePos(false)
//#i53725# - absolute positioned objects have to be
// anchored at-paragraph to assure its correct anchor position.
- rIo.m_pLastAnchorPos.reset( new SwPosition(*rPaM.GetPoint()));
+ rIo.m_oLastAnchorPos.emplace(*rPaM.GetPoint());
switch (nYBind)
{
@@ -1967,12 +1994,17 @@ bTogglePos(false)
}
// #i18732#
- switch( rWW.nSp27 ) // particular Y-positions ?
+ switch( rWW.nTDyaAbs ) // particular Y-positions ?
{
+ case 0: // inline
+ // Specifies that the parent object shall be vertically aligned in line
+ // with the surrounding text (i.e. shall not allow any text wrapping around it)
+ eVRel = text::RelOrientation::FRAME;
+ break;
case -4:
eVAlign = text::VertOrientation::TOP;
if (nYBind < 2)
- nUpMgn = 0;
+ nUpperMargin = 0;
break; // up
case -8:
eVAlign = text::VertOrientation::CENTER;
@@ -1980,25 +2012,25 @@ bTogglePos(false)
case -12:
eVAlign = text::VertOrientation::BOTTOM;
if (nYBind < 2)
- nLoMgn = 0;
+ nLowerMargin = 0;
break; // down
default:
- nYPos = rWW.nSp27 + static_cast<short>(nIniFlyDy);
+ nYPos = rWW.nTDyaAbs + static_cast<short>(nIniFlyDy);
break; // corrections from ini file
}
- switch( rWW.nSp26 ) // particular X-positions ?
+ switch( rWW.nTDxaAbs ) // particular X-positions ?
{
case 0:
eHAlign = text::HoriOrientation::LEFT;
- nLeMgn = 0;
+ nLeftMargin = 0;
break; // left
case -4:
eHAlign = text::HoriOrientation::CENTER;
break; // centered
case -8:
eHAlign = text::HoriOrientation::RIGHT;
- nRiMgn = 0;
+ nRightMargin = 0;
break; // right
case -12:
eHAlign = text::HoriOrientation::LEFT;
@@ -2009,7 +2041,7 @@ bTogglePos(false)
bTogglePos = true;
break; // outside
default:
- nXPos = rWW.nSp26 + static_cast<short>(nIniFlyDx);
+ nXPos = rWW.nTDxaAbs + static_cast<short>(nIniFlyDx);
break; // corrections from ini file
}
@@ -2058,9 +2090,9 @@ bTogglePos(false)
// to page text area'
eHAlign = text::HoriOrientation::NONE;
eHRel = text::RelOrientation::PAGE_PRINT_AREA;
- nXPos = -nWidth - (2*nLeBorderMgn) - rWW.nRiMgn;
+ nXPos = -nWidth - (2*nLeBorderMgn) - rWW.nRightMargin;
// re-set left wrap distance
- nLeMgn = rWW.nLeMgn;
+ nLeftMargin = rWW.nLeftMargin;
}
else if ( !bAutoWidth && eHAlign == text::HoriOrientation::RIGHT && eHRel == text::RelOrientation::PAGE_FRAME )
{
@@ -2069,9 +2101,9 @@ bTogglePos(false)
// to right page border'
eHAlign = text::HoriOrientation::NONE;
eHRel = text::RelOrientation::PAGE_RIGHT;
- nXPos = ( nRiBorderMgn - nLeBorderMgn ) + rWW.nLeMgn;
+ nXPos = ( nRiBorderMgn - nLeBorderMgn ) + rWW.nLeftMargin;
// re-set right wrap distance
- nRiMgn = rWW.nRiMgn;
+ nRightMargin = rWW.nRightMargin;
}
else if ( !bAutoWidth && eHAlign == text::HoriOrientation::LEFT && eHRel == text::RelOrientation::PAGE_PRINT_AREA )
{
@@ -2081,7 +2113,7 @@ bTogglePos(false)
eHRel = text::RelOrientation::PAGE_PRINT_AREA;
nXPos = -nLeBorderMgn;
// re-set left wrap distance
- nLeMgn = rWW.nLeMgn;
+ nLeftMargin = rWW.nLeftMargin;
}
else if ( !bAutoWidth && eHAlign == text::HoriOrientation::RIGHT && eHRel == text::RelOrientation::PAGE_PRINT_AREA )
{
@@ -2091,7 +2123,7 @@ bTogglePos(false)
eHRel = text::RelOrientation::PAGE_RIGHT;
nXPos = -nWidth - nLeBorderMgn;
// re-set right wrap distance
- nRiMgn = rWW.nRiMgn;
+ nRightMargin = rWW.nRightMargin;
}
else if (rWW.bBorderLines)
{
@@ -2135,14 +2167,29 @@ void WW8SwFlyPara::BoxUpWidth( tools::Long nInWidth )
{
if( bAutoWidth && nInWidth > nNewNetWidth )
nNewNetWidth = nInWidth;
-};
+}
-// The class WW8FlySet is derived from SfxItemSet and does not
+SwFlyFrameFormat* WW8SwFlyPara::GetFlyFormat() const
+{
+ if (!m_xFlyFormat)
+ return nullptr;
+ return static_cast<SwFlyFrameFormat*>(m_xFlyFormat->GetFormat());
+}
+
+void WW8SwFlyPara::SetFlyFormat(SwFlyFrameFormat* pNewFlyFormat)
+{
+ if (pNewFlyFormat)
+ m_xFlyFormat.reset(new FrameDeleteWatch(pNewFlyFormat));
+ else
+ m_xFlyFormat.reset();
+}
+
+// The class WW8FlySet is derived from SfxItemSetFixed and does not
// provide more, but is easier to handle for me.
// WW8FlySet-ctor for Apos and graphics Apos
WW8FlySet::WW8FlySet(SwWW8ImplReader& rReader, const WW8FlyPara* pFW,
const WW8SwFlyPara* pFS, bool bGraf)
- : SfxItemSet(rReader.m_rDoc.GetAttrPool(),svl::Items<RES_FRMATR_BEGIN,RES_FRMATR_END-1>{})
+ : SfxItemSetFixed(rReader.m_rDoc.GetAttrPool())
{
Reader::ResetFrameFormatAttrs(*this); // remove distance/border
// position
@@ -2156,11 +2203,11 @@ WW8FlySet::WW8FlySet(SwWW8ImplReader& rReader, const WW8FlyPara* pFW,
Put( SwFormatHoriOrient(nXPos, pFS->eHAlign, pFS->eHRel, pFS->bTogglePos ));
Put( SwFormatVertOrient( pFS->nYPos, pFS->eVAlign, pFS->eVRel ) );
- if (pFS->nLeMgn || pFS->nRiMgn) // set borders
- Put(SvxLRSpaceItem(pFS->nLeMgn, pFS->nRiMgn, 0, 0, RES_LR_SPACE));
+ if (pFS->nLeftMargin || pFS->nRightMargin) // set borders
+ Put(SvxLRSpaceItem(pFS->nLeftMargin, pFS->nRightMargin, 0, RES_LR_SPACE));
- if (pFS->nUpMgn || pFS->nLoMgn)
- Put(SvxULSpaceItem(pFS->nUpMgn, pFS->nLoMgn, RES_UL_SPACE));
+ if (pFS->nUpperMargin || pFS->nLowerMargin)
+ Put(SvxULSpaceItem(pFS->nUpperMargin, pFS->nLowerMargin, RES_UL_SPACE));
//we no longer need to hack around the header/footer problems
SwFormatSurround aSurround(pFS->eSurround);
@@ -2197,7 +2244,7 @@ WW8FlySet::WW8FlySet(SwWW8ImplReader& rReader, const WW8FlyPara* pFW,
// WW8FlySet-ctor for character bound graphics
WW8FlySet::WW8FlySet( SwWW8ImplReader& rReader, const SwPaM* pPaM,
const WW8_PIC& rPic, tools::Long nWidth, tools::Long nHeight )
- : SfxItemSet(rReader.m_rDoc.GetAttrPool(),svl::Items<RES_FRMATR_BEGIN,RES_FRMATR_END-1>{})
+ : SfxItemSetFixed<RES_FRMATR_BEGIN,RES_FRMATR_END-1>(rReader.m_rDoc.GetAttrPool())
{
Init(rReader, pPaM);
@@ -2218,7 +2265,7 @@ WW8FlySet::WW8FlySet( SwWW8ImplReader& rReader, const SwPaM* pPaM,
brcVer9[i] = WW8_BRCVer9(rPic.rgbrc[i]);
if (SwWW8ImplReader::SetFlyBordersShadow( *this, brcVer9, &aSizeArray[0]))
{
- Put(SvxLRSpaceItem( aSizeArray[WW8_LEFT], 0, 0, 0, RES_LR_SPACE ) );
+ Put(SvxLRSpaceItem( aSizeArray[WW8_LEFT], 0, 0, RES_LR_SPACE ) );
Put(SvxULSpaceItem( aSizeArray[WW8_TOP], 0, RES_UL_SPACE ));
aSizeArray[WW8_RIGHT]*=2;
aSizeArray[WW8_BOT]*=2;
@@ -2248,26 +2295,26 @@ void WW8FlySet::Init(const SwWW8ImplReader& rReader, const SwPaM* pPaM)
}
WW8DupProperties::WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStack)
- : pCtrlStck(pStack),
- aChrSet(rDoc.GetAttrPool(), svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END - 1>{} ),
- aParSet(rDoc.GetAttrPool(), svl::Items<RES_PARATR_BEGIN, RES_PARATR_END - 1>{} )
+ : m_pCtrlStck(pStack),
+ m_aChrSet(rDoc.GetAttrPool()),
+ m_aParSet(rDoc.GetAttrPool())
{
//Close any open character properties and duplicate them inside the
//first table cell
- size_t nCnt = pCtrlStck->size();
+ size_t nCnt = m_pCtrlStck->size();
for (size_t i=0; i < nCnt; ++i)
{
- const SwFltStackEntry& rEntry = (*pCtrlStck)[ i ];
- if (rEntry.bOpen)
+ const SwFltStackEntry& rEntry = (*m_pCtrlStck)[ i ];
+ if (rEntry.m_bOpen)
{
- if (isCHRATR(rEntry.pAttr->Which()))
+ if (isCHRATR(rEntry.m_pAttr->Which()))
{
- aChrSet.Put( *rEntry.pAttr );
+ m_aChrSet.Put( *rEntry.m_pAttr );
}
- else if (isPARATR(rEntry.pAttr->Which()))
+ else if (isPARATR(rEntry.m_pAttr->Which()))
{
- aParSet.Put( *rEntry.pAttr );
+ m_aParSet.Put( *rEntry.m_pAttr );
}
}
}
@@ -2275,7 +2322,7 @@ WW8DupProperties::WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStack)
void WW8DupProperties::Insert(const SwPosition &rPos)
{
- for (const SfxItemSet* pSet : {&aChrSet, &aParSet})
+ for (const SfxItemSet* pSet : {&m_aChrSet, &m_aParSet})
{
if( pSet->Count() )
{
@@ -2283,7 +2330,7 @@ void WW8DupProperties::Insert(const SwPosition &rPos)
const SfxPoolItem* pItem = aIter.GetCurItem();
do
{
- pCtrlStck->NewAttr(rPos, *pItem);
+ m_pCtrlStck->NewAttr(rPos, *pItem);
} while ((pItem = aIter.NextItem()));
}
}
@@ -2298,8 +2345,7 @@ void SwWW8ImplReader::MoveInsideFly(const SwFrameFormat *pFlyFormat)
// set Pam in FlyFrame
const SwFormatContent& rContent = pFlyFormat->GetContent();
OSL_ENSURE( rContent.GetContentIdx(), "No content prepared." );
- m_pPaM->GetPoint()->nNode = rContent.GetContentIdx()->GetIndex() + 1;
- m_pPaM->GetPoint()->nContent.Assign( m_pPaM->GetContentNode(), 0 );
+ m_pPaM->GetPoint()->Assign( rContent.GetContentIdx()->GetIndex() + 1 );
aDup.Insert(*m_pPaM->GetPoint());
}
@@ -2392,7 +2438,7 @@ std::unique_ptr<WW8FlyPara> SwWW8ImplReader::ConstructApo(const ApoTestResults &
// find APO parameter and test for bGrafApo
if (rApo.HasFrame())
- pRet->ReadFull(rApo.m_nSprm29, this);
+ pRet->ReadFull(rApo.m_nSprmPPc, this);
pRet->ApplyTabPos(pTabPos);
@@ -2449,7 +2495,7 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, const WW8_TablePos *p
if (IsDropCap())
{
m_bDropCap = true;
- m_xCurrentItemSet.reset(new SfxItemSet(m_rDoc.GetAttrPool(), svl::Items<RES_CHRATR_BEGIN, RES_PARATR_END - 1>{}));
+ m_xCurrentItemSet.reset(new SfxItemSet(m_rDoc.GetAttrPool(), svl::Items<RES_CHRATR_BEGIN, RES_PARATR_END - 1>));
return false;
}
@@ -2464,34 +2510,63 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, const WW8_TablePos *p
WW8FlySet aFlySet(*this, m_xWFlyPara.get(), m_xSFlyPara.get(), false);
- if (pTabPos && pTabPos->bNoFly)
- {
- m_xSFlyPara->pFlyFormat = nullptr;
- }
- else
+ // ofz#34749 we shouldn't anchor anything into an 'extra' paragraph scheduled for
+ // removal at end of import, but check if that scenario is happening
+ m_aExtraneousParas.remove_if_present(m_pPaM->GetPointNode().GetTextNode());
+
+ if (pTabPos)
{
- m_xSFlyPara->pFlyFormat = m_rDoc.MakeFlySection(WW8SwFlyPara::eAnchor,
- m_pPaM->GetPoint(), &aFlySet);
- OSL_ENSURE(m_xSFlyPara->pFlyFormat->GetAnchor().GetAnchorId() ==
- WW8SwFlyPara::eAnchor, "Not the anchor type requested!");
+ if (m_xFormatOfJustInsertedApo)
+ {
+ // We just inserted a floating table and we'll insert a next one.
+ SwFrameFormat* pFormat = m_xFormatOfJustInsertedApo->GetFormat();
+ if (pFormat)
+ {
+ const SwNode* pAnchorNode = pFormat->GetAnchor().GetAnchorNode();
+ SwPosition* pPoint = m_pPaM->GetPoint();
+ if (pAnchorNode && *pAnchorNode == pPoint->GetNode())
+ {
+ // The two fly frames would have the same anchor position, leading to
+ // potentially overlapping text, prevent that.
+ FinalizeTextNode(*pPoint);
+ }
+ }
+ }
+
+ // Map a positioned table to a split fly.
+ aFlySet.Put(SwFormatFlySplit(true));
+
+ if (pTabPos->nTFNoAllowOverlap)
+ {
+ // text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE is not the default and is set in
+ // the WW8FlySet ctor already, keep that unchanged.
+ SwFormatWrapInfluenceOnObjPos aInfluence(aFlySet.Get(RES_WRAP_INFLUENCE_ON_OBJPOS));
+ aInfluence.SetAllowOverlap(false);
+ aFlySet.Put(aInfluence);
+ }
}
- if (m_xSFlyPara->pFlyFormat)
+ m_xSFlyPara->SetFlyFormat(m_rDoc.MakeFlySection(WW8SwFlyPara::eAnchor,
+ m_pPaM->GetPoint(), &aFlySet));
+ OSL_ENSURE(m_xSFlyPara->GetFlyFormat()->GetAnchor().GetAnchorId() ==
+ WW8SwFlyPara::eAnchor, "Not the anchor type requested!");
+
+ if (SwFlyFrameFormat* pFlyFormat = m_xSFlyPara->GetFlyFormat())
{
if (!m_pDrawModel)
GraphicCtor();
- SdrObject* pOurNewObject = CreateContactObject(m_xSFlyPara->pFlyFormat);
+ SdrObject* pOurNewObject = CreateContactObject(pFlyFormat);
m_xWWZOrder->InsertTextLayerObject(pOurNewObject);
}
- if (RndStdIds::FLY_AS_CHAR != WW8SwFlyPara::eAnchor && m_xSFlyPara->pFlyFormat)
+ if (RndStdIds::FLY_AS_CHAR != WW8SwFlyPara::eAnchor && m_xSFlyPara->GetFlyFormat())
{
- m_xAnchorStck->AddAnchor(*m_pPaM->GetPoint(), m_xSFlyPara->pFlyFormat);
+ m_xAnchorStck->AddAnchor(*m_pPaM->GetPoint(), m_xSFlyPara->GetFlyFormat());
}
// remember Pos in body text
- m_xSFlyPara->xMainTextPos.reset(new SwPosition(*m_pPaM->GetPoint()));
+ m_xSFlyPara->xMainTextPos = m_rDoc.CreateUnoCursor(*m_pPaM->GetPoint());
//remove fltanchors, otherwise they will be closed inside the
//frame, which makes no sense, restore them after the frame is
@@ -2499,8 +2574,8 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, const WW8_TablePos *p
m_xSFlyPara->xOldAnchorStck = std::move(m_xAnchorStck);
m_xAnchorStck.reset(new SwWW8FltAnchorStack(m_rDoc, m_nFieldFlags));
- if (m_xSFlyPara->pFlyFormat)
- MoveInsideFly(m_xSFlyPara->pFlyFormat);
+ if (SwFlyFrameFormat* pFlyFormat = m_xSFlyPara->GetFlyFormat())
+ MoveInsideFly(pFlyFormat);
// 1) ReadText() is not called recursively because the length of
// the Apo is unknown at that time, and ReadText() needs it.
@@ -2515,30 +2590,29 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, const WW8_TablePos *p
void wwSectionManager::JoinNode(const SwPosition &rPos, const SwNode &rNode)
{
- if ((!maSegments.empty()) && (maSegments.back().maStart == rPos.nNode))
+ if ((!maSegments.empty()) && (maSegments.back().maStart == rPos.GetNode()))
maSegments.back().maStart.Assign(rNode);
}
bool SwWW8ImplReader::JoinNode(SwPaM &rPam, bool bStealAttr)
{
bool bRet = false;
- rPam.GetPoint()->nContent = 0; // go to start of paragraph
+ rPam.GetPoint()->SetContent(0); // go to start of paragraph
- SwNodeIndex aPref(rPam.GetPoint()->nNode, -1);
+ SwNodeIndex aPref(rPam.GetPoint()->GetNode(), -1);
if (SwTextNode* pNode = aPref.GetNode().GetTextNode())
{
m_aSectionManager.JoinNode(*rPam.GetPoint(), aPref.GetNode());
- rPam.GetPoint()->nNode = aPref;
- rPam.GetPoint()->nContent.Assign(pNode, pNode->GetText().getLength());
+ rPam.GetPoint()->Assign(*pNode, pNode->GetText().getLength());
if (bStealAttr)
- m_xCtrlStck->StealAttr(rPam.GetPoint()->nNode);
+ m_xCtrlStck->StealAttr(rPam.GetPoint()->GetNode());
- if (m_pLastAnchorPos || m_pPreviousNode || (m_xSFlyPara && m_xSFlyPara->xMainTextPos))
+ if (m_oLastAnchorPos || m_xPreviousNode || (m_xSFlyPara && m_xSFlyPara->xMainTextPos))
{
SwNodeIndex aToBeJoined(aPref, 1);
- if (m_pLastAnchorPos)
+ if (m_oLastAnchorPos)
{
//If the last anchor pos is here, then clear the anchor pos.
//This "last anchor pos" is only used for fixing up the
@@ -2546,25 +2620,25 @@ bool SwWW8ImplReader::JoinNode(SwPaM &rPam, bool bStealAttr)
//we are removing the last paragraph of a frame, so there
//cannot be a page break at this point so we can
//safely reset m_pLastAnchorPos to avoid any dangling
- //SwIndex's pointing into the deleted paragraph
- SwNodeIndex aLastAnchorPos(m_pLastAnchorPos->nNode);
+ //SwContentIndex's pointing into the deleted paragraph
+ SwNodeIndex aLastAnchorPos(m_oLastAnchorPos->GetNode());
if (aLastAnchorPos == aToBeJoined)
- m_pLastAnchorPos.reset();
+ m_oLastAnchorPos.reset();
}
- if (m_pPreviousNode)
+ if (m_xPreviousNode)
{
//If the drop character start pos is here, then clear it.
- SwNodeIndex aDropCharPos(*m_pPreviousNode);
+ SwNodeIndex aDropCharPos(*m_xPreviousNode->GetTextNode());
if (aDropCharPos == aToBeJoined)
- m_pPreviousNode = nullptr;
+ m_xPreviousNode.reset();
}
if (m_xSFlyPara && m_xSFlyPara->xMainTextPos)
{
// If an open apo pos is here, then clear it before
// JoinNext destroys it
- SwNodeIndex aOpenApoPos(m_xSFlyPara->xMainTextPos->nNode);
+ SwNodeIndex aOpenApoPos(m_xSFlyPara->xMainTextPos->GetPoint()->GetNode());
if (aOpenApoPos == aToBeJoined)
m_xSFlyPara->xMainTextPos.reset();
}
@@ -2591,12 +2665,12 @@ void SwWW8ImplReader::StripNegativeAfterIndent(SwFrameFormat const *pFlyFormat)
SwTextNode *pNd = aIdx.GetNode().GetTextNode();
if (pNd)
{
- const SvxLRSpaceItem& rLR = ItemGet<SvxLRSpaceItem>(*pNd, RES_LR_SPACE);
- if (rLR.GetRight() < 0)
+ const SvxRightMarginItem & rRightMargin(pNd->GetAttr(RES_MARGIN_RIGHT));
+ if (rRightMargin.GetRight() < 0)
{
- SvxLRSpaceItem aLR(rLR);
- aLR.SetRight(0);
- pNd->SetAttr(aLR);
+ SvxRightMarginItem rightMargin(rRightMargin);
+ rightMargin.SetRight(0);
+ pNd->SetAttr(rightMargin);
}
}
++aIdx;
@@ -2636,10 +2710,10 @@ void SwWW8ImplReader::StopApo()
that comes with the frame by default so that as normal we don't end up
with one more paragraph than we wanted.
*/
- SwNodeIndex aPref(m_pPaM->GetPoint()->nNode, -1);
+ SwNodeIndex aPref(m_pPaM->GetPoint()->GetNode(), -1);
SwTwips nNewWidth =
- MoveOutsideFly(m_xSFlyPara->pFlyFormat, *m_xSFlyPara->xMainTextPos);
+ MoveOutsideFly(m_xSFlyPara->GetFlyFormat(), *m_xSFlyPara->xMainTextPos->GetPoint());
if (nNewWidth)
m_xSFlyPara->BoxUpWidth(nNewWidth);
@@ -2647,7 +2721,7 @@ void SwWW8ImplReader::StopApo()
SwTextNode* pNd = aPref.GetNode().GetTextNode();
SwTextNode* pJoinNext = nullptr;
- if (pNd && m_xSFlyPara->pFlyFormat)
+ if (pNd && m_xSFlyPara->GetFlyFormat())
{
/*
#i582#
@@ -2660,7 +2734,7 @@ void SwWW8ImplReader::StopApo()
if (rBrush.GetColor() != COL_AUTO)
aBg = rBrush.GetColor();
- if (m_pLastAnchorPos)
+ if (m_oLastAnchorPos)
{
//If the last anchor pos is here, then clear the anchor pos.
//This "last anchor pos" is only used for fixing up the
@@ -2668,19 +2742,19 @@ void SwWW8ImplReader::StopApo()
//we are removing the last paragraph of a frame, so there
//cannot be a page break at this point so we can
//safely reset m_pLastAnchorPos to avoid any dangling
- //SwIndex's pointing into the deleted paragraph
- SwNodeIndex aLastAnchorPos(m_pLastAnchorPos->nNode);
+ //SwContentIndex's pointing into the deleted paragraph
+ SwNodeIndex aLastAnchorPos(m_oLastAnchorPos->GetNode());
SwNodeIndex aToBeJoined(aPref, 1);
if (aLastAnchorPos == aToBeJoined)
- m_pLastAnchorPos.reset();
+ m_oLastAnchorPos.reset();
}
//Get rid of extra empty paragraph
pJoinNext = pNd;
}
- if (m_xSFlyPara->pFlyFormat)
- m_xSFlyPara->pFlyFormat->SetFormatAttr(SvxBrushItem(aBg, RES_BACKGROUND));
+ if (SwFlyFrameFormat* pFlyFormat = m_xSFlyPara->GetFlyFormat())
+ pFlyFormat->SetFormatAttr(SvxBrushItem(aBg, RES_BACKGROUND));
DeleteAnchorStack();
if (pJoinNext)
@@ -2692,11 +2766,11 @@ void SwWW8ImplReader::StopApo()
// function, the extension of the SW-fly has to be set
// manually as the SW fly has no auto function to adjust the
// frame´s size.
- if (m_xSFlyPara->nNewNetWidth > MINFLY && m_xSFlyPara->pFlyFormat) // BoxUpWidth ?
+ if (m_xSFlyPara->nNewNetWidth > MINFLY && m_xSFlyPara->GetFlyFormat()) // BoxUpWidth ?
{
tools::Long nW = m_xSFlyPara->nNewNetWidth;
nW += m_xSFlyPara->nWidth - m_xSFlyPara->nNetWidth; // border for it
- m_xSFlyPara->pFlyFormat->SetFormatAttr(
+ m_xSFlyPara->GetFlyFormat()->SetFormatAttr(
SwFormatFrameSize(m_xSFlyPara->eHeightFix, nW, m_xSFlyPara->nHeight));
}
/*
@@ -2707,24 +2781,27 @@ void SwWW8ImplReader::StopApo()
#i27204# Added AutoWidth setting. Left the old CalculateFlySize in place
so that if the user unselects autowidth, the width doesn't max out
*/
- else if (!m_xWFlyPara->nSp28 && m_xSFlyPara->pFlyFormat)
+ else if (!m_xWFlyPara->nSp28 && m_xSFlyPara->GetFlyFormat())
{
using namespace sw::util;
- SfxItemSet aFlySet( m_xSFlyPara->pFlyFormat->GetAttrSet() );
+ SfxItemSet aFlySet( m_xSFlyPara->GetFlyFormat()->GetAttrSet() );
- SwFormatFrameSize aSize(ItemGet<SwFormatFrameSize>(aFlySet, RES_FRM_SIZE));
+ SwFormatFrameSize aSize(aFlySet.Get(RES_FRM_SIZE));
aFlySet.ClearItem(RES_FRM_SIZE);
- CalculateFlySize(aFlySet, m_xSFlyPara->xMainTextPos->nNode,
- m_xSFlyPara->nWidth);
+ if (!m_bFuzzing)
+ {
+ CalculateFlySize(aFlySet, m_xSFlyPara->xMainTextPos->GetPoint()->GetNode(),
+ m_xSFlyPara->nWidth);
+ }
- nNewWidth = ItemGet<SwFormatFrameSize>(aFlySet, RES_FRM_SIZE).GetWidth();
+ nNewWidth = aFlySet.Get(RES_FRM_SIZE).GetWidth();
aSize.SetWidth(nNewWidth);
aSize.SetWidthSizeType(SwFrameSize::Variable);
- m_xSFlyPara->pFlyFormat->SetFormatAttr(aSize);
+ m_xSFlyPara->GetFlyFormat()->SetFormatAttr(aSize);
}
m_xSFlyPara->xMainTextPos.reset();
@@ -2734,8 +2811,8 @@ void SwWW8ImplReader::StopApo()
}
//#i8062#
- if (m_xSFlyPara && m_xSFlyPara->pFlyFormat)
- m_xFormatOfJustInsertedApo.reset(new FrameDeleteWatch(m_xSFlyPara->pFlyFormat));
+ if (m_xSFlyPara && m_xSFlyPara->GetFlyFormat())
+ m_xFormatOfJustInsertedApo.reset(new FrameDeleteWatch(m_xSFlyPara->GetFlyFormat()));
m_xSFlyPara.reset();
m_xWFlyPara.reset();
@@ -2760,7 +2837,7 @@ bool SwWW8ImplReader::TestSameApo(const ApoTestResults &rApo,
WW8FlyPara aF(m_bVer67, rApo.mpStyleApo);
// WWPara for current para
if (rApo.HasFrame())
- aF.Read(rApo.m_nSprm29, m_xPlcxMan->GetPapPLCF());
+ aF.Read(rApo.m_nSprmPPc, m_xPlcxMan->GetPapPLCF());
aF.ApplyTabPos(pTabPos);
return aF == *m_xWFlyPara;
@@ -2792,13 +2869,13 @@ void SwWW8ImplReader::NewAttr( const SfxPoolItem& rAttr,
// #i103711#
if ( bFirstLineOfStSet )
{
- const SwNode* pNd = &(m_pPaM->GetPoint()->nNode.GetNode());
+ const SwNode* pNd = &(m_pPaM->GetPoint()->GetNode());
m_aTextNodesHavingFirstLineOfstSet.insert( pNd );
}
// #i105414#
if ( bLeftIndentSet )
{
- const SwNode* pNd = &(m_pPaM->GetPoint()->nNode.GetNode());
+ const SwNode* pNd = &(m_pPaM->GetPoint()->GetNode());
m_aTextNodesHavingLeftIndentSet.insert( pNd );
}
}
@@ -2819,7 +2896,7 @@ const SfxPoolItem* SwWW8ImplReader::GetFormatAttr( sal_uInt16 nWhich )
if (!pRet)
pRet = m_pStandardFormatColl ? &(m_pStandardFormatColl->GetFormatAttr(nWhich)) : nullptr;
if (!pRet)
- pRet = &m_rDoc.GetAttrPool().GetDefaultItem(nWhich);
+ pRet = &m_rDoc.GetAttrPool().GetUserOrPoolDefaultItem(nWhich);
}
else if (m_xPlcxMan && m_xPlcxMan->GetDoingDrawTextBox())
{
@@ -2835,7 +2912,7 @@ const SfxPoolItem* SwWW8ImplReader::GetFormatAttr( sal_uInt16 nWhich )
if (!pRet)
pRet = m_pStandardFormatColl ? &(m_pStandardFormatColl->GetFormatAttr(nWhich)) : nullptr;
if (!pRet)
- pRet = &m_rDoc.GetAttrPool().GetDefaultItem(nWhich);
+ pRet = &m_rDoc.GetAttrPool().GetUserOrPoolDefaultItem(nWhich);
}
else
pRet = m_xCtrlStck->GetFormatAttr(*m_pPaM->GetPoint(), nWhich);
@@ -3063,7 +3140,7 @@ void SwWW8ImplReader::Read_BoldUsw( sal_uInt16 nId, const sal_uInt8* pData, shor
pSI->m_n81Flags |= nMask; // set flag
else
pSI->m_n81Flags &= ~nMask; // delete flag
- }
+ }
}
else
{
@@ -3319,6 +3396,22 @@ void SwWW8ImplReader::SetToggleAttr(sal_uInt8 nAttrId, bool bOn)
: SvxCaseMap::NotMapped, RES_CHRATR_CASEMAP ) );
break;
case 7:
+ if (m_pPaM->GetPoint()->GetContentIndex() == 0 && m_xFormatOfJustInsertedApo)
+ {
+ // We just inserted a frame and we're at the next paragraph start.
+ SwFrameFormat* pFormat = m_xFormatOfJustInsertedApo->GetFormat();
+ if (pFormat)
+ {
+ SwNode* pAnchorNode = pFormat->GetAnchor().GetAnchorNode();
+ if (pAnchorNode && *pAnchorNode == m_pPaM->GetPoint()->GetNode())
+ {
+ // The anchor paragraph would be hidden, leading to hiding the frame as
+ // well, prevent that.
+ break;
+ }
+ }
+ }
+
NewAttr(SvxCharHiddenItem(bOn, RES_CHRATR_HIDDEN));
break;
case 8:
@@ -3401,10 +3494,10 @@ SwFrameFormat *SwWW8ImplReader::ContainsSingleInlineGraphic(const SwPaM &rRegion
RndStdIds::FLY_AS_CHAR and then we can change its anchoring to centered in the line.
*/
SwFrameFormat *pRet=nullptr;
- SwNodeIndex aBegin(rRegion.Start()->nNode);
- const sal_Int32 nBegin(rRegion.Start()->nContent.GetIndex());
- SwNodeIndex aEnd(rRegion.End()->nNode);
- const sal_Int32 nEnd(rRegion.End()->nContent.GetIndex());
+ SwNodeIndex aBegin(rRegion.Start()->GetNode());
+ const sal_Int32 nBegin(rRegion.Start()->GetContentIndex());
+ SwNodeIndex aEnd(rRegion.End()->GetNode());
+ const sal_Int32 nEnd(rRegion.End()->GetContentIndex());
const SwTextNode* pTNd;
const SwTextAttr* pTFlyAttr;
if (
@@ -3443,7 +3536,7 @@ bool SwWW8ImplReader::ConvertSubToGraphicPlacement()
SwFltPosition aPtPos(*m_pPaM->GetPoint());
SwFrameFormat *pFlyFormat = nullptr;
- if (SwFltStackEntry::MakeRegion(m_rDoc, aRegion, SwFltStackEntry::RegionMode::NoCheck, aMkPos, aPtPos)
+ if (SwFltStackEntry::MakeRegion(aRegion, SwFltStackEntry::RegionMode::NoCheck, aMkPos, aPtPos)
&& nullptr != (pFlyFormat = ContainsSingleInlineGraphic(aRegion)))
{
m_xCtrlStck->DeleteAndDestroy(nPos);
@@ -3477,8 +3570,7 @@ void SwWW8ImplReader::Read_SubSuperProp( sal_uInt16, const sal_uInt8* pData, sho
// font position in HalfPoints
short nPos = eVersion <= ww::eWW2 ? static_cast< sal_Int8 >( *pData ) : SVBT16ToInt16( pData );
sal_Int32 nPos2 = nPos * ( 10 * 100 ); // HalfPoints in 100 * tw
- const SvxFontHeightItem* pF
- = static_cast<const SvxFontHeightItem*>(GetFormatAttr(RES_CHRATR_FONTSIZE));
+ const SvxFontHeightItem* pF = GetFormatAttr(RES_CHRATR_FONTSIZE);
OSL_ENSURE(pF, "Expected to have the fontheight available here");
// #i59022: Check ensure nHeight != 0. Div by zero otherwise.
@@ -4093,12 +4185,12 @@ void SwWW8ImplReader::Read_CharShadow( sal_uInt16, const sal_uInt8* pData, shor
aSHD.SetWWValue( *reinterpret_cast<SVBT16 const *>(pData) );
SwWW8Shade aSh( m_bVer67, aSHD );
- NewAttr( SvxBrushItem( aSh.aColor, RES_CHRATR_BACKGROUND ));
+ NewAttr( SvxBrushItem( aSh.m_aColor, RES_CHRATR_BACKGROUND ));
// Add a marker to the grabbag indicating that character background was imported from MSO shading
- SfxGrabBagItem aGrabBag = *static_cast<const SfxGrabBagItem*>(GetFormatAttr(RES_CHRATR_GRABBAG));
+ SfxGrabBagItem aGrabBag = *GetFormatAttr(RES_CHRATR_GRABBAG);
std::map<OUString, css::uno::Any>& rMap = aGrabBag.GetGrabBag();
- rMap.insert(std::pair<OUString, css::uno::Any>("CharShadingMarker",uno::makeAny(true)));
+ rMap.insert(std::pair<OUString, css::uno::Any>("CharShadingMarker",uno::Any(true)));
NewAttr(aGrabBag);
}
}
@@ -4118,9 +4210,9 @@ void SwWW8ImplReader::Read_TextBackColor(sal_uInt16, const sal_uInt8* pData, sho
NewAttr(SvxBrushItem(aColour, RES_CHRATR_BACKGROUND));
// Add a marker to the grabbag indicating that character background was imported from MSO shading
- SfxGrabBagItem aGrabBag = *static_cast<const SfxGrabBagItem*>(GetFormatAttr(RES_CHRATR_GRABBAG));
+ SfxGrabBagItem aGrabBag = *GetFormatAttr(RES_CHRATR_GRABBAG);
std::map<OUString, css::uno::Any>& rMap = aGrabBag.GetGrabBag();
- rMap.insert(std::pair<OUString, css::uno::Any>("CharShadingMarker",uno::makeAny(true)));
+ rMap.insert(std::pair<OUString, css::uno::Any>("CharShadingMarker",uno::Any(true)));
NewAttr(aGrabBag);
}
}
@@ -4155,8 +4247,7 @@ void SwWW8ImplReader::Read_NoLineNumb(sal_uInt16 , const sal_uInt8* pData, short
return;
}
SwFormatLineNumber aLN;
- if (const SwFormatLineNumber* pLN
- = static_cast<const SwFormatLineNumber*>(GetFormatAttr(RES_LINENUMBER)))
+ if (const SwFormatLineNumber* pLN = GetFormatAttr(RES_LINENUMBER))
{
aLN.SetStartValue( pLN->GetStartValue() );
}
@@ -4183,24 +4274,35 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe
{
if (nLen < 2) // end of attribute
{
- m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_LR_SPACE);
+ m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_MARGIN_FIRSTLINE);
+ m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_MARGIN_TEXTLEFT);
+ m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_MARGIN_RIGHT);
return;
}
short nPara = SVBT16ToUInt16( pData );
- std::shared_ptr<SvxLRSpaceItem> aLR(std::make_shared<SvxLRSpaceItem>(RES_LR_SPACE));
- const SfxPoolItem* pLR = GetFormatAttr(RES_LR_SPACE);
- if( pLR )
- aLR.reset(static_cast<SvxLRSpaceItem*>(pLR->Clone()));
+ SfxPoolItem const* pItem(GetFormatAttr(RES_MARGIN_FIRSTLINE));
+ ::std::unique_ptr<SvxFirstLineIndentItem> pFirstLine(pItem
+ ? static_cast<SvxFirstLineIndentItem*>(pItem->Clone())
+ : new SvxFirstLineIndentItem(RES_MARGIN_FIRSTLINE));
+ pItem = GetFormatAttr(RES_MARGIN_TEXTLEFT);
+ ::std::unique_ptr<SvxTextLeftMarginItem> pLeftMargin(pItem
+ ? static_cast<SvxTextLeftMarginItem*>(pItem->Clone())
+ : new SvxTextLeftMarginItem(RES_MARGIN_TEXTLEFT));
+ pItem = GetFormatAttr(RES_MARGIN_RIGHT);
+ ::std::unique_ptr<SvxRightMarginItem> pRightMargin(pItem
+ ? static_cast<SvxRightMarginItem*>(pItem->Clone())
+ : new SvxRightMarginItem(RES_MARGIN_RIGHT));
// Fix the regression issue: #i99822#: Discussion?
// Since the list level formatting doesn't apply into paragraph style
// for list levels of mode LABEL_ALIGNMENT.(see ww8par3.cxx
// W8ImplReader::RegisterNumFormatOnTextNode).
// Need to apply the list format to the paragraph here.
- SwTextNode* pTextNode = m_pPaM->GetNode().GetTextNode();
- if( pTextNode && pTextNode->AreListLevelIndentsApplicable() )
+ SwTextNode* pTextNode = m_pPaM->GetPointNode().GetTextNode();
+ if (pTextNode
+ && pTextNode->AreListLevelIndentsApplicable() != ::sw::ListLevelIndents::No)
{
SwNumRule * pNumRule = pTextNode->GetNumRule();
if( pNumRule )
@@ -4209,10 +4311,11 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe
const SwNumFormat* pFormat = pNumRule->GetNumFormat( nLvl );
if ( pFormat && pFormat->GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
{
- aLR->SetTextLeft( pFormat->GetIndentAt() );
- aLR->SetTextFirstLineOffset( static_cast<short>(pFormat->GetFirstLineIndent()) );
+ pLeftMargin->SetTextLeft(pFormat->GetIndentAt());
+ pFirstLine->SetTextFirstLineOffset(static_cast<short>(pFormat->GetFirstLineIndent()));
// make paragraph have hard-set indent attributes
- pTextNode->SetAttr( *aLR );
+ pTextNode->SetAttr(*pLeftMargin);
+ pTextNode->SetAttr(*pFirstLine);
}
}
}
@@ -4252,7 +4355,7 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe
case NS_sprm::v6::sprmPDxaLeft:
case NS_sprm::PDxaLeft80::val:
case NS_sprm::PDxaLeft::val:
- aLR->SetTextLeft( nPara );
+ pLeftMargin->SetTextLeft(nPara);
if (m_pCurrentColl && m_nCurrentColl < m_vColl.size())
{
m_vColl[m_nCurrentColl].m_bListRelevantIndentSet = true;
@@ -4279,27 +4382,26 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe
SprmResult aIsZeroed = m_xPlcxMan->GetPapPLCF()->HasSprm(NS_sprm::PIlfo::val);
if (aIsZeroed.pSprm && aIsZeroed.nRemainingData >= 1 && *aIsZeroed.pSprm == 0)
{
- const SvxLRSpaceItem &rLR =
- ItemGet<SvxLRSpaceItem>(*(m_vColl[m_nCurrentColl].m_pFormat),
- RES_LR_SPACE);
- nPara = nPara - rLR.GetTextFirstLineOffset();
+ const SvxFirstLineIndentItem & rFirstLine =
+ m_vColl[m_nCurrentColl].m_pFormat->GetFormatAttr(RES_MARGIN_FIRSTLINE);
+ nPara = nPara - rFirstLine.GetTextFirstLineOffset();
}
}
- aLR->SetTextFirstLineOffset(nPara);
+ pFirstLine->SetTextFirstLineOffset(nPara);
if (!m_pCurrentColl)
{
- if (const SwTextNode* pNode = m_pPaM->GetNode().GetTextNode())
+ if (const SwTextNode* pNode = m_pPaM->GetPointNode().GetTextNode())
{
if ( const SwNumFormat *pNumFormat = GetNumFormatFromTextNode(*pNode) )
{
if (!lcl_HasExplicitLeft(m_xPlcxMan.get(), m_bVer67))
{
- aLR->SetTextLeft(pNumFormat->GetIndentAt());
+ pLeftMargin->SetTextLeft(pNumFormat->GetIndentAt());
// If have not explicit left, set number format list tab position is doc default tab
- const SvxTabStopItem *pDefaultStopItem = m_rDoc.GetAttrPool().GetPoolDefaultItem(RES_PARATR_TABSTOP);
+ const SvxTabStopItem *pDefaultStopItem = m_rDoc.GetAttrPool().GetUserDefaultItem(RES_PARATR_TABSTOP);
if ( pDefaultStopItem && pDefaultStopItem->Count() > 0 )
const_cast<SwNumFormat*>(pNumFormat)->SetListtabPos( const_cast<SvxTabStop&>((*pDefaultStopItem)[0]).GetTabPos() );
}
@@ -4316,13 +4418,15 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe
case NS_sprm::v6::sprmPDxaRight:
case NS_sprm::PDxaRight80::val:
case NS_sprm::PDxaRight::val:
- aLR->SetRight( nPara );
+ pRightMargin->SetRight(nPara);
break;
default:
return;
}
- NewAttr( *aLR, bFirstLinOfstSet, bLeftIndentSet ); // #i103711#, #i105414#
+ NewAttr(*pFirstLine, bFirstLinOfstSet, false); // #i103711#, #i105414#
+ NewAttr(*pLeftMargin, false, bLeftIndentSet);
+ NewAttr(*pRightMargin, false, false);
}
// Sprm 20
@@ -4373,15 +4477,14 @@ void SwWW8ImplReader::Read_LineSpace( sal_uInt16, const sal_uInt8* pData, short
tools::Long n = nSpace * 10 / 24; // WW: 240 = 100%, SW: 100 = 100%
// here n is in [0..13653]
- aLSpc.SetPropLineSpace( static_cast<sal_uInt16>(n) );
- const SvxFontHeightItem* pH = static_cast<const SvxFontHeightItem*>(
- GetFormatAttr( RES_CHRATR_FONTSIZE ));
- nSpaceTw = static_cast<sal_uInt16>( n * pH->GetHeight() / 100 );
+ aLSpc.SetPropLineSpace( o3tl::narrowing<sal_uInt16>(n) );
+ const SvxFontHeightItem* pH = GetFormatAttr( RES_CHRATR_FONTSIZE );
+ nSpaceTw = o3tl::narrowing<sal_uInt16>( n * pH->GetHeight() / 100 );
}
else // Fixed / Minimum
{
// for negative space, the distance is "exact", otherwise "at least"
- nSpaceTw = static_cast<sal_uInt16>(nSpace);
+ nSpaceTw = o3tl::narrowing<sal_uInt16>(nSpace);
aLSpc.SetLineHeight( nSpaceTw );
aLSpc.SetLineSpaceRule( eLnSpc);
}
@@ -4409,7 +4512,7 @@ void SwWW8ImplReader::Read_ParaAutoBefore(sal_uInt16, const sal_uInt8 *pData, sh
if (*pData)
{
- SvxULSpaceItem aUL(*static_cast<const SvxULSpaceItem*>(GetFormatAttr(RES_UL_SPACE)));
+ SvxULSpaceItem aUL(*GetFormatAttr(RES_UL_SPACE));
aUL.SetUpper(GetParagraphAutoSpace(m_xWDop->fDontUseHTMLAutoSpacing));
NewAttr(aUL);
if (m_pCurrentColl && m_nCurrentColl < m_vColl.size())
@@ -4436,7 +4539,7 @@ void SwWW8ImplReader::Read_ParaAutoAfter(sal_uInt16, const sal_uInt8 *pData, sho
if (*pData)
{
- SvxULSpaceItem aUL(*static_cast<const SvxULSpaceItem*>(GetFormatAttr(RES_UL_SPACE)));
+ SvxULSpaceItem aUL(*GetFormatAttr(RES_UL_SPACE));
aUL.SetLower(GetParagraphAutoSpace(m_xWDop->fDontUseHTMLAutoSpacing));
NewAttr(aUL);
if (m_pCurrentColl && m_nCurrentColl < m_vColl.size())
@@ -4477,7 +4580,7 @@ void SwWW8ImplReader::Read_UL( sal_uInt16 nId, const sal_uInt8* pData, short nLe
if( nPara < 0 )
nPara = -nPara;
- SvxULSpaceItem aUL( *static_cast<const SvxULSpaceItem*>(GetFormatAttr( RES_UL_SPACE )));
+ SvxULSpaceItem aUL( *GetFormatAttr( RES_UL_SPACE ));
switch( nId )
{
@@ -4505,11 +4608,49 @@ void SwWW8ImplReader::Read_ParaContextualSpacing( sal_uInt16, const sal_uInt8* p
m_xCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_UL_SPACE );
return;
}
- SvxULSpaceItem aUL( *static_cast<const SvxULSpaceItem*>(GetFormatAttr( RES_UL_SPACE )));
+ SvxULSpaceItem aUL( *GetFormatAttr( RES_UL_SPACE ));
aUL.SetContextValue(*pData != 0);
NewAttr( aUL );
}
+void SwWW8ImplReader::Read_LineBreakClear(sal_uInt16 /*nId*/, const sal_uInt8* pData, short nLen)
+{
+ if (nLen == -1 && m_oLineBreakClear.has_value())
+ {
+ SwTextNode* pText = m_pPaM->GetPointNode().GetTextNode();
+ sal_Int32 nPos = m_pPaM->GetPoint()->GetContentIndex();
+ if (!pText || !nPos)
+ {
+ // There should have been a linebreak char.
+ return;
+ }
+
+ // Replace the linebreak char with a clearing break.
+ --nPos;
+ m_pPaM->SetMark();
+ m_pPaM->GetMark()->AdjustContent(-1);
+ m_rDoc.getIDocumentContentOperations().DeleteRange(*m_pPaM);
+ m_pPaM->DeleteMark();
+ SwFormatLineBreak aLineBreak(*m_oLineBreakClear);
+ m_oLineBreakClear.reset();
+ pText->InsertItem(aLineBreak, nPos, nPos);
+ }
+
+ if (nLen < 1)
+ {
+ return;
+ }
+
+ sal_uInt8 nClear = pData[0];
+ if (nClear > 3)
+ {
+ return;
+ }
+
+ auto eClear = static_cast<SwLineBreakClear>(nClear);
+ m_oLineBreakClear = eClear;
+}
+
void SwWW8ImplReader::Read_IdctHint( sal_uInt16, const sal_uInt8* pData, short nLen )
{
// sprmcidcthint (opcode 0x286f) specifies a script bias for the text in the run.
@@ -4575,8 +4716,7 @@ bool SwWW8ImplReader::IsRightToLeft()
bRTL = *aDir.pSprm != 0;
else
{
- const SvxFrameDirectionItem* pItem=
- static_cast<const SvxFrameDirectionItem*>(GetFormatAttr(RES_FRAMEDIR));
+ const SvxFrameDirectionItem* pItem = GetFormatAttr(RES_FRAMEDIR);
if (pItem && (pItem->GetValue() == SvxFrameDirection::Horizontal_RL_TB))
bRTL = true;
}
@@ -4674,8 +4814,8 @@ void SwWW8ImplReader::Read_Emphasis( sal_uInt16, const sal_uInt8* pData, short n
nLang = LanguageType(SVBT16ToUInt16(aLang.pSprm));
else
{
- nLang = static_cast<const SvxLanguageItem *>(
- GetFormatAttr(RES_CHRATR_CJK_LANGUAGE))->GetLanguage();
+ const SvxLanguageItem * pLangItem = GetFormatAttr(RES_CHRATR_CJK_LANGUAGE);
+ nLang = pLangItem->GetLanguage();
}
FontEmphasisMark nVal;
@@ -4739,8 +4879,7 @@ void SwWW8ImplReader::Read_Relief( sal_uInt16 nId, const sal_uInt8* pData, short
// 2 x emboss on -> no emboss !!!
// the actual value must be searched over the stack / template
- const SvxCharReliefItem* pOld = static_cast<const SvxCharReliefItem*>(
- GetFormatAttr( RES_CHRATR_RELIEF ));
+ const SvxCharReliefItem* pOld = GetFormatAttr( RES_CHRATR_RELIEF );
FontRelief nNewValue = NS_sprm::CFImprint::val == nId ? FontRelief::Engraved
: ( NS_sprm::CFEmboss::val == nId ? FontRelief::Embossed
: FontRelief::NONE );
@@ -4889,7 +5028,7 @@ void SwWW8Shade::SetShade(Color nFore, Color nBack, sal_uInt16 nIndex)
switch (nWW8BrushStyle)
{
case 0: // Null-Brush
- aColor = nBack;
+ m_aColor = nBack;
break;
default:
{
@@ -4903,7 +5042,7 @@ void SwWW8Shade::SetShade(Color nFore, Color nBack, sal_uInt16 nIndex)
nGreen += aBackColor.GetGreen()* (1000 - nWW8BrushStyle);
nBlue += aBackColor.GetBlue() * (1000 - nWW8BrushStyle);
- aColor = Color( nRed/1000, nGreen/1000, nBlue/1000 );
+ m_aColor = Color( nRed/1000, nGreen/1000, nBlue/1000 );
}
break;
}
@@ -4927,7 +5066,7 @@ void SwWW8ImplReader::Read_Shade( sal_uInt16, const sal_uInt8* pData, short nLen
SwWW8Shade aSh( m_bVer67, aSHD );
NewAttr( XFillStyleItem(drawing::FillStyle_SOLID) );
- NewAttr( XFillColorItem(OUString(), aSh.aColor) );
+ NewAttr( XFillColorItem(OUString(), aSh.m_aColor) );
}
}
@@ -4970,7 +5109,7 @@ Color SwWW8ImplReader::ExtractColour(const sal_uInt8* &rpData, bool bVer67)
OSL_ENSURE(nBack == COL_AUTO || !nBack.IsTransparent(),
"ww8: don't know what to do with such a transparent bg colour, report");
SwWW8Shade aShade(nFore, nBack, nIndex);
- return aShade.aColor;
+ return aShade.m_aColor;
}
void SwWW8ImplReader::Read_TextVerticalAdjustment( sal_uInt16, const sal_uInt8* pData, short nLen )
@@ -5034,8 +5173,7 @@ void SwWW8ImplReader::Read_Border(sal_uInt16 , const sal_uInt8*, short nLen)
// even if no border is set, the attribute has to be set,
// otherwise it's not possible to turn off the style attribute.
- const SvxBoxItem* pBox
- = static_cast<const SvxBoxItem*>(GetFormatAttr( RES_BOX ));
+ const SvxBoxItem* pBox = GetFormatAttr( RES_BOX );
std::shared_ptr<SvxBoxItem> aBox(std::make_shared<SvxBoxItem>(RES_BOX));
if (pBox)
aBox.reset(pBox->Clone());
@@ -5047,16 +5185,16 @@ void SwWW8ImplReader::Read_Border(sal_uInt16 , const sal_uInt8*, short nLen)
GetBorderDistance( aBrcs, aInnerDist );
if (nBorder & (1 << WW8_LEFT))
- aBox->SetDistance( static_cast<sal_uInt16>(aInnerDist.Left()), SvxBoxItemLine::LEFT );
+ aBox->SetDistance( o3tl::narrowing<sal_uInt16>(aInnerDist.Left()), SvxBoxItemLine::LEFT );
if (nBorder & (1 << WW8_TOP))
- aBox->SetDistance( static_cast<sal_uInt16>(aInnerDist.Top()), SvxBoxItemLine::TOP );
+ aBox->SetDistance( o3tl::narrowing<sal_uInt16>(aInnerDist.Top()), SvxBoxItemLine::TOP );
if (nBorder & (1 << WW8_RIGHT))
- aBox->SetDistance( static_cast<sal_uInt16>(aInnerDist.Right()), SvxBoxItemLine::RIGHT );
+ aBox->SetDistance( o3tl::narrowing<sal_uInt16>(aInnerDist.Right()), SvxBoxItemLine::RIGHT );
if (nBorder & (1 << WW8_BOT))
- aBox->SetDistance( static_cast<sal_uInt16>(aInnerDist.Bottom()), SvxBoxItemLine::BOTTOM );
+ aBox->SetDistance( o3tl::narrowing<sal_uInt16>(aInnerDist.Bottom()), SvxBoxItemLine::BOTTOM );
NewAttr( *aBox );
@@ -5083,8 +5221,7 @@ void SwWW8ImplReader::Read_CharBorder(sal_uInt16 nId, const sal_uInt8* pData, sh
}
else
{
- const SvxBoxItem* pBox
- = static_cast<const SvxBoxItem*>(GetFormatAttr( RES_CHRATR_BOX ));
+ const SvxBoxItem* pBox = GetFormatAttr( RES_CHRATR_BOX );
if( pBox )
{
std::unique_ptr<SvxBoxItem> aBoxItem(pBox->Clone());
@@ -5116,8 +5253,7 @@ void SwWW8ImplReader::Read_Hyphenation( sal_uInt16, const sal_uInt8* pData, shor
m_xCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_PARATR_HYPHENZONE );
else
{
- SvxHyphenZoneItem aAttr(
- *static_cast<const SvxHyphenZoneItem*>(GetFormatAttr( RES_PARATR_HYPHENZONE ) ));
+ SvxHyphenZoneItem aAttr( *GetFormatAttr( RES_PARATR_HYPHENZONE ) );
aAttr.SetHyphen( 0 == *pData ); // sic !
@@ -5248,27 +5384,34 @@ bool SwWW8ImplReader::ParseTabPos(WW8_TablePos *pTabPos, WW8PLCFx_Cp_FKP* pPap)
SprmResult aRes = pPap->HasSprm(NS_sprm::TPc::val);
if (aRes.pSprm && aRes.nRemainingData >= 1)
{
- pTabPos->nSp29 = *aRes.pSprm;
- pTabPos->nSp37 = 2; //Possible fail area, always parallel wrap
+ pTabPos->nTPc = *aRes.pSprm;
+ pTabPos->nPWr = 2; //Possible fail area, always parallel wrap
aRes = pPap->HasSprm(NS_sprm::TDxaAbs::val);
if (aRes.pSprm && aRes.nRemainingData >= 2)
- pTabPos->nSp26 = SVBT16ToUInt16(aRes.pSprm);
+ pTabPos->nTDxaAbs = SVBT16ToUInt16(aRes.pSprm);
aRes = pPap->HasSprm(NS_sprm::TDyaAbs::val);
if (aRes.pSprm && aRes.nRemainingData >= 2)
- pTabPos->nSp27 = SVBT16ToUInt16(aRes.pSprm);
+ pTabPos->nTDyaAbs = SVBT16ToUInt16(aRes.pSprm);
aRes = pPap->HasSprm(NS_sprm::TDxaFromText::val);
if (aRes.pSprm && aRes.nRemainingData >= 2)
- pTabPos->nLeMgn = SVBT16ToUInt16(aRes.pSprm);
+ pTabPos->nLeftMargin = SVBT16ToUInt16(aRes.pSprm);
aRes = pPap->HasSprm(NS_sprm::TDxaFromTextRight::val);
if (aRes.pSprm && aRes.nRemainingData >= 2)
- pTabPos->nRiMgn = SVBT16ToUInt16(aRes.pSprm);
+ pTabPos->nRightMargin = SVBT16ToUInt16(aRes.pSprm);
aRes = pPap->HasSprm(NS_sprm::TDyaFromText::val);
if (aRes.pSprm && aRes.nRemainingData >= 2)
- pTabPos->nUpMgn = SVBT16ToUInt16(aRes.pSprm);
+ pTabPos->nUpperMargin = SVBT16ToUInt16(aRes.pSprm);
aRes = pPap->HasSprm(NS_sprm::TDyaFromTextBottom::val);
if (aRes.pSprm && aRes.nRemainingData >= 2)
- pTabPos->nLoMgn = SVBT16ToUInt16(aRes.pSprm);
- pTabPos->bNoFly = !FloatingTableConversion(pPap);
+ pTabPos->nLowerMargin = SVBT16ToUInt16(aRes.pSprm);
+
+ aRes = pPap->HasSprm(NS_sprm::TFNoAllowOverlap::val);
+ if (aRes.pSprm)
+ {
+ // Remember the no-overlap request, to be consumed in SwWW8ImplReader::StartApo().
+ pTabPos->nTFNoAllowOverlap = *aRes.pSprm;
+ }
+
bRet = true;
}
return bRet;
@@ -6073,6 +6216,7 @@ static const wwSprmDispatcher *GetWW8SprmDispatcher()
{NS_sprm::PFDyaBeforeAuto::val, &SwWW8ImplReader::Read_ParaAutoBefore},
{NS_sprm::PFDyaAfterAuto::val, &SwWW8ImplReader::Read_ParaAutoAfter},
{NS_sprm::PFContextualSpacing::val, &SwWW8ImplReader::Read_ParaContextualSpacing},
+ {NS_sprm::CLbcCRJ::val, &SwWW8ImplReader::Read_LineBreakClear},
};
static wwSprmDispatcher aSprmSrch(aSprms, SAL_N_ELEMENTS(aSprms));
@@ -6120,14 +6264,14 @@ void SwWW8ImplReader::EndSprm( sal_uInt16 nId )
short SwWW8ImplReader::ImportSprm(const sal_uInt8* pPos, sal_Int32 nMemLen, sal_uInt16 nId)
{
if (!nId)
- nId = m_xSprmParser->GetSprmId(pPos);
+ nId = m_oSprmParser->GetSprmId(pPos);
OSL_ENSURE( nId != 0xff, "Sprm FF !!!!" );
const SprmReadInfo& rSprm = GetSprmReadInfo(nId);
- sal_Int32 nFixedLen = m_xSprmParser->DistanceToData(nId);
- sal_Int32 nL = m_xSprmParser->GetSprmSize(nId, pPos, nMemLen);
+ sal_Int32 nFixedLen = m_oSprmParser->DistanceToData(nId);
+ sal_Int32 nL = m_oSprmParser->GetSprmSize(nId, pPos, nMemLen);
if (rSprm.pReadFnc)
(this->*rSprm.pReadFnc)(nId, pPos + nFixedLen, nL - nFixedLen);
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index c37ccf2d1470..80f9102dcb1b 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -44,10 +44,6 @@
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
-#ifdef DEBUGSPRMREADER
-#include <stdio.h>
-#endif
-
using namespace ::com::sun::star::lang;
namespace
@@ -63,7 +59,7 @@ namespace
bool TestBeltAndBraces(SvStream& rStrm)
{
bool bRet = false;
- sal_uInt32 nOldPos = rStrm.Tell();
+ sal_uInt64 nOldPos = rStrm.Tell();
sal_uInt16 nBelt(0);
rStrm.ReadUInt16( nBelt );
nBelt *= sizeof(sal_Unicode);
@@ -216,7 +212,7 @@ const wwSprmSearcher *wwSprmParser::GetWW2SprmSearcher()
{147, { 2, L_FIX} }, // "sprmTDxaLeft" tap.rgdxaCenter dxa word
{148, { 2, L_FIX} }, // "sprmTDxaGapHalf" tap.dxaGapHalf, tap.rgdxaCenter
{149, { 1, L_FIX} }, // "sprmTFBiDi" ;;;
- {152, { 0, L_VAR} }, // "sprmTDefTable10" tap.rgdxaCenter, tap.rgtc complex
+ {152, { 0, L_VAR2} },// "sprmTDefTable10" tap.rgdxaCenter, tap.rgtc complex
{153, { 2, L_FIX} }, // "sprmTDyaRowHeight" tap.dyaRowHeight dya word
{154, { 0, L_VAR2} },// "sprmTDefTable" tap.rgtc complex
{155, { 1, L_VAR} }, // "sprmTDefTableShd" tap.rgshd complex
@@ -397,7 +393,7 @@ const wwSprmSearcher *wwSprmParser::GetWW6SprmSearcher(const WW8Fib& rFib)
{NS_sprm::v6::sprmTFCantSplit, { 1, L_FIX} }, // tap.fCantSplit 1 or 0 byte
{NS_sprm::v6::sprmTTableHeader, { 1, L_FIX} }, // tap.fTableHeader 1 or 0 byte
{NS_sprm::v6::sprmTTableBorders, {12, L_FIX} }, // tap.rgbrcTable complex 12 bytes
- {NS_sprm::v6::sprmTDefTable10, { 0, L_VAR} }, // tap.rgdxaCenter, tap.rgtc complex
+ {NS_sprm::v6::sprmTDefTable10, { 0, L_VAR2} }, // tap.rgdxaCenter, tap.rgtc complex
{NS_sprm::v6::sprmTDyaRowHeight, { 2, L_FIX} }, // tap.dyaRowHeight dya word
{NS_sprm::v6::sprmTDefTable, { 0, L_VAR2} }, // tap.rgtc complex
{NS_sprm::v6::sprmTDefTableShd, { 1, L_VAR} }, // tap.rgshd complex
@@ -701,10 +697,10 @@ const wwSprmSearcher *wwSprmParser::GetWW8SprmSearcher()
InfoRow<NS_sprm::TTableHeader>(), // tap.fTableHeader;1 or 0;byte;
InfoRow<NS_sprm::TFCantSplit>(), // tap.fCantSplit;1 or 0;byte;
InfoRow<NS_sprm::TTableBorders80>(), // tap.rgbrcTable;complex
- {NS_sprm::LN_TDefTable10, { 0, L_VAR} }, // "sprmTDefTable10" tap.rgdxaCenter,
+ {NS_sprm::LN_TDefTable10, { 0, L_VAR2} }, // "sprmTDefTable10" tap.rgdxaCenter,
// tap.rgtc;complex
InfoRow<NS_sprm::TDyaRowHeight>(), // tap.dyaRowHeight;dya;word;
- InfoRow<NS_sprm::TDefTable>(), // tap.rgtc;complex
+ {NS_sprm::LN_TDefTable, { 0, L_VAR2} }, // "sprmTDefTable" tap.rgtc;complex
InfoRow<NS_sprm::TDefTableShd80>(), // tap.rgshd;complex
InfoRow<NS_sprm::TTlp>(), // tap.tlp;TLP;4 bytes;
InfoRow<NS_sprm::TFBiDi>(), // ;;;
@@ -874,50 +870,50 @@ static sal_Int32 Get_Long( sal_uInt8 *& p )
WW8SprmIter::WW8SprmIter(const sal_uInt8* pSprms_, sal_Int32 nLen_,
const wwSprmParser &rParser)
- : mrSprmParser(rParser), pSprms( pSprms_), nRemLen( nLen_)
+ : mrSprmParser(rParser), m_pSprms( pSprms_), m_nRemLen( nLen_)
{
UpdateMyMembers();
}
void WW8SprmIter::SetSprms(const sal_uInt8* pSprms_, sal_Int32 nLen_)
{
- pSprms = pSprms_;
- nRemLen = nLen_;
+ m_pSprms = pSprms_;
+ m_nRemLen = nLen_;
UpdateMyMembers();
}
void WW8SprmIter::advance()
{
- if (nRemLen > 0 )
+ if (m_nRemLen > 0 )
{
- sal_uInt16 nSize = nCurrentSize;
- if (nSize > nRemLen)
- nSize = nRemLen;
- pSprms += nSize;
- nRemLen -= nSize;
+ sal_uInt16 nSize = m_nCurrentSize;
+ if (nSize > m_nRemLen)
+ nSize = m_nRemLen;
+ m_pSprms += nSize;
+ m_nRemLen -= nSize;
UpdateMyMembers();
}
}
void WW8SprmIter::UpdateMyMembers()
{
- bool bValid = (pSprms && nRemLen >= mrSprmParser.MinSprmLen());
+ bool bValid = (m_pSprms && m_nRemLen >= mrSprmParser.MinSprmLen());
if (bValid)
{
- nCurrentId = mrSprmParser.GetSprmId(pSprms);
- nCurrentSize = mrSprmParser.GetSprmSize(nCurrentId, pSprms, nRemLen);
- pCurrentParams = pSprms + mrSprmParser.DistanceToData(nCurrentId);
- bValid = nCurrentSize <= nRemLen;
+ m_nCurrentId = mrSprmParser.GetSprmId(m_pSprms);
+ m_nCurrentSize = mrSprmParser.GetSprmSize(m_nCurrentId, m_pSprms, m_nRemLen);
+ m_pCurrentParams = m_pSprms + mrSprmParser.DistanceToData(m_nCurrentId);
+ bValid = m_nCurrentSize <= m_nRemLen;
SAL_WARN_IF(!bValid, "sw.ww8", "sprm longer than remaining bytes, doc or parser is wrong");
}
if (!bValid)
{
- nCurrentId = 0;
- pCurrentParams = nullptr;
- nCurrentSize = 0;
- nRemLen = 0;
+ m_nCurrentId = 0;
+ m_pCurrentParams = nullptr;
+ m_nCurrentSize = 0;
+ m_nRemLen = 0;
}
}
@@ -952,8 +948,8 @@ SprmResult WW8SprmIter::FindSprm(sal_uInt16 nId, bool bFindFirst, const sal_uInt
// All methods relating to iterators are therefore dummies.
WW8PLCFx_PCDAttrs::WW8PLCFx_PCDAttrs(const WW8Fib& rFib,
WW8PLCFx_PCD* pPLCFx_PCD, const WW8ScannerBase* pBase)
- : WW8PLCFx(rFib, true), pPcdI(pPLCFx_PCD->GetPLCFIter()),
- pPcd(pPLCFx_PCD), mrGrpprls(pBase->m_aPieceGrpprls)
+ : WW8PLCFx(rFib, true), m_pPcdI(pPLCFx_PCD->GetPLCFIter()),
+ m_pPcd(pPLCFx_PCD), mrGrpprls(pBase->m_aPieceGrpprls)
{
}
@@ -977,7 +973,7 @@ void WW8PLCFx_PCDAttrs::advance()
WW8_CP WW8PLCFx_PCDAttrs::Where()
{
- return pPcd ? pPcd->Where() : WW8_CP_MAX;
+ return m_pPcd ? m_pPcd->Where() : WW8_CP_MAX;
}
void WW8PLCFx_PCDAttrs::GetSprms(WW8PLCFxDesc* p)
@@ -985,7 +981,7 @@ void WW8PLCFx_PCDAttrs::GetSprms(WW8PLCFxDesc* p)
void* pData;
p->bRealLineEnd = false;
- if ( !pPcdI || !pPcdI->Get(p->nStartPos, p->nEndPos, pData) )
+ if ( !m_pPcdI || !m_pPcdI->Get(p->nStartPos, p->nEndPos, pData) )
{
// PLCF fully processed
p->nStartPos = p->nEndPos = WW8_CP_MAX;
@@ -1023,12 +1019,12 @@ void WW8PLCFx_PCDAttrs::GetSprms(WW8PLCFxDesc* p)
if (IsSevenMinus(GetFIBVersion()))
{
- aShortSprm[0] = static_cast<sal_uInt8>( ( nPrm & 0xfe) >> 1 );
- aShortSprm[1] = static_cast<sal_uInt8>( nPrm >> 8 );
+ m_aShortSprm[0] = static_cast<sal_uInt8>( ( nPrm & 0xfe) >> 1 );
+ m_aShortSprm[1] = static_cast<sal_uInt8>( nPrm >> 8 );
p->nSprmsLen = nPrm ? 2 : 0; // length
// store Position of internal mini storage in Data Pointer
- p->pMemPos = aShortSprm;
+ p->pMemPos = m_aShortSprm;
}
else
{
@@ -1120,15 +1116,15 @@ void WW8PLCFx_PCDAttrs::GetSprms(WW8PLCFxDesc* p)
if( nSprmId )
{
// move Sprm Id and Sprm Param to internal mini storage:
- aShortSprm[0] = static_cast<sal_uInt8>( nSprmId & 0x00ff) ;
- aShortSprm[1] = static_cast<sal_uInt8>( ( nSprmId & 0xff00) >> 8 );
- aShortSprm[2] = static_cast<sal_uInt8>( nPrm >> 8 );
+ m_aShortSprm[0] = static_cast<sal_uInt8>( nSprmId & 0x00ff) ;
+ m_aShortSprm[1] = static_cast<sal_uInt8>( ( nSprmId & 0xff00) >> 8 );
+ m_aShortSprm[2] = static_cast<sal_uInt8>( nPrm >> 8 );
// store Sprm Length in member:
p->nSprmsLen = nPrm ? 3 : 0;
// store Position of internal mini storage in Data Pointer
- p->pMemPos = aShortSprm;
+ p->pMemPos = m_aShortSprm;
}
}
}
@@ -1137,11 +1133,11 @@ void WW8PLCFx_PCDAttrs::GetSprms(WW8PLCFxDesc* p)
WW8PLCFx_PCD::WW8PLCFx_PCD(const WW8Fib& rFib, WW8PLCFpcd* pPLCFpcd,
WW8_CP nStartCp, bool bVer67P)
- : WW8PLCFx(rFib, false), nClipStart(-1)
+ : WW8PLCFx(rFib, false), m_nClipStart(-1)
{
// construct own iterator
- pPcdI.reset( new WW8PLCFpcd_Iter(*pPLCFpcd, nStartCp) );
- bVer67= bVer67P;
+ m_pPcdI.reset( new WW8PLCFpcd_Iter(*pPLCFpcd, nStartCp) );
+ m_bVer67= bVer67P;
}
WW8PLCFx_PCD::~WW8PLCFx_PCD()
@@ -1150,28 +1146,28 @@ WW8PLCFx_PCD::~WW8PLCFx_PCD()
sal_uInt32 WW8PLCFx_PCD::GetIMax() const
{
- return pPcdI ? pPcdI->GetIMax() : 0;
+ return m_pPcdI ? m_pPcdI->GetIMax() : 0;
}
sal_uInt32 WW8PLCFx_PCD::GetIdx() const
{
- return pPcdI ? pPcdI->GetIdx() : 0;
+ return m_pPcdI ? m_pPcdI->GetIdx() : 0;
}
void WW8PLCFx_PCD::SetIdx(sal_uInt32 nIdx)
{
- if (pPcdI)
- pPcdI->SetIdx( nIdx );
+ if (m_pPcdI)
+ m_pPcdI->SetIdx( nIdx );
}
bool WW8PLCFx_PCD::SeekPos(WW8_CP nCpPos)
{
- return pPcdI && pPcdI->SeekPos( nCpPos );
+ return m_pPcdI && m_pPcdI->SeekPos( nCpPos );
}
WW8_CP WW8PLCFx_PCD::Where()
{
- return pPcdI ? pPcdI->Where() : WW8_CP_MAX;
+ return m_pPcdI ? m_pPcdI->Where() : WW8_CP_MAX;
}
tools::Long WW8PLCFx_PCD::GetNoSprms( WW8_CP& rStart, WW8_CP& rEnd, sal_Int32& rLen )
@@ -1179,19 +1175,19 @@ tools::Long WW8PLCFx_PCD::GetNoSprms( WW8_CP& rStart, WW8_CP& rEnd, sal_Int32& r
void* pData;
rLen = 0;
- if ( !pPcdI || !pPcdI->Get(rStart, rEnd, pData) )
+ if ( !m_pPcdI || !m_pPcdI->Get(rStart, rEnd, pData) )
{
rStart = rEnd = WW8_CP_MAX;
return -1;
}
- return pPcdI->GetIdx();
+ return m_pPcdI->GetIdx();
}
void WW8PLCFx_PCD::advance()
{
- OSL_ENSURE(pPcdI , "missing pPcdI");
- if (pPcdI)
- pPcdI->advance();
+ OSL_ENSURE(m_pPcdI , "missing pPcdI");
+ if (m_pPcdI)
+ m_pPcdI->advance();
}
WW8_FC WW8PLCFx_PCD::CurrentPieceStartCp2Fc( WW8_CP nCp )
@@ -1199,7 +1195,7 @@ WW8_FC WW8PLCFx_PCD::CurrentPieceStartCp2Fc( WW8_CP nCp )
WW8_CP nCpStart, nCpEnd;
void* pData;
- if ( !pPcdI->Get(nCpStart, nCpEnd, pData) )
+ if ( !m_pPcdI->Get(nCpStart, nCpEnd, pData) )
{
OSL_ENSURE( false, "CurrentPieceStartCp2Fc() with false Cp found (1)" );
return WW8_FC_MAX;
@@ -1215,7 +1211,7 @@ WW8_FC WW8PLCFx_PCD::CurrentPieceStartCp2Fc( WW8_CP nCp )
bool bIsUnicode = false;
WW8_FC nFC = SVBT32ToUInt32( static_cast<WW8_PCD*>(pData)->fc );
- if( !bVer67 )
+ if( !m_bVer67 )
nFC = WW8PLCFx_PCD::TransformPieceAddress( nFC, bIsUnicode );
WW8_CP nDistance;
@@ -1262,14 +1258,14 @@ WW8_CP WW8PLCFx_PCD::CurrentPieceStartFc2Cp( WW8_FC nStartPos )
{
WW8_CP nCpStart, nCpEnd;
void* pData;
- if ( !pPcdI->Get( nCpStart, nCpEnd, pData ) )
+ if ( !m_pPcdI->Get( nCpStart, nCpEnd, pData ) )
{
OSL_ENSURE( false, "CurrentPieceStartFc2Cp() - error" );
return WW8_CP_MAX;
}
bool bIsUnicode = false;
sal_Int32 nFcStart = SVBT32ToUInt32( static_cast<WW8_PCD*>(pData)->fc );
- if( !bVer67 )
+ if( !m_bVer67 )
nFcStart = WW8PLCFx_PCD::TransformPieceAddress( nFcStart, bIsUnicode );
sal_Int32 nUnicodeFactor = bIsUnicode ? 2 : 1;
@@ -2137,7 +2133,7 @@ sal_Int32 WW8ScannerBase::WW8ReadString( SvStream& rStrm, OUString& rStr,
WW8PLCFspecial::WW8PLCFspecial(SvStream* pSt, sal_uInt32 nFilePos,
sal_uInt32 nPLCF, sal_uInt32 nStruct)
- : nIdx(0), nStru(nStruct)
+ : m_nIdx(0), m_nStru(nStruct)
{
const sal_uInt32 nValidMin=4;
@@ -2150,23 +2146,23 @@ WW8PLCFspecial::WW8PLCFspecial(SvStream* pSt, sal_uInt32 nFilePos,
nPLCF = bValid ? std::min(nRemainingSize, static_cast<std::size_t>(nPLCF)) : nValidMin;
// Pointer to Pos- and Struct-array
- pPLCF_PosArray.reset( new sal_Int32[ ( nPLCF + 3 ) / 4 ] );
- pPLCF_PosArray[0] = 0;
+ m_pPLCF_PosArray.reset( new sal_Int32[ ( nPLCF + 3 ) / 4 ] );
+ m_pPLCF_PosArray[0] = 0;
- nPLCF = bValid ? pSt->ReadBytes(pPLCF_PosArray.get(), nPLCF) : nValidMin;
+ nPLCF = bValid ? pSt->ReadBytes(m_pPLCF_PosArray.get(), nPLCF) : nValidMin;
nPLCF = std::max(nPLCF, nValidMin);
- nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
+ m_nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
#ifdef OSL_BIGENDIAN
- for( nIdx = 0; nIdx <= nIMax; nIdx++ )
- pPLCF_PosArray[nIdx] = OSL_SWAPDWORD( pPLCF_PosArray[nIdx] );
- nIdx = 0;
+ for( m_nIdx = 0; m_nIdx <= m_nIMax; m_nIdx++ )
+ m_pPLCF_PosArray[m_nIdx] = OSL_SWAPDWORD( m_pPLCF_PosArray[m_nIdx] );
+ m_nIdx = 0;
#endif // OSL_BIGENDIAN
if( nStruct ) // Pointer to content array
- pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&pPLCF_PosArray[nIMax + 1]);
+ m_pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&m_pPLCF_PosArray[m_nIMax + 1]);
else
- pPLCF_Contents = nullptr; // no content
+ m_pPLCF_Contents = nullptr; // no content
pSt->Seek(nOldPos);
}
@@ -2177,33 +2173,33 @@ WW8PLCFspecial::WW8PLCFspecial(SvStream* pSt, sal_uInt32 nFilePos,
// the position nPos.
bool WW8PLCFspecial::SeekPos(tools::Long nP)
{
- if( nP < pPLCF_PosArray[0] )
+ if( nP < m_pPLCF_PosArray[0] )
{
- nIdx = 0;
+ m_nIdx = 0;
return false; // Not found: nP less than smallest entry
}
// Search from beginning?
- if ((nIdx < 1) || (nP < pPLCF_PosArray[nIdx - 1]))
- nIdx = 1;
+ if ((m_nIdx < 1) || (nP < m_pPLCF_PosArray[m_nIdx - 1]))
+ m_nIdx = 1;
- tools::Long nI = nIdx;
- tools::Long nEnd = nIMax;
+ tools::Long nI = m_nIdx;
+ tools::Long nEnd = m_nIMax;
- for(int n = (1==nIdx ? 1 : 2); n; --n )
+ for(int n = (1==m_nIdx ? 1 : 2); n; --n )
{
for( ; nI <=nEnd; ++nI)
{ // search with an index that is incremented by 1
- if( nP < pPLCF_PosArray[nI] )
+ if( nP < m_pPLCF_PosArray[nI] )
{ // found position
- nIdx = nI - 1; // nI - 1 is the correct index
+ m_nIdx = nI - 1; // nI - 1 is the correct index
return true; // done
}
}
nI = 1;
- nEnd = nIdx-1;
+ nEnd = m_nIdx-1;
}
- nIdx = nIMax; // not found, greater than all entries
+ m_nIdx = m_nIMax; // not found, greater than all entries
return false;
}
@@ -2212,49 +2208,49 @@ bool WW8PLCFspecial::SeekPos(tools::Long nP)
// Is used for fields and bookmarks.
bool WW8PLCFspecial::SeekPosExact(tools::Long nP)
{
- if( nP < pPLCF_PosArray[0] )
+ if( nP < m_pPLCF_PosArray[0] )
{
- nIdx = 0;
+ m_nIdx = 0;
return false; // Not found: nP less than smallest entry
}
// Search from beginning?
- if( nP <=pPLCF_PosArray[nIdx] )
- nIdx = 0;
+ if( nP <=m_pPLCF_PosArray[m_nIdx] )
+ m_nIdx = 0;
- tools::Long nI = nIdx ? nIdx-1 : 0;
- tools::Long nEnd = nIMax;
+ tools::Long nI = m_nIdx ? m_nIdx-1 : 0;
+ tools::Long nEnd = m_nIMax;
- for(int n = (0==nIdx ? 1 : 2); n; --n )
+ for(int n = (0==m_nIdx ? 1 : 2); n; --n )
{
for( ; nI < nEnd; ++nI)
{
- if( nP <=pPLCF_PosArray[nI] )
+ if( nP <=m_pPLCF_PosArray[nI] )
{ // found position
- nIdx = nI; // nI is the correct index
+ m_nIdx = nI; // nI is the correct index
return true; // done
}
}
nI = 0;
- nEnd = nIdx;
+ nEnd = m_nIdx;
}
- nIdx = nIMax; // Not found, greater than all entries
+ m_nIdx = m_nIMax; // Not found, greater than all entries
return false;
}
bool WW8PLCFspecial::Get(WW8_CP& rPos, void*& rpValue) const
{
- return GetData( nIdx, rPos, rpValue );
+ return GetData( m_nIdx, rPos, rpValue );
}
bool WW8PLCFspecial::GetData(tools::Long nInIdx, WW8_CP& rPos, void*& rpValue) const
{
- if ( nInIdx >= nIMax )
+ if ( nInIdx >= m_nIMax )
{
rPos = WW8_CP_MAX;
return false;
}
- rPos = pPLCF_PosArray[nInIdx];
- rpValue = pPLCF_Contents ? static_cast<void*>(&pPLCF_Contents[nInIdx * nStru]) : nullptr;
+ rPos = m_pPLCF_PosArray[nInIdx];
+ rpValue = m_pPLCF_Contents ? static_cast<void*>(&m_pPLCF_Contents[nInIdx * m_nStru]) : nullptr;
return true;
}
@@ -2262,7 +2258,7 @@ bool WW8PLCFspecial::GetData(tools::Long nInIdx, WW8_CP& rPos, void*& rpValue) c
// Ctor for *others* than Fkps
// With nStartPos < 0, the first element of PLCFs will be taken
WW8PLCF::WW8PLCF(SvStream& rSt, WW8_FC nFilePos, sal_Int32 nPLCF, int nStruct,
- WW8_CP nStartPos) : nIdx(0), nStru(nStruct)
+ WW8_CP nStartPos) : m_nIdx(0), m_nStru(nStruct)
{
if (nPLCF < 0)
{
@@ -2270,7 +2266,7 @@ WW8PLCF::WW8PLCF(SvStream& rSt, WW8_FC nFilePos, sal_Int32 nPLCF, int nStruct,
nPLCF = 0;
}
else
- nIMax = (nPLCF - 4) / (4 + nStruct);
+ m_nIMax = (nPLCF - 4) / (4 + nStruct);
ReadPLCF(rSt, nFilePos, nPLCF);
@@ -2284,18 +2280,18 @@ WW8PLCF::WW8PLCF(SvStream& rSt, WW8_FC nFilePos, sal_Int32 nPLCF, int nStruct,
// lack of resources and for WordPad (W95).
// With nStartPos < 0, the first element of the PLCFs is taken.
WW8PLCF::WW8PLCF(SvStream& rSt, WW8_FC nFilePos, sal_Int32 nPLCF, int nStruct,
- WW8_CP nStartPos, sal_Int32 nPN, sal_Int32 ncpN): nIdx(0),
- nStru(nStruct)
+ WW8_CP nStartPos, sal_Int32 nPN, sal_Int32 ncpN): m_nIdx(0),
+ m_nStru(nStruct)
{
if (nPLCF < 0)
{
SAL_WARN("sw.ww8", "broken WW8PLCF, ignoring");
- nIMax = SAL_MAX_INT32;
+ m_nIMax = SAL_MAX_INT32;
}
else
- nIMax = (nPLCF - 4) / (4 + nStruct);
+ m_nIMax = (nPLCF - 4) / (4 + nStruct);
- if( nIMax >= ncpN )
+ if( m_nIMax >= ncpN )
ReadPLCF(rSt, nFilePos, nPLCF);
else
GeneratePLCF(rSt, nPN, ncpN);
@@ -2313,19 +2309,26 @@ void WW8PLCF::ReadPLCF(SvStream& rSt, WW8_FC nFilePos, sal_uInt32 nPLCF)
if (bValid)
{
// Pointer to Pos-array
- pPLCF_PosArray.reset( new WW8_CP[ ( nPLCF + 3 ) / 4 ] );
- bValid = checkRead(rSt, pPLCF_PosArray.get(), nPLCF);
+ const size_t nEntries = (nPLCF + 3) / 4;
+ m_pPLCF_PosArray.reset(new WW8_CP[nEntries]);
+ bValid = checkRead(rSt, m_pPLCF_PosArray.get(), nPLCF);
+ size_t nBytesAllocated = nEntries * sizeof(WW8_CP);
+ if (bValid && nPLCF != nBytesAllocated)
+ {
+ sal_uInt8* pStartBlock = reinterpret_cast<sal_uInt8*>(m_pPLCF_PosArray.get());
+ memset(pStartBlock + nPLCF, 0, nBytesAllocated - nPLCF);
+ }
}
if (bValid)
{
#ifdef OSL_BIGENDIAN
- for( nIdx = 0; nIdx <= nIMax; nIdx++ )
- pPLCF_PosArray[nIdx] = OSL_SWAPDWORD( pPLCF_PosArray[nIdx] );
- nIdx = 0;
+ for( m_nIdx = 0; m_nIdx <= m_nIMax; m_nIdx++ )
+ m_pPLCF_PosArray[m_nIdx] = OSL_SWAPDWORD( m_pPLCF_PosArray[m_nIdx] );
+ m_nIdx = 0;
#endif // OSL_BIGENDIAN
// Pointer to content array
- pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&pPLCF_PosArray[nIMax + 1]);
+ m_pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&m_pPLCF_PosArray[m_nIMax + 1]);
TruncToSortedRange();
}
@@ -2340,10 +2343,10 @@ void WW8PLCF::ReadPLCF(SvStream& rSt, WW8_FC nFilePos, sal_uInt32 nPLCF)
void WW8PLCF::MakeFailedPLCF()
{
- nIMax = 0;
- pPLCF_PosArray.reset( new WW8_CP[2] );
- pPLCF_PosArray[0] = pPLCF_PosArray[1] = WW8_CP_MAX;
- pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&pPLCF_PosArray[nIMax + 1]);
+ m_nIMax = 0;
+ m_pPLCF_PosArray.reset( new WW8_CP[2] );
+ m_pPLCF_PosArray[0] = m_pPLCF_PosArray[1] = WW8_CP_MAX;
+ m_pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&m_pPLCF_PosArray[m_nIMax + 1]);
}
namespace
@@ -2367,22 +2370,22 @@ namespace
void WW8PLCFpcd::TruncToSortedRange()
{
- nIMax = ::TruncToSortedRange(pPLCF_PosArray.get(), nIMax);
+ m_nIMax = ::TruncToSortedRange(m_pPLCF_PosArray.get(), m_nIMax);
}
void WW8PLCF::TruncToSortedRange()
{
- nIMax = ::TruncToSortedRange(pPLCF_PosArray.get(), nIMax);
+ m_nIMax = ::TruncToSortedRange(m_pPLCF_PosArray.get(), m_nIMax);
}
void WW8PLCF::GeneratePLCF(SvStream& rSt, sal_Int32 nPN, sal_Int32 ncpN)
{
- OSL_ENSURE( nIMax < ncpN, "Pcl.Fkp: Why is PLCF too big?" );
+ OSL_ENSURE( m_nIMax < ncpN, "Pcl.Fkp: Why is PLCF too big?" );
bool failure = false;
- nIMax = ncpN;
+ m_nIMax = ncpN;
- if ((nIMax < 1) || (nIMax > (WW8_CP_MAX - 4) / (4 + nStru)) || nPN < 0)
+ if ((m_nIMax < 1) || (m_nIMax > (WW8_CP_MAX - 4) / (4 + m_nStru)) || nPN < 0)
failure = true;
if (!failure)
@@ -2394,9 +2397,9 @@ void WW8PLCF::GeneratePLCF(SvStream& rSt, sal_Int32 nPN, sal_Int32 ncpN)
if (!failure)
{
- size_t nSiz = (4 + nStru) * nIMax + 4;
+ size_t nSiz = (4 + m_nStru) * m_nIMax + 4;
size_t nElems = ( nSiz + 3 ) / 4;
- pPLCF_PosArray.reset( new WW8_CP[ nElems ] ); // Pointer to Pos-array
+ m_pPLCF_PosArray.reset( new WW8_CP[ nElems ] ); // Pointer to Pos-array
for (sal_Int32 i = 0; i < ncpN && !failure; ++i)
{
@@ -2408,7 +2411,7 @@ void WW8PLCF::GeneratePLCF(SvStream& rSt, sal_Int32 nPN, sal_Int32 ncpN)
WW8_CP nFc(0);
rSt.ReadInt32( nFc );
- pPLCF_PosArray[i] = nFc;
+ m_pPLCF_PosArray[i] = nFc;
failure = bool(rSt.GetError());
}
@@ -2420,7 +2423,7 @@ void WW8PLCF::GeneratePLCF(SvStream& rSt, sal_Int32 nPN, sal_Int32 ncpN)
{
failure = true;
- std::size_t nLastFkpPos = nPN + nIMax - 1;
+ std::size_t nLastFkpPos = nPN + m_nIMax - 1;
nLastFkpPos = nLastFkpPos << 9;
// number of FC entries of last Fkp
if (!checkSeek(rSt, nLastFkpPos + 511))
@@ -2434,7 +2437,7 @@ void WW8PLCF::GeneratePLCF(SvStream& rSt, sal_Int32 nPN, sal_Int32 ncpN)
WW8_CP nFc(0);
rSt.ReadInt32( nFc );
- pPLCF_PosArray[nIMax] = nFc; // end of the last Fkp
+ m_pPLCF_PosArray[m_nIMax] = nFc; // end of the last Fkp
failure = bool(rSt.GetError());
} while(false);
@@ -2443,13 +2446,13 @@ void WW8PLCF::GeneratePLCF(SvStream& rSt, sal_Int32 nPN, sal_Int32 ncpN)
if (!failure)
{
// Pointer to content array
- pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&pPLCF_PosArray[nIMax + 1]);
- sal_uInt8* p = pPLCF_Contents;
+ m_pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&m_pPLCF_PosArray[m_nIMax + 1]);
+ sal_uInt8* p = m_pPLCF_Contents;
for (sal_Int32 i = 0; i < ncpN; ++i) // construct PNs
{
- ShortToSVBT16(static_cast<sal_uInt16>(nPN + i), p);
- p += nStru;
+ ShortToSVBT16(o3tl::narrowing<sal_uInt16>(nPN + i), p);
+ p += m_nStru;
}
}
@@ -2463,62 +2466,62 @@ bool WW8PLCF::SeekPos(WW8_CP nPos)
{
WW8_CP nP = nPos;
- if( nP < pPLCF_PosArray[0] )
+ if( nP < m_pPLCF_PosArray[0] )
{
- nIdx = 0;
+ m_nIdx = 0;
// not found: nPos less than smallest entry
return false;
}
// Search from beginning?
- if ((nIdx < 1) || (nP < pPLCF_PosArray[nIdx - 1]))
- nIdx = 1;
+ if ((m_nIdx < 1) || (nP < m_pPLCF_PosArray[m_nIdx - 1]))
+ m_nIdx = 1;
- sal_Int32 nI = nIdx;
- sal_Int32 nEnd = nIMax;
+ sal_Int32 nI = m_nIdx;
+ sal_Int32 nEnd = m_nIMax;
- for(int n = (1==nIdx ? 1 : 2); n; --n )
+ for(int n = (1==m_nIdx ? 1 : 2); n; --n )
{
for( ; nI <=nEnd; ++nI) // search with an index that is incremented by 1
{
- if( nP < pPLCF_PosArray[nI] ) // found position
+ if( nP < m_pPLCF_PosArray[nI] ) // found position
{
- nIdx = nI - 1; // nI - 1 is the correct index
+ m_nIdx = nI - 1; // nI - 1 is the correct index
return true; // done
}
}
nI = 1;
- nEnd = nIdx-1;
+ nEnd = m_nIdx-1;
}
- nIdx = nIMax; // not found, greater than all entries
+ m_nIdx = m_nIMax; // not found, greater than all entries
return false;
}
bool WW8PLCF::Get(WW8_CP& rStart, WW8_CP& rEnd, void*& rpValue) const
{
- if ( nIdx >= nIMax )
+ if ( m_nIdx >= m_nIMax )
{
rStart = rEnd = WW8_CP_MAX;
return false;
}
- rStart = pPLCF_PosArray[ nIdx ];
- rEnd = pPLCF_PosArray[ nIdx + 1 ];
- rpValue = static_cast<void*>(&pPLCF_Contents[nIdx * nStru]);
+ rStart = m_pPLCF_PosArray[ m_nIdx ];
+ rEnd = m_pPLCF_PosArray[ m_nIdx + 1 ];
+ rpValue = static_cast<void*>(&m_pPLCF_Contents[m_nIdx * m_nStru]);
return true;
}
WW8_CP WW8PLCF::Where() const
{
- if ( nIdx >= nIMax )
+ if ( m_nIdx >= m_nIMax )
return WW8_CP_MAX;
- return pPLCF_PosArray[nIdx];
+ return m_pPLCF_PosArray[m_nIdx];
}
WW8PLCFpcd::WW8PLCFpcd(SvStream* pSt, sal_uInt32 nFilePos,
sal_uInt32 nPLCF, sal_uInt32 nStruct)
- : nStru( nStruct )
+ : m_nStru( nStruct )
{
const sal_uInt32 nValidMin=4;
@@ -2530,20 +2533,20 @@ WW8PLCFpcd::WW8PLCFpcd(SvStream* pSt, sal_uInt32 nFilePos,
bValid = false;
nPLCF = bValid ? std::min(nRemainingSize, static_cast<std::size_t>(nPLCF)) : nValidMin;
- pPLCF_PosArray.reset( new WW8_CP[ ( nPLCF + 3 ) / 4 ] ); // Pointer to Pos-array
- pPLCF_PosArray[0] = 0;
+ m_pPLCF_PosArray.reset( new WW8_CP[ ( nPLCF + 3 ) / 4 ] ); // Pointer to Pos-array
+ m_pPLCF_PosArray[0] = 0;
- nPLCF = bValid ? pSt->ReadBytes(pPLCF_PosArray.get(), nPLCF) : nValidMin;
+ nPLCF = bValid ? pSt->ReadBytes(m_pPLCF_PosArray.get(), nPLCF) : nValidMin;
nPLCF = std::max(nPLCF, nValidMin);
- nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
+ m_nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
#ifdef OSL_BIGENDIAN
- for( tools::Long nI = 0; nI <= nIMax; nI++ )
- pPLCF_PosArray[nI] = OSL_SWAPDWORD( pPLCF_PosArray[nI] );
+ for( tools::Long nI = 0; nI <= m_nIMax; nI++ )
+ m_pPLCF_PosArray[nI] = OSL_SWAPDWORD( m_pPLCF_PosArray[nI] );
#endif // OSL_BIGENDIAN
// Pointer to content array
- pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&pPLCF_PosArray[nIMax + 1]);
+ m_pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&m_pPLCF_PosArray[m_nIMax + 1]);
TruncToSortedRange();
pSt->Seek( nOldPos );
@@ -2551,7 +2554,7 @@ WW8PLCFpcd::WW8PLCFpcd(SvStream* pSt, sal_uInt32 nFilePos,
// If nStartPos < 0, the first element of PLCFs will be taken
WW8PLCFpcd_Iter::WW8PLCFpcd_Iter( WW8PLCFpcd& rPLCFpcd, tools::Long nStartPos )
- :rPLCF( rPLCFpcd ), nIdx( 0 )
+ :m_rPLCF( rPLCFpcd ), m_nIdx( 0 )
{
if( nStartPos >= 0 )
SeekPos( nStartPos );
@@ -2561,54 +2564,54 @@ bool WW8PLCFpcd_Iter::SeekPos(tools::Long nPos)
{
tools::Long nP = nPos;
- if( nP < rPLCF.pPLCF_PosArray[0] )
+ if( nP < m_rPLCF.m_pPLCF_PosArray[0] )
{
- nIdx = 0;
+ m_nIdx = 0;
return false; // not found: nPos less than smallest entry
}
// Search from beginning?
- if ((nIdx < 1) || (nP < rPLCF.pPLCF_PosArray[nIdx - 1]))
- nIdx = 1;
+ if ((m_nIdx < 1) || (nP < m_rPLCF.m_pPLCF_PosArray[m_nIdx - 1]))
+ m_nIdx = 1;
- tools::Long nI = nIdx;
- tools::Long nEnd = rPLCF.nIMax;
+ tools::Long nI = m_nIdx;
+ tools::Long nEnd = m_rPLCF.m_nIMax;
- for(int n = (1==nIdx ? 1 : 2); n; --n )
+ for(int n = (1==m_nIdx ? 1 : 2); n; --n )
{
for( ; nI <=nEnd; ++nI)
{ // search with an index that is incremented by 1
- if( nP < rPLCF.pPLCF_PosArray[nI] )
+ if( nP < m_rPLCF.m_pPLCF_PosArray[nI] )
{ // found position
- nIdx = nI - 1; // nI - 1 is the correct index
+ m_nIdx = nI - 1; // nI - 1 is the correct index
return true; // done
}
}
nI = 1;
- nEnd = nIdx-1;
+ nEnd = m_nIdx-1;
}
- nIdx = rPLCF.nIMax; // not found, greater than all entries
+ m_nIdx = m_rPLCF.m_nIMax; // not found, greater than all entries
return false;
}
bool WW8PLCFpcd_Iter::Get(WW8_CP& rStart, WW8_CP& rEnd, void*& rpValue) const
{
- if( nIdx >= rPLCF.nIMax )
+ if( m_nIdx >= m_rPLCF.m_nIMax )
{
rStart = rEnd = WW8_CP_MAX;
return false;
}
- rStart = rPLCF.pPLCF_PosArray[nIdx];
- rEnd = rPLCF.pPLCF_PosArray[nIdx + 1];
- rpValue = static_cast<void*>(&rPLCF.pPLCF_Contents[nIdx * rPLCF.nStru]);
+ rStart = m_rPLCF.m_pPLCF_PosArray[m_nIdx];
+ rEnd = m_rPLCF.m_pPLCF_PosArray[m_nIdx + 1];
+ rpValue = static_cast<void*>(&m_rPLCF.m_pPLCF_Contents[m_nIdx * m_rPLCF.m_nStru]);
return true;
}
sal_Int32 WW8PLCFpcd_Iter::Where() const
{
- if ( nIdx >= rPLCF.nIMax )
+ if ( m_nIdx >= m_rPLCF.m_nIMax )
return SAL_MAX_INT32;
- return rPLCF.pPLCF_PosArray[nIdx];
+ return m_rPLCF.m_pPLCF_PosArray[m_nIdx];
}
bool WW8PLCFx_Fc_FKP::WW8Fkp::Entry::operator<
@@ -2641,7 +2644,7 @@ void WW8PLCFx_Fc_FKP::WW8Fkp::FillEntry(WW8PLCFx_Fc_FKP::WW8Fkp::Entry &rEntry,
}
const sal_uInt16 nAvailableData = sizeof(maRawData)-nDataOffset;
- OSL_ENSURE(nLen <= nAvailableData, "srpm sequence len is out of range, clipping");
+ OSL_ENSURE(nLen <= nAvailableData, "sprm sequence len is out of range, clipping");
rEntry.mnLen = std::min(nLen, nAvailableData);
rEntry.mpData = maRawData + nDataOffset;
}
@@ -2649,7 +2652,7 @@ void WW8PLCFx_Fc_FKP::WW8Fkp::FillEntry(WW8PLCFx_Fc_FKP::WW8Fkp::Entry &rEntry,
WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(const WW8Fib& rFib, SvStream* pSt,
SvStream* pDataSt, tools::Long _nFilePos, tools::Long nItemSiz, ePLCFT ePl,
WW8_FC nStartFc)
- : nItemSize(nItemSiz), nFilePos(_nFilePos), mnIdx(0), ePLCF(ePl)
+ : m_nItemSize(nItemSiz), m_nFilePos(_nFilePos), mnIdx(0), m_ePLCF(ePl)
, mnMustRemainCached(0), maSprmParser(rFib)
{
memset(maRawData, 0, 512);
@@ -2658,7 +2661,7 @@ WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(const WW8Fib& rFib, SvStream* pSt,
sal_uInt64 const nOldPos = pSt->Tell();
- bool bCouldSeek = checkSeek(*pSt, nFilePos);
+ bool bCouldSeek = checkSeek(*pSt, m_nFilePos);
bool bCouldRead = bCouldSeek && checkRead(*pSt, maRawData, 512);
mnIMax = bCouldRead ? maRawData[511] : 0;
@@ -2669,7 +2672,7 @@ WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(const WW8Fib& rFib, SvStream* pSt,
for (mnIdx = 0; mnIdx < mnIMax; ++mnIdx)
{
- const size_t nRawDataOffset = nRawDataStart + mnIdx * nItemSize;
+ const size_t nRawDataOffset = nRawDataStart + mnIdx * m_nItemSize;
//clip to available data, corrupt fkp
if (nRawDataOffset >= 511)
@@ -2685,7 +2688,7 @@ WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(const WW8Fib& rFib, SvStream* pSt,
if (nOfs)
{
- switch (ePLCF)
+ switch (m_ePLCF)
{
case CHP:
{
@@ -2698,7 +2701,7 @@ WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(const WW8Fib& rFib, SvStream* pSt,
if (aEntry.mnLen && eVersion <= ww::eWW2)
{
- Word2CHPX aChpx = ReadWord2Chpx(*pSt, nFilePos + nOfs + 1, static_cast< sal_uInt8 >(aEntry.mnLen));
+ Word2CHPX aChpx = ReadWord2Chpx(*pSt, m_nFilePos + nOfs + 1, static_cast< sal_uInt8 >(aEntry.mnLen));
std::vector<sal_uInt8> aSprms = ChpxToSprms(aChpx);
aEntry.mnLen = static_cast< sal_uInt16 >(aSprms.size());
if (aEntry.mnLen)
@@ -2784,7 +2787,7 @@ WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(const WW8Fib& rFib, SvStream* pSt,
pStartData = nullptr;
if ((IsReplaceAllSprm(nSpId) || bExpand) && pStartData)
{
- sal_uInt32 nCurr = pDataSt->Tell();
+ sal_uInt64 nCurr = pDataSt->Tell();
sal_uInt32 nPos = SVBT32ToUInt32(pStartData);
sal_uInt16 nLen(0);
@@ -2826,19 +2829,6 @@ WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(const WW8Fib& rFib, SvStream* pSt,
}
maEntries.push_back(aEntry);
-
-#ifdef DEBUGSPRMREADER
- {
- sal_Int32 nLen;
- sal_uInt8* pSprms = GetLenAndIStdAndSprms( nLen );
- WW8SprmIter aIter(pSprms, nLen, maSprmParser);
- while (aIter.GetSprms())
- {
- fprintf(stderr, "id is %x\n", aIter.GetCurrentId());
- aIter.advance();
- }
- }
-#endif
}
//one more FC than grrpl entries
@@ -3089,32 +3079,32 @@ bool WW8PLCFx_Fc_FKP::NewFkp()
return false;
}
- if (!pPLCF->Get( nPLCFStart, nPLCFEnd, pPage ))
+ if (!m_pPLCF->Get( nPLCFStart, nPLCFEnd, pPage ))
{
- pFkp = nullptr;
+ m_pFkp = nullptr;
return false; // PLCF completely processed
}
- pPLCF->advance();
+ m_pPLCF->advance();
tools::Long nPo = SVBT16ToUInt16( static_cast<sal_uInt8 *>(pPage) );
nPo <<= 9; // shift as LONG
- tools::Long nCurrentFkpFilePos = pFkp ? pFkp->GetFilePos() : -1;
+ tools::Long nCurrentFkpFilePos = m_pFkp ? m_pFkp->GetFilePos() : -1;
if (nCurrentFkpFilePos == nPo)
- pFkp->Reset(GetStartFc());
+ m_pFkp->Reset(GetStartFc());
else
{
auto aIter =
std::find_if(maFkpCache.begin(), maFkpCache.end(), SamePos(nPo));
if (aIter != maFkpCache.end())
{
- pFkp = aIter->get();
- pFkp->Reset(GetStartFc());
+ m_pFkp = aIter->get();
+ m_pFkp->Reset(GetStartFc());
}
else
{
- pFkp = new WW8Fkp(GetFIB(), pFKPStrm, pDataStrm, nPo,
- pFkpSizeTab[ ePLCF ], ePLCF, GetStartFc());
- maFkpCache.push_back(std::unique_ptr<WW8Fkp>(pFkp));
+ m_pFkp = new WW8Fkp(GetFIB(), m_pFKPStrm, m_pDataStrm, nPo,
+ pFkpSizeTab[ m_ePLCF ], m_ePLCF, GetStartFc());
+ maFkpCache.push_back(std::unique_ptr<WW8Fkp>(m_pFkp));
if (maFkpCache.size() > eMaxCache)
{
@@ -3133,19 +3123,19 @@ bool WW8PLCFx_Fc_FKP::NewFkp()
WW8PLCFx_Fc_FKP::WW8PLCFx_Fc_FKP(SvStream* pSt, SvStream* pTableSt,
SvStream* pDataSt, const WW8Fib& rFib, ePLCFT ePl, WW8_FC nStartFcL)
- : WW8PLCFx(rFib, true), pFKPStrm(pSt), pDataStrm(pDataSt)
- , pFkp(nullptr), ePLCF(ePl)
+ : WW8PLCFx(rFib, true), m_pFKPStrm(pSt), m_pDataStrm(pDataSt)
+ , m_pFkp(nullptr), m_ePLCF(ePl)
{
SetStartFc(nStartFcL);
tools::Long nLenStruct = (8 > rFib.m_nVersion) ? 2 : 4;
if (ePl == CHP)
{
- pPLCF.reset(new WW8PLCF(*pTableSt, rFib.m_fcPlcfbteChpx, rFib.m_lcbPlcfbteChpx,
+ m_pPLCF.reset(new WW8PLCF(*pTableSt, rFib.m_fcPlcfbteChpx, rFib.m_lcbPlcfbteChpx,
nLenStruct, GetStartFc(), rFib.m_pnChpFirst, rFib.m_cpnBteChp));
}
else
{
- pPLCF.reset(new WW8PLCF(*pTableSt, rFib.m_fcPlcfbtePapx, rFib.m_lcbPlcfbtePapx,
+ m_pPLCF.reset(new WW8PLCF(*pTableSt, rFib.m_fcPlcfbtePapx, rFib.m_lcbPlcfbtePapx,
nLenStruct, GetStartFc(), rFib.m_pnPapFirst, rFib.m_cpnBtePap));
}
}
@@ -3153,15 +3143,15 @@ WW8PLCFx_Fc_FKP::WW8PLCFx_Fc_FKP(SvStream* pSt, SvStream* pTableSt,
WW8PLCFx_Fc_FKP::~WW8PLCFx_Fc_FKP()
{
maFkpCache.clear();
- pPLCF.reset();
- pPCDAttrs.reset();
+ m_pPLCF.reset();
+ m_pPCDAttrs.reset();
}
sal_uInt32 WW8PLCFx_Fc_FKP::GetIdx() const
{
- sal_uInt32 u = pPLCF->GetIdx() << 8;
- if (pFkp)
- u |= pFkp->GetIdx();
+ sal_uInt32 u = m_pPLCF->GetIdx() << 8;
+ if (m_pFkp)
+ u |= m_pFkp->GetIdx();
return u;
}
@@ -3169,17 +3159,17 @@ void WW8PLCFx_Fc_FKP::SetIdx(sal_uInt32 nIdx)
{
if( !( nIdx & 0xffffff00L ) )
{
- pPLCF->SetIdx( nIdx >> 8 );
- pFkp = nullptr;
+ m_pPLCF->SetIdx( nIdx >> 8 );
+ m_pFkp = nullptr;
}
else
{ // there was a Fkp
// Set PLCF one position back to retrieve the address of the Fkp
- pPLCF->SetIdx( ( nIdx >> 8 ) - 1 );
+ m_pPLCF->SetIdx( ( nIdx >> 8 ) - 1 );
if (NewFkp()) // read Fkp again
{
sal_uInt8 nFkpIdx = static_cast<sal_uInt8>(nIdx & 0xff);
- pFkp->SetIdx(nFkpIdx); // set Fkp-Pos again
+ m_pFkp->SetIdx(nFkpIdx); // set Fkp-Pos again
}
}
}
@@ -3190,32 +3180,32 @@ bool WW8PLCFx_Fc_FKP::SeekPos(WW8_FC nFcPos)
SetStartFc( nFcPos );
// find StartPos for next pPLCF->Get()
- bool bRet = pPLCF->SeekPos(nFcPos);
+ bool bRet = m_pPLCF->SeekPos(nFcPos);
// make FKP invalid?
WW8_CP nPLCFStart, nPLCFEnd;
void* pPage;
- if( pFkp && pPLCF->Get( nPLCFStart, nPLCFEnd, pPage ) )
+ if( m_pFkp && m_pPLCF->Get( nPLCFStart, nPLCFEnd, pPage ) )
{
tools::Long nPo = SVBT16ToUInt16( static_cast<sal_uInt8 *>(pPage) );
nPo <<= 9; // shift as LONG
- if (nPo != pFkp->GetFilePos())
- pFkp = nullptr;
+ if (nPo != m_pFkp->GetFilePos())
+ m_pFkp = nullptr;
else
- pFkp->SeekPos( nFcPos );
+ m_pFkp->SeekPos( nFcPos );
}
return bRet;
}
WW8_FC WW8PLCFx_Fc_FKP::Where()
{
- if( !pFkp && !NewFkp() )
+ if( !m_pFkp && !NewFkp() )
return WW8_FC_MAX;
- WW8_FC nP = pFkp ? pFkp->Where() : WW8_FC_MAX;
+ WW8_FC nP = m_pFkp ? m_pFkp->Where() : WW8_FC_MAX;
if( nP != WW8_FC_MAX )
return nP;
- pFkp = nullptr; // FKP finished -> get new
+ m_pFkp = nullptr; // FKP finished -> get new
return Where(); // easiest way: do it recursively
}
@@ -3224,13 +3214,13 @@ sal_uInt8* WW8PLCFx_Fc_FKP::GetSprmsAndPos(WW8_FC& rStart, WW8_FC& rEnd, sal_Int
rLen = 0; // Default
rStart = rEnd = WW8_FC_MAX;
- if( !pFkp ) // Fkp not there ?
+ if( !m_pFkp ) // Fkp not there ?
{
if( !NewFkp() )
return nullptr;
}
- sal_uInt8* pPos = pFkp ? pFkp->Get( rStart, rEnd, rLen ) : nullptr;
+ sal_uInt8* pPos = m_pFkp ? m_pFkp->Get( rStart, rEnd, rLen ) : nullptr;
if( rStart == WW8_FC_MAX ) //Not found
return nullptr;
return pPos;
@@ -3238,42 +3228,42 @@ sal_uInt8* WW8PLCFx_Fc_FKP::GetSprmsAndPos(WW8_FC& rStart, WW8_FC& rEnd, sal_Int
void WW8PLCFx_Fc_FKP::advance()
{
- if( !pFkp && !NewFkp() )
+ if( !m_pFkp && !NewFkp() )
return;
- if (!pFkp)
+ if (!m_pFkp)
return;
- pFkp->advance();
- if( pFkp->Where() == WW8_FC_MAX )
+ m_pFkp->advance();
+ if( m_pFkp->Where() == WW8_FC_MAX )
(void)NewFkp();
}
sal_uInt16 WW8PLCFx_Fc_FKP::GetIstd() const
{
- return pFkp ? pFkp->GetIstd() : 0xFFFF;
+ return m_pFkp ? m_pFkp->GetIstd() : 0xFFFF;
}
void WW8PLCFx_Fc_FKP::GetPCDSprms( WW8PLCFxDesc& rDesc )
{
rDesc.pMemPos = nullptr;
rDesc.nSprmsLen = 0;
- if( pPCDAttrs )
+ if( m_pPCDAttrs )
{
- if( !pFkp )
+ if( !m_pFkp )
{
OSL_FAIL("+Problem: GetPCDSprms: NewFkp necessary (not possible!)" );
if( !NewFkp() )
return;
}
- pPCDAttrs->GetSprms(&rDesc);
+ m_pPCDAttrs->GetSprms(&rDesc);
}
}
SprmResult WW8PLCFx_Fc_FKP::HasSprm(sal_uInt16 nId, bool bFindFirst)
{
// const would be nicer, but for that, NewFkp() would need to be replaced or eliminated
- if( !pFkp )
+ if( !m_pFkp )
{
OSL_FAIL( "+Motz: HasSprm: NewFkp needed ( no const possible )" );
// happens in BugDoc 31722
@@ -3281,10 +3271,10 @@ SprmResult WW8PLCFx_Fc_FKP::HasSprm(sal_uInt16 nId, bool bFindFirst)
return SprmResult();
}
- if (!pFkp)
+ if (!m_pFkp)
return SprmResult();
- SprmResult aRes = pFkp->HasSprm(nId, bFindFirst);
+ SprmResult aRes = m_pFkp->HasSprm(nId, bFindFirst);
if (!aRes.pSprm)
{
@@ -3294,7 +3284,7 @@ SprmResult WW8PLCFx_Fc_FKP::HasSprm(sal_uInt16 nId, bool bFindFirst)
if (aDesc.pMemPos)
{
WW8SprmIter aIter(aDesc.pMemPos, aDesc.nSprmsLen,
- pFkp->GetSprmParser());
+ m_pFkp->GetSprmParser());
aRes = aIter.FindSprm(nId, bFindFirst);
}
}
@@ -3305,7 +3295,7 @@ SprmResult WW8PLCFx_Fc_FKP::HasSprm(sal_uInt16 nId, bool bFindFirst)
void WW8PLCFx_Fc_FKP::HasSprm(sal_uInt16 nId, std::vector<SprmResult> &rResult)
{
// const would be nicer, but for that, NewFkp() would need to be replaced or eliminated
- if (!pFkp)
+ if (!m_pFkp)
{
OSL_FAIL( "+Motz: HasSprm: NewFkp needed ( no const possible )" );
// happens in BugDoc 31722
@@ -3313,10 +3303,10 @@ void WW8PLCFx_Fc_FKP::HasSprm(sal_uInt16 nId, std::vector<SprmResult> &rResult)
return;
}
- if (!pFkp)
+ if (!m_pFkp)
return;
- pFkp->HasSprm(nId, rResult);
+ m_pFkp->HasSprm(nId, rResult);
WW8PLCFxDesc aDesc;
GetPCDSprms( aDesc );
@@ -3324,7 +3314,7 @@ void WW8PLCFx_Fc_FKP::HasSprm(sal_uInt16 nId, std::vector<SprmResult> &rResult)
if (!aDesc.pMemPos)
return;
- const wwSprmParser &rSprmParser = pFkp->GetSprmParser();
+ const wwSprmParser &rSprmParser = m_pFkp->GetSprmParser();
WW8SprmIter aIter(aDesc.pMemPos, aDesc.nSprmsLen, rSprmParser);
while(aIter.GetSprms())
{
@@ -3341,14 +3331,14 @@ void WW8PLCFx_Fc_FKP::HasSprm(sal_uInt16 nId, std::vector<SprmResult> &rResult)
WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream* pSt, SvStream* pTableSt,
SvStream* pDataSt, const WW8ScannerBase& rBase, ePLCFT ePl )
: WW8PLCFx_Fc_FKP(pSt, pTableSt, pDataSt, *rBase.m_pWw8Fib, ePl,
- rBase.WW8Cp2Fc(0)), rSBase(rBase), nAttrStart(-1), nAttrEnd(-1),
- bLineEnd(false),
- bComplex( (7 < rBase.m_pWw8Fib->m_nVersion) || rBase.m_pWw8Fib->m_fComplex )
+ rBase.WW8Cp2Fc(0)), m_rSBase(rBase), m_nAttrStart(-1), m_nAttrEnd(-1),
+ m_bLineEnd(false),
+ m_bComplex( (7 < rBase.m_pWw8Fib->m_nVersion) || rBase.m_pWw8Fib->m_fComplex )
{
ResetAttrStartEnd();
- if (rSBase.m_pPiecePLCF)
- pPcd.reset( new WW8PLCFx_PCD(GetFIB(), rBase.m_pPiecePLCF.get(), 0, IsSevenMinus(GetFIBVersion())) );
+ if (m_rSBase.m_pPiecePLCF)
+ m_pPcd.reset( new WW8PLCFx_PCD(GetFIB(), rBase.m_pPiecePLCF.get(), 0, IsSevenMinus(GetFIBVersion())) );
/*
Make a copy of the piece attributes for so that the calls to HasSprm on a
@@ -3356,13 +3346,13 @@ WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream* pSt, SvStream* pTableSt,
despite the fact that such attributes can only be found through a cp based
mechanism.
*/
- if (pPcd)
+ if (m_pPcd)
{
- pPCDAttrs.reset( rSBase.m_pPLCFx_PCDAttrs ? new WW8PLCFx_PCDAttrs(
- *rSBase.m_pWw8Fib, pPcd.get(), &rSBase) : nullptr);
+ m_pPCDAttrs.reset( m_rSBase.m_pPLCFx_PCDAttrs ? new WW8PLCFx_PCDAttrs(
+ *m_rSBase.m_pWw8Fib, m_pPcd.get(), &m_rSBase) : nullptr);
}
- pPieceIter = rSBase.m_pPieceIter.get();
+ m_pPieceIter = m_rSBase.m_pPieceIter.get();
}
WW8PLCFx_Cp_FKP::~WW8PLCFx_Cp_FKP()
@@ -3371,36 +3361,36 @@ WW8PLCFx_Cp_FKP::~WW8PLCFx_Cp_FKP()
void WW8PLCFx_Cp_FKP::ResetAttrStartEnd()
{
- nAttrStart = -1;
- nAttrEnd = -1;
- bLineEnd = false;
+ m_nAttrStart = -1;
+ m_nAttrEnd = -1;
+ m_bLineEnd = false;
}
sal_uInt32 WW8PLCFx_Cp_FKP::GetPCDIdx() const
{
- return pPcd ? pPcd->GetIdx() : 0;
+ return m_pPcd ? m_pPcd->GetIdx() : 0;
}
bool WW8PLCFx_Cp_FKP::SeekPos(WW8_CP nCpPos)
{
- if( pPcd ) // Complex
+ if( m_pPcd ) // Complex
{
- if( !pPcd->SeekPos( nCpPos ) ) // set piece
+ if( !m_pPcd->SeekPos( nCpPos ) ) // set piece
return false;
- if (pPCDAttrs && !pPCDAttrs->GetIter()->SeekPos(nCpPos))
+ if (m_pPCDAttrs && !m_pPCDAttrs->GetIter()->SeekPos(nCpPos))
return false;
- return WW8PLCFx_Fc_FKP::SeekPos(pPcd->CurrentPieceStartCp2Fc(nCpPos));
+ return WW8PLCFx_Fc_FKP::SeekPos(m_pPcd->CurrentPieceStartCp2Fc(nCpPos));
}
// NO piece table !!!
- return WW8PLCFx_Fc_FKP::SeekPos( rSBase.WW8Cp2Fc(nCpPos) );
+ return WW8PLCFx_Fc_FKP::SeekPos( m_rSBase.WW8Cp2Fc(nCpPos) );
}
WW8_CP WW8PLCFx_Cp_FKP::Where()
{
WW8_FC nFc = WW8PLCFx_Fc_FKP::Where();
- if( pPcd )
- return pPcd->CurrentPieceStartFc2Cp( nFc ); // identify piece
- return rSBase.WW8Fc2Cp( nFc ); // NO piece table !!!
+ if( m_pPcd )
+ return m_pPcd->CurrentPieceStartFc2Cp( nFc ); // identify piece
+ return m_rSBase.WW8Fc2Cp( nFc ); // NO piece table !!!
}
void WW8PLCFx_Cp_FKP::GetSprms(WW8PLCFxDesc* p)
@@ -3425,23 +3415,23 @@ void WW8PLCFx_Cp_FKP::GetSprms(WW8PLCFxDesc* p)
Otherwise our cool fastsave algorithm can be brought to bear on the
problem.
*/
- if( !pPieceIter )
+ if( !m_pPieceIter )
return;
- const sal_uInt32 nOldPos = pPieceIter->GetIdx();
- bool bOk = pPieceIter->SeekPos(nOrigCp);
- pPieceIter->SetIdx(nOldPos);
+ const sal_uInt32 nOldPos = m_pPieceIter->GetIdx();
+ bool bOk = m_pPieceIter->SeekPos(nOrigCp);
+ m_pPieceIter->SetIdx(nOldPos);
if (!bOk)
return;
}
- if( pPcd ) // piece table available
+ if( m_pPcd ) // piece table available
{
// Init ( no ++ called, yet )
- if( (nAttrStart > nAttrEnd) || (nAttrStart == -1) )
+ if( (m_nAttrStart > m_nAttrEnd) || (m_nAttrStart == -1) )
{
- p->bRealLineEnd = (ePLCF == PAP);
+ p->bRealLineEnd = (m_ePLCF == PAP);
- if ( ((ePLCF == PAP ) || (ePLCF == CHP)) && (nOrigCp != WW8_CP_MAX) )
+ if ( ((m_ePLCF == PAP ) || (m_ePLCF == CHP)) && (nOrigCp != WW8_CP_MAX) )
{
bool bIsUnicode=false;
/*
@@ -3454,9 +3444,9 @@ void WW8PLCFx_Cp_FKP::GetSprms(WW8PLCFxDesc* p)
//We set the piece iterator to the piece that contains the
//character, now we have the correct piece for this character
- sal_uInt32 nOldPos = pPieceIter->GetIdx();
+ sal_uInt32 nOldPos = m_pPieceIter->GetIdx();
p->nStartPos = nOrigCp;
- pPieceIter->SeekPos( p->nStartPos);
+ m_pPieceIter->SeekPos( p->nStartPos);
//This is the FC assigned to the character, but we already
//have the result of the next stage, so we can skip this step
@@ -3478,11 +3468,11 @@ void WW8PLCFx_Cp_FKP::GetSprms(WW8PLCFxDesc* p)
*/
WW8_CP nCpStart, nCpEnd;
void* pData=nullptr;
- bool bOk = pPieceIter->Get(nCpStart, nCpEnd, pData);
+ bool bOk = m_pPieceIter->Get(nCpStart, nCpEnd, pData);
if (!bOk)
{
- pPieceIter->SetIdx(nOldPos);
+ m_pPieceIter->SetIdx(nOldPos);
return;
}
@@ -3501,7 +3491,7 @@ void WW8PLCFx_Cp_FKP::GetSprms(WW8PLCFxDesc* p)
{
SAL_WARN("sw.ww8", "broken offset, ignoring");
p->nStartPos = p->nEndPos = WW8_FC_MAX;
- pPieceIter->SetIdx(nOldPos);
+ m_pPieceIter->SetIdx(nOldPos);
return;
}
@@ -3512,7 +3502,7 @@ void WW8PLCFx_Cp_FKP::GetSprms(WW8PLCFxDesc* p)
{
SAL_WARN("sw.ww8", "broken offset, ignoring");
p->nStartPos = p->nEndPos = WW8_FC_MAX;
- pPieceIter->SetIdx(nOldPos);
+ m_pPieceIter->SetIdx(nOldPos);
return;
}
}
@@ -3522,7 +3512,7 @@ void WW8PLCFx_Cp_FKP::GetSprms(WW8PLCFxDesc* p)
{
SAL_WARN("sw.ww8", "broken offset, ignoring");
p->nStartPos = p->nEndPos = WW8_FC_MAX;
- pPieceIter->SetIdx(nOldPos);
+ m_pPieceIter->SetIdx(nOldPos);
return;
}
@@ -3533,7 +3523,7 @@ void WW8PLCFx_Cp_FKP::GetSprms(WW8PLCFxDesc* p)
{
SAL_WARN("sw.ww8", "broken offset, ignoring");
p->nStartPos = p->nEndPos = WW8_FC_MAX;
- pPieceIter->SetIdx(nOldPos);
+ m_pPieceIter->SetIdx(nOldPos);
return;
}
@@ -3544,15 +3534,14 @@ void WW8PLCFx_Cp_FKP::GetSprms(WW8PLCFxDesc* p)
{
SAL_WARN("sw.ww8", "broken offset, ignoring");
p->nStartPos = p->nEndPos = WW8_FC_MAX;
- pPieceIter->SetIdx(nOldPos);
+ m_pPieceIter->SetIdx(nOldPos);
return;
}
}
else
{
- if (ePLCF == CHP)
- p->nEndPos = nCpEnd;
- else
+ p->nEndPos = nCpEnd;
+ if (m_ePLCF != CHP)
{
/*
If the FKP FC that was found was greater than the FC
@@ -3572,12 +3561,12 @@ void WW8PLCFx_Cp_FKP::GetSprms(WW8PLCFxDesc* p)
FKP fc
*/
- pPieceIter->advance();
+ m_pPieceIter->advance();
- for (;pPieceIter->GetIdx() < pPieceIter->GetIMax();
- pPieceIter->advance())
+ for (;m_pPieceIter->GetIdx() < m_pPieceIter->GetIMax();
+ m_pPieceIter->advance())
{
- if( !pPieceIter->Get( nCpStart, nCpEnd, pData ) )
+ if( !m_pPieceIter->Get( nCpStart, nCpEnd, pData ) )
{
OSL_ENSURE( false, "piece iter broken!" );
break;
@@ -3659,23 +3648,23 @@ void WW8PLCFx_Cp_FKP::GetSprms(WW8PLCFxDesc* p)
}
}
}
- pPieceIter->SetIdx( nOldPos );
+ m_pPieceIter->SetIdx( nOldPos );
}
else
- WW8PLCFx_PCD::CurrentPieceFc2Cp( p->nStartPos, p->nEndPos,&rSBase );
+ WW8PLCFx_PCD::CurrentPieceFc2Cp( p->nStartPos, p->nEndPos,&m_rSBase );
}
else
{
- p->nStartPos = nAttrStart;
- p->nEndPos = nAttrEnd;
- p->bRealLineEnd = bLineEnd;
+ p->nStartPos = m_nAttrStart;
+ p->nEndPos = m_nAttrEnd;
+ p->bRealLineEnd = m_bLineEnd;
}
}
else // NO piece table !!!
{
- p->nStartPos = rSBase.WW8Fc2Cp( p->nStartPos );
- p->nEndPos = rSBase.WW8Fc2Cp( p->nEndPos );
- p->bRealLineEnd = ePLCF == PAP;
+ p->nStartPos = m_rSBase.WW8Fc2Cp( p->nStartPos );
+ p->nEndPos = m_rSBase.WW8Fc2Cp( p->nEndPos );
+ p->bRealLineEnd = m_ePLCF == PAP;
}
}
@@ -3683,33 +3672,33 @@ void WW8PLCFx_Cp_FKP::advance()
{
WW8PLCFx_Fc_FKP::advance();
// !pPcd: emergency break
- if ( !bComplex || !pPcd )
+ if ( !m_bComplex || !m_pPcd )
return;
- if( GetPCDIdx() >= pPcd->GetIMax() ) // End of PLCF
+ if( GetPCDIdx() >= m_pPcd->GetIMax() ) // End of PLCF
{
- nAttrStart = nAttrEnd = WW8_CP_MAX;
+ m_nAttrStart = m_nAttrEnd = WW8_CP_MAX;
return;
}
sal_Int32 nFkpLen; // Fkp entry
// get Fkp entry
- WW8PLCFx_Fc_FKP::GetSprmsAndPos(nAttrStart, nAttrEnd, nFkpLen);
+ WW8PLCFx_Fc_FKP::GetSprmsAndPos(m_nAttrStart, m_nAttrEnd, nFkpLen);
- WW8PLCFx_PCD::CurrentPieceFc2Cp( nAttrStart, nAttrEnd, &rSBase );
- bLineEnd = (ePLCF == PAP);
+ WW8PLCFx_PCD::CurrentPieceFc2Cp( m_nAttrStart, m_nAttrEnd, &m_rSBase );
+ m_bLineEnd = (m_ePLCF == PAP);
}
WW8PLCFx_SEPX::WW8PLCFx_SEPX(SvStream* pSt, SvStream* pTableSt,
const WW8Fib& rFib, WW8_CP nStartCp)
: WW8PLCFx(rFib, true), maSprmParser(rFib),
- pStrm(pSt), nArrMax(256), nSprmSiz(0)
+ m_pStrm(pSt), m_nArrMax(256), m_nSprmSiz(0)
{
if (rFib.m_lcbPlcfsed)
- pPLCF.reset( new WW8PLCF(*pTableSt, rFib.m_fcPlcfsed, rFib.m_lcbPlcfsed,
+ m_pPLCF.reset( new WW8PLCF(*pTableSt, rFib.m_fcPlcfsed, rFib.m_lcbPlcfsed,
GetFIBVersion() <= ww::eWW2 ? 6 : 12, nStartCp) );
- pSprms.reset( new sal_uInt8[nArrMax] ); // maximum length
+ m_pSprms.reset( new sal_uInt8[m_nArrMax] ); // maximum length
}
WW8PLCFx_SEPX::~WW8PLCFx_SEPX()
@@ -3718,32 +3707,32 @@ WW8PLCFx_SEPX::~WW8PLCFx_SEPX()
sal_uInt32 WW8PLCFx_SEPX::GetIdx() const
{
- return pPLCF ? pPLCF->GetIdx() : 0;
+ return m_pPLCF ? m_pPLCF->GetIdx() : 0;
}
void WW8PLCFx_SEPX::SetIdx(sal_uInt32 nIdx)
{
- if( pPLCF ) pPLCF->SetIdx( nIdx );
+ if( m_pPLCF ) m_pPLCF->SetIdx( nIdx );
}
bool WW8PLCFx_SEPX::SeekPos(WW8_CP nCpPos)
{
- return pPLCF && pPLCF->SeekPos( nCpPos );
+ return m_pPLCF && m_pPLCF->SeekPos( nCpPos );
}
WW8_CP WW8PLCFx_SEPX::Where()
{
- return pPLCF ? pPLCF->Where() : 0;
+ return m_pPLCF ? m_pPLCF->Where() : 0;
}
void WW8PLCFx_SEPX::GetSprms(WW8PLCFxDesc* p)
{
- if( !pPLCF ) return;
+ if( !m_pPLCF ) return;
void* pData;
p->bRealLineEnd = false;
- if (!pPLCF->Get( p->nStartPos, p->nEndPos, pData ))
+ if (!m_pPLCF->Get( p->nStartPos, p->nEndPos, pData ))
{
p->nStartPos = p->nEndPos = WW8_CP_MAX; // PLCF completely processed
p->pMemPos = nullptr;
@@ -3752,7 +3741,7 @@ void WW8PLCFx_SEPX::GetSprms(WW8PLCFxDesc* p)
else
{
sal_uInt32 nPo = SVBT32ToUInt32( static_cast<sal_uInt8*>(pData)+2 );
- if (nPo == 0xFFFFFFFF || !checkSeek(*pStrm, nPo))
+ if (nPo == 0xFFFFFFFF || !checkSeek(*m_pStrm, nPo))
{
p->nStartPos = p->nEndPos = WW8_CP_MAX; // Sepx empty
p->pMemPos = nullptr;
@@ -3764,47 +3753,47 @@ void WW8PLCFx_SEPX::GetSprms(WW8PLCFxDesc* p)
if (GetFIBVersion() <= ww::eWW2) // eWW6 ?, docs say yes, but...
{
sal_uInt8 nSiz(0);
- pStrm->ReadUChar( nSiz );
- nSprmSiz = nSiz;
+ m_pStrm->ReadUChar( nSiz );
+ m_nSprmSiz = nSiz;
}
else
{
- pStrm->ReadUInt16( nSprmSiz );
+ m_pStrm->ReadUInt16( m_nSprmSiz );
}
- std::size_t nRemaining = pStrm->remainingSize();
- if (nSprmSiz > nRemaining)
- nSprmSiz = nRemaining;
+ std::size_t nRemaining = m_pStrm->remainingSize();
+ if (m_nSprmSiz > nRemaining)
+ m_nSprmSiz = nRemaining;
- if( nSprmSiz > nArrMax )
+ if( m_nSprmSiz > m_nArrMax )
{ // does not fit
- nArrMax = nSprmSiz; // Get more memory
- pSprms.reset( new sal_uInt8[nArrMax] );
+ m_nArrMax = m_nSprmSiz; // Get more memory
+ m_pSprms.reset( new sal_uInt8[m_nArrMax] );
}
- nSprmSiz = pStrm->ReadBytes(pSprms.get(), nSprmSiz); // read Sprms
+ m_nSprmSiz = m_pStrm->ReadBytes(m_pSprms.get(), m_nSprmSiz); // read Sprms
- p->nSprmsLen = nSprmSiz;
- p->pMemPos = pSprms.get(); // return Position
+ p->nSprmsLen = m_nSprmSiz;
+ p->pMemPos = m_pSprms.get(); // return Position
}
}
}
void WW8PLCFx_SEPX::advance()
{
- if (pPLCF)
- pPLCF->advance();
+ if (m_pPLCF)
+ m_pPLCF->advance();
}
SprmResult WW8PLCFx_SEPX::HasSprm(sal_uInt16 nId) const
{
- return HasSprm(nId, pSprms.get(), nSprmSiz);
+ return HasSprm(nId, m_pSprms.get(), m_nSprmSiz);
}
SprmResult WW8PLCFx_SEPX::HasSprm( sal_uInt16 nId, const sal_uInt8* pOtherSprms,
tools::Long nOtherSprmSiz ) const
{
SprmResult aRet;
- if (pPLCF)
+ if (m_pPLCF)
{
WW8SprmIter aIter(pOtherSprms, nOtherSprmSiz, maSprmParser);
aRet = aIter.FindSprm(nId, /*bFindFirst=*/true);
@@ -3815,18 +3804,18 @@ SprmResult WW8PLCFx_SEPX::HasSprm( sal_uInt16 nId, const sal_uInt8* pOtherSprms
bool WW8PLCFx_SEPX::Find4Sprms(sal_uInt16 nId1,sal_uInt16 nId2,sal_uInt16 nId3,sal_uInt16 nId4,
SprmResult& r1, SprmResult& r2, SprmResult& r3, SprmResult& r4) const
{
- if( !pPLCF )
+ if( !m_pPLCF )
return false;
bool bFound = false;
- sal_uInt8* pSp = pSprms.get();
+ sal_uInt8* pSp = m_pSprms.get();
size_t i = 0;
- while (i + maSprmParser.MinSprmLen() <= nSprmSiz)
+ while (i + maSprmParser.MinSprmLen() <= m_nSprmSiz)
{
// Sprm found?
const sal_uInt16 nCurrentId = maSprmParser.GetSprmId(pSp);
- sal_Int32 nRemLen = nSprmSiz - i;
+ sal_Int32 nRemLen = m_nSprmSiz - i;
const sal_Int32 x = maSprmParser.GetSprmSize(nCurrentId, pSp, nRemLen);
bool bValid = x <= nRemLen;
if (!bValid)
@@ -3868,9 +3857,9 @@ bool WW8PLCFx_SEPX::Find4Sprms(sal_uInt16 nId1,sal_uInt16 nId2,sal_uInt16 nId3,s
SprmResult WW8PLCFx_SEPX::HasSprm( sal_uInt16 nId, sal_uInt8 n2nd ) const
{
SprmResult aRet;
- if (pPLCF)
+ if (m_pPLCF)
{
- WW8SprmIter aIter(pSprms.get(), nSprmSiz, maSprmParser);
+ WW8SprmIter aIter(m_pSprms.get(), m_nSprmSiz, maSprmParser);
aRet = aIter.FindSprm(nId, /*bFindFirst=*/true, &n2nd);
}
return aRet;
@@ -3883,43 +3872,43 @@ WW8PLCFx_SubDoc::WW8PLCFx_SubDoc(SvStream* pSt, const WW8Fib& rFib,
{
if( nLenRef && nLenText )
{
- pRef.reset(new WW8PLCF(*pSt, nFcRef, nLenRef, nStruct, nStartCp));
- pText.reset(new WW8PLCF(*pSt, nFcText, nLenText, 0, nStartCp));
+ m_pRef.reset(new WW8PLCF(*pSt, nFcRef, nLenRef, nStruct, nStartCp));
+ m_pText.reset(new WW8PLCF(*pSt, nFcText, nLenText, 0, nStartCp));
}
}
WW8PLCFx_SubDoc::~WW8PLCFx_SubDoc()
{
- pRef.reset();
- pText.reset();
+ m_pRef.reset();
+ m_pText.reset();
}
sal_uInt32 WW8PLCFx_SubDoc::GetIdx() const
{
// Probably pText ... no need for it
- if( pRef )
- return ( pRef->GetIdx() << 16 | pText->GetIdx() );
+ if( m_pRef )
+ return ( m_pRef->GetIdx() << 16 | m_pText->GetIdx() );
return 0;
}
void WW8PLCFx_SubDoc::SetIdx(sal_uInt32 nIdx)
{
- if( pRef )
+ if( m_pRef )
{
- pRef->SetIdx( nIdx >> 16 );
+ m_pRef->SetIdx( nIdx >> 16 );
// Probably pText ... no need for it
- pText->SetIdx( nIdx & 0xFFFF );
+ m_pText->SetIdx( nIdx & 0xFFFF );
}
}
bool WW8PLCFx_SubDoc::SeekPos( WW8_CP nCpPos )
{
- return pRef && pRef->SeekPos( nCpPos );
+ return m_pRef && m_pRef->SeekPos( nCpPos );
}
WW8_CP WW8PLCFx_SubDoc::Where()
{
- return pRef ? pRef->Where() : WW8_CP_MAX;
+ return m_pRef ? m_pRef->Where() : WW8_CP_MAX;
}
void WW8PLCFx_SubDoc::GetSprms(WW8PLCFxDesc* p)
@@ -3929,14 +3918,14 @@ void WW8PLCFx_SubDoc::GetSprms(WW8PLCFxDesc* p)
p->nSprmsLen = 0;
p->bRealLineEnd = false;
- if (!pRef)
+ if (!m_pRef)
return;
- sal_uInt32 nNr = pRef->GetIdx();
+ sal_uInt32 nNr = m_pRef->GetIdx();
void *pData;
WW8_CP nFoo;
- if (!pRef->Get(p->nStartPos, nFoo, pData))
+ if (!m_pRef->Get(p->nStartPos, nFoo, pData))
{
p->nEndPos = p->nStartPos = WW8_CP_MAX;
return;
@@ -3949,12 +3938,12 @@ void WW8PLCFx_SubDoc::GetSprms(WW8PLCFxDesc* p)
return;
}
- if (!pText)
+ if (!m_pText)
return;
- pText->SetIdx(nNr);
+ m_pText->SetIdx(nNr);
- if (!pText->Get(p->nCp2OrIdx, p->nSprmsLen, pData))
+ if (!m_pText->Get(p->nCp2OrIdx, p->nSprmsLen, pData))
{
p->nEndPos = p->nStartPos = WW8_CP_MAX;
p->nSprmsLen = 0;
@@ -3974,16 +3963,16 @@ void WW8PLCFx_SubDoc::GetSprms(WW8PLCFxDesc* p)
void WW8PLCFx_SubDoc::advance()
{
- if (pRef && pText)
+ if (m_pRef && m_pText)
{
- pRef->advance();
- pText->advance();
+ m_pRef->advance();
+ m_pText->advance();
}
}
// fields
WW8PLCFx_FLD::WW8PLCFx_FLD( SvStream* pSt, const WW8Fib& rMyFib, short nType)
- : WW8PLCFx(rMyFib, true), rFib(rMyFib)
+ : WW8PLCFx(rMyFib, true), m_rFib(rMyFib)
{
WW8_FC nFc;
sal_Int32 nLen;
@@ -3991,37 +3980,37 @@ WW8PLCFx_FLD::WW8PLCFx_FLD( SvStream* pSt, const WW8Fib& rMyFib, short nType)
switch( nType )
{
case MAN_HDFT:
- nFc = rFib.m_fcPlcffldHdr;
- nLen = rFib.m_lcbPlcffldHdr;
+ nFc = m_rFib.m_fcPlcffldHdr;
+ nLen = m_rFib.m_lcbPlcffldHdr;
break;
case MAN_FTN:
- nFc = rFib.m_fcPlcffldFootnote;
- nLen = rFib.m_lcbPlcffldFootnote;
+ nFc = m_rFib.m_fcPlcffldFootnote;
+ nLen = m_rFib.m_lcbPlcffldFootnote;
break;
case MAN_EDN:
- nFc = rFib.m_fcPlcffldEdn;
- nLen = rFib.m_lcbPlcffldEdn;
+ nFc = m_rFib.m_fcPlcffldEdn;
+ nLen = m_rFib.m_lcbPlcffldEdn;
break;
case MAN_AND:
- nFc = rFib.m_fcPlcffldAtn;
- nLen = rFib.m_lcbPlcffldAtn;
+ nFc = m_rFib.m_fcPlcffldAtn;
+ nLen = m_rFib.m_lcbPlcffldAtn;
break;
case MAN_TXBX:
- nFc = rFib.m_fcPlcffldTxbx;
- nLen = rFib.m_lcbPlcffldTxbx;
+ nFc = m_rFib.m_fcPlcffldTxbx;
+ nLen = m_rFib.m_lcbPlcffldTxbx;
break;
case MAN_TXBX_HDFT:
- nFc = rFib.m_fcPlcffldHdrTxbx;
- nLen = rFib.m_lcbPlcffldHdrTxbx;
+ nFc = m_rFib.m_fcPlcffldHdrTxbx;
+ nLen = m_rFib.m_lcbPlcffldHdrTxbx;
break;
default:
- nFc = rFib.m_fcPlcffldMom;
- nLen = rFib.m_lcbPlcffldMom;
+ nFc = m_rFib.m_fcPlcffldMom;
+ nLen = m_rFib.m_lcbPlcffldMom;
break;
}
if( nLen )
- pPLCF.reset( new WW8PLCFspecial( pSt, nFc, nLen, 2 ) );
+ m_pPLCF.reset( new WW8PLCFspecial( pSt, nFc, nLen, 2 ) );
}
WW8PLCFx_FLD::~WW8PLCFx_FLD()
@@ -4030,51 +4019,51 @@ WW8PLCFx_FLD::~WW8PLCFx_FLD()
sal_uInt32 WW8PLCFx_FLD::GetIdx() const
{
- return pPLCF ? pPLCF->GetIdx() : 0;
+ return m_pPLCF ? m_pPLCF->GetIdx() : 0;
}
void WW8PLCFx_FLD::SetIdx(sal_uInt32 nIdx)
{
- if( pPLCF )
- pPLCF->SetIdx( nIdx );
+ if( m_pPLCF )
+ m_pPLCF->SetIdx( nIdx );
}
bool WW8PLCFx_FLD::SeekPos(WW8_CP nCpPos)
{
- return pPLCF && pPLCF->SeekPosExact( nCpPos );
+ return m_pPLCF && m_pPLCF->SeekPosExact( nCpPos );
}
WW8_CP WW8PLCFx_FLD::Where()
{
- return pPLCF ? pPLCF->Where() : WW8_CP_MAX;
+ return m_pPLCF ? m_pPLCF->Where() : WW8_CP_MAX;
}
bool WW8PLCFx_FLD::StartPosIsFieldStart()
{
void* pData;
sal_Int32 nTest;
- return pPLCF && pPLCF->Get(nTest, pData) && ((static_cast<sal_uInt8*>(pData)[0] & 0x1f) == 0x13);
+ return m_pPLCF && m_pPLCF->Get(nTest, pData) && ((static_cast<sal_uInt8*>(pData)[0] & 0x1f) == 0x13);
}
bool WW8PLCFx_FLD::EndPosIsFieldEnd(WW8_CP& nCP)
{
bool bRet = false;
- if (pPLCF)
+ if (m_pPLCF)
{
- tools::Long n = pPLCF->GetIdx();
+ tools::Long n = m_pPLCF->GetIdx();
- pPLCF->advance();
+ m_pPLCF->advance();
void* pData;
sal_Int32 nTest;
- if ( pPLCF->Get(nTest, pData) && ((static_cast<sal_uInt8*>(pData)[0] & 0x1f) == 0x15) )
+ if ( m_pPLCF->Get(nTest, pData) && ((static_cast<sal_uInt8*>(pData)[0] & 0x1f) == 0x15) )
{
nCP = nTest;
bRet = true;
}
- pPLCF->SetIdx(n);
+ m_pPLCF->SetIdx(n);
}
return bRet;
@@ -4087,17 +4076,17 @@ void WW8PLCFx_FLD::GetSprms(WW8PLCFxDesc* p)
p->nSprmsLen = 0;
p->bRealLineEnd = false;
- if (!pPLCF)
+ if (!m_pPLCF)
{
p->nStartPos = WW8_CP_MAX; // there are no fields
return;
}
- tools::Long n = pPLCF->GetIdx();
+ tools::Long n = m_pPLCF->GetIdx();
sal_Int32 nP;
void *pData;
- if (!pPLCF->Get(nP, pData)) // end of PLCFspecial?
+ if (!m_pPLCF->Get(nP, pData)) // end of PLCFspecial?
{
p->nStartPos = WW8_CP_MAX; // PLCF completely processed
return;
@@ -4105,8 +4094,8 @@ void WW8PLCFx_FLD::GetSprms(WW8PLCFxDesc* p)
p->nStartPos = nP;
- pPLCF->advance();
- if (!pPLCF->Get(nP, pData)) // end of PLCFspecial?
+ m_pPLCF->advance();
+ if (!m_pPLCF->Get(nP, pData)) // end of PLCFspecial?
{
p->nStartPos = WW8_CP_MAX; // PLCF completely processed
return;
@@ -4114,31 +4103,31 @@ void WW8PLCFx_FLD::GetSprms(WW8PLCFxDesc* p)
p->nEndPos = nP;
- pPLCF->SetIdx(n);
+ m_pPLCF->SetIdx(n);
- p->nCp2OrIdx = pPLCF->GetIdx();
+ p->nCp2OrIdx = m_pPLCF->GetIdx();
}
void WW8PLCFx_FLD::advance()
{
- SAL_WARN_IF(!pPLCF, "sw.ww8", "Call without PLCFspecial field");
- if( !pPLCF )
+ SAL_WARN_IF(!m_pPLCF, "sw.ww8", "Call without PLCFspecial field");
+ if( !m_pPLCF )
return;
- pPLCF->advance();
+ m_pPLCF->advance();
}
bool WW8PLCFx_FLD::GetPara(tools::Long nIdx, WW8FieldDesc& rF)
{
- SAL_WARN_IF(!pPLCF, "sw.ww8", "Call without PLCFspecial field");
- if( !pPLCF )
+ SAL_WARN_IF(!m_pPLCF, "sw.ww8", "Call without PLCFspecial field");
+ if( !m_pPLCF )
return false;
- tools::Long n = pPLCF->GetIdx();
- pPLCF->SetIdx(nIdx);
+ tools::Long n = m_pPLCF->GetIdx();
+ m_pPLCF->SetIdx(nIdx);
- bool bOk = WW8GetFieldPara(*pPLCF, rF);
+ bool bOk = WW8GetFieldPara(*m_pPLCF, rF);
- pPLCF->SetIdx(n);
+ m_pPLCF->SetIdx(n);
return bOk;
}
@@ -4236,7 +4225,7 @@ void WW8ReadSTTBF(bool bVer8, SvStream& rStrm, sal_uInt32 nStart, sal_Int32 nLen
nLen = SAL_MAX_UINT16;
else if (nLen < 2 )
nLen = 2;
- nLen2 = static_cast<sal_uInt16>(nLen);
+ nLen2 = o3tl::narrowing<sal_uInt16>(nLen);
}
sal_uLong nRead = 0;
for( nLen2 -= 2; nRead < nLen2; )
@@ -4274,31 +4263,31 @@ void WW8ReadSTTBF(bool bVer8, SvStream& rStrm, sal_uInt32 nStart, sal_Int32 nLen
}
WW8PLCFx_Book::WW8PLCFx_Book(SvStream* pTableSt, const WW8Fib& rFib)
- : WW8PLCFx(rFib, false), nIsEnd(0), nBookmarkId(1)
+ : WW8PLCFx(rFib, false), m_nIsEnd(0), m_nBookmarkId(1)
{
if( !rFib.m_fcPlcfbkf || !rFib.m_lcbPlcfbkf || !rFib.m_fcPlcfbkl ||
!rFib.m_lcbPlcfbkl || !rFib.m_fcSttbfbkmk || !rFib.m_lcbSttbfbkmk )
{
- nIMax = 0;
+ m_nIMax = 0;
}
else
{
- pBook[0].reset( new WW8PLCFspecial(pTableSt,rFib.m_fcPlcfbkf,rFib.m_lcbPlcfbkf,4) );
+ m_pBook[0].reset( new WW8PLCFspecial(pTableSt,rFib.m_fcPlcfbkf,rFib.m_lcbPlcfbkf,4) );
- pBook[1].reset( new WW8PLCFspecial(pTableSt,rFib.m_fcPlcfbkl,rFib.m_lcbPlcfbkl,0) );
+ m_pBook[1].reset( new WW8PLCFspecial(pTableSt,rFib.m_fcPlcfbkl,rFib.m_lcbPlcfbkl,0) );
rtl_TextEncoding eStructChrSet = WW8Fib::GetFIBCharset(rFib.m_chseTables, rFib.m_lid);
WW8ReadSTTBF( (7 < rFib.m_nVersion), *pTableSt, rFib.m_fcSttbfbkmk,
- rFib.m_lcbSttbfbkmk, 0, eStructChrSet, aBookNames );
+ rFib.m_lcbSttbfbkmk, 0, eStructChrSet, m_aBookNames );
- nIMax = aBookNames.size();
+ m_nIMax = m_aBookNames.size();
- if( pBook[0]->GetIMax() < nIMax ) // Count of Bookmarks
- nIMax = pBook[0]->GetIMax();
- if( pBook[1]->GetIMax() < nIMax )
- nIMax = pBook[1]->GetIMax();
- aStatus.resize(nIMax);
+ if( m_pBook[0]->GetIMax() < m_nIMax ) // Count of Bookmarks
+ m_nIMax = m_pBook[0]->GetIMax();
+ if( m_pBook[1]->GetIMax() < m_nIMax )
+ m_nIMax = m_pBook[1]->GetIMax();
+ m_aStatus.resize(m_nIMax);
}
}
@@ -4308,44 +4297,44 @@ WW8PLCFx_Book::~WW8PLCFx_Book()
sal_uInt32 WW8PLCFx_Book::GetIdx() const
{
- return nIMax ? pBook[0]->GetIdx() : 0;
+ return m_nIMax ? m_pBook[0]->GetIdx() : 0;
}
void WW8PLCFx_Book::SetIdx(sal_uInt32 nI)
{
- if( nIMax )
- pBook[0]->SetIdx( nI );
+ if( m_nIMax )
+ m_pBook[0]->SetIdx( nI );
}
sal_uInt32 WW8PLCFx_Book::GetIdx2() const
{
- return nIMax ? ( pBook[1]->GetIdx() | ( nIsEnd ? 0x80000000 : 0 ) ) : 0;
+ return m_nIMax ? ( m_pBook[1]->GetIdx() | ( m_nIsEnd ? 0x80000000 : 0 ) ) : 0;
}
void WW8PLCFx_Book::SetIdx2(sal_uInt32 nI)
{
- if( nIMax )
+ if( m_nIMax )
{
- pBook[1]->SetIdx( nI & 0x7fffffff );
- nIsEnd = static_cast<sal_uInt16>( ( nI >> 31 ) & 1 ); // 0 or 1
+ m_pBook[1]->SetIdx( nI & 0x7fffffff );
+ m_nIsEnd = o3tl::narrowing<sal_uInt16>( ( nI >> 31 ) & 1 ); // 0 or 1
}
}
bool WW8PLCFx_Book::SeekPos(WW8_CP nCpPos)
{
- if( !pBook[0] )
+ if( !m_pBook[0] )
return false;
- bool bOk = pBook[0]->SeekPosExact( nCpPos );
- bOk &= pBook[1]->SeekPosExact( nCpPos );
- nIsEnd = 0;
+ bool bOk = m_pBook[0]->SeekPosExact( nCpPos );
+ bOk &= m_pBook[1]->SeekPosExact( nCpPos );
+ m_nIsEnd = 0;
return bOk;
}
WW8_CP WW8PLCFx_Book::Where()
{
- return pBook[nIsEnd]->Where();
+ return m_pBook[m_nIsEnd]->Where();
}
tools::Long WW8PLCFx_Book::GetNoSprms( WW8_CP& rStart, WW8_CP& rEnd, sal_Int32& rLen )
@@ -4354,14 +4343,14 @@ tools::Long WW8PLCFx_Book::GetNoSprms( WW8_CP& rStart, WW8_CP& rEnd, sal_Int32&
rEnd = WW8_CP_MAX;
rLen = 0;
- if (!pBook[0] || !pBook[1] || !nIMax || (pBook[nIsEnd]->GetIdx()) >= nIMax)
+ if (!m_pBook[0] || !m_pBook[1] || !m_nIMax || (m_pBook[m_nIsEnd]->GetIdx()) >= m_nIMax)
{
rStart = rEnd = WW8_CP_MAX;
return -1;
}
- (void)pBook[nIsEnd]->Get( rStart, pData ); // query position
- return pBook[nIsEnd]->GetIdx();
+ (void)m_pBook[m_nIsEnd]->Get( rStart, pData ); // query position
+ return m_pBook[m_nIsEnd]->GetIdx();
}
// The operator ++ has a pitfall: If 2 bookmarks adjoin each other,
@@ -4379,74 +4368,74 @@ tools::Long WW8PLCFx_Book::GetNoSprms( WW8_CP& rStart, WW8_CP& rEnd, sal_Int32&
void WW8PLCFx_Book::advance()
{
- if( !(pBook[0] && pBook[1] && nIMax) )
+ if( !(m_pBook[0] && m_pBook[1] && m_nIMax) )
return;
- (*pBook[nIsEnd]).advance();
+ (*m_pBook[m_nIsEnd]).advance();
- sal_uLong l0 = pBook[0]->Where();
- sal_uLong l1 = pBook[1]->Where();
+ sal_uLong l0 = m_pBook[0]->Where();
+ sal_uLong l1 = m_pBook[1]->Where();
if( l0 < l1 )
- nIsEnd = 0;
+ m_nIsEnd = 0;
else if( l1 < l0 )
- nIsEnd = 1;
+ m_nIsEnd = 1;
else
{
- const void * p = pBook[0]->GetData(pBook[0]->GetIdx());
+ const void * p = m_pBook[0]->GetData(m_pBook[0]->GetIdx());
tools::Long nPairFor = (p == nullptr) ? 0 : SVBT16ToUInt16(*static_cast<SVBT16 const *>(p));
- if (nPairFor == pBook[1]->GetIdx())
- nIsEnd = 0;
+ if (nPairFor == m_pBook[1]->GetIdx())
+ m_nIsEnd = 0;
else
- nIsEnd = nIsEnd ? 0 : 1;
+ m_nIsEnd = m_nIsEnd ? 0 : 1;
}
}
tools::Long WW8PLCFx_Book::GetLen() const
{
- if( nIsEnd )
+ if( m_nIsEnd )
{
OSL_ENSURE( false, "Incorrect call (1) of PLCF_Book::GetLen()" );
return 0;
}
void * p;
WW8_CP nStartPos;
- if( !pBook[0]->Get( nStartPos, p ) )
+ if( !m_pBook[0]->Get( nStartPos, p ) )
{
OSL_ENSURE( false, "Incorrect call (2) of PLCF_Book::GetLen()" );
return 0;
}
const sal_uInt16 nEndIdx = SVBT16ToUInt16( *static_cast<SVBT16*>(p) );
- tools::Long nNum = pBook[1]->GetPos( nEndIdx );
+ tools::Long nNum = m_pBook[1]->GetPos( nEndIdx );
nNum -= nStartPos;
return nNum;
}
void WW8PLCFx_Book::SetStatus(sal_uInt16 nIndex, eBookStatus eStat)
{
- SAL_WARN_IF(nIndex >= nIMax, "sw.ww8",
+ SAL_WARN_IF(nIndex >= m_nIMax, "sw.ww8",
"bookmark index " << nIndex << " invalid");
- eBookStatus eStatus = aStatus.at(nIndex);
- aStatus[nIndex] = static_cast<eBookStatus>(eStatus | eStat);
+ eBookStatus eStatus = m_aStatus.at(nIndex);
+ m_aStatus[nIndex] = static_cast<eBookStatus>(eStatus | eStat);
}
eBookStatus WW8PLCFx_Book::GetStatus() const
{
- if (aStatus.empty())
+ if (m_aStatus.empty())
return BOOK_NORMAL;
tools::Long nEndIdx = GetHandle();
- return ( nEndIdx < nIMax ) ? aStatus[nEndIdx] : BOOK_NORMAL;
+ return ( nEndIdx < m_nIMax ) ? m_aStatus[nEndIdx] : BOOK_NORMAL;
}
tools::Long WW8PLCFx_Book::GetHandle() const
{
- if( !pBook[0] || !pBook[1] )
+ if( !m_pBook[0] || !m_pBook[1] )
return LONG_MAX;
- if( nIsEnd )
- return pBook[1]->GetIdx();
+ if( m_nIsEnd )
+ return m_pBook[1]->GetIdx();
else
{
- if (const void* p = pBook[0]->GetData(pBook[0]->GetIdx()))
+ if (const void* p = m_pBook[0]->GetData(m_pBook[0]->GetIdx()))
return SVBT16ToUInt16( *static_cast<SVBT16 const *>(p) );
else
return LONG_MAX;
@@ -4457,15 +4446,15 @@ OUString WW8PLCFx_Book::GetBookmark(tools::Long nStart,tools::Long nEnd, sal_uIn
{
bool bFound = false;
sal_uInt16 i = 0;
- if (pBook[0] && pBook[1])
+ if (m_pBook[0] && m_pBook[1])
{
WW8_CP nStartCurrent, nEndCurrent;
- while (sal::static_int_cast<decltype(aBookNames)::size_type>(i) < aBookNames.size())
+ while (sal::static_int_cast<decltype(m_aBookNames)::size_type>(i) < m_aBookNames.size())
{
void* p;
sal_uInt16 nEndIdx;
- if( pBook[0]->GetData( i, nStartCurrent, p ) && p )
+ if( m_pBook[0]->GetData( i, nStartCurrent, p ) && p )
nEndIdx = SVBT16ToUInt16( *static_cast<SVBT16*>(p) );
else
{
@@ -4473,7 +4462,7 @@ OUString WW8PLCFx_Book::GetBookmark(tools::Long nStart,tools::Long nEnd, sal_uIn
nEndIdx = i;
}
- nEndCurrent = pBook[1]->GetPos( nEndIdx );
+ nEndCurrent = m_pBook[1]->GetPos( nEndIdx );
if ((nStartCurrent >= nStart) && (nEndCurrent <= nEnd))
{
@@ -4484,22 +4473,22 @@ OUString WW8PLCFx_Book::GetBookmark(tools::Long nStart,tools::Long nEnd, sal_uIn
++i;
}
}
- return bFound ? aBookNames[i] : OUString();
+ return bFound ? m_aBookNames[i] : OUString();
}
OUString WW8PLCFx_Book::GetUniqueBookmarkName(const OUString &rSuggestedName)
{
OUString aRet(rSuggestedName.isEmpty() ? OUString("Unnamed") : rSuggestedName);
size_t i = 0;
- while (i < aBookNames.size())
+ while (i < m_aBookNames.size())
{
- if (aRet == aBookNames[i])
+ if (aRet == m_aBookNames[i])
{
sal_Int32 len = aRet.getLength();
sal_Int32 p = len - 1;
while (p > 0 && aRet[p] >= '0' && aRet[p] <= '9')
--p;
- aRet = aRet.subView(0, p+1) + OUString::number(nBookmarkId++);
+ aRet = aRet.subView(0, p+1) + OUString::number(m_nBookmarkId++);
i = 0; // start search from beginning
}
else
@@ -4510,15 +4499,15 @@ OUString WW8PLCFx_Book::GetUniqueBookmarkName(const OUString &rSuggestedName)
void WW8PLCFx_Book::MapName(OUString& rName)
{
- if( !pBook[0] || !pBook[1] )
+ if( !m_pBook[0] || !m_pBook[1] )
return;
size_t i = 0;
- while (i < aBookNames.size())
+ while (i < m_aBookNames.size())
{
- if (rName.equalsIgnoreAsciiCase(aBookNames[i]))
+ if (rName.equalsIgnoreAsciiCase(m_aBookNames[i]))
{
- rName = aBookNames[i];
+ rName = m_aBookNames[i];
break;
}
++i;
@@ -4528,8 +4517,8 @@ void WW8PLCFx_Book::MapName(OUString& rName)
const OUString* WW8PLCFx_Book::GetName() const
{
const OUString *pRet = nullptr;
- if (!nIsEnd && (pBook[0]->GetIdx() < nIMax))
- pRet = &(aBookNames[pBook[0]->GetIdx()]);
+ if (!m_nIsEnd && (m_pBook[0]->GetIdx() < m_nIMax))
+ pRet = &(m_aBookNames[m_pBook[0]->GetIdx()]);
return pRet;
}
@@ -4539,16 +4528,16 @@ WW8PLCFx_AtnBook::WW8PLCFx_AtnBook(SvStream* pTableSt, const WW8Fib& rFib)
{
if (!rFib.m_fcPlcfAtnbkf || !rFib.m_lcbPlcfAtnbkf || !rFib.m_fcPlcfAtnbkl || !rFib.m_lcbPlcfAtnbkl)
{
- nIMax = 0;
+ m_nIMax = 0;
}
else
{
m_pBook[0].reset( new WW8PLCFspecial(pTableSt, rFib.m_fcPlcfAtnbkf, rFib.m_lcbPlcfAtnbkf, 4) );
m_pBook[1].reset( new WW8PLCFspecial(pTableSt, rFib.m_fcPlcfAtnbkl, rFib.m_lcbPlcfAtnbkl, 0) );
- nIMax = m_pBook[0]->GetIMax();
- if (m_pBook[1]->GetIMax() < nIMax)
- nIMax = m_pBook[1]->GetIMax();
+ m_nIMax = m_pBook[0]->GetIMax();
+ if (m_pBook[1]->GetIMax() < m_nIMax)
+ m_nIMax = m_pBook[1]->GetIMax();
}
}
@@ -4558,18 +4547,18 @@ WW8PLCFx_AtnBook::~WW8PLCFx_AtnBook()
sal_uInt32 WW8PLCFx_AtnBook::GetIdx() const
{
- return nIMax ? m_pBook[0]->GetIdx() : 0;
+ return m_nIMax ? m_pBook[0]->GetIdx() : 0;
}
void WW8PLCFx_AtnBook::SetIdx(sal_uInt32 nI)
{
- if( nIMax )
+ if( m_nIMax )
m_pBook[0]->SetIdx( nI );
}
sal_uInt32 WW8PLCFx_AtnBook::GetIdx2() const
{
- if (nIMax)
+ if (m_nIMax)
return m_pBook[1]->GetIdx() | ( m_bIsEnd ? 0x80000000 : 0 );
else
return 0;
@@ -4577,7 +4566,7 @@ sal_uInt32 WW8PLCFx_AtnBook::GetIdx2() const
void WW8PLCFx_AtnBook::SetIdx2(sal_uInt32 nI)
{
- if( nIMax )
+ if( m_nIMax )
{
m_pBook[1]->SetIdx( nI & 0x7fffffff );
m_bIsEnd = static_cast<bool>(( nI >> 31 ) & 1);
@@ -4607,7 +4596,7 @@ tools::Long WW8PLCFx_AtnBook::GetNoSprms( WW8_CP& rStart, WW8_CP& rEnd, sal_Int3
rEnd = WW8_CP_MAX;
rLen = 0;
- if (!m_pBook[0] || !m_pBook[1] || !nIMax || (m_pBook[static_cast<int>(m_bIsEnd)]->GetIdx()) >= nIMax)
+ if (!m_pBook[0] || !m_pBook[1] || !m_nIMax || (m_pBook[static_cast<int>(m_bIsEnd)]->GetIdx()) >= m_nIMax)
{
rStart = rEnd = WW8_CP_MAX;
return -1;
@@ -4619,7 +4608,7 @@ tools::Long WW8PLCFx_AtnBook::GetNoSprms( WW8_CP& rStart, WW8_CP& rEnd, sal_Int3
void WW8PLCFx_AtnBook::advance()
{
- if( !(m_pBook[0] && m_pBook[1] && nIMax) )
+ if( !(m_pBook[0] && m_pBook[1] && m_nIMax) )
return;
(*m_pBook[static_cast<int>(m_bIsEnd)]).advance();
@@ -5074,7 +5063,7 @@ WW8PLCFMan::WW8PLCFMan(const WW8ScannerBase* pBase, ManTypes nType, tools::Long
if( p->pPLCFx->IsSprm() )
{
// Careful: nEndPos must be
- p->xIdStack.reset(new std::stack<sal_uInt16>);
+ p->xIdStack.emplace();
if ((p == m_pChp) || (p == m_pPap))
{
WW8_CP nTemp = p->nEndPos+p->nCpOfs;
@@ -5226,7 +5215,8 @@ bool WW8PLCFMan::IsSprmLegalForCategory(sal_uInt16 nSprmId, short nIdx) const
auto nSGC = ((nSprmId & 0x1C00) >> 10);
bRet = nSGC == 4;
}
- SAL_WARN_IF(!bRet, "sw.ww8", "sprm, id " << nSprmId << " wrong category for section properties");
+ if (!bRet)
+ SAL_INFO("sw.ww8", "sprm, id " << nSprmId << " wrong category for section properties");
return bRet;
}
@@ -5400,7 +5390,7 @@ void WW8PLCFMan::AdvSprm(short nIdx, bool bStart)
p->nStartPos = p->nOrigEndPos+p->nCpOfs;
/*
- On failed seek we have run out of sprms, probably. But if its
+ On failed seek we have run out of sprms, probably. But if it's
a fastsaved file (has pPcd) then we may be just in a sprm free
gap between pieces that have them, so set dirty flag in sprm
finder to consider than.
@@ -5630,31 +5620,31 @@ sal_uInt32 WW8PLCFx_Cp_FKP::GetIdx2() const
void WW8PLCFx_Cp_FKP::SetIdx2(sal_uInt32 nIdx)
{
- if( pPcd )
- pPcd->SetIdx( nIdx );
+ if( m_pPcd )
+ m_pPcd->SetIdx( nIdx );
}
void WW8PLCFx_Cp_FKP::Save( WW8PLCFxSave1& rSave ) const
{
- if (pFkp)
- pFkp->IncMustRemainCache();
+ if (m_pFkp)
+ m_pFkp->IncMustRemainCache();
WW8PLCFx::Save( rSave );
- rSave.nAttrStart = nAttrStart;
- rSave.nAttrEnd = nAttrEnd;
- rSave.bLineEnd = bLineEnd;
+ rSave.nAttrStart = m_nAttrStart;
+ rSave.nAttrEnd = m_nAttrEnd;
+ rSave.bLineEnd = m_bLineEnd;
}
void WW8PLCFx_Cp_FKP::Restore( const WW8PLCFxSave1& rSave )
{
WW8PLCFx::Restore( rSave );
- nAttrStart = rSave.nAttrStart;
- nAttrEnd = rSave.nAttrEnd;
- bLineEnd = rSave.bLineEnd;
+ m_nAttrStart = rSave.nAttrStart;
+ m_nAttrEnd = rSave.nAttrEnd;
+ m_bLineEnd = rSave.bLineEnd;
- if (pFkp)
- pFkp->DecMustRemainCache();
+ if (m_pFkp)
+ m_pFkp->DecMustRemainCache();
}
void WW8PLCFxDesc::Save( WW8PLCFxSave1& rSave ) const
@@ -5853,9 +5843,6 @@ WW8Fib::WW8Fib(SvStream& rSt, sal_uInt8 nWantedVersion, sal_uInt32 nOffset):
// above bit-field member initializations can be moved to the class definition
{
// See [MS-DOC] 2.5.15 "How to read the FIB".
- sal_uInt8 aBits1;
- sal_uInt8 aBits2;
- sal_uInt8 aVer8Bits1; // only used starting with WinWord 8
rSt.Seek( nOffset );
/*
note desired number, identify file version number
@@ -5914,13 +5901,16 @@ WW8Fib::WW8Fib(SvStream& rSt, sal_uInt8 nWantedVersion, sal_uInt32 nOffset):
rSt.ReadUInt16(nTmpLid);
m_lid = LanguageType(nTmpLid);
rSt.ReadInt16( m_pnNext );
+ sal_uInt8 aBits1(0);
rSt.ReadUChar( aBits1 );
+ sal_uInt8 aBits2(0);
rSt.ReadUChar( aBits2 );
rSt.ReadUInt16( m_nFibBack );
rSt.ReadUInt16( m_nHash );
rSt.ReadUInt16( m_nKey );
rSt.ReadUChar( m_envr );
- rSt.ReadUChar( aVer8Bits1 ); // only have an empty reserve field under Ver67
+ sal_uInt8 aVer8Bits1(0); // only used starting with WinWord 8
+ rSt.ReadUChar( aVer8Bits1 ); // only have an empty reserve field under Ver67
// content from aVer8Bits1
// sal_uInt8 fMac :1;
@@ -6005,7 +5995,7 @@ WW8Fib::WW8Fib(SvStream& rSt, sal_uInt8 nWantedVersion, sal_uInt32 nOffset):
rSt.ReadUInt16( m_cfclcb );
// Read cswNew to find out if nFib should be ignored.
- sal_uInt32 nPos = rSt.Tell();
+ sal_uInt64 nPos = rSt.Tell();
rSt.SeekRel(m_cfclcb * 8);
if (rSt.good() && rSt.remainingSize() >= 2)
{
@@ -6213,7 +6203,7 @@ WW8Fib::WW8Fib(SvStream& rSt, sal_uInt8 nWantedVersion, sal_uInt32 nOffset):
identify the values for PLCF and PLF LFO
and PLCF for the textbox break descriptors
*/
- tools::Long nOldPos = rSt.Tell();
+ sal_uInt64 nOldPos = rSt.Tell();
rSt.Seek( 0x02da );
rSt.ReadInt32( m_fcSttbFnm );
@@ -6333,7 +6323,7 @@ WW8Fib::WW8Fib(sal_uInt8 nVer, bool bDot):
m_lidFE = m_lid;
LanguageTag aLanguageTag( m_lid );
- LocaleDataWrapper aLocaleWrapper( aLanguageTag );
+ LocaleDataWrapper aLocaleWrapper( std::move(aLanguageTag) );
m_nNumDecimalSep = aLocaleWrapper.getNumDecimalSep()[0];
}
@@ -6554,10 +6544,10 @@ void WW8Fib::Write(SvStream& rStrm)
if( !bVer8 )
{
pData += 1*sizeof( sal_Int16);
- Set_UInt16( pData, static_cast<sal_uInt16>(m_pnChpFirst) );
- Set_UInt16( pData, static_cast<sal_uInt16>(m_pnPapFirst) );
- Set_UInt16( pData, static_cast<sal_uInt16>(m_cpnBteChp) );
- Set_UInt16( pData, static_cast<sal_uInt16>(m_cpnBtePap) );
+ Set_UInt16( pData, o3tl::narrowing<sal_uInt16>(m_pnChpFirst) );
+ Set_UInt16( pData, o3tl::narrowing<sal_uInt16>(m_pnPapFirst) );
+ Set_UInt16( pData, o3tl::narrowing<sal_uInt16>(m_cpnBteChp) );
+ Set_UInt16( pData, o3tl::narrowing<sal_uInt16>(m_cpnBtePap) );
}
Set_UInt32( pData, m_fcPlcfdoaMom ); // only at Ver67, in Ver8 unused
@@ -6703,13 +6693,13 @@ static OUString Read(SvStream& rStream)
return aRet;
}
-static void Write(const OUString& rString, SvStream& rStream)
+static void Write(std::u16string_view aString, SvStream& rStream)
{
sal_uInt16 nBuf = 0;
- nBuf |= rString.getLength(); // cch, 0..14th bits.
+ nBuf |= sal_Int32(aString.size()); // cch, 0..14th bits.
nBuf |= 0x8000; // fAnsiString, 15th bit.
rStream.WriteUInt16(nBuf);
- SwWW8Writer::WriteString8(rStream, rString, false, RTL_TEXTENCODING_ASCII_US);
+ SwWW8Writer::WriteString8(rStream, aString, false, RTL_TEXTENCODING_ASCII_US);
}
};
@@ -6725,13 +6715,13 @@ void MSOFactoidType::Read(SvStream& rStream)
void MSOFactoidType::Write(WW8Export& rExport)
{
- SvStream& rStream = *rExport.pTableStrm;
+ SvStream& rStream = *rExport.m_pTableStrm;
SvMemoryStream aStream;
aStream.WriteUInt32(m_nId); // id
MSOPBString::Write(m_aUri, aStream);
MSOPBString::Write(m_aTag, aStream);
- MSOPBString::Write("", aStream); // rgbDownloadURL
+ MSOPBString::Write(u"", aStream); // rgbDownloadURL
rStream.WriteUInt32(aStream.Tell());
aStream.Seek(0);
rStream.WriteStream(aStream);
@@ -6774,7 +6764,7 @@ void MSOPropertyBagStore::Read(SvStream& rStream)
void MSOPropertyBagStore::Write(WW8Export& rExport)
{
- SvStream& rStream = *rExport.pTableStrm;
+ SvStream& rStream = *rExport.m_pTableStrm;
rStream.WriteUInt32(m_aFactoidTypes.size()); // cFactoidType
for (MSOFactoidType& rType : m_aFactoidTypes)
rType.Write(rExport);
@@ -6835,7 +6825,7 @@ bool MSOPropertyBag::Read(SvStream& rStream)
void MSOPropertyBag::Write(WW8Export& rExport)
{
- SvStream& rStream = *rExport.pTableStrm;
+ SvStream& rStream = *rExport.m_pTableStrm;
rStream.WriteUInt16(m_nId);
rStream.WriteUInt16(m_aProperties.size());
rStream.WriteUInt16(0); // cbUnknown
@@ -6965,7 +6955,10 @@ WW8Style::WW8Style(SvStream& rStream, WW8Fib& rFibPara)
std::unique_ptr<WW8_STD> WW8Style::Read1STDFixed(sal_uInt16& rSkip)
{
if (m_rStream.remainingSize() < 2)
+ {
+ rSkip = 0;
return nullptr;
+ }
std::unique_ptr<WW8_STD> pStd;
@@ -7205,16 +7198,17 @@ namespace
return true;
}
- sal_Int32 getStringLength(
- sal_uInt8 const * p, std::size_t offset, sal_uInt8 const * pEnd)
+ sal_Int32 getStringLengthWithMax(
+ sal_uInt8 const * p, std::size_t offset, sal_uInt8 const * pEnd, std::size_t maxchars)
{
assert(p <= pEnd);
assert(pEnd - p <= SAL_MAX_INT32);
if (offset >= o3tl::make_unsigned(pEnd - p)) {
return -1;
}
- void const * p2 = std::memchr(
- p + offset, 0, static_cast<std::size_t>(pEnd - p) - offset);
+ std::size_t nbytes = static_cast<std::size_t>(pEnd - p) - offset;
+ std::size_t nsearch = std::min(nbytes, maxchars + 1);
+ void const * p2 = std::memchr(p + offset, 0, nsearch);
if (p2 == nullptr) {
return -1;
}
@@ -7313,12 +7307,13 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib const & rFib )
if ((eEnc == RTL_TEXTENCODING_SYMBOL) || (eEnc == RTL_TEXTENCODING_DONTKNOW))
eEnc = RTL_TEXTENCODING_MS_1252;
- sal_Int32 n = getStringLength(pVer2, 1 + 2, pEnd);
+ const size_t nStringOffset = 1 + 2;
+ sal_Int32 n = getStringLengthWithMax(pVer2, nStringOffset, pEnd, maxStrSize);
if (n == -1) {
break;
}
p->sFontname = OUString(
- reinterpret_cast<char const *>(pVer2 + 1 + 2), n, eEnc);
+ reinterpret_cast<char const *>(pVer2 + nStringOffset), n, eEnc);
pVer2 = pVer2 + p->aFFNBase.cbFfnM1 + 1;
}
nMax = i;
@@ -7364,26 +7359,20 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib const & rFib )
rtl_TextEncoding eEnc = WW8Fib::GetFIBCharset(p->aFFNBase.chs, rFib.m_lid);
if ((eEnc == RTL_TEXTENCODING_SYMBOL) || (eEnc == RTL_TEXTENCODING_DONTKNOW))
eEnc = RTL_TEXTENCODING_MS_1252;
- sal_Int32 n = getStringLength(
- pVer6, offsetof(WW8_FFN_Ver6, szFfn), pEnd);
+ const size_t nStringOffset = offsetof(WW8_FFN_Ver6, szFfn);
+ sal_Int32 n = getStringLengthWithMax(pVer6, nStringOffset, pEnd, maxStrSize);
if (n == -1) {
break;
}
- p->sFontname = OUString(
- reinterpret_cast<char const *>(
- pVer6 + offsetof(WW8_FFN_Ver6, szFfn)),
- n, eEnc);
+ p->sFontname = OUString(reinterpret_cast<char const*>(pVer6 + nStringOffset), n, eEnc);
if (p->aFFNBase.ibszAlt && p->aFFNBase.ibszAlt < maxStrSize) //don't start after end of string
{
- n = getStringLength(
- pVer6, offsetof(WW8_FFN_Ver6, szFfn) + p->aFFNBase.ibszAlt,
- pEnd);
+ const size_t nAltStringOffset = offsetof(WW8_FFN_Ver6, szFfn) + p->aFFNBase.ibszAlt;
+ n = getStringLengthWithMax(pVer6, nAltStringOffset, pEnd, maxStrSize);
if (n == -1) {
break;
}
- p->sFontname += ";" + OUString(
- reinterpret_cast<char const *>(
- pVer6 + offsetof(WW8_FFN_Ver6, szFfn) + p->aFFNBase.ibszAlt),
+ p->sFontname += ";" + OUString(reinterpret_cast<char const*>(pVer6 + nAltStringOffset),
n, eEnc);
}
else
@@ -7505,9 +7494,9 @@ const WW8_FFN* WW8Fonts::GetFont( sal_uInt16 nNum ) const
// -> maybe we can get a right result then
WW8PLCF_HdFt::WW8PLCF_HdFt( SvStream* pSt, WW8Fib const & rFib, WW8Dop const & rDop )
- : aPLCF(*pSt, rFib.m_fcPlcfhdd , rFib.m_lcbPlcfhdd , 0)
+ : m_aPLCF(*pSt, rFib.m_fcPlcfhdd , rFib.m_lcbPlcfhdd , 0)
{
- nIdxOffset = 0;
+ m_nIdxOffset = 0;
/*
This dop.grpfIhdt has a bit set for each special
@@ -7523,14 +7512,14 @@ WW8PLCF_HdFt::WW8PLCF_HdFt( SvStream* pSt, WW8Fib const & rFib, WW8Dop const & r
*/
for( sal_uInt8 nI = 0x1; nI <= 0x20; nI <<= 1 )
if( nI & rDop.grpfIhdt ) // bit set?
- nIdxOffset++;
+ m_nIdxOffset++;
}
bool WW8PLCF_HdFt::GetTextPos(sal_uInt8 grpfIhdt, sal_uInt8 nWhich, WW8_CP& rStart,
WW8_CP& rLen)
{
sal_uInt8 nI = 0x01;
- short nIdx = nIdxOffset;
+ short nIdx = m_nIdxOffset;
while (true)
{
if( nI & nWhich )
@@ -7545,8 +7534,8 @@ bool WW8PLCF_HdFt::GetTextPos(sal_uInt8 grpfIhdt, sal_uInt8 nWhich, WW8_CP& rSta
WW8_CP nEnd;
void* pData;
- aPLCF.SetIdx( nIdx ); // Lookup suitable CP
- aPLCF.Get( rStart, nEnd, pData );
+ m_aPLCF.SetIdx( nIdx ); // Lookup suitable CP
+ m_aPLCF.Get( rStart, nEnd, pData );
if (nEnd < rStart)
{
SAL_WARN("sw.ww8", "End " << nEnd << " before Start " << rStart);
@@ -7560,7 +7549,7 @@ bool WW8PLCF_HdFt::GetTextPos(sal_uInt8 grpfIhdt, sal_uInt8 nWhich, WW8_CP& rSta
return false;
}
- aPLCF.advance();
+ m_aPLCF.advance();
return true;
}
@@ -7570,8 +7559,8 @@ void WW8PLCF_HdFt::GetTextPosExact(short nIdx, WW8_CP& rStart, WW8_CP& rLen)
WW8_CP nEnd;
void* pData;
- aPLCF.SetIdx( nIdx ); // Lookup suitable CP
- aPLCF.Get( rStart, nEnd, pData );
+ m_aPLCF.SetIdx( nIdx ); // Lookup suitable CP
+ m_aPLCF.Get( rStart, nEnd, pData );
if (nEnd < rStart)
{
SAL_WARN("sw.ww8", "End " << nEnd << " before Start " << rStart);
@@ -7590,7 +7579,7 @@ void WW8PLCF_HdFt::UpdateIndex( sal_uInt8 grpfIhdt )
// Caution: Description is not correct
for( sal_uInt8 nI = 0x01; nI <= 0x20; nI <<= 1 )
if( nI & grpfIhdt )
- nIdxOffset++;
+ m_nIdxOffset++;
}
WW8Dop::WW8Dop(SvStream& rSt, sal_Int16 nFib, sal_Int32 nPos, sal_uInt32 nSize):
@@ -7629,7 +7618,7 @@ WW8Dop::WW8Dop(SvStream& rSt, sal_Int16 nFib, sal_Int32 nPos, sal_uInt32 nSize):
fCompatibilityOptions_Unknown2_5(false), fCompatibilityOptions_Unknown2_6(false),
fCompatibilityOptions_Unknown2_7(false), fCompatibilityOptions_Unknown2_8(false),
fCompatibilityOptions_Unknown2_9(false), fCompatibilityOptions_Unknown2_10(false),
- fCompatibilityOptions_Unknown2_11(false), fCompatibilityOptions_Unknown2_12(false),
+ fDontBreakWrappedTables(false), fCompatibilityOptions_Unknown2_12(false),
fCompatibilityOptions_Unknown2_13(false), fCompatibilityOptions_Unknown2_14(false),
fCompatibilityOptions_Unknown2_15(false), fCompatibilityOptions_Unknown2_16(false),
fCompatibilityOptions_Unknown2_17(false), fCompatibilityOptions_Unknown2_18(false),
@@ -7900,7 +7889,7 @@ WW8Dop::WW8Dop():
fCompatibilityOptions_Unknown2_5(false), fCompatibilityOptions_Unknown2_6(false),
fCompatibilityOptions_Unknown2_7(false), fCompatibilityOptions_Unknown2_8(false),
fCompatibilityOptions_Unknown2_9(false), fCompatibilityOptions_Unknown2_10(false),
- fCompatibilityOptions_Unknown2_11(false), fCompatibilityOptions_Unknown2_12(false),
+ fDontBreakWrappedTables(false), fCompatibilityOptions_Unknown2_12(false),
fCompatibilityOptions_Unknown2_13(false), fCompatibilityOptions_Unknown2_14(false),
fCompatibilityOptions_Unknown2_15(false), fCompatibilityOptions_Unknown2_16(false),
fCompatibilityOptions_Unknown2_17(false), fCompatibilityOptions_Unknown2_18(false),
@@ -8017,7 +8006,7 @@ void WW8Dop::SetCompatibilityOptions2(sal_uInt32 a32Bit)
fCompatibilityOptions_Unknown2_8 = ( a32Bit & 0x00000080 ) >> 7 ;
fCompatibilityOptions_Unknown2_9 = ( a32Bit & 0x00000100 ) >> 8 ;
fCompatibilityOptions_Unknown2_10 = ( a32Bit & 0x00000200 ) >> 9 ;
- fCompatibilityOptions_Unknown2_11 = ( a32Bit & 0x00000400 ) >> 10 ;
+ fDontBreakWrappedTables = ( a32Bit & 0x00000400 ) >> 10 ;
fCompatibilityOptions_Unknown2_12 = ( a32Bit & 0x00000800 ) >> 11 ;
fCompatibilityOptions_Unknown2_13 = ( a32Bit & 0x00001000 ) >> 12 ;
fCompatibilityOptions_Unknown2_14 = ( a32Bit & 0x00002000 ) >> 13 ;
@@ -8054,7 +8043,7 @@ sal_uInt32 WW8Dop::GetCompatibilityOptions2() const
if (fCompatibilityOptions_Unknown2_8) a32Bit |= 0x00000080;
if (fCompatibilityOptions_Unknown2_9) a32Bit |= 0x00000100;
if (fCompatibilityOptions_Unknown2_10) a32Bit |= 0x00000200;
- if (fCompatibilityOptions_Unknown2_11) a32Bit |= 0x00000400;
+ if (fDontBreakWrappedTables) a32Bit |= 0x00000400;
if (fCompatibilityOptions_Unknown2_12) a32Bit |= 0x00000800;
if (fCompatibilityOptions_Unknown2_13) a32Bit |= 0x00001000;
//#i42909# set thai "line breaking rules" compatibility option
@@ -8406,18 +8395,6 @@ sal_uInt16 wwSprmParser::GetSprmTailLen(sal_uInt16 nId, const sal_uInt8* pSprm,
nL = 2 + 4 * nDel + 3 * nIns;
}
break;
- case 0xD608:
- {
- sal_uInt8 nIndex = 1 + mnDelta;
- if (nIndex + 1 >= nRemLen)
- {
- SAL_WARN("sw.ww8", "sprm longer than remaining bytes, doc or parser is wrong");
- nL = 0;
- }
- else
- nL = SVBT16ToUInt16(&pSprm[nIndex]);
- break;
- }
default:
switch (aSprm.nVari)
{
@@ -8425,14 +8402,16 @@ sal_uInt16 wwSprmParser::GetSprmTailLen(sal_uInt16 nId, const sal_uInt8* pSprm,
nL = aSprm.nLen; // Excl. Token
break;
case L_VAR:
- // Variable 1-Byte Length?
- // Excl. Token + Var-Lengthbyte
+ // Variable 1-Byte Length
+ // parameter length (i.e. excluding token and length byte)
nL = static_cast< sal_uInt16 >(pSprm[1 + mnDelta] + aSprm.nLen);
break;
case L_VAR2:
{
- // Variable 2-Byte Length?
- // Excl. Token + Var-Lengthbyte
+ // Variable 2-Byte Length
+ // For sprmTDefTable and sprmTDefTable10, the length of the
+ // parameter plus 1 is recorded in the two bytes beginning
+ // at offset (WW7-) 1 or (WW8+) 2
sal_uInt8 nIndex = 1 + mnDelta;
sal_uInt16 nCount;
if (nIndex + 1 >= nRemLen)
@@ -8441,8 +8420,13 @@ sal_uInt16 wwSprmParser::GetSprmTailLen(sal_uInt16 nId, const sal_uInt8* pSprm,
nCount = 0;
}
else
+ {
nCount = SVBT16ToUInt16(&pSprm[nIndex]);
- nL = static_cast< sal_uInt16 >(nCount + aSprm.nLen - 1);
+ SAL_WARN_IF(nCount < 1, "sw.ww8", "length should have been at least 1");
+ if (nCount)
+ --nCount;
+ }
+ nL = static_cast<sal_uInt16>(nCount + aSprm.nLen);
break;
}
default:
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index 81221db9eb82..320d3e3cb10e 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -24,6 +24,7 @@
#include <cstddef>
#include <deque>
#include <memory>
+#include <optional>
#include <stack>
#include <unordered_map>
#include <vector>
@@ -41,14 +42,14 @@ class SvStream;
//Commonly used string literals for stream and storage names in word docs
namespace SL
{
- inline constexpr OUStringLiteral aObjectPool = u"ObjectPool";
- inline constexpr OUStringLiteral a1Table = u"1Table";
- inline constexpr OUStringLiteral a0Table = u"0Table";
- inline constexpr OUStringLiteral aData = u"Data";
- inline constexpr OUStringLiteral aCheckBox = u"CheckBox";
- inline constexpr OUStringLiteral aListBox = u"ListBox";
- inline constexpr OUStringLiteral aTextField = u"TextField";
- inline constexpr OUStringLiteral aMSMacroCmds = u"MSMacroCmds";
+ inline constexpr OUString aObjectPool = u"ObjectPool"_ustr;
+ inline constexpr OUString a1Table = u"1Table"_ustr;
+ inline constexpr OUString a0Table = u"0Table"_ustr;
+ inline constexpr OUString aData = u"Data"_ustr;
+ inline constexpr OUString aCheckBox = u"CheckBox"_ustr;
+ inline constexpr OUString aListBox = u"ListBox"_ustr;
+ inline constexpr OUString aTextField = u"TextField"_ustr;
+ inline constexpr OUString aMSMacroCmds = u"MSMacroCmds"_ustr;
}
struct SprmInfo
@@ -219,11 +220,11 @@ struct WW8PLCFxSave1
class WW8PLCFspecial // iterator for PLCFs
{
private:
- std::unique_ptr<sal_Int32[]> pPLCF_PosArray; ///< pointer to Pos-array and to the whole structure
- sal_uInt8* pPLCF_Contents; ///< pointer to content-array-part of Pos-array
- tools::Long nIMax; ///< number of elements
- tools::Long nIdx; ///< marker where we currently are
- sal_uInt32 nStru;
+ std::unique_ptr<sal_Int32[]> m_pPLCF_PosArray; ///< pointer to Pos-array and to the whole structure
+ sal_uInt8* m_pPLCF_Contents; ///< pointer to content-array-part of Pos-array
+ tools::Long m_nIMax; ///< number of elements
+ tools::Long m_nIdx; ///< marker where we currently are
+ sal_uInt32 m_nStru;
WW8PLCFspecial(const WW8PLCFspecial&) = delete;
WW8PLCFspecial& operator=(const WW8PLCFspecial&) = delete;
@@ -231,29 +232,29 @@ private:
public:
WW8PLCFspecial(SvStream* pSt, sal_uInt32 nFilePos, sal_uInt32 nPLCF,
sal_uInt32 nStruct);
- tools::Long GetIdx() const { return nIdx; }
- void SetIdx( tools::Long nI ) { nIdx = nI; }
- tools::Long GetIMax() const { return nIMax; }
+ tools::Long GetIdx() const { return m_nIdx; }
+ void SetIdx( tools::Long nI ) { m_nIdx = nI; }
+ tools::Long GetIMax() const { return m_nIMax; }
bool SeekPos(tools::Long nPos); // walks over FC- or CP-value
// resp. next biggest value
bool SeekPosExact(tools::Long nPos);
sal_Int32 Where() const
- { return ( nIdx >= nIMax ) ? SAL_MAX_INT32 : pPLCF_PosArray[nIdx]; }
+ { return ( m_nIdx >= m_nIMax ) ? SAL_MAX_INT32 : m_pPLCF_PosArray[m_nIdx]; }
bool Get(WW8_CP& rStart, void*& rpValue) const;
bool GetData(tools::Long nIdx, WW8_CP& rPos, void*& rpValue) const;
const void* GetData( tools::Long nInIdx ) const
{
- return ( nInIdx >= nIMax ) ? nullptr
- : static_cast<const void*>(&pPLCF_Contents[nInIdx * nStru]);
+ return ( nInIdx >= m_nIMax ) ? nullptr
+ : static_cast<const void*>(&m_pPLCF_Contents[nInIdx * m_nStru]);
}
sal_Int32 GetPos( tools::Long nInIdx ) const
- { return ( nInIdx >= nIMax ) ? SAL_MAX_INT32 : pPLCF_PosArray[nInIdx]; }
+ { return ( nInIdx >= m_nIMax ) ? SAL_MAX_INT32 : m_pPLCF_PosArray[nInIdx]; }
void advance()
{
- if (nIdx <= nIMax)
- ++nIdx;
+ if (m_nIdx <= m_nIMax)
+ ++m_nIdx;
}
};
@@ -263,12 +264,12 @@ class WW8SprmIter
private:
const wwSprmParser &mrSprmParser;
// these members will be updated
- const sal_uInt8* pSprms; // remaining part of the SPRMs ( == start of current SPRM)
- const sal_uInt8* pCurrentParams; // start of current SPRM's parameters
- sal_uInt16 nCurrentId;
- sal_Int32 nCurrentSize;
+ const sal_uInt8* m_pSprms; // remaining part of the SPRMs ( == start of current SPRM)
+ const sal_uInt8* m_pCurrentParams; // start of current SPRM's parameters
+ sal_uInt16 m_nCurrentId;
+ sal_Int32 m_nCurrentSize;
- sal_Int32 nRemLen; // length of remaining SPRMs (including current SPRM)
+ sal_Int32 m_nRemLen; // length of remaining SPRMs (including current SPRM)
void UpdateMyMembers();
@@ -279,10 +280,10 @@ public:
SprmResult FindSprm(sal_uInt16 nId, bool bFindFirst, const sal_uInt8* pNextByteMatch = nullptr);
void advance();
const sal_uInt8* GetSprms() const
- { return ( pSprms && (0 < nRemLen) ) ? pSprms : nullptr; }
- const sal_uInt8* GetCurrentParams() const { return pCurrentParams; }
- sal_uInt16 GetCurrentId() const { return nCurrentId; }
- sal_Int32 GetRemLen() const { return nRemLen; }
+ { return ( m_pSprms && (0 < m_nRemLen) ) ? m_pSprms : nullptr; }
+ const sal_uInt8* GetCurrentParams() const { return m_pCurrentParams; }
+ sal_uInt16 GetCurrentId() const { return m_nCurrentId; }
+ sal_Int32 GetRemLen() const { return m_nRemLen; }
private:
WW8SprmIter(const WW8SprmIter&) = delete;
@@ -293,11 +294,11 @@ private:
class WW8PLCF // Iterator for PLCFs
{
private:
- std::unique_ptr<WW8_CP[]> pPLCF_PosArray; // pointer to Pos-array and the whole structure
- sal_uInt8* pPLCF_Contents; // pointer to content-array-part of Pos-array
- sal_Int32 nIMax; // number of elements
- sal_Int32 nIdx;
- int nStru;
+ std::unique_ptr<WW8_CP[]> m_pPLCF_PosArray; // pointer to Pos-array and the whole structure
+ sal_uInt8* m_pPLCF_Contents; // pointer to content-array-part of Pos-array
+ sal_Int32 m_nIMax; // number of elements
+ sal_Int32 m_nIdx;
+ int m_nStru;
void ReadPLCF(SvStream& rSt, WW8_FC nFilePos, sal_uInt32 nPLCF);
@@ -320,18 +321,18 @@ public:
WW8PLCF(SvStream& rSt, WW8_FC nFilePos, sal_Int32 nPLCF, int nStruct,
WW8_CP nStartPos, sal_Int32 nPN, sal_Int32 ncpN);
- sal_Int32 GetIdx() const { return nIdx; }
- void SetIdx( sal_Int32 nI ) { nIdx = nI; }
- sal_Int32 GetIMax() const { return nIMax; }
+ sal_Int32 GetIdx() const { return m_nIdx; }
+ void SetIdx( sal_Int32 nI ) { m_nIdx = nI; }
+ sal_Int32 GetIMax() const { return m_nIMax; }
bool SeekPos(WW8_CP nPos);
WW8_CP Where() const;
bool Get(WW8_CP& rStart, WW8_CP& rEnd, void*& rpValue) const;
- void advance() { if( nIdx < nIMax ) ++nIdx; }
+ void advance() { if( m_nIdx < m_nIMax ) ++m_nIdx; }
const void* GetData( sal_Int32 nInIdx ) const
{
- return ( nInIdx >= nIMax ) ? nullptr :
- static_cast<const void*>(&pPLCF_Contents[nInIdx * nStru]);
+ return ( nInIdx >= m_nIMax ) ? nullptr :
+ static_cast<const void*>(&m_pPLCF_Contents[nInIdx * m_nStru]);
}
};
@@ -340,10 +341,10 @@ class WW8PLCFpcd
{
friend class WW8PLCFpcd_Iter;
- std::unique_ptr<WW8_CP[]> pPLCF_PosArray; // pointer to Pos-array and the whole structure
- sal_uInt8* pPLCF_Contents; // pointer to content-array-part of Pos-array
- sal_Int32 nIMax;
- sal_uInt32 nStru;
+ std::unique_ptr<WW8_CP[]> m_pPLCF_PosArray; // pointer to Pos-array and the whole structure
+ sal_uInt8* m_pPLCF_Contents; // pointer to content-array-part of Pos-array
+ sal_Int32 m_nIMax;
+ sal_uInt32 m_nStru;
WW8PLCFpcd(const WW8PLCFpcd&) = delete;
WW8PLCFpcd& operator=(const WW8PLCFpcd&) = delete;
@@ -359,24 +360,24 @@ public:
class WW8PLCFpcd_Iter
{
private:
- WW8PLCFpcd& rPLCF;
- tools::Long nIdx;
+ WW8PLCFpcd& m_rPLCF;
+ tools::Long m_nIdx;
WW8PLCFpcd_Iter(const WW8PLCFpcd_Iter&) = delete;
WW8PLCFpcd_Iter& operator=(const WW8PLCFpcd_Iter&) = delete;
public:
WW8PLCFpcd_Iter( WW8PLCFpcd& rPLCFpcd, tools::Long nStartPos = -1 );
- tools::Long GetIdx() const { return nIdx; }
- void SetIdx( tools::Long nI ) { nIdx = nI; }
- tools::Long GetIMax() const { return rPLCF.nIMax; }
+ tools::Long GetIdx() const { return m_nIdx; }
+ void SetIdx( tools::Long nI ) { m_nIdx = nI; }
+ tools::Long GetIMax() const { return m_rPLCF.m_nIMax; }
bool SeekPos(tools::Long nPos);
sal_Int32 Where() const;
bool Get(WW8_CP& rStart, WW8_CP& rEnd, void*& rpValue) const;
void advance()
{
- if( nIdx < rPLCF.nIMax )
- ++nIdx;
+ if( m_nIdx < m_rPLCF.m_nIMax )
+ ++m_nIdx;
}
};
@@ -393,9 +394,9 @@ class WW8PLCFx // virtual iterator for Piece Table Exceptions
{
private:
const WW8Fib& mrFib;
- bool bIsSprm; // PLCF of Sprms or other stuff ( Footnote, ... )
- WW8_FC nStartFc;
- bool bDirty;
+ bool m_bIsSprm; // PLCF of Sprms or other stuff ( Footnote, ... )
+ WW8_FC m_nStartFc;
+ bool m_bDirty;
WW8PLCFx(const WW8PLCFx&) = delete;
WW8PLCFx& operator=(const WW8PLCFx&) = delete;
@@ -403,13 +404,13 @@ private:
public:
WW8PLCFx(const WW8Fib& rFib, bool bSprm)
: mrFib(rFib)
- , bIsSprm(bSprm)
- , nStartFc(-1)
- , bDirty(false)
+ , m_bIsSprm(bSprm)
+ , m_nStartFc(-1)
+ , m_bDirty(false)
{
}
virtual ~WW8PLCFx() {}
- bool IsSprm() const { return bIsSprm; }
+ bool IsSprm() const { return m_bIsSprm; }
virtual sal_uInt32 GetIdx() const = 0;
virtual void SetIdx(sal_uInt32 nIdx) = 0;
virtual sal_uInt32 GetIdx2() const;
@@ -424,20 +425,19 @@ public:
virtual void Restore( const WW8PLCFxSave1& rSave );
ww::WordVersion GetFIBVersion() const;
const WW8Fib& GetFIB() const { return mrFib; }
- void SetStartFc( WW8_FC nFc ) { nStartFc = nFc; }
- WW8_FC GetStartFc() const { return nStartFc; }
- void SetDirty(bool bIn) {bDirty=bIn;}
- bool GetDirty() const {return bDirty;}
+ void SetStartFc( WW8_FC nFc ) { m_nStartFc = nFc; }
+ WW8_FC GetStartFc() const { return m_nStartFc; }
+ void SetDirty(bool bIn) {m_bDirty=bIn;}
+ bool GetDirty() const {return m_bDirty;}
};
class WW8PLCFx_PCDAttrs : public WW8PLCFx
{
private:
- WW8PLCFpcd_Iter* pPcdI;
- WW8PLCFx_PCD* pPcd;
+ WW8PLCFpcd_Iter* m_pPcdI;
+ WW8PLCFx_PCD* m_pPcd;
std::vector<std::unique_ptr<sal_uInt8[]>> const & mrGrpprls; // attribute of Piece-table
- SVBT32 aShortSprm; // mini storage: can contain ONE sprm with
- // 1 byte param
+ sal_uInt8 m_aShortSprm[4]; // mini storage: can contain ONE sprm with 1 byte param
WW8PLCFx_PCDAttrs(const WW8PLCFx_PCDAttrs&) = delete;
WW8PLCFx_PCDAttrs& operator=(const WW8PLCFx_PCDAttrs&) = delete;
@@ -452,15 +452,15 @@ public:
virtual void GetSprms( WW8PLCFxDesc* p ) override;
virtual void advance() override;
- WW8PLCFpcd_Iter* GetIter() const { return pPcdI; }
+ WW8PLCFpcd_Iter* GetIter() const { return m_pPcdI; }
};
class WW8PLCFx_PCD : public WW8PLCFx // iterator for Piece table
{
private:
- std::unique_ptr<WW8PLCFpcd_Iter> pPcdI;
- bool bVer67;
- WW8_CP nClipStart;
+ std::unique_ptr<WW8PLCFpcd_Iter> m_pPcdI;
+ bool m_bVer67;
+ WW8_CP m_nClipStart;
WW8PLCFx_PCD(const WW8PLCFx_PCD&) = delete;
WW8PLCFx_PCD& operator=(const WW8PLCFx_PCD&) = delete;
@@ -480,9 +480,9 @@ public:
WW8_FC CurrentPieceStartCp2Fc( WW8_CP nCp );
static void CurrentPieceFc2Cp(WW8_CP& rStartPos, WW8_CP& rEndPos,
const WW8ScannerBase *pSBase);
- WW8PLCFpcd_Iter* GetPLCFIter() { return pPcdI.get(); }
- void SetClipStart(WW8_CP nIn) { nClipStart = nIn; }
- WW8_CP GetClipStart() const { return nClipStart; }
+ WW8PLCFpcd_Iter* GetPLCFIter() { return m_pPcdI.get(); }
+ void SetClipStart(WW8_CP nIn) { m_nClipStart = nIn; }
+ WW8_CP GetClipStart() const { return m_nClipStart; }
static sal_Int32 TransformPieceAddress(tools::Long nfc, bool& bIsUnicodeAddress)
{
@@ -522,12 +522,12 @@ public:
sal_uInt8 maRawData[512];
std::vector<Entry> maEntries;
- tools::Long nItemSize; // either 1 Byte or a complete BX
+ tools::Long m_nItemSize; // either 1 Byte or a complete BX
// Offset in Stream where last read of 512 bytes took place
- tools::Long nFilePos;
+ tools::Long m_nFilePos;
sal_uInt8 mnIdx; // Pos marker
- ePLCFT ePLCF;
+ ePLCFT m_ePLCF;
sal_uInt8 mnIMax; // number of entries
int mnMustRemainCached; // after SaveAllPLCFx, before RestoreAllPLCFx
@@ -541,7 +541,7 @@ public:
SvStream* pDataStrm, tools::Long _nFilePos, tools::Long nItemSiz, ePLCFT ePl,
WW8_FC nStartFc);
void Reset(WW8_FC nPos);
- tools::Long GetFilePos() const { return nFilePos; }
+ tools::Long GetFilePos() const { return m_nFilePos; }
sal_uInt8 GetIdx() const { return mnIdx; }
void SetIdx(sal_uInt8 nI);
bool SeekPos(WW8_FC nFc);
@@ -580,11 +580,11 @@ public:
};
private:
- SvStream* pFKPStrm; // input file
- SvStream* pDataStrm; // input file
- std::unique_ptr<WW8PLCF> pPLCF;
+ SvStream* m_pFKPStrm; // input file
+ SvStream* m_pDataStrm; // input file
+ std::unique_ptr<WW8PLCF> m_pPLCF;
protected:
- WW8Fkp* pFkp;
+ WW8Fkp* m_pFkp;
private:
/*
@@ -608,8 +608,8 @@ private:
WW8PLCFx_Fc_FKP& operator=(const WW8PLCFx_Fc_FKP&) = delete;
protected:
- ePLCFT ePLCF;
- std::unique_ptr<WW8PLCFx_PCDAttrs> pPCDAttrs;
+ ePLCFT m_ePLCF;
+ std::unique_ptr<WW8PLCFx_PCDAttrs> m_pPCDAttrs;
public:
WW8PLCFx_Fc_FKP( SvStream* pSt, SvStream* pTableSt, SvStream* pDataSt,
@@ -625,19 +625,19 @@ public:
void GetPCDSprms( WW8PLCFxDesc& rDesc );
SprmResult HasSprm(sal_uInt16 nId, bool bFindFirst = true);
void HasSprm(sal_uInt16 nId, std::vector<SprmResult> &rResult);
- bool HasFkp() const { return (nullptr != pFkp); }
+ bool HasFkp() const { return (nullptr != m_pFkp); }
};
/// iterator for Piece Table Exceptions of Fkps works on CPs (high-level)
class WW8PLCFx_Cp_FKP : public WW8PLCFx_Fc_FKP
{
private:
- const WW8ScannerBase& rSBase;
- std::unique_ptr<WW8PLCFx_PCD> pPcd;
- WW8PLCFpcd_Iter *pPieceIter;
- WW8_CP nAttrStart, nAttrEnd;
- bool bLineEnd : 1;
- bool bComplex : 1;
+ const WW8ScannerBase& m_rSBase;
+ std::unique_ptr<WW8PLCFx_PCD> m_pPcd;
+ WW8PLCFpcd_Iter *m_pPieceIter;
+ WW8_CP m_nAttrStart, m_nAttrEnd;
+ bool m_bLineEnd : 1;
+ bool m_bComplex : 1;
WW8PLCFx_Cp_FKP(const WW8PLCFx_Cp_FKP&) = delete;
WW8PLCFx_Cp_FKP& operator=(const WW8PLCFx_Cp_FKP&) = delete;
@@ -663,11 +663,11 @@ class WW8PLCFx_SEPX : public WW8PLCFx
{
private:
wwSprmParser maSprmParser;
- SvStream* pStrm;
- std::unique_ptr<WW8PLCF> pPLCF;
- std::unique_ptr<sal_uInt8[]> pSprms;
- sal_uInt16 nArrMax;
- sal_uInt16 nSprmSiz;
+ SvStream* m_pStrm;
+ std::unique_ptr<WW8PLCF> m_pPLCF;
+ std::unique_ptr<sal_uInt8[]> m_pSprms;
+ sal_uInt16 m_nArrMax;
+ sal_uInt16 m_nSprmSiz;
WW8PLCFx_SEPX(const WW8PLCFx_SEPX&) = delete;
WW8PLCFx_SEPX& operator=(const WW8PLCFx_SEPX&) = delete;
@@ -694,8 +694,8 @@ public:
class WW8PLCFx_SubDoc : public WW8PLCFx
{
private:
- std::unique_ptr<WW8PLCF> pRef;
- std::unique_ptr<WW8PLCF> pText;
+ std::unique_ptr<WW8PLCF> m_pRef;
+ std::unique_ptr<WW8PLCF> m_pText;
WW8PLCFx_SubDoc(const WW8PLCFx_SubDoc&) = delete;
WW8PLCFx_SubDoc& operator=(const WW8PLCFx_SubDoc&) = delete;
@@ -712,20 +712,20 @@ public:
// returns reference descriptors
const void* GetData() const
{
- return pRef ? pRef->GetData( pRef->GetIdx() ) : nullptr;
+ return m_pRef ? m_pRef->GetData( m_pRef->GetIdx() ) : nullptr;
}
virtual void GetSprms(WW8PLCFxDesc* p) override;
virtual void advance() override;
- tools::Long Count() const { return pRef ? pRef->GetIMax() : 0; }
+ tools::Long Count() const { return m_pRef ? m_pRef->GetIMax() : 0; }
};
/// Iterator for fields
class WW8PLCFx_FLD : public WW8PLCFx
{
private:
- std::unique_ptr<WW8PLCFspecial> pPLCF;
- const WW8Fib& rFib;
+ std::unique_ptr<WW8PLCFspecial> m_pPLCF;
+ const WW8Fib& m_rFib;
WW8PLCFx_FLD(const WW8PLCFx_FLD&) = delete;
WW8PLCFx_FLD& operator=(const WW8PLCFx_FLD &) = delete;
@@ -749,12 +749,12 @@ enum eBookStatus { BOOK_NORMAL = 0, BOOK_IGNORE = 0x1, BOOK_FIELD = 0x2 };
class WW8PLCFx_Book : public WW8PLCFx
{
private:
- std::unique_ptr<WW8PLCFspecial> pBook[2]; // Start and End Position
- std::vector<OUString> aBookNames; // Name
- std::vector<eBookStatus> aStatus;
- tools::Long nIMax; // Number of Booknotes
- sal_uInt16 nIsEnd;
- sal_Int32 nBookmarkId; // counter incremented by GetUniqueBookmarkName.
+ std::unique_ptr<WW8PLCFspecial> m_pBook[2]; // Start and End Position
+ std::vector<OUString> m_aBookNames; // Name
+ std::vector<eBookStatus> m_aStatus;
+ tools::Long m_nIMax; // Number of Booknotes
+ sal_uInt16 m_nIsEnd;
+ sal_Int32 m_nBookmarkId; // counter incremented by GetUniqueBookmarkName.
WW8PLCFx_Book(const WW8PLCFx_Book&) = delete;
WW8PLCFx_Book& operator=(const WW8PLCFx_Book&) = delete;
@@ -762,7 +762,7 @@ private:
public:
WW8PLCFx_Book(SvStream* pTableSt,const WW8Fib& rFib);
virtual ~WW8PLCFx_Book() override;
- tools::Long GetIMax() const { return nIMax; }
+ tools::Long GetIMax() const { return m_nIMax; }
virtual sal_uInt32 GetIdx() const override;
virtual void SetIdx(sal_uInt32 nI) override;
virtual sal_uInt32 GetIdx2() const override;
@@ -773,9 +773,9 @@ public:
virtual void advance() override;
const OUString* GetName() const;
WW8_CP GetStartPos() const
- { return nIsEnd ? WW8_CP_MAX : pBook[0]->Where(); }
+ { return m_nIsEnd ? WW8_CP_MAX : m_pBook[0]->Where(); }
tools::Long GetLen() const;
- bool GetIsEnd() const { return nIsEnd != 0; }
+ bool GetIsEnd() const { return m_nIsEnd != 0; }
tools::Long GetHandle() const;
void SetStatus( sal_uInt16 nIndex, eBookStatus eStat );
void MapName(OUString& rName);
@@ -791,7 +791,7 @@ private:
/// Start and end positions.
std::unique_ptr<WW8PLCFspecial> m_pBook[2];
/// Number of annotation marks
- sal_Int32 nIMax;
+ sal_Int32 m_nIMax;
bool m_bIsEnd;
WW8PLCFx_AtnBook(const WW8PLCFx_AtnBook&) = delete;
@@ -878,7 +878,7 @@ enum ManTypes // enums for PLCFMan-ctor
struct WW8PLCFxDesc
{
WW8PLCFx* pPLCFx;
- std::unique_ptr<std::stack<sal_uInt16>> xIdStack; // memory for Attr-Id for Attr-end(s)
+ std::optional<std::stack<sal_uInt16>> xIdStack; // memory for Attr-Id for Attr-end(s)
const sal_uInt8* pMemPos;// where are the Sprm(s)
tools::Long nOrigSprmsLen;
@@ -1080,6 +1080,7 @@ public:
~WW8ScannerBase();
bool AreThereFootnotes() const { return m_pFootnotePLCF->Count() > 0; };
bool AreThereEndnotes() const { return m_pEdnPLCF->Count() > 0; };
+ tools::Long GetEndnoteCount() const { return m_pEdnPLCF->Count(); };
//If you use WW8Fc2Cp you are almost certainly doing the wrong thing
//when it comes to fastsaved files, avoid like the plague. For export
@@ -1779,6 +1780,7 @@ public:
sal_Int16 hpsZoomFontPag = 0;
sal_Int16 dywDispPag = 0;
+ // [MS-DOC] 2.7.11 Copts A..H
bool fCompatibilityOptions_Unknown2_1 : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_2 : 1 /*= false*/; // #i78591#
bool fDontUseHTMLAutoSpacing : 1 /*= false*/;
@@ -1787,13 +1789,17 @@ public:
bool fCompatibilityOptions_Unknown2_6 : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_7 : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_8 : 1 /*= false*/; // #i78591#
+
+ // [MS-DOC] 2.7.11 Copts I..P
bool fCompatibilityOptions_Unknown2_9 : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_10 : 1 /*= false*/; // #i78591#
- bool fCompatibilityOptions_Unknown2_11 : 1 /*= false*/; // #i78591#
+ bool fDontBreakWrappedTables : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_12 : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_13 : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_14 : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_15 : 1 /*= false*/; // #i78591#
+
+ // [MS-DOC] 2.7.11 Copts Q..X
bool fCompatibilityOptions_Unknown2_16 : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_17 : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_18 : 1 /*= false*/; // #i78591#
@@ -1802,6 +1808,8 @@ public:
bool fCompatibilityOptions_Unknown2_21 : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_22 : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_23 : 1 /*= false*/; // #i78591#
+
+ // [MS-DOC] 2.7.11 Copts Y..f
bool fCompatibilityOptions_Unknown2_24 : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_25 : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_26 : 1 /*= false*/; // #i78591#
@@ -1810,6 +1818,8 @@ public:
bool fCompatibilityOptions_Unknown2_29 : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_30 : 1 /*= false*/; // #i78591#
bool fCompatibilityOptions_Unknown2_31 : 1 /*= false*/; // #i78591#
+
+ // [MS-DOC] 2.7.11 Copts g
bool fCompatibilityOptions_Unknown2_32 : 1 /*= false*/; // #i78591#
sal_uInt16 fUnknown3 : 15 /*= 0*/;
@@ -1849,8 +1859,8 @@ public:
class WW8PLCF_HdFt
{
private:
- WW8PLCF aPLCF;
- short nIdxOffset;
+ WW8PLCF m_aPLCF;
+ short m_nIdxOffset;
public:
WW8PLCF_HdFt( SvStream* pSt, WW8Fib const & rFib, WW8Dop const & rDop );
diff --git a/sw/source/filter/ww8/ww8struc.hxx b/sw/source/filter/ww8/ww8struc.hxx
index 825947a19033..a1a22d7a0501 100644
--- a/sw/source/filter/ww8/ww8struc.hxx
+++ b/sw/source/filter/ww8/ww8struc.hxx
@@ -394,18 +394,18 @@ public:
//full document, might not matter all that much though ?
enum RuleLengths {nMaxFollowing = 101, nMaxLeading = 51};
- static constexpr OUStringLiteral JapanNotBeginLevel1
+ static constexpr OUString JapanNotBeginLevel1
= u"\u0021\u0025\u0029\u002c\u002e\u003a\u003b\u003f"
"\u005d\u007d\u00a2\u00b0\u2019\u201d\u2030\u2032"
"\u2033\u2103\u3001\u3002\u3005\u3009\u300b\u300d"
"\u300f\u3011\u3015\u309b\u309c\u309d\u309e\u30fb"
"\u30fd\u30fe\uff01\uff05\uff09\uff0c\uff0e\uff1a"
"\uff1b\uff1f\uff3d\uff5d\uff61\uff63\uff64\uff65"
- "\uff9e\uff9f\uffe0";
- static constexpr OUStringLiteral JapanNotEndLevel1
+ "\uff9e\uff9f\uffe0"_ustr;
+ static constexpr OUString JapanNotEndLevel1
= u"\u0024\u0028\u005b\u005c\u007b\u00a3\u00a5\u2018"
"\u201c\u3008\u300a\u300c\u300e\u3010\u3014\uff04"
- "\uff08\uff3b\uff5b\uff62\uffe1\uffe5";
+ "\uff08\uff3b\uff5b\uff62\uffe1\uffe5"_ustr;
sal_Int16 m_cchFollowingPunct; // length of rgxchFPunct
sal_Int16 m_cchLeadingPunct; // length of rgxchLPunct
@@ -889,15 +889,15 @@ struct WW67_ATRD // for versions 6/7
struct WW8_TablePos
{
- sal_Int16 nSp26;
- sal_Int16 nSp27;
- sal_Int16 nLeMgn;
- sal_Int16 nRiMgn;
- sal_Int16 nUpMgn;
- sal_Int16 nLoMgn;
- sal_uInt8 nSp29;
- sal_uInt8 nSp37;
- bool bNoFly;
+ sal_Int16 nTDxaAbs;
+ sal_Int16 nTDyaAbs;
+ sal_Int16 nLeftMargin;
+ sal_Int16 nRightMargin;
+ sal_Int16 nUpperMargin;
+ sal_Int16 nLowerMargin;
+ sal_uInt8 nTPc;
+ sal_uInt8 nPWr;
+ sal_uInt8 nTFNoAllowOverlap;
};
struct WW8_FSPA
diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx
index 95970314240d..9ef5cdf0ca10 100644
--- a/sw/source/filter/ww8/ww8toolbar.cxx
+++ b/sw/source/filter/ww8/ww8toolbar.cxx
@@ -10,19 +10,21 @@
#include "ww8toolbar.hxx"
#include "ww8scan.hxx"
#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/document/IndexedPropertyValues.hpp>
#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/lang/XSingleComponentFactory.hpp>
#include <com/sun/star/ui/ItemType.hpp>
#include <fstream>
#include <comphelper/documentinfo.hxx>
+#include <comphelper/indexedpropertyvalues.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <comphelper/sequence.hxx>
#include <o3tl/safeint.hxx>
#include <sfx2/objsh.hxx>
-#include <tools/diagnose_ex.h>
-#include <unotools/configmgr.hxx>
+#include <comphelper/diagnose_ex.hxx>
+#include <comphelper/configuration.hxx>
+#include <rtl/ref.hxx>
#include <map>
#include <sal/log.hxx>
@@ -37,8 +39,8 @@ namespace {
class MSOWordCommandConvertor : public MSOCommandConvertor
{
- IdToString msoToOOcmd;
- IdToString tcidToOOcmd;
+ IdToString m_MSOToOOcmd;
+ IdToString m_TCIDToOOcmd;
public:
MSOWordCommandConvertor();
@@ -52,39 +54,39 @@ MSOWordCommandConvertor::MSOWordCommandConvertor()
{
// mso command id to ooo command string
// #FIXME and *HUNDREDS* of id's to added here
- msoToOOcmd[ 0x20b ] = ".uno:CloseDoc";
- msoToOOcmd[ 0x50 ] = ".uno:Open";
+ m_MSOToOOcmd[ 0x20b ] = ".uno:CloseDoc";
+ m_MSOToOOcmd[ 0x50 ] = ".uno:Open";
// mso tcid to ooo command string
// #FIXME and *HUNDREDS* of id's to added here
- tcidToOOcmd[ 0x9d9 ] = ".uno:Print";
+ m_TCIDToOOcmd[ 0x9d9 ] = ".uno:Print";
}
OUString MSOWordCommandConvertor::MSOCommandToOOCommand( sal_Int16 key )
{
- IdToString::iterator it = msoToOOcmd.find( key );
- if ( it != msoToOOcmd.end() )
+ IdToString::iterator it = m_MSOToOOcmd.find( key );
+ if ( it != m_MSOToOOcmd.end() )
return it->second;
return OUString();
}
OUString MSOWordCommandConvertor::MSOTCIDToOOCommand( sal_Int16 key )
{
- IdToString::iterator it = tcidToOOcmd.find( key );
- if ( it != tcidToOOcmd.end() )
+ IdToString::iterator it = m_TCIDToOOcmd.find( key );
+ if ( it != m_TCIDToOOcmd.end() )
return it->second;
return OUString();
}
SwCTBWrapper::SwCTBWrapper() :
-reserved2(0)
-,reserved3(0)
-,reserved4(0)
-,reserved5(0)
-,cbTBD(0)
-,cCust(0)
-,cbDTBC(0)
-,rtbdc(0)
+m_reserved2(0)
+,m_reserved3(0)
+,m_reserved4(0)
+,m_reserved5(0)
+,m_cbTBD(0)
+,m_cCust(0)
+,m_cbDTBC(0)
+,m_rtbdc(0)
{
}
@@ -94,19 +96,19 @@ SwCTBWrapper::~SwCTBWrapper()
Customization* SwCTBWrapper::GetCustomizaton( sal_Int16 index )
{
- if ( index < 0 || index >= static_cast<sal_Int16>( rCustomizations.size() ) )
+ if ( index < 0 || o3tl::make_unsigned(index) >= m_rCustomizations.size() )
return nullptr;
- return &rCustomizations[ index ];
+ return &m_rCustomizations[ index ];
}
SwCTB* SwCTBWrapper::GetCustomizationData( const OUString& sTBName )
{
- auto it = std::find_if(rCustomizations.begin(), rCustomizations.end(),
+ auto it = std::find_if(m_rCustomizations.begin(), m_rCustomizations.end(),
[&sTBName](Customization& rCustomization) {
SwCTB* pCTB = rCustomization.GetCustomizationData();
return pCTB && pCTB->GetName() == sTBName;
});
- if (it != rCustomizations.end())
+ if (it != m_rCustomizations.end())
return it->GetCustomizationData();
return nullptr;
}
@@ -116,10 +118,10 @@ bool SwCTBWrapper::Read( SvStream& rS )
SAL_INFO("sw.ww8","SwCTBWrapper::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
Tcg255SubStruct::Read( rS );
- rS.ReadUInt16( reserved2 ).ReadUChar( reserved3 ).ReadUInt16( reserved4 ).ReadUInt16( reserved5 );
- rS.ReadInt16( cbTBD ).ReadUInt16( cCust ).ReadInt32( cbDTBC );
- tools::Long nExpectedPos = rS.Tell() + cbDTBC;
- if ( cbDTBC )
+ rS.ReadUInt16( m_reserved2 ).ReadUChar( m_reserved3 ).ReadUInt16( m_reserved4 ).ReadUInt16( m_reserved5 );
+ rS.ReadInt16( m_cbTBD ).ReadUInt16( m_cCust ).ReadInt32( m_cbDTBC );
+ sal_uInt64 nExpectedPos = rS.Tell() + m_cbDTBC;
+ if ( m_cbDTBC )
{
// cbDTBC is the size in bytes of the SwTBC array
// but the size of a SwTBC element is dynamic ( and this relates to TBDelta's
@@ -134,62 +136,62 @@ bool SwCTBWrapper::Read( SvStream& rS )
SwTBC aTBC;
if ( !aTBC.Read( rS ) )
return false;
- rtbdc.push_back( aTBC );
- bytesToRead = cbDTBC - ( rS.Tell() - nStart );
+ m_rtbdc.push_back( aTBC );
+ bytesToRead = m_cbDTBC - ( rS.Tell() - nStart );
} while ( bytesToRead > 0 );
}
- if ( static_cast< tools::Long >( rS.Tell() ) != nExpectedPos )
+ if ( rS.Tell() != nExpectedPos )
{
// Strange error condition, shouldn't happen ( but does in at least
// one test document ) In the case where it happens the SwTBC &
// TBCHeader records seem blank??? ( and incorrect )
- SAL_WARN_IF( static_cast< tools::Long >(rS.Tell()) != nExpectedPos, "sw.ww8","### Error: Expected pos not equal to actual pos after reading rtbdc");
+ SAL_WARN_IF( rS.Tell() != nExpectedPos, "sw.ww8","### Error: Expected pos not equal to actual pos after reading rtbdc");
SAL_INFO("sw.ww8","\tPos now is 0x" << std::hex << rS.Tell() << " should be 0x" << std::hex << nExpectedPos );
// seek to correct position after rtbdc
rS.Seek( nExpectedPos );
}
- if (cCust)
+ if (m_cCust)
{
//Each customization takes a min of 8 bytes
size_t nMaxPossibleRecords = rS.remainingSize() / 8;
- if (cCust > nMaxPossibleRecords)
+ if (m_cCust > nMaxPossibleRecords)
{
return false;
}
- for (sal_uInt16 index = 0; index < cCust; ++index)
+ for (sal_uInt16 index = 0; index < m_cCust; ++index)
{
Customization aCust( this );
if ( !aCust.Read( rS ) )
return false;
- rCustomizations.push_back( aCust );
+ m_rCustomizations.push_back( aCust );
}
}
- for ( const auto& rIndex : dropDownMenuIndices )
+ for ( const auto& rIndex : m_dropDownMenuIndices )
{
- if (rIndex < 0 || o3tl::make_unsigned(rIndex) >= rCustomizations.size())
+ if (rIndex < 0 || o3tl::make_unsigned(rIndex) >= m_rCustomizations.size())
continue;
- rCustomizations[rIndex].bIsDroppedMenuTB = true;
+ m_rCustomizations[rIndex].m_bIsDroppedMenuTB = true;
}
return rS.good();
}
SwTBC* SwCTBWrapper::GetTBCAtOffset( sal_uInt32 nStreamOffset )
{
- auto it = std::find_if(rtbdc.begin(), rtbdc.end(),
+ auto it = std::find_if(m_rtbdc.begin(), m_rtbdc.end(),
[&nStreamOffset](SwTBC& rItem) { return rItem.GetOffset() == nStreamOffset; });
- if ( it != rtbdc.end() )
+ if ( it != m_rtbdc.end() )
return &(*it);
return nullptr;
}
bool SwCTBWrapper::ImportCustomToolBar( SfxObjectShell& rDocSh )
{
- for ( auto& rCustomization : rCustomizations )
+ for ( auto& rCustomization : m_rCustomizations )
{
try
{
css::uno::Reference<css::ui::XUIConfigurationManager> xCfgMgr;
- if (!utl::ConfigManager::IsFuzzing())
+ if (!comphelper::IsFuzzing())
{
uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xAppCfgSupp( ui::theModuleUIConfigurationManagerSupplier::get(xContext) );
@@ -210,11 +212,11 @@ bool SwCTBWrapper::ImportCustomToolBar( SfxObjectShell& rDocSh )
}
Customization::Customization( SwCTBWrapper* wrapper )
- : tbidForTBD( 0 )
- , reserved1( 0 )
- , ctbds( 0 )
- , pWrapper( wrapper )
- , bIsDroppedMenuTB( false )
+ : m_tbidForTBD( 0 )
+ , m_reserved1( 0 )
+ , m_ctbds( 0 )
+ , m_pWrapper( wrapper )
+ , m_bIsDroppedMenuTB( false )
{
}
@@ -222,28 +224,28 @@ bool Customization::Read( SvStream &rS)
{
SAL_INFO("sw.ww8","Customization::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
- rS.ReadInt32( tbidForTBD ).ReadUInt16( reserved1 ).ReadUInt16( ctbds );
- if ( tbidForTBD )
+ rS.ReadInt32( m_tbidForTBD ).ReadUInt16( m_reserved1 ).ReadUInt16( m_ctbds );
+ if ( m_tbidForTBD )
{
//each TBDelta is at least 18 bytes in size
size_t nMaxAvailableRecords = rS.remainingSize() / 18;
- if (ctbds > nMaxAvailableRecords)
+ if (m_ctbds > nMaxAvailableRecords)
return false;
- for (sal_uInt16 index = 0; index < ctbds; ++index)
+ for (sal_uInt16 index = 0; index < m_ctbds; ++index)
{
TBDelta aTBDelta;
if (!aTBDelta.Read( rS ) )
return false;
- customizationDataTBDelta.push_back( aTBDelta );
+ m_customizationDataTBDelta.push_back( aTBDelta );
// Only set the drop down for menus associated with standard toolbar
- if ( aTBDelta.ControlDropsToolBar() && tbidForTBD == 0x25 )
- pWrapper->InsertDropIndex( aTBDelta.CustomizationIndex() );
+ if ( aTBDelta.ControlDropsToolBar() && m_tbidForTBD == 0x25 )
+ m_pWrapper->InsertDropIndex( aTBDelta.CustomizationIndex() );
}
}
else
{
- customizationDataCTB = std::make_shared<SwCTB>();
- if ( !customizationDataCTB->Read( rS ) )
+ m_customizationDataCTB = std::make_shared<SwCTB>();
+ if ( !m_customizationDataCTB->Read( rS ) )
return false;
}
return rS.good();
@@ -251,22 +253,22 @@ bool Customization::Read( SvStream &rS)
bool Customization::ImportMenu( SwCTBWrapper& rWrapper, CustomToolBarImportHelper& helper )
{
- if ( tbidForTBD == 0x25 ) // we can handle in a limited way additions the built-in menu bar
+ if ( m_tbidForTBD == 0x25 ) // we can handle in a limited way additions the built-in menu bar
{
- for ( auto& rTBDelta : customizationDataTBDelta )
+ for ( auto& rTBDelta : m_customizationDataTBDelta )
{
// for each new menu ( control that drops a toolbar )
// import a toolbar
if ( rTBDelta.ControlIsInserted() && rTBDelta.ControlDropsToolBar() )
{
- Customization* pCust = pWrapper->GetCustomizaton( rTBDelta.CustomizationIndex() );
+ Customization* pCust = m_pWrapper->GetCustomizaton( rTBDelta.CustomizationIndex() );
if ( pCust )
{
// currently only support built-in menu
- static const OUStringLiteral sMenuBar( u"private:resource/menubar/menubar" );
+ static constexpr OUString sMenuBar( u"private:resource/menubar/menubar"_ustr );
// Get menu name
- SwTBC* pTBC = pWrapper->GetTBCAtOffset( rTBDelta.TBCStreamOffset() );
+ SwTBC* pTBC = m_pWrapper->GetTBCAtOffset( rTBDelta.TBCStreamOffset() );
if ( !pTBC )
return false;
const OUString sMenuName = pTBC->GetCustomText().replace('&','~');
@@ -291,21 +293,18 @@ bool Customization::ImportMenu( SwCTBWrapper& rWrapper, CustomToolBarImportHelpe
uno::Reference< lang::XSingleComponentFactory > xSCF( xIndexContainer, uno::UNO_QUERY_THROW );
uno::Reference< uno::XComponentContext > xContext(
comphelper::getProcessComponentContext() );
- // create the popup menu
- uno::Sequence< beans::PropertyValue > aPopupMenu( 4 );
- aPopupMenu[0].Name = "CommandURL";
- aPopupMenu[0].Value <<= "vnd.openoffice.org:" + sMenuName;
- aPopupMenu[1].Name = "Label";
- aPopupMenu[1].Value <<= sMenuName;
- aPopupMenu[2].Name = "Type";
- aPopupMenu[2].Value <<= sal_Int32( 0 );
- aPopupMenu[3].Name = "ItemDescriptorContainer";
uno::Reference< container::XIndexContainer > xMenuContainer( xSCF->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW );
- aPopupMenu[3].Value <<= xMenuContainer;
- if ( pCust->customizationDataCTB && !pCust->customizationDataCTB->ImportMenuTB( rWrapper, xMenuContainer, helper ) )
+ // create the popup menu
+ uno::Sequence< beans::PropertyValue > aPopupMenu{
+ comphelper::makePropertyValue("CommandURL", "vnd.openoffice.org:" + sMenuName),
+ comphelper::makePropertyValue("Label", sMenuName),
+ comphelper::makePropertyValue("Type", sal_Int32( 0 )),
+ comphelper::makePropertyValue("ItemDescriptorContainer", xMenuContainer)
+ };
+ if ( pCust->m_customizationDataCTB && !pCust->m_customizationDataCTB->ImportMenuTB( rWrapper, xMenuContainer, helper ) )
return false;
SAL_INFO("sw.ww8","** there are " << xIndexContainer->getCount() << " menu items on the bar, inserting after that");
- xIndexContainer->insertByIndex( xIndexContainer->getCount(), uno::makeAny( aPopupMenu ) );
+ xIndexContainer->insertByIndex( xIndexContainer->getCount(), uno::Any( aPopupMenu ) );
if ( bHasSettings )
helper.getCfgManager()->replaceSettings( sMenuBar, uno::Reference< container::XIndexAccess >( xIndexContainer, uno::UNO_QUERY_THROW ) );
@@ -324,43 +323,43 @@ bool Customization::ImportMenu( SwCTBWrapper& rWrapper, CustomToolBarImportHelpe
bool Customization::ImportCustomToolBar( SwCTBWrapper& rWrapper, CustomToolBarImportHelper& helper )
{
- if ( tbidForTBD == 0x25 )
+ if ( m_tbidForTBD == 0x25 )
return ImportMenu( rWrapper, helper );
- if ( !customizationDataCTB )
+ if ( !m_customizationDataCTB )
return false;
- if ( !customizationDataCTB->IsMenuToolbar() )
+ if ( !m_customizationDataCTB->IsMenuToolbar() )
{
- if ( !customizationDataCTB->ImportCustomToolBar( rWrapper, helper ) )
+ if ( !m_customizationDataCTB->ImportCustomToolBar( rWrapper, helper ) )
return false;
}
return true;
}
TBDelta::TBDelta()
- : doprfatendFlags(0)
- , ibts(0)
- , cidNext(0)
- , cid(0)
- , fc(0)
- , CiTBDE(0)
- , cbTBC(0)
+ : m_doprfatendFlags(0)
+ , m_ibts(0)
+ , m_cidNext(0)
+ , m_cid(0)
+ , m_fc(0)
+ , m_CiTBDE(0)
+ , m_cbTBC(0)
{
}
bool TBDelta::ControlIsInserted()
{
- return ( ( doprfatendFlags & 0x3 ) == 0x1 );
+ return ( ( m_doprfatendFlags & 0x3 ) == 0x1 );
}
bool TBDelta::ControlDropsToolBar()
{
- return !( CiTBDE & 0x8000 );
+ return !( m_CiTBDE & 0x8000 );
}
sal_Int16 TBDelta::CustomizationIndex()
{
- sal_Int16 nIndex = CiTBDE;
+ sal_Int16 nIndex = m_CiTBDE;
nIndex = nIndex >> 1;
nIndex &= 0x1ff; // only 13 bits are relevant
return nIndex;
@@ -370,16 +369,16 @@ bool TBDelta::Read(SvStream &rS)
{
SAL_INFO("sw.ww8","TBDelta::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
- rS.ReadUChar( doprfatendFlags ).ReadUChar( ibts ).ReadInt32( cidNext ).ReadInt32( cid ).ReadInt32( fc ) ;
- rS.ReadUInt16( CiTBDE ).ReadUInt16( cbTBC );
+ rS.ReadUChar( m_doprfatendFlags ).ReadUChar( m_ibts ).ReadInt32( m_cidNext ).ReadInt32( m_cid ).ReadInt32( m_fc ) ;
+ rS.ReadUInt16( m_CiTBDE ).ReadUInt16( m_cbTBC );
return rS.good();
}
-SwCTB::SwCTB() : cbTBData( 0 )
-,iWCTBl( 0 )
-,reserved( 0 )
-,unused( 0 )
-,cCtls( 0 )
+SwCTB::SwCTB() : m_cbTBData( 0 )
+,m_iWCTBl( 0 )
+,m_reserved( 0 )
+,m_unused( 0 )
+,m_cCtls( 0 )
{
}
@@ -389,35 +388,35 @@ SwCTB::~SwCTB()
bool SwCTB::IsMenuToolbar() const
{
- return tb.IsMenuToolbar();
+ return m_tb.IsMenuToolbar();
}
bool SwCTB::Read( SvStream &rS)
{
SAL_INFO("sw.ww8","SwCTB::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
- if ( !name.Read( rS ) )
+ if ( !m_name.Read( rS ) )
return false;
- rS.ReadInt32( cbTBData );
- if ( !tb.Read( rS ) )
+ rS.ReadInt32( m_cbTBData );
+ if ( !m_tb.Read( rS ) )
return false;
for ( short index = 0; index < nVisualData; ++index )
{
TBVisualData aVisData;
aVisData.Read( rS );
- rVisualData.push_back( aVisData );
+ m_rVisualData.push_back( aVisData );
}
- rS.ReadInt32( iWCTBl ).ReadUInt16( reserved ).ReadUInt16( unused ).ReadInt32( cCtls );
+ rS.ReadInt32( m_iWCTBl ).ReadUInt16( m_reserved ).ReadUInt16( m_unused ).ReadInt32( m_cCtls );
- if ( cCtls )
+ if ( m_cCtls )
{
- for ( sal_Int32 index = 0; index < cCtls; ++index )
+ for ( sal_Int32 index = 0; index < m_cCtls; ++index )
{
SwTBC aTBC;
if ( !aTBC.Read( rS ) )
return false;
- rTBC.push_back( aTBC );
+ m_rTBC.push_back( aTBC );
}
}
return rS.good();
@@ -428,7 +427,7 @@ bool SwCTB::ImportCustomToolBar( SwCTBWrapper& rWrapper, CustomToolBarImportHelp
bool bRes = false;
try
{
- if ( !tb.IsEnabled() )
+ if ( !m_tb.IsEnabled() )
return true; // didn't fail, just ignoring
// Create default setting
uno::Reference< container::XIndexContainer > xIndexContainer( helper.getCfgManager()->createSettings(), uno::UNO_SET_THROW );
@@ -436,10 +435,10 @@ bool SwCTB::ImportCustomToolBar( SwCTBWrapper& rWrapper, CustomToolBarImportHelp
uno::Reference< beans::XPropertySet > xProps( xIndexContainer, uno::UNO_QUERY_THROW );
// set UI name for toolbar
- xProps->setPropertyValue( "UIName", uno::makeAny( name.getString() ) );
+ xProps->setPropertyValue( "UIName", uno::Any( m_name.getString() ) );
- const OUString sToolBarName = "private:resource/toolbar/custom_" + name.getString();
- for ( auto& rItem : rTBC )
+ const OUString sToolBarName = "private:resource/toolbar/custom_" + m_name.getString();
+ for ( auto& rItem : m_rTBC )
{
// createToolBar item for control
if ( !rItem.ImportToolBarControl( rWrapper, xIndexContainer, helper, IsMenuToolbar() ) )
@@ -469,7 +468,7 @@ bool SwCTB::ImportCustomToolBar( SwCTBWrapper& rWrapper, CustomToolBarImportHelp
bool SwCTB::ImportMenuTB( SwCTBWrapper& rWrapper, const css::uno::Reference< css::container::XIndexContainer >& xIndexContainer, CustomToolBarImportHelper& rHelper )
{
- for ( auto& rItem : rTBC )
+ for ( auto& rItem : m_rTBC )
{
// createToolBar item for control
if ( !rItem.ImportToolBarControl( rWrapper, xIndexContainer, rHelper, true ) )
@@ -486,18 +485,18 @@ bool SwTBC::Read( SvStream &rS )
{
SAL_INFO("sw.ww8","SwTBC::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
- if ( !tbch.Read( rS ) )
+ if ( !m_tbch.Read( rS ) )
return false;
- if ( tbch.getTcID() != 0x1 && tbch.getTcID() != 0x1051 )
+ if ( m_tbch.getTcID() != 0x1 && m_tbch.getTcID() != 0x1051 )
{
- cid = std::make_shared<sal_uInt32>();
- rS.ReadUInt32( *cid );
+ m_cid = std::make_shared<sal_uInt32>();
+ rS.ReadUInt32( *m_cid );
}
// MUST exist if tbch.tct is not equal to 0x16
- if ( tbch.getTct() != 0x16 )
+ if ( m_tbch.getTct() != 0x16 )
{
- tbcd = std::make_shared<TBCData>( tbch );
- if ( !tbcd->Read( rS ) )
+ m_tbcd = std::make_shared<TBCData>( m_tbch );
+ if ( !m_tbcd->Read( rS ) )
return false;
}
return rS.good();
@@ -512,9 +511,9 @@ SwTBC::ImportToolBarControl( SwCTBWrapper& rWrapper, const css::uno::Reference<
// cmtNil 0x7 No command. See Cid.
bool bBuiltin = false;
sal_Int16 cmdId = 0;
- if ( cid )
+ if ( m_cid )
{
- const sal_uInt32 nCid = ( *cid & 0xFFFF );
+ const sal_uInt32 nCid = ( *m_cid & 0xFFFF );
const sal_uInt8 cmt = static_cast<sal_uInt8>( nCid & 0x7 );
const sal_Int16 arg2 = static_cast<sal_Int16>( nCid >> 3 );
@@ -541,7 +540,7 @@ SwTBC::ImportToolBarControl( SwCTBWrapper& rWrapper, const css::uno::Reference<
}
}
- if ( tbcd )
+ if ( m_tbcd )
{
std::vector< css::beans::PropertyValue > props;
if ( bBuiltin )
@@ -557,9 +556,9 @@ SwTBC::ImportToolBarControl( SwCTBWrapper& rWrapper, const css::uno::Reference<
}
}
bool bBeginGroup = false;
- tbcd->ImportToolBarControl( helper, props, bBeginGroup, bIsMenuBar );
+ m_tbcd->ImportToolBarControl( helper, props, bBeginGroup, bIsMenuBar );
- TBCMenuSpecific* pMenu = tbcd->getMenuSpecific();
+ TBCMenuSpecific* pMenu = m_tbcd->getMenuSpecific();
if ( pMenu )
{
SAL_INFO("sw.ww8","** control has a menu, name of toolbar with menu items is " << pMenu->Name() );
@@ -570,7 +569,7 @@ SwTBC::ImportToolBarControl( SwCTBWrapper& rWrapper, const css::uno::Reference<
SwCTB* pCustTB = rWrapper.GetCustomizationData( pMenu->Name() );
if ( pCustTB )
{
- uno::Reference< container::XIndexContainer > xMenuDesc = document::IndexedPropertyValues::create( comphelper::getProcessComponentContext() );
+ rtl::Reference< comphelper::IndexedPropertyValuesContainer > xMenuDesc = new comphelper::IndexedPropertyValuesContainer();
if ( !pCustTB->ImportMenuTB( rWrapper,xMenuDesc, helper ) )
return false;
if ( !bIsMenuBar )
@@ -582,7 +581,7 @@ SwTBC::ImportToolBarControl( SwCTBWrapper& rWrapper, const css::uno::Reference<
{
beans::PropertyValue aProp;
aProp.Name = "ItemDescriptorContainer";
- aProp.Value <<= xMenuDesc;
+ aProp.Value <<= uno::Reference< container::XIndexContainer >(xMenuDesc);
props.push_back( aProp );
}
}
@@ -591,13 +590,12 @@ SwTBC::ImportToolBarControl( SwCTBWrapper& rWrapper, const css::uno::Reference<
if ( bBeginGroup )
{
// insert spacer
- uno::Sequence< beans::PropertyValue > sProps( 1 );
- sProps[ 0 ].Name = "Type";
- sProps[ 0 ].Value <<= ui::ItemType::SEPARATOR_LINE;
- toolbarcontainer->insertByIndex( toolbarcontainer->getCount(), uno::makeAny( sProps ) );
+ uno::Sequence< beans::PropertyValue > sProps{ comphelper::makePropertyValue(
+ "Type", ui::ItemType::SEPARATOR_LINE) };
+ toolbarcontainer->insertByIndex( toolbarcontainer->getCount(), uno::Any( sProps ) );
}
- toolbarcontainer->insertByIndex( toolbarcontainer->getCount(), uno::makeAny( comphelper::containerToSequence(props) ) );
+ toolbarcontainer->insertByIndex( toolbarcontainer->getCount(), uno::Any( comphelper::containerToSequence(props) ) );
}
return true;
}
@@ -605,8 +603,8 @@ SwTBC::ImportToolBarControl( SwCTBWrapper& rWrapper, const css::uno::Reference<
OUString
SwTBC::GetCustomText()
{
- if ( tbcd )
- return tbcd->getGeneralInfo().CustomText();
+ if ( m_tbcd )
+ return m_tbcd->getGeneralInfo().CustomText();
return OUString();
}
@@ -615,11 +613,11 @@ Xst::Read( SvStream& rS )
{
SAL_INFO("sw.ww8","Xst::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
- sString = read_uInt16_PascalString(rS);
+ m_sString = read_uInt16_PascalString(rS);
return rS.good();
}
-Tcg::Tcg() : nTcgVer( -1 )
+Tcg::Tcg() : m_nTcgVer( -1 )
{
}
@@ -627,17 +625,17 @@ bool Tcg::Read(SvStream &rS)
{
SAL_INFO("sw.ww8","Tcg::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
- rS.ReadSChar( nTcgVer );
- if ( nTcgVer != -1 )
+ rS.ReadSChar( m_nTcgVer );
+ if ( m_nTcgVer != -1 )
return false;
- tcg.reset( new Tcg255() );
- return tcg->Read( rS );
+ m_tcg.reset( new Tcg255() );
+ return m_tcg->Read( rS );
}
bool Tcg::ImportCustomToolBar( SfxObjectShell& rDocSh )
{
- if (tcg)
- return tcg->ImportCustomToolBar( rDocSh );
+ if (m_tcg)
+ return m_tcg->ImportCustomToolBar( rDocSh );
return false;
}
@@ -689,17 +687,17 @@ bool Tcg255::processSubStruct( sal_uInt8 nId, SvStream &rS )
SAL_INFO("sw.ww8","Unknown id 0x" << std::hex << nId);
return false;
}
- xSubStruct->ch = nId;
+ xSubStruct->m_ch = nId;
if (!xSubStruct->Read(rS))
return false;
- rgtcgData.push_back(std::move(xSubStruct));
+ m_rgtcgData.push_back(std::move(xSubStruct));
return true;
}
bool Tcg255::ImportCustomToolBar( SfxObjectShell& rDocSh )
{
// Find the SwCTBWrapper
- for ( const auto & rSubStruct : rgtcgData )
+ for ( const auto & rSubStruct : m_rgtcgData )
{
if ( rSubStruct->id() == 0x12 )
{
@@ -736,7 +734,7 @@ bool Tcg255::Read(SvStream &rS)
// Peek at
}
-Tcg255SubStruct::Tcg255SubStruct( ) : ch(0)
+Tcg255SubStruct::Tcg255SubStruct( ) : m_ch(0)
{
}
@@ -748,7 +746,7 @@ bool Tcg255SubStruct::Read(SvStream &rS)
}
PlfMcd::PlfMcd()
- : iMac(0)
+ : m_iMac(0)
{
}
@@ -757,21 +755,21 @@ bool PlfMcd::Read(SvStream &rS)
SAL_INFO("sw.ww8","PffMcd::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
Tcg255SubStruct::Read( rS );
- rS.ReadInt32( iMac );
- if (iMac < 0)
+ rS.ReadInt32( m_iMac );
+ if (m_iMac < 0)
return false;
auto nMaxPossibleRecords = rS.remainingSize() / 24 /*sizeof MCD*/;
- if (o3tl::make_unsigned(iMac) > nMaxPossibleRecords)
+ if (o3tl::make_unsigned(m_iMac) > nMaxPossibleRecords)
{
- SAL_WARN("sw.ww8", iMac << " records claimed, but max possible is " << nMaxPossibleRecords);
- iMac = nMaxPossibleRecords;
+ SAL_WARN("sw.ww8", m_iMac << " records claimed, but max possible is " << nMaxPossibleRecords);
+ m_iMac = nMaxPossibleRecords;
}
- if (iMac)
+ if (m_iMac)
{
- rgmcd.resize(iMac);
- for ( sal_Int32 index = 0; index < iMac; ++index )
+ m_rgmcd.resize(m_iMac);
+ for ( sal_Int32 index = 0; index < m_iMac; ++index )
{
- if ( !rgmcd[ index ].Read( rS ) )
+ if ( !m_rgmcd[ index ].Read( rS ) )
return false;
}
}
@@ -779,7 +777,7 @@ bool PlfMcd::Read(SvStream &rS)
}
PlfAcd::PlfAcd() :
- iMac(0)
+ m_iMac(0)
{
}
@@ -792,21 +790,21 @@ bool PlfAcd::Read( SvStream &rS)
SAL_INFO("sw.ww8","PffAcd::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
Tcg255SubStruct::Read( rS );
- rS.ReadInt32( iMac );
- if (iMac < 0)
+ rS.ReadInt32( m_iMac );
+ if (m_iMac < 0)
return false;
auto nMaxPossibleRecords = rS.remainingSize() / (sizeof(sal_uInt16)*2);
- if (o3tl::make_unsigned(iMac) > nMaxPossibleRecords)
+ if (o3tl::make_unsigned(m_iMac) > nMaxPossibleRecords)
{
- SAL_WARN("sw.ww8", iMac << " records claimed, but max possible is " << nMaxPossibleRecords);
- iMac = nMaxPossibleRecords;
+ SAL_WARN("sw.ww8", m_iMac << " records claimed, but max possible is " << nMaxPossibleRecords);
+ m_iMac = nMaxPossibleRecords;
}
- if (iMac)
+ if (m_iMac)
{
- rgacd.reset( new Acd[ iMac ] );
- for ( sal_Int32 index = 0; index < iMac; ++index )
+ m_rgacd.reset( new Acd[ m_iMac ] );
+ for ( sal_Int32 index = 0; index < m_iMac; ++index )
{
- if ( !rgacd[ index ].Read( rS ) )
+ if ( !m_rgacd[ index ].Read( rS ) )
return false;
}
}
@@ -814,7 +812,7 @@ bool PlfAcd::Read( SvStream &rS)
}
PlfKme::PlfKme() :
- iMac( 0 )
+ m_iMac( 0 )
{
}
@@ -827,18 +825,18 @@ bool PlfKme::Read(SvStream &rS)
SAL_INFO("sw.ww8","PlfKme::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
Tcg255SubStruct::Read( rS );
- rS.ReadInt32( iMac );
- if (iMac > 0)
+ rS.ReadInt32( m_iMac );
+ if (m_iMac > 0)
{
//each Kme is 14 bytes in size
size_t nMaxAvailableRecords = rS.remainingSize() / 14;
- if (o3tl::make_unsigned(iMac) > nMaxAvailableRecords)
+ if (o3tl::make_unsigned(m_iMac) > nMaxAvailableRecords)
return false;
- rgkme.reset( new Kme[ iMac ] );
- for( sal_Int32 index=0; index<iMac; ++index )
+ m_rgkme.reset( new Kme[ m_iMac ] );
+ for( sal_Int32 index=0; index<m_iMac; ++index )
{
- if ( !rgkme[ index ].Read( rS ) )
+ if ( !m_rgkme[ index ].Read( rS ) )
return false;
}
}
@@ -854,12 +852,12 @@ bool TcgSttbf::Read( SvStream &rS)
SAL_INFO("sw.ww8","TcgSttbf::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
Tcg255SubStruct::Read( rS );
- return sttbf.Read( rS );
+ return m_sttbf.Read( rS );
}
-TcgSttbfCore::TcgSttbfCore() : fExtend( 0 )
-,cData( 0 )
-,cbExtra( 0 )
+TcgSttbfCore::TcgSttbfCore() : m_fExtend( 0 )
+,m_cData( 0 )
+,m_cbExtra( 0 )
{
}
@@ -871,24 +869,24 @@ bool TcgSttbfCore::Read( SvStream& rS )
{
SAL_INFO("sw.ww8","TcgSttbfCore::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
- rS.ReadUInt16( fExtend ).ReadUInt16( cData ).ReadUInt16( cbExtra );
- if ( cData )
+ rS.ReadUInt16( m_fExtend ).ReadUInt16( m_cData ).ReadUInt16( m_cbExtra );
+ if ( m_cData )
{
- if (cData > rS.remainingSize() / 4) //definitely an invalid record
+ if (m_cData > rS.remainingSize() / 4) //definitely an invalid record
return false;
- dataItems.reset( new SBBItem[ cData ] );
- for ( sal_Int32 index = 0; index < cData; ++index )
+ m_dataItems.reset( new SBBItem[ m_cData ] );
+ for ( sal_Int32 index = 0; index < m_cData; ++index )
{
- rS.ReadUInt16( dataItems[ index ].cchData );
- dataItems[ index ].data = read_uInt16s_ToOUString(rS, dataItems[index].cchData);
- rS.ReadUInt16( dataItems[ index ].extraData );
+ rS.ReadUInt16( m_dataItems[ index ].cchData );
+ m_dataItems[ index ].data = read_uInt16s_ToOUString(rS, m_dataItems[index].cchData);
+ rS.ReadUInt16( m_dataItems[ index ].extraData );
}
}
return rS.good();
}
MacroNames::MacroNames() :
- iMac( 0 )
+ m_iMac( 0 )
{
}
@@ -901,24 +899,24 @@ bool MacroNames::Read( SvStream &rS)
SAL_INFO("sw.ww8","MacroNames::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
Tcg255SubStruct::Read( rS );
- rS.ReadUInt16( iMac );
- if ( iMac )
+ rS.ReadUInt16( m_iMac );
+ if ( m_iMac )
{
//even an empty MacroName will take 2 bytes
size_t nMaxAvailableRecords = rS.remainingSize()/sizeof(sal_uInt16);
- if (iMac > nMaxAvailableRecords)
+ if (m_iMac > nMaxAvailableRecords)
return false;
- rgNames.reset( new MacroName[ iMac ] );
- for ( sal_Int32 index = 0; index < iMac; ++index )
+ m_rgNames.reset( new MacroName[ m_iMac ] );
+ for ( sal_Int32 index = 0; index < m_iMac; ++index )
{
- if ( !rgNames[ index ].Read( rS ) )
+ if ( !m_rgNames[ index ].Read( rS ) )
return false;
}
}
return rS.good();
}
-MacroName::MacroName():ibst(0)
+MacroName::MacroName():m_ibst(0)
{
}
@@ -926,11 +924,11 @@ bool MacroName::Read(SvStream &rS)
{
SAL_INFO("sw.ww8","MacroName::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
- rS.ReadUInt16( ibst );
- return xstz.Read( rS );
+ rS.ReadUInt16( m_ibst );
+ return m_xstz.Read( rS );
}
-Xstz::Xstz():chTerm(0)
+Xstz::Xstz():m_chTerm(0)
{
}
@@ -939,20 +937,20 @@ Xstz::Read(SvStream &rS)
{
SAL_INFO("sw.ww8","Xstz::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
- if ( !xst.Read( rS ) )
+ if ( !m_xst.Read( rS ) )
return false;
- rS.ReadUInt16( chTerm );
- if ( chTerm != 0 ) // should be an assert
+ rS.ReadUInt16( m_chTerm );
+ if ( m_chTerm != 0 ) // should be an assert
return false;
return rS.good();
}
-Kme::Kme() : reserved1(0)
-,reserved2(0)
-,kcm1(0)
-,kcm2(0)
-,kt(0)
-,param(0)
+Kme::Kme() : m_reserved1(0)
+,m_reserved2(0)
+,m_kcm1(0)
+,m_kcm2(0)
+,m_kt(0)
+,m_param(0)
{
}
@@ -965,12 +963,12 @@ Kme::Read(SvStream &rS)
{
SAL_INFO("sw.ww8","Kme::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
- rS.ReadInt16( reserved1 ).ReadInt16( reserved2 ).ReadUInt16( kcm1 ).ReadUInt16( kcm2 ).ReadUInt16( kt ).ReadUInt32( param );
+ rS.ReadInt16( m_reserved1 ).ReadInt16( m_reserved2 ).ReadUInt16( m_kcm1 ).ReadUInt16( m_kcm2 ).ReadUInt16( m_kt ).ReadUInt32( m_param );
return rS.good();
}
-Acd::Acd() : ibst( 0 )
-, fciBasedOnABC( 0 )
+Acd::Acd() : m_ibst( 0 )
+, m_fciBasedOnABC( 0 )
{
}
@@ -978,19 +976,19 @@ bool Acd::Read(SvStream &rS)
{
SAL_INFO("sw.ww8","Acd::Read() stream pos 0x" << std::hex << rS.Tell() );
nOffSet = rS.Tell();
- rS.ReadInt16( ibst ).ReadUInt16( fciBasedOnABC );
+ rS.ReadInt16( m_ibst ).ReadUInt16( m_fciBasedOnABC );
return rS.good();
}
-MCD::MCD() : reserved1(0x56)
-,reserved2( 0 )
-,ibst( 0 )
-,ibstName( 0 )
-,reserved3( 0xFFFF )
-,reserved4( 0 )
-,reserved5( 0 )
-,reserved6( 0 )
-,reserved7( 0 )
+MCD::MCD() : m_reserved1(0x56)
+,m_reserved2( 0 )
+,m_ibst( 0 )
+,m_ibstName( 0 )
+,m_reserved3( 0xFFFF )
+,m_reserved4( 0 )
+,m_reserved5( 0 )
+,m_reserved6( 0 )
+,m_reserved7( 0 )
{
}
@@ -998,8 +996,8 @@ bool MCD::Read(SvStream &rS)
{
SAL_INFO("sw.ww8","MCD::Read() stream pos 0x" << rS.Tell() );
nOffSet = rS.Tell();
- rS.ReadSChar( reserved1 ).ReadUChar( reserved2 ).ReadUInt16( ibst ).ReadUInt16( ibstName ).ReadUInt16( reserved3 );
- rS.ReadUInt32( reserved4 ).ReadUInt32( reserved5 ).ReadUInt32( reserved6 ).ReadUInt32( reserved7 );
+ rS.ReadSChar( m_reserved1 ).ReadUChar( m_reserved2 ).ReadUInt16( m_ibst ).ReadUInt16( m_ibstName ).ReadUInt16( m_reserved3 );
+ rS.ReadUInt32( m_reserved4 ).ReadUInt32( m_reserved5 ).ReadUInt32( m_reserved6 ).ReadUInt32( m_reserved7 );
return rS.good();
}
diff --git a/sw/source/filter/ww8/ww8toolbar.hxx b/sw/source/filter/ww8/ww8toolbar.hxx
index 346c39535a09..2d6876744ccf 100644
--- a/sw/source/filter/ww8/ww8toolbar.hxx
+++ b/sw/source/filter/ww8/ww8toolbar.hxx
@@ -19,19 +19,19 @@ class SwCTBWrapper;
class Xst : public TBBase
{
- OUString sString;
+ OUString m_sString;
public:
Xst(){}
bool Read(SvStream &rS) override;
- const OUString& getString() const { return sString; }
+ const OUString& getString() const { return m_sString; }
};
class SwTBC : public TBBase
{
- TBCHeader tbch;
- std::shared_ptr< sal_uInt32 > cid; // optional
- std::shared_ptr<TBCData> tbcd;
+ TBCHeader m_tbch;
+ std::shared_ptr< sal_uInt32 > m_cid; // optional
+ std::shared_ptr<TBCData> m_tbcd;
public:
SwTBC();
@@ -42,15 +42,15 @@ public:
class SwCTB : public TBBase
{
- Xst name;
- sal_Int32 cbTBData;
- TB tb;
- std::vector<TBVisualData> rVisualData;
- sal_Int32 iWCTBl;
- sal_uInt16 reserved;
- sal_uInt16 unused;
- sal_Int32 cCtls;
- std::vector< SwTBC > rTBC;
+ Xst m_name;
+ sal_Int32 m_cbTBData;
+ TB m_tb;
+ std::vector<TBVisualData> m_rVisualData;
+ sal_Int32 m_iWCTBl;
+ sal_uInt16 m_reserved;
+ sal_uInt16 m_unused;
+ sal_Int32 m_cCtls;
+ std::vector< SwTBC > m_rTBC;
SwCTB(const SwCTB&) = delete;
SwCTB& operator = ( const SwCTB&) = delete;
@@ -62,26 +62,26 @@ public:
bool IsMenuToolbar() const;
bool ImportCustomToolBar( SwCTBWrapper&, CustomToolBarImportHelper& );
bool ImportMenuTB( SwCTBWrapper&, const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper& );
- OUString const & GetName() { return tb.getName().getString(); }
+ OUString const & GetName() { return m_tb.getName().getString(); }
};
class TBDelta : public TBBase
{
- sal_uInt8 doprfatendFlags;
+ sal_uInt8 m_doprfatendFlags;
- sal_uInt8 ibts;
- sal_Int32 cidNext;
- sal_Int32 cid;
- sal_Int32 fc;
- sal_uInt16 CiTBDE; // careful of this ( endian matters etc. )
- sal_uInt16 cbTBC;
+ sal_uInt8 m_ibts;
+ sal_Int32 m_cidNext;
+ sal_Int32 m_cid;
+ sal_Int32 m_fc;
+ sal_uInt16 m_CiTBDE; // careful of this ( endian matters etc. )
+ sal_uInt16 m_cbTBC;
public:
TBDelta();
bool Read(SvStream &rS) override;
bool ControlIsInserted();
bool ControlDropsToolBar();
- sal_Int32 TBCStreamOffset() { return fc;}
+ sal_Int32 TBCStreamOffset() { return m_fc;}
sal_Int16 CustomizationIndex();
};
@@ -93,11 +93,11 @@ class Tcg255SubStruct : public TBBase
Tcg255SubStruct& operator = ( const Tcg255SubStruct&) = delete;
protected:
- sal_uInt8 ch;
+ sal_uInt8 m_ch;
public:
explicit Tcg255SubStruct();
- sal_uInt8 id() const { return ch; }
+ sal_uInt8 id() const { return m_ch; }
bool Read(SvStream &rS) override;
};
@@ -105,45 +105,45 @@ class Customization : public TBBase
{
friend class SwCTBWrapper;
- sal_Int32 tbidForTBD;
- sal_uInt16 reserved1;
- sal_uInt16 ctbds;
- SwCTBWrapper* pWrapper;
- std::shared_ptr< SwCTB > customizationDataCTB;
- std::vector< TBDelta > customizationDataTBDelta;
- bool bIsDroppedMenuTB;
+ sal_Int32 m_tbidForTBD;
+ sal_uInt16 m_reserved1;
+ sal_uInt16 m_ctbds;
+ SwCTBWrapper* m_pWrapper;
+ std::shared_ptr< SwCTB > m_customizationDataCTB;
+ std::vector< TBDelta > m_customizationDataTBDelta;
+ bool m_bIsDroppedMenuTB;
public:
explicit Customization( SwCTBWrapper* rapper );
bool Read(SvStream &rS) override;
bool ImportCustomToolBar( SwCTBWrapper&, CustomToolBarImportHelper& );
bool ImportMenu( SwCTBWrapper&, CustomToolBarImportHelper& );
- SwCTB* GetCustomizationData() { return customizationDataCTB.get(); };
+ SwCTB* GetCustomizationData() { return m_customizationDataCTB.get(); };
};
class SwCTBWrapper : public Tcg255SubStruct
{
// reserved1 is the ch field of Tcg255SubStruct
- sal_uInt16 reserved2;
- sal_uInt8 reserved3;
- sal_uInt16 reserved4;
- sal_uInt16 reserved5;
+ sal_uInt16 m_reserved2;
+ sal_uInt8 m_reserved3;
+ sal_uInt16 m_reserved4;
+ sal_uInt16 m_reserved5;
- sal_Int16 cbTBD;
- sal_uInt16 cCust;
+ sal_Int16 m_cbTBD;
+ sal_uInt16 m_cCust;
- sal_Int32 cbDTBC;
+ sal_Int32 m_cbDTBC;
- std::vector< SwTBC > rtbdc;
- std::vector< Customization > rCustomizations; // array of Customizations
- std::vector< sal_Int16 > dropDownMenuIndices; // array of indexes of Customization toolbars that are dropped by a menu
+ std::vector< SwTBC > m_rtbdc;
+ std::vector< Customization > m_rCustomizations; // array of Customizations
+ std::vector< sal_Int16 > m_dropDownMenuIndices; // array of indexes of Customization toolbars that are dropped by a menu
SwCTBWrapper(const SwCTBWrapper&) = delete;
SwCTBWrapper& operator = ( const SwCTBWrapper&) = delete;
public:
explicit SwCTBWrapper();
virtual ~SwCTBWrapper() override;
- void InsertDropIndex( sal_Int32 aIndex ) { dropDownMenuIndices.push_back( aIndex ); }
+ void InsertDropIndex( sal_Int32 aIndex ) { m_dropDownMenuIndices.push_back( aIndex ); }
SwTBC* GetTBCAtOffset( sal_uInt32 nStreamOffset );
bool Read(SvStream &rS) override;
bool ImportCustomToolBar( SfxObjectShell& rDocSh );
@@ -154,15 +154,15 @@ public:
class MCD : public TBBase
{
- sal_Int8 reserved1; // A signed integer that MUST be 0x56.
- sal_uInt8 reserved2; // MUST be 0.
- sal_uInt16 ibst; // Unsigned integer that specifies the name of the macro. Macro name is specified by MacroName.xstz of the MacroName entry in the MacroNames such that MacroName.ibst equals ibst. MacroNames MUST contain such an entry.
- sal_uInt16 ibstName; // An unsigned integer that specifies the index into the Command String Table (TcgSttbf.sttbf) where the macro's name and arguments are specified.
- sal_uInt16 reserved3; // An unsigned integer that MUST be 0xFFFF.
- sal_uInt32 reserved4; //MUST be ignored.
- sal_uInt32 reserved5; //MUST be 0.
- sal_uInt32 reserved6; //MUST be ignored.
- sal_uInt32 reserved7; //MUST be ignored
+ sal_Int8 m_reserved1; // A signed integer that MUST be 0x56.
+ sal_uInt8 m_reserved2; // MUST be 0.
+ sal_uInt16 m_ibst; // Unsigned integer that specifies the name of the macro. Macro name is specified by MacroName.xstz of the MacroName entry in the MacroNames such that MacroName.ibst equals ibst. MacroNames MUST contain such an entry.
+ sal_uInt16 m_ibstName; // An unsigned integer that specifies the index into the Command String Table (TcgSttbf.sttbf) where the macro's name and arguments are specified.
+ sal_uInt16 m_reserved3; // An unsigned integer that MUST be 0xFFFF.
+ sal_uInt32 m_reserved4; //MUST be ignored.
+ sal_uInt32 m_reserved5; //MUST be 0.
+ sal_uInt32 m_reserved6; //MUST be ignored.
+ sal_uInt32 m_reserved7; //MUST be ignored
public:
MCD();
@@ -171,8 +171,8 @@ public:
class PlfMcd : public Tcg255SubStruct
{
- sal_Int32 iMac;
- std::vector<MCD> rgmcd; // array of MCD's
+ sal_Int32 m_iMac;
+ std::vector<MCD> m_rgmcd; // array of MCD's
PlfMcd(const PlfMcd&) = delete;
PlfMcd& operator = ( const PlfMcd&) = delete;
@@ -183,8 +183,8 @@ public:
class Acd : public TBBase
{
- sal_Int16 ibst;
- sal_uInt16 fciBasedOnABC; // fciBasedOn(13 bits) A(1bit)B(1bit)C(1Bit)
+ sal_Int16 m_ibst;
+ sal_uInt16 m_fciBasedOnABC; // fciBasedOn(13 bits) A(1bit)B(1bit)C(1Bit)
Acd(const Acd&) = delete;
Acd& operator = ( const Acd&) = delete;
@@ -195,8 +195,8 @@ public:
class PlfAcd: public Tcg255SubStruct
{
- sal_Int32 iMac;
- std::unique_ptr<Acd[]> rgacd;
+ sal_Int32 m_iMac;
+ std::unique_ptr<Acd[]> m_rgacd;
PlfAcd(const PlfAcd&) = delete;
PlfAcd& operator = ( const PlfAcd&) = delete;
@@ -208,12 +208,12 @@ public:
class Kme : public TBBase
{
- sal_Int16 reserved1; //MUST be zero.
- sal_Int16 reserved2; //MUST be zero.
- sal_uInt16 kcm1; //A Kcm that specifies the primary shortcut key.
- sal_uInt16 kcm2; //A Kcm that specifies the secondary shortcut key, or 0x00FF if there is no secondary shortcut key.
- sal_uInt16 kt; //A Kt that specifies the type of action to be taken when the key combination is pressed.
- sal_uInt32 param; //The meaning of this field depends on the value of kt
+ sal_Int16 m_reserved1; //MUST be zero.
+ sal_Int16 m_reserved2; //MUST be zero.
+ sal_uInt16 m_kcm1; //A Kcm that specifies the primary shortcut key.
+ sal_uInt16 m_kcm2; //A Kcm that specifies the secondary shortcut key, or 0x00FF if there is no secondary shortcut key.
+ sal_uInt16 m_kt; //A Kt that specifies the type of action to be taken when the key combination is pressed.
+ sal_uInt32 m_param; //The meaning of this field depends on the value of kt
Kme(const Kme&) = delete;
Kme& operator = ( const Kme&) = delete;
@@ -226,8 +226,8 @@ public:
class PlfKme : public Tcg255SubStruct
{
- sal_Int32 iMac;
- std::unique_ptr<Kme[]> rgkme;
+ sal_Int32 m_iMac;
+ std::unique_ptr<Kme[]> m_rgkme;
PlfKme(const PlfKme&) = delete;
PlfKme& operator = ( const PlfKme&) = delete;
@@ -247,10 +247,10 @@ class TcgSttbfCore : public TBBase
SBBItem() : cchData(0), extraData(0){}
};
- sal_uInt16 fExtend;
- sal_uInt16 cData;
- sal_uInt16 cbExtra;
- std::unique_ptr<SBBItem[]> dataItems;
+ sal_uInt16 m_fExtend;
+ sal_uInt16 m_cData;
+ sal_uInt16 m_cbExtra;
+ std::unique_ptr<SBBItem[]> m_dataItems;
TcgSttbfCore(const TcgSttbfCore&) = delete;
TcgSttbfCore& operator = ( const TcgSttbfCore&) = delete;
@@ -262,7 +262,7 @@ public:
class TcgSttbf : public Tcg255SubStruct
{
- TcgSttbfCore sttbf;
+ TcgSttbfCore m_sttbf;
TcgSttbf(const TcgSttbf&) = delete;
TcgSttbf& operator = ( const TcgSttbf&) = delete;
@@ -273,8 +273,8 @@ public:
class Xstz : public TBBase
{
- Xst xst; //An Xst specifying the string with its pre-pended length.
- sal_uInt16 chTerm;
+ Xst m_xst; //An Xst specifying the string with its pre-pended length.
+ sal_uInt16 m_chTerm;
Xstz(const Xstz&) = delete;
Xstz& operator = ( const Xstz&) = delete;
@@ -286,8 +286,8 @@ public:
class MacroName : public TBBase
{
- sal_uInt16 ibst; //An unsigned integer that specifies the index of the current entry in the macro name table. MUST NOT be the same as the index of any other entry.
- Xstz xstz;
+ sal_uInt16 m_ibst; //An unsigned integer that specifies the index of the current entry in the macro name table. MUST NOT be the same as the index of any other entry.
+ Xstz m_xstz;
MacroName(const MacroName&) = delete;
MacroName& operator = ( const MacroName&) = delete;
@@ -298,8 +298,8 @@ public:
class MacroNames : public Tcg255SubStruct
{
- sal_uInt16 iMac; //An unsigned integer that specifies the number of MacroName structures in rgNames.
- std::unique_ptr<MacroName[]> rgNames;
+ sal_uInt16 m_iMac; //An unsigned integer that specifies the number of MacroName structures in rgNames.
+ std::unique_ptr<MacroName[]> m_rgNames;
MacroNames(const MacroNames&) = delete;
MacroNames& operator = ( const MacroNames&) = delete;
@@ -312,7 +312,7 @@ public:
class Tcg255 : public TBBase
{
- std::vector< std::unique_ptr<Tcg255SubStruct> > rgtcgData; // array of sub structures
+ std::vector< std::unique_ptr<Tcg255SubStruct> > m_rgtcgData; // array of sub structures
Tcg255(const Tcg255&) = delete;
Tcg255& operator = ( const Tcg255&) = delete;
bool processSubStruct( sal_uInt8 nId, SvStream& );
@@ -326,8 +326,8 @@ public:
class Tcg: public TBBase
{
- sal_Int8 nTcgVer;
- std::unique_ptr< Tcg255 > tcg;
+ sal_Int8 m_nTcgVer;
+ std::unique_ptr< Tcg255 > m_tcg;
Tcg(const Tcg&) = delete;
Tcg& operator = ( const Tcg&) = delete;