summaryrefslogtreecommitdiff
path: root/sw/source/filter
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/filter')
-rw-r--r--sw/source/filter/ascii/ascatr.cxx87
-rw-r--r--sw/source/filter/ascii/parasc.cxx267
-rw-r--r--sw/source/filter/ascii/wrtasc.cxx71
-rw-r--r--sw/source/filter/ascii/wrtasc.hxx3
-rw-r--r--sw/source/filter/basflt/fltini.cxx96
-rw-r--r--sw/source/filter/basflt/fltshell.cxx360
-rw-r--r--sw/source/filter/basflt/iodetect.cxx32
-rw-r--r--sw/source/filter/basflt/shellio.cxx122
-rw-r--r--sw/source/filter/docx/swdocxreader.cxx51
-rw-r--r--sw/source/filter/docx/swdocxreader.hxx2
-rw-r--r--sw/source/filter/html/README42
-rw-r--r--sw/source/filter/html/SwAppletImpl.cxx77
-rw-r--r--sw/source/filter/html/css1atr.cxx1263
-rw-r--r--sw/source/filter/html/css1kywd.cxx214
-rw-r--r--sw/source/filter/html/css1kywd.hxx280
-rw-r--r--sw/source/filter/html/htmlatr.cxx1794
-rw-r--r--sw/source/filter/html/htmlbas.cxx15
-rw-r--r--sw/source/filter/html/htmlcss1.cxx265
-rw-r--r--sw/source/filter/html/htmlctxt.cxx178
-rw-r--r--sw/source/filter/html/htmldrawreader.cxx81
-rw-r--r--sw/source/filter/html/htmldrawwriter.cxx72
-rw-r--r--sw/source/filter/html/htmlfld.cxx36
-rw-r--r--sw/source/filter/html/htmlfldw.cxx146
-rw-r--r--sw/source/filter/html/htmlfly.cxx34
-rw-r--r--sw/source/filter/html/htmlfly.hxx51
-rw-r--r--sw/source/filter/html/htmlflyt.cxx514
-rw-r--r--sw/source/filter/html/htmlflywriter.cxx1277
-rw-r--r--sw/source/filter/html/htmlform.cxx247
-rw-r--r--sw/source/filter/html/htmlform.hxx2
-rw-r--r--sw/source/filter/html/htmlforw.cxx221
-rw-r--r--sw/source/filter/html/htmlftn.cxx187
-rw-r--r--sw/source/filter/html/htmlgrin.cxx177
-rw-r--r--sw/source/filter/html/htmlnum.cxx60
-rw-r--r--sw/source/filter/html/htmlnum.hxx70
-rw-r--r--sw/source/filter/html/htmlnumreader.cxx36
-rw-r--r--sw/source/filter/html/htmlnumwriter.cxx118
-rw-r--r--sw/source/filter/html/htmlplug.cxx541
-rw-r--r--sw/source/filter/html/htmlreqifreader.cxx275
-rw-r--r--sw/source/filter/html/htmlreqifreader.hxx8
-rw-r--r--sw/source/filter/html/htmlsect.cxx133
-rw-r--r--sw/source/filter/html/htmltab.cxx818
-rw-r--r--sw/source/filter/html/htmltabw.cxx468
-rw-r--r--sw/source/filter/html/parcss1.cxx168
-rw-r--r--sw/source/filter/html/parcss1.hxx24
-rw-r--r--sw/source/filter/html/svxcss1.cxx547
-rw-r--r--sw/source/filter/html/svxcss1.hxx52
-rw-r--r--sw/source/filter/html/swhtml.cxx834
-rw-r--r--sw/source/filter/html/swhtml.hxx207
-rw-r--r--sw/source/filter/html/wrthtml.cxx695
-rw-r--r--sw/source/filter/html/wrthtml.hxx190
-rw-r--r--sw/source/filter/inc/IndexingExport.hxx32
-rw-r--r--sw/source/filter/inc/IndexingExportFilter.hxx68
-rw-r--r--sw/source/filter/inc/fltini.hxx13
-rw-r--r--sw/source/filter/inc/fltshell.hxx108
-rw-r--r--sw/source/filter/inc/msfilter.hxx39
-rw-r--r--sw/source/filter/inc/rtf.hxx10
-rw-r--r--sw/source/filter/inc/wrt_fn.hxx7
-rw-r--r--sw/source/filter/inc/wrtswtbl.hxx111
-rw-r--r--sw/source/filter/inc/wwstyles.hxx9
-rw-r--r--sw/source/filter/indexing/IndexingExport.cxx203
-rw-r--r--sw/source/filter/indexing/IndexingExportFilter.cxx61
-rw-r--r--sw/source/filter/rtf/swparrtf.cxx26
-rw-r--r--sw/source/filter/writer/writer.cxx168
-rw-r--r--sw/source/filter/writer/wrt_fn.cxx8
-rw-r--r--sw/source/filter/writer/wrtswtbl.cxx77
-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.hxx67
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx4892
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx345
-rw-r--r--sw/source/filter/ww8/docxexport.cxx704
-rw-r--r--sw/source/filter/ww8/docxexport.hxx45
-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.cxx1147
-rw-r--r--sw/source/filter/ww8/docxsdrexport.hxx11
-rw-r--r--sw/source/filter/ww8/docxtableexport.cxx898
-rw-r--r--sw/source/filter/ww8/docxtablestyleexport.cxx134
-rw-r--r--sw/source/filter/ww8/escher.hxx15
-rw-r--r--sw/source/filter/ww8/fields.cxx4
-rw-r--r--sw/source/filter/ww8/fields.hxx2
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx1229
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.hxx96
-rw-r--r--sw/source/filter/ww8/rtfexport.cxx541
-rw-r--r--sw/source/filter/ww8/rtfexport.hxx35
-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.cxx131
-rw-r--r--sw/source/filter/ww8/rtfstringbuffer.cxx12
-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.cxx194
-rw-r--r--sw/source/filter/ww8/writerhelper.cxx162
-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.cxx541
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx1012
-rw-r--r--sw/source/filter/ww8/wrtw8num.cxx193
-rw-r--r--sw/source/filter/ww8/wrtw8sty.cxx1107
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx1366
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx296
-rw-r--r--sw/source/filter/ww8/wrtww8gr.cxx172
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx1160
-rw-r--r--sw/source/filter/ww8/ww8attributeoutput.hxx118
-rw-r--r--sw/source/filter/ww8/ww8glsy.cxx84
-rw-r--r--sw/source/filter/ww8/ww8glsy.hxx18
-rw-r--r--sw/source/filter/ww8/ww8graf.cxx923
-rw-r--r--sw/source/filter/ww8/ww8graf.hxx8
-rw-r--r--sw/source/filter/ww8/ww8graf2.cxx140
-rw-r--r--sw/source/filter/ww8/ww8par.cxx1346
-rw-r--r--sw/source/filter/ww8/ww8par.hxx353
-rw-r--r--sw/source/filter/ww8/ww8par2.cxx513
-rw-r--r--sw/source/filter/ww8/ww8par2.hxx38
-rw-r--r--sw/source/filter/ww8/ww8par3.cxx550
-rw-r--r--sw/source/filter/ww8/ww8par4.cxx60
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx443
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx750
-rw-r--r--sw/source/filter/ww8/ww8scan.cxx1115
-rw-r--r--sw/source/filter/ww8/ww8scan.hxx252
-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
-rw-r--r--sw/source/filter/xml/XMLRedlineImportHelper.cxx208
-rw-r--r--sw/source/filter/xml/XMLRedlineImportHelper.hxx6
-rw-r--r--sw/source/filter/xml/swxml.cxx131
-rw-r--r--sw/source/filter/xml/wrtxml.cxx103
-rw-r--r--sw/source/filter/xml/wrtxml.hxx9
-rw-r--r--sw/source/filter/xml/xmlbrsh.cxx34
-rw-r--r--sw/source/filter/xml/xmlbrshe.hxx5
-rw-r--r--sw/source/filter/xml/xmlbrshi.hxx4
-rw-r--r--sw/source/filter/xml/xmlexp.cxx96
-rw-r--r--sw/source/filter/xml/xmlexp.hxx10
-rw-r--r--sw/source/filter/xml/xmlexpit.cxx45
-rw-r--r--sw/source/filter/xml/xmlexpit.hxx21
-rw-r--r--sw/source/filter/xml/xmlfmt.cxx254
-rw-r--r--sw/source/filter/xml/xmlfmte.cxx101
-rw-r--r--sw/source/filter/xml/xmlfonte.cxx73
-rw-r--r--sw/source/filter/xml/xmlimp.cxx533
-rw-r--r--sw/source/filter/xml/xmlimp.hxx22
-rw-r--r--sw/source/filter/xml/xmlimpit.cxx72
-rw-r--r--sw/source/filter/xml/xmlimpit.hxx5
-rw-r--r--sw/source/filter/xml/xmlitem.cxx32
-rw-r--r--sw/source/filter/xml/xmlitem.hxx9
-rw-r--r--sw/source/filter/xml/xmliteme.cxx68
-rw-r--r--sw/source/filter/xml/xmlitemi.cxx9
-rw-r--r--sw/source/filter/xml/xmlitemm.cxx40
-rw-r--r--sw/source/filter/xml/xmlithlp.cxx16
-rw-r--r--sw/source/filter/xml/xmlitmap.hxx19
-rw-r--r--sw/source/filter/xml/xmlitmpr.cxx46
-rw-r--r--sw/source/filter/xml/xmlmeta.cxx8
-rw-r--r--sw/source/filter/xml/xmlscript.cxx2
-rw-r--r--sw/source/filter/xml/xmltble.cxx507
-rw-r--r--sw/source/filter/xml/xmltbli.cxx456
-rw-r--r--sw/source/filter/xml/xmltbli.hxx16
-rw-r--r--sw/source/filter/xml/xmltexte.cxx97
-rw-r--r--sw/source/filter/xml/xmltexte.hxx22
-rw-r--r--sw/source/filter/xml/xmltexti.cxx253
-rw-r--r--sw/source/filter/xml/xmltexti.hxx5
-rw-r--r--sw/source/filter/xml/zorder.hxx78
163 files changed, 23610 insertions, 18591 deletions
diff --git a/sw/source/filter/ascii/ascatr.cxx b/sw/source/filter/ascii/ascatr.cxx
index da433d4272e0..c4f4d1249070 100644
--- a/sw/source/filter/ascii/ascatr.cxx
+++ b/sw/source/filter/ascii/ascatr.cxx
@@ -45,45 +45,36 @@ namespace {
class SwASC_AttrIter
{
- SwASCWriter& rWrt;
- const SwTextNode& rNd;
- sal_Int32 nCurrentSwPos;
+ SwASCWriter& m_rWrt;
+ const SwTextNode& m_rNd;
+ sal_Int32 m_nCurrentSwPos;
sal_Int32 SearchNext( sal_Int32 nStartPos );
public:
SwASC_AttrIter( SwASCWriter& rWrt, const SwTextNode& rNd, sal_Int32 nStt );
- void NextPos()
- {
- nCurrentSwPos = SearchNext( nCurrentSwPos + 1 );
- }
+ void NextPos() { m_nCurrentSwPos = SearchNext(m_nCurrentSwPos + 1); }
- sal_Int32 WhereNext() const
- {
- return nCurrentSwPos;
- }
+ sal_Int32 WhereNext() const { return m_nCurrentSwPos; }
bool OutAttr( sal_Int32 nSwPos );
};
}
-SwASC_AttrIter::SwASC_AttrIter(
- SwASCWriter& rWr,
- const SwTextNode& rTextNd,
- sal_Int32 nStt )
- : rWrt( rWr )
- , rNd( rTextNd )
- , nCurrentSwPos( 0 )
+SwASC_AttrIter::SwASC_AttrIter(SwASCWriter& rWr, const SwTextNode& rTextNd, sal_Int32 nStt)
+ : m_rWrt(rWr)
+ , m_rNd(rTextNd)
+ , m_nCurrentSwPos(0)
{
- nCurrentSwPos = SearchNext( nStt + 1 );
+ m_nCurrentSwPos = SearchNext(nStt + 1);
}
sal_Int32 SwASC_AttrIter::SearchNext( sal_Int32 nStartPos )
{
sal_Int32 nMinPos = SAL_MAX_INT32;
- const SwpHints* pTextAttrs = rNd.GetpSwpHints();
+ const SwpHints* pTextAttrs = m_rNd.GetpSwpHints();
if( pTextAttrs )
{
// TODO: This can be optimized, if we make use of the fact that the TextAttrs
@@ -123,7 +114,7 @@ sal_Int32 SwASC_AttrIter::SearchNext( sal_Int32 nStartPos )
bool SwASC_AttrIter::OutAttr( sal_Int32 nSwPos )
{
bool bRet = false;
- const SwpHints* pTextAttrs = rNd.GetpSwpHints();
+ const SwpHints* pTextAttrs = m_rNd.GetpSwpHints();
if( pTextAttrs )
{
for( size_t i = 0; i < pTextAttrs->Count(); ++i )
@@ -150,16 +141,22 @@ bool SwASC_AttrIter::OutAttr( sal_Int32 nSwPos )
if( !rFootnote.GetNumStr().isEmpty() )
sOut = rFootnote.GetNumStr();
else if( rFootnote.IsEndNote() )
- sOut = rWrt.m_pDoc->GetEndNoteInfo().m_aFormat.
- GetNumStr( rFootnote.GetNumber() );
+ sOut = m_rWrt.m_pDoc->GetEndNoteInfo().m_aFormat.GetNumStr(
+ rFootnote.GetNumber());
else
- sOut = rWrt.m_pDoc->GetFootnoteInfo().m_aFormat.
- GetNumStr( rFootnote.GetNumber() );
+ sOut = m_rWrt.m_pDoc->GetFootnoteInfo().m_aFormat.GetNumStr(
+ rFootnote.GetNumber());
}
break;
+ case RES_TXTATR_LINEBREAK:
+ {
+ // Downgrade the clearing break to a simple linebreak.
+ sOut = OUStringChar(GetCharOfTextAttr(*pHt));
+ break;
+ }
}
if( !sOut.isEmpty() )
- rWrt.Strm().WriteUnicodeOrByteText( sOut );
+ m_rWrt.Strm().WriteUnicodeOrByteText(sOut);
}
else if( nSwPos < pHt->GetStart() )
break;
@@ -194,8 +191,8 @@ public:
return false;
}
SwRangeRedline const*const pRedline(m_rIDRA.GetRedlineTable()[m_nextRedline]);
- return pRedline->Start()->nNode.GetIndex() < m_rNode.GetIndex()
- && m_rNode.GetIndex() < pRedline->End()->nNode.GetIndex();
+ return pRedline->Start()->GetNodeIndex() < m_rNode.GetIndex()
+ && m_rNode.GetIndex() < pRedline->End()->GetNodeIndex();
}
std::pair<sal_Int32, sal_Int32> GetNextRedlineSkip()
@@ -209,29 +206,28 @@ public:
{
continue;
}
- SwPosition const*const pStart(pRedline->Start());
- SwPosition const*const pEnd(pRedline->End());
- if (m_rNode.GetIndex() < pStart->nNode.GetIndex())
+ auto [pStart, pEnd] = pRedline->StartEnd(); // SwPosition*
+ if (m_rNode.GetIndex() < pStart->GetNodeIndex())
{
m_nextRedline = SwRedlineTable::npos;
break; // done
}
if (nRedlineStart == COMPLETE_STRING)
{
- nRedlineStart = pStart->nNode.GetIndex() == m_rNode.GetIndex()
- ? pStart->nContent.GetIndex()
+ nRedlineStart = pStart->GetNodeIndex() == m_rNode.GetIndex()
+ ? pStart->GetContentIndex()
: 0;
}
else
{
- if (pStart->nContent.GetIndex() != nRedlineEnd)
+ if (pStart->GetContentIndex() != nRedlineEnd)
{
- assert(nRedlineEnd < pStart->nContent.GetIndex());
+ assert(nRedlineEnd < pStart->GetContentIndex());
break; // no increment, revisit it next call
}
}
- nRedlineEnd = pEnd->nNode.GetIndex() == m_rNode.GetIndex()
- ? pEnd->nContent.GetIndex()
+ nRedlineEnd = pEnd->GetNodeIndex() == m_rNode.GetIndex()
+ ? pEnd->GetContentIndex()
: COMPLETE_STRING;
}
return std::make_pair(nRedlineStart, nRedlineEnd);
@@ -246,14 +242,14 @@ static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode )
{
const SwTextNode& rNd = static_cast<SwTextNode&>(rNode);
- sal_Int32 nStrPos = rWrt.m_pCurrentPam->GetPoint()->nContent.GetIndex();
+ sal_Int32 nStrPos = rWrt.m_pCurrentPam->GetPoint()->GetContentIndex();
const sal_Int32 nNodeEnd = rNd.Len();
sal_Int32 nEnd = nNodeEnd;
- bool bLastNd = rWrt.m_pCurrentPam->GetPoint()->nNode == rWrt.m_pCurrentPam->GetMark()->nNode;
+ bool bLastNd = rWrt.m_pCurrentPam->GetPoint()->GetNode() == rWrt.m_pCurrentPam->GetMark()->GetNode();
if( bLastNd )
- nEnd = rWrt.m_pCurrentPam->GetMark()->nContent.GetIndex();
+ nEnd = rWrt.m_pCurrentPam->GetMark()->GetContentIndex();
- bool bIsOneParagraph = rWrt.m_pOrigPam->Start()->nNode == rWrt.m_pOrigPam->End()->nNode;
+ bool bIsOneParagraph = rWrt.m_pOrigPam->Start()->GetNode() == rWrt.m_pOrigPam->End()->GetNode() && !getenv("SW_ASCII_COPY_NUMBERING");
SwASC_AttrIter aAttrIter( static_cast<SwASCWriter&>(rWrt), rNd, nStrPos );
SwASC_RedlineIter redlineIter(static_cast<SwASCWriter&>(rWrt), rNd);
@@ -289,7 +285,7 @@ static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode )
}
if (!level.isEmpty() || !numString.isEmpty())
- rWrt.Strm().WriteUnicodeOrByteText(level + numString + " ");
+ rWrt.Strm().WriteUnicodeOrByteText(Concat2View(level + numString + " "));
}
OUString aStr( rNd.GetText() );
@@ -316,14 +312,14 @@ static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode )
{
if (nNextAttr <= curRedline.first)
{
- buf.append(aStr.copy(nStrPos, nNextAttr - nStrPos));
+ buf.append(aStr.subView(nStrPos, nNextAttr - nStrPos));
break;
}
else if (nStrPos < curRedline.second)
{
if (nStrPos < curRedline.first)
{
- buf.append(aStr.copy(nStrPos, curRedline.first - nStrPos));
+ buf.append(aStr.subView(nStrPos, curRedline.first - nStrPos));
}
if (curRedline.second <= nNextAttr)
{
@@ -345,7 +341,7 @@ static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode )
if ( !bExportSoftHyphens )
aOutStr = aOutStr.replaceAll(OUStringChar(CHAR_SOFTHYPHEN), "");
- // all INWORD/BREAKWORD should be already removed by OutAttr
+ // all INWORD should be already removed by OutAttr
// but the field-marks are not attributes so filter those
static sal_Unicode const forbidden [] = {
CH_TXT_ATR_INPUTFIELDSTART,
@@ -354,6 +350,7 @@ static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode )
CH_TXT_ATR_FIELDSTART,
CH_TXT_ATR_FIELDSEP,
CH_TXT_ATR_FIELDEND,
+ CH_TXTATR_BREAKWORD,
0
};
aOutStr = comphelper::string::removeAny(aOutStr, forbidden);
diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx
index b58f268547ef..b4e191df621d 100644
--- a/sw/source/filter/ascii/parasc.cxx
+++ b/sw/source/filter/ascii/parasc.cxx
@@ -21,7 +21,9 @@
#include <tools/stream.hxx>
#include <hintids.hxx>
+#include <sfx2/docfile.hxx>
#include <sfx2/printer.hxx>
+#include <sfx2/sfxsids.hrc>
#include <editeng/fontitem.hxx>
#include <editeng/langitem.hxx>
#include <editeng/formatbreakitem.hxx>
@@ -48,15 +50,16 @@ namespace {
class SwASCIIParser
{
- SwDoc& rDoc;
- std::unique_ptr<SwPaM> pPam;
- SvStream& rInput;
- std::unique_ptr<char[]> pArr;
- const SwAsciiOptions& rOpt;
- std::unique_ptr<SfxItemSet> pItemSet;
- tools::Long nFileSize;
- SvtScriptType nScript;
- bool bNewDoc;
+ SwDoc& m_rDoc;
+ std::optional<SwPaM> m_oPam;
+ SvStream& m_rInput;
+ std::unique_ptr<char[]> m_pArr;
+ const SwAsciiOptions& m_rOpt;
+ SwAsciiOptions m_usedAsciiOptions;
+ std::optional<SfxItemSet> m_oItemSet;
+ tools::Long m_nFileSize;
+ SvtScriptType m_nScript;
+ bool m_bNewDoc;
ErrCode ReadChars();
void InsertText( const OUString& rStr );
@@ -69,12 +72,13 @@ public:
bool bReadNewDoc, const SwAsciiOptions& rOpts );
ErrCode CallParser();
+ const SwAsciiOptions& GetUsedAsciiOptions() const { return m_usedAsciiOptions; }
};
}
// Call for the general reader interface
-ErrCode AsciiReader::Read( SwDoc& rDoc, const OUString&, SwPaM &rPam, const OUString & )
+ErrCodeMsg AsciiReader::Read( SwDoc& rDoc, const OUString&, SwPaM &rPam, const OUString & )
{
if( !m_pStream )
{
@@ -82,107 +86,121 @@ ErrCode AsciiReader::Read( SwDoc& rDoc, const OUString&, SwPaM &rPam, const OUSt
return ERR_SWG_READ_ERROR;
}
- std::unique_ptr<SwASCIIParser> xParser(new SwASCIIParser( rDoc, rPam, *m_pStream,
- !m_bInsertMode, m_aOption.GetASCIIOpts() ));
- ErrCode nRet = xParser->CallParser();
+ ErrCode nRet;
+ {
+ SwASCIIParser aParser( rDoc, rPam, *m_pStream,
+ !m_bInsertMode, m_aOption.GetASCIIOpts() );
+ nRet = aParser.CallParser();
+
+ OUString optionsString;
+ aParser.GetUsedAsciiOptions().WriteUserData(optionsString);
- xParser.reset();
+ if(m_pMedium != nullptr)
+ m_pMedium->GetItemSet().Put(SfxStringItem(SID_FILE_FILTEROPTIONS, optionsString));
+ }
// after Read reset the options
m_aOption.ResetASCIIOpts();
return nRet;
}
-SwASCIIParser::SwASCIIParser(SwDoc& rD, const SwPaM& rCursor, SvStream& rIn,
- bool bReadNewDoc, const SwAsciiOptions& rOpts)
- : rDoc(rD), rInput(rIn), rOpt(rOpts), nFileSize(0), nScript(SvtScriptType::NONE)
- , bNewDoc(bReadNewDoc)
+SwASCIIParser::SwASCIIParser(SwDoc& rD, const SwPaM& rCursor, SvStream& rIn, bool bReadNewDoc,
+ const SwAsciiOptions& rOpts)
+ : m_rDoc(rD)
+ , m_rInput(rIn)
+ , m_rOpt(rOpts)
+ , m_usedAsciiOptions(rOpts)
+ , m_nFileSize(0)
+ , m_nScript(SvtScriptType::NONE)
+ , m_bNewDoc(bReadNewDoc)
{
- pPam.reset( new SwPaM( *rCursor.GetPoint() ) );
- pArr.reset( new char [ ASC_BUFFLEN + 2 ] );
+ m_oPam.emplace(*rCursor.GetPoint());
+ m_pArr.reset(new char[ASC_BUFFLEN + 2]);
- pItemSet = std::make_unique<SfxItemSet>( rDoc.GetAttrPool(),
- svl::Items<RES_CHRATR_FONT, RES_CHRATR_LANGUAGE,
- RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_LANGUAGE,
- RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_LANGUAGE>{} );
+ m_oItemSet.emplace(
+ m_rDoc.GetAttrPool(),
+ svl::Items<RES_CHRATR_FONT, RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_FONT,
+ RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_LANGUAGE>);
// set defaults from the options
- if( rOpt.GetLanguage() )
+ if (m_rOpt.GetLanguage())
{
- SvxLanguageItem aLang( rOpt.GetLanguage(), RES_CHRATR_LANGUAGE );
- pItemSet->Put( aLang );
+ SvxLanguageItem aLang(m_rOpt.GetLanguage(), RES_CHRATR_LANGUAGE);
+ m_oItemSet->Put(aLang);
aLang.SetWhich(RES_CHRATR_CJK_LANGUAGE);
- pItemSet->Put( aLang );
+ m_oItemSet->Put(aLang);
aLang.SetWhich(RES_CHRATR_CTL_LANGUAGE);
- pItemSet->Put( aLang );
+ m_oItemSet->Put(aLang);
}
- if( rOpt.GetFontName().isEmpty() )
+ if (m_rOpt.GetFontName().isEmpty())
return;
- vcl::Font aTextFont( rOpt.GetFontName(), Size( 0, 10 ) );
- if( rDoc.getIDocumentDeviceAccess().getPrinter( false ) )
- aTextFont = rDoc.getIDocumentDeviceAccess().getPrinter( false )->GetFontMetric( aTextFont );
+ vcl::Font aTextFont(m_rOpt.GetFontName(), Size(0, 10));
+ if (m_rDoc.getIDocumentDeviceAccess().getPrinter(false))
+ aTextFont = m_rDoc.getIDocumentDeviceAccess().getPrinter(false)->GetFontMetric(aTextFont);
SvxFontItem aFont( aTextFont.GetFamilyType(), aTextFont.GetFamilyName(),
OUString(), aTextFont.GetPitch(), aTextFont.GetCharSet(), RES_CHRATR_FONT );
- pItemSet->Put( aFont );
+ m_oItemSet->Put(aFont);
aFont.SetWhich(RES_CHRATR_CJK_FONT);
- pItemSet->Put( aFont );
+ m_oItemSet->Put(aFont);
aFont.SetWhich(RES_CHRATR_CTL_FONT);
- pItemSet->Put( aFont );
+ m_oItemSet->Put(aFont);
}
// Calling the parser
ErrCode SwASCIIParser::CallParser()
{
- rInput.ResetError();
- nFileSize = rInput.TellEnd();
- rInput.Seek(STREAM_SEEK_TO_BEGIN);
- rInput.ResetError();
+ m_rInput.ResetError();
+ m_nFileSize = m_rInput.TellEnd();
+ m_rInput.Seek(STREAM_SEEK_TO_BEGIN);
+ m_rInput.ResetError();
- ::StartProgress( STR_STATSTR_W4WREAD, 0, nFileSize, rDoc.GetDocShell() );
+ ::StartProgress(STR_STATSTR_W4WREAD, 0, m_nFileSize, m_rDoc.GetDocShell());
- std::unique_ptr<SwPaM> pInsPam;
+ std::optional<SwPaM> pInsPam;
sal_Int32 nSttContent = 0;
- if (!bNewDoc)
+ if (!m_bNewDoc)
{
- const SwNodeIndex& rTmp = pPam->GetPoint()->nNode;
- pInsPam.reset(new SwPaM( rTmp, rTmp, 0, -1 ));
- nSttContent = pPam->GetPoint()->nContent.GetIndex();
+ const SwNode& rTmp = m_oPam->GetPoint()->GetNode();
+ pInsPam.emplace( rTmp, rTmp, SwNodeOffset(0), SwNodeOffset(-1) );
+ nSttContent = m_oPam->GetPoint()->GetContentIndex();
}
SwTextFormatColl *pColl = nullptr;
- if (bNewDoc)
+ if (m_bNewDoc)
{
- pColl = rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_HTML_PRE, false);
+ pColl = m_rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_HTML_PRE,
+ false);
if (!pColl)
- pColl = rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_STANDARD,false);
+ pColl = m_rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_STANDARD,
+ false);
if (pColl)
- rDoc.SetTextFormatColl(*pPam, pColl);
+ m_rDoc.SetTextFormatColl(*m_oPam, pColl);
}
ErrCode nError = ReadChars();
- if( pItemSet )
+ if (m_oItemSet)
{
// set only the attribute, for scanned scripts.
- if( !( SvtScriptType::LATIN & nScript ))
+ if (!(SvtScriptType::LATIN & m_nScript))
{
- pItemSet->ClearItem( RES_CHRATR_FONT );
- pItemSet->ClearItem( RES_CHRATR_LANGUAGE );
+ m_oItemSet->ClearItem(RES_CHRATR_FONT);
+ m_oItemSet->ClearItem(RES_CHRATR_LANGUAGE);
}
- if( !( SvtScriptType::ASIAN & nScript ))
+ if (!(SvtScriptType::ASIAN & m_nScript))
{
- pItemSet->ClearItem( RES_CHRATR_CJK_FONT );
- pItemSet->ClearItem( RES_CHRATR_CJK_LANGUAGE );
+ m_oItemSet->ClearItem(RES_CHRATR_CJK_FONT);
+ m_oItemSet->ClearItem(RES_CHRATR_CJK_LANGUAGE);
}
- if( !( SvtScriptType::COMPLEX & nScript ))
+ if (!(SvtScriptType::COMPLEX & m_nScript))
{
- pItemSet->ClearItem( RES_CHRATR_CTL_FONT );
- pItemSet->ClearItem( RES_CHRATR_CTL_LANGUAGE );
+ m_oItemSet->ClearItem(RES_CHRATR_CTL_FONT);
+ m_oItemSet->ClearItem(RES_CHRATR_CTL_LANGUAGE);
}
- if( pItemSet->Count() )
+ if (m_oItemSet->Count())
{
- if( bNewDoc )
+ if (m_bNewDoc)
{
if (pColl)
{
@@ -206,37 +224,36 @@ ErrCode SwASCIIParser::CallParser()
while (*pWhichIds)
{
const SfxPoolItem *pItem;
- if (SfxItemState::SET == pItemSet->GetItemState(*pWhichIds,
- false, &pItem))
+ if (SfxItemState::SET
+ == m_oItemSet->GetItemState(*pWhichIds, false, &pItem))
{
pColl->SetFormatAttr( *pItem );
- pItemSet->ClearItem( *pWhichIds );
+ m_oItemSet->ClearItem(*pWhichIds);
}
++pWhichIds;
}
}
- if (pItemSet->Count())
- rDoc.SetDefault(*pItemSet);
+ if (m_oItemSet->Count())
+ m_rDoc.SetDefault(*m_oItemSet);
}
else if( pInsPam )
{
// then set over the insert range the defined attributes
- *pInsPam->GetMark() = *pPam->GetPoint();
- ++pInsPam->GetPoint()->nNode;
- pInsPam->GetPoint()->nContent.Assign(
- pInsPam->GetContentNode(), nSttContent );
+ *pInsPam->GetMark() = *m_oPam->GetPoint();
+ pInsPam->GetPoint()->Assign(pInsPam->GetPoint()->GetNode(), SwNodeOffset(1),
+ nSttContent );
// !!!!!
OSL_ENSURE( false, "Have to change - hard attr. to para. style" );
- rDoc.getIDocumentContentOperations().InsertItemSet( *pInsPam, *pItemSet );
+ m_rDoc.getIDocumentContentOperations().InsertItemSet(*pInsPam, *m_oItemSet);
}
}
- pItemSet.reset();
+ m_oItemSet.reset();
}
pInsPam.reset();
- ::EndProgress( rDoc.GetDocShell() );
+ ::EndProgress(m_rDoc.GetDocShell());
return nError;
}
@@ -247,20 +264,21 @@ ErrCode SwASCIIParser::ReadChars()
sal_Unicode cLastCR = 0;
bool bSwapUnicode = false;
- const SwAsciiOptions *pUseMe=&rOpt;
+ const SwAsciiOptions* pUseMe = &m_rOpt;
SwAsciiOptions aEmpty;
- if (nFileSize >= 2 &&
- aEmpty.GetFontName() == rOpt.GetFontName() &&
- aEmpty.GetCharSet() == rOpt.GetCharSet() &&
- aEmpty.GetLanguage() == rOpt.GetLanguage() &&
- aEmpty.GetParaFlags() == rOpt.GetParaFlags())
+ if (m_nFileSize >= 2 && aEmpty.GetFontName() == m_rOpt.GetFontName()
+ && aEmpty.GetCharSet() == m_rOpt.GetCharSet()
+ && aEmpty.GetLanguage() == m_rOpt.GetLanguage()
+ && aEmpty.GetParaFlags() == m_rOpt.GetParaFlags())
{
sal_Size nLen, nOrig;
- nOrig = nLen = rInput.ReadBytes(pArr.get(), ASC_BUFFLEN);
+ nOrig = nLen = m_rInput.ReadBytes(m_pArr.get(), ASC_BUFFLEN);
rtl_TextEncoding eCharSet;
LineEnd eLineEnd;
+ bool bHasBom;
const bool bRet
- = SwIoSystem::IsDetectableText(pArr.get(), nLen, &eCharSet, &bSwapUnicode, &eLineEnd);
+ = SwIoSystem::IsDetectableText(m_pArr.get(), nLen, &eCharSet,
+ &bSwapUnicode, &eLineEnd, &bHasBom);
if (!bRet)
return ERRCODE_IO_BROKENPACKAGE;
@@ -269,12 +287,14 @@ ErrCode SwASCIIParser::ReadChars()
{
aEmpty.SetCharSet(eCharSet);
aEmpty.SetParaFlags(eLineEnd);
- rInput.SeekRel(-(tools::Long(nLen)));
+ aEmpty.SetIncludeBOM(bHasBom);
+ m_rInput.SeekRel(-(tools::Long(nLen)));
}
else
- rInput.SeekRel(-(tools::Long(nOrig)));
+ m_rInput.SeekRel(-(tools::Long(nOrig)));
pUseMe=&aEmpty;
}
+ m_usedAsciiOptions = *pUseMe;
rtl_TextToUnicodeConverter hConverter=nullptr;
rtl_TextToUnicodeContext hContext=nullptr;
@@ -292,8 +312,8 @@ ErrCode SwASCIIParser::ReadChars()
}
else if (pUseMe != &aEmpty) //Already successfully figured out type
{
- rInput.StartReadingUnicodeText( currentCharSet );
- bSwapUnicode = rInput.IsEndianSwap();
+ m_rInput.StartReadingUnicodeText(currentCharSet);
+ bSwapUnicode = m_rInput.IsEndianSwap();
}
std::unique_ptr<sal_Unicode[]> aWork;
@@ -307,9 +327,10 @@ ErrCode SwASCIIParser::ReadChars()
// Read a new block
sal_Size lGCount;
- if( ERRCODE_NONE != rInput.GetError() || 0 == (lGCount =
- rInput.ReadBytes( pArr.get() + nArrOffset,
- ASC_BUFFLEN - nArrOffset )))
+ if (ERRCODE_NONE != m_rInput.GetError()
+ || 0
+ == (lGCount = m_rInput.ReadBytes(m_pArr.get() + nArrOffset,
+ ASC_BUFFLEN - nArrOffset)))
break; // break from the while loop
/*
@@ -328,32 +349,29 @@ ErrCode SwASCIIParser::ReadChars()
sal_Unicode* pBuf = aWork.get();
pBuf[nNewLen] = 0; // ensure '\0'
- nNewLen = rtl_convertTextToUnicode( hConverter, hContext,
- pArr.get(), lGCount, pBuf, nNewLen,
- (
- RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT |
- RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |
- RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT |
- RTL_TEXTTOUNICODE_FLAGS_GLOBAL_SIGNATURE
- ),
- &nInfo,
- &nCntBytes );
+ nNewLen = rtl_convertTextToUnicode(hConverter, hContext, m_pArr.get(), lGCount,
+ pBuf, nNewLen,
+ (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT
+ | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT
+ | RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT
+ | RTL_TEXTTOUNICODE_FLAGS_GLOBAL_SIGNATURE),
+ &nInfo, &nCntBytes);
nArrOffset = lGCount - nCntBytes;
if( 0 != nArrOffset )
- memmove( pArr.get(), pArr.get() + nCntBytes, nArrOffset );
+ memmove(m_pArr.get(), m_pArr.get() + nCntBytes, nArrOffset);
pStt = pLastStt = aWork.get();
pEnd = pStt + nNewLen;
}
else
{
- pStt = pLastStt = reinterpret_cast<sal_Unicode*>(pArr.get());
+ pStt = pLastStt = reinterpret_cast<sal_Unicode*>(m_pArr.get());
auto nChars = lGCount / 2;
pEnd = pStt + nChars;
if( bSwapUnicode )
{
- char* pF = pArr.get(), *pN = pArr.get() + 1;
+ char *pF = m_pArr.get(), *pN = m_pArr.get() + 1;
for (sal_Size n = 0; n < nChars; ++n, pF += 2, pN += 2)
{
char c = *pF;
@@ -366,7 +384,7 @@ ErrCode SwASCIIParser::ReadChars()
*pEnd = 0;
nReadCnt += lGCount;
- ::SetProgressState( nReadCnt, rDoc.GetDocShell() );
+ ::SetProgressState(nReadCnt, m_rDoc.GetDocShell());
if( cLastCR )
{
@@ -375,9 +393,8 @@ ErrCode SwASCIIParser::ReadChars()
cLastCR = 0;
nLineLen = 0;
// We skip the last one at the end
- if( !rInput.eof() || !(pEnd == pStt ||
- ( !*pEnd && pEnd == pStt+1 ) ) )
- rDoc.getIDocumentContentOperations().SplitNode( *pPam->GetPoint(), false );
+ if (!m_rInput.eof() || !(pEnd == pStt || (!*pEnd && pEnd == pStt + 1)))
+ m_rDoc.getIDocumentContentOperations().SplitNode(*m_oPam->GetPoint(), false);
}
}
@@ -392,7 +409,7 @@ ErrCode SwASCIIParser::ReadChars()
++pStt;
// We skip the last one at the end
- if( !rInput.eof() || pEnd != pStt )
+ if (!m_rInput.eof() || pEnd != pStt)
bSplitNode = true;
}
break;
@@ -416,7 +433,7 @@ ErrCode SwASCIIParser::ReadChars()
}
// We skip the last one at the end
- if( bChkSplit && ( !rInput.eof() || pEnd != pStt ))
+ if (bChkSplit && (!m_rInput.eof() || pEnd != pStt))
bSplitNode = true;
}
break;
@@ -429,9 +446,10 @@ ErrCode SwASCIIParser::ReadChars()
{
InsertText( OUString( pLastStt ));
}
- rDoc.getIDocumentContentOperations().SplitNode( *pPam->GetPoint(), false );
- rDoc.getIDocumentContentOperations().InsertPoolItem(
- *pPam, SvxFormatBreakItem( SvxBreak::PageBefore, RES_BREAK ) );
+ m_rDoc.getIDocumentContentOperations().SplitNode(*m_oPam->GetPoint(),
+ false);
+ m_rDoc.getIDocumentContentOperations().InsertPoolItem(
+ *m_oPam, SvxFormatBreakItem(SvxBreak::PageBefore, RES_BREAK));
pLastStt = pStt;
nLineLen = 0;
bIns = false;
@@ -439,11 +457,11 @@ ErrCode SwASCIIParser::ReadChars()
break;
case 0x1a:
- if( nReadCnt == nFileSize && pStt+1 == pEnd )
- *pStt = 0;
- else
- *pStt = '#'; // Replacement visualisation
- break;
+ if (nReadCnt == m_nFileSize && pStt + 1 == pEnd)
+ *pStt = 0;
+ else
+ *pStt = '#'; // Replacement visualisation
+ break;
case '\t': break;
@@ -462,7 +480,7 @@ ErrCode SwASCIIParser::ReadChars()
sal_Unicode c = *pStt;
*pStt = 0;
InsertText( OUString( pLastStt ));
- rDoc.getIDocumentContentOperations().SplitNode( *pPam->GetPoint(), false );
+ m_rDoc.getIDocumentContentOperations().SplitNode(*m_oPam->GetPoint(), false);
pLastStt = pStt;
nLineLen = 0;
*pStt = c;
@@ -474,10 +492,10 @@ ErrCode SwASCIIParser::ReadChars()
{
// We found a CR/LF, thus save the text
InsertText( OUString( pLastStt ));
- if(bNewDoc)
- rDoc.getIDocumentContentOperations().AppendTextNode( *pPam->GetPoint() );
+ if (m_bNewDoc)
+ m_rDoc.getIDocumentContentOperations().AppendTextNode(*m_oPam->GetPoint());
else
- rDoc.getIDocumentContentOperations().SplitNode( *pPam->GetPoint(), false );
+ m_rDoc.getIDocumentContentOperations().SplitNode(*m_oPam->GetPoint(), false);
pLastStt = pStt;
nLineLen = 0;
}
@@ -493,12 +511,11 @@ ErrCode SwASCIIParser::ReadChars()
void SwASCIIParser::InsertText( const OUString& rStr )
{
- rDoc.getIDocumentContentOperations().InsertString( *pPam, rStr );
+ m_rDoc.getIDocumentContentOperations().InsertString(*m_oPam, rStr);
- if( pItemSet && g_pBreakIt && nScript != ( SvtScriptType::LATIN |
- SvtScriptType::ASIAN |
- SvtScriptType::COMPLEX ) )
- nScript |= g_pBreakIt->GetAllScriptsOfText( rStr );
+ if (m_oItemSet && g_pBreakIt
+ && m_nScript != (SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX))
+ m_nScript |= g_pBreakIt->GetAllScriptsOfText(rStr);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ascii/wrtasc.cxx b/sw/source/filter/ascii/wrtasc.cxx
index 2d530e7531b5..0f1e368b928e 100644
--- a/sw/source/filter/ascii/wrtasc.cxx
+++ b/sw/source/filter/ascii/wrtasc.cxx
@@ -27,20 +27,25 @@
#include <frmfmt.hxx>
#include "wrtasc.hxx"
#include <frameformats.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <o3tl/string_view.hxx>
#include <strings.hrc>
-SwASCWriter::SwASCWriter( const OUString& rFltNm )
+SwASCWriter::SwASCWriter( std::u16string_view rFltNm )
{
SwAsciiOptions aNewOpts;
- switch( 5 <= rFltNm.getLength() ? rFltNm[4] : 0 )
+ switch( 5 <= rFltNm.size() ? rFltNm[4] : 0 )
{
case 'D':
aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_850 );
aNewOpts.SetParaFlags( LINEEND_CRLF );
- if( 5 < rFltNm.getLength() )
- switch( rFltNm.copy( 5 ).toInt32() )
+ if( 5 < rFltNm.size() )
+ {
+ std::u16string_view aFilterNum = rFltNm.substr( 5 );
+ switch( o3tl::toInt32(aFilterNum) )
{
case 437: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_437 ); break;
case 850: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_850 ); break;
@@ -49,6 +54,7 @@ SwASCWriter::SwASCWriter( const OUString& rFltNm )
case 863: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_863 ); break;
case 865: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_865 ); break;
}
+ }
break;
case 'A':
@@ -71,7 +77,7 @@ SwASCWriter::SwASCWriter( const OUString& rFltNm )
break;
default:
- if( rFltNm.getLength() >= 4 && rFltNm.subView( 4 )==u"_DLG" )
+ if( rFltNm.size() >= 4 && rFltNm.substr( 4 )==u"_DLG" )
{
// use the options
aNewOpts = GetAsciiOptions();
@@ -84,24 +90,29 @@ SwASCWriter::~SwASCWriter() {}
ErrCode SwASCWriter::WriteStream()
{
+ static constexpr OUString STR_CR = u"\015"_ustr;
+ static constexpr OUStringLiteral STR_LF = u"\012";
+ static constexpr OUStringLiteral STR_CRLF = u"\015\012";
+ static constexpr OUStringLiteral STR_BLANK = u" ";
bool bIncludeBOM = GetAsciiOptions().GetIncludeBOM();
+ bool bIncludeHidden = GetAsciiOptions().GetIncludeHidden();
if( m_bASCII_ParaAsCR ) // If predefined
- m_sLineEnd = "\015";
+ m_sLineEnd = STR_CR;
else if( m_bASCII_ParaAsBlank )
- m_sLineEnd = " ";
+ m_sLineEnd = STR_BLANK;
else
switch( GetAsciiOptions().GetParaFlags() )
{
- case LINEEND_CR: m_sLineEnd = "\015"; break;
- case LINEEND_LF: m_sLineEnd = "\012"; break;
- case LINEEND_CRLF: m_sLineEnd = "\015\012"; break;
+ case LINEEND_CR: m_sLineEnd = STR_CR; break;
+ case LINEEND_LF: m_sLineEnd = STR_LF; break;
+ case LINEEND_CRLF: m_sLineEnd = STR_CRLF; break;
}
- tools::Long nMaxNode = m_pDoc->GetNodes().Count();
+ SwNodeOffset nMaxNode = m_pDoc->GetNodes().Count();
if( m_bShowProgress )
- ::StartProgress( STR_STATSTR_W4WWRITE, 0, nMaxNode, m_pDoc->GetDocShell() );
+ ::StartProgress( STR_STATSTR_W4WWRITE, 0, sal_Int32(nMaxNode), m_pDoc->GetDocShell() );
SwPaM* pPam = m_pOrigPam;
@@ -115,11 +126,11 @@ ErrCode SwASCWriter::WriteStream()
// Output all areas of the pam into the ASC file
do {
bool bTstFly = true;
- while( m_pCurrentPam->GetPoint()->nNode.GetIndex() < m_pCurrentPam->GetMark()->nNode.GetIndex() ||
- (m_pCurrentPam->GetPoint()->nNode.GetIndex() == m_pCurrentPam->GetMark()->nNode.GetIndex() &&
- m_pCurrentPam->GetPoint()->nContent.GetIndex() <= m_pCurrentPam->GetMark()->nContent.GetIndex()) )
+ while( m_pCurrentPam->GetPoint()->GetNodeIndex() < m_pCurrentPam->GetMark()->GetNodeIndex() ||
+ (m_pCurrentPam->GetPoint()->GetNodeIndex() == m_pCurrentPam->GetMark()->GetNodeIndex() &&
+ m_pCurrentPam->GetPoint()->GetContentIndex() <= m_pCurrentPam->GetMark()->GetContentIndex()) )
{
- SwTextNode* pNd = m_pCurrentPam->GetPoint()->nNode.GetNode().GetTextNode();
+ SwTextNode* pNd = m_pCurrentPam->GetPoint()->GetNode().GetTextNode();
if( pNd )
{
// Should we have frames only?
@@ -133,7 +144,7 @@ ErrCode SwASCWriter::WriteStream()
m_pDoc->GetNodes().GetEndOfContent().GetIndex() &&
// And exactly this one is selected
m_pDoc->GetNodes().GetEndOfContent().GetIndex() - 1 ==
- m_pCurrentPam->GetPoint()->nNode.GetIndex() )
+ m_pCurrentPam->GetPoint()->GetNodeIndex() )
{
// Print the frame's content.
// It is always at position 0!
@@ -147,7 +158,7 @@ ErrCode SwASCWriter::WriteStream()
continue; // reset while loop!
}
}
- else
+ else if (!pNd->IsHidden() || bIncludeHidden)
{
if (bWriteSttTag)
{
@@ -163,17 +174,13 @@ ErrCode SwASCWriter::WriteStream()
case RTL_TEXTENCODING_UCS2:
#ifdef OSL_LITENDIAN
Strm().SetEndian(SvStreamEndian::LITTLE);
- if( bIncludeBOM )
- {
- Strm().WriteUChar( 0xFF ).WriteUChar( 0xFE );
- }
#else
Strm().SetEndian(SvStreamEndian::BIG);
+#endif
if( bIncludeBOM )
{
- Strm().WriteUChar( 0xFE ).WriteUChar( 0xFF );
+ Strm().StartWritingUnicodeText();
}
-#endif
break;
}
@@ -188,7 +195,7 @@ ErrCode SwASCWriter::WriteStream()
break;
if( m_bShowProgress )
- ::SetProgressState( m_pCurrentPam->GetPoint()->nNode.GetIndex(),
+ ::SetProgressState( sal_Int32(m_pCurrentPam->GetPoint()->GetNodeIndex()),
m_pDoc->GetDocShell() ); // How far?
}
@@ -202,8 +209,20 @@ ErrCode SwASCWriter::WriteStream()
return ERRCODE_NONE;
}
+void SwASCWriter::SetupFilterOptions(SfxMedium& rMedium)
+{
+ if( const SfxStringItem* pItem = rMedium.GetItemSet().GetItemIfSet( SID_FILE_FILTEROPTIONS ) )
+ {
+ SwAsciiOptions aOpt;
+ OUString sItemOpt;
+ sItemOpt = pItem->GetValue();
+ aOpt.ReadUserData(sItemOpt);
+ SetAsciiOptions(aOpt);
+ }
+}
+
void GetASCWriter(
- const OUString& rFltNm, [[maybe_unused]] const OUString& /*rBaseURL*/, WriterRef& xRet )
+ std::u16string_view rFltNm, [[maybe_unused]] const OUString& /*rBaseURL*/, WriterRef& xRet )
{
xRet = new SwASCWriter( rFltNm );
}
diff --git a/sw/source/filter/ascii/wrtasc.hxx b/sw/source/filter/ascii/wrtasc.hxx
index 8be5e5352f61..c2e3dfa9a2d4 100644
--- a/sw/source/filter/ascii/wrtasc.hxx
+++ b/sw/source/filter/ascii/wrtasc.hxx
@@ -33,9 +33,10 @@ class SwASCWriter : public Writer
virtual ErrCode WriteStream() override;
public:
- SwASCWriter(const OUString& rFilterName);
+ SwASCWriter(std::u16string_view rFilterName);
virtual ~SwASCWriter() override;
+ void SetupFilterOptions(SfxMedium& rMedium) override;
const OUString& GetLineEnd() const { return m_sLineEnd; }
};
diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx
index e8a64eda2d83..9a5b6f0e2c4f 100644
--- a/sw/source/filter/basflt/fltini.cxx
+++ b/sw/source/filter/basflt/fltini.cxx
@@ -78,7 +78,7 @@ Reader* SwReaderWriterEntry::GetReader()
return nullptr;
}
-void SwReaderWriterEntry::GetWriter( const OUString& rNm, const OUString& rBaseURL, WriterRef& xWrt ) const
+void SwReaderWriterEntry::GetWriter( std::u16string_view rNm, const OUString& rBaseURL, WriterRef& xWrt ) const
{
if ( fnGetWriter )
(*fnGetWriter)( rNm, rBaseURL, xWrt );
@@ -156,7 +156,7 @@ Reader* GetDOCXReader()
return aReaderWriter[READER_WRITER_DOCX].GetReader();
}
-void GetWriter( const OUString& rFltName, const OUString& rBaseURL, WriterRef& xRet )
+void GetWriter( std::u16string_view rFltName, const OUString& rBaseURL, WriterRef& xRet )
{
for( int n = 0; n < MAXFILTER; ++n )
if ( aFilterDetect[n].IsFilter( rFltName ) )
@@ -193,17 +193,6 @@ bool StgWriter::IsStgWriter() const { return true; }
/*
<FilterFlags>
- <Excel_Lotus>
- <MinRow cfg:type="long">0</MinRow>
- <MaxRow cfg:type="long">0</MaxRow>
- <MinCol cfg:type="long">0</MinCol>
- <MaxCol cfg:type="long">0</MaxCol>
- </Excel_Lotus>
- <W4W>
- <W4WHD cfg:type="long">0</W4WHD>
- <W4WFT cfg:type="long">0</W4WFT>
- <W4W000 cfg:type="long">0</W4W000>
- </W4W>
<WinWord>
<WW1F cfg:type="long">0</WW1F>
<WW cfg:type="long">0</WW>
@@ -220,9 +209,6 @@ bool StgWriter::IsStgWriter() const { return true; }
<WWFT cfg:type="long">0</WWFT>
<WWWR cfg:type="long">0</WWWR>
</WinWord>
- <Writer>
- <SW3Imp cfg:type="long">0</SW3Imp>
- </Writer>
</FilterFlags>
*/
@@ -268,21 +254,20 @@ void StgReader::SetFltName( const OUString& rFltNm )
m_aFltName = rFltNm;
}
-void CalculateFlySize(SfxItemSet& rFlySet, const SwNodeIndex& rAnchor,
+void CalculateFlySize(SfxItemSet& rFlySet, const SwNode& rAnchor,
SwTwips nPageWidth)
{
- const SfxPoolItem* pItem = nullptr;
- if( SfxItemState::SET != rFlySet.GetItemState( RES_FRM_SIZE, true, &pItem ) ||
- MINFLY > static_cast<const SwFormatFrameSize*>(pItem)->GetWidth() )
+ const SwFormatFrameSize* pFrameSizeItem = rFlySet.GetItemIfSet( RES_FRM_SIZE );
+ if( !pFrameSizeItem || MINFLY > pFrameSizeItem->GetWidth() )
{
std::unique_ptr<SwFormatFrameSize> aSz(rFlySet.Get(RES_FRM_SIZE).Clone());
- if (pItem)
- aSz.reset(static_cast<SwFormatFrameSize*>(pItem->Clone()));
+ if (pFrameSizeItem)
+ aSz.reset(pFrameSizeItem->Clone());
SwTwips nWidth;
// determine the width; if there is a table use the width of the table;
// otherwise use the width of the page
- const SwTableNode* pTableNd = rAnchor.GetNode().FindTableNode();
+ const SwTableNode* pTableNd = rAnchor.FindTableNode();
if( pTableNd )
nWidth = pTableNd->GetTable().GetFrameFormat()->GetFrameSize().GetWidth();
else
@@ -323,7 +308,7 @@ void CalculateFlySize(SfxItemSet& rFlySet, const SwNodeIndex& rAnchor,
{
// if the first node don't contained any content, then
// insert one char in it calc again and delete once again
- SwIndex aNdIdx( pFirstTextNd );
+ SwContentIndex aNdIdx( pFirstTextNd );
pFirstTextNd->InsertText("MM", aNdIdx);
sal_uLong nAbsMinCnts;
pFirstTextNd->GetMinMaxSize( pFirstTextNd->GetIndex(),
@@ -354,9 +339,9 @@ void CalculateFlySize(SfxItemSet& rFlySet, const SwNodeIndex& rAnchor,
if( nMaxFrame < MINLAY )
nMaxFrame = MINLAY;
- if( nWidth > static_cast<sal_uInt16>(nMaxFrame) )
+ if( nWidth > o3tl::narrowing<sal_uInt16>(nMaxFrame) )
nWidth = nMaxFrame;
- else if( nWidth > static_cast<sal_uInt16>(nMinFrame) )
+ else if( nWidth > o3tl::narrowing<sal_uInt16>(nMinFrame) )
nWidth = nMinFrame;
}
}
@@ -367,11 +352,11 @@ void CalculateFlySize(SfxItemSet& rFlySet, const SwNodeIndex& rAnchor,
aSz->SetWidth( nWidth );
if( MINFLY > aSz->GetHeight() )
aSz->SetHeight( MINFLY );
- rFlySet.Put( *aSz );
+ rFlySet.Put( std::move(aSz) );
}
- else if( MINFLY > static_cast<const SwFormatFrameSize*>(pItem)->GetHeight() )
+ else if( MINFLY > pFrameSizeItem->GetHeight() )
{
- std::unique_ptr<SwFormatFrameSize> aSz(static_cast<SwFormatFrameSize*>(pItem->Clone()));
+ std::unique_ptr<SwFormatFrameSize> aSz(pFrameSizeItem->Clone());
aSz->SetHeight( MINFLY );
rFlySet.Put( std::move(aSz) );
}
@@ -491,14 +476,14 @@ const CharSetNameMap *GetCharSetNameMap()
/*
Get a rtl_TextEncoding from its name
*/
-rtl_TextEncoding CharSetFromName(const OUString& rChrSetStr)
+rtl_TextEncoding CharSetFromName(std::u16string_view rChrSetStr)
{
const CharSetNameMap *pStart = GetCharSetNameMap();
rtl_TextEncoding nRet = pStart->eCode;
for(const CharSetNameMap *pMap = pStart; pMap->pName; ++pMap)
{
- if(rChrSetStr.equalsIgnoreAsciiCaseAscii(pMap->pName))
+ if(o3tl::equalsIgnoreAsciiCase(rChrSetStr, pMap->pName))
{
nRet = pMap->eCode;
break;
@@ -542,32 +527,36 @@ OUString NameFromCharSet(rtl_TextEncoding nChrSet)
// 3. Fontname
// 4. Language
// 5. Whether to include byte-order-mark - as true/false
+// 6. Whether to include hidden paragraphs and text - as true/false
// the delimiter character is ","
-void SwAsciiOptions::ReadUserData( const OUString& rStr )
+void SwAsciiOptions::ReadUserData( std::u16string_view rStr )
{
sal_Int32 nToken = 0;
- OUString sToken = rStr.getToken(0, ',', nToken); // 1. Charset name
- if (!sToken.isEmpty())
+ std::u16string_view sToken = o3tl::getToken(rStr, 0, ',', nToken); // 1. Charset name
+ if (!sToken.empty())
m_eCharSet = CharSetFromName(sToken);
- if (nToken >= 0 && !(sToken = rStr.getToken(0, ',', nToken)).isEmpty()) // 2. Line ending type
+ if (nToken >= 0 && !(sToken = o3tl::getToken(rStr, 0, ',', nToken)).empty()) // 2. Line ending type
{
- if (sToken.equalsIgnoreAsciiCase("CRLF"))
+ if (o3tl::equalsIgnoreAsciiCase(sToken, u"CRLF"))
m_eCRLF_Flag = LINEEND_CRLF;
- else if (sToken.equalsIgnoreAsciiCase("LF"))
+ else if (o3tl::equalsIgnoreAsciiCase(sToken, u"LF"))
m_eCRLF_Flag = LINEEND_LF;
else
m_eCRLF_Flag = LINEEND_CR;
}
- if (nToken >= 0 && !(sToken = rStr.getToken(0, ',', nToken)).isEmpty()) // 3. Font name
+ if (nToken >= 0 && !(sToken = o3tl::getToken(rStr, 0, ',', nToken)).empty()) // 3. Font name
m_sFont = sToken;
- if (nToken >= 0 && !(sToken = rStr.getToken(0, ',', nToken)).isEmpty()) // 4. Language tag
- m_nLanguage = LanguageTag::convertToLanguageTypeWithFallback(sToken);
- if (nToken >= 0 && !(sToken = rStr.getToken(0, ',', nToken)).isEmpty()) // 5. Include BOM?
- m_bIncludeBOM = !(sToken.equalsIgnoreAsciiCase("FALSE"));
+ if (nToken >= 0 && !(sToken = o3tl::getToken(rStr, 0, ',', nToken)).empty()) // 4. Language tag
+ m_nLanguage = LanguageTag::convertToLanguageTypeWithFallback(OUString(sToken));
+ if (nToken >= 0 && !(sToken = o3tl::getToken(rStr, 0, ',', nToken)).empty()) // 5. Include BOM?
+ m_bIncludeBOM = !(o3tl::equalsIgnoreAsciiCase(sToken, u"FALSE"));
+ // 6. Include hidden text
+ if (nToken >= 0 && !(sToken = o3tl::getToken(rStr, 0, ',', nToken)).empty())
+ m_bIncludeHidden = !(o3tl::equalsIgnoreAsciiCase(sToken, u"FALSE"));
}
-void SwAsciiOptions::WriteUserData(OUString& rStr)
+void SwAsciiOptions::WriteUserData(OUString& rStr) const
{
// 1. charset
rStr = NameFromCharSet(m_eCharSet) + ",";
@@ -598,7 +587,18 @@ void SwAsciiOptions::WriteUserData(OUString& rStr)
rStr += ",";
// 5. Whether to include byte-order-mark
- if( m_bIncludeBOM )
+ if(m_bIncludeBOM)
+ {
+ rStr += "true";
+ }
+ else
+ {
+ rStr += "false";
+ }
+ rStr += ",";
+
+ // 6. Whether to include hidden paragraphs and text
+ if(m_bIncludeHidden)
{
rStr += "true";
}
@@ -613,9 +613,9 @@ void SwAsciiOptions::WriteUserData(OUString& rStr)
extern "C" {
Reader *ImportRTF();
- void ExportRTF( const OUString&, const OUString& rBaseURL, WriterRef& );
+ void ExportRTF( std::u16string_view, const OUString& rBaseURL, WriterRef& );
Reader *ImportDOC();
- void ExportDOC( const OUString&, const OUString& rBaseURL, WriterRef& );
+ void ExportDOC( std::u16string_view, const OUString& rBaseURL, WriterRef& );
Reader *ImportDOCX();
sal_uInt32 SaveOrDelMSVBAStorage_ww8( SfxObjectShell&, SotStorage&, sal_Bool, const OUString& );
sal_uInt32 GetSaveWarningOfMSVBAStorage_ww8( SfxObjectShell& );
@@ -639,7 +639,7 @@ Reader* GetRTFReader()
}
-void GetRTFWriter( const OUString& rFltName, const OUString& rBaseURL, WriterRef& xRet )
+void GetRTFWriter( std::u16string_view rFltName, const OUString& rBaseURL, WriterRef& xRet )
{
#ifndef DISABLE_DYNLOADING
FnGetWriter pFunction = reinterpret_cast<FnGetWriter>( SwGlobals::getFilters().GetMswordLibSymbol( "ExportRTF" ) );
@@ -667,7 +667,7 @@ Reader* GetWW8Reader()
#endif
}
-void GetWW8Writer( const OUString& rFltName, const OUString& rBaseURL, WriterRef& xRet )
+void GetWW8Writer( std::u16string_view rFltName, const OUString& rBaseURL, WriterRef& xRet )
{
#ifndef DISABLE_DYNLOADING
FnGetWriter pFunction = reinterpret_cast<FnGetWriter>( SwGlobals::getFilters().GetMswordLibSymbol( "ExportDOC" ) );
diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx
index 153ccf42a37b..aa11df926e9e 100644
--- a/sw/source/filter/basflt/fltshell.cxx
+++ b/sw/source/filter/basflt/fltshell.cxx
@@ -44,20 +44,20 @@
#include <txtfld.hxx>
#include <tox.hxx>
#include <expfld.hxx>
-#include <bookmrk.hxx>
+#include <bookmark.hxx>
#include <fltshell.hxx>
#include <rdfhelper.hxx>
+#include <utility>
using namespace com::sun::star;
-static SwContentNode* GetContentNode(SwDoc& rDoc, SwNodeIndex& rIdx, bool bNext)
+static SwContentNode* GetContentNode(SwPosition& rPos, bool bNext)
{
- SwContentNode * pCNd = rIdx.GetNode().GetContentNode();
- if(!pCNd && nullptr == (pCNd = bNext ? rDoc.GetNodes().GoNext(&rIdx)
- : SwNodes::GoPrevious(&rIdx)))
+ SwContentNode * pCNd = rPos.GetNode().GetContentNode();
+ if (!pCNd && nullptr == (pCNd = bNext ? SwNodes::GoNext(&rPos)
+ : SwNodes::GoPrevious(&rPos)))
{
- pCNd = bNext ? SwNodes::GoPrevious(&rIdx)
- : rDoc.GetNodes().GoNext(&rIdx);
+ pCNd = bNext ? SwNodes::GoPrevious(&rPos) : SwNodes::GoNext(&rPos);
OSL_ENSURE(pCNd, "no ContentNode found");
}
return pCNd;
@@ -78,15 +78,12 @@ static OUString lcl_getTypePath(OUString& rType)
SwFltStackEntry::SwFltStackEntry(const SwPosition& rStartPos, std::unique_ptr<SfxPoolItem> pHt)
: m_aMkPos(rStartPos)
, m_aPtPos(rStartPos)
- , pAttr( std::move(pHt) )
+ , m_pAttr( std::move(pHt) )
, m_isAnnotationOnEnd(false)
- , mnStartCP(-1)
- , mnEndCP(-1)
- , bIsParaEnd(false)
{
- bOld = false; // used for marking Attributes *before* skipping field results
- bOpen = true; // lock the attribute --> may first
- bConsumedByField = false;
+ m_bOld = false; // used for marking Attributes *before* skipping field results
+ m_bOpen = true; // lock the attribute --> may first
+ m_bConsumedByField = false;
}
SwFltStackEntry::~SwFltStackEntry()
@@ -97,24 +94,21 @@ SwFltStackEntry::~SwFltStackEntry()
void SwFltStackEntry::SetEndPos(const SwPosition& rEndPos)
{
// Release attribute and keep track of end
- // Everything with sal_uInt16s, lest the inserting of new text at
+ // Everything with sal_uInt16s, because otherwise the inserting of new text at
// the cursor position moves the attribute's range
// That's not the desired behavior!
- bOpen = false; // release and remember END
- m_aPtPos.SetPos(rEndPos);
+ m_bOpen = false; // release and remember END
+ m_aPtPos.FromSwPosition(rEndPos);
}
-bool SwFltStackEntry::MakeRegion(SwDoc& rDoc, SwPaM& rRegion, RegionMode const eCheck,
- const SwFltPosition &rMkPos, const SwFltPosition &rPtPos, bool bIsParaEnd,
+bool SwFltStackEntry::MakeRegion(SwPaM& rRegion, RegionMode const eCheck,
+ const SwFltPosition &rMkPos, const SwFltPosition &rPtPos,
sal_uInt16 nWhich)
{
// does this range actually contain something?
// empty range is allowed if at start of empty paragraph
// fields are special: never have range, so leave them
-
- // The only position of 0x0D will not be able to make region in the old logic
- // because it is beyond the length of para...need special consideration here.
- sal_uLong nMk = rMkPos.m_nNode.GetIndex() + 1;
+ SwNodeOffset nMk = rMkPos.m_nNode.GetIndex() + 1;
const SwNodes& rMkNodes = rMkPos.m_nNode.GetNodes();
if (nMk >= rMkNodes.Count())
return false;
@@ -123,41 +117,38 @@ bool SwFltStackEntry::MakeRegion(SwDoc& rDoc, SwPaM& rRegion, RegionMode const e
((0 != rPtPos.m_nContent) || (pContentNode && (0 != pContentNode->Len())))
&& ( RES_TXTATR_FIELD != nWhich
&& RES_TXTATR_ANNOTATION != nWhich
- && RES_TXTATR_INPUTFIELD != nWhich )
- && !(bIsParaEnd && pContentNode && pContentNode->IsTextNode() && 0 != pContentNode->Len() ))
+ && RES_TXTATR_INPUTFIELD != nWhich ))
{
return false;
}
// The content indices always apply to the node!
- rRegion.GetPoint()->nNode = rMkPos.m_nNode.GetIndex() + 1;
- SwContentNode* pCNd = GetContentNode(rDoc, rRegion.GetPoint()->nNode, true);
+ rRegion.GetPoint()->Assign( rMkPos.m_nNode.GetIndex() + 1 );
+ SwContentNode* pCNd = GetContentNode(*rRegion.GetPoint(), true);
SAL_WARN_IF(pCNd->Len() < rMkPos.m_nContent, "sw.ww8",
"invalid content index " << rMkPos.m_nContent << " but text node has only " << pCNd->Len());
- rRegion.GetPoint()->nContent.Assign(pCNd,
- std::min<sal_Int32>(rMkPos.m_nContent, pCNd->Len()));
+ rRegion.GetPoint()->SetContent( std::min<sal_Int32>(rMkPos.m_nContent, pCNd->Len()) );
rRegion.SetMark();
if (rMkPos.m_nNode != rPtPos.m_nNode)
{
- sal_uLong n = rPtPos.m_nNode.GetIndex() + 1;
- SwNodes& rNodes = rRegion.GetPoint()->nNode.GetNodes();
+ SwNodeOffset n = rPtPos.m_nNode.GetIndex() + 1;
+ SwNodes& rNodes = rRegion.GetPoint()->GetNodes();
if (n >= rNodes.Count())
return false;
- rRegion.GetPoint()->nNode = n;
- pCNd = GetContentNode(rDoc, rRegion.GetPoint()->nNode, false);
+ rRegion.GetPoint()->Assign(n);
+ pCNd = GetContentNode(*rRegion.GetPoint(), false);
}
SAL_WARN_IF(pCNd->Len() < rPtPos.m_nContent, "sw.ww8",
"invalid content index " << rPtPos.m_nContent << " but text node has only " << pCNd->Len());
- rRegion.GetPoint()->nContent.Assign(pCNd,
- std::min<sal_Int32>(rPtPos.m_nContent, pCNd->Len()));
- OSL_ENSURE( CheckNodesRange( rRegion.Start()->nNode,
- rRegion.End()->nNode, true ),
+ rRegion.GetPoint()->SetContent( std::min<sal_Int32>(rPtPos.m_nContent, pCNd->Len()) );
+ OSL_ENSURE( CheckNodesRange( rRegion.Start()->GetNode(),
+ rRegion.End()->GetNode(), true ),
"attribute or similar crosses section-boundaries" );
bool bRet = true;
if (eCheck & RegionMode::CheckNodes)
{
- bRet &= CheckNodesRange(rRegion.Start()->nNode,
- rRegion.End()->nNode, true);
+ bRet &= CheckNodesRange(rRegion.Start()->GetNode(),
+ rRegion.End()->GetNode(), true);
}
if (eCheck & RegionMode::CheckFieldmark)
{
@@ -166,14 +157,13 @@ bool SwFltStackEntry::MakeRegion(SwDoc& rDoc, SwPaM& rRegion, RegionMode const e
return bRet;
}
-bool SwFltStackEntry::MakeRegion(SwDoc& rDoc, SwPaM& rRegion, RegionMode eCheck) const
+bool SwFltStackEntry::MakeRegion(SwPaM& rRegion, RegionMode eCheck) const
{
- return MakeRegion(rDoc, rRegion, eCheck, m_aMkPos, m_aPtPos, bIsParaEnd,
- pAttr->Which());
+ return MakeRegion(rRegion, eCheck, m_aMkPos, m_aPtPos, m_pAttr->Which());
}
SwFltControlStack::SwFltControlStack(SwDoc& rDo, sal_uLong nFieldFl)
- : nFieldFlags(nFieldFl),bHasSdOD(true), bSdODChecked(false), rDoc(rDo), bIsEndStack(false)
+ : m_nFieldFlags(nFieldFl), m_rDoc(rDo), m_bIsEndStack(false)
{
}
@@ -191,11 +181,10 @@ SwFltControlStack::~SwFltControlStack()
// same paragraph further out by one character.
void SwFltControlStack::MoveAttrs(const SwPosition& rPos, MoveAttrsMode eMode)
{
- size_t nCnt = m_Entries.size();
- sal_uLong nPosNd = rPos.nNode.GetIndex();
- sal_uInt16 nPosCt = rPos.nContent.GetIndex() - 1;
+ SwNodeOffset nPosNd = rPos.GetNodeIndex();
+ sal_uInt16 nPosCt = rPos.GetContentIndex() - 1;
- for (size_t i=0; i < nCnt; ++i)
+ for (size_t i = 0, nCnt = m_Entries.size(); i < nCnt; ++i)
{
SwFltStackEntry& rEntry = *m_Entries[i];
if (
@@ -205,7 +194,7 @@ void SwFltControlStack::MoveAttrs(const SwPosition& rPos, MoveAttrsMode eMode)
{
rEntry.m_aMkPos.m_nContent++;
OSL_ENSURE( rEntry.m_aMkPos.m_nContent
- <= rDoc.GetNodes()[nPosNd]->GetContentNode()->Len(),
+ <= m_rDoc.GetNodes()[nPosNd]->GetContentNode()->Len(),
"Attribute ends after end of line" );
}
if (
@@ -219,14 +208,14 @@ void SwFltControlStack::MoveAttrs(const SwPosition& rPos, MoveAttrsMode eMode)
assert(!(rEntry.m_isAnnotationOnEnd && rEntry.m_aPtPos.m_nContent > nPosCt));
if ( eMode == MoveAttrsMode::POSTIT_INSERTED
&& rEntry.m_aPtPos.m_nContent == nPosCt
- && rEntry.pAttr->Which() == RES_FLTR_ANNOTATIONMARK)
+ && rEntry.m_pAttr->Which() == RES_FLTR_ANNOTATIONMARK)
{
rEntry.m_isAnnotationOnEnd = true;
eMode = MoveAttrsMode::DEFAULT; // only set 1 flag
}
rEntry.m_aPtPos.m_nContent++;
OSL_ENSURE( rEntry.m_aPtPos.m_nContent
- <= rDoc.GetNodes()[nPosNd]->GetContentNode()->Len(),
+ <= m_rDoc.GetNodes()[nPosNd]->GetContentNode()->Len(),
"Attribute ends after end of line" );
}
}
@@ -237,7 +226,7 @@ void SwFltControlStack::MarkAllAttrsOld()
{
size_t nCnt = m_Entries.size();
for (size_t i=0; i < nCnt; ++i)
- m_Entries[i]->bOld = true;
+ m_Entries[i]->m_bOld = true;
}
namespace
@@ -246,12 +235,12 @@ namespace
const SfxPoolItem& rAttr)
{
return (pExtendCandidate &&
- !pExtendCandidate->bConsumedByField &&
+ !pExtendCandidate->m_bConsumedByField &&
//if we bring character attributes into the fold we need to both
//a) consider RES_CHRATR_FONTSIZE and RES_CHRATR_FONT wrt Word's CJK/CTL variants
//b) consider crossing table cell boundaries (tdf#102334)
isPARATR_LIST(rAttr.Which()) &&
- *(pExtendCandidate->pAttr) == rAttr);
+ *(pExtendCandidate->m_pAttr) == rAttr);
}
}
@@ -271,12 +260,11 @@ void SwFltControlStack::NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr
//from. If so we merge it with this one and elide adding another
//to the stack
pExtendCandidate->SetEndPos(rPos);
- pExtendCandidate->bOpen=true;
+ pExtendCandidate->m_bOpen=true;
}
else
{
SwFltStackEntry *pTmp = new SwFltStackEntry(rPos, std::unique_ptr<SfxPoolItem>(rAttr.Clone()) );
- pTmp->SetStartCP(GetCurrAttrCP());
m_Entries.push_back(std::unique_ptr<SwFltStackEntry>(pTmp));
}
}
@@ -289,14 +277,6 @@ void SwFltControlStack::DeleteAndDestroy(Entries::size_type nCnt)
auto aElement = m_Entries.begin() + nCnt;
m_Entries.erase(aElement);
}
- //Clear the para end position recorded in reader intermittently for the least impact on loading performance
- //Because the attributes handled based on the unit of para
- if ( empty() )
- {
- ClearParaEndPosition();
- bHasSdOD = true;
- bSdODChecked = false;
- }
}
// SwFltControlStack::StealAttr() removes attributes of the given type
@@ -304,7 +284,7 @@ void SwFltControlStack::DeleteAndDestroy(Entries::size_type nCnt)
// type. This makes them disappear from the doc structure. Only
// attributes from the same paragraph as rPos are removed. Used for
// graphic apos -> images.
-void SwFltControlStack::StealAttr(const SwNodeIndex& rNode)
+void SwFltControlStack::StealAttr(const SwNode& rNode)
{
size_t nCnt = m_Entries.size();
@@ -332,8 +312,8 @@ void SwFltControlStack::KillUnlockedAttrs(const SwPosition& rPos)
{
nCnt --;
SwFltStackEntry& rEntry = *m_Entries[nCnt];
- if( !rEntry.bOld
- && !rEntry.bOpen
+ if( !rEntry.m_bOld
+ && !rEntry.m_bOpen
&& (rEntry.m_aMkPos == aFltPos)
&& (rEntry.m_aPtPos == aFltPos))
{
@@ -364,7 +344,7 @@ SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos,
bool bLastEntry = aI == m_Entries.end() - 1;
SwFltStackEntry& rEntry = **aI;
- if (rEntry.bOpen)
+ if (rEntry.m_bOpen)
{
// set end of attribute
bool bF = false;
@@ -372,32 +352,31 @@ SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos,
{
bF = true;
}
- else if (nAttrId == rEntry.pAttr->Which())
+ else if (nAttrId == rEntry.m_pAttr->Which())
{
if( nAttrId != RES_FLTR_BOOKMARK && nAttrId != RES_FLTR_ANNOTATIONMARK && nAttrId != RES_FLTR_RDFMARK )
{
// query handle
bF = true;
}
- else if (nAttrId == RES_FLTR_BOOKMARK && nHand == static_cast<SwFltBookmark*>(rEntry.pAttr.get())->GetHandle())
+ else if (nAttrId == RES_FLTR_BOOKMARK && nHand == static_cast<SwFltBookmark*>(rEntry.m_pAttr.get())->GetHandle())
{
bF = true;
}
- else if (nAttrId == RES_FLTR_ANNOTATIONMARK && nHand == static_cast<CntUInt16Item*>(rEntry.pAttr.get())->GetValue())
+ else if (nAttrId == RES_FLTR_ANNOTATIONMARK && nHand == static_cast<CntUInt16Item*>(rEntry.m_pAttr.get())->GetValue())
{
bF = true;
}
- else if (nAttrId == RES_FLTR_RDFMARK && nHand == static_cast<SwFltRDFMark*>(rEntry.pAttr.get())->GetHandle())
+ else if (nAttrId == RES_FLTR_RDFMARK && nHand == static_cast<SwFltRDFMark*>(rEntry.m_pAttr.get())->GetHandle())
{
bF = true;
}
}
if (bF)
{
- rEntry.bConsumedByField = consumedByField;
+ rEntry.m_bConsumedByField = consumedByField;
rEntry.SetEndPos(rPos);
- rEntry.SetEndCP(GetCurrAttrCP());
- if (bLastEntry && nAttrId == rEntry.pAttr->Which())
+ if (bLastEntry && nAttrId == rEntry.m_pAttr->Which())
{
//potential candidate for merging with an identical
//property beginning at rPos
@@ -414,7 +393,7 @@ SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos,
// Never apply end stack except at document ending
if (bTstEnd)
{
- if (bIsEndStack)
+ if (m_bIsEndStack)
{
++aI;
continue;
@@ -424,7 +403,7 @@ SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos,
//we advance to the next node, or finish processing the document
if (rEntry.m_aPtPos.m_nNode.GetIndex() == aFltPos.m_nNode.GetIndex())
{
- if (bLastEntry && nAttrId == rEntry.pAttr->Which() &&
+ if (bLastEntry && nAttrId == rEntry.m_pAttr->Which() &&
rEntry.m_aPtPos.m_nContent == aFltPos.m_nContent)
{
//potential candidate for merging with an identical
@@ -443,42 +422,40 @@ SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos,
return pRet;
}
-static bool MakePoint(const SwFltStackEntry& rEntry, SwDoc& rDoc,
- SwPaM& rRegion)
+static bool MakePoint(const SwFltStackEntry& rEntry, SwPaM& rRegion)
{
// the anchor is the Pam's Point. It's modified when inserting
// text, etc.; therefore it is kept on the stack. Only the
// attribute's format needs to be set.
rRegion.DeleteMark();
- sal_uLong nMk = rEntry.m_aMkPos.m_nNode.GetIndex() + 1;
+ SwNodeOffset nMk = rEntry.m_aMkPos.m_nNode.GetIndex() + 1;
const SwNodes& rMkNodes = rEntry.m_aMkPos.m_nNode.GetNodes();
if (nMk >= rMkNodes.Count())
return false;
- rRegion.GetPoint()->nNode = nMk;
- SwContentNode* pCNd = GetContentNode(rDoc, rRegion.GetPoint()->nNode, true);
- rRegion.GetPoint()->nContent.Assign(pCNd, rEntry.m_aMkPos.m_nContent);
+ rRegion.GetPoint()->Assign(nMk);
+ GetContentNode(*rRegion.GetPoint(), true);
+ rRegion.GetPoint()->SetContent(rEntry.m_aMkPos.m_nContent);
return true;
}
// MakeBookRegionOrPoint() behaves like MakeRegionOrPoint, except that
// it adheres to certain restrictions on bookmarks in tables (cannot
// span more than one cell)
-static bool MakeBookRegionOrPoint(const SwFltStackEntry& rEntry, SwDoc& rDoc,
- SwPaM& rRegion )
+static bool MakeBookRegionOrPoint(const SwFltStackEntry& rEntry, SwPaM& rRegion )
{
- if (rEntry.MakeRegion(rDoc, rRegion, SwFltStackEntry::RegionMode::CheckNodes))
+ if (rEntry.MakeRegion(rRegion, SwFltStackEntry::RegionMode::CheckNodes))
{
- if (rRegion.GetPoint()->nNode.GetNode().FindTableBoxStartNode()
- != rRegion.GetMark()->nNode.GetNode().FindTableBoxStartNode())
+ if (rRegion.GetPoint()->GetNode().FindTableBoxStartNode()
+ != rRegion.GetMark()->GetNode().FindTableBoxStartNode())
{
rRegion.Exchange(); // invalid range
rRegion.DeleteMark(); // -> both to mark
}
return true;
}
- return MakePoint(rEntry, rDoc, rRegion);
+ return MakePoint(rEntry, rRegion);
}
// IterateNumrulePiece() looks for the first range valid for Numrules
@@ -490,15 +467,15 @@ static bool MakeBookRegionOrPoint(const SwFltStackEntry& rEntry, SwDoc& rDoc,
// out: start of valid range
// rTmpEnd is an out parameter
// Returns true for valid range
-static bool IterateNumrulePiece( const SwNodeIndex& rEnd,
+static bool IterateNumrulePiece( const SwPosition& rEnd,
SwNodeIndex& rTmpStart, SwNodeIndex& rTmpEnd )
{
- while( ( rTmpStart <= rEnd )
+ while( ( rTmpStart <= rEnd.GetNode() )
&& !( rTmpStart.GetNode().IsTextNode() ) ) // look for valid start
++rTmpStart;
rTmpEnd = rTmpStart;
- while( ( rTmpEnd <= rEnd )
+ while( ( rTmpEnd <= rEnd.GetNode() )
&& ( rTmpEnd.GetNode().IsTextNode() ) ) // look for valid end + 1
++rTmpEnd;
@@ -507,47 +484,25 @@ static bool IterateNumrulePiece( const SwNodeIndex& rEnd,
return rTmpStart <= rTmpEnd; // valid ?
}
-//***This function will check whether there is existing individual attribute position for 0x0D***/
-//The check will happen only once for a paragraph during loading
-bool SwFltControlStack::HasSdOD()
-{
- bool bRet = false;
-
- for (auto const& it : m_Entries)
- {
- SwFltStackEntry& rEntry = *it;
- if ( rEntry.mnStartCP == rEntry.mnEndCP )
- {
- if ( CheckSdOD(rEntry.mnStartCP,rEntry.mnEndCP) )
- {
- bRet = true;
- break;
- }
- }
- }
-
- return bRet;
-}
-
void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
SwFltStackEntry& rEntry)
{
SwPaM aRegion( rTmpPos );
- switch(rEntry.pAttr->Which())
+ switch(rEntry.m_pAttr->Which())
{
case RES_FLTR_ANCHOR:
{
- SwFrameFormat* pFormat = static_cast<SwFltAnchor*>(rEntry.pAttr.get())->GetFrameFormat();
+ SwFrameFormat* pFormat = static_cast<SwFltAnchor*>(rEntry.m_pAttr.get())->GetFrameFormat();
if (pFormat != nullptr)
{
- MakePoint(rEntry, rDoc, aRegion);
+ MakePoint(rEntry, aRegion);
SwFormatAnchor aAnchor(pFormat->GetAnchor());
aAnchor.SetAnchor(aRegion.GetPoint());
pFormat->SetFormatAttr(aAnchor);
// So the frames will be created when inserting into
// existing doc (after setting the anchor!):
- if (rDoc.getIDocumentLayoutAccess().GetCurrentViewShell()
+ if (m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell()
&& (RndStdIds::FLY_AT_PARA == pFormat->GetAnchor().GetAnchorId()))
{
pFormat->MakeFrames();
@@ -566,73 +521,73 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
case RES_FLTR_NUMRULE: // insert Numrule
{
- const OUString& rNumNm = static_cast<SfxStringItem*>(rEntry.pAttr.get())->GetValue();
- SwNumRule* pNumRule = rDoc.FindNumRulePtr( rNumNm );
+ const OUString& rNumNm = static_cast<SfxStringItem*>(rEntry.m_pAttr.get())->GetValue();
+ SwNumRule* pNumRule = m_rDoc.FindNumRulePtr( rNumNm );
if( pNumRule )
{
- if (rEntry.MakeRegion(rDoc, aRegion, SwFltStackEntry::RegionMode::CheckNodes))
+ if (rEntry.MakeRegion(aRegion, SwFltStackEntry::RegionMode::CheckNodes))
{
- SwNodeIndex aTmpStart( aRegion.Start()->nNode );
+ SwNodeIndex aTmpStart( aRegion.Start()->GetNode() );
SwNodeIndex aTmpEnd( aTmpStart );
- SwNodeIndex& rRegEndNd = aRegion.End()->nNode;
+ SwPosition& rRegEndNd = *aRegion.End();
while( IterateNumrulePiece( rRegEndNd,
aTmpStart, aTmpEnd ) )
{
SwPaM aTmpPam( aTmpStart, aTmpEnd );
// no start of a new list
- rDoc.SetNumRule( aTmpPam, *pNumRule, false );
+ m_rDoc.SetNumRule( aTmpPam, *pNumRule, false );
aTmpStart = aTmpEnd; // here starts the next range
++aTmpStart;
}
}
else
- rDoc.DelNumRule( rNumNm );
+ m_rDoc.DelNumRule( rNumNm );
}
}
break;
case RES_FLTR_BOOKMARK:
{
- SwFltBookmark* pB = static_cast<SwFltBookmark*>(rEntry.pAttr.get());
- const OUString& rName = static_cast<SwFltBookmark*>(rEntry.pAttr.get())->GetName();
+ SwFltBookmark* pB = static_cast<SwFltBookmark*>(rEntry.m_pAttr.get());
+ const OUString& rName = static_cast<SwFltBookmark*>(rEntry.m_pAttr.get())->GetName();
if (IsFlagSet(BOOK_TO_VAR_REF))
{
- SwFieldType* pFT = rDoc.getIDocumentFieldsAccess().GetFieldType(SwFieldIds::SetExp, rName, false);
+ SwFieldType* pFT = m_rDoc.getIDocumentFieldsAccess().GetFieldType(SwFieldIds::SetExp, rName, false);
if (!pFT)
{
- SwSetExpFieldType aS(&rDoc, rName, nsSwGetSetExpType::GSE_STRING);
- pFT = rDoc.getIDocumentFieldsAccess().InsertFieldType(aS);
+ SwSetExpFieldType aS(&m_rDoc, rName, nsSwGetSetExpType::GSE_STRING);
+ pFT = m_rDoc.getIDocumentFieldsAccess().InsertFieldType(aS);
}
SwSetExpField aField(static_cast<SwSetExpFieldType*>(pFT), pB->GetValSys());
aField.SetSubType( nsSwExtendedSubType::SUB_INVISIBLE );
- MakePoint(rEntry, rDoc, aRegion);
- rDoc.getIDocumentContentOperations().InsertPoolItem(aRegion, SwFormatField(aField));
+ MakePoint(rEntry, aRegion);
+ m_rDoc.getIDocumentContentOperations().InsertPoolItem(aRegion, SwFormatField(aField));
MoveAttrs( *(aRegion.GetPoint()) );
}
if ( ( !IsFlagSet(HYPO) || IsFlagSet(BOOK_AND_REF) ) &&
- !rEntry.bConsumedByField )
+ !rEntry.m_bConsumedByField )
{
- MakeBookRegionOrPoint(rEntry, rDoc, aRegion);
+ MakeBookRegionOrPoint(rEntry, aRegion);
// #i120879# - create a cross reference heading bookmark if appropriate.
const IDocumentMarkAccess::MarkType eBookmarkType =
( pB->IsTOCBookmark() &&
IDocumentMarkAccess::IsLegalPaMForCrossRefHeadingBookmark( aRegion ) )
? IDocumentMarkAccess::MarkType::CROSSREF_HEADING_BOOKMARK
: IDocumentMarkAccess::MarkType::BOOKMARK;
- rDoc.getIDocumentMarkAccess()->makeMark(aRegion, rName, eBookmarkType, sw::mark::InsertMode::New);
+ m_rDoc.getIDocumentMarkAccess()->makeMark(aRegion, rName, eBookmarkType, sw::mark::InsertMode::New);
}
}
break;
case RES_FLTR_ANNOTATIONMARK:
{
- if (MakeBookRegionOrPoint(rEntry, rDoc, aRegion))
+ if (MakeBookRegionOrPoint(rEntry, aRegion))
{
SwTextNode const*const pTextNode(
- aRegion.End()->nNode.GetNode().GetTextNode());
+ aRegion.End()->GetNode().GetTextNode());
SwTextField const*const pField = pTextNode ? pTextNode->GetFieldTextAttrAt(
- aRegion.End()->nContent.GetIndex() - 1, true) : nullptr;
+ aRegion.End()->GetContentIndex() - 1, ::sw::GetTextAttrMode::Default) : nullptr;
if (pField)
{
SwPostItField const*const pPostIt(
@@ -648,10 +603,10 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
// Adjust the start of the range to actually cover the comment, similar
// to what the UI and the UNO API does.
aRegion.SetMark();
- --aRegion.Start()->nContent;
+ aRegion.Start()->AdjustContent(-1);
}
- rDoc.getIDocumentMarkAccess()->makeAnnotationMark(aRegion, OUString());
+ m_rDoc.getIDocumentMarkAccess()->makeAnnotationMark(aRegion, OUString());
}
else
{
@@ -669,12 +624,12 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
break;
case RES_FLTR_RDFMARK:
{
- if (MakeBookRegionOrPoint(rEntry, rDoc, aRegion))
+ if (MakeBookRegionOrPoint(rEntry, aRegion))
{
- SwFltRDFMark* pMark = static_cast<SwFltRDFMark*>(rEntry.pAttr.get());
- if (aRegion.GetNode().IsTextNode())
+ SwFltRDFMark* pMark = static_cast<SwFltRDFMark*>(rEntry.m_pAttr.get());
+ if (aRegion.GetPointNode().IsTextNode())
{
- SwTextNode& rTextNode = *aRegion.GetNode().GetTextNode();
+ SwTextNode& rTextNode = *aRegion.GetPointNode().GetTextNode();
for (const std::pair<OUString, OUString>& rAttribute : pMark->GetAttributes())
{
@@ -693,19 +648,19 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
break;
case RES_FLTR_TOX:
{
- MakePoint(rEntry, rDoc, aRegion);
+ MakePoint(rEntry, aRegion);
SwPosition* pPoint = aRegion.GetPoint();
- SwFltTOX* pTOXAttr = static_cast<SwFltTOX*>(rEntry.pAttr.get());
+ SwFltTOX* pTOXAttr = static_cast<SwFltTOX*>(rEntry.m_pAttr.get());
// test if on this node there had been a pagebreak BEFORE the
// tox attribute was put on the stack
- SfxItemSet aBkSet( rDoc.GetAttrPool(), svl::Items<RES_PAGEDESC, RES_BREAK>{} );
+ SfxItemSetFixed<RES_PAGEDESC, RES_BREAK> aBkSet( m_rDoc.GetAttrPool() );
SwContentNode* pNd = nullptr;
if( !pTOXAttr->HadBreakItem() || !pTOXAttr->HadPageDescItem() )
{
- pNd = pPoint->nNode.GetNode().GetContentNode();
+ pNd = pPoint->GetNode().GetContentNode();
if( pNd )
{
const SfxItemSet* pSet = pNd->GetpSwAttrSet();
@@ -735,22 +690,23 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
break;
case RES_FLTR_REDLINE:
{
- if (rEntry.MakeRegion(rDoc, aRegion,
+ if (rEntry.MakeRegion(aRegion,
SwFltStackEntry::RegionMode::CheckNodes|SwFltStackEntry::RegionMode::CheckFieldmark))
{
- rDoc.getIDocumentRedlineAccess().SetRedlineFlags( RedlineFlags::On
+ m_rDoc.getIDocumentRedlineAccess().SetRedlineFlags( RedlineFlags::On
| RedlineFlags::ShowInsert
| RedlineFlags::ShowDelete );
- SwFltRedline& rFltRedline = *static_cast<SwFltRedline*>(rEntry.pAttr.get());
+ SwFltRedline& rFltRedline = *static_cast<SwFltRedline*>(rEntry.m_pAttr.get());
- SwRedlineData aData(rFltRedline.eType,
- rFltRedline.nAutorNo,
- rFltRedline.aStamp,
+ SwRedlineData aData(rFltRedline.m_eType,
+ rFltRedline.m_nAutorNo,
+ rFltRedline.m_aStamp,
+ 0,
OUString(),
nullptr
);
- rDoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline(aData, aRegion), true );
- rDoc.getIDocumentRedlineAccess().SetRedlineFlags( RedlineFlags::NONE
+ m_rDoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline(aData, aRegion), true );
+ m_rDoc.getIDocumentRedlineAccess().SetRedlineFlags( RedlineFlags::NONE
| RedlineFlags::ShowInsert
| RedlineFlags::ShowDelete );
}
@@ -758,44 +714,15 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
break;
default:
{
- // Revised for more complex situations should be considered
- if ( !bSdODChecked )
+ if (rEntry.MakeRegion(aRegion, SwFltStackEntry::RegionMode::NoCheck))
{
- bHasSdOD = HasSdOD();
- bSdODChecked = true;
- }
- sal_Int32 nStart = rEntry.GetStartCP();
- sal_Int32 nEnd = rEntry.GetEndCP();
- if (nStart != -1 && nEnd != -1 && nEnd >= nStart )
- {
- rEntry.SetIsParaEnd( IsParaEndInCPs(nStart,nEnd,bHasSdOD) );
- }
- if (rEntry.MakeRegion(rDoc, aRegion, SwFltStackEntry::RegionMode::NoCheck))
- {
- if (rEntry.IsParaEnd())
- {
- rDoc.getIDocumentContentOperations().InsertPoolItem(aRegion, *rEntry.pAttr, SetAttrMode::DEFAULT, nullptr, true);
- }
- else
- {
- rDoc.getIDocumentContentOperations().InsertPoolItem(aRegion, *rEntry.pAttr);
- }
+ m_rDoc.getIDocumentContentOperations().InsertPoolItem(aRegion, *rEntry.m_pAttr);
}
}
break;
}
}
-bool SwFltControlStack::IsParaEndInCPs(sal_Int32 /*nStart*/, sal_Int32 /*nEnd*/,bool /*bSdOD*/) const
-{
- return false;
-}
-
-bool SwFltControlStack::CheckSdOD(sal_Int32 /*nStart*/, sal_Int32 /*nEnd*/)
-{
- return false;
-}
-
SfxPoolItem* SwFltControlStack::GetFormatStackAttr(sal_uInt16 nWhich, sal_uInt16 * pPos)
{
size_t nSize = m_Entries.size();
@@ -805,11 +732,11 @@ SfxPoolItem* SwFltControlStack::GetFormatStackAttr(sal_uInt16 nWhich, sal_uInt16
// is it the looked-for attribute ? (only applies to locked, meaning
// currently set attributes!!)
SwFltStackEntry &rEntry = *m_Entries[--nSize];
- if (rEntry.bOpen && rEntry.pAttr->Which() == nWhich)
+ if (rEntry.m_bOpen && rEntry.m_pAttr->Which() == nWhich)
{
if (pPos)
*pPos = nSize;
- return rEntry.pAttr.get(); // Ok, so stop
+ return rEntry.m_pAttr.get(); // Ok, so stop
}
}
return nullptr;
@@ -824,9 +751,9 @@ const SfxPoolItem* SwFltControlStack::GetOpenStackAttr(const SwPosition& rPos, s
while (nSize)
{
SwFltStackEntry &rEntry = *m_Entries[--nSize];
- if (rEntry.bOpen && rEntry.pAttr->Which() == nWhich && rEntry.m_aMkPos == aFltPos)
+ if (rEntry.m_bOpen && rEntry.m_pAttr->Which() == nWhich && rEntry.m_aMkPos == aFltPos)
{
- return rEntry.pAttr.get();
+ return rEntry.m_pAttr.get();
}
}
return nullptr;
@@ -834,15 +761,15 @@ const SfxPoolItem* SwFltControlStack::GetOpenStackAttr(const SwPosition& rPos, s
void SwFltControlStack::Delete(const SwPaM &rPam)
{
- const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End();
+ auto [pStt, pEnd] = rPam.StartEnd(); // SwPosition*
if( !rPam.HasMark() || *pStt >= *pEnd )
return;
- SwNodeIndex aStartNode(pStt->nNode, -1);
- const sal_Int32 nStartIdx = pStt->nContent.GetIndex();
- SwNodeIndex aEndNode(pEnd->nNode, -1);
- const sal_Int32 nEndIdx = pEnd->nContent.GetIndex();
+ SwNodeIndex aStartNode(pStt->GetNode(), -1);
+ const sal_Int32 nStartIdx = pStt->GetContentIndex();
+ SwNodeIndex aEndNode(pEnd->GetNode(), -1);
+ const sal_Int32 nEndIdx = pEnd->GetContentIndex();
// We don't support deleting content that is over one node, or removing a node.
OSL_ENSURE(aEndNode == aStartNode, "nodes must be the same, or this method extended");
@@ -863,7 +790,7 @@ void SwFltControlStack::Delete(const SwPaM &rPam)
bool bEntryEndAfterSelStart = false;
bool bEntryEndBeforeSelEnd = false;
- if (!rEntry.bOpen)
+ if (!rEntry.m_bOpen)
{
bEntryEndAfterSelStart =
(rEntry.m_aPtPos.m_nNode == aStartNode &&
@@ -913,24 +840,24 @@ void SwFltControlStack::Delete(const SwPaM &rPam)
}
//That's what Open is, end equal to start, and nPtContent is invalid
- if (rEntry.bOpen)
+ if (rEntry.m_bOpen)
rEntry.m_aPtPos = rEntry.m_aMkPos;
}
}
// methods of SwFltAnchor follow
SwFltAnchor::SwFltAnchor(SwFrameFormat* pFormat) :
- SfxPoolItem(RES_FLTR_ANCHOR), pFrameFormat(pFormat)
+ SfxPoolItem(RES_FLTR_ANCHOR), m_pFrameFormat(pFormat)
{
- pListener.reset(new SwFltAnchorListener(this));
- pListener->StartListening(pFrameFormat->GetNotifier());
+ m_pListener.reset(new SwFltAnchorListener(this));
+ m_pListener->StartListening(m_pFrameFormat->GetNotifier());
}
SwFltAnchor::SwFltAnchor(const SwFltAnchor& rCpy) :
- SfxPoolItem(RES_FLTR_ANCHOR), pFrameFormat(rCpy.pFrameFormat)
+ SfxPoolItem(RES_FLTR_ANCHOR), m_pFrameFormat(rCpy.m_pFrameFormat)
{
- pListener.reset(new SwFltAnchorListener(this));
- pListener->StartListening(pFrameFormat->GetNotifier());
+ m_pListener.reset(new SwFltAnchorListener(this));
+ m_pListener->StartListening(m_pFrameFormat->GetNotifier());
}
SwFltAnchor::~SwFltAnchor()
@@ -939,14 +866,14 @@ SwFltAnchor::~SwFltAnchor()
void SwFltAnchor::SetFrameFormat(SwFrameFormat * _pFrameFormat)
{
- pFrameFormat = _pFrameFormat;
+ m_pFrameFormat = _pFrameFormat;
}
bool SwFltAnchor::operator==(const SfxPoolItem& rItem) const
{
return SfxPoolItem::operator==(rItem) &&
- pFrameFormat == static_cast<const SwFltAnchor&>(rItem).pFrameFormat;
+ m_pFrameFormat == static_cast<const SwFltAnchor&>(rItem).m_pFrameFormat;
}
SwFltAnchor* SwFltAnchor::Clone(SfxItemPool*) const
@@ -962,14 +889,16 @@ void SwFltAnchorListener::Notify(const SfxHint& rHint)
{
if (rHint.GetId() == SfxHintId::Dying)
m_pFltAnchor->SetFrameFormat(nullptr);
- else if (auto pDrawFrameFormatHint = dynamic_cast<const sw::DrawFrameFormatHint*>(&rHint))
+ else if (rHint.GetId() == SfxHintId::SwDrawFrameFormat)
{
+ auto pDrawFrameFormatHint = static_cast<const sw::DrawFrameFormatHint*>(&rHint);
if (pDrawFrameFormatHint->m_eId != sw::DrawFrameFormatHintId::DYING)
return;
m_pFltAnchor->SetFrameFormat(nullptr);
}
- else if (auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
+ else if (rHint.GetId() == SfxHintId::SwLegacyModify)
{
+ auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
if(pLegacyHint->m_pNew->Which() != RES_FMT_CHG)
return;
auto pFormatChg = dynamic_cast<const SwFormatChg*>(pLegacyHint->m_pNew);
@@ -983,7 +912,7 @@ void SwFltAnchorListener::Notify(const SfxHint& rHint)
bool SwFltRedline::operator==(const SfxPoolItem& rItem) const
{
return SfxPoolItem::operator==(rItem) &&
- this == &rItem;
+ SfxPoolItem::areSame(*this, rItem);
}
SwFltRedline* SwFltRedline::Clone( SfxItemPool* ) const
@@ -992,12 +921,12 @@ SwFltRedline* SwFltRedline::Clone( SfxItemPool* ) const
}
// methods of SwFltBookmark follow
-SwFltBookmark::SwFltBookmark( const OUString& rNa, const OUString& rVa,
+SwFltBookmark::SwFltBookmark( const OUString& rNa, OUString aVa,
tools::Long nHand, const bool bIsTOCBookmark )
: SfxPoolItem( RES_FLTR_BOOKMARK )
, mnHandle( nHand )
, maName( rNa )
- , maVal( rVa )
+ , maVal(std::move( aVa ))
, mbIsTOCBookmark( bIsTOCBookmark )
{
// eSrc: CHARSET_DONTKNOW for no transform at operator <<
@@ -1056,9 +985,9 @@ tools::Long SwFltRDFMark::GetHandle() const
return m_nHandle;
}
-void SwFltRDFMark::SetAttributes(const std::vector< std::pair<OUString, OUString> >& rAttributes)
+void SwFltRDFMark::SetAttributes( std::vector< std::pair<OUString, OUString> >&& rAttributes)
{
- m_aAttributes = rAttributes;
+ m_aAttributes = std::move(rAttributes);
}
const std::vector< std::pair<OUString, OUString> >& SwFltRDFMark::GetAttributes() const
@@ -1069,7 +998,7 @@ const std::vector< std::pair<OUString, OUString> >& SwFltRDFMark::GetAttributes(
// methods of SwFltTOX follow
SwFltTOX::SwFltTOX(std::shared_ptr<SwTOXBase> xBase)
: SfxPoolItem(RES_FLTR_TOX), m_xTOXBase(std::move(xBase)),
- bHadBreakItem( false ), bHadPageDescItem( false )
+ m_bHadBreakItem( false ), m_bHadPageDescItem( false )
{
}
@@ -1111,8 +1040,11 @@ void FrameDeleteWatch::Notify(const SfxHint& rHint)
bool bDying = false;
if (rHint.GetId() == SfxHintId::Dying)
bDying = true;
- else if (auto pDrawFrameFormatHint = dynamic_cast<const sw::DrawFrameFormatHint*>(&rHint))
+ else if (rHint.GetId() == SfxHintId::SwDrawFrameFormat)
+ {
+ auto pDrawFrameFormatHint = static_cast<const sw::DrawFrameFormatHint*>(&rHint);
bDying = pDrawFrameFormatHint->m_eId == sw::DrawFrameFormatHintId::DYING;
+ }
if (bDying)
{
m_pFormat = nullptr;
diff --git a/sw/source/filter/basflt/iodetect.cxx b/sw/source/filter/basflt/iodetect.cxx
index 2f49b2b199d1..9afff4d8b23b 100644
--- a/sw/source/filter/basflt/iodetect.cxx
+++ b/sw/source/filter/basflt/iodetect.cxx
@@ -130,7 +130,7 @@ bool SwIoSystem::IsValidStgFilter(SotStorage& rStg, const SfxFilter& rFilter)
== (rFilter.GetUserData() == FILTER_WW8);
if (bRet && !rFilter.IsAllowedAsTemplate())
{
- tools::SvRef<SotStorageStream> xRef =
+ rtl::Reference<SotStorageStream> xRef =
rStg.OpenSotStream("WordDocument",
StreamMode::STD_READ );
xRef->Seek(10);
@@ -161,7 +161,7 @@ std::shared_ptr<const SfxFilter> SwIoSystem::GetFileFilter(const OUString& rFile
if (SotStorage::IsStorageFile(rFileName))
{
// package storage or OLEStorage based format
- tools::SvRef<SotStorage> xStg;
+ rtl::Reference<SotStorage> xStg;
INetURLObject aObj;
aObj.SetSmartProtocol( INetProtocol::File );
aObj.SetSmartURL( rFileName );
@@ -238,12 +238,29 @@ std::shared_ptr<const SfxFilter> SwIoSystem::GetFileFilter(const OUString& rFile
return SwIoSystem::GetFilterOfFormat(FILTER_TEXT);
}
+rtl_TextEncoding SwIoSystem::GetTextEncoding(SvStream& rStrm)
+{
+ sal_Size nLen, nOrig;
+ char aBuf[4096];
+ nOrig = nLen = rStrm.ReadBytes(aBuf, sizeof(aBuf));
+
+ rtl_TextEncoding eCharSet;
+ const bool bRet = SwIoSystem::IsDetectableText(aBuf, nLen, &eCharSet, nullptr, nullptr, nullptr);
+ if (bRet && eCharSet != RTL_TEXTENCODING_DONTKNOW)
+ rStrm.SeekRel(-(tools::Long(nLen)));
+ else
+ rStrm.SeekRel(-(tools::Long(nOrig)));
+
+ return eCharSet;
+}
+
bool SwIoSystem::IsDetectableText(const char* pBuf, sal_uLong &rLen,
- rtl_TextEncoding *pCharSet, bool *pSwap, LineEnd *pLineEnd)
+ rtl_TextEncoding *pCharSet, bool *pSwap, LineEnd *pLineEnd, bool *pBom)
{
bool bSwap = false;
rtl_TextEncoding eCharSet = RTL_TEXTENCODING_DONTKNOW;
bool bLE = true;
+ bool bBom = false;
/*See if it's a known unicode type*/
if (rLen >= 2)
{
@@ -253,17 +270,20 @@ bool SwIoSystem::IsDetectableText(const char* pBuf, sal_uLong &rLen,
{
eCharSet = RTL_TEXTENCODING_UTF8;
nHead = 3;
+ bBom = true;
}
else if (sal_uInt8(pBuf[0]) == 0xFE && sal_uInt8(pBuf[1]) == 0xFF)
{
eCharSet = RTL_TEXTENCODING_UCS2;
bLE = false;
nHead = 2;
+ bBom = true;
}
else if (sal_uInt8(pBuf[1]) == 0xFE && sal_uInt8(pBuf[0]) == 0xFF)
{
eCharSet = RTL_TEXTENCODING_UCS2;
nHead = 2;
+ bBom = true;
}
pBuf+=nHead;
rLen-=nHead;
@@ -291,6 +311,10 @@ bool SwIoSystem::IsDetectableText(const char* pBuf, sal_uLong &rLen,
{
eCharSet = RTL_TEXTENCODING_UCS2; // UTF-16LE
}
+ else if (U_SUCCESS(uerr) && !strcmp("GB18030", pEncodingName))
+ {
+ eCharSet = RTL_TEXTENCODING_GB_18030;
+ }
}
ucsdet_close(ucd);
@@ -400,6 +424,8 @@ bool SwIoSystem::IsDetectableText(const char* pBuf, sal_uLong &rLen,
*pSwap = bSwap;
if (pLineEnd)
*pLineEnd = eLineEnd;
+ if (pBom)
+ *pBom = bBom;
return !bIsBareUnicode;
}
diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx
index 88e6d04459cd..9c306617d501 100644
--- a/sw/source/filter/basflt/shellio.cxx
+++ b/sw/source/filter/basflt/shellio.cxx
@@ -29,6 +29,8 @@
#include <editeng/ulspitem.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/paperinf.hxx>
+#include <o3tl/deleter.hxx>
+#include <officecfg/Office/Writer.hxx>
#include <node.hxx>
#include <docary.hxx>
#include <fmtanchr.hxx>
@@ -62,10 +64,11 @@
#include <swerror.h>
#include <pausethreadstarting.hxx>
#include <frameformats.hxx>
+#include <utility>
using namespace ::com::sun::star;
-static bool sw_MergePortions(SwNode *const& pNode, void *)
+static bool sw_MergePortions(SwNode* pNode, void *)
{
if (pNode->IsTextNode())
{
@@ -74,7 +77,17 @@ static bool sw_MergePortions(SwNode *const& pNode, void *)
return true;
}
-ErrCode SwReader::Read( const Reader& rOptions )
+void SwAsciiOptions::Reset()
+{
+ m_sFont.clear();
+ m_eCRLF_Flag = GetSystemLineEnd();
+ m_eCharSet = ::osl_getThreadTextEncoding();
+ m_nLanguage = LANGUAGE_SYSTEM;
+ m_bIncludeBOM = true;
+ m_bIncludeHidden = officecfg::Office::Writer::FilterFlags::ASCII::IncludeHiddenText::get();
+}
+
+ErrCodeMsg SwReader::Read( const Reader& rOptions )
{
// copy variables
Reader* po = const_cast<Reader*>(&rOptions);
@@ -95,7 +108,7 @@ ErrCode SwReader::Read( const Reader& rOptions )
return ERR_SWG_FILE_FORMAT_ERROR;
}
- ErrCode nError = ERRCODE_NONE;
+ ErrCodeMsg nError = ERRCODE_NONE;
GetDoc();
@@ -116,8 +129,7 @@ ErrCode SwReader::Read( const Reader& rOptions )
else
{
// if the Reader was not called by a Shell, create a PaM ourselves
- SwNodeIndex nNode( mxDoc->GetNodes().GetEndOfContent(), -1 );
- pPam = new SwPaM( nNode );
+ pPam = new SwPaM( mxDoc->GetNodes().GetEndOfContent(), SwNodeOffset(-1) );
// For Web documents the default template was set already by InitNew,
// unless the filter is not HTML,
// or a SetTemplateName was called in ConvertFrom.
@@ -164,12 +176,12 @@ ErrCode SwReader::Read( const Reader& rOptions )
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
- std::unique_ptr<SwPaM> pUndoPam;
+ std::optional<SwPaM> pUndoPam;
if( bDocUndo || mpCursor )
{
// set Pam to the previous node, so that it is not also moved
- const SwNodeIndex& rTmp = pPam->GetPoint()->nNode;
- pUndoPam.reset(new SwPaM( rTmp, rTmp, 0, -1 ));
+ const SwNode& rTmp = pPam->GetPoint()->GetNode();
+ pUndoPam.emplace( rTmp, rTmp, SwNodeOffset(0), SwNodeOffset(-1) );
}
// store for now all Fly's
@@ -179,12 +191,12 @@ ErrCode SwReader::Read( const Reader& rOptions )
mxDoc->GetSpzFrameFormats()->end() );
}
- const sal_Int32 nSttContent = pPam->GetPoint()->nContent.GetIndex();
+ const sal_Int32 nSttContent = pPam->GetPoint()->GetContentIndex();
// make sure the End position is correct for all Readers
- SwContentNode* pCNd = pPam->GetContentNode();
+ SwContentNode* pCNd = pPam->GetPointContentNode();
sal_Int32 nEndContent = pCNd ? pCNd->Len() - nSttContent : 0;
- SwNodeIndex aEndPos( pPam->GetPoint()->nNode, 1 );
+ SwNodeIndex aEndPos( pPam->GetPoint()->GetNode(), 1 );
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
@@ -200,15 +212,14 @@ ErrCode SwReader::Read( const Reader& rOptions )
--aEndPos;
pCNd = aEndPos.GetNode().GetContentNode();
if( !pCNd && nullptr == ( pCNd = SwNodes::GoPrevious( &aEndPos ) ))
- pCNd = mxDoc->GetNodes().GoNext( &aEndPos );
+ pCNd = SwNodes::GoNext(&aEndPos);
- pPam->GetPoint()->nNode = aEndPos;
const sal_Int32 nLen = pCNd->Len();
if( nLen < nEndContent )
nEndContent = 0;
else
nEndContent = nLen - nEndContent;
- pPam->GetPoint()->nContent.Assign( pCNd, nEndContent );
+ pPam->GetPoint()->Assign( *pCNd, nEndContent );
const SwStartNode* pTableBoxStart = pCNd->FindTableBoxStartNode();
if ( pTableBoxStart )
@@ -224,30 +235,25 @@ ErrCode SwReader::Read( const Reader& rOptions )
if( mpCursor )
{
*pUndoPam->GetMark() = *pPam->GetPoint();
- ++pUndoPam->GetPoint()->nNode;
- SwNode& rNd = pUndoPam->GetNode();
+ pUndoPam->GetPoint()->Adjust(SwNodeOffset(1));
+ SwNode& rNd = pUndoPam->GetPointNode();
if( rNd.IsContentNode() )
- pUndoPam->GetPoint()->nContent.Assign(
- static_cast<SwContentNode*>(&rNd), nSttContent );
- else
- pUndoPam->GetPoint()->nContent.Assign( nullptr, 0 );
+ pUndoPam->GetPoint()->SetContent( nSttContent );
bool bChkHeaderFooter = rNd.FindHeaderStartNode() ||
rNd.FindFooterStartNode();
// search all new Fly's, and store them as individual Undo Objects
- for( SwFrameFormats::size_type n = 0; n < mxDoc->GetSpzFrameFormats()->size(); ++n )
+ for( sw::FrameFormats<sw::SpzFrameFormat*>::size_type n = 0; n < mxDoc->GetSpzFrameFormats()->size(); ++n )
{
SwFrameFormat* pFrameFormat = (*mxDoc->GetSpzFrameFormats())[ n ];
const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor();
// ok, here IsAlive is a misnomer...
if (!aFlyFrameArr.IsAlive(pFrameFormat))
{
- if ( (RndStdIds::FLY_AT_PAGE == rAnchor.GetAnchorId())
- // TODO: why is this not handled via SetInsertRange?
- || SwUndoInserts::IsCreateUndoForNewFly(rAnchor,
- pUndoPam->GetPoint()->nNode.GetIndex(),
- pUndoPam->GetMark()->nNode.GetIndex()))
+ if (SwUndoInserts::IsCreateUndoForNewFly(rAnchor,
+ pUndoPam->GetPoint()->GetNodeIndex(),
+ pUndoPam->GetMark()->GetNodeIndex()))
{
if( bChkHeaderFooter &&
(RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId()) &&
@@ -260,16 +266,6 @@ ErrCode SwReader::Read( const Reader& rOptions )
}
else
{
- if( bSaveUndo )
- {
- mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
- // UGLY: temp. enable undo
- mxDoc->GetIDocumentUndoRedo().DoUndo(true);
- mxDoc->GetIDocumentUndoRedo().AppendUndo(
- std::make_unique<SwUndoInsLayFormat>( pFrameFormat,0,0 ) );
- mxDoc->GetIDocumentUndoRedo().DoUndo(false);
- mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
- }
if( pFrameFormat->HasWriterListeners() )
{
// Draw-Objects create a Frame when being inserted; thus delete them
@@ -278,7 +274,7 @@ ErrCode SwReader::Read( const Reader& rOptions )
if (RndStdIds::FLY_AT_PAGE == rAnchor.GetAnchorId())
{
- if( !rAnchor.GetContentAnchor() )
+ if( !rAnchor.GetAnchorNode() )
{
pFrameFormat->MakeFrames();
}
@@ -305,7 +301,7 @@ ErrCode SwReader::Read( const Reader& rOptions )
if( bSaveUndo )
{
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
- pUndo->SetInsertRange( *pUndoPam, false );
+ pUndo->SetInsertRange(*pUndoPam, true);
// UGLY: temp. enable undo
mxDoc->GetIDocumentUndoRedo().DoUndo(true);
mxDoc->GetIDocumentUndoRedo().AppendUndo( std::move(pUndo) );
@@ -374,7 +370,7 @@ ErrCode SwReader::Read( const Reader& rOptions )
// not insert: set the redline mode read from settings.xml
eOld = ePostReadRedlineFlags & ~RedlineFlags::Ignore;
- mxDoc->getIDocumentFieldsAccess().SetFieldsDirty(false, nullptr, 0);
+ mxDoc->getIDocumentFieldsAccess().SetFieldsDirty(true, nullptr, SwNodeOffset(0));
}
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
@@ -400,9 +396,9 @@ ErrCode SwReader::Read( const Reader& rOptions )
}
-SwReader::SwReader(SfxMedium& rMedium, const OUString& rFileName, SwDoc *pDocument)
+SwReader::SwReader(SfxMedium& rMedium, OUString aFileName, SwDoc *pDocument)
: SwDocFac(pDocument), mpStrm(nullptr), mpMedium(&rMedium), mpCursor(nullptr),
- maFileName(rFileName), mbSkipImages(false)
+ maFileName(std::move(aFileName)), mbSkipImages(false)
{
SetBaseURL( rMedium.GetBaseURL() );
SetSkipImages( rMedium.IsSkipImages() );
@@ -410,22 +406,22 @@ SwReader::SwReader(SfxMedium& rMedium, const OUString& rFileName, SwDoc *pDocume
// Read into an existing document
-SwReader::SwReader(SvStream& rStrm, const OUString& rFileName, const OUString& rBaseURL, SwPaM& rPam)
+SwReader::SwReader(SvStream& rStrm, OUString aFileName, const OUString& rBaseURL, SwPaM& rPam)
: SwDocFac(&rPam.GetDoc()), mpStrm(&rStrm), mpMedium(nullptr), mpCursor(&rPam),
- maFileName(rFileName), mbSkipImages(false)
+ maFileName(std::move(aFileName)), mbSkipImages(false)
{
SetBaseURL( rBaseURL );
}
-SwReader::SwReader(SfxMedium& rMedium, const OUString& rFileName, SwPaM& rPam)
+SwReader::SwReader(SfxMedium& rMedium, OUString aFileName, SwPaM& rPam)
: SwDocFac(&rPam.GetDoc()), mpStrm(nullptr), mpMedium(&rMedium),
- mpCursor(&rPam), maFileName(rFileName), mbSkipImages(false)
+ mpCursor(&rPam), maFileName(std::move(aFileName)), mbSkipImages(false)
{
SetBaseURL( rMedium.GetBaseURL() );
}
-SwReader::SwReader( const uno::Reference < embed::XStorage > &rStg, const OUString& rFilename, SwPaM &rPam )
- : SwDocFac(&rPam.GetDoc()), mpStrm(nullptr), mxStg( rStg ), mpMedium(nullptr), mpCursor(&rPam), maFileName(rFilename), mbSkipImages(false)
+SwReader::SwReader( uno::Reference < embed::XStorage > xStg, OUString aFilename, SwPaM &rPam )
+ : SwDocFac(&rPam.GetDoc()), mpStrm(nullptr), mxStg( std::move(xStg) ), mpMedium(nullptr), mpCursor(&rPam), maFileName(std::move(aFilename)), mbSkipImages(false)
{
}
@@ -499,8 +495,8 @@ SwDoc* Reader::GetTemplateDoc(SwDoc& rDoc)
SvtModuleOptions aModuleOptions;
if (aModuleOptions.IsWriter())
{
- SwDocShell *pDocSh = new SwDocShell(SfxObjectCreateMode::INTERNAL);
- SfxObjectShellLock xDocSh = pDocSh;
+ rtl::Reference<SwDocShell> pDocSh = new SwDocShell(SfxObjectCreateMode::INTERNAL);
+ SfxObjectShellLock xDocSh = pDocSh.get();
if (pDocSh->DoInitNew())
{
mxTemplate = pDocSh->GetDoc();
@@ -710,8 +706,8 @@ SwWriter::SwWriter(SvStream& rStrm, SwPaM& rPam, bool bInWriteAll)
{
}
-SwWriter::SwWriter( const uno::Reference < embed::XStorage >& rStg, SwDoc &rDocument)
- : m_pStrm(nullptr), m_xStg( rStg ), m_pMedium(nullptr), m_pOutPam(nullptr), m_pShell(nullptr), m_rDoc(rDocument), m_bWriteAll(true)
+SwWriter::SwWriter( uno::Reference < embed::XStorage > xStg, SwDoc &rDocument)
+ : m_pStrm(nullptr), m_xStg( std::move(xStg) ), m_pMedium(nullptr), m_pOutPam(nullptr), m_pShell(nullptr), m_rDoc(rDocument), m_bWriteAll(true)
{
}
@@ -727,7 +723,13 @@ SwWriter::SwWriter(SfxMedium& rMedium, SwDoc &rDocument)
{
}
-ErrCode SwWriter::Write( WriterRef const & rxWriter, const OUString* pRealFileName )
+static bool isFlyNode(const SwPaM& pam)
+{
+ return *pam.GetPoint() == *pam.GetMark()
+ && (pam.GetPoint()->GetNode().IsOLENode() || pam.GetPoint()->GetNode().IsGrfNode());
+}
+
+ErrCodeMsg SwWriter::Write( WriterRef const & rxWriter, const OUString* pRealFileName )
{
// #i73788#
SwPauseThreadStarting aPauseThreadStarting;
@@ -754,7 +756,7 @@ ErrCode SwWriter::Write( WriterRef const & rxWriter, const OUString* pRealFileNa
SwNodeIndex aIdx( xDoc->GetNodes().GetEndOfExtras(), 2 );
SwContentNode *pNd = aIdx.GetNode().GetContentNode();
OSL_ENSURE( pNd, "Node not found" );
- SwPosition aPos( aIdx, SwIndex( pNd ) );
+ SwPosition aPos( aIdx, pNd, 0 );
pTableNd->GetTable().MakeCopy( *xDoc, aPos, aBoxes );
}
@@ -768,13 +770,11 @@ ErrCode SwWriter::Write( WriterRef const & rxWriter, const OUString* pRealFileNa
SwPaM *pEnd = pPam;
// 1st round: Check if there is a selection
- while(true)
+ do
{
- bHasMark = bHasMark || pPam->HasMark();
+ bHasMark = pPam->HasMark() || isFlyNode(*pPam);
pPam = pPam->GetNext();
- if(bHasMark || pPam == pEnd)
- break;
- }
+ } while (!bHasMark && pPam != pEnd);
// if there is no selection, select the whole document
if(!bHasMark)
@@ -851,10 +851,10 @@ ErrCode SwWriter::Write( WriterRef const & rxWriter, const OUString* pRealFileNa
pESh->StartAllAction();
}
- auto xGuard = std::make_unique<PurgeGuard>(*pOutDoc);
+ std::unique_ptr<PurgeGuard, o3tl::default_delete<PurgeGuard>> xGuard(new PurgeGuard(*pOutDoc));
pOutDoc->SetInWriting(true);
- ErrCode nError = ERRCODE_NONE;
+ ErrCodeMsg nError = ERRCODE_NONE;
if( m_pMedium )
nError = rxWriter->Write( *pPam, *m_pMedium, pRealFileName );
else if( m_pStrm )
@@ -913,7 +913,7 @@ bool SetHTMLTemplate( SwDoc & rDoc )
SwNodes& rNds = rDoc.GetNodes();
SwNodeIndex aIdx( rNds.GetEndOfExtras(), 1 );
- SwContentNode* pCNd = rNds.GoNext( &aIdx );
+ SwContentNode* pCNd = SwNodes::GoNext(&aIdx);
if( pCNd )
{
pCNd->SetAttr
diff --git a/sw/source/filter/docx/swdocxreader.cxx b/sw/source/filter/docx/swdocxreader.cxx
index 790f91f0d344..c77c4417f73f 100644
--- a/sw/source/filter/docx/swdocxreader.cxx
+++ b/sw/source/filter/docx/swdocxreader.cxx
@@ -34,9 +34,9 @@
#include <unotools/streamwrap.hxx>
#include <unotextrange.hxx>
#include <sfx2/docfile.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
-#define AUTOTEXT_GALLERY "autoTxt"
+constexpr OUString AUTOTEXT_GALLERY = u"autoTxt"_ustr;
using namespace css;
@@ -45,7 +45,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT Reader* ImportDOCX()
return new SwDOCXReader;
}
-ErrCode SwDOCXReader::Read(SwDoc& rDoc, const OUString& /* rBaseURL */, SwPaM& rPam, const OUString& /* FileName */ )
+ErrCodeMsg SwDOCXReader::Read(SwDoc& rDoc, const OUString& /* rBaseURL */, SwPaM& rPam, const OUString& /* FileName */ )
{
if (!m_pMedium->GetInStream())
return ERR_SWG_READ_ERROR;
@@ -63,7 +63,7 @@ ErrCode SwDOCXReader::Read(SwDoc& rDoc, const OUString& /* rBaseURL */, SwPaM& r
uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW);
xImporter->setTargetDocument(xDstDoc);
- const uno::Reference<text::XTextRange> xInsertTextRange = SwXTextRange::CreateXTextRange(rDoc, *rPam.GetPoint(), nullptr);
+ const rtl::Reference<SwXTextRange> xInsertTextRange = SwXTextRange::CreateXTextRange(rDoc, *rPam.GetPoint(), nullptr);
uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*m_pMedium->GetInStream()));
//SetLoading hack because the document properties will be re-initted
@@ -76,7 +76,7 @@ ErrCode SwDOCXReader::Read(SwDoc& rDoc, const OUString& /* rBaseURL */, SwPaM& r
{
{ "InputStream", uno::Any(xStream) },
{ "InsertMode", uno::Any(true) },
- { "TextInsertModeRange", uno::Any(xInsertTextRange) }
+ { "TextInsertModeRange", uno::Any(uno::Reference<text::XTextRange>(xInsertTextRange)) }
}));
ErrCode ret = ERRCODE_NONE;
@@ -156,7 +156,7 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks )
SwNodeIndex aStart( *aDocEnd.GetNode().StartOfSectionNode(), 1 );
bool bIsAutoText = false;
- if( aStart < aDocEnd && ( aDocEnd.GetIndex() - aStart.GetIndex() > 2 ) )
+ if( aStart < aDocEnd && ( aDocEnd.GetIndex() - aStart.GetIndex() > SwNodeOffset(2) ) )
{
SwTextFormatColl* pColl = pD->getIDocumentStylePoolAccess().GetTextCollFromPool
(RES_POOLCOLL_STANDARD, false);
@@ -167,49 +167,44 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks )
OUString aLNm;
{
SwPaM aPam( aStart );
- SwNodeIndex& rIdx = aPam.GetPoint()->nNode;
- ++rIdx;
- aLNm = aPam.GetNode().GetTextNode()->GetText();
+ aPam.GetPoint()->Adjust(SwNodeOffset(1));
+ aLNm = aPam.GetPointNode().GetTextNode()->GetText();
// is AutoText?
bIsAutoText = aLNm.startsWith(AUTOTEXT_GALLERY);
- aLNm = aLNm.copy(strlen(AUTOTEXT_GALLERY) + 1);
+ aLNm = aLNm.copy(AUTOTEXT_GALLERY.getLength() + 1);
}
// Do not copy name
- aStart++;
+ ++aStart;
// Get content
SwPaM aPam( aStart );
{
- SwNodeIndex& rIdx = aPam.GetPoint()->nNode;
- ++rIdx;
- pCNd = rIdx.GetNode().GetTextNode();
+ SwNodeIndex aIdx( aPam.GetPoint()->GetNode(), SwNodeOffset(1) );
+ pCNd = aIdx.GetNode().GetTextNode();
if( nullptr == pCNd )
{
- pCNd = pD->GetNodes().MakeTextNode( rIdx, pColl );
- rIdx = *pCNd;
+ pCNd = pD->GetNodes().MakeTextNode( aIdx.GetNode(), pColl );
}
}
- aPam.GetPoint()->nContent.Assign( pCNd, 0 );
+ aPam.GetPoint()->Assign( *pCNd );
aPam.SetMark();
{
- SwNodeIndex& rIdx = aPam.GetPoint()->nNode;
- rIdx = aStart.GetNode().EndOfSectionIndex() - 1;
+ SwNodeIndex aIdx( *aStart.GetNode().EndOfSectionNode(), SwNodeOffset(-1) );
// don't add extra empty text node if exist (.dotx but not .dotm)
- if( rIdx.GetNode().GetTextNode() &&
- rIdx.GetNode().GetTextNode()->GetText().isEmpty() )
- rIdx = aStart.GetNode().EndOfSectionIndex() - 2;
- pCNd = rIdx.GetNode().GetContentNode();
+ if( aIdx.GetNode().GetTextNode() &&
+ aIdx.GetNode().GetTextNode()->GetText().isEmpty() )
+ aIdx = aStart.GetNode().EndOfSectionIndex() - 2;
+ pCNd = aIdx.GetNode().GetContentNode();
if( nullptr == pCNd )
{
- ++rIdx;
- pCNd = pD->GetNodes().MakeTextNode( rIdx, pColl );
- rIdx = *pCNd;
+ ++aIdx;
+ pCNd = pD->GetNodes().MakeTextNode( aIdx.GetNode(), pColl );
}
}
- aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
+ aPam.GetPoint()->Assign( *pCNd, pCNd->Len() );
if( bIsAutoText )
{
@@ -234,7 +229,7 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks )
SwDoc* pGlDoc = rBlocks.GetDoc();
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();
}
diff --git a/sw/source/filter/docx/swdocxreader.hxx b/sw/source/filter/docx/swdocxreader.hxx
index dc641d13c13d..0a8b8a91c4a0 100644
--- a/sw/source/filter/docx/swdocxreader.hxx
+++ b/sw/source/filter/docx/swdocxreader.hxx
@@ -32,7 +32,7 @@ public:
virtual bool ReadGlossaries(SwTextBlocks& rBlocks, bool bSaveRelFiles) const override;
private:
- virtual ErrCode Read(SwDoc&, const OUString&, SwPaM&, const OUString&) override;
+ virtual ErrCodeMsg Read(SwDoc&, const OUString&, SwPaM&, const OUString&) override;
static bool MakeEntries(SwDoc* pD, SwTextBlocks& rBlocks);
};
diff --git a/sw/source/filter/html/README b/sw/source/filter/html/README
new file mode 100644
index 000000000000..7b16fb0838a3
--- /dev/null
+++ b/sw/source/filter/html/README
@@ -0,0 +1,42 @@
+This filter is used when the "HTML (StarWriter)" filter is invoked.
+
+Import options:
+
+- FilterOptions: string
+
+ - xhtmlns=reqif-xhtml: actives the ReqIF mode
+
+- AllowedRTFOLEMimeTypes: sequence<string>
+
+ In case an (UNO) client wants to limit the accepted set of MIME types for
+ OLE objects in ReqIF mode, that's possible via this parameter.
+
+ Any MIME type is accepted by default.
+
+Export options:
+
+- FilterOptions: string
+
+ - SkipImages: skips images
+
+ - SkipHeaderFooter: skips the header and footer
+
+ - EmbedImages: inlines images
+
+ - XHTML: activates the XHTML mode
+
+ - xhtmlns=reqif-xhtml: actives the ReqIF mode
+
+- RTFOLEMimeType: string
+
+ Defines what MIME type to use for OLE objects in ReqIF mode, defaults to text/rtf.
+
+- ExportImagesAsOLE: boolean
+
+ Defines if images should be exported as OLE objects or bitmaps, defaults to
+ false.
+
+- ShapeDPI: long (32bit signed int)
+
+ Defines a custom DPI when converting vector shapes to bitmaps, defaults to
+ the system DPI (96 when not on HiDPI).
diff --git a/sw/source/filter/html/SwAppletImpl.cxx b/sw/source/filter/html/SwAppletImpl.cxx
index fe79b0d26753..9dbca2748305 100644
--- a/sw/source/filter/html/SwAppletImpl.cxx
+++ b/sw/source/filter/html/SwAppletImpl.cxx
@@ -26,6 +26,7 @@
#include <comphelper/embeddedobjectcontainer.hxx>
#include <comphelper/classids.hxx>
#include <com/sun/star/uno/Any.hxx>
+#include <o3tl/string_view.hxx>
#include <svtools/embedhlp.hxx>
#include <tools/globname.hxx>
#include <tools/urlobj.hxx>
@@ -33,75 +34,75 @@
using namespace com::sun::star;
-SwHtmlOptType SwApplet_Impl::GetOptionType( const OUString& rName, bool bApplet )
+SwHtmlOptType SwApplet_Impl::GetOptionType( std::u16string_view rName, bool bApplet )
{
SwHtmlOptType nType = bApplet ? SwHtmlOptType::PARAM : SwHtmlOptType::TAG;
- switch( rName.toChar() )
+ switch( rName[0] )
{
case 'A':
case 'a':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_align ) ||
- rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_alt ) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_align ) ||
+ o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_alt ) )
nType = SwHtmlOptType::IGNORE;
else if( bApplet &&
- (rName == "ARCHIVE" || rName == "ARCHIVES" ) )
+ (rName == u"ARCHIVE" || rName == u"ARCHIVES" ) )
nType = SwHtmlOptType::TAG;
break;
case 'C':
case 'c':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_class ) ||
- (bApplet && (rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_code ) ||
- rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_codebase ))) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_class ) ||
+ (bApplet && (o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_code ) ||
+ o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_codebase ))) )
nType = SwHtmlOptType::IGNORE;
break;
case 'H':
case 'h':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_height ) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_height ) )
nType = SwHtmlOptType::SIZE;
- else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_hspace ) ||
- (!bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SW_HTML_O_Hidden )) )
+ else if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_hspace ) ||
+ (!bApplet && o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SW_HTML_O_Hidden )) )
nType = SwHtmlOptType::IGNORE;
break;
case 'I':
case 'i':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_id ) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_id ) )
nType = SwHtmlOptType::IGNORE;
break;
case 'M':
case 'm':
- if( bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_mayscript ) )
+ if( bApplet && o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_mayscript ) )
nType = SwHtmlOptType::IGNORE;
break;
case 'N':
case 'n':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_name ) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_name ) )
nType = SwHtmlOptType::IGNORE;
break;
case 'O':
case 'o':
- if( bApplet && rName == "OBJECT" )
+ if( bApplet && rName == u"OBJECT" )
nType = SwHtmlOptType::TAG;
break;
case 'S':
case 's':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_style ) ||
- (!bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_src )) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_style ) ||
+ (!bApplet && o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_src )) )
nType = SwHtmlOptType::IGNORE;
break;
case 'T':
case 't':
- if( !bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_type ) )
+ if( !bApplet && o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_type ) )
nType = SwHtmlOptType::IGNORE;
break;
case 'V':
case 'v':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_vspace ) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_vspace ) )
nType = SwHtmlOptType::IGNORE;
break;
case 'W':
case 'w':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_width ) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_width ) )
nType = SwHtmlOptType::SIZE;
break;
}
@@ -109,48 +110,48 @@ SwHtmlOptType SwApplet_Impl::GetOptionType( const OUString& rName, bool bApplet
return nType;
}
SwApplet_Impl::SwApplet_Impl( SfxItemPool& rPool ) :
- aItemSet( rPool, svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1>{} )
+ m_aItemSet( rPool, svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1> )
{
}
void SwApplet_Impl::CreateApplet( const OUString& rCode, const OUString& rName,
bool bMayScript, const OUString& rCodeBase,
- const OUString& rDocumentBaseURL )
+ std::u16string_view rDocumentBaseURL )
{
comphelper::EmbeddedObjectContainer aCnt;
OUString aName;
// create Applet; it will be in running state
- xApplet = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_APPLET_CLASSID ).GetByteSequence(), aName );
- ::svt::EmbeddedObjectRef::TryRunningState( xApplet );
+ m_xApplet = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_APPLET_CLASSID ).GetByteSequence(), aName );
+ (void)::svt::EmbeddedObjectRef::TryRunningState( m_xApplet );
INetURLObject aUrlBase(rDocumentBaseURL);
aUrlBase.removeSegment();
OUString sDocBase = aUrlBase.GetMainURL(INetURLObject::DecodeMechanism::NONE);
- uno::Reference < beans::XPropertySet > xSet( xApplet->getComponent(), uno::UNO_QUERY );
+ uno::Reference < beans::XPropertySet > xSet( m_xApplet->getComponent(), uno::UNO_QUERY );
if ( xSet.is() )
{
- xSet->setPropertyValue("AppletCode", uno::makeAny( rCode ) );
- xSet->setPropertyValue("AppletName", uno::makeAny( rName ) );
- xSet->setPropertyValue("AppletIsScript", uno::makeAny( bMayScript ) );
- xSet->setPropertyValue("AppletDocBase", uno::makeAny( sDocBase ) );
+ xSet->setPropertyValue("AppletCode", uno::Any( rCode ) );
+ xSet->setPropertyValue("AppletName", uno::Any( rName ) );
+ xSet->setPropertyValue("AppletIsScript", uno::Any( bMayScript ) );
+ xSet->setPropertyValue("AppletDocBase", uno::Any( sDocBase ) );
if ( !rCodeBase.isEmpty() )
- xSet->setPropertyValue("AppletCodeBase", uno::makeAny( rCodeBase ) );
+ xSet->setPropertyValue("AppletCodeBase", uno::Any( rCodeBase ) );
else
- xSet->setPropertyValue("AppletCodeBase", uno::makeAny( sDocBase ) );
+ xSet->setPropertyValue("AppletCodeBase", uno::Any( sDocBase ) );
}
}
#if HAVE_FEATURE_JAVA
-bool SwApplet_Impl::CreateApplet( const OUString& rBaseURL )
+bool SwApplet_Impl::CreateApplet( std::u16string_view rBaseURL )
{
OUString aCode, aName, aCodeBase;
bool bMayScript = false;
- size_t nArgCount = aCommandList.size();
+ size_t nArgCount = m_aCommandList.size();
for( size_t i = 0; i < nArgCount; i++ )
{
- const SvCommand& rArg = aCommandList[i];
+ const SvCommand& rArg = m_aCommandList[i];
const OUString& rName = rArg.GetCommand();
if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_code ) )
aCode = rArg.GetArgument();
@@ -174,19 +175,19 @@ SwApplet_Impl::~SwApplet_Impl()
}
void SwApplet_Impl::FinishApplet()
{
- uno::Reference < beans::XPropertySet > xSet( xApplet->getComponent(), uno::UNO_QUERY );
+ uno::Reference < beans::XPropertySet > xSet( m_xApplet->getComponent(), uno::UNO_QUERY );
if ( xSet.is() )
{
uno::Sequence < beans::PropertyValue > aProps;
- aCommandList.FillSequence( aProps );
- xSet->setPropertyValue("AppletCommands", uno::makeAny( aProps ) );
+ m_aCommandList.FillSequence( aProps );
+ xSet->setPropertyValue("AppletCommands", uno::Any( aProps ) );
}
}
#if HAVE_FEATURE_JAVA
void SwApplet_Impl::AppendParam( const OUString& rName, const OUString& rValue )
{
- aCommandList.Append( rName, rValue );
+ m_aCommandList.Append( rName, rValue );
}
#endif
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index e0c2f9fb8021..0cbf5b36da86 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -23,6 +23,7 @@
#include <hintids.hxx>
#include <comphelper/string.hxx>
+#include <comphelper/xmlencode.hxx>
#include <vcl/svapp.hxx>
#include <svl/whiter.hxx>
#include <editeng/boxitem.hxx>
@@ -91,8 +92,10 @@
#include <IDocumentStylePoolAccess.hxx>
#include <numrule.hxx>
#include <o3tl/typed_flags_set.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <rtl/strbuf.hxx>
+#include <osl/diagnose.h>
using namespace css;
using editeng::SvxBorderLine;
@@ -101,14 +104,6 @@ using editeng::SvxBorderLine;
namespace {
-enum class Css1Background {
- Attr = 1,
- Page = 2,
- Table = 3,
- Fly = 4,
- Section = 5
-};
-
enum class Css1FrameSize {
NONE = 0x00,
Width = 0x01,
@@ -123,43 +118,46 @@ namespace o3tl {
template<> struct typed_flags<Css1FrameSize> : is_typed_flags<Css1FrameSize, 0x17> {};
}
-#define DOT_LEADERS_MAX_WIDTH 18
+constexpr int DOT_LEADERS_MAX_WIDTH = 18; // cm
-static Writer& OutCSS1_SwFormat( Writer& rWrt, const SwFormat& rFormat,
+static SwHTMLWriter& OutCSS1_SwFormat( SwHTMLWriter& rWrt, const SwFormat& rFormat,
IDocumentStylePoolAccess /*SwDoc*/ *pDoc, SwDoc *pTemplate );
-static Writer& OutCSS1_SwPageDesc( Writer& rWrt, const SwPageDesc& rFormat,
+static SwHTMLWriter& OutCSS1_SwPageDesc( SwHTMLWriter& rWrt, const SwPageDesc& rFormat,
IDocumentStylePoolAccess /*SwDoc*/ *pDoc, SwDoc *pTemplate,
sal_uInt16 nRefPoolId, bool bExtRef,
bool bPseudo=true );
-static Writer& OutCSS1_SwFootnoteInfo( Writer& rWrt, const SwEndNoteInfo& rInfo,
+static SwHTMLWriter& OutCSS1_SwFootnoteInfo( SwHTMLWriter& rWrt, const SwEndNoteInfo& rInfo,
SwDoc *pDoc, bool bHasNotes, bool bEndNote );
static void OutCSS1_SwFormatDropAttrs( SwHTMLWriter& rHWrt,
const SwFormatDrop& rDrop,
const SfxItemSet *pCharFormatItemSet=nullptr );
-static Writer& OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( Writer& rWrt,
+static SwHTMLWriter& OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( SwHTMLWriter& rWrt,
const SvxUnderlineItem *pUItem,
const SvxOverlineItem *pOItem,
const SvxCrossedOutItem *pCOItem,
const SvxBlinkItem *pBItem );
-static Writer& OutCSS1_SvxFontWeight( Writer& rWrt, const SfxPoolItem& rHt );
-static Writer& OutCSS1_SvxPosture( Writer& rWrt, const SfxPoolItem& rHt );
-static Writer& OutCSS1_SvxULSpace( Writer& rWrt, const SfxPoolItem& rHt );
-static Writer& OutCSS1_SvxLRSpace( Writer& rWrt, const SfxPoolItem& rHt );
-static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt,
+static SwHTMLWriter& OutCSS1_SvxFontWeight( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
+static SwHTMLWriter& OutCSS1_SvxPosture( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
+static SwHTMLWriter& OutCSS1_SvxULSpace( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
+static SwHTMLWriter& OutCSS1_SvxFirstLineIndent(SwHTMLWriter& rWrt, const SfxPoolItem& rHt);
+static SwHTMLWriter& OutCSS1_SvxTextLeftMargin(SwHTMLWriter& rWrt, const SfxPoolItem& rHt);
+static SwHTMLWriter& OutCSS1_SvxRightMargin(SwHTMLWriter& rWrt, const SfxPoolItem& rHt);
+static SwHTMLWriter& OutCSS1_SvxLRSpace( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
+static SwHTMLWriter& OutCSS1_SvxULSpace_SvxLRSpace( SwHTMLWriter& rWrt,
const SvxULSpaceItem *pULSpace,
const SvxLRSpaceItem *pLRSpace );
-static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt,
+static SwHTMLWriter& OutCSS1_SvxULSpace_SvxLRSpace( SwHTMLWriter& rWrt,
const SfxItemSet& rItemSet );
-static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt,
- Css1Background nMode,
+static SwHTMLWriter& OutCSS1_SvxBrush( SwHTMLWriter& rWrt, const SfxPoolItem& rHt,
+ sw::Css1Background nMode,
const OUString *pGraphicName );
-static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt );
-static Writer& OutCSS1_SwFormatFrameSize( Writer& rWrt, const SfxPoolItem& rHt,
+static SwHTMLWriter& OutCSS1_SvxBrush( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
+static SwHTMLWriter& OutCSS1_SwFormatFrameSize( SwHTMLWriter& rWrt, const SfxPoolItem& rHt,
Css1FrameSize nMode );
-static Writer& OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( Writer& rWrt,
+static SwHTMLWriter& OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( SwHTMLWriter& rWrt,
const SfxItemSet& rItemSet,
bool bDeep );
-static Writer& OutCSS1_SwFormatLayoutSplit( Writer& rWrt, const SfxPoolItem& rHt );
+static SwHTMLWriter& OutCSS1_SwFormatLayoutSplit( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
namespace
{
@@ -188,11 +186,24 @@ OString lclConvToHex(sal_uInt16 nHex)
}
}
-bool IgnorePropertyForReqIF(bool bReqIF, std::string_view rProperty, std::string_view rValue)
+bool IgnorePropertyForReqIF(bool bReqIF, std::string_view rProperty, std::string_view rValue,
+ std::optional<sw::Css1Background> oMode)
{
if (!bReqIF)
return false;
+ if (oMode.has_value() && *oMode != sw::Css1Background::TableCell)
+ {
+ // Table or row.
+ if (rProperty == sCSS1_P_background && rValue == "transparent")
+ {
+ // This is the default already.
+ return true;
+ }
+
+ return false;
+ }
+
// Only allow these two keys, nothing else in ReqIF mode.
if (rProperty == sCSS1_P_text_decoration)
{
@@ -244,11 +255,17 @@ public:
}
-void SwHTMLWriter::OutCSS1_Property( const char *pProp,
+void SwHTMLWriter::OutCSS1_Property( std::string_view pProp,
std::string_view sVal,
- const OUString *pSVal )
+ const OUString *pSVal,
+ std::optional<sw::Css1Background> oMode )
{
- if (IgnorePropertyForReqIF(mbReqIF, pProp, sVal))
+ OString aPropertyValue(sVal);
+ if (aPropertyValue.isEmpty() && pSVal)
+ {
+ aPropertyValue = OUStringToOString(*pSVal, RTL_TEXTENCODING_UTF8);
+ }
+ if (IgnorePropertyForReqIF(mbReqIF, pProp, aPropertyValue, oMode))
return;
OStringBuffer sOut;
@@ -301,7 +318,8 @@ void SwHTMLWriter::OutCSS1_Property( const char *pProp,
"p." sCSS2_P_CLASS_leaders " span+span{float:right;padding-left:0.33em;"
"background:white;position:relative;z-index:1}");
}
- Strm().WriteOString( sOut.makeStringAndClear() );
+ Strm().WriteOString( sOut );
+ sOut.setLength(0);
IncIndentLevel();
}
@@ -319,7 +337,7 @@ void SwHTMLWriter::OutCSS1_Property( const char *pProp,
}
else
{
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_span, false );
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false );
return;
}
break;
@@ -327,7 +345,7 @@ void SwHTMLWriter::OutCSS1_Property( const char *pProp,
case CSS1_OUTMODE_RULE_ON:
{
OutNewLine();
- sOut.append(OUStringToOString(m_aCSS1Selector, m_eDestEnc) + " { ");
+ sOut.append(OUStringToOString(m_aCSS1Selector, RTL_TEXTENCODING_UTF8) + " { ");
}
break;
@@ -342,28 +360,25 @@ void SwHTMLWriter::OutCSS1_Property( const char *pProp,
sOut.append("; ");
}
- sOut.append(pProp + OStringLiteral(": "));
+ sOut.append(pProp + OString::Concat(": "));
if( m_nCSS1OutMode & CSS1_OUTMODE_ENCODE )
{
// for STYLE-Option encode string
- Strm().WriteOString( sOut.makeStringAndClear() );
+ Strm().WriteOString( sOut );
+ sOut.setLength(0);
if( !sVal.empty() )
- HTMLOutFuncs::Out_String( Strm(), OUString::createFromAscii(sVal),
- m_eDestEnc, &m_aNonConvertableCharacters );
+ HTMLOutFuncs::Out_String( Strm(), OUString::createFromAscii(sVal) );
else if( pSVal )
- HTMLOutFuncs::Out_String( Strm(), *pSVal, m_eDestEnc, &m_aNonConvertableCharacters );
+ HTMLOutFuncs::Out_String( Strm(), *pSVal );
}
else
{
// for STYLE-Tag print string directly
- if( !sVal.empty() )
- sOut.append(sVal);
- else if( pSVal )
- sOut.append(OUStringToOString(*pSVal, m_eDestEnc));
+ sOut.append(aPropertyValue);
}
if (!sOut.isEmpty())
- Strm().WriteOString( sOut.makeStringAndClear() );
+ Strm().WriteOString( sOut );
}
static void AddUnitPropertyValue(OStringBuffer &rOut, tools::Long nVal,
@@ -376,20 +391,16 @@ static void AddUnitPropertyValue(OStringBuffer &rOut, tools::Long nVal,
rOut.append('-');
}
- // the recalculated unit results from (x * nMul)/(nDiv*nFac*10)
- tools::Long nMul = 1000;
- tools::Long nDiv = 1;
- tools::Long nFac = 100;
- const char *pUnit;
+ o3tl::Length eTo;
+ int nFac; // used to get specific number of decimals
+ std::string_view pUnit;
switch( eUnit )
{
case FieldUnit::MM_100TH:
OSL_ENSURE( FieldUnit::MM == eUnit, "Measuring unit not supported" );
[[fallthrough]];
case FieldUnit::MM:
- // 0.01mm = 0.57twip
- nMul = 25400; // 25.4 * 1000
- nDiv = 1440; // 72 * 20;
+ eTo = o3tl::Length::mm;
nFac = 100;
pUnit = sCSS1_UNIT_mm;
break;
@@ -399,9 +410,7 @@ static void AddUnitPropertyValue(OStringBuffer &rOut, tools::Long nVal,
OSL_ENSURE( FieldUnit::CM == eUnit, "Measuring unit not supported" );
[[fallthrough]];
case FieldUnit::CM:
- // 0.01cm = 5.7twip (not exact, but the UI is also not exact)
- nMul = 2540; // 2.54 * 1000
- nDiv = 1440; // 72 * 20;
+ eTo = o3tl::Length::cm;
nFac = 100;
pUnit = sCSS1_UNIT_cm;
break;
@@ -410,17 +419,13 @@ static void AddUnitPropertyValue(OStringBuffer &rOut, tools::Long nVal,
OSL_ENSURE( FieldUnit::POINT == eUnit, "Measuring unit not supported" );
[[fallthrough]];
case FieldUnit::POINT:
- // 0.1pt = 2.0twip (not exact, but the UI is also not exact)
- nMul = 100;
- nDiv = 20;
+ eTo = o3tl::Length::pt;
nFac = 10;
pUnit = sCSS1_UNIT_pt;
break;
case FieldUnit::PICA:
- // 0.01pc = 2.40twip (not exact, but the UI is also not exact)
- nMul = 1000;
- nDiv = 240; // 12 * 20;
+ eTo = o3tl::Length::pc;
nFac = 100;
pUnit = sCSS1_UNIT_pc;
break;
@@ -433,80 +438,37 @@ static void AddUnitPropertyValue(OStringBuffer &rOut, tools::Long nVal,
case FieldUnit::INCH:
default:
OSL_ENSURE( FieldUnit::INCH == eUnit, "Measuring unit not supported" );
- // 0.01in = 14.4twip (not exact, but the UI is also not exact)
- nMul = 1000;
- nDiv = 1440; // 72 * 20;
+ eTo = o3tl::Length::in;
nFac = 100;
pUnit = sCSS1_UNIT_inch;
break;
}
- tools::Long nLongVal = 0;
- bool bOutLongVal = true;
- if( nVal > LONG_MAX / nMul )
- {
- sal_Int64 nBigVal( nVal );
- nBigVal *= nMul;
- nBigVal /= nDiv;
- nBigVal += 5;
- nBigVal /= 10;
-
- if( nBigVal <= LONG_MAX )
- {
- // a long is sufficient
- nLongVal = static_cast<tools::Long>(nBigVal);
- }
- else
- {
- rOut.append(nBigVal / static_cast<sal_Int64>(nFac));
- if( (nBigVal % static_cast<sal_Int64>(nFac)) != 0 )
- {
- rOut.append('.');
- while( nFac > 1 && (nBigVal % static_cast<sal_Int64>(nFac)) != 0 )
- {
- nFac /= 10;
- rOut.append((nBigVal / static_cast<sal_Int64>(nFac)) % sal_Int64(10));
- }
- }
- bOutLongVal = false;
- }
- }
- else
- {
- nLongVal = nVal * nMul;
- nLongVal /= nDiv;
- nLongVal += 5;
- nLongVal /= 10;
- }
-
- if( bOutLongVal )
+ sal_Int64 nResult = o3tl::convert(nVal * nFac, o3tl::Length::twip, eTo);
+ rOut.append(nResult/nFac);
+ if ((nResult % nFac) != 0)
{
- rOut.append(OString::number(nLongVal/nFac));
- if( (nLongVal % nFac) != 0 )
+ rOut.append('.');
+ while (nFac > 1 && (nResult % nFac) != 0)
{
- rOut.append('.');
- while( nFac > 1 && (nLongVal % nFac) != 0 )
- {
- nFac /= 10;
- rOut.append(OString::number((nLongVal / nFac) % 10));
- }
+ nFac /= 10;
+ rOut.append((nResult / nFac) % 10);
}
}
rOut.append(pUnit);
}
-void SwHTMLWriter::OutCSS1_UnitProperty( const char *pProp, tools::Long nVal )
+void SwHTMLWriter::OutCSS1_UnitProperty( std::string_view pProp, tools::Long nVal )
{
OStringBuffer sOut;
AddUnitPropertyValue(sOut, nVal, m_eCSS1Unit);
- OutCSS1_PropertyAscii(pProp, sOut.makeStringAndClear());
+ OutCSS1_PropertyAscii(pProp, sOut);
}
-void SwHTMLWriter::OutCSS1_PixelProperty( const char *pProp, tools::Long nVal,
- bool bVert )
+void SwHTMLWriter::OutCSS1_PixelProperty( std::string_view pProp, tools::Long nTwips )
{
- OString sOut(OString::number(ToPixel(nVal,bVert)) + sCSS1_UNIT_px);
+ OString sOut(OString::number(ToPixel(nTwips)) + sCSS1_UNIT_px);
OutCSS1_PropertyAscii(pProp, sOut);
}
@@ -621,7 +583,7 @@ void SwHTMLWriter::OutStyleSheet( const SwPageDesc& rPageDesc )
DecIndentLevel();
OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_style, false );
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_style), false );
}
else
{
@@ -661,22 +623,22 @@ sal_uInt16 SwHTMLWriter::GetCSS1Selector( const SwFormat *pFormat, OString& rTok
if (!bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_blockquote)
{
rRefPoolId = RES_POOLCOLL_HTML_BLOCKQUOTE;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_blockquote);
+ rToken = OOO_STRING_SVTOOLS_HTML_blockquote ""_ostr;
}
- else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_citiation)
+ else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_citation)
{
- rRefPoolId = RES_POOLCHR_HTML_CITIATION;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_citiation);
+ rRefPoolId = RES_POOLCHR_HTML_CITATION;
+ rToken = OOO_STRING_SVTOOLS_HTML_citation ""_ostr;
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_code)
{
rRefPoolId = RES_POOLCHR_HTML_CODE;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_code);
+ rToken = OOO_STRING_SVTOOLS_HTML_code ""_ostr;
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_definstance)
{
rRefPoolId = RES_POOLCHR_HTML_DEFINSTANCE;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_definstance);
+ rToken = OOO_STRING_SVTOOLS_HTML_definstance ""_ostr;
}
else if (!bChrFormat && (aNm == OOO_STRING_SVTOOLS_HTML_dd ||
aNm == OOO_STRING_SVTOOLS_HTML_dt))
@@ -694,19 +656,19 @@ sal_uInt16 SwHTMLWriter::GetCSS1Selector( const SwFormat *pFormat, OString& rTok
else if (nDefListLvl & HTML_DLCOLL_DD)
{
rRefPoolId = RES_POOLCOLL_HTML_DD;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_dd);
+ rToken = OOO_STRING_SVTOOLS_HTML_dd ""_ostr;
}
else
{
rRefPoolId = RES_POOLCOLL_HTML_DT;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_dt);
+ rToken = OOO_STRING_SVTOOLS_HTML_dt ""_ostr;
}
}
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_emphasis)
{
rRefPoolId = RES_POOLCHR_HTML_EMPHASIS;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_emphasis);
+ rToken = OOO_STRING_SVTOOLS_HTML_emphasis ""_ostr;
}
else if (!bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_horzrule)
{
@@ -716,44 +678,44 @@ sal_uInt16 SwHTMLWriter::GetCSS1Selector( const SwFormat *pFormat, OString& rTok
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_keyboard)
{
rRefPoolId = RES_POOLCHR_HTML_KEYBOARD;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_keyboard);
+ rToken = OOO_STRING_SVTOOLS_HTML_keyboard ""_ostr;
}
else if (!bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_listing)
{
// Export Listings as PRE or PRE-derived template
- rToken = OString(OOO_STRING_SVTOOLS_HTML_preformtxt);
+ rToken = OOO_STRING_SVTOOLS_HTML_preformtxt ""_ostr;
rRefPoolId = RES_POOLCOLL_HTML_PRE;
nDeep = CSS1_FMT_CMPREF;
}
else if (!bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_preformtxt)
{
rRefPoolId = RES_POOLCOLL_HTML_PRE;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_preformtxt);
+ rToken = OOO_STRING_SVTOOLS_HTML_preformtxt ""_ostr;
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_sample)
{
rRefPoolId = RES_POOLCHR_HTML_SAMPLE;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_sample);
+ rToken = OOO_STRING_SVTOOLS_HTML_sample ""_ostr;
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_strong)
{
rRefPoolId = RES_POOLCHR_HTML_STRONG;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_strong);
+ rToken = OOO_STRING_SVTOOLS_HTML_strong ""_ostr;
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_teletype)
{
rRefPoolId = RES_POOLCHR_HTML_TELETYPE;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_teletype);
+ rToken = OOO_STRING_SVTOOLS_HTML_teletype ""_ostr;
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_variable)
{
rRefPoolId = RES_POOLCHR_HTML_VARIABLE;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_variable);
+ rToken = OOO_STRING_SVTOOLS_HTML_variable ""_ostr;
}
else if (!bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_xmp)
{
// export XMP as PRE (but not the template as Style)
- rToken = OString(OOO_STRING_SVTOOLS_HTML_preformtxt);
+ rToken = OOO_STRING_SVTOOLS_HTML_preformtxt ""_ostr;
rRefPoolId = RES_POOLCOLL_HTML_PRE;
nDeep = CSS1_FMT_CMPREF;
}
@@ -774,60 +736,60 @@ sal_uInt16 SwHTMLWriter::GetCSS1Selector( const SwFormat *pFormat, OString& rTok
bStop = (nDeep==0);
break;
case RES_POOLCOLL_TEXT:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_parabreak);
+ rToken = OOO_STRING_SVTOOLS_HTML_parabreak ""_ostr;
break;
case RES_POOLCOLL_HEADLINE1:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_head1);
+ rToken = OOO_STRING_SVTOOLS_HTML_head1 ""_ostr;
break;
case RES_POOLCOLL_HEADLINE2:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_head2);
+ rToken = OOO_STRING_SVTOOLS_HTML_head2 ""_ostr;
break;
case RES_POOLCOLL_HEADLINE3:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_head3);
+ rToken = OOO_STRING_SVTOOLS_HTML_head3 ""_ostr;
break;
case RES_POOLCOLL_HEADLINE4:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_head4);
+ rToken = OOO_STRING_SVTOOLS_HTML_head4 ""_ostr;
break;
case RES_POOLCOLL_HEADLINE5:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_head5);
+ rToken = OOO_STRING_SVTOOLS_HTML_head5 ""_ostr;
break;
case RES_POOLCOLL_HEADLINE6:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_head6);
+ rToken = OOO_STRING_SVTOOLS_HTML_head6 ""_ostr;
break;
case RES_POOLCOLL_SEND_ADDRESS:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_address);
+ rToken = OOO_STRING_SVTOOLS_HTML_address ""_ostr;
break;
case RES_POOLCOLL_HTML_BLOCKQUOTE:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_blockquote);
+ rToken = OOO_STRING_SVTOOLS_HTML_blockquote ""_ostr;
break;
case RES_POOLCOLL_HTML_PRE:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_preformtxt);
+ rToken = OOO_STRING_SVTOOLS_HTML_preformtxt ""_ostr;
break;
case RES_POOLCOLL_HTML_DD:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_dd);
+ rToken = OOO_STRING_SVTOOLS_HTML_dd ""_ostr;
break;
case RES_POOLCOLL_HTML_DT:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_dt);
+ rToken = OOO_STRING_SVTOOLS_HTML_dt ""_ostr;
break;
case RES_POOLCOLL_TABLE:
if( pPseudo )
{
rToken = OOO_STRING_SVTOOLS_HTML_tabledata " "
- OOO_STRING_SVTOOLS_HTML_parabreak;
+ OOO_STRING_SVTOOLS_HTML_parabreak ""_ostr;
}
else
- rToken = OOO_STRING_SVTOOLS_HTML_parabreak;
+ rToken = OOO_STRING_SVTOOLS_HTML_parabreak ""_ostr;
break;
case RES_POOLCOLL_TABLE_HDLN:
if( pPseudo )
{
rToken = OOO_STRING_SVTOOLS_HTML_tableheader " "
- OOO_STRING_SVTOOLS_HTML_parabreak;
+ OOO_STRING_SVTOOLS_HTML_parabreak ""_ostr;
}
else
- rToken = OString(OOO_STRING_SVTOOLS_HTML_parabreak);
+ rToken = OOO_STRING_SVTOOLS_HTML_parabreak ""_ostr;
break;
case RES_POOLCOLL_HTML_HR:
// do not export HR !
@@ -836,7 +798,7 @@ sal_uInt16 SwHTMLWriter::GetCSS1Selector( const SwFormat *pFormat, OString& rTok
case RES_POOLCOLL_FOOTNOTE:
if( !nDeep )
{
- rToken = OString(OOO_STRING_SVTOOLS_HTML_parabreak);
+ rToken = OOO_STRING_SVTOOLS_HTML_parabreak ""_ostr;
rClass = OOO_STRING_SVTOOLS_HTML_sdfootnote;
rRefPoolId = RES_POOLCOLL_TEXT;
nDeep = CSS1_FMT_CMPREF;
@@ -845,7 +807,7 @@ sal_uInt16 SwHTMLWriter::GetCSS1Selector( const SwFormat *pFormat, OString& rTok
case RES_POOLCOLL_ENDNOTE:
if( !nDeep )
{
- rToken = OString(OOO_STRING_SVTOOLS_HTML_parabreak);
+ rToken = OOO_STRING_SVTOOLS_HTML_parabreak ""_ostr;
rClass = OOO_STRING_SVTOOLS_HTML_sdendnote;
rRefPoolId = RES_POOLCOLL_TEXT;
nDeep = CSS1_FMT_CMPREF;
@@ -854,44 +816,44 @@ sal_uInt16 SwHTMLWriter::GetCSS1Selector( const SwFormat *pFormat, OString& rTok
// character templates
case RES_POOLCHR_HTML_EMPHASIS:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_emphasis);
+ rToken = OOO_STRING_SVTOOLS_HTML_emphasis ""_ostr;
break;
- case RES_POOLCHR_HTML_CITIATION:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_citiation);
+ case RES_POOLCHR_HTML_CITATION:
+ rToken = OOO_STRING_SVTOOLS_HTML_citation ""_ostr;
break;
case RES_POOLCHR_HTML_STRONG:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_strong);
+ rToken = OOO_STRING_SVTOOLS_HTML_strong ""_ostr;
break;
case RES_POOLCHR_HTML_CODE:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_code);
+ rToken = OOO_STRING_SVTOOLS_HTML_code ""_ostr;
break;
case RES_POOLCHR_HTML_SAMPLE:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_sample);
+ rToken = OOO_STRING_SVTOOLS_HTML_sample ""_ostr;
break;
case RES_POOLCHR_HTML_KEYBOARD:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_keyboard);
+ rToken = OOO_STRING_SVTOOLS_HTML_keyboard ""_ostr;
break;
case RES_POOLCHR_HTML_VARIABLE:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_variable);
+ rToken = OOO_STRING_SVTOOLS_HTML_variable ""_ostr;
break;
case RES_POOLCHR_HTML_DEFINSTANCE:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_definstance);
+ rToken = OOO_STRING_SVTOOLS_HTML_definstance ""_ostr;
break;
case RES_POOLCHR_HTML_TELETYPE:
- rToken = OString(OOO_STRING_SVTOOLS_HTML_teletype);
+ rToken = OOO_STRING_SVTOOLS_HTML_teletype ""_ostr;
break;
case RES_POOLCHR_INET_NORMAL:
if( pPseudo )
{
- rToken = OString(OOO_STRING_SVTOOLS_HTML_anchor);
+ rToken = OOO_STRING_SVTOOLS_HTML_anchor ""_ostr;
*pPseudo = OStringToOUString( sCSS1_link, RTL_TEXTENCODING_ASCII_US );
}
break;
case RES_POOLCHR_INET_VISIT:
if( pPseudo )
{
- rToken = OString(OOO_STRING_SVTOOLS_HTML_anchor);
+ rToken = OOO_STRING_SVTOOLS_HTML_anchor ""_ostr;
*pPseudo = OStringToOUString( sCSS1_visited, RTL_TEXTENCODING_ASCII_US );
}
break;
@@ -936,7 +898,7 @@ sal_uInt16 SwHTMLWriter::GetCSS1Selector( const SwFormat *pFormat, OString& rTok
sal_Int32 nPos = rClass.indexOf( '.' );
if( nPos >= 0 && rClass.getLength() > nPos+1 )
{
- rClass = rClass.replaceAt( 0, nPos+1, "" );
+ rClass = rClass.replaceAt( 0, nPos+1, u"" );
}
rClass = GetAppCharClass().lowercase( rClass );
@@ -1036,7 +998,7 @@ void SwHTMLWriter::SubtractItemSet( SfxItemSet& rItemSet,
{
const SfxPoolItem *pRefItem, *pItem;
bool bItemSet = ( SfxItemState::SET ==
- rItemSet.GetItemState( nWhich, false, &pItem) );
+ aIter.GetItemState( false, &pItem) );
bool bRefItemSet;
if( pRefScriptItemSet )
@@ -1093,7 +1055,7 @@ void SwHTMLWriter::SubtractItemSet( SfxItemSet& rItemSet,
{
// the Attribute exists only in the reference; the default
// might have to be exported
- rItemSet.Put( rItemSet.GetPool()->GetDefaultItem(nWhich) );
+ rItemSet.Put( rItemSet.GetPool()->GetUserOrPoolDefaultItem(nWhich) );
}
}
@@ -1114,7 +1076,7 @@ void SwHTMLWriter::PrepareFontList( const SvxFontItem& rFontItem,
while( nStrPos != -1 )
{
OUString aName = rName.getToken( 0, ';', nStrPos );
- aName = comphelper::string::strip(aName, ' ');
+ aName = comphelper::string::encodeForXml(comphelper::string::strip(aName, ' '));
if( aName.isEmpty() )
continue;
@@ -1159,7 +1121,7 @@ void SwHTMLWriter::PrepareFontList( const SvxFontItem& rFontItem,
if( bContainsKeyword || !bGeneric )
return;
- const char *pStr = nullptr;
+ std::string_view pStr;
switch( rFontItem.GetFamily() )
{
case FAMILY_ROMAN: pStr = sCSS1_PV_serif; break;
@@ -1171,7 +1133,7 @@ void SwHTMLWriter::PrepareFontList( const SvxFontItem& rFontItem,
;
}
- if( pStr )
+ if( !pStr.empty() )
{
if( !rNames.isEmpty() )
rNames += ", ";
@@ -1242,26 +1204,23 @@ bool SwHTMLWriter::HasScriptDependentItems( const SfxItemSet& rItemSet,
}
}
- const SfxPoolItem *pItem;
+ const SwFormatDrop *pDrop;
if( bCheckDropCap &&
- SfxItemState::SET == rItemSet.GetItemState( RES_PARATR_DROP, true,
- &pItem ) )
+ (pDrop = rItemSet.GetItemIfSet( RES_PARATR_DROP )) )
{
- const SwFormatDrop *pDrop = static_cast<const SwFormatDrop *>(pItem);
const SwCharFormat *pDCCharFormat = pDrop->GetCharFormat();
if( pDCCharFormat )
{
//sequence of (start, end) property ranges we want to
//query
- SfxItemSet aTstItemSet(
- *pDCCharFormat->GetAttrSet().GetPool(),
- svl::Items<
+ SfxItemSetFixed<
RES_CHRATR_FONT, RES_CHRATR_FONT,
RES_CHRATR_POSTURE, RES_CHRATR_POSTURE,
RES_CHRATR_WEIGHT, RES_CHRATR_WEIGHT,
RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
RES_CHRATR_CJK_POSTURE, RES_CHRATR_CTL_FONT,
- RES_CHRATR_CTL_POSTURE, RES_CHRATR_CTL_WEIGHT>{});
+ RES_CHRATR_CTL_POSTURE, RES_CHRATR_CTL_WEIGHT>
+ aTstItemSet(*pDCCharFormat->GetAttrSet().GetPool());
aTstItemSet.Set( pDCCharFormat->GetAttrSet() );
return HasScriptDependentItems( aTstItemSet, false );
}
@@ -1270,7 +1229,7 @@ bool SwHTMLWriter::HasScriptDependentItems( const SfxItemSet& rItemSet,
return false;
}
-static bool OutCSS1Rule( SwHTMLWriter& rHTMLWrt, const OUString& rSelector,
+static bool OutCSS1Rule( SwHTMLWriter& rWrt, const OUString& rSelector,
const SfxItemSet& rItemSet, bool bHasClass,
bool bCheckForPseudo )
{
@@ -1278,16 +1237,16 @@ static bool OutCSS1Rule( SwHTMLWriter& rHTMLWrt, const OUString& rSelector,
if( SwHTMLWriter::HasScriptDependentItems( rItemSet, bHasClass ) )
{
bScriptDependent = true;
- OUString aSelector( rSelector );
+ std::u16string_view aSelector( rSelector );
- OUString aPseudo;
+ std::u16string_view aPseudo;
if( bCheckForPseudo )
{
- sal_Int32 nPos = aSelector.lastIndexOf( ':' );
- if( nPos >= 0 )
+ size_t nPos = aSelector.rfind( ':' );
+ if( nPos != std::u16string_view::npos )
{
- aPseudo = aSelector.copy( nPos );
- aSelector =aSelector.copy( 0, nPos );
+ aPseudo = aSelector.substr( nPos );
+ aSelector =aSelector.substr( 0, nPos );
}
}
@@ -1297,39 +1256,39 @@ static bool OutCSS1Rule( SwHTMLWriter& rHTMLWrt, const OUString& rSelector,
// rule for all properties that aren't style dependent and
// some class rule for the additional style dependen properties
{
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_NO_SCRIPT|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_NO_SCRIPT|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&rSelector );
- rHTMLWrt.OutCSS1_SfxItemSet( rItemSet, false );
+ rWrt.OutCSS1_SfxItemSet( rItemSet, false );
}
//sequence of (start, end) property ranges we want to
//query
- SfxItemSet aScriptItemSet( *rItemSet.GetPool(),
- svl::Items<RES_CHRATR_FONT, RES_CHRATR_FONTSIZE,
+ SfxItemSetFixed<RES_CHRATR_FONT, RES_CHRATR_FONTSIZE,
RES_CHRATR_LANGUAGE, RES_CHRATR_POSTURE,
RES_CHRATR_WEIGHT, RES_CHRATR_WEIGHT,
- RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_WEIGHT>{} );
+ RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_WEIGHT>
+ aScriptItemSet( *rItemSet.GetPool() );
aScriptItemSet.Put( rItemSet );
- OUString aNewSelector = aSelector + ".western" + aPseudo;
+ OUString aNewSelector = OUString::Concat(aSelector) + ".western" + aPseudo;
{
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_WESTERN|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_WESTERN|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&aNewSelector );
- rHTMLWrt.OutCSS1_SfxItemSet( aScriptItemSet, false );
+ rWrt.OutCSS1_SfxItemSet( aScriptItemSet, false );
}
- aNewSelector = aSelector + ".cjk" + aPseudo;
+ aNewSelector = OUString::Concat(aSelector) + ".cjk" + aPseudo;
{
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CJK|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_CJK|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&aNewSelector );
- rHTMLWrt.OutCSS1_SfxItemSet( aScriptItemSet, false );
+ rWrt.OutCSS1_SfxItemSet( aScriptItemSet, false );
}
- aNewSelector = aSelector + ".ctl" + aPseudo;
+ aNewSelector = OUString::Concat(aSelector) + ".ctl" + aPseudo;
{
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CTL|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_CTL|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&aNewSelector );
- rHTMLWrt.OutCSS1_SfxItemSet( aScriptItemSet, false );
+ rWrt.OutCSS1_SfxItemSet( aScriptItemSet, false );
}
}
else
@@ -1337,25 +1296,25 @@ static bool OutCSS1Rule( SwHTMLWriter& rHTMLWrt, const OUString& rSelector,
// If there are script dependencies and we are derived from a tag,
// when we have to export a style dependent class for all
// scripts
- OUString aNewSelector = aSelector + "-western" + aPseudo;
+ OUString aNewSelector = OUString::Concat(aSelector) + "-western" + aPseudo;
{
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_WESTERN|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_WESTERN|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&aNewSelector );
- rHTMLWrt.OutCSS1_SfxItemSet( rItemSet, false );
+ rWrt.OutCSS1_SfxItemSet( rItemSet, false );
}
- aNewSelector = aSelector + "-cjk" + aPseudo;
+ aNewSelector = OUString::Concat(aSelector) + "-cjk" + aPseudo;
{
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CJK|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_CJK|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&aNewSelector );
- rHTMLWrt.OutCSS1_SfxItemSet( rItemSet, false );
+ rWrt.OutCSS1_SfxItemSet( rItemSet, false );
}
- aNewSelector = aSelector + "-ctl" + aPseudo;
+ aNewSelector = OUString::Concat(aSelector) + "-ctl" + aPseudo;
{
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CTL|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_CTL|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&aNewSelector );
- rHTMLWrt.OutCSS1_SfxItemSet( rItemSet, false );
+ rWrt.OutCSS1_SfxItemSet( rItemSet, false );
}
}
}
@@ -1365,17 +1324,17 @@ static bool OutCSS1Rule( SwHTMLWriter& rHTMLWrt, const OUString& rSelector,
// exported in one step. For hyperlinks only, a script information
// must be there, because these two chr formats don't support
// script dependencies by now.
- SwCSS1OutMode aMode( rHTMLWrt,
- rHTMLWrt.m_nCSS1Script|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
+ SwCSS1OutMode aMode( rWrt,
+ rWrt.m_nCSS1Script|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&rSelector );
- rHTMLWrt.OutCSS1_SfxItemSet( rItemSet, false );
+ rWrt.OutCSS1_SfxItemSet( rItemSet, false );
}
return bScriptDependent;
}
static void OutCSS1DropCapRule(
- SwHTMLWriter& rHTMLWrt, const OUString& rSelector,
+ SwHTMLWriter& rWrt, const OUString& rSelector,
const SwFormatDrop& rDrop, bool bHasClass,
bool bHasScriptDependencies )
{
@@ -1383,14 +1342,14 @@ static void OutCSS1DropCapRule(
if( (bHasScriptDependencies && bHasClass) ||
(pDCCharFormat && SwHTMLWriter::HasScriptDependentItems( pDCCharFormat->GetAttrSet(), false ) ) )
{
- OUString aSelector( rSelector );
+ std::u16string_view aSelector( rSelector );
- OUString aPseudo;
- sal_Int32 nPos = aSelector.lastIndexOf( ':' );
- if( nPos >= 0 )
+ std::u16string_view aPseudo;
+ size_t nPos = aSelector.rfind( ':' );
+ if( nPos != std::u16string_view::npos )
{
- aPseudo = aSelector.copy( nPos );
- aSelector = aSelector.copy( 0, nPos );
+ aPseudo = aSelector.substr( nPos );
+ aSelector = aSelector.substr( 0, nPos );
}
if( !bHasClass )
@@ -1399,38 +1358,38 @@ static void OutCSS1DropCapRule(
// rule for all properties that aren't style dependent and
// some class rule for the additional style dependen properties
{
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_NO_SCRIPT|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_NO_SCRIPT|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&rSelector );
- OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop );
+ OutCSS1_SwFormatDropAttrs( rWrt, rDrop );
}
- SfxItemSet aScriptItemSet( rHTMLWrt.m_pDoc->GetAttrPool(),
- svl::Items<RES_CHRATR_FONT, RES_CHRATR_FONTSIZE,
- RES_CHRATR_LANGUAGE, RES_CHRATR_POSTURE,
- RES_CHRATR_WEIGHT, RES_CHRATR_WEIGHT,
- RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_WEIGHT>{} );
+ SfxItemSetFixed<RES_CHRATR_FONT, RES_CHRATR_FONTSIZE,
+ RES_CHRATR_LANGUAGE, RES_CHRATR_POSTURE,
+ RES_CHRATR_WEIGHT, RES_CHRATR_WEIGHT,
+ RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_WEIGHT>
+ aScriptItemSet( rWrt.m_pDoc->GetAttrPool() );
if( pDCCharFormat )
aScriptItemSet.Set( pDCCharFormat->GetAttrSet() );
- OUString aNewSelector = aSelector + ".western" + aPseudo;
+ OUString aNewSelector = OUString::Concat(aSelector) + ".western" + aPseudo;
{
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_WESTERN|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_WESTERN|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&aNewSelector );
- OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop, &aScriptItemSet );
+ OutCSS1_SwFormatDropAttrs( rWrt, rDrop, &aScriptItemSet );
}
- aNewSelector = aSelector + ".cjk" + aPseudo;
+ aNewSelector = OUString::Concat(aSelector) + ".cjk" + aPseudo;
{
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CJK|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_CJK|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&aNewSelector );
- OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop, &aScriptItemSet );
+ OutCSS1_SwFormatDropAttrs( rWrt, rDrop, &aScriptItemSet );
}
- aNewSelector = aSelector + ".ctl" + aPseudo;
+ aNewSelector = OUString::Concat(aSelector) + ".ctl" + aPseudo;
{
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CTL|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_CTL|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&aNewSelector );
- OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop, &aScriptItemSet );
+ OutCSS1_SwFormatDropAttrs( rWrt, rDrop, &aScriptItemSet );
}
}
else
@@ -1438,25 +1397,25 @@ static void OutCSS1DropCapRule(
// If there are script dependencies and we are derived from a tag,
// when we have to export a style dependent class for all
// scripts
- OUString aNewSelector = aSelector + "-western" + aPseudo;
+ OUString aNewSelector = OUString::Concat(aSelector) + "-western" + aPseudo;
{
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_WESTERN|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_WESTERN|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&aNewSelector );
- OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop );
+ OutCSS1_SwFormatDropAttrs( rWrt, rDrop );
}
- aNewSelector = aSelector + "-cjk" + aPseudo;
+ aNewSelector = OUString::Concat(aSelector) + "-cjk" + aPseudo;
{
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CJK|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_CJK|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&aNewSelector );
- OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop );
+ OutCSS1_SwFormatDropAttrs( rWrt, rDrop );
}
- aNewSelector = aSelector + "-ctl" + aPseudo;
+ aNewSelector = OUString::Concat(aSelector) + "-ctl" + aPseudo;
{
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CTL|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_CTL|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&aNewSelector );
- OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop );
+ OutCSS1_SwFormatDropAttrs( rWrt, rDrop );
}
}
}
@@ -1466,18 +1425,16 @@ static void OutCSS1DropCapRule(
// exported in one step. For hyperlinks only, a script information
// must be there, because these two chr formats don't support
// script dependencies by now.
- SwCSS1OutMode aMode( rHTMLWrt,
- rHTMLWrt.m_nCSS1Script|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
+ SwCSS1OutMode aMode( rWrt,
+ rWrt.m_nCSS1Script|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&rSelector );
- OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop );
+ OutCSS1_SwFormatDropAttrs( rWrt, rDrop );
}
}
-static Writer& OutCSS1_SwFormat( Writer& rWrt, const SwFormat& rFormat,
+static SwHTMLWriter& OutCSS1_SwFormat( SwHTMLWriter& rWrt, const SwFormat& rFormat,
IDocumentStylePoolAccess/*SwDoc*/ *pDoc, SwDoc *pTemplate )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
bool bCharFormat = false;
switch( rFormat.Which() )
{
@@ -1556,29 +1513,29 @@ static Writer& OutCSS1_SwFormat( Writer& rWrt, const SwFormat& rFormat,
if( !bCharFormat )
{
const SvxULSpaceItem& rULItem = pRefFormat->GetULSpace();
- rHTMLWrt.m_nDfltTopMargin = rULItem.GetUpper();
- rHTMLWrt.m_nDfltBottomMargin = rULItem.GetLower();
+ rWrt.m_nDfltTopMargin = rULItem.GetUpper();
+ rWrt.m_nDfltBottomMargin = rULItem.GetLower();
}
}
else if( CSS1_FMT_ISTAG==nDeep && !bCharFormat )
{
// set Default-distance above and below (for the
// case that there is no reference template)
- rHTMLWrt.m_nDfltTopMargin = 0;
- rHTMLWrt.m_nDfltBottomMargin = HTML_PARSPACE;
+ rWrt.m_nDfltTopMargin = 0;
+ rWrt.m_nDfltBottomMargin = HTML_PARSPACE;
if( USER_FMT & nPoolFormatId )
{
// user templates
const OUString& aNm(rFormat.GetName());
if (aNm == "DD 1" || aNm == "DT 1")
- rHTMLWrt.m_nDfltBottomMargin = 0;
+ rWrt.m_nDfltBottomMargin = 0;
else if (aNm == OOO_STRING_SVTOOLS_HTML_listing)
- rHTMLWrt.m_nDfltBottomMargin = 0;
+ rWrt.m_nDfltBottomMargin = 0;
else if (aNm == OOO_STRING_SVTOOLS_HTML_preformtxt)
- rHTMLWrt.m_nDfltBottomMargin = 0;
+ rWrt.m_nDfltBottomMargin = 0;
else if (aNm == OOO_STRING_SVTOOLS_HTML_xmp)
- rHTMLWrt.m_nDfltBottomMargin = 0;
+ rWrt.m_nDfltBottomMargin = 0;
}
else
{
@@ -1591,13 +1548,13 @@ static Writer& OutCSS1_SwFormat( Writer& rWrt, const SwFormat& rFormat,
case RES_POOLCOLL_HEADLINE4:
case RES_POOLCOLL_HEADLINE5:
case RES_POOLCOLL_HEADLINE6:
- rHTMLWrt.m_nDfltTopMargin = HTML_HEADSPACE;
+ rWrt.m_nDfltTopMargin = HTML_HEADSPACE;
break;
case RES_POOLCOLL_SEND_ADDRESS:
case RES_POOLCOLL_HTML_DT:
case RES_POOLCOLL_HTML_DD:
case RES_POOLCOLL_HTML_PRE:
- rHTMLWrt.m_nDfltBottomMargin = 0;
+ rWrt.m_nDfltBottomMargin = 0;
break;
}
}
@@ -1616,40 +1573,36 @@ static Writer& OutCSS1_SwFormat( Writer& rWrt, const SwFormat& rFormat,
// export now the Attributes (incl. selector)
bool bHasScriptDependencies = false;
- if( OutCSS1Rule( rHTMLWrt, aSelector, aItemSet, CSS1_FMT_ISTAG != nDeep,
+ if( OutCSS1Rule( rWrt, aSelector, aItemSet, CSS1_FMT_ISTAG != nDeep,
bCheckForPseudo ) )
{
if( bCharFormat )
- rHTMLWrt.m_aScriptTextStyles.insert( rFormat.GetName() );
+ rWrt.m_aScriptTextStyles.insert( rFormat.GetName() );
else
{
if( nPoolFormatId==RES_POOLCOLL_TEXT )
- rHTMLWrt.m_aScriptParaStyles.insert( pDoc->GetTextCollFromPool( RES_POOLCOLL_STANDARD, false )->GetName() );
- rHTMLWrt.m_aScriptParaStyles.insert( rFormat.GetName() );
+ rWrt.m_aScriptParaStyles.insert( pDoc->GetTextCollFromPool( RES_POOLCOLL_STANDARD, false )->GetName() );
+ rWrt.m_aScriptParaStyles.insert( rFormat.GetName() );
}
bHasScriptDependencies = true;
}
// export Drop-Caps
- const SfxPoolItem *pItem;
- if( SfxItemState::SET==aItemSet.GetItemState( RES_PARATR_DROP, false, &pItem ))
+ if( const SwFormatDrop *pDrop = aItemSet.GetItemIfSet( RES_PARATR_DROP, false ) )
{
OUString sOut = aSelector +
":" + OStringToOUString( sCSS1_first_letter, RTL_TEXTENCODING_ASCII_US );
- const SwFormatDrop *pDrop = static_cast<const SwFormatDrop *>(pItem);
- OutCSS1DropCapRule( rHTMLWrt, sOut, *pDrop, CSS1_FMT_ISTAG != nDeep, bHasScriptDependencies );
+ OutCSS1DropCapRule( rWrt, sOut, *pDrop, CSS1_FMT_ISTAG != nDeep, bHasScriptDependencies );
}
return rWrt;
}
-static Writer& OutCSS1_SwPageDesc( Writer& rWrt, const SwPageDesc& rPageDesc,
+static SwHTMLWriter& OutCSS1_SwPageDesc( SwHTMLWriter& rWrt, const SwPageDesc& rPageDesc,
IDocumentStylePoolAccess/*SwDoc*/ *pDoc, SwDoc *pTemplate,
sal_uInt16 nRefPoolId, bool bExtRef,
bool bPseudo )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
const SwPageDesc* pRefPageDesc = nullptr;
if( !bExtRef )
pRefPageDesc = pDoc->GetPageDescFromPool( nRefPoolId, false );
@@ -1660,18 +1613,18 @@ static Writer& OutCSS1_SwPageDesc( Writer& rWrt, const SwPageDesc& rPageDesc,
if( bPseudo )
{
- const char *pPseudo = nullptr;
+ std::string_view pPseudo;
switch( rPageDesc.GetPoolFormatId() )
{
case RES_POOLPAGE_FIRST: pPseudo = sCSS1_first; break;
case RES_POOLPAGE_LEFT: pPseudo = sCSS1_left; break;
case RES_POOLPAGE_RIGHT: pPseudo = sCSS1_right; break;
}
- if( pPseudo )
+ if( !pPseudo.empty() )
aSelector += ":" + OStringToOUString( pPseudo, RTL_TEXTENCODING_ASCII_US );
}
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_RULE_ON|CSS1_OUTMODE_TEMPLATE,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_RULE_ON|CSS1_OUTMODE_TEMPLATE,
&aSelector );
// Size: If the only difference is the Landscape-Flag,
@@ -1701,7 +1654,7 @@ static Writer& OutCSS1_SwPageDesc( Writer& rWrt, const SwPageDesc& rPageDesc,
{
if( bRefLandscape != rPageDesc.GetLandscape() )
{
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_size,
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_size,
rPageDesc.GetLandscape() ? sCSS1_PV_landscape
: sCSS1_PV_portrait );
}
@@ -1709,16 +1662,15 @@ static Writer& OutCSS1_SwPageDesc( Writer& rWrt, const SwPageDesc& rPageDesc,
else
{
OStringBuffer sVal;
- AddUnitPropertyValue(sVal, rSz.Width(), rHTMLWrt.GetCSS1Unit());
+ AddUnitPropertyValue(sVal, rSz.Width(), rWrt.GetCSS1Unit());
sVal.append(' ');
- AddUnitPropertyValue(sVal, rSz.Height(), rHTMLWrt.GetCSS1Unit());
- rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_size, sVal.makeStringAndClear());
+ AddUnitPropertyValue(sVal, rSz.Height(), rWrt.GetCSS1Unit());
+ rWrt.OutCSS1_PropertyAscii(sCSS1_P_size, sVal);
}
// Export the distance-Attributes as normally
const SwFrameFormat &rMaster = rPageDesc.GetMaster();
- SfxItemSet aItemSet( *rMaster.GetAttrSet().GetPool(),
- svl::Items<RES_LR_SPACE, RES_UL_SPACE>{} );
+ SfxItemSetFixed<RES_LR_SPACE, RES_UL_SPACE> aItemSet( *rMaster.GetAttrSet().GetPool() );
aItemSet.Set( rMaster.GetAttrSet() );
if( pRefPageDesc )
@@ -1733,25 +1685,23 @@ static Writer& OutCSS1_SwPageDesc( Writer& rWrt, const SwPageDesc& rPageDesc,
// If for a Pseudo-Selector no Property had been set, we still
// have to export something, so that the corresponding template is
// created on the next import.
- if( rHTMLWrt.m_bFirstCSS1Property && bPseudo )
+ if( rWrt.m_bFirstCSS1Property && bPseudo )
{
- rHTMLWrt.OutNewLine();
- OString sTmp(OUStringToOString(aSelector, rHTMLWrt.m_eDestEnc));
- rWrt.Strm().WriteOString( sTmp ).WriteCharPtr( " {" );
- rHTMLWrt.m_bFirstCSS1Property = false;
+ rWrt.OutNewLine();
+ OString sTmp(OUStringToOString(aSelector, RTL_TEXTENCODING_UTF8));
+ rWrt.Strm().WriteOString( sTmp ).WriteOString( " {" );
+ rWrt.m_bFirstCSS1Property = false;
}
- if( !rHTMLWrt.m_bFirstCSS1Property )
- rWrt.Strm().WriteCharPtr( sCSS1_rule_end );
+ if( !rWrt.m_bFirstCSS1Property )
+ rWrt.Strm().WriteOString( sCSS1_rule_end );
return rWrt;
}
-static Writer& OutCSS1_SwFootnoteInfo( Writer& rWrt, const SwEndNoteInfo& rInfo,
+static SwHTMLWriter& OutCSS1_SwFootnoteInfo( SwHTMLWriter& rWrt, const SwEndNoteInfo& rInfo,
SwDoc *pDoc, bool bHasNotes, bool bEndNote )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
OUString aSelector;
if( bHasNotes )
@@ -1759,11 +1709,11 @@ static Writer& OutCSS1_SwFootnoteInfo( Writer& rWrt, const SwEndNoteInfo& rInfo,
aSelector = OUString::Concat(OOO_STRING_SVTOOLS_HTML_anchor ".") +
( bEndNote ? std::u16string_view(u"" OOO_STRING_SVTOOLS_HTML_sdendnote_anc)
: std::u16string_view(u"" OOO_STRING_SVTOOLS_HTML_sdfootnote_anc) );
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&aSelector );
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_font_size,
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_font_size,
sHTML_FTN_fontheight );
- rHTMLWrt.Strm().WriteCharPtr( sCSS1_rule_end );
+ rWrt.Strm().WriteOString( sCSS1_rule_end );
}
const SwCharFormat *pSymCharFormat = rInfo.GetCharFormat( *pDoc );
@@ -1777,9 +1727,9 @@ static Writer& OutCSS1_SwFootnoteInfo( Writer& rWrt, const SwEndNoteInfo& rInfo,
// exported, so that Netscape displays the document correctly.
// Otherwise it is sufficient, to export the differences to the
// footnote and endnote template.
- if( !bHasNotes && rHTMLWrt.m_xTemplate.is() )
+ if( !bHasNotes && rWrt.m_xTemplate.is() )
{
- SwFormat *pRefFormat = rHTMLWrt.m_xTemplate->getIDocumentStylePoolAccess().GetCharFormatFromPool(
+ SwFormat *pRefFormat = rWrt.m_xTemplate->getIDocumentStylePoolAccess().GetCharFormatFromPool(
static_cast< sal_uInt16 >(bEndNote ? RES_POOLCHR_ENDNOTE : RES_POOLCHR_FOOTNOTE) );
if( pRefFormat )
SwHTMLWriter::SubtractItemSet( aItemSet, pRefFormat->GetAttrSet(),
@@ -1791,19 +1741,17 @@ static Writer& OutCSS1_SwFootnoteInfo( Writer& rWrt, const SwEndNoteInfo& rInfo,
( bEndNote ? std::u16string_view(u"" OOO_STRING_SVTOOLS_HTML_sdendnote_sym)
: std::u16string_view(
u"" OOO_STRING_SVTOOLS_HTML_sdfootnote_sym));
- if( OutCSS1Rule( rHTMLWrt, aSelector, aItemSet, true, false ))
- rHTMLWrt.m_aScriptTextStyles.insert( pSymCharFormat->GetName() );
+ if( OutCSS1Rule( rWrt, aSelector, aItemSet, true, false ))
+ rWrt.m_aScriptTextStyles.insert( pSymCharFormat->GetName() );
}
}
return rWrt;
}
-Writer& OutCSS1_BodyTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet )
+SwHTMLWriter& OutCSS1_BodyTagStyleOpt( SwHTMLWriter& rWrt, const SfxItemSet& rItemSet )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_STYLE_OPT_ON |
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_STYLE_OPT_ON |
CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_BODY, nullptr );
// Only export the attributes of the page template.
@@ -1815,7 +1763,7 @@ Writer& OutCSS1_BodyTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet )
&pItem ) )
{
OUString rEmbeddedGraphicName;
- OutCSS1_SvxBrush( rWrt, *pItem, Css1Background::Page, &rEmbeddedGraphicName );
+ OutCSS1_SvxBrush( rWrt, *pItem, sw::Css1Background::Page, &rEmbeddedGraphicName );
}
if( SfxItemState::SET == rItemSet.GetItemState( RES_BOX, false,
@@ -1824,7 +1772,7 @@ Writer& OutCSS1_BodyTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet )
OutCSS1_SvxBox( rWrt, *pItem );
}
- if( !rHTMLWrt.m_bFirstCSS1Property )
+ if( !rWrt.m_bFirstCSS1Property )
{
// if a Property was exported as part of a Style-Option,
// the Option still needs to be finished
@@ -1834,39 +1782,32 @@ Writer& OutCSS1_BodyTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet )
return rWrt;
}
-Writer& OutCSS1_ParaTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet )
+SwHTMLWriter& OutCSS1_ParaTagStyleOpt( SwHTMLWriter& rWrt, const SfxItemSet& rItemSet, std::string_view rAdd )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
- SwCSS1OutMode aMode( rHTMLWrt, rHTMLWrt.m_nCSS1Script|CSS1_OUTMODE_STYLE_OPT |
+ SwCSS1OutMode aMode( rWrt, rWrt.m_nCSS1Script|CSS1_OUTMODE_STYLE_OPT |
CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_PARA, nullptr );
- rHTMLWrt.OutCSS1_SfxItemSet( rItemSet, false );
+ rWrt.OutCSS1_SfxItemSet( rItemSet, false, rAdd );
return rWrt;
}
-// Wrapper for Table background
-Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt )
+SwHTMLWriter& OutCSS1_TableBGStyleOpt( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_STYLE_OPT_ON |
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_STYLE_OPT_ON |
CSS1_OUTMODE_ENCODE|
CSS1_OUTMODE_TABLEBOX, nullptr );
- OutCSS1_SvxBrush( rWrt, rHt, Css1Background::Table, nullptr );
+ OutCSS1_SvxBrush( rWrt, rHt, sw::Css1Background::TableRow, nullptr );
- if( !rHTMLWrt.m_bFirstCSS1Property )
- rWrt.Strm().WriteChar( '\"' );
+ if (!rWrt.m_bFirstCSS1Property)
+ rWrt.Strm().WriteChar(cCSS1_style_opt_end);
return rWrt;
}
-Writer& OutCSS1_NumberBulletListStyleOpt( Writer& rWrt, const SwNumRule& rNumRule,
+SwHTMLWriter& OutCSS1_NumberBulletListStyleOpt( SwHTMLWriter& rWrt, const SwNumRule& rNumRule,
sal_uInt8 nLevel )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_STYLE_OPT |
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_STYLE_OPT |
CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_PARA, nullptr );
const SwNumFormat& rNumFormat = rNumRule.Get( nLevel );
@@ -1881,15 +1822,15 @@ Writer& OutCSS1_NumberBulletListStyleOpt( Writer& rWrt, const SwNumRule& rNumRul
nDfltFirstLineOffset = rPrevNumFormat.GetFirstLineOffset();
}
- if( rHTMLWrt.IsHTMLMode(HTMLMODE_LSPACE_IN_NUMBER_BULLET) &&
+ if( rWrt.IsHTMLMode(HTMLMODE_LSPACE_IN_NUMBER_BULLET) &&
nLSpace != HTML_NUMBER_BULLET_MARGINLEFT )
- rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_left, nLSpace );
+ rWrt.OutCSS1_UnitProperty( sCSS1_P_margin_left, nLSpace );
- if( rHTMLWrt.IsHTMLMode(HTMLMODE_FRSTLINE_IN_NUMBER_BULLET) &&
+ if( rWrt.IsHTMLMode(HTMLMODE_FRSTLINE_IN_NUMBER_BULLET) &&
nFirstLineOffset != nDfltFirstLineOffset )
- rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_text_indent, nFirstLineOffset );
+ rWrt.OutCSS1_UnitProperty( sCSS1_P_text_indent, nFirstLineOffset );
- if( !rHTMLWrt.m_bFirstCSS1Property )
+ if( !rWrt.m_bFirstCSS1Property )
rWrt.Strm().WriteChar( '\"' );
return rWrt;
@@ -1920,7 +1861,7 @@ void SwHTMLWriter::OutCSS1_FrameFormatOptions( const SwFrameFormat& rFrameFormat
if( !(nFrameOpts & HtmlFrmOpts::Align) )
{
// float
- const char *pStr = text::HoriOrientation::RIGHT==rHoriOri.GetHoriOrient()
+ std::string_view pStr = text::HoriOrientation::RIGHT==rHoriOri.GetHoriOrient()
? sCSS1_PV_right
: sCSS1_PV_left;
OutCSS1_PropertyAscii( sCSS1_P_float, pStr );
@@ -1977,7 +1918,7 @@ void SwHTMLWriter::OutCSS1_FrameFormatOptions( const SwFrameFormat& rFrameFormat
nYPos -= aULItem.GetUpper();
if( nYPos < 0 )
{
- aULItem.SetUpper( static_cast<sal_uInt16>(aULItem.GetUpper() + nYPos) );
+ aULItem.SetUpper( o3tl::narrowing<sal_uInt16>(aULItem.GetUpper() + nYPos) );
nYPos = 0;
}
}
@@ -1993,7 +1934,7 @@ void SwHTMLWriter::OutCSS1_FrameFormatOptions( const SwFrameFormat& rFrameFormat
nXPos -= aLRItem.GetLeft();
if( nXPos < 0 )
{
- aLRItem.SetLeft( static_cast<sal_uInt16>(aLRItem.GetLeft() + nXPos) );
+ aLRItem.SetLeft( o3tl::narrowing<sal_uInt16>(aLRItem.GetLeft() + nXPos) );
nXPos = 0;
}
}
@@ -2023,16 +1964,14 @@ void SwHTMLWriter::OutCSS1_FrameFormatOptions( const SwFrameFormat& rFrameFormat
if( nFrameOpts & HtmlFrmOpts::SWidth )
{
if( nFrameOpts & HtmlFrmOpts::SPixSize )
- OutCSS1_PixelProperty( sCSS1_P_width, aTwipSz.Width(),
- false );
+ OutCSS1_PixelProperty( sCSS1_P_width, aTwipSz.Width() );
else
OutCSS1_UnitProperty( sCSS1_P_width, aTwipSz.Width() );
}
if( nFrameOpts & HtmlFrmOpts::SHeight )
{
if( nFrameOpts & HtmlFrmOpts::SPixSize )
- OutCSS1_PixelProperty( sCSS1_P_height, aTwipSz.Height(),
- true );
+ OutCSS1_PixelProperty( sCSS1_P_height, aTwipSz.Height() );
else
OutCSS1_UnitProperty( sCSS1_P_height, aTwipSz.Height() );
}
@@ -2101,7 +2040,7 @@ void SwHTMLWriter::OutCSS1_TableFrameFormatOptions( const SwFrameFormat& rFrameF
const SfxPoolItem *pItem;
const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
if( SfxItemState::SET==rItemSet.GetItemState( RES_BACKGROUND, false, &pItem ) )
- OutCSS1_SvxBrush( *this, *pItem, Css1Background::Table, nullptr );
+ OutCSS1_SvxBrush( *this, *pItem, sw::Css1Background::Table, nullptr );
if( IsHTMLMode( HTMLMODE_PRINT_EXT ) )
OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( *this, rItemSet, false );
@@ -2109,19 +2048,30 @@ void SwHTMLWriter::OutCSS1_TableFrameFormatOptions( const SwFrameFormat& rFrameF
if( SfxItemState::SET==rItemSet.GetItemState( RES_LAYOUT_SPLIT, false, &pItem ) )
OutCSS1_SwFormatLayoutSplit( *this, *pItem );
+ if (mbXHTML)
+ {
+ sal_Int16 eTabHoriOri = rFrameFormat.GetHoriOrient().GetHoriOrient();
+ if (eTabHoriOri == text::HoriOrientation::CENTER)
+ {
+ // Emit XHTML's center using inline CSS.
+ OutCSS1_Property(sCSS1_P_margin_left, "auto", nullptr, sw::Css1Background::Table);
+ OutCSS1_Property(sCSS1_P_margin_right, "auto", nullptr, sw::Css1Background::Table);
+ }
+ }
+
if( !m_bFirstCSS1Property )
Strm().WriteChar( '\"' );
}
-void SwHTMLWriter::OutCSS1_TableCellBorderHack(SwFrameFormat const& rFrameFormat)
+void SwHTMLWriter::OutCSS1_TableCellBordersAndBG(SwFrameFormat const& rFrameFormat, const SvxBrushItem *pBrushItem)
{
SwCSS1OutMode const aMode( *this,
CSS1_OUTMODE_STYLE_OPT_ON|CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_TABLEBOX, nullptr );
+ if (pBrushItem)
+ OutCSS1_SvxBrush(*this, *pBrushItem, sw::Css1Background::TableCell, nullptr);
OutCSS1_SvxBox(*this, rFrameFormat.GetBox());
if (!m_bFirstCSS1Property)
- {
- Strm().WriteChar( cCSS1_style_opt_end );
- }
+ Strm().WriteChar(cCSS1_style_opt_end);
}
void SwHTMLWriter::OutCSS1_SectionFormatOptions( const SwFrameFormat& rFrameFormat, const SwFormatCol *pCol )
@@ -2133,7 +2083,18 @@ void SwHTMLWriter::OutCSS1_SectionFormatOptions( const SwFrameFormat& rFrameForm
const SfxPoolItem *pItem;
const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
if( SfxItemState::SET==rItemSet.GetItemState( RES_BACKGROUND, false, &pItem ) )
- OutCSS1_SvxBrush( *this, *pItem, Css1Background::Section, nullptr );
+ OutCSS1_SvxBrush( *this, *pItem, sw::Css1Background::Section, nullptr );
+
+ if (mbXHTML)
+ {
+ SvxFrameDirection nDir = GetHTMLDirection(rFrameFormat.GetAttrSet());
+ OString sConvertedDirection = convertDirection(nDir);
+ if (!sConvertedDirection.isEmpty())
+ {
+ OutCSS1_Property(sCSS1_P_dir, sConvertedDirection, nullptr,
+ sw::Css1Background::Section);
+ }
+ }
if (pCol)
{
@@ -2155,7 +2116,7 @@ static bool OutCSS1_FrameFormatBrush( SwHTMLWriter& rWrt,
!rBrushItem.GetGraphicLink().isEmpty() ||
0 != rBrushItem.GetGraphicPos() )
{
- OutCSS1_SvxBrush( rWrt, rBrushItem, Css1Background::Fly, nullptr );
+ OutCSS1_SvxBrush( rWrt, rBrushItem, sw::Css1Background::Fly, nullptr );
bWritten = true;
}
return bWritten;
@@ -2170,23 +2131,22 @@ void SwHTMLWriter::OutCSS1_FrameFormatBackground( const SwFrameFormat& rFrameFor
// If the frame is not linked to a page, we use the background of the anchor.
const SwFormatAnchor& rAnchor = rFrameFormat.GetAnchor();
RndStdIds eAnchorId = rAnchor.GetAnchorId();
- const SwPosition *pAnchorPos = rAnchor.GetContentAnchor();
- if (RndStdIds::FLY_AT_PAGE != eAnchorId && pAnchorPos)
+ const SwNode *pAnchorNode = rAnchor.GetAnchorNode();
+ if (RndStdIds::FLY_AT_PAGE != eAnchorId && pAnchorNode)
{
- const SwNode& rNode = pAnchorPos->nNode.GetNode();
- if( rNode.IsContentNode() )
+ if( pAnchorNode->IsContentNode() )
{
// If the frame is linked to a content-node,
// we take the background of the content-node, if it has one.
if( OutCSS1_FrameFormatBrush( *this,
- rNode.GetContentNode()->GetSwAttrSet().GetBackground()) )
+ pAnchorNode->GetContentNode()->GetSwAttrSet().GetBackground()) )
return;
// Otherwise we also could be in a table
- const SwTableNode *pTableNd = rNode.FindTableNode();
+ const SwTableNode *pTableNd = pAnchorNode->FindTableNode();
if( pTableNd )
{
- const SwStartNode *pBoxSttNd = rNode.FindTableBoxStartNode();
+ const SwStartNode *pBoxSttNd = pAnchorNode->FindTableBoxStartNode();
const SwTableBox *pBox =
pTableNd->GetTable().GetTableBox( pBoxSttNd->GetIndex() );
@@ -2215,7 +2175,7 @@ void SwHTMLWriter::OutCSS1_FrameFormatBackground( const SwFrameFormat& rFrameFor
}
// If the anchor is again in a Fly-Frame, use the background of the Fly-Frame.
- const SwFrameFormat *pFrameFormat = rNode.GetFlyFormat();
+ const SwFrameFormat *pFrameFormat = pAnchorNode->GetFlyFormat();
if( pFrameFormat )
{
OutCSS1_FrameFormatBackground( *pFrameFormat );
@@ -2247,16 +2207,15 @@ void SwHTMLWriter::OutCSS1_FrameFormatBackground( const SwFrameFormat& rFrameFor
OutCSS1_PropertyAscii(sCSS1_P_background, GetCSS1_Color(aColor));
}
-static Writer& OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( Writer& rWrt,
+static SwHTMLWriter& OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( SwHTMLWriter& rWrt,
const SvxUnderlineItem *pUItem,
const SvxOverlineItem *pOItem,
const SvxCrossedOutItem *pCOItem,
const SvxBlinkItem *pBItem )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
bool bNone = false;
+ OStringBuffer sOut;
- const char *pUStr = nullptr;
if( pUItem )
{
switch( pUItem->GetLineStyle() )
@@ -2267,19 +2226,18 @@ static Writer& OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( Writer& rWrt,
case LINESTYLE_DONTKNOW:
break;
default:
- if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ if( !rWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
{
// this also works in HTML does not need to be written as
// a STYLE-Options, and must not be written as Hint
- OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT) || rHTMLWrt.mbReqIF,
+ OSL_ENSURE( !rWrt.IsCSS1Source(CSS1_OUTMODE_HINT) || rWrt.mbReqIF,
"write underline as Hint?" );
- pUStr = sCSS1_PV_underline;
+ sOut.append(sCSS1_PV_underline);
}
break;
}
}
- const char *pOStr = nullptr;
if( pOItem )
{
switch( pOItem->GetLineStyle() )
@@ -2290,19 +2248,20 @@ static Writer& OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( Writer& rWrt,
case LINESTYLE_DONTKNOW:
break;
default:
- if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ if( !rWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
{
// this also works in HTML does not need to be written as
// a STYLE-Options, and must not be written as Hint
- OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
+ OSL_ENSURE( !rWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
"write overline as Hint?" );
- pOStr = sCSS1_PV_overline;
+ if (!sOut.isEmpty())
+ sOut.append(' ');
+ sOut.append(sCSS1_PV_overline);
}
break;
}
}
- const char *pCOStr = nullptr;
if( pCOItem )
{
switch( pCOItem->GetStrikeout() )
@@ -2313,88 +2272,64 @@ static Writer& OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( Writer& rWrt,
case STRIKEOUT_DONTKNOW:
break;
default:
- if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ if( !rWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
{
// this also works in HTML does not need to be written as
// a STYLE-Options, and must not be written as Hint
- OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT) || rHTMLWrt.mbReqIF,
+ OSL_ENSURE( !rWrt.IsCSS1Source(CSS1_OUTMODE_HINT) || rWrt.mbReqIF,
"write crossedOut as Hint?" );
- pCOStr = sCSS1_PV_line_through;
+ if (!sOut.isEmpty())
+ sOut.append(' ');
+ sOut.append(sCSS1_PV_line_through);
}
break;
}
}
- const char *pBStr = nullptr;
if( pBItem )
{
if( !pBItem->GetValue() )
{
bNone = true;
}
- else if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ else if( !rWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
{
// this also works in HTML does not need to be written as
// a STYLE-Options, and must not be written as Hint
- OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
+ OSL_ENSURE( !rWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
"write blink as Hint?" );
- pBStr = sCSS1_PV_blink;
+ if (!sOut.isEmpty())
+ sOut.append(' ');
+ sOut.append(sCSS1_PV_blink);
}
}
- OStringBuffer sOut;
- if( pUStr )
- sOut.append(pUStr);
-
- if( pOStr )
- {
- if (!sOut.isEmpty())
- sOut.append(' ');
- sOut.append(pOStr);
- }
-
- if( pCOStr )
- {
- if (!sOut.isEmpty())
- sOut.append(' ');
- sOut.append(pCOStr);
- }
-
- if( pBStr )
- {
- if (!sOut.isEmpty())
- sOut.append(' ');
- sOut.append(pBStr);
- }
-
if (!sOut.isEmpty())
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_text_decoration, sOut.makeStringAndClear() );
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_text_decoration, sOut );
else if( bNone )
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_text_decoration, sCSS1_PV_none );
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_text_decoration, sCSS1_PV_none );
return rWrt;
}
-static Writer& OutCSS1_SvxCaseMap( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxCaseMap( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
switch( static_cast<const SvxCaseMapItem&>(rHt).GetCaseMap() )
{
case SvxCaseMap::NotMapped:
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_font_variant, sCSS1_PV_normal );
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_font_variant, sCSS1_PV_normal );
break;
case SvxCaseMap::SmallCaps:
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_font_variant, sCSS1_PV_small_caps );
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_font_variant, sCSS1_PV_small_caps );
break;
case SvxCaseMap::Uppercase:
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_text_transform, sCSS1_PV_uppercase );
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_text_transform, sCSS1_PV_uppercase );
break;
case SvxCaseMap::Lowercase:
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_text_transform, sCSS1_PV_lowercase );
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_text_transform, sCSS1_PV_lowercase );
break;
case SvxCaseMap::Capitalize:
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_text_transform, sCSS1_PV_capitalize );
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_text_transform, sCSS1_PV_capitalize );
break;
default:
;
@@ -2403,44 +2338,40 @@ static Writer& OutCSS1_SvxCaseMap( Writer& rWrt, const SfxPoolItem& rHt )
return rWrt;
}
-static Writer& OutCSS1_SvxColor( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxColor( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
// Colors do not need to be exported for Style-Option.
- if( rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) &&
- !rHTMLWrt.m_bCfgPreferStyles )
+ if( rWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) &&
+ !rWrt.m_bCfgPreferStyles )
return rWrt;
- OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
+ OSL_ENSURE( !rWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
"write color as Hint?" );
Color aColor( static_cast<const SvxColorItem&>(rHt).GetValue() );
if( COL_AUTO == aColor )
aColor = COL_BLACK;
- rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_color, GetCSS1_Color(aColor));
+ rWrt.OutCSS1_PropertyAscii(sCSS1_P_color, GetCSS1_Color(aColor));
return rWrt;
}
-static Writer& OutCSS1_SvxCrossedOut( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxCrossedOut( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
// This function only exports Hints!
// Otherwise OutCSS1_SvxTextLn_SvxCrOut_SvxBlink() is called directly.
- if( static_cast<SwHTMLWriter&>(rWrt).IsCSS1Source(CSS1_OUTMODE_HINT) )
+ if( rWrt.IsCSS1Source(CSS1_OUTMODE_HINT) )
OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( rWrt,
nullptr, nullptr, static_cast<const SvxCrossedOutItem *>(&rHt), nullptr );
return rWrt;
}
-static Writer& OutCSS1_SvxFont( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxFont( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
// No need to export Fonts for the Style-Option.
- if( rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ if( rWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
return rWrt;
sal_uInt16 nScript = CSS1_OUTMODE_WESTERN;
@@ -2449,32 +2380,30 @@ static Writer& OutCSS1_SvxFont( Writer& rWrt, const SfxPoolItem& rHt )
case RES_CHRATR_CJK_FONT: nScript = CSS1_OUTMODE_CJK; break;
case RES_CHRATR_CTL_FONT: nScript = CSS1_OUTMODE_CTL; break;
}
- if( !rHTMLWrt.IsCSS1Script( nScript ) )
+ if( !rWrt.IsCSS1Script( nScript ) )
return rWrt;
- OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
+ OSL_ENSURE( !rWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
"write Font as Hint?" );
OUString sOut;
// MS IE3b1 has problems with single quotes
- sal_uInt16 nMode = rHTMLWrt.m_nCSS1OutMode & CSS1_OUTMODE_ANY_ON;
+ sal_uInt16 nMode = rWrt.m_nCSS1OutMode & CSS1_OUTMODE_ANY_ON;
sal_Unicode cQuote = nMode == CSS1_OUTMODE_RULE_ON ? '\"' : '\'';
SwHTMLWriter::PrepareFontList( static_cast<const SvxFontItem&>(rHt), sOut, cQuote,
true );
- rHTMLWrt.OutCSS1_Property( sCSS1_P_font_family, sOut );
+ rWrt.OutCSS1_Property( sCSS1_P_font_family, sOut );
return rWrt;
}
-static Writer& OutCSS1_SvxFontHeight( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxFontHeight( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
// Font-Height need not be exported in the Style-Option.
// For Drop-Caps another Font-Size is exported.
- if( rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) ||
- rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_DROPCAP ) )
+ if( rWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) ||
+ rWrt.IsCSS1Source( CSS1_OUTMODE_DROPCAP ) )
return rWrt;
sal_uInt16 nScript = CSS1_OUTMODE_WESTERN;
@@ -2483,40 +2412,38 @@ static Writer& OutCSS1_SvxFontHeight( Writer& rWrt, const SfxPoolItem& rHt )
case RES_CHRATR_CJK_FONTSIZE: nScript = CSS1_OUTMODE_CJK; break;
case RES_CHRATR_CTL_FONTSIZE: nScript = CSS1_OUTMODE_CTL; break;
}
- if( !rHTMLWrt.IsCSS1Script( nScript ) )
+ if( !rWrt.IsCSS1Script( nScript ) )
return rWrt;
sal_uInt32 nHeight = static_cast<const SvxFontHeightItem&>(rHt).GetHeight();
OString sHeight(OString::number(nHeight/20) + sCSS1_UNIT_pt);
- rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_font_size, sHeight);
+ rWrt.OutCSS1_PropertyAscii(sCSS1_P_font_size, sHeight);
return rWrt;
}
-static Writer& OutCSS1_SvxPosture( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxPosture( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
sal_uInt16 nScript = CSS1_OUTMODE_WESTERN;
switch( rHt.Which() )
{
case RES_CHRATR_CJK_POSTURE: nScript = CSS1_OUTMODE_CJK; break;
case RES_CHRATR_CTL_POSTURE: nScript = CSS1_OUTMODE_CTL; break;
}
- if( !rHTMLWrt.IsCSS1Script( nScript ) )
+ if( !rWrt.IsCSS1Script( nScript ) )
return rWrt;
- const char *pStr = nullptr;
+ std::string_view pStr;
switch( static_cast<const SvxPostureItem&>(rHt).GetPosture() )
{
case ITALIC_NONE: pStr = sCSS1_PV_normal; break;
case ITALIC_OBLIQUE: pStr = sCSS1_PV_oblique; break;
case ITALIC_NORMAL:
- if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ if( !rWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
{
// this also works in HTML does not need to be written as
// a STYLE-Options, and must not be written as Hint
- OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
+ OSL_ENSURE( !rWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
"write italic as Hint?" );
pStr = sCSS1_PV_italic;
}
@@ -2525,16 +2452,14 @@ static Writer& OutCSS1_SvxPosture( Writer& rWrt, const SfxPoolItem& rHt )
;
}
- if( pStr )
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_font_style, pStr );
+ if( !pStr.empty() )
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_font_style, pStr );
return rWrt;
}
-static Writer& OutCSS1_SvxKerning( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxKerning( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
sal_Int16 nValue = static_cast<const SvxKerningItem&>(rHt).GetValue();
if( nValue )
{
@@ -2550,24 +2475,22 @@ static Writer& OutCSS1_SvxKerning( Writer& rWrt, const SfxPoolItem& rHt )
sOut.append(OString::number(nValue / 10) + "." + OString::number(nValue % 10) +
sCSS1_UNIT_pt);
- rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_letter_spacing,
- sOut.makeStringAndClear());
+ rWrt.OutCSS1_PropertyAscii(sCSS1_P_letter_spacing, sOut);
+ sOut.setLength(0);
}
else
{
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_letter_spacing,
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_letter_spacing,
sCSS1_PV_normal );
}
return rWrt;
}
-static Writer& OutCSS1_SvxLanguage( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxLanguage( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
// Only export Language rules
- if( rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ if( rWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
return rWrt;
sal_uInt16 nScript = CSS1_OUTMODE_WESTERN;
@@ -2576,10 +2499,10 @@ static Writer& OutCSS1_SvxLanguage( Writer& rWrt, const SfxPoolItem& rHt )
case RES_CHRATR_CJK_LANGUAGE: nScript = CSS1_OUTMODE_CJK; break;
case RES_CHRATR_CTL_LANGUAGE: nScript = CSS1_OUTMODE_CTL; break;
}
- if( !rHTMLWrt.IsCSS1Script( nScript ) )
+ if( !rWrt.IsCSS1Script( nScript ) )
return rWrt;
- OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
+ OSL_ENSURE( !rWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
"write Language as Hint?" );
LanguageType eLang = static_cast<const SvxLanguageItem &>(rHt).GetLanguage();
@@ -2588,59 +2511,55 @@ static Writer& OutCSS1_SvxLanguage( Writer& rWrt, const SfxPoolItem& rHt )
OUString sOut = LanguageTag::convertToBcp47( eLang );
- rHTMLWrt.OutCSS1_Property( sCSS1_P_so_language, sOut );
+ rWrt.OutCSS1_Property( sCSS1_P_so_language, sOut );
return rWrt;
}
-static Writer& OutCSS1_SvxUnderline( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxUnderline( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
// This function only exports Hints!
// Otherwise OutCSS1_SvxTextLn_SvxCrOut_SvxBlink() is called directly.
- if( static_cast<SwHTMLWriter&>(rWrt).IsCSS1Source(CSS1_OUTMODE_HINT) )
+ if( rWrt.IsCSS1Source(CSS1_OUTMODE_HINT) )
OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( rWrt,
static_cast<const SvxUnderlineItem *>(&rHt), nullptr, nullptr, nullptr );
return rWrt;
}
-static Writer& OutCSS1_SvxOverline( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxOverline( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
// This function only exports Hints!
// Otherwise OutCSS1_SvxTextLn_SvxCrOut_SvxBlink() is called directly.
- if( static_cast<SwHTMLWriter&>(rWrt).IsCSS1Source(CSS1_OUTMODE_HINT) )
+ if( rWrt.IsCSS1Source(CSS1_OUTMODE_HINT) )
OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( rWrt,
nullptr, static_cast<const SvxOverlineItem *>(&rHt), nullptr, nullptr );
return rWrt;
}
-static Writer& OutCSS1_SvxHidden( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxHidden( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
if ( static_cast<const SvxCharHiddenItem&>(rHt).GetValue() )
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_display, sCSS1_PV_none );
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_display, sCSS1_PV_none );
return rWrt;
}
-static Writer& OutCSS1_SvxFontWeight( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxFontWeight( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
sal_uInt16 nScript = CSS1_OUTMODE_WESTERN;
switch( rHt.Which() )
{
case RES_CHRATR_CJK_WEIGHT: nScript = CSS1_OUTMODE_CJK; break;
case RES_CHRATR_CTL_WEIGHT: nScript = CSS1_OUTMODE_CTL; break;
}
- if( !rHTMLWrt.IsCSS1Script( nScript ) )
+ if( !rWrt.IsCSS1Script( nScript ) )
return rWrt;
- const char *pStr = nullptr;
+ std::string_view pStr;
switch( static_cast<const SvxWeightItem&>(rHt).GetWeight() )
{
case WEIGHT_ULTRALIGHT: pStr = sCSS1_PV_extra_light; break;
@@ -2649,11 +2568,11 @@ static Writer& OutCSS1_SvxFontWeight( Writer& rWrt, const SfxPoolItem& rHt )
case WEIGHT_NORMAL: pStr = sCSS1_PV_normal; break;
case WEIGHT_SEMIBOLD: pStr = sCSS1_PV_demi_bold; break;
case WEIGHT_BOLD:
- if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ if( !rWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
{
// this also works in HTML does not need to be written as
// a STYLE-Options, and must not be written as Hint
- OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
+ OSL_ENSURE( !rWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
"write bold as Hint?" );
pStr = sCSS1_PV_bold;
}
@@ -2663,32 +2582,30 @@ static Writer& OutCSS1_SvxFontWeight( Writer& rWrt, const SfxPoolItem& rHt )
pStr = sCSS1_PV_normal;
}
- if( pStr )
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_font_weight, pStr );
+ if( !pStr.empty() )
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_font_weight, pStr );
return rWrt;
}
-static Writer& OutCSS1_SvxBlink( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxBlink( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
// This function only exports Hints!
// Otherwise OutCSS1_SvxTextLn_SvxCrOut_SvxBlink() is called directly.
- if( static_cast<SwHTMLWriter&>(rWrt).IsCSS1Source(CSS1_OUTMODE_HINT) )
+ if( rWrt.IsCSS1Source(CSS1_OUTMODE_HINT) )
OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( rWrt,
nullptr, nullptr, nullptr, static_cast<const SvxBlinkItem *>(&rHt) );
return rWrt;
}
-static Writer& OutCSS1_SvxLineSpacing( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxLineSpacing( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
// Netscape4 has big problems with cell heights if the line spacing is
// changed within a table and the width of the table is not calculated
// automatically (== if there is a WIDTH-Option)
- if( rHTMLWrt.m_bOutTable && rHTMLWrt.m_bCfgNetscape4 )
+ if( rWrt.m_bOutTable && rWrt.m_bCfgNetscape4 )
return rWrt;
const SvxLineSpacingItem& rLSItem = static_cast<const SvxLineSpacingItem&>(rHt);
@@ -2724,27 +2641,25 @@ static Writer& OutCSS1_SvxLineSpacing( Writer& rWrt, const SfxPoolItem& rHt )
}
if( nHeight )
- rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_line_height, static_cast<tools::Long>(nHeight) );
+ rWrt.OutCSS1_UnitProperty( sCSS1_P_line_height, static_cast<tools::Long>(nHeight) );
else if( nPercentHeight &&
- !(nPercentHeight < 115 && rHTMLWrt.m_bParaDotLeaders )) // avoid HTML scrollbars and missing descenders
+ !(nPercentHeight < 115 && rWrt.m_bParaDotLeaders )) // avoid HTML scrollbars and missing descenders
{
OString sHeight(OString::number(nPercentHeight) + "%");
- rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_line_height, sHeight);
+ rWrt.OutCSS1_PropertyAscii(sCSS1_P_line_height, sHeight);
}
return rWrt;
}
-static Writer& OutCSS1_SvxAdjust( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxAdjust( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
// Export Alignment in Style-Option only if the Tag does not allow ALIGN=xxx
- if( rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) &&
- !rHTMLWrt.m_bNoAlign)
+ if( rWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) &&
+ !rWrt.m_bNoAlign)
return rWrt;
- const char* pStr = nullptr;
+ std::string_view pStr;
switch( static_cast<const SvxAdjustItem&>(rHt).GetAdjust() )
{
case SvxAdjust::Left: pStr = sCSS1_PV_left; break;
@@ -2755,52 +2670,44 @@ static Writer& OutCSS1_SvxAdjust( Writer& rWrt, const SfxPoolItem& rHt )
;
}
- if( pStr )
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_text_align, pStr );
+ if( !pStr.empty() )
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_text_align, pStr );
return rWrt;
}
-static Writer& OutCSS1_SvxFormatSplit( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxFormatSplit( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
- const char *pStr = static_cast<const SvxFormatSplitItem&>(rHt).GetValue()
+ std::string_view pStr = static_cast<const SvxFormatSplitItem&>(rHt).GetValue()
? sCSS1_PV_auto
: sCSS1_PV_avoid;
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_inside, pStr );
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_inside, pStr );
return rWrt;
}
-static Writer& OutCSS1_SwFormatLayoutSplit( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SwFormatLayoutSplit( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
- const char *pStr = static_cast<const SwFormatLayoutSplit&>(rHt).GetValue()
+ std::string_view pStr = static_cast<const SwFormatLayoutSplit&>(rHt).GetValue()
? sCSS1_PV_auto
: sCSS1_PV_avoid;
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_inside, pStr );
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_inside, pStr );
return rWrt;
}
-static Writer& OutCSS1_SvxWidows( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxWidows( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
OString aStr(OString::number(static_cast<const SvxWidowsItem&>(rHt).GetValue()));
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_widows, aStr );
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_widows, aStr );
return rWrt;
}
-static Writer& OutCSS1_SvxOrphans( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxOrphans( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
OString aStr(OString::number(static_cast<const SvxOrphansItem&>(rHt).GetValue()));
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_orphans, aStr );
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_orphans, aStr );
return rWrt;
}
@@ -2827,40 +2734,36 @@ static void OutCSS1_SwFormatDropAttrs( SwHTMLWriter& rHWrt,
else if( pDCCharFormat )
rHWrt.OutCSS1_SfxItemSet( pDCCharFormat->GetAttrSet() );
else if( (rHWrt.m_nCSS1OutMode & CSS1_OUTMODE_ANY_OFF) == CSS1_OUTMODE_RULE_OFF )
- rHWrt.Strm().WriteCharPtr( sCSS1_rule_end );
+ rHWrt.Strm().WriteOString( sCSS1_rule_end );
}
-static Writer& OutCSS1_SwFormatDrop( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SwFormatDrop( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
// never export as an Option of a paragraph, but only as Hints
- if( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT) )
+ if( !rWrt.IsCSS1Source(CSS1_OUTMODE_HINT) )
return rWrt;
- if( rHTMLWrt.m_bTagOn )
+ if( rWrt.m_bTagOn )
{
- SwCSS1OutMode aMode( rHTMLWrt,
- rHTMLWrt.m_nCSS1Script|CSS1_OUTMODE_SPAN_TAG1_ON|CSS1_OUTMODE_ENCODE|
+ SwCSS1OutMode aMode( rWrt,
+ rWrt.m_nCSS1Script|CSS1_OUTMODE_SPAN_TAG1_ON|CSS1_OUTMODE_ENCODE|
CSS1_OUTMODE_DROPCAP, nullptr );
- OutCSS1_SwFormatDropAttrs( rHTMLWrt, static_cast<const SwFormatDrop&>(rHt) );
+ OutCSS1_SwFormatDropAttrs( rWrt, static_cast<const SwFormatDrop&>(rHt) );
// A "> is already printed by the calling OutCSS1_HintAsSpanTag.
}
else
{
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span, false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false );
}
return rWrt;
}
-static Writer& OutCSS1_SwFormatFrameSize( Writer& rWrt, const SfxPoolItem& rHt,
+static SwHTMLWriter& OutCSS1_SwFormatFrameSize( SwHTMLWriter& rWrt, const SfxPoolItem& rHt,
Css1FrameSize nMode )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
const SwFormatFrameSize& rFSItem = static_cast<const SwFormatFrameSize&>(rHt);
if( nMode & Css1FrameSize::Width )
@@ -2869,16 +2772,16 @@ static Writer& OutCSS1_SwFormatFrameSize( Writer& rWrt, const SfxPoolItem& rHt,
if( nPercentWidth )
{
OString sOut(OString::number(nPercentWidth) + "%");
- rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_width, sOut);
+ rWrt.OutCSS1_PropertyAscii(sCSS1_P_width, sOut);
}
else if( nMode & Css1FrameSize::Pixel )
{
- rHTMLWrt.OutCSS1_PixelProperty( sCSS1_P_width,
- rFSItem.GetSize().Width(), false );
+ rWrt.OutCSS1_PixelProperty( sCSS1_P_width,
+ rFSItem.GetSize().Width() );
}
else
{
- rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_width,
+ rWrt.OutCSS1_UnitProperty( sCSS1_P_width,
rFSItem.GetSize().Width() );
}
}
@@ -2886,81 +2789,130 @@ static Writer& OutCSS1_SwFormatFrameSize( Writer& rWrt, const SfxPoolItem& rHt,
return rWrt;
}
-static Writer& OutCSS1_SvxLRSpace( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxFirstLineIndent(SwHTMLWriter & rWrt, SfxPoolItem const& rHt)
+{
+ const SvxFirstLineIndentItem & rFirstLine(static_cast<const SvxFirstLineIndentItem&>(rHt));
+
+ // No Export of a firm attribute is needed if the new values
+ // match that of the current template
+
+ // The LineIndent of the first line might contain the room for numbering
+ tools::Long nFirstLineIndent = static_cast<tools::Long>(rFirstLine.GetTextFirstLineOffset())
+ - rWrt.m_nFirstLineIndent;
+ if (rWrt.m_nDfltFirstLineIndent != nFirstLineIndent)
+ {
+ rWrt.OutCSS1_UnitProperty(sCSS1_P_text_indent, nFirstLineIndent);
+ }
+
+ return rWrt;
+}
+
+static SwHTMLWriter& OutCSS1_SvxTextLeftMargin(SwHTMLWriter & rWrt, SfxPoolItem const& rHt)
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
+ const SvxTextLeftMarginItem& rLeftMargin(static_cast<const SvxTextLeftMarginItem&>(rHt));
+ // No Export of a firm attribute is needed if the new values
+ // match that of the current template
+
+ // A left margin can exist because of a list nearby
+ tools::Long nLeftMargin = rLeftMargin.GetTextLeft() - rWrt.m_nLeftMargin;
+ if (rWrt.m_nDfltLeftMargin != nLeftMargin)
+ {
+ rWrt.OutCSS1_UnitProperty(sCSS1_P_margin_left, nLeftMargin);
+
+ // max-width = max-width - margin-left for TOC paragraphs with dot leaders
+ if (rWrt.m_bParaDotLeaders)
+ rWrt.OutCSS1_UnitProperty(sCSS1_P_max_width, o3tl::convert(DOT_LEADERS_MAX_WIDTH, o3tl::Length::cm, o3tl::Length::twip) - nLeftMargin);
+
+ }
+
+ return rWrt;
+}
+
+static SwHTMLWriter& OutCSS1_SvxRightMargin(SwHTMLWriter & rWrt, SfxPoolItem const& rHt)
+{
+ const SvxRightMarginItem& rRightMargin(static_cast<const SvxRightMarginItem&>(rHt));
+
+ // No Export of a firm attribute is needed if the new values
+ // match that of the current template
+
+ if (rWrt.m_nDfltRightMargin != rRightMargin.GetRight())
+ {
+ rWrt.OutCSS1_UnitProperty(sCSS1_P_margin_right, rRightMargin.GetRight());
+ }
+
+ return rWrt;
+}
+
+static SwHTMLWriter& OutCSS1_SvxLRSpace( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
+{
const SvxLRSpaceItem& rLRItem = static_cast<const SvxLRSpaceItem&>(rHt);
// No Export of a firm attribute is needed if the new values
// match that of the current template
// A left margin can exist because of a list nearby
- tools::Long nLeftMargin = rLRItem.GetTextLeft() - rHTMLWrt.m_nLeftMargin;
- if( rHTMLWrt.m_nDfltLeftMargin != nLeftMargin )
+ tools::Long nLeftMargin = rLRItem.GetTextLeft() - rWrt.m_nLeftMargin;
+ if( rWrt.m_nDfltLeftMargin != nLeftMargin )
{
- rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_left, nLeftMargin );
+ rWrt.OutCSS1_UnitProperty( sCSS1_P_margin_left, nLeftMargin );
// max-width = max-width - margin-left for TOC paragraphs with dot leaders
- if( rHTMLWrt.m_bParaDotLeaders )
- rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_max_width, tools::Long(DOT_LEADERS_MAX_WIDTH/2.54*72*20) - nLeftMargin );
+ if( rWrt.m_bParaDotLeaders )
+ rWrt.OutCSS1_UnitProperty( sCSS1_P_max_width, o3tl::convert(DOT_LEADERS_MAX_WIDTH, o3tl::Length::cm, o3tl::Length::twip) - nLeftMargin );
}
- if( rHTMLWrt.m_nDfltRightMargin != rLRItem.GetRight() )
+ if( rWrt.m_nDfltRightMargin != rLRItem.GetRight() )
{
- rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_right, rLRItem.GetRight() );
+ rWrt.OutCSS1_UnitProperty( sCSS1_P_margin_right, rLRItem.GetRight() );
}
// The LineIndent of the first line might contain the room for numbering
tools::Long nFirstLineIndent = static_cast<tools::Long>(rLRItem.GetTextFirstLineOffset()) -
- rHTMLWrt.m_nFirstLineIndent;
- if( rHTMLWrt.m_nDfltFirstLineIndent != nFirstLineIndent )
+ rWrt.m_nFirstLineIndent;
+ if( rWrt.m_nDfltFirstLineIndent != nFirstLineIndent )
{
- rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_text_indent,
+ rWrt.OutCSS1_UnitProperty( sCSS1_P_text_indent,
nFirstLineIndent );
}
return rWrt;
}
-static Writer& OutCSS1_SvxULSpace( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxULSpace( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
const SvxULSpaceItem& rULItem = static_cast<const SvxULSpaceItem&>(rHt);
- if( rHTMLWrt.m_nDfltTopMargin != rULItem.GetUpper() )
+ if( rWrt.m_nDfltTopMargin != rULItem.GetUpper() )
{
- rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_top,
+ rWrt.OutCSS1_UnitProperty( sCSS1_P_margin_top,
static_cast<tools::Long>(rULItem.GetUpper()) );
}
- if( rHTMLWrt.m_nDfltBottomMargin != rULItem.GetLower() )
+ if( rWrt.m_nDfltBottomMargin != rULItem.GetLower() )
{
- rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_bottom,
+ rWrt.OutCSS1_UnitProperty( sCSS1_P_margin_bottom,
static_cast<tools::Long>(rULItem.GetLower()) );
}
return rWrt;
}
-static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt,
+static SwHTMLWriter& OutCSS1_SvxULSpace_SvxLRSpace( SwHTMLWriter& rWrt,
const SvxULSpaceItem *pULItem,
const SvxLRSpaceItem *pLRItem )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
if( pLRItem && pULItem &&
pLRItem->GetLeft() == pLRItem->GetRight() &&
pLRItem->GetLeft() == pULItem->GetUpper() &&
pLRItem->GetLeft() == pULItem->GetLower() &&
- pLRItem->GetLeft() != rHTMLWrt.m_nDfltLeftMargin &&
- pLRItem->GetRight() != rHTMLWrt.m_nDfltRightMargin &&
- pULItem->GetUpper() != rHTMLWrt.m_nDfltTopMargin &&
- pULItem->GetLower() != rHTMLWrt.m_nDfltBottomMargin )
+ pLRItem->GetLeft() != rWrt.m_nDfltLeftMargin &&
+ pLRItem->GetRight() != rWrt.m_nDfltRightMargin &&
+ pULItem->GetUpper() != rWrt.m_nDfltTopMargin &&
+ pULItem->GetLower() != rWrt.m_nDfltBottomMargin )
{
- rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin, pLRItem->GetLeft() );
+ rWrt.OutCSS1_UnitProperty( sCSS1_P_margin, pLRItem->GetLeft() );
}
else
{
@@ -2973,17 +2925,11 @@ static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt,
return rWrt;
}
-static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt,
+static SwHTMLWriter& OutCSS1_SvxULSpace_SvxLRSpace( SwHTMLWriter& rWrt,
const SfxItemSet& rItemSet )
{
- const SvxULSpaceItem *pULSpace = nullptr;
- const SvxLRSpaceItem *pLRSpace = nullptr;
- const SfxPoolItem *pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( RES_LR_SPACE, false/*bDeep*/, &pItem ) )
- pLRSpace = static_cast<const SvxLRSpaceItem *>(pItem);
-
- if( SfxItemState::SET == rItemSet.GetItemState( RES_UL_SPACE, false/*bDeep*/, &pItem ) )
- pULSpace = static_cast<const SvxULSpaceItem *>(pItem);
+ const SvxLRSpaceItem *pLRSpace = rItemSet.GetItemIfSet( RES_LR_SPACE, false/*bDeep*/ );
+ const SvxULSpaceItem *pULSpace = rItemSet.GetItemIfSet( RES_UL_SPACE, false/*bDeep*/ );
if( pLRSpace || pULSpace )
OutCSS1_SvxULSpace_SvxLRSpace( rWrt, pULSpace, pLRSpace );
@@ -2991,18 +2937,16 @@ static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt,
return rWrt;
}
-static Writer& OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( Writer& rWrt,
+static SwHTMLWriter& OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( SwHTMLWriter& rWrt,
const SvxFormatBreakItem *pBreakItem,
const SwFormatPageDesc *pPDescItem,
const SvxFormatKeepItem *pKeepItem )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
- if( !rHTMLWrt.IsHTMLMode(HTMLMODE_PRINT_EXT) )
+ if( !rWrt.IsHTMLMode(HTMLMODE_PRINT_EXT) )
return rWrt;
- const char *pBreakBefore = nullptr;
- const char *pBreakAfter = nullptr;
+ std::string_view pBreakBefore;
+ std::string_view pBreakAfter;
if( pKeepItem )
{
@@ -3014,7 +2958,7 @@ static Writer& OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( Writer& rWrt,
{
case SvxBreak::NONE:
pBreakBefore = sCSS1_PV_auto;
- if( !pBreakAfter )
+ if( pBreakAfter.empty() )
pBreakAfter = sCSS1_PV_auto;
break;
@@ -3042,47 +2986,40 @@ static Writer& OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( Writer& rWrt,
default: pBreakBefore = sCSS1_PV_always; break;
}
}
- else if( !pBreakBefore )
+ else if( pBreakBefore.empty() )
{
pBreakBefore = sCSS1_PV_auto;
}
}
- if (rHTMLWrt.mbSkipHeaderFooter)
+ if (rWrt.mbSkipHeaderFooter)
// No page break when writing only a fragment.
return rWrt;
- if( pBreakBefore )
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_before,
+ if( !pBreakBefore.empty() )
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_before,
pBreakBefore );
- if( pBreakAfter )
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_after,
+ if( !pBreakAfter.empty() )
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_after,
pBreakAfter );
return rWrt;
}
-static Writer& OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( Writer& rWrt,
+static SwHTMLWriter& OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( SwHTMLWriter& rWrt,
const SfxItemSet& rItemSet,
bool bDeep )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- const SfxPoolItem *pItem;
- const SvxFormatBreakItem *pBreakItem = nullptr;
- if( SfxItemState::SET==rItemSet.GetItemState( RES_BREAK, bDeep, &pItem ))
- pBreakItem = static_cast<const SvxFormatBreakItem *>(pItem);
+ const SvxFormatBreakItem *pBreakItem = rItemSet.GetItemIfSet( RES_BREAK, bDeep );
const SwFormatPageDesc *pPDescItem = nullptr;
- if( ( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) ||
- !rHTMLWrt.m_bCSS1IgnoreFirstPageDesc ||
- rHTMLWrt.m_pStartNdIdx->GetIndex() !=
- rHTMLWrt.m_pCurrentPam->GetPoint()->nNode.GetIndex() ) &&
- SfxItemState::SET==rItemSet.GetItemState( RES_PAGEDESC, bDeep, &pItem ))
- pPDescItem = static_cast<const SwFormatPageDesc*>(pItem);
+ if( !rWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) ||
+ !rWrt.m_bCSS1IgnoreFirstPageDesc ||
+ rWrt.m_pStartNdIdx->GetIndex() !=
+ rWrt.m_pCurrentPam->GetPoint()->GetNodeIndex() )
+ pPDescItem = rItemSet.GetItemIfSet( RES_PAGEDESC, bDeep );
- const SvxFormatKeepItem *pKeepItem = nullptr;
- if( SfxItemState::SET==rItemSet.GetItemState( RES_KEEP, bDeep, &pItem ))
- pKeepItem = static_cast<const SvxFormatKeepItem *>(pItem);
+ const SvxFormatKeepItem *pKeepItem = rItemSet.GetItemIfSet( RES_KEEP, bDeep );
if( pBreakItem || pPDescItem || pKeepItem )
OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( rWrt, pBreakItem,
@@ -3092,22 +3029,20 @@ static Writer& OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( Writer& rWrt,
}
// Wrapper for OutCSS1_SfxItemSet etc.
-static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxBrush( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- OutCSS1_SvxBrush( rWrt, rHt, Css1Background::Attr, nullptr );
+ OutCSS1_SvxBrush( rWrt, rHt, sw::Css1Background::Attr, nullptr );
return rWrt;
}
-static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt,
- Css1Background nMode,
+static SwHTMLWriter& OutCSS1_SvxBrush( SwHTMLWriter& rWrt, const SfxPoolItem& rHt,
+ sw::Css1Background nMode,
const OUString* pGraphicName)
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
// The Character-Attribute is skipped, if we are about to
// exporting options
if( rHt.Which() < RES_CHRATR_END &&
- rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ rWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
return rWrt;
// start getting a few values
@@ -3116,7 +3051,7 @@ static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt,
OUString aLink = pGraphicName ? *pGraphicName
: static_cast<const SvxBrushItem &>(rHt).GetGraphicLink();
SvxGraphicPosition ePos = static_cast<const SvxBrushItem &>(rHt).GetGraphicPos();
- if( Css1Background::Page == nMode && !rHTMLWrt.mbEmbedImages )
+ if( sw::Css1Background::Page == nMode && !rWrt.mbEmbedImages )
{
// page style images are exported if not tiled
if( aLink.isEmpty() || GPOS_TILED==ePos )
@@ -3139,30 +3074,30 @@ static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt,
// Embedded Graphic -> export WriteEmbedded
const Graphic* pGrf = nullptr;
- if( rHTMLWrt.mbEmbedImages || aLink.isEmpty())
+ if( rWrt.mbEmbedImages || aLink.isEmpty())
{
pGrf = static_cast<const SvxBrushItem &>(rHt).GetGraphic();
if( pGrf )
{
if( !XOutBitmap::GraphicToBase64(*pGrf, aGraphicInBase64) )
{
- rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
+ rWrt.m_nWarn = WARN_SWG_POOR_LOAD;
}
}
aLink.clear();
}
- else if( !pGraphicName && rHTMLWrt.m_bCfgCpyLinkedGrfs )
+ else if( !pGraphicName && rWrt.m_bCfgCpyLinkedGrfs )
{
OUString aGraphicAsLink = aLink;
rWrt.CopyLocalFileToINet( aGraphicAsLink );
aLink = aGraphicAsLink;
}
// In tables we only export something if there is a Graphic
- if( Css1Background::Table==nMode && !pGrf && !aLink.isEmpty())
+ if( (nMode == sw::Css1Background::Table || nMode == sw::Css1Background::TableRow) && !pGrf && !aLink.isEmpty())
return rWrt;
// if necessary, add the orientation of the Graphic
- const char *pRepeat = nullptr, *pHori = nullptr, *pVert = nullptr;
+ std::string_view pRepeat, pHori, pVert;
if( pGrf || !aLink.isEmpty() )
{
if( GPOS_TILED==ePos )
@@ -3219,7 +3154,7 @@ static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt,
;
}
- if( pHori || pVert )
+ if( !pHori.empty() || !pVert.empty() )
pRepeat = sCSS1_PV_no_repeat;
}
}
@@ -3229,7 +3164,7 @@ static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt,
if( !pGrf && aLink.isEmpty() && !bColor )
{
// no color and no Link, but a transparent Brush
- if( bTransparent && Css1Background::Fly != nMode )
+ if( bTransparent && sw::Css1Background::Fly != nMode )
sOut += OStringToOUString(sCSS1_PV_transparent, RTL_TEXTENCODING_ASCII_US);
}
else
@@ -3257,16 +3192,16 @@ static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt,
aLink) + ")";
}
- if( pRepeat )
+ if( !pRepeat.empty() )
{
sOut += " " + OStringToOUString(pRepeat, RTL_TEXTENCODING_ASCII_US);
}
- if( pHori )
+ if( !pHori.empty() )
{
sOut += " " + OStringToOUString(pHori, RTL_TEXTENCODING_ASCII_US);
}
- if( pVert )
+ if( !pVert.empty() )
{
sOut += " " + OStringToOUString(pVert, RTL_TEXTENCODING_ASCII_US);
}
@@ -3276,27 +3211,28 @@ static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt,
}
if( !sOut.isEmpty() )
- rHTMLWrt.OutCSS1_Property( sCSS1_P_background, sOut );
+ {
+ rWrt.OutCSS1_Property(sCSS1_P_background, std::string_view(), &sOut,
+ nMode);
+ }
return rWrt;
}
-static void OutCSS1_SvxBorderLine( SwHTMLWriter& rHTMLWrt,
- const char *pProperty,
+static void OutCSS1_SvxBorderLine( SwHTMLWriter& rWrt,
+ std::string_view pProperty,
const SvxBorderLine *pLine )
{
if( !pLine || pLine->isEmpty() )
{
- rHTMLWrt.OutCSS1_PropertyAscii( pProperty, sCSS1_PV_none );
+ rWrt.OutCSS1_PropertyAscii( pProperty, sCSS1_PV_none );
return;
}
sal_Int32 nWidth = pLine->GetWidth();
OStringBuffer sOut;
- if( Application::GetDefaultDevice() &&
- nWidth <= Application::GetDefaultDevice()->PixelToLogic(
- Size( 1, 1 ), MapMode( MapUnit::MapTwip) ).Width() )
+ if( nWidth <= o3tl::convert(1, o3tl::Length::px, o3tl::Length::twip) )
{
// If the width is smaller than one pixel, then export as 1px
// so that Netscape and IE show the line.
@@ -3353,28 +3289,28 @@ static void OutCSS1_SvxBorderLine( SwHTMLWriter& rHTMLWrt,
// and also the color
sOut.append(GetCSS1_Color(pLine->GetColor()));
- rHTMLWrt.OutCSS1_PropertyAscii(pProperty, sOut.makeStringAndClear());
+ rWrt.OutCSS1_PropertyAscii(pProperty, sOut);
}
-Writer& OutCSS1_SvxBox( Writer& rWrt, const SfxPoolItem& rHt )
+SwHTMLWriter& OutCSS1_SvxBox( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
// Avoid interference between character and paragraph attributes
if( rHt.Which() < RES_CHRATR_END &&
- rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ rWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
return rWrt;
if( rHt.Which() == RES_CHRATR_BOX )
{
- if( rHTMLWrt.m_bTagOn )
+ constexpr std::string_view inline_block("inline-block");
+ if( rWrt.m_bTagOn )
{
// Inline-block to make the line height changing correspond to the character border
- rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_display, "inline-block");
+ rWrt.OutCSS1_PropertyAscii(sCSS1_P_display, inline_block);
}
else
{
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span, false );
+ if (!IgnorePropertyForReqIF(rWrt.mbReqIF, sCSS1_P_display, inline_block))
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false );
return rWrt;
}
}
@@ -3391,15 +3327,15 @@ Writer& OutCSS1_SvxBox( Writer& rWrt, const SfxPoolItem& rHt )
{
// all Lines are set and equal, or all Lines are not set
// => border : ...
- OutCSS1_SvxBorderLine( rHTMLWrt, sCSS1_P_border, pTop );
+ OutCSS1_SvxBorderLine( rWrt, sCSS1_P_border, pTop );
}
else
{
// otherwise export all Lines separately
- OutCSS1_SvxBorderLine( rHTMLWrt, sCSS1_P_border_top, pTop );
- OutCSS1_SvxBorderLine( rHTMLWrt, sCSS1_P_border_bottom, pBottom );
- OutCSS1_SvxBorderLine( rHTMLWrt, sCSS1_P_border_left, pLeft );
- OutCSS1_SvxBorderLine( rHTMLWrt, sCSS1_P_border_right, pRight );
+ OutCSS1_SvxBorderLine( rWrt, sCSS1_P_border_top, pTop );
+ OutCSS1_SvxBorderLine( rWrt, sCSS1_P_border_bottom, pBottom );
+ OutCSS1_SvxBorderLine( rWrt, sCSS1_P_border_left, pLeft );
+ OutCSS1_SvxBorderLine( rWrt, sCSS1_P_border_right, pRight );
}
tools::Long nTopDist = pTop ? rBoxItem.GetDistance( SvxBoxItemLine::TOP ) : 0;
@@ -3410,36 +3346,34 @@ Writer& OutCSS1_SvxBox( Writer& rWrt, const SfxPoolItem& rHt )
if( nTopDist == nBottomDist && nLeftDist == nRightDist )
{
OStringBuffer sVal;
- AddUnitPropertyValue(sVal, nTopDist, rHTMLWrt.GetCSS1Unit());
+ AddUnitPropertyValue(sVal, nTopDist, rWrt.GetCSS1Unit());
if( nTopDist != nLeftDist )
{
sVal.append(' ');
- AddUnitPropertyValue(sVal, nLeftDist, rHTMLWrt.GetCSS1Unit());
+ AddUnitPropertyValue(sVal, nLeftDist, rWrt.GetCSS1Unit());
}
- rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_padding, sVal.makeStringAndClear());
+ rWrt.OutCSS1_PropertyAscii(sCSS1_P_padding, sVal);
}
else
{
- rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_padding_top, nTopDist );
- rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_padding_bottom, nBottomDist );
- rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_padding_left, nLeftDist );
- rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_padding_right, nRightDist );
+ rWrt.OutCSS1_UnitProperty( sCSS1_P_padding_top, nTopDist );
+ rWrt.OutCSS1_UnitProperty( sCSS1_P_padding_bottom, nBottomDist );
+ rWrt.OutCSS1_UnitProperty( sCSS1_P_padding_left, nLeftDist );
+ rWrt.OutCSS1_UnitProperty( sCSS1_P_padding_right, nRightDist );
}
return rWrt;
}
-static Writer& OutCSS1_SvxFrameDirection( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutCSS1_SvxFrameDirection( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast< SwHTMLWriter& >( rWrt );
-
// Language will be exported rules only
- if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_TEMPLATE ) )
+ if( !rWrt.IsCSS1Source( CSS1_OUTMODE_TEMPLATE ) )
return rWrt;
SvxFrameDirection nDir =
static_cast< const SvxFrameDirectionItem& >( rHt ).GetValue();
- const char* pStr = nullptr;
+ std::string_view pStr;
switch( nDir )
{
case SvxFrameDirection::Horizontal_LR_TB:
@@ -3456,8 +3390,8 @@ static Writer& OutCSS1_SvxFrameDirection( Writer& rWrt, const SfxPoolItem& rHt )
default: break;
}
- if( pStr )
- rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_direction, pStr );
+ if( !pStr.empty() )
+ rWrt.OutCSS1_PropertyAscii( sCSS1_P_direction, pStr );
return rWrt;
}
@@ -3525,14 +3459,14 @@ SwAttrFnTab const aCSS1AttrFnTab = {
/* RES_TXTATR_CJK_RUBY */ nullptr,
/* RES_TXTATR_UNKNOWN_CONTAINER */ nullptr,
/* RES_TXTATR_INPUTFIELD */ nullptr,
+/* RES_TXTATR_CONTENTCONTROL */ nullptr,
/* RES_TXTATR_FIELD */ nullptr,
/* RES_TXTATR_FLYCNT */ nullptr,
/* RES_TXTATR_FTN */ nullptr,
/* RES_TXTATR_ANNOTATION */ nullptr,
-/* RES_TXTATR_DUMMY3 */ nullptr,
+/* RES_TXTATR_LINEBREAK */ nullptr,
/* RES_TXTATR_DUMMY1 */ nullptr, // Dummy:
-/* RES_TXTATR_DUMMY2 */ nullptr, // Dummy:
/* RES_PARATR_LINESPACING */ OutCSS1_SvxLineSpacing,
/* RES_PARATR_ADJUST */ OutCSS1_SvxAdjust,
@@ -3564,6 +3498,12 @@ SwAttrFnTab const aCSS1AttrFnTab = {
/* RES_FILL_ORDER */ nullptr,
/* RES_FRM_SIZE */ nullptr,
/* RES_PAPER_BIN */ nullptr,
+/* RES_MARGIN_FIRSTLINE */ OutCSS1_SvxFirstLineIndent,
+/* RES_MARGIN_TEXTLEFT */ OutCSS1_SvxTextLeftMargin,
+/* RES_MARGIN_RIGHT */ OutCSS1_SvxRightMargin,
+/* RES_MARGIN_LEFT */ nullptr,
+/* RES_MARGIN_GUTTER */ nullptr,
+/* RES_MARGIN_GUTTER_RIGHT */ nullptr,
/* RES_LR_SPACE */ OutCSS1_SvxLRSpace,
/* RES_UL_SPACE */ OutCSS1_SvxULSpace,
/* RES_PAGEDESC */ nullptr,
@@ -3596,6 +3536,7 @@ SwAttrFnTab const aCSS1AttrFnTab = {
/* RES_FRAMEDIR */ OutCSS1_SvxFrameDirection,
/* RES_HEADER_FOOTER_EAT_SPACING */ nullptr,
/* RES_ROW_SPLIT */ nullptr,
+/* RES_FLY_SPLIT */ nullptr,
/* RES_FOLLOW_TEXT_FLOW */ nullptr,
/* RES_COLLAPSING_BORDERS */ nullptr,
/* RES_WRAP_INFLUENCE_ON_OBJPOS */ nullptr,
@@ -3604,6 +3545,9 @@ SwAttrFnTab const aCSS1AttrFnTab = {
/* RES_FRMATR_CONDITIONAL_STYLE_NAME */ nullptr,
/* RES_FRMATR_GRABBAG */ nullptr,
/* RES_TEXT_VERT_ADJUST */ nullptr,
+/* RES_BACKGROUND_FULL_SIZE */ nullptr,
+/* RES_RTL_GUTTER */ nullptr,
+/* RES_DECORATIVE */ nullptr,
/* RES_GRFATR_MIRRORGRF */ nullptr,
/* RES_GRFATR_CROPGRF */ nullptr,
@@ -3617,8 +3561,6 @@ SwAttrFnTab const aCSS1AttrFnTab = {
/* RES_GRFATR_INVERT */ nullptr,
/* RES_GRFATR_TRANSPARENCY */ nullptr,
/* RES_GRFATR_DRWAMODE */ nullptr,
-/* RES_GRFATR_DUMMY1 */ nullptr,
-/* RES_GRFATR_DUMMY2 */ nullptr,
/* RES_GRFATR_DUMMY3 */ nullptr,
/* RES_GRFATR_DUMMY4 */ nullptr,
/* RES_GRFATR_DUMMY5 */ nullptr,
@@ -3631,33 +3573,28 @@ SwAttrFnTab const aCSS1AttrFnTab = {
static_assert(SAL_N_ELEMENTS(aCSS1AttrFnTab) == RES_BOXATR_END);
void SwHTMLWriter::OutCSS1_SfxItemSet( const SfxItemSet& rItemSet,
- bool bDeep )
+ bool bDeep, std::string_view rAdd )
{
// print ItemSet, including all attributes
Out_SfxItemSet( aCSS1AttrFnTab, *this, rItemSet, bDeep );
// some Attributes require special treatment
- const SfxPoolItem *pItem = nullptr;
// Underline, Overline, CrossedOut and Blink form together a CSS1-Property
// (doesn't work of course for Hints)
if( !IsCSS1Source(CSS1_OUTMODE_HINT) )
{
- const SvxUnderlineItem *pUnderlineItem = nullptr;
- if( SfxItemState::SET==rItemSet.GetItemState( RES_CHRATR_UNDERLINE, bDeep, &pItem ))
- pUnderlineItem = static_cast<const SvxUnderlineItem *>(pItem);
+ const SvxUnderlineItem *pUnderlineItem =
+ rItemSet.GetItemIfSet( RES_CHRATR_UNDERLINE, bDeep );
- const SvxOverlineItem *pOverlineItem = nullptr;
- if( SfxItemState::SET==rItemSet.GetItemState( RES_CHRATR_OVERLINE, bDeep, &pItem ))
- pOverlineItem = static_cast<const SvxOverlineItem *>(pItem);
+ const SvxOverlineItem *pOverlineItem =
+ rItemSet.GetItemIfSet( RES_CHRATR_OVERLINE, bDeep );
- const SvxCrossedOutItem *pCrossedOutItem = nullptr;
- if( SfxItemState::SET==rItemSet.GetItemState( RES_CHRATR_CROSSEDOUT, bDeep, &pItem ))
- pCrossedOutItem = static_cast<const SvxCrossedOutItem *>(pItem);
+ const SvxCrossedOutItem *pCrossedOutItem =
+ rItemSet.GetItemIfSet( RES_CHRATR_CROSSEDOUT, bDeep );
- const SvxBlinkItem *pBlinkItem = nullptr;
- if( SfxItemState::SET==rItemSet.GetItemState( RES_CHRATR_BLINK, bDeep, &pItem ))
- pBlinkItem = static_cast<const SvxBlinkItem *>(pItem);
+ const SvxBlinkItem *pBlinkItem =
+ rItemSet.GetItemIfSet( RES_CHRATR_BLINK, bDeep );
if( pUnderlineItem || pOverlineItem || pCrossedOutItem || pBlinkItem )
OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( *this, pUnderlineItem,
@@ -3668,6 +3605,20 @@ void SwHTMLWriter::OutCSS1_SfxItemSet( const SfxItemSet& rItemSet,
OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( *this, rItemSet, bDeep );
}
+ if (!rAdd.empty())
+ {
+ for (std::size_t index = 0; index != std::string_view::npos;)
+ {
+ std::string_view attr = o3tl::trim(o3tl::getToken(rAdd, ':', index));
+ assert(!attr.empty());
+ assert(index != std::string_view::npos);
+
+ std::string_view val = o3tl::trim(o3tl::getToken(rAdd, ':', index));
+ assert(!val.empty());
+ OutCSS1_PropertyAscii(attr, val);
+ }
+ }
+
if( m_bFirstCSS1Property )
return;
@@ -3689,35 +3640,31 @@ void SwHTMLWriter::OutCSS1_SfxItemSet( const SfxItemSet& rItemSet,
break;
}
if (!sOut.isEmpty())
- Strm().WriteOString( sOut.makeStringAndClear() );
+ Strm().WriteOString( sOut );
}
-Writer& OutCSS1_HintSpanTag( Writer& rWrt, const SfxPoolItem& rHt )
+SwHTMLWriter& OutCSS1_HintSpanTag( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_SPAN_TAG |
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_SPAN_TAG |
CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_HINT, nullptr );
Out( aCSS1AttrFnTab, rHt, rWrt );
- if( !rHTMLWrt.m_bFirstCSS1Property && rHTMLWrt.m_bTagOn )
- rWrt.Strm().WriteCharPtr( sCSS1_span_tag_end );
+ if( !rWrt.m_bFirstCSS1Property && rWrt.m_bTagOn )
+ rWrt.Strm().WriteOString( sCSS1_span_tag_end );
return rWrt;
}
-Writer& OutCSS1_HintStyleOpt( Writer& rWrt, const SfxPoolItem& rHt )
+SwHTMLWriter& OutCSS1_HintStyleOpt( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
- SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_STYLE_OPT_ON |
+ SwCSS1OutMode aMode( rWrt, CSS1_OUTMODE_STYLE_OPT_ON |
CSS1_OUTMODE_ENCODE|
CSS1_OUTMODE_HINT, nullptr );
Out( aCSS1AttrFnTab, rHt, rWrt );
- if( !rHTMLWrt.m_bFirstCSS1Property )
+ if( !rWrt.m_bFirstCSS1Property )
rWrt.Strm().WriteChar( '\"' );
return rWrt;
diff --git a/sw/source/filter/html/css1kywd.cxx b/sw/source/filter/html/css1kywd.cxx
deleted file mode 100644
index af8c5392a765..000000000000
--- a/sw/source/filter/html/css1kywd.cxx
+++ /dev/null
@@ -1,214 +0,0 @@
-/* -*- 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 "css1kywd.hxx"
-
-const char* const sCSS_mimetype = "text/css";
-
-const char* const sCSS1_page = "page";
-//const char* const sCSS1_media = "media";
-
-const char* const sCSS1_link = "link";
-const char* const sCSS1_visited = "visited";
-const char* const sCSS1_first_letter = "first-letter";
-
-const char* const sCSS1_left = "left";
-const char* const sCSS1_right = "right";
-const char* const sCSS1_first = "first";
-
-const char* const sCSS1_url = "url";
-
-const char* const sCSS1_UNIT_pt = "pt";
-const char* const sCSS1_UNIT_mm = "mm";
-const char* const sCSS1_UNIT_cm = "cm";
-const char* const sCSS1_UNIT_pc = "pc";
-const char* const sCSS1_UNIT_inch = "in";
-const char* const sCSS1_UNIT_px = "px";
-
-// Strings for font properties
-
-const char* const sCSS1_P_font_family = "font-family";
-
-const char* const sCSS1_PV_serif = "serif";
-const char* const sCSS1_PV_sans_serif = "sans-serif";
-const char* const sCSS1_PV_cursive = "cursive";
-const char* const sCSS1_PV_fantasy = "fantasy";
-const char* const sCSS1_PV_monospace = "monospace";
-
-const char* const sCSS1_P_font_style = "font-style";
-
-const char* const sCSS1_PV_normal = "normal";
-const char* const sCSS1_PV_italic = "italic";
-const char* const sCSS1_PV_oblique = "oblique";
-
-const char* const sCSS1_P_font_variant = "font-variant";
-
-//const char* const sCSS1_PV_normal = "normal";
-const char* const sCSS1_PV_small_caps = "small-caps";
-
-const char* const sCSS1_P_font_weight = "font-weight";
-
-const char* const sCSS1_PV_extra_light = "extra-light";
-const char* const sCSS1_PV_light = "light";
-const char* const sCSS1_PV_demi_light = "demi-light";
-//const char* const sCSS1_PV_medium = "medium";
-const char* const sCSS1_PV_demi_bold = "demi-bold";
-const char* const sCSS1_PV_bold = "bold";
-const char* const sCSS1_PV_extra_bold = "extra-bold";
-
-const char* const sCSS1_P_text_transform = "text-transform";
-
-const char* const sCSS1_PV_capitalize = "capitalize";
-const char* const sCSS1_PV_uppercase = "uppercase";
-const char* const sCSS1_PV_lowercase = "lowercase";
-
-const char* const sCSS1_P_font_size = "font-size";
-
-const char* const sCSS1_P_font = "font";
-
-// Strings for color and background properties
-
-const char* const sCSS1_P_color = "color";
-
-const char* const sCSS1_P_background = "background";
-const char* const sCSS1_P_background_color = "background-color";
-
-const char* const sCSS1_PV_transparent = "transparent";
-
-const char* const sCSS1_PV_repeat = "repeat";
-const char* const sCSS1_PV_no_repeat = "no-repeat";
-
-const char* const sCSS1_PV_top = "top";
-const char* const sCSS1_PV_middle = "middle";
-const char* const sCSS1_PV_bottom = "bottom";
-
-const char* const sCSS1_PV_scroll = "scroll";
-
-// Strings for text properties
-
-const char* const sCSS1_P_letter_spacing = "letter-spacing";
-
-const char* const sCSS1_P_text_decoration = "text-decoration";
-
-const char* const sCSS1_PV_none = "none";
-const char* const sCSS1_PV_underline = "underline";
-const char* const sCSS1_PV_overline = "overline";
-const char* const sCSS1_PV_line_through = "line-through";
-const char* const sCSS1_PV_blink = "blink";
-
-const char* const sCSS1_P_text_align = "text-align";
-
-const char* const sCSS1_PV_left = "left";
-const char* const sCSS1_PV_center = "center";
-const char* const sCSS1_PV_right = "right";
-const char* const sCSS1_PV_justify = "justify";
-
-const char* const sCSS1_P_text_indent = "text-indent";
-
-const char* const sCSS1_P_line_height = "line-height";
-const char* const sCSS1_P_list_style_type = "list-style-type";
-
-// Strings for box properties
-
-const char* const sCSS1_P_margin_left = "margin-left";
-const char* const sCSS1_P_margin_right = "margin-right";
-const char* const sCSS1_P_margin_top = "margin-top";
-const char* const sCSS1_P_margin_bottom = "margin-bottom";
-const char* const sCSS1_P_margin = "margin";
-
-const char* const sCSS1_P_padding_top = "padding-top";
-const char* const sCSS1_P_padding_bottom = "padding-bottom";
-const char* const sCSS1_P_padding_left = "padding-left";
-const char* const sCSS1_P_padding_right = "padding-right";
-const char* const sCSS1_P_padding = "padding";
-
-const char* const sCSS1_PV_auto = "auto";
-
-const char* const sCSS1_P_border_left_width = "border-left-width";
-const char* const sCSS1_P_border_right_width = "border-right-width";
-const char* const sCSS1_P_border_top_width = "border-top-width";
-const char* const sCSS1_P_border_bottom_width = "border-bottom-width";
-const char* const sCSS1_P_border_width = "border-width";
-const char* const sCSS1_P_border_color = "border-color";
-const char* const sCSS1_P_border_style = "border-style";
-const char* const sCSS1_P_border_left = "border-left";
-const char* const sCSS1_P_border_right = "border-right";
-const char* const sCSS1_P_border_top = "border-top";
-const char* const sCSS1_P_border_bottom = "border-bottom";
-const char* const sCSS1_P_border = "border";
-
-//const char* const sCSS1_PV_none = "none";
-const char* const sCSS1_PV_dotted = "dotted";
-const char* const sCSS1_PV_dashed = "dashed";
-const char* const sCSS1_PV_solid = "solid";
-const char* const sCSS1_PV_double = "double";
-const char* const sCSS1_PV_groove = "groove";
-const char* const sCSS1_PV_ridge = "ridge";
-const char* const sCSS1_PV_inset = "inset";
-const char* const sCSS1_PV_outset = "outset";
-
-const char* const sCSS1_P_width = "width";
-const char* const sCSS1_P_max_width = "max-width";
-
-const char* const sCSS1_P_height = "height";
-
-const char* const sCSS1_P_float = "float";
-
-const char* const sCSS1_P_column_count = "column-count";
-
-// Strings for positioning
-
-const char* const sCSS1_P_position = "position";
-
-const char* const sCSS1_PV_absolute = "absolute";
-
-const char* const sCSS1_P_left = "left";
-
-const char* const sCSS1_P_top = "top";
-
-// Strings for printing extensions
-
-const char* const sCSS1_P_page_break_before = "page-break-before";
-const char* const sCSS1_P_page_break_after = "page-break-after";
-const char* const sCSS1_P_page_break_inside = "page-break-inside";
-const char* const sCSS1_P_size = "size";
-const char* const sCSS1_P_widows = "widows";
-const char* const sCSS1_P_visibility = "visibility";
-const char* const sCSS1_P_orphans = "orphans";
-//const char* const sCSS1_P_marks = "marks";
-
-const char* const sCSS1_PV_always = "always";
-const char* const sCSS1_PV_avoid = "avoid";
-
-const char* const sCSS1_PV_portrait = "portrait";
-const char* const sCSS1_PV_landscape = "landscape";
-
-//const char* const sCSS1_PV_crop = "crop";
-//const char* const sCSS1_PV_cross = "cross";
-
-const char* const sCSS1_P_so_language = "so-language";
-
-const char* const sCSS1_P_direction = "direction";
-const char* const sCSS1_PV_ltr = "ltr";
-const char* const sCSS1_PV_rtl = "rtl";
-const char* const sCSS1_PV_inherit = "inherit";
-
-const char* const sCSS1_P_display = "display";
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/css1kywd.hxx b/sw/source/filter/html/css1kywd.hxx
index 443af7e1ae91..42ad28da9259 100644
--- a/sw/source/filter/html/css1kywd.hxx
+++ b/sw/source/filter/html/css1kywd.hxx
@@ -20,196 +20,204 @@
#ifndef INCLUDED_SW_SOURCE_FILTER_HTML_CSS1KYWD_HXX
#define INCLUDED_SW_SOURCE_FILTER_HTML_CSS1KYWD_HXX
-extern const char* const sCSS_mimetype;
+#include <sal/config.h>
-extern const char* const sCSS1_page;
+#include <string_view>
-extern const char* const sCSS1_link;
-extern const char* const sCSS1_visited;
-extern const char* const sCSS1_first_letter;
+constexpr inline std::string_view sCSS_mimetype = "text/css";
-extern const char* const sCSS1_left;
-extern const char* const sCSS1_right;
-extern const char* const sCSS1_first;
+constexpr inline std::string_view sCSS1_page = "page";
+//constexpr inline std::string_view sCSS1_media = "media";
-extern const char* const sCSS1_url;
+constexpr inline std::string_view sCSS1_link = "link";
+constexpr inline std::string_view sCSS1_visited = "visited";
+constexpr inline std::string_view sCSS1_first_letter = "first-letter";
-extern const char* const sCSS1_UNIT_pt;
-extern const char* const sCSS1_UNIT_mm;
-extern const char* const sCSS1_UNIT_cm;
-extern const char* const sCSS1_UNIT_pc;
-extern const char* const sCSS1_UNIT_inch;
-extern const char* const sCSS1_UNIT_px;
+constexpr inline std::string_view sCSS1_left = "left";
+constexpr inline std::string_view sCSS1_right = "right";
+constexpr inline std::string_view sCSS1_first = "first";
+
+constexpr inline std::string_view sCSS1_url = "url";
+
+constexpr inline std::string_view sCSS1_UNIT_pt = "pt";
+constexpr inline std::string_view sCSS1_UNIT_mm = "mm";
+constexpr inline std::string_view sCSS1_UNIT_cm = "cm";
+constexpr inline std::string_view sCSS1_UNIT_pc = "pc";
+constexpr inline std::string_view sCSS1_UNIT_inch = "in";
+constexpr inline std::string_view sCSS1_UNIT_px = "px";
// Strings for font properties
-extern const char* const sCSS1_P_font_family;
+constexpr inline std::string_view sCSS1_P_font_family = "font-family";
-extern const char* const sCSS1_PV_serif;
-extern const char* const sCSS1_PV_sans_serif;
-extern const char* const sCSS1_PV_cursive;
-extern const char* const sCSS1_PV_fantasy;
-extern const char* const sCSS1_PV_monospace;
+constexpr inline std::string_view sCSS1_PV_serif = "serif";
+constexpr inline std::string_view sCSS1_PV_sans_serif = "sans-serif";
+constexpr inline std::string_view sCSS1_PV_cursive = "cursive";
+constexpr inline std::string_view sCSS1_PV_fantasy = "fantasy";
+constexpr inline std::string_view sCSS1_PV_monospace = "monospace";
-extern const char* const sCSS1_P_font_style;
+constexpr inline std::string_view sCSS1_P_font_style = "font-style";
-extern const char* const sCSS1_PV_normal;
-extern const char* const sCSS1_PV_italic;
-extern const char* const sCSS1_PV_oblique;
+constexpr inline std::string_view sCSS1_PV_normal = "normal";
+constexpr inline std::string_view sCSS1_PV_italic = "italic";
+constexpr inline std::string_view sCSS1_PV_oblique = "oblique";
-extern const char* const sCSS1_P_font_variant;
+constexpr inline std::string_view sCSS1_P_font_variant = "font-variant";
-//extern const char* const sCSS1_PV_normal;
-extern const char* const sCSS1_PV_small_caps;
+//constexpr inline std::string_view sCSS1_PV_normal = "normal";
+constexpr inline std::string_view sCSS1_PV_small_caps = "small-caps";
-extern const char* const sCSS1_P_text_transform;
+constexpr inline std::string_view sCSS1_P_text_transform = "text-transform";
-extern const char* const sCSS1_PV_capitalize;
-extern const char* const sCSS1_PV_uppercase;
-extern const char* const sCSS1_PV_lowercase;
+constexpr inline std::string_view sCSS1_PV_capitalize = "capitalize";
+constexpr inline std::string_view sCSS1_PV_uppercase = "uppercase";
+constexpr inline std::string_view sCSS1_PV_lowercase = "lowercase";
-extern const char* const sCSS1_P_font_weight;
+constexpr inline std::string_view sCSS1_P_font_weight = "font-weight";
-extern const char* const sCSS1_PV_extra_light;
-extern const char* const sCSS1_PV_light;
-extern const char* const sCSS1_PV_demi_light;
-//extern const char* const sCSS1_PV_medium;
-extern const char* const sCSS1_PV_demi_bold;
-extern const char* const sCSS1_PV_bold;
-extern const char* const sCSS1_PV_extra_bold;
+constexpr inline std::string_view sCSS1_PV_extra_light = "extra-light";
+constexpr inline std::string_view sCSS1_PV_light = "light";
+constexpr inline std::string_view sCSS1_PV_demi_light = "demi-light";
+//constexpr inline std::string_view sCSS1_PV_medium = "medium";
+constexpr inline std::string_view sCSS1_PV_demi_bold = "demi-bold";
+constexpr inline std::string_view sCSS1_PV_bold = "bold";
+constexpr inline std::string_view sCSS1_PV_extra_bold = "extra-bold";
-extern const char* const sCSS1_P_font_size;
+constexpr inline std::string_view sCSS1_P_font_size = "font-size";
-extern const char* const sCSS1_P_font;
+constexpr inline std::string_view sCSS1_P_font = "font";
// Strings for color and background properties
-extern const char* const sCSS1_P_color;
+constexpr inline std::string_view sCSS1_P_color = "color";
-extern const char* const sCSS1_P_background;
-extern const char* const sCSS1_P_background_color;
+constexpr inline std::string_view sCSS1_P_background = "background";
+constexpr inline std::string_view sCSS1_P_background_color = "background-color";
-extern const char* const sCSS1_PV_transparent;
+constexpr inline std::string_view sCSS1_PV_transparent = "transparent";
-extern const char* const sCSS1_PV_repeat;
-extern const char* const sCSS1_PV_no_repeat;
+constexpr inline std::string_view sCSS1_PV_repeat = "repeat";
+constexpr inline std::string_view sCSS1_PV_no_repeat = "no-repeat";
-extern const char* const sCSS1_PV_top;
-extern const char* const sCSS1_PV_middle;
-extern const char* const sCSS1_PV_bottom;
+constexpr inline std::string_view sCSS1_PV_top = "top";
+constexpr inline std::string_view sCSS1_PV_middle = "middle";
+constexpr inline std::string_view sCSS1_PV_bottom = "bottom";
-extern const char* const sCSS1_PV_scroll;
+constexpr inline std::string_view sCSS1_PV_scroll = "scroll";
// Strings for text properties
-extern const char* const sCSS1_P_letter_spacing;
+constexpr inline std::string_view sCSS1_P_letter_spacing = "letter-spacing";
-extern const char* const sCSS1_P_text_decoration;
+constexpr inline std::string_view sCSS1_P_text_decoration = "text-decoration";
-extern const char* const sCSS1_PV_none;
-extern const char* const sCSS1_PV_underline;
-extern const char* const sCSS1_PV_overline;
-extern const char* const sCSS1_PV_line_through;
-extern const char* const sCSS1_PV_blink;
+constexpr inline std::string_view sCSS1_PV_none = "none";
+constexpr inline std::string_view sCSS1_PV_underline = "underline";
+constexpr inline std::string_view sCSS1_PV_overline = "overline";
+constexpr inline std::string_view sCSS1_PV_line_through = "line-through";
+constexpr inline std::string_view sCSS1_PV_blink = "blink";
-extern const char* const sCSS1_P_text_align;
+constexpr inline std::string_view sCSS1_P_text_align = "text-align";
-extern const char* const sCSS1_PV_left;
-extern const char* const sCSS1_PV_center;
-extern const char* const sCSS1_PV_right;
-extern const char* const sCSS1_PV_justify;
+constexpr inline std::string_view sCSS1_PV_left = "left";
+constexpr inline std::string_view sCSS1_PV_center = "center";
+constexpr inline std::string_view sCSS1_PV_right = "right";
+constexpr inline std::string_view sCSS1_PV_justify = "justify";
-extern const char* const sCSS1_P_text_indent;
+constexpr inline std::string_view sCSS1_P_text_indent = "text-indent";
-extern const char* const sCSS1_P_line_height;
+constexpr inline std::string_view sCSS1_P_line_height = "line-height";
-extern const char* const sCSS1_P_list_style_type;
+constexpr inline std::string_view sCSS1_P_list_style_type = "list-style-type";
// Strings for box properties
-extern const char* const sCSS1_P_margin_left;
-extern const char* const sCSS1_P_margin_right;
-extern const char* const sCSS1_P_margin_top;
-extern const char* const sCSS1_P_margin_bottom;
-extern const char* const sCSS1_P_margin;
-
-extern const char* const sCSS1_P_padding_top;
-extern const char* const sCSS1_P_padding_bottom;
-extern const char* const sCSS1_P_padding_left;
-extern const char* const sCSS1_P_padding_right;
-extern const char* const sCSS1_P_padding;
-
-extern const char* const sCSS1_PV_auto;
-
-extern const char* const sCSS1_P_border_left_width;
-extern const char* const sCSS1_P_border_right_width;
-extern const char* const sCSS1_P_border_top_width;
-extern const char* const sCSS1_P_border_bottom_width;
-extern const char* const sCSS1_P_border_width;
-extern const char* const sCSS1_P_border_color;
-extern const char* const sCSS1_P_border_style;
-extern const char* const sCSS1_P_border_left;
-extern const char* const sCSS1_P_border_right;
-extern const char* const sCSS1_P_border_top;
-extern const char* const sCSS1_P_border_bottom;
-extern const char* const sCSS1_P_border;
-
-//extern const char* const sCSS1_PV_none;
-extern const char* const sCSS1_PV_dotted;
-extern const char* const sCSS1_PV_dashed;
-extern const char* const sCSS1_PV_solid;
-extern const char* const sCSS1_PV_double;
-extern const char* const sCSS1_PV_groove;
-extern const char* const sCSS1_PV_ridge;
-extern const char* const sCSS1_PV_inset;
-extern const char* const sCSS1_PV_outset;
-
-extern const char* const sCSS1_P_width;
-extern const char* const sCSS1_P_max_width;
-
-extern const char* const sCSS1_P_height;
-
-extern const char* const sCSS1_P_float;
-
-extern const char* const sCSS1_P_column_count;
+constexpr inline std::string_view sCSS1_P_margin_left = "margin-left";
+constexpr inline std::string_view sCSS1_P_margin_right = "margin-right";
+constexpr inline std::string_view sCSS1_P_margin_top = "margin-top";
+constexpr inline std::string_view sCSS1_P_margin_bottom = "margin-bottom";
+constexpr inline std::string_view sCSS1_P_margin = "margin";
+
+constexpr inline std::string_view sCSS1_P_padding_top = "padding-top";
+constexpr inline std::string_view sCSS1_P_padding_bottom = "padding-bottom";
+constexpr inline std::string_view sCSS1_P_padding_left = "padding-left";
+constexpr inline std::string_view sCSS1_P_padding_right = "padding-right";
+constexpr inline std::string_view sCSS1_P_padding = "padding";
+
+constexpr inline std::string_view sCSS1_PV_auto = "auto";
+
+constexpr inline std::string_view sCSS1_P_border_left_width = "border-left-width";
+constexpr inline std::string_view sCSS1_P_border_right_width = "border-right-width";
+constexpr inline std::string_view sCSS1_P_border_top_width = "border-top-width";
+constexpr inline std::string_view sCSS1_P_border_bottom_width = "border-bottom-width";
+constexpr inline std::string_view sCSS1_P_border_width = "border-width";
+constexpr inline std::string_view sCSS1_P_border_color = "border-color";
+constexpr inline std::string_view sCSS1_P_border_style = "border-style";
+constexpr inline std::string_view sCSS1_P_border_left = "border-left";
+constexpr inline std::string_view sCSS1_P_border_right = "border-right";
+constexpr inline std::string_view sCSS1_P_border_top = "border-top";
+constexpr inline std::string_view sCSS1_P_border_bottom = "border-bottom";
+constexpr inline std::string_view sCSS1_P_border = "border";
+
+//constexpr inline std::string_view sCSS1_PV_none = "none";
+constexpr inline std::string_view sCSS1_PV_dotted = "dotted";
+constexpr inline std::string_view sCSS1_PV_dashed = "dashed";
+constexpr inline std::string_view sCSS1_PV_solid = "solid";
+constexpr inline std::string_view sCSS1_PV_double = "double";
+constexpr inline std::string_view sCSS1_PV_groove = "groove";
+constexpr inline std::string_view sCSS1_PV_ridge = "ridge";
+constexpr inline std::string_view sCSS1_PV_inset = "inset";
+constexpr inline std::string_view sCSS1_PV_outset = "outset";
+
+constexpr inline std::string_view sCSS1_P_width = "width";
+constexpr inline std::string_view sCSS1_P_max_width = "max-width";
+
+constexpr inline std::string_view sCSS1_P_height = "height";
+
+constexpr inline std::string_view sCSS1_P_float = "float";
+
+constexpr inline std::string_view sCSS1_P_column_count = "column-count";
+constexpr inline std::string_view sCSS1_P_dir = "dir";
// Strings for positioning
-extern const char* const sCSS1_P_position;
+constexpr inline std::string_view sCSS1_P_position = "position";
-extern const char* const sCSS1_PV_absolute;
+constexpr inline std::string_view sCSS1_PV_absolute = "absolute";
-extern const char* const sCSS1_P_left;
+constexpr inline std::string_view sCSS1_P_left = "left";
-extern const char* const sCSS1_P_top;
+constexpr inline std::string_view sCSS1_P_top = "top";
// Strings for printing extensions
-extern const char* const sCSS1_P_page_break_before;
-extern const char* const sCSS1_P_page_break_after;
-extern const char* const sCSS1_P_page_break_inside;
-extern const char* const sCSS1_P_size;
-extern const char* const sCSS1_P_widows;
-extern const char* const sCSS1_P_visibility;
-extern const char* const sCSS1_P_orphans;
-//extern const char* const sCSS1_P_marks;
+constexpr inline std::string_view sCSS1_P_page_break_before = "page-break-before";
+constexpr inline std::string_view sCSS1_P_page_break_after = "page-break-after";
+constexpr inline std::string_view sCSS1_P_page_break_inside = "page-break-inside";
+constexpr inline std::string_view sCSS1_P_size = "size";
+constexpr inline std::string_view sCSS1_P_widows = "widows";
+constexpr inline std::string_view sCSS1_P_visibility = "visibility";
+constexpr inline std::string_view sCSS1_P_orphans = "orphans";
+//constexpr inline std::string_view sCSS1_P_marks = "marks";
+
+constexpr inline std::string_view sCSS1_PV_always = "always";
+constexpr inline std::string_view sCSS1_PV_avoid = "avoid";
-extern const char* const sCSS1_PV_always;
-extern const char* const sCSS1_PV_avoid;
+constexpr inline std::string_view sCSS1_PV_portrait = "portrait";
+constexpr inline std::string_view sCSS1_PV_landscape = "landscape";
-extern const char* const sCSS1_PV_portrait;
-extern const char* const sCSS1_PV_landscape;
+//constexpr inline std::string_view sCSS1_PV_crop = "crop";
+//constexpr inline std::string_view sCSS1_PV_cross = "cross";
-//extern const char* const sCSS1_PV_crop;
-//extern const char* const sCSS1_PV_cross;
+constexpr inline std::string_view sCSS1_P_so_language = "so-language";
+constexpr inline std::string_view sCSS1_P_direction = "direction";
+constexpr inline std::string_view sCSS1_PV_ltr = "ltr";
+constexpr inline std::string_view sCSS1_PV_rtl = "rtl";
+constexpr inline std::string_view sCSS1_PV_inherit = "inherit";
-extern const char* const sCSS1_P_so_language;
-extern const char* const sCSS1_P_direction;
-extern const char* const sCSS1_PV_ltr;
-extern const char* const sCSS1_PV_rtl;
-extern const char* const sCSS1_PV_inherit;
+constexpr inline std::string_view sCSS1_P_display = "display";
-extern const char* const sCSS1_P_display;
+constexpr inline std::string_view sCSS1_white_space = "white-space";
#endif
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index cdbfae284ff8..f298f93dc5b2 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -76,6 +76,7 @@
#include <deque>
#include <svtools/HtmlWriter.hxx>
+#include <o3tl/string_view.hxx>
#include <memory>
#include <algorithm>
@@ -90,9 +91,9 @@ HTMLOutEvent const aAnchorEventTable[] =
{ nullptr, nullptr, SvMacroItemId::NONE }
};
-static Writer& OutHTML_SvxAdjust( Writer& rWrt, const SfxPoolItem& rHt );
+static SwHTMLWriter& OutHTML_SvxAdjust( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
-sal_uInt16 SwHTMLWriter::GetDefListLvl( const OUString& rNm, sal_uInt16 nPoolId )
+sal_uInt16 SwHTMLWriter::GetDefListLvl( std::u16string_view rNm, sal_uInt16 nPoolId )
{
if( nPoolId == RES_POOLCOLL_HTML_DD )
{
@@ -104,14 +105,14 @@ sal_uInt16 SwHTMLWriter::GetDefListLvl( const OUString& rNm, sal_uInt16 nPoolId
}
OUString sDTDD = OOO_STRING_SVTOOLS_HTML_dt " ";
- if( rNm.startsWith(sDTDD) )
+ if( o3tl::starts_with(rNm, sDTDD) )
// DefinitionList - term
- return static_cast<sal_uInt16>(rNm.copy( sDTDD.getLength() ).toInt32()) | HTML_DLCOLL_DT;
+ return o3tl::narrowing<sal_uInt16>(o3tl::toInt32(rNm.substr( sDTDD.getLength() ))) | HTML_DLCOLL_DT;
sDTDD = OOO_STRING_SVTOOLS_HTML_dd " ";
- if( rNm.startsWith(sDTDD) )
+ if( o3tl::starts_with(rNm, sDTDD) )
// DefinitionList - definition
- return static_cast<sal_uInt16>(rNm.copy( sDTDD.getLength() ).toInt32()) | HTML_DLCOLL_DD;
+ return o3tl::narrowing<sal_uInt16>(o3tl::toInt32(rNm.substr( sDTDD.getLength() ))) | HTML_DLCOLL_DD;
return 0;
}
@@ -132,11 +133,12 @@ void SwHTMLWriter::OutAndSetDefList( sal_uInt16 nNewLvl )
// write according to the level difference
for( sal_uInt16 i=m_nDefListLvl; i<nNewLvl; i++ )
{
- if( m_bLFPossible )
+ if (IsLFPossible())
OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_deflist );
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_deflist) );
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_dd) );
IncIndentLevel();
- m_bLFPossible = true;
+ SetLFPossible(true);
}
}
else if( m_nDefListLvl > nNewLvl )
@@ -144,10 +146,11 @@ void SwHTMLWriter::OutAndSetDefList( sal_uInt16 nNewLvl )
for( sal_uInt16 i=nNewLvl ; i < m_nDefListLvl; i++ )
{
DecIndentLevel();
- if( m_bLFPossible )
+ if (IsLFPossible())
OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_deflist, false );
- m_bLFPossible = true;
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_dd), false );
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_deflist), false );
+ SetLFPossible(true);
}
}
@@ -158,8 +161,8 @@ void SwHTMLWriter::ChangeParaToken( HtmlTokenId nNew )
{
if( nNew != m_nLastParaToken && HtmlTokenId::PREFORMTXT_ON == m_nLastParaToken )
{
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_preformtxt, false );
- m_bLFPossible = true;
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_preformtxt), false );
+ SetLFPossible(true);
}
m_nLastParaToken = nNew;
}
@@ -201,7 +204,7 @@ namespace {
struct SwHTMLTextCollOutputInfo
{
OString aToken; // End token to be output
- std::unique_ptr<SfxItemSet> pItemSet; // hard attribute
+ std::optional<SfxItemSet> moItemSet; // hard attribute
bool bInNumberBulletList; // in an enumerated list;
bool bParaPossible; // a </P> may be output additionally
@@ -291,22 +294,22 @@ SwHTMLFormatInfo::SwHTMLFormatInfo( const SwFormat *pF, SwDoc *pDoc, SwDoc *pTem
if( pReferenceFormat || nDeep==0 )
{
- pItemSet.reset( new SfxItemSet( *pFormat->GetAttrSet().GetPool(),
- pFormat->GetAttrSet().GetRanges() ) );
+ moItemSet.emplace( *pFormat->GetAttrSet().GetPool(),
+ pFormat->GetAttrSet().GetRanges() );
// if the differences to a different style are supposed to be
// written, hard attribute is necessary. This is always true
// for styles that are not derived from HTML-tag styles.
- pItemSet->Set( pFormat->GetAttrSet() );
+ moItemSet->Set( pFormat->GetAttrSet() );
if( pReferenceFormat )
- SwHTMLWriter::SubtractItemSet( *pItemSet, pReferenceFormat->GetAttrSet(), true );
+ SwHTMLWriter::SubtractItemSet( *moItemSet, pReferenceFormat->GetAttrSet(), true );
// delete ItemSet that is empty straight away. This will save work
// later on
- if( !pItemSet->Count() )
+ if( !moItemSet->Count() )
{
- pItemSet.reset();
+ moItemSet.reset();
}
}
@@ -355,10 +358,10 @@ SwHTMLFormatInfo::SwHTMLFormatInfo( const SwFormat *pF, SwDoc *pDoc, SwDoc *pTem
const SfxPoolItem& rSet = pFormat->GetFormatAttr( aWhichIds[nSet][i] );
if( rSet != rRef )
{
- if( !pItemSet )
- pItemSet.reset( new SfxItemSet( *pFormat->GetAttrSet().GetPool(),
- pFormat->GetAttrSet().GetRanges() ) );
- pItemSet->Put( rSet );
+ if( !moItemSet )
+ moItemSet.emplace( *pFormat->GetAttrSet().GetPool(),
+ pFormat->GetAttrSet().GetRanges() );
+ moItemSet->Put( rSet );
}
}
}
@@ -366,11 +369,15 @@ SwHTMLFormatInfo::SwHTMLFormatInfo( const SwFormat *pF, SwDoc *pDoc, SwDoc *pTem
// remember all the different default spacings from the style or
// the comparison style.
- const SvxLRSpaceItem &rLRSpace =
- (pReferenceFormat ? pReferenceFormat : pFormat)->GetLRSpace();
- nLeftMargin = rLRSpace.GetTextLeft();
- nRightMargin = rLRSpace.GetRight();
- nFirstLineIndent = rLRSpace.GetTextFirstLineOffset();
+ SvxFirstLineIndentItem const& rFirstLine(
+ (pReferenceFormat ? pReferenceFormat : pFormat)->GetFirstLineIndent());
+ SvxTextLeftMarginItem const& rTextLeftMargin(
+ (pReferenceFormat ? pReferenceFormat : pFormat)->GetTextLeftMargin());
+ SvxRightMarginItem const& rRightMargin(
+ (pReferenceFormat ? pReferenceFormat : pFormat)->GetRightMargin());
+ nLeftMargin = rTextLeftMargin.GetTextLeft();
+ nRightMargin = rRightMargin.GetRight();
+ nFirstLineIndent = rFirstLine.GetTextFirstLineOffset();
const SvxULSpaceItem &rULSpace =
(pReferenceFormat ? pReferenceFormat : pFormat)->GetULSpace();
@@ -378,34 +385,32 @@ SwHTMLFormatInfo::SwHTMLFormatInfo( const SwFormat *pF, SwDoc *pDoc, SwDoc *pTem
nBottomMargin = rULSpace.GetLower();
// export language if it differs from the default language
- sal_uInt16 nWhichId =
+ TypedWhichId<SvxLanguageItem> nWhichId =
SwHTMLWriter::GetLangWhichIdFromScript( nCSS1Script );
- const SvxLanguageItem& rLang =
- static_cast<const SvxLanguageItem&>(pFormat->GetFormatAttr( nWhichId ));
+ const SvxLanguageItem& rLang = pFormat->GetFormatAttr( nWhichId );
LanguageType eLang = rLang.GetLanguage();
if( eLang != eDfltLang )
{
- if( !pItemSet )
- pItemSet.reset( new SfxItemSet( *pFormat->GetAttrSet().GetPool(),
- pFormat->GetAttrSet().GetRanges() ) );
- pItemSet->Put( rLang );
+ if( !moItemSet )
+ moItemSet.emplace( *pFormat->GetAttrSet().GetPool(),
+ pFormat->GetAttrSet().GetRanges() );
+ moItemSet->Put( rLang );
}
- static const sal_uInt16 aWhichIds[3] =
+ static const TypedWhichId<SvxLanguageItem> aWhichIds[3] =
{ RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
RES_CHRATR_CTL_LANGUAGE };
- for(sal_uInt16 i : aWhichIds)
+ for(const TypedWhichId<SvxLanguageItem>& i : aWhichIds)
{
if( i != nWhichId )
{
- const SvxLanguageItem& rTmpLang =
- static_cast<const SvxLanguageItem&>(pFormat->GetFormatAttr(i));
+ const SvxLanguageItem& rTmpLang = pFormat->GetFormatAttr(i);
if( rTmpLang.GetLanguage() != eLang )
{
- if( !pItemSet )
- pItemSet.reset( new SfxItemSet( *pFormat->GetAttrSet().GetPool(),
- pFormat->GetAttrSet().GetRanges() ) );
- pItemSet->Put( rTmpLang );
+ if( !moItemSet )
+ moItemSet.emplace( *pFormat->GetAttrSet().GetPool(),
+ pFormat->GetAttrSet().GetRanges() );
+ moItemSet->Put( rTmpLang );
}
}
}
@@ -416,15 +421,13 @@ SwHTMLFormatInfo::~SwHTMLFormatInfo()
{
}
-static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
+static void OutHTML_SwFormat( SwHTMLWriter& rWrt, const SwFormat& rFormat,
const SfxItemSet *pNodeItemSet,
SwHTMLTextCollOutputInfo& rInfo )
{
OSL_ENSURE( RES_CONDTXTFMTCOLL==rFormat.Which() || RES_TXTFMTCOLL==rFormat.Which(),
"not a paragraph style" );
- SwHTMLWriter & rHWrt = static_cast<SwHTMLWriter&>(rWrt);
-
// First, some flags
sal_uInt16 nNewDefListLvl = 0;
sal_uInt16 nNumStart = USHRT_MAX;
@@ -436,23 +439,23 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
rInfo.bParaPossible = false; // a <P> may be additionally output
bool bNoEndTag = false; // don't output an end tag
- rHWrt.m_bNoAlign = false; // no ALIGN=... possible
+ rWrt.m_bNoAlign = false; // no ALIGN=... possible
- if (rHWrt.mbXHTML)
+ if (rWrt.mbXHTML)
{
- rHWrt.m_bNoAlign = true;
+ rWrt.m_bNoAlign = true;
}
sal_uInt8 nBulletGrfLvl = 255; // The bullet graphic we want to output
// Are we in a bulleted or numbered list?
- const SwTextNode* pTextNd = rWrt.m_pCurrentPam->GetNode().GetTextNode();
+ const SwTextNode* pTextNd = rWrt.m_pCurrentPam->GetPointNode().GetTextNode();
SwHTMLNumRuleInfo aNumInfo;
- if( rHWrt.GetNextNumInfo() )
+ if( rWrt.GetNextNumInfo() )
{
- aNumInfo = *rHWrt.GetNextNumInfo();
- rHWrt.ClearNextNumInfo();
+ aNumInfo = *rWrt.GetNextNumInfo();
+ rWrt.ClearNextNumInfo();
}
else
{
@@ -485,7 +488,7 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
{
nNumStart = static_cast< sal_uInt16 >(pTextNd->GetActualListStartValue());
}
- OSL_ENSURE( rHWrt.m_nLastParaToken == HtmlTokenId::NONE,
+ OSL_ENSURE( rWrt.m_nLastParaToken == HtmlTokenId::NONE,
"<PRE> was not closed before <LI>." );
}
}
@@ -493,18 +496,18 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
// Now, we're getting the token and, if necessary, the class
std::unique_ptr<SwHTMLFormatInfo> pTmpInfo(new SwHTMLFormatInfo(&rFormat));
SwHTMLFormatInfo *pFormatInfo;
- SwHTMLFormatInfos::iterator it = rHWrt.m_TextCollInfos.find( pTmpInfo );
- if (it != rHWrt.m_TextCollInfos.end())
+ SwHTMLFormatInfos::iterator it = rWrt.m_TextCollInfos.find( pTmpInfo );
+ if (it != rWrt.m_TextCollInfos.end())
{
pFormatInfo = it->get();
}
else
{
- pFormatInfo = new SwHTMLFormatInfo( &rFormat, rWrt.m_pDoc, rHWrt.m_xTemplate.get(),
- rHWrt.m_bCfgOutStyles, rHWrt.m_eLang,
- rHWrt.m_nCSS1Script );
- rHWrt.m_TextCollInfos.insert(std::unique_ptr<SwHTMLFormatInfo>(pFormatInfo));
- if( rHWrt.m_aScriptParaStyles.count( rFormat.GetName() ) )
+ pFormatInfo = new SwHTMLFormatInfo( &rFormat, rWrt.m_pDoc, rWrt.m_xTemplate.get(),
+ rWrt.m_bCfgOutStyles, rWrt.m_eLang,
+ rWrt.m_nCSS1Script );
+ rWrt.m_TextCollInfos.insert(std::unique_ptr<SwHTMLFormatInfo>(pFormatInfo));
+ if( rWrt.m_aScriptParaStyles.count( rFormat.GetName() ) )
pFormatInfo->bScriptDependent = true;
}
@@ -520,12 +523,12 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
if (rInfo.aToken == OOO_STRING_SVTOOLS_HTML_address)
{
rInfo.bParaPossible = true;
- rHWrt.m_bNoAlign = true;
+ rWrt.m_bNoAlign = true;
}
else if (rInfo.aToken == OOO_STRING_SVTOOLS_HTML_blockquote)
{
rInfo.bParaPossible = true;
- rHWrt.m_bNoAlign = true;
+ rWrt.m_bNoAlign = true;
}
else if (rInfo.aToken == OOO_STRING_SVTOOLS_HTML_parabreak)
{
@@ -533,14 +536,14 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
}
else if (rInfo.aToken == OOO_STRING_SVTOOLS_HTML_preformtxt)
{
- if (HtmlTokenId::PREFORMTXT_ON == rHWrt.m_nLastParaToken)
+ if (HtmlTokenId::PREFORMTXT_ON == rWrt.m_nLastParaToken)
{
bOutNewLine = true;
}
else
{
nToken = HtmlTokenId::PREFORMTXT_ON;
- rHWrt.m_bNoAlign = true;
+ rWrt.m_bNoAlign = true;
bNoEndTag = true;
}
}
@@ -548,7 +551,7 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
{
bDT = rInfo.aToken == OOO_STRING_SVTOOLS_HTML_dt;
rInfo.bParaPossible = !bDT;
- rHWrt.m_bNoAlign = true;
+ rWrt.m_bNoAlign = true;
bForceDL = true;
}
}
@@ -557,24 +560,24 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
// all styles that do not correspond to an HTML tag, or that are
// not derived from it, are exported as <P>
- rInfo.aToken = OOO_STRING_SVTOOLS_HTML_parabreak;
+ rInfo.aToken = OOO_STRING_SVTOOLS_HTML_parabreak ""_ostr;
bPara = true;
}
// If necessary, take the hard attribute from the style
- if( pFormatInfo->pItemSet )
+ if( pFormatInfo->moItemSet )
{
- OSL_ENSURE(!rInfo.pItemSet, "Where does this ItemSet come from?");
- rInfo.pItemSet.reset(new SfxItemSet( *pFormatInfo->pItemSet ));
+ OSL_ENSURE(!rInfo.moItemSet, "Where does this ItemSet come from?");
+ rInfo.moItemSet.emplace( *pFormatInfo->moItemSet );
}
// additionally, add the hard attribute from the paragraph
if( pNodeItemSet )
{
- if (rInfo.pItemSet)
- rInfo.pItemSet->Put( *pNodeItemSet );
+ if (rInfo.moItemSet)
+ rInfo.moItemSet->Put( *pNodeItemSet );
else
- rInfo.pItemSet.reset(new SfxItemSet( *pNodeItemSet ));
+ rInfo.moItemSet.emplace( *pNodeItemSet );
}
// we will need the lower spacing of the paragraph later on
@@ -582,27 +585,27 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
pNodeItemSet ? pNodeItemSet->Get(RES_UL_SPACE)
: rFormat.GetULSpace();
- if( (rHWrt.m_bOutHeader &&
- rWrt.m_pCurrentPam->GetPoint()->nNode.GetIndex() ==
- rWrt.m_pCurrentPam->GetMark()->nNode.GetIndex()) ||
- rHWrt.m_bOutFooter )
+ if( (rWrt.m_bOutHeader &&
+ rWrt.m_pCurrentPam->GetPoint()->GetNodeIndex() ==
+ rWrt.m_pCurrentPam->GetMark()->GetNodeIndex()) ||
+ rWrt.m_bOutFooter )
{
- if( rHWrt.m_bCfgOutStyles )
+ if( rWrt.m_bCfgOutStyles )
{
SvxULSpaceItem aULSpaceItem( rULSpace );
- if( rHWrt.m_bOutHeader )
- aULSpaceItem.SetLower( rHWrt.m_nHeaderFooterSpace );
+ if( rWrt.m_bOutHeader )
+ aULSpaceItem.SetLower( rWrt.m_nHeaderFooterSpace );
else
- aULSpaceItem.SetUpper( rHWrt.m_nHeaderFooterSpace );
+ aULSpaceItem.SetUpper( rWrt.m_nHeaderFooterSpace );
- if (!rInfo.pItemSet)
+ if (!rInfo.moItemSet)
{
- rInfo.pItemSet.reset(new SfxItemSet(*rFormat.GetAttrSet().GetPool(), svl::Items<RES_UL_SPACE, RES_UL_SPACE>{}));
+ rInfo.moItemSet.emplace(*rFormat.GetAttrSet().GetPool(), svl::Items<RES_UL_SPACE, RES_UL_SPACE>);
}
- rInfo.pItemSet->Put( aULSpaceItem );
+ rInfo.moItemSet->Put( aULSpaceItem );
}
- rHWrt.m_bOutHeader = false;
- rHWrt.m_bOutFooter = false;
+ rWrt.m_bOutHeader = false;
+ rWrt.m_bOutFooter = false;
}
if( bOutNewLine )
@@ -610,45 +613,43 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
// output a line break (without indentation) at the beginning of the
// paragraph, only
rInfo.aToken.clear(); // don't output an end tag
- rWrt.Strm().WriteCharPtr( SAL_NEWLINE_STRING );
+ rWrt.Strm().WriteOString( SAL_NEWLINE_STRING );
return;
}
// should an ALIGN=... be written?
- const SfxPoolItem* pAdjItem = nullptr;
- const SfxPoolItem* pItem;
+ const SvxAdjustItem* pAdjItem = nullptr;
- if( rInfo.pItemSet &&
- SfxItemState::SET == rInfo.pItemSet->GetItemState( RES_PARATR_ADJUST,
- false, &pItem ) )
- {
- pAdjItem = pItem;
- }
+ if( rInfo.moItemSet )
+ pAdjItem = rInfo.moItemSet->GetItemIfSet( RES_PARATR_ADJUST, false );
// Consider the lower spacing of the paragraph? (never in the last
// paragraph of tables)
- bool bUseParSpace = !rHWrt.m_bOutTable ||
- (rWrt.m_pCurrentPam->GetPoint()->nNode.GetIndex() !=
- rWrt.m_pCurrentPam->GetMark()->nNode.GetIndex());
+ bool bUseParSpace = !rWrt.m_bOutTable ||
+ (rWrt.m_pCurrentPam->GetPoint()->GetNodeIndex() !=
+ rWrt.m_pCurrentPam->GetMark()->GetNodeIndex());
// If styles are exported, indented paragraphs become definition lists
- const SvxLRSpaceItem& rLRSpace =
- pNodeItemSet ? pNodeItemSet->Get(RES_LR_SPACE)
- : rFormat.GetLRSpace();
- if( (!rHWrt.m_bCfgOutStyles || bForceDL) && !rInfo.bInNumberBulletList )
+ SvxFirstLineIndentItem const& rFirstLine(
+ pNodeItemSet ? pNodeItemSet->Get(RES_MARGIN_FIRSTLINE)
+ : rFormat.GetFirstLineIndent());
+ SvxTextLeftMarginItem const& rTextLeftMargin(
+ pNodeItemSet ? pNodeItemSet->Get(RES_MARGIN_TEXTLEFT)
+ : rFormat.GetTextLeftMargin());
+ if( (!rWrt.m_bCfgOutStyles || bForceDL) && !rInfo.bInNumberBulletList )
{
sal_Int32 nLeftMargin;
if( bForceDL )
- nLeftMargin = rLRSpace.GetTextLeft();
+ nLeftMargin = rTextLeftMargin.GetTextLeft();
else
- nLeftMargin = rLRSpace.GetTextLeft() > pFormatInfo->nLeftMargin
- ? rLRSpace.GetTextLeft() - pFormatInfo->nLeftMargin
+ nLeftMargin = rTextLeftMargin.GetTextLeft() > pFormatInfo->nLeftMargin
+ ? rTextLeftMargin.GetTextLeft() - pFormatInfo->nLeftMargin
: 0;
- if( nLeftMargin > 0 && rHWrt.m_nDefListMargin > 0 )
+ if( nLeftMargin > 0 && rWrt.m_nDefListMargin > 0 )
{
- nNewDefListLvl = static_cast< sal_uInt16 >((nLeftMargin + (rHWrt.m_nDefListMargin/2)) /
- rHWrt.m_nDefListMargin);
+ nNewDefListLvl = static_cast< sal_uInt16 >((nLeftMargin + (rWrt.m_nDefListMargin/2)) /
+ rWrt.m_nDefListMargin);
if( nNewDefListLvl == 0 && bForceDL && !bDT )
nNewDefListLvl = 1;
}
@@ -661,7 +662,7 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
}
bool bIsNextTextNode =
- rWrt.m_pDoc->GetNodes()[rWrt.m_pCurrentPam->GetPoint()->nNode.GetIndex()+1]
+ rWrt.m_pDoc->GetNodes()[rWrt.m_pCurrentPam->GetPoint()->GetNodeIndex()+1]
->IsTextNode();
if( bForceDL && bDT )
@@ -669,32 +670,31 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
// Instead of a DD we must use a DT from the level above this one.
nNewDefListLvl++;
}
- else if( !nNewDefListLvl && !rHWrt.m_bCfgOutStyles && bPara &&
+ else if( !nNewDefListLvl && !rWrt.m_bCfgOutStyles && bPara &&
rULSpace.GetLower()==0 &&
- ((bUseParSpace && bIsNextTextNode) || rHWrt.m_nDefListLvl==1) &&
- (!pAdjItem || SvxAdjust::Left==
- static_cast<const SvxAdjustItem *>(pAdjItem)->GetAdjust()) )
+ ((bUseParSpace && bIsNextTextNode) || rWrt.m_nDefListLvl==1) &&
+ (!pAdjItem || SvxAdjust::Left==pAdjItem->GetAdjust()) )
{
// Export paragraphs without a lower spacing as DT
nNewDefListLvl = 1;
bDT = true;
rInfo.bParaPossible = false;
- rHWrt.m_bNoAlign = true;
+ rWrt.m_bNoAlign = true;
}
}
- if( nNewDefListLvl != rHWrt.m_nDefListLvl )
- rHWrt.OutAndSetDefList( nNewDefListLvl );
+ if( nNewDefListLvl != rWrt.m_nDefListLvl )
+ rWrt.OutAndSetDefList( nNewDefListLvl );
// if necessary, start a bulleted or numbered list
if( rInfo.bInNumberBulletList )
{
- OSL_ENSURE( !rHWrt.m_nDefListLvl, "DL cannot be inside OL!" );
- OutHTML_NumberBulletListStart( rHWrt, aNumInfo );
+ OSL_ENSURE( !rWrt.m_nDefListLvl, "DL cannot be inside OL!" );
+ OutHTML_NumberBulletListStart( rWrt, aNumInfo );
if( bNumbered )
{
- if( !rHWrt.m_aBulletGrfs[nBulletGrfLvl].isEmpty() )
+ if( !rWrt.m_aBulletGrfs[nBulletGrfLvl].isEmpty() )
bNumbered = false;
else
nBulletGrfLvl = 255;
@@ -703,96 +703,112 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
// Take the defaults of the style, because they don't need to be
// exported
- rHWrt.m_nDfltLeftMargin = pFormatInfo->nLeftMargin;
- rHWrt.m_nDfltRightMargin = pFormatInfo->nRightMargin;
- rHWrt.m_nDfltFirstLineIndent = pFormatInfo->nFirstLineIndent;
+ rWrt.m_nDfltLeftMargin = pFormatInfo->nLeftMargin;
+ rWrt.m_nDfltRightMargin = pFormatInfo->nRightMargin;
+ rWrt.m_nDfltFirstLineIndent = pFormatInfo->nFirstLineIndent;
if( rInfo.bInNumberBulletList )
{
- if( !rHWrt.IsHTMLMode( HTMLMODE_LSPACE_IN_NUMBER_BULLET ) )
- rHWrt.m_nDfltLeftMargin = rLRSpace.GetTextLeft();
+ if( !rWrt.IsHTMLMode( HTMLMODE_LSPACE_IN_NUMBER_BULLET ) )
+ rWrt.m_nDfltLeftMargin = rTextLeftMargin.GetTextLeft();
// In numbered lists, don't output a first line indent.
- rHWrt.m_nFirstLineIndent = rLRSpace.GetTextFirstLineOffset();
+ rWrt.m_nFirstLineIndent = rFirstLine.GetTextFirstLineOffset();
}
- if( rInfo.bInNumberBulletList && bNumbered && bPara && !rHWrt.m_bCfgOutStyles )
+ if( rInfo.bInNumberBulletList && bNumbered && bPara && !rWrt.m_bCfgOutStyles )
{
// a single LI doesn't have spacing
- rHWrt.m_nDfltTopMargin = 0;
- rHWrt.m_nDfltBottomMargin = 0;
+ rWrt.m_nDfltTopMargin = 0;
+ rWrt.m_nDfltBottomMargin = 0;
}
- else if( rHWrt.m_nDefListLvl && bPara )
+ else if( rWrt.m_nDefListLvl && bPara )
{
// a single DD doesn't have spacing, as well
- rHWrt.m_nDfltTopMargin = 0;
- rHWrt.m_nDfltBottomMargin = 0;
+ rWrt.m_nDfltTopMargin = 0;
+ rWrt.m_nDfltBottomMargin = 0;
}
else
{
- rHWrt.m_nDfltTopMargin = pFormatInfo->nTopMargin;
+ rWrt.m_nDfltTopMargin = pFormatInfo->nTopMargin;
// if in the last paragraph of a table the lower paragraph spacing
// is changed, Netscape doesn't get it. That's why we don't
// export anything here for now, by setting this spacing to the
// default value.
- if( rHWrt.m_bCfgNetscape4 && !bUseParSpace )
- rHWrt.m_nDfltBottomMargin = rULSpace.GetLower();
+ if( rWrt.m_bCfgNetscape4 && !bUseParSpace )
+ rWrt.m_nDfltBottomMargin = rULSpace.GetLower();
else
- rHWrt.m_nDfltBottomMargin = pFormatInfo->nBottomMargin;
+ rWrt.m_nDfltBottomMargin = pFormatInfo->nBottomMargin;
}
- if( rHWrt.m_nDefListLvl )
+ if( rWrt.m_nDefListLvl )
{
- rHWrt.m_nLeftMargin =
- (rHWrt.m_nDefListLvl-1) * rHWrt.m_nDefListMargin;
+ rWrt.m_nLeftMargin =
+ (rWrt.m_nDefListLvl-1) * rWrt.m_nDefListMargin;
}
- if( rHWrt.m_bLFPossible && !rHWrt.m_bFirstLine )
- rHWrt.OutNewLine(); // paragraph tag on a new line
+ if (rWrt.IsLFPossible() && !rWrt.m_bFirstLine)
+ rWrt.OutNewLine(); // paragraph tag on a new line
rInfo.bOutPara = false;
// this is now our new token
- rHWrt.ChangeParaToken( nToken );
+ rWrt.ChangeParaToken( nToken );
bool bHasParSpace = bUseParSpace && rULSpace.GetLower() > 0;
+ // XHTML doesn't allow character children for <blockquote>.
+ bool bXhtmlBlockQuote = rWrt.mbXHTML && rInfo.aToken == OOO_STRING_SVTOOLS_HTML_blockquote;
// if necessary, start a new list item
- if( rInfo.bInNumberBulletList && bNumbered )
+ bool bNumberedForListItem = bNumbered;
+ if (!bNumberedForListItem)
+ {
+ // Open a list also for the leading unnumbered nodes (= list headers in ODF terminology);
+ // to do that, detect if this unnumbered node is the first in this list
+ const auto& rPrevListInfo = rWrt.GetNumInfo();
+ if (rPrevListInfo.GetNumRule() != aNumInfo.GetNumRule() || aNumInfo.IsRestart(rPrevListInfo)
+ || rPrevListInfo.GetDepth() < aNumInfo.GetDepth())
+ bNumberedForListItem = true;
+ }
+ if( rInfo.bInNumberBulletList && bNumberedForListItem )
{
- HtmlWriter html(rWrt.Strm(), rHWrt.maNamespace);
- html.start(OOO_STRING_SVTOOLS_HTML_li);
- if( USHRT_MAX != nNumStart )
- html.attribute(OOO_STRING_SVTOOLS_HTML_O_value, OString::number(nNumStart));
- // Finish the opening element, but don't close it.
- html.characters(OString());
+ OStringBuffer sOut(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_li);
+ if (!bNumbered)
+ {
+ // Handles list headers (<text:list-header> ODF element)
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_style "=\"display: block\"");
+ }
+ else if (USHRT_MAX != nNumStart)
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_value "=\"" + OString::number(nNumStart)
+ + "\"");
+ HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), sOut);
}
- if( rHWrt.m_nDefListLvl > 0 && !bForceDL )
+ if( rWrt.m_nDefListLvl > 0 && !bForceDL )
{
OString aTag = bDT ? OOO_STRING_SVTOOLS_HTML_dt : OOO_STRING_SVTOOLS_HTML_dd;
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHWrt.GetNamespace() + aTag );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aTag) );
}
if( pAdjItem &&
- rHWrt.IsHTMLMode( HTMLMODE_NO_CONTROL_CENTERING ) &&
- rHWrt.HasControls() )
+ rWrt.IsHTMLMode( HTMLMODE_NO_CONTROL_CENTERING ) &&
+ rWrt.HasControls() )
{
// The align=... attribute does behave strange in netscape
// if there are controls in a paragraph, because the control and
// all text behind the control does not recognize this attribute.
- OString sOut = "<" + rHWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_division;
+ OString sOut = "<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_division;
rWrt.Strm().WriteOString( sOut );
- rHWrt.m_bTextAttr = false;
- rHWrt.m_bOutOpts = true;
+ rWrt.m_bTextAttr = false;
+ rWrt.m_bOutOpts = true;
OutHTML_SvxAdjust( rWrt, *pAdjItem );
rWrt.Strm().WriteChar( '>' );
pAdjItem = nullptr;
- rHWrt.m_bNoAlign = false;
+ rWrt.m_bNoAlign = false;
rInfo.bOutDiv = true;
- rHWrt.IncIndentLevel();
- rHWrt.m_bLFPossible = true;
- rHWrt.OutNewLine();
+ rWrt.IncIndentLevel();
+ rWrt.SetLFPossible(true);
+ rWrt.OutNewLine();
}
// for BLOCKQUOTE, ADDRESS and DD we output another paragraph token, if
@@ -800,38 +816,39 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
// - a lower spacing or a paragraph alignment exists
// Also, XHTML does not allow character children in this context.
OString aToken = rInfo.aToken;
- if( (!rHWrt.m_bCfgOutStyles || rHWrt.mbXHTML) && rInfo.bParaPossible && !bPara &&
- (bHasParSpace || pAdjItem) )
+ if( (!rWrt.m_bCfgOutStyles || rWrt.mbXHTML) && rInfo.bParaPossible && !bPara &&
+ (bHasParSpace || bXhtmlBlockQuote || pAdjItem) )
{
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHWrt.GetNamespace() + rInfo.aToken );
- aToken = OOO_STRING_SVTOOLS_HTML_parabreak;
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + rInfo.aToken) );
+ aToken = OOO_STRING_SVTOOLS_HTML_parabreak ""_ostr;
bPara = true;
- rHWrt.m_bNoAlign = false;
+ rWrt.m_bNoAlign = false;
}
LanguageType eLang;
- if (rInfo.pItemSet)
- eLang = static_cast<const SvxLanguageItem&>(rInfo.pItemSet->Get(SwHTMLWriter::GetLangWhichIdFromScript(rHWrt.m_nCSS1Script))).GetLanguage();
+ if (rInfo.moItemSet)
+ {
+ const SvxLanguageItem& rLangItem = rInfo.moItemSet->Get(SwHTMLWriter::GetLangWhichIdFromScript(rWrt.m_nCSS1Script));
+ eLang = rLangItem.GetLanguage();
+ }
else
- eLang = rHWrt.m_eLang;
+ eLang = rWrt.m_eLang;
- if( rInfo.pItemSet )
+ if( rInfo.moItemSet )
{
- static const sal_uInt16 aWhichIds[3] = { RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE };
+ static const TypedWhichId<SvxLanguageItem> aWhichIds[3] = { RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE };
- for(sal_uInt16 i : aWhichIds)
+ for(auto const & i : aWhichIds)
{
// export language if it differs from the default language only.
- const SfxPoolItem *pTmpItem;
- if( SfxItemState::SET == rInfo.pItemSet->GetItemState( i,
- true, &pTmpItem ) &&
- static_cast<const SvxLanguageItem *>(pTmpItem)->GetLanguage() == eLang )
- rInfo.pItemSet->ClearItem( i );
+ const SvxLanguageItem* pTmpItem = rInfo.moItemSet->GetItemIfSet( i );
+ if( pTmpItem && pTmpItem->GetLanguage() == eLang )
+ rInfo.moItemSet->ClearItem( i );
}
}
// and the text direction
- SvxFrameDirection nDir = rHWrt.GetHTMLDirection(
+ SvxFrameDirection nDir = rWrt.GetHTMLDirection(
(pNodeItemSet ? pNodeItemSet->Get( RES_FRAMEDIR )
: rFormat.GetFrameDir() ).GetValue() );
@@ -846,49 +863,49 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
// - a user format is exported, or
// - a paragraph attribute exists
if( !bPara ||
- (!rInfo.bInNumberBulletList && !rHWrt.m_nDefListLvl) ||
+ (!rInfo.bInNumberBulletList && !rWrt.m_nDefListLvl) ||
(rInfo.bInNumberBulletList && !bNumbered) ||
- (!rHWrt.m_bCfgOutStyles &&
- (bHasParSpace || pAdjItem ||
- (eLang != LANGUAGE_DONTKNOW && eLang != rHWrt.m_eLang))) ||
- nDir != rHWrt.m_nDirection ||
- rHWrt.m_bCfgOutStyles )
+ (!rWrt.m_bCfgOutStyles &&
+ (bHasParSpace || bXhtmlBlockQuote || pAdjItem ||
+ (eLang != LANGUAGE_DONTKNOW && eLang != rWrt.m_eLang))) ||
+ nDir != rWrt.m_nDirection ||
+ rWrt.m_bCfgOutStyles )
{
// now, options are output
- rHWrt.m_bTextAttr = false;
- rHWrt.m_bOutOpts = true;
+ rWrt.m_bTextAttr = false;
+ rWrt.m_bOutOpts = true;
- OString sOut = "<" + rHWrt.GetNamespace() + aToken;
+ OString sOut = "<" + rWrt.GetNamespace() + aToken;
- if( eLang != LANGUAGE_DONTKNOW && eLang != rHWrt.m_eLang )
+ if( eLang != LANGUAGE_DONTKNOW && eLang != rWrt.m_eLang )
{
rWrt.Strm().WriteOString( sOut );
- sOut = "";
- rHWrt.OutLanguage( eLang );
+ sOut = ""_ostr;
+ rWrt.OutLanguage( eLang );
}
- if( nDir != rHWrt.m_nDirection )
+ if( nDir != rWrt.m_nDirection )
{
if( !sOut.isEmpty() )
{
rWrt.Strm().WriteOString( sOut );
- sOut = "";
+ sOut = ""_ostr;
}
- rHWrt.OutDirection( nDir );
+ rWrt.OutDirection( nDir );
}
- if( rHWrt.m_bCfgOutStyles &&
+ if( rWrt.m_bCfgOutStyles &&
(!pFormatInfo->aClass.isEmpty() || pFormatInfo->bScriptDependent) )
{
sOut += " " OOO_STRING_SVTOOLS_HTML_O_class "=\"";
rWrt.Strm().WriteOString( sOut );
- sOut = "";
+ sOut = ""_ostr;
OUString aClass( pFormatInfo->aClass );
if( pFormatInfo->bScriptDependent )
{
if( !aClass.isEmpty() )
aClass += "-";
- switch( rHWrt.m_nCSS1Script )
+ switch( rWrt.m_nCSS1Script )
{
case CSS1_OUTMODE_WESTERN:
aClass += "western";
@@ -901,32 +918,40 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
break;
}
}
- HTMLOutFuncs::Out_String( rWrt.Strm(), aClass,
- rHWrt.m_eDestEnc, &rHWrt.m_aNonConvertableCharacters );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aClass );
sOut += "\"";
}
rWrt.Strm().WriteOString( sOut );
- sOut = "";
+ sOut = ""_ostr;
+
+ std::string_view sStyle;
+ if (rWrt.IsSpacePreserve())
+ {
+ if (rWrt.mbXHTML)
+ rWrt.Strm().WriteOString(" xml:space=\"preserve\"");
+ else
+ sStyle = "white-space: pre-wrap";
+ }
// if necessary, output alignment
- if( !rHWrt.m_bNoAlign && pAdjItem )
+ if( !rWrt.m_bNoAlign && pAdjItem )
OutHTML_SvxAdjust( rWrt, *pAdjItem );
- rHWrt.m_bParaDotLeaders = bPara && rHWrt.m_bCfgPrintLayout && rHWrt.indexOfDotLeaders(
+ rWrt.m_bParaDotLeaders = bPara && rWrt.m_bCfgPrintLayout && rWrt.indexOfDotLeaders(
pTextNd->GetAnyFormatColl().GetPoolFormatId(), pTextNd->GetText()) > -1;
// and now, if necessary, the STYLE options
- if (rHWrt.m_bCfgOutStyles && rInfo.pItemSet)
+ if (rWrt.m_bCfgOutStyles && rInfo.moItemSet)
{
- OutCSS1_ParaTagStyleOpt( rWrt, *rInfo.pItemSet );
+ OutCSS1_ParaTagStyleOpt(rWrt, *rInfo.moItemSet, sStyle);
}
- if (rHWrt.m_bParaDotLeaders) {
+ if (rWrt.m_bParaDotLeaders) {
sOut += " " OOO_STRING_SVTOOLS_HTML_O_class "=\""
sCSS2_P_CLASS_leaders "\"><"
OOO_STRING_SVTOOLS_HTML_O_span;
rWrt.Strm().WriteOString( sOut );
- sOut = "";
+ sOut = ""_ostr;
}
rWrt.Strm().WriteChar( '>' );
@@ -934,7 +959,7 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
// is a </P> supposed to be written?
rInfo.bOutPara =
bPara &&
- ( rHWrt.m_bCfgOutStyles || bHasParSpace );
+ ( rWrt.m_bCfgOutStyles || bHasParSpace );
// if no end tag is supposed to be written, delete it
if( bNoEndTag )
@@ -947,79 +972,77 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
OSL_ENSURE( nBulletGrfLvl < MAXLEVEL, "There are not this many layers." );
const SwNumFormat& rNumFormat = aNumInfo.GetNumRule()->Get(nBulletGrfLvl);
OutHTML_BulletImage( rWrt, OOO_STRING_SVTOOLS_HTML_image, rNumFormat.GetBrush(),
- rHWrt.m_aBulletGrfs[nBulletGrfLvl]);
+ rWrt.m_aBulletGrfs[nBulletGrfLvl]);
}
- rHWrt.GetNumInfo() = aNumInfo;
+ rWrt.GetNumInfo() = aNumInfo;
// reset the defaults
- rHWrt.m_nDfltLeftMargin = 0;
- rHWrt.m_nDfltRightMargin = 0;
- rHWrt.m_nDfltFirstLineIndent = 0;
- rHWrt.m_nDfltTopMargin = 0;
- rHWrt.m_nDfltBottomMargin = 0;
- rHWrt.m_nLeftMargin = 0;
- rHWrt.m_nFirstLineIndent = 0;
+ rWrt.m_nDfltLeftMargin = 0;
+ rWrt.m_nDfltRightMargin = 0;
+ rWrt.m_nDfltFirstLineIndent = 0;
+ rWrt.m_nDfltTopMargin = 0;
+ rWrt.m_nDfltBottomMargin = 0;
+ rWrt.m_nLeftMargin = 0;
+ rWrt.m_nFirstLineIndent = 0;
}
-static void OutHTML_SwFormatOff( Writer& rWrt, const SwHTMLTextCollOutputInfo& rInfo )
+static void OutHTML_SwFormatOff( SwHTMLWriter& rWrt, const SwHTMLTextCollOutputInfo& rInfo )
{
- SwHTMLWriter & rHWrt = static_cast<SwHTMLWriter&>(rWrt);
-
// if there is no token, we don't need to output anything
if( rInfo.aToken.isEmpty() )
{
- rHWrt.FillNextNumInfo();
- const SwHTMLNumRuleInfo& rNextInfo = *rHWrt.GetNextNumInfo();
+ rWrt.FillNextNumInfo();
+ const SwHTMLNumRuleInfo& rNextInfo = *rWrt.GetNextNumInfo();
// a bulleted list must be closed in PRE as well
if( rInfo.bInNumberBulletList )
{
- const SwHTMLNumRuleInfo& rNRInfo = rHWrt.GetNumInfo();
+ const SwHTMLNumRuleInfo& rNRInfo = rWrt.GetNumInfo();
if( rNextInfo.GetNumRule() != rNRInfo.GetNumRule() ||
rNextInfo.GetDepth() != rNRInfo.GetDepth() ||
- rNextInfo.IsNumbered() || rNextInfo.IsRestart() )
- rHWrt.ChangeParaToken( HtmlTokenId::NONE );
- OutHTML_NumberBulletListEnd( rHWrt, rNextInfo );
+ rNextInfo.IsNumbered() || rNextInfo.IsRestart(rNRInfo) )
+ rWrt.ChangeParaToken( HtmlTokenId::NONE );
+ OutHTML_NumberBulletListEnd( rWrt, rNextInfo );
}
else if( rNextInfo.GetNumRule() != nullptr )
- rHWrt.ChangeParaToken( HtmlTokenId::NONE );
+ rWrt.ChangeParaToken( HtmlTokenId::NONE );
return;
}
if( rInfo.ShouldOutputToken() )
{
- if( rHWrt.m_bLFPossible )
- rHWrt.OutNewLine( true );
+ if (rWrt.IsPrettyPrint() && rWrt.IsLFPossible())
+ rWrt.OutNewLine( true );
// if necessary, for BLOCKQUOTE, ADDRESS and DD another paragraph token
// is output, if
// - no styles are written and
// - a lower spacing exists
if( rInfo.bParaPossible && rInfo.bOutPara )
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_parabreak, false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_parabreak), false );
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHWrt.GetNamespace() + rInfo.aToken, false );
- rHWrt.m_bLFPossible =
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + rInfo.aToken), false );
+ rWrt.SetLFPossible(
rInfo.aToken != OOO_STRING_SVTOOLS_HTML_dt &&
rInfo.aToken != OOO_STRING_SVTOOLS_HTML_dd &&
- rInfo.aToken != OOO_STRING_SVTOOLS_HTML_li;
+ rInfo.aToken != OOO_STRING_SVTOOLS_HTML_li);
}
if( rInfo.bOutDiv )
{
- rHWrt.DecIndentLevel();
- if( rHWrt.m_bLFPossible )
- rHWrt.OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_division, false );
- rHWrt.m_bLFPossible = true;
+ rWrt.DecIndentLevel();
+ if (rWrt.IsLFPossible())
+ rWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_division), false );
+ rWrt.SetLFPossible(true);
}
// if necessary, close the list item, then close a bulleted or numbered list
if( rInfo.bInNumberBulletList )
{
- rHWrt.FillNextNumInfo();
- OutHTML_NumberBulletListEnd( rHWrt, *rHWrt.GetNextNumInfo() );
+ rWrt.FillNextNumInfo();
+ OutHTML_NumberBulletListEnd( rWrt, *rWrt.GetNextNumInfo() );
}
}
@@ -1027,33 +1050,32 @@ namespace {
class HTMLStartEndPos
{
- sal_Int32 nStart;
- sal_Int32 nEnd;
- std::unique_ptr<SfxPoolItem> pItem;
+ sal_Int32 m_nStart;
+ sal_Int32 m_nEnd;
+ std::unique_ptr<SfxPoolItem> m_pItem;
public:
HTMLStartEndPos( const SfxPoolItem& rItem, sal_Int32 nStt, sal_Int32 nE );
- const SfxPoolItem *GetItem() const { return pItem.get(); }
+ const SfxPoolItem& GetItem() const { return *m_pItem; }
- void SetStart( sal_Int32 nStt ) { nStart = nStt; }
- sal_Int32 GetStart() const { return nStart; }
+ void SetStart(sal_Int32 nStt) { m_nStart = nStt; }
+ sal_Int32 GetStart() const { return m_nStart; }
- sal_Int32 GetEnd() const { return nEnd; }
- void SetEnd( sal_Int32 nE ) { nEnd = nE; }
+ sal_Int32 GetEnd() const { return m_nEnd; }
+ void SetEnd(sal_Int32 nE) { m_nEnd = nE; }
};
}
-HTMLStartEndPos::HTMLStartEndPos( const SfxPoolItem& rItem, sal_Int32 nStt,
- sal_Int32 nE ) :
- nStart( nStt ),
- nEnd( nE ),
- pItem( rItem.Clone() )
+HTMLStartEndPos::HTMLStartEndPos(const SfxPoolItem& rItem, sal_Int32 nStt, sal_Int32 nE)
+ : m_nStart(nStt)
+ , m_nEnd(nE)
+ , m_pItem(rItem.Clone())
{}
-typedef std::vector<HTMLStartEndPos *> HTMLStartEndPositions;
+typedef std::map<sal_Int32, std::vector<HTMLStartEndPos*>> HTMLStartEndPositions;
namespace {
@@ -1069,27 +1091,26 @@ enum HTMLOnOffState { HTML_NOT_SUPPORTED, // unsupported Attribute
class HTMLEndPosLst
{
- HTMLStartEndPositions aStartLst; // list, sorted for start positions
- HTMLStartEndPositions aEndLst; // list, sorted for end positions
- std::deque<sal_Int32> aScriptChgLst; // positions where script changes
- // 0 is not contained in this list,
- // but the text length
+ HTMLStartEndPositions m_aStartLst; // list, each position's elements sorted by appearance order
+ HTMLStartEndPositions m_aEndLst; // list, no sort of elements in position
+ std::deque<sal_Int32> m_aScriptChgLst; // positions where script changes
+ // 0 is not contained in this list,
+ // but the text length
// the script that is valid up to the position
// contained in aScriptChgList at the same index
- std::vector<sal_uInt16> aScriptLst;
+ std::vector<sal_uInt16> m_aScriptLst;
- SwDoc *pDoc; // the current document
- SwDoc* pTemplate; // the HTML template (or 0)
- std::optional<Color> xDfltColor;// the default foreground colors
- std::set<OUString>& rScriptTextStyles;
+ SwDoc* m_pDoc; // the current document
+ SwDoc* m_pTemplate; // the HTML template (or 0)
+ std::optional<Color> m_xDefaultColor; // the default foreground colors
+ std::set<OUString>& m_rScriptTextStyles;
- sal_uLong nHTMLMode;
- bool bOutStyles : 1; // are styles exported
+ sal_uLong m_nHTMLMode;
+ bool m_bOutStyles : 1; // are styles exported
// Insert/remove a SttEndPos in/from the Start and End lists.
// The end position is known.
- void InsertItem_( HTMLStartEndPos *pPos, HTMLStartEndPositions::size_type nEndPos );
- void RemoveItem_( HTMLStartEndPositions::size_type nEndPos );
+ void InsertItem_(HTMLStartEndPos* pPos);
// determine the 'type' of the attribute
HTMLOnOffState GetHTMLItemState( const SfxPoolItem& rItem );
@@ -1103,8 +1124,7 @@ class HTMLEndPosLst
sal_Int32 nEndPos );
// adapt the end of a split item
- void FixSplittedItem( HTMLStartEndPos *pPos, sal_Int32 nNewEnd,
- HTMLStartEndPositions::size_type nStartPos );
+ void FixSplittedItem(HTMLStartEndPos* pPos, sal_Int32 nNewEnd);
// insert an attribute in the lists and, if necessary, split it
void InsertItem( const SfxPoolItem& rItem, sal_Int32 nStart,
@@ -1122,6 +1142,8 @@ class HTMLEndPosLst
const SwHTMLFormatInfo *GetFormatInfo( const SwFormat& rFormat,
SwHTMLFormatInfos& rFormatInfos );
+ void OutEndAttrs(SwHTMLWriter& rWrt, std::vector<HTMLStartEndPos*>& posItems);
+
public:
HTMLEndPosLst( SwDoc *pDoc, SwDoc* pTemplate, std::optional<Color> xDfltColor,
@@ -1141,45 +1163,52 @@ public:
sal_uInt16 GetScriptAtPos( sal_Int32 nPos,
sal_uInt16 nWeak );
- void OutStartAttrs( SwHTMLWriter& rHWrt, sal_Int32 nPos,
- HTMLOutContext *pContext = nullptr );
- void OutEndAttrs( SwHTMLWriter& rHWrt, sal_Int32 nPos,
- HTMLOutContext *pContext );
+ void OutStartAttrs( SwHTMLWriter& rWrt, sal_Int32 nPos );
+ void OutEndAttrs( SwHTMLWriter& rWrt, sal_Int32 nPos );
- bool IsHTMLMode( sal_uLong nMode ) const { return (nHTMLMode & nMode) != 0; }
+ bool IsHTMLMode(sal_uLong nMode) const { return (m_nHTMLMode & nMode) != 0; }
};
-}
-
-void HTMLEndPosLst::InsertItem_( HTMLStartEndPos *pPos, HTMLStartEndPositions::size_type nEndPos )
+struct SortEnds
{
- // Insert the attribute in the Start list behind all attributes that
- // were started before, or at the same position.
- sal_Int32 nStart = pPos->GetStart();
- HTMLStartEndPositions::size_type i {0};
+ HTMLStartEndPositions& m_startList;
+ SortEnds(HTMLStartEndPositions& startList) : m_startList(startList) {}
+ bool operator()(const HTMLStartEndPos* p1, const HTMLStartEndPos* p2)
+ {
+ // if p1 start after p2, then it ends before
+ if (p1->GetStart() > p2->GetStart())
+ return true;
+ if (p1->GetStart() < p2->GetStart())
+ return false;
+ for (const auto p : m_startList[p1->GetStart()])
+ {
+ if (p == p1)
+ return false;
+ if (p == p2)
+ return true;
+ }
+ assert(!"Neither p1 nor p2 found in their start list");
+ return false;
+ }
+};
- while( i < aStartLst.size() && aStartLst[i]->GetStart() <= nStart )
- ++i;
- aStartLst.insert( aStartLst.begin() + i, pPos );
+#ifndef NDEBUG
+bool IsEmpty(const HTMLStartEndPositions& l)
+{
+ return std::find_if(l.begin(), l.end(), [](auto& i) { return !i.second.empty(); }) == l.end();
+}
+#endif
- // the position in the End list was supplied
- aEndLst.insert( aEndLst.begin() + nEndPos, pPos );
}
-void HTMLEndPosLst::RemoveItem_( HTMLStartEndPositions::size_type nEndPos )
+void HTMLEndPosLst::InsertItem_(HTMLStartEndPos* pPos)
{
- HTMLStartEndPos *pPos = aEndLst[nEndPos];
+ // Character border attribute must be the first which is written out because of border merge.
+ auto& posItems1 = m_aStartLst[pPos->GetStart()];
+ auto it = pPos->GetItem().Which() == RES_CHRATR_BOX ? posItems1.begin() : posItems1.end();
+ posItems1.insert(it, pPos);
- // now, we are looking for it in the Start list
- HTMLStartEndPositions::iterator it =
- std::find(aStartLst.begin(), aStartLst.end(), pPos );
- OSL_ENSURE(it != aStartLst.end(), "Item not found in Start List!");
- if( it != aStartLst.end() )
- aStartLst.erase( it );
-
- aEndLst.erase( aEndLst.begin() + nEndPos );
-
- delete pPos;
+ m_aEndLst[pPos->GetEnd()].push_back(pPos);
}
HTMLOnOffState HTMLEndPosLst::GetHTMLItemState( const SfxPoolItem& rItem )
@@ -1206,7 +1235,7 @@ HTMLOnOffState HTMLEndPosLst::GetHTMLItemState( const SfxPoolItem& rItem )
break;
case RES_CHRATR_CROSSEDOUT:
- switch( static_cast<const SvxCrossedOutItem&>(rItem).GetStrikeout() )
+ switch( rItem.StaticWhichCast(RES_CHRATR_CROSSEDOUT).GetStrikeout() )
{
case STRIKEOUT_SINGLE:
case STRIKEOUT_DOUBLE:
@@ -1221,7 +1250,7 @@ HTMLOnOffState HTMLEndPosLst::GetHTMLItemState( const SfxPoolItem& rItem )
break;
case RES_CHRATR_ESCAPEMENT:
- switch( static_cast<SvxEscapement>(static_cast<const SvxEscapementItem&>(rItem).GetEnumValue()) )
+ switch( static_cast<SvxEscapement>(rItem.StaticWhichCast(RES_CHRATR_ESCAPEMENT).GetEnumValue()) )
{
case SvxEscapement::Superscript:
case SvxEscapement::Subscript:
@@ -1236,7 +1265,7 @@ HTMLOnOffState HTMLEndPosLst::GetHTMLItemState( const SfxPoolItem& rItem )
break;
case RES_CHRATR_UNDERLINE:
- switch( static_cast<const SvxUnderlineItem&>(rItem).GetLineStyle() )
+ switch( rItem.StaticWhichCast(RES_CHRATR_UNDERLINE).GetLineStyle() )
{
case LINESTYLE_SINGLE:
eState = HTML_ON_VALUE;
@@ -1276,7 +1305,7 @@ HTMLOnOffState HTMLEndPosLst::GetHTMLItemState( const SfxPoolItem& rItem )
break;
case RES_CHRATR_BLINK:
- eState = static_cast<const SvxBlinkItem&>(rItem).GetValue() ? HTML_ON_VALUE
+ eState = rItem.StaticWhichCast(RES_CHRATR_BLINK).GetValue() ? HTML_ON_VALUE
: HTML_OFF_VALUE;
break;
@@ -1333,23 +1362,25 @@ HTMLOnOffState HTMLEndPosLst::GetHTMLItemState( const SfxPoolItem& rItem )
bool HTMLEndPosLst::ExistsOnTagItem( sal_uInt16 nWhich, sal_Int32 nPos )
{
- for( auto pTest : aStartLst )
+ for (const auto& [startPos, items] : m_aStartLst)
{
- if( pTest->GetStart() > nPos )
+ if (startPos > nPos)
{
// this attribute, and all attributes that follow, start later
break;
}
- else if( pTest->GetEnd() > nPos )
+
+ for (const auto* pTest : items)
{
- // the attribute starts before, or at, the current position and
- // ends after it
- const SfxPoolItem *pItem = pTest->GetItem();
- if( pItem->Which() == nWhich &&
- HTML_ON_VALUE == GetHTMLItemState(*pItem) )
+ if (pTest->GetEnd() > nPos)
{
- // an OnTag attribute was found
- return true;
+ // the attribute starts before, or at, the current position and ends after it
+ const SfxPoolItem& rItem = pTest->GetItem();
+ if (rItem.Which() == nWhich && HTML_ON_VALUE == GetHTMLItemState(rItem))
+ {
+ // an OnTag attribute was found
+ return true;
+ }
}
}
}
@@ -1367,24 +1398,17 @@ bool HTMLEndPosLst::ExistsOffTagItem( sal_uInt16 nWhich, sal_Int32 nStartPos,
return false;
}
- for( auto pTest : aStartLst )
+ for (const auto* pTest : m_aStartLst[nStartPos])
{
- if( pTest->GetStart() > nStartPos )
- {
- // this attribute, and all attributes that follow, start later
- break;
- }
- else if( pTest->GetStart()==nStartPos &&
- pTest->GetEnd()==nEndPos )
+ if (pTest->GetEnd() == nEndPos)
{
- // the attribute starts before or at the current position and
- // ends after it
- const SfxPoolItem *pItem = pTest->GetItem();
- sal_uInt16 nTstWhich = pItem->Which();
+ // the attribute starts before or at the current position and ends after it
+ const SfxPoolItem& rItem = pTest->GetItem();
+ sal_uInt16 nTstWhich = rItem.Which();
if( (nTstWhich == RES_CHRATR_CROSSEDOUT ||
nTstWhich == RES_CHRATR_UNDERLINE ||
nTstWhich == RES_CHRATR_BLINK) &&
- HTML_OFF_VALUE == GetHTMLItemState(*pItem) )
+ HTML_OFF_VALUE == GetHTMLItemState(rItem) )
{
// an OffTag attribute was found that is exported the same
// way as the current item
@@ -1396,56 +1420,51 @@ bool HTMLEndPosLst::ExistsOffTagItem( sal_uInt16 nWhich, sal_Int32 nStartPos,
return false;
}
-void HTMLEndPosLst::FixSplittedItem( HTMLStartEndPos *pPos, sal_Int32 nNewEnd,
- HTMLStartEndPositions::size_type nStartPos )
+void HTMLEndPosLst::FixSplittedItem(HTMLStartEndPos* pPos, sal_Int32 nNewEnd)
{
+ // remove the item from the End list
+ std::erase(m_aEndLst[pPos->GetEnd()], pPos);
// fix the end position accordingly
pPos->SetEnd( nNewEnd );
-
- // remove the item from the End list
- HTMLStartEndPositions::iterator it =
- std::find(aEndLst.begin(), aEndLst.end(), pPos );
- OSL_ENSURE(it != aEndLst.end(), "Item not found in End List!" );
- if( it != aEndLst.end() )
- aEndLst.erase( it );
-
- // from now on, it is closed as the last one at the corresponding position
- HTMLStartEndPositions::size_type nEndPos {0};
- while( nEndPos < aEndLst.size() && aEndLst[nEndPos]->GetEnd() <= nNewEnd )
- ++nEndPos;
- aEndLst.insert( aEndLst.begin() + nEndPos, pPos );
+ // from now on, it is closed at the corresponding position
+ m_aEndLst[nNewEnd].push_back(pPos);
// now, adjust the attributes that got started afterwards
- for( HTMLStartEndPositions::size_type i = nStartPos+1; i<aStartLst.size(); ++i )
+ const sal_Int32 nPos = pPos->GetStart();
+ for (const auto& [startPos, items] : m_aStartLst)
{
- HTMLStartEndPos *pTest = aStartLst[i];
- sal_Int32 nTestEnd = pTest->GetEnd();
- if( pTest->GetStart() >= nNewEnd )
- {
- // the Test attribute and all the following ones start, after the
- // split attribute ends
+ if (startPos < nPos)
+ continue;
+
+ if (startPos >= nNewEnd)
break;
+
+ auto it = items.begin();
+ if (startPos == nPos)
+ {
+ it = std::find(items.begin(), items.end(), pPos);
+ if (it != items.end())
+ ++it;
}
- else if( nTestEnd > nNewEnd )
+ for (; it != items.end(); ++it)
{
+ HTMLStartEndPos* pTest = *it;
+ const sal_Int32 nTestEnd = pTest->GetEnd();
+ if (nTestEnd <= nNewEnd)
+ continue;
+
// the Test attribute starts before the split attribute
// ends, and ends afterwards, i.e., it must be split, as well
+ // remove the attribute from the End list
+ std::erase(m_aEndLst[pTest->GetEnd()], pTest);
// set the new end
pTest->SetEnd( nNewEnd );
-
- // remove the attribute from the End list
- it = std::find(aEndLst.begin(), aEndLst.end(), pTest );
- OSL_ENSURE(it != aEndLst.end(), "Item not found in End List!" );
- if( it != aEndLst.end() )
- aEndLst.erase( it );
-
- // it now ends as the first attribute in the respective position.
- // We already know this position in the End list.
- aEndLst.insert( aEndLst.begin() + nEndPos, pTest );
+ // it now ends in the respective position.
+ m_aEndLst[nNewEnd].push_back(pTest);
// insert the 'rest' of the attribute
- InsertItem( *pTest->GetItem(), nNewEnd, nTestEnd );
+ InsertItem( pTest->GetItem(), nNewEnd, nTestEnd );
}
}
}
@@ -1453,36 +1472,38 @@ void HTMLEndPosLst::FixSplittedItem( HTMLStartEndPos *pPos, sal_Int32 nNewEnd,
void HTMLEndPosLst::InsertItem( const SfxPoolItem& rItem, sal_Int32 nStart,
sal_Int32 nEnd )
{
- HTMLStartEndPositions::size_type i;
- for( i = 0; i < aEndLst.size(); i++ )
+ assert(nStart < nEnd);
+
+ for (auto& [endPos, items] : m_aEndLst)
{
- HTMLStartEndPos *pTest = aEndLst[i];
- sal_Int32 nTestEnd = pTest->GetEnd();
- if( nTestEnd <= nStart )
+ if (endPos <= nStart)
{
// the Test attribute ends, before the new one starts
continue;
}
- else if( nTestEnd < nEnd )
+ if (endPos >= nEnd)
+ {
+ // the Test attribute (and all that follow) ends, before the new
+ // one ends
+ break;
+ }
+
+ std::sort(items.begin(), items.end(), SortEnds(m_aStartLst));
+
+ for (HTMLStartEndPos* pTest : items)
{
if( pTest->GetStart() < nStart )
{
// the Test attribute ends, before the new one ends. Thus, the
// new attribute must be split.
- InsertItem_( new HTMLStartEndPos( rItem, nStart, nTestEnd ), i );
- nStart = nTestEnd;
+ InsertItem_(new HTMLStartEndPos(rItem, nStart, endPos));
+ nStart = endPos;
}
}
- else
- {
- // the Test attribute (and all that follow) ends, before the new
- // one ends
- break;
- }
}
// one attribute must still be inserted
- InsertItem_( new HTMLStartEndPos( rItem, nStart, nEnd ), i );
+ InsertItem_(new HTMLStartEndPos(rItem, nStart, nEnd));
}
void HTMLEndPosLst::SplitItem( const SfxPoolItem& rItem, sal_Int32 nStart,
@@ -1493,59 +1514,45 @@ void HTMLEndPosLst::SplitItem( const SfxPoolItem& rItem, sal_Int32 nStart,
// first, we must search for the old items by using the start list and
// determine the new item range
- for( HTMLStartEndPositions::size_type i=0; i<aStartLst.size(); ++i )
+ for (auto& [nTestStart, items] : m_aStartLst)
{
- HTMLStartEndPos *pTest = aStartLst[i];
- sal_Int32 nTestStart = pTest->GetStart();
- sal_Int32 nTestEnd = pTest->GetEnd();
-
if( nTestStart >= nEnd )
{
// this attribute, and all that follow, start later
break;
}
- else if( nTestEnd > nStart )
+
+ for (auto it = items.begin(); it != items.end();)
{
+ auto itTest = it++; // forward early, allow 'continue', and keep a copy for 'erase'
+ HTMLStartEndPos* pTest = *itTest;
+ const sal_Int32 nTestEnd = pTest->GetEnd();
+ if (nTestEnd <= nStart)
+ continue;
+
// the Test attribute ends in the range that must be deleted
- const SfxPoolItem *pItem = pTest->GetItem();
+ const SfxPoolItem& rTestItem = pTest->GetItem();
// only the corresponding OnTag attributes have to be considered
- if( pItem->Which() == nWhich &&
- HTML_ON_VALUE == GetHTMLItemState( *pItem ) )
- {
- bool bDelete = true;
-
- if( nTestStart < nStart )
- {
- // the start of the new attribute corresponds to the new
- // end of the attribute
- FixSplittedItem( pTest, nStart, i );
- bDelete = false;
- }
- else
- {
- // the Test item only starts after the new end of the
- // attribute. Therefore, it can be completely erased.
- aStartLst.erase( aStartLst.begin() + i );
- i--;
-
- HTMLStartEndPositions::iterator it =
- std::find(aEndLst.begin(), aEndLst.end(), pTest );
- OSL_ENSURE(it != aEndLst.end(), "Item not found in End List!" );
- if( it != aEndLst.end() )
- aEndLst.erase( it );
- }
+ if (rTestItem.Which() != nWhich || HTML_ON_VALUE != GetHTMLItemState(rTestItem))
+ continue;
- // if necessary, insert the second part of the split
- // attribute
- if( nTestEnd > nEnd )
- {
- InsertItem( *pTest->GetItem(), nEnd, nTestEnd );
- }
+ // if necessary, insert the second part of the split attribute
+ if (nTestEnd > nEnd)
+ InsertItem(rTestItem, nEnd, nTestEnd);
- if( bDelete )
- delete pTest;
+ if (nTestStart >= nStart)
+ {
+ // the Test item only starts after the new end of the
+ // attribute. Therefore, it can be completely erased.
+ it = items.erase(itTest);
+ std::erase(m_aEndLst[nTestEnd], pTest);
+ delete pTest;
+ continue;
}
+
+ // the start of the new attribute corresponds to the new end of the attribute
+ FixSplittedItem(pTest, nStart);
}
}
}
@@ -1562,25 +1569,23 @@ const SwHTMLFormatInfo *HTMLEndPosLst::GetFormatInfo( const SwFormat& rFormat,
}
else
{
- pFormatInfo = new SwHTMLFormatInfo( &rFormat, pDoc, pTemplate,
- bOutStyles );
+ pFormatInfo = new SwHTMLFormatInfo(&rFormat, m_pDoc, m_pTemplate, m_bOutStyles);
rFormatInfos.insert(std::unique_ptr<SwHTMLFormatInfo>(pFormatInfo));
- if ( rScriptTextStyles.count( rFormat.GetName() ) )
+ if (m_rScriptTextStyles.count(rFormat.GetName()))
pFormatInfo->bScriptDependent = true;
}
return pFormatInfo;
}
-HTMLEndPosLst::HTMLEndPosLst(SwDoc* pD, SwDoc* pTempl, std::optional<Color> xDfltCol,
- bool bStyles, sal_uLong nMode, const OUString& rText,
- std::set<OUString>& rStyles)
- : pDoc(pD)
- , pTemplate(pTempl)
- , xDfltColor(std::move(xDfltCol))
- , rScriptTextStyles(rStyles)
- , nHTMLMode(nMode)
- , bOutStyles(bStyles)
+HTMLEndPosLst::HTMLEndPosLst(SwDoc* pD, SwDoc* pTempl, std::optional<Color> xDfltCol, bool bStyles,
+ sal_uLong nMode, const OUString& rText, std::set<OUString>& rStyles)
+ : m_pDoc(pD)
+ , m_pTemplate(pTempl)
+ , m_xDefaultColor(std::move(xDfltCol))
+ , m_rScriptTextStyles(rStyles)
+ , m_nHTMLMode(nMode)
+ , m_bOutStyles(bStyles)
{
sal_Int32 nEndPos = rText.getLength();
sal_Int32 nPos = 0;
@@ -1588,15 +1593,15 @@ HTMLEndPosLst::HTMLEndPosLst(SwDoc* pD, SwDoc* pTempl, std::optional<Color> xDfl
{
sal_uInt16 nScript = g_pBreakIt->GetBreakIter()->getScriptType( rText, nPos );
nPos = g_pBreakIt->GetBreakIter()->endOfScript( rText, nPos, nScript );
- aScriptChgLst.push_back( nPos );
- aScriptLst.push_back( nScript );
+ m_aScriptChgLst.push_back(nPos);
+ m_aScriptLst.push_back(nScript);
}
}
HTMLEndPosLst::~HTMLEndPosLst()
{
- OSL_ENSURE(aStartLst.empty(), "Start List not empty in destructor");
- OSL_ENSURE(aEndLst.empty(), "End List not empty in destructor");
+ assert(IsEmpty(m_aStartLst) && "Start List not empty in destructor");
+ assert(IsEmpty(m_aEndLst) && "End List not empty in destructor");
}
void HTMLEndPosLst::InsertNoScript( const SfxPoolItem& rItem,
@@ -1623,8 +1628,7 @@ void HTMLEndPosLst::InsertNoScript( const SfxPoolItem& rItem,
// together with the paragraph tag.
if( ExistsOnTagItem( rItem.Which(), nStart ) )
bSplit = true;
- bSet = bOutStyles && !bParaAttrs &&
- !ExistsOffTagItem( rItem.Which(), nStart, nEnd );
+ bSet = m_bOutStyles && !bParaAttrs && !ExistsOffTagItem(rItem.Which(), nStart, nEnd);
break;
case HTML_REAL_VALUE:
@@ -1637,18 +1641,16 @@ void HTMLEndPosLst::InsertNoScript( const SfxPoolItem& rItem,
// the paragraph, it was already output with the paragraph tag.
// The only exception is the character-background attribute. This
// attribute must always be handled like a Hint.
- bSet = bOutStyles &&
- (!bParaAttrs
- || rItem.Which()==RES_CHRATR_BACKGROUND
- || rItem.Which()==RES_CHRATR_BOX
- || rItem.Which()==RES_CHRATR_OVERLINE);
+ bSet = m_bOutStyles
+ && (!bParaAttrs || rItem.Which() == RES_CHRATR_BACKGROUND
+ || rItem.Which() == RES_CHRATR_BOX || rItem.Which() == RES_CHRATR_OVERLINE);
break;
case HTML_CHRFMT_VALUE:
{
OSL_ENSURE( RES_TXTATR_CHARFMT == rItem.Which(),
"Not a character style after all" );
- const SwFormatCharFormat& rChrFormat = static_cast<const SwFormatCharFormat&>(rItem);
+ const SwFormatCharFormat& rChrFormat = rItem.StaticWhichCast(RES_TXTATR_CHARFMT);
const SwCharFormat* pFormat = rChrFormat.GetCharFormat();
const SwHTMLFormatInfo *pFormatInfo = GetFormatInfo( *pFormat, rFormatInfos );
@@ -1658,9 +1660,9 @@ void HTMLEndPosLst::InsertNoScript( const SfxPoolItem& rItem,
// attributes
InsertItem( rItem, nStart, nEnd );
}
- if( pFormatInfo->pItemSet )
+ if( pFormatInfo->moItemSet )
{
- Insert( *pFormatInfo->pItemSet, nStart, nEnd,
+ Insert( *pFormatInfo->moItemSet, nStart, nEnd,
rFormatInfos, true, bParaAttrs );
}
}
@@ -1668,7 +1670,9 @@ void HTMLEndPosLst::InsertNoScript( const SfxPoolItem& rItem,
case HTML_AUTOFMT_VALUE:
{
- const SwFormatAutoFormat& rAutoFormat = static_cast<const SwFormatAutoFormat&>(rItem);
+ OSL_ENSURE( RES_TXTATR_AUTOFMT == rItem.Which(),
+ "Not an automatic style, after all" );
+ const SwFormatAutoFormat& rAutoFormat = rItem.StaticWhichCast(RES_TXTATR_AUTOFMT);
const std::shared_ptr<SfxItemSet>& pSet = rAutoFormat.GetStyleHandle();
if( pSet )
Insert( *pSet, nStart, nEnd, rFormatInfos, true, bParaAttrs );
@@ -1681,11 +1685,10 @@ void HTMLEndPosLst::InsertNoScript( const SfxPoolItem& rItem,
{
OSL_ENSURE( RES_CHRATR_COLOR == rItem.Which(),
"Not a foreground color, after all" );
- Color aColor( static_cast<const SvxColorItem&>(rItem).GetValue() );
+ Color aColor( rItem.StaticWhichCast(RES_CHRATR_COLOR).GetValue() );
if( COL_AUTO == aColor )
aColor = COL_BLACK;
- bSet = !bParaAttrs || !xDfltColor ||
- !xDfltColor->IsRGBEqual( aColor );
+ bSet = !bParaAttrs || !m_xDefaultColor || !m_xDefaultColor->IsRGBEqual(aColor);
}
break;
@@ -1693,9 +1696,9 @@ void HTMLEndPosLst::InsertNoScript( const SfxPoolItem& rItem,
{
OSL_ENSURE( RES_PARATR_DROP == rItem.Which(),
"Not a drop cap, after all" );
- const SwFormatDrop& rDrop = static_cast<const SwFormatDrop&>(rItem);
+ const SwFormatDrop& rDrop = rItem.StaticWhichCast(RES_PARATR_DROP);
nEnd = nStart + rDrop.GetChars();
- if( !bOutStyles )
+ if (!m_bOutStyles)
{
// At least use the attributes of the character style
const SwCharFormat *pCharFormat = rDrop.GetCharFormat();
@@ -1757,7 +1760,7 @@ void HTMLEndPosLst::Insert( const SfxPoolItem& rItem,
break;
case RES_TXTATR_CHARFMT:
{
- const SwFormatCharFormat& rChrFormat = static_cast<const SwFormatCharFormat&>(rItem);
+ const SwFormatCharFormat& rChrFormat = rItem.StaticWhichCast(RES_TXTATR_CHARFMT);
const SwCharFormat* pFormat = rChrFormat.GetCharFormat();
const SwHTMLFormatInfo *pFormatInfo = GetFormatInfo( *pFormat, rFormatInfos );
if( pFormatInfo->bScriptDependent )
@@ -1769,10 +1772,14 @@ void HTMLEndPosLst::Insert( const SfxPoolItem& rItem,
break;
case RES_TXTATR_INETFMT:
{
- if( GetFormatInfo( *pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool(
- RES_POOLCHR_INET_NORMAL), rFormatInfos )->bScriptDependent ||
- GetFormatInfo( *pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool(
- RES_POOLCHR_INET_VISIT), rFormatInfos )->bScriptDependent )
+ if (GetFormatInfo(*m_pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool(
+ RES_POOLCHR_INET_NORMAL),
+ rFormatInfos)
+ ->bScriptDependent
+ || GetFormatInfo(*m_pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool(
+ RES_POOLCHR_INET_VISIT),
+ rFormatInfos)
+ ->bScriptDependent)
{
bDependsOnScript = true;
bDependsOnAnyScript = true;
@@ -1784,9 +1791,9 @@ void HTMLEndPosLst::Insert( const SfxPoolItem& rItem,
if( bDependsOnScript )
{
sal_Int32 nPos = nStart;
- for( size_t i=0; i < aScriptChgLst.size(); i++ )
+ for (size_t i = 0; i < m_aScriptChgLst.size(); i++)
{
- sal_Int32 nChgPos = aScriptChgLst[i];
+ sal_Int32 nChgPos = m_aScriptChgLst[i];
if( nPos >= nChgPos )
{
// the hint starts behind or at the next script change,
@@ -1798,7 +1805,7 @@ void HTMLEndPosLst::Insert( const SfxPoolItem& rItem,
// the (rest of) the hint ends before or at the next script
// change, so we can insert it, but only if it belongs
// to the current script.
- if( bDependsOnAnyScript || nScript == aScriptLst[i] )
+ if (bDependsOnAnyScript || nScript == m_aScriptLst[i])
InsertNoScript( rItem, nPos, nEnd, rFormatInfos,
bParaAttrs );
break;
@@ -1807,7 +1814,7 @@ void HTMLEndPosLst::Insert( const SfxPoolItem& rItem,
// the hint starts before the next script change and ends behind
// it, so we can insert a hint up to the next script change and
// continue with the rest of the hint.
- if( bDependsOnAnyScript || nScript == aScriptLst[i] )
+ if (bDependsOnAnyScript || nScript == m_aScriptLst[i])
InsertNoScript( rItem, nPos, nChgPos, rFormatInfos, bParaAttrs );
nPos = nChgPos;
}
@@ -1829,7 +1836,7 @@ void HTMLEndPosLst::Insert( const SfxItemSet& rItemSet,
while( nWhich )
{
const SfxPoolItem *pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( nWhich, bDeep, &pItem ) )
+ if( SfxItemState::SET == aIter.GetItemState( bDeep, &pItem ) )
{
Insert( *pItem, nStart, nEnd, rFormatInfos, bParaAttrs );
}
@@ -1850,164 +1857,188 @@ void HTMLEndPosLst::Insert( const SwDrawFrameFormat& rFormat, sal_Int32 nPos,
// insert them as hints. Because of the amount of Hints the styles
// are not considered!
const SfxItemSet& rFormatItemSet = rFormat.GetAttrSet();
- SfxItemSet aItemSet( *rFormatItemSet.GetPool(), svl::Items<RES_CHRATR_BEGIN,
- RES_CHRATR_END>{} );
+ SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END> aItemSet( *rFormatItemSet.GetPool() );
SwHTMLWriter::GetEEAttrsFromDrwObj( aItemSet, pTextObj );
- bool bOutStylesOld = bOutStyles;
- bOutStyles = false;
+ bool bOutStylesOld = m_bOutStyles;
+ m_bOutStyles = false;
Insert( aItemSet, nPos, nPos+1, rFormatInfos, false );
- bOutStyles = bOutStylesOld;
+ m_bOutStyles = bOutStylesOld;
}
sal_uInt16 HTMLEndPosLst::GetScriptAtPos( sal_Int32 nPos, sal_uInt16 nWeak )
{
sal_uInt16 nRet = CSS1_OUTMODE_ANY_SCRIPT;
- size_t nScriptChgs = aScriptChgLst.size();
+ size_t nScriptChgs = m_aScriptChgLst.size();
size_t i=0;
- while( i < nScriptChgs && nPos >= aScriptChgLst[i] )
+ while (i < nScriptChgs && nPos >= m_aScriptChgLst[i])
i++;
OSL_ENSURE( i < nScriptChgs, "script list is too short" );
if( i < nScriptChgs )
{
- if( i18n::ScriptType::WEAK == aScriptLst[i] )
+ if (i18n::ScriptType::WEAK == m_aScriptLst[i])
nRet = nWeak;
else
- nRet = SwHTMLWriter::GetCSS1ScriptForScriptType( aScriptLst[i] );
+ nRet = SwHTMLWriter::GetCSS1ScriptForScriptType(m_aScriptLst[i]);
}
return nRet;
}
-void HTMLEndPosLst::OutStartAttrs( SwHTMLWriter& rHWrt, sal_Int32 nPos,
- HTMLOutContext *pContext )
+void HTMLEndPosLst::OutStartAttrs( SwHTMLWriter& rWrt, sal_Int32 nPos )
{
- rHWrt.m_bTagOn = true;
-
- // Character border attribute must be the first which is written out
- // because of border merge.
- HTMLStartEndPositions::size_type nCharBoxIndex = 0;
- while( nCharBoxIndex < aStartLst.size() &&
- aStartLst[nCharBoxIndex]->GetItem()->Which() != RES_CHRATR_BOX )
- {
- ++nCharBoxIndex;
- }
+ rWrt.m_bTagOn = true;
+ auto it = m_aStartLst.find(nPos);
+ if (it == m_aStartLst.end())
+ return;
// the attributes of the start list are sorted in ascending order
- for( HTMLStartEndPositions::size_type i=0; i< aStartLst.size(); ++i )
+ for (HTMLStartEndPos* pPos : it->second)
{
- HTMLStartEndPos *pPos = nullptr;
- if( nCharBoxIndex < aStartLst.size() )
+ // output the attribute
+ sal_uInt16 nCSS1Script = rWrt.m_nCSS1Script;
+ sal_uInt16 nWhich = pPos->GetItem().Which();
+ if( RES_TXTATR_CHARFMT == nWhich ||
+ RES_TXTATR_INETFMT == nWhich ||
+ RES_PARATR_DROP == nWhich )
{
- if( i == 0 )
- pPos = aStartLst[nCharBoxIndex];
- else if( i == nCharBoxIndex )
- pPos = aStartLst[0];
- else
- pPos = aStartLst[i];
+ rWrt.m_nCSS1Script = GetScriptAtPos( nPos, nCSS1Script );
}
- else
- pPos = aStartLst[i];
+ HTMLOutFuncs::FlushToAscii( rWrt.Strm() ); // was one time only - do we still need it?
+ Out( aHTMLAttrFnTab, pPos->GetItem(), rWrt );
+ rWrt.maStartedAttributes[pPos->GetItem().Which()]++;
+ rWrt.m_nCSS1Script = nCSS1Script;
+ }
+}
- sal_Int32 nStart = pPos->GetStart();
- if( nStart > nPos )
- {
- // this attribute, and all that follow, will be opened later on
- break;
- }
- else if( nStart == nPos )
+void HTMLEndPosLst::OutEndAttrs( SwHTMLWriter& rWrt, sal_Int32 nPos )
+{
+ rWrt.m_bTagOn = false;
+
+ if (nPos == SAL_MAX_INT32)
+ {
+ for (auto& element : m_aEndLst)
+ OutEndAttrs(rWrt, element.second);
+ }
+ else
+ {
+ auto it = m_aEndLst.find(nPos);
+ if (it != m_aEndLst.end())
+ OutEndAttrs(rWrt, it->second);
+ }
+}
+
+void HTMLEndPosLst::OutEndAttrs(SwHTMLWriter& rWrt, std::vector<HTMLStartEndPos*>& posItems)
+{
+ std::sort(posItems.begin(), posItems.end(), SortEnds(m_aStartLst));
+ for (auto it = posItems.begin(); it != posItems.end(); it = posItems.erase(it))
+ {
+ HTMLStartEndPos* pPos = *it;
+ HTMLOutFuncs::FlushToAscii( rWrt.Strm() ); // was one time only - do we still need it?
+ // Skip closing span if next character span has the same border (border merge)
+ bool bSkipOut = false;
+ if( pPos->GetItem().Which() == RES_CHRATR_BOX )
{
- // output the attribute
- sal_uInt16 nCSS1Script = rHWrt.m_nCSS1Script;
- sal_uInt16 nWhich = pPos->GetItem()->Which();
- if( RES_TXTATR_CHARFMT == nWhich ||
- RES_TXTATR_INETFMT == nWhich ||
- RES_PARATR_DROP == nWhich )
+ auto& startPosItems = m_aStartLst[pPos->GetEnd()];
+ for (auto it2 = startPosItems.begin(); it2 != startPosItems.end(); ++it2)
{
- rHWrt.m_nCSS1Script = GetScriptAtPos( nPos, nCSS1Script );
- }
- if( pContext )
- {
- HTMLOutFuncs::FlushToAscii( rHWrt.Strm(), *pContext );
- pContext = nullptr; // one time only
+ HTMLStartEndPos* pEndPos = *it2;
+ if( pEndPos->GetItem().Which() == RES_CHRATR_BOX &&
+ static_cast<const SvxBoxItem&>(pEndPos->GetItem()) ==
+ static_cast<const SvxBoxItem&>(pPos->GetItem()) )
+ {
+ startPosItems.erase(it2);
+ pEndPos->SetStart(pPos->GetStart());
+ auto& oldStartPosItems = m_aStartLst[pEndPos->GetStart()];
+ oldStartPosItems.insert(oldStartPosItems.begin(), pEndPos);
+ bSkipOut = true;
+ break;
+ }
}
- Out( aHTMLAttrFnTab, *pPos->GetItem(), rHWrt );
- rHWrt.maStartedAttributes[pPos->GetItem()->Which()]++;
- rHWrt.m_nCSS1Script = nCSS1Script;
}
+ if( !bSkipOut )
+ {
+ Out( aHTMLAttrFnTab, pPos->GetItem(), rWrt );
+ rWrt.maStartedAttributes[pPos->GetItem().Which()]--;
+ }
+
+ std::erase(m_aStartLst[pPos->GetStart()], pPos);
+ delete pPos;
}
}
-void HTMLEndPosLst::OutEndAttrs( SwHTMLWriter& rHWrt, sal_Int32 nPos,
- HTMLOutContext *pContext = nullptr )
+static constexpr bool IsLF(sal_Unicode ch) { return ch == '\n'; }
+
+static constexpr bool IsWhitespaceExcludingLF(sal_Unicode ch)
{
- rHWrt.m_bTagOn = false;
+ return ch == ' ' || ch == '\t' || ch == '\r';
+}
- // the attributes in the End list are sorted in ascending order
- HTMLStartEndPositions::size_type i {0};
- while( i < aEndLst.size() )
- {
- HTMLStartEndPos *pPos = aEndLst[i];
- sal_Int32 nEnd = pPos->GetEnd();
+static constexpr bool IsWhitespaceIncludingLF(sal_Unicode ch)
+{
+ return IsWhitespaceExcludingLF(ch) || IsLF(ch);
+}
- if( SAL_MAX_INT32 == nPos || nEnd == nPos )
+static bool NeedPreserveWhitespace(std::u16string_view str, bool xml)
+{
+ if (str.empty())
+ return false;
+ // leading / trailing spaces
+ // A leading / trailing \n would turn into a leading / trailing <br/>,
+ // and will not disappear, even without space preserving option
+ if (IsWhitespaceExcludingLF(str.front()) || IsWhitespaceExcludingLF(str.back()))
+ return true;
+ for (size_t i = 0; i < str.size(); ++i)
+ {
+ if (xml)
+ {
+ // No need to consider \n, which convert to <br/>, when it's after a space
+ // (but handle it *before* a space)
+ if (IsWhitespaceIncludingLF(str[i]))
+ {
+ do
+ {
+ ++i;
+ if (i == str.size())
+ return false;
+ } while (IsLF(str[i]));
+ if (IsWhitespaceExcludingLF(str[i]))
+ return true; // Second whitespace in a row
+ }
+ }
+ else // html
{
- if( pContext )
+ // Only consider \n, when an adjacent space is not \n - which would be eaten
+ // without a space preserving option
+ if (IsWhitespaceExcludingLF(str[i]))
{
- HTMLOutFuncs::FlushToAscii( rHWrt.Strm(), *pContext );
- pContext = nullptr; // one time only
+ ++i;
+ if (i == str.size())
+ return false;
+ if (IsWhitespaceIncludingLF(str[i]))
+ return true; // Any whitespace after a non-LF whitespace
}
- // Skip closing span if next character span has the same border (border merge)
- bool bSkipOut = false;
- if( pPos->GetItem()->Which() == RES_CHRATR_BOX )
+ else if (IsLF(str[i]))
{
- HTMLStartEndPositions::iterator it =
- std::find(aStartLst.begin(), aStartLst.end(), pPos );
- OSL_ENSURE(it != aStartLst.end(), "Item not found in Start List!" );
- if (it != aStartLst.end())
- ++it;
- while(it != aStartLst.end() )
+ do
{
- HTMLStartEndPos *pEndPos = *it;
- if( pEndPos->GetItem()->Which() == RES_CHRATR_BOX &&
- *static_cast<const SvxBoxItem*>(pEndPos->GetItem()) ==
- *static_cast<const SvxBoxItem*>(pPos->GetItem()) )
- {
- pEndPos->SetStart(pPos->GetStart());
- bSkipOut = true;
- break;
- }
- ++it;
+ ++i;
+ if (i == str.size())
+ return false;
}
+ while (IsLF(str[i]));
+ if (IsWhitespaceExcludingLF(str[i]))
+ return true; // A non-LF whitespace after a LF
}
- if( !bSkipOut )
- {
- Out( aHTMLAttrFnTab, *pPos->GetItem(), rHWrt );
- rHWrt.maStartedAttributes[pPos->GetItem()->Which()]--;
- }
- RemoveItem_( i );
- }
- else if( nEnd > nPos )
- {
- // this attribute, and all that follow, are closed later on
- break;
- }
- else
- {
- // The attribute is closed before the current position. This
- // is not allowed, but we can handle it anyway.
- OSL_ENSURE( nEnd >= nPos,
- "The attribute should've been closed a long time ago" );
- i++;
}
}
+ return false;
}
/* Output of the nodes*/
-Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
+SwHTMLWriter& OutHTML_SwTextNode( SwHTMLWriter& rWrt, const SwContentNode& rNode )
{
const SwTextNode * pNd = &static_cast<const SwTextNode&>(rNode);
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
const OUString& rStr = pNd->GetText();
sal_Int32 nEnd = rStr.getLength();
@@ -2024,34 +2055,39 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
// MIB 8.7.97: We enclose the line in a <PRE>. This means that the
// spacings are wrong, but otherwise we get an empty paragraph
// after the <HR> which is even uglier.
- rHTMLWrt.ChangeParaToken( HtmlTokenId::NONE );
+ rWrt.ChangeParaToken( HtmlTokenId::NONE );
// Output all the nodes that are anchored to a frame
- rHTMLWrt.OutFlyFrame( rNode.GetIndex(), 0, HtmlPosition::Any );
+ rWrt.OutFlyFrame( rNode.GetIndex(), 0, HtmlPosition::Any );
- if( rHTMLWrt.m_bLFPossible )
- rHTMLWrt.OutNewLine(); // paragraph tag on a new line
+ if (rWrt.IsLFPossible())
+ rWrt.OutNewLine(); // paragraph tag on a new line
- rHTMLWrt.m_bLFPossible = true;
+ rWrt.SetLFPossible(true);
- HtmlWriter aHtml(rWrt.Strm(), rHTMLWrt.maNamespace);
- aHtml.start(OOO_STRING_SVTOOLS_HTML_horzrule);
+ HtmlWriter aHtml(rWrt.Strm(), rWrt.maNamespace);
+ aHtml.prettyPrint(rWrt.IsPrettyPrint());
+ aHtml.start(OOO_STRING_SVTOOLS_HTML_horzrule ""_ostr);
const SfxItemSet* pItemSet = pNd->GetpSwAttrSet();
if( !pItemSet )
{
- aHtml.endAttribute();
- return rHTMLWrt;
+ aHtml.end();
+ return rWrt;
}
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == pItemSet->GetItemState( RES_LR_SPACE, false, &pItem ))
+ if (pItemSet->GetItemIfSet(RES_MARGIN_FIRSTLINE, false)
+ || pItemSet->GetItemIfSet(RES_MARGIN_TEXTLEFT, false)
+ || pItemSet->GetItemIfSet(RES_MARGIN_RIGHT, false))
{
- sal_Int32 nLeft = static_cast<const SvxLRSpaceItem*>(pItem)->GetLeft();
- sal_Int32 nRight = static_cast<const SvxLRSpaceItem*>(pItem)->GetRight();
+ SvxFirstLineIndentItem const& rFirstLine(pItemSet->Get(RES_MARGIN_FIRSTLINE));
+ SvxTextLeftMarginItem const& rTextLeftMargin(pItemSet->Get(RES_MARGIN_TEXTLEFT));
+ SvxRightMarginItem const& rRightMargin(pItemSet->Get(RES_MARGIN_RIGHT));
+ sal_Int32 const nLeft(rTextLeftMargin.GetLeft(rFirstLine));
+ sal_Int32 const nRight(rRightMargin.GetRight());
if( nLeft || nRight )
{
const SwFrameFormat& rPgFormat =
- rHTMLWrt.m_pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool
+ rWrt.m_pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool
( RES_POOLPAGE_HTML, false )->GetMaster();
const SwFormatFrameSize& rSz = rPgFormat.GetFrameSize();
const SvxLRSpaceItem& rLR = rPgFormat.GetLRSpace();
@@ -2071,7 +2107,7 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
nPageWidth = pBox->GetFrameFormat()->GetFrameSize().GetWidth();
}
- OString sWidth = OString::number(SwHTMLWriter::ToPixel(nPageWidth - nLeft - nRight, false));
+ OString sWidth = OString::number(SwHTMLWriter::ToPixel(nPageWidth - nLeft - nRight));
aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_width, sWidth);
if( !nLeft )
@@ -2083,14 +2119,13 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
}
}
- if( SfxItemState::SET == pItemSet->GetItemState( RES_BOX, false, &pItem ))
+ if( const SvxBoxItem* pBoxItem = pItemSet->GetItemIfSet( RES_BOX, false ))
{
- const SvxBoxItem* pBoxItem = static_cast<const SvxBoxItem*>(pItem);
const editeng::SvxBorderLine* pBorderLine = pBoxItem->GetBottom();
if( pBorderLine )
{
sal_uInt16 nWidth = pBorderLine->GetScaledWidth();
- OString sWidth = OString::number(SwHTMLWriter::ToPixel(nWidth, false));
+ OString sWidth = OString::number(SwHTMLWriter::ToPixel(nWidth));
aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_size, sWidth);
const Color& rBorderColor = pBorderLine->GetColor();
@@ -2106,7 +2141,7 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
}
}
aHtml.end();
- return rHTMLWrt;
+ return rWrt;
}
// Do not export the empty nodes with 2pt fonts and standard style that
@@ -2117,14 +2152,14 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
nPoolId == RES_POOLCOLL_TABLE_HDLN) )
{
// The current node is empty and contains the standard style ...
- const SfxPoolItem* pItem;
+ const SvxFontHeightItem* pFontHeightItem;
const SfxItemSet* pItemSet = pNd->GetpSwAttrSet();
if( pItemSet && pItemSet->Count() &&
- SfxItemState::SET == pItemSet->GetItemState( RES_CHRATR_FONTSIZE, false, &pItem ) &&
- 40 == static_cast<const SvxFontHeightItem *>(pItem)->GetHeight() )
+ (pFontHeightItem = pItemSet->GetItemIfSet( RES_CHRATR_FONTSIZE, false )) &&
+ 40 == pFontHeightItem->GetHeight() )
{
// ... moreover, the 2pt font is set ...
- sal_uLong nNdPos = rWrt.m_pCurrentPam->GetPoint()->nNode.GetIndex();
+ SwNodeOffset nNdPos = rWrt.m_pCurrentPam->GetPoint()->GetNodeIndex();
const SwNode *pNextNd = rWrt.m_pDoc->GetNodes()[nNdPos+1];
const SwNode *pPrevNd = rWrt.m_pDoc->GetNodes()[nNdPos-1];
bool bStdColl = nPoolId == RES_POOLCOLL_STANDARD;
@@ -2135,12 +2170,12 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
SwTableBoxStartNode == pPrevNd->GetStartNode()->GetStartNodeType() ) )
{
// ... and it is located before a table or a section
- rHTMLWrt.OutBookmarks();
- rHTMLWrt.m_bLFPossible = rHTMLWrt.m_nLastParaToken == HtmlTokenId::NONE;
+ rWrt.OutBookmarks();
+ rWrt.SetLFPossible(rWrt.m_nLastParaToken == HtmlTokenId::NONE);
// Output all frames that are anchored to this node
- rHTMLWrt.OutFlyFrame( rNode.GetIndex(), 0, HtmlPosition::Any );
- rHTMLWrt.m_bLFPossible = false;
+ rWrt.OutFlyFrame( rNode.GetIndex(), 0, HtmlPosition::Any );
+ rWrt.SetLFPossible(false);
return rWrt;
}
@@ -2149,24 +2184,23 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
// catch PageBreaks and PageDescs
bool bPageBreakBehind = false;
- if( rHTMLWrt.m_bCfgFormFeed &&
- !(rHTMLWrt.m_bOutTable || rHTMLWrt.m_bOutFlyFrame) &&
- rHTMLWrt.m_pStartNdIdx->GetIndex() != rHTMLWrt.m_pCurrentPam->GetPoint()->nNode.GetIndex() )
+ if( rWrt.m_bCfgFormFeed &&
+ !(rWrt.m_bOutTable || rWrt.m_bOutFlyFrame) &&
+ rWrt.m_pStartNdIdx->GetIndex() != rWrt.m_pCurrentPam->GetPoint()->GetNodeIndex() )
{
bool bPageBreakBefore = false;
- const SfxPoolItem* pItem;
const SfxItemSet* pItemSet = pNd->GetpSwAttrSet();
if( pItemSet )
{
- if( SfxItemState::SET == pItemSet->GetItemState( RES_PAGEDESC, true, &pItem ) &&
- static_cast<const SwFormatPageDesc *>(pItem)->GetPageDesc() )
+ const SwFormatPageDesc* pPageDescItem = pItemSet->GetItemIfSet( RES_PAGEDESC );
+ if( pPageDescItem && pPageDescItem->GetPageDesc() )
{
bPageBreakBefore = true;
}
- else if( SfxItemState::SET == pItemSet->GetItemState( RES_BREAK, true, &pItem ) )
+ else if( const SvxFormatBreakItem* pItem = pItemSet->GetItemIfSet( RES_BREAK ) )
{
- switch( static_cast<const SvxFormatBreakItem *>(pItem)->GetBreak() )
+ switch( pItem->GetBreak() )
{
case SvxBreak::PageBefore:
bPageBreakBefore = true;
@@ -2189,48 +2223,53 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
}
// if necessary, open a form
- rHTMLWrt.OutForm();
+ rWrt.OutForm();
// Output the page-anchored frames that are 'anchored' to this node
- bool bFlysLeft = rHTMLWrt.OutFlyFrame( rNode.GetIndex(), 0, HtmlPosition::Prefix );
+ bool bFlysLeft = rWrt.OutFlyFrame( rNode.GetIndex(), 0, HtmlPosition::Prefix );
// Output all frames that are anchored to this node that are supposed to
// be written before the paragraph tag.
if( bFlysLeft )
{
- bFlysLeft = rHTMLWrt.OutFlyFrame( rNode.GetIndex(), 0, HtmlPosition::Before );
+ bFlysLeft = rWrt.OutFlyFrame( rNode.GetIndex(), 0, HtmlPosition::Before );
}
- if( rHTMLWrt.m_pCurrentPam->GetPoint()->nNode == rHTMLWrt.m_pCurrentPam->GetMark()->nNode )
+ if( rWrt.m_pCurrentPam->GetPoint()->GetNode() == rWrt.m_pCurrentPam->GetMark()->GetNode() )
{
- nEnd = rHTMLWrt.m_pCurrentPam->GetMark()->nContent.GetIndex();
+ nEnd = rWrt.m_pCurrentPam->GetMark()->GetContentIndex();
}
// are there any hard attributes that must be written as options?
- rHTMLWrt.m_bTagOn = true;
+ rWrt.m_bTagOn = true;
// now, output the tag of the paragraph
const SwFormat& rFormat = pNd->GetAnyFormatColl();
SwHTMLTextCollOutputInfo aFormatInfo;
- bool bOldLFPossible = rHTMLWrt.m_bLFPossible;
+ bool bOldLFPossible = rWrt.IsLFPossible();
+ bool bOldSpacePreserve = rWrt.IsSpacePreserve();
+ if (rWrt.IsPreserveSpacesOnWritePrefSet())
+ rWrt.SetSpacePreserve(NeedPreserveWhitespace(rStr, rWrt.mbReqIF));
OutHTML_SwFormat( rWrt, rFormat, pNd->GetpSwAttrSet(), aFormatInfo );
// If we didn't open a new line before the paragraph tag, we do that now
- rHTMLWrt.m_bLFPossible = rHTMLWrt.m_nLastParaToken == HtmlTokenId::NONE;
- if( !bOldLFPossible && rHTMLWrt.m_bLFPossible )
- rHTMLWrt.OutNewLine();
+ rWrt.SetLFPossible(rWrt.m_nLastParaToken == HtmlTokenId::NONE);
+ if (!bOldLFPossible && rWrt.IsLFPossible())
+ rWrt.OutNewLine();
// then, the bookmarks (including end tag)
- rHTMLWrt.m_bOutOpts = false;
- rHTMLWrt.OutBookmarks();
+ rWrt.m_bOutOpts = false;
+ rWrt.OutBookmarks();
// now it's a good opportunity again for an LF - if it is still allowed
- if( rHTMLWrt.m_bLFPossible &&
- rHTMLWrt.GetLineLen() >= rHTMLWrt.m_nWishLineLen )
+ // FIXME: for LOK case we set rWrt.m_nWishLineLen as -1, for now keep old flow
+ // when LOK side will be fixed - don't insert new line at the beginning
+ if( rWrt.IsLFPossible() && rWrt.IsPrettyPrint() && rWrt.m_nWishLineLen >= 0 &&
+ rWrt.GetLineLen() >= rWrt.m_nWishLineLen )
{
- rHTMLWrt.OutNewLine();
+ rWrt.OutNewLine();
}
- rHTMLWrt.m_bLFPossible = false;
+ rWrt.SetLFPossible(false);
// find text that originates from an outline numbering
sal_Int32 nOffset = 0;
@@ -2247,66 +2286,65 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
aFullText = aOutlineText;
}
OUString aFootEndNoteSym;
- if( rHTMLWrt.m_pFormatFootnote )
+ if( rWrt.m_pFormatFootnote )
{
- aFootEndNoteSym = rHTMLWrt.GetFootEndNoteSym( *rHTMLWrt.m_pFormatFootnote );
+ aFootEndNoteSym = rWrt.GetFootEndNoteSym( *rWrt.m_pFormatFootnote );
nOffset = nOffset + aFootEndNoteSym.getLength();
aFullText += aFootEndNoteSym;
}
// Table of Contents or other paragraph with dot leaders?
- sal_Int32 nIndexTab = rHTMLWrt.indexOfDotLeaders( nPoolId, rStr );
+ sal_Int32 nIndexTab = rWrt.indexOfDotLeaders( nPoolId, rStr );
if (nIndexTab > -1)
// skip part after the tabulator (page number)
nEnd = nIndexTab;
// are there any hard attributes that must be written as tags?
aFullText += rStr;
- HTMLEndPosLst aEndPosLst( rWrt.m_pDoc, rHTMLWrt.m_xTemplate.get(),
- rHTMLWrt.m_xDfltColor, rHTMLWrt.m_bCfgOutStyles,
- rHTMLWrt.GetHTMLMode(), aFullText,
- rHTMLWrt.m_aScriptTextStyles );
- if( aFormatInfo.pItemSet )
+ HTMLEndPosLst aEndPosLst( rWrt.m_pDoc, rWrt.m_xTemplate.get(),
+ rWrt.m_xDfltColor, rWrt.m_bCfgOutStyles,
+ rWrt.GetHTMLMode(), aFullText,
+ rWrt.m_aScriptTextStyles );
+ if( aFormatInfo.moItemSet )
{
- aEndPosLst.Insert( *aFormatInfo.pItemSet, 0, nEnd + nOffset,
- rHTMLWrt.m_CharFormatInfos, false, true );
+ aEndPosLst.Insert( *aFormatInfo.moItemSet, 0, nEnd + nOffset,
+ rWrt.m_CharFormatInfos, false, true );
}
- if( !aOutlineText.isEmpty() || rHTMLWrt.m_pFormatFootnote )
+ if( !aOutlineText.isEmpty() || rWrt.m_pFormatFootnote )
{
// output paragraph attributes, so that the text gets the attributes of
// the paragraph.
- aEndPosLst.OutStartAttrs( rHTMLWrt, 0 );
+ aEndPosLst.OutStartAttrs( rWrt, 0 );
// Theoretically, we would have to consider the character style of
// the numbering. Because it cannot be set via the UI, let's ignore
// it for now.
if( !aOutlineText.isEmpty() )
- HTMLOutFuncs::Out_String( rWrt.Strm(), aOutlineText,
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters);
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aOutlineText );
- if( rHTMLWrt.m_pFormatFootnote )
+ if( rWrt.m_pFormatFootnote )
{
- rHTMLWrt.OutFootEndNoteSym( *rHTMLWrt.m_pFormatFootnote, aFootEndNoteSym,
- aEndPosLst.GetScriptAtPos( aOutlineText.getLength(), rHTMLWrt.m_nCSS1Script ) );
- rHTMLWrt.m_pFormatFootnote = nullptr;
+ rWrt.OutFootEndNoteSym( *rWrt.m_pFormatFootnote, aFootEndNoteSym,
+ aEndPosLst.GetScriptAtPos( aOutlineText.getLength(), rWrt.m_nCSS1Script ) );
+ rWrt.m_pFormatFootnote = nullptr;
}
}
// for now, correct the start. I.e., if we only output part of the sentence,
// the attributes must be correct there, as well!!
- rHTMLWrt.m_bTextAttr = true;
+ rWrt.m_bTextAttr = true;
size_t nAttrPos = 0;
- sal_Int32 nStrPos = rHTMLWrt.m_pCurrentPam->GetPoint()->nContent.GetIndex();
+ sal_Int32 nStrPos = rWrt.m_pCurrentPam->GetPoint()->GetContentIndex();
const SwTextAttr * pHt = nullptr;
const size_t nCntAttr = pNd->HasHints() ? pNd->GetSwpHints().Count() : 0;
if( nCntAttr && nStrPos > ( pHt = pNd->GetSwpHints().Get(0) )->GetStart() )
{
// Ok, there are earlier attributes that we must output
do {
- aEndPosLst.OutEndAttrs( rHTMLWrt, nStrPos + nOffset );
+ aEndPosLst.OutEndAttrs( rWrt, nStrPos + nOffset );
nAttrPos++;
if( pHt->Which() == RES_TXTATR_FIELD
@@ -2317,7 +2355,7 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
{
const sal_Int32 nHtEnd = *pHt->End(),
nHtStt = pHt->GetStart();
- if( !rHTMLWrt.m_bWriteAll && nHtEnd <= nStrPos )
+ if( !rWrt.m_bWriteAll && nHtEnd <= nStrPos )
continue;
// don't consider empty hints at the beginning - or should we ??
@@ -2325,17 +2363,17 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
continue;
// add attribute to the list
- if( rHTMLWrt.m_bWriteAll )
+ if( rWrt.m_bWriteAll )
aEndPosLst.Insert( pHt->GetAttr(), nHtStt + nOffset,
nHtEnd + nOffset,
- rHTMLWrt.m_CharFormatInfos );
+ rWrt.m_CharFormatInfos );
else
{
sal_Int32 nTmpStt = nHtStt < nStrPos ? nStrPos : nHtStt;
sal_Int32 nTmpEnd = std::min(nHtEnd, nEnd);
aEndPosLst.Insert( pHt->GetAttr(), nTmpStt + nOffset,
nTmpEnd + nOffset,
- rHTMLWrt.m_CharFormatInfos );
+ rWrt.m_CharFormatInfos );
}
continue;
// but don't output it, that will be done later !!
@@ -2345,26 +2383,28 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
( pHt = pNd->GetSwpHints().Get( nAttrPos ) )->GetStart() );
// so, let's output all collected attributes from the string pos on
- aEndPosLst.OutEndAttrs( rHTMLWrt, nStrPos + nOffset );
- aEndPosLst.OutStartAttrs( rHTMLWrt, nStrPos + nOffset );
+ aEndPosLst.OutEndAttrs( rWrt, nStrPos + nOffset );
+ aEndPosLst.OutStartAttrs( rWrt, nStrPos + nOffset );
}
- bool bWriteBreak = (HtmlTokenId::PREFORMTXT_ON != rHTMLWrt.m_nLastParaToken);
- if( bWriteBreak && pNd->GetNumRule() )
+ bool bWriteBreak = (HtmlTokenId::PREFORMTXT_ON != rWrt.m_nLastParaToken);
+ if (bWriteBreak && (pNd->GetNumRule() || rWrt.mbReqIF))
+ {
+ // One line-break is exactly one <br> in the ReqIF case.
bWriteBreak = false;
+ }
{
- HTMLOutContext aContext( rHTMLWrt.m_eDestEnc );
-
+ // Tabs are leading till there is a non-tab since the start of the paragraph.
+ bool bLeadingTab = true;
for( ; nStrPos < nEnd; nStrPos++ )
{
// output the frames that are anchored to the current position
if( bFlysLeft )
{
- aEndPosLst.OutEndAttrs( rHTMLWrt, nStrPos + nOffset, &aContext );
- bFlysLeft = rHTMLWrt.OutFlyFrame( rNode.GetIndex(),
- nStrPos, HtmlPosition::Inside,
- &aContext );
+ aEndPosLst.OutEndAttrs( rWrt, nStrPos + nOffset );
+ bFlysLeft = rWrt.OutFlyFrame( rNode.GetIndex(),
+ nStrPos, HtmlPosition::Inside );
}
bool bOutChar = true;
@@ -2381,16 +2421,16 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
// are ignored)
aEndPosLst.Insert( pHt->GetAttr(), nStrPos + nOffset,
*pHt->End() + nOffset,
- rHTMLWrt.m_CharFormatInfos );
+ rWrt.m_CharFormatInfos );
}
}
else
{
// hints without an end are output last
OSL_ENSURE( !pTextHt, "Why is there already an attribute without an end?" );
- if( rHTMLWrt.m_nTextAttrsToIgnore>0 )
+ if( rWrt.m_nTextAttrsToIgnore>0 )
{
- rHTMLWrt.m_nTextAttrsToIgnore--;
+ rWrt.m_nTextAttrsToIgnore--;
}
else
{
@@ -2413,29 +2453,29 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
if( pTextHt && RES_TXTATR_FLYCNT == pTextHt->Which() )
{
const SwFrameFormat* pFrameFormat =
- static_cast<const SwFormatFlyCnt &>(pTextHt->GetAttr()).GetFrameFormat();
+ pTextHt->GetAttr().StaticWhichCast(RES_TXTATR_FLYCNT).GetFrameFormat();
if( RES_DRAWFRMFMT == pFrameFormat->Which() )
aEndPosLst.Insert( *static_cast<const SwDrawFrameFormat *>(pFrameFormat),
nStrPos + nOffset,
- rHTMLWrt.m_CharFormatInfos );
+ rWrt.m_CharFormatInfos );
}
- aEndPosLst.OutEndAttrs( rHTMLWrt, nStrPos + nOffset, &aContext );
- aEndPosLst.OutStartAttrs( rHTMLWrt, nStrPos + nOffset, &aContext );
+ aEndPosLst.OutEndAttrs( rWrt, nStrPos + nOffset );
+ aEndPosLst.OutStartAttrs( rWrt, nStrPos + nOffset );
if( pTextHt )
{
- rHTMLWrt.m_bLFPossible = rHTMLWrt.m_nLastParaToken == HtmlTokenId::NONE &&
+ rWrt.SetLFPossible(rWrt.m_nLastParaToken == HtmlTokenId::NONE &&
nStrPos > 0 &&
- rStr[nStrPos-1] == ' ';
- sal_uInt16 nCSS1Script = rHTMLWrt.m_nCSS1Script;
- rHTMLWrt.m_nCSS1Script = aEndPosLst.GetScriptAtPos(
+ rStr[nStrPos-1] == ' ');
+ sal_uInt16 nCSS1Script = rWrt.m_nCSS1Script;
+ rWrt.m_nCSS1Script = aEndPosLst.GetScriptAtPos(
nStrPos + nOffset, nCSS1Script );
- HTMLOutFuncs::FlushToAscii( rWrt.Strm(), aContext );
- Out( aHTMLAttrFnTab, pTextHt->GetAttr(), rHTMLWrt );
- rHTMLWrt.m_nCSS1Script = nCSS1Script;
- rHTMLWrt.m_bLFPossible = false;
+ HTMLOutFuncs::FlushToAscii( rWrt.Strm() );
+ Out( aHTMLAttrFnTab, pTextHt->GetAttr(), rWrt );
+ rWrt.m_nCSS1Script = nCSS1Script;
+ rWrt.SetLFPossible(false);
}
if( bOutChar )
@@ -2453,21 +2493,22 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
// try to split a line after about 255 characters
// at a space character unless in a PRE-context
- if( ' ' == c && rHTMLWrt.m_nLastParaToken == HtmlTokenId::NONE )
+ if( ' ' == c && rWrt.m_nLastParaToken == HtmlTokenId::NONE && !rWrt.IsSpacePreserve() )
{
sal_Int32 nLineLen;
- nLineLen = rHTMLWrt.GetLineLen();
+ nLineLen = rWrt.GetLineLen();
sal_Int32 nWordLen = rStr.indexOf( ' ', nStrPos+1 );
if( nWordLen == -1 )
nWordLen = nEnd;
nWordLen -= nStrPos;
- if( nLineLen >= rHTMLWrt.m_nWishLineLen ||
- (nLineLen+nWordLen) >= rHTMLWrt.m_nWishLineLen )
+ if( rWrt.IsPrettyPrint() && rWrt.m_nWishLineLen >= 0 &&
+ (nLineLen >= rWrt.m_nWishLineLen ||
+ (nLineLen+nWordLen) >= rWrt.m_nWishLineLen ) )
{
- HTMLOutFuncs::FlushToAscii( rWrt.Strm(), aContext );
- rHTMLWrt.OutNewLine();
+ HTMLOutFuncs::FlushToAscii( rWrt.Strm() );
+ rWrt.OutNewLine();
bOutChar = false;
}
}
@@ -2476,74 +2517,104 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
{
if( 0x0a == c )
{
- HTMLOutFuncs::FlushToAscii( rWrt.Strm(), aContext );
- HtmlWriter aHtml(rWrt.Strm(), rHTMLWrt.maNamespace);
- aHtml.single(OOO_STRING_SVTOOLS_HTML_linebreak);
+ HTMLOutFuncs::FlushToAscii( rWrt.Strm() );
+ HtmlWriter aHtml(rWrt.Strm(), rWrt.maNamespace);
+ aHtml.prettyPrint(rWrt.IsPrettyPrint());
+ aHtml.single(OOO_STRING_SVTOOLS_HTML_linebreak ""_ostr);
}
else if (c == CH_TXT_ATR_FORMELEMENT)
{
// Placeholder for a single-point fieldmark.
SwPosition aMarkPos = *rWrt.m_pCurrentPam->GetPoint();
- aMarkPos.nContent += nStrPos - aMarkPos.nContent.GetIndex();
- rHTMLWrt.OutPointFieldmarks(aMarkPos);
+ aMarkPos.AdjustContent( nStrPos - aMarkPos.GetContentIndex() );
+ rWrt.OutPointFieldmarks(aMarkPos);
}
else
- HTMLOutFuncs::Out_Char( rWrt.Strm(), c, aContext, &rHTMLWrt.m_aNonConvertableCharacters );
+ {
+ bool bConsumed = false;
+ if (c == '\t')
+ {
+ if (bLeadingTab && rWrt.m_nLeadingTabWidth.has_value())
+ {
+ // Consume a tab if it's leading and we know the number of NBSPs to
+ // be used as a replacement.
+ for (sal_Int32 i = 0; i < *rWrt.m_nLeadingTabWidth; ++i)
+ {
+ rWrt.Strm().WriteOString("&#160;");
+ }
+ bConsumed = true;
+ }
+ }
+ else
+ {
+ // Not a tab -> later tabs are no longer leading.
+ bLeadingTab = false;
+ }
+
+ if (!bConsumed)
+ {
+ HTMLOutFuncs::Out_Char(rWrt.Strm(), c);
+ }
+ }
- // if a paragraph's last character is a hard line break
- // then we need to add an extra <br>
- // because browsers like Mozilla wouldn't add a line for the next paragraph
- bWriteBreak = (0x0a == c) &&
- (HtmlTokenId::PREFORMTXT_ON != rHTMLWrt.m_nLastParaToken);
+ if (!rWrt.mbReqIF)
+ {
+ // if a paragraph's last character is a hard line break
+ // then we need to add an extra <br>
+ // because browsers like Mozilla wouldn't add a line for the next paragraph
+ bWriteBreak = (0x0a == c) &&
+ (HtmlTokenId::PREFORMTXT_ON != rWrt.m_nLastParaToken);
+ }
}
}
}
- HTMLOutFuncs::FlushToAscii( rWrt.Strm(), aContext );
+ HTMLOutFuncs::FlushToAscii( rWrt.Strm() );
}
- aEndPosLst.OutEndAttrs( rHTMLWrt, SAL_MAX_INT32 );
+ aEndPosLst.OutEndAttrs( rWrt, SAL_MAX_INT32 );
// Output the frames that are anchored to the last position
if( bFlysLeft )
- bFlysLeft = rHTMLWrt.OutFlyFrame( rNode.GetIndex(),
+ bFlysLeft = rWrt.OutFlyFrame( rNode.GetIndex(),
nEnd, HtmlPosition::Inside );
OSL_ENSURE( !bFlysLeft, "Not all frames were saved!" );
- rHTMLWrt.m_bTextAttr = false;
+ rWrt.m_bTextAttr = false;
if( bWriteBreak )
{
- bool bEndOfCell = rHTMLWrt.m_bOutTable &&
- rWrt.m_pCurrentPam->GetPoint()->nNode.GetIndex() ==
- rWrt.m_pCurrentPam->GetMark()->nNode.GetIndex();
+ bool bEndOfCell = rWrt.m_bOutTable &&
+ rWrt.m_pCurrentPam->GetPoint()->GetNodeIndex() ==
+ rWrt.m_pCurrentPam->GetMark()->GetNodeIndex();
if( bEndOfCell && !nEnd &&
- rHTMLWrt.IsHTMLMode(HTMLMODE_NBSP_IN_TABLES) )
+ rWrt.IsHTMLMode(HTMLMODE_NBSP_IN_TABLES) )
{
// If the last paragraph of a table cell is empty and we export
// for the MS-IE, we write a &nbsp; instead of a <BR>
- rWrt.Strm().WriteChar( '&' ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_S_nbsp ).WriteChar( ';' );
+ rWrt.Strm().WriteChar( '&' ).WriteOString( OOO_STRING_SVTOOLS_HTML_S_nbsp ).WriteChar( ';' );
}
else
{
- HtmlWriter aHtml(rHTMLWrt.Strm(), rHTMLWrt.maNamespace);
- aHtml.single(OOO_STRING_SVTOOLS_HTML_linebreak);
+ HtmlWriter aHtml(rWrt.Strm(), rWrt.maNamespace);
+ aHtml.prettyPrint(rWrt.IsPrettyPrint());
+ aHtml.single(OOO_STRING_SVTOOLS_HTML_linebreak ""_ostr);
const SvxULSpaceItem& rULSpace = pNd->GetSwAttrSet().Get(RES_UL_SPACE);
if (rULSpace.GetLower() > 0 && !bEndOfCell)
{
- aHtml.single(OOO_STRING_SVTOOLS_HTML_linebreak);
+ aHtml.single(OOO_STRING_SVTOOLS_HTML_linebreak ""_ostr);
}
- rHTMLWrt.m_bLFPossible = true;
+ rWrt.SetLFPossible(true);
}
}
- if( rHTMLWrt.m_bClearLeft || rHTMLWrt.m_bClearRight )
+ if( rWrt.m_bClearLeft || rWrt.m_bClearRight )
{
const char* pString;
- if( rHTMLWrt.m_bClearLeft )
+ if( rWrt.m_bClearLeft )
{
- if( rHTMLWrt.m_bClearRight )
+ if( rWrt.m_bClearRight )
pString = OOO_STRING_SVTOOLS_HTML_AL_all;
else
pString = OOO_STRING_SVTOOLS_HTML_AL_left;
@@ -2553,61 +2624,64 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
pString = OOO_STRING_SVTOOLS_HTML_AL_right;
}
- HtmlWriter aHtml(rHTMLWrt.Strm(), rHTMLWrt.maNamespace);
- aHtml.start(OOO_STRING_SVTOOLS_HTML_linebreak);
+ HtmlWriter aHtml(rWrt.Strm(), rWrt.maNamespace);
+ aHtml.prettyPrint(rWrt.IsPrettyPrint());
+ aHtml.start(OOO_STRING_SVTOOLS_HTML_linebreak ""_ostr);
aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_clear, pString);
aHtml.end();
- rHTMLWrt.m_bClearLeft = false;
- rHTMLWrt.m_bClearRight = false;
+ rWrt.m_bClearLeft = false;
+ rWrt.m_bClearRight = false;
- rHTMLWrt.m_bLFPossible = true;
+ rWrt.SetLFPossible(true);
}
// if an LF is not allowed already, it is allowed once the paragraphs
// ends with a ' '
- if( !rHTMLWrt.m_bLFPossible &&
- rHTMLWrt.m_nLastParaToken == HtmlTokenId::NONE &&
+ if (!rWrt.IsLFPossible() &&
+ rWrt.m_nLastParaToken == HtmlTokenId::NONE &&
nEnd > 0 && ' ' == rStr[nEnd-1] )
- rHTMLWrt.m_bLFPossible = true;
+ rWrt.SetLFPossible(true);
// dot leaders: print the skipped page number in a different span element
if (nIndexTab > -1) {
OString sOut = OUStringToOString(rStr.subView(nIndexTab + 1), RTL_TEXTENCODING_ASCII_US);
- rWrt.Strm().WriteOString( "</span><span>" + sOut + "</span>" );
+ rWrt.Strm().WriteOString( Concat2View("</span><span>" + sOut + "</span>") );
}
- rHTMLWrt.m_bTagOn = false;
+ rWrt.m_bTagOn = false;
OutHTML_SwFormatOff( rWrt, aFormatInfo );
+ rWrt.SetSpacePreserve(bOldSpacePreserve);
// if necessary, close a form
- rHTMLWrt.OutForm( false );
+ rWrt.OutForm( false );
if( bPageBreakBehind )
rWrt.Strm().WriteChar( '\f' );
- return rHTMLWrt;
+ return rWrt;
}
-sal_uInt32 SwHTMLWriter::ToPixel( sal_uInt32 nVal, const bool bVert )
+// In CSS, "px" is 1/96 of inch: https://www.w3.org/TR/css3-values/#absolute-lengths
+sal_uInt32 SwHTMLWriter::ToPixel(sal_uInt32 nTwips)
{
- if( Application::GetDefaultDevice() && nVal )
- {
- Size aSz( bVert ? 0 : nVal, bVert ? nVal : 0 );
- aSz = Application::GetDefaultDevice()->LogicToPixel(aSz, MapMode( MapUnit::MapTwip ));
- nVal = bVert ? aSz.Height() : aSz.Width();
- if( !nVal ) // if there is a Twip, there should be a pixel as well
- nVal = 1;
- }
- return nVal;
+ // if there is a Twip, there should be a pixel as well
+ return nTwips
+ ? std::max(o3tl::convert(nTwips, o3tl::Length::twip, o3tl::Length::px), sal_Int64(1))
+ : 0;
+}
+
+Size SwHTMLWriter::ToPixel(Size aTwips)
+{
+ return Size(ToPixel(aTwips.Width()), ToPixel(aTwips.Height()));
}
-static Writer& OutHTML_CSS1Attr( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutHTML_CSS1Attr( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
// if hints are currently written, we try to write the hint as an
// CSS1 attribute
- if( static_cast<SwHTMLWriter&>(rWrt).m_bCfgOutStyles && static_cast<SwHTMLWriter&>(rWrt).m_bTextAttr )
+ if( rWrt.m_bCfgOutStyles && rWrt.m_bTextAttr )
OutCSS1_HintSpanTag( rWrt, rHt );
return rWrt;
@@ -2615,35 +2689,34 @@ static Writer& OutHTML_CSS1Attr( Writer& rWrt, const SfxPoolItem& rHt )
/* File CHRATR.HXX: */
-static Writer& OutHTML_SvxColor( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutHTML_SvxColor( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- if( rHTMLWrt.m_bOutOpts )
+ if( rWrt.m_bOutOpts )
return rWrt;
- if( !rHTMLWrt.m_bTextAttr && rHTMLWrt.m_bCfgOutStyles && rHTMLWrt.m_bCfgPreferStyles )
+ if( !rWrt.m_bTextAttr && rWrt.m_bCfgOutStyles && rWrt.m_bCfgPreferStyles )
{
// don't write the font color as a tag, if styles are preferred to
// normal tags
return rWrt;
}
- if( rHTMLWrt.m_bTagOn )
+ if( rWrt.m_bTagOn )
{
Color aColor( static_cast<const SvxColorItem&>(rHt).GetValue() );
if( COL_AUTO == aColor )
aColor = COL_BLACK;
- if (rHTMLWrt.mbXHTML)
+ if (rWrt.mbXHTML)
{
- OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span
+ OString sOut = "<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span
" " OOO_STRING_SVTOOLS_HTML_O_style "=";
rWrt.Strm().WriteOString(sOut);
HTMLOutFuncs::Out_Color(rWrt.Strm(), aColor, /*bXHTML=*/true).WriteChar('>');
}
else
{
- OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font " "
+ OString sOut = "<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font " "
OOO_STRING_SVTOOLS_HTML_O_color "=";
rWrt.Strm().WriteOString( sOut );
HTMLOutFuncs::Out_Color( rWrt.Strm(), aColor ).WriteChar( '>' );
@@ -2651,28 +2724,27 @@ static Writer& OutHTML_SvxColor( Writer& rWrt, const SfxPoolItem& rHt )
}
else
{
- if (rHTMLWrt.mbXHTML)
+ if (rWrt.mbXHTML)
HTMLOutFuncs::Out_AsciiTag(
- rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span, false);
+ rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false);
else
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font, false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font), false );
}
return rWrt;
}
-static Writer& OutHTML_SwPosture( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutHTML_SwPosture( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- if( rHTMLWrt.m_bOutOpts )
+ if( rWrt.m_bOutOpts )
return rWrt;
const FontItalic nPosture = static_cast<const SvxPostureItem&>(rHt).GetPosture();
if( ITALIC_NORMAL == nPosture )
{
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_italic, rHTMLWrt.m_bTagOn );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_italic), rWrt.m_bTagOn );
}
- else if( rHTMLWrt.m_bCfgOutStyles && rHTMLWrt.m_bTextAttr )
+ else if( rWrt.m_bCfgOutStyles && rWrt.m_bTextAttr )
{
// maybe as CSS1 attribute?
OutCSS1_HintSpanTag( rWrt, rHt );
@@ -2681,68 +2753,65 @@ static Writer& OutHTML_SwPosture( Writer& rWrt, const SfxPoolItem& rHt )
return rWrt;
}
-static Writer& OutHTML_SvxFont( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutHTML_SvxFont( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- if( rHTMLWrt.m_bOutOpts )
+ if( rWrt.m_bOutOpts )
return rWrt;
- if (IgnorePropertyForReqIF(rHTMLWrt.mbReqIF, "font-family", ""))
+ if (IgnorePropertyForReqIF(rWrt.mbReqIF, "font-family", ""))
{
return rWrt;
}
- if( rHTMLWrt.m_bTagOn )
+ if( rWrt.m_bTagOn )
{
OUString aNames;
SwHTMLWriter::PrepareFontList( static_cast<const SvxFontItem&>(rHt), aNames, 0,
- rHTMLWrt.IsHTMLMode(HTMLMODE_FONT_GENERIC) );
- if (rHTMLWrt.mbXHTML)
+ rWrt.IsHTMLMode(HTMLMODE_FONT_GENERIC) );
+ if (rWrt.mbXHTML)
{
- OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span
+ OString sOut = "<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span
" " OOO_STRING_SVTOOLS_HTML_O_style "=\"font-family: ";
rWrt.Strm().WriteOString(sOut);
- HTMLOutFuncs::Out_String(rWrt.Strm(), aNames, rHTMLWrt.m_eDestEnc,
- &rHTMLWrt.m_aNonConvertableCharacters)
- .WriteCharPtr("\">");
+ HTMLOutFuncs::Out_String(rWrt.Strm(), aNames)
+ .WriteOString("\">");
}
else
{
- OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font " "
+ OString sOut = "<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font " "
OOO_STRING_SVTOOLS_HTML_O_face "=\"";
rWrt.Strm().WriteOString( sOut );
- HTMLOutFuncs::Out_String( rWrt.Strm(), aNames, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters )
- .WriteCharPtr( "\">" );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aNames )
+ .WriteOString( "\">" );
}
}
else
{
- if (rHTMLWrt.mbXHTML)
+ if (rWrt.mbXHTML)
HTMLOutFuncs::Out_AsciiTag(
- rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span, false);
+ rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false);
else
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font, false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font), false );
}
return rWrt;
}
-static Writer& OutHTML_SvxFontHeight( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutHTML_SvxFontHeight( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- if( rHTMLWrt.m_bOutOpts )
+ if( rWrt.m_bOutOpts )
return rWrt;
- if (IgnorePropertyForReqIF(rHTMLWrt.mbReqIF, "font-size", ""))
+ if (IgnorePropertyForReqIF(rWrt.mbReqIF, "font-size", ""))
{
return rWrt;
}
- if( rHTMLWrt.m_bTagOn )
+ if( rWrt.m_bTagOn )
{
- if (rHTMLWrt.mbXHTML)
+ if (rWrt.mbXHTML)
{
- OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span;
+ OString sOut = "<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span;
sal_uInt32 nHeight = static_cast<const SvxFontHeightItem&>(rHt).GetHeight();
// Twips -> points.
@@ -2753,15 +2822,15 @@ static Writer& OutHTML_SvxFontHeight( Writer& rWrt, const SfxPoolItem& rHt )
}
else
{
- OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font;
+ OString sOut = "<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font;
sal_uInt32 nHeight = static_cast<const SvxFontHeightItem&>(rHt).GetHeight();
- sal_uInt16 nSize = rHTMLWrt.GetHTMLFontSize( nHeight );
+ sal_uInt16 nSize = rWrt.GetHTMLFontSize( nHeight );
sOut += " " OOO_STRING_SVTOOLS_HTML_O_size "=\"" +
OString::number(static_cast<sal_Int32>(nSize)) + "\"";
rWrt.Strm().WriteOString( sOut );
- if( rHTMLWrt.m_bCfgOutStyles && rHTMLWrt.m_bTextAttr )
+ if( rWrt.m_bCfgOutStyles && rWrt.m_bTextAttr )
{
// always export font size as CSS option, too
OutCSS1_HintStyleOpt( rWrt, rHt );
@@ -2771,52 +2840,50 @@ static Writer& OutHTML_SvxFontHeight( Writer& rWrt, const SfxPoolItem& rHt )
}
else
{
- if (rHTMLWrt.mbXHTML)
+ if (rWrt.mbXHTML)
HTMLOutFuncs::Out_AsciiTag(
- rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span, false);
+ rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false);
else
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font, false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font), false );
}
return rWrt;
}
-static Writer& OutHTML_SvxLanguage( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutHTML_SvxLanguage( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- if( rHTMLWrt.m_bOutOpts )
+ if( rWrt.m_bOutOpts )
return rWrt;
LanguageType eLang = static_cast<const SvxLanguageItem &>(rHt).GetLanguage();
if( LANGUAGE_DONTKNOW == eLang )
return rWrt;
- if( rHTMLWrt.m_bTagOn )
+ if( rWrt.m_bTagOn )
{
- OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span;
+ OString sOut = "<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span;
rWrt.Strm().WriteOString( sOut );
- rHTMLWrt.OutLanguage( static_cast<const SvxLanguageItem &>(rHt).GetLanguage() );
+ rWrt.OutLanguage( static_cast<const SvxLanguageItem &>(rHt).GetLanguage() );
rWrt.Strm().WriteChar( '>' );
}
else
{
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span, false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false );
}
return rWrt;
}
-static Writer& OutHTML_SwWeight( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutHTML_SwWeight( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- if( rHTMLWrt.m_bOutOpts )
+ if( rWrt.m_bOutOpts )
return rWrt;
const FontWeight nBold = static_cast<const SvxWeightItem&>(rHt).GetWeight();
if( WEIGHT_BOLD == nBold )
{
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_bold, rHTMLWrt.m_bTagOn );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_bold), rWrt.m_bTagOn );
}
- else if( rHTMLWrt.m_bCfgOutStyles && rHTMLWrt.m_bTextAttr )
+ else if( rWrt.m_bCfgOutStyles && rWrt.m_bTextAttr )
{
// maybe as CSS1 attribute ?
OutCSS1_HintSpanTag( rWrt, rHt );
@@ -2825,19 +2892,18 @@ static Writer& OutHTML_SwWeight( Writer& rWrt, const SfxPoolItem& rHt )
return rWrt;
}
-static Writer& OutHTML_SwCrossedOut( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutHTML_SwCrossedOut( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- if( rHTMLWrt.m_bOutOpts )
+ if( rWrt.m_bOutOpts )
return rWrt;
// Because of Netscape, we output STRIKE and not S!
const FontStrikeout nStrike = static_cast<const SvxCrossedOutItem&>(rHt).GetStrikeout();
- if( STRIKEOUT_NONE != nStrike && !rHTMLWrt.mbReqIF )
+ if( STRIKEOUT_NONE != nStrike && !rWrt.mbReqIF )
{
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_strike, rHTMLWrt.m_bTagOn );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_strike), rWrt.m_bTagOn );
}
- else if( rHTMLWrt.m_bCfgOutStyles && rHTMLWrt.m_bTextAttr )
+ else if( rWrt.m_bCfgOutStyles && rWrt.m_bTextAttr )
{
// maybe as CSS1 attribute?
OutCSS1_HintSpanTag( rWrt, rHt );
@@ -2846,10 +2912,9 @@ static Writer& OutHTML_SwCrossedOut( Writer& rWrt, const SfxPoolItem& rHt )
return rWrt;
}
-static Writer& OutHTML_SvxEscapement( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutHTML_SvxEscapement( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- if( rHTMLWrt.m_bOutOpts )
+ if( rWrt.m_bOutOpts )
return rWrt;
const SvxEscapement eEscape =
@@ -2857,17 +2922,17 @@ static Writer& OutHTML_SvxEscapement( Writer& rWrt, const SfxPoolItem& rHt )
OString aTag;
switch( eEscape )
{
- case SvxEscapement::Superscript: aTag = OOO_STRING_SVTOOLS_HTML_superscript; break;
- case SvxEscapement::Subscript: aTag = OOO_STRING_SVTOOLS_HTML_subscript; break;
+ case SvxEscapement::Superscript: aTag = OOO_STRING_SVTOOLS_HTML_superscript ""_ostr; break;
+ case SvxEscapement::Subscript: aTag = OOO_STRING_SVTOOLS_HTML_subscript ""_ostr; break;
default:
;
}
if( !aTag.isEmpty() )
{
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + aTag, rHTMLWrt.m_bTagOn );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aTag), rWrt.m_bTagOn );
}
- else if( rHTMLWrt.m_bCfgOutStyles && rHTMLWrt.m_bTextAttr )
+ else if( rWrt.m_bCfgOutStyles && rWrt.m_bTextAttr )
{
// maybe as CSS1 attribute?
OutCSS1_HintSpanTag( rWrt, rHt );
@@ -2876,18 +2941,17 @@ static Writer& OutHTML_SvxEscapement( Writer& rWrt, const SfxPoolItem& rHt )
return rWrt;
}
-static Writer& OutHTML_SwUnderline( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutHTML_SwUnderline( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- if( rHTMLWrt.m_bOutOpts )
+ if( rWrt.m_bOutOpts )
return rWrt;
const FontLineStyle eUnder = static_cast<const SvxUnderlineItem&>(rHt).GetLineStyle();
- if( LINESTYLE_NONE != eUnder && !rHTMLWrt.mbReqIF )
+ if( LINESTYLE_NONE != eUnder && !rWrt.mbReqIF )
{
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_underline, rHTMLWrt.m_bTagOn );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_underline), rWrt.m_bTagOn );
}
- else if( rHTMLWrt.m_bCfgOutStyles && rHTMLWrt.m_bTextAttr )
+ else if( rWrt.m_bCfgOutStyles && rWrt.m_bTextAttr )
{
// maybe as CSS1 attribute?
OutCSS1_HintSpanTag( rWrt, rHt );
@@ -2896,34 +2960,31 @@ static Writer& OutHTML_SwUnderline( Writer& rWrt, const SfxPoolItem& rHt )
return rWrt;
}
-static Writer& OutHTML_SwFlyCnt( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutHTML_SwFlyCnt( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
const SwFormatFlyCnt& rFlyCnt = static_cast<const SwFormatFlyCnt&>(rHt);
const SwFrameFormat& rFormat = *rFlyCnt.GetFrameFormat();
const SdrObject *pSdrObj = nullptr;
- SwHTMLFrameType eType =
- static_cast<SwHTMLFrameType>(rHTMLWrt.GuessFrameType( rFormat, pSdrObj ));
- AllHtmlFlags nMode = aHTMLOutFrameAsCharTable[eType][rHTMLWrt.m_nExportMode];
- rHTMLWrt.OutFrameFormat( nMode, rFormat, pSdrObj );
+ SwHTMLFrameType eType = rWrt.GuessFrameType( rFormat, pSdrObj );
+ AllHtmlFlags nMode = getHTMLOutFrameAsCharTable(eType, rWrt.m_nExportMode);
+ rWrt.OutFrameFormat( nMode, rFormat, pSdrObj );
return rWrt;
}
// This is now our Blink item. Blinking is activated by setting the item to
// true!
-static Writer& OutHTML_SwBlink( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutHTML_SwBlink( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- if( rHTMLWrt.m_bOutOpts )
+ if( rWrt.m_bOutOpts )
return rWrt;
if( static_cast<const SvxBlinkItem&>(rHt).GetValue() )
{
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_blink, rHTMLWrt.m_bTagOn );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_blink), rWrt.m_bTagOn );
}
- else if( rHTMLWrt.m_bCfgOutStyles && rHTMLWrt.m_bTextAttr )
+ else if( rWrt.m_bCfgOutStyles && rWrt.m_bTextAttr )
{
// maybe as CSS1 attribute?
OutCSS1_HintSpanTag( rWrt, rHt );
@@ -2932,10 +2993,8 @@ static Writer& OutHTML_SwBlink( Writer& rWrt, const SfxPoolItem& rHt )
return rWrt;
}
-Writer& OutHTML_INetFormat( Writer& rWrt, const SwFormatINetFormat& rINetFormat, bool bOn )
+SwHTMLWriter& OutHTML_INetFormat( SwHTMLWriter& rWrt, const SwFormatINetFormat& rINetFormat, bool bOn )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
OUString aURL( rINetFormat.GetValue() );
const SvxMacroTableDtor *pMacTable = rINetFormat.GetMacroTable();
bool bEvents = pMacTable != nullptr && !pMacTable->empty();
@@ -2947,19 +3006,19 @@ Writer& OutHTML_INetFormat( Writer& rWrt, const SwFormatINetFormat& rINetFormat,
// bOn controls if we are writing the opening or closing tag
if( !bOn )
{
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor, false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor), false );
return rWrt;
}
- OString sOut("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor);
+ OString sOut("<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor);
bool bScriptDependent = false;
{
const SwCharFormat* pFormat = rWrt.m_pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool(
RES_POOLCHR_INET_NORMAL );
std::unique_ptr<SwHTMLFormatInfo> pFormatInfo(new SwHTMLFormatInfo(pFormat));
- auto const it = rHTMLWrt.m_CharFormatInfos.find( pFormatInfo );
- if (it != rHTMLWrt.m_CharFormatInfos.end())
+ auto const it = rWrt.m_CharFormatInfos.find( pFormatInfo );
+ if (it != rWrt.m_CharFormatInfos.end())
{
bScriptDependent = (*it)->bScriptDependent;
}
@@ -2969,8 +3028,8 @@ Writer& OutHTML_INetFormat( Writer& rWrt, const SwFormatINetFormat& rINetFormat,
const SwCharFormat* pFormat = rWrt.m_pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool(
RES_POOLCHR_INET_VISIT );
std::unique_ptr<SwHTMLFormatInfo> pFormatInfo(new SwHTMLFormatInfo(pFormat));
- auto const it = rHTMLWrt.m_CharFormatInfos.find( pFormatInfo );
- if (it != rHTMLWrt.m_CharFormatInfos.end())
+ auto const it = rWrt.m_CharFormatInfos.find( pFormatInfo );
+ if (it != rWrt.m_CharFormatInfos.end())
{
bScriptDependent = (*it)->bScriptDependent;
}
@@ -2980,7 +3039,7 @@ Writer& OutHTML_INetFormat( Writer& rWrt, const SwFormatINetFormat& rINetFormat,
{
sOut += " " OOO_STRING_SVTOOLS_HTML_O_class "=\"";
const char* pStr = nullptr;
- switch( rHTMLWrt.m_nCSS1Script )
+ switch( rWrt.m_nCSS1Script )
{
case CSS1_OUTMODE_WESTERN:
pStr = "western";
@@ -2992,11 +3051,11 @@ Writer& OutHTML_INetFormat( Writer& rWrt, const SwFormatINetFormat& rINetFormat,
pStr = "ctl";
break;
}
- sOut += pStr + OStringLiteral("\"");
+ sOut += pStr + OString::Concat("\"");
}
rWrt.Strm().WriteOString( sOut );
- sOut = "";
+ sOut = ""_ostr;
OUString sRel;
@@ -3013,17 +3072,16 @@ Writer& OutHTML_INetFormat( Writer& rWrt, const SwFormatINetFormat& rINetFormat,
sOut += " " OOO_STRING_SVTOOLS_HTML_O_href "=\"";
rWrt.Strm().WriteOString( sOut );
- rHTMLWrt.OutHyperlinkHRefValue( aURL );
- sOut = "\"";
+ rWrt.OutHyperlinkHRefValue( aURL );
+ sOut = "\""_ostr;
}
if( !rINetFormat.GetName().isEmpty() )
{
sOut += " " OOO_STRING_SVTOOLS_HTML_O_name "=\"";
rWrt.Strm().WriteOString( sOut );
- HTMLOutFuncs::Out_String( rWrt.Strm(), rINetFormat.GetName(),
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
- sOut = "\"";
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rINetFormat.GetName() );
+ sOut = "\""_ostr;
}
const OUString& rTarget = rINetFormat.GetTargetFrame();
@@ -3031,8 +3089,8 @@ Writer& OutHTML_INetFormat( Writer& rWrt, const SwFormatINetFormat& rINetFormat,
{
sOut += " " OOO_STRING_SVTOOLS_HTML_O_target "=\"";
rWrt.Strm().WriteOString( sOut );
- HTMLOutFuncs::Out_String( rWrt.Strm(), rTarget, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
- sOut = "\"";
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rTarget );
+ sOut = "\""_ostr;
}
if( !sRel.isEmpty() )
@@ -3043,29 +3101,26 @@ Writer& OutHTML_INetFormat( Writer& rWrt, const SwFormatINetFormat& rINetFormat,
if( bEvents )
HTMLOutFuncs::Out_Events( rWrt.Strm(), *pMacTable, aAnchorEventTable,
- rHTMLWrt.m_bCfgStarBasic, rHTMLWrt.m_eDestEnc,
- &rHTMLWrt.m_aNonConvertableCharacters );
- rWrt.Strm().WriteCharPtr( ">" );
+ rWrt.m_bCfgStarBasic );
+ rWrt.Strm().WriteOString( ">" );
return rWrt;
}
-static Writer& OutHTML_SwFormatINetFormat( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutHTML_SwFormatINetFormat( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
- if( rHTMLWrt.m_bOutOpts )
+ if( rWrt.m_bOutOpts )
return rWrt;
const SwFormatINetFormat& rINetFormat = static_cast<const SwFormatINetFormat&>(rHt);
- if( rHTMLWrt.m_bTagOn )
+ if( rWrt.m_bTagOn )
{
// if necessary, temporarily close an attribute that is still open
- if( !rHTMLWrt.m_aINetFormats.empty() )
+ if( !rWrt.m_aINetFormats.empty() )
{
SwFormatINetFormat *pINetFormat =
- rHTMLWrt.m_aINetFormats.back();
+ rWrt.m_aINetFormats.back();
OutHTML_INetFormat( rWrt, *pINetFormat, false );
}
@@ -3074,25 +3129,25 @@ static Writer& OutHTML_SwFormatINetFormat( Writer& rWrt, const SfxPoolItem& rHt
// and remember it
SwFormatINetFormat *pINetFormat = new SwFormatINetFormat( rINetFormat );
- rHTMLWrt.m_aINetFormats.push_back( pINetFormat );
+ rWrt.m_aINetFormats.push_back( pINetFormat );
}
else
{
OutHTML_INetFormat( rWrt, rINetFormat, false );
- OSL_ENSURE( rHTMLWrt.m_aINetFormats.size(), "there must be a URL attribute missing" );
- if( !rHTMLWrt.m_aINetFormats.empty() )
+ OSL_ENSURE( rWrt.m_aINetFormats.size(), "there must be a URL attribute missing" );
+ if( !rWrt.m_aINetFormats.empty() )
{
// get its own attribute from the stack
- SwFormatINetFormat *pINetFormat = rHTMLWrt.m_aINetFormats.back();
- rHTMLWrt.m_aINetFormats.pop_back();
+ SwFormatINetFormat *pINetFormat = rWrt.m_aINetFormats.back();
+ rWrt.m_aINetFormats.pop_back();
delete pINetFormat;
}
- if( !rHTMLWrt.m_aINetFormats.empty() )
+ if( !rWrt.m_aINetFormats.empty() )
{
// there is still an attribute on the stack that must be reopened
- SwFormatINetFormat *pINetFormat = rHTMLWrt.m_aINetFormats.back();
+ SwFormatINetFormat *pINetFormat = rWrt.m_aINetFormats.back();
OutHTML_INetFormat( rWrt, *pINetFormat, true );
}
}
@@ -3100,10 +3155,9 @@ static Writer& OutHTML_SwFormatINetFormat( Writer& rWrt, const SfxPoolItem& rHt
return rWrt;
}
-static Writer& OutHTML_SwTextCharFormat( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutHTML_SwTextCharFormat( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- if( rHTMLWrt.m_bOutOpts )
+ if( rWrt.m_bOutOpts )
return rWrt;
const SwFormatCharFormat& rChrFormat = static_cast<const SwFormatCharFormat&>(rHt);
@@ -3115,22 +3169,22 @@ static Writer& OutHTML_SwTextCharFormat( Writer& rWrt, const SfxPoolItem& rHt )
}
std::unique_ptr<SwHTMLFormatInfo> pTmpInfo(new SwHTMLFormatInfo(pFormat));
- SwHTMLFormatInfos::const_iterator it = rHTMLWrt.m_CharFormatInfos.find(pTmpInfo);
- if (it == rHTMLWrt.m_CharFormatInfos.end())
+ SwHTMLFormatInfos::const_iterator it = rWrt.m_CharFormatInfos.find(pTmpInfo);
+ if (it == rWrt.m_CharFormatInfos.end())
return rWrt;
const SwHTMLFormatInfo *pFormatInfo = it->get();
OSL_ENSURE( pFormatInfo, "Why is there no information about the character style?" );
- if( rHTMLWrt.m_bTagOn )
+ if( rWrt.m_bTagOn )
{
- OString sOut = "<" + rHTMLWrt.GetNamespace();
+ OString sOut = "<" + rWrt.GetNamespace();
if( !pFormatInfo->aToken.isEmpty() )
sOut += pFormatInfo->aToken;
else
- sOut += OString(OOO_STRING_SVTOOLS_HTML_span);
+ sOut += OOO_STRING_SVTOOLS_HTML_span;
- if( rHTMLWrt.m_bCfgOutStyles &&
+ if( rWrt.m_bCfgOutStyles &&
(!pFormatInfo->aClass.isEmpty() || pFormatInfo->bScriptDependent) )
{
sOut += " " OOO_STRING_SVTOOLS_HTML_O_class "=\"";
@@ -3140,7 +3194,7 @@ static Writer& OutHTML_SwTextCharFormat( Writer& rWrt, const SfxPoolItem& rHt )
{
if( !aClass.isEmpty() )
aClass += "-";
- switch( rHTMLWrt.m_nCSS1Script )
+ switch( rWrt.m_nCSS1Script )
{
case CSS1_OUTMODE_WESTERN:
aClass += "western";
@@ -3153,9 +3207,8 @@ static Writer& OutHTML_SwTextCharFormat( Writer& rWrt, const SfxPoolItem& rHt )
break;
}
}
- HTMLOutFuncs::Out_String( rWrt.Strm(), aClass,
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
- sOut = "\"";
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aClass );
+ sOut = "\""_ostr;
}
sOut += ">";
rWrt.Strm().WriteOString( sOut );
@@ -3164,16 +3217,15 @@ static Writer& OutHTML_SwTextCharFormat( Writer& rWrt, const SfxPoolItem& rHt )
{
OString aTag = !pFormatInfo->aToken.isEmpty() ? pFormatInfo->aToken.getStr()
: OOO_STRING_SVTOOLS_HTML_span;
- HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), rHTMLWrt.GetNamespace() + aTag, false);
+ HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aTag), false);
}
return rWrt;
}
-static Writer& OutHTML_SvxAdjust( Writer& rWrt, const SfxPoolItem& rHt )
+static SwHTMLWriter& OutHTML_SvxAdjust( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- if( !rHTMLWrt.m_bOutOpts || !rHTMLWrt.m_bTagOn )
+ if( !rWrt.m_bOutOpts || !rWrt.m_bTagOn )
return rWrt;
const SvxAdjustItem& rAdjust = static_cast<const SvxAdjustItem&>(rHt);
@@ -3189,7 +3241,7 @@ static Writer& OutHTML_SvxAdjust( Writer& rWrt, const SfxPoolItem& rHt )
}
if( pStr )
{
- OString sOut = OStringLiteral(" " OOO_STRING_SVTOOLS_HTML_O_align "=\"") +
+ OString sOut = OString::Concat(" " OOO_STRING_SVTOOLS_HTML_O_align "=\"") +
pStr + "\"";
rWrt.Strm().WriteOString( sOut );
}
@@ -3259,20 +3311,20 @@ SwAttrFnTab aHTMLAttrFnTab = {
/* RES_TXTATR_CJK_RUBY */ nullptr,
/* RES_TXTATR_UNKNOWN_CONTAINER */ nullptr,
/* RES_TXTATR_INPUTFIELD */ OutHTML_SwFormatField,
+/* RES_TXTATR_CONTENTCONTROL */ nullptr,
/* RES_TXTATR_FIELD */ OutHTML_SwFormatField,
/* RES_TXTATR_FLYCNT */ OutHTML_SwFlyCnt,
/* RES_TXTATR_FTN */ OutHTML_SwFormatFootnote,
/* RES_TXTATR_ANNOTATION */ OutHTML_SwFormatField,
-/* RES_TXTATR_DUMMY3 */ nullptr,
+/* RES_TXTATR_LINEBREAK */ OutHTML_SwFormatLineBreak,
/* RES_TXTATR_DUMMY1 */ nullptr, // Dummy:
-/* RES_TXTATR_DUMMY2 */ nullptr, // Dummy:
/* RES_PARATR_LINESPACING */ nullptr,
/* RES_PARATR_ADJUST */ OutHTML_SvxAdjust,
/* RES_PARATR_SPLIT */ nullptr,
-/* RES_PARATR_WIDOWS */ nullptr,
/* RES_PARATR_ORPHANS */ nullptr,
+/* RES_PARATR_WIDOWS */ nullptr,
/* RES_PARATR_TABSTOP */ nullptr,
/* RES_PARATR_HYPHENZONE*/ nullptr,
/* RES_PARATR_DROP */ OutHTML_CSS1Attr,
@@ -3297,6 +3349,12 @@ SwAttrFnTab aHTMLAttrFnTab = {
/* RES_FILL_ORDER */ nullptr,
/* RES_FRM_SIZE */ nullptr,
/* RES_PAPER_BIN */ nullptr,
+/* RES_MARGIN_FIRSTLINE */ nullptr,
+/* RES_MARGIN_TEXTLEFT */ nullptr,
+/* RES_MARGIN_RIGHT */ nullptr,
+/* RES_MARGIN_LEFT */ nullptr,
+/* RES_MARGIN_GUTTER */ nullptr,
+/* RES_MARGIN_GUTTER_RIGHT */ nullptr,
/* RES_LR_SPACE */ nullptr,
/* RES_UL_SPACE */ nullptr,
/* RES_PAGEDESC */ nullptr,
@@ -3329,6 +3387,7 @@ SwAttrFnTab aHTMLAttrFnTab = {
/* RES_FRAMEDIR */ nullptr,
/* RES_HEADER_FOOTER_EAT_SPACING */ nullptr,
/* RES_ROW_SPLIT */ nullptr,
+/* RES_FLY_SPLIT */ nullptr,
/* RES_FOLLOW_TEXT_FLOW */ nullptr,
/* RES_COLLAPSING_BORDERS */ nullptr,
/* RES_WRAP_INFLUENCE_ON_OBJPOS */ nullptr,
@@ -3337,6 +3396,9 @@ SwAttrFnTab aHTMLAttrFnTab = {
/* RES_FRMATR_CONDITIONAL_STYLE_NAME */ nullptr,
/* RES_FRMATR_GRABBAG */ nullptr,
/* RES_TEXT_VERT_ADJUST */ nullptr,
+/* RES_BACKGROUND_FULL_SIZE */ nullptr,
+/* RES_RTL_GUTTER */ nullptr,
+/* RES_DECORATIVE */ nullptr,
/* RES_GRFATR_MIRRORGRF */ nullptr,
/* RES_GRFATR_CROPGRF */ nullptr,
@@ -3350,8 +3412,6 @@ SwAttrFnTab aHTMLAttrFnTab = {
/* RES_GRFATR_INVERT */ nullptr,
/* RES_GRFATR_TRANSPARENCY */ nullptr,
/* RES_GRFATR_DRWAMODE */ nullptr,
-/* RES_GRFATR_DUMMY1 */ nullptr,
-/* RES_GRFATR_DUMMY2 */ nullptr,
/* RES_GRFATR_DUMMY3 */ nullptr,
/* RES_GRFATR_DUMMY4 */ nullptr,
/* RES_GRFATR_DUMMY5 */ nullptr,
diff --git a/sw/source/filter/html/htmlbas.cxx b/sw/source/filter/html/htmlbas.cxx
index fecead1e542e..3500a631f108 100644
--- a/sw/source/filter/html/htmlbas.cxx
+++ b/sw/source/filter/html/htmlbas.cxx
@@ -189,7 +189,7 @@ void SwHTMLParser::AddScriptSource()
if( nPos != -1 )
{
m_aBasicLib =
- aToken.copy( nPos + sizeof(OOO_STRING_SVTOOLS_HTML_SB_library) - 1 );
+ aToken.subView( nPos + sizeof(OOO_STRING_SVTOOLS_HTML_SB_library) - 1 );
m_aBasicLib = comphelper::string::strip(m_aBasicLib, ' ');
}
}
@@ -200,7 +200,7 @@ void SwHTMLParser::AddScriptSource()
if( nPos != -1 )
{
m_aBasicModule =
- aToken.copy( nPos + sizeof(OOO_STRING_SVTOOLS_HTML_SB_module) - 1 );
+ aToken.subView( nPos + sizeof(OOO_STRING_SVTOOLS_HTML_SB_module) - 1 );
m_aBasicModule = comphelper::string::strip(m_aBasicModule, ' ');
}
}
@@ -284,16 +284,15 @@ void SwHTMLWriter::OutBasic(const SwHTMLWriter & rHTMLWrt)
"=\"text/x-";
Strm().WriteOString( sOut );
// Entities aren't welcome here
- Strm().WriteOString( OUStringToOString(sLang, m_eDestEnc) )
- .WriteCharPtr( "\">" );
+ Strm().WriteOString( OUStringToOString(sLang, RTL_TEXTENCODING_UTF8) )
+ .WriteOString( "\">" );
}
const OUString& rModName = pModule->GetName();
- Strm().WriteCharPtr( SAL_NEWLINE_STRING ); // don't indent!
+ Strm().WriteOString( SAL_NEWLINE_STRING ); // don't indent!
HTMLOutFuncs::OutScript( Strm(), GetBaseURL(), pModule->GetSource32(),
sLang, STARBASIC, OUString(),
- &rLibName, &rModName,
- m_eDestEnc, &m_aNonConvertableCharacters );
+ &rLibName, &rModName );
}
}
#endif
@@ -325,7 +324,7 @@ void SwHTMLWriter::OutBasicBodyEvents()
if( !aDocTable.empty() )
HTMLOutFuncs::Out_Events( Strm(), aDocTable, aBodyEventTable,
- m_bCfgStarBasic, m_eDestEnc, &m_aNonConvertableCharacters );
+ m_bCfgStarBasic );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx
index 2560ef45bb8d..92e5d0d94d3a 100644
--- a/sw/source/filter/html/htmlcss1.cxx
+++ b/sw/source/filter/html/htmlcss1.cxx
@@ -34,6 +34,7 @@
#include <editeng/fontitem.hxx>
#include <editeng/langitem.hxx>
#include <editeng/frmdiritem.hxx>
+#include <o3tl/string_view.hxx>
#include <svtools/htmltokn.h>
#include <svtools/htmlkywd.hxx>
#include <fmtpdsc.hxx>
@@ -178,14 +179,12 @@ bool SwCSS1Parser::SetFormatBreak( SfxItemSet& rItemSet,
static void SetCharFormatAttrs( SwCharFormat *pCharFormat, SfxItemSet& rItemSet )
{
- const SfxPoolItem *pItem;
- static const sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONTSIZE,RES_CHRATR_CJK_FONTSIZE,
+ static const TypedWhichId<SvxFontHeightItem> aWhichIds[3] = { RES_CHRATR_FONTSIZE,RES_CHRATR_CJK_FONTSIZE,
RES_CHRATR_CTL_FONTSIZE };
- for(sal_uInt16 i : aWhichIds)
+ for(auto const & i : aWhichIds)
{
- if( SfxItemState::SET == rItemSet.GetItemState( i, false,
- &pItem ) &&
- static_cast<const SvxFontHeightItem *>(pItem)->GetProp() != 100)
+ const SvxFontHeightItem* pItem = rItemSet.GetItemIfSet( i, false );
+ if( pItem && pItem->GetProp() != 100)
{
// percentage values at the FontHeight item aren't supported
rItemSet.ClearItem( i );
@@ -194,19 +193,19 @@ static void SetCharFormatAttrs( SwCharFormat *pCharFormat, SfxItemSet& rItemSet
pCharFormat->SetFormatAttr( rItemSet );
- if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false, &pItem ) )
+ if( const SvxBrushItem* pItem = rItemSet.GetItemIfSet( RES_BACKGROUND, false ) )
{
// A Brush-Item with RES_BACKGROUND must be converted to one
// with RES_CHRATR_BACKGROUND
- SvxBrushItem aBrushItem( *static_cast<const SvxBrushItem *>(pItem) );
+ SvxBrushItem aBrushItem( *pItem );
aBrushItem.SetWhich( RES_CHRATR_BACKGROUND );
pCharFormat->SetFormatAttr( aBrushItem );
}
- if( SfxItemState::SET == rItemSet.GetItemState( RES_BOX, false, &pItem ) )
+ if( const SvxBoxItem* pItem = rItemSet.GetItemIfSet( RES_BOX, false ) )
{
- SvxBoxItem aBoxItem( *static_cast<const SvxBoxItem *>(pItem) );
+ SvxBoxItem aBoxItem( *pItem );
aBoxItem.SetWhich( RES_CHRATR_BOX );
pCharFormat->SetFormatAttr( aBoxItem );
}
@@ -269,39 +268,22 @@ static void SetTextCollAttrs( SwTextFormatColl *pColl, SfxItemSet& rItemSet,
SwCSS1Parser *pCSS1Parser )
{
const SfxItemSet& rCollItemSet = pColl->GetAttrSet();
- const SfxPoolItem *pCollItem, *pItem;
- // left, right border and first line indentation
- if( (rPropInfo.m_bLeftMargin || rPropInfo.m_bRightMargin ||
- rPropInfo.m_bTextIndent) &&
- (!rPropInfo.m_bLeftMargin || !rPropInfo.m_bRightMargin ||
- !rPropInfo.m_bTextIndent) &&
- SfxItemState::SET == rCollItemSet.GetItemState(RES_LR_SPACE,true,&pCollItem) &&
- SfxItemState::SET == rItemSet.GetItemState(RES_LR_SPACE,false,&pItem) )
- {
- const SvxLRSpaceItem *pLRItem = static_cast<const SvxLRSpaceItem *>(pItem);
-
- SvxLRSpaceItem aLRItem( *static_cast<const SvxLRSpaceItem *>(pCollItem) );
- if( rPropInfo.m_bLeftMargin )
- aLRItem.SetTextLeft( pLRItem->GetTextLeft() );
- if( rPropInfo.m_bRightMargin )
- aLRItem.SetRight( pLRItem->GetRight() );
- if( rPropInfo.m_bTextIndent )
- aLRItem.SetTextFirstLineOffset( pLRItem->GetTextFirstLineOffset() );
-
- rItemSet.Put( aLRItem );
- }
+ // note: there was some SvxLRSpaceItem code here that was nonobvious
+ // but it looks like the only cases in which it would be required
+ // with split items are if some nProp != 100 or if SetAutoFirst() had
+ // been called (on the pColl items) but it looks like none of these are
+ // possible in HTML import.
// top and bottom border
+ const SvxULSpaceItem* pCollULItem;
+ const SvxULSpaceItem* pULItem;
if( (rPropInfo.m_bTopMargin || rPropInfo.m_bBottomMargin) &&
(!rPropInfo.m_bTopMargin || !rPropInfo.m_bBottomMargin) &&
- SfxItemState::SET == rCollItemSet.GetItemState(RES_UL_SPACE,true,
- &pCollItem) &&
- SfxItemState::SET == rItemSet.GetItemState(RES_UL_SPACE,false,&pItem) )
+ (pCollULItem = rCollItemSet.GetItemIfSet(RES_UL_SPACE)) &&
+ (pULItem = rItemSet.GetItemIfSet(RES_UL_SPACE,false)) )
{
- const SvxULSpaceItem *pULItem = static_cast<const SvxULSpaceItem *>(pItem);
-
- SvxULSpaceItem aULItem( *static_cast<const SvxULSpaceItem *>(pCollItem) );
+ SvxULSpaceItem aULItem( *pCollULItem );
if( rPropInfo.m_bTopMargin )
aULItem.SetUpper( pULItem->GetUpper() );
if( rPropInfo.m_bBottomMargin )
@@ -310,13 +292,12 @@ static void SetTextCollAttrs( SwTextFormatColl *pColl, SfxItemSet& rItemSet,
rItemSet.Put( aULItem );
}
- static const sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONTSIZE,RES_CHRATR_CJK_FONTSIZE,
+ static const TypedWhichId<SvxFontHeightItem> aWhichIds[3] = { RES_CHRATR_FONTSIZE,RES_CHRATR_CJK_FONTSIZE,
RES_CHRATR_CTL_FONTSIZE };
- for(sal_uInt16 i : aWhichIds)
+ for(auto const & i : aWhichIds)
{
- if( SfxItemState::SET == rItemSet.GetItemState( i, false,
- &pItem ) &&
- static_cast<const SvxFontHeightItem *>(pItem)->GetProp() != 100)
+ const SvxFontHeightItem* pItem = rItemSet.GetItemIfSet( i, false );
+ if( pItem && pItem->GetProp() != 100)
{
// percentage values at the FontHeight item aren't supported
rItemSet.ClearItem( i );
@@ -385,28 +366,26 @@ void SwCSS1Parser::SetPageDescAttrs( const SvxBrushItem *pBrush,
if( pItemSet2 )
{
- const SfxPoolItem *pItem = nullptr;
- if( SfxItemState::SET == pItemSet2->GetItemState( RES_BACKGROUND, false,
- &pItem ) )
+ if( const SvxBrushItem* pItem = pItemSet2->GetItemIfSet( RES_BACKGROUND, false ) )
{
// set a background
- aBrushItem.reset(static_cast<SvxBrushItem*>(pItem->Clone()));
+ aBrushItem.reset(pItem->Clone());
pItemSet2->ClearItem( RES_BACKGROUND );
bSetBrush = true;
}
- if( SfxItemState::SET == pItemSet2->GetItemState( RES_BOX, false, &pItem ) )
+ if( const SvxBoxItem* pItem = pItemSet2->GetItemIfSet( RES_BOX, false ) )
{
// set a border
- aBoxItem.reset(static_cast<SvxBoxItem*>(pItem->Clone()));
+ aBoxItem.reset(pItem->Clone());
pItemSet2->ClearItem( RES_BOX );
bSetBox = true;
}
- if( SfxItemState::SET == pItemSet2->GetItemState( RES_FRAMEDIR, false, &pItem ) )
+ if( const SvxFrameDirectionItem* pItem = pItemSet2->GetItemIfSet( RES_FRAMEDIR, false ) )
{
// set a frame
- aFrameDirItem.reset(static_cast<SvxFrameDirectionItem*>(pItem->Clone()));
+ aFrameDirItem.reset(pItem->Clone());
pItemSet2->ClearItem( RES_FRAMEDIR );
bSetFrameDir = true;
}
@@ -447,45 +426,65 @@ void SwCSS1Parser::SetPageDescAttrs( const SwPageDesc *pPageDesc,
SwPageDesc aNewPageDesc( *pPageDesc );
SwFrameFormat &rMaster = aNewPageDesc.GetMaster();
const SfxItemSet& rPageItemSet = rMaster.GetAttrSet();
- const SfxPoolItem *pPageItem, *pItem;
bool bChanged = false;
// left, right border and first line indentation
- if( (rPropInfo.m_bLeftMargin || rPropInfo.m_bRightMargin) &&
- SfxItemState::SET == rItemSet.GetItemState(RES_LR_SPACE,false,&pItem) )
+ ::std::optional<SvxLRSpaceItem> oLRSpace;
+ assert(!rItemSet.GetItemIfSet(RES_LR_SPACE,false));
+ if (rPropInfo.m_bLeftMargin)
{
- if( (!rPropInfo.m_bLeftMargin || !rPropInfo.m_bRightMargin) &&
- SfxItemState::SET == rPageItemSet.GetItemState(RES_LR_SPACE,
- true,&pPageItem) )
+ // note: parser never creates SvxLeftMarginItem! must be converted
+ if (SvxTextLeftMarginItem const*const pLeft = rItemSet.GetItemIfSet(RES_MARGIN_TEXTLEFT, false))
{
- const SvxLRSpaceItem *pLRItem = static_cast<const SvxLRSpaceItem *>(pItem);
-
- SvxLRSpaceItem aLRItem( *static_cast<const SvxLRSpaceItem *>(pPageItem) );
- if( rPropInfo.m_bLeftMargin )
- aLRItem.SetLeft( pLRItem->GetLeft() );
- if( rPropInfo.m_bRightMargin )
- aLRItem.SetRight( pLRItem->GetRight() );
-
- rMaster.SetFormatAttr( aLRItem );
+ if (!oLRSpace)
+ {
+ if (const SvxLRSpaceItem* pPageItem = rPageItemSet.GetItemIfSet(RES_LR_SPACE))
+ {
+ oLRSpace.emplace(*pPageItem);
+ }
+ else
+ {
+ oLRSpace.emplace(RES_LR_SPACE);
+ }
+ }
+ oLRSpace->SetLeft(pLeft->GetTextLeft());
}
- else
+ }
+ if (rPropInfo.m_bRightMargin)
+ {
+ // note: parser never creates SvxLeftMarginItem! must be converted
+ if (SvxRightMarginItem const*const pRight = rItemSet.GetItemIfSet(RES_MARGIN_RIGHT, false))
{
- rMaster.SetFormatAttr( *pItem );
+ if (!oLRSpace)
+ {
+ if (const SvxLRSpaceItem* pPageItem = rPageItemSet.GetItemIfSet(RES_LR_SPACE))
+ {
+ oLRSpace.emplace(*pPageItem);
+ }
+ else
+ {
+ oLRSpace.emplace(RES_LR_SPACE);
+ }
+ }
+ oLRSpace->SetRight(pRight->GetRight());
}
+ }
+ if (oLRSpace)
+ {
+ rMaster.SetFormatAttr(*oLRSpace);
bChanged = true;
}
// top and bottom border
+ const SvxULSpaceItem *pULItem;
if( (rPropInfo.m_bTopMargin || rPropInfo.m_bBottomMargin) &&
- SfxItemState::SET == rItemSet.GetItemState(RES_UL_SPACE,false,&pItem) )
+ (pULItem = rItemSet.GetItemIfSet(RES_UL_SPACE,false)) )
{
+ const SvxULSpaceItem* pPageItem;
if( (!rPropInfo.m_bTopMargin || !rPropInfo.m_bBottomMargin) &&
- SfxItemState::SET == rPageItemSet.GetItemState(RES_UL_SPACE,
- true,&pPageItem) )
+ (pPageItem = rPageItemSet.GetItemIfSet(RES_UL_SPACE) ) )
{
- const SvxULSpaceItem *pULItem = static_cast<const SvxULSpaceItem *>(pItem);
-
- SvxULSpaceItem aULItem( *static_cast<const SvxULSpaceItem *>(pPageItem) );
+ SvxULSpaceItem aULItem( *pPageItem );
if( rPropInfo.m_bTopMargin )
aULItem.SetUpper( pULItem->GetUpper() );
if( rPropInfo.m_bBottomMargin )
@@ -495,7 +494,7 @@ void SwCSS1Parser::SetPageDescAttrs( const SwPageDesc *pPageDesc,
}
else
{
- rMaster.SetFormatAttr( *pItem );
+ rMaster.SetFormatAttr( *pULItem );
}
bChanged = true;
}
@@ -533,7 +532,7 @@ void SwCSS1Parser::SetPageDescAttrs( const SwPageDesc *pPageDesc,
}
// Is that possible?
- if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false, &pItem ) )
+ if( const SvxBrushItem* pItem = rItemSet.GetItemIfSet( RES_BACKGROUND, false ) )
{
// set a background
rMaster.SetFormatAttr( *pItem );
@@ -800,12 +799,8 @@ void SwCSS1Parser::StyleParsed( const CSS1Selector *pSelector,
// We must test the background before setting, because
// in SetPageDescAttrs it will be deleted.
- const SfxPoolItem *pItem;
- if( SfxItemState::SET==rItemSet.GetItemState(RES_BACKGROUND,false,&pItem) )
+ if( const SvxBrushItem *pBrushItem = rItemSet.GetItemIfSet(RES_BACKGROUND,false) )
{
- const SvxBrushItem *pBrushItem =
- static_cast<const SvxBrushItem *>(pItem);
-
/// Body has a background color, if it is not "no fill"/"auto fill"
if( pBrushItem->GetColor() != COL_TRANSPARENT )
m_bBodyBGColorSet = true;
@@ -992,11 +987,8 @@ void SwCSS1Parser::StyleParsed( const CSS1Selector *pSelector,
if( !pNext )
{
// set only the attributes at the style
- const SfxPoolItem *pItem;
- const SvxBoxItem *pBoxItem = nullptr;
- if( SfxItemState::SET ==
- pColl->GetAttrSet().GetItemState(RES_BOX,true,&pItem) )
- pBoxItem = static_cast<const SvxBoxItem *>(pItem);
+ const SvxBoxItem *pBoxItem =
+ pColl->GetAttrSet().GetItemIfSet(RES_BOX);
rPropInfo.SetBoxItem( rItemSet, MIN_BORDER_DIST, pBoxItem );
if( Css1ScriptFlags::AllMask == nScript && !pParentColl )
{
@@ -1131,7 +1123,7 @@ SwCharFormat* SwCSS1Parser::GetChrFormat( HtmlTokenId nToken2, const OUString& r
switch( nToken2 )
{
case HtmlTokenId::EMPHASIS_ON: nPoolId = RES_POOLCHR_HTML_EMPHASIS; break;
- case HtmlTokenId::CITIATION_ON: nPoolId = RES_POOLCHR_HTML_CITIATION; break;
+ case HtmlTokenId::CITATION_ON: nPoolId = RES_POOLCHR_HTML_CITATION; break;
case HtmlTokenId::STRONG_ON: nPoolId = RES_POOLCHR_HTML_STRONG; break;
case HtmlTokenId::CODE_ON: nPoolId = RES_POOLCHR_HTML_CODE; break;
case HtmlTokenId::SAMPLE_ON: nPoolId = RES_POOLCHR_HTML_SAMPLE; break;
@@ -1468,10 +1460,9 @@ void SwCSS1Parser::FillDropCap( SwFormatDrop& rDrop,
// the number of lines matches somehow a percentage value
// for the height (what happens with absolute heights???)
sal_uInt8 nLines = rDrop.GetLines();
- const SfxPoolItem *pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( RES_CHRATR_FONTSIZE, false, &pItem ) )
+ if( const SvxFontHeightItem* pFontHeightItem = rItemSet.GetItemIfSet( RES_CHRATR_FONTSIZE, false ) )
{
- sal_uInt16 nProp = static_cast<const SvxFontHeightItem *>(pItem)->GetProp();
+ sal_uInt16 nProp = pFontHeightItem->GetProp();
nLines = static_cast<sal_uInt8>((nProp + 50) / 100);
if( nLines < 1 )
nLines = 1;
@@ -1496,12 +1487,13 @@ void SwCSS1Parser::FillDropCap( SwFormatDrop& rDrop,
rDrop.GetLines() = nLines;
// a right border becomes the spacing to text!
- if( SfxItemState::SET == rItemSet.GetItemState( RES_LR_SPACE, false, &pItem ) )
+ if (const SvxRightMarginItem *const pRightMargin = rItemSet.GetItemIfSet(RES_MARGIN_RIGHT, false))
{
- rDrop.GetDistance() = static_cast< sal_uInt16 >(
- static_cast<const SvxLRSpaceItem *>(pItem)->GetRight() );
- rItemSet.ClearItem( RES_LR_SPACE );
+ rDrop.GetDistance() = static_cast<sal_uInt16>(pRightMargin->GetRight());
+ rItemSet.ClearItem(RES_MARGIN_RIGHT);
}
+ rItemSet.ClearItem(RES_MARGIN_FIRSTLINE);
+ rItemSet.ClearItem(RES_MARGIN_TEXTLEFT);
// for every other attribute create a character style
if( !rItemSet.Count() )
@@ -1615,8 +1607,14 @@ HTMLAttr **SwHTMLParser::GetAttrTabEntry( sal_uInt16 nWhich )
ppAttr = &m_xAttrTab->pAdjust;
break;
- case RES_LR_SPACE:
- ppAttr = &m_xAttrTab->pLRSpace;
+ case RES_MARGIN_FIRSTLINE:
+ ppAttr = &m_xAttrTab->pFirstLineIndent;
+ break;
+ case RES_MARGIN_TEXTLEFT:
+ ppAttr = &m_xAttrTab->pTextLeftMargin;
+ break;
+ case RES_MARGIN_RIGHT:
+ ppAttr = &m_xAttrTab->pRightMargin;
break;
case RES_UL_SPACE:
ppAttr = &m_xAttrTab->pULSpace;
@@ -1677,7 +1675,7 @@ void SwHTMLParser::NewStyle()
}
m_bIgnoreRawData = sType.getLength() &&
- !sType.getToken(0,';').equalsAscii(sCSS_mimetype);
+ !o3tl::equalsAscii(o3tl::getToken(sType, 0,';'), sCSS_mimetype);
}
void SwHTMLParser::EndStyle()
@@ -1763,7 +1761,7 @@ void SwHTMLParser::InsertLink()
if( !sHRef.isEmpty() && sRel.equalsIgnoreAsciiCase( "STYLESHEET" ) &&
( sType.isEmpty() ||
- sType.getToken(0,';').equalsAscii(sCSS_mimetype) ) )
+ o3tl::equalsAscii(o3tl::getToken(sType, 0,';'), sCSS_mimetype) ) )
{
if( GetMedium() )
{
@@ -1951,7 +1949,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( const SvxCSS1PropertyInfo &rPropInfo,
// Absolute positioned objects are page-bound, when they
// aren't in a frame and otherwise frame-bound.
const SwStartNode *pFlySttNd =
- m_pPam->GetPoint()->nNode.GetNode().FindFlyStartNode();
+ m_pPam->GetPoint()->GetNode().FindFlyStartNode();
if( pFlySttNd )
{
aAnchor.SetType( RndStdIds::FLY_AT_FLY );
@@ -1991,7 +1989,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( const SvxCSS1PropertyInfo &rPropInfo,
// still empty and otherwise auto-bound.
// Auto-bound frames for the time being inserted at the previous position
// and later moved.
- const sal_Int32 nContent = m_pPam->GetPoint()->nContent.GetIndex();
+ const sal_Int32 nContent = m_pPam->GetPoint()->GetContentIndex();
if( nContent )
{
aAnchor.SetType( RndStdIds::FLY_AT_CHAR );
@@ -2079,35 +2077,37 @@ void SwHTMLParser::SetFrameFormatAttrs( SfxItemSet &rItemSet,
HtmlFrameFormatFlags nFlags,
SfxItemSet &rFrameItemSet )
{
- const SfxPoolItem *pItem;
+ const SvxBoxItem *pBoxItem;
if( (nFlags & HtmlFrameFormatFlags::Box) &&
- SfxItemState::SET==rItemSet.GetItemState( RES_BOX, true, &pItem ) )
+ (pBoxItem = rItemSet.GetItemIfSet( RES_BOX )) )
{
if( nFlags & HtmlFrameFormatFlags::Padding )
{
- SvxBoxItem aBoxItem( *static_cast<const SvxBoxItem *>(pItem) );
+ SvxBoxItem aBoxItem( *pBoxItem );
// reset all 4 sides to 0
aBoxItem.SetAllDistances(0);
rFrameItemSet.Put( aBoxItem );
}
else
{
- rFrameItemSet.Put( *pItem );
+ rFrameItemSet.Put( *pBoxItem );
}
rItemSet.ClearItem( RES_BOX );
}
+ const SvxBrushItem* pBrushItem;
if( (nFlags & HtmlFrameFormatFlags::Background) &&
- SfxItemState::SET==rItemSet.GetItemState( RES_BACKGROUND, true, &pItem ) )
+ (pBrushItem = rItemSet.GetItemIfSet( RES_BACKGROUND )) )
{
- rFrameItemSet.Put( *pItem );
+ rFrameItemSet.Put( *pBrushItem );
rItemSet.ClearItem( RES_BACKGROUND );
}
+ const SvxFrameDirectionItem* pFrameDirectionItem;
if( (nFlags & HtmlFrameFormatFlags::Direction) &&
- SfxItemState::SET==rItemSet.GetItemState( RES_FRAMEDIR, true, &pItem ) )
+ (pFrameDirectionItem = rItemSet.GetItemIfSet( RES_FRAMEDIR )) )
{
- rFrameItemSet.Put( *pItem );
+ rFrameItemSet.Put( *pFrameDirectionItem );
rItemSet.ClearItem( RES_FRAMEDIR );
}
}
@@ -2196,8 +2196,8 @@ void SwHTMLParser::GetMarginsFromContextWithNumberBullet( sal_uInt16& nLeft,
void SwHTMLParser::GetULSpaceFromContext( sal_uInt16& nUpper,
sal_uInt16& nLower ) const
{
- sal_uInt16 nDfltColl = 0;
- OUString aDfltClass;
+ sal_uInt16 nDefaultColl = 0;
+ OUString aDefaultClass;
HTMLAttrContexts::size_type nPos = m_aContexts.size();
while( nPos > m_nContextStAttrMin )
@@ -2208,19 +2208,19 @@ void SwHTMLParser::GetULSpaceFromContext( sal_uInt16& nUpper,
pCntxt->GetULSpace( nUpper, nLower );
return;
}
- else if( !nDfltColl )
+ else if (!nDefaultColl)
{
- nDfltColl = pCntxt->GetDfltTextFormatColl();
- if( nDfltColl )
- aDfltClass = pCntxt->GetClass();
+ nDefaultColl = pCntxt->GetDefaultTextFormatColl();
+ if (nDefaultColl)
+ aDefaultClass = pCntxt->GetClass();
}
}
- if( !nDfltColl )
- nDfltColl = RES_POOLCOLL_TEXT;
+ if (!nDefaultColl)
+ nDefaultColl = RES_POOLCOLL_TEXT;
const SwTextFormatColl *pColl =
- m_pCSS1Parser->GetTextFormatColl( nDfltColl, aDfltClass );
+ m_pCSS1Parser->GetTextFormatColl(nDefaultColl, aDefaultClass);
const SvxULSpaceItem& rULSpace = pColl->GetULSpace();
nUpper = rULSpace.GetUpper();
nLower = rULSpace.GetLower();
@@ -2235,7 +2235,7 @@ void SwHTMLParser::EndContextAttrs( HTMLAttrContext *pContext )
{
// Set the number of characters for DropCaps. If it's zero at the
// end, the attribute is set to invalid and then isn't set from SetAttr.
- sal_Int32 nChars = m_pPam->GetPoint()->nContent.GetIndex();
+ sal_Int32 nChars = m_pPam->GetPoint()->GetContentIndex();
if( nChars < 1 )
pAttr->Invalidate();
else if( nChars > MAX_DROPCAP_CHARS )
@@ -2276,22 +2276,21 @@ static void lcl_swcss1_setEncoding( SwFormat& rFormat, rtl_TextEncoding eEnc )
return;
const SfxItemSet& rItemSet = rFormat.GetAttrSet();
- static const sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
- RES_CHRATR_CTL_FONT };
- const SfxPoolItem *pItem;
- for(sal_uInt16 i : aWhichIds)
- {
- if( SfxItemState::SET == rItemSet.GetItemState( i, false,&pItem ) )
- {
- const SvxFontItem& rFont = *static_cast<const SvxFontItem *>(pItem);
- if( RTL_TEXTENCODING_SYMBOL != rFont.GetCharSet() )
- {
- SvxFontItem aFont( rFont.GetFamily(), rFont.GetFamilyName(),
- rFont.GetStyleName(), rFont.GetPitch(),
- eEnc, i);
- rFormat.SetFormatAttr( aFont );
- }
- }
+ static const TypedWhichId<SvxFontItem> aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
+ RES_CHRATR_CTL_FONT };
+ for (auto const & i : aWhichIds)
+ {
+ const SvxFontItem *pFontItem = rItemSet.GetItemIfSet(i, false);
+ if (!pFontItem)
+ continue;
+ if (RTL_TEXTENCODING_SYMBOL == pFontItem->GetCharSet())
+ continue;
+ if (eEnc == pFontItem->GetCharSet())
+ continue;
+ SvxFontItem aFont(pFontItem->GetFamily(), pFontItem->GetFamilyName(),
+ pFontItem->GetStyleName(), pFontItem->GetPitch(),
+ eEnc, i);
+ rFormat.SetFormatAttr(aFont);
}
}
diff --git a/sw/source/filter/html/htmlctxt.cxx b/sw/source/filter/html/htmlctxt.cxx
index 6be3cab727d1..0e87b83644f8 100644
--- a/sw/source/filter/html/htmlctxt.cxx
+++ b/sw/source/filter/html/htmlctxt.cxx
@@ -29,6 +29,7 @@
#include <svtools/htmltokn.h>
#include <editeng/boxitem.hxx>
#include <osl/diagnose.h>
+#include <o3tl/string_view.hxx>
#include <doc.hxx>
#include <pam.hxx>
@@ -39,72 +40,73 @@
#include "swhtml.hxx"
#include <memory>
+#include <utility>
using namespace ::com::sun::star;
class HTMLAttrContext_SaveDoc
{
- SwHTMLNumRuleInfo aNumRuleInfo; // Numbering for this environment
+ SwHTMLNumRuleInfo m_aNumRuleInfo; // Numbering for this environment
std::unique_ptr<SwPosition>
- pPos; // Jump back to here when leaving context
+ m_pPos; // Jump back to here when leaving context
std::shared_ptr<HTMLAttrTable>
- xAttrTab; // Valid attributes for the environment,
+ m_xAttrTab; // Valid attributes for the environment,
// if attributes shouldn't be preserved
- size_t nContextStMin; // Stack lower bound for the environment
+ size_t m_nContextStMin; // Stack lower bound for the environment
// if stack needs to be protected
- size_t nContextStAttrMin; // Stack lower bound for the environment
+ size_t m_nContextStAttrMin; // Stack lower bound for the environment
// if the attributes shouldn't be preserved
- bool bStripTrailingPara : 1;
- bool bKeepNumRules : 1;
- bool bFixHeaderDist : 1;
- bool bFixFooterDist : 1;
+ bool m_bStripTrailingPara : 1;
+ bool m_bKeepNumRules : 1;
+ bool m_bFixHeaderDist : 1;
+ bool m_bFixFooterDist : 1;
public:
HTMLAttrContext_SaveDoc() :
- nContextStMin( SIZE_MAX ), nContextStAttrMin( SIZE_MAX ),
- bStripTrailingPara( false ), bKeepNumRules( false ),
- bFixHeaderDist( false ), bFixFooterDist( false )
+ m_nContextStMin( SIZE_MAX ), m_nContextStAttrMin( SIZE_MAX ),
+ m_bStripTrailingPara( false ), m_bKeepNumRules( false ),
+ m_bFixHeaderDist( false ), m_bFixFooterDist( false )
{}
// The position is ours, so we need to create and delete it
- void SetPos( const SwPosition& rPos ) { pPos.reset( new SwPosition(rPos) ); }
- const SwPosition *GetPos() const { return pPos.get(); }
+ void SetPos( const SwPosition& rPos ) { m_pPos.reset( new SwPosition(rPos) ); }
+ const SwPosition *GetPos() const { return m_pPos.get(); }
// The index isn't ours. So no creation or deletion
- void SetNumInfo( const SwHTMLNumRuleInfo& rInf ) { aNumRuleInfo.Set(rInf); }
- const SwHTMLNumRuleInfo& GetNumInfo() const { return aNumRuleInfo; }
+ void SetNumInfo( const SwHTMLNumRuleInfo& rInf ) { m_aNumRuleInfo.Set(rInf); }
+ const SwHTMLNumRuleInfo& GetNumInfo() const { return m_aNumRuleInfo; }
std::shared_ptr<HTMLAttrTable> const & GetAttrTab(bool bCreate = false);
- void SetContextStMin( size_t nMin ) { nContextStMin = nMin; }
- size_t GetContextStMin() const { return nContextStMin; }
+ void SetContextStMin( size_t nMin ) { m_nContextStMin = nMin; }
+ size_t GetContextStMin() const { return m_nContextStMin; }
- void SetContextStAttrMin( size_t nMin ) { nContextStAttrMin = nMin; }
- size_t GetContextStAttrMin() const { return nContextStAttrMin; }
+ void SetContextStAttrMin( size_t nMin ) { m_nContextStAttrMin = nMin; }
+ size_t GetContextStAttrMin() const { return m_nContextStAttrMin; }
- void SetStripTrailingPara( bool bSet ) { bStripTrailingPara = bSet; }
- bool GetStripTrailingPara() const { return bStripTrailingPara; }
+ void SetStripTrailingPara( bool bSet ) { m_bStripTrailingPara = bSet; }
+ bool GetStripTrailingPara() const { return m_bStripTrailingPara; }
- void SetKeepNumRules( bool bSet ) { bKeepNumRules = bSet; }
- bool GetKeepNumRules() const { return bKeepNumRules; }
+ void SetKeepNumRules( bool bSet ) { m_bKeepNumRules = bSet; }
+ bool GetKeepNumRules() const { return m_bKeepNumRules; }
- void SetFixHeaderDist( bool bSet ) { bFixHeaderDist = bSet; }
- bool GetFixHeaderDist() const { return bFixHeaderDist; }
+ void SetFixHeaderDist( bool bSet ) { m_bFixHeaderDist = bSet; }
+ bool GetFixHeaderDist() const { return m_bFixHeaderDist; }
- void SetFixFooterDist( bool bSet ) { bFixFooterDist = bSet; }
- bool GetFixFooterDist() const { return bFixFooterDist; }
+ void SetFixFooterDist( bool bSet ) { m_bFixFooterDist = bSet; }
+ bool GetFixFooterDist() const { return m_bFixFooterDist; }
};
std::shared_ptr<HTMLAttrTable> const & HTMLAttrContext_SaveDoc::GetAttrTab( bool bCreate )
{
- if (!xAttrTab && bCreate)
+ if (!m_xAttrTab && bCreate)
{
- xAttrTab = std::make_shared<HTMLAttrTable>();
- memset(xAttrTab.get(), 0, sizeof(HTMLAttrTable));
+ m_xAttrTab = std::make_shared<HTMLAttrTable>();
+ memset(m_xAttrTab.get(), 0, sizeof(HTMLAttrTable));
}
- return xAttrTab;
+ return m_xAttrTab;
}
HTMLAttrContext_SaveDoc *HTMLAttrContext::GetSaveDocContext( bool bCreate )
@@ -115,9 +117,9 @@ HTMLAttrContext_SaveDoc *HTMLAttrContext::GetSaveDocContext( bool bCreate )
return m_pSaveDocContext.get();
}
-HTMLAttrContext::HTMLAttrContext( HtmlTokenId nTokn, sal_uInt16 nPoolId, const OUString& rClass,
+HTMLAttrContext::HTMLAttrContext( HtmlTokenId nTokn, sal_uInt16 nPoolId, OUString aClass,
bool bDfltColl ) :
- m_aClass( rClass ),
+ m_aClass(std::move( aClass )),
m_nToken( nTokn ),
m_nTextFormatColl( nPoolId ),
m_nLeftMargin( 0 ),
@@ -177,14 +179,14 @@ void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos )
"Danger: there are non-final paragraph attributes");
m_aParaAttrs.clear();
- const SwNodeIndex* pOldEndPara = &m_pPam->GetPoint()->nNode;
+ const SwPosition* pOldEndPara = m_pPam->GetPoint();
#ifndef NDEBUG
- auto const nOld(pOldEndPara->GetIndex());
+ auto const nOld(pOldEndPara->GetNodeIndex());
#endif
- sal_Int32 nOldEndCnt = m_pPam->GetPoint()->nContent.GetIndex();
+ sal_Int32 nOldEndCnt = m_pPam->GetPoint()->GetContentIndex();
- const SwNodeIndex& rNewSttPara = rNewPos.nNode;
- sal_Int32 nNewSttCnt = rNewPos.nContent.GetIndex();
+ const SwPosition& rNewSttPara = rNewPos;
+ sal_Int32 nNewSttCnt = rNewPos.GetContentIndex();
bool bMoveBack = false;
@@ -200,31 +202,31 @@ void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos )
sal_uInt16 nWhich = pAttr->m_pItem->Which();
if( !nOldEndCnt && RES_PARATR_BEGIN <= nWhich &&
- pAttr->GetSttParaIdx() < pOldEndPara->GetIndex() )
+ pAttr->GetStartParagraphIdx() < pOldEndPara->GetNodeIndex() )
{
// The attribute needs to be closed one content position beforehand
if( !bMoveBack )
{
bMoveBack = m_pPam->Move( fnMoveBackward );
- nOldEndCnt = m_pPam->GetPoint()->nContent.GetIndex();
+ nOldEndCnt = m_pPam->GetPoint()->GetContentIndex();
}
}
else if( bMoveBack )
{
m_pPam->Move( fnMoveForward );
- nOldEndCnt = m_pPam->GetPoint()->nContent.GetIndex();
+ nOldEndCnt = m_pPam->GetPoint()->GetContentIndex();
bMoveBack = false;
}
if( (RES_PARATR_BEGIN <= nWhich && bMoveBack) ||
- pAttr->GetSttParaIdx() < pOldEndPara->GetIndex() ||
- (pAttr->GetSttPara() == *pOldEndPara &&
- pAttr->GetSttCnt() != nOldEndCnt) )
+ pAttr->GetStartParagraphIdx() < pOldEndPara->GetNodeIndex() ||
+ (pAttr->GetStartParagraph() == pOldEndPara->GetNode() &&
+ pAttr->GetStartContent() != nOldEndCnt) )
{
// The attribute needs to be set. Because we still need the original, since
// pointers to the attribute still exists in the contexts, we need to clone it.
// The next-list gets lost but the previous-list is preserved
- HTMLAttr *pSetAttr = pAttr->Clone( *pOldEndPara, nOldEndCnt );
+ HTMLAttr *pSetAttr = pAttr->Clone( pOldEndPara->GetNode(), nOldEndCnt );
if( pNext )
pNext->InsertPrev( pSetAttr );
@@ -252,8 +254,8 @@ void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos )
}
// Set the start of the attribute
- pAttr->m_nStartPara = rNewSttPara;
- pAttr->m_nEndPara = rNewSttPara;
+ pAttr->m_nStartPara = rNewSttPara.GetNode();
+ pAttr->m_nEndPara = rNewSttPara.GetNode();
pAttr->m_nStartContent = nNewSttCnt;
pAttr->m_nEndContent = nNewSttCnt;
pAttr->m_pPrev = nullptr;
@@ -265,7 +267,7 @@ void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos )
if( bMoveBack )
m_pPam->Move( fnMoveForward );
- assert(m_pPam->GetPoint()->nNode.GetIndex() == nOld);
+ assert(m_pPam->GetPoint()->GetNodeIndex() == nOld);
}
void SwHTMLParser::SaveDocContext( HTMLAttrContext *pCntxt,
@@ -399,7 +401,7 @@ void SwHTMLParser::EndContext( HTMLAttrContext *pContext )
// Add a paragraph break if needed
if( AM_NONE != pContext->GetAppendMode() &&
- m_pPam->GetPoint()->nContent.GetIndex() )
+ m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode( pContext->GetAppendMode() );
// Restart PRE, LISTING and XMP environments
@@ -476,8 +478,7 @@ bool SwHTMLParser::DoPositioning( SfxItemSet &rItemSet,
// - there's a given width
if( SwCSS1Parser::MayBePositioned( rPropInfo ) )
{
- SfxItemSet aFrameItemSet( m_xDoc->GetAttrPool(),
- svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aFrameItemSet( m_xDoc->GetAttrPool() );
if( !IsNewDoc() )
Reader::ResetFrameFormatAttrs(aFrameItemSet );
@@ -501,13 +502,13 @@ bool SwHTMLParser::DoPositioning( SfxItemSet &rItemSet,
return bRet;
}
-bool SwHTMLParser::CreateContainer( const OUString& rClass,
+bool SwHTMLParser::CreateContainer( std::u16string_view rClass,
SfxItemSet &rItemSet,
SvxCSS1PropertyInfo &rPropInfo,
HTMLAttrContext *pContext )
{
bool bRet = false;
- if( rClass.equalsIgnoreAsciiCase( "sd-abs-pos" ) &&
+ if( o3tl::equalsIgnoreAsciiCase( rClass, u"sd-abs-pos" ) &&
SwCSS1Parser::MayBePositioned( rPropInfo ) )
{
// Container class
@@ -535,7 +536,7 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet,
bool bCharLvl )
{
// Put together a DropCap attribute, if a "float:left" is before the first character
- if( bCharLvl && !m_pPam->GetPoint()->nContent.GetIndex() &&
+ if( bCharLvl && !m_pPam->GetPoint()->GetContentIndex() &&
SvxAdjust::Left == rPropInfo.m_eFloat )
{
SwFormatDrop aDrop;
@@ -564,18 +565,36 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet,
SfxItemIter aIter( rItemSet );
+ const SvxFirstLineIndentItem * pFirstLineItem(nullptr);
+ const SvxTextLeftMarginItem * pTextLeftMargin(nullptr);
+ const SvxRightMarginItem * pRightMargin(nullptr);
+
for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
{
- HTMLAttr **ppAttr = nullptr;
-
switch( pItem->Which() )
{
- case RES_LR_SPACE:
+ case RES_MARGIN_FIRSTLINE:
+ {
+ pFirstLineItem = static_cast<const SvxFirstLineIndentItem*>(pItem);
+ }
+ break;
+ case RES_MARGIN_TEXTLEFT:
+ {
+ pTextLeftMargin = static_cast<const SvxTextLeftMarginItem*>(pItem);
+ }
+ break;
+ case RES_MARGIN_RIGHT:
+ {
+ pRightMargin = static_cast<const SvxRightMarginItem*>(pItem);
+ }
+ break;
+ }
+ }
+
+#if 1
{
// Paragraph indents need to be added and are generated for each paragraphs
// (here for the first paragraph only, all the following in SetTextCollAttrs)
- const SvxLRSpaceItem *pLRItem =
- static_cast<const SvxLRSpaceItem *>(pItem);
// Get old paragraph indents without the top context (that's the one we're editing)
sal_uInt16 nOldLeft = 0, nOldRight = 0;
@@ -597,7 +616,8 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet,
if( rPropInfo.m_bLeftMargin )
{
OSL_ENSURE( rPropInfo.m_nLeftMargin < 0 ||
- rPropInfo.m_nLeftMargin == pLRItem->GetTextLeft(),
+ !pTextLeftMargin ||
+ rPropInfo.m_nLeftMargin == pTextLeftMargin->GetTextLeft(),
"left margin does not match with item" );
if( rPropInfo.m_nLeftMargin < 0 &&
-rPropInfo.m_nLeftMargin > nOldLeft )
@@ -608,7 +628,8 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet,
if( rPropInfo.m_bRightMargin )
{
OSL_ENSURE( rPropInfo.m_nRightMargin < 0 ||
- rPropInfo.m_nRightMargin == pLRItem->GetRight(),
+ !pRightMargin ||
+ rPropInfo.m_nRightMargin == pRightMargin->GetRight(),
"right margin does not match with item" );
if( rPropInfo.m_nRightMargin < 0 &&
-rPropInfo.m_nRightMargin > nOldRight )
@@ -616,21 +637,32 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet,
else
nRight = nOldRight + static_cast< sal_uInt16 >(rPropInfo.m_nRightMargin);
}
- if( rPropInfo.m_bTextIndent )
- nIndent = pLRItem->GetTextFirstLineOffset();
+ if (rPropInfo.m_bTextIndent && pFirstLineItem)
+ nIndent = pFirstLineItem->GetTextFirstLineOffset();
// Remember the value for the following paragraphs
pContext->SetMargins( nLeft, nRight, nIndent );
// Set the attribute on the current paragraph
- SvxLRSpaceItem aLRItem( *pLRItem );
- aLRItem.SetTextFirstLineOffset( nIndent );
- aLRItem.SetTextLeft( nLeft );
- aLRItem.SetRight( nRight );
- NewAttr(m_xAttrTab, &m_xAttrTab->pLRSpace, aLRItem);
- EndAttr( m_xAttrTab->pLRSpace, false );
+ SvxFirstLineIndentItem const firstLine(nIndent, RES_MARGIN_FIRSTLINE);
+ NewAttr(m_xAttrTab, &m_xAttrTab->pFirstLineIndent, firstLine);
+ EndAttr(m_xAttrTab->pFirstLineIndent, false);
+ SvxTextLeftMarginItem const leftMargin(nLeft, RES_MARGIN_TEXTLEFT);
+ NewAttr(m_xAttrTab, &m_xAttrTab->pTextLeftMargin, leftMargin);
+ EndAttr(m_xAttrTab->pTextLeftMargin, false);
+ SvxRightMarginItem const rightMargin(nRight, RES_MARGIN_RIGHT);
+ NewAttr(m_xAttrTab, &m_xAttrTab->pRightMargin, rightMargin);
+ EndAttr(m_xAttrTab->pRightMargin, false);
}
- break;
+#endif
+
+ SfxItemIter aIter2(rItemSet);
+ for (const SfxPoolItem* pItem = aIter2.GetCurItem(); pItem; pItem = aIter2.NextItem())
+ {
+ HTMLAttr **ppAttr = nullptr;
+
+ switch( pItem->Which() )
+ {
case RES_UL_SPACE:
if( !rPropInfo.m_bTopMargin || !rPropInfo.m_bBottomMargin )
@@ -767,8 +799,8 @@ void SwHTMLParser::SplitPREListingXMP( HTMLAttrContext *pCntxt )
SfxItemSet *HTMLAttrContext::GetFrameItemSet( SwDoc *pCreateDoc )
{
if( !m_pFrameItemSet && pCreateDoc )
- m_pFrameItemSet = std::make_unique<SfxItemSet>( pCreateDoc->GetAttrPool(),
- svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1>{} );
+ m_pFrameItemSet = std::make_unique<SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1>>
+ ( pCreateDoc->GetAttrPool() );
return m_pFrameItemSet.get();
}
diff --git a/sw/source/filter/html/htmldrawreader.cxx b/sw/source/filter/html/htmldrawreader.cxx
index 1f09a40cf09b..fdbc187348e9 100644
--- a/sw/source/filter/html/htmldrawreader.cxx
+++ b/sw/source/filter/html/htmldrawreader.cxx
@@ -38,6 +38,7 @@
#include <svl/itemiter.hxx>
#include <svtools/htmltokn.h>
#include <svtools/htmlkywd.hxx>
+#include <osl/diagnose.h>
#include <charatr.hxx>
#include <drawdoc.hxx>
@@ -81,41 +82,37 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj,
// to the visible layer.
pNewDrawObj->SetLayer( m_xDoc->getIDocumentDrawModelAccess().GetInvisibleHeavenId() );
- SfxItemSet aFrameSet( m_xDoc->GetAttrPool(),
- svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aFrameSet( m_xDoc->GetAttrPool() );
if( !IsNewDoc() )
Reader::ResetFrameFormatAttrs( aFrameSet );
sal_uInt16 nLeftSpace = 0, nRightSpace = 0, nUpperSpace = 0, nLowerSpace = 0;
- if( (rPixSpace.Width() || rPixSpace.Height()) && Application::GetDefaultDevice() )
+ if( rPixSpace.Width() || rPixSpace.Height() )
{
- Size aTwipSpc( rPixSpace.Width(), rPixSpace.Height() );
- aTwipSpc =
- Application::GetDefaultDevice()->PixelToLogic( aTwipSpc,
- MapMode(MapUnit::MapTwip) );
- nLeftSpace = nRightSpace = static_cast<sal_uInt16>(aTwipSpc.Width());
- nUpperSpace = nLowerSpace = static_cast<sal_uInt16>(aTwipSpc.Height());
+ nLeftSpace = nRightSpace = o3tl::convert(rPixSpace.Width(), o3tl::Length::px, o3tl::Length::twip);
+ nUpperSpace = nLowerSpace = o3tl::convert(rPixSpace.Height(), o3tl::Length::px, o3tl::Length::twip);
}
// set left/right border
- const SfxPoolItem *pItem;
- if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, true, &pItem ) )
+ // note: parser never creates SvxLeftMarginItem! must be converted
+ if (const SvxTextLeftMarginItem *const pLeft = rCSS1ItemSet.GetItemIfSet(RES_MARGIN_TEXTLEFT))
{
- // maybe flatten the first line indentation
- const SvxLRSpaceItem *pLRItem = static_cast<const SvxLRSpaceItem *>(pItem);
- SvxLRSpaceItem aLRItem( *pLRItem );
- aLRItem.SetTextFirstLineOffset( 0 );
if( rCSS1PropInfo.m_bLeftMargin )
{
- nLeftSpace = static_cast< sal_uInt16 >(aLRItem.GetLeft());
+ // should be SvxLeftMarginItem... "cast" it
+ nLeftSpace = static_cast<sal_uInt16>(pLeft->GetTextLeft());
rCSS1PropInfo.m_bLeftMargin = false;
}
+ rCSS1ItemSet.ClearItem(RES_MARGIN_TEXTLEFT);
+ }
+ if (const SvxRightMarginItem *const pRight = rCSS1ItemSet.GetItemIfSet(RES_MARGIN_RIGHT))
+ {
if( rCSS1PropInfo.m_bRightMargin )
{
- nRightSpace = static_cast< sal_uInt16 >(aLRItem.GetRight());
+ nRightSpace = static_cast< sal_uInt16 >(pRight->GetRight());
rCSS1PropInfo.m_bRightMargin = false;
}
- rCSS1ItemSet.ClearItem( RES_LR_SPACE );
+ rCSS1ItemSet.ClearItem(RES_MARGIN_RIGHT);
}
if( nLeftSpace || nRightSpace )
{
@@ -126,10 +123,9 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj,
}
// set top/bottom border
- if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, true, &pItem ) )
+ if( const SvxULSpaceItem* pULItem = rCSS1ItemSet.GetItemIfSet( RES_UL_SPACE ) )
{
// maybe flatten the first line indentation
- const SvxULSpaceItem *pULItem = static_cast<const SvxULSpaceItem *>(pItem);
if( rCSS1PropInfo.m_bTopMargin )
{
nUpperSpace = pULItem->GetUpper();
@@ -157,7 +153,7 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj,
SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.m_eTopType )
{
const SwStartNode *pFlySttNd =
- m_pPam->GetPoint()->nNode.GetNode().FindFlyStartNode();
+ m_pPam->GetPoint()->GetNode().FindFlyStartNode();
if( pFlySttNd )
{
@@ -306,7 +302,7 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
break;
case HtmlOptionId::SCROLLDELAY:
- nDelay = static_cast<sal_uInt16>(rOption.GetNumber());
+ nDelay = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::WIDTH:
@@ -349,15 +345,15 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
// #i52858# - method name changed
SwDrawModel* pModel = m_xDoc->getIDocumentDrawModelAccess().GetOrCreateDrawModel();
SdrPage* pPg = pModel->GetPage( 0 );
- m_pMarquee = SdrObjFactory::MakeNewObject(
+ m_pMarquee = static_cast<SdrTextObj*>(SdrObjFactory::MakeNewObject(
*pModel,
SdrInventor::Default,
- OBJ_TEXT);
+ SdrObjKind::Text).get());
if( !m_pMarquee )
return;
- pPg->InsertObject( m_pMarquee );
+ pPg->InsertObject( m_pMarquee.get() );
if( !aId.isEmpty() )
InsertBookmark( aId );
@@ -367,11 +363,11 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
eAniDir = SdrTextAniDirection::Right;
// re set the attributes needed for scrolling
- sal_uInt16 const aWhichMap[] { XATTR_FILL_FIRST, XATTR_FILL_LAST,
- SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
- EE_CHAR_START, EE_CHAR_END,
- 0 };
- SfxItemSet aItemSet( pModel->GetItemPool(), aWhichMap );
+ SfxItemSetFixed<
+ XATTR_FILL_FIRST, XATTR_FILL_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ EE_CHAR_START, EE_CHAR_END>
+ aItemSet( pModel->GetItemPool() );
aItemSet.Put( makeSdrTextAutoGrowWidthItem( false ) );
aItemSet.Put( makeSdrTextAutoGrowHeightItem( true ) );
aItemSet.Put( SdrTextAniKindItem( eAniKind ) );
@@ -409,7 +405,7 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
0
};
SwTextNode const*const pTextNd =
- m_pPam->GetPoint()->nNode.GetNode().GetTextNode();
+ m_pPam->GetPoint()->GetNode().GetTextNode();
if( pTextNd )
{
const SfxItemSet& rItemSet = pTextNd->GetAnyFormatColl().GetAttrSet();
@@ -454,10 +450,9 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
// now set the size
Size aTwipSz( bPercentWidth ? 0 : nWidth, nHeight );
- if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
+ if( aTwipSz.Width() || aTwipSz.Height() )
{
- aTwipSz = Application::GetDefaultDevice()
- ->PixelToLogic( aTwipSz, MapMode( MapUnit::MapTwip ) );
+ aTwipSz = o3tl::convert(aTwipSz, o3tl::Length::px, o3tl::Length::twip);
}
if( SVX_CSS1_LTYPE_TWIP== aPropInfo.m_eWidthType )
@@ -511,7 +506,7 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
m_pMarquee->SetLogicRect( tools::Rectangle( 0, 0, aTwipSz.Width(), aTwipSz.Height() ) );
// and insert the object into the document
- InsertDrawObject( m_pMarquee, aSpace, eVertOri, eHoriOri, aStyleItemSet,
+ InsertDrawObject( m_pMarquee.get(), aSpace, eVertOri, eHoriOri, aStyleItemSet,
aPropInfo );
// Register the drawing object at the table. Is a little bit complicated,
@@ -520,12 +515,12 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
// The global pTable also can't be used, because the marquee can also be
// in a sub-table.
if( pCurTable && bPercentWidth)
- RegisterDrawObjectToTable( pCurTable, m_pMarquee, static_cast<sal_uInt8>(nWidth) );
+ RegisterDrawObjectToTable( pCurTable, m_pMarquee.get(), static_cast<sal_uInt8>(nWidth) );
}
void SwHTMLParser::EndMarquee()
{
- OSL_ENSURE( m_pMarquee && OBJ_TEXT==m_pMarquee->GetObjIdentifier(),
+ OSL_ENSURE( m_pMarquee && SdrObjKind::Text==m_pMarquee->GetObjIdentifier(),
"no marquee or wrong type" );
if( m_bFixMarqueeWidth )
@@ -538,13 +533,13 @@ void SwHTMLParser::EndMarquee()
}
// insert the collected text
- static_cast<SdrTextObj*>(m_pMarquee)->SetText( m_aContents );
+ m_pMarquee->SetText( m_aContents );
m_pMarquee->SetMergedItemSetAndBroadcast( m_pMarquee->GetMergedItemSet() );
- if( m_bFixMarqueeWidth )
+ if (m_bFixMarqueeWidth && !bFuzzing)
{
// adjust the size to the text
- static_cast<SdrTextObj*>(m_pMarquee)->FitFrameToTextSize();
+ m_pMarquee->FitFrameToTextSize();
}
m_aContents.clear();
@@ -553,7 +548,7 @@ void SwHTMLParser::EndMarquee()
void SwHTMLParser::InsertMarqueeText()
{
- OSL_ENSURE( m_pMarquee && OBJ_TEXT==m_pMarquee->GetObjIdentifier(),
+ OSL_ENSURE( m_pMarquee && SdrObjKind::Text==m_pMarquee->GetObjIdentifier(),
"no marquee or wrong type" );
// append the current text part to the text
@@ -562,10 +557,10 @@ void SwHTMLParser::InsertMarqueeText()
void SwHTMLParser::ResizeDrawObject( SdrObject* pObj, SwTwips nWidth )
{
- OSL_ENSURE( OBJ_TEXT==pObj->GetObjIdentifier(),
+ OSL_ENSURE( SdrObjKind::Text==pObj->GetObjIdentifier(),
"no marquee or wrong type" );
- if( OBJ_TEXT!=pObj->GetObjIdentifier() )
+ if( SdrObjKind::Text!=pObj->GetObjIdentifier() )
return;
// the old size
diff --git a/sw/source/filter/html/htmldrawwriter.cxx b/sw/source/filter/html/htmldrawwriter.cxx
index d9ff363bda18..0ef2d2514a22 100644
--- a/sw/source/filter/html/htmldrawwriter.cxx
+++ b/sw/source/filter/html/htmldrawwriter.cxx
@@ -31,6 +31,7 @@
#include <svl/whiter.hxx>
#include <svtools/htmlout.hxx>
#include <svtools/htmlkywd.hxx>
+#include <osl/diagnose.h>
#include <rtl/strbuf.hxx>
@@ -71,8 +72,7 @@ void SwHTMLWriter::GetEEAttrsFromDrwObj( SfxItemSet& rItemSet,
while( nEEWhich )
{
const SfxPoolItem *pEEItem;
- bool bSet = SfxItemState::SET == rObjItemSet.GetItemState( nEEWhich, false,
- &pEEItem );
+ bool bSet = SfxItemState::SET == aIter.GetItemState( false, &pEEItem );
sal_uInt16 nSwWhich = 0;
switch( nEEWhich )
@@ -100,7 +100,7 @@ void SwHTMLWriter::GetEEAttrsFromDrwObj( SfxItemSet& rItemSet,
{
// if the item isn't set we maybe take the default item
if( !bSet )
- pEEItem = &rObjItemSet.GetPool()->GetDefaultItem(nEEWhich);
+ pEEItem = &rObjItemSet.GetPool()->GetUserOrPoolDefaultItem(nEEWhich);
// now we clone the item with the which id of the writer
rItemSet.Put( pEEItem->CloneSetWhich(nSwWhich) );
@@ -110,12 +110,10 @@ void SwHTMLWriter::GetEEAttrsFromDrwObj( SfxItemSet& rItemSet,
}
}
-Writer& OutHTML_DrawFrameFormatAsMarquee( Writer& rWrt,
+SwHTMLWriter& OutHTML_DrawFrameFormatAsMarquee( SwHTMLWriter& rWrt,
const SwDrawFrameFormat& rFormat,
const SdrObject& rSdrObject )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
OSL_ENSURE( rWrt.m_pDoc->getIDocumentDrawModelAccess().GetDrawModel(),
"There is a Draw-Obj with no Draw-Model?" );
const SdrTextObj *pTextObj = static_cast<const SdrTextObj *>(&rSdrObject);
@@ -126,8 +124,7 @@ Writer& OutHTML_DrawFrameFormatAsMarquee( Writer& rWrt,
if( !pOutlinerParaObj )
return rWrt;
- OStringBuffer sOut;
- sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_marquee);
+ OStringBuffer sOut("<" OOO_STRING_SVTOOLS_HTML_marquee);
// get attributes of the object
const SfxItemSet& rItemSet = pTextObj->GetMergedItemSet();
@@ -151,8 +148,8 @@ Writer& OutHTML_DrawFrameFormatAsMarquee( Writer& rWrt,
if( pStr )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_behavior).
- append("=\"").append(pStr).append("\"");
+ sOut.append(OString::Concat(" " OOO_STRING_SVTOOLS_HTML_O_behavior "=\"") +
+ pStr + "\"");
}
// DIRECTION
@@ -168,21 +165,21 @@ Writer& OutHTML_DrawFrameFormatAsMarquee( Writer& rWrt,
if( pStr )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_direction).
- append("=\"").append(pStr).append("\"");
+ sOut.append(OString::Concat(" " OOO_STRING_SVTOOLS_HTML_O_direction
+ "=\"") + pStr + "\"");
}
// LOOP
sal_Int32 nCount = rItemSet.Get( SDRATTR_TEXT_ANICOUNT ).GetValue();
if( 0==nCount )
nCount = SdrTextAniKind::Slide==eAniKind ? 1 : -1;
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_loop).append("=\"").
- append(nCount).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_loop "=\"" +
+ OString::number(nCount) + "\"");
// SCROLLDELAY
sal_uInt16 nDelay = rItemSet.Get( SDRATTR_TEXT_ANIDELAY ).GetValue();
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_scrolldelay).
- append("=\"").append(static_cast<sal_Int32>(nDelay)).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_scrolldelay
+ "=\"" + OString::number(nDelay) + "\"");
// SCROLLAMOUNT
sal_Int16 nAmount = rItemSet.Get( SDRATTR_TEXT_ANIAMOUNT ).GetValue();
@@ -190,16 +187,14 @@ Writer& OutHTML_DrawFrameFormatAsMarquee( Writer& rWrt,
{
nAmount = -nAmount;
}
- else if( nAmount && Application::GetDefaultDevice() )
+ else
{
- nAmount = Application::GetDefaultDevice()
- ->LogicToPixel( Size(nAmount,0),
- MapMode(MapUnit::MapTwip) ).Width();
+ nAmount = SwHTMLWriter::ToPixel(nAmount);
}
if( nAmount )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_scrollamount).
- append("=\"").append(static_cast<sal_Int32>(nAmount)).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_scrollamount
+ "=\"" + OString::number(nAmount) + "\"");
}
Size aTwipSz( pTextObj->GetLogicRect().GetSize() );
@@ -229,14 +224,14 @@ Writer& OutHTML_DrawFrameFormatAsMarquee( Writer& rWrt,
if( aPixelSz.Width() )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_width).
- append("=\"").append(static_cast<sal_Int32>(aPixelSz.Width())).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_width
+ "=\"" + OString::number(aPixelSz.Width()) + "\"");
}
if( aPixelSz.Height() )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_height).
- append("=\"").append(static_cast<sal_Int32>(aPixelSz.Height())).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_height
+ "=\"" + OString::number(aPixelSz.Height()) + "\"");
}
}
@@ -248,34 +243,37 @@ Writer& OutHTML_DrawFrameFormatAsMarquee( Writer& rWrt,
const Color& rFillColor =
rItemSet.Get(XATTR_FILLCOLOR).GetColorValue();
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_bgcolor).append("=");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_bgcolor "=");
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
HTMLOutFuncs::Out_Color( rWrt.Strm(), rFillColor );
}
if (!sOut.isEmpty())
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ {
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ }
// and now ALIGN, HSPACE and VSPACE
HtmlFrmOpts nFrameFlags = HTML_FRMOPTS_MARQUEE;
- if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) )
+ if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) )
nFrameFlags |= HTML_FRMOPTS_MARQUEE_CSS1;
- OString aEndTags = rHTMLWrt.OutFrameFormatOptions(rFormat, OUString(), nFrameFlags);
- if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) )
- rHTMLWrt.OutCSS1_FrameFormatOptions( rFormat, nFrameFlags, &rSdrObject );
+ OString aEndTags = rWrt.OutFrameFormatOptions(rFormat, u"", nFrameFlags);
+ if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) )
+ rWrt.OutCSS1_FrameFormatOptions( rFormat, nFrameFlags, &rSdrObject );
rWrt.Strm().WriteChar( '>' );
// What follows now is the counterpart of SdrTextObject::SetText()
Outliner aOutliner(nullptr, OutlinerMode::TextObject);
- aOutliner.SetUpdateMode( false );
+ aOutliner.SetUpdateLayout( false );
aOutliner.SetText( *pOutlinerParaObj );
OUString aText( aOutliner.GetText( aOutliner.GetParagraph(0),
aOutliner.GetParagraphCount() ) );
- HTMLOutFuncs::Out_String( rWrt.Strm(), aText,
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aText );
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_marquee, false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_marquee), false );
if( !aEndTags.isEmpty() )
rWrt.Strm().WriteOString( aEndTags );
diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx
index 989457ef6244..c1eff7ef7cb7 100644
--- a/sw/source/filter/html/htmlfld.cxx
+++ b/sw/source/filter/html/htmlfld.cxx
@@ -20,10 +20,12 @@
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/document/XDocumentProperties.hpp>
#include <com/sun/star/frame/XModel.hpp>
+#include <o3tl/string_view.hxx>
#include <osl/diagnose.h>
#include <docsh.hxx>
#include <IDocumentFieldsAccess.hxx>
#include <svtools/htmltokn.h>
+#include <svl/numformat.hxx>
#include <svl/zforlist.hxx>
#include <unotools/useroptions.hxx>
#include <fmtfld.hxx>
@@ -42,7 +44,7 @@ namespace {
struct HTMLNumFormatTableEntry
{
- const char *pName;
+ std::string_view pName;
NfIndexTableOffset eFormat;
};
@@ -81,7 +83,7 @@ HTMLNumFormatTableEntry const aHTMLDateFieldFormatTable[] =
{ "MD", NF_DATE_DIN_MMDD },
{ "YMD", NF_DATE_DIN_YYMMDD },
{ "YYMD", NF_DATE_DIN_YYYYMMDD },
- { nullptr, NF_NUMERIC_START }
+ { {}, NF_NUMERIC_START }
};
HTMLNumFormatTableEntry const aHTMLTimeFieldFormatTable[] =
@@ -89,7 +91,7 @@ HTMLNumFormatTableEntry const aHTMLTimeFieldFormatTable[] =
{ "SYS", NF_TIME_HHMMSS },
{ "SSMM24", NF_TIME_HHMM },
{ "SSMM12", NF_TIME_HHMMAMPM },
- { nullptr, NF_NUMERIC_START }
+ { {}, NF_NUMERIC_START }
};
HTMLOptionEnum<SvxNumType> const aHTMLPageNumFieldFormatTable[] =
@@ -195,12 +197,12 @@ HTMLOptionEnum<SwFileNameFormat> const aHTMLFileNameFieldFormatTable[] =
{ nullptr, SwFileNameFormat(0) }
};
-SvxNumType SwHTMLParser::GetNumType( const OUString& rStr, SvxNumType nDfltType )
+SvxNumType SwHTMLParser::GetNumType( std::u16string_view rStr, SvxNumType nDfltType )
{
const HTMLOptionEnum<SvxNumType> *pOptEnums = aHTMLPageNumFieldFormatTable;
while( pOptEnums->pName )
{
- if( rStr.equalsIgnoreAsciiCaseAscii( pOptEnums->pName ) )
+ if( o3tl::equalsIgnoreAsciiCase( rStr, pOptEnums->pName ) )
return pOptEnums->nValue;
pOptEnums++;
}
@@ -353,7 +355,7 @@ void SwHTMLParser::NewField()
if( pFormatOption )
{
const OUString& rFormat = pFormatOption->GetString();
- for( int k = 0; pFormatTable[k].pName; ++k )
+ for( int k = 0; !pFormatTable[k].pName.empty(); ++k )
{
if( rFormat.equalsIgnoreAsciiCaseAscii( pFormatTable[k].pName ) )
{
@@ -583,23 +585,23 @@ void SwHTMLParser::InsertFieldText()
}
}
-void SwHTMLParser::InsertCommentText( const char *pTag )
+void SwHTMLParser::InsertCommentText( std::string_view pTag )
{
bool bEmpty = m_aContents.isEmpty();
if( !bEmpty )
m_aContents += "\n";
m_aContents += aToken;
- if( bEmpty && pTag )
+ if( bEmpty && !pTag.empty() )
{
- m_aContents = OUStringLiteral(u"HTML: <") + OUStringChar(*pTag) + ">" + m_aContents;
+ m_aContents = OUString::Concat("HTML: <") + OUString::createFromAscii(pTag) + ">" + m_aContents;
}
}
-void SwHTMLParser::InsertComment( const OUString& rComment, const char *pTag )
+void SwHTMLParser::InsertComment( const OUString& rComment, std::string_view pTag )
{
OUString aComment( rComment );
- if( pTag )
+ if( !pTag.empty() )
{
aComment += "</" +
OUString::createFromAscii(pTag) +
@@ -609,20 +611,20 @@ void SwHTMLParser::InsertComment( const OUString& rComment, const char *pTag )
// MIB 24.06.97: If a PostIt should be insert after a space, we
// will insert before the space. Then there are less problems
// during formatting. (bug #40483#)
- const sal_Int32 nPos = m_pPam->GetPoint()->nContent.GetIndex();
- SwTextNode *pTextNd = m_pPam->GetNode().GetTextNode();
+ const sal_Int32 nPos = m_pPam->GetPoint()->GetContentIndex();
+ SwTextNode *pTextNd = m_pPam->GetPointNode().GetTextNode();
bool bMoveFwd = false;
if (nPos>0 && pTextNd && (' ' == pTextNd->GetText()[nPos-1]))
{
bMoveFwd = true;
- sal_uLong nNodeIdx = m_pPam->GetPoint()->nNode.GetIndex();
- const sal_Int32 nIdx = m_pPam->GetPoint()->nContent.GetIndex();
+ SwNodeOffset nNodeIdx = m_pPam->GetPoint()->GetNodeIndex();
+ const sal_Int32 nIdx = m_pPam->GetPoint()->GetContentIndex();
for( auto i = m_aSetAttrTab.size(); i > 0; )
{
HTMLAttr *pAttr = m_aSetAttrTab[--i];
- if( pAttr->GetSttParaIdx() != nNodeIdx ||
- pAttr->GetSttCnt() != nIdx )
+ if( pAttr->GetStartParagraphIdx() != nNodeIdx ||
+ pAttr->GetStartContent() != nIdx )
break;
if( RES_TXTATR_FIELD == pAttr->m_pItem->Which() &&
diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx
index 825d563a9f39..65f0d7167d2a 100644
--- a/sw/source/filter/html/htmlfldw.cxx
+++ b/sw/source/filter/html/htmlfldw.cxx
@@ -19,11 +19,16 @@
#include <com/sun/star/i18n/XBreakIterator.hpp>
#include <comphelper/string.hxx>
+#include <comphelper/xmlencode.hxx>
#include <svtools/htmlkywd.hxx>
#include <svtools/htmlout.hxx>
#include <osl/diagnose.h>
+#include <o3tl/string_view.hxx>
#include <fmtfld.hxx>
#include <doc.hxx>
+#include <docsh.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
#include <breakit.hxx>
#include <ndtxt.hxx>
#include <txtfld.hxx>
@@ -62,11 +67,9 @@ const char *SwHTMLWriter::GetNumFormat( sal_uInt16 nFormat )
return pFormatStr;
}
-static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
+static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField,
const SwTextNode& rTextNd, sal_Int32 nFieldPos )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
const SwFieldType* pFieldTyp = pField->GetTyp();
SwFieldIds nField = pFieldTyp->Which();
sal_uLong nFormat = pField->GetFormat();
@@ -258,7 +261,7 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
}
// ReqIF-XHTML doesn't allow <sdfield>.
- if (rHTMLWrt.mbReqIF && pTypeStr)
+ if (rWrt.mbReqIF && pTypeStr)
{
pTypeStr = nullptr;
}
@@ -266,36 +269,37 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
// Output the <sdfield> tag.
if( pTypeStr )
{
- OStringBuffer sOut;
- sOut.append('<');
- sOut.append(rHTMLWrt.GetNamespace());
- sOut.append(OOO_STRING_SVTOOLS_HTML_sdfield).append(' ').
- append(OOO_STRING_SVTOOLS_HTML_O_type).append('=').
- append(pTypeStr);
+ OStringBuffer sOut("<"
+ + rWrt.GetNamespace()
+ + OOO_STRING_SVTOOLS_HTML_sdfield
+ " "
+ OOO_STRING_SVTOOLS_HTML_O_type
+ "="
+ + pTypeStr);
if( pSubStr )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_subtype).
- append('=').append(pSubStr);
+ sOut.append(OString::Concat(" " OOO_STRING_SVTOOLS_HTML_O_subtype "=")
+ + pSubStr);
}
if( pFormatStr )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_format).
- append('=').append(pFormatStr);
+ sOut.append(OString::Concat(" " OOO_STRING_SVTOOLS_HTML_O_format "=")
+ + pFormatStr);
}
if( !aName.isEmpty() )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_name).
- append("=\"");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( rWrt.Strm(), aName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_name "=\"");
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aName );
sOut.append('\"');
}
if( !aValue.isEmpty() )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_value).
- append("=\"");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( rWrt.Strm(), aValue, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_value "=\"");
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aValue );
sOut.append('\"');
}
if( bNumFormat )
@@ -303,15 +307,15 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
OSL_ENSURE( nFormat, "number format is 0" );
sOut.append(HTMLOutFuncs::CreateTableDataOptionsValNum(
bNumValue, dNumValue, nFormat,
- *rHTMLWrt.m_pDoc->GetNumberFormatter(), rHTMLWrt.m_eDestEnc,
- &rHTMLWrt.m_aNonConvertableCharacters));
+ *rWrt.m_pDoc->GetNumberFormatter()));
}
if( bFixed )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_sdfixed);
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_sdfixed);
}
sOut.append('>');
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
}
// output content of the field
@@ -325,7 +329,7 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
sal_uInt16 nScript =
SwHTMLWriter::GetCSS1ScriptForScriptType( nScriptType );
- if( (nPos < sExpand.getLength() && nPos >= 0) || nScript != rHTMLWrt.m_nCSS1Script )
+ if( (nPos < sExpand.getLength() && nPos >= 0) || nScript != rWrt.m_nCSS1Script )
{
bNeedsCJKProcessing = true;
}
@@ -335,11 +339,11 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
{
//sequence of (start, end) property ranges we want to
//query
- SfxItemSet aScriptItemSet( rWrt.m_pDoc->GetAttrPool(),
- svl::Items<RES_CHRATR_FONT, RES_CHRATR_FONTSIZE,
- RES_CHRATR_POSTURE, RES_CHRATR_POSTURE,
- RES_CHRATR_WEIGHT, RES_CHRATR_WEIGHT,
- RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_WEIGHT>{} );
+ SfxItemSetFixed<RES_CHRATR_FONT, RES_CHRATR_FONTSIZE,
+ RES_CHRATR_POSTURE, RES_CHRATR_POSTURE,
+ RES_CHRATR_WEIGHT, RES_CHRATR_WEIGHT,
+ RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_WEIGHT>
+ aScriptItemSet( rWrt.m_pDoc->GetAttrPool() );
rTextNd.GetParaAttr(aScriptItemSet, nFieldPos, nFieldPos+1);
sal_uInt16 aWesternWhichIds[4] =
@@ -353,7 +357,7 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
RES_CHRATR_CTL_POSTURE, RES_CHRATR_CTL_WEIGHT };
sal_uInt16 *pRefWhichIds = nullptr;
- switch( rHTMLWrt.m_nCSS1Script )
+ switch( rWrt.m_nCSS1Script )
{
case CSS1_OUTMODE_WESTERN:
pRefWhichIds = aWesternWhichIds;
@@ -376,7 +380,7 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
sExpand, nPos, nScriptType );
sal_Int32 nChunkLen = nEndPos - nPos;
if( nScript != CSS1_OUTMODE_ANY_SCRIPT &&
- /* #108791# */ nScript != rHTMLWrt.m_nCSS1Script )
+ /* #108791# */ nScript != rWrt.m_nCSS1Script )
{
sal_uInt16 *pWhichIds = nullptr;
switch( nScript )
@@ -386,7 +390,7 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
case CSS1_OUTMODE_CTL: pWhichIds = aCTLWhichIds; break;
}
- rHTMLWrt.m_bTagOn = true;
+ rWrt.m_bTagOn = true;
const SfxPoolItem *aItems[5];
int nItems = 0;
@@ -404,24 +408,22 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
!(0==i ? swhtml_css1atr_equalFontItems( *pRefItem, *pItem )
: *pRefItem == *pItem) )
{
- Out( aHTMLAttrFnTab, *pItem, rHTMLWrt );
+ Out( aHTMLAttrFnTab, *pItem, rWrt );
aItems[nItems++] = pItem;
}
}
}
- HTMLOutFuncs::Out_String( rWrt.Strm(), sExpand.copy( nPos, nChunkLen ),
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sExpand.subView( nPos, nChunkLen ) );
- rHTMLWrt.m_bTagOn = false;
+ rWrt.m_bTagOn = false;
while( nItems )
- Out( aHTMLAttrFnTab, *aItems[--nItems], rHTMLWrt );
+ Out( aHTMLAttrFnTab, *aItems[--nItems], rWrt );
}
else
{
- HTMLOutFuncs::Out_String( rWrt.Strm(), sExpand.copy( nPos, nChunkLen ),
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sExpand.subView( nPos, nChunkLen ) );
}
nPos = nEndPos;
}
@@ -429,20 +431,18 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
}
else
{
- HTMLOutFuncs::Out_String( rWrt.Strm(), sExpand,
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sExpand );
}
// Output the closing tag.
if( pTypeStr )
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_sdfield, false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_sdfield), false );
return rWrt;
}
-Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
+SwHTMLWriter& OutHTML_SwFormatField( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
const SwFormatField & rField = static_cast<const SwFormatField&>(rHt);
const SwField* pField = rField.GetField();
const SwFieldType* pFieldTyp = pField->GetTyp();
@@ -461,7 +461,7 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
// TODO: HTML-Tags are written without entities, that for, characters
// not contained in the destination encoding are lost!
OString sTmp(OUStringToOString(rText,
- static_cast<SwHTMLWriter&>(rWrt).m_eDestEnc));
+ RTL_TEXTENCODING_UTF8));
rWrt.Strm().WriteOString( sTmp ).WriteChar( '>' );
}
else if( SwFieldIds::Postit == pFieldTyp->Which() )
@@ -472,7 +472,7 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
bool bWritten = false;
if( (rComment.getLength() >= 6 && rComment.startsWith("<") && rComment.endsWith(">") &&
- rComment.copy( 1, 4 ).equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_meta) ) ||
+ o3tl::equalsIgnoreAsciiCase(rComment.subView( 1, 4 ), u"" OOO_STRING_SVTOOLS_HTML_meta) ) ||
(rComment.getLength() >= 7 &&
rComment.startsWith( "<!--" ) &&
rComment.endsWith( "-->" )) )
@@ -482,7 +482,7 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
// TODO: HTML-Tags are written without entities, that for,
// characters not contained in the destination encoding are lost!
OString sTmp(OUStringToOString(sComment,
- static_cast<SwHTMLWriter&>(rWrt).m_eDestEnc));
+ RTL_TEXTENCODING_UTF8));
rWrt.Strm().WriteOString( sTmp );
bWritten = true;
}
@@ -490,7 +490,7 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
rComment.endsWith(">") &&
rComment.startsWithIgnoreAsciiCase( "HTML:" ) )
{
- OUString sComment(comphelper::string::stripStart(rComment.copy(5), ' '));
+ OUString sComment(comphelper::string::stripStart(rComment.subView(5), ' '));
if( '<' == sComment[0] )
{
sComment = convertLineEnd(sComment, GetSystemLineEnd());
@@ -498,7 +498,7 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
// characters not contained in the destination encoding are
// lost!
OString sTmp(OUStringToOString(sComment,
- static_cast<SwHTMLWriter&>(rWrt).m_eDestEnc));
+ RTL_TEXTENCODING_UTF8));
rWrt.Strm().WriteOString( sTmp );
bWritten = true;
}
@@ -512,15 +512,15 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
OString sOut =
"<" OOO_STRING_SVTOOLS_HTML_comment
" " +
- OUStringToOString(sComment, static_cast<SwHTMLWriter&>(rWrt).m_eDestEnc) +
+ OUStringToOString(comphelper::string::encodeForXml(sComment), RTL_TEXTENCODING_UTF8) +
" -->";
rWrt.Strm().WriteOString( sOut );
}
}
else if( SwFieldIds::Script == pFieldTyp->Which() )
{
- if( rHTMLWrt.m_bLFPossible )
- rHTMLWrt.OutNewLine( true );
+ if (rWrt.IsLFPossible())
+ rWrt.OutNewLine( true );
bool bURL = static_cast<const SwScriptField *>(pField)->IsCodeURL();
const OUString& rType = pField->GetPar1();
@@ -533,39 +533,39 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
// otherwise is the script content itself. Since only JavaScript
// is in fields, it must be JavaScript ...:)
HTMLOutFuncs::OutScript( rWrt.Strm(), rWrt.GetBaseURL(), aContents, rType, JAVASCRIPT,
- aURL, nullptr, nullptr, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ aURL, nullptr, nullptr );
- if( rHTMLWrt.m_bLFPossible )
- rHTMLWrt.OutNewLine( true );
+ if (rWrt.IsLFPossible())
+ rWrt.OutNewLine( true );
}
else
{
const SwTextField *pTextField = rField.GetTextField();
OSL_ENSURE( pTextField, "Where is the txt fld?" );
- if( pTextField )
+ if (pTextField && rWrt.m_pDoc->GetDocShell() && rWrt.m_pDoc->GetDocShell()->GetView())
{
// ReqIF-XHTML doesn't allow specifying a background color.
- bool bFieldShadings = SwViewOption::IsFieldShadings() && !rHTMLWrt.mbReqIF;
+ const SwViewOption* pViewOptions = rWrt.m_pDoc->GetDocShell()->GetView()->GetWrtShell().GetViewOptions();
+ bool bFieldShadings = pViewOptions->IsFieldShadings() && !rWrt.mbReqIF;
if (bFieldShadings)
{
// If there is a text portion background started already, that should have priority.
- auto it = rHTMLWrt.maStartedAttributes.find(RES_CHRATR_BACKGROUND);
- if (it != rHTMLWrt.maStartedAttributes.end())
+ auto it = rWrt.maStartedAttributes.find(RES_CHRATR_BACKGROUND);
+ if (it != rWrt.maStartedAttributes.end())
bFieldShadings = it->second <= 0;
}
if (bFieldShadings)
{
- OStringBuffer sOut;
- sOut.append("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span);
- sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_style "=\"");
- sOut.append(sCSS1_P_background);
- sOut.append(": ");
-
- Color& rColor = SwViewOption::GetFieldShadingsColor();
- sOut.append(GetCSS1_Color(rColor));
- sOut.append("\">");
- rWrt.Strm().WriteOString(sOut.makeStringAndClear());
+ const Color& rColor = pViewOptions->GetFieldShadingsColor();
+ OString sOut(
+ "<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span
+ " " OOO_STRING_SVTOOLS_HTML_O_style "=\""
+ + sCSS1_P_background
+ + ": "
+ + GetCSS1_Color(rColor)
+ + "\">");
+ rWrt.Strm().WriteOString(sOut);
}
OutHTML_SwField( rWrt, pField, pTextField->GetTextNode(),
@@ -573,7 +573,7 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
if (bFieldShadings)
HTMLOutFuncs::Out_AsciiTag(
- rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span, false);
+ rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false);
}
}
return rWrt;
diff --git a/sw/source/filter/html/htmlfly.cxx b/sw/source/filter/html/htmlfly.cxx
index 771a449ec90a..c4fe7dfa1006 100644
--- a/sw/source/filter/html/htmlfly.cxx
+++ b/sw/source/filter/html/htmlfly.cxx
@@ -33,12 +33,12 @@ using namespace css;
SwHTMLPosFlyFrame::SwHTMLPosFlyFrame( const SwPosFlyFrame& rPosFly,
const SdrObject *pSdrObj,
AllHtmlFlags nFlags ) :
- pFrameFormat( &rPosFly.GetFormat() ),
- pSdrObject( pSdrObj ),
- pNdIdx( new SwNodeIndex( rPosFly.GetNdIndex() ) ),
- nOrdNum( rPosFly.GetOrdNum() ),
- nContentIdx( 0 ),
- nAllFlags( nFlags )
+ m_pFrameFormat( &rPosFly.GetFormat() ),
+ m_pSdrObject( pSdrObj ),
+ m_aNodeIndex( rPosFly.GetNode() ),
+ m_nOrdNum( rPosFly.GetOrdNum() ),
+ m_nContentIndex( 0 ),
+ m_nAllFlags( nFlags )
{
const SwFormatAnchor& rAnchor = rPosFly.GetFormat().GetAnchor();
if ((RndStdIds::FLY_AT_CHAR != rAnchor.GetAnchorId()) ||
@@ -47,38 +47,38 @@ SwHTMLPosFlyFrame::SwHTMLPosFlyFrame( const SwPosFlyFrame& rPosFly,
// Output of auto-bound frames will be a character farther back,
// because then the position aligns with Netscape.
- OSL_ENSURE( rAnchor.GetContentAnchor(), "No anchor position?" );
- if( !rAnchor.GetContentAnchor() )
+ OSL_ENSURE( rAnchor.GetAnchorNode(), "No anchor position?" );
+ if( !rAnchor.GetAnchorNode() )
return;
- nContentIdx = rAnchor.GetContentAnchor()->nContent.GetIndex();
+ m_nContentIndex = rAnchor.GetAnchorContentOffset();
sal_Int16 eHoriRel = rPosFly.GetFormat().GetHoriOrient().
GetRelationOrient();
if( text::RelOrientation::FRAME == eHoriRel || text::RelOrientation::PRINT_AREA == eHoriRel )
{
- const SwContentNode *pCNd = pNdIdx->GetNode().GetContentNode();
+ const SwContentNode *pCNd = m_aNodeIndex.GetNode().GetContentNode();
OSL_ENSURE( pCNd, "No Content-Node at PaM position" );
- if( pCNd && nContentIdx < pCNd->Len() )
- nContentIdx++;
+ if( pCNd && m_nContentIndex < pCNd->Len() )
+ m_nContentIndex++;
}
}
bool SwHTMLPosFlyFrame::operator<( const SwHTMLPosFlyFrame& rFrame ) const
{
- if( pNdIdx->GetIndex() == rFrame.pNdIdx->GetIndex() )
+ if( m_aNodeIndex.GetIndex() == rFrame.m_aNodeIndex.GetIndex() )
{
- if( nContentIdx == rFrame.nContentIdx )
+ if( m_nContentIndex == rFrame.m_nContentIndex )
{
if( GetOutPos() == rFrame.GetOutPos() )
- return nOrdNum < rFrame.nOrdNum;
+ return m_nOrdNum < rFrame.m_nOrdNum;
else
return GetOutPos() < rFrame.GetOutPos();
}
else
- return nContentIdx < rFrame.nContentIdx;
+ return m_nContentIndex < rFrame.m_nContentIndex;
}
else
- return pNdIdx->GetIndex() < rFrame.pNdIdx->GetIndex();
+ return m_aNodeIndex.GetIndex() < rFrame.m_aNodeIndex.GetIndex();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmlfly.hxx b/sw/source/filter/html/htmlfly.hxx
index 32b9d80aa65d..4038ac2a2dcf 100644
--- a/sw/source/filter/html/htmlfly.hxx
+++ b/sw/source/filter/html/htmlfly.hxx
@@ -17,15 +17,16 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_SW_SOURCE_FILTER_HTML_HTMLFLY_HXX
-#define INCLUDED_SW_SOURCE_FILTER_HTML_HTMLFLY_HXX
+#pragma once
#include <o3tl/sorted_vector.hxx>
#include <o3tl/typed_flags_set.hxx>
+#include <sal/types.h>
+#include <ndindex.hxx>
+#include <memory>
class SdrObject;
class SwFrameFormat;
-class SwNodeIndex;
class SwPosFlyFrame;
// ATTENTION: The values of this enum are used directly in the output table!!!
@@ -78,28 +79,26 @@ namespace o3tl {
template<> struct typed_flags<HtmlContainerFlags> : is_typed_flags<HtmlContainerFlags, 0x03> {};
}
-const sal_uInt16 MAX_FRMTYPES = HTML_FRMTYPE_END;
-const sal_uInt16 MAX_BROWSERS = 4;
-
struct AllHtmlFlags {
HtmlOut nOut;
HtmlPosition nPosition;
HtmlContainerFlags nContainer;
};
-extern AllHtmlFlags const aHTMLOutFramePageFlyTable[MAX_FRMTYPES][MAX_BROWSERS];
-extern AllHtmlFlags const aHTMLOutFrameParaFrameTable[MAX_FRMTYPES][MAX_BROWSERS];
-extern AllHtmlFlags const aHTMLOutFrameParaPrtAreaTable[MAX_FRMTYPES][MAX_BROWSERS];
-extern AllHtmlFlags const aHTMLOutFrameParaOtherTable[MAX_FRMTYPES][MAX_BROWSERS];
-extern AllHtmlFlags const aHTMLOutFrameAsCharTable[MAX_FRMTYPES][MAX_BROWSERS];
+
+AllHtmlFlags getHTMLOutFramePageFlyTable(SwHTMLFrameType eFrameType, sal_uInt16 nExportMode);
+AllHtmlFlags getHTMLOutFrameParaFrameTable(SwHTMLFrameType eFrameType, sal_uInt16 nExportMode);
+AllHtmlFlags getHTMLOutFrameParaPrtAreaTable(SwHTMLFrameType eFrameType, sal_uInt16 nExportMode);
+AllHtmlFlags getHTMLOutFrameParaOtherTable(SwHTMLFrameType eFrameType, sal_uInt16 nExportMode);
+AllHtmlFlags getHTMLOutFrameAsCharTable(SwHTMLFrameType eFrameType, sal_uInt16 nExportMode);
class SwHTMLPosFlyFrame
{
- const SwFrameFormat *pFrameFormat; // the frame
- const SdrObject *pSdrObject; // maybe Sdr-Object
- SwNodeIndex *pNdIdx; // Node-Index
- sal_uInt32 nOrdNum; // from SwPosFlyFrame
- sal_Int32 nContentIdx; // its position in content
- AllHtmlFlags nAllFlags;
+ const SwFrameFormat *m_pFrameFormat; // the frame
+ const SdrObject *m_pSdrObject; // maybe Sdr-Object
+ SwNodeIndex m_aNodeIndex; // Node-Index
+ sal_uInt32 m_nOrdNum; // from SwPosFlyFrame
+ sal_Int32 m_nContentIndex; // its position in content
+ AllHtmlFlags m_nAllFlags;
SwHTMLPosFlyFrame(const SwHTMLPosFlyFrame&) = delete;
SwHTMLPosFlyFrame& operator=(const SwHTMLPosFlyFrame&) = delete;
@@ -111,21 +110,19 @@ public:
bool operator<( const SwHTMLPosFlyFrame& ) const;
- const SwFrameFormat& GetFormat() const { return *pFrameFormat; }
- const SdrObject* GetSdrObject() const { return pSdrObject; }
- const SwNodeIndex& GetNdIndex() const { return *pNdIdx; }
- sal_Int32 GetContentIndex() const { return nContentIdx; }
- AllHtmlFlags const & GetOutMode() const { return nAllFlags; }
- HtmlOut GetOutFn() const { return nAllFlags.nOut; }
- HtmlPosition GetOutPos() const { return nAllFlags.nPosition; }
+ const SwFrameFormat& GetFormat() const { return *m_pFrameFormat; }
+ const SdrObject* GetSdrObject() const { return m_pSdrObject; }
+ const SwNodeIndex& GetNdIndex() const { return m_aNodeIndex; }
+ sal_Int32 GetContentIndex() const { return m_nContentIndex; }
+ AllHtmlFlags const & GetOutMode() const { return m_nAllFlags; }
+ HtmlOut GetOutFn() const { return m_nAllFlags.nOut; }
+ HtmlPosition GetOutPos() const { return m_nAllFlags.nPosition; }
};
class SwHTMLPosFlyFrames
: public o3tl::sorted_vector<std::unique_ptr<SwHTMLPosFlyFrame>,
- o3tl::less_uniqueptr_to<SwHTMLPosFlyFrame>,
+ o3tl::less_ptr_to,
o3tl::find_partialorder_ptrequals>
{};
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmlflyt.cxx b/sw/source/filter/html/htmlflyt.cxx
index 9e4596ebc7bb..9653c0bb062e 100644
--- a/sw/source/filter/html/htmlflyt.cxx
+++ b/sw/source/filter/html/htmlflyt.cxx
@@ -18,488 +18,470 @@
*/
#include "htmlfly.hxx"
+#include <svtools/htmlcfg.hxx>
-#define TE(t,p,c) { HtmlOut::t, HtmlPosition::p, HtmlContainerFlags::c }
+constexpr sal_uInt16 MAX_FRMTYPES = HTML_FRMTYPE_END;
+constexpr sal_uInt16 MAX_BROWSERS = HTML_CFG_MAX + 1;
-AllHtmlFlags const aHTMLOutFramePageFlyTable[MAX_FRMTYPES][MAX_BROWSERS] =
+constexpr AllHtmlFlags aHTMLOutFramePageFlyTable[][MAX_BROWSERS] =
{
{
// text frame with table
- TE(TableNode, Before, NONE), // HTML 3.2
- TE(Div, Prefix, NONE), // IE 4
- TE(Div, Prefix, NONE), // SW
- TE(Div, Prefix, NONE) // Netscape 4!
+ { HtmlOut::Div, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Div, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Div, HtmlPosition::Prefix, HtmlContainerFlags::NONE } // Netscape 4!
},
{
// text frame with table and headline
- TE(TableNode, Before, NONE), // HTML 3.2
- TE(Div, Prefix, NONE), // IE 4
- TE(Div, Prefix, NONE), // SW
- TE(Div, Prefix, NONE) // Netscape 4
+ { HtmlOut::Div, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Div, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Div, HtmlPosition::Prefix, HtmlContainerFlags::NONE } // Netscape 4
},
{
// column frame
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(GraphicFrame, Prefix, NONE), // IE 4
- TE(MultiCol, Prefix, NONE), // SW
- TE(MultiCol, Prefix, Div) // Netscape 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::MultiCol, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::MultiCol, HtmlPosition::Prefix, HtmlContainerFlags::Div } // Netscape 4
},
{
// empty text frame
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(Div, Prefix, NONE), // IE 4
- TE(Div, Prefix, NONE), // SW
- TE(Div, Prefix, NONE) // Netscape 4
+ { HtmlOut::Div, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Div, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Div, HtmlPosition::Prefix, HtmlContainerFlags::NONE } // Netscape 4
},
{
// other text frame
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(Div, Prefix, NONE), // IE 4
- TE(Div, Prefix, NONE), // SW
- TE(Div, Prefix, NONE) // Netscape 4
+ { HtmlOut::Div, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Div, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Div, HtmlPosition::Prefix, HtmlContainerFlags::NONE } // Netscape 4
},
{
// graphic node
- TE(GraphicNode, Inside, NONE), // HTML 3.2
- TE(GraphicNode, Prefix, NONE), // IE 4
- TE(GraphicNode, Prefix, NONE), // SW
- TE(GraphicNode, Prefix, Span) // Netscape 4
+ { HtmlOut::GraphicNode, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::GraphicNode, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicNode, HtmlPosition::Prefix, HtmlContainerFlags::Span } // Netscape 4
},
{
// plug-in
- TE(OleNode, Inside, NONE), // HTML 3.2
- TE(OleNode, Prefix, NONE), // IE 4
- TE(OleNode, Prefix, NONE), // SW
- TE(OleNode, Prefix, Span) // Netscape 4
+ { HtmlOut::OleNode, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleNode, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleNode, HtmlPosition::Prefix, HtmlContainerFlags::Span } // Netscape 4
},
{
// applet
- TE(OleNode, Inside, NONE), // HTML 3.2
- TE(OleNode, Prefix, NONE), // IE 4
- TE(OleNode, Prefix, NONE), // SW
- TE(OleNode, Prefix, Span) // Netscape 4
+ { HtmlOut::OleNode, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleNode, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleNode, HtmlPosition::Prefix, HtmlContainerFlags::Span } // Netscape 4
},
{
// floating frame
- TE(OleGraphic, Inside, NONE), // HTML 3.2
- TE(OleNode, Prefix, NONE), // IE 4
- TE(OleNode, Prefix, NONE), // SW
- TE(OleGraphic, Prefix, Span) // Netscape 4
+ { HtmlOut::OleNode, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleNode, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleGraphic, HtmlPosition::Prefix, HtmlContainerFlags::Span } // Netscape 4
},
{
// other OLE objects
- TE(OleGraphic, Inside, NONE), // HTML 3.2
- TE(OleGraphic, Prefix, NONE), // IE 4
- TE(OleGraphic, Prefix, NONE), // SW
- TE(OleGraphic, Prefix, Span) // Netscape 4
+ { HtmlOut::OleGraphic, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleGraphic, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleGraphic, HtmlPosition::Prefix, HtmlContainerFlags::Span } // Netscape 4
},
{
// marquee
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(AMarquee, Prefix, NONE), // IE 4
- TE(AMarquee, Prefix, NONE), // SW
- TE(GraphicFrame, Prefix, Span) // Netscape 4
+ { HtmlOut::AMarquee, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::AMarquee, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicFrame, HtmlPosition::Prefix, HtmlContainerFlags::Span } // Netscape 4
},
{
// controls
- TE(Control, Inside, NONE), // HTML 3.2
- TE(Control, Prefix, NONE), // IE 4
- TE(Control, Prefix, NONE), // SW
+ { HtmlOut::Control, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Control, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
// Netscape disables FROM at controls in absolute position span.
- TE(Control, Inside, NONE) // Netscape 4
+ { HtmlOut::Control, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// other character objects
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(GraphicFrame, Prefix, NONE), // IE 4
- TE(GraphicFrame, Prefix, NONE), // SW
- TE(GraphicFrame, Prefix, Span) // Netscape 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicFrame, HtmlPosition::Prefix, HtmlContainerFlags::Span } // Netscape 4
}
};
-AllHtmlFlags const aHTMLOutFrameParaFrameTable[MAX_FRMTYPES][MAX_BROWSERS] =
+AllHtmlFlags getHTMLOutFramePageFlyTable(SwHTMLFrameType eFrameType, sal_uInt16 nExportMode)
+{
+ static_assert(std::size(aHTMLOutFramePageFlyTable) == MAX_FRMTYPES);
+ assert(eFrameType < HTML_FRMTYPE_END);
+ assert(nExportMode <= HTML_CFG_MAX);
+
+ return aHTMLOutFramePageFlyTable[eFrameType][nExportMode];
+}
+
+constexpr AllHtmlFlags aHTMLOutFrameParaFrameTable[][MAX_BROWSERS] =
{
{
// text frame with table
- TE(TableNode, Before, NONE), // HTML 3.2
- TE(TableNode, Before, NONE), // IE 4
- TE(TableNode, Before, NONE), // SW
- TE(TableNode, Before, NONE) // Netscape 4
+ { HtmlOut::TableNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::TableNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::TableNode, HtmlPosition::Before, HtmlContainerFlags::NONE } // Netscape 4
},
{
// text frame with table and headline
- TE(TableNode, Before, NONE), // HTML 3.2
- TE(Div, Before, NONE), // IE 4
- TE(Div, Before, NONE), // SW
- TE(TableNode, Before, NONE) // Netscape 4
+ { HtmlOut::Div, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Div, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::TableNode, HtmlPosition::Before, HtmlContainerFlags::NONE } // Netscape 4
},
{
// column frame
- TE(GraphicFrame, Before, NONE), // HTML 3.2
- TE(GraphicFrame, Before, NONE), // IE 4
- TE(MultiCol, Before, NONE), // SW
- TE(MultiCol, Before, Div) // Netscape 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::MultiCol, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::MultiCol, HtmlPosition::Before, HtmlContainerFlags::Div } // Netscape 4
},
{
// empty text frame
- TE(GraphicFrame, Before, NONE), // HTML 3.2
- TE(Div, Before, NONE), // IE 4
- TE(Spacer, Before, NONE), // SW
- TE(Spacer, Before, NONE) // Netscape 4
+ { HtmlOut::Div, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Spacer, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Spacer, HtmlPosition::Before, HtmlContainerFlags::NONE } // Netscape 4
},
{
// other text frame
- TE(GraphicFrame, Before, NONE), // HTML 3.2
- TE(Div, Before, NONE), // IE 4
- TE(Div, Before, NONE), // SW
- TE(Div, Before, NONE) // Netscape 4
+ { HtmlOut::Div, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Div, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Div, HtmlPosition::Before, HtmlContainerFlags::NONE } // Netscape 4
},
{
// graphic node
- TE(GraphicNode, Before, NONE), // HTML 3.2
- TE(GraphicNode, Before, NONE), // IE 4
- TE(GraphicNode, Before, NONE), // SW
- TE(GraphicNode, Before, NONE) // Netscape 4
+ { HtmlOut::GraphicNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::GraphicNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicNode, HtmlPosition::Before, HtmlContainerFlags::NONE } // Netscape 4
},
{
// plug-in
- TE(OleNode, Before, NONE), // HTML 3.2
- TE(OleNode, Before, NONE), // IE 4
- TE(OleNode, Before, NONE), // SW
- TE(OleNode, Before, NONE) // Netscape 4
+ { HtmlOut::OleNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleNode, HtmlPosition::Before, HtmlContainerFlags::NONE } // Netscape 4
},
{
// applet
- TE(OleNode, Before, NONE), // HTML 3.2
- TE(OleNode, Before, NONE), // IE 4
- TE(OleNode, Before, NONE), // SW
- TE(OleNode, Before, NONE) // Netscape 4
+ { HtmlOut::OleNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleNode, HtmlPosition::Before, HtmlContainerFlags::NONE } // Netscape 4
},
{
// floating frame
- TE(OleGraphic, Before, NONE), // HTML 3.2
- TE(OleNode, Before, NONE), // IE 4
- TE(OleNode, Before, NONE), // SW
- TE(OleGraphic, Before, NONE) // Netscape 4
+ { HtmlOut::OleNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleGraphic, HtmlPosition::Before, HtmlContainerFlags::NONE } // Netscape 4
},
{
// other OLE objects
- TE(OleGraphic, Before, NONE), // HTML 3.2
- TE(OleGraphic, Before, NONE), // IE 4
- TE(OleGraphic, Before, NONE), // SW
- TE(OleGraphic, Before, NONE) // Netscape 4
+ { HtmlOut::OleGraphic, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleGraphic, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleGraphic, HtmlPosition::Before, HtmlContainerFlags::NONE } // Netscape 4
},
{
// marquee (for Netscape 4 in container, so that
// the marquee appears at the right spot)
- TE(GraphicFrame, Before, NONE), // HTML 3.2
- TE(AMarquee, Before, NONE), // IE 4
- TE(AMarquee, Before, NONE), // SW
- TE(GraphicFrame, Before, NONE) // Netscape 4
+ { HtmlOut::AMarquee, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::AMarquee, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicFrame, HtmlPosition::Before, HtmlContainerFlags::NONE } // Netscape 4
},
{
// controls
- TE(Control, Inside, NONE), // HTML 3.2
- TE(Control, Before, NONE), // IE 4
- TE(Control, Before, NONE), // SW
+ { HtmlOut::Control, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Control, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
// here you could make container out if it (import is missing)
- TE(Control, Before, NONE) // Netscape 4
+ { HtmlOut::Control, HtmlPosition::Before, HtmlContainerFlags::NONE } // Netscape 4
},
{
// other character objects
- TE(GraphicFrame, Before, NONE), // HTML 3.2
- TE(GraphicFrame, Before, NONE), // IE 4
- TE(GraphicFrame, Before, NONE), // SW
- TE(GraphicFrame, Before, NONE) // Netscape 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicFrame, HtmlPosition::Before, HtmlContainerFlags::NONE } // Netscape 4
}
};
-AllHtmlFlags const aHTMLOutFrameParaPrtAreaTable[MAX_FRMTYPES][MAX_BROWSERS] =
+AllHtmlFlags getHTMLOutFrameParaFrameTable(SwHTMLFrameType eFrameType, sal_uInt16 nExportMode)
+{
+ static_assert(std::size(aHTMLOutFrameParaFrameTable) == MAX_FRMTYPES);
+ assert(eFrameType < HTML_FRMTYPE_END);
+ assert(nExportMode <= HTML_CFG_MAX);
+
+ return aHTMLOutFrameParaFrameTable[eFrameType][nExportMode];
+}
+
+constexpr AllHtmlFlags aHTMLOutFrameParaPrtAreaTable[][MAX_BROWSERS] =
{
{
// text frame with table
- TE(TableNode, Inside, NONE), // HTML 3.2
- TE(TableNode, Inside, NONE), // IE 4
- TE(TableNode, Inside, NONE), // SW
- TE(TableNode, Inside, NONE) // Netscape 4
+ { HtmlOut::TableNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::TableNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::TableNode, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// text frame with table and headline
- TE(TableNode, Inside, NONE), // HTML 3.2
- TE(Span, Inside, NONE), // IE 4
- TE(Span, Inside, NONE), // SW
- TE(Span, Inside, NONE) // Netscape 4
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// column frame
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(GraphicFrame, Inside, NONE), // IE 4
- TE(MultiCol, Inside, NONE), // SW
- TE(MultiCol, Inside, Span) // Netscape 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::MultiCol, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::MultiCol, HtmlPosition::Inside, HtmlContainerFlags::Span } // Netscape 4
},
{
// empty text frame
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(Span, Inside, NONE), // IE 4
- TE(Spacer, Inside, NONE), // SW
- TE(Spacer, Inside, NONE) // Netscape 4
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Spacer, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Spacer, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// other text frame
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(Span, Inside, NONE), // IE 4
- TE(Span, Inside, NONE), // SW
- TE(Span, Inside, NONE) // Netscape 4
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// graphic node
- TE(GraphicNode, Inside, NONE), // HTML 3.2
- TE(GraphicNode, Inside, NONE), // IE 4
- TE(GraphicNode, Inside, NONE), // SW
- TE(GraphicNode, Inside, NONE) // Netscape 4
+ { HtmlOut::GraphicNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::GraphicNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicNode, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// plug-in
- TE(OleNode, Inside, NONE), // HTML 3.2
- TE(OleNode, Inside, NONE), // IE 4
- TE(OleNode, Inside, NONE), // SW
- TE(OleNode, Inside, NONE) // Netscape 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// applet
- TE(OleNode, Inside, NONE), // HTML 3.2
- TE(OleNode, Inside, NONE), // IE 4
- TE(OleNode, Inside, NONE), // SW
- TE(OleNode, Inside, NONE) // Netscape 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// floating frame
- TE(OleGraphic, Inside, NONE), // HTML 3.2
- TE(OleNode, Inside, NONE), // IE 4
- TE(OleNode, Inside, NONE), // SW
- TE(OleGraphic, Inside, NONE) // Netscape 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleGraphic, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// other OLE objects
- TE(OleGraphic, Inside, NONE), // HTML 3.2
- TE(OleGraphic, Inside, NONE), // IE 4
- TE(OleGraphic, Inside, NONE), // SW
- TE(OleGraphic, Inside, NONE) // Netscape 4
+ { HtmlOut::OleGraphic, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleGraphic, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleGraphic, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// marquee
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(AMarquee, Inside, NONE), // IE 4
- TE(AMarquee, Inside, NONE), // SW
- TE(GraphicFrame, Inside, NONE) // Netscape 4
+ { HtmlOut::AMarquee, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::AMarquee, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// controls
- TE(Control, Inside, NONE), // HTML 3.2
- TE(Control, Inside, NONE), // IE 4
- TE(Control, Inside, NONE), // SW
+ { HtmlOut::Control, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Control, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
// here you could make container out if it (import is missing)
- TE(Control, Inside, NONE) // Netscape 4
+ { HtmlOut::Control, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// other character objects
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(GraphicFrame, Inside, NONE), // IE 4
- TE(GraphicFrame, Inside, NONE), // SW
- TE(GraphicFrame, Inside, NONE) // Netscape 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
}
};
-AllHtmlFlags const aHTMLOutFrameParaOtherTable[MAX_FRMTYPES][MAX_BROWSERS] =
+AllHtmlFlags getHTMLOutFrameParaPrtAreaTable(SwHTMLFrameType eFrameType, sal_uInt16 nExportMode)
+{
+ static_assert(std::size(aHTMLOutFrameParaPrtAreaTable) == MAX_FRMTYPES);
+ assert(eFrameType < HTML_FRMTYPE_END);
+ assert(nExportMode <= HTML_CFG_MAX);
+
+ return aHTMLOutFrameParaPrtAreaTable[eFrameType][nExportMode];
+}
+
+constexpr AllHtmlFlags aHTMLOutFrameParaOtherTable[][MAX_BROWSERS] =
{
{
// text frame with table
- TE(TableNode, Before, NONE), // HTML 3.2
- TE(Span, Inside, NONE), // IE 4
- TE(Span, Inside, NONE), // SW
- TE(Span, Inside, NONE) // Netscape 4
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// text frame with table and headline
- TE(TableNode, Before, NONE), // HTML 3.2
- TE(Span, Inside, NONE), // IE 4
- TE(Span, Inside, NONE), // SW
- TE(Span, Inside, NONE) // Netscape 4
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// column frame
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(GraphicFrame, Inside, NONE), // IE 4
- TE(MultiCol, Inside, NONE), // SW
- TE(MultiCol, Inside, Span) // Netscape 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::MultiCol, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::MultiCol, HtmlPosition::Inside, HtmlContainerFlags::Span } // Netscape 4
},
{
// empty text frame
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(Span, Inside, NONE), // IE 4
- TE(Span, Inside, NONE), // SW
- TE(Span, Inside, NONE) // Netscape 4
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// other text frame
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(Span, Inside, NONE), // IE 4
- TE(Span, Inside, NONE), // SW
- TE(Span, Inside, NONE) // Netscape 4
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Span, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// graphic node
- TE(GraphicNode, Inside, NONE), // HTML 3.2
- TE(GraphicNode, Inside, NONE), // IE 4
- TE(GraphicNode, Inside, NONE), // SW
- TE(GraphicNode, Inside, Span) // Netscape 4
+ { HtmlOut::GraphicNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::GraphicNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicNode, HtmlPosition::Inside, HtmlContainerFlags::Span } // Netscape 4
},
{
// plug-in
- TE(OleNode, Inside, NONE), // HTML 3.2
- TE(OleNode, Inside, NONE), // IE 4
- TE(OleNode, Inside, NONE), // SW
- TE(OleNode, Inside, Span) // Netscape 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::Span } // Netscape 4
},
{
// applet
- TE(OleNode, Inside, NONE), // HTML 3.2
- TE(OleNode, Inside, NONE), // IE 4
- TE(OleNode, Inside, NONE), // SW
- TE(OleNode, Inside, Span) // Netscape 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::Span } // Netscape 4
},
{
// floating frame
- TE(OleGraphic, Inside, NONE), // HTML 3.2
- TE(OleNode, Inside, NONE), // IE 4
- TE(OleNode, Inside, NONE), // SW
- TE(OleGraphic, Inside, Span) // Netscape 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleGraphic, HtmlPosition::Inside, HtmlContainerFlags::Span } // Netscape 4
},
{
// other OLE objects
- TE(OleGraphic, Inside, NONE), // HTML 3.2
- TE(OleGraphic, Inside, NONE), // IE 4
- TE(OleGraphic, Inside, NONE), // SW
- TE(OleGraphic, Inside, Span) // Netscape 4
+ { HtmlOut::OleGraphic, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleGraphic, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleGraphic, HtmlPosition::Inside, HtmlContainerFlags::Span } // Netscape 4
},
{
// marquee
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(AMarquee, Inside, NONE), // IE 4
- TE(AMarquee, Inside, NONE), // SW
- TE(GraphicFrame, Inside, Span) // Netscape 4
+ { HtmlOut::AMarquee, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::AMarquee, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::Span } // Netscape 4
},
{
// controls
- TE(Control, Inside, NONE), // HTML 3.2
- TE(Control, Inside, NONE), // IE 4
- TE(Control, Inside, NONE), // SW
+ { HtmlOut::Control, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Control, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
// Netscape disables FROM at controls in absolute position span.
- TE(Control, Inside, NONE) // Netscape 4
+ { HtmlOut::Control, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// other character objects
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(GraphicFrame, Inside, NONE), // IE 4
- TE(GraphicFrame, Inside, NONE), // SW
- TE(GraphicFrame, Inside, Span) // Netscape 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::Span } // Netscape 4
}
};
-AllHtmlFlags const aHTMLOutFrameAsCharTable[MAX_FRMTYPES][MAX_BROWSERS] =
+AllHtmlFlags getHTMLOutFrameParaOtherTable(SwHTMLFrameType eFrameType, sal_uInt16 nExportMode)
+{
+ static_assert(std::size(aHTMLOutFrameParaOtherTable) == MAX_FRMTYPES);
+ assert(eFrameType < HTML_FRMTYPE_END);
+ assert(nExportMode <= HTML_CFG_MAX);
+
+ return aHTMLOutFrameParaOtherTable[eFrameType][nExportMode];
+}
+
+constexpr AllHtmlFlags aHTMLOutFrameAsCharTable[][MAX_BROWSERS] =
{
{
// text frame with table
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(GraphicFrame, Inside, NONE), // IE 4
- TE(GraphicFrame, Inside, NONE), // SW
- TE(GraphicFrame, Inside, NONE) // Netscape 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// text frame with table and headline
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(GraphicFrame, Inside, NONE), // IE 4
- TE(GraphicFrame, Inside, NONE), // SW
- TE(GraphicFrame, Inside, NONE) // Netscape 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// column frame
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(GraphicFrame, Inside, NONE), // IE 4
- TE(MultiCol, Inside, NONE), // SW
- TE(MultiCol, Inside, NONE) // Netscape 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::MultiCol, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::MultiCol, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// empty text frame
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(GraphicFrame, Inside, NONE), // IE 4
- TE(Spacer, Inside, NONE), // SW
- TE(Spacer, Inside, NONE) // Netscape 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Spacer, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Spacer, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// other text frame
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(GraphicFrame, Inside, NONE), // IE 4
- TE(GraphicFrame, Inside, NONE), // SW
- TE(GraphicFrame, Inside, NONE) // Netscape 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// graphic node
- TE(GraphicNode, Inside, NONE), // HTML 3.2
- TE(GraphicNode, Inside, NONE), // IE 4
- TE(GraphicNode, Inside, NONE), // SW
- TE(GraphicNode, Inside, NONE) // Netscape 4
+ { HtmlOut::GraphicNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::GraphicNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicNode, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// plug-in
- TE(OleNode, Inside, NONE), // HTML 3.2
- TE(OleNode, Inside, NONE), // IE 4
- TE(OleNode, Inside, NONE), // SW
- TE(OleNode, Inside, NONE) // Netscape 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// applet
- TE(OleNode, Inside, NONE), // HTML 3.2
- TE(OleNode, Inside, NONE), // IE 4
- TE(OleNode, Inside, NONE), // SW
- TE(OleNode, Inside, NONE) // Netscape 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// floating frame
- TE(OleGraphic, Inside, NONE), // HTML 3.2
- TE(OleNode, Inside, NONE), // IE 4
- TE(OleNode, Inside, NONE), // SW
- TE(OleGraphic, Inside, NONE) // Netscape 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleGraphic, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// other OLE objects
- TE(OleGraphic, Inside, NONE), // HTML 3.2
- TE(OleGraphic, Inside, NONE), // IE 4
- TE(OleGraphic, Inside, NONE), // SW
- TE(OleGraphic, Inside, NONE) // Netscape 4
+ { HtmlOut::OleGraphic, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::OleGraphic, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::OleGraphic, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// marquee (can always exported as marquee, because
// the content shows up at the right spot
- TE(Marquee, Inside, NONE), // HTML 3.2
- TE(Marquee, Inside, NONE), // IE 4
- TE(Marquee, Inside, NONE), // SW
- TE(Marquee, Inside, NONE) // Netscape 4
+ { HtmlOut::Marquee, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Marquee, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Marquee, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// controls
- TE(Control, Inside, NONE), // HTML 3.2
- TE(Control, Inside, NONE), // IE 4
- TE(Control, Inside, NONE), // SW
- TE(Control, Inside, NONE) // Netscape 4
+ { HtmlOut::Control, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::Control, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::Control, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// other character objects
- TE(GraphicFrame, Inside, NONE), // HTML 3.2
- TE(GraphicFrame, Inside, NONE), // IE 4
- TE(GraphicFrame, Inside, NONE), // SW
- TE(GraphicFrame, Inside, NONE) // Netscape 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
+ { HtmlOut::GraphicFrame, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
}
};
+AllHtmlFlags getHTMLOutFrameAsCharTable(SwHTMLFrameType eFrameType, sal_uInt16 nExportMode)
+{
+ static_assert(std::size(aHTMLOutFrameAsCharTable) == MAX_FRMTYPES);
+ assert(eFrameType < HTML_FRMTYPE_END);
+ assert(nExportMode <= HTML_CFG_MAX);
+
+ return aHTMLOutFrameAsCharTable[eFrameType][nExportMode];
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx
index e6cf6316474f..ea421f3cbc72 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -40,6 +40,9 @@
#include <editeng/ulspitem.hxx>
#include <editeng/brushitem.hxx>
#include <sal/log.hxx>
+#include <osl/diagnose.h>
+#include <svx/svdograf.hxx>
+#include <comphelper/xmlencode.hxx>
#include <fmtanchr.hxx>
#include <fmtornt.hxx>
@@ -127,18 +130,18 @@ const HtmlFrmOpts HTML_FRMOPTS_CNTNR =
HtmlFrmOpts::AbsSize |
HtmlFrmOpts::SPixSize;
-static Writer& OutHTML_FrameFormatTableNode( Writer& rWrt, const SwFrameFormat& rFrameFormat );
-static Writer& OutHTML_FrameFormatAsMulticol( Writer& rWrt, const SwFrameFormat& rFormat,
+static SwHTMLWriter& OutHTML_FrameFormatTableNode( SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat );
+static SwHTMLWriter& OutHTML_FrameFormatAsMulticol( SwHTMLWriter& rWrt, const SwFrameFormat& rFormat,
bool bInCntnr );
-static Writer& OutHTML_FrameFormatAsSpacer( Writer& rWrt, const SwFrameFormat& rFormat );
-static Writer& OutHTML_FrameFormatAsDivOrSpan( Writer& rWrt,
+static SwHTMLWriter& OutHTML_FrameFormatAsSpacer( SwHTMLWriter& rWrt, const SwFrameFormat& rFormat );
+static SwHTMLWriter& OutHTML_FrameFormatAsDivOrSpan( SwHTMLWriter& rWrt,
const SwFrameFormat& rFrameFormat, bool bSpan );
-static Writer& OutHTML_FrameFormatAsImage( Writer& rWrt, const SwFrameFormat& rFormat );
+static SwHTMLWriter& OutHTML_FrameFormatAsImage( SwHTMLWriter& rWrt, const SwFrameFormat& rFormat, bool bPNGFallback );
-static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rFormat,
- bool bInCntnr );
+static SwHTMLWriter& OutHTML_FrameFormatGrfNode( SwHTMLWriter& rWrt, const SwFrameFormat& rFormat,
+ bool bInCntnr, bool bPNGFallback );
-static Writer& OutHTML_FrameFormatAsMarquee( Writer& rWrt, const SwFrameFormat& rFrameFormat,
+static SwHTMLWriter& OutHTML_FrameFormatAsMarquee( SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat,
const SdrObject& rSdrObj );
HTMLOutEvent const aImageEventTable[] =
@@ -156,7 +159,7 @@ HTMLOutEvent const aIMapEventTable[] =
{ nullptr, nullptr, SvMacroItemId::NONE }
};
-sal_uInt16 SwHTMLWriter::GuessFrameType( const SwFrameFormat& rFrameFormat,
+SwHTMLFrameType SwHTMLWriter::GuessFrameType( const SwFrameFormat& rFrameFormat,
const SdrObject*& rpSdrObj )
{
SwHTMLFrameType eType;
@@ -192,7 +195,7 @@ sal_uInt16 SwHTMLWriter::GuessFrameType( const SwFrameFormat& rFrameFormat,
eType = HTML_FRMTYPE_TEXT;
const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
- sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
+ SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
const SwNode* pNd = m_pDoc->GetNodes()[ nStt ];
if( pNd->IsGrfNode() )
@@ -203,17 +206,15 @@ sal_uInt16 SwHTMLWriter::GuessFrameType( const SwFrameFormat& rFrameFormat,
else if( pNd->IsOLENode() )
{
// applet, plugin, floating frame
- eType = static_cast<SwHTMLFrameType>(GuessOLENodeFrameType( *pNd ));
+ eType = GuessOLENodeFrameType( *pNd );
}
else
{
- sal_uLong nEnd = m_pDoc->GetNodes()[nStt-1]->EndOfSectionIndex();
+ SwNodeOffset nEnd = m_pDoc->GetNodes()[nStt-1]->EndOfSectionIndex();
- const SfxPoolItem* pItem;
const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
- if( SfxItemState::SET == rItemSet.GetItemState( RES_COL,
- true, &pItem ) &&
- static_cast<const SwFormatCol *>(pItem)->GetNumCols() > 1 )
+ const SwFormatCol* pFormatCol = rItemSet.GetItemIfSet( RES_COL );
+ if( pFormatCol && pFormatCol->GetNumCols() > 1 )
{
// frame with columns
eType = HTML_FRMTYPE_MULTICOL;
@@ -221,7 +222,7 @@ sal_uInt16 SwHTMLWriter::GuessFrameType( const SwFrameFormat& rFrameFormat,
else if( pNd->IsTableNode() )
{
const SwTableNode *pTableNd = pNd->GetTableNode();
- sal_uLong nTableEnd = pTableNd->EndOfSectionIndex();
+ SwNodeOffset nTableEnd = pTableNd->EndOfSectionIndex();
if( nTableEnd+1 == nEnd )
{
@@ -244,15 +245,12 @@ sal_uInt16 SwHTMLWriter::GuessFrameType( const SwFrameFormat& rFrameFormat,
// empty frame? Only if no frame is
// anchored to the text or start node.
bEmpty = true;
- if( m_pHTMLPosFlyFrames )
+ for( auto & pHTMLPosFlyFrame : m_aHTMLPosFlyFrames )
{
- for( auto & pHTMLPosFlyFrame : *m_pHTMLPosFlyFrames )
- {
- sal_uLong nIdx = pHTMLPosFlyFrame->GetNdIndex().GetIndex();
- bEmpty = (nIdx != nStt) && (nIdx != nStt-1);
- if( !bEmpty || nIdx > nStt )
- break;
- }
+ SwNodeOffset nIdx = pHTMLPosFlyFrame->GetNdIndex().GetIndex();
+ bEmpty = (nIdx != nStt) && (nIdx != nStt-1);
+ if( !bEmpty || nIdx > nStt )
+ break;
}
}
if( bEmpty )
@@ -260,9 +258,8 @@ sal_uInt16 SwHTMLWriter::GuessFrameType( const SwFrameFormat& rFrameFormat,
std::unique_ptr<SvxBrushItem> aBrush = rFrameFormat.makeBackgroundBrushItem();
/// background is not empty, if it has a background graphic
/// or its background color is not "no fill"/"auto fill".
- if( aBrush &&
- (GPOS_NONE != aBrush->GetGraphicPos() ||
- aBrush->GetColor() != COL_TRANSPARENT ))
+ if( GPOS_NONE != aBrush->GetGraphicPos() ||
+ aBrush->GetColor() != COL_TRANSPARENT )
{
bEmpty = false;
}
@@ -286,24 +283,21 @@ sal_uInt16 SwHTMLWriter::GuessFrameType( const SwFrameFormat& rFrameFormat,
}
}
- return static_cast< sal_uInt16 >(eType);
+ return eType;
}
void SwHTMLWriter::CollectFlyFrames()
{
- OSL_ENSURE( HTML_CFG_MAX+1 == MAX_BROWSERS,
- "number of browser configurations has changed" );
-
SwPosFlyFrames aFlyPos(
m_pDoc->GetAllFlyFormats(m_bWriteAll ? nullptr : m_pCurrentPam.get(), true));
- for(const auto& rpItem : aFlyPos)
+ for(const SwPosFlyFrame& rItem : aFlyPos)
{
- const SwFrameFormat& rFrameFormat = rpItem->GetFormat();
+ const SwFrameFormat& rFrameFormat = rItem.GetFormat();
const SdrObject *pSdrObj = nullptr;
- const SwPosition *pAPos;
+ const SwNode *pAnchorNode;
const SwContentNode *pACNd;
- SwHTMLFrameType eType = static_cast<SwHTMLFrameType>(GuessFrameType( rFrameFormat, pSdrObj ));
+ SwHTMLFrameType eType = GuessFrameType( rFrameFormat, pSdrObj );
AllHtmlFlags nMode;
const SwFormatAnchor& rAnchor = rFrameFormat.GetAnchor();
@@ -312,7 +306,7 @@ void SwHTMLWriter::CollectFlyFrames()
{
case RndStdIds::FLY_AT_PAGE:
case RndStdIds::FLY_AT_FLY:
- nMode = aHTMLOutFramePageFlyTable[eType][m_nExportMode];
+ nMode = getHTMLOutFramePageFlyTable(eType, m_nExportMode);
break;
case RndStdIds::FLY_AT_PARA:
@@ -320,61 +314,59 @@ void SwHTMLWriter::CollectFlyFrames()
// before the paragraph, if the paragraph has a
// spacing.
if( text::RelOrientation::FRAME == eHoriRel &&
- (pAPos = rAnchor.GetContentAnchor()) != nullptr &&
- (pACNd = pAPos->nNode.GetNode().GetContentNode()) != nullptr )
+ (pAnchorNode = rAnchor.GetAnchorNode()) != nullptr &&
+ (pACNd = pAnchorNode->GetContentNode()) != nullptr )
{
- const SvxLRSpaceItem& rLRItem =
- static_cast<const SvxLRSpaceItem&>(pACNd->GetAttr(RES_LR_SPACE));
- if( rLRItem.GetTextLeft() || rLRItem.GetRight() )
+ const SvxTextLeftMarginItem& rTextLeftMargin =
+ pACNd->GetAttr(RES_MARGIN_TEXTLEFT);
+ const SvxRightMarginItem& rRightMargin =
+ pACNd->GetAttr(RES_MARGIN_RIGHT);
+ if (rTextLeftMargin.GetTextLeft() || rRightMargin.GetRight())
{
- nMode = aHTMLOutFrameParaFrameTable[eType][m_nExportMode];
+ nMode = getHTMLOutFrameParaFrameTable(eType, m_nExportMode);
break;
}
}
- nMode = aHTMLOutFrameParaPrtAreaTable[eType][m_nExportMode];
+ nMode = getHTMLOutFrameParaPrtAreaTable(eType, m_nExportMode);
break;
case RndStdIds::FLY_AT_CHAR:
if( text::RelOrientation::FRAME == eHoriRel || text::RelOrientation::PRINT_AREA == eHoriRel )
- nMode = aHTMLOutFrameParaPrtAreaTable[eType][m_nExportMode];
+ nMode = getHTMLOutFrameParaPrtAreaTable(eType, m_nExportMode);
else
- nMode = aHTMLOutFrameParaOtherTable[eType][m_nExportMode];
+ nMode = getHTMLOutFrameParaOtherTable(eType, m_nExportMode);
break;
default:
- nMode = aHTMLOutFrameParaPrtAreaTable[eType][m_nExportMode];
+ nMode = getHTMLOutFrameParaPrtAreaTable(eType, m_nExportMode);
break;
}
- if( !m_pHTMLPosFlyFrames )
- m_pHTMLPosFlyFrames.reset(new SwHTMLPosFlyFrames);
-
- m_pHTMLPosFlyFrames->insert( std::make_unique<SwHTMLPosFlyFrame>(*rpItem, pSdrObj, nMode) );
+ m_aHTMLPosFlyFrames.insert( std::make_unique<SwHTMLPosFlyFrame>(rItem, pSdrObj, nMode) );
}
}
-bool SwHTMLWriter::OutFlyFrame( sal_uLong nNdIdx, sal_Int32 nContentIdx, HtmlPosition nPos,
- HTMLOutContext *pContext )
+bool SwHTMLWriter::OutFlyFrame( SwNodeOffset nNdIdx, sal_Int32 nContentIdx, HtmlPosition nPos )
{
bool bFlysLeft = false; // Are there still Flys left at the current node position?
// OutFlyFrame can be called recursively. Thus, sometimes it is
// necessary to start over after a Fly was returned.
bool bRestart = true;
- while( m_pHTMLPosFlyFrames && bRestart )
+ while( !m_aHTMLPosFlyFrames.empty() && bRestart )
{
bFlysLeft = bRestart = false;
// search for the beginning of the FlyFrames
size_t i {0};
- for( ; i < m_pHTMLPosFlyFrames->size() &&
- (*m_pHTMLPosFlyFrames)[i]->GetNdIndex().GetIndex() < nNdIdx; i++ )
+ for( ; i < m_aHTMLPosFlyFrames.size() &&
+ m_aHTMLPosFlyFrames[i]->GetNdIndex().GetIndex() < nNdIdx; i++ )
;
- for( ; !bRestart && i < m_pHTMLPosFlyFrames->size() &&
- (*m_pHTMLPosFlyFrames)[i]->GetNdIndex().GetIndex() == nNdIdx; i++ )
+ for( ; !bRestart && i < m_aHTMLPosFlyFrames.size() &&
+ m_aHTMLPosFlyFrames[i]->GetNdIndex().GetIndex() == nNdIdx; i++ )
{
- SwHTMLPosFlyFrame *pPosFly = (*m_pHTMLPosFlyFrames)[i].get();
+ SwHTMLPosFlyFrame *pPosFly = m_aHTMLPosFlyFrames[i].get();
if( ( HtmlPosition::Any == nPos ||
pPosFly->GetOutPos() == nPos ) &&
pPosFly->GetContentIndex() == nContentIdx )
@@ -382,19 +374,14 @@ bool SwHTMLWriter::OutFlyFrame( sal_uLong nNdIdx, sal_Int32 nContentIdx, HtmlPos
// It is important to remove it first, because additional
// elements or the whole array could be deleted on
// deeper recursion levels.
- std::unique_ptr<SwHTMLPosFlyFrame> flyHolder = m_pHTMLPosFlyFrames->erase_extract(i);
+ std::unique_ptr<SwHTMLPosFlyFrame> flyHolder = m_aHTMLPosFlyFrames.erase_extract(i);
i--;
- if( m_pHTMLPosFlyFrames->empty() )
+ if( m_aHTMLPosFlyFrames.empty() )
{
- m_pHTMLPosFlyFrames.reset();
bRestart = true; // not really, only exit the loop
}
- if( pContext )
- {
- HTMLOutFuncs::FlushToAscii(Strm(), *pContext );
- pContext = nullptr; // one time only
- }
+ HTMLOutFuncs::FlushToAscii(Strm()); // it was one time only; do we still need it?
OutFrameFormat( pPosFly->GetOutMode(), pPosFly->GetFormat(),
pPosFly->GetSdrObject() );
@@ -428,17 +415,18 @@ void SwHTMLWriter::OutFrameFormat( AllHtmlFlags nMode, const SwFrameFormat& rFra
if( HtmlContainerFlags::NONE != nCntnrMode )
{
- if( m_bLFPossible && HtmlContainerFlags::Div == nCntnrMode )
+ if (IsLFPossible() && HtmlContainerFlags::Div == nCntnrMode)
OutNewLine();
OStringBuffer sOut;
aContainerStr = (HtmlContainerFlags::Div == nCntnrMode)
? OOO_STRING_SVTOOLS_HTML_division
: OOO_STRING_SVTOOLS_HTML_span;
- sOut.append('<').append(GetNamespace() + aContainerStr).append(' ')
- .append(OOO_STRING_SVTOOLS_HTML_O_class).append("=\"")
- .append("sd-abs-pos").append('\"');
- Strm().WriteOString( sOut.makeStringAndClear() );
+ sOut.append("<" + GetNamespace() + aContainerStr + " "
+ OOO_STRING_SVTOOLS_HTML_O_class "=\""
+ "sd-abs-pos\"");
+ Strm().WriteOString( sOut );
+ sOut.setLength(0);
// Output a width for non-draw objects
HtmlFrmOpts nFrameFlags = HTML_FRMOPTS_CNTNR;
@@ -455,7 +443,7 @@ void SwHTMLWriter::OutFrameFormat( AllHtmlFlags nMode, const SwFrameFormat& rFra
if( HtmlContainerFlags::Div == nCntnrMode )
{
IncIndentLevel();
- m_bLFPossible = true;
+ SetLFPossible(true);
}
}
@@ -466,7 +454,7 @@ void SwHTMLWriter::OutFrameFormat( AllHtmlFlags nMode, const SwFrameFormat& rFra
OutHTML_FrameFormatTableNode( *this, rFrameFormat );
break;
case HtmlOut::GraphicNode: // OK
- OutHTML_FrameFormatGrfNode( *this, rFrameFormat, !aContainerStr.isEmpty() );
+ OutHTML_FrameFormatGrfNode( *this, rFrameFormat, !aContainerStr.isEmpty(), /*bPNGFallback=*/true );
break;
case HtmlOut::OleNode: // OK
OutHTML_FrameFormatOLENode( *this, rFrameFormat, !aContainerStr.isEmpty() );
@@ -500,29 +488,28 @@ void SwHTMLWriter::OutFrameFormat( AllHtmlFlags nMode, const SwFrameFormat& rFra
static_cast<const SwDrawFrameFormat &>(rFrameFormat), *pSdrObject );
break;
case HtmlOut::GraphicFrame:
- OutHTML_FrameFormatAsImage( *this, rFrameFormat );
+ OutHTML_FrameFormatAsImage( *this, rFrameFormat, /*bPNGFallback=*/true );
break;
}
if( HtmlContainerFlags::Div == nCntnrMode )
{
DecIndentLevel();
- if( m_bLFPossible )
+ if (IsLFPossible())
OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_division, false );
- m_bLFPossible = true;
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_division), false );
+ SetLFPossible(true);
}
else if( HtmlContainerFlags::Span == nCntnrMode )
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_span, false );
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false );
}
OString SwHTMLWriter::OutFrameFormatOptions( const SwFrameFormat &rFrameFormat,
- const OUString& rAlternateText,
+ std::u16string_view rAlternateText,
HtmlFrmOpts nFrameOpts )
{
OString sRetEndTags;
OStringBuffer sOut;
- const SfxPoolItem* pItem;
const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
// Name
@@ -531,10 +518,10 @@ OString SwHTMLWriter::OutFrameFormatOptions( const SwFrameFormat &rFrameFormat,
{
const char *pStr =
(nFrameOpts & HtmlFrmOpts::Id) ? OOO_STRING_SVTOOLS_HTML_O_id : OOO_STRING_SVTOOLS_HTML_O_name;
- sOut.append(' ').append(pStr).
- append("=\"");
- Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( Strm(), rFrameFormat.GetName(), m_eDestEnc, &m_aNonConvertableCharacters );
+ sOut.append(OString::Concat(" ") + pStr + "=\"");
+ Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( Strm(), rFrameFormat.GetName() );
sOut.append('\"');
}
@@ -542,17 +529,18 @@ OString SwHTMLWriter::OutFrameFormatOptions( const SwFrameFormat &rFrameFormat,
if( nFrameOpts & HtmlFrmOpts::Dir )
{
SvxFrameDirection nDir = GetHTMLDirection( rItemSet );
- Strm().WriteOString( sOut.makeStringAndClear() );
+ Strm().WriteOString( sOut );
+ sOut.setLength(0);
OutDirection( nDir );
}
// ALT
- if( (nFrameOpts & HtmlFrmOpts::Alt) && !rAlternateText.isEmpty() )
+ if( (nFrameOpts & HtmlFrmOpts::Alt) && !rAlternateText.empty() )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_alt).
- append("=\"");
- Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( Strm(), rAlternateText, m_eDestEnc, &m_aNonConvertableCharacters );
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_alt "=\"");
+ Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( Strm(), rAlternateText );
sOut.append('\"');
}
@@ -575,12 +563,13 @@ OString SwHTMLWriter::OutFrameFormatOptions( const SwFrameFormat &rFrameFormat,
: OOO_STRING_SVTOOLS_HTML_AL_left;
}
}
+ const SwFormatVertOrient* pVertOrient;
if( (nFrameOpts & HtmlFrmOpts::Align) && !pStr &&
( !(nFrameOpts & HtmlFrmOpts::SAlign) ||
(RndStdIds::FLY_AS_CHAR == eAnchorId) ) &&
- SfxItemState::SET == rItemSet.GetItemState( RES_VERT_ORIENT, true, &pItem ))
+ (pVertOrient = rItemSet.GetItemIfSet( RES_VERT_ORIENT )) )
{
- switch( static_cast<const SwFormatVertOrient*>(pItem)->GetVertOrient() )
+ switch( pVertOrient->GetVertOrient() )
{
case text::VertOrientation::LINE_TOP: pStr = OOO_STRING_SVTOOLS_HTML_VA_top; break;
case text::VertOrientation::CHAR_TOP:
@@ -596,51 +585,45 @@ OString SwHTMLWriter::OutFrameFormatOptions( const SwFrameFormat &rFrameFormat,
}
if( pStr )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_align).append("=\"").
- append(pStr).append("\"");
+ sOut.append(OString::Concat(" " OOO_STRING_SVTOOLS_HTML_O_align "=\"") +
+ pStr + "\"");
}
// HSPACE and VSPACE
Size aTwipSpc( 0, 0 );
+ const SvxLRSpaceItem* pLRSpaceItem;
if( (nFrameOpts & (HtmlFrmOpts::Space|HtmlFrmOpts::MarginSize)) &&
- SfxItemState::SET == rItemSet.GetItemState( RES_LR_SPACE, true, &pItem ))
+ (pLRSpaceItem = rItemSet.GetItemIfSet( RES_LR_SPACE )) )
{
aTwipSpc.setWidth(
- ( static_cast<const SvxLRSpaceItem*>(pItem)->GetLeft() +
- static_cast<const SvxLRSpaceItem*>(pItem)->GetRight() ) / 2 );
+ ( pLRSpaceItem->GetLeft() + pLRSpaceItem->GetRight() ) / 2 );
m_nDfltLeftMargin = m_nDfltRightMargin = aTwipSpc.Width();
}
+ const SvxULSpaceItem* pULSpaceItem;
if( (nFrameOpts & (HtmlFrmOpts::Space|HtmlFrmOpts::MarginSize)) &&
- SfxItemState::SET == rItemSet.GetItemState( RES_UL_SPACE, true, &pItem ))
+ (pULSpaceItem = rItemSet.GetItemIfSet( RES_UL_SPACE )) )
{
aTwipSpc.setHeight(
- ( static_cast<const SvxULSpaceItem*>(pItem)->GetUpper() +
- static_cast<const SvxULSpaceItem*>(pItem)->GetLower() ) / 2 );
- m_nDfltTopMargin = m_nDfltBottomMargin = static_cast<sal_uInt16>(aTwipSpc.Height());
+ ( pULSpaceItem->GetUpper() + pULSpaceItem->GetLower() ) / 2 );
+ m_nDfltTopMargin = m_nDfltBottomMargin = o3tl::narrowing<sal_uInt16>(aTwipSpc.Height());
}
if( (nFrameOpts & HtmlFrmOpts::Space) &&
(aTwipSpc.Width() || aTwipSpc.Height()) &&
- Application::GetDefaultDevice() )
+ !mbReqIF )
{
- Size aPixelSpc =
- Application::GetDefaultDevice()->LogicToPixel( aTwipSpc,
- MapMode(MapUnit::MapTwip) );
- if( !aPixelSpc.Width() && aTwipSpc.Width() )
- aPixelSpc.setWidth( 1 );
- if( !aPixelSpc.Height() && aTwipSpc.Height() )
- aPixelSpc.setHeight( 1 );
+ Size aPixelSpc = SwHTMLWriter::ToPixel(aTwipSpc);
if( aPixelSpc.Width() )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_hspace).
- append("=\"").append(static_cast<sal_Int32>(aPixelSpc.Width())).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_hspace
+ "=\"" + OString::number(aPixelSpc.Width()) + "\"");
}
if( aPixelSpc.Height() )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_vspace).
- append("=\"").append(static_cast<sal_Int32>(aPixelSpc.Height())).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_vspace
+ "=\"" + OString::number(aPixelSpc.Height()) + "\"");
}
}
@@ -657,11 +640,10 @@ OString SwHTMLWriter::OutFrameFormatOptions( const SwFrameFormat &rFrameFormat,
aTwipSpc.setHeight( 0 );
}
+ const SvxBoxItem* pBoxItem;
if( !(nFrameOpts & HtmlFrmOpts::AbsSize) &&
- SfxItemState::SET == rItemSet.GetItemState( RES_BOX, true, &pItem ))
+ (pBoxItem = rItemSet.GetItemIfSet( RES_BOX )) )
{
- const SvxBoxItem* pBoxItem = static_cast<const SvxBoxItem*>(pItem);
-
aTwipSpc.AdjustWidth(pBoxItem->CalcLineSpace( SvxBoxItemLine::LEFT ) );
aTwipSpc.AdjustWidth(pBoxItem->CalcLineSpace( SvxBoxItemLine::RIGHT ) );
aTwipSpc.AdjustHeight(pBoxItem->CalcLineSpace( SvxBoxItemLine::TOP ) );
@@ -670,12 +652,12 @@ OString SwHTMLWriter::OutFrameFormatOptions( const SwFrameFormat &rFrameFormat,
// WIDTH and/or HEIGHT
// Output SwFrameSize::Variable/SwFrameSize::Minimum only, if ANYSIZE is set
+ const SwFormatFrameSize *pFSItem;
if( (nFrameOpts & HtmlFrmOpts::Size) &&
- SfxItemState::SET == rItemSet.GetItemState( RES_FRM_SIZE, true, &pItem ) &&
+ (pFSItem = rItemSet.GetItemIfSet( RES_FRM_SIZE )) &&
( (nFrameOpts & HtmlFrmOpts::AnySize) ||
- SwFrameSize::Fixed == static_cast<const SwFormatFrameSize *>(pItem)->GetHeightSizeType()) )
+ SwFrameSize::Fixed == pFSItem->GetHeightSizeType()) )
{
- const SwFormatFrameSize *pFSItem = static_cast<const SwFormatFrameSize *>(pItem);
sal_uInt8 nPercentWidth = pFSItem->GetWidthPercent();
sal_uInt8 nPercentHeight = pFSItem->GetHeightPercent();
@@ -685,32 +667,20 @@ OString SwHTMLWriter::OutFrameFormatOptions( const SwFrameFormat &rFrameFormat,
(nPercentHeight ? 0
: pFSItem->GetHeight()-aTwipSpc.Height()) );
- OSL_ENSURE( !aTwipSz.IsEmpty(), "Frame size minus spacing < 0!!!???" );
+ OSL_ENSURE( aTwipSz.Width() >= 0 && aTwipSz.Height() >= 0, "Frame size minus spacing < 0!!!???" );
if( aTwipSz.Width() < 0 )
aTwipSz.setWidth( 0 );
if( aTwipSz.Height() < 0 )
aTwipSz.setHeight( 0 );
- Size aPixelSz( 0, 0 );
- if( (aTwipSz.Width() || aTwipSz.Height()) &&
- Application::GetDefaultDevice() )
- {
- aPixelSz =
- Application::GetDefaultDevice()->LogicToPixel( aTwipSz,
- MapMode(MapUnit::MapTwip) );
- if( !aPixelSz.Width() && aTwipSz.Width() )
- aPixelSz.setWidth( 1 );
- if( !aPixelSz.Height() && aTwipSz.Height() )
- aPixelSz.setHeight( 1 );
- }
+ Size aPixelSz(SwHTMLWriter::ToPixel(aTwipSz));
if( (nFrameOpts & HtmlFrmOpts::Width) &&
((nPercentWidth && nPercentWidth!=255) || aPixelSz.Width()) )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_width).
- append("=\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_width "=\"");
if( nPercentWidth )
- sOut.append(static_cast<sal_Int32>(nPercentWidth)).append('%');
+ sOut.append(OString::number(static_cast<sal_Int32>(nPercentWidth)) + "%");
else
sOut.append(static_cast<sal_Int32>(aPixelSz.Width()));
sOut.append("\"");
@@ -719,10 +689,9 @@ OString SwHTMLWriter::OutFrameFormatOptions( const SwFrameFormat &rFrameFormat,
if( (nFrameOpts & HtmlFrmOpts::Height) &&
((nPercentHeight && nPercentHeight!=255) || aPixelSz.Height()) )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_height).
- append("=\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_height "=\"");
if( nPercentHeight )
- sOut.append(static_cast<sal_Int32>(nPercentHeight)).append('%');
+ sOut.append(OString::number(static_cast<sal_Int32>(nPercentHeight)) + "%");
else
sOut.append(static_cast<sal_Int32>(aPixelSz.Height()));
sOut.append("\"");
@@ -730,79 +699,84 @@ OString SwHTMLWriter::OutFrameFormatOptions( const SwFrameFormat &rFrameFormat,
}
if (!sOut.isEmpty())
- Strm().WriteOString( sOut.makeStringAndClear() );
+ {
+ Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ }
- // Insert wrap for graphics that are anchored to a paragraph as
- // <BR CLEAR=...> in the string
- if( (nFrameOpts & HtmlFrmOpts::BrClear) &&
- ((RndStdIds::FLY_AT_PARA == rFrameFormat.GetAnchor().GetAnchorId()) ||
- (RndStdIds::FLY_AT_CHAR == rFrameFormat.GetAnchor().GetAnchorId())) &&
- SfxItemState::SET == rItemSet.GetItemState( RES_SURROUND, true, &pItem ))
- {
- const SwFormatSurround* pSurround = static_cast<const SwFormatSurround*>(pItem);
- sal_Int16 eHoriOri = rFrameFormat.GetHoriOrient().GetHoriOrient();
- pStr = nullptr;
- css::text::WrapTextMode eSurround = pSurround->GetSurround();
- bool bAnchorOnly = pSurround->IsAnchorOnly();
- switch( eHoriOri )
+ if (!mbReqIF)
+ {
+ // Insert wrap for graphics that are anchored to a paragraph as
+ // <BR CLEAR=...> in the string
+ const SwFormatSurround* pSurround;
+ if( (nFrameOpts & HtmlFrmOpts::BrClear) &&
+ ((RndStdIds::FLY_AT_PARA == rFrameFormat.GetAnchor().GetAnchorId()) ||
+ (RndStdIds::FLY_AT_CHAR == rFrameFormat.GetAnchor().GetAnchorId())) &&
+ (pSurround = rItemSet.GetItemIfSet( RES_SURROUND )) )
{
- case text::HoriOrientation::RIGHT:
+ sal_Int16 eHoriOri = rFrameFormat.GetHoriOrient().GetHoriOrient();
+ pStr = nullptr;
+ css::text::WrapTextMode eSurround = pSurround->GetSurround();
+ bool bAnchorOnly = pSurround->IsAnchorOnly();
+ switch( eHoriOri )
{
- switch( eSurround )
+ case text::HoriOrientation::RIGHT:
{
- case css::text::WrapTextMode_NONE:
- case css::text::WrapTextMode_RIGHT:
- pStr = OOO_STRING_SVTOOLS_HTML_AL_right;
- break;
- case css::text::WrapTextMode_LEFT:
- case css::text::WrapTextMode_PARALLEL:
- if( bAnchorOnly )
- m_bClearRight = true;
- break;
- default:
- ;
+ switch( eSurround )
+ {
+ case css::text::WrapTextMode_NONE:
+ case css::text::WrapTextMode_RIGHT:
+ pStr = OOO_STRING_SVTOOLS_HTML_AL_right;
+ break;
+ case css::text::WrapTextMode_LEFT:
+ case css::text::WrapTextMode_PARALLEL:
+ if( bAnchorOnly )
+ m_bClearRight = true;
+ break;
+ default:
+ ;
+ }
}
- }
- break;
+ break;
- default:
- // If a frame is centered, it gets left aligned. This
- // should be taken into account here, too.
- {
- switch( eSurround )
+ default:
+ // If a frame is centered, it gets left aligned. This
+ // should be taken into account here, too.
{
- case css::text::WrapTextMode_NONE:
- case css::text::WrapTextMode_LEFT:
- pStr = OOO_STRING_SVTOOLS_HTML_AL_left;
- break;
- case css::text::WrapTextMode_RIGHT:
- case css::text::WrapTextMode_PARALLEL:
- if( bAnchorOnly )
- m_bClearLeft = true;
- break;
- default:
- ;
+ switch( eSurround )
+ {
+ case css::text::WrapTextMode_NONE:
+ case css::text::WrapTextMode_LEFT:
+ pStr = OOO_STRING_SVTOOLS_HTML_AL_left;
+ break;
+ case css::text::WrapTextMode_RIGHT:
+ case css::text::WrapTextMode_PARALLEL:
+ if( bAnchorOnly )
+ m_bClearLeft = true;
+ break;
+ default:
+ ;
+ }
}
- }
- break;
+ break;
- }
+ }
- if( pStr )
- {
- sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_linebreak).
- append(' ').append(OOO_STRING_SVTOOLS_HTML_O_clear).
- append("=\"").append(pStr).append("\">");
- sRetEndTags = sOut.makeStringAndClear();
+ if( pStr )
+ {
+ sOut.append("<" OOO_STRING_SVTOOLS_HTML_linebreak
+ " " OOO_STRING_SVTOOLS_HTML_O_clear
+ "=\"" + OString::Concat(pStr) + "\">");
+ sRetEndTags = sOut.makeStringAndClear();
+ }
}
}
return sRetEndTags;
}
-void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameFormat& rFrameFormat, std::u16string_view rAlternateText, HtmlFrmOpts nFrameOptions)
+void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameFormat& rFrameFormat, const OUString& rAlternateText, HtmlFrmOpts nFrameOptions)
{
bool bReplacement = (nFrameOptions & HtmlFrmOpts::Replacement) || mbReqIF;
- const SfxPoolItem* pItem;
const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
// Name
@@ -822,13 +796,13 @@ void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameForma
}
// alt
- if( (nFrameOptions & HtmlFrmOpts::Alt) && !rAlternateText.empty() && !bReplacement )
+ if( (nFrameOptions & HtmlFrmOpts::Alt) && !rAlternateText.isEmpty() && !bReplacement )
{
aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_alt, rAlternateText);
}
// align
- const char* pAlignString = nullptr;
+ std::string_view pAlignString;
RndStdIds eAnchorId = rFrameFormat.GetAnchor().GetAnchorId();
if( (nFrameOptions & HtmlFrmOpts::Align) &&
((RndStdIds::FLY_AT_PARA == eAnchorId) || (RndStdIds::FLY_AT_CHAR == eAnchorId)) && !bReplacement)
@@ -839,16 +813,17 @@ void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameForma
text::RelOrientation::PRINT_AREA == rHoriOri.GetRelationOrient() )
{
pAlignString = text::HoriOrientation::RIGHT == rHoriOri.GetHoriOrient()
- ? OOO_STRING_SVTOOLS_HTML_AL_right
- : OOO_STRING_SVTOOLS_HTML_AL_left;
+ ? std::string_view(OOO_STRING_SVTOOLS_HTML_AL_right)
+ : std::string_view(OOO_STRING_SVTOOLS_HTML_AL_left);
}
}
- if( (nFrameOptions & HtmlFrmOpts::Align) && !pAlignString &&
+ const SwFormatVertOrient* pVertOrient;
+ if( (nFrameOptions & HtmlFrmOpts::Align) && pAlignString.empty() &&
( !(nFrameOptions & HtmlFrmOpts::SAlign) ||
(RndStdIds::FLY_AS_CHAR == eAnchorId) ) &&
- SfxItemState::SET == rItemSet.GetItemState( RES_VERT_ORIENT, true, &pItem ))
+ (pVertOrient = rItemSet.GetItemIfSet( RES_VERT_ORIENT )) )
{
- switch( static_cast<const SwFormatVertOrient*>(pItem)->GetVertOrient() )
+ switch( pVertOrient->GetVertOrient() )
{
case text::VertOrientation::LINE_TOP: pAlignString = OOO_STRING_SVTOOLS_HTML_VA_top; break;
case text::VertOrientation::CHAR_TOP:
@@ -862,41 +837,35 @@ void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameForma
case text::VertOrientation::NONE: break;
}
}
- if (pAlignString && !bReplacement)
+ if (!pAlignString.empty() && !bReplacement)
{
aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_align, pAlignString);
}
// hspace and vspace
Size aTwipSpc( 0, 0 );
+ const SvxLRSpaceItem* pLRSpaceItem;
if( (nFrameOptions & (HtmlFrmOpts::Space | HtmlFrmOpts::MarginSize)) &&
- SfxItemState::SET == rItemSet.GetItemState( RES_LR_SPACE, true, &pItem ))
+ (pLRSpaceItem = rItemSet.GetItemIfSet( RES_LR_SPACE )) )
{
aTwipSpc.setWidth(
- ( static_cast<const SvxLRSpaceItem*>(pItem)->GetLeft() +
- static_cast<const SvxLRSpaceItem*>(pItem)->GetRight() ) / 2 );
+ ( pLRSpaceItem->GetLeft() + pLRSpaceItem->GetRight() ) / 2 );
m_nDfltLeftMargin = m_nDfltRightMargin = aTwipSpc.Width();
}
+ const SvxULSpaceItem* pULSpaceItem;
if( (nFrameOptions & (HtmlFrmOpts::Space|HtmlFrmOpts::MarginSize)) &&
- SfxItemState::SET == rItemSet.GetItemState( RES_UL_SPACE, true, &pItem ))
+ (pULSpaceItem = rItemSet.GetItemIfSet( RES_UL_SPACE )) )
{
aTwipSpc.setHeight(
- ( static_cast<const SvxULSpaceItem*>(pItem)->GetUpper() +
- static_cast<const SvxULSpaceItem*>(pItem)->GetLower() ) / 2 );
- m_nDfltTopMargin = m_nDfltBottomMargin = static_cast<sal_uInt16>(aTwipSpc.Height());
+ ( pULSpaceItem->GetUpper() + pULSpaceItem->GetLower() ) / 2 );
+ m_nDfltTopMargin = m_nDfltBottomMargin = o3tl::narrowing<sal_uInt16>(aTwipSpc.Height());
}
if( (nFrameOptions & HtmlFrmOpts::Space) &&
(aTwipSpc.Width() || aTwipSpc.Height()) &&
- Application::GetDefaultDevice() )
+ !mbReqIF )
{
- Size aPixelSpc =
- Application::GetDefaultDevice()->LogicToPixel( aTwipSpc,
- MapMode(MapUnit::MapTwip) );
- if( !aPixelSpc.Width() && aTwipSpc.Width() )
- aPixelSpc.setWidth( 1 );
- if( !aPixelSpc.Height() && aTwipSpc.Height() )
- aPixelSpc.setHeight( 1 );
+ Size aPixelSpc = SwHTMLWriter::ToPixel(aTwipSpc);
if (aPixelSpc.Width())
{
@@ -922,11 +891,10 @@ void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameForma
aTwipSpc.setHeight( 0 );
}
+ const SvxBoxItem* pBoxItem;
if( !(nFrameOptions & HtmlFrmOpts::AbsSize) &&
- SfxItemState::SET == rItemSet.GetItemState( RES_BOX, true, &pItem ))
+ (pBoxItem = rItemSet.GetItemIfSet( RES_BOX )) )
{
- const SvxBoxItem* pBoxItem = static_cast<const SvxBoxItem*>(pItem);
-
aTwipSpc.AdjustWidth(pBoxItem->CalcLineSpace( SvxBoxItemLine::LEFT ) );
aTwipSpc.AdjustWidth(pBoxItem->CalcLineSpace( SvxBoxItemLine::RIGHT ) );
aTwipSpc.AdjustHeight(pBoxItem->CalcLineSpace( SvxBoxItemLine::TOP ) );
@@ -935,49 +903,70 @@ void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameForma
// "width" and/or "height"
// Only output SwFrameSize::Variable/SwFrameSize::Minimum if ANYSIZE is set
+ std::optional<SwFormatFrameSize> aFrameSize;
+ const SwFormatFrameSize* pFSItem = rItemSet.GetItemIfSet( RES_FRM_SIZE );
+ const SdrObject* pObject;
+ if (!pFSItem && (pObject = rFrameFormat.FindSdrObject()))
+ {
+ // Write size for Draw shapes as well.
+ const tools::Rectangle& rSnapRect = pObject->GetSnapRect();
+ aFrameSize.emplace();
+ aFrameSize->SetWidthSizeType(SwFrameSize::Fixed);
+ aFrameSize->SetWidth(rSnapRect.getOpenWidth());
+ aFrameSize->SetHeightSizeType(SwFrameSize::Fixed);
+ aFrameSize->SetHeight(rSnapRect.getOpenHeight());
+ pFSItem = &*aFrameSize;
+ }
if( (nFrameOptions & HtmlFrmOpts::Size) &&
- SfxItemState::SET == rItemSet.GetItemState( RES_FRM_SIZE, true, &pItem ) &&
+ pFSItem &&
( (nFrameOptions & HtmlFrmOpts::AnySize) ||
- SwFrameSize::Fixed == static_cast<const SwFormatFrameSize *>(pItem)->GetHeightSizeType()) )
+ SwFrameSize::Fixed == pFSItem->GetHeightSizeType()) )
{
- const SwFormatFrameSize *pFSItem = static_cast<const SwFormatFrameSize *>(pItem);
sal_uInt8 nPercentWidth = pFSItem->GetWidthPercent();
sal_uInt8 nPercentHeight = pFSItem->GetHeightPercent();
// Size of the object in Twips without margins
- Size aTwipSz( (nPercentWidth ? 0
+ Size aTwipSz( (nPercentWidth && nPercentWidth != 255 ? 0
: pFSItem->GetWidth()-aTwipSpc.Width()),
- (nPercentHeight ? 0
+ (nPercentHeight && nPercentHeight != 255 ? 0
: pFSItem->GetHeight()-aTwipSpc.Height()) );
- OSL_ENSURE( !aTwipSz.IsEmpty(), "Frame size minus spacing < 0!!!???" );
+ OSL_ENSURE( aTwipSz.Width() >= 0 && aTwipSz.Height() >= 0, "Frame size minus spacing < 0!!!???" );
if( aTwipSz.Width() < 0 )
aTwipSz.setWidth( 0 );
if( aTwipSz.Height() < 0 )
aTwipSz.setHeight( 0 );
- Size aPixelSz( 0, 0 );
- if( (aTwipSz.Width() || aTwipSz.Height()) &&
- Application::GetDefaultDevice() )
- {
- aPixelSz =
- Application::GetDefaultDevice()->LogicToPixel( aTwipSz,
- MapMode(MapUnit::MapTwip) );
- if( !aPixelSz.Width() && aTwipSz.Width() )
- aPixelSz.setWidth( 1 );
- if( !aPixelSz.Height() && aTwipSz.Height() )
- aPixelSz.setHeight( 1 );
- }
+ Size aPixelSz(SwHTMLWriter::ToPixel(aTwipSz));
if( (nFrameOptions & HtmlFrmOpts::Width) &&
((nPercentWidth && nPercentWidth!=255) || aPixelSz.Width()) )
{
OString sWidth;
if (nPercentWidth)
- sWidth = OString::number(static_cast<sal_Int32>(nPercentWidth)) + "%";
+ {
+ if (nPercentWidth == 255)
+ {
+ if (nPercentHeight)
+ {
+ sWidth = "auto"_ostr;
+ }
+ else
+ {
+ sWidth = OString::number(static_cast<sal_Int32>(aPixelSz.Width()));
+ }
+ }
+ else
+ {
+ sWidth = OString::number(static_cast<sal_Int32>(nPercentWidth)) + "%";
+ }
+ }
else
sWidth = OString::number(static_cast<sal_Int32>(aPixelSz.Width()));
- aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_width, sWidth);
+ if (!mbXHTML || sWidth != "auto")
+ {
+ aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_width, sWidth);
+ }
}
if( (nFrameOptions & HtmlFrmOpts::Height) &&
@@ -985,25 +974,49 @@ void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameForma
{
OString sHeight;
if (nPercentHeight)
- sHeight = OString::number(static_cast<sal_Int32>(nPercentHeight)) + "%";
+ {
+ if (nPercentHeight == 255)
+ {
+ if (nPercentWidth)
+ {
+ sHeight = "auto"_ostr;
+ }
+ else
+ {
+ sHeight = OString::number(static_cast<sal_Int32>(aPixelSz.Height()));
+ }
+ }
+ else
+ {
+ sHeight = OString::number(static_cast<sal_Int32>(nPercentHeight)) + "%";
+ }
+ }
else
sHeight = OString::number(static_cast<sal_Int32>(aPixelSz.Height()));
- aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_height, sHeight);
+ if (!mbXHTML || sHeight != "auto")
+ {
+ aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_height, sHeight);
+ }
}
}
+ if (mbReqIF)
+ return;
+
// Insert wrap for graphics that are anchored to a paragraph as
// <BR CLEAR=...> in the string
- if( !((nFrameOptions & HtmlFrmOpts::BrClear) &&
- ((RndStdIds::FLY_AT_PARA == rFrameFormat.GetAnchor().GetAnchorId()) ||
- (RndStdIds::FLY_AT_CHAR == rFrameFormat.GetAnchor().GetAnchorId())) &&
- SfxItemState::SET == rItemSet.GetItemState( RES_SURROUND, true, &pItem )))
+ if( !(nFrameOptions & HtmlFrmOpts::BrClear) )
+ return;
+ RndStdIds nAnchorId = rFrameFormat.GetAnchor().GetAnchorId();
+ if (RndStdIds::FLY_AT_PARA != nAnchorId && RndStdIds::FLY_AT_CHAR != nAnchorId)
+ return;
+ const SwFormatSurround* pSurround = rItemSet.GetItemIfSet( RES_SURROUND );
+ if (!pSurround)
return;
- const char* pSurroundString = nullptr;
+ std::string_view pSurroundString;
- const SwFormatSurround* pSurround = static_cast<const SwFormatSurround*>(pItem);
sal_Int16 eHoriOri = rFrameFormat.GetHoriOrient().GetHoriOrient();
css::text::WrapTextMode eSurround = pSurround->GetSurround();
bool bAnchorOnly = pSurround->IsAnchorOnly();
@@ -1050,9 +1063,9 @@ void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameForma
break;
}
- if (pSurroundString)
+ if (!pSurroundString.empty())
{
- aHtml.start(OOO_STRING_SVTOOLS_HTML_linebreak);
+ aHtml.start(OOO_STRING_SVTOOLS_HTML_linebreak ""_ostr);
aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_clear, pSurroundString);
aHtml.end();
}
@@ -1061,18 +1074,14 @@ void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameForma
namespace
{
-OUString lclWriteOutImap(SwHTMLWriter& rHTMLWrt, const SfxItemSet& rItemSet, const SwFrameFormat& rFrameFormat,
+OUString lclWriteOutImap(SwHTMLWriter& rWrt, const SfxItemSet& rItemSet, const SwFrameFormat& rFrameFormat,
const Size& rRealSize, const ImageMap* pAltImgMap, const SwFormatURL*& pURLItem)
{
OUString aIMapName;
- const SfxPoolItem* pItem;
-
// Only consider the URL attribute if no ImageMap was supplied
- if (!pAltImgMap && SfxItemState::SET == rItemSet.GetItemState( RES_URL, true, &pItem))
- {
- pURLItem = static_cast<const SwFormatURL*>( pItem);
- }
+ if (!pAltImgMap)
+ pURLItem = rItemSet.GetItemIfSet( RES_URL );
// write ImageMap
const ImageMap* pIMap = pAltImgMap;
@@ -1092,13 +1101,13 @@ OUString lclWriteOutImap(SwHTMLWriter& rHTMLWrt, const SfxItemSet& rItemSet, con
aNameBase = OOO_STRING_SVTOOLS_HTML_map;
if (aIMapName.isEmpty())
- aIMapName = aNameBase + OUString::number(rHTMLWrt.m_nImgMapCnt);
+ aIMapName = aNameBase + OUString::number(rWrt.m_nImgMapCnt);
bool bFound;
do
{
bFound = false;
- for (const OUString & rImgMapName : rHTMLWrt.m_aImgMapNames)
+ for (const OUString & rImgMapName : rWrt.m_aImgMapNames)
{
// TODO: Unicode: Comparison is case insensitive for ASCII
// characters only now!
@@ -1110,8 +1119,8 @@ OUString lclWriteOutImap(SwHTMLWriter& rHTMLWrt, const SfxItemSet& rItemSet, con
}
if (bFound)
{
- rHTMLWrt.m_nImgMapCnt++;
- aIMapName = aNameBase + OUString::number( rHTMLWrt.m_nImgMapCnt );
+ rWrt.m_nImgMapCnt++;
+ aIMapName = aNameBase + OUString::number( rWrt.m_nImgMapCnt );
}
} while (bFound);
@@ -1155,16 +1164,16 @@ OUString lclWriteOutImap(SwHTMLWriter& rHTMLWrt, const SfxItemSet& rItemSet, con
}
}
- rHTMLWrt.m_aImgMapNames.push_back(aIMapName);
+ rWrt.m_aImgMapNames.push_back(aIMapName);
OString aIndMap, aIndArea;
const char *pIndArea = nullptr, *pIndMap = nullptr;
- if (rHTMLWrt.m_bLFPossible)
+ if (rWrt.IsLFPossible())
{
- rHTMLWrt.OutNewLine( true );
- aIndMap = rHTMLWrt.GetIndentString();
- aIndArea = rHTMLWrt.GetIndentString(1);
+ rWrt.OutNewLine( true );
+ aIndMap = rWrt.GetIndentString();
+ aIndArea = rWrt.GetIndentString(1);
pIndArea = aIndArea.getStr();
pIndMap = aIndMap.getStr();
}
@@ -1173,29 +1182,53 @@ OUString lclWriteOutImap(SwHTMLWriter& rHTMLWrt, const SfxItemSet& rItemSet, con
{
ImageMap aScaledIMap(*pIMap);
aScaledIMap.Scale(aScaleX, aScaleY);
- HTMLOutFuncs::Out_ImageMap( rHTMLWrt.Strm(), rHTMLWrt.GetBaseURL(), aScaledIMap, aIMapName,
+ HTMLOutFuncs::Out_ImageMap( rWrt.Strm(), rWrt.GetBaseURL(), aScaledIMap, aIMapName,
aIMapEventTable,
- rHTMLWrt.m_bCfgStarBasic,
- SAL_NEWLINE_STRING, pIndArea, pIndMap,
- rHTMLWrt.m_eDestEnc,
- &rHTMLWrt.m_aNonConvertableCharacters );
+ rWrt.m_bCfgStarBasic,
+ SAL_NEWLINE_STRING, pIndArea, pIndMap );
}
else
{
- HTMLOutFuncs::Out_ImageMap( rHTMLWrt.Strm(), rHTMLWrt.GetBaseURL(), *pIMap, aIMapName,
+ HTMLOutFuncs::Out_ImageMap( rWrt.Strm(), rWrt.GetBaseURL(), *pIMap, aIMapName,
aIMapEventTable,
- rHTMLWrt.m_bCfgStarBasic,
- SAL_NEWLINE_STRING, pIndArea, pIndMap,
- rHTMLWrt.m_eDestEnc,
- &rHTMLWrt.m_aNonConvertableCharacters );
+ rWrt.m_bCfgStarBasic,
+ SAL_NEWLINE_STRING, pIndArea, pIndMap );
}
}
return aIMapName;
}
+OUString getFrameFormatText(const SwFrameFormat& rFrameFormat)
+{
+ const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
+ const SwNodeIndex* pSttIx = rFlyContent.GetContentIdx();
+ if (!pSttIx)
+ return {};
+
+ const SwNodeOffset nStt = pSttIx->GetIndex();
+ const auto& nodes = rFrameFormat.GetDoc()->GetNodes();
+ const SwNodeOffset nEnd = nodes[nStt]->EndOfSectionIndex();
+
+ OUStringBuffer result;
+ for (SwNodeOffset i = nStt + 1; i < nEnd; ++i)
+ {
+ if (const auto* pTextNd = nodes[i]->GetTextNode())
+ {
+ if (!result.isEmpty())
+ result.append("\n");
+ result.append(comphelper::string::encodeForXml(pTextNd->GetExpandText(
+ nullptr, 0, -1, true, true, false,
+ ExpandMode::ExpandFields | ExpandMode::HideInvisible | ExpandMode::HideDeletions
+ | ExpandMode::HideFieldmarkCommands)));
+ }
+ }
+
+ return result.makeStringAndClear();
+}
+
}
-Writer& OutHTML_Image( Writer& rWrt, const SwFrameFormat &rFrameFormat,
+SwHTMLWriter& OutHTML_ImageStart( HtmlWriter& rHtml, SwHTMLWriter& rWrt, const SwFrameFormat &rFrameFormat,
const OUString& rGraphicURL,
Graphic const & rGraphic, const OUString& rAlternateText,
const Size &rRealSize, HtmlFrmOpts nFrameOpts,
@@ -1203,48 +1236,40 @@ Writer& OutHTML_Image( Writer& rWrt, const SwFrameFormat &rFrameFormat,
const ImageMap *pAltImgMap,
const OUString& rMimeType )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
// <object data="..."> instead of <img src="...">
- bool bReplacement = (nFrameOpts & HtmlFrmOpts::Replacement) || rHTMLWrt.mbReqIF;
+ bool bReplacement = (nFrameOpts & HtmlFrmOpts::Replacement) || rWrt.mbReqIF;
- if (rHTMLWrt.mbSkipImages)
- return rHTMLWrt;
+ if (rWrt.mbSkipImages)
+ return rWrt;
// if necessary, temporarily close an open attribute
- if( !rHTMLWrt.m_aINetFormats.empty() )
+ if( !rWrt.m_aINetFormats.empty() )
{
- SwFormatINetFormat* pINetFormat = rHTMLWrt.m_aINetFormats.back();
+ SwFormatINetFormat* pINetFormat = rWrt.m_aINetFormats.back();
OutHTML_INetFormat( rWrt, *pINetFormat, false );
}
OUString aGraphicURL( rGraphicURL );
- if( !rHTMLWrt.mbEmbedImages && !HTMLOutFuncs::PrivateURLToInternalImg(aGraphicURL) && !rHTMLWrt.mpTempBaseURL )
+ if( !rWrt.mbEmbedImages && !HTMLOutFuncs::PrivateURLToInternalImg(aGraphicURL) && !rWrt.mpTempBaseURL )
aGraphicURL = URIHelper::simpleNormalizedMakeRelative( rWrt.GetBaseURL(), aGraphicURL);
- const SfxPoolItem* pItem;
const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
const SwFormatURL* pURLItem = nullptr;
- OUString aIMapName = lclWriteOutImap(rHTMLWrt, rItemSet, rFrameFormat, rRealSize, pAltImgMap, pURLItem);
+ OUString aIMapName = lclWriteOutImap(rWrt, rItemSet, rFrameFormat, rRealSize, pAltImgMap, pURLItem);
// put img into new line
- if( rHTMLWrt.m_bLFPossible )
- rHTMLWrt.OutNewLine( true );
-
- HtmlWriter aHtml(rWrt.Strm(), rHTMLWrt.maNamespace);
+ if (rWrt.IsLFPossible())
+ rWrt.OutNewLine( true );
// <a name=...></a>...<img ...>
if( pMarkType && !rFrameFormat.GetName().isEmpty() )
{
- rHTMLWrt.OutImplicitMark( rFrameFormat.GetName(), pMarkType );
+ rWrt.OutImplicitMark( rFrameFormat.GetName(), pMarkType );
}
// URL -> <a>...<img ... >...</a>
- const SvxMacroItem *pMacItem = nullptr;
- if (SfxItemState::SET == rItemSet.GetItemState(RES_FRMMACRO, true, &pItem))
- {
- pMacItem = static_cast<const SvxMacroItem *>(pItem);
- }
+ const SvxMacroItem *pMacItem = rItemSet.GetItemIfSet(RES_FRMMACRO);
if (pURLItem || pMacItem)
{
@@ -1263,22 +1288,22 @@ Writer& OutHTML_Image( Writer& rWrt, const SwFrameFormat &rFrameFormat,
if( !aMapURL.isEmpty() || !aName.isEmpty() || !aTarget.isEmpty() || bEvents )
{
- aHtml.start(OOO_STRING_SVTOOLS_HTML_anchor);
+ rHtml.start(OOO_STRING_SVTOOLS_HTML_anchor ""_ostr);
// Output "href" element if a link or macro exists
if( !aMapURL.isEmpty() || bEvents )
{
- aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_href, OUStringToOString(rHTMLWrt.convertHyperlinkHRefValue(aMapURL), RTL_TEXTENCODING_UTF8));
+ rHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_href, rWrt.convertHyperlinkHRefValue(aMapURL));
}
if( !aName.isEmpty() )
{
- aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_name, OUStringToOString(aName, RTL_TEXTENCODING_UTF8));
+ rHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_name, aName);
}
if( !aTarget.isEmpty() )
{
- aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_target, OUStringToOString(aTarget, RTL_TEXTENCODING_UTF8));
+ rHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_target, aTarget);
}
if( pMacItem )
@@ -1286,7 +1311,7 @@ Writer& OutHTML_Image( Writer& rWrt, const SwFrameFormat &rFrameFormat,
const SvxMacroTableDtor& rMacTable = pMacItem->GetMacroTable();
if (!rMacTable.empty())
{
- HtmlWriterHelper::applyEvents(aHtml, rMacTable, aAnchorEventTable, rHTMLWrt.m_bCfgStarBasic);
+ HtmlWriterHelper::applyEvents(rHtml, rMacTable, aAnchorEventTable, rWrt.m_bCfgStarBasic);
}
}
}
@@ -1294,12 +1319,11 @@ Writer& OutHTML_Image( Writer& rWrt, const SwFrameFormat &rFrameFormat,
// <font color = ...>...<img ... >...</font>
sal_uInt16 nBorderWidth = 0;
+ const SvxBoxItem* pBoxItem;
if( (nFrameOpts & HtmlFrmOpts::Border) &&
- SfxItemState::SET == rItemSet.GetItemState( RES_BOX, true, &pItem ))
+ (pBoxItem = rItemSet.GetItemIfSet( RES_BOX )) )
{
Size aTwipBorder( 0, 0 );
- const SvxBoxItem* pBoxItem = static_cast<const SvxBoxItem*>(pItem);
-
const ::editeng::SvxBorderLine *pColBorderLine = nullptr;
const ::editeng::SvxBorderLine *pBorderLine = pBoxItem->GetLeft();
if( pBorderLine )
@@ -1335,150 +1359,152 @@ Writer& OutHTML_Image( Writer& rWrt, const SwFrameFormat &rFrameFormat,
if( (aTwipBorder.Width() || aTwipBorder.Height()) &&
Application::GetDefaultDevice() )
{
- Size aPixelBorder =
- Application::GetDefaultDevice()->LogicToPixel( aTwipBorder,
- MapMode(MapUnit::MapTwip) );
- if( !aPixelBorder.Width() && aTwipBorder.Width() )
- aPixelBorder.setWidth( 1 );
- if( !aPixelBorder.Height() && aTwipBorder.Height() )
- aPixelBorder.setHeight( 1 );
+ Size aPixelBorder = SwHTMLWriter::ToPixel(aTwipBorder);
if( aPixelBorder.Width() )
aPixelBorder.setHeight( 0 );
nBorderWidth =
- static_cast<sal_uInt16>(aPixelBorder.Width() + aPixelBorder.Height());
+ o3tl::narrowing<sal_uInt16>(aPixelBorder.Width() + aPixelBorder.Height());
}
if( pColBorderLine )
{
- aHtml.start(OOO_STRING_SVTOOLS_HTML_font);
- HtmlWriterHelper::applyColor(aHtml, OOO_STRING_SVTOOLS_HTML_O_color, pColBorderLine->GetColor());
+ rHtml.start(OOO_STRING_SVTOOLS_HTML_font ""_ostr);
+ HtmlWriterHelper::applyColor(rHtml, OOO_STRING_SVTOOLS_HTML_O_color, pColBorderLine->GetColor());
}
}
- OString aTag(OOO_STRING_SVTOOLS_HTML_image);
+ OString aTag(OOO_STRING_SVTOOLS_HTML_image ""_ostr);
if (bReplacement)
// Write replacement graphic of OLE object as <object>.
- aTag = OOO_STRING_SVTOOLS_HTML_object;
- aHtml.start(aTag);
+ aTag = OOO_STRING_SVTOOLS_HTML_object ""_ostr;
+ rHtml.start(aTag);
- OStringBuffer sBuffer;
- if(rHTMLWrt.mbEmbedImages)
+ if(rWrt.mbEmbedImages)
{
OUString aGraphicInBase64;
if (XOutBitmap::GraphicToBase64(rGraphic, aGraphicInBase64))
{
- sBuffer.append(OOO_STRING_SVTOOLS_HTML_O_data);
- sBuffer.append(":");
- sBuffer.append(OUStringToOString(aGraphicInBase64, RTL_TEXTENCODING_UTF8));
- aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_src, sBuffer.makeStringAndClear().getStr());
+ OString sBuffer(OString::Concat(OOO_STRING_SVTOOLS_HTML_O_data)
+ + ":"
+ + OUStringToOString(aGraphicInBase64, RTL_TEXTENCODING_UTF8));
+ rHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_src, sBuffer);
}
else
- rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
+ rWrt.m_nWarn = WARN_SWG_POOR_LOAD;
}
else
{
- sBuffer.append(OUStringToOString(aGraphicURL, RTL_TEXTENCODING_UTF8));
- OString aAttribute(OOO_STRING_SVTOOLS_HTML_O_src);
+ OString sBuffer(OUStringToOString(aGraphicURL, RTL_TEXTENCODING_UTF8));
+ OString aAttribute(OOO_STRING_SVTOOLS_HTML_O_src ""_ostr);
if (bReplacement)
- aAttribute = OOO_STRING_SVTOOLS_HTML_O_data;
- aHtml.attribute(aAttribute, sBuffer.makeStringAndClear().getStr());
+ aAttribute = OOO_STRING_SVTOOLS_HTML_O_data ""_ostr;
+ rHtml.attribute(aAttribute, sBuffer);
}
if (bReplacement)
{
// Handle XHTML type attribute for OLE replacement images.
if (!rMimeType.isEmpty())
- aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_type, rMimeType.toUtf8());
+ rHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_type, rMimeType);
}
// Events
- if (SfxItemState::SET == rItemSet.GetItemState(RES_FRMMACRO, true, &pItem))
+ if (const SvxMacroItem* pMacroItem = rItemSet.GetItemIfSet(RES_FRMMACRO))
{
- const SvxMacroTableDtor& rMacTable = static_cast<const SvxMacroItem *>(pItem)->GetMacroTable();
+ const SvxMacroTableDtor& rMacTable = pMacroItem->GetMacroTable();
if (!rMacTable.empty())
{
- HtmlWriterHelper::applyEvents(aHtml, rMacTable, aImageEventTable, rHTMLWrt.m_bCfgStarBasic);
+ HtmlWriterHelper::applyEvents(rHtml, rMacTable, aImageEventTable, rWrt.m_bCfgStarBasic);
}
}
// alt, align, width, height, hspace, vspace
- rHTMLWrt.writeFrameFormatOptions(aHtml, rFrameFormat, rAlternateText, nFrameOpts);
- if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) )
- rHTMLWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameOpts );
+ rWrt.writeFrameFormatOptions(rHtml, rFrameFormat, rAlternateText, nFrameOpts);
+ if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) )
+ rWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameOpts );
if ((nFrameOpts & HtmlFrmOpts::Border) && !bReplacement)
{
- aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_border, nBorderWidth);
+ rHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_border, nBorderWidth);
}
if( pURLItem && pURLItem->IsServerMap() )
{
- aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_ismap);
+ rHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_ismap);
}
if( !aIMapName.isEmpty() )
{
- aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_usemap, OUString("#" + aIMapName));
+ rHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_usemap, "#" + aIMapName);
}
if (bReplacement)
{
+ OUString aAltText = rAlternateText;
+ // In ReqIF mode, output text from the frame instead
+ if (rWrt.mbReqIF)
+ if (OUString aFrameText = getFrameFormatText(rFrameFormat); !aFrameText.isEmpty())
+ aAltText = aFrameText;
+
// XHTML object replacement image's alternate text doesn't use the
// "alt" attribute.
- if (rAlternateText.isEmpty())
+ if (aAltText.isEmpty())
// Empty alternate text is not valid.
- aHtml.characters(" ");
+ rHtml.characters(" ");
else
- aHtml.characters(rAlternateText.toUtf8());
+ rHtml.characters(aAltText.toUtf8());
}
- aHtml.flushStack();
+ return rWrt;
+}
+
+SwHTMLWriter& OutHTML_ImageEnd( HtmlWriter& rHtml, SwHTMLWriter& rWrt )
+{
+ rHtml.flushStack();
- if( !rHTMLWrt.m_aINetFormats.empty() )
+ if( !rWrt.m_aINetFormats.empty() )
{
// There is still an attribute on the stack that has to be reopened
- SwFormatINetFormat *pINetFormat = rHTMLWrt.m_aINetFormats.back();
+ SwFormatINetFormat *pINetFormat = rWrt.m_aINetFormats.back();
OutHTML_INetFormat( rWrt, *pINetFormat, true );
}
- return rHTMLWrt;
+ return rWrt;
}
-Writer& OutHTML_BulletImage( Writer& rWrt,
+SwHTMLWriter& OutHTML_BulletImage( SwHTMLWriter& rWrt,
const char *pTag,
const SvxBrushItem* pBrush,
const OUString &rGraphicURL)
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
OUString aGraphicInBase64;
OUString aLink;
if( pBrush )
{
aLink = pBrush->GetGraphicLink();
- if(rHTMLWrt.mbEmbedImages || aLink.isEmpty())
+ if(rWrt.mbEmbedImages || aLink.isEmpty())
{
const Graphic* pGrf = pBrush->GetGraphic();
if( pGrf )
{
if( !XOutBitmap::GraphicToBase64(*pGrf, aGraphicInBase64) )
{
- rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
+ rWrt.m_nWarn = WARN_SWG_POOR_LOAD;
}
}
}
else if(!aLink.isEmpty())
{
- if( rHTMLWrt.m_bCfgCpyLinkedGrfs )
+ if( rWrt.m_bCfgCpyLinkedGrfs )
{
- rHTMLWrt.CopyLocalFileToINet( aLink );
+ rWrt.CopyLocalFileToINet( aLink );
}
}
}
- else if(!rHTMLWrt.mbEmbedImages)
+ else if(!rWrt.mbEmbedImages)
{
aLink = rGraphicURL;
}
@@ -1490,98 +1516,94 @@ Writer& OutHTML_BulletImage( Writer& rWrt,
OStringBuffer sOut;
if( pTag )
- sOut.append('<').append(pTag);
+ sOut.append(OString::Concat("<") + pTag);
- sOut.append(' ');
- sOut.append(OOO_STRING_SVTOOLS_HTML_O_style).append("=\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_style "=\"");
if(!aLink.isEmpty())
{
- sOut.append(OOO_STRING_SVTOOLS_HTML_O_src).append("=\"");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( rWrt.Strm(), aLink, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ sOut.append(OOO_STRING_SVTOOLS_HTML_O_src "=\"");
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aLink );
}
else
{
- sOut.append("list-style-image: ").append("url(").
- append(OOO_STRING_SVTOOLS_HTML_O_data).append(":");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( rWrt.Strm(), aGraphicInBase64, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ sOut.append("list-style-image: url("
+ OOO_STRING_SVTOOLS_HTML_O_data ":");
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aGraphicInBase64 );
sOut.append(");");
}
sOut.append('\"');
if (pTag)
sOut.append('>');
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ rWrt.Strm().WriteOString( sOut );
return rWrt;
}
-static Writer& OutHTML_FrameFormatTableNode( Writer& rWrt, const SwFrameFormat& rFrameFormat )
+static SwHTMLWriter& OutHTML_FrameFormatTableNode( SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
- sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
- sal_uLong nEnd = rHTMLWrt.m_pDoc->GetNodes()[nStt-1]->EndOfSectionIndex();
+ SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
+ SwNodeOffset nEnd = rWrt.m_pDoc->GetNodes()[nStt-1]->EndOfSectionIndex();
OUString aCaption;
bool bTopCaption = false;
// Not const, because GetTable won't be const sometime later
- SwNode *pNd = rHTMLWrt.m_pDoc->GetNodes()[ nStt ];
+ SwNode *pNd = rWrt.m_pDoc->GetNodes()[ nStt ];
SwTableNode *pTableNd = pNd->GetTableNode();
const SwTextNode *pTextNd = pNd->GetTextNode();
if( !pTableNd && pTextNd )
{
// Table with heading
bTopCaption = true;
- pTableNd = rHTMLWrt.m_pDoc->GetNodes()[nStt+1]->GetTableNode();
+ pTableNd = rWrt.m_pDoc->GetNodes()[nStt+1]->GetTableNode();
}
OSL_ENSURE( pTableNd, "Frame does not contain a table" );
if( pTableNd )
{
- sal_uLong nTableEnd = pTableNd->EndOfSectionIndex();
+ SwNodeOffset nTableEnd = pTableNd->EndOfSectionIndex();
OSL_ENSURE( nTableEnd == nEnd - 1 ||
(nTableEnd == nEnd - 2 && !bTopCaption),
"Invalid frame content for a table" );
if( nTableEnd == nEnd - 2 )
- pTextNd = rHTMLWrt.m_pDoc->GetNodes()[nTableEnd+1]->GetTextNode();
+ pTextNd = rWrt.m_pDoc->GetNodes()[nTableEnd+1]->GetTextNode();
}
if( pTextNd )
aCaption = pTextNd->GetText();
if( pTableNd )
{
- HTMLSaveData aSaveData( rHTMLWrt, pTableNd->GetIndex()+1,
+ HTMLSaveData aSaveData( rWrt, pTableNd->GetIndex()+1,
pTableNd->EndOfSectionIndex(),
true, &rFrameFormat );
- rHTMLWrt.m_bOutFlyFrame = true;
- OutHTML_SwTableNode( rHTMLWrt, *pTableNd, &rFrameFormat, &aCaption,
+ rWrt.m_bOutFlyFrame = true;
+ OutHTML_SwTableNode( rWrt, *pTableNd, &rFrameFormat, &aCaption,
bTopCaption );
}
return rWrt;
}
-static Writer & OutHTML_FrameFormatAsMulticol( Writer& rWrt,
+static SwHTMLWriter & OutHTML_FrameFormatAsMulticol( SwHTMLWriter& rWrt,
const SwFrameFormat& rFrameFormat,
bool bInCntnr )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
- rHTMLWrt.ChangeParaToken( HtmlTokenId::NONE );
+ rWrt.ChangeParaToken( HtmlTokenId::NONE );
// Close the current <DL>!
- rHTMLWrt.OutAndSetDefList( 0 );
+ rWrt.OutAndSetDefList( 0 );
// output as Multicol
- if( rHTMLWrt.m_bLFPossible )
- rHTMLWrt.OutNewLine();
+ if (rWrt.IsLFPossible())
+ rWrt.OutNewLine();
- OStringBuffer sOut;
- sOut.append('<').append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_multicol);
+ OStringBuffer sOut("<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_multicol);
const SwFormatCol& rFormatCol = rFrameFormat.GetCol();
@@ -1589,79 +1611,73 @@ static Writer & OutHTML_FrameFormatAsMulticol( Writer& rWrt,
sal_uInt16 nCols = rFormatCol.GetNumCols();
if( nCols )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_cols).
- append("=\"").append(static_cast<sal_Int32>(nCols)).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_cols
+ "=\"" + OString::number(nCols) + "\"");
}
// the Gutter width (minimum value) as GUTTER
sal_uInt16 nGutter = rFormatCol.GetGutterWidth( true );
if( nGutter!=USHRT_MAX )
{
- if( nGutter && Application::GetDefaultDevice() )
- {
- nGutter = static_cast<sal_uInt16>(Application::GetDefaultDevice()
- ->LogicToPixel( Size(nGutter,0),
- MapMode(MapUnit::MapTwip) ).Width());
- }
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_gutter).
- append("=\"").append(static_cast<sal_Int32>(nGutter)).append("\"");
+ nGutter = SwHTMLWriter::ToPixel(nGutter);
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_gutter
+ "=\"" + OString::number(nGutter) + "\"");
}
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
// WIDTH
HtmlFrmOpts nFrameFlags = HTML_FRMOPTS_MULTICOL;
- if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
+ if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
nFrameFlags |= HTML_FRMOPTS_MULTICOL_CSS1;
- rHTMLWrt.OutFrameFormatOptions(rFrameFormat, OUString(), nFrameFlags);
- if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
- rHTMLWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameFlags );
+ rWrt.OutFrameFormatOptions(rFrameFormat, u"", nFrameFlags);
+ if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
+ rWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameFlags );
rWrt.Strm().WriteChar( '>' );
- rHTMLWrt.m_bLFPossible = true;
- rHTMLWrt.IncIndentLevel(); // indent the content of Multicol
+ rWrt.SetLFPossible(true);
+ rWrt.IncIndentLevel(); // indent the content of Multicol
const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
- sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex();
+ SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex();
const SwStartNode* pSttNd = rWrt.m_pDoc->GetNodes()[nStt]->GetStartNode();
OSL_ENSURE( pSttNd, "Where is the start node" );
{
// in a block, so that the old state can be restored in time
// before the end
- HTMLSaveData aSaveData( rHTMLWrt, nStt+1,
+ HTMLSaveData aSaveData( rWrt, nStt+1,
pSttNd->EndOfSectionIndex(),
true, &rFrameFormat );
- rHTMLWrt.m_bOutFlyFrame = true;
- rHTMLWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() );
+ rWrt.m_bOutFlyFrame = true;
+ rWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() );
}
- rHTMLWrt.DecIndentLevel(); // indent the content of Multicol;
- if( rHTMLWrt.m_bLFPossible )
- rHTMLWrt.OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_multicol, false );
- rHTMLWrt.m_bLFPossible = true;
+ rWrt.DecIndentLevel(); // indent the content of Multicol;
+ if (rWrt.IsLFPossible())
+ rWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_multicol), false );
+ rWrt.SetLFPossible(true);
return rWrt;
}
-static Writer& OutHTML_FrameFormatAsSpacer( Writer& rWrt, const SwFrameFormat& rFrameFormat )
+static SwHTMLWriter& OutHTML_FrameFormatAsSpacer( SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
// if possible, output a line break before the graphic
- if( rHTMLWrt.m_bLFPossible )
- rHTMLWrt.OutNewLine( true );
+ if (rWrt.IsLFPossible())
+ rWrt.OutNewLine( true );
OString sOut =
- "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_spacer " "
+ "<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_spacer " "
OOO_STRING_SVTOOLS_HTML_O_type "=\""
OOO_STRING_SVTOOLS_HTML_SPTYPE_block "\"";
rWrt.Strm().WriteOString( sOut );
// ALIGN, WIDTH, HEIGHT
- OString aEndTags = rHTMLWrt.OutFrameFormatOptions(rFrameFormat, OUString(), HTML_FRMOPTS_SPACER);
+ OString aEndTags = rWrt.OutFrameFormatOptions(rFrameFormat, u"", HTML_FRMOPTS_SPACER);
rWrt.Strm().WriteChar( '>' );
if( !aEndTags.isEmpty() )
@@ -1670,46 +1686,44 @@ static Writer& OutHTML_FrameFormatAsSpacer( Writer& rWrt, const SwFrameFormat& r
return rWrt;
}
-static Writer& OutHTML_FrameFormatAsDivOrSpan( Writer& rWrt,
+static SwHTMLWriter& OutHTML_FrameFormatAsDivOrSpan( SwHTMLWriter& rWrt,
const SwFrameFormat& rFrameFormat, bool bSpan)
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
OString aTag;
if( !bSpan )
{
- rHTMLWrt.ChangeParaToken( HtmlTokenId::NONE );
+ rWrt.ChangeParaToken( HtmlTokenId::NONE );
// Close the current <DL>!
- rHTMLWrt.OutAndSetDefList( 0 );
- aTag = OOO_STRING_SVTOOLS_HTML_division;
+ rWrt.OutAndSetDefList( 0 );
+ aTag = OOO_STRING_SVTOOLS_HTML_division ""_ostr;
}
else
- aTag = OOO_STRING_SVTOOLS_HTML_span;
+ aTag = OOO_STRING_SVTOOLS_HTML_span ""_ostr;
// output as DIV
- if( rHTMLWrt.m_bLFPossible )
- rHTMLWrt.OutNewLine();
+ if (rWrt.IsLFPossible())
+ rWrt.OutNewLine();
- OStringBuffer sOut;
- sOut.append('<').append(rHTMLWrt.GetNamespace() + aTag);
+ OStringBuffer sOut("<" + rWrt.GetNamespace() + aTag);
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
HtmlFrmOpts nFrameFlags = HTML_FRMOPTS_DIV;
- if( rHTMLWrt.IsHTMLMode( HTMLMODE_BORDER_NONE ) )
+ if( rWrt.IsHTMLMode( HTMLMODE_BORDER_NONE ) )
nFrameFlags |= HtmlFrmOpts::SNoBorder;
- OString aEndTags = rHTMLWrt.OutFrameFormatOptions(rFrameFormat, OUString(), nFrameFlags);
- rHTMLWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameFlags );
+ OString aEndTags = rWrt.OutFrameFormatOptions(rFrameFormat, u"", nFrameFlags);
+ rWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameFlags );
rWrt.Strm().WriteChar( '>' );
- rHTMLWrt.IncIndentLevel(); // indent the content
- rHTMLWrt.m_bLFPossible = true;
+ rWrt.IncIndentLevel(); // indent the content
+ rWrt.SetLFPossible(true);
const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
- sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex();
+ SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex();
// Output frame-anchored frames that are anchored to the start node
- rHTMLWrt.OutFlyFrame( nStt, 0, HtmlPosition::Any );
+ rWrt.OutFlyFrame( nStt, 0, HtmlPosition::Any );
const SwStartNode* pSttNd = rWrt.m_pDoc->GetNodes()[nStt]->GetStartNode();
OSL_ENSURE( pSttNd, "Where is the start node" );
@@ -1717,17 +1731,17 @@ static Writer& OutHTML_FrameFormatAsDivOrSpan( Writer& rWrt,
{
// in a block, so that the old state can be restored in time
// before the end
- HTMLSaveData aSaveData( rHTMLWrt, nStt+1,
+ HTMLSaveData aSaveData( rWrt, nStt+1,
pSttNd->EndOfSectionIndex(),
true, &rFrameFormat );
- rHTMLWrt.m_bOutFlyFrame = true;
- rHTMLWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() );
+ rWrt.m_bOutFlyFrame = true;
+ rWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() );
}
- rHTMLWrt.DecIndentLevel(); // indent the content of Multicol;
- if( rHTMLWrt.m_bLFPossible )
- rHTMLWrt.OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + aTag, false );
+ rWrt.DecIndentLevel(); // indent the content of Multicol;
+ if (rWrt.IsLFPossible())
+ rWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aTag), false );
if( !aEndTags.isEmpty() )
rWrt.Strm().WriteOString( aEndTags );
@@ -1735,29 +1749,109 @@ static Writer& OutHTML_FrameFormatAsDivOrSpan( Writer& rWrt,
return rWrt;
}
-static Writer & OutHTML_FrameFormatAsImage( Writer& rWrt, const SwFrameFormat& rFrameFormat )
+/// Starts the OLE version of an image in the ReqIF + OLE case.
+static void OutHTML_ImageOLEStart(SwHTMLWriter& rWrt, const Graphic& rGraphic,
+ const SwFrameFormat& rFrameFormat)
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
+ if (!rWrt.mbReqIF || !rWrt.m_bExportImagesAsOLE)
+ return;
- if (rHTMLWrt.mbSkipImages)
+ // Write the original image as an RTF fragment.
+ OUString aFileName;
+ if (rWrt.GetOrigFileName())
+ aFileName = *rWrt.GetOrigFileName();
+ INetURLObject aURL(aFileName);
+ OUString aName = aURL.getBase() + "_" + aURL.getExtension() + "_"
+ + OUString::number(rGraphic.GetChecksum(), 16);
+ aURL.setBase(aName);
+ aURL.setExtension(u"ole");
+ aFileName = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
+
+ SvFileStream aOutStream(aFileName, StreamMode::WRITE);
+ if (!SwReqIfReader::WrapGraphicInRtf(rGraphic, rFrameFormat, aOutStream))
+ SAL_WARN("sw.html", "SwReqIfReader::WrapGraphicInRtf() failed");
+
+ // Refer to this data.
+ aFileName = URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aFileName);
+ rWrt.Strm().WriteOString(
+ Concat2View("<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object));
+ rWrt.Strm().WriteOString(Concat2View(" data=\"" + aFileName.toUtf8() + "\""));
+ rWrt.Strm().WriteOString(" type=\"text/rtf\"");
+ rWrt.Strm().WriteOString(">");
+ rWrt.OutNewLine();
+}
+
+/// Ends the OLE version of an image in the ReqIF + OLE case.
+static void OutHTML_ImageOLEEnd(SwHTMLWriter& rWrt)
+{
+ if (rWrt.mbReqIF && rWrt.m_bExportImagesAsOLE)
+ {
+ rWrt.Strm().WriteOString(
+ Concat2View("</" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object ">"));
+ }
+}
+
+static SwHTMLWriter & OutHTML_FrameFormatAsImage( SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat, bool bPNGFallback)
+{
+ bool bWritePNGFallback = rWrt.mbReqIF && !rWrt.m_bExportImagesAsOLE && bPNGFallback;
+
+ if (rWrt.mbSkipImages)
return rWrt;
ImageMap aIMap;
- Graphic aGraphic( const_cast<SwFrameFormat &>(rFrameFormat).MakeGraphic( &aIMap ) );
+ std::optional<Size> aDPI;
+ if (rWrt.m_nShapeDPI.has_value())
+ {
+ aDPI.emplace(*rWrt.m_nShapeDPI, *rWrt.m_nShapeDPI);
+ }
+ Graphic aGraphic( const_cast<SwFrameFormat &>(rFrameFormat).MakeGraphic( &aIMap, /*nMaximumQuadraticPixels=*/2100000, aDPI ) );
+
+ if (rWrt.mbReqIF)
+ {
+ // ImageMap doesn't seem to be allowed in reqif.
+ if (auto pGrafObj = dynamic_cast<const SdrGrafObj*>(rFrameFormat.FindSdrObject()))
+ {
+ aGraphic = pGrafObj->GetGraphic();
+ }
+ else
+ {
+ // We only have a bitmap, write that as PNG without any fallback.
+ bWritePNGFallback = false;
+ }
+ }
+
Size aSz( 0, 0 );
OUString GraphicURL;
- if(!rHTMLWrt.mbEmbedImages)
+ OUString aMimeType("image/jpeg");
+ if(!rWrt.mbEmbedImages)
{
- if( rHTMLWrt.GetOrigFileName() )
- GraphicURL = *rHTMLWrt.GetOrigFileName();
+ if( rWrt.GetOrigFileName() )
+ GraphicURL = *rWrt.GetOrigFileName();
+
+ OUString aFilterName("JPG");
+ XOutFlags nFlags = XOutFlags::UseGifIfPossible | XOutFlags::UseNativeIfPossible;
+
+ if (rWrt.mbReqIF && !bWritePNGFallback)
+ {
+ // Writing image without fallback PNG in ReqIF mode: force PNG output.
+ aFilterName = "PNG";
+ nFlags = XOutFlags::NONE;
+ aMimeType = "image/png";
+ }
+ else if (rWrt.mbReqIF)
+ {
+ // Original format is wanted, don't force JPG.
+ aFilterName.clear();
+ aMimeType.clear();
+ }
+
if( aGraphic.GetType() == GraphicType::NONE ||
XOutBitmap::WriteGraphic( aGraphic, GraphicURL,
- "JPG",
- (XOutFlags::UseGifIfPossible|
- XOutFlags::UseNativeIfPossible) ) != ERRCODE_NONE )
+ aFilterName,
+ nFlags ) != ERRCODE_NONE )
{
// empty or incorrect, because there is nothing to output
- rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
+ rWrt.m_nWarn = WARN_SWG_POOR_LOAD;
return rWrt;
}
@@ -1766,46 +1860,70 @@ static Writer & OutHTML_FrameFormatAsImage( Writer& rWrt, const SwFrameFormat& r
URIHelper::GetMaybeFileHdl() );
}
- OutHTML_Image( rWrt, rFrameFormat, GraphicURL, aGraphic, rFrameFormat.GetName(), aSz,
+ uno::Reference<beans::XPropertySet> xGraphic(aGraphic.GetXGraphic(), uno::UNO_QUERY);
+ if (xGraphic.is() && aMimeType.isEmpty())
+ xGraphic->getPropertyValue("MimeType") >>= aMimeType;
+
+ OutHTML_ImageOLEStart(rWrt, aGraphic, rFrameFormat);
+
+ HtmlWriter aHtml(rWrt.Strm(), rWrt.maNamespace);
+ OutHTML_ImageStart( aHtml, rWrt, rFrameFormat, GraphicURL, aGraphic, rFrameFormat.GetName(), aSz,
HtmlFrmOpts::GenImgMask, "frame",
- aIMap.GetIMapObjectCount() ? &aIMap : nullptr );
+ aIMap.GetIMapObjectCount() ? &aIMap : nullptr, aMimeType );
+
+ GfxLink aLink = aGraphic.GetGfxLink();
+ if (bWritePNGFallback && aLink.GetType() != GfxLinkType::NativePng)
+ {
+ OutHTML_FrameFormatAsImage( rWrt, rFrameFormat, /*bPNGFallback=*/false);
+ }
+
+ OutHTML_ImageEnd(aHtml, rWrt);
+
+ OutHTML_ImageOLEEnd(rWrt);
return rWrt;
}
-static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rFrameFormat,
- bool bInCntnr )
+static SwHTMLWriter& OutHTML_FrameFormatGrfNode( SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat,
+ bool bInCntnr, bool bPNGFallback )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
+ bool bWritePNGFallback = rWrt.mbReqIF && !rWrt.m_bExportImagesAsOLE && bPNGFallback;
- if (rHTMLWrt.mbSkipImages)
+ if (rWrt.mbSkipImages)
return rWrt;
const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
- sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
- SwGrfNode *pGrfNd = rHTMLWrt.m_pDoc->GetNodes()[ nStt ]->GetGrfNode();
+ SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
+ SwGrfNode *pGrfNd = rWrt.m_pDoc->GetNodes()[ nStt ]->GetGrfNode();
OSL_ENSURE( pGrfNd, "Grf node expected" );
if( !pGrfNd )
return rWrt;
HtmlFrmOpts nFrameFlags = bInCntnr ? HTML_FRMOPTS_IMG_CNTNR : HTML_FRMOPTS_IMG;
- if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
+ if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
nFrameFlags |= HTML_FRMOPTS_IMG_CSS1;
Graphic aGraphic = pGrfNd->GetGraphic();
+
+ if (aGraphic.GetType() == GraphicType::GdiMetafile)
+ {
+ // We only have a metafile, write that as PNG without any fallback.
+ bWritePNGFallback = false;
+ }
+
OUString aGraphicURL;
OUString aMimeType;
- if(!rHTMLWrt.mbEmbedImages)
+ if(!rWrt.mbEmbedImages)
{
const SwMirrorGrf& rMirror = pGrfNd->GetSwAttrSet().GetMirrorGrf();
if( !pGrfNd->IsLinkedFile() || MirrorGraph::Dont != rMirror.GetValue() )
{
// create a (mirrored) jpeg file
- if( rHTMLWrt.GetOrigFileName() )
- aGraphicURL = *rHTMLWrt.GetOrigFileName();
+ if( rWrt.GetOrigFileName() )
+ aGraphicURL = *rWrt.GetOrigFileName();
else
- aGraphicURL = rHTMLWrt.GetBaseURL();
+ aGraphicURL = rWrt.GetBaseURL();
pGrfNd->GetGrf( true );
XOutFlags nFlags = XOutFlags::UseGifIfSensible |
@@ -1820,21 +1938,25 @@ static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rF
default: break;
}
- Size aMM100Size;
const SwFormatFrameSize& rSize = rFrameFormat.GetFrameSize();
- aMM100Size = OutputDevice::LogicToLogic( rSize.GetSize(),
- MapMode( MapUnit::MapTwip ), MapMode( MapUnit::Map100thMM ));
+ Size aMM100Size = o3tl::convert( rSize.GetSize(),
+ o3tl::Length::twip, o3tl::Length::mm100 );
- OUString aFilterName("");
+ OUString aFilterName;
- if (rHTMLWrt.mbReqIF)
+ if (rWrt.mbReqIF)
{
- // Writing image without fallback PNG in ReqIF mode: force PNG
- // output.
- aFilterName = "PNG";
- nFlags &= ~XOutFlags::UseNativeIfPossible;
+ // In ReqIF mode, do not try to write GIF for other image types
nFlags &= ~XOutFlags::UseGifIfSensible;
- aMimeType = "image/png";
+ if (!bWritePNGFallback)
+ {
+ // Writing image without fallback PNG in ReqIF mode: force PNG
+ // output.
+ // But don't force it when writing the original format and we'll write PNG inside
+ // that.
+ aFilterName = "PNG";
+ nFlags &= ~XOutFlags::UseNativeIfPossible;
+ }
}
const Graphic& rGraphic = pGrfNd->GetGrf();
@@ -1843,11 +1965,33 @@ static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rF
if (!rGraphic.isAvailable())
const_cast<Graphic&>(rGraphic).makeAvailable();
+ if (rWrt.mbReqIF && bWritePNGFallback)
+ {
+ // ReqIF: force native data if possible.
+ const std::shared_ptr<VectorGraphicData>& pVectorGraphicData = rGraphic.getVectorGraphicData();
+ if (pVectorGraphicData && pVectorGraphicData->getType() == VectorGraphicDataType::Svg)
+ {
+ aFilterName = "svg";
+ }
+ else if (rGraphic.GetGfxLink().IsEMF())
+ {
+ aFilterName = "emf";
+ }
+ else if (pVectorGraphicData && pVectorGraphicData->getType() == VectorGraphicDataType::Wmf)
+ {
+ aFilterName = "wmf";
+ }
+ else if (rGraphic.GetGfxLink().GetType() == GfxLinkType::NativeTif)
+ {
+ aFilterName = "tif";
+ }
+ }
+
ErrCode nErr = XOutBitmap::WriteGraphic( rGraphic, aGraphicURL,
- aFilterName, nFlags, &aMM100Size );
+ aFilterName, nFlags, &aMM100Size, nullptr, &aMimeType );
if( nErr )
{
- rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
+ rWrt.m_nWarn = WARN_SWG_POOR_LOAD;
return rWrt;
}
aGraphicURL = URIHelper::SmartRel2Abs(
@@ -1857,7 +2001,7 @@ static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rF
else
{
pGrfNd->GetFileFilterNms( &aGraphicURL, nullptr );
- if( rHTMLWrt.m_bCfgCpyLinkedGrfs )
+ if( rWrt.m_bCfgCpyLinkedGrfs )
rWrt.CopyLocalFileToINet( aGraphicURL );
}
@@ -1866,174 +2010,152 @@ static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rF
if (xGraphic.is() && aMimeType.isEmpty())
xGraphic->getPropertyValue("MimeType") >>= aMimeType;
- if (rHTMLWrt.mbReqIF)
- {
- // Write the original image as an RTF fragment.
- OUString aFileName;
- if (rHTMLWrt.GetOrigFileName())
- aFileName = *rHTMLWrt.GetOrigFileName();
- INetURLObject aURL(aFileName);
- OUString aName = aURL.getBase() + "_" +
- aURL.getExtension() + "_" +
- OUString::number(aGraphic.GetChecksum(), 16);
- aURL.setBase(aName);
- aURL.setExtension("ole");
- aFileName = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
-
- SvFileStream aOutStream(aFileName, StreamMode::WRITE);
- if (!SwReqIfReader::WrapGraphicInRtf(aGraphic, pGrfNd->GetTwipSize(), aOutStream))
- SAL_WARN("sw.html", "SwReqIfReader::WrapGraphicInRtf() failed");
-
- // Refer to this data.
- aFileName = URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aFileName);
- rWrt.Strm().WriteOString("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object);
- rWrt.Strm().WriteOString(" data=\"" + aFileName.toUtf8() + "\"");
- rWrt.Strm().WriteOString(" type=\"text/rtf\"");
- rWrt.Strm().WriteOString(">");
- rHTMLWrt.OutNewLine();
- }
-
- OutHTML_Image( rWrt, rFrameFormat, aGraphicURL, aGraphic, pGrfNd->GetTitle(),
+ OutHTML_ImageOLEStart(rWrt, aGraphic, rFrameFormat);
+
+ HtmlWriter aHtml(rWrt.Strm(), rWrt.maNamespace);
+ OutHTML_ImageStart( aHtml, rWrt, rFrameFormat, aGraphicURL, aGraphic, pGrfNd->GetTitle(),
pGrfNd->GetTwipSize(), nFrameFlags, "graphic", nullptr, aMimeType );
- if (rHTMLWrt.mbReqIF)
- rWrt.Strm().WriteOString("</" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object ">");
+ GfxLink aLink = aGraphic.GetGfxLink();
+ if (bWritePNGFallback && aLink.GetType() != GfxLinkType::NativePng)
+ {
+ // Not OLE mode, outer format is not PNG: write inner PNG.
+ OutHTML_FrameFormatGrfNode( rWrt, rFrameFormat,
+ bInCntnr, /*bPNGFallback=*/false );
+ }
+
+ OutHTML_ImageEnd(aHtml, rWrt);
+
+ OutHTML_ImageOLEEnd(rWrt);
return rWrt;
}
-static Writer& OutHTML_FrameFormatAsMarquee( Writer& rWrt, const SwFrameFormat& rFrameFormat,
+static SwHTMLWriter& OutHTML_FrameFormatAsMarquee( SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat,
const SdrObject& rSdrObj )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
// get the edit engine attributes of the object as SW attributes and
// sort them as Hints
const SfxItemSet& rFormatItemSet = rFrameFormat.GetAttrSet();
- SfxItemSet aItemSet( *rFormatItemSet.GetPool(), svl::Items<RES_CHRATR_BEGIN,
- RES_CHRATR_END>{} );
+ SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END> aItemSet( *rFormatItemSet.GetPool() );
SwHTMLWriter::GetEEAttrsFromDrwObj( aItemSet, &rSdrObj );
- bool bCfgOutStylesOld = rHTMLWrt.m_bCfgOutStyles;
- rHTMLWrt.m_bCfgOutStyles = false;
- rHTMLWrt.m_bTextAttr = true;
- rHTMLWrt.m_bTagOn = true;
+ bool bCfgOutStylesOld = rWrt.m_bCfgOutStyles;
+ rWrt.m_bCfgOutStyles = false;
+ rWrt.m_bTextAttr = true;
+ rWrt.m_bTagOn = true;
Out_SfxItemSet( aHTMLAttrFnTab, rWrt, aItemSet, false );
- rHTMLWrt.m_bTextAttr = false;
+ rWrt.m_bTextAttr = false;
- OutHTML_DrawFrameFormatAsMarquee( rHTMLWrt,
+ OutHTML_DrawFrameFormatAsMarquee( rWrt,
static_cast<const SwDrawFrameFormat &>(rFrameFormat),
rSdrObj );
- rHTMLWrt.m_bTextAttr = true;
- rHTMLWrt.m_bTagOn = false;
+ rWrt.m_bTextAttr = true;
+ rWrt.m_bTagOn = false;
Out_SfxItemSet( aHTMLAttrFnTab, rWrt, aItemSet, false );
- rHTMLWrt.m_bTextAttr = false;
- rHTMLWrt.m_bCfgOutStyles = bCfgOutStylesOld;
+ rWrt.m_bTextAttr = false;
+ rWrt.m_bCfgOutStyles = bCfgOutStylesOld;
return rWrt;
}
-Writer& OutHTML_HeaderFooter( Writer& rWrt, const SwFrameFormat& rFrameFormat,
+SwHTMLWriter& OutHTML_HeaderFooter( SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat,
bool bHeader )
{
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
// output as Multicol
- rHTMLWrt.OutNewLine();
+ rWrt.OutNewLine();
OStringBuffer sOut;
- sOut.append(OOO_STRING_SVTOOLS_HTML_division).append(' ')
- .append(OOO_STRING_SVTOOLS_HTML_O_title).append("=\"")
+ sOut.append(OOO_STRING_SVTOOLS_HTML_division " "
+ OOO_STRING_SVTOOLS_HTML_O_title "=\"")
.append( bHeader ? "header" : "footer" ).append("\"");
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + sOut.makeStringAndClear().getStr() );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + sOut) );
- rHTMLWrt.IncIndentLevel(); // indent the content of Multicol;
+ rWrt.IncIndentLevel(); // indent the content of Multicol;
// Piece a spacer for the spacing together. Because the
// <DL> or </DL> always produces a space between paragraphs, it is
// subtracted if necessary.
const SvxULSpaceItem& rULSpace = rFrameFormat.GetULSpace();
sal_uInt16 nSize = bHeader ? rULSpace.GetLower() : rULSpace.GetUpper();
- rHTMLWrt.m_nHeaderFooterSpace = nSize;
+ rWrt.m_nHeaderFooterSpace = nSize;
OString aSpacer;
- if( rHTMLWrt.IsHTMLMode(HTMLMODE_VERT_SPACER) &&
- nSize > HTML_PARSPACE && Application::GetDefaultDevice() )
+ if( rWrt.IsHTMLMode(HTMLMODE_VERT_SPACER) &&
+ nSize > HTML_PARSPACE )
{
nSize -= HTML_PARSPACE;
- nSize = static_cast<sal_Int16>(Application::GetDefaultDevice()
- ->LogicToPixel( Size(nSize,0), MapMode(MapUnit::MapTwip) ).Width());
+ nSize = SwHTMLWriter::ToPixel(nSize);
- aSpacer = OStringBuffer(OOO_STRING_SVTOOLS_HTML_spacer).
- append(' ').append(OOO_STRING_SVTOOLS_HTML_O_type).
- append("=\"").append(OOO_STRING_SVTOOLS_HTML_SPTYPE_vertical).append("\"").
- append(' ').append(OOO_STRING_SVTOOLS_HTML_O_size).
- append("=\"").append(static_cast<sal_Int32>(nSize)).append("\"").
- makeStringAndClear();
+ aSpacer = OOO_STRING_SVTOOLS_HTML_spacer
+ " " OOO_STRING_SVTOOLS_HTML_O_type
+ "=\"" OOO_STRING_SVTOOLS_HTML_SPTYPE_vertical "\""
+ " " OOO_STRING_SVTOOLS_HTML_O_size
+ "=\"" + OString::number(nSize) + "\"";
}
const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
- sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex();
+ SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex();
const SwStartNode* pSttNd = rWrt.m_pDoc->GetNodes()[nStt]->GetStartNode();
OSL_ENSURE( pSttNd, "Where is the start node" );
if( !bHeader && !aSpacer.isEmpty() )
{
- rHTMLWrt.OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + aSpacer.getStr() );
+ rWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aSpacer) );
}
{
// in a block, so that the old state can be restored in time
// before the end. pFlyFormat doesn't need to be set here, because
// PageDesc attributes cannot occur here
- HTMLSaveData aSaveData( rHTMLWrt, nStt+1,
+ HTMLSaveData aSaveData( rWrt, nStt+1,
pSttNd->EndOfSectionIndex() );
if( bHeader )
- rHTMLWrt.m_bOutHeader = true;
+ rWrt.m_bOutHeader = true;
else
- rHTMLWrt.m_bOutFooter = true;
+ rWrt.m_bOutFooter = true;
- rHTMLWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() );
+ rWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() );
}
if( bHeader && !aSpacer.isEmpty() )
{
- rHTMLWrt.OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + aSpacer.getStr() );
+ rWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aSpacer) );
}
- rHTMLWrt.DecIndentLevel(); // indent the content of Multicol;
- rHTMLWrt.OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_division, false );
+ rWrt.DecIndentLevel(); // indent the content of Multicol;
+ rWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_division), false );
- rHTMLWrt.m_nHeaderFooterSpace = 0;
+ rWrt.m_nHeaderFooterSpace = 0;
return rWrt;
}
-void SwHTMLWriter::AddLinkTarget( const OUString& rURL )
+void SwHTMLWriter::AddLinkTarget( std::u16string_view aURL )
{
- if( rURL.isEmpty() || rURL[0] != '#' )
+ if( aURL.empty() || aURL[0] != '#' )
return;
// There might be a '|' as delimiter (if the link has been inserted
// freshly) or a '%7c' or a '%7C' if the document has been saved and
// loaded already.
- sal_Int32 nPos = rURL.getLength();
+ sal_Int32 nPos = aURL.size();
bool bFound = false, bEncoded = false;
while( !bFound && nPos > 0 )
{
- sal_Unicode c = rURL[ --nPos ];
+ sal_Unicode c = aURL[ --nPos ];
switch( c )
{
case cMarkSeparator:
bFound = true;
break;
case '%':
- bFound = (rURL.getLength() - nPos) >=3 && rURL[ nPos+1 ] == '7';
+ bFound = (aURL.size() - nPos) >=3 && aURL[ nPos+1 ] == '7';
if(bFound)
{
- c = rURL[ nPos+2 ];
+ c = aURL[ nPos+2 ];
bFound = (c == 'C' || c == 'c');
}
if( bFound )
@@ -2043,10 +2165,10 @@ void SwHTMLWriter::AddLinkTarget( const OUString& rURL )
if( !bFound || nPos < 2 ) // at least "#a|..."
return;
- OUString aURL( rURL.copy( 1 ) );
+ aURL = aURL.substr( 1 );
// nPos-1+1/3 (-1 because of Erase)
- OUString sCmp = aURL.copy(bEncoded ? nPos+2 : nPos).replaceAll(" ","");
+ OUString sCmp = OUString(aURL.substr(bEncoded ? nPos+2 : nPos)).replaceAll(" ","");
if( sCmp.isEmpty() )
return;
@@ -2059,21 +2181,22 @@ void SwHTMLWriter::AddLinkTarget( const OUString& rURL )
sCmp == "table" )
{
// Just remember it in a sorted array
+ OUString aURL2(aURL);
if( bEncoded )
{
- aURL = aURL.replaceAt( nPos - 1, 3, OUString(cMarkSeparator) );
+ aURL2 = aURL2.replaceAt( nPos - 1, 3, rtl::OUStringChar(cMarkSeparator) );
}
- m_aImplicitMarks.insert( aURL );
+ m_aImplicitMarks.insert( aURL2 );
}
else if( sCmp == "outline" )
{
// Here, we need position and name. That's why we sort a
// sal_uInt16 and a string array ourselves.
- OUString aOutline( aURL.copy( 0, nPos-1 ) );
+ OUString aOutline( aURL.substr( 0, nPos-1 ) );
SwPosition aPos( *m_pCurrentPam->GetPoint() );
if( m_pDoc->GotoOutline( aPos, aOutline ) )
{
- sal_uInt32 nIdx = aPos.nNode.GetIndex();
+ SwNodeOffset nIdx = aPos.GetNodeIndex();
decltype(m_aOutlineMarkPoss)::size_type nIns=0;
while( nIns < m_aOutlineMarkPoss.size() &&
@@ -2081,11 +2204,12 @@ void SwHTMLWriter::AddLinkTarget( const OUString& rURL )
nIns++;
m_aOutlineMarkPoss.insert( m_aOutlineMarkPoss.begin()+nIns, nIdx );
+ OUString aURL2(aURL);
if( bEncoded )
{
- aURL = aURL.replaceAt( nPos - 1, 3, OUString(cMarkSeparator) );
+ aURL2 = aURL2.replaceAt( nPos - 1, 3, rtl::OUStringChar(cMarkSeparator) );
}
- m_aOutlineMarks.insert( m_aOutlineMarks.begin()+nIns, aURL );
+ m_aOutlineMarks.insert( m_aOutlineMarks.begin()+nIns, aURL2 );
}
}
}
@@ -2094,7 +2218,9 @@ void SwHTMLWriter::CollectLinkTargets()
{
const SwTextINetFormat* pTextAttr;
- for (const SfxPoolItem* pItem : m_pDoc->GetAttrPool().GetItemSurrogates(RES_TXTATR_INETFMT))
+ ItemSurrogates aSurrogates;
+ m_pDoc->GetAttrPool().GetItemSurrogates(aSurrogates, RES_TXTATR_INETFMT);
+ for (const SfxPoolItem* pItem : aSurrogates)
{
auto pINetFormat = dynamic_cast<const SwFormatINetFormat*>(pItem);
const SwTextNode* pTextNd;
@@ -2108,7 +2234,8 @@ void SwHTMLWriter::CollectLinkTargets()
}
}
- for (const SfxPoolItem* pItem : m_pDoc->GetAttrPool().GetItemSurrogates(RES_URL))
+ m_pDoc->GetAttrPool().GetItemSurrogates(aSurrogates, RES_URL);
+ for (const SfxPoolItem* pItem : aSurrogates)
{
auto pURL = dynamic_cast<const SwFormatURL*>(pItem);
if( pURL )
diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx
index bb51694df012..d37abddc68d1 100644
--- a/sw/source/filter/html/htmlform.cxx
+++ b/sw/source/filter/html/htmlform.cxx
@@ -24,9 +24,12 @@
#include <hintids.hxx>
#include <comphelper/documentinfo.hxx>
#include <comphelper/string.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <tools/UnitConversion.hxx>
+#include <o3tl/string_view.hxx>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/unohelp.hxx>
#include <svtools/htmlkywd.hxx>
#include <svtools/htmltokn.h>
@@ -64,7 +67,6 @@
#include <com/sun/star/awt/XImageConsumer.hpp>
#include <com/sun/star/awt/ImageStatus.hpp>
#include <com/sun/star/form/XImageProducerSupplier.hpp>
-#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
#include <com/sun/star/form/XForm.hpp>
#include <doc.hxx>
#include <IDocumentLayoutAccess.hxx>
@@ -372,21 +374,21 @@ namespace {
class SwHTMLImageWatcher :
public cppu::WeakImplHelper< awt::XImageConsumer, XEventListener >
{
- uno::Reference< drawing::XShape > xShape; // the control
- uno::Reference< XImageProducerSupplier > xSrc;
- uno::Reference< awt::XImageConsumer > xThis; // reference to self
- bool bSetWidth;
- bool bSetHeight;
+ uno::Reference< drawing::XShape > m_xShape; // the control
+ uno::Reference< XImageProducerSupplier > m_xSrc;
+ uno::Reference< awt::XImageConsumer > m_xThis; // reference to self
+ bool m_bSetWidth;
+ bool m_bSetHeight;
void clear();
public:
- SwHTMLImageWatcher( const uno::Reference< drawing::XShape > & rShape,
+ SwHTMLImageWatcher( uno::Reference< drawing::XShape > xShape,
bool bWidth, bool bHeight );
// startProduction can not be called in the constructor because it can
// destruct itself, hence a separate method.
- void start() { xSrc->getImageProducer()->startProduction(); }
+ void start() { m_xSrc->getImageProducer()->startProduction(); }
// UNO binding
@@ -415,47 +417,47 @@ public:
}
SwHTMLImageWatcher::SwHTMLImageWatcher(
- const uno::Reference< drawing::XShape >& rShape,
+ uno::Reference< drawing::XShape > xShape,
bool bWidth, bool bHeight ) :
- xShape( rShape ),
- bSetWidth( bWidth ), bSetHeight( bHeight )
+ m_xShape(std::move( xShape )),
+ m_bSetWidth( bWidth ), m_bSetHeight( bHeight )
{
// Remember the source of the image
- uno::Reference< drawing::XControlShape > xControlShape( xShape, UNO_QUERY );
+ uno::Reference< drawing::XControlShape > xControlShape( m_xShape, UNO_QUERY );
uno::Reference< awt::XControlModel > xControlModel(
xControlShape->getControl() );
- xSrc.set( xControlModel, UNO_QUERY );
- OSL_ENSURE( xSrc.is(), "No XImageProducerSupplier" );
+ m_xSrc.set( xControlModel, UNO_QUERY );
+ OSL_ENSURE( m_xSrc.is(), "No XImageProducerSupplier" );
// Register as Event-Listener on the shape to be able to release it on dispose.
uno::Reference< XEventListener > xEvtLstnr = static_cast<XEventListener *>(this);
- uno::Reference< XComponent > xComp( xShape, UNO_QUERY );
+ uno::Reference< XComponent > xComp( m_xShape, UNO_QUERY );
xComp->addEventListener( xEvtLstnr );
// Lastly we keep a reference to ourselves so we are not destroyed
// (should not be necessary since we're still registered elsewhere)
- xThis = static_cast<awt::XImageConsumer *>(this);
+ m_xThis = static_cast<awt::XImageConsumer *>(this);
// Register at ImageProducer to retrieve the size...
- xSrc->getImageProducer()->addConsumer( xThis );
+ m_xSrc->getImageProducer()->addConsumer( m_xThis );
}
void SwHTMLImageWatcher::clear()
{
// Unregister on Shape
uno::Reference< XEventListener > xEvtLstnr = static_cast<XEventListener *>(this);
- uno::Reference< XComponent > xComp( xShape, UNO_QUERY );
+ uno::Reference< XComponent > xComp( m_xShape, UNO_QUERY );
xComp->removeEventListener( xEvtLstnr );
// Unregister on ImageProducer
- uno::Reference<awt::XImageProducer> xProd = xSrc->getImageProducer();
+ uno::Reference<awt::XImageProducer> xProd = m_xSrc->getImageProducer();
if( xProd.is() )
- xProd->removeConsumer( xThis );
+ xProd->removeConsumer( m_xThis );
}
void SwHTMLImageWatcher::init( sal_Int32 Width, sal_Int32 Height )
{
- OSL_ENSURE( bSetWidth || bSetHeight,
+ OSL_ENSURE( m_bSetWidth || m_bSetHeight,
"Width or height has to be adjusted" );
// If no width or height is given, it is initialized to those of
@@ -465,27 +467,19 @@ void SwHTMLImageWatcher::init( sal_Int32 Width, sal_Int32 Height )
return;
awt::Size aNewSz;
- aNewSz.Width = Width;
- aNewSz.Height = Height;
- if( Application::GetDefaultDevice() )
- {
- Size aTmp(aNewSz.Width, aNewSz.Height);
- aTmp = Application::GetDefaultDevice()
- ->PixelToLogic( aTmp, MapMode( MapUnit::Map100thMM ) );
- aNewSz.Width = aTmp.Width();
- aNewSz.Height = aTmp.Height();
- }
+ aNewSz.Width = o3tl::convert(Width, o3tl::Length::px, o3tl::Length::mm100);
+ aNewSz.Height = o3tl::convert(Height, o3tl::Length::px, o3tl::Length::mm100);
- if( !bSetWidth || !bSetHeight )
+ if( !m_bSetWidth || !m_bSetHeight )
{
- awt::Size aSz( xShape->getSize() );
- if( bSetWidth && aNewSz.Height )
+ awt::Size aSz( m_xShape->getSize() );
+ if( m_bSetWidth && aNewSz.Height )
{
aNewSz.Width *= aSz.Height;
aNewSz.Width /= aNewSz.Height;
aNewSz.Height = aSz.Height;
}
- if( bSetHeight && aNewSz.Width )
+ if( m_bSetHeight && aNewSz.Width )
{
aNewSz.Height *= aSz.Width;
aNewSz.Height /= aNewSz.Width;
@@ -497,15 +491,15 @@ void SwHTMLImageWatcher::init( sal_Int32 Width, sal_Int32 Height )
if( aNewSz.Height < MINFLY )
aNewSz.Height = MINFLY;
- xShape->setSize( aNewSz );
- if( bSetWidth )
+ m_xShape->setSize( aNewSz );
+ if( m_bSetWidth )
{
// If the control is anchored to a table, the column have to be recalculated
// To get to the SwXShape* we need an interface that is implemented by SwXShape
- uno::Reference< beans::XPropertySet > xPropSet( xShape, UNO_QUERY );
- SwXShape *pSwShape = comphelper::getUnoTunnelImplementation<SwXShape>(xPropSet);
+ uno::Reference< beans::XPropertySet > xPropSet( m_xShape, UNO_QUERY );
+ SwXShape *pSwShape = comphelper::getFromUnoTunnel<SwXShape>(xPropSet);
OSL_ENSURE( pSwShape, "Where is SW-Shape?" );
if( pSwShape )
@@ -513,9 +507,9 @@ void SwHTMLImageWatcher::init( sal_Int32 Width, sal_Int32 Height )
SwFrameFormat *pFrameFormat = pSwShape->GetFrameFormat();
const SwDoc *pDoc = pFrameFormat->GetDoc();
- const SwPosition* pAPos = pFrameFormat->GetAnchor().GetContentAnchor();
+ SwNode* pAnchorNode = pFrameFormat->GetAnchor().GetAnchorNode();
SwTableNode *pTableNd;
- if (pAPos && nullptr != (pTableNd = pAPos->nNode.GetNode().FindTableNode()))
+ if (pAnchorNode && nullptr != (pTableNd = pAnchorNode->FindTableNode()))
{
const bool bLastGrf = !pTableNd->GetTable().DecGrfsThatResize();
SwHTMLTableLayout *pLayout =
@@ -538,7 +532,7 @@ void SwHTMLImageWatcher::init( sal_Int32 Width, sal_Int32 Height )
// unregister and delete self
clear();
- xThis = nullptr;
+ m_xThis = nullptr;
}
void SwHTMLImageWatcher::setColorModel(
@@ -566,7 +560,7 @@ void SwHTMLImageWatcher::complete( sal_Int32 Status,
{
// unregister and delete self
clear();
- xThis = nullptr;
+ m_xThis = nullptr;
}
}
@@ -575,11 +569,11 @@ void SwHTMLImageWatcher::disposing(const lang::EventObject& evt)
uno::Reference< awt::XImageConsumer > xTmp;
// We need to release the shape if it is disposed of
- if( evt.Source == xShape )
+ if( evt.Source == m_xShape )
{
clear();
xTmp = static_cast<awt::XImageConsumer*>(this);
- xThis = nullptr;
+ m_xThis = nullptr;
}
}
@@ -641,7 +635,7 @@ void SwHTMLParser::SetControlSize( const uno::Reference< drawing::XShape >& rSha
if ( pDocSh->GetMedium() )
{
// if there is no hidden property in the MediaDescriptor it should be removed after loading
- const SfxBoolItem* pHiddenItem = SfxItemSet::GetItem<SfxBoolItem>(pDocSh->GetMedium()->GetItemSet(), SID_HIDDEN, false);
+ const SfxBoolItem* pHiddenItem = pDocSh->GetMedium()->GetItemSet().GetItem(SID_HIDDEN, false);
m_bRemoveHidden = ( pHiddenItem == nullptr || !pHiddenItem->GetValue() );
}
@@ -653,7 +647,7 @@ void SwHTMLParser::SetControlSize( const uno::Reference< drawing::XShape >& rSha
}
}
- SwXShape *pSwShape = comphelper::getUnoTunnelImplementation<SwXShape>(xPropSet);
+ SwXShape *pSwShape = comphelper::getFromUnoTunnel<SwXShape>(xPropSet);
OSL_ENSURE( pSwShape, "Where is SW-Shape?" );
@@ -671,7 +665,7 @@ void SwHTMLParser::SetControlSize( const uno::Reference< drawing::XShape >& rSha
const SdrUnoObj *pFormObj = dynamic_cast<const SdrUnoObj*>( pObj );
uno::Reference< awt::XControl > xControl;
if ( pDrawView && pVSh->GetWin() && pFormObj )
- xControl = pFormObj->GetUnoControl( *pDrawView, *pVSh->GetWin() );
+ xControl = pFormObj->GetUnoControl( *pDrawView, *pVSh->GetWin()->GetOutDev() );
awt::Size aSz( rShape->getSize() );
awt::Size aNewSz( 0, 0 );
@@ -709,14 +703,8 @@ void SwHTMLParser::SetControlSize( const uno::Reference< drawing::XShape >& rSha
}
}
- if( Application::GetDefaultDevice() )
- {
- Size aTmpSz( aNewSz.Width, aNewSz.Height );
- aTmpSz = Application::GetDefaultDevice()
- ->PixelToLogic( aTmpSz, MapMode( MapUnit::Map100thMM ) );
- aNewSz.Width = aTmpSz.Width();
- aNewSz.Height = aTmpSz.Height();
- }
+ aNewSz.Width = o3tl::convert(aNewSz.Width, o3tl::Length::px, o3tl::Length::mm100);
+ aNewSz.Height = o3tl::convert(aNewSz.Height, o3tl::Length::px, o3tl::Length::mm100);
if( aNewSz.Width )
{
if( aNewSz.Width < MINLAY )
@@ -753,9 +741,9 @@ static bool lcl_html_setEvents(
for( const auto &rStr : rUnoMacroTable )
{
sal_Int32 nIndex = 0;
- if( rStr.getToken( 0, '-', nIndex ).isEmpty() || -1 == nIndex )
+ if( o3tl::getToken(rStr, 0, '-', nIndex ).empty() || -1 == nIndex )
continue;
- if( rStr.getToken( 0, '-', nIndex ).isEmpty() || -1 == nIndex )
+ if( o3tl::getToken(rStr, 0, '-', nIndex ).empty() || -1 == nIndex )
continue;
if( nIndex < rStr.getLength() )
nEvents++;
@@ -884,25 +872,25 @@ uno::Reference< drawing::XShape > SwHTMLParser::InsertControl(
uno::Reference< beans::XPropertySet > xShapePropSet( xCreate, UNO_QUERY );
// set left/right border
- const SfxPoolItem *pItem;
- if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, true,
- &pItem ) )
+ // note: parser never creates SvxLeftMarginItem! must be converted
+ if (const SvxTextLeftMarginItem *const pLeft = rCSS1ItemSet.GetItemIfSet(RES_MARGIN_TEXTLEFT))
{
- // Flatten first line indent
- const SvxLRSpaceItem *pLRItem = static_cast<const SvxLRSpaceItem *>(pItem);
- SvxLRSpaceItem aLRItem( *pLRItem );
- aLRItem.SetTextFirstLineOffset( 0 );
if( rCSS1PropInfo.m_bLeftMargin )
{
- nLeftSpace = convertTwipToMm100( aLRItem.GetLeft() );
+ // should be SvxLeftMarginItem... "cast" it
+ nLeftSpace = convertTwipToMm100(pLeft->GetTextLeft());
rCSS1PropInfo.m_bLeftMargin = false;
}
+ rCSS1ItemSet.ClearItem(RES_MARGIN_TEXTLEFT);
+ }
+ if (const SvxRightMarginItem *const pRight = rCSS1ItemSet.GetItemIfSet(RES_MARGIN_RIGHT))
+ {
if( rCSS1PropInfo.m_bRightMargin )
{
- nRightSpace = convertTwipToMm100( aLRItem.GetRight() );
+ nRightSpace = convertTwipToMm100(pRight->GetRight());
rCSS1PropInfo.m_bRightMargin = false;
}
- rCSS1ItemSet.ClearItem( RES_LR_SPACE );
+ rCSS1ItemSet.ClearItem(RES_MARGIN_RIGHT);
}
if( nLeftSpace || nRightSpace )
{
@@ -915,11 +903,9 @@ uno::Reference< drawing::XShape > SwHTMLParser::InsertControl(
}
// set upper/lower border
- if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, true,
- &pItem ) )
+ if( const SvxULSpaceItem *pULItem = rCSS1ItemSet.GetItemIfSet( RES_UL_SPACE ) )
{
// Flatten first line indent
- const SvxULSpaceItem *pULItem = static_cast<const SvxULSpaceItem *>(pItem);
if( rCSS1PropInfo.m_bTopMargin )
{
nUpperSpace = convertTwipToMm100( pULItem->GetUpper() );
@@ -946,11 +932,10 @@ uno::Reference< drawing::XShape > SwHTMLParser::InsertControl(
uno::Reference< beans::XPropertySetInfo > xPropSetInfo =
rFCompPropSet->getPropertySetInfo();
OUString sPropName = "BackgroundColor";
- if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_BACKGROUND, true,
- &pItem ) &&
- xPropSetInfo->hasPropertyByName( sPropName ) )
+ const SvxBrushItem* pBrushItem = rCSS1ItemSet.GetItemIfSet( RES_BACKGROUND );
+ if( pBrushItem && xPropSetInfo->hasPropertyByName( sPropName ) )
{
- const Color &rColor = static_cast<const SvxBrushItem *>(pItem)->GetColor();
+ const Color &rColor = pBrushItem->GetColor();
/// copy color, if color is not "no fill"/"auto fill"
if( rColor != COL_TRANSPARENT )
{
@@ -962,30 +947,24 @@ uno::Reference< drawing::XShape > SwHTMLParser::InsertControl(
}
sPropName = "TextColor";
- if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_CHRATR_COLOR, true,
- &pItem ) &&
- xPropSetInfo->hasPropertyByName( sPropName ) )
+ const SvxColorItem* pColorItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_COLOR );
+ if( pColorItem && xPropSetInfo->hasPropertyByName( sPropName ) )
{
- aTmp <<= static_cast<sal_Int32>(static_cast<const SvxColorItem *>(pItem)->GetValue()
- .GetRGBColor());
+ aTmp <<= static_cast<sal_Int32>(pColorItem->GetValue().GetRGBColor());
rFCompPropSet->setPropertyValue( sPropName, aTmp );
}
sPropName = "FontHeight";
- if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_CHRATR_FONTSIZE,
- true, &pItem ) &&
- xPropSetInfo->hasPropertyByName( sPropName ) )
+ const SvxFontHeightItem* pFontHeightItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_FONTSIZE );
+ if( pFontHeightItem && xPropSetInfo->hasPropertyByName( sPropName ) )
{
- float fVal = static_cast< float >(
- (static_cast<const SvxFontHeightItem *>(pItem)->GetHeight()) / 20.0 );
+ float fVal = static_cast< float >( pFontHeightItem->GetHeight() / 20.0 );
aTmp <<= fVal;
rFCompPropSet->setPropertyValue( sPropName, aTmp );
}
- if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_CHRATR_FONT, true,
- &pItem ) )
+ if( const SvxFontItem* pFontItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_FONT ) )
{
- const SvxFontItem *pFontItem = static_cast<const SvxFontItem *>(pItem);
sPropName = "FontName";
if( xPropSetInfo->hasPropertyByName( sPropName ) )
{
@@ -1019,40 +998,36 @@ uno::Reference< drawing::XShape > SwHTMLParser::InsertControl(
}
sPropName = "FontWeight";
- if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_CHRATR_WEIGHT,
- true, &pItem ) &&
- xPropSetInfo->hasPropertyByName( sPropName ) )
+ const SvxWeightItem* pWeightItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_WEIGHT );
+ if( pWeightItem && xPropSetInfo->hasPropertyByName( sPropName ) )
{
float fVal = vcl::unohelper::ConvertFontWeight(
- static_cast<const SvxWeightItem *>(pItem)->GetWeight() );
+ pWeightItem->GetWeight() );
aTmp <<= fVal;
rFCompPropSet->setPropertyValue( sPropName, aTmp );
}
sPropName = "FontSlant";
- if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_CHRATR_POSTURE,
- true, &pItem ) &&
- xPropSetInfo->hasPropertyByName( sPropName ) )
+ const SvxPostureItem* pPostureItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_POSTURE );
+ if( pPostureItem && xPropSetInfo->hasPropertyByName( sPropName ) )
{
- aTmp <<= static_cast<sal_Int16>(static_cast<const SvxPostureItem *>(pItem)->GetPosture());
+ aTmp <<= static_cast<sal_Int16>(pPostureItem->GetPosture());
rFCompPropSet->setPropertyValue( sPropName, aTmp );
}
sPropName = "FontUnderline";
- if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_CHRATR_UNDERLINE,
- true, &pItem ) &&
- xPropSetInfo->hasPropertyByName( sPropName ) )
+ const SvxUnderlineItem* pUnderlineItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_UNDERLINE );
+ if( pUnderlineItem && xPropSetInfo->hasPropertyByName( sPropName ) )
{
- aTmp <<= static_cast<sal_Int16>(static_cast<const SvxUnderlineItem *>(pItem)->GetLineStyle());
+ aTmp <<= static_cast<sal_Int16>(pUnderlineItem->GetLineStyle());
rFCompPropSet->setPropertyValue( sPropName, aTmp );
}
sPropName = "FontStrikeout";
- if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_CHRATR_CROSSEDOUT,
- true, &pItem ) &&
- xPropSetInfo->hasPropertyByName( sPropName ) )
+ const SvxCrossedOutItem* pCrossedOutItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_CROSSEDOUT );
+ if( pCrossedOutItem && xPropSetInfo->hasPropertyByName( sPropName ) )
{
- aTmp <<= static_cast<sal_Int16>(static_cast<const SvxCrossedOutItem *>(pItem)->GetStrikeout());
+ aTmp <<= static_cast<sal_Int16>(pCrossedOutItem->GetStrikeout());
rFCompPropSet->setPropertyValue( sPropName, aTmp );
}
@@ -1066,7 +1041,7 @@ uno::Reference< drawing::XShape > SwHTMLParser::InsertControl(
SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.m_eTopType )
{
const SwStartNode *pFlySttNd =
- m_pPam->GetPoint()->nNode.GetNode().FindFlyStartNode();
+ m_pPam->GetPoint()->GetNode().FindFlyStartNode();
if( pFlySttNd )
{
@@ -1212,7 +1187,7 @@ void SwHTMLParser::NewForm( bool bAppend )
if( bAppend )
{
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if( m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode( AM_SPACE );
else
AddParSpace();
@@ -1301,18 +1276,22 @@ void SwHTMLParser::NewForm( bool bAppend )
return;
uno::Reference< XInterface > xInt;
+ uno::Reference<XForm> xForm;
try
{
xInt = rSrvcMgr->createInstance("com.sun.star.form.component.Form");
+ if (!xInt.is())
+ return;
+ xForm.set(xInt, UNO_QUERY);
+ SAL_WARN_IF(!xForm.is(), "sw", "no XForm for com.sun.star.form.component.Form?");
+ if (!xForm.is())
+ return;
}
- catch (const css::lang::ServiceNotRegisteredException&)
+ catch (...)
{
- }
- if( !xInt.is() )
+ TOOLS_WARN_EXCEPTION("sw", "");
return;
-
- uno::Reference< XForm > xForm( xInt, UNO_QUERY );
- OSL_ENSURE( xForm.is(), "no Form?" );
+ }
uno::Reference< container::XIndexContainer > xFormComps( xForm, UNO_QUERY );
m_pFormImpl->SetFormComps( xFormComps );
@@ -1371,7 +1350,7 @@ void SwHTMLParser::EndForm( bool bAppend )
{
if( bAppend )
{
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if( m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode( AM_SPACE );
else
AddParSpace();
@@ -1448,7 +1427,7 @@ void SwHTMLParser::InsertInput()
nMaxLen = static_cast<sal_Int16>(rOption.GetNumber());
break;
case HtmlOptionId::SIZE:
- nSize = static_cast<sal_uInt16>(rOption.GetNumber());
+ nSize = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::SRC:
sImgSrc = rOption.GetString();
@@ -1628,7 +1607,7 @@ void SwHTMLParser::InsertInput()
if( bDisabled )
{
- xPropSet->setPropertyValue("Enabled", makeAny(false) );
+ xPropSet->setPropertyValue("Enabled", Any(false) );
}
}
@@ -1673,14 +1652,8 @@ void SwHTMLParser::InsertInput()
case HTMLInputType::Image:
{
// SIZE = WIDTH
- aSz.setWidth( nSize ? nSize : nWidth );
- aSz.setWidth( nWidth );
- aSz.setHeight( nHeight );
- if( (aSz.Width() || aSz.Height()) && Application::GetDefaultDevice() )
- {
- aSz = Application::GetDefaultDevice()
- ->PixelToLogic( aSz, MapMode( MapUnit::Map100thMM ) );
- }
+ aSz.setWidth(o3tl::convert(nWidth, o3tl::Length::px, o3tl::Length::mm100));
+ aSz.setHeight(o3tl::convert(nHeight, o3tl::Length::px, o3tl::Length::mm100));
aTmp <<= FormButtonType_SUBMIT;
xPropSet->setPropertyValue("ButtonType", aTmp );
@@ -1763,15 +1736,9 @@ void SwHTMLParser::InsertInput()
if( bUseSize && nSize>0 )
{
- if( Application::GetDefaultDevice() )
- {
- Size aNewSz( nSize, 0 );
- aNewSz = Application::GetDefaultDevice()
- ->PixelToLogic( aNewSz, MapMode( MapUnit::Map100thMM ) );
- aSz.setWidth( aNewSz.Width() );
- OSL_ENSURE( !aTextSz.Width(), "text width is present" );
- bMinWidth = false;
- }
+ aSz.setWidth(o3tl::convert(nSize, o3tl::Length::px, o3tl::Length::mm100));
+ OSL_ENSURE( !aTextSz.Width(), "text width is present" );
+ bMinWidth = false;
}
SfxItemSet aCSS1ItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
@@ -1907,10 +1874,10 @@ void SwHTMLParser::NewTextArea()
bDisabled = true;
break;
case HtmlOptionId::ROWS:
- nRows = static_cast<sal_uInt16>(rOption.GetNumber());
+ nRows = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::COLS:
- nCols = static_cast<sal_uInt16>(rOption.GetNumber());
+ nCols = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::WRAP:
nWrap = rOption.GetEnum( aHTMLTextAreaWrapTable, nWrap );
@@ -2022,7 +1989,7 @@ void SwHTMLParser::NewTextArea()
if( bDisabled )
{
- xPropSet->setPropertyValue("Enabled", makeAny(false) );
+ xPropSet->setPropertyValue("Enabled", Any(false) );
}
OSL_ENSURE( m_pFormImpl->GetText().isEmpty(), "Text is not empty!" );
@@ -2188,7 +2155,7 @@ void SwHTMLParser::NewSelect()
bDisabled = true;
break;
case HtmlOptionId::SIZE:
- m_nSelectEntryCnt = static_cast<sal_uInt16>(rOption.GetNumber());
+ m_nSelectEntryCnt = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::TABINDEX:
@@ -2279,14 +2246,14 @@ void SwHTMLParser::NewSelect()
if( bDisabled )
{
- xPropSet->setPropertyValue("Enabled", makeAny(false) );
+ xPropSet->setPropertyValue("Enabled", Any(false) );
}
Size aTextSz( 0, 0 );
bool bMinWidth = true, bMinHeight = true;
if( !bMultiple && 1==m_nSelectEntryCnt )
{
- xPropSet->setPropertyValue("Dropdown", makeAny(true) );
+ xPropSet->setPropertyValue("Dropdown", Any(true) );
}
else
{
@@ -2295,7 +2262,7 @@ void SwHTMLParser::NewSelect()
if( bMultiple )
{
- xPropSet->setPropertyValue("MultiSelection", makeAny(true) );
+ xPropSet->setPropertyValue("MultiSelection", Any(true) );
}
aTextSz.setHeight( m_nSelectEntryCnt );
bMinHeight = false;
@@ -2479,7 +2446,7 @@ void SwHTMLParser::InsertSelectText()
{
sal_Int32 nLen = rText.getLength();
if( !nLen || ' '==rText[nLen-1])
- aToken = aToken.replaceAt( 0, 1, "" );
+ aToken.remove( 0, 1 );
}
if( !aToken.isEmpty() )
rText += aToken;
diff --git a/sw/source/filter/html/htmlform.hxx b/sw/source/filter/html/htmlform.hxx
index 0a3f02db47d1..d1acce1faf57 100644
--- a/sw/source/filter/html/htmlform.hxx
+++ b/sw/source/filter/html/htmlform.hxx
@@ -20,8 +20,6 @@
#ifndef INCLUDED_SW_SOURCE_FILTER_HTML_HTMLFORM_HXX
#define INCLUDED_SW_SOURCE_FILTER_HTML_HTMLFORM_HXX
-#include <sal/types.h>
-
extern const char* aEventListenerTable[];
extern const char* aEventMethodTable[];
extern const char* aEventSDOptionTable[];
diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx
index 91262fac3763..6416dfc93cd7 100644
--- a/sw/source/filter/html/htmlforw.cxx
+++ b/sw/source/filter/html/htmlforw.cxx
@@ -31,6 +31,7 @@
#include <hintids.hxx>
#include <o3tl/any.hxx>
#include <rtl/math.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <svl/macitem.hxx>
#include <svtools/htmlout.hxx>
@@ -46,6 +47,7 @@
#include <editeng/postitem.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/crossedoutitem.hxx>
+#include <osl/diagnose.h>
#include <docsh.hxx>
#include <fmtanchr.hxx>
#include <viewsh.hxx>
@@ -78,9 +80,7 @@ const HtmlFrmOpts HTML_FRMOPTS_IMG_CONTROL_CSS1 =
static void lcl_html_outEvents( SvStream& rStrm,
const uno::Reference< form::XFormComponent >& rFormComp,
- bool bCfgStarBasic,
- rtl_TextEncoding eDestEnc,
- OUString *pNonConvertableChars )
+ bool bCfgStarBasic )
{
uno::Reference< uno::XInterface > xParentIfc = rFormComp->getParent();
OSL_ENSURE( xParentIfc.is(), "lcl_html_outEvents: no parent interface" );
@@ -163,10 +163,10 @@ static void lcl_html_outEvents( SvStream& rStrm,
}
}
- OString sOut = " ";
+ OString sOut = " "_ostr;
if( pOpt && (EXTENDED_STYPE != eScriptType ||
rDesc.AddListenerParam.isEmpty()) )
- sOut += OString(pOpt);
+ sOut += pOpt;
else
{
sOut += OOO_STRING_SVTOOLS_HTML_O_sdevent +
@@ -175,7 +175,7 @@ static void lcl_html_outEvents( SvStream& rStrm,
}
sOut += "=\"";
rStrm.WriteOString( sOut );
- HTMLOutFuncs::Out_String( rStrm, rDesc.ScriptCode, eDestEnc, pNonConvertableChars );
+ HTMLOutFuncs::Out_String( rStrm, rDesc.ScriptCode );
rStrm.WriteChar( '\"' );
if( EXTENDED_STYPE == eScriptType &&
!rDesc.AddListenerParam.isEmpty() )
@@ -184,8 +184,7 @@ static void lcl_html_outEvents( SvStream& rStrm,
OUStringToOString(sListener, RTL_TEXTENCODING_ASCII_US) + "-" +
OUStringToOString(sMethod, RTL_TEXTENCODING_ASCII_US) + "=\"";
rStrm.WriteOString( sOut );
- HTMLOutFuncs::Out_String( rStrm, rDesc.AddListenerParam,
- eDestEnc, pNonConvertableChars );
+ HTMLOutFuncs::Out_String( rStrm, rDesc.AddListenerParam );
rStrm.WriteChar( '\"' );
}
}
@@ -213,7 +212,7 @@ static bool lcl_html_isHTMLControl( sal_Int16 nClassId )
bool SwHTMLWriter::HasControls() const
{
- sal_uInt32 nStartIdx = m_pCurrentPam->GetPoint()->nNode.GetIndex();
+ SwNodeOffset nStartIdx = m_pCurrentPam->GetPoint()->GetNodeIndex();
size_t i = 0;
// Skip all controls in front of the current paragraph
@@ -241,8 +240,8 @@ void SwHTMLWriter::OutForm( bool bTag_On, const SwStartNode *pStartNd )
}
uno::Reference< container::XIndexContainer > xNewFormComps;
- sal_uInt32 nStartIdx = pStartNd ? pStartNd->GetIndex()
- : m_pCurrentPam->GetPoint()->nNode.GetIndex();
+ SwNodeOffset nStartIdx = pStartNd ? pStartNd->GetIndex()
+ : m_pCurrentPam->GetPoint()->GetNodeIndex();
// skip controls before the interesting area
size_t i = 0;
@@ -266,7 +265,7 @@ void SwHTMLWriter::OutForm( bool bTag_On, const SwStartNode *pStartNd )
uno::Reference< container::XIndexContainer > xCurrentFormComps;// current form in table
const SwStartNode *pCurrentStNd = nullptr; // and the start node of a Control
sal_Int32 nCurrentCtrls = 0; // and the found controls in it
- sal_uInt32 nEndIdx = pStartNd->EndOfSectionIndex();
+ SwNodeOffset nEndIdx = pStartNd->EndOfSectionIndex();
for( ; i < m_aHTMLControls.size() &&
m_aHTMLControls[i]->nNdIdx <= nEndIdx; i++ )
{
@@ -434,16 +433,16 @@ void SwHTMLWriter::OutForm( bool bOn,
if( !bOn )
{
DecIndentLevel(); // indent content of form
- if( m_bLFPossible )
+ if (IsLFPossible())
OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_form, false );
- m_bLFPossible = true;
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_form), false );
+ SetLFPossible(true);
return;
}
// the new form is opened
- if( m_bLFPossible )
+ if (IsLFPossible())
OutNewLine();
OString sOut = "<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_form;
@@ -456,9 +455,8 @@ void SwHTMLWriter::OutForm( bool bOn,
{
sOut += " " OOO_STRING_SVTOOLS_HTML_O_name "=\"";
Strm().WriteOString( sOut );
- HTMLOutFuncs::Out_String( Strm(), *s,
- m_eDestEnc, &m_aNonConvertableCharacters );
- sOut = "\"";
+ HTMLOutFuncs::Out_String( Strm(), *s );
+ sOut = "\""_ostr;
}
}
@@ -471,8 +469,8 @@ void SwHTMLWriter::OutForm( bool bOn,
Strm().WriteOString( sOut );
OUString aURL
= URIHelper::simpleNormalizedMakeRelative( GetBaseURL(), *s);
- HTMLOutFuncs::Out_String( Strm(), aURL, m_eDestEnc, &m_aNonConvertableCharacters );
- sOut = "\"";
+ HTMLOutFuncs::Out_String( Strm(), aURL );
+ sOut = "\""_ostr;
}
}
@@ -503,7 +501,7 @@ void SwHTMLWriter::OutForm( bool bOn,
if( pStr )
{
- sOut += OStringLiteral(" " OOO_STRING_SVTOOLS_HTML_O_enctype "=\"") +
+ sOut += OString::Concat(" " OOO_STRING_SVTOOLS_HTML_O_enctype "=\"") +
pStr + "\"";
}
}
@@ -515,19 +513,18 @@ void SwHTMLWriter::OutForm( bool bOn,
{
sOut += " " OOO_STRING_SVTOOLS_HTML_O_target "=\"";
Strm().WriteOString( sOut );
- HTMLOutFuncs::Out_String( Strm(), *s,
- m_eDestEnc, &m_aNonConvertableCharacters );
- sOut = "\"";
+ HTMLOutFuncs::Out_String( Strm(), *s );
+ sOut = "\""_ostr;
}
}
Strm().WriteOString( sOut );
uno::Reference< form::XFormComponent > xFormComp( rFormComps, uno::UNO_QUERY );
- lcl_html_outEvents( Strm(), xFormComp, m_bCfgStarBasic, m_eDestEnc, &m_aNonConvertableCharacters );
+ lcl_html_outEvents( Strm(), xFormComp, m_bCfgStarBasic );
Strm().WriteChar( '>' );
IncIndentLevel(); // indent content of form
- m_bLFPossible = true;
+ SetLFPossible(true);
}
void SwHTMLWriter::OutHiddenControls(
@@ -572,7 +569,7 @@ void SwHTMLWriter::OutHiddenControls(
if( form::FormComponentType::HIDDENCONTROL == *n )
{
- if( m_bLFPossible )
+ if (IsLFPossible())
OutNewLine( true );
OString sOut = "<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_input " "
OOO_STRING_SVTOOLS_HTML_O_type "=\""
@@ -585,9 +582,8 @@ void SwHTMLWriter::OutHiddenControls(
{
sOut += " " OOO_STRING_SVTOOLS_HTML_O_name "=\"";
Strm().WriteOString( sOut );
- HTMLOutFuncs::Out_String( Strm(), *s,
- m_eDestEnc, &m_aNonConvertableCharacters );
- sOut = "\"";
+ HTMLOutFuncs::Out_String( Strm(), *s );
+ sOut = "\""_ostr;
}
}
aTmp = xPropSet->getPropertyValue( "HiddenValue" );
@@ -597,9 +593,8 @@ void SwHTMLWriter::OutHiddenControls(
{
sOut += " " OOO_STRING_SVTOOLS_HTML_O_value "=\"";
Strm().WriteOString( sOut );
- HTMLOutFuncs::Out_String( Strm(), *s,
- m_eDestEnc, &m_aNonConvertableCharacters );
- sOut = "\"";
+ HTMLOutFuncs::Out_String( Strm(), *s );
+ sOut = "\""_ostr;
}
}
sOut += ">";
@@ -663,7 +658,7 @@ static void GetControlSize(const SdrUnoObj& rFormObj, Size& rSz, SwDoc *pDoc)
SdrView* pDrawView = pVSh->GetDrawView();
OSL_ENSURE( pDrawView && pVSh->GetWin(), "no DrawView or window!" );
if ( pDrawView && pVSh->GetWin() )
- xControl = rFormObj.GetUnoControl( *pDrawView, *pVSh->GetWin() );
+ xControl = rFormObj.GetUnoControl( *pDrawView, *pVSh->GetWin()->GetOutDev() );
uno::Reference< awt::XTextLayoutConstrains > xLC( xControl, uno::UNO_QUERY );
OSL_ENSURE( xLC.is(), "no XTextLayoutConstrains" );
if( !xLC.is() )
@@ -675,7 +670,7 @@ static void GetControlSize(const SdrUnoObj& rFormObj, Size& rSz, SwDoc *pDoc)
rSz.setHeight( nLines );
}
-Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
+SwHTMLWriter& OutHTML_DrawFrameFormatAsControl( SwHTMLWriter& rWrt,
const SwDrawFrameFormat& rFormat,
const SdrUnoObj& rFormObj,
bool bInCntnr )
@@ -691,8 +686,7 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
uno::Reference< beans::XPropertySetInfo > xPropSetInfo =
xPropSet->getPropertySetInfo();
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- rHTMLWrt.m_nFormCntrlCnt++;
+ rWrt.m_nFormCntrlCnt++;
enum Tag { TAG_INPUT, TAG_SELECT, TAG_TEXTAREA, TAG_NONE };
static char const * const TagNames[] = {
@@ -775,8 +769,8 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
break;
case form::FormComponentType::LISTBOX:
- if( rHTMLWrt.m_bLFPossible )
- rHTMLWrt.OutNewLine( true );
+ if (rWrt.IsLFPossible())
+ rWrt.OutNewLine( true );
eTag = TAG_SELECT;
aTmp = xPropSet->getPropertyValue( "Dropdown" );
if( auto b1 = o3tl::tryAccess<bool>(aTmp) )
@@ -815,14 +809,14 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
if( xPropSetInfo->hasPropertyByName( sMultiLine ) )
{
aTmp = xPropSet->getPropertyValue( sMultiLine );
- auto b = o3tl::tryAccess<bool>(aTmp);
- bMultiLine = b && *b;
+ std::optional<const bool> b = o3tl::tryAccess<bool>(aTmp);
+ bMultiLine = b.has_value() && *b;
}
if( bMultiLine )
{
- if( rHTMLWrt.m_bLFPossible )
- rHTMLWrt.OutNewLine( true );
+ if (rWrt.IsLFPossible())
+ rWrt.OutNewLine( true );
eTag = TAG_TEXTAREA;
if( aSz.Height() )
@@ -843,10 +837,10 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
{
const char *pWrapStr = nullptr;
auto aTmp2 = xPropSet->getPropertyValue( "HardLineBreaks" );
- auto b = o3tl::tryAccess<bool>(aTmp2);
- pWrapStr = (b && *b) ? OOO_STRING_SVTOOLS_HTML_WW_hard
+ std::optional<const bool> b = o3tl::tryAccess<bool>(aTmp2);
+ pWrapStr = (b.has_value() && *b) ? OOO_STRING_SVTOOLS_HTML_WW_hard
: OOO_STRING_SVTOOLS_HTML_WW_soft;
- sOptions += OStringLiteral(" " OOO_STRING_SVTOOLS_HTML_O_wrap "=\"") +
+ sOptions += OString::Concat(" " OOO_STRING_SVTOOLS_HTML_O_wrap "=\"") +
pWrapStr + "\"";
}
}
@@ -924,10 +918,10 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
if( eTag == TAG_NONE )
return rWrt;
- OString sOut = OStringLiteral("<") + TagNames[eTag];
+ OString sOut = OString::Concat("<") + TagNames[eTag];
if( eType != TYPE_NONE )
{
- sOut += OStringLiteral(" " OOO_STRING_SVTOOLS_HTML_O_type "=\"") +
+ sOut += OString::Concat(" " OOO_STRING_SVTOOLS_HTML_O_type "=\"") +
TypeNames[eType] + "\"";
}
@@ -938,9 +932,8 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
{
sOut += " " OOO_STRING_SVTOOLS_HTML_O_name "=\"";
rWrt.Strm().WriteOString( sOut );
- HTMLOutFuncs::Out_String( rWrt.Strm(), *s,
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
- sOut = "\"";
+ HTMLOutFuncs::Out_String( rWrt.Strm(), *s );
+ sOut = "\""_ostr;
}
}
@@ -957,8 +950,8 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
{
sOut += " " OOO_STRING_SVTOOLS_HTML_O_value "=\"";
rWrt.Strm().WriteOString( sOut );
- HTMLOutFuncs::Out_String( rWrt.Strm(), sValue, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
- sOut = "\"";
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sValue );
+ sOut = "\""_ostr;
}
sOut += " " + sOptions;
@@ -974,25 +967,12 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
rWrt.Strm().WriteOString( sOut );
HTMLOutFuncs::Out_String( rWrt.Strm(),
- URIHelper::simpleNormalizedMakeRelative( rWrt.GetBaseURL(), *s),
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
- sOut = "\"";
+ URIHelper::simpleNormalizedMakeRelative( rWrt.GetBaseURL(), *s) );
+ sOut = "\""_ostr;
}
}
- Size aTwipSz( rFormObj.GetLogicRect().GetSize() );
- Size aPixelSz( 0, 0 );
- if( (aTwipSz.Width() || aTwipSz.Height()) &&
- Application::GetDefaultDevice() )
- {
- aPixelSz =
- Application::GetDefaultDevice()->LogicToPixel( aTwipSz,
- MapMode(MapUnit::MapTwip) );
- if( !aPixelSz.Width() && aTwipSz.Width() )
- aPixelSz.setWidth( 1 );
- if( !aPixelSz.Height() && aTwipSz.Height() )
- aPixelSz.setHeight( 1 );
- }
+ Size aPixelSz(SwHTMLWriter::ToPixel(rFormObj.GetLogicRect().GetSize()));
if( aPixelSz.Width() )
{
@@ -1025,7 +1005,7 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
rWrt.Strm().WriteOString( sOut );
OSL_ENSURE( !bInCntnr, "Container is not supported for Controls" );
- if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) && !bInCntnr )
+ if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) && !bInCntnr )
{
// If Character-Objects can't be positioned absolutely,
// then delete the corresponding flag.
@@ -1035,15 +1015,14 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
}
OString aEndTags;
if( nFrameOpts != HtmlFrmOpts::NONE )
- aEndTags = rHTMLWrt.OutFrameFormatOptions(rFormat, OUString(), nFrameOpts);
+ aEndTags = rWrt.OutFrameFormatOptions(rFormat, u"", nFrameOpts);
- if( rHTMLWrt.m_bCfgOutStyles )
+ if( rWrt.m_bCfgOutStyles )
{
bool bEdit = TAG_TEXTAREA == eTag || TYPE_FILE == eType ||
TYPE_TEXT == eType;
- SfxItemSet aItemSet( rHTMLWrt.m_pDoc->GetAttrPool(), svl::Items<RES_CHRATR_BEGIN,
- RES_CHRATR_END>{} );
+ SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END> aItemSet( rWrt.m_pDoc->GetAttrPool() );
if( xPropSetInfo->hasPropertyByName( "BackgroundColor" ) )
{
aTmp = xPropSet->getPropertyValue( "BackgroundColor" );
@@ -1141,13 +1120,12 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
}
}
- rHTMLWrt.OutCSS1_FrameFormatOptions( rFormat, nFrameOpts, &rFormObj,
+ rWrt.OutCSS1_FrameFormatOptions( rFormat, nFrameOpts, &rFormObj,
&aItemSet );
}
uno::Reference< form::XFormComponent > xFormComp( xControlModel, uno::UNO_QUERY );
- lcl_html_outEvents( rWrt.Strm(), xFormComp, rHTMLWrt.m_bCfgStarBasic,
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ lcl_html_outEvents( rWrt.Strm(), xFormComp, rWrt.m_bCfgStarBasic );
rWrt.Strm().WriteChar( '>' );
@@ -1156,7 +1134,7 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
aTmp = xPropSet->getPropertyValue( "StringItemList" );
if( auto aList = o3tl::tryAccess<uno::Sequence<OUString>>(aTmp) )
{
- rHTMLWrt.IncIndentLevel(); // the content of Select can be indented
+ rWrt.IncIndentLevel(); // the content of Select can be indented
sal_Int32 nCnt = aList->getLength();
const OUString *pStrings = aList->getConstArray();
@@ -1200,15 +1178,14 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
if( bSelected )
nSel++;
- rHTMLWrt.OutNewLine(); // every Option gets its own line
- sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_option;
+ rWrt.OutNewLine(); // every Option gets its own line
+ sOut = "<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_option;
if( !sVal.isEmpty() || bEmptyVal )
{
sOut += " " OOO_STRING_SVTOOLS_HTML_O_value "=\"";
rWrt.Strm().WriteOString( sOut );
- HTMLOutFuncs::Out_String( rWrt.Strm(), sVal,
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
- sOut = "\"";
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sVal );
+ sOut = "\""_ostr;
}
if( bSelected )
sOut += " " OOO_STRING_SVTOOLS_HTML_O_selected;
@@ -1216,15 +1193,14 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
sOut += ">";
rWrt.Strm().WriteOString( sOut );
- HTMLOutFuncs::Out_String( rWrt.Strm(), pStrings[i],
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), pStrings[i] );
}
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_option, false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_option), false );
- rHTMLWrt.DecIndentLevel();
- rHTMLWrt.OutNewLine();// the </SELECT> gets its own line
+ rWrt.DecIndentLevel();
+ rWrt.OutNewLine();// the </SELECT> gets its own line
}
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_select, false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_select), false );
}
else if( TAG_TEXTAREA == eTag )
{
@@ -1245,13 +1221,12 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
while ( nPos != -1 )
{
if( nPos )
- rWrt.Strm().WriteCharPtr( SAL_NEWLINE_STRING );
+ rWrt.Strm().WriteOString( SAL_NEWLINE_STRING );
OUString aLine = sVal.getToken( 0, 0x0A, nPos );
- HTMLOutFuncs::Out_String( rWrt.Strm(), aLine,
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aLine );
}
}
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_textarea, false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_textarea), false );
}
else if( TYPE_CHECKBOX == eType || TYPE_RADIO == eType )
{
@@ -1260,8 +1235,7 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
{
if( !s->isEmpty() )
{
- HTMLOutFuncs::Out_String( rWrt.Strm(), *s,
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters ).WriteChar( ' ' );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), *s ).WriteChar( ' ' );
}
}
}
@@ -1270,10 +1244,10 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
rWrt.Strm().WriteOString( aEndTags );
// Controls aren't bound to a paragraph, therefore don't output LF anymore!
- rHTMLWrt.m_bLFPossible = false;
+ rWrt.SetLFPossible(false);
- if( rHTMLWrt.mxFormComps.is() )
- rHTMLWrt.OutHiddenControls( rHTMLWrt.mxFormComps, xPropSet );
+ if( rWrt.mxFormComps.is() )
+ rWrt.OutHiddenControls( rWrt.mxFormComps, xPropSet );
return rWrt;
}
@@ -1282,7 +1256,7 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
*/
static void AddControl( HTMLControls& rControls,
const SdrUnoObj& rFormObj,
- sal_uInt32 nNodeIdx )
+ SwNodeOffset nNodeIdx )
{
const uno::Reference< awt::XControlModel >& xControlModel =
rFormObj.GetUnoControlModel();
@@ -1315,51 +1289,46 @@ void SwHTMLWriter::GetControls()
// With that array it's possible to find out where form::Forms must be
// opened and closed.
- if( m_pHTMLPosFlyFrames )
+ // collect the paragraph-bound controls
+ for( size_t i=0; i<m_aHTMLPosFlyFrames.size(); i++ )
{
- // collect the paragraph-bound controls
- for( size_t i=0; i<m_pHTMLPosFlyFrames->size(); i++ )
- {
- const SwHTMLPosFlyFrame* pPosFlyFrame = (*m_pHTMLPosFlyFrames)[ i ].get();
- if( HtmlOut::Control != pPosFlyFrame->GetOutFn() )
- continue;
+ const SwHTMLPosFlyFrame* pPosFlyFrame = m_aHTMLPosFlyFrames[ i ].get();
+ if( HtmlOut::Control != pPosFlyFrame->GetOutFn() )
+ continue;
- const SdrObject *pSdrObj = pPosFlyFrame->GetSdrObject();
- OSL_ENSURE( pSdrObj, "Where is the SdrObject?" );
- if( !pSdrObj )
- continue;
+ const SdrObject *pSdrObj = pPosFlyFrame->GetSdrObject();
+ OSL_ENSURE( pSdrObj, "Where is the SdrObject?" );
+ if( !pSdrObj )
+ continue;
- AddControl( m_aHTMLControls, dynamic_cast<const SdrUnoObj&>(*pSdrObj),
- pPosFlyFrame->GetNdIndex().GetIndex() );
- }
+ AddControl( m_aHTMLControls, dynamic_cast<const SdrUnoObj&>(*pSdrObj),
+ pPosFlyFrame->GetNdIndex().GetIndex() );
}
// and now the ones in a character-bound frame
- const SwFrameFormats* pSpzFrameFormats = m_pDoc->GetSpzFrameFormats();
- for( size_t i=0; i<pSpzFrameFormats->size(); i++ )
+ for(sw::SpzFrameFormat* pSpz: *m_pDoc->GetSpzFrameFormats())
{
- const SwFrameFormat *pFrameFormat = (*pSpzFrameFormats)[i];
- if( RES_DRAWFRMFMT != pFrameFormat->Which() )
+ if( RES_DRAWFRMFMT != pSpz->Which() )
continue;
- const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor();
- const SwPosition *pPos = rAnchor.GetContentAnchor();
- if ((RndStdIds::FLY_AS_CHAR != rAnchor.GetAnchorId()) || !pPos)
+ const SwFormatAnchor& rAnchor = pSpz->GetAnchor();
+ const SwNode *pAnchorNode = rAnchor.GetAnchorNode();
+ if ((RndStdIds::FLY_AS_CHAR != rAnchor.GetAnchorId()) || !pAnchorNode)
continue;
const SdrObject *pSdrObj =
- SwHTMLWriter::GetHTMLControl( *static_cast<const SwDrawFrameFormat*>(pFrameFormat) );
+ SwHTMLWriter::GetHTMLControl(*static_cast<SwDrawFrameFormat*>(pSpz) );
if( !pSdrObj )
continue;
- AddControl( m_aHTMLControls, dynamic_cast<const SdrUnoObj&>(*pSdrObj), pPos->nNode.GetIndex() );
+ AddControl( m_aHTMLControls, dynamic_cast<const SdrUnoObj&>(*pSdrObj), pAnchorNode->GetIndex() );
}
}
HTMLControl::HTMLControl(
- const uno::Reference< container::XIndexContainer > & rFormComps,
- sal_uInt32 nIdx ) :
- xFormComps( rFormComps ), nNdIdx( nIdx ), nCount( 1 )
+ uno::Reference< container::XIndexContainer > _xFormComps,
+ SwNodeOffset nIdx ) :
+ xFormComps(std::move( _xFormComps )), nNdIdx( nIdx ), nCount( 1 )
{}
HTMLControl::~HTMLControl()
diff --git a/sw/source/filter/html/htmlftn.cxx b/sw/source/filter/html/htmlftn.cxx
index cec1d3df6326..74916af9c705 100644
--- a/sw/source/filter/html/htmlftn.cxx
+++ b/sw/source/filter/html/htmlftn.cxx
@@ -17,9 +17,14 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <string_view>
+
#include <osl/diagnose.h>
#include <svtools/htmlout.hxx>
#include <svtools/htmlkywd.hxx>
+#include <svtools/HtmlWriter.hxx>
#include <rtl/strbuf.hxx>
#include <ndindex.hxx>
#include <fmtftn.hxx>
@@ -32,11 +37,11 @@
#include "swhtml.hxx"
#include "wrthtml.hxx"
-static sal_Int32 lcl_html_getNextPart( OUString& rPart, const OUString& rContent,
+static sal_Int32 lcl_html_getNextPart( OUString& rPart, std::u16string_view aContent,
sal_Int32 nPos )
{
rPart.clear();
- sal_Int32 nLen = rContent.getLength();
+ sal_Int32 nLen = aContent.size();
if( nPos >= nLen )
{
nPos = -1;
@@ -46,7 +51,7 @@ static sal_Int32 lcl_html_getNextPart( OUString& rPart, const OUString& rContent
bool bQuoted = false, bDone = false;
for( ; nPos < nLen && !bDone; nPos++ )
{
- sal_Unicode c = rContent[nPos];
+ sal_Unicode c = aContent[nPos];
switch( c )
{
case '\\':
@@ -75,7 +80,7 @@ static sal_Int32 lcl_html_getNextPart( OUString& rPart, const OUString& rContent
}
static sal_Int32 lcl_html_getEndNoteInfo( SwEndNoteInfo& rInfo,
- const OUString& rContent,
+ std::u16string_view aContent,
bool bEndNote )
{
sal_Int32 nStrPos = 0;
@@ -83,7 +88,7 @@ static sal_Int32 lcl_html_getEndNoteInfo( SwEndNoteInfo& rInfo,
{
OUString aPart;
if( -1 != nStrPos )
- nStrPos = lcl_html_getNextPart( aPart, rContent, nStrPos );
+ nStrPos = lcl_html_getNextPart( aPart, aContent, nStrPos );
switch( nPart )
{
@@ -95,7 +100,7 @@ static sal_Int32 lcl_html_getEndNoteInfo( SwEndNoteInfo& rInfo,
break;
case 1:
- rInfo.m_nFootnoteOffset = aPart.isEmpty() ? 0 : static_cast<sal_uInt16>(aPart.toInt32());
+ rInfo.m_nFootnoteOffset = aPart.isEmpty() ? 0 : o3tl::narrowing<sal_uInt16>(aPart.toInt32());
break;
case 2:
@@ -111,24 +116,24 @@ static sal_Int32 lcl_html_getEndNoteInfo( SwEndNoteInfo& rInfo,
return nStrPos;
}
-void SwHTMLParser::FillEndNoteInfo( const OUString& rContent )
+void SwHTMLParser::FillEndNoteInfo( std::u16string_view aContent )
{
SwEndNoteInfo aInfo( m_xDoc->GetEndNoteInfo() );
- lcl_html_getEndNoteInfo( aInfo, rContent, true );
+ lcl_html_getEndNoteInfo( aInfo, aContent, true );
m_xDoc->SetEndNoteInfo( aInfo );
}
-void SwHTMLParser::FillFootNoteInfo( const OUString& rContent )
+void SwHTMLParser::FillFootNoteInfo( std::u16string_view aContent )
{
SwFootnoteInfo aInfo( m_xDoc->GetFootnoteInfo() );
- sal_Int32 nStrPos = lcl_html_getEndNoteInfo( aInfo, rContent, false );
+ sal_Int32 nStrPos = lcl_html_getEndNoteInfo( aInfo, aContent, false );
for( int nPart = 4; nPart < 8; ++nPart )
{
OUString aPart;
if( -1 != nStrPos )
- nStrPos = lcl_html_getNextPart( aPart, rContent, nStrPos );
+ nStrPos = lcl_html_getNextPart( aPart, aContent, nStrPos );
switch( nPart )
{
@@ -196,11 +201,11 @@ void SwHTMLParser::FinishFootEndNote()
m_xDoc->getIDocumentContentOperations().InsertPoolItem( *m_pPam, aFootnote );
SwTextFootnote * const pTextFootnote = static_cast<SwTextFootnote *>(
- m_pPam->GetNode().GetTextNode()->GetTextAttrForCharAt(
- m_pPam->GetPoint()->nContent.GetIndex() - 1, RES_TXTATR_FTN ) );
+ m_pPam->GetPointNode().GetTextNode()->GetTextAttrForCharAt(
+ m_pPam->GetPoint()->GetContentIndex() - 1, RES_TXTATR_FTN ) );
// In header and footer no footnotes can be inserted.
if (pTextFootnote)
- m_pFootEndNoteImpl->aTextFootnotes.push_back(SwHTMLTextFootnote(m_pFootEndNoteImpl->sName,pTextFootnote));
+ m_pFootEndNoteImpl->aTextFootnotes.emplace_back(m_pFootEndNoteImpl->sName,pTextFootnote);
m_pFootEndNoteImpl->sName.clear();
m_pFootEndNoteImpl->sContent.clear();
m_pFootEndNoteImpl->bFixed = false;
@@ -223,9 +228,9 @@ SwNodeIndex *SwHTMLParser::GetFootEndNoteSection( const OUString& rName )
size_t nCount = m_pFootEndNoteImpl->aTextFootnotes.size();
for(size_t i = 0; i < nCount; ++i)
{
- if (m_pFootEndNoteImpl->aTextFootnotes[i].sName == aName)
+ if (m_pFootEndNoteImpl->aTextFootnotes[i].GetName() == aName)
{
- pStartNodeIdx = m_pFootEndNoteImpl->aTextFootnotes[i].pTextFootnote->GetStartNode();
+ pStartNodeIdx = const_cast<SwNodeIndex*>(m_pFootEndNoteImpl->aTextFootnotes[i].GetStartNode());
m_pFootEndNoteImpl->aTextFootnotes.erase( m_pFootEndNoteImpl->aTextFootnotes.begin() + i );
if (m_pFootEndNoteImpl->aTextFootnotes.empty())
{
@@ -240,10 +245,33 @@ SwNodeIndex *SwHTMLParser::GetFootEndNoteSection( const OUString& rName )
return pStartNodeIdx;
}
-Writer& OutHTML_SwFormatFootnote( Writer& rWrt, const SfxPoolItem& rHt )
+SwHTMLWriter& OutHTML_SwFormatLineBreak(SwHTMLWriter& rWrt, const SfxPoolItem& rHt)
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
+ const auto& rLineBreak = static_cast<const SwFormatLineBreak&>(rHt);
+ HtmlWriter aWriter(rWrt.Strm(), rWrt.maNamespace);
+ aWriter.start(OOO_STRING_SVTOOLS_HTML_linebreak ""_ostr);
+ switch (rLineBreak.GetValue())
+ {
+ case SwLineBreakClear::NONE:
+ aWriter.attribute(OOO_STRING_SVTOOLS_HTML_O_clear, "none");
+ break;
+ case SwLineBreakClear::LEFT:
+ aWriter.attribute(OOO_STRING_SVTOOLS_HTML_O_clear, "left");
+ break;
+ case SwLineBreakClear::RIGHT:
+ aWriter.attribute(OOO_STRING_SVTOOLS_HTML_O_clear, "right");
+ break;
+ case SwLineBreakClear::ALL:
+ aWriter.attribute(OOO_STRING_SVTOOLS_HTML_O_clear, "all");
+ break;
+ }
+ aWriter.end();
+ return rWrt;
+}
+
+SwHTMLWriter& OutHTML_SwFormatFootnote( SwHTMLWriter& rWrt, const SfxPoolItem& rHt )
+{
SwFormatFootnote& rFormatFootnote = const_cast<SwFormatFootnote&>(static_cast<const SwFormatFootnote&>(rHt));
SwTextFootnote *pTextFootnote = rFormatFootnote.GetTextFootnote();
if( !pTextFootnote )
@@ -253,55 +281,58 @@ Writer& OutHTML_SwFormatFootnote( Writer& rWrt, const SfxPoolItem& rHt )
size_t nPos;
if( rFormatFootnote.IsEndNote() )
{
- nPos = rHTMLWrt.m_pFootEndNotes ? rHTMLWrt.m_pFootEndNotes->size() : 0;
- OSL_ENSURE( nPos == static_cast<size_t>(rHTMLWrt.m_nFootNote + rHTMLWrt.m_nEndNote),
+ nPos = rWrt.m_xFootEndNotes ? rWrt.m_xFootEndNotes->size() : 0;
+ OSL_ENSURE( nPos == static_cast<size_t>(rWrt.m_nFootNote + rWrt.m_nEndNote),
"OutHTML_SwFormatFootnote: wrong position" );
sClass = OOO_STRING_SVTOOLS_HTML_sdendnote_anc;
- sFootnoteName = OOO_STRING_SVTOOLS_HTML_sdendnote + OUString::number( static_cast<sal_Int32>(++rHTMLWrt.m_nEndNote) );
+ sFootnoteName = OOO_STRING_SVTOOLS_HTML_sdendnote + OUString::number( static_cast<sal_Int32>(++rWrt.m_nEndNote) );
}
else
{
- nPos = rHTMLWrt.m_nFootNote;
+ nPos = rWrt.m_nFootNote;
sClass = OOO_STRING_SVTOOLS_HTML_sdfootnote_anc;
- sFootnoteName = OOO_STRING_SVTOOLS_HTML_sdfootnote + OUString::number( static_cast<sal_Int32>(++rHTMLWrt.m_nFootNote));
+ sFootnoteName = OOO_STRING_SVTOOLS_HTML_sdfootnote + OUString::number( static_cast<sal_Int32>(++rWrt.m_nFootNote));
}
- if( !rHTMLWrt.m_pFootEndNotes )
- rHTMLWrt.m_pFootEndNotes.reset(new std::vector<SwTextFootnote*>);
- rHTMLWrt.m_pFootEndNotes->insert( rHTMLWrt.m_pFootEndNotes->begin() + nPos, pTextFootnote );
+ if( !rWrt.m_xFootEndNotes )
+ rWrt.m_xFootEndNotes.emplace();
+ rWrt.m_xFootEndNotes->insert( rWrt.m_xFootEndNotes->begin() + nPos, pTextFootnote );
OStringBuffer sOut;
- OString aTag = rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor;
+ OString aTag = rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor;
sOut.append("<" + aTag + " " OOO_STRING_SVTOOLS_HTML_O_class "=\"");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( rWrt.Strm(), sClass, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sClass );
sOut.append("\" " OOO_STRING_SVTOOLS_HTML_O_name "=\"");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( rWrt.Strm(), sFootnoteName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sFootnoteName );
sOut.append(OOO_STRING_SVTOOLS_HTML_FTN_anchor "\" "
OOO_STRING_SVTOOLS_HTML_O_href "=\"#");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( rWrt.Strm(), sFootnoteName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sFootnoteName );
sOut.append(OOO_STRING_SVTOOLS_HTML_FTN_symbol "\"");
if( !rFormatFootnote.GetNumStr().isEmpty() )
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_sdfixed);
sOut.append(">");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_superscript );
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_superscript ));
- HTMLOutFuncs::Out_String( rWrt.Strm(), rFormatFootnote.GetViewNumStr(*rWrt.m_pDoc, nullptr),
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_superscript, false );
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor, false );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rFormatFootnote.GetViewNumStr(*rWrt.m_pDoc, nullptr) );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_superscript), false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor), false );
return rWrt;
}
void SwHTMLWriter::OutFootEndNotes()
{
- OSL_ENSURE( m_pFootEndNotes,
+ OSL_ENSURE( m_xFootEndNotes,
"SwHTMLWriter::OutFootEndNotes(): unnecessary call" );
- if( !m_pFootEndNotes )
+ if( !m_xFootEndNotes )
return;
#if OSL_DEBUG_LEVEL > 0
@@ -310,7 +341,7 @@ void SwHTMLWriter::OutFootEndNotes()
m_nFootNote = 0;
m_nEndNote = 0;
- for( auto *pTextFootnote : *m_pFootEndNotes )
+ for( auto *pTextFootnote : *m_xFootEndNotes )
{
m_pFormatFootnote = &pTextFootnote->GetFootnote();
@@ -324,20 +355,20 @@ void SwHTMLWriter::OutFootEndNotes()
sFootnoteName = OOO_STRING_SVTOOLS_HTML_sdfootnote + OUString::number(static_cast<sal_Int32>(++m_nFootNote));
}
- if( m_bLFPossible )
+ if (IsLFPossible())
OutNewLine();
OString sOut =
"<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_division
" " OOO_STRING_SVTOOLS_HTML_O_id "=\"";
Strm().WriteOString( sOut );
- HTMLOutFuncs::Out_String( Strm(), sFootnoteName, m_eDestEnc, &m_aNonConvertableCharacters );
- Strm().WriteCharPtr( "\">" );
+ HTMLOutFuncs::Out_String( Strm(), sFootnoteName );
+ Strm().WriteOString( "\">" );
- m_bLFPossible = true;
+ SetLFPossible(true);
IncIndentLevel(); // indent content of <DIV>
OSL_ENSURE( pTextFootnote, "SwHTMLWriter::OutFootEndNotes: SwTextFootnote is missing" );
- SwNodeIndex *pSttNdIdx = pTextFootnote->GetStartNode();
+ const SwNodeIndex *pSttNdIdx = pTextFootnote->GetStartNode();
OSL_ENSURE( pSttNdIdx,
"SwHTMLWriter::OutFootEndNotes: StartNode-Index is missing" );
if( pSttNdIdx )
@@ -348,10 +379,10 @@ void SwHTMLWriter::OutFootEndNotes()
}
DecIndentLevel(); // indent content of <DIV>
- if( m_bLFPossible )
+ if (IsLFPossible())
OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_division, false );
- m_bLFPossible = true;
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_division), false );
+ SetLFPossible(true);
OSL_ENSURE( !m_pFormatFootnote,
"SwHTMLWriter::OutFootEndNotes: Footnote was not output" );
@@ -373,7 +404,7 @@ void SwHTMLWriter::OutFootEndNotes()
"SwHTMLWriter::OutFootEndNotes: Number of endnotes does not match" );
#endif
- m_pFootEndNotes.reset();
+ m_xFootEndNotes.reset();
m_nFootNote = m_nEndNote = 0;
}
@@ -395,7 +426,7 @@ OUString SwHTMLWriter::GetFootEndNoteSym( const SwFormatFootnote& rFormatFootnot
}
void SwHTMLWriter::OutFootEndNoteSym( const SwFormatFootnote& rFormatFootnote,
- const OUString& rNum,
+ std::u16string_view rNum,
sal_uInt16 nScript )
{
const SwEndNoteInfo *pInfo;
@@ -433,23 +464,27 @@ void SwHTMLWriter::OutFootEndNoteSym( const SwFormatFootnote& rFormatFootnote,
}
}
- OStringBuffer sOut;
- sOut.append('<').append(GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor).append(' ')
- .append(OOO_STRING_SVTOOLS_HTML_O_class).append("=\"");
- Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( Strm(), sClass, m_eDestEnc, &m_aNonConvertableCharacters );
- sOut.append("\" ").append(OOO_STRING_SVTOOLS_HTML_O_name).append("=\"");
- Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( Strm(), sFootnoteName, m_eDestEnc, &m_aNonConvertableCharacters );
- sOut.append(OOO_STRING_SVTOOLS_HTML_FTN_symbol).append("\" ")
- .append(OOO_STRING_SVTOOLS_HTML_O_href).append("=\"#");
- Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( Strm(), sFootnoteName, m_eDestEnc, &m_aNonConvertableCharacters );
- sOut.append(OOO_STRING_SVTOOLS_HTML_FTN_anchor).append("\">");
- Strm().WriteOString( sOut.makeStringAndClear() );
-
- HTMLOutFuncs::Out_String( Strm(), rNum, m_eDestEnc, &m_aNonConvertableCharacters );
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor, false );
+ OStringBuffer sOut("<"
+ + GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor " "
+ OOO_STRING_SVTOOLS_HTML_O_class "=\"");
+ Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( Strm(), sClass );
+ sOut.append("\" " OOO_STRING_SVTOOLS_HTML_O_name "=\"");
+ Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( Strm(), sFootnoteName );
+ sOut.append(OOO_STRING_SVTOOLS_HTML_FTN_symbol "\" "
+ OOO_STRING_SVTOOLS_HTML_O_href "=\"#");
+ Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( Strm(), sFootnoteName );
+ sOut.append(OOO_STRING_SVTOOLS_HTML_FTN_anchor "\">");
+ Strm().WriteOString( sOut );
+ sOut.setLength(0);
+
+ HTMLOutFuncs::Out_String( Strm(), rNum );
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor), false );
}
static int lcl_html_fillEndNoteInfo( const SwEndNoteInfo& rInfo,
@@ -486,11 +521,9 @@ static int lcl_html_fillEndNoteInfo( const SwEndNoteInfo& rInfo,
return nParts;
}
-static void lcl_html_outFootEndNoteInfo( Writer& rWrt, OUString const *pParts,
+static void lcl_html_outFootEndNoteInfo( SwHTMLWriter& rWrt, OUString const *pParts,
int nParts, const char *pName )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
OUStringBuffer aContent;
for( int i=0; i<nParts; ++i )
{
@@ -502,14 +535,14 @@ static void lcl_html_outFootEndNoteInfo( Writer& rWrt, OUString const *pParts,
aContent.append(aTmp);
}
- rHTMLWrt.OutNewLine();
+ rWrt.OutNewLine();
OString sOut =
- "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_meta " "
+ "<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_meta " "
OOO_STRING_SVTOOLS_HTML_O_name "=\"" + pName +
"\" " OOO_STRING_SVTOOLS_HTML_O_content "=\"";
rWrt.Strm().WriteOString( sOut );
- HTMLOutFuncs::Out_String( rWrt.Strm(), aContent.makeStringAndClear(), rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
- rWrt.Strm().WriteCharPtr( "\">" );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aContent.makeStringAndClear() );
+ rWrt.Strm().WriteOString( "\">" );
}
void SwHTMLWriter::OutFootEndNoteInfo()
@@ -529,7 +562,7 @@ void SwHTMLWriter::OutFootEndNoteInfo()
int nParts = lcl_html_fillEndNoteInfo( rInfo, aParts, false );
if( rInfo.m_eNum != FTNNUM_DOC )
{
- aParts[4] = rInfo.m_eNum == FTNNUM_CHAPTER ? OUStringLiteral( u"C" ) : OUStringLiteral( u"P" );
+ aParts[4] = rInfo.m_eNum == FTNNUM_CHAPTER ? std::u16string_view( u"C" ) : std::u16string_view( u"P" );
nParts = 5;
}
if( rInfo.m_ePos != FTNPOS_PAGE)
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
index 7b0c49cc3f3a..4b5a0d5e4bd5 100644
--- a/sw/source/filter/html/htmlgrin.cxx
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -19,6 +19,7 @@
#include <memory>
#include <hintids.hxx>
+#include <comphelper/lok.hxx>
#include <comphelper/string.hxx>
#include <comphelper/documentinfo.hxx>
#include <vcl/svapp.hxx>
@@ -34,12 +35,14 @@
#include <editeng/langitem.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/event.hxx>
+#include <sfx2/lokhelper.hxx>
#include <vcl/imap.hxx>
#include <svtools/htmltokn.h>
#include <svtools/htmlkywd.hxx>
#include <unotools/eventcfg.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
+#include <o3tl/string_view.hxx>
#include <fmtornt.hxx>
#include <fmturl.hxx>
@@ -67,7 +70,10 @@
#include <frameformats.hxx>
#include <vcl/graphicfilter.hxx>
+#include <tools/UnitConversion.hxx>
+#include <tools/hostfilter.hxx>
#include <tools/urlobj.hxx>
+#include <unotools/securityoptions.hxx>
using namespace ::com::sun::star;
@@ -91,7 +97,7 @@ HTMLOptionEnum<sal_Int16> const aHTMLImgVAlignTable[] =
{ nullptr, 0 }
};
-ImageMap *SwHTMLParser::FindImageMap( const OUString& rName ) const
+ImageMap *SwHTMLParser::FindImageMap( std::u16string_view rName ) const
{
OSL_ENSURE( rName[0] != '#', "FindImageMap: name begins with '#'!" );
@@ -99,7 +105,7 @@ ImageMap *SwHTMLParser::FindImageMap( const OUString& rName ) const
{
for (const auto &rpIMap : *m_pImageMaps)
{
- if (rName.equalsIgnoreAsciiCase(rpIMap->GetName()))
+ if (o3tl::equalsIgnoreAsciiCase(rName, rpIMap->GetName()))
{
return rpIMap.get();
}
@@ -112,8 +118,8 @@ void SwHTMLParser::ConnectImageMaps()
{
SwNodes& rNds = m_xDoc->GetNodes();
// on the first node of section #1
- sal_uLong nIdx = rNds.GetEndOfAutotext().StartOfSectionIndex() + 1;
- sal_uLong nEndIdx = rNds.GetEndOfAutotext().GetIndex();
+ SwNodeOffset nIdx = rNds.GetEndOfAutotext().StartOfSectionIndex() + 1;
+ SwNodeOffset nEndIdx = rNds.GetEndOfAutotext().GetIndex();
SwGrfNode* pGrfNd;
while( m_nMissingImgMaps > 0 && nIdx < nEndIdx )
@@ -235,7 +241,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( sal_Int16 eVertOri,
}
// determine vertical alignment and anchoring
- const sal_Int32 nContent = m_pPam->GetPoint()->nContent.GetIndex();
+ const sal_Int32 nContent = m_pPam->GetPoint()->GetContentIndex();
if( nContent )
{
aAnchor.SetType( RndStdIds::FLY_AT_CHAR );
@@ -259,7 +265,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( sal_Int16 eVertOri,
if( bMoveBackward )
m_pPam->Move( fnMoveBackward );
- if (aAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR && !m_pPam->GetNode().GetTextNode())
+ if (aAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR && !m_pPam->GetPointNode().GetTextNode())
{
eState = SvParserState::Error;
return;
@@ -281,7 +287,7 @@ void SwHTMLParser::RegisterFlyFrame( SwFrameFormat *pFlyFormat )
css::text::WrapTextMode_THROUGH == pFlyFormat->GetSurround().GetSurround() )
{
m_aMoveFlyFrames.emplace_back(std::make_unique<SwHTMLFrameFormatListener>(pFlyFormat));
- m_aMoveFlyCnts.push_back( m_pPam->GetPoint()->nContent.GetIndex() );
+ m_aMoveFlyCnts.push_back( m_pPam->GetPoint()->GetContentIndex() );
}
}
@@ -307,7 +313,7 @@ namespace
{
sReferer = sh->GetMedium()->GetName();
}
- return !SvtSecurityOptions().isUntrustedReferer(sReferer);
+ return !SvtSecurityOptions::isUntrustedReferer(sReferer);
}
}
@@ -402,7 +408,7 @@ void SwHTMLParser::InsertImage()
sAltNm = rOption.GetString();
break;
case HtmlOptionId::BORDER:
- nBorder = static_cast<sal_uInt16>(rOption.GetNumber());
+ nBorder = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::ISMAP:
bIsMap = true;
@@ -460,12 +466,12 @@ IMAGE_SETEVENT:
// When we are in an ordered list and the paragraph is still empty and not
// numbered, it may be a graphic for a bullet list.
- if( !m_pPam->GetPoint()->nContent.GetIndex() &&
+ if( !m_pPam->GetPoint()->GetContentIndex() &&
GetNumInfo().GetDepth() > 0 && GetNumInfo().GetDepth() <= MAXLEVEL &&
!m_aBulletGrfs[GetNumInfo().GetDepth()-1].isEmpty() &&
m_aBulletGrfs[GetNumInfo().GetDepth()-1]==sGrfNm )
{
- SwTextNode* pTextNode = m_pPam->GetNode().GetTextNode();
+ SwTextNode* pTextNode = m_pPam->GetPointNode().GetTextNode();
if( pTextNode && ! pTextNode->IsCountedInList())
{
@@ -477,7 +483,7 @@ IMAGE_SETEVENT:
// It's necessary to invalidate the rule, because between the reading
// of LI and the graphic an EndAction could be called.
if( GetNumInfo().GetNumRule() )
- GetNumInfo().GetNumRule()->SetInvalidRule( true );
+ GetNumInfo().GetNumRule()->Invalidate();
// Set the style again, so that indent of the first line is correct.
SetTextCollAttrs();
@@ -499,13 +505,16 @@ IMAGE_SETEVENT:
if (!sGrfNm.isEmpty())
{
- if (ERRCODE_NONE == rFilter.ImportGraphic(aGraphic, "", *pStream))
+ if (ERRCODE_NONE == rFilter.ImportGraphic(aGraphic, u"", *pStream))
sGrfNm.clear();
}
}
}
else if (m_sBaseURL.isEmpty() || !aGraphicData.isEmpty())
{
+ if (comphelper::LibreOfficeKit::isActive() && HostFilter::isForbidden(aGraphicURL.GetHost()))
+ SfxLokHelper::sendNetworkAccessError("paste");
+
// sBaseURL is empty if the source is clipboard
// aGraphicData is non-empty for <object data="..."> -> not a linked graphic.
if (ERRCODE_NONE == GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aGraphicURL))
@@ -524,6 +533,31 @@ IMAGE_SETEVENT:
nWidth = aPixelSize.Width();
if (!bHeightProvided)
nHeight = aPixelSize.Height();
+ // tdf#142781 - calculate the width/height keeping the aspect ratio
+ if (bWidthProvided && !bHeightProvided && aPixelSize.Width())
+ {
+ if (bPercentWidth)
+ {
+ nHeight = SwFormatFrameSize::SYNCED;
+ bPercentHeight = true;
+ }
+ else
+ {
+ nHeight = nWidth * aPixelSize.Height() / aPixelSize.Width();
+ }
+ }
+ else if (!bWidthProvided && bHeightProvided && aPixelSize.Height())
+ {
+ if (bPercentHeight)
+ {
+ nWidth = SwFormatFrameSize::SYNCED;
+ bPercentWidth = true;
+ }
+ else
+ {
+ nWidth = nHeight * aPixelSize.Width() / aPixelSize.Height();
+ }
+ }
}
SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
@@ -531,8 +565,7 @@ IMAGE_SETEVENT:
if( HasStyleOptions( aStyle, aId, aClass ) )
ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
- SfxItemSet aFrameSet( m_xDoc->GetAttrPool(),
- svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aFrameSet( m_xDoc->GetAttrPool() );
if( !IsNewDoc() )
Reader::ResetFrameFormatAttrs( aFrameSet );
@@ -585,19 +618,19 @@ IMAGE_SETEVENT:
SetFrameFormatAttrs( aItemSet, HtmlFrameFormatFlags::Box, aFrameSet );
Size aTwipSz( bPercentWidth ? 0 : nWidth, bPercentHeight ? 0 : nHeight );
- if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
+ if( aTwipSz.Width() || aTwipSz.Height() )
{
if (bWidthProvided || bHeightProvided || // attributes imply pixel!
aGraphic.GetPrefMapMode().GetMapUnit() == MapUnit::MapPixel)
{
- aTwipSz = Application::GetDefaultDevice()
- ->PixelToLogic( aTwipSz, MapMode( MapUnit::MapTwip ) );
+ aTwipSz = o3tl::convert(aTwipSz, o3tl::Length::px, o3tl::Length::twip);
}
else
{ // some bitmaps may have a size in metric units (e.g. PNG); use that
assert(aGraphic.GetPrefMapMode().GetMapUnit() < MapUnit::MapPixel);
- aTwipSz = OutputDevice::LogicToLogic(aGraphic.GetPrefSize(),
- aGraphic.GetPrefMapMode(), MapMode(MapUnit::MapTwip));
+ aTwipSz = o3tl::convert(aGraphic.GetPrefSize(),
+ MapToO3tlLength(aGraphic.GetPrefMapMode().GetMapUnit()),
+ o3tl::Length::twip);
}
}
@@ -642,21 +675,31 @@ IMAGE_SETEVENT:
// bPercentWidth / bPercentHeight means we have a percent size. If that's not the case and we have no
// size from nWidth / nHeight either, then inspect the image header.
- if ((!bPercentWidth && !nWidth) && (!bPercentHeight && !nHeight) && allowAccessLink(*m_xDoc))
+ bool bRelWidthScale = bPercentWidth && nWidth == SwFormatFrameSize::SYNCED;
+ bool bNeedWidth = (!bPercentWidth && !nWidth) || bRelWidthScale;
+ bool bRelHeightScale = bPercentHeight && nHeight == SwFormatFrameSize::SYNCED;
+ bool bNeedHeight = (!bPercentHeight && !nHeight) || bRelHeightScale;
+ if ((bNeedWidth || bNeedHeight) && !bFuzzing && allowAccessLink(*m_xDoc))
{
GraphicDescriptor aDescriptor(aGraphicURL);
if (aDescriptor.Detect(/*bExtendedInfo=*/true))
{
// Try to use size info from the image header before defaulting to
// HTML_DFLT_IMG_WIDTH/HEIGHT.
- aTwipSz = Application::GetDefaultDevice()->PixelToLogic(aDescriptor.GetSizePixel(),
- MapMode(MapUnit::MapTwip));
- nWidth = aTwipSz.getWidth();
- nHeight = aTwipSz.getHeight();
+ aTwipSz
+ = o3tl::convert(aDescriptor.GetSizePixel(), o3tl::Length::px, o3tl::Length::twip);
+ if (!bPercentWidth && !nWidth)
+ {
+ nWidth = aTwipSz.getWidth();
+ }
+ if (!bPercentHeight && !nHeight)
+ {
+ nHeight = aTwipSz.getHeight();
+ }
}
}
- if( !nWidth || !nHeight )
+ if( !(nWidth && !bRelWidthScale) || !(nHeight && !bRelHeightScale) )
{
// When the graphic is in a table, it will be requested immediately,
// so that it is available before the table is layouted.
@@ -747,9 +790,10 @@ IMAGE_SETEVENT:
}
// observe minimum values !!
+ bool bRelSizeScale = bRelWidthScale || bRelHeightScale;
if( nPercentWidth )
{
- OSL_ENSURE( !aTwipSz.Width(),
+ OSL_ENSURE( !aTwipSz.Width() || bRelSizeScale,
"Why is a width set if we already have percentage value?" );
aTwipSz.setWidth( aGrfSz.Width() ? aGrfSz.Width()
: HTML_DFLT_IMG_WIDTH );
@@ -762,7 +806,7 @@ IMAGE_SETEVENT:
}
if( nPercentHeight )
{
- OSL_ENSURE( !aTwipSz.Height(),
+ OSL_ENSURE( !aTwipSz.Height() || bRelSizeScale,
"Why is a height set if we already have percentage value?" );
aTwipSz.setHeight( aGrfSz.Height() ? aGrfSz.Height()
: HTML_DFLT_IMG_HEIGHT );
@@ -779,7 +823,7 @@ IMAGE_SETEVENT:
aFrameSize.SetHeightPercent( nPercentHeight );
aFrameSet.Put( aFrameSize );
- const SwNodeType eNodeType = m_pPam->GetNode().GetNodeType();
+ const SwNodeType eNodeType = m_pPam->GetPointNode().GetNodeType();
if (eNodeType != SwNodeType::Text && eNodeType != SwNodeType::Table)
return;
@@ -793,7 +837,7 @@ IMAGE_SETEVENT:
if( !sHTMLGrfName.isEmpty() )
{
- pFlyFormat->SetName( sHTMLGrfName );
+ pFlyFormat->SetFormatName( sHTMLGrfName );
// maybe jump to graphic
if( JumpToMarks::Graphic == m_eJumpTo && sHTMLGrfName == m_sJmpMark )
@@ -844,10 +888,10 @@ IMAGE_SETEVENT:
}
if ((RndStdIds::FLY_AS_CHAR == pFlyFormat->GetAnchor().GetAnchorId()) &&
- m_xAttrTab->pINetFormat->GetSttPara() ==
- m_pPam->GetPoint()->nNode &&
- m_xAttrTab->pINetFormat->GetSttCnt() ==
- m_pPam->GetPoint()->nContent.GetIndex() - 1 )
+ m_xAttrTab->pINetFormat->GetStartParagraph() ==
+ m_pPam->GetPoint()->GetNode() &&
+ m_xAttrTab->pINetFormat->GetStartContent() ==
+ m_pPam->GetPoint()->GetContentIndex() - 1 )
{
// the attribute was insert right before as-character anchored
// graphic, therefore we move it
@@ -865,6 +909,15 @@ IMAGE_SETEVENT:
}
}
+ else if (!m_aEmbedURL.isEmpty())
+ {
+ // This is an inner <object> image and the outer <object> has a URL for us. Set that on the
+ // image.
+ SwFormatURL aURL(pFlyFormat->GetURL());
+ aURL.SetURL(m_aEmbedURL, bIsMap);
+ m_aEmbedURL.clear();
+ pFlyFormat->SetFormatAttr(aURL);
+ }
if( !aMacroItem.GetMacroTable().empty() )
{
@@ -1047,19 +1100,16 @@ void SwHTMLParser::InsertBodyOptions()
m_pCSS1Parser->SetPageDescAttrs( bSetBrush ? aBrushItem.get() : nullptr,
&aItemSet );
- const SfxPoolItem *pItem;
- static const sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONTSIZE,
+ static const TypedWhichId<SvxFontHeightItem> aWhichIds[3] = { RES_CHRATR_FONTSIZE,
RES_CHRATR_CJK_FONTSIZE,
RES_CHRATR_CTL_FONTSIZE };
- for(sal_uInt16 i : aWhichIds)
+ for(auto const & i : aWhichIds)
{
- if( SfxItemState::SET == aItemSet.GetItemState( i, false,
- &pItem ) &&
- static_cast <const SvxFontHeightItem * >(pItem)->GetProp() != 100)
+ const SvxFontHeightItem *pItem = aItemSet.GetItemIfSet( i, false );
+ if( pItem && pItem->GetProp() != 100)
{
sal_uInt32 nHeight =
- ( m_aFontHeights[2] *
- static_cast <const SvxFontHeightItem * >(pItem)->GetProp() ) / 100;
+ ( m_aFontHeights[2] * pItem->GetProp() ) / 100;
SvxFontHeightItem aNewItem( nHeight, 100, i );
aItemSet.Put( aNewItem );
}
@@ -1093,7 +1143,7 @@ void SwHTMLParser::InsertBodyOptions()
LanguageType eLang = LanguageTag::convertToLanguageTypeWithFallback( aLang );
if( LANGUAGE_DONTKNOW != eLang )
{
- sal_uInt16 nWhich = 0;
+ TypedWhichId<SvxLanguageItem> nWhich(0);
switch( SvtLanguageOptions::GetScriptTypeOfLanguage( eLang ) )
{
case SvtScriptType::LATIN:
@@ -1357,7 +1407,7 @@ void SwHTMLParser::InsertBookmark( const OUString& rName )
bool SwHTMLParser::HasCurrentParaBookmarks( bool bIgnoreStack ) const
{
bool bHasMarks = false;
- sal_uLong nNodeIdx = m_pPam->GetPoint()->nNode.GetIndex();
+ SwNodeOffset nNodeIdx = m_pPam->GetPoint()->GetNodeIndex();
// first step: are there still bookmark in the attribute-stack?
// bookmarks are added to the end of the stack - thus we only have
@@ -1369,7 +1419,7 @@ bool SwHTMLParser::HasCurrentParaBookmarks( bool bIgnoreStack ) const
HTMLAttr* pAttr = m_aSetAttrTab[ --i ];
if( RES_FLTR_BOOKMARK == pAttr->m_pItem->Which() )
{
- if( pAttr->GetSttParaIdx() == nNodeIdx )
+ if( pAttr->GetStartParagraphIdx() == nNodeIdx )
bHasMarks = true;
break;
}
@@ -1386,7 +1436,7 @@ bool SwHTMLParser::HasCurrentParaBookmarks( bool bIgnoreStack ) const
{
const ::sw::mark::IMark* pBookmark = *ppMark;
- const sal_uLong nBookNdIdx = pBookmark->GetMarkPos().nNode.GetIndex();
+ const SwNodeOffset nBookNdIdx = pBookmark->GetMarkPos().GetNodeIndex();
if( nBookNdIdx==nNodeIdx )
{
bHasMarks = true;
@@ -1406,23 +1456,22 @@ void SwHTMLParser::StripTrailingPara()
{
bool bSetSmallFont = false;
- SwContentNode* pCNd = m_pPam->GetContentNode();
- sal_uLong nNodeIdx = m_pPam->GetPoint()->nNode.GetIndex();
- if( !m_pPam->GetPoint()->nContent.GetIndex() )
+ SwContentNode* pCNd = m_pPam->GetPointContentNode();
+ SwNodeOffset nNodeIdx = m_pPam->GetPoint()->GetNodeIndex();
+ if( !m_pPam->GetPoint()->GetContentIndex() )
{
if( pCNd && pCNd->StartOfSectionIndex() + 2 <
pCNd->EndOfSectionIndex() && CanRemoveNode(nNodeIdx))
{
- const SwFrameFormats& rFrameFormatTable = *m_xDoc->GetSpzFrameFormats();
- for( auto pFormat : rFrameFormatTable )
+ for(sw::SpzFrameFormat* pSpz: *m_xDoc->GetSpzFrameFormats())
{
- SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor();
- SwPosition const*const pAPos = pAnchor->GetContentAnchor();
- if (pAPos &&
+ SwFormatAnchor const*const pAnchor = &pSpz->GetAnchor();
+ SwNode const*const pAnchorNode = pAnchor->GetAnchorNode();
+ if (pAnchorNode &&
((RndStdIds::FLY_AT_PARA == pAnchor->GetAnchorId()) ||
(RndStdIds::FLY_AT_CHAR == pAnchor->GetAnchorId())) &&
- pAPos->nNode == nNodeIdx )
+ pAnchorNode->GetIndex() == nNodeIdx )
return; // we can't delete the node
}
@@ -1438,7 +1487,7 @@ void SwHTMLParser::StripTrailingPara()
SwTextNode *pPrvNd = m_xDoc->GetNodes()[nNodeIdx-1]->GetTextNode();
if( pPrvNd )
{
- SwIndex aSrc( pCNd, 0 );
+ SwContentIndex aSrc( pCNd, 0 );
pCNd->GetTextNode()->CutText( pPrvNd, aSrc, pCNd->Len() );
}
}
@@ -1451,10 +1500,10 @@ void SwHTMLParser::StripTrailingPara()
{
::sw::mark::IMark* pMark = *ppMark;
- sal_uLong nBookNdIdx = pMark->GetMarkPos().nNode.GetIndex();
+ SwNodeOffset nBookNdIdx = pMark->GetMarkPos().GetNodeIndex();
if(nBookNdIdx==nNodeIdx)
{
- SwNodeIndex nNewNdIdx(m_pPam->GetPoint()->nNode);
+ SwNodeIndex nNewNdIdx(m_pPam->GetPoint()->GetNode());
SwContentNode* pNd = SwNodes::GoPrevious(&nNewNdIdx);
if(!pNd)
{
@@ -1464,9 +1513,7 @@ void SwHTMLParser::StripTrailingPara()
// #i81002# - refactoring
// Do not directly manipulate member of <SwBookmark>
{
- SwPosition aNewPos(*pNd);
- aNewPos.nContent.Assign(pNd, pNd->Len());
- const SwPaM aPaM(aNewPos);
+ const SwPaM aPaM(*pNd, pNd->Len());
pMarkAccess->repositionMark(*ppMark, aPaM);
}
}
@@ -1474,11 +1521,11 @@ void SwHTMLParser::StripTrailingPara()
break;
}
- m_pPam->GetPoint()->nContent.Assign( nullptr, 0 );
+ SwNode& rDelNode = m_pPam->GetPoint()->GetNode();
+ m_pPam->Move( fnMoveBackward, GoInNode );
m_pPam->SetMark();
m_pPam->DeleteMark();
- m_xDoc->GetNodes().Delete( m_pPam->GetPoint()->nNode );
- m_pPam->Move( fnMoveBackward, GoInNode );
+ m_xDoc->GetNodes().Delete( rDelNode );
}
else if (pCNd && pCNd->IsTextNode() && m_xTable)
{
@@ -1496,7 +1543,7 @@ void SwHTMLParser::StripTrailingPara()
bSetSmallFont = true;
SwTextNode* pTextNd = pCNd->GetTextNode();
- sal_Int32 nPos = m_pPam->GetPoint()->nContent.GetIndex();
+ sal_Int32 nPos = m_pPam->GetPoint()->GetContentIndex();
while( bSetSmallFont && nPos>0 )
{
--nPos;
diff --git a/sw/source/filter/html/htmlnum.cxx b/sw/source/filter/html/htmlnum.cxx
index 345645a240c8..8fa120a630cf 100644
--- a/sw/source/filter/html/htmlnum.cxx
+++ b/sw/source/filter/html/htmlnum.cxx
@@ -26,22 +26,68 @@ void SwHTMLNumRuleInfo::Set(const SwTextNode& rTextNd)
const SwNumRule* pTextNdNumRule(rTextNd.GetNumRule());
if (pTextNdNumRule && pTextNdNumRule != rTextNd.GetDoc().GetOutlineNumRule())
{
- pNumRule = const_cast<SwNumRule*>(pTextNdNumRule);
- nDeep = static_cast<sal_uInt16>(pNumRule ? rTextNd.GetActualListLevel() + 1 : 0);
- bNumbered = rTextNd.IsCountedInList();
+ m_pNumRule = const_cast<SwNumRule*>(pTextNdNumRule);
+ m_nDeep = o3tl::narrowing<sal_uInt16>(m_pNumRule ? rTextNd.GetActualListLevel() + 1 : 0);
+ m_bNumbered = rTextNd.IsCountedInList();
// #i57919# - correction of refactoring done by cws swnumtree:
// <bRestart> has to be set to <true>, if numbering is restarted at this
// text node and the start value equals <USHRT_MAX>.
// Start value <USHRT_MAX> indicates, that at this text node the numbering
// is restarted with the value given at the corresponding level.
- bRestart = rTextNd.IsListRestart() && !rTextNd.HasAttrListRestartValue();
+ m_bRestart = rTextNd.IsListRestart() && !rTextNd.HasAttrListRestartValue();
}
else
{
- pNumRule = nullptr;
- nDeep = 0;
- bNumbered = bRestart = false;
+ m_pNumRule = nullptr;
+ m_nDeep = 0;
+ m_bNumbered = m_bRestart = false;
}
}
+// Restart flag is only effective when this level is not below the previous
+bool SwHTMLNumRuleInfo::IsRestart(const SwHTMLNumRuleInfo& rPrev) const
+{
+ // calling this, when the rules are different, makes no sense
+ assert(rPrev.GetNumRule() == GetNumRule());
+
+ // An example ODF when the restart flag is set, but has no effect:
+ // <text:list text:style-name="L1">
+ // <text:list-item>
+ // <text:p>l1</text:p>
+ // <text:list>
+ // <text:list-item>
+ // <text:p>l2</text:p>
+ // </text:list-item>
+ // <text:list-item>
+ // <text:p>l2</text:p>
+ // </text:list-item>
+ // </text:list>
+ // <text:list>
+ // <text:list-item>
+ // <text:list>
+ // <text:list-item>
+ // <text:p>l3</text:p>
+ // </text:list-item>
+ // </text:list>
+ // </text:list-item>
+ // </text:list>
+ // </text:list-item>
+ // </text:list>
+ // In this case, "l3" is in a separate sublist than "l2", and so the "l3" node gets the
+ // "list restart" property. But the document rendering would be
+ // 1. l1
+ // 1.1. l2
+ // 1.2. l2
+ // 1.2.1. l3
+ // and the second-level numbering will not actually restart at the "l3" node.
+ //
+ // TODO/LATER: note that restarting may happen at different levels. In the code using this
+ // function, the level is reset to 0 whenever a restart is detected. And also, there is no
+ // code to actually descend to that new level (close corresponding li/ul/ol elements).
+
+ if (rPrev.GetDepth() < GetDepth())
+ return false; // No matter if the restart flag is set, it is not effective for subitems
+ return m_bRestart;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmlnum.hxx b/sw/source/filter/html/htmlnum.hxx
index 917c0514a259..670f08229df2 100644
--- a/sw/source/filter/html/htmlnum.hxx
+++ b/sw/source/filter/html/htmlnum.hxx
@@ -22,8 +22,8 @@
#include <swtypes.hxx>
#include <string.h>
-#define HTML_NUMBER_BULLET_MARGINLEFT (MM50*2 + MM50/2)
-#define HTML_NUMBER_BULLET_INDENT (-MM50)
+#define HTML_NUMBER_BULLET_MARGINLEFT (o3tl::toTwips(125, o3tl::Length::mm10))
+#define HTML_NUMBER_BULLET_INDENT (-o3tl::toTwips(5, o3tl::Length::mm))
class SwTextNode;
class SwNumRule;
@@ -35,11 +35,11 @@ class SwNumRule;
class SwHTMLNumRuleInfo
{
- sal_uInt16 aNumStarts[MAXLEVEL];
- SwNumRule * pNumRule; // current numbering
- sal_uInt16 nDeep; // current numbering depth (1, 2, 3, ...)
- bool bRestart : 1; // Export: restart numbering
- bool bNumbered : 1; // Export: paragraph is numbered
+ sal_uInt16 m_aNumStarts[MAXLEVEL];
+ SwNumRule * m_pNumRule; // current numbering
+ sal_uInt16 m_nDeep; // current numbering depth (1, 2, 3, ...)
+ bool m_bRestart; // Export: restart numbering
+ bool m_bNumbered; // Export: paragraph is numbered
public:
@@ -47,17 +47,17 @@ public:
void Set( const SwTextNode& rTextNd );
SwHTMLNumRuleInfo() :
- pNumRule( nullptr ), nDeep( 0 ),
- bRestart( false ), bNumbered( false )
+ m_pNumRule( nullptr ), m_nDeep( 0 ),
+ m_bRestart( false ), m_bNumbered( false )
{
- memset( &aNumStarts, 0xff, sizeof( aNumStarts ) );
+ memset( &m_aNumStarts, 0xff, sizeof( m_aNumStarts ) );
}
SwHTMLNumRuleInfo( const SwHTMLNumRuleInfo& rInf ) :
- pNumRule( rInf.pNumRule ), nDeep( rInf.nDeep ),
- bRestart( rInf.bRestart ), bNumbered( rInf.bNumbered )
+ m_pNumRule( rInf.m_pNumRule ), m_nDeep( rInf.m_nDeep ),
+ m_bRestart( rInf.m_bRestart ), m_bNumbered( rInf.m_bNumbered )
{
- memcpy( &aNumStarts, &rInf.aNumStarts, sizeof( aNumStarts ) );
+ memcpy( &m_aNumStarts, &rInf.m_aNumStarts, sizeof( m_aNumStarts ) );
}
explicit SwHTMLNumRuleInfo( const SwTextNode& rTextNd ) { Set( rTextNd ); }
@@ -65,22 +65,22 @@ public:
inline void Clear();
- void SetNumRule( const SwNumRule *pRule ) { pNumRule = const_cast<SwNumRule *>(pRule); }
- SwNumRule *GetNumRule() { return pNumRule; }
- const SwNumRule *GetNumRule() const { return pNumRule; }
+ void SetNumRule( const SwNumRule *pRule ) { m_pNumRule = const_cast<SwNumRule *>(pRule); }
+ SwNumRule *GetNumRule() { return m_pNumRule; }
+ const SwNumRule *GetNumRule() const { return m_pNumRule; }
- void SetDepth( sal_uInt16 nDepth ) { nDeep = nDepth; }
- sal_uInt16 GetDepth() const { return nDeep; }
- void IncDepth() { ++nDeep; }
- void DecDepth() { if (nDeep!=0) --nDeep; }
+ void SetDepth( sal_uInt16 nDepth ) { m_nDeep = nDepth; }
+ sal_uInt16 GetDepth() const { return m_nDeep; }
+ void IncDepth() { ++m_nDeep; }
+ void DecDepth() { if (m_nDeep!=0) --m_nDeep; }
inline sal_uInt8 GetLevel() const;
- bool IsRestart() const { return bRestart; }
+ bool IsRestart(const SwHTMLNumRuleInfo& rPrev) const;
- bool IsNumbered() const { return bNumbered; }
+ bool IsNumbered() const { return m_bNumbered; }
inline void SetNodeStartValue( sal_uInt8 nLvl, sal_uInt16 nVal=USHRT_MAX );
- sal_uInt16 GetNodeStartValue( sal_uInt8 nLvl ) const { return aNumStarts[nLvl]; }
+ sal_uInt16 GetNodeStartValue( sal_uInt8 nLvl ) const { return m_aNumStarts[nLvl]; }
};
inline SwHTMLNumRuleInfo& SwHTMLNumRuleInfo::operator=(
@@ -92,32 +92,32 @@ inline SwHTMLNumRuleInfo& SwHTMLNumRuleInfo::operator=(
inline void SwHTMLNumRuleInfo::Set( const SwHTMLNumRuleInfo& rInf )
{
- pNumRule = rInf.pNumRule;
- nDeep = rInf.nDeep;
- bRestart = rInf.bRestart;
- bNumbered = rInf.bNumbered;
- memcpy( &aNumStarts, &rInf.aNumStarts, sizeof( aNumStarts ) );
+ m_pNumRule = rInf.m_pNumRule;
+ m_nDeep = rInf.m_nDeep;
+ m_bRestart = rInf.m_bRestart;
+ m_bNumbered = rInf.m_bNumbered;
+ memcpy( &m_aNumStarts, &rInf.m_aNumStarts, sizeof( m_aNumStarts ) );
}
inline void SwHTMLNumRuleInfo::Clear()
{
- pNumRule = nullptr;
- nDeep = 0;
- bRestart = bNumbered = false;
- memset( &aNumStarts, 0xff, sizeof( aNumStarts ) );
+ m_pNumRule = nullptr;
+ m_nDeep = 0;
+ m_bRestart = m_bNumbered = false;
+ memset( &m_aNumStarts, 0xff, sizeof( m_aNumStarts ) );
}
inline sal_uInt8 SwHTMLNumRuleInfo::GetLevel() const
{
return
- static_cast<sal_uInt8>( pNumRule!=nullptr && nDeep != 0
- ? ( nDeep<=MAXLEVEL ? nDeep-1 : MAXLEVEL - 1 )
+ static_cast<sal_uInt8>( m_pNumRule!=nullptr && m_nDeep != 0
+ ? ( m_nDeep<=MAXLEVEL ? m_nDeep-1 : MAXLEVEL - 1 )
: 0 );
}
inline void SwHTMLNumRuleInfo::SetNodeStartValue( sal_uInt8 nLvl, sal_uInt16 nVal )
{
- aNumStarts[nLvl] = nVal;
+ m_aNumStarts[nLvl] = nVal;
}
#endif
diff --git a/sw/source/filter/html/htmlnumreader.cxx b/sw/source/filter/html/htmlnumreader.cxx
index feaee46f4cb3..d9ecc21f3d3b 100644
--- a/sw/source/filter/html/htmlnumreader.cxx
+++ b/sw/source/filter/html/htmlnumreader.cxx
@@ -56,7 +56,7 @@ void SwHTMLParser::NewNumberBulletList( HtmlTokenId nToken )
// Create a new paragraph
bool bSpace = (rInfo.GetDepth() + m_nDefListDeep) == 0;
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if( m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode( bSpace ? AM_SPACE : AM_NOSPACE, false );
else if( bSpace )
AddParSpace();
@@ -165,7 +165,7 @@ void SwHTMLParser::NewNumberBulletList( HtmlTokenId nToken )
break;
case HtmlOptionId::START:
{
- sal_uInt16 nStart = static_cast<sal_uInt16>(rOption.GetNumber());
+ sal_uInt16 nStart = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
if( bNewNumFormat )
{
aNumFormat.SetStart( nStart );
@@ -198,10 +198,10 @@ void SwHTMLParser::NewNumberBulletList( HtmlTokenId nToken )
}
break;
case HtmlOptionId::WIDTH:
- nWidth = static_cast<sal_uInt16>(rOption.GetNumber());
+ nWidth = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::HEIGHT:
- nHeight = static_cast<sal_uInt16>(rOption.GetNumber());
+ nHeight = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::ALIGN:
eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
@@ -224,9 +224,7 @@ void SwHTMLParser::NewNumberBulletList( HtmlTokenId nToken )
Size aTwipSz( nWidth, nHeight), *pTwipSz=nullptr;
if( nWidth!=USHRT_MAX && nHeight!=USHRT_MAX )
{
- aTwipSz =
- Application::GetDefaultDevice()->PixelToLogic( aTwipSz,
- MapMode(MapUnit::MapTwip) );
+ aTwipSz = o3tl::convert(aTwipSz, o3tl::Length::px, o3tl::Length::twip);
pTwipSz = &aTwipSz;
}
@@ -280,7 +278,7 @@ void SwHTMLParser::NewNumberBulletList( HtmlTokenId nToken )
if( aPropInfo.m_bTextIndent )
{
short nTextIndent =
- aItemSet.Get( RES_LR_SPACE ).GetTextFirstLineOffset();
+ aItemSet.Get(RES_MARGIN_FIRSTLINE).GetTextFirstLineOffset();
aNumFormat.SetFirstLineOffset( nTextIndent );
bChangeNumFormat = true;
}
@@ -297,7 +295,7 @@ void SwHTMLParser::NewNumberBulletList( HtmlTokenId nToken )
}
aPropInfo.m_bLeftMargin = aPropInfo.m_bTextIndent = false;
if( !aPropInfo.m_bRightMargin )
- aItemSet.ClearItem( RES_LR_SPACE );
+ aItemSet.ClearItem(RES_MARGIN_RIGHT); // superfluous?
// #i89812# - Perform change to list style before calling <DoPositioning(..)>,
// because <DoPositioning(..)> may open a new context and thus may
@@ -334,10 +332,10 @@ void SwHTMLParser::EndNumberBulletList( HtmlTokenId nToken )
// A new paragraph needs to be created, when
// - the current one isn't empty (it contains text or paragraph-bound objects)
// - the current one is numbered
- bool bAppend = m_pPam->GetPoint()->nContent.GetIndex() > 0;
+ bool bAppend = m_pPam->GetPoint()->GetContentIndex() > 0;
if( !bAppend )
{
- SwTextNode* pTextNode = m_pPam->GetNode().GetTextNode();
+ SwTextNode* pTextNode = m_pPam->GetPointNode().GetTextNode();
bAppend = (pTextNode && ! pTextNode->IsOutline() && pTextNode->IsCountedInList()) ||
@@ -395,7 +393,7 @@ void SwHTMLParser::EndNumberBulletList( HtmlTokenId nToken )
// On the last append, the NumRule item and NodeNum object were copied.
// Now we need to delete them. ResetAttr deletes the NodeNum object as well
- if (SwTextNode *pTextNode = m_pPam->GetNode().GetTextNode())
+ if (SwTextNode *pTextNode = m_pPam->GetPointNode().GetTextNode())
pTextNode->ResetAttr(RES_PARATR_NUMRULE);
rInfo.Clear();
@@ -441,7 +439,7 @@ void SwHTMLParser::NewNumberBulletListItem( HtmlTokenId nToken )
switch( rOption.GetToken() )
{
case HtmlOptionId::VALUE:
- nStart = static_cast<sal_uInt16>(rOption.GetNumber());
+ nStart = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::ID:
aId = rOption.GetString();
@@ -463,11 +461,11 @@ void SwHTMLParser::NewNumberBulletListItem( HtmlTokenId nToken )
}
// create a new paragraph
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if( m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode( AM_NOSPACE, false );
m_bNoParSpace = false; // no space in <LI>!
- SwTextNode* pTextNode = m_pPam->GetNode().GetTextNode();
+ SwTextNode* pTextNode = m_pPam->GetPointNode().GetTextNode();
if (!pTextNode)
{
SAL_WARN("sw.html", "No Text-Node at PaM-Position");
@@ -528,7 +526,7 @@ void SwHTMLParser::NewNumberBulletListItem( HtmlTokenId nToken )
}
if( GetNumInfo().GetNumRule() )
- GetNumInfo().GetNumRule()->SetInvalidRule( true );
+ GetNumInfo().GetNumRule()->Invalidate();
// parse styles
if( HasStyleOptions( aStyle, aId, aClass, &aLang, &aDir ) )
@@ -555,7 +553,7 @@ void SwHTMLParser::NewNumberBulletListItem( HtmlTokenId nToken )
void SwHTMLParser::EndNumberBulletListItem( HtmlTokenId nToken, bool bSetColl )
{
// Create a new paragraph
- if( nToken == HtmlTokenId::NONE && m_pPam->GetPoint()->nContent.GetIndex() )
+ if( nToken == HtmlTokenId::NONE && m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode( AM_NOSPACE );
// Get context to that token and pop it from stack
@@ -601,7 +599,7 @@ void SwHTMLParser::EndNumberBulletListItem( HtmlTokenId nToken, bool bSetColl )
void SwHTMLParser::SetNodeNum( sal_uInt8 nLevel )
{
- SwTextNode* pTextNode = m_pPam->GetNode().GetTextNode();
+ SwTextNode* pTextNode = m_pPam->GetPointNode().GetTextNode();
if (!pTextNode)
{
SAL_WARN("sw.html", "No Text-Node at PaM-Position");
@@ -616,7 +614,7 @@ void SwHTMLParser::SetNodeNum( sal_uInt8 nLevel )
pTextNode->SetCountedInList( false );
// Invalidate NumRule, it may have been set valid because of an EndAction
- GetNumInfo().GetNumRule()->SetInvalidRule( false );
+ GetNumInfo().GetNumRule()->Invalidate();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmlnumwriter.cxx b/sw/source/filter/html/htmlnumwriter.cxx
index ea3c949c3801..046747754a38 100644
--- a/sw/source/filter/html/htmlnumwriter.cxx
+++ b/sw/source/filter/html/htmlnumwriter.cxx
@@ -37,7 +37,7 @@ void SwHTMLWriter::FillNextNumInfo()
{
m_pNextNumRuleInfo = nullptr;
- sal_uLong nPos = m_pCurrentPam->GetPoint()->nNode.GetIndex() + 1;
+ SwNodeOffset nPos = m_pCurrentPam->GetPoint()->GetNodeIndex() + 1;
bool bTable = false;
do
@@ -53,7 +53,7 @@ void SwHTMLWriter::FillNextNumInfo()
// numbering level during import.
if( bTable &&
m_pNextNumRuleInfo->GetNumRule()==GetNumInfo().GetNumRule() &&
- !m_pNextNumRuleInfo->IsRestart() )
+ !m_pNextNumRuleInfo->IsRestart(GetNumInfo()) )
{
m_pNextNumRuleInfo->SetDepth( GetNumInfo().GetDepth() );
}
@@ -83,13 +83,13 @@ void SwHTMLWriter::SetNextNumInfo( std::unique_ptr<SwHTMLNumRuleInfo> pNxt )
m_pNextNumRuleInfo = std::move(pNxt);
}
-Writer& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt,
+SwHTMLWriter& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt,
const SwHTMLNumRuleInfo& rInfo )
{
SwHTMLNumRuleInfo& rPrevInfo = rWrt.GetNumInfo();
bool bSameRule = rPrevInfo.GetNumRule() == rInfo.GetNumRule();
if( bSameRule && rPrevInfo.GetDepth() >= rInfo.GetDepth() &&
- !rInfo.IsRestart() )
+ !rInfo.IsRestart(rPrevInfo) )
{
return rWrt;
}
@@ -111,8 +111,8 @@ Writer& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt,
bStartValue = true;
if( rInfo.GetDepth() > 1 )
{
- sal_uLong nPos =
- rWrt.m_pCurrentPam->GetPoint()->nNode.GetIndex() + 1;
+ SwNodeOffset nPos =
+ rWrt.m_pCurrentPam->GetPoint()->GetNodeIndex() + 1;
do
{
const SwNode* pNd = rWrt.m_pDoc->GetNodes()[nPos];
@@ -167,7 +167,7 @@ Writer& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt,
OSL_ENSURE( rWrt.m_nLastParaToken == HtmlTokenId::NONE,
"<PRE> was not closed before <OL>." );
sal_uInt16 nPrevDepth =
- (bSameRule && !rInfo.IsRestart()) ? rPrevInfo.GetDepth() : 0;
+ (bSameRule && !rInfo.IsRestart(rPrevInfo)) ? rPrevInfo.GetDepth() : 0;
for( sal_uInt16 i=nPrevDepth; i<rInfo.GetDepth(); i++ )
{
@@ -175,12 +175,17 @@ Writer& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt,
rWrt.m_aBulletGrfs[i].clear();
OString sOut = "<" + rWrt.GetNamespace();
+ if (rWrt.mbXHTML && i != nPrevDepth)
+ {
+ // for all skipped sublevels, add a li
+ sOut += OOO_STRING_SVTOOLS_HTML_li "><" + rWrt.GetNamespace();
+ }
const SwNumFormat& rNumFormat = rInfo.GetNumRule()->Get( i );
sal_Int16 eType = rNumFormat.GetNumberingType();
if( SVX_NUM_CHAR_SPECIAL == eType )
{
- // ordered list: <OL>
- sOut += OString(OOO_STRING_SVTOOLS_HTML_unorderlist);
+ // unordered list: <UL>
+ sOut += OOO_STRING_SVTOOLS_HTML_unorderlist;
// determine the type by the bullet character
const char *pStr = nullptr;
@@ -199,28 +204,25 @@ Writer& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt,
if( pStr )
{
- sOut += OStringLiteral(" " OOO_STRING_SVTOOLS_HTML_O_type "=\"") + pStr + "\"";
+ sOut += OString::Concat(" " OOO_STRING_SVTOOLS_HTML_O_type "=\"") + pStr + "\"";
}
}
else if( SVX_NUM_BITMAP == eType )
{
// Unordered list: <UL>
- sOut += OString(OOO_STRING_SVTOOLS_HTML_unorderlist);
- rWrt.Strm().WriteOString( sOut );
- OutHTML_BulletImage( rWrt,
- nullptr,
- rNumFormat.GetBrush(),
- rWrt.m_aBulletGrfs[i]);
+ sOut += OOO_STRING_SVTOOLS_HTML_unorderlist;
}
else
{
// Ordered list: <OL>
- sOut += OString(OOO_STRING_SVTOOLS_HTML_orderlist);
+ sOut += OOO_STRING_SVTOOLS_HTML_orderlist;
- // determine the type by the format
- char cType = 0;
- switch( eType )
+ if (!rWrt.mbReqIF) // No 'type' nor 'start' attribute in ReqIF
{
+ // determine the type by the format
+ char cType = 0;
+ switch (eType)
+ {
case SVX_NUM_CHARS_UPPER_LETTER:
case SVX_NUM_CHARS_UPPER_LETTER_N:
cType = 'A';
@@ -235,33 +237,36 @@ Writer& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt,
case SVX_NUM_ROMAN_LOWER:
cType = 'i';
break;
- }
- if( cType )
- {
- sOut += " " OOO_STRING_SVTOOLS_HTML_O_type "=\"" + OStringChar(cType) + "\"";
- }
+ }
+ if( cType )
+ {
+ sOut += " " OOO_STRING_SVTOOLS_HTML_O_type "=\"" + OStringChar(cType) + "\"";
+ }
- sal_uInt16 nStartVal = rNumFormat.GetStart();
- if( bStartValue && 1 == nStartVal && i == rInfo.GetDepth()-1 )
- {
- if ( rWrt.m_pCurrentPam->GetNode().GetTextNode()->GetNum() )
+ sal_uInt16 nStartVal = rNumFormat.GetStart();
+ if( bStartValue && 1 == nStartVal && i == rInfo.GetDepth()-1 )
{
- nStartVal = static_cast< sal_uInt16 >( rWrt.m_pCurrentPam->GetNode()
- .GetTextNode()->GetNumberVector()[i] );
+ if ( rWrt.m_pCurrentPam->GetPointNode().GetTextNode()->GetNum() )
+ {
+ nStartVal = static_cast< sal_uInt16 >( rWrt.m_pCurrentPam->GetPointNode()
+ .GetTextNode()->GetNumberVector()[i] );
+ }
+ else
+ {
+ OSL_FAIL( "<OutHTML_NumberBulletListStart(..) - text node has no number." );
+ }
}
- else
+ if( nStartVal != 1 )
{
- OSL_FAIL( "<OutHTML_NumberBulletListStart(..) - text node has no number." );
+ sOut += " " OOO_STRING_SVTOOLS_HTML_O_start "=\"" + OString::number(static_cast<sal_Int32>(nStartVal)) + "\"";
}
}
- if( nStartVal != 1 )
- {
- sOut += " " OOO_STRING_SVTOOLS_HTML_O_start "=\"" + OString::number(static_cast<sal_Int32>(nStartVal)) + "\"";
- }
}
- if (!sOut.isEmpty() && SVX_NUM_BITMAP != eType) // second condition to avoid adding extra ul, already done before.
- rWrt.Strm().WriteOString( sOut );
+ rWrt.Strm().WriteOString(sOut);
+
+ if (eType == SVX_NUM_BITMAP)
+ OutHTML_BulletImage(rWrt, nullptr, rNumFormat.GetBrush(), rWrt.m_aBulletGrfs[i]);
if( rWrt.m_bCfgOutStyles )
OutCSS1_NumberBulletListStyleOpt( rWrt, *rInfo.GetNumRule(), static_cast<sal_uInt8>(i) );
@@ -274,20 +279,20 @@ Writer& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt,
return rWrt;
}
-Writer& OutHTML_NumberBulletListEnd( SwHTMLWriter& rWrt,
+SwHTMLWriter& OutHTML_NumberBulletListEnd( SwHTMLWriter& rWrt,
const SwHTMLNumRuleInfo& rNextInfo )
{
SwHTMLNumRuleInfo& rInfo = rWrt.GetNumInfo();
bool bSameRule = rNextInfo.GetNumRule() == rInfo.GetNumRule();
- bool bListEnd = !bSameRule || rNextInfo.GetDepth() < rInfo.GetDepth() || rNextInfo.IsRestart();
+ bool bListEnd = !bSameRule || rNextInfo.GetDepth() < rInfo.GetDepth() || rNextInfo.IsRestart(rInfo);
+ bool bNextIsSubitem = !bListEnd && rNextInfo.GetDepth() > rInfo.GetDepth();
- if (rWrt.mbXHTML)
+ // XHTML </li> for the list item content, if there is an open <li>.
+ if (bListEnd || (!bNextIsSubitem && rNextInfo.IsNumbered()))
{
- if (bListEnd || (!bListEnd && rNextInfo.IsNumbered()))
- {
- HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(),
- rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_li, false);
- }
+ HTMLOutFuncs::Out_AsciiTag(
+ rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_li),
+ false);
}
if (!bListEnd)
@@ -298,24 +303,31 @@ Writer& OutHTML_NumberBulletListEnd( SwHTMLWriter& rWrt,
OSL_ENSURE( rWrt.m_nLastParaToken == HtmlTokenId::NONE,
"<PRE> was not closed before </OL>." );
sal_uInt16 nNextDepth =
- (bSameRule && !rNextInfo.IsRestart()) ? rNextInfo.GetDepth() : 0;
+ (bSameRule && !rNextInfo.IsRestart(rInfo)) ? rNextInfo.GetDepth() : 0;
// MIB 23.7.97: We must loop backwards, to get the right order of </OL>/</UL>
for( sal_uInt16 i=rInfo.GetDepth(); i>nNextDepth; i-- )
{
rWrt.DecIndentLevel(); // indent content of <OL>
- if( rWrt.m_bLFPossible )
+ if (rWrt.IsLFPossible())
rWrt.OutNewLine(); // </OL>/</UL> in a new line
// a list is started or ended:
sal_Int16 eType = rInfo.GetNumRule()->Get( i-1 ).GetNumberingType();
OString aTag;
if( SVX_NUM_CHAR_SPECIAL == eType || SVX_NUM_BITMAP == eType)
- aTag = OOO_STRING_SVTOOLS_HTML_unorderlist;
+ aTag = OOO_STRING_SVTOOLS_HTML_unorderlist ""_ostr;
else
- aTag = OOO_STRING_SVTOOLS_HTML_orderlist;
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rWrt.GetNamespace() + aTag, false );
- rWrt.m_bLFPossible = true;
+ aTag = OOO_STRING_SVTOOLS_HTML_orderlist ""_ostr;
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aTag), false );
+ if (rWrt.mbXHTML && (i != nNextDepth + 1 || (i != 1 && rNextInfo.IsNumbered())))
+ {
+ // for all skipped sublevels, close a li
+ HTMLOutFuncs::Out_AsciiTag(
+ rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_li),
+ /*bOn=*/false);
+ }
+ rWrt.SetLFPossible(true);
}
return rWrt;
diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx
index 65e0419f4ed9..d70634e2dddf 100644
--- a/sw/source/filter/html/htmlplug.cxx
+++ b/sw/source/filter/html/htmlplug.cxx
@@ -34,7 +34,7 @@
#include <svtools/htmlout.hxx>
#include <svtools/htmlkywd.hxx>
#include <svtools/htmltokn.h>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <IDocumentContentOperations.hxx>
#include <SwAppletImpl.hxx>
#include <fmtornt.hxx>
@@ -79,14 +79,16 @@
#include <o3tl/safeint.hxx>
#include <osl/file.hxx>
#include <comphelper/propertyvalue.hxx>
+#include <svtools/HtmlWriter.hxx>
using namespace com::sun::star;
-#define HTML_DFLT_EMBED_WIDTH ((MM50*5)/2)
-#define HTML_DFLT_EMBED_HEIGHT ((MM50*5)/2)
-#define HTML_DFLT_APPLET_WIDTH ((MM50*5)/2)
-#define HTML_DFLT_APPLET_HEIGHT ((MM50*5)/2)
+#define HTML_DFLT_EMBED_WIDTH (o3tl::toTwips(125, o3tl::Length::mm10))
+#define HTML_DFLT_EMBED_HEIGHT (o3tl::toTwips(125, o3tl::Length::mm10))
+
+#define HTML_DFLT_APPLET_WIDTH (o3tl::toTwips(125, o3tl::Length::mm10))
+#define HTML_DFLT_APPLET_HEIGHT (o3tl::toTwips(125, o3tl::Length::mm10))
const HtmlFrmOpts HTML_FRMOPTS_EMBED_ALL =
@@ -142,7 +144,7 @@ namespace
* itself and a wanted extension.
*/
OUString lcl_CalculateFileName(const OUString* pOrigFileName, const Graphic& rGraphic,
- const OUString& rExtension)
+ std::u16string_view rExtension)
{
OUString aFileName;
@@ -170,11 +172,9 @@ void SwHTMLParser::SetFixSize( const Size& rPixSize,
sal_uInt8 nPercentWidth = 0, nPercentHeight = 0;
Size aTwipSz( bPercentWidth || USHRT_MAX==rPixSize.Width() ? 0 : rPixSize.Width(),
bPercentHeight || USHRT_MAX==rPixSize.Height() ? 0 : rPixSize.Height() );
- if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
+ if( aTwipSz.Width() || aTwipSz.Height() )
{
- aTwipSz =
- Application::GetDefaultDevice()->PixelToLogic( aTwipSz,
- MapMode(MapUnit::MapTwip) );
+ aTwipSz = o3tl::convert(aTwipSz, o3tl::Length::px, o3tl::Length::twip);
}
// process width
@@ -190,7 +190,7 @@ void SwHTMLParser::SetFixSize( const Size& rPixSize,
else if( bPercentWidth && rPixSize.Width() )
{
nPercentWidth = static_cast<sal_uInt8>(rPixSize.Width());
- if( nPercentWidth > 100 )
+ if (nPercentWidth > 100 && nPercentWidth != SwFormatFrameSize::SYNCED)
nPercentWidth = 100;
aTwipSz.setWidth( rTwipDfltSize.Width() );
@@ -217,7 +217,7 @@ void SwHTMLParser::SetFixSize( const Size& rPixSize,
else if( bPercentHeight && rPixSize.Height() )
{
nPercentHeight = static_cast<sal_uInt8>(rPixSize.Height());
- if( nPercentHeight > 100 )
+ if (nPercentHeight > 100 && nPercentHeight != SwFormatFrameSize::SYNCED)
nPercentHeight = 100;
aTwipSz.setHeight( rTwipDfltSize.Height() );
@@ -245,35 +245,32 @@ void SwHTMLParser::SetSpace( const Size& rPixSpace,
{
sal_Int32 nLeftSpace = 0, nRightSpace = 0;
sal_uInt16 nUpperSpace = 0, nLowerSpace = 0;
- if( (rPixSpace.Width() || rPixSpace.Height()) && Application::GetDefaultDevice() )
+ if( rPixSpace.Width() || rPixSpace.Height() )
{
- Size aTwipSpc( rPixSpace.Width(), rPixSpace.Height() );
- aTwipSpc =
- Application::GetDefaultDevice()->PixelToLogic( aTwipSpc,
- MapMode(MapUnit::MapTwip) );
- nLeftSpace = nRightSpace = aTwipSpc.Width();
- nUpperSpace = nLowerSpace = static_cast<sal_uInt16>(aTwipSpc.Height());
+ nLeftSpace = nRightSpace = o3tl::convert(rPixSpace.Width(), o3tl::Length::px, o3tl::Length::twip);
+ nUpperSpace = nLowerSpace = o3tl::convert(rPixSpace.Height(), o3tl::Length::px, o3tl::Length::twip);
}
// set left/right margin
- const SfxPoolItem *pItem;
- if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, true, &pItem ) )
+ // note: parser never creates SvxLeftMarginItem! must be converted
+ if (const SvxTextLeftMarginItem *const pLeft = rCSS1ItemSet.GetItemIfSet(RES_MARGIN_TEXTLEFT))
{
- // if applicable remove the first line indent
- const SvxLRSpaceItem *pLRItem = static_cast<const SvxLRSpaceItem *>(pItem);
- SvxLRSpaceItem aLRItem( *pLRItem );
- aLRItem.SetTextFirstLineOffset( 0 );
if( rCSS1PropInfo.m_bLeftMargin )
{
- nLeftSpace = aLRItem.GetLeft();
+ // should be SvxLeftMarginItem... "cast" it
+ nLeftSpace = pLeft->GetTextLeft();
rCSS1PropInfo.m_bLeftMargin = false;
}
+ rCSS1ItemSet.ClearItem(RES_MARGIN_TEXTLEFT);
+ }
+ if (const SvxRightMarginItem *const pRight = rCSS1ItemSet.GetItemIfSet(RES_MARGIN_RIGHT))
+ {
if( rCSS1PropInfo.m_bRightMargin )
{
- nRightSpace = aLRItem.GetRight();
+ nRightSpace = pRight->GetRight();
rCSS1PropInfo.m_bRightMargin = false;
}
- rCSS1ItemSet.ClearItem( RES_LR_SPACE );
+ rCSS1ItemSet.ClearItem(RES_MARGIN_RIGHT);
}
if( nLeftSpace > 0 || nRightSpace > 0 )
{
@@ -295,10 +292,9 @@ void SwHTMLParser::SetSpace( const Size& rPixSpace,
}
// set top/bottom margin
- if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, true, &pItem ) )
+ if( const SvxULSpaceItem *pULItem = rCSS1ItemSet.GetItemIfSet( RES_UL_SPACE ) )
{
// if applicable remove the first line indent
- const SvxULSpaceItem *pULItem = static_cast<const SvxULSpaceItem *>(pItem);
if( rCSS1PropInfo.m_bTopMargin )
{
nUpperSpace = pULItem->GetUpper();
@@ -331,7 +327,7 @@ void SwHTMLParser::SetSpace( const Size& rPixSpace,
}
}
-OUString SwHTMLParser::StripQueryFromPath(const OUString& rBase, const OUString& rPath)
+OUString SwHTMLParser::StripQueryFromPath(std::u16string_view rBase, const OUString& rPath)
{
if (!comphelper::isFileUrl(rBase))
return rPath;
@@ -433,9 +429,26 @@ bool SwHTMLParser::InsertEmbed()
aCmdLst.Append( rOption.GetTokenString(), rOption.GetString() );
}
- if (aType == "image/png" && m_aEmbeds.empty())
- // Toplevel <object> for PNG -> that's an image, not an OLE object.
+ static const std::set<std::u16string_view> vAllowlist = {
+ u"image/png",
+ u"image/gif",
+ u"image/x-MS-bmp",
+ u"image/jpeg",
+ u"image/x-wmf",
+ u"image/svg+xml",
+ u"image/tiff",
+ u"image/x-emf",
+ u"image/bmp",
+ u"image/tif",
+ u"image/wmf",
+ };
+
+ if (vAllowlist.find(aType) != vAllowlist.end() && m_aEmbeds.empty())
+ {
+ // Toplevel <object> for an image format -> that's an image, not an OLE object.
+ m_aEmbeds.push(nullptr);
return false;
+ }
SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
SvxCSS1PropertyInfo aPropInfo;
@@ -487,6 +500,12 @@ bool SwHTMLParser::InsertEmbed()
{
// Nested XHTML <object> element: points to replacement graphic.
SwOLENode* pOLENode = m_aEmbeds.top();
+ if (!pOLENode)
+ {
+ // <object> is mapped to an image -> ignore replacement graphic.
+ return true;
+ }
+
svt::EmbeddedObjectRef& rObj = pOLENode->GetOLEObj().GetObject();
Graphic aGraphic;
if (GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aURLObj) != ERRCODE_NONE)
@@ -495,25 +514,27 @@ bool SwHTMLParser::InsertEmbed()
rObj.SetGraphic(aGraphic, aType);
// Set the size of the OLE frame to the size of the graphic.
- OutputDevice* pDevice = Application::GetDefaultDevice();
- if (aSize.getHeight() == USHRT_MAX || aSize.getWidth() == USHRT_MAX)
- {
- Size aPixelSize = aGraphic.GetSizePixel(pDevice);
- if (aSize.getWidth() == USHRT_MAX)
- aSize.setWidth(aPixelSize.getWidth());
- if (aSize.getHeight() == USHRT_MAX)
- aSize.setHeight(aPixelSize.getHeight());
- }
-
SwFrameFormat* pFormat = pOLENode->GetFlyFormat();
if (!pFormat)
return true;
-
SwAttrSet aAttrSet(pFormat->GetAttrSet());
aAttrSet.ClearItem(RES_CNTNT);
- Size aTwipSize(pDevice->PixelToLogic(aSize, MapMode(MapUnit::MapTwip)));
- SwFormatFrameSize aFrameSize(SwFrameSize::Fixed, aTwipSize.Width(), aTwipSize.Height());
- aAttrSet.Put(aFrameSize);
+ Size aDefaultTwipSize(o3tl::convert(aGraphic.GetSizePixel(), o3tl::Length::px, o3tl::Length::twip));
+
+ if (aSize.Width() == USHRT_MAX && bPercentHeight)
+ {
+ // Height is relative, width is not set: keep aspect ratio.
+ aSize.setWidth(SwFormatFrameSize::SYNCED);
+ bPercentWidth = true;
+ }
+ if (aSize.Height() == USHRT_MAX && bPercentWidth)
+ {
+ // Width is relative, height is not set: keep aspect ratio.
+ aSize.setHeight(SwFormatFrameSize::SYNCED);
+ bPercentHeight = true;
+ }
+
+ SetFixSize(aSize, aDefaultTwipSize, bPercentWidth, bPercentHeight, aPropInfo, aAttrSet);
pOLENode->GetDoc().SetFlyFrameAttr(*pFormat, aAttrSet);
return true;
}
@@ -531,13 +552,13 @@ bool SwHTMLParser::InsertEmbed()
if ( xSet.is() )
{
if( bHasURL )
- xSet->setPropertyValue("PluginURL", uno::makeAny( aURL ) );
+ xSet->setPropertyValue("PluginURL", uno::Any( aURL ) );
if( bHasType )
- xSet->setPropertyValue("PluginMimeType", uno::makeAny( aType ) );
+ xSet->setPropertyValue("PluginMimeType", uno::Any( aType ) );
uno::Sequence < beans::PropertyValue > aProps;
aCmdLst.FillSequence( aProps );
- xSet->setPropertyValue("PluginCommands", uno::makeAny( aProps ) );
+ xSet->setPropertyValue("PluginCommands", uno::Any( aProps ) );
}
}
@@ -549,8 +570,8 @@ bool SwHTMLParser::InsertEmbed()
aCnt.SwitchPersistence(xStorage);
aObjName = aCnt.CreateUniqueObjectName();
{
- SvFileStream aFileStream(aURLObj.GetMainURL(INetURLObject::DecodeMechanism::NONE),
- StreamMode::READ);
+ OUString aEmbedURL = aURLObj.GetMainURL(INetURLObject::DecodeMechanism::NONE);
+ SvFileStream aFileStream(aEmbedURL, StreamMode::READ);
uno::Reference<io::XInputStream> xInStream;
SvMemoryStream aMemoryStream;
@@ -559,7 +580,7 @@ bool SwHTMLParser::InsertEmbed()
auto it = m_aAllowedRTFOLEMimeTypes.find(aType);
if (m_aAllowedRTFOLEMimeTypes.empty() || it != m_aAllowedRTFOLEMimeTypes.end())
{
- OString aMagic("{\\object");
+ OString aMagic("{\\object"_ostr);
OString aHeader(read_uInt8s_ToOString(aFileStream, aMagic.getLength()));
aFileStream.Seek(0);
if (aHeader == aMagic)
@@ -574,9 +595,9 @@ bool SwHTMLParser::InsertEmbed()
if (bOwnFormat)
{
uno::Sequence<beans::PropertyValue> aMedium = comphelper::InitPropertySequence(
- { { "InputStream", uno::makeAny(xInStream) },
- { "URL", uno::makeAny(OUString("private:stream")) },
- { "DocumentBaseURL", uno::makeAny(m_sBaseURL) } });
+ { { "InputStream", uno::Any(xInStream) },
+ { "URL", uno::Any(OUString("private:stream")) },
+ { "DocumentBaseURL", uno::Any(m_sBaseURL) } });
xObj = aCnt.InsertEmbeddedObject(aMedium, aName, &m_sBaseURL);
}
else
@@ -588,8 +609,13 @@ bool SwHTMLParser::InsertEmbed()
}
if (!xInStream.is())
- // Non-RTF case.
- xInStream.set(new utl::OStreamWrapper(aFileStream));
+ {
+ // Object data is neither OLE2 in RTF, nor an image. Then map this to an URL that
+ // will be set on the inner image.
+ m_aEmbedURL = aEmbedURL;
+ // Signal success, so the outer object won't fall back to the image handler.
+ return true;
+ }
if (!xObj.is())
{
@@ -604,15 +630,14 @@ bool SwHTMLParser::InsertEmbed()
// Set media type of the native data.
uno::Reference<beans::XPropertySet> xOutStreamProps(xOutStream, uno::UNO_QUERY);
if (xOutStreamProps.is())
- xOutStreamProps->setPropertyValue("MediaType", uno::makeAny(aType));
+ xOutStreamProps->setPropertyValue("MediaType", uno::Any(aType));
}
}
xObj = aCnt.GetEmbeddedObject(aObjName);
}
}
- SfxItemSet aFrameSet( m_xDoc->GetAttrPool(),
- svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aFrameSet( m_xDoc->GetAttrPool() );
if( !IsNewDoc() )
Reader::ResetFrameFormatAttrs( aFrameSet );
@@ -644,7 +669,7 @@ bool SwHTMLParser::InsertEmbed()
// during parsing.
uno::Sequence<beans::PropertyValue> aValues{ comphelper::makePropertyValue("StreamReadOnly",
true) };
- uno::Sequence<uno::Any> aArguments{ uno::makeAny(aValues) };
+ uno::Sequence<uno::Any> aArguments{ uno::Any(aValues) };
xObjInitialization->initialize(aArguments);
}
SwFrameFormat* pFlyFormat =
@@ -655,13 +680,13 @@ bool SwHTMLParser::InsertEmbed()
{
uno::Sequence<beans::PropertyValue> aValues{ comphelper::makePropertyValue("StreamReadOnly",
false) };
- uno::Sequence<uno::Any> aArguments{ uno::makeAny(aValues) };
+ uno::Sequence<uno::Any> aArguments{ uno::Any(aValues) };
xObjInitialization->initialize(aArguments);
}
// set name at FrameFormat
if( !aName.isEmpty() )
- pFlyFormat->SetName( aName );
+ pFlyFormat->SetFormatName( aName );
// set the alternative text
SwNoTextNode *pNoTextNd =
@@ -1090,24 +1115,29 @@ void SwHTMLParser::InsertFloatingFrame()
bool bHasBorder = aFrameDesc.HasFrameBorder();
Size aMargin = aFrameDesc.GetMargin();
- xSet->setPropertyValue("FrameURL", uno::makeAny( aFrameDesc.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ) ) );
- xSet->setPropertyValue("FrameName", uno::makeAny( aName ) );
+ OUString sHRef = aFrameDesc.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE );
+
+ if (INetURLObject(sHRef).IsExoticProtocol())
+ NotifyMacroEventRead();
+
+ xSet->setPropertyValue("FrameURL", uno::Any( sHRef ) );
+ xSet->setPropertyValue("FrameName", uno::Any( aName ) );
if ( eScroll == ScrollingMode::Auto )
xSet->setPropertyValue("FrameIsAutoScroll",
- uno::makeAny( true ) );
+ uno::Any( true ) );
else
xSet->setPropertyValue("FrameIsScrollingMode",
- uno::makeAny( eScroll == ScrollingMode::Yes ) );
+ uno::Any( eScroll == ScrollingMode::Yes ) );
xSet->setPropertyValue("FrameIsBorder",
- uno::makeAny( bHasBorder ) );
+ uno::Any( bHasBorder ) );
xSet->setPropertyValue("FrameMarginWidth",
- uno::makeAny( sal_Int32( aMargin.Width() ) ) );
+ uno::Any( sal_Int32( aMargin.Width() ) ) );
xSet->setPropertyValue("FrameMarginHeight",
- uno::makeAny( sal_Int32( aMargin.Height() ) ) );
+ uno::Any( sal_Int32( aMargin.Height() ) ) );
}
}
}
@@ -1121,8 +1151,7 @@ void SwHTMLParser::InsertFloatingFrame()
ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
// fetch the ItemSet
- SfxItemSet aFrameSet( m_xDoc->GetAttrPool(),
- svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aFrameSet( m_xDoc->GetAttrPool() );
if( !IsNewDoc() )
Reader::ResetFrameFormatAttrs( aFrameSet );
@@ -1150,14 +1179,18 @@ void SwHTMLParser::InsertFloatingFrame()
RegisterFlyFrame( pFlyFormat );
m_bInFloatingFrame = true;
+
+ ++m_nFloatingFrames;
}
-sal_uInt16 SwHTMLWriter::GuessOLENodeFrameType( const SwNode& rNode )
+SwHTMLFrameType SwHTMLWriter::GuessOLENodeFrameType( const SwNode& rNode )
{
- SwOLEObj& rObj = const_cast<SwOLENode*>(rNode.GetOLENode())->GetOLEObj();
-
SwHTMLFrameType eType = HTML_FRMTYPE_OLE;
+ SwOLENode* pOLENode = const_cast<SwOLENode*>(rNode.GetOLENode());
+ assert(pOLENode && "must exist");
+ SwOLEObj& rObj = pOLENode->GetOLEObj();
+
uno::Reference < embed::XClassifiedObject > xClass = rObj.GetOleRef();
SvGlobalName aClass( xClass->getClassID() );
if( aClass == SvGlobalName( SO3_PLUGIN_CLASSID ) )
@@ -1175,17 +1208,15 @@ sal_uInt16 SwHTMLWriter::GuessOLENodeFrameType( const SwNode& rNode )
}
#endif
- return static_cast< sal_uInt16 >(eType);
+ return eType;
}
-Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFormat,
+SwHTMLWriter& OutHTML_FrameFormatOLENode( SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat,
bool bInCntnr )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
- sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
- SwOLENode *pOLENd = rHTMLWrt.m_pDoc->GetNodes()[ nStt ]->GetOLENode();
+ SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
+ SwOLENode *pOLENd = rWrt.m_pDoc->GetNodes()[ nStt ]->GetOLENode();
OSL_ENSURE( pOLENd, "OLE-Node expected" );
if( !pOLENd )
@@ -1209,20 +1240,19 @@ Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFor
HtmlFrmOpts nFrameOpts;
// if possible output a line break before the "object"
- if( rHTMLWrt.m_bLFPossible )
- rHTMLWrt.OutNewLine( true );
+ if (rWrt.IsLFPossible())
+ rWrt.OutNewLine( true );
if( !rFrameFormat.GetName().isEmpty() )
- rHTMLWrt.OutImplicitMark( rFrameFormat.GetName(),
+ rWrt.OutImplicitMark( rFrameFormat.GetName(),
"ole" );
uno::Any aAny;
SvGlobalName aGlobName( xObj->getClassID() );
- OStringBuffer sOut;
- sOut.append('<');
+ OStringBuffer sOut("<");
if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
{
// first the plug-in specifics
- sOut.append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_embed);
+ sOut.append(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_embed);
OUString aStr;
OUString aURL;
@@ -1235,10 +1265,10 @@ Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFor
if( !aURL.isEmpty() )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_src)
- .append("=\"");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( rWrt.Strm(), aURL, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_src "=\"");
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aURL );
sOut.append('\"');
}
@@ -1246,10 +1276,10 @@ Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFor
aAny = xSet->getPropertyValue("PluginMimeType");
if( (aAny >>= aType) && !aType.isEmpty() )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_type)
- .append("=\"");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( rWrt.Strm(), aType, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_type "=\"");
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aType );
sOut.append('\"');
}
@@ -1257,7 +1287,7 @@ Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFor
css::text::WrapTextMode_THROUGH == rFrameFormat.GetSurround().GetSurround() )
{
// A HIDDEN plug-in
- sOut.append(' ').append(OOO_STRING_SW_HTML_O_Hidden);
+ sOut.append(" " OOO_STRING_SW_HTML_O_Hidden);
nFrameOpts = HTML_FRMOPTS_HIDDEN_EMBED;
bHiddenEmbed = true;
}
@@ -1271,7 +1301,7 @@ Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFor
{
// or the applet specifics
- sOut.append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_applet);
+ sOut.append(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_applet);
// CODEBASE
OUString aCd;
@@ -1281,10 +1311,10 @@ Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFor
OUString sCodeBase( URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aCd) );
if( !sCodeBase.isEmpty() )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_codebase)
- .append("=\"");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( rWrt.Strm(), sCodeBase, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_codebase "=\"");
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sCodeBase );
sOut.append('\"');
}
}
@@ -1293,10 +1323,10 @@ Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFor
OUString aClass;
aAny = xSet->getPropertyValue("AppletCode");
aAny >>= aClass;
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_code)
- .append("=\"");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( rWrt.Strm(), aClass, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_code "=\"");
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aClass );
sOut.append('\"');
// NAME
@@ -1305,10 +1335,10 @@ Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFor
aAny >>= aAppletName;
if( !aAppletName.isEmpty() )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_name)
- .append("=\"");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( rWrt.Strm(), aAppletName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_name "=\"");
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aAppletName );
sOut.append('\"');
}
@@ -1316,7 +1346,7 @@ Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFor
aAny = xSet->getPropertyValue("AppletIsScript");
aAny >>= bScript;
if( bScript )
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_mayscript);
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_mayscript);
nFrameOpts = bInCntnr ? HTML_FRMOPTS_APPLET_CNTNR
: HTML_FRMOPTS_APPLET;
@@ -1325,26 +1355,26 @@ Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFor
{
// or the Floating-Frame specifics
- sOut.append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_iframe);
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ sOut.append(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_iframe);
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
SfxFrameHTMLWriter::Out_FrameDescriptor( rWrt.Strm(), rWrt.GetBaseURL(),
- xSet,
- rHTMLWrt.m_eDestEnc,
- &rHTMLWrt.m_aNonConvertableCharacters );
+ xSet );
nFrameOpts = bInCntnr ? HTML_FRMOPTS_IFRAME_CNTNR
: HTML_FRMOPTS_IFRAME;
}
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
// ALT, WIDTH, HEIGHT, HSPACE, VSPACE, ALIGN
- if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
+ if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
nFrameOpts |= HTML_FRMOPTS_OLE_CSS1;
- OString aEndTags = rHTMLWrt.OutFrameFormatOptions( rFrameFormat, pOLENd->GetTitle(), nFrameOpts );
- if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
- rHTMLWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameOpts );
+ OString aEndTags = rWrt.OutFrameFormatOptions( rFrameFormat, pOLENd->GetTitle(), nFrameOpts );
+ if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
+ rWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameOpts );
if( aGlobName == SvGlobalName( SO3_APPLET_CLASSID ) )
{
@@ -1368,9 +1398,9 @@ Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFor
{
const OUString& rValue = rCommand.GetArgument();
rWrt.Strm().WriteChar( ' ' );
- HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
- rWrt.Strm().WriteCharPtr( "=\"" );
- HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters ).WriteChar( '\"' );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rName );
+ rWrt.Strm().WriteOString( "=\"" );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rValue ).WriteChar( '\"' );
}
else if( SwHtmlOptType::PARAM == nType )
{
@@ -1378,9 +1408,9 @@ Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFor
}
}
- rHTMLWrt.Strm().WriteChar( '>' );
+ rWrt.Strm().WriteChar( '>' );
- rHTMLWrt.IncIndentLevel(); // indent the applet content
+ rWrt.IncIndentLevel(); // indent the applet content
size_t ii = aParams.size();
while( ii > 0 )
@@ -1388,23 +1418,24 @@ Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFor
const SvCommand& rCommand = aCommands[ aParams[--ii] ];
const OUString& rName = rCommand.GetCommand();
const OUString& rValue = rCommand.GetArgument();
- rHTMLWrt.OutNewLine();
- OStringBuffer sBuf;
- sBuf.append('<').append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_param)
- .append(' ').append(OOO_STRING_SVTOOLS_HTML_O_name)
- .append("=\"");
- rWrt.Strm().WriteOString( sBuf.makeStringAndClear() );
- HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
- sBuf.append("\" ").append(OOO_STRING_SVTOOLS_HTML_O_value)
- .append("=\"");
- rWrt.Strm().WriteOString( sBuf.makeStringAndClear() );
- HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters ).WriteCharPtr( "\">" );
+ rWrt.OutNewLine();
+ sOut.append(
+ "<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_param
+ " " OOO_STRING_SVTOOLS_HTML_O_name
+ "=\"");
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rName );
+ sOut.append("\" " OOO_STRING_SVTOOLS_HTML_O_value "=\"");
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rValue ).WriteOString( "\">" );
}
- rHTMLWrt.DecIndentLevel(); // indent the applet content
+ rWrt.DecIndentLevel(); // indent the applet content
if( aCommands.size() )
- rHTMLWrt.OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_applet, false );
+ rWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_applet), false );
}
else if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
{
@@ -1425,19 +1456,19 @@ Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFor
{
const OUString& rValue = rCommand.GetArgument();
rWrt.Strm().WriteChar( ' ' );
- HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
- rWrt.Strm().WriteCharPtr( "=\"" );
- HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters ).WriteChar( '\"' );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rName );
+ rWrt.Strm().WriteOString( "=\"" );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rValue ).WriteChar( '\"' );
}
}
- rHTMLWrt.Strm().WriteChar( '>' );
+ rWrt.Strm().WriteChar( '>' );
}
else
{
// and for Floating-Frames just output another </IFRAME>
- rHTMLWrt.Strm().WriteChar( '>' );
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_iframe, false );
+ rWrt.Strm().WriteChar( '>' );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_iframe), false );
}
if( !aEndTags.isEmpty() )
@@ -1446,32 +1477,141 @@ Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFor
return rWrt;
}
-Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrameFormat,
- bool bInCntnr )
+static void OutHTMLGraphic(SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat, SwOLENode* pOLENd,
+ const Graphic& rGraphic, bool bObjectOpened, bool bInCntnr)
+{
+ OUString aGraphicURL;
+ OUString aMimeType;
+ if (!rWrt.mbEmbedImages)
+ {
+ const OUString* pTempFileName = rWrt.GetOrigFileName();
+ if (pTempFileName)
+ aGraphicURL = *pTempFileName;
+
+ OUString aFilterName(u"JPG"_ustr);
+ XOutFlags nFlags = XOutFlags::UseGifIfPossible | XOutFlags::UseNativeIfPossible;
+
+ if (bObjectOpened)
+ {
+ aFilterName = u"PNG"_ustr;
+ nFlags = XOutFlags::NONE;
+ aMimeType = u"image/png"_ustr;
+
+ if (rGraphic.GetType() == GraphicType::NONE)
+ {
+ // The OLE Object has no replacement image, write a stub.
+ aGraphicURL = lcl_CalculateFileName(rWrt.GetOrigFileName(), rGraphic, u"png");
+ osl::File aFile(aGraphicURL);
+ aFile.open(osl_File_OpenFlag_Create);
+ aFile.close();
+ }
+ }
+
+ ErrCode nErr = XOutBitmap::WriteGraphic(rGraphic, aGraphicURL, aFilterName, nFlags);
+ if (nErr) // error, don't write anything
+ {
+ rWrt.m_nWarn = WARN_SWG_POOR_LOAD;
+ if (bObjectOpened) // Still at least close the tag.
+ rWrt.Strm().WriteOString(
+ Concat2View("</" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object ">"));
+ return;
+ }
+ aGraphicURL = URIHelper::SmartRel2Abs(INetURLObject(rWrt.GetBaseURL()), aGraphicURL,
+ URIHelper::GetMaybeFileHdl());
+ }
+ HtmlFrmOpts nFlags = bInCntnr ? HtmlFrmOpts::GenImgAllMask : HtmlFrmOpts::GenImgMask;
+ if (bObjectOpened)
+ nFlags |= HtmlFrmOpts::Replacement;
+ HtmlWriter aHtml(rWrt.Strm(), rWrt.maNamespace);
+ OutHTML_ImageStart(aHtml, rWrt, rFrameFormat, aGraphicURL, rGraphic, pOLENd->GetTitle(),
+ pOLENd->GetTwipSize(), nFlags, "ole", nullptr, aMimeType);
+ OutHTML_ImageEnd(aHtml, rWrt);
+}
+
+static void OutHTMLStartObject(SwHTMLWriter& rWrt, const OUString& rFileName, const OUString& rFileType)
+{
+ OUString aFileName = URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), rFileName);
+
+ if (rWrt.IsLFPossible())
+ rWrt.OutNewLine();
+ rWrt.Strm().WriteOString(
+ Concat2View("<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object));
+ rWrt.Strm().WriteOString(Concat2View(" data=\"" + aFileName.toUtf8() + "\""));
+ if (!rFileType.isEmpty())
+ rWrt.Strm().WriteOString(Concat2View(" type=\"" + rFileType.toUtf8() + "\""));
+ rWrt.Strm().WriteOString(">");
+ rWrt.SetLFPossible(true);
+}
+
+static void OutHTMLEndObject(SwHTMLWriter& rWrt)
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
+ rWrt.Strm().WriteOString(
+ Concat2View("</" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object ">"));
+}
+
+static bool TrySaveFormulaAsPDF(SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat,
+ SwOLENode* pOLENd, bool bWriteReplacementGraphic, bool bInCntnr)
+{
+ if (!rWrt.mbReqIF)
+ return false;
+ if (!rWrt.m_bExportFormulasAsPDF)
+ return false;
+
+ auto xTextContent = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
+ *rWrt.m_pDoc, const_cast<SwFrameFormat*>(&rFrameFormat));
+ uno::Reference<frame::XStorable> xStorable(xTextContent->getEmbeddedObject(), uno::UNO_QUERY);
+ uno::Reference<lang::XServiceInfo> xServiceInfo(xStorable, uno::UNO_QUERY);
+ if (!xServiceInfo)
+ return false;
+ if (!xServiceInfo->supportsService(u"com.sun.star.formula.FormulaProperties"_ustr))
+ return false;
+
+ Graphic aGraphic(xTextContent->getReplacementGraphic());
+ OUString aFileName = lcl_CalculateFileName(rWrt.GetOrigFileName(), aGraphic, u"pdf");
+
+ utl::MediaDescriptor aDescr;
+ aDescr[u"FilterName"_ustr] <<= u"math_pdf_Export"_ustr;
+ // Properties from starmath/inc/unomodel.hxx
+ aDescr[u"FilterData"_ustr] <<= comphelper::InitPropertySequence({
+ { u"TitleRow"_ustr, css::uno::Any(false) },
+ { u"FormulaText"_ustr, css::uno::Any(false) },
+ { u"Border"_ustr, css::uno::Any(false) },
+ { u"PrintFormat"_ustr, css::uno::Any(sal_Int32(1)) }, // PRINT_SIZE_SCALED
+ });
+ xStorable->storeToURL(aFileName, aDescr.getAsConstPropertyValueList());
+
+ OutHTMLStartObject(rWrt, aFileName, u"application/pdf"_ustr);
+
+ if (bWriteReplacementGraphic)
+ OutHTMLGraphic(rWrt, rFrameFormat, pOLENd, aGraphic, true, bInCntnr);
+
+ OutHTMLEndObject(rWrt);
+ return true;
+}
+
+SwHTMLWriter& OutHTML_FrameFormatOLENodeGrf( SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat,
+ bool bInCntnr, bool bWriteReplacementGraphic )
+{
const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
- sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
- SwOLENode *pOLENd = rHTMLWrt.m_pDoc->GetNodes()[ nStt ]->GetOLENode();
+ SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
+ SwOLENode *pOLENd = rWrt.m_pDoc->GetNodes()[ nStt ]->GetOLENode();
OSL_ENSURE( pOLENd, "OLE-Node expected" );
if( !pOLENd )
return rWrt;
- if (rHTMLWrt.mbSkipImages)
+ if (rWrt.mbSkipImages)
{
// If we skip images, embedded objects would be completely lost.
// Instead, try to use the HTML export of the embedded object.
- uno::Reference<text::XTextContent> xTextContent = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(*rHTMLWrt.m_pDoc, const_cast<SwFrameFormat*>(&rFrameFormat));
- uno::Reference<document::XEmbeddedObjectSupplier2> xEmbeddedObjectSupplier(xTextContent, uno::UNO_QUERY);
- uno::Reference<frame::XStorable> xStorable(xEmbeddedObjectSupplier->getEmbeddedObject(), uno::UNO_QUERY);
+ auto xTextContent = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(*rWrt.m_pDoc, const_cast<SwFrameFormat*>(&rFrameFormat));
+ uno::Reference<frame::XStorable> xStorable(xTextContent->getEmbeddedObject(), uno::UNO_QUERY);
SAL_WARN_IF(!xStorable.is(), "sw.html", "OutHTML_FrameFormatOLENodeGrf: no embedded object");
// Figure out what is the filter name of the embedded object.
- uno::Reference<lang::XServiceInfo> xServiceInfo(xStorable, uno::UNO_QUERY);
OUString aFilter;
- if (xServiceInfo.is())
+ if (uno::Reference<lang::XServiceInfo> xServiceInfo{ xStorable, uno::UNO_QUERY })
{
if (xServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument"))
aFilter = "HTML (StarCalc)";
@@ -1479,7 +1619,7 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame
aFilter = "HTML (StarWriter)";
}
- if (xStorable.is() && !aFilter.isEmpty())
+ if (!aFilter.isEmpty())
{
try
{
@@ -1494,9 +1634,9 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame
SAL_WARN_IF(aStream.GetSize()>=o3tl::make_unsigned(SAL_MAX_INT32), "sw.html", "Stream can't fit in OString");
OString aData(static_cast<const char*>(aStream.GetData()), static_cast<sal_Int32>(aStream.GetSize()));
// Wrap output in a <span> tag to avoid 'HTML parser error: Unexpected end tag: p'
- HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span);
+ HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span));
rWrt.Strm().WriteOString(aData);
- HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span, false);
+ HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false);
}
catch ( uno::Exception& )
{
@@ -1506,6 +1646,9 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame
return rWrt;
}
+ if (TrySaveFormulaAsPDF(rWrt, rFrameFormat, pOLENd, bWriteReplacementGraphic, bInCntnr))
+ return rWrt;
+
if ( !pOLENd->GetGraphic() )
{
SAL_WARN("sw.html", "Unexpected missing OLE fallback graphic");
@@ -1514,21 +1657,21 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame
Graphic aGraphic( *pOLENd->GetGraphic() );
- SwDocShell* pDocSh = rHTMLWrt.m_pDoc->GetDocShell();
+ SwDocShell* pDocSh = rWrt.m_pDoc->GetDocShell();
bool bObjectOpened = false;
OUString aRTFType = "text/rtf";
- if (!rHTMLWrt.m_aRTFOLEMimeType.isEmpty())
+ if (!rWrt.m_aRTFOLEMimeType.isEmpty())
{
- aRTFType = rHTMLWrt.m_aRTFOLEMimeType;
+ aRTFType = rWrt.m_aRTFOLEMimeType;
}
- if (rHTMLWrt.mbXHTML && pDocSh)
+ if (rWrt.mbXHTML && pDocSh)
{
// Map native data to an outer <object> element.
// Calculate the file name, which is meant to be the same as the
// replacement image, just with a .ole extension.
- OUString aFileName = lcl_CalculateFileName(rHTMLWrt.GetOrigFileName(), aGraphic, "ole");
+ OUString aFileName = lcl_CalculateFileName(rWrt.GetOrigFileName(), aGraphic, u"ole");
// Write the data.
SwOLEObj& rOLEObj = pOLENd->GetOLEObj();
@@ -1549,7 +1692,7 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame
if (xStream.is())
{
std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xStream));
- if (SwReqIfReader::WrapOleInRtf(*pStream, aOutStream, *pOLENd))
+ if (SwReqIfReader::WrapOleInRtf(*pStream, aOutStream, *pOLENd, rFrameFormat))
{
// Data always wrapped in RTF.
aFileType = aRTFType;
@@ -1564,11 +1707,11 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame
// export it.
pOLENd->GetTwipSize();
SvMemoryStream aMemory;
- tools::SvRef<SotStorage> pStorage = new SotStorage(aMemory);
+ rtl::Reference<SotStorage> pStorage = new SotStorage(aMemory);
aOLEExp.ExportOLEObject(rOLEObj.GetObject(), *pStorage);
pStorage->Commit();
aMemory.Seek(0);
- if (SwReqIfReader::WrapOleInRtf(aMemory, aOutStream, *pOLENd))
+ if (SwReqIfReader::WrapOleInRtf(aMemory, aOutStream, *pOLENd, rFrameFormat))
{
// Data always wrapped in RTF.
aFileType = aRTFType;
@@ -1603,72 +1746,18 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame
aFileType = aRTFType;
}
}
- aFileName = URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aFileName);
// Refer to this data.
- if (rHTMLWrt.m_bLFPossible)
- rHTMLWrt.OutNewLine();
- rWrt.Strm().WriteOString("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object);
- rWrt.Strm().WriteOString(" data=\"" + aFileName.toUtf8() + "\"");
- if (!aFileType.isEmpty())
- rWrt.Strm().WriteOString(" type=\"" + aFileType.toUtf8() + "\"");
- rWrt.Strm().WriteOString(">");
+ OutHTMLStartObject(rWrt, aFileName, aFileType);
bObjectOpened = true;
- rHTMLWrt.m_bLFPossible = true;
}
- OUString aGraphicURL;
- OUString aMimeType;
- if(!rHTMLWrt.mbEmbedImages)
- {
- const OUString* pTempFileName = rHTMLWrt.GetOrigFileName();
- if(pTempFileName)
- aGraphicURL = *pTempFileName;
-
- OUString aFilterName("JPG");
- XOutFlags nFlags = XOutFlags::UseGifIfPossible | XOutFlags::UseNativeIfPossible;
-
- if (bObjectOpened)
- {
- aFilterName = "PNG";
- nFlags = XOutFlags::NONE;
- aMimeType = "image/png";
-
- if (aGraphic.GetType() == GraphicType::NONE)
- {
- // The OLE Object has no replacement image, write a stub.
- aGraphicURL = lcl_CalculateFileName(rHTMLWrt.GetOrigFileName(), aGraphic, "png");
- osl::File aFile(aGraphicURL);
- aFile.open(osl_File_OpenFlag_Create);
- aFile.close();
- }
- }
-
- ErrCode nErr = XOutBitmap::WriteGraphic( aGraphic, aGraphicURL,
- aFilterName,
- nFlags );
- if( nErr ) // error, don't write anything
- {
- rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
- return rWrt;
- }
- aGraphicURL = URIHelper::SmartRel2Abs(
- INetURLObject(rWrt.GetBaseURL()), aGraphicURL,
- URIHelper::GetMaybeFileHdl() );
-
- }
- HtmlFrmOpts nFlags = bInCntnr ? HtmlFrmOpts::GenImgAllMask
- : HtmlFrmOpts::GenImgMask;
- if (bObjectOpened)
- nFlags |= HtmlFrmOpts::Replacement;
- OutHTML_Image( rWrt, rFrameFormat, aGraphicURL, aGraphic,
- pOLENd->GetTitle(), pOLENd->GetTwipSize(),
- nFlags, "ole", nullptr, aMimeType );
+ if (!bObjectOpened || bWriteReplacementGraphic)
+ OutHTMLGraphic(rWrt, rFrameFormat, pOLENd, aGraphic, bObjectOpened, bInCntnr);
if (bObjectOpened)
// Close native data.
- rWrt.Strm().WriteOString("</" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object
- ">");
+ OutHTMLEndObject(rWrt);
return rWrt;
}
diff --git a/sw/source/filter/html/htmlreqifreader.cxx b/sw/source/filter/html/htmlreqifreader.cxx
index d656f51bc0cb..d784312b6fd2 100644
--- a/sw/source/filter/html/htmlreqifreader.cxx
+++ b/sw/source/filter/html/htmlreqifreader.cxx
@@ -21,6 +21,13 @@
#include <vcl/cvtgrf.hxx>
#include <ndole.hxx>
#include <sal/log.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include <vcl/wmf.hxx>
+#include <comphelper/propertyvalue.hxx>
+#include <fmtfsize.hxx>
+#include <frmfmt.hxx>
+
+using namespace com::sun::star;
namespace
{
@@ -65,11 +72,11 @@ bool ReqIfRtfReader::WriteObjectData(SvStream& rOLE)
}
/// Looks up what OLE1 calls the ClassName, see [MS-OLEDS] 2.3.8 CompObjStream.
-OString ExtractOLEClassName(const tools::SvRef<SotStorage>& xStorage)
+OString ExtractOLEClassName(const rtl::Reference<SotStorage>& xStorage)
{
OString aRet;
- tools::SvRef<SotStorageStream> pCompObj = xStorage->OpenSotStream("\1CompObj");
+ rtl::Reference<SotStorageStream> pCompObj = xStorage->OpenSotStream("\1CompObj");
if (!pCompObj)
return aRet;
@@ -99,8 +106,8 @@ bool ParseOLE2Presentation(SvStream& rOle2, sal_uInt32& nWidth, sal_uInt32& nHei
{
// See [MS-OLEDS] 2.3.4, OLEPresentationStream
rOle2.Seek(0);
- tools::SvRef<SotStorage> pStorage = new SotStorage(rOle2);
- tools::SvRef<SotStorageStream> xOle2Presentation
+ rtl::Reference<SotStorage> pStorage = new SotStorage(rOle2);
+ rtl::Reference<SotStorageStream> xOle2Presentation
= pStorage->OpenSotStream("\002OlePres000", StreamMode::STD_READ);
// Read AnsiClipboardFormat.
@@ -137,6 +144,15 @@ bool ParseOLE2Presentation(SvStream& rOle2, sal_uInt32& nWidth, sal_uInt32& nHei
// Read Data.
if (nSize > xOle2Presentation->remainingSize())
return false;
+
+ if (nSize <= 64)
+ {
+ SAL_WARN("sw.html",
+ "ParseOLE2Presentation: ignoring potentially broken small preview: size is "
+ << nSize);
+ return false;
+ }
+
std::vector<char> aBuffer(nSize);
xOle2Presentation->ReadBytes(aBuffer.data(), aBuffer.size());
rPresentationData.WriteBytes(aBuffer.data(), aBuffer.size());
@@ -148,10 +164,10 @@ bool ParseOLE2Presentation(SvStream& rOle2, sal_uInt32& nWidth, sal_uInt32& nHei
* Inserts an OLE1 header before an OLE2 storage, assuming that the storage has an Ole10Native
* stream.
*/
-OString InsertOLE1HeaderFromOle10NativeStream(const tools::SvRef<SotStorage>& xStorage,
+OString InsertOLE1HeaderFromOle10NativeStream(const rtl::Reference<SotStorage>& xStorage,
SwOLENode& rOLENode, SvStream& rOle1)
{
- tools::SvRef<SotStorageStream> xOle1Stream
+ rtl::Reference<SotStorageStream> xOle1Stream
= xStorage->OpenSotStream("\1Ole10Native", StreamMode::STD_READ);
sal_uInt32 nOle1Size = 0;
xOle1Stream->ReadUInt32(nOle1Size);
@@ -159,7 +175,7 @@ OString InsertOLE1HeaderFromOle10NativeStream(const tools::SvRef<SotStorage>& xS
OString aClassName;
if (xStorage->GetClassName() == SvGlobalName(0x0003000A, 0, 0, 0xc0, 0, 0, 0, 0, 0, 0, 0x46))
{
- aClassName = "PBrush";
+ aClassName = "PBrush"_ostr;
}
else
{
@@ -169,7 +185,7 @@ OString InsertOLE1HeaderFromOle10NativeStream(const tools::SvRef<SotStorage>& xS
SAL_WARN("sw.html", "InsertOLE1HeaderFromOle10NativeStream: unexpected class id: "
<< xStorage->GetClassName().GetHexName());
}
- aClassName = "Package";
+ aClassName = "Package"_ostr;
}
// Write ObjectHeader, see [MS-OLEDS] 2.2.4.
@@ -224,7 +240,7 @@ OString InsertOLE1HeaderFromOle10NativeStream(const tools::SvRef<SotStorage>& xS
// FormatID: constant means the ClassName field is present.
rOle1.WriteUInt32(0x00000005);
// ClassName: null terminated pascal string.
- OString aPresentationClassName("METAFILEPICT");
+ OString aPresentationClassName("METAFILEPICT"_ostr);
rOle1.WriteUInt32(aPresentationClassName.getLength() + 1);
rOle1.WriteOString(aPresentationClassName);
rOle1.WriteChar(0);
@@ -255,9 +271,9 @@ OString InsertOLE1Header(SvStream& rOle2, SvStream& rOle1, sal_uInt32& nWidth, s
sal_uInt64 nPresentationData)
{
rOle2.Seek(0);
- tools::SvRef<SotStorage> xStorage(new SotStorage(rOle2));
+ rtl::Reference<SotStorage> xStorage(new SotStorage(rOle2));
if (xStorage->GetError() != ERRCODE_NONE)
- return OString();
+ return {};
if (xStorage->IsStream("\1Ole10Native"))
{
@@ -303,7 +319,7 @@ OString InsertOLE1Header(SvStream& rOle2, SvStream& rOle1, sal_uInt32& nWidth, s
// FormatID: constant means the ClassName field is present.
rOle1.WriteUInt32(0x00000005);
// ClassName: null terminated pascal string.
- OString aPresentationClassName("METAFILEPICT");
+ OString aPresentationClassName("METAFILEPICT"_ostr);
rOle1.WriteUInt32(aPresentationClassName.getLength() + 1);
rOle1.WriteOString(aPresentationClassName);
rOle1.WriteChar(0);
@@ -325,8 +341,8 @@ OString InsertOLE1Header(SvStream& rOle2, SvStream& rOle1, sal_uInt32& nWidth, s
rOle1.WriteUInt32(nWidth);
// Height.
rOle1.WriteUInt32(nHeight * -1);
- // PresentationDataSize
- rOle1.WriteUInt32(8 + nPresentationData);
+ // PresentationDataSize: size of (reserved fields + pBytes).
+ rOle1.WriteUInt32(8 + nBytes);
// Reserved1-4.
rOle1.WriteUInt16(0x0008);
rOle1.WriteUInt16(0x31b1);
@@ -342,31 +358,31 @@ void WrapOleGraphicInRtf(SvStream& rRtf, sal_uInt32 nWidth, sal_uInt32 nHeight,
const sal_uInt8* pPresentationData, sal_uInt64 nPresentationData)
{
// Start result.
- rRtf.WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_RESULT);
+ rRtf.WriteOString("{" OOO_STRING_SVTOOLS_RTF_RESULT);
// Start pict.
- rRtf.WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_PICT);
+ rRtf.WriteOString("{" OOO_STRING_SVTOOLS_RTF_PICT);
- rRtf.WriteCharPtr(OOO_STRING_SVTOOLS_RTF_WMETAFILE "8");
- rRtf.WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PICW);
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_WMETAFILE "8");
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_PICW);
rRtf.WriteOString(OString::number(nWidth));
- rRtf.WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PICH);
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_PICH);
rRtf.WriteOString(OString::number(nHeight));
- rRtf.WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PICWGOAL);
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_PICWGOAL);
rRtf.WriteOString(OString::number(nWidth));
- rRtf.WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PICHGOAL);
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_PICHGOAL);
rRtf.WriteOString(OString::number(nHeight));
if (pPresentationData)
{
- rRtf.WriteCharPtr(SAL_NEWLINE_STRING);
+ rRtf.WriteOString(SAL_NEWLINE_STRING);
msfilter::rtfutil::WriteHex(pPresentationData, nPresentationData, &rRtf);
}
// End pict.
- rRtf.WriteCharPtr("}");
+ rRtf.WriteOString("}");
// End result.
- rRtf.WriteCharPtr("}");
+ rRtf.WriteOString("}");
}
}
@@ -391,7 +407,7 @@ bool ExtractOleFromRtf(SvStream& rRtf, SvStream& rOle, bool& bOwnFormat)
if (!xReader->WriteObjectData(rOle))
return false;
- tools::SvRef<SotStorage> pStorage = new SotStorage(rOle);
+ rtl::Reference<SotStorage> pStorage = new SotStorage(rOle);
OUString aFilterName = SvxMSDffManager::GetFilterNameFromClassID(pStorage->GetClassName());
bOwnFormat = !aFilterName.isEmpty();
if (!bOwnFormat)
@@ -413,7 +429,8 @@ bool ExtractOleFromRtf(SvStream& rRtf, SvStream& rOle, bool& bOwnFormat)
return true;
}
-bool WrapOleInRtf(SvStream& rOle2, SvStream& rRtf, SwOLENode& rOLENode)
+bool WrapOleInRtf(SvStream& rOle2, SvStream& rRtf, SwOLENode& rOLENode,
+ const SwFrameFormat& rFormat)
{
sal_uInt64 nPos = rOle2.Tell();
comphelper::ScopeGuard g([&rOle2, nPos] { rOle2.Seek(nPos); });
@@ -422,7 +439,7 @@ bool WrapOleInRtf(SvStream& rOle2, SvStream& rRtf, SwOLENode& rOLENode)
SvMemoryStream aOLE1;
// Prepare presentation data early, so it's available to both OLE1 and RTF.
- Size aSize(rOLENode.GetTwipSize());
+ Size aSize = rFormat.GetFrameSize().GetSize();
sal_uInt32 nWidth = aSize.getWidth();
sal_uInt32 nHeight = aSize.getHeight();
const Graphic* pGraphic = rOLENode.GetGraphic();
@@ -431,8 +448,10 @@ bool WrapOleInRtf(SvStream& rOle2, SvStream& rRtf, SwOLENode& rOLENode)
SvMemoryStream aGraphicStream;
if (pGraphic)
{
- if (GraphicConverter::Export(aGraphicStream, *pGraphic, ConvertDataFormat::WMF)
- == ERRCODE_NONE)
+ uno::Sequence<beans::PropertyValue> aFilterData
+ = { comphelper::makePropertyValue("EmbedEMF", false) };
+ FilterConfigItem aConfigItem(&aFilterData);
+ if (ConvertGraphicToWMF(*pGraphic, aGraphicStream, &aConfigItem))
{
pPresentationData = static_cast<const sal_uInt8*>(aGraphicStream.GetData());
nPresentationData = aGraphicStream.TellEnd();
@@ -443,28 +462,28 @@ bool WrapOleInRtf(SvStream& rOle2, SvStream& rRtf, SwOLENode& rOLENode)
pPresentationData, nPresentationData);
// Start object.
- rRtf.WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_OBJECT);
- rRtf.WriteCharPtr(OOO_STRING_SVTOOLS_RTF_OBJEMB);
+ rRtf.WriteOString("{" OOO_STRING_SVTOOLS_RTF_OBJECT);
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_OBJEMB);
// Start objclass.
- rRtf.WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_OBJCLASS " ");
+ rRtf.WriteOString("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_OBJCLASS " ");
rRtf.WriteOString(aClassName);
// End objclass.
- rRtf.WriteCharPtr("}");
+ rRtf.WriteOString("}");
// Object size.
- rRtf.WriteCharPtr(OOO_STRING_SVTOOLS_RTF_OBJW);
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_OBJW);
rRtf.WriteOString(OString::number(nWidth));
- rRtf.WriteCharPtr(OOO_STRING_SVTOOLS_RTF_OBJH);
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_OBJH);
rRtf.WriteOString(OString::number(nHeight));
// Start objdata.
- rRtf.WriteCharPtr(
+ rRtf.WriteOString(
"{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_OBJDATA SAL_NEWLINE_STRING);
msfilter::rtfutil::WriteHex(static_cast<const sal_uInt8*>(aOLE1.GetData()), aOLE1.GetSize(),
&rRtf);
// End objdata.
- rRtf.WriteCharPtr("}");
+ rRtf.WriteOString("}");
if (pPresentationData)
{
@@ -472,72 +491,160 @@ bool WrapOleInRtf(SvStream& rOle2, SvStream& rRtf, SwOLENode& rOLENode)
}
// End object.
- rRtf.WriteCharPtr("}");
+ rRtf.WriteOString("}");
return true;
}
-bool WrapGraphicInRtf(const Graphic& rGraphic, const Size& rLogicSize, SvStream& rRtf)
+bool WrapGraphicInRtf(const Graphic& rGraphic, const SwFrameFormat& rFormat, SvStream& rRtf)
{
- rRtf.WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_PICT);
-
- GfxLink aLink = rGraphic.GetGfxLink();
- const sal_uInt8* pGraphicAry = aLink.GetData();
- sal_uInt64 nSize = aLink.GetDataSize();
- OString aBlipType;
- bool bIsWMF = false;
- switch (aLink.GetType())
+ // Start object.
+ rRtf.WriteOString("{" OOO_STRING_SVTOOLS_RTF_OBJECT);
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_OBJEMB);
+
+ // Object size: as used in the document model (not pixel size)
+ Size aSize = rFormat.GetFrameSize().GetSize();
+ sal_uInt32 nWidth = aSize.getWidth();
+ sal_uInt32 nHeight = aSize.getHeight();
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_OBJW);
+ rRtf.WriteOString(OString::number(nWidth));
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_OBJH);
+ rRtf.WriteOString(OString::number(nHeight));
+ rRtf.WriteOString(SAL_NEWLINE_STRING);
+
+ // Start objclass.
+ rRtf.WriteOString("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_OBJCLASS " ");
+ OString aClassName("PBrush"_ostr);
+ rRtf.WriteOString(aClassName);
+ // End objclass.
+ rRtf.WriteOString("}");
+ rRtf.WriteOString(SAL_NEWLINE_STRING);
+
+ // Start objdata.
+ rRtf.WriteOString("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_OBJDATA " ");
+
+ SvMemoryStream aOle1;
+ // Write ObjectHeader, see [MS-OLEDS] 2.2.4.
+ // OLEVersion.
+ aOle1.WriteUInt32(0x00000501);
+
+ // FormatID is EmbeddedObject.
+ aOle1.WriteUInt32(0x00000002);
+
+ // ClassName
+ aOle1.WriteUInt32(aClassName.getLength() + 1);
+ aOle1.WriteOString(aClassName);
+ // Null terminated pascal string.
+ aOle1.WriteChar(0);
+
+ // TopicName.
+ aOle1.WriteUInt32(0);
+
+ // ItemName.
+ aOle1.WriteUInt32(0);
+
+ // NativeDataSize
+ SvMemoryStream aNativeData;
+
+ // Set white background for the semi-transparent pixels.
+ BitmapEx aBitmapEx = rGraphic.GetBitmapEx();
+ Bitmap aBitmap = aBitmapEx.GetBitmap(/*aTransparentReplaceColor=*/COL_WHITE);
+
+ if (aBitmap.getPixelFormat() != vcl::PixelFormat::N24_BPP)
{
- case GfxLinkType::NativeBmp:
- aBlipType = OOO_STRING_SVTOOLS_RTF_WBITMAP;
- break;
- case GfxLinkType::NativeJpg:
- aBlipType = OOO_STRING_SVTOOLS_RTF_JPEGBLIP;
- break;
- case GfxLinkType::NativePng:
- aBlipType = OOO_STRING_SVTOOLS_RTF_PNGBLIP;
- break;
- case GfxLinkType::NativeWmf:
- if (aLink.IsEMF())
- aBlipType = OOO_STRING_SVTOOLS_RTF_EMFBLIP;
- else
- {
- aBlipType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
- bIsWMF = true;
- }
- break;
- default:
- break;
+ // More exotic pixel formats cause trouble for ms paint.
+ aBitmap.Convert(BmpConversion::N24Bit);
}
- if (aBlipType.isEmpty())
- return false;
+ if (GraphicConverter::Export(aNativeData, BitmapEx(aBitmap), ConvertDataFormat::BMP)
+ != ERRCODE_NONE)
+ {
+ SAL_WARN("sw.html", "WrapGraphicInRtf: bmp conversion failed");
+ }
+ aOle1.WriteUInt32(aNativeData.TellEnd());
- rRtf.WriteOString(aBlipType);
+ // Write the actual native data.
+ aNativeData.Seek(0);
+ aOle1.WriteStream(aNativeData);
+
+ // Prepare presentation data.
+ const sal_uInt8* pPresentationData = nullptr;
+ sal_uInt64 nPresentationData = 0;
+ SvMemoryStream aGraphicStream;
+ uno::Sequence<beans::PropertyValue> aFilterData
+ = { comphelper::makePropertyValue("EmbedEMF", false) };
+ FilterConfigItem aConfigItem(&aFilterData);
+ if (ConvertGraphicToWMF(rGraphic, aGraphicStream, &aConfigItem))
+ {
+ pPresentationData = static_cast<const sal_uInt8*>(aGraphicStream.GetData());
+ nPresentationData = aGraphicStream.TellEnd();
+ msfilter::rtfutil::StripMetafileHeader(pPresentationData, nPresentationData);
+ }
+
+ // Write Presentation.
+ // OLEVersion.
+ aOle1.WriteUInt32(0x00000501);
+ // FormatID: constant means the ClassName field is present.
+ aOle1.WriteUInt32(0x00000005);
+ // ClassName: null terminated pascal string.
+ OString aPresentationClassName("METAFILEPICT"_ostr);
+ aOle1.WriteUInt32(aPresentationClassName.getLength() + 1);
+ aOle1.WriteOString(aPresentationClassName);
+ aOle1.WriteChar(0);
+ const sal_uInt8* pBytes = nullptr;
+ sal_uInt64 nBytes = 0;
+ // Take presentation data for OLE1 from RTF.
+ pBytes = pPresentationData;
+ nBytes = nPresentationData;
+ // Width.
+ aOle1.WriteUInt32(nWidth);
+ // Height.
+ aOle1.WriteUInt32(nHeight * -1);
+ // PresentationDataSize: size of (reserved fields + pBytes).
+ aOle1.WriteUInt32(8 + nBytes);
+ // Reserved1-4.
+ aOle1.WriteUInt16(0x0008);
+ aOle1.WriteUInt16(0x31b1);
+ aOle1.WriteUInt16(0x1dd9);
+ aOle1.WriteUInt16(0x0000);
+ aOle1.WriteBytes(pBytes, nBytes);
+
+ // End objdata.
+ msfilter::rtfutil::WriteHex(static_cast<const sal_uInt8*>(aOle1.GetData()), aOle1.GetSize(),
+ &rRtf);
+ rRtf.WriteOString("}");
+ rRtf.WriteOString(SAL_NEWLINE_STRING);
+
+ rRtf.WriteOString("{" OOO_STRING_SVTOOLS_RTF_RESULT);
+ rRtf.WriteOString("{" OOO_STRING_SVTOOLS_RTF_PICT);
Size aMapped(rGraphic.GetPrefSize());
- rRtf.WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PICW);
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_PICW);
rRtf.WriteOString(OString::number(aMapped.Width()));
- rRtf.WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PICH);
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_PICH);
rRtf.WriteOString(OString::number(aMapped.Height()));
- rRtf.WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PICWGOAL);
- rRtf.WriteOString(OString::number(rLogicSize.Width()));
- rRtf.WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PICHGOAL);
- rRtf.WriteOString(OString::number(rLogicSize.Height()));
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_PICWGOAL);
+ rRtf.WriteOString(OString::number(nWidth));
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_PICHGOAL);
+ rRtf.WriteOString(OString::number(nHeight));
+ rRtf.WriteOString(OOO_STRING_SVTOOLS_RTF_WMETAFILE "8");
+ rRtf.WriteOString(SAL_NEWLINE_STRING);
- if (bIsWMF)
+ if (pPresentationData)
{
- rRtf.WriteOString(OString::number(8));
- msfilter::rtfutil::StripMetafileHeader(pGraphicAry, nSize);
+ msfilter::rtfutil::WriteHex(pPresentationData, nPresentationData, &rRtf);
+ rRtf.WriteOString(SAL_NEWLINE_STRING);
}
- rRtf.WriteOString(SAL_NEWLINE_STRING);
-
- msfilter::rtfutil::WriteHex(pGraphicAry, nSize, &rRtf);
- rRtf.WriteOString(SAL_NEWLINE_STRING);
// End pict.
- rRtf.WriteCharPtr("}");
+ rRtf.WriteOString("}");
+
+ // End result.
+ rRtf.WriteOString("}");
+
+ // End object.
+ rRtf.WriteOString("}");
return true;
}
}
diff --git a/sw/source/filter/html/htmlreqifreader.hxx b/sw/source/filter/html/htmlreqifreader.hxx
index 3d0816739d6a..84169bb7c087 100644
--- a/sw/source/filter/html/htmlreqifreader.hxx
+++ b/sw/source/filter/html/htmlreqifreader.hxx
@@ -13,6 +13,7 @@ class Graphic;
class Size;
class SvStream;
class SwOLENode;
+class SwFrameFormat;
namespace SwReqIfReader
{
@@ -24,14 +25,13 @@ namespace SwReqIfReader
bool ExtractOleFromRtf(SvStream& rRtf, SvStream& rOle, bool& bOwnFormat);
/// Wraps an OLE2 container binary in an RTF fragment.
-bool WrapOleInRtf(SvStream& rOle2, SvStream& rRtf, SwOLENode& rOLENode);
+bool WrapOleInRtf(SvStream& rOle2, SvStream& rRtf, SwOLENode& rOLENode,
+ const SwFrameFormat& rFormat);
/**
* Wraps an image in an RTF fragment.
- *
- * @param rLogicSize the size used in the document model (not pixel size)
*/
-bool WrapGraphicInRtf(const Graphic& rGraphic, const Size& rLogicSize, SvStream& rRtf);
+bool WrapGraphicInRtf(const Graphic& rGraphic, const SwFrameFormat& rFormat, SvStream& rRtf);
}
#endif // INCLUDED_SW_SOURCE_FILTER_HTML_HTMLREQIFREADER_HXX
diff --git a/sw/source/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx
index d68a22e2e389..26a1ec8d0e19 100644
--- a/sw/source/filter/html/htmlsect.cxx
+++ b/sw/source/filter/html/htmlsect.cxx
@@ -103,7 +103,7 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
}
bool bAppended = false;
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if( m_pPam->GetPoint()->GetContentIndex() )
{
AppendTextNode( bHeader||bFooter||!aId.isEmpty()|| !aHRef.isEmpty() ? AM_NORMAL
: AM_NOSPACE );
@@ -185,18 +185,16 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
const SwFormatContent& rFlyContent = pHdFtFormat->GetContent();
const SwNodeIndex& rContentStIdx = *rFlyContent.GetContentIdx();
- SwContentNode *pCNd;
- if( bNew )
+ if( !bNew )
{
- pCNd = m_xDoc->GetNodes()[rContentStIdx.GetIndex()+1]
- ->GetContentNode();
- }
- else
- {
- // Create a new node at the beginning of the section
+ // Our own html export only exports one "header" at most (and one "footer")
+
+ // Create a new node at the beginning of the section if a duplicate arises
+ // and hide the original header/footers content by putting it into a hidden
+ // document-level section
SwNodeIndex aSttIdx( rContentStIdx, 1 );
- pCNd = m_xDoc->GetNodes().MakeTextNode( aSttIdx,
+ m_xDoc->GetNodes().MakeTextNode( aSttIdx.GetNode(),
m_pCSS1Parser->GetTextCollFromPool(RES_POOLCOLL_TEXT));
// delete the current content of the section
@@ -205,13 +203,11 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
const SwStartNode *pStNd =
static_cast<const SwStartNode *>( &rContentStIdx.GetNode() );
- aDelPam.GetPoint()->nNode = pStNd->EndOfSectionIndex() - 1;
+ aDelPam.GetPoint()->Assign( pStNd->EndOfSectionIndex() );
- if (!PendingObjectsInPaM(aDelPam))
- {
- ClearFootnotesMarksInRange(aDelPam.GetMark()->nNode, aDelPam.GetPoint()->nNode);
- m_xDoc->getIDocumentContentOperations().DelFullPara(aDelPam);
- }
+ SwSectionData aSection(SectionType::Content, m_xDoc->GetUniqueSectionName());
+ if (SwSection* pOldContent = m_xDoc->InsertSwSection(aDelPam, aSection, nullptr, nullptr, false))
+ pOldContent->SetHidden(true);
// update page style
for( size_t i=0; i < m_xDoc->GetPageDescCnt(); i++ )
@@ -224,7 +220,7 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
}
}
- SwPosition aNewPos( SwNodeIndex( rContentStIdx, 1 ), SwIndex( pCNd, 0 ) );
+ SwPosition aNewPos( rContentStIdx, SwNodeOffset(1) );
SaveDocContext(xCntxt.get(), nFlags, &aNewPos);
}
else if( !bPositioned && aId.getLength() > 9 &&
@@ -244,7 +240,7 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
SwContentNode *pCNd =
m_xDoc->GetNodes()[pStartNdIdx->GetIndex()+1]->GetContentNode();
SwNodeIndex aTmpSwNodeIndex(*pCNd);
- SwPosition aNewPos( aTmpSwNodeIndex, SwIndex( pCNd, 0 ) );
+ SwPosition aNewPos( aTmpSwNodeIndex, pCNd, 0 );
SaveDocContext(xCntxt.get(), HtmlContextFlags::MultiColMask, &aNewPos);
aId.clear();
aPropInfo.m_aId.clear();
@@ -263,7 +259,7 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
// Therefore we have to add a node and delete it again!
if( !bAppended )
{
- SwNodeIndex aPrvNdIdx( m_pPam->GetPoint()->nNode, -1 );
+ SwNodeIndex aPrvNdIdx( m_pPam->GetPoint()->GetNode(), -1 );
if (aPrvNdIdx.GetNode().IsSectionNode())
{
AppendTextNode();
@@ -285,11 +281,7 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
{
nPos2 = aHRef.lastIndexOf( cDelim, nPos );
if( nPos2 != -1 )
- {
- sal_Int32 nTmp = nPos;
- nPos = nPos2;
- nPos2 = nTmp;
- }
+ std::swap( nPos, nPos2 );
}
OUString aURL;
if( nPos == -1 )
@@ -324,20 +316,16 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
aSection.SetProtectFlag(true);
}
- SfxItemSet aFrameItemSet( m_xDoc->GetAttrPool(),
- svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aFrameItemSet( m_xDoc->GetAttrPool() );
if( !IsNewDoc() )
Reader::ResetFrameFormatAttrs(aFrameItemSet );
- const SfxPoolItem *pItem;
- if( SfxItemState::SET == aItemSet.GetItemState( RES_BACKGROUND, false,
- &pItem ) )
+ if( const SvxBrushItem* pItem = aItemSet.GetItemIfSet( RES_BACKGROUND, false ) )
{
aFrameItemSet.Put( *pItem );
aItemSet.ClearItem( RES_BACKGROUND );
}
- if( SfxItemState::SET == aItemSet.GetItemState( RES_FRAMEDIR, false,
- &pItem ) )
+ if( const SvxFrameDirectionItem* pItem = aItemSet.GetItemIfSet( RES_FRAMEDIR, false ) )
{
aFrameItemSet.Put( *pItem );
aItemSet.ClearItem( RES_FRAMEDIR );
@@ -353,14 +341,14 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
}
SwTextNode* pOldTextNd =
- bAppended ? nullptr : m_pPam->GetPoint()->nNode.GetNode().GetTextNode();
+ bAppended ? nullptr : m_pPam->GetPoint()->GetNode().GetTextNode();
m_pPam->Move( fnMoveBackward );
// move PageDesc and SwFormatBreak attribute from current node into
// (first) node of the section
if( pOldTextNd )
- MovePageDescAttrs( pOldTextNd, m_pPam->GetPoint()->nNode.GetIndex(),
+ MovePageDescAttrs( pOldTextNd, m_pPam->GetPoint()->GetNodeIndex(),
true );
if( pPostIts )
@@ -437,14 +425,14 @@ void SwHTMLParser::FixHeaderFooterDistance( bool bHeader,
const SwFormatContent& rFlyContent = pHdFtFormat->GetContent();
const SwNodeIndex& rContentStIdx = *rFlyContent.GetContentIdx();
- sal_uLong nPrvNxtIdx;
+ SwNodeOffset nPrvNxtIdx;
if( bHeader )
{
nPrvNxtIdx = rContentStIdx.GetNode().EndOfSectionIndex()-1;
}
else
{
- nPrvNxtIdx = pOldPos->nNode.GetIndex() - 1;
+ nPrvNxtIdx = pOldPos->GetNodeIndex() - 1;
}
sal_uInt16 nSpace = 0;
@@ -452,8 +440,7 @@ void SwHTMLParser::FixHeaderFooterDistance( bool bHeader,
if( pTextNode )
{
const SvxULSpaceItem& rULSpace =
- static_cast<const SvxULSpaceItem&>(pTextNode
- ->SwContentNode::GetAttr( RES_UL_SPACE ));
+ pTextNode->SwContentNode::GetAttr( RES_UL_SPACE );
// The bottom paragraph padding becomes the padding
// to header or footer
@@ -472,7 +459,7 @@ void SwHTMLParser::FixHeaderFooterDistance( bool bHeader,
if( bHeader )
{
- nPrvNxtIdx = pOldPos->nNode.GetIndex();
+ nPrvNxtIdx = pOldPos->GetNodeIndex();
}
else
{
@@ -484,8 +471,7 @@ void SwHTMLParser::FixHeaderFooterDistance( bool bHeader,
if( pTextNode )
{
const SvxULSpaceItem& rULSpace =
- static_cast<const SvxULSpaceItem&>(pTextNode
- ->SwContentNode::GetAttr( RES_UL_SPACE ));
+ pTextNode->SwContentNode::GetAttr( RES_UL_SPACE );
// The top paragraph padding becomes the padding
// to headline or footer if it is greater than the
@@ -515,7 +501,7 @@ void SwHTMLParser::FixHeaderFooterDistance( bool bHeader,
bool SwHTMLParser::EndSection( bool bLFStripped )
{
- SwEndNode *pEndNd = m_xDoc->GetNodes()[m_pPam->GetPoint()->nNode.GetIndex()+1]
+ SwEndNode *pEndNd = m_xDoc->GetNodes()[m_pPam->GetPoint()->GetNodeIndex()+1]
->GetEndNode();
if( pEndNd && pEndNd->StartOfSectionNode()->IsSectionNode() )
{
@@ -579,7 +565,7 @@ void SwHTMLParser::NewMultiCol( sal_uInt16 columnsFromCss )
aDir = rOption.GetString();
break;
case HtmlOptionId::COLS:
- nCols = static_cast<sal_uInt16>(rOption.GetNumber());
+ nCols = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::WIDTH:
nWidth = rOption.GetNumber();
@@ -588,7 +574,7 @@ void SwHTMLParser::NewMultiCol( sal_uInt16 columnsFromCss )
nWidth = 100;
break;
case HtmlOptionId::GUTTER:
- nGutter = static_cast<sal_uInt16>(rOption.GetNumber());
+ nGutter = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
default: break;
}
@@ -614,11 +600,9 @@ void SwHTMLParser::NewMultiCol( sal_uInt16 columnsFromCss )
// Calculate width.
sal_uInt8 nPercentWidth = bPercentWidth ? static_cast<sal_uInt8>(nWidth) : 0;
SwTwips nTwipWidth = 0;
- if( !bPercentWidth && nWidth && Application::GetDefaultDevice() )
+ if( !bPercentWidth && nWidth )
{
- nTwipWidth = Application::GetDefaultDevice()
- ->PixelToLogic( Size(nWidth, 0),
- MapMode(MapUnit::MapTwip) ).Width();
+ nTwipWidth = o3tl::convert(nWidth, o3tl::Length::px, o3tl::Length::twip);
}
if( !nPercentWidth && nTwipWidth < MINFLY )
@@ -628,8 +612,7 @@ void SwHTMLParser::NewMultiCol( sal_uInt16 columnsFromCss )
bool bPositioned = false;
if( bInCntnr || SwCSS1Parser::MayBePositioned( aPropInfo, true ) )
{
- SfxItemSet aFrameItemSet( m_xDoc->GetAttrPool(),
- svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aFrameItemSet( m_xDoc->GetAttrPool() );
if( !IsNewDoc() )
Reader::ResetFrameFormatAttrs(aFrameItemSet );
@@ -667,7 +650,7 @@ void SwHTMLParser::NewMultiCol( sal_uInt16 columnsFromCss )
bool bAppended = false;
if( !bPositioned )
{
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if( m_pPam->GetPoint()->GetContentIndex() )
{
AppendTextNode( AM_SPACE );
bAppended = true;
@@ -686,7 +669,7 @@ void SwHTMLParser::NewMultiCol( sal_uInt16 columnsFromCss )
// If the pam is at the start of a section, an additional text
// node must be inserted. Otherwise, the new section will be
// inserted in front of the old one.
- SwNodeIndex aPrvNdIdx( m_pPam->GetPoint()->nNode, -1 );
+ SwNodeIndex aPrvNdIdx( m_pPam->GetPoint()->GetNode(), -1 );
if (aPrvNdIdx.GetNode().IsSectionNode())
{
AppendTextNode();
@@ -700,16 +683,13 @@ void SwHTMLParser::NewMultiCol( sal_uInt16 columnsFromCss )
OUString aName( m_xDoc->GetUniqueSectionName( !aId.isEmpty() ? &aId : nullptr ) );
SwSectionData aSection( SectionType::Content, aName );
- SfxItemSet aFrameItemSet( m_xDoc->GetAttrPool(),
- svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aFrameItemSet( m_xDoc->GetAttrPool() );
if( !IsNewDoc() )
Reader::ResetFrameFormatAttrs(aFrameItemSet );
- if( nGutter && Application::GetDefaultDevice() )
+ if( nGutter )
{
- nGutter = static_cast<sal_uInt16>(Application::GetDefaultDevice()
- ->PixelToLogic( Size(nGutter, 0),
- MapMode(MapUnit::MapTwip) ).Width());
+ nGutter = o3tl::convert(nGutter, o3tl::Length::px, o3tl::Length::twip);
}
SwFormatCol aFormatCol;
@@ -717,15 +697,12 @@ void SwHTMLParser::NewMultiCol( sal_uInt16 columnsFromCss )
aFormatCol.Init( nCols, nGutter, USHRT_MAX );
aFrameItemSet.Put( aFormatCol );
- const SfxPoolItem *pItem;
- if( SfxItemState::SET == aItemSet.GetItemState( RES_BACKGROUND, false,
- &pItem ) )
+ if( const SvxBrushItem* pItem = aItemSet.GetItemIfSet( RES_BACKGROUND, false) )
{
aFrameItemSet.Put( *pItem );
aItemSet.ClearItem( RES_BACKGROUND );
}
- if( SfxItemState::SET == aItemSet.GetItemState( RES_FRAMEDIR, false,
- &pItem ) )
+ if( const SvxFrameDirectionItem* pItem = aItemSet.GetItemIfSet( RES_FRAMEDIR, false ) )
{
aFrameItemSet.Put( *pItem );
aItemSet.ClearItem( RES_FRAMEDIR );
@@ -740,14 +717,14 @@ void SwHTMLParser::NewMultiCol( sal_uInt16 columnsFromCss )
}
SwTextNode* pOldTextNd =
- bAppended ? nullptr : m_pPam->GetPoint()->nNode.GetNode().GetTextNode();
+ bAppended ? nullptr : m_pPam->GetPoint()->GetNode().GetTextNode();
m_pPam->Move( fnMoveBackward );
// Move PageDesc and SwFormatBreak attributes of the current node
// to the section's first node.
if( pOldTextNd )
- MovePageDescAttrs( pOldTextNd, m_pPam->GetPoint()->nNode.GetIndex(),
+ MovePageDescAttrs( pOldTextNd, m_pPam->GetPoint()->GetNodeIndex(),
true );
if( pPostIts )
@@ -782,22 +759,20 @@ void SwHTMLParser::InsertFlyFrame( const SfxItemSet& rItemSet,
SwFlyFrameFormat* pFlyFormat = m_xDoc->MakeFlySection( eAnchorId, m_pPam->GetPoint(),
&rItemSet );
if( !rName.isEmpty() )
- pFlyFormat->SetName( rName );
+ pFlyFormat->SetFormatName( rName );
RegisterFlyFrame( pFlyFormat );
const SwFormatContent& rFlyContent = pFlyFormat->GetContent();
const SwNodeIndex& rFlyCntIdx = *rFlyContent.GetContentIdx();
- SwContentNode *pCNd = m_xDoc->GetNodes()[rFlyCntIdx.GetIndex()+1]
- ->GetContentNode();
- SwPosition aNewPos( SwNodeIndex( rFlyCntIdx, 1 ), SwIndex( pCNd, 0 ) );
+ SwPosition aNewPos( rFlyCntIdx, SwNodeOffset(1) );
const HtmlContextFlags nFlags = HtmlContextFlags::ProtectStack|HtmlContextFlags::StripPara;
SaveDocContext( pCntxt, nFlags, &aNewPos );
}
void SwHTMLParser::MovePageDescAttrs( SwNode *pSrcNd,
- sal_uLong nDestIdx,
+ SwNodeOffset nDestIdx,
bool bFormatBreak )
{
SwContentNode* pDestContentNd =
@@ -809,18 +784,17 @@ void SwHTMLParser::MovePageDescAttrs( SwNode *pSrcNd,
{
SwContentNode* pSrcContentNd = pSrcNd->GetContentNode();
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == pSrcContentNd->GetSwAttrSet()
- .GetItemState( RES_PAGEDESC, false, &pItem ) &&
- static_cast<const SwFormatPageDesc *>(pItem)->GetPageDesc() )
+ const SwFormatPageDesc* pFormatPageDesc =
+ pSrcContentNd->GetSwAttrSet().GetItemIfSet( RES_PAGEDESC, false );
+ if( pFormatPageDesc && pFormatPageDesc->GetPageDesc() )
{
- pDestContentNd->SetAttr( *pItem );
+ pDestContentNd->SetAttr( *pFormatPageDesc );
pSrcContentNd->ResetAttr( RES_PAGEDESC );
}
- if( SfxItemState::SET == pSrcContentNd->GetSwAttrSet()
- .GetItemState( RES_BREAK, false, &pItem ) )
+ if( const SvxFormatBreakItem* pItem = pSrcContentNd->GetSwAttrSet()
+ .GetItemIfSet( RES_BREAK, false ) )
{
- switch( static_cast<const SvxFormatBreakItem *>(pItem)->GetBreak() )
+ switch( pItem->GetBreak() )
{
case SvxBreak::PageBefore:
case SvxBreak::PageAfter:
@@ -838,9 +812,8 @@ void SwHTMLParser::MovePageDescAttrs( SwNode *pSrcNd,
{
SwFrameFormat *pFrameFormat = pSrcNd->GetTableNode()->GetTable().GetFrameFormat();
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == pFrameFormat->GetAttrSet().
- GetItemState( RES_PAGEDESC, false, &pItem ) )
+ if( const SwFormatPageDesc* pItem = pFrameFormat->GetAttrSet().
+ GetItemIfSet( RES_PAGEDESC, false ) )
{
if (pDestContentNd)
pDestContentNd->SetAttr(*pItem);
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index c3c95cf7f788..1719347fe5dd 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -19,7 +19,9 @@
#include <memory>
#include <hintids.hxx>
+#include <comphelper/configuration.hxx>
#include <comphelper/flagguard.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/brushitem.hxx>
@@ -32,8 +34,12 @@
#include <unotools/configmgr.hxx>
#include <svtools/htmltokn.h>
#include <svtools/htmlkywd.hxx>
+#include <svl/numformat.hxx>
#include <svl/urihelper.hxx>
+#include <svx/sdrobjectuser.hxx>
+#include <svx/svdotext.hxx>
#include <sal/log.hxx>
+#include <osl/diagnose.h>
#include <dcontact.hxx>
#include <fmtornt.hxx>
@@ -113,57 +119,57 @@ struct HTMLTableOptions
class HTMLTableContext
{
- SwHTMLNumRuleInfo aNumRuleInfo; // Numbering valid before the table
+ SwHTMLNumRuleInfo m_aNumRuleInfo; // Numbering valid before the table
- SwTableNode *pTableNd; // table node
- SwFrameFormat *pFrameFormat; // the Fly frame::Frame, containing the table
- std::unique_ptr<SwPosition> pPos; // position behind the table
+ SwTableNode *m_pTableNd; // table node
+ SwFrameFormat *m_pFrameFormat; // the Fly frame::Frame, containing the table
+ std::unique_ptr<SwPosition> m_pPos; // position behind the table
- size_t nContextStAttrMin;
- size_t nContextStMin;
+ size_t m_nContextStAttrMin;
+ size_t m_nContextStMin;
- bool bRestartPRE : 1;
- bool bRestartXMP : 1;
- bool bRestartListing : 1;
+ bool m_bRestartPRE : 1;
+ bool m_bRestartXMP : 1;
+ bool m_bRestartListing : 1;
HTMLTableContext(const HTMLTableContext&) = delete;
HTMLTableContext& operator=(const HTMLTableContext&) = delete;
public:
- std::shared_ptr<HTMLAttrTable> xAttrTab; // attributes
+ std::shared_ptr<HTMLAttrTable> m_xAttrTab; // attributes
HTMLTableContext( SwPosition *pPs, size_t nCntxtStMin,
size_t nCntxtStAttrMin ) :
- pTableNd( nullptr ),
- pFrameFormat( nullptr ),
- pPos( pPs ),
- nContextStAttrMin( nCntxtStAttrMin ),
- nContextStMin( nCntxtStMin ),
- bRestartPRE( false ),
- bRestartXMP( false ),
- bRestartListing( false ),
- xAttrTab(std::make_shared<HTMLAttrTable>())
+ m_pTableNd( nullptr ),
+ m_pFrameFormat( nullptr ),
+ m_pPos( pPs ),
+ m_nContextStAttrMin( nCntxtStAttrMin ),
+ m_nContextStMin( nCntxtStMin ),
+ m_bRestartPRE( false ),
+ m_bRestartXMP( false ),
+ m_bRestartListing( false ),
+ m_xAttrTab(std::make_shared<HTMLAttrTable>())
{
- memset(xAttrTab.get(), 0, sizeof(HTMLAttrTable));
+ memset(m_xAttrTab.get(), 0, sizeof(HTMLAttrTable));
}
- void SetNumInfo( const SwHTMLNumRuleInfo& rInf ) { aNumRuleInfo.Set(rInf); }
- const SwHTMLNumRuleInfo& GetNumInfo() const { return aNumRuleInfo; };
+ void SetNumInfo( const SwHTMLNumRuleInfo& rInf ) { m_aNumRuleInfo.Set(rInf); }
+ const SwHTMLNumRuleInfo& GetNumInfo() const { return m_aNumRuleInfo; };
void SavePREListingXMP( SwHTMLParser& rParser );
void RestorePREListingXMP( SwHTMLParser& rParser );
- SwPosition *GetPos() const { return pPos.get(); }
+ SwPosition *GetPos() const { return m_pPos.get(); }
- void SetTableNode( SwTableNode *pNd ) { pTableNd = pNd; }
- SwTableNode *GetTableNode() const { return pTableNd; }
+ void SetTableNode( SwTableNode *pNd ) { m_pTableNd = pNd; }
+ SwTableNode *GetTableNode() const { return m_pTableNd; }
- void SetFrameFormat( SwFrameFormat *pFormat ) { pFrameFormat = pFormat; }
- SwFrameFormat *GetFrameFormat() const { return pFrameFormat; }
+ void SetFrameFormat( SwFrameFormat *pFormat ) { m_pFrameFormat = pFormat; }
+ SwFrameFormat *GetFrameFormat() const { return m_pFrameFormat; }
- size_t GetContextStMin() const { return nContextStMin; }
- size_t GetContextStAttrMin() const { return nContextStAttrMin; }
+ size_t GetContextStMin() const { return m_nContextStMin; }
+ size_t GetContextStAttrMin() const { return m_nContextStAttrMin; }
};
}
@@ -188,7 +194,7 @@ class HTMLTableCnts
public:
explicit HTMLTableCnts(const SwStartNode* pStNd);
- explicit HTMLTableCnts(const std::shared_ptr<HTMLTable>& rTab);
+ explicit HTMLTableCnts(std::shared_ptr<HTMLTable> xTab);
~HTMLTableCnts(); // only allowed in ~HTMLTableCell
@@ -285,24 +291,24 @@ namespace {
class HTMLTableRow
{
std::vector<HTMLTableCell> m_aCells; ///< cells of the row
- std::unique_ptr<SvxBrushItem> xBGBrush; // background of cell from STYLE
+ std::unique_ptr<SvxBrushItem> m_xBGBrush; // background of cell from STYLE
- SvxAdjust eAdjust;
- sal_uInt16 nHeight; // options of <TR>/<TD>
- sal_uInt16 nEmptyRows; // number of empty rows are following
- sal_Int16 eVertOri;
- bool bIsEndOfGroup : 1;
- bool bBottomBorder : 1; // Is there a line after the row?
+ SvxAdjust m_eAdjust;
+ sal_uInt16 m_nHeight; // options of <TR>/<TD>
+ sal_uInt16 m_nEmptyRows; // number of empty rows are following
+ sal_Int16 m_eVertOri;
+ bool m_bIsEndOfGroup : 1;
+ bool m_bBottomBorder : 1; // Is there a line after the row?
public:
explicit HTMLTableRow( sal_uInt16 nCells ); // cells of the row are empty
- void SetBottomBorder(bool bIn) { bBottomBorder = bIn; }
- bool GetBottomBorder() const { return bBottomBorder; }
+ void SetBottomBorder(bool bIn) { m_bBottomBorder = bIn; }
+ bool GetBottomBorder() const { return m_bBottomBorder; }
inline void SetHeight( sal_uInt16 nHeight );
- sal_uInt16 GetHeight() const { return nHeight; }
+ sal_uInt16 GetHeight() const { return m_nHeight; }
const HTMLTableCell& GetCell(sal_uInt16 nCell) const;
HTMLTableCell& GetCell(sal_uInt16 nCell)
@@ -310,20 +316,20 @@ public:
return const_cast<HTMLTableCell&>(const_cast<const HTMLTableRow&>(*this).GetCell(nCell));
}
- void SetAdjust( SvxAdjust eAdj ) { eAdjust = eAdj; }
- SvxAdjust GetAdjust() const { return eAdjust; }
+ void SetAdjust( SvxAdjust eAdj ) { m_eAdjust = eAdj; }
+ SvxAdjust GetAdjust() const { return m_eAdjust; }
- void SetVertOri( sal_Int16 eV) { eVertOri = eV; }
- sal_Int16 GetVertOri() const { return eVertOri; }
+ void SetVertOri( sal_Int16 eV) { m_eVertOri = eV; }
+ sal_Int16 GetVertOri() const { return m_eVertOri; }
- void SetBGBrush(std::unique_ptr<SvxBrushItem>& rBrush ) { xBGBrush = std::move(rBrush); }
- const std::unique_ptr<SvxBrushItem>& GetBGBrush() const { return xBGBrush; }
+ void SetBGBrush(std::unique_ptr<SvxBrushItem>& rBrush ) { m_xBGBrush = std::move(rBrush); }
+ const std::unique_ptr<SvxBrushItem>& GetBGBrush() const { return m_xBGBrush; }
- void SetEndOfGroup() { bIsEndOfGroup = true; }
- bool IsEndOfGroup() const { return bIsEndOfGroup; }
+ void SetEndOfGroup() { m_bIsEndOfGroup = true; }
+ bool IsEndOfGroup() const { return m_bIsEndOfGroup; }
- void IncEmptyRows() { nEmptyRows++; }
- sal_uInt16 GetEmptyRows() const { return nEmptyRows; }
+ void IncEmptyRows() { m_nEmptyRows++; }
+ sal_uInt16 GetEmptyRows() const { return m_nEmptyRows; }
// Expand row by adding empty cells
void Expand( sal_uInt16 nCells, bool bOneCell=false );
@@ -335,35 +341,35 @@ public:
// Column of a HTML table
class HTMLTableColumn
{
- bool bIsEndOfGroup;
+ bool m_bIsEndOfGroup;
- sal_uInt16 nWidth; // options of <COL>
- bool bRelWidth;
+ sal_uInt16 m_nWidth; // options of <COL>
+ bool m_bRelWidth;
- SvxAdjust eAdjust;
- sal_Int16 eVertOri;
+ SvxAdjust m_eAdjust;
+ sal_Int16 m_eVertOri;
- SwFrameFormat *aFrameFormats[6];
+ SwFrameFormat *m_aFrameFormats[6];
static inline sal_uInt16 GetFrameFormatIdx( bool bBorderLine,
sal_Int16 eVertOri );
public:
- bool bLeftBorder; // is there a line before the column
+ bool m_bLeftBorder; // is there a line before the column
HTMLTableColumn();
inline void SetWidth( sal_uInt16 nWidth, bool bRelWidth);
- void SetAdjust( SvxAdjust eAdj ) { eAdjust = eAdj; }
- SvxAdjust GetAdjust() const { return eAdjust; }
+ void SetAdjust( SvxAdjust eAdj ) { m_eAdjust = eAdj; }
+ SvxAdjust GetAdjust() const { return m_eAdjust; }
- void SetVertOri( sal_Int16 eV) { eVertOri = eV; }
- sal_Int16 GetVertOri() const { return eVertOri; }
+ void SetVertOri( sal_Int16 eV) { m_eVertOri = eV; }
+ sal_Int16 GetVertOri() const { return m_eVertOri; }
- void SetEndOfGroup() { bIsEndOfGroup = true; }
- bool IsEndOfGroup() const { return bIsEndOfGroup; }
+ void SetEndOfGroup() { m_bIsEndOfGroup = true; }
+ bool IsEndOfGroup() const { return m_bIsEndOfGroup; }
inline void SetFrameFormat( SwFrameFormat *pFormat, bool bBorderLine,
sal_Int16 eVertOri );
@@ -378,15 +384,15 @@ public:
// HTML table
typedef std::vector<SdrObject *> SdrObjects;
-class HTMLTable
+class HTMLTable : public sdr::ObjectUser
{
OUString m_aId;
OUString m_aStyle;
OUString m_aClass;
OUString m_aDir;
- std::unique_ptr<SdrObjects> m_pResizeDrawObjects;// SDR objects
- std::unique_ptr<std::vector<sal_uInt16>> m_pDrawObjectPercentWidths; // column of draw object and its rel. width
+ std::optional<SdrObjects> m_xResizeDrawObjects;// SDR objects
+ std::optional<std::vector<sal_uInt16>> m_xDrawObjectPercentWidths; // column of draw object and its rel. width
std::vector<HTMLTableRow> m_aRows; ///< table rows
std::vector<HTMLTableColumn> m_aColumns; ///< table columns
@@ -526,6 +532,8 @@ private:
sal_uInt16 GetBorderWidth( const SvxBorderLine& rBLine,
bool bWithDistance=false ) const;
+ virtual void ObjectInDestruction(const SdrObject& rObject) override;
+
public:
bool m_bFirstCell; // is there a cell created already?
@@ -535,7 +543,7 @@ public:
bool bHasToFly,
const HTMLTableOptions& rOptions);
- ~HTMLTable();
+ virtual ~HTMLTable();
// Identifying of a cell
const HTMLTableCell& GetCell(sal_uInt16 nRow, sal_uInt16 nCell) const;
@@ -629,8 +637,6 @@ public:
void IncBoxCount() { m_nBoxes++; }
bool IsOverflowing() const { return m_nBoxes > 64000; }
-
- bool PendingDrawObjectsInPaM(SwPaM& rPam) const;
};
void HTMLTableCnts::InitCtor()
@@ -646,9 +652,9 @@ HTMLTableCnts::HTMLTableCnts(const SwStartNode* pStNd)
InitCtor();
}
-HTMLTableCnts::HTMLTableCnts(const std::shared_ptr<HTMLTable>& rTab)
+HTMLTableCnts::HTMLTableCnts(std::shared_ptr<HTMLTable> xTab)
: m_pStartNode(nullptr)
- , m_xTable(rTab)
+ , m_xTable(std::move(xTab))
{
InitCtor();
}
@@ -775,12 +781,12 @@ std::unique_ptr<SwHTMLTableLayoutCell> HTMLTableCell::CreateLayoutInfo()
HTMLTableRow::HTMLTableRow(sal_uInt16 const nCells)
: m_aCells(nCells)
- , eAdjust(SvxAdjust::End)
- , nHeight(0)
- , nEmptyRows(0)
- , eVertOri(text::VertOrientation::TOP)
- , bIsEndOfGroup(false)
- , bBottomBorder(false)
+ , m_eAdjust(SvxAdjust::End)
+ , m_nHeight(0)
+ , m_nEmptyRows(0)
+ , m_eVertOri(text::VertOrientation::TOP)
+ , m_bIsEndOfGroup(false)
+ , m_bBottomBorder(false)
{
assert(nCells == m_aCells.size() &&
"wrong Cell count in new HTML table row");
@@ -788,8 +794,8 @@ HTMLTableRow::HTMLTableRow(sal_uInt16 const nCells)
inline void HTMLTableRow::SetHeight( sal_uInt16 nHght )
{
- if( nHght > nHeight )
- nHeight = nHght;
+ if( nHght > m_nHeight )
+ m_nHeight = nHght;
}
const HTMLTableCell& HTMLTableRow::GetCell(sal_uInt16 nCell) const
@@ -857,30 +863,30 @@ void HTMLTableRow::Shrink( sal_uInt16 nCells )
}
HTMLTableColumn::HTMLTableColumn():
- bIsEndOfGroup(false),
- nWidth(0), bRelWidth(false),
- eAdjust(SvxAdjust::End), eVertOri(text::VertOrientation::TOP),
- bLeftBorder(false)
+ m_bIsEndOfGroup(false),
+ m_nWidth(0), m_bRelWidth(false),
+ m_eAdjust(SvxAdjust::End), m_eVertOri(text::VertOrientation::TOP),
+ m_bLeftBorder(false)
{
- for(SwFrameFormat* & rp : aFrameFormats)
+ for(SwFrameFormat* & rp : m_aFrameFormats)
rp = nullptr;
}
inline void HTMLTableColumn::SetWidth( sal_uInt16 nWdth, bool bRelWdth )
{
- if( bRelWidth==bRelWdth )
+ if( m_bRelWidth==bRelWdth )
{
- if( nWdth > nWidth )
- nWidth = nWdth;
+ if( nWdth > m_nWidth )
+ m_nWidth = nWdth;
}
else
- nWidth = nWdth;
- bRelWidth = bRelWdth;
+ m_nWidth = nWdth;
+ m_bRelWidth = bRelWdth;
}
inline std::unique_ptr<SwHTMLTableLayoutColumn> HTMLTableColumn::CreateLayoutInfo()
{
- return std::unique_ptr<SwHTMLTableLayoutColumn>(new SwHTMLTableLayoutColumn( nWidth, bRelWidth, bLeftBorder ));
+ return std::unique_ptr<SwHTMLTableLayoutColumn>(new SwHTMLTableLayoutColumn( m_nWidth, m_bRelWidth, m_bLeftBorder ));
}
inline sal_uInt16 HTMLTableColumn::GetFrameFormatIdx( bool bBorderLine,
@@ -901,13 +907,13 @@ inline sal_uInt16 HTMLTableColumn::GetFrameFormatIdx( bool bBorderLine,
inline void HTMLTableColumn::SetFrameFormat( SwFrameFormat *pFormat, bool bBorderLine,
sal_Int16 eVertOrient )
{
- aFrameFormats[GetFrameFormatIdx(bBorderLine,eVertOrient)] = pFormat;
+ m_aFrameFormats[GetFrameFormatIdx(bBorderLine,eVertOrient)] = pFormat;
}
inline SwFrameFormat *HTMLTableColumn::GetFrameFormat( bool bBorderLine,
sal_Int16 eVertOrient ) const
{
- return aFrameFormats[GetFrameFormatIdx(bBorderLine,eVertOrient)];
+ return m_aFrameFormats[GetFrameFormatIdx(bBorderLine,eVertOrient)];
}
void HTMLTable::InitCtor(const HTMLTableOptions& rOptions)
@@ -944,7 +950,7 @@ void HTMLTable::InitCtor(const HTMLTableOptions& rOptions)
// nBorder tells the width of the border as it's used in the width calculation of NetScape
// If pOption->nBorder == USHRT_MAX, there wasn't a BORDER option given
// Nonetheless, a 1 pixel wide border will be used for width calculation
- m_nBorder = static_cast<sal_uInt16>(nPWidth);
+ m_nBorder = o3tl::narrowing<sal_uInt16>(nPWidth);
if( nBorderOpt==USHRT_MAX )
nPWidth = 0;
@@ -972,14 +978,8 @@ void HTMLTable::InitCtor(const HTMLTableOptions& rOptions)
m_aRightBorderLine = m_aLeftBorderLine;
if( rOptions.nCellSpacing != 0 )
- {
m_aBorderLine.SetBorderLineStyle(SvxBorderLineStyle::DOUBLE);
- m_aBorderLine.SetWidth( DEF_LINE_WIDTH_0 );
- }
- else
- {
- m_aBorderLine.SetWidth( DEF_LINE_WIDTH_0 );
- }
+ m_aBorderLine.SetWidth(SvxBorderLineWidth::Hairline);
m_aBorderLine.SetColor( rBorderColor );
if( m_nCellPadding )
@@ -1003,8 +1003,8 @@ void HTMLTable::InitCtor(const HTMLTableOptions& rOptions)
nPWidth = rOptions.nHSpace;
nPHeight = rOptions.nVSpace;
SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
- m_nHSpace = static_cast<sal_uInt16>(nPWidth);
- m_nVSpace = static_cast<sal_uInt16>(nPHeight);
+ m_nHSpace = o3tl::narrowing<sal_uInt16>(nPWidth);
+ m_nVSpace = o3tl::narrowing<sal_uInt16>(nPHeight);
m_bColSpec = false;
@@ -1056,7 +1056,7 @@ void SwHTMLParser::DeregisterHTMLTable(HTMLTable* pOld)
{
if (pOld->m_xBox1)
m_aOrphanedTableBoxes.emplace_back(std::move(pOld->m_xBox1));
- m_aTables.erase(std::remove(m_aTables.begin(), m_aTables.end(), pOld));
+ std::erase(m_aTables, pOld);
}
SwDoc* SwHTMLParser::GetDoc() const
@@ -1069,12 +1069,34 @@ bool SwHTMLParser::IsReqIF() const
return m_bReqIF;
}
+// if any m_xResizeDrawObjects members are deleted during parse, remove them
+// from m_xResizeDrawObjects and m_xDrawObjectPercentWidths
+void HTMLTable::ObjectInDestruction(const SdrObject& rObject)
+{
+ auto it = std::find(m_xResizeDrawObjects->begin(), m_xResizeDrawObjects->end(), &rObject);
+ assert(it != m_xResizeDrawObjects->end());
+ auto nIndex = std::distance(m_xResizeDrawObjects->begin(), it);
+ m_xResizeDrawObjects->erase(it);
+ auto otherit = m_xDrawObjectPercentWidths->begin() + nIndex * 3;
+ m_xDrawObjectPercentWidths->erase(otherit, otherit + 3);
+}
+
HTMLTable::~HTMLTable()
{
m_pParser->DeregisterHTMLTable(this);
- m_pResizeDrawObjects.reset();
- m_pDrawObjectPercentWidths.reset();
+ if (m_xResizeDrawObjects)
+ {
+ size_t nCount = m_xResizeDrawObjects->size();
+ for (size_t i = 0; i < nCount; ++i)
+ {
+ SdrObject *pObj = (*m_xResizeDrawObjects)[i];
+ pObj->RemoveObjectUser(*this);
+ }
+ m_xResizeDrawObjects.reset();
+ }
+
+ m_xDrawObjectPercentWidths.reset();
m_pContext.reset();
@@ -1087,7 +1109,7 @@ const std::shared_ptr<SwHTMLTableLayout>& HTMLTable::CreateLayoutInfo()
sal_uInt16 nBorderWidth = GetBorderWidth( m_aBorderLine, true );
sal_uInt16 nLeftBorderWidth =
- m_aColumns[0].bLeftBorder ? GetBorderWidth(m_aLeftBorderLine, true) : 0;
+ m_aColumns[0].m_bLeftBorder ? GetBorderWidth(m_aLeftBorderLine, true) : 0;
sal_uInt16 nRightBorderWidth =
m_bRightBorder ? GetBorderWidth( m_aRightBorderLine, true ) : 0;
@@ -1225,21 +1247,6 @@ const SwStartNode* HTMLTable::GetPrevBoxStartNode( sal_uInt16 nRow, sal_uInt16 n
return pTable->GetPrevBoxStartNode(USHRT_MAX, USHRT_MAX);
}
-static bool IsBoxEmpty( const SwTableBox *pBox )
-{
- const SwStartNode *pSttNd = pBox->GetSttNd();
- if( pSttNd &&
- pSttNd->GetIndex() + 2 == pSttNd->EndOfSectionIndex() )
- {
- const SwContentNode *pCNd =
- pSttNd->GetNodes()[pSttNd->GetIndex()+1]->GetContentNode();
- if( pCNd && !pCNd->Len() )
- return true;
- }
-
- return false;
-}
-
sal_uInt16 HTMLTable::GetTopCellSpace( sal_uInt16 nRow ) const
{
sal_uInt16 nSpace = m_nCellPadding;
@@ -1371,7 +1378,7 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox,
}
bSet = true;
}
- if (m_aColumns[nCol].bLeftBorder)
+ if (m_aColumns[nCol].m_bLeftBorder)
{
const SvxBorderLine& rBorderLine =
0==nCol ? m_aLeftBorderLine : m_aBorderLine;
@@ -1412,12 +1419,12 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox,
pFrameFormat->ResetFormatAttr( RES_BACKGROUND );
// Only set format if there's a value or the box is empty
- if( bHasNumFormat && (bHasValue || IsBoxEmpty(pBox)) )
+ if( bHasNumFormat && (bHasValue || pBox->IsEmpty()) )
{
bool bLock = pFrameFormat->GetDoc()->GetNumberFormatter()
->IsTextFormat( nNumFormat );
- SfxItemSet aItemSet( *pFrameFormat->GetAttrSet().GetPool(),
- svl::Items<RES_BOXATR_FORMAT, RES_BOXATR_VALUE>{} );
+ SfxItemSetFixed<RES_BOXATR_FORMAT, RES_BOXATR_VALUE>
+ aItemSet( *pFrameFormat->GetAttrSet().GetPool() );
SvxAdjust eAdjust = SvxAdjust::End;
SwContentNode *pCNd = nullptr;
if( !bLock )
@@ -1425,13 +1432,12 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox,
const SwStartNode *pSttNd = pBox->GetSttNd();
pCNd = pSttNd->GetNodes()[pSttNd->GetIndex()+1]
->GetContentNode();
- const SfxPoolItem *pItem;
+ const SvxAdjustItem *pItem;
if( pCNd && pCNd->HasSwAttrSet() &&
- SfxItemState::SET==pCNd->GetpSwAttrSet()->GetItemState(
- RES_PARATR_ADJUST, false, &pItem ) )
+ (pItem = pCNd->GetpSwAttrSet()->GetItemIfSet(
+ RES_PARATR_ADJUST, false )) )
{
- eAdjust = static_cast<const SvxAdjustItem *>(pItem)
- ->GetAdjust();
+ eAdjust = pItem->GetAdjust();
}
}
aItemSet.Put( SwTableBoxNumFormat(nNumFormat) );
@@ -1482,11 +1488,34 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox,
if (pTableFormat)
{
sal_uInt8 nPos = SwTableAutoFormat::CountPos(nCol, m_nCols, nRow, m_nRows);
+ const SfxItemSet& rAttrSet = pFrameFormat->GetAttrSet();
+ std::unique_ptr<SvxBoxItem> pOldBoxItem;
+ if (const SvxBoxItem* pBoxItem2 = rAttrSet.GetItemIfSet(RES_BOX))
+ pOldBoxItem.reset(pBoxItem2->Clone());
pTableFormat->UpdateToSet(nPos, m_nRows==1, m_nCols==1,
- const_cast<SfxItemSet&>(static_cast<SfxItemSet const&>(
- pFrameFormat->GetAttrSet())),
+ const_cast<SfxItemSet&>(rAttrSet),
SwTableAutoFormatUpdateFlags::Box,
pFrameFormat->GetDoc()->GetNumberFormatter());
+ if (pOldBoxItem)
+ {
+ // There was an old item, so it's guaranteed that there's a new item
+ const SvxBoxItem* pBoxItem2(rAttrSet.GetItem(RES_BOX));
+ if (*pBoxItem2 != *pOldBoxItem)
+ {
+ std::unique_ptr<SvxBoxItem> pNewBoxItem(pBoxItem2->Clone());
+ // Restore the box elements that could have been already set
+ for (auto eLine : { SvxBoxItemLine::TOP, SvxBoxItemLine::BOTTOM,
+ SvxBoxItemLine::LEFT, SvxBoxItemLine::RIGHT })
+ {
+ if (auto pLine = pOldBoxItem->GetLine(eLine))
+ pNewBoxItem->SetLine(pLine, eLine);
+ if (auto nDistance = pOldBoxItem->GetDistance(eLine, true))
+ pNewBoxItem->SetDistance(nDistance, eLine);
+ }
+
+ pFrameFormat->SetFormatAttr(*pNewBoxItem);
+ }
+ }
}
}
}
@@ -1814,7 +1843,7 @@ void HTMLTable::InheritVertBorders( const HTMLTable *pParent,
GetBorderWidth( m_aInheritedRightBorderLine, true ) + MIN_BORDER_DIST;
}
- if (pParent->m_aColumns[nCol].bLeftBorder)
+ if (pParent->m_aColumns[nCol].m_bLeftBorder)
{
m_bInheritedLeftBorder = true; // just remember for now
m_aInheritedLeftBorderLine = 0==nCol ? pParent->m_aLeftBorderLine
@@ -1832,7 +1861,7 @@ void HTMLTable::InheritVertBorders( const HTMLTable *pParent,
m_bRightAllowed = ( pParent->m_bRightAllowed &&
(nCol+nColSpan==pParent->m_nCols ||
- !pParent->m_aColumns[nCol+nColSpan].bLeftBorder) );
+ !pParent->m_aColumns[nCol+nColSpan].m_bLeftBorder) );
}
void HTMLTable::SetBorders()
@@ -1843,7 +1872,7 @@ void HTMLTable::SetBorders()
((HTMLTableRules::Rows==m_eRules || HTMLTableRules::Groups==m_eRules) &&
m_aColumns[i-1].IsEndOfGroup()))
{
- m_aColumns[i].bLeftBorder = true;
+ m_aColumns[i].m_bLeftBorder = true;
}
for( i=0; i<m_nRows-1; i++ )
@@ -1867,7 +1896,7 @@ void HTMLTable::SetBorders()
m_bRightBorder = true;
if( HTMLTableFrame::LHS==m_eFrame || HTMLTableFrame::VSides==m_eFrame || HTMLTableFrame::Box==m_eFrame )
{
- m_aColumns[0].bLeftBorder = true;
+ m_aColumns[0].m_bLeftBorder = true;
}
for( i=0; i<m_nRows; i++ )
@@ -2027,23 +2056,22 @@ void HTMLTable::InsertCell( std::shared_ptr<HTMLTableCnts> const& rCnts,
}
Size aTwipSz( bRelWidth ? 0 : nCellWidth, nCellHeight );
- if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
+ if( aTwipSz.Width() || aTwipSz.Height() )
{
- aTwipSz = Application::GetDefaultDevice()
- ->PixelToLogic( aTwipSz, MapMode( MapUnit::MapTwip ) );
+ aTwipSz = o3tl::convert(aTwipSz, o3tl::Length::px, o3tl::Length::twip);
}
// Only set width on the first cell!
if( nCellWidth )
{
- sal_uInt16 nTmp = bRelWidth ? nCellWidth : static_cast<sal_uInt16>(aTwipSz.Width());
+ sal_uInt16 nTmp = bRelWidth ? nCellWidth : o3tl::narrowing<sal_uInt16>(aTwipSz.Width());
GetCell( m_nCurrentRow, m_nCurrentColumn ).SetWidth( nTmp, bRelWidth );
}
// Remember height
if( nCellHeight && 1==nRowSpan )
{
- m_aRows[m_nCurrentRow].SetHeight(static_cast<sal_uInt16>(aTwipSz.Height()));
+ m_aRows[m_nCurrentRow].SetHeight(o3tl::narrowing<sal_uInt16>(aTwipSz.Height()));
}
// Set the column counter behind the new cells
@@ -2160,17 +2188,12 @@ void HTMLTable::InsertCol( sal_uInt16 nSpan, sal_uInt16 nColWidth, bool bRelWidt
m_nCols = nColsReq;
}
- Size aTwipSz( bRelWidth ? 0 : nColWidth, 0 );
- if( aTwipSz.Width() && Application::GetDefaultDevice() )
- {
- aTwipSz = Application::GetDefaultDevice()
- ->PixelToLogic( aTwipSz, MapMode( MapUnit::MapTwip ) );
- }
+ sal_uInt16 nTwipWidth(bRelWidth ? 0 : o3tl::convert(nColWidth, o3tl::Length::px, o3tl::Length::twip));
for( i=m_nCurrentColumn; i<nColsReq; i++ )
{
HTMLTableColumn& rCol = m_aColumns[i];
- sal_uInt16 nTmp = bRelWidth ? nColWidth : static_cast<sal_uInt16>(aTwipSz.Width());
+ sal_uInt16 nTmp = bRelWidth ? nColWidth : o3tl::narrowing<sal_uInt16>(nTwipWidth);
rCol.SetWidth( nTmp, bRelWidth );
rCol.SetAdjust( eAdjust );
rCol.SetVertOri( eVertOrient );
@@ -2290,16 +2313,19 @@ void HTMLTable::MakeTable( SwTableBox *pBox, sal_uInt16 nAbsAvail,
// Step 1: needed layout structures are created (including tables in tables)
CreateLayoutInfo();
- // Step 2: the minimal and maximal column width is calculated
- // (including tables in tables). Since we don't have boxes yet,
- // we'll work on the start nodes
- m_xLayoutInfo->AutoLayoutPass1();
+ if (!comphelper::IsFuzzing()) // skip slow path for fuzzing
+ {
+ // Step 2: the minimal and maximal column width is calculated
+ // (including tables in tables). Since we don't have boxes yet,
+ // we'll work on the start nodes
+ m_xLayoutInfo->AutoLayoutPass1();
- // Step 3: the actual column widths of this table are calculated (not tables in tables)
- // We need this now to decide if we need filler cells
- // (Pass1 was needed because of this as well)
- m_xLayoutInfo->AutoLayoutPass2( nAbsAvail, nRelAvail, nAbsLeftSpace,
- nAbsRightSpace, nInhAbsSpace );
+ // Step 3: the actual column widths of this table are calculated (not tables in tables)
+ // We need this now to decide if we need filler cells
+ // (Pass1 was needed because of this as well)
+ m_xLayoutInfo->AutoLayoutPass2( nAbsAvail, nRelAvail, nAbsLeftSpace,
+ nAbsRightSpace, nInhAbsSpace );
+ }
// Set adjustment for the top table
sal_Int16 eHoriOri;
@@ -2416,8 +2442,8 @@ void HTMLTable::MakeTable( SwTableBox *pBox, sal_uInt16 nAbsAvail,
// left or right adjusted table without width mustn't be adjusted in width
// as they would only shrink but never grow
m_xLayoutInfo->SetMustNotRecalc( true );
- if( m_pContext->GetFrameFormat()->GetAnchor().GetContentAnchor()
- ->nNode.GetNode().FindTableNode() )
+ if( m_pContext->GetFrameFormat()->GetAnchor().GetAnchorNode()
+ ->FindTableNode() )
{
sal_uInt32 nMax = m_xLayoutInfo->GetMax();
if( nMax > USHRT_MAX )
@@ -2444,16 +2470,16 @@ void HTMLTable::MakeTable( SwTableBox *pBox, sal_uInt16 nAbsAvail,
const_cast<SwTable *>(m_pSwTable)->SetHTMLTableLayout(m_xLayoutInfo);
- if( !m_pResizeDrawObjects )
+ if( !m_xResizeDrawObjects )
return;
- sal_uInt16 nCount = m_pResizeDrawObjects->size();
+ sal_uInt16 nCount = m_xResizeDrawObjects->size();
for( sal_uInt16 i=0; i<nCount; i++ )
{
- SdrObject *pObj = (*m_pResizeDrawObjects)[i];
- sal_uInt16 nRow = (*m_pDrawObjectPercentWidths)[3*i];
- sal_uInt16 nCol = (*m_pDrawObjectPercentWidths)[3*i+1];
- sal_uInt8 nPercentWidth = static_cast<sal_uInt8>((*m_pDrawObjectPercentWidths)[3*i+2]);
+ SdrObject *pObj = (*m_xResizeDrawObjects)[i];
+ sal_uInt16 nRow = (*m_xDrawObjectPercentWidths)[3*i];
+ sal_uInt16 nCol = (*m_xDrawObjectPercentWidths)[3*i+1];
+ sal_uInt8 nPercentWidth = static_cast<sal_uInt8>((*m_xDrawObjectPercentWidths)[3*i+2]);
SwHTMLTableLayoutCell *pLayoutCell =
m_xLayoutInfo->GetCell( nRow, nCol );
@@ -2484,15 +2510,16 @@ void HTMLTable::SetTable( const SwStartNode *pStNd, std::unique_ptr<HTMLTableCon
void HTMLTable::RegisterDrawObject( SdrObject *pObj, sal_uInt8 nPercentWidth )
{
- if( !m_pResizeDrawObjects )
- m_pResizeDrawObjects.reset(new SdrObjects);
- m_pResizeDrawObjects->push_back( pObj );
-
- if( !m_pDrawObjectPercentWidths )
- m_pDrawObjectPercentWidths.reset(new std::vector<sal_uInt16>);
- m_pDrawObjectPercentWidths->push_back( m_nCurrentRow );
- m_pDrawObjectPercentWidths->push_back( m_nCurrentColumn );
- m_pDrawObjectPercentWidths->push_back( static_cast<sal_uInt16>(nPercentWidth) );
+ if( !m_xResizeDrawObjects )
+ m_xResizeDrawObjects.emplace();
+ m_xResizeDrawObjects->push_back( pObj );
+ pObj->AddObjectUser(*this);
+
+ if( !m_xDrawObjectPercentWidths )
+ m_xDrawObjectPercentWidths.emplace();
+ m_xDrawObjectPercentWidths->push_back( m_nCurrentRow );
+ m_xDrawObjectPercentWidths->push_back( m_nCurrentColumn );
+ m_xDrawObjectPercentWidths->push_back( o3tl::narrowing<sal_uInt16>(nPercentWidth) );
}
void HTMLTable::MakeParentContents()
@@ -2508,9 +2535,9 @@ void HTMLTable::MakeParentContents()
void HTMLTableContext::SavePREListingXMP( SwHTMLParser& rParser )
{
- bRestartPRE = rParser.IsReadPRE();
- bRestartXMP = rParser.IsReadXMP();
- bRestartListing = rParser.IsReadListing();
+ m_bRestartPRE = rParser.IsReadPRE();
+ m_bRestartXMP = rParser.IsReadXMP();
+ m_bRestartListing = rParser.IsReadListing();
rParser.FinishPREListingXMP();
}
@@ -2518,13 +2545,13 @@ void HTMLTableContext::RestorePREListingXMP( SwHTMLParser& rParser )
{
rParser.FinishPREListingXMP();
- if( bRestartPRE )
+ if( m_bRestartPRE )
rParser.StartPRE();
- if( bRestartXMP )
+ if( m_bRestartXMP )
rParser.StartXMP();
- if( bRestartListing )
+ if( m_bRestartListing )
rParser.StartListing();
}
@@ -2539,7 +2566,7 @@ const SwStartNode *SwHTMLParser::InsertTableSection
const SwStartNode *pStNd;
if (m_xTable->m_bFirstCell )
{
- SwNode *const pNd = & m_pPam->GetPoint()->nNode.GetNode();
+ SwNode *const pNd = & m_pPam->GetPoint()->GetNode();
pNd->GetTextNode()->ChgFormatColl( pColl );
pStNd = pNd->FindTableBoxStartNode();
m_xTable->m_bFirstCell = false;
@@ -2552,7 +2579,7 @@ const SwStartNode *SwHTMLParser::InsertTableSection
else
pNd = pPrevStNd->EndOfSectionNode();
SwNodeIndex nIdx( *pNd, 1 );
- pStNd = m_xDoc->GetNodes().MakeTextSection( nIdx, SwTableBoxStartNode,
+ pStNd = m_xDoc->GetNodes().MakeTextSection( nIdx.GetNode(), SwTableBoxStartNode,
pColl );
m_xTable->IncBoxCount();
}
@@ -2588,7 +2615,7 @@ const SwStartNode *SwHTMLParser::InsertTableSection( sal_uInt16 nPoolId )
SwTextFormatColl *pColl = m_pCSS1Parser->GetTextCollFromPool( nPoolId );
- SwNode *const pNd = & m_pPam->GetPoint()->nNode.GetNode();
+ SwNode *const pNd = & m_pPam->GetPoint()->GetNode();
const SwStartNode *pStNd;
if (m_xTable->m_bFirstCell)
{
@@ -2619,13 +2646,10 @@ const SwStartNode *SwHTMLParser::InsertTableSection( sal_uInt16 nPoolId )
pOutTable = pOutTable->StartOfSectionNode()->FindTableNode();
} while( pOutTable && pTableNd->GetTable().GetHTMLTableLayout() );
}
- SwNodeIndex aIdx( *pTableNd->EndOfSectionNode() );
- pStNd = m_xDoc->GetNodes().MakeTextSection( aIdx, SwTableBoxStartNode,
+ pStNd = m_xDoc->GetNodes().MakeTextSection( *pTableNd->EndOfSectionNode(), SwTableBoxStartNode,
pColl );
- m_pPam->GetPoint()->nNode = pStNd->GetIndex() + 1;
- SwTextNode *pTextNd = m_pPam->GetPoint()->nNode.GetNode().GetTextNode();
- m_pPam->GetPoint()->nContent.Assign( pTextNd, 0 );
+ m_pPam->GetPoint()->Assign( pStNd->GetIndex() + 1 );
m_xTable->IncBoxCount();
}
@@ -2640,13 +2664,10 @@ const SwStartNode *SwHTMLParser::InsertTableSection( sal_uInt16 nPoolId )
SwStartNode *SwHTMLParser::InsertTempTableCaptionSection()
{
SwTextFormatColl *pColl = m_pCSS1Parser->GetTextCollFromPool( RES_POOLCOLL_TEXT );
- SwNodeIndex& rIdx = m_pPam->GetPoint()->nNode;
- rIdx = m_xDoc->GetNodes().GetEndOfExtras();
- SwStartNode *pStNd = m_xDoc->GetNodes().MakeTextSection( rIdx,
+ SwStartNode *pStNd = m_xDoc->GetNodes().MakeTextSection( m_xDoc->GetNodes().GetEndOfExtras(),
SwNormalStartNode, pColl );
- rIdx = pStNd->GetIndex() + 1;
- m_pPam->GetPoint()->nContent.Assign( rIdx.GetNode().GetTextNode(), 0 );
+ m_pPam->GetPoint()->Assign( pStNd->GetIndex() + 1);
return pStNd;
}
@@ -2655,10 +2676,16 @@ sal_Int32 SwHTMLParser::StripTrailingLF()
{
sal_Int32 nStripped = 0;
- const sal_Int32 nLen = m_pPam->GetPoint()->nContent.GetIndex();
+ if (IsReqIF())
+ {
+ // One <br> is exactly one line-break in the ReqIF case.
+ return nStripped;
+ }
+
+ const sal_Int32 nLen = m_pPam->GetPoint()->GetContentIndex();
if( nLen )
{
- SwTextNode* pTextNd = m_pPam->GetPoint()->nNode.GetNode().GetTextNode();
+ SwTextNode* pTextNd = m_pPam->GetPoint()->GetNode().GetTextNode();
// careful, when comments aren't ignored!!!
if( pTextNd )
{
@@ -2681,7 +2708,7 @@ sal_Int32 SwHTMLParser::StripTrailingLF()
}
nPos = nLen - nLFCount;
- SwIndex nIdx( pTextNd, nPos );
+ SwContentIndex nIdx( pTextNd, nPos );
pTextNd->EraseText( nIdx, nLFCount );
nStripped = nLFCount;
}
@@ -2701,8 +2728,7 @@ SvxBrushItem* SwHTMLParser::CreateBrushItem( const Color *pColor,
if( !rStyle.isEmpty() || !rId.isEmpty() || !rClass.isEmpty() )
{
- SfxItemSet aItemSet( m_xDoc->GetAttrPool(), svl::Items<RES_BACKGROUND,
- RES_BACKGROUND>{} );
+ SfxItemSetFixed<RES_BACKGROUND, RES_BACKGROUND> aItemSet( m_xDoc->GetAttrPool() );
SvxCSS1PropertyInfo aPropInfo;
if( !rClass.isEmpty() )
@@ -2722,11 +2748,9 @@ SvxBrushItem* SwHTMLParser::CreateBrushItem( const Color *pColor,
}
m_pCSS1Parser->ParseStyleOption( rStyle, aItemSet, aPropInfo );
- const SfxPoolItem *pItem = nullptr;
- if( SfxItemState::SET == aItemSet.GetItemState( RES_BACKGROUND, false,
- &pItem ) )
+ if( const SvxBrushItem *pItem = aItemSet.GetItemIfSet( RES_BACKGROUND, false ) )
{
- pBrushItem = new SvxBrushItem( *static_cast<const SvxBrushItem *>(pItem) );
+ pBrushItem = new SvxBrushItem( *pItem );
}
}
@@ -2828,7 +2852,7 @@ class CellSaveStruct : public SectionSaveStruct
std::shared_ptr<HTMLTableCnts> m_xCnts; // List of all contents
HTMLTableCnts* m_pCurrCnts; // current content or 0
- std::unique_ptr<SwNodeIndex> m_pNoBreakEndNodeIndex; // Paragraph index of a <NOBR>
+ std::optional<SwNodeIndex> m_oNoBreakEndNodeIndex; // Paragraph index of a <NOBR>
double m_nValue;
@@ -2902,7 +2926,7 @@ CellSaveStruct::CellSaveStruct( SwHTMLParser& rParser, HTMLTable const *pCurTabl
m_aId = rOption.GetString();
break;
case HtmlOptionId::COLSPAN:
- m_nColSpan = static_cast<sal_uInt16>(rOption.GetNumber());
+ m_nColSpan = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
if (m_nColSpan > 256)
{
SAL_INFO("sw.html", "ignoring huge COLSPAN " << m_nColSpan);
@@ -2910,8 +2934,8 @@ CellSaveStruct::CellSaveStruct( SwHTMLParser& rParser, HTMLTable const *pCurTabl
}
break;
case HtmlOptionId::ROWSPAN:
- m_nRowSpan = static_cast<sal_uInt16>(rOption.GetNumber());
- if (m_nRowSpan > 8192 || (m_nRowSpan > 256 && utl::ConfigManager::IsFuzzing()))
+ m_nRowSpan = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
+ if (m_nRowSpan > 8192 || (m_nRowSpan > 256 && comphelper::IsFuzzing()))
{
SAL_INFO("sw.html", "ignoring huge ROWSPAN " << m_nRowSpan);
m_nRowSpan = 1;
@@ -2924,13 +2948,13 @@ CellSaveStruct::CellSaveStruct( SwHTMLParser& rParser, HTMLTable const *pCurTabl
m_eVertOri = rOption.GetEnum( aHTMLTableVAlignTable, m_eVertOri );
break;
case HtmlOptionId::WIDTH:
- m_nWidth = static_cast<sal_uInt16>(rOption.GetNumber()); // Just for Netscape
+ m_nWidth = o3tl::narrowing<sal_uInt16>(rOption.GetNumber()); // Just for Netscape
m_bPercentWidth = (rOption.GetString().indexOf('%') != -1);
if( m_bPercentWidth && m_nWidth>100 )
m_nWidth = 100;
break;
case HtmlOptionId::HEIGHT:
- m_nHeight = static_cast<sal_uInt16>(rOption.GetNumber()); // Just for Netscape
+ m_nHeight = o3tl::narrowing<sal_uInt16>(rOption.GetNumber()); // Just for Netscape
if( rOption.GetString().indexOf('%') != -1)
m_nHeight = 0; // don't consider % attributes
break;
@@ -3013,10 +3037,9 @@ CellSaveStruct::CellSaveStruct( SwHTMLParser& rParser, HTMLTable const *pCurTabl
if( rParser.ParseStyleOptions( m_aStyle, m_aId, m_aClass, aItemSet,
aPropInfo, &aLang, &aDir ) )
{
- SfxPoolItem const* pItem;
- if (SfxItemState::SET == aItemSet.GetItemState(RES_BOX, false, &pItem))
+ if (SvxBoxItem const* pItem = aItemSet.GetItemIfSet(RES_BOX, false))
{ // fdo#41796: steal box item to set it in FixFrameFormat later!
- m_xBoxItem.reset(dynamic_cast<SvxBoxItem *>(pItem->Clone()));
+ m_xBoxItem.reset(pItem->Clone());
aItemSet.ClearItem(RES_BOX);
}
rParser.InsertAttrs(aItemSet, aPropInfo, xCntxt.get());
@@ -3081,10 +3104,10 @@ void CellSaveStruct::InsertCell( SwHTMLParser& rParser,
void CellSaveStruct::StartNoBreak( const SwPosition& rPos )
{
if( !m_xCnts ||
- (!rPos.nContent.GetIndex() && m_pCurrCnts == m_xCnts.get() &&
+ (!rPos.GetContentIndex() && m_pCurrCnts == m_xCnts.get() &&
m_xCnts->GetStartNode() &&
m_xCnts->GetStartNode()->GetIndex() + 1 ==
- rPos.nNode.GetIndex()) )
+ rPos.GetNodeIndex()) )
{
m_bNoBreak = true;
}
@@ -3094,8 +3117,8 @@ void CellSaveStruct::EndNoBreak( const SwPosition& rPos )
{
if( m_bNoBreak )
{
- m_pNoBreakEndNodeIndex.reset( new SwNodeIndex( rPos.nNode ) );
- m_nNoBreakEndContentPos = rPos.nContent.GetIndex();
+ m_oNoBreakEndNodeIndex.emplace( rPos.GetNode() );
+ m_nNoBreakEndContentPos = rPos.GetContentIndex();
m_bNoBreak = false;
}
}
@@ -3110,17 +3133,17 @@ void CellSaveStruct::CheckNoBreak( const SwPosition& rPos )
// <NOBR> wasn't closed
m_xCnts->SetNoBreak();
}
- else if( m_pNoBreakEndNodeIndex &&
- m_pNoBreakEndNodeIndex->GetIndex() == rPos.nNode.GetIndex() )
+ else if( m_oNoBreakEndNodeIndex &&
+ m_oNoBreakEndNodeIndex->GetIndex() == rPos.GetNodeIndex() )
{
- if( m_nNoBreakEndContentPos == rPos.nContent.GetIndex() )
+ if( m_nNoBreakEndContentPos == rPos.GetContentIndex() )
{
// <NOBR> was closed immediately before the cell end
m_xCnts->SetNoBreak();
}
- else if( m_nNoBreakEndContentPos + 1 == rPos.nContent.GetIndex() )
+ else if( m_nNoBreakEndContentPos + 1 == rPos.GetContentIndex() )
{
- SwTextNode const*const pTextNd(rPos.nNode.GetNode().GetTextNode());
+ SwTextNode const*const pTextNd(rPos.GetNode().GetTextNode());
if( pTextNd )
{
sal_Unicode const cLast =
@@ -3152,8 +3175,8 @@ std::unique_ptr<HTMLTableCnts> SwHTMLParser::InsertTableContents(
}
// Reset attributation start
- const SwNodeIndex& rSttPara = m_pPam->GetPoint()->nNode;
- sal_Int32 nSttCnt = m_pPam->GetPoint()->nContent.GetIndex();
+ const SwNode& rSttPara = m_pPam->GetPoint()->GetNode();
+ sal_Int32 nSttCnt = m_pPam->GetPoint()->GetContentIndex();
HTMLAttr** pHTMLAttributes = reinterpret_cast<HTMLAttr**>(m_xAttrTab.get());
for (sal_uInt16 nCnt = sizeof(HTMLAttrTable) / sizeof(HTMLAttr*); nCnt--; ++pHTMLAttributes)
@@ -3222,19 +3245,15 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
// the table has no content yet, this means the actual table needs
// to be created first
- static sal_uInt16 aWhichIds[] =
- {
+ SfxItemSetFixed<
RES_PARATR_SPLIT, RES_PARATR_SPLIT,
RES_PAGEDESC, RES_PAGEDESC,
RES_BREAK, RES_BREAK,
RES_BACKGROUND, RES_BACKGROUND,
RES_KEEP, RES_KEEP,
RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT,
- RES_FRAMEDIR, RES_FRAMEDIR,
- 0
- };
-
- SfxItemSet aItemSet( m_xDoc->GetAttrPool(), aWhichIds );
+ RES_FRAMEDIR, RES_FRAMEDIR
+ > aItemSet( m_xDoc->GetAttrPool() );
SvxCSS1PropertyInfo aPropInfo;
bool bStyleParsed = ParseStyleOptions( pCurTable->GetStyle(),
@@ -3242,21 +3261,19 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
pCurTable->GetClass(),
aItemSet, aPropInfo,
nullptr, &pCurTable->GetDirection() );
- const SfxPoolItem *pItem = nullptr;
if( bStyleParsed )
{
- if( SfxItemState::SET == aItemSet.GetItemState(
- RES_BACKGROUND, false, &pItem ) )
+ if( const SvxBrushItem* pItem = aItemSet.GetItemIfSet(
+ RES_BACKGROUND, false ) )
{
- pCurTable->SetBGBrush( *static_cast<const SvxBrushItem *>(pItem) );
+ pCurTable->SetBGBrush( *pItem );
aItemSet.ClearItem( RES_BACKGROUND );
}
- if( SfxItemState::SET == aItemSet.GetItemState(
- RES_PARATR_SPLIT, false, &pItem ) )
+ if( const SvxFormatSplitItem* pSplitItem = aItemSet.GetItemIfSet(
+ RES_PARATR_SPLIT, false ) )
{
aItemSet.Put(
- SwFormatLayoutSplit( static_cast<const SvxFormatSplitItem *>(pItem)
- ->GetValue() ) );
+ SwFormatLayoutSplit( pSplitItem->GetValue() ) );
aItemSet.ClearItem( RES_PARATR_SPLIT );
}
}
@@ -3299,13 +3316,13 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
// Otherwise, we need to open a new paragraph if the paragraph
// is empty or contains text frames or bookmarks
bAppend =
- m_pPam->GetPoint()->nContent.GetIndex() ||
+ m_pPam->GetPoint()->GetContentIndex() ||
HasCurrentParaFlys() ||
HasCurrentParaBookmarks();
}
if( bAppend )
{
- if( !m_pPam->GetPoint()->nContent.GetIndex() )
+ if( !m_pPam->GetPoint()->GetContentIndex() )
{
//Set default to CJK and CTL
m_xDoc->SetTextFormatColl( *m_pPam,
@@ -3369,10 +3386,10 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
m_nContextStAttrMin ) );
// end all open attributes and open them again behind the table
- std::unique_ptr<std::deque<std::unique_ptr<HTMLAttr>>> pPostIts;
+ std::optional<std::deque<std::unique_ptr<HTMLAttr>>> pPostIts;
if( !bForceFrame && (bTopTable || pCurTable->HasParentSection()) )
{
- SplitAttrTab(pTCntxt->xAttrTab, bTopTable);
+ SplitAttrTab(pTCntxt->m_xAttrTab, bTopTable);
// If we reuse an already existing paragraph, we can't add
// PostIts since the paragraph gets behind that table.
// They're gonna be moved into the first paragraph of the table
@@ -3380,17 +3397,17 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
// still empty paragraph, since it's not gonna be deleted that way
if( (bTopTable && !bAppended) ||
(!bTopTable && !bParentLFStripped &&
- !m_pPam->GetPoint()->nContent.GetIndex()) )
- pPostIts.reset(new std::deque<std::unique_ptr<HTMLAttr>>);
- SetAttr( bTopTable, bTopTable, pPostIts.get() );
+ !m_pPam->GetPoint()->GetContentIndex()) )
+ pPostIts.emplace();
+ SetAttr( bTopTable, bTopTable, pPostIts ? &*pPostIts : nullptr );
}
else
{
- SaveAttrTab(pTCntxt->xAttrTab);
+ SaveAttrTab(pTCntxt->m_xAttrTab);
if( bTopTable && !bAppended )
{
- pPostIts.reset(new std::deque<std::unique_ptr<HTMLAttr>>);
- SetAttr( true, true, pPostIts.get() );
+ pPostIts.emplace();
+ SetAttr( true, true, &*pPostIts );
}
}
m_bNoParSpace = false;
@@ -3406,8 +3423,8 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
{
// the table should be put in a text frame
- SfxItemSet aFrameSet( m_xDoc->GetAttrPool(),
- svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1>
+ aFrameSet( m_xDoc->GetAttrPool() );
if( !pCurTable->IsNewDoc() )
Reader::ResetFrameFormatAttrs( aFrameSet );
@@ -3434,13 +3451,15 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
true );
aFrameSet.Put( SwFormatSurround(eSurround) );
- SwFormatFrameSize aFrameSize( SwFrameSize::Variable, 20*MM50, MINLAY );
+ constexpr tools::Long constTwips_100mm = o3tl::convert(tools::Long(100), o3tl::Length::mm, o3tl::Length::twip);
+
+ SwFormatFrameSize aFrameSize( SwFrameSize::Variable, constTwips_100mm, MINLAY );
aFrameSize.SetWidthPercent( 100 );
aFrameSet.Put( aFrameSize );
sal_uInt16 nSpace = pCurTable->GetHSpace();
if( nSpace )
- aFrameSet.Put( SvxLRSpaceItem(nSpace,nSpace, 0, 0, RES_LR_SPACE) );
+ aFrameSet.Put( SvxLRSpaceItem(nSpace, nSpace, 0, RES_LR_SPACE) );
nSpace = pCurTable->GetVSpace();
if( nSpace )
aFrameSet.Put( SvxULSpaceItem(nSpace,nSpace, RES_UL_SPACE) );
@@ -3453,17 +3472,14 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
pTCntxt->SetFrameFormat( pFrameFormat );
const SwFormatContent& rFlyContent = pFrameFormat->GetContent();
- m_pPam->GetPoint()->nNode = *rFlyContent.GetContentIdx();
- SwContentNode *pCNd =
- m_xDoc->GetNodes().GoNext( &(m_pPam->GetPoint()->nNode) );
- m_pPam->GetPoint()->nContent.Assign( pCNd, 0 );
-
+ m_pPam->GetPoint()->Assign( *rFlyContent.GetContentIdx() );
+ SwNodes::GoNext(m_pPam->GetPoint());
}
// create a SwTable with a box and set the PaM to the content of
// the box section (the adjustment parameter is a dummy for now
// and will be corrected later)
- OSL_ENSURE( !m_pPam->GetPoint()->nContent.GetIndex(),
+ OSL_ENSURE( !m_pPam->GetPoint()->GetContentIndex(),
"The paragraph after the table is not empty!" );
const SwTable* pSwTable = m_xDoc->InsertTable(
SwInsertTableOptions( SwInsertTableFlags::HeadlineNoBorder, 1 ),
@@ -3472,7 +3488,7 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
if( bForceFrame )
{
- SwNodeIndex aDstIdx( m_pPam->GetPoint()->nNode );
+ SwNodeIndex aDstIdx( m_pPam->GetPoint()->GetNode() );
m_pPam->Move( fnMoveBackward );
m_xDoc->GetNodes().Delete( aDstIdx );
}
@@ -3486,29 +3502,29 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
m_pPam->Move( fnMoveBackward );
}
- SwNode const*const pNd = & m_pPam->GetPoint()->nNode.GetNode();
+ SwNode const*const pNd = & m_pPam->GetPoint()->GetNode();
SwTextNode *const pOldTextNd = (!bAppended && !bForceFrame) ?
- pSavePos->nNode.GetNode().GetTextNode() : nullptr;
+ pSavePos->GetNode().GetTextNode() : nullptr;
if (pFrameFormat && pOldTextNd)
{
- const SfxPoolItem* pItem2;
- if( SfxItemState::SET == pOldTextNd->GetSwAttrSet()
- .GetItemState( RES_PAGEDESC, false, &pItem2 ) &&
- static_cast<const SwFormatPageDesc *>(pItem2)->GetPageDesc() )
+ const SwFormatPageDesc* pPageDescItem = pOldTextNd->GetSwAttrSet()
+ .GetItemIfSet( RES_PAGEDESC, false );
+ if( pPageDescItem && pPageDescItem->GetPageDesc() )
{
- pFrameFormat->SetFormatAttr( *pItem2 );
+ pFrameFormat->SetFormatAttr( *pPageDescItem );
pOldTextNd->ResetAttr( RES_PAGEDESC );
}
- if( SfxItemState::SET == pOldTextNd->GetSwAttrSet()
- .GetItemState( RES_BREAK, true, &pItem2 ) )
+
+ if( const SvxFormatBreakItem* pBreakItem = pOldTextNd->GetSwAttrSet()
+ .GetItemIfSet( RES_BREAK ) )
{
- switch( static_cast<const SvxFormatBreakItem *>(pItem2)->GetBreak() )
+ switch( pBreakItem->GetBreak() )
{
case SvxBreak::PageBefore:
case SvxBreak::PageAfter:
case SvxBreak::PageBoth:
- pFrameFormat->SetFormatAttr( *pItem2 );
+ pFrameFormat->SetFormatAttr( *pBreakItem );
pOldTextNd->ResetAttr( RES_BREAK );
break;
default:
@@ -3554,7 +3570,7 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
}
}
- SwNode const*const pNd = & m_pPam->GetPoint()->nNode.GetNode();
+ SwNode const*const pNd = & m_pPam->GetPoint()->GetNode();
const SwStartNode *pStNd = (m_xTable->m_bFirstCell ? pNd->FindTableNode()
: pNd->FindTableBoxStartNode() );
@@ -3839,11 +3855,11 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
}
// Remove LFs at the paragraph end
- if (StripTrailingLF() == 0 && !m_pPam->GetPoint()->nContent.GetIndex())
+ if (StripTrailingLF() == 0 && !m_pPam->GetPoint()->GetContentIndex())
{
HTMLTableContext* pTableContext = m_xTable ? m_xTable->GetContext() : nullptr;
SwPosition* pSavedPos = pTableContext ? pTableContext->GetPos() : nullptr;
- const bool bDeleteSafe = !pSavedPos || pSavedPos->nNode != m_pPam->GetPoint()->nNode;
+ const bool bDeleteSafe = !pSavedPos || pSavedPos->GetNode() != m_pPam->GetPoint()->GetNode();
if (bDeleteSafe)
StripTrailingPara();
}
@@ -4319,7 +4335,7 @@ void SwHTMLParser::BuildTableColGroup( HTMLTable *pCurTable,
InsertBookmark( rOption.GetString() );
break;
case HtmlOptionId::SPAN:
- pSaveStruct->nColGrpSpan = static_cast<sal_uInt16>(rOption.GetNumber());
+ pSaveStruct->nColGrpSpan = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
if (pSaveStruct->nColGrpSpan > 256)
{
SAL_INFO("sw.html", "ignoring huge SPAN " << pSaveStruct->nColGrpSpan);
@@ -4327,7 +4343,7 @@ void SwHTMLParser::BuildTableColGroup( HTMLTable *pCurTable,
}
break;
case HtmlOptionId::WIDTH:
- pSaveStruct->nColGrpWidth = static_cast<sal_uInt16>(rOption.GetNumber());
+ pSaveStruct->nColGrpWidth = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
pSaveStruct->bRelColGrpWidth =
(rOption.GetString().indexOf('*') != -1);
break;
@@ -4406,7 +4422,7 @@ void SwHTMLParser::BuildTableColGroup( HTMLTable *pCurTable,
InsertBookmark( rOption.GetString() );
break;
case HtmlOptionId::SPAN:
- nColSpan = static_cast<sal_uInt16>(rOption.GetNumber());
+ nColSpan = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
if (nColSpan > 256)
{
SAL_INFO("sw.html", "ignoring huge SPAN " << nColSpan);
@@ -4414,7 +4430,7 @@ void SwHTMLParser::BuildTableColGroup( HTMLTable *pCurTable,
}
break;
case HtmlOptionId::WIDTH:
- nColWidth = static_cast<sal_uInt16>(rOption.GetNumber());
+ nColWidth = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
bRelColWidth =
(rOption.GetString().indexOf('*') != -1);
break;
@@ -4474,25 +4490,25 @@ void SwHTMLParser::BuildTableColGroup( HTMLTable *pCurTable,
class CaptionSaveStruct : public SectionSaveStruct
{
- SwPosition aSavePos;
- SwHTMLNumRuleInfo aNumRuleInfo; // valid numbering
+ SwPosition m_aSavePos;
+ SwHTMLNumRuleInfo m_aNumRuleInfo; // valid numbering
public:
- std::shared_ptr<HTMLAttrTable> xAttrTab; // attributes
+ std::shared_ptr<HTMLAttrTable> m_xAttrTab; // attributes
- CaptionSaveStruct( SwHTMLParser& rParser, const SwPosition& rPos ) :
- SectionSaveStruct( rParser ), aSavePos( rPos ),
- xAttrTab(std::make_shared<HTMLAttrTable>())
+ CaptionSaveStruct( SwHTMLParser& rParser, SwPosition aPos ) :
+ SectionSaveStruct( rParser ), m_aSavePos(std::move( aPos )),
+ m_xAttrTab(std::make_shared<HTMLAttrTable>())
{
- rParser.SaveAttrTab(xAttrTab);
+ rParser.SaveAttrTab(m_xAttrTab);
// The current numbering was remembered and just needs to be closed
- aNumRuleInfo.Set( rParser.GetNumInfo() );
+ m_aNumRuleInfo.Set( rParser.GetNumInfo() );
rParser.GetNumInfo().Clear();
}
- const SwPosition& GetPos() const { return aSavePos; }
+ const SwPosition& GetPos() const { return m_aSavePos; }
void RestoreAll( SwHTMLParser& rParser )
{
@@ -4500,10 +4516,10 @@ public:
Restore( rParser );
// Recover the old attribute tables
- rParser.RestoreAttrTab(xAttrTab);
+ rParser.RestoreAttrTab(m_xAttrTab);
// Re-open the old numbering
- rParser.GetNumInfo().Set( aNumRuleInfo );
+ rParser.GetNumInfo().Set( m_aNumRuleInfo );
}
};
@@ -4660,13 +4676,13 @@ void SwHTMLParser::BuildTableCaption( HTMLTable *pCurTable )
{
// On moving the caption later, the last paragraph isn't moved as well.
// That means, there has to be an empty paragraph at the end of the section
- if( m_pPam->GetPoint()->nContent.GetIndex() || bLFStripped )
+ if( m_pPam->GetPoint()->GetContentIndex() || bLFStripped )
AppendTextNode( AM_NOSPACE );
}
else
{
// Strip LFs at the end of the paragraph
- if( !m_pPam->GetPoint()->nContent.GetIndex() && !bLFStripped )
+ if( !m_pPam->GetPoint()->GetContentIndex() && !bLFStripped )
StripTrailingPara();
}
@@ -4694,8 +4710,8 @@ class TableSaveStruct : public SwPendingData
public:
std::shared_ptr<HTMLTable> m_xCurrentTable;
- explicit TableSaveStruct(const std::shared_ptr<HTMLTable>& rCurTable)
- : m_xCurrentTable(rCurTable)
+ explicit TableSaveStruct(std::shared_ptr<HTMLTable> xCurTable)
+ : m_xCurrentTable(std::move(xCurTable))
{
}
@@ -4730,9 +4746,9 @@ void TableSaveStruct::MakeTable( sal_uInt16 nWidth, SwPosition& rPos, SwDoc *pDo
{
pTableNd->DelFrames();
SwNodeIndex aIdx( *pTableNd->EndOfSectionNode(), 1 );
- OSL_ENSURE( aIdx.GetIndex() <= pTCntxt->GetPos()->nNode.GetIndex(),
+ OSL_ENSURE( aIdx.GetIndex() <= pTCntxt->GetPos()->GetNodeIndex(),
"unexpected node for table layout" );
- pTableNd->MakeOwnFrames(&aIdx);
+ pTableNd->MakeOwnFrames();
}
}
@@ -4765,24 +4781,24 @@ HTMLTableOptions::HTMLTableOptions( const HTMLOptions& rOptions,
aId = rOption.GetString();
break;
case HtmlOptionId::COLS:
- nCols = static_cast<sal_uInt16>(rOption.GetNumber());
+ nCols = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::WIDTH:
- nWidth = static_cast<sal_uInt16>(rOption.GetNumber());
+ nWidth = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
bPercentWidth = (rOption.GetString().indexOf('%') != -1);
if( bPercentWidth && nWidth>100 )
nWidth = 100;
break;
case HtmlOptionId::HEIGHT:
- nHeight = static_cast<sal_uInt16>(rOption.GetNumber());
+ nHeight = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
if( rOption.GetString().indexOf('%') != -1 )
nHeight = 0; // don't use % attributes
break;
case HtmlOptionId::CELLPADDING:
- nCellPadding = static_cast<sal_uInt16>(rOption.GetNumber());
+ nCellPadding = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::CELLSPACING:
- nCellSpacing = static_cast<sal_uInt16>(rOption.GetNumber());
+ nCellSpacing = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::ALIGN:
{
@@ -4801,7 +4817,7 @@ HTMLTableOptions::HTMLTableOptions( const HTMLOptions& rOptions,
!rOption.GetString().equalsIgnoreAsciiCase(
OOO_STRING_SVTOOLS_HTML_O_border))
{
- nBorder = static_cast<sal_uInt16>(rOption.GetNumber());
+ nBorder = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
}
else
nBorder = 1;
@@ -4849,10 +4865,10 @@ HTMLTableOptions::HTMLTableOptions( const HTMLOptions& rOptions,
aDir = rOption.GetString();
break;
case HtmlOptionId::HSPACE:
- nHSpace = static_cast<sal_uInt16>(rOption.GetNumber());
+ nHSpace = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::VSPACE:
- nVSpace = static_cast<sal_uInt16>(rOption.GetNumber());
+ nVSpace = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
default: break;
}
@@ -4872,86 +4888,13 @@ HTMLTableOptions::HTMLTableOptions( const HTMLOptions& rOptions,
}
}
-namespace
-{
- class IndexInRange
- {
- private:
- SwNodeIndex maStart;
- SwNodeIndex maEnd;
- public:
- explicit IndexInRange(const SwNodeIndex& rStart, const SwNodeIndex& rEnd)
- : maStart(rStart)
- , maEnd(rEnd)
- {
- }
- bool operator()(const SwHTMLTextFootnote& rTextFootnote) const
- {
- const SwNodeIndex aTextIdx(rTextFootnote.pTextFootnote->GetTextNode());
- return aTextIdx >= maStart && aTextIdx <= maEnd;
- }
- };
-}
-
-void SwHTMLParser::ClearFootnotesMarksInRange(const SwNodeIndex& rMkNdIdx, const SwNodeIndex& rPtNdIdx)
-{
- //similarly for footnotes
- if (m_pFootEndNoteImpl)
- {
- m_pFootEndNoteImpl->aTextFootnotes.erase(std::remove_if(m_pFootEndNoteImpl->aTextFootnotes.begin(),
- m_pFootEndNoteImpl->aTextFootnotes.end(), IndexInRange(rMkNdIdx, rPtNdIdx)), m_pFootEndNoteImpl->aTextFootnotes.end());
- if (m_pFootEndNoteImpl->aTextFootnotes.empty())
- {
- m_pFootEndNoteImpl.reset();
- }
- }
-
- //follow DelFlyInRange pattern here
- assert(rMkNdIdx.GetIndex() <= rPtNdIdx.GetIndex());
-
- SwDoc& rDoc = rMkNdIdx.GetNode().GetDoc();
-
- //ofz#9733 drop bookmarks in this range
- IDocumentMarkAccess* const pMarkAccess = rDoc.getIDocumentMarkAccess();
- pMarkAccess->deleteMarks(rMkNdIdx, SwNodeIndex(rPtNdIdx, 1), nullptr, nullptr, nullptr);
-
- SwFrameFormats& rTable = *rDoc.GetSpzFrameFormats();
- for ( auto i = rTable.size(); i; )
- {
- SwFrameFormat *pFormat = rTable[--i];
- const SwFormatAnchor &rAnch = pFormat->GetAnchor();
- SwPosition const*const pAPos = rAnch.GetContentAnchor();
- if (pAPos &&
- ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA) ||
- (rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR)) &&
- ( rMkNdIdx < pAPos->nNode && pAPos->nNode <= rPtNdIdx ))
- {
- if( rPtNdIdx != pAPos->nNode )
- {
- // If the Fly is deleted, all Flys in its content have to be deleted too.
- const SwFormatContent &rContent = pFormat->GetContent();
- // But only fly formats own their content, not draw formats.
- if (rContent.GetContentIdx() && pFormat->Which() == RES_FLYFRMFMT)
- {
- ClearFootnotesMarksInRange(*rContent.GetContentIdx(),
- SwNodeIndex(*rContent.GetContentIdx()->GetNode().EndOfSectionNode()));
- }
- }
- }
- }
-}
-
void SwHTMLParser::DeleteSection(SwStartNode* pSttNd)
{
//if section to be deleted contains a pending m_pMarquee, it will be deleted
//so clear m_pMarquee pointer if that's the case
- SwFrameFormat* pObjectFormat = m_pMarquee ? ::FindFrameFormat(m_pMarquee) : nullptr;
+ SwFrameFormat* pObjectFormat = m_pMarquee ? ::FindFrameFormat(m_pMarquee.get()) : nullptr;
FrameDeleteWatch aWatch(pObjectFormat);
- //similarly for footnotes
- SwNodeIndex aSttIdx(*pSttNd), aEndIdx(*pSttNd->EndOfSectionNode());
- ClearFootnotesMarksInRange(aSttIdx, aEndIdx);
-
m_xDoc->getIDocumentContentOperations().DeleteSection(pSttNd);
if (pObjectFormat)
@@ -4993,6 +4936,35 @@ std::shared_ptr<HTMLTable> SwHTMLParser::BuildTable(SvxAdjust eParentAdjust,
else
{
m_xTable.reset();
+
+ // Parse CSS on the table.
+ OUString aStyle;
+ const HTMLOptions& rHTMLOptions = GetOptions();
+ for (size_t i = rHTMLOptions.size(); i;)
+ {
+ const HTMLOption& rOption = rHTMLOptions[--i];
+ if (rOption.GetToken() == HtmlOptionId::STYLE)
+ {
+ aStyle = rOption.GetString();
+ }
+ }
+ if (!aStyle.isEmpty())
+ {
+ // Have inline CSS.
+ SfxItemSet aItemSet(m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap());
+ SvxCSS1PropertyInfo aPropInfo;
+ if (ParseStyleOptions(aStyle, /*aId=*/OUString(), /*aClass=*/OUString(), aItemSet,
+ aPropInfo))
+ {
+ if (aPropInfo.m_eLeftMarginType == SVX_CSS1_LTYPE_AUTO
+ && aPropInfo.m_eRightMarginType == SVX_CSS1_LTYPE_AUTO)
+ {
+ // Both left & right is set to auto: that's our center.
+ eParentAdjust = SvxAdjust::Center;
+ }
+ }
+ }
+
HTMLTableOptions aTableOptions(GetOptions(), eParentAdjust);
if (!aTableOptions.aId.isEmpty())
@@ -5139,37 +5111,40 @@ std::shared_ptr<HTMLTable> SwHTMLParser::BuildTable(SvxAdjust eParentAdjust,
// The last paragraph of the section is never part of the copy.
// That's why the section needs to contain at least two paragraphs
- if( pCapStNd->EndOfSectionIndex() - pCapStNd->GetIndex() > 2 )
+ if( pCapStNd->EndOfSectionIndex() - pCapStNd->GetIndex() > SwNodeOffset(2) )
{
// Don't copy start node and the last paragraph
- SwNodeRange aSrcRg( *pCapStNd, 1,
- *pCapStNd->EndOfSectionNode(), -1 );
+ SwNodeRange aSrcRg( *pCapStNd, SwNodeOffset(1),
+ *pCapStNd->EndOfSectionNode(), SwNodeOffset(-1) );
bool bTop = m_xTable->IsTopCaption();
SwStartNode *pTableStNd = pTCntxt->GetTableNode();
OSL_ENSURE( pTableStNd, "Where is the table node" );
- OSL_ENSURE( pTableStNd==m_pPam->GetNode().FindTableNode(),
+ OSL_ENSURE( pTableStNd == m_pPam->GetPointNode().FindTableNode(),
"Are we in the wrong table?" );
- SwNode* pNd;
- if( bTop )
- pNd = pTableStNd;
- else
- pNd = pTableStNd->EndOfSectionNode();
- SwNodeIndex aDstIdx( *pNd, bTop ? 0 : 1 );
-
- m_xDoc->getIDocumentContentOperations().MoveNodeRange( aSrcRg, aDstIdx,
- SwMoveFlags::DEFAULT );
-
- // If the caption was added before the table, a page style on that table
- // needs to be moved to the first paragraph of the header.
- // Additionally, all remembered indices that point to the table node
- // need to be moved
- if( bTop )
+ if (pTableStNd)
{
- MovePageDescAttrs( pTableStNd, aSrcRg.aStart.GetIndex(),
- false );
+ SwNode* pNd;
+ if( bTop )
+ pNd = pTableStNd;
+ else
+ pNd = pTableStNd->EndOfSectionNode();
+ SwNodeIndex aDstIdx( *pNd, bTop ? 0 : 1 );
+
+ m_xDoc->getIDocumentContentOperations().MoveNodeRange( aSrcRg, aDstIdx.GetNode(),
+ SwMoveFlags::DEFAULT );
+
+ // If the caption was added before the table, a page style on that table
+ // needs to be moved to the first paragraph of the header.
+ // Additionally, all remembered indices that point to the table node
+ // need to be moved
+ if( bTop )
+ {
+ MovePageDescAttrs( pTableStNd, aSrcRg.aStart.GetIndex(),
+ false );
+ }
}
}
@@ -5181,13 +5156,13 @@ std::shared_ptr<HTMLTable> SwHTMLParser::BuildTable(SvxAdjust eParentAdjust,
}
// Process SwTable
- sal_uInt16 nBrowseWidth = static_cast<sal_uInt16>(GetCurrentBrowseWidth());
+ sal_uInt16 nBrowseWidth = o3tl::narrowing<sal_uInt16>(GetCurrentBrowseWidth());
xSaveStruct->MakeTable(nBrowseWidth, *m_pPam->GetPoint(), m_xDoc.get());
}
GetNumInfo().Set( pTCntxt->GetNumInfo() );
pTCntxt->RestorePREListingXMP( *this );
- RestoreAttrTab(pTCntxt->xAttrTab);
+ RestoreAttrTab(pTCntxt->m_xAttrTab);
if (m_xTable == xCurTable)
{
@@ -5243,51 +5218,4 @@ std::shared_ptr<HTMLTable> SwHTMLParser::BuildTable(SvxAdjust eParentAdjust,
return xRetTable;
}
-bool HTMLTable::PendingDrawObjectsInPaM(SwPaM& rPam) const
-{
- if (!m_pResizeDrawObjects)
- return false;
-
- bool bRet = false;
-
- sal_uInt16 nCount = m_pResizeDrawObjects->size();
- for (sal_uInt16 i = 0; i < nCount && !bRet; ++i)
- {
- SdrObject *pObj = (*m_pResizeDrawObjects)[i];
- SwFrameFormat* pObjectFormat = ::FindFrameFormat(pObj);
- if (!pObjectFormat)
- continue;
- const SwFormatAnchor& rAnch = pObjectFormat->GetAnchor();
- if (const SwPosition* pPos = rAnch.GetContentAnchor())
- {
- SwNodeIndex aObjNodeIndex(pPos->nNode);
- bRet = (aObjNodeIndex >= rPam.Start()->nNode && aObjNodeIndex <= rPam.End()->nNode);
- }
- }
-
- return bRet;
-}
-
-bool SwHTMLParser::PendingObjectsInPaM(SwPaM& rPam) const
-{
- bool bRet = false;
- for (const auto& a : m_aTables)
- {
- bRet = a->PendingDrawObjectsInPaM(rPam);
- if (bRet)
- break;
- const SwTable *pTable = a->GetSwTable();
- if (!pTable)
- continue;
- const SwTableNode* pTableNode = pTable->GetTableNode();
- if (!pTableNode)
- continue;
- SwNodeIndex aTableNodeIndex(*pTableNode);
- bRet = (aTableNodeIndex >= rPam.Start()->nNode && aTableNodeIndex <= rPam.End()->nNode);
- if (bRet)
- break;
- }
- return bRet;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx
index 4c83319747b7..b1ef282396a0 100644
--- a/sw/source/filter/html/htmltabw.cxx
+++ b/sw/source/filter/html/htmltabw.cxx
@@ -63,12 +63,20 @@ class SwHTMLWrtTable : public SwWriteTable
static void Pixelize( sal_uInt16& rValue );
void PixelizeBorders();
+ /// Writes a single table cell.
+ ///
+ /// bCellRowSpan decides if the cell's row span should be written or not.
void OutTableCell( SwHTMLWriter& rWrt, const SwWriteTableCell *pCell,
- bool bOutVAlign ) const;
+ bool bOutVAlign,
+ bool bCellRowSpan ) const;
+ /// Writes a single table row.
+ ///
+ /// rSkipRows decides if the next N rows should be skipped or written.
void OutTableCells( SwHTMLWriter& rWrt,
const SwWriteTableCells& rCells,
- const SvxBrushItem *pBrushItem ) const;
+ const SvxBrushItem *pBrushItem,
+ sal_uInt16& rSkipRows ) const;
virtual bool ShouldExpandSub( const SwTableBox *pBox,
bool bExpandedBefore, sal_uInt16 nDepth ) const override;
@@ -111,14 +119,9 @@ SwHTMLWrtTable::SwHTMLWrtTable( const SwHTMLTableLayout *pLayoutInfo )
void SwHTMLWrtTable::Pixelize( sal_uInt16& rValue )
{
- if( rValue && Application::GetDefaultDevice() )
+ if( rValue )
{
- Size aSz( rValue, 0 );
- aSz = Application::GetDefaultDevice()->LogicToPixel( aSz, MapMode(MapUnit::MapTwip) );
- if( !aSz.Width() )
- aSz.setWidth( 1 );
- aSz = Application::GetDefaultDevice()->PixelToLogic( aSz, MapMode(MapUnit::MapTwip) );
- rValue = static_cast<sal_uInt16>(aSz.Width());
+ rValue = o3tl::convert(SwHTMLWriter::ToPixel(rValue), o3tl::Length::px, o3tl::Length::twip);
}
}
@@ -143,8 +146,8 @@ bool SwHTMLWrtTable::HasTabBackground( const SwTableBox& rBox,
/// The table box has a background, if its background color is not "no fill"/
/// "auto fill" or it has a background graphic.
- bRet = aBrushItem && (aBrushItem->GetColor() != COL_TRANSPARENT ||
- !aBrushItem->GetGraphicLink().isEmpty() || aBrushItem->GetGraphic());
+ bRet = aBrushItem->GetColor() != COL_TRANSPARENT ||
+ !aBrushItem->GetGraphicLink().isEmpty() || aBrushItem->GetGraphic();
}
else
{
@@ -172,8 +175,8 @@ bool SwHTMLWrtTable::HasTabBackground( const SwTableLine& rLine,
std::unique_ptr<SvxBrushItem> aBrushItem = rLine.GetFrameFormat()->makeBackgroundBrushItem();
/// The table line has a background, if its background color is not "no fill"/
/// "auto fill" or it has a background graphic.
- bool bRet = aBrushItem && (aBrushItem->GetColor() != COL_TRANSPARENT ||
- !aBrushItem->GetGraphicLink().isEmpty() || aBrushItem->GetGraphic());
+ bool bRet = aBrushItem->GetColor() != COL_TRANSPARENT ||
+ !aBrushItem->GetGraphicLink().isEmpty() || aBrushItem->GetGraphic();
if( !bRet )
{
@@ -254,7 +257,8 @@ bool SwHTMLWrtTable::ShouldExpandSub( const SwTableBox *pBox,
// Write a box as single cell
void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
const SwWriteTableCell *pCell,
- bool bOutVAlign ) const
+ bool bOutVAlign,
+ bool bCellRowSpan ) const
{
const SwTableBox *pBox = pCell->GetBox();
sal_uInt16 nRow = pCell->GetRow();
@@ -269,7 +273,7 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
bool bHead = false;
if( pSttNd )
{
- sal_uLong nNdPos = pSttNd->GetIndex()+1;
+ SwNodeOffset nNdPos = pSttNd->GetIndex()+1;
// determine the type of cell (TD/TH)
SwNode* pNd;
@@ -301,21 +305,20 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
}
rWrt.OutNewLine(); // <TH>/<TD> in new line
- OStringBuffer sOut;
- sOut.append('<');
+ OStringBuffer sOut("<");
OString aTag(bHead ? OOO_STRING_SVTOOLS_HTML_tableheader : OOO_STRING_SVTOOLS_HTML_tabledata);
sOut.append(rWrt.GetNamespace() + aTag);
// output ROW- and COLSPAN
- if( nRowSpan>1 )
+ if (nRowSpan > 1 && bCellRowSpan)
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_rowspan).
- append("=\"").append(static_cast<sal_Int32>(nRowSpan)).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_rowspan
+ "=\"" + OString::number(nRowSpan) + "\"");
}
if( nColSpan > 1 )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_colspan).
- append("=\"").append(static_cast<sal_Int32>(nColSpan)).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_colspan
+ "=\"" + OString::number(nColSpan) + "\"");
}
tools::Long nWidth = 0;
@@ -350,28 +353,15 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
tools::Long nHeight = pCell->GetHeight() > 0
? GetAbsHeight( pCell->GetHeight(), nRow, nRowSpan )
: 0;
- Size aPixelSz( nWidth, nHeight );
-
- // output WIDTH (Argh: only for Netscape)
- if( (aPixelSz.Width() || aPixelSz.Height()) && Application::GetDefaultDevice() )
- {
- Size aOldSz( aPixelSz );
- aPixelSz = Application::GetDefaultDevice()->LogicToPixel( aPixelSz,
- MapMode(MapUnit::MapTwip) );
- if( aOldSz.Width() && !aPixelSz.Width() )
- aPixelSz.setWidth( 1 );
- if( aOldSz.Height() && !aPixelSz.Height() )
- aPixelSz.setHeight( 1 );
- }
+ Size aPixelSz(SwHTMLWriter::ToPixel(nWidth), SwHTMLWriter::ToPixel(nHeight));
// output WIDTH: from layout or calculated
if( bOutWidth )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_width).
- append("=\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_width "=\"");
if( nPercentWidth != SAL_MAX_UINT32 )
{
- sOut.append(static_cast<sal_Int32>(nPercentWidth)).append('%');
+ sOut.append(OString::number(static_cast<sal_Int32>(nPercentWidth)) + "%");
}
else
{
@@ -380,14 +370,19 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
sOut.append("\"");
}
+ if (rWrt.mbReqIF)
+ {
+ // ReqIF implies strict XHTML: no height for <td>.
+ nHeight = 0;
+ }
+
if( nHeight )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_height)
- .append("=\"").append(static_cast<sal_Int32>(aPixelSz.Height())).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_height
+ "=\"" + OString::number(aPixelSz.Height()) + "\"");
}
const SfxItemSet& rItemSet = pBox->GetFrameFormat()->GetAttrSet();
- const SfxPoolItem *pItem;
// ALIGN is only outputted at the paragraphs from now on
@@ -397,23 +392,20 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
sal_Int16 eVertOri = pCell->GetVertOri();
if( text::VertOrientation::TOP==eVertOri || text::VertOrientation::BOTTOM==eVertOri )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_valign)
- .append("=\"").append(text::VertOrientation::TOP==eVertOri ?
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_valign
+ "=\"").append(text::VertOrientation::TOP==eVertOri ?
OOO_STRING_SVTOOLS_HTML_VA_top :
OOO_STRING_SVTOOLS_HTML_VA_bottom)
.append("\"");
}
}
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
rWrt.m_bTextAttr = false;
rWrt.m_bOutOpts = true;
- const SvxBrushItem *pBrushItem = nullptr;
- if( SfxItemState::SET==rItemSet.GetItemState( RES_BACKGROUND, false, &pItem ) )
- {
- pBrushItem = static_cast<const SvxBrushItem *>(pItem);
- }
+ const SvxBrushItem *pBrushItem = rItemSet.GetItemIfSet( RES_BACKGROUND, false );
if( !pBrushItem )
pBrushItem = pCell->GetBackground();
@@ -424,37 +416,40 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
// Avoid non-CSS version in the ReqIF case.
rWrt.OutBackground( pBrushItem, false );
- if( rWrt.m_bCfgOutStyles )
- OutCSS1_TableBGStyleOpt( rWrt, *pBrushItem );
+ if (!rWrt.m_bCfgOutStyles)
+ pBrushItem = nullptr;
}
- rWrt.OutCSS1_TableCellBorderHack(*pBox->GetFrameFormat());
+ // tdf#132739 with rWrt.m_bCfgOutStyles of true bundle the brush item css
+ // properties into the same "style" tag as the borders so there is only one
+ // style tag
+ rWrt.OutCSS1_TableCellBordersAndBG(*pBox->GetFrameFormat(), pBrushItem);
sal_uInt32 nNumFormat = 0;
double nValue = 0.0;
bool bNumFormat = false, bValue = false;
- if( SfxItemState::SET==rItemSet.GetItemState( RES_BOXATR_FORMAT, false, &pItem ) )
+ if( const SwTableBoxNumFormat* pItem = rItemSet.GetItemIfSet( RES_BOXATR_FORMAT, false ) )
{
- nNumFormat = static_cast<const SwTableBoxNumFormat *>(pItem)->GetValue();
+ nNumFormat = pItem->GetValue();
bNumFormat = true;
}
- if( SfxItemState::SET==rItemSet.GetItemState( RES_BOXATR_VALUE, false, &pItem ) )
+ if( const SwTableBoxValue* pItem = rItemSet.GetItemIfSet( RES_BOXATR_VALUE, false ) )
{
- nValue = static_cast<const SwTableBoxValue *>(pItem)->GetValue();
+ nValue = pItem->GetValue();
bValue = true;
if( !bNumFormat )
nNumFormat = pBox->GetFrameFormat()->GetTableBoxNumFormat().GetValue();
}
- if( bNumFormat || bValue )
+ if ((bNumFormat || bValue) && !rWrt.mbXHTML)
{
sOut.append(HTMLOutFuncs::CreateTableDataOptionsValNum(bValue, nValue,
- nNumFormat, *rWrt.m_pDoc->GetNumberFormatter(), rWrt.m_eDestEnc,
- &rWrt.m_aNonConvertableCharacters));
+ nNumFormat, *rWrt.m_pDoc->GetNumberFormatter()));
}
sOut.append('>');
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- rWrt.m_bLFPossible = true;
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ rWrt.SetLFPossible(true);
rWrt.IncIndentLevel(); // indent the content of <TD>...</TD>
@@ -491,17 +486,18 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
rWrt.DecIndentLevel(); // indent the content of <TD>...</TD>
- if( rWrt.m_bLFPossible )
+ if (rWrt.IsLFPossible())
rWrt.OutNewLine();
aTag = bHead ? OOO_STRING_SVTOOLS_HTML_tableheader : OOO_STRING_SVTOOLS_HTML_tabledata;
- HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), rWrt.GetNamespace() + aTag, false);
- rWrt.m_bLFPossible = true;
+ HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aTag), false);
+ rWrt.SetLFPossible(true);
}
// output a line as lines
void SwHTMLWrtTable::OutTableCells( SwHTMLWriter& rWrt,
const SwWriteTableCells& rCells,
- const SvxBrushItem *pBrushItem ) const
+ const SvxBrushItem *pBrushItem,
+ sal_uInt16& rSkipRows ) const
{
// If the line contains more the one cell and all cells have the same
// alignment, then output the VALIGN at the line instead of the cell.
@@ -524,39 +520,60 @@ void SwHTMLWrtTable::OutTableCells( SwHTMLWriter& rWrt,
}
rWrt.OutNewLine(); // <TR> in new line
- rWrt.Strm().WriteChar( '<' ).WriteOString( rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_tablerow );
+ rWrt.Strm().WriteChar( '<' ).WriteOString( Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_tablerow) );
if( pBrushItem )
{
- rWrt.OutBackground( pBrushItem, false );
+ if (!rWrt.mbXHTML)
+ {
+ rWrt.OutBackground(pBrushItem, false);
+ }
rWrt.m_bTextAttr = false;
rWrt.m_bOutOpts = true;
- if( rWrt.m_bCfgOutStyles )
+ if (rWrt.m_bCfgOutStyles || rWrt.mbXHTML)
OutCSS1_TableBGStyleOpt( rWrt, *pBrushItem );
}
if( text::VertOrientation::TOP==eRowVertOri || text::VertOrientation::BOTTOM==eRowVertOri )
{
OStringBuffer sOut;
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_valign)
- .append("=\"").append(text::VertOrientation::TOP==eRowVertOri ? OOO_STRING_SVTOOLS_HTML_VA_top : OOO_STRING_SVTOOLS_HTML_VA_bottom)
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_valign
+ "=\"").append(text::VertOrientation::TOP==eRowVertOri ? OOO_STRING_SVTOOLS_HTML_VA_top : OOO_STRING_SVTOOLS_HTML_VA_bottom)
.append("\"");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
}
rWrt.Strm().WriteChar( '>' );
rWrt.IncIndentLevel(); // indent content of <TR>...</TR>
+ bool bCellRowSpan = true;
+ if (!rCells.empty() && rCells[0]->GetRowSpan() > 1)
+ {
+ // Skip the rowspan attrs of <td> elements if they are the same for every cell of this row.
+ bCellRowSpan = std::adjacent_find(rCells.begin(), rCells.end(),
+ [](const std::unique_ptr<SwWriteTableCell>& pA,
+ const std::unique_ptr<SwWriteTableCell>& pB)
+ { return pA->GetRowSpan() != pB->GetRowSpan(); })
+ != rCells.end();
+ if (!bCellRowSpan)
+ {
+ // If no rowspan is written, then skip rows which would only contain covered cells, but
+ // not the current row.
+ rSkipRows = rCells[0]->GetRowSpan() - 1;
+ }
+ }
+
for (const auto &rpCell : rCells)
{
- OutTableCell(rWrt, rpCell.get(), text::VertOrientation::NONE == eRowVertOri);
+ OutTableCell(rWrt, rpCell.get(), text::VertOrientation::NONE == eRowVertOri, bCellRowSpan);
}
rWrt.DecIndentLevel(); // indent content of <TR>...</TR>
rWrt.OutNewLine(); // </TR> in new line
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_tablerow, false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_tablerow), false );
}
void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign,
@@ -567,143 +584,124 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign,
// determine value of RULES
bool bRowsHaveBorder = false;
bool bRowsHaveBorderOnly = true;
- SwWriteTableRow *pRow = m_aRows[0].get();
- for( SwWriteTableRows::size_type nRow=1; nRow < m_aRows.size(); ++nRow )
+ assert(m_aRows.begin() != m_aRows.end());
+ for (auto row = m_aRows.begin(), next = std::next(row); next < m_aRows.end(); ++row, ++next)
{
- SwWriteTableRow *pNextRow = m_aRows[nRow].get();
- bool bBorder = ( pRow->bBottomBorder || pNextRow->bTopBorder );
+ SwWriteTableRow* pRow = row->get();
+ SwWriteTableRow* pNextRow = next->get();
+ bool bBorder = ( pRow->HasBottomBorder() || pNextRow->HasTopBorder() );
bRowsHaveBorder |= bBorder;
bRowsHaveBorderOnly &= bBorder;
- sal_uInt16 nBorder2 = pRow->bBottomBorder ? pRow->nBottomBorder : USHRT_MAX;
- if( pNextRow->bTopBorder && pNextRow->nTopBorder < nBorder2 )
- nBorder2 = pNextRow->nTopBorder;
-
- pRow->bBottomBorder = bBorder;
- pRow->nBottomBorder = nBorder2;
-
- pNextRow->bTopBorder = bBorder;
- pNextRow->nTopBorder = nBorder2;
-
- pRow = pNextRow;
+ pRow->SetBottomBorder(bBorder);
+ pNextRow->SetTopBorder(bBorder);
}
bool bColsHaveBorder = false;
bool bColsHaveBorderOnly = true;
- SwWriteTableCol *pCol = m_aCols[0].get();
- for( SwWriteTableCols::size_type nCol=1; nCol<m_aCols.size(); ++nCol )
+ assert(m_aCols.begin() != m_aCols.end());
+ for (auto col = m_aCols.begin(), next = std::next(col); next < m_aCols.end(); ++col, ++next)
{
- SwWriteTableCol *pNextCol = m_aCols[nCol].get();
- bool bBorder = ( pCol->bRightBorder || pNextCol->bLeftBorder );
+ SwWriteTableCol* pCol = col->get();
+ SwWriteTableCol* pNextCol = next->get();
+ bool bBorder = ( pCol->m_bRightBorder || pNextCol->m_bLeftBorder );
bColsHaveBorder |= bBorder;
bColsHaveBorderOnly &= bBorder;
- pCol->bRightBorder = bBorder;
- pNextCol->bLeftBorder = bBorder;
- pCol = pNextCol;
+ pCol->m_bRightBorder = bBorder;
+ pNextCol->m_bLeftBorder = bBorder;
}
// close previous numbering, etc
rWrt.ChangeParaToken( HtmlTokenId::NONE );
- if( rWrt.m_bLFPossible )
+ if (rWrt.IsLFPossible())
rWrt.OutNewLine(); // <TABLE> in new line
- OStringBuffer sOut;
- sOut.append('<').append(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_table);
+ OStringBuffer sOut("<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_table);
const SvxFrameDirection nOldDirection = rWrt.m_nDirection;
if( pFrameFormat )
rWrt.m_nDirection = rWrt.GetHTMLDirection( pFrameFormat->GetAttrSet() );
if( rWrt.m_bOutFlyFrame || nOldDirection != rWrt.m_nDirection )
{
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
rWrt.OutDirection( rWrt.m_nDirection );
}
// output ALIGN=
if( text::HoriOrientation::RIGHT == eAlign )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_align).
- append("=\"").append(OOO_STRING_SVTOOLS_HTML_AL_right).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_align
+ "=\"" OOO_STRING_SVTOOLS_HTML_AL_right "\"");
}
else if( text::HoriOrientation::CENTER == eAlign )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_align).
- append("=\"").append(OOO_STRING_SVTOOLS_HTML_AL_center).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_align
+ "=\"" OOO_STRING_SVTOOLS_HTML_AL_center "\"");
}
else if( text::HoriOrientation::LEFT == eAlign )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_align).
- append("=\"").append(OOO_STRING_SVTOOLS_HTML_AL_left).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_align
+ "=\"" OOO_STRING_SVTOOLS_HTML_AL_left "\"");
}
// output WIDTH: from layout or calculated
if( m_nTabWidth )
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_width).
- append("=\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_width "=\"");
if( HasRelWidths() )
- sOut.append(static_cast<sal_Int32>(m_nTabWidth)).append('%');
- else if( Application::GetDefaultDevice() )
- {
- sal_Int32 nPixWidth = Application::GetDefaultDevice()->LogicToPixel(
- Size(m_nTabWidth,0), MapMode(MapUnit::MapTwip) ).Width();
- if( !nPixWidth )
- nPixWidth = 1;
-
- sOut.append(nPixWidth);
- }
+ sOut.append(OString::number(static_cast<sal_Int32>(m_nTabWidth)) + "%");
else
{
- OSL_ENSURE( Application::GetDefaultDevice(), "no Application-Window!?" );
- sOut.append("100%");
+ sal_Int32 nPixWidth = SwHTMLWriter::ToPixel(m_nTabWidth);
+ sOut.append(nPixWidth);
}
sOut.append("\"");
}
- if( (nHSpace || nVSpace) && Application::GetDefaultDevice())
+ if( (nHSpace || nVSpace) && !rWrt.mbReqIF)
{
- Size aPixelSpc =
- Application::GetDefaultDevice()->LogicToPixel( Size(nHSpace,nVSpace),
- MapMode(MapUnit::MapTwip) );
- if( !aPixelSpc.Width() && nHSpace )
- aPixelSpc.setWidth( 1 );
- if( !aPixelSpc.Height() && nVSpace )
- aPixelSpc.setHeight( 1 );
-
- if( aPixelSpc.Width() )
+ if (auto nPixHSpace = SwHTMLWriter::ToPixel(nHSpace))
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_hspace).
- append("=\"").append(static_cast<sal_Int32>(aPixelSpc.Width())).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_hspace
+ "=\"" + OString::number(nPixHSpace) + "\"");
}
- if( aPixelSpc.Height() )
+ if (auto nPixVSpace = SwHTMLWriter::ToPixel(nVSpace))
{
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_vspace).
- append("=\"").append(static_cast<sal_Int32>(aPixelSpc.Height())).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_vspace
+ "=\"" + OString::number(nPixVSpace) + "\"");
}
}
// output CELLPADDING: from layout or calculated
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_cellpadding).
- append("=\"").append(static_cast<sal_Int32>(SwHTMLWriter::ToPixel(m_nCellPadding,false))).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_cellpadding
+ "=\"" + OString::number(SwHTMLWriter::ToPixel(m_nCellPadding)) + "\"");
// output CELLSPACING: from layout or calculated
- sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_cellspacing).
- append("=\"").append(static_cast<sal_Int32>(SwHTMLWriter::ToPixel(m_nCellSpacing,false))).append("\"");
+ sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_cellspacing
+ "=\"" + OString::number(SwHTMLWriter::ToPixel(m_nCellSpacing)) + "\"");
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
// output background
if( pFrameFormat )
{
- rWrt.OutBackground( pFrameFormat->GetAttrSet(), false );
+ if (!rWrt.mbXHTML)
+ {
+ rWrt.OutBackground(pFrameFormat->GetAttrSet(), false);
+ }
- if (rWrt.m_bCfgOutStyles)
+ if (rWrt.m_bCfgOutStyles || rWrt.mbXHTML)
+ {
rWrt.OutCSS1_TableFrameFormatOptions( *pFrameFormat );
+ }
}
sOut.append('>');
- rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ rWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
rWrt.IncIndentLevel(); // indent content of table
@@ -712,16 +710,14 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign,
{
rWrt.OutNewLine(); // <CAPTION> in new line
OStringBuffer sOutStr(OOO_STRING_SVTOOLS_HTML_caption);
- sOutStr.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_align).append("=\"")
+ sOutStr.append(" " OOO_STRING_SVTOOLS_HTML_O_align "=\"")
.append(bTopCaption ? OOO_STRING_SVTOOLS_HTML_VA_top : OOO_STRING_SVTOOLS_HTML_VA_bottom)
.append("\"");
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rWrt.GetNamespace() + sOutStr.getStr() );
- HTMLOutFuncs::Out_String( rWrt.Strm(), *pCaption, rWrt.m_eDestEnc, &rWrt.m_aNonConvertableCharacters );
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_caption, false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + sOutStr) );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), *pCaption );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_caption), false );
}
- const SwWriteTableCols::size_type nCols = m_aCols.size();
-
// output <COLGRP>/<COL>: If exporting via layout only when during import
// some were there, otherwise always.
bool bColGroups = (bColsHaveBorder && !bColsHaveBorderOnly);
@@ -730,11 +726,12 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign,
if( bColGroups )
{
rWrt.OutNewLine(); // <COLGRP> in new line
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_colgroup );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_colgroup) );
rWrt.IncIndentLevel(); // indent content of <COLGRP>
}
+ const SwWriteTableCols::size_type nCols = m_aCols.size();
for( SwWriteTableCols::size_type nCol=0; nCol<nCols; ++nCol )
{
rWrt.OutNewLine(); // </COL> in new line
@@ -742,7 +739,8 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign,
const SwWriteTableCol *pColumn = m_aCols[nCol].get();
HtmlWriter html(rWrt.Strm(), rWrt.maNamespace);
- html.start(OOO_STRING_SVTOOLS_HTML_col);
+ html.prettyPrint(false); // We add newlines ourself
+ html.start(OOO_STRING_SVTOOLS_HTML_col ""_ostr);
sal_uInt32 nWidth;
bool bRel;
@@ -758,19 +756,19 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign,
}
if( bRel )
- html.attribute(OOO_STRING_SVTOOLS_HTML_O_width, OString::number(nWidth) + "*");
+ html.attribute(OOO_STRING_SVTOOLS_HTML_O_width, Concat2View(OString::number(nWidth) + "*"));
else
- html.attribute(OOO_STRING_SVTOOLS_HTML_O_width, OString::number(SwHTMLWriter::ToPixel(nWidth,false)));
+ html.attribute(OOO_STRING_SVTOOLS_HTML_O_width, OString::number(SwHTMLWriter::ToPixel(nWidth)));
html.end();
- if( bColGroups && pColumn->bRightBorder && nCol<nCols-1 )
+ if( bColGroups && pColumn->m_bRightBorder && nCol<nCols-1 )
{
rWrt.DecIndentLevel(); // indent content of <COLGRP>
rWrt.OutNewLine(); // </COLGRP> in new line
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_colgroup,
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_colgroup),
false );
rWrt.OutNewLine(); // <COLGRP> in new line
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_colgroup );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_colgroup) );
rWrt.IncIndentLevel(); // indent content of <COLGRP>
}
}
@@ -779,7 +777,7 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign,
rWrt.DecIndentLevel(); // indent content of <COLGRP>
rWrt.OutNewLine(); // </COLGRP> in new line
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_colgroup,
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_colgroup),
false );
}
}
@@ -794,7 +792,7 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign,
// can be outputted if there is a line below the cell.
if( bTHead &&
(bTSections || bColGroups) &&
- m_nHeadEndRow<m_aRows.size()-1 && !m_aRows[m_nHeadEndRow]->bBottomBorder )
+ m_nHeadEndRow<m_aRows.size()-1 && !m_aRows[m_nHeadEndRow]->HasBottomBorder() )
bTHead = false;
// Output <TBODY> only if <THEAD> is outputted.
@@ -804,42 +802,39 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign,
{
rWrt.OutNewLine(); // <THEAD>/<TDATA> in new line
OString aTag = bTHead ? OOO_STRING_SVTOOLS_HTML_thead : OOO_STRING_SVTOOLS_HTML_tbody;
- HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), rWrt.GetNamespace() + aTag);
+ HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aTag));
rWrt.IncIndentLevel(); // indent content of <THEAD>/<TDATA>
}
+ sal_uInt16 nSkipRows = 0;
for( SwWriteTableRows::size_type nRow = 0; nRow < m_aRows.size(); ++nRow )
{
- const SwWriteTableRow *pRow2 = m_aRows[nRow].get();
+ const SwWriteTableRow *pRow = m_aRows[nRow].get();
- OutTableCells( rWrt, pRow2->GetCells(), pRow2->GetBackground() );
- if( !m_nCellSpacing && nRow < m_aRows.size()-1 && pRow2->bBottomBorder &&
- pRow2->nBottomBorder > DEF_LINE_WIDTH_1 )
+ if (nSkipRows == 0)
{
- for( auto nCnt = (pRow2->nBottomBorder / DEF_LINE_WIDTH_1) - 1; nCnt; --nCnt )
- {
- rWrt.OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_tablerow );
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_tablerow,
- false );
- }
+ OutTableCells(rWrt, pRow->GetCells(), pRow->GetBackground(), nSkipRows);
+ }
+ else
+ {
+ --nSkipRows;
}
if( ( (bTHead && nRow==m_nHeadEndRow) ||
- (bTBody && pRow2->bBottomBorder) ) &&
+ (bTBody && pRow->HasBottomBorder()) ) &&
nRow < m_aRows.size()-1 )
{
rWrt.DecIndentLevel(); // indent content of <THEAD>/<TDATA>
rWrt.OutNewLine(); // </THEAD>/</TDATA> in new line
OString aTag = bTHead ? OOO_STRING_SVTOOLS_HTML_thead : OOO_STRING_SVTOOLS_HTML_tbody;
- HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), rWrt.GetNamespace() + aTag, false);
+ HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aTag), false);
rWrt.OutNewLine(); // <THEAD>/<TDATA> in new line
if( bTHead && nRow==m_nHeadEndRow )
bTHead = false;
aTag = bTHead ? OOO_STRING_SVTOOLS_HTML_thead : OOO_STRING_SVTOOLS_HTML_tbody;
- HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), rWrt.GetNamespace() + aTag);
+ HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aTag));
rWrt.IncIndentLevel(); // indent content of <THEAD>/<TDATA>
}
}
@@ -850,26 +845,25 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign,
rWrt.OutNewLine(); // </THEAD>/</TDATA> in new line
OString aTag = bTHead ? OOO_STRING_SVTOOLS_HTML_thead : OOO_STRING_SVTOOLS_HTML_tbody;
- HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), rWrt.GetNamespace() + aTag, false);
+ HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aTag), false);
}
rWrt.DecIndentLevel(); // indent content of <TABLE>
rWrt.OutNewLine(); // </TABLE> in new line
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_table, false );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_table), false );
rWrt.m_nDirection = nOldDirection;
}
-Writer& OutHTML_SwTableNode( Writer& rWrt, SwTableNode & rNode,
+SwHTMLWriter& OutHTML_SwTableNode( SwHTMLWriter& rWrt, SwTableNode & rNode,
const SwFrameFormat *pFlyFrameFormat,
const OUString *pCaption, bool bTopCaption )
{
SwTable& rTable = rNode.GetTable();
- SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
- rHTMLWrt.m_bOutTable = true;
+ rWrt.m_bOutTable = true;
// The horizontal alignment of the frame (if exists) has priority.
// NONE means that no horizontal alignment was outputted.
@@ -899,11 +893,11 @@ Writer& OutHTML_SwTableNode( Writer& rWrt, SwTableNode & rNode,
// maybe open a FORM
bool bPreserveForm = false;
- if( !rHTMLWrt.m_bPreserveForm )
+ if( !rWrt.m_bPreserveForm )
{
- rHTMLWrt.OutForm( true, &rNode );
- bPreserveForm = rHTMLWrt.mxFormComps.is();
- rHTMLWrt.m_bPreserveForm = bPreserveForm;
+ rWrt.OutForm( true, &rNode );
+ bPreserveForm = rWrt.mxFormComps.is();
+ rWrt.m_bPreserveForm = bPreserveForm;
}
SwFrameFormat *pFormat = rTable.GetFrameFormat();
@@ -911,7 +905,7 @@ Writer& OutHTML_SwTableNode( Writer& rWrt, SwTableNode & rNode,
const SwFormatFrameSize& rFrameSize = pFormat->GetFrameSize();
tools::Long nWidth = rFrameSize.GetSize().Width();
sal_uInt8 nPercentWidth = rFrameSize.GetWidthPercent();
- sal_uInt16 nBaseWidth = static_cast<sal_uInt16>(nWidth);
+ sal_uInt16 nBaseWidth = o3tl::narrowing<sal_uInt16>(nWidth);
sal_Int16 eTabHoriOri = pFormat->GetHoriOrient().GetHoriOrient();
@@ -976,38 +970,31 @@ Writer& OutHTML_SwTableNode( Writer& rWrt, SwTableNode & rNode,
break;
}
- if( bCheckDefList )
+ // In ReqIF case, do not emulate indentation with fake description list
+ if( bCheckDefList && !rWrt.mbReqIF )
{
- OSL_ENSURE( !rHTMLWrt.GetNumInfo().GetNumRule() ||
- rHTMLWrt.GetNextNumInfo(),
+ OSL_ENSURE( !rWrt.GetNumInfo().GetNumRule() ||
+ rWrt.GetNextNumInfo(),
"NumInfo for next paragraph is missing!" );
const SvxLRSpaceItem& aLRItem = pFormat->GetLRSpace();
- if( aLRItem.GetLeft() > 0 && rHTMLWrt.m_nDefListMargin > 0 &&
- ( !rHTMLWrt.GetNumInfo().GetNumRule() ||
- ( rHTMLWrt.GetNextNumInfo() &&
- (rHTMLWrt.GetNextNumInfo()->IsRestart() ||
- rHTMLWrt.GetNumInfo().GetNumRule() !=
- rHTMLWrt.GetNextNumInfo()->GetNumRule()) ) ) )
+ if( aLRItem.GetLeft() > 0 && rWrt.m_nDefListMargin > 0 &&
+ ( !rWrt.GetNumInfo().GetNumRule() ||
+ ( rWrt.GetNextNumInfo() &&
+ (rWrt.GetNumInfo().GetNumRule() != rWrt.GetNextNumInfo()->GetNumRule() ||
+ rWrt.GetNextNumInfo()->IsRestart(rWrt.GetNumInfo())) ) ) )
{
// If the paragraph before the table is not numbered or the
// paragraph after the table starts with a new numbering or with
// a different rule, we can maintain the indentation with a DL.
// Otherwise we keep the indentation of the numbering.
nNewDefListLvl = static_cast< sal_uInt16 >(
- (aLRItem.GetLeft() + (rHTMLWrt.m_nDefListMargin/2)) /
- rHTMLWrt.m_nDefListMargin );
+ (aLRItem.GetLeft() + (rWrt.m_nDefListMargin/2)) /
+ rWrt.m_nDefListMargin );
}
}
- if( !pFlyFrameFormat && nNewDefListLvl != rHTMLWrt.m_nDefListLvl )
- rHTMLWrt.OutAndSetDefList( nNewDefListLvl );
-
- if( nNewDefListLvl )
- {
- if( rHTMLWrt.m_bLFPossible )
- rHTMLWrt.OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_dd );
- }
+ if( !pFlyFrameFormat && !rWrt.mbReqIF && nNewDefListLvl != rWrt.m_nDefListLvl )
+ rWrt.OutAndSetDefList( nNewDefListLvl );
// eFlyHoriOri and eTabHoriOri now only contain the values of
// LEFT/CENTER and RIGHT!
@@ -1056,28 +1043,44 @@ Writer& OutHTML_SwTableNode( Writer& rWrt, SwTableNode & rNode,
nFlyHSpace = nFlyVSpace = 0;
if( !pFormat->GetName().isEmpty() )
- rHTMLWrt.OutImplicitMark( pFormat->GetName(), "table" );
+ rWrt.OutImplicitMark( pFormat->GetName(), "table" );
if( text::HoriOrientation::NONE!=eDivHoriOri )
{
- if( rHTMLWrt.m_bLFPossible )
- rHTMLWrt.OutNewLine(); // <CENTER> in new line
+ if (rWrt.IsLFPossible())
+ rWrt.OutNewLine(); // <CENTER> in new line
if( text::HoriOrientation::CENTER==eDivHoriOri )
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_center );
+ {
+ if (!rWrt.mbXHTML)
+ {
+ // Not XHTML's css center: start <center>.
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_center) );
+ }
+ }
else
{
- OString sOut = OOO_STRING_SVTOOLS_HTML_division
- " " OOO_STRING_SVTOOLS_HTML_O_align "=\""
- OOO_STRING_SVTOOLS_HTML_AL_right "\"";
- HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + sOut.getStr() );
+ if (rWrt.mbReqIF)
+ {
+ // In ReqIF, div cannot have an 'align' attribute. For now, use 'style' only
+ // for ReqIF; maybe it makes sense to use it in both cases?
+ static constexpr char sOut[] = OOO_STRING_SVTOOLS_HTML_division
+ " style=\"display: flex; flex-direction: column; align-items: flex-end\"";
+ HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), Concat2View(rWrt.GetNamespace() + sOut));
+ }
+ else
+ {
+ static constexpr char sOut[] = OOO_STRING_SVTOOLS_HTML_division
+ " " OOO_STRING_SVTOOLS_HTML_O_align "=\"" OOO_STRING_SVTOOLS_HTML_AL_right "\"";
+ HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), Concat2View(rWrt.GetNamespace() + sOut));
+ }
}
- rHTMLWrt.IncIndentLevel(); // indent content of <CENTER>
- rHTMLWrt.m_bLFPossible = true;
+ rWrt.IncIndentLevel(); // indent content of <CENTER>
+ rWrt.SetLFPossible(true);
}
// If the table isn't in a frame, then you always can output a LF.
if( text::HoriOrientation::NONE==eTabHoriOri )
- rHTMLWrt.m_bLFPossible = true;
+ rWrt.SetLFPossible(true);
const SwHTMLTableLayout *pLayout = rTable.GetHTMLTableLayout();
@@ -1092,7 +1095,7 @@ Writer& OutHTML_SwTableNode( Writer& rWrt, SwTableNode & rNode,
if( pLayout && pLayout->IsExportable() )
{
SwHTMLWrtTable aTableWrt( pLayout );
- aTableWrt.Write( rHTMLWrt, eTabHoriOri, rTable.GetRowsToRepeat() > 0,
+ aTableWrt.Write( rWrt, eTabHoriOri, rTable.GetRowsToRepeat() > 0,
pFormat, pCaption, bTopCaption,
nFlyHSpace, nFlyVSpace );
}
@@ -1100,49 +1103,52 @@ Writer& OutHTML_SwTableNode( Writer& rWrt, SwTableNode & rNode,
{
SwHTMLWrtTable aTableWrt( rTable.GetTabLines(), nWidth,
nBaseWidth, bRelWidths, 0, 0, rTable.GetRowsToRepeat() );
- aTableWrt.Write( rHTMLWrt, eTabHoriOri, rTable.GetRowsToRepeat() > 0,
+ aTableWrt.Write( rWrt, eTabHoriOri, rTable.GetRowsToRepeat() > 0,
pFormat, pCaption, bTopCaption,
nFlyHSpace, nFlyVSpace );
}
// If the table wasn't in a frame, then you always can output a LF.
if( text::HoriOrientation::NONE==eTabHoriOri )
- rHTMLWrt.m_bLFPossible = true;
+ rWrt.SetLFPossible(true);
if( text::HoriOrientation::NONE!=eDivHoriOri )
{
- rHTMLWrt.DecIndentLevel(); // indent content of <CENTER>
- rHTMLWrt.OutNewLine(); // </CENTER> in new line
+ rWrt.DecIndentLevel(); // indent content of <CENTER>
+ rWrt.OutNewLine(); // </CENTER> in new line
OString aTag = text::HoriOrientation::CENTER == eDivHoriOri
? OOO_STRING_SVTOOLS_HTML_center
: OOO_STRING_SVTOOLS_HTML_division;
- HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), rHTMLWrt.GetNamespace() + aTag, false);
- rHTMLWrt.m_bLFPossible = true;
+ if (!rWrt.mbXHTML || eDivHoriOri != text::HoriOrientation::CENTER)
+ {
+ // Not XHTML's css center: end <center>.
+ HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aTag), false);
+ }
+ rWrt.SetLFPossible(true);
}
// move Pam behind the table
- rHTMLWrt.m_pCurrentPam->GetPoint()->nNode = *rNode.EndOfSectionNode();
+ rWrt.m_pCurrentPam->GetPoint()->Assign( *rNode.EndOfSectionNode() );
if( bPreserveForm )
{
- rHTMLWrt.m_bPreserveForm = false;
- rHTMLWrt.OutForm( false );
+ rWrt.m_bPreserveForm = false;
+ rWrt.OutForm( false );
}
- rHTMLWrt.m_bOutTable = false;
+ rWrt.m_bOutTable = false;
- if( rHTMLWrt.GetNextNumInfo() &&
- !rHTMLWrt.GetNextNumInfo()->IsRestart() &&
- rHTMLWrt.GetNextNumInfo()->GetNumRule() ==
- rHTMLWrt.GetNumInfo().GetNumRule() )
+ if( rWrt.GetNextNumInfo() &&
+ rWrt.GetNextNumInfo()->GetNumRule() == rWrt.GetNumInfo().GetNumRule() &&
+ !rWrt.GetNextNumInfo()->IsRestart(rWrt.GetNumInfo()) )
{
// If the paragraph after the table is numbered with the same rule as the
// one before, then the NumInfo of the next paragraph holds the level of
// paragraph before the table. Therefore NumInfo must be fetched again
// to maybe close the Num list.
- rHTMLWrt.ClearNextNumInfo();
- rHTMLWrt.FillNextNumInfo();
- OutHTML_NumberBulletListEnd( rHTMLWrt, *rHTMLWrt.GetNextNumInfo() );
+ rWrt.ClearNextNumInfo();
+ rWrt.FillNextNumInfo();
+ OutHTML_NumberBulletListEnd( rWrt, *rWrt.GetNextNumInfo() );
}
return rWrt;
}
diff --git a/sw/source/filter/html/parcss1.cxx b/sw/source/filter/html/parcss1.cxx
index 39038ab8b91c..a32de72ab52f 100644
--- a/sw/source/filter/html/parcss1.cxx
+++ b/sw/source/filter/html/parcss1.cxx
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <o3tl/string_view.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <osl/diagnose.h>
#include <rtl/character.hxx>
#include <rtl/ustrbuf.hxx>
@@ -373,92 +375,67 @@ CSS1Token CSS1Parser::GetNextToken()
// save current position
sal_Int32 nInPosOld = m_nInPos;
sal_Unicode cNextChOld = m_cNextCh;
- sal_uLong nlLineNrOld = m_nlLineNr;
- sal_uLong nlLinePosOld = m_nlLinePos;
+ sal_uInt32 nlLineNrOld = m_nlLineNr;
+ sal_uInt32 nlLinePosOld = m_nlLinePos;
bool bEOFOld = m_bEOF;
// parse the next identifier
- OUString aIdent;
OUStringBuffer sTmpBuffer2(64);
do {
- sTmpBuffer2.append( m_cNextCh );
+ sTmpBuffer2.append(static_cast<sal_Unicode>(rtl::toAsciiLowerCase(m_cNextCh)));
m_cNextCh = GetNextChar();
} while( (rtl::isAsciiAlphanumeric(m_cNextCh) ||
'-' == m_cNextCh) && !IsEOF() );
- aIdent += sTmpBuffer2;
+ OUString aIdent = sTmpBuffer2.makeStringAndClear();
+ nRet = CSS1_NUMBER;
// Is it a unit?
- const char *pCmp1 = nullptr, *pCmp2 = nullptr, *pCmp3 = nullptr;
- double nScale1 = 1., nScale2 = 1.;
- CSS1Token nToken1 = CSS1_LENGTH,
- nToken2 = CSS1_LENGTH,
- nToken3 = CSS1_LENGTH;
switch( aIdent[0] )
{
case 'c':
- case 'C':
- pCmp1 = "cm";
- nScale1 = (72.*20.)/2.54; // twip
+ if (aIdent == "cm")
+ {
+ m_nValue = o3tl::convert(m_nValue, o3tl::Length::cm, o3tl::Length::twip);
+ nRet = CSS1_LENGTH;
+ }
break;
case 'e':
- case 'E':
- pCmp1 = "em";
- nToken1 = CSS1_EMS;
-
- pCmp2 = "ex";
- nToken2 = CSS1_EMX;
+ if (aIdent == "em")
+ nRet = CSS1_EMS;
+ else if (aIdent == "ex")
+ nRet = CSS1_EMX;
break;
case 'i':
- case 'I':
- pCmp1 = "in";
- nScale1 = 72.*20.; // twip
+ if (aIdent == "in")
+ {
+ nRet = CSS1_LENGTH;
+ m_nValue = o3tl::convert(m_nValue, o3tl::Length::in, o3tl::Length::twip);
+ }
break;
case 'm':
- case 'M':
- pCmp1 = "mm";
- nScale1 = (72.*20.)/25.4; // twip
+ if (aIdent == "mm")
+ {
+ nRet = CSS1_LENGTH;
+ m_nValue = o3tl::convert(m_nValue, o3tl::Length::mm, o3tl::Length::twip);
+ }
break;
case 'p':
- case 'P':
- pCmp1 = "pt";
- nScale1 = 20.; // twip
-
- pCmp2 = "pc";
- nScale2 = 12.*20.; // twip
-
- pCmp3 = "px";
- nToken3 = CSS1_PIXLENGTH;
+ if (aIdent == "pt")
+ {
+ nRet = CSS1_LENGTH;
+ m_nValue = o3tl::convert(m_nValue, o3tl::Length::pt, o3tl::Length::twip);
+ }
+ else if (aIdent == "pc")
+ {
+ nRet = CSS1_LENGTH;
+ m_nValue = o3tl::convert(m_nValue, o3tl::Length::pc, o3tl::Length::twip);
+ }
+ else if (aIdent == "px")
+ nRet = CSS1_PIXLENGTH;
break;
}
- double nScale = 0.0;
- OSL_ENSURE( pCmp1, "Where does the first digit come from?" );
- if( aIdent.equalsIgnoreAsciiCaseAscii( pCmp1 ) )
- {
- nScale = nScale1;
- nRet = nToken1;
- }
- else if( pCmp2 &&
- aIdent.equalsIgnoreAsciiCaseAscii( pCmp2 ) )
- {
- nScale = nScale2;
- nRet = nToken2;
- }
- else if( pCmp3 &&
- aIdent.equalsIgnoreAsciiCaseAscii( pCmp3 ) )
- {
- nScale = 1.; // nScale3
- nRet = nToken3;
- }
- else
- {
- nRet = CSS1_NUMBER;
- }
-
- if( CSS1_LENGTH==nRet && nScale!=1.0 )
- m_nValue *= nScale;
-
if( nRet == CSS1_NUMBER )
{
m_nInPos = nInPosOld;
@@ -524,16 +501,16 @@ CSS1Token CSS1Parser::GetNextToken()
// save current position
sal_Int32 nInPosSave = m_nInPos;
sal_Unicode cNextChSave = m_cNextCh;
- sal_uLong nlLineNrSave = m_nlLineNr;
- sal_uLong nlLinePosSave = m_nlLinePos;
+ sal_uInt32 nlLineNrSave = m_nlLineNr;
+ sal_uInt32 nlLinePosSave = m_nlLinePos;
bool bEOFSave = m_bEOF;
// first try to parse a hex digit
- OUStringBuffer sTmpBuffer(6);
+ OUStringBuffer sTmpBuffer(8);
do {
sTmpBuffer.append( m_cNextCh );
m_cNextCh = GetNextChar();
- } while( sTmpBuffer.getLength() < 7 &&
+ } while( sTmpBuffer.getLength() < 9 &&
( ('0'<=m_cNextCh && '9'>=m_cNextCh) ||
('A'<=m_cNextCh && 'F'>=m_cNextCh) ||
('a'<=m_cNextCh && 'f'>=m_cNextCh) ) &&
@@ -541,7 +518,7 @@ CSS1Token CSS1Parser::GetNextToken()
if( sTmpBuffer.getLength()==6 || sTmpBuffer.getLength()==3 )
{
- // we found a color in hex
+ // we found a color in hex (RGB)
m_aToken += sTmpBuffer;
nRet = CSS1_HEXCOLOR;
bNextCh = false;
@@ -549,6 +526,26 @@ CSS1Token CSS1Parser::GetNextToken()
break;
}
+ if( sTmpBuffer.getLength()==8 )
+ {
+ // we found a color in hex (RGBA)
+ // we convert it to RGB assuming white background
+ sal_uInt32 nColor = sTmpBuffer.makeStringAndClear().toUInt32(16);
+ sal_uInt32 nRed = (nColor & 0xff000000) >> 24;
+ sal_uInt32 nGreen = (nColor & 0xff0000) >> 16;
+ sal_uInt32 nBlue = (nColor & 0xff00) >> 8;
+ double nAlpha = (nColor & 0xff) / 255.0;
+ nRed = (1 - nAlpha) * 255 + nAlpha * nRed;
+ nGreen = (1 - nAlpha) * 255 + nAlpha * nGreen;
+ nBlue = (1 - nAlpha) * 255 + nAlpha * nBlue;
+ nColor = (nRed << 16) + (nGreen << 8) + nBlue;
+ m_aToken += OUString::number(nColor, 16);
+ nRet = CSS1_HEXCOLOR;
+ bNextCh = false;
+
+ break;
+ }
+
// otherwise we try a number
m_nInPos = nInPosSave;
m_cNextCh = cNextChSave;
@@ -612,7 +609,8 @@ CSS1Token CSS1Parser::GetNextToken()
( (('u'==m_aToken[0] || 'U'==m_aToken[0]) &&
m_aToken.equalsIgnoreAsciiCase( "url" )) ||
(('r'==m_aToken[0] || 'R'==m_aToken[0]) &&
- m_aToken.equalsIgnoreAsciiCase( "rgb" )) ) )
+ (m_aToken.equalsIgnoreAsciiCase( "rgb" ) || m_aToken.equalsIgnoreAsciiCase( "rgba" ) )
+ ) ) )
{
int nNestCnt = 0;
OUStringBuffer sTmpBuffer2(64);
@@ -1200,7 +1198,7 @@ void CSS1Parser::DeclarationParsed( const OUString& /*rProperty*/,
CSS1Selector::~CSS1Selector()
{
- delete pNext;
+ delete m_pNext;
}
CSS1Expression::~CSS1Expression()
@@ -1247,25 +1245,31 @@ bool CSS1Expression::GetColor( Color &rColor ) const
{
case CSS1_RGB:
{
- sal_uInt8 aColors[3] = { 0, 0, 0 };
+ // fourth value to 255 means no alpha transparency
+ // so the right by default value
+ sal_uInt8 aColors[4] = { 0, 0, 0, 255 };
+ // it can be "rgb" or "rgba"
if (!aValue.startsWithIgnoreAsciiCase( "rgb" ) || aValue.getLength() < 6 ||
- aValue[3] != '(' || aValue[aValue.getLength()-1] != ')')
+ (aValue[3] != '(' && aValue[4] != '(' ) || aValue[aValue.getLength()-1] != ')')
{
break;
}
- sal_Int32 nPos = 4; // start after "rgb("
- for ( int nCol = 0; nCol < 3 && nPos > 0; ++nCol )
+ sal_Int32 nPos = aValue.startsWithIgnoreAsciiCase( "rgba" )?5:4; // start after "rgba(" or "rgb("
+ char cSep = (aValue.indexOf(',') != -1)?',':' ';
+ // alpha value can be after a "/" or ","
+ bool bIsSepAlphaDiv = (aValue.indexOf('/') != -1)?true:false;
+ for ( int nCol = 0; nCol < 4 && nPos > 0; ++nCol )
{
- const OUString aNumber = aValue.getToken(0, ',', nPos);
+ const std::u16string_view aNumber = o3tl::getToken(aValue, 0, cSep, nPos);
- sal_Int32 nNumber = aNumber.toInt32();
+ sal_Int32 nNumber = o3tl::toInt32(aNumber);
if( nNumber<0 )
{
nNumber = 0;
}
- else if( aNumber.indexOf('%') >= 0 )
+ else if( aNumber.find('%') != std::u16string_view::npos )
{
if( nNumber > 100 )
nNumber = 100;
@@ -1274,13 +1278,25 @@ bool CSS1Expression::GetColor( Color &rColor ) const
}
else if( nNumber > 255 )
nNumber = 255;
-
+ else if( aNumber.find('.') != std::u16string_view::npos )
+ {
+ // in this case aNumber contains something like "0.3" so not an sal_Int32
+ nNumber = static_cast<sal_Int32>(255.0*o3tl::toDouble(aNumber));
+ }
aColors[nCol] = static_cast<sal_uInt8>(nNumber);
+ // rgb with alpha and '/' has this form: rgb(255 0 0 / 50%)
+ if (bIsSepAlphaDiv && nCol == 2)
+ {
+ // but there can be some spaces or not before and after the "/", so skip them
+ while (aValue[nPos] == '/' || aValue[nPos] == ' ')
+ ++nPos;
+ }
}
rColor.SetRed( aColors[0] );
rColor.SetGreen( aColors[1] );
rColor.SetBlue( aColors[2] );
+ rColor.SetAlpha( aColors[3] );
bRet = true; // something different than a colour isn't possible
}
diff --git a/sw/source/filter/html/parcss1.hxx b/sw/source/filter/html/parcss1.hxx
index 6e2d50426d4c..99f46af8e830 100644
--- a/sw/source/filter/html/parcss1.hxx
+++ b/sw/source/filter/html/parcss1.hxx
@@ -24,6 +24,7 @@
#include <tools/color.hxx>
#include <memory>
+#include <utility>
// tokens of the CSS1 parser
enum CSS1Token
@@ -90,22 +91,22 @@ enum CSS1SelectorType
*/
class CSS1Selector
{
- CSS1SelectorType eType; // the type
- OUString aSelector; // the selector itself
- CSS1Selector *pNext; // the following component
+ CSS1SelectorType m_eType; // the type
+ OUString m_aSelector; // the selector itself
+ CSS1Selector *m_pNext; // the following component
public:
- CSS1Selector( CSS1SelectorType eTyp, const OUString &rSel )
- : eType(eTyp), aSelector( rSel ), pNext( nullptr )
+ CSS1Selector( CSS1SelectorType eTyp, OUString aSel )
+ : m_eType(eTyp), m_aSelector(std::move( aSel )), m_pNext( nullptr )
{}
~CSS1Selector();
- CSS1SelectorType GetType() const { return eType; }
- const OUString& GetString() const { return aSelector; }
+ CSS1SelectorType GetType() const { return m_eType; }
+ const OUString& GetString() const { return m_aSelector; }
- void SetNext( CSS1Selector *pNxt ) { pNext = pNxt; }
- const CSS1Selector *GetNext() const { return pNext; }
+ void SetNext( CSS1Selector *pNxt ) { m_pNext = pNxt; }
+ const CSS1Selector *GetNext() const { return m_pNext; }
};
/** a subexpression of a CSS1 declaration
@@ -117,6 +118,7 @@ public:
*/
struct CSS1Expression
{
+private:
sal_Unicode cOp; // type of the link with its predecessor
CSS1Token eType; // type of the expression
OUString aValue; // value as string
@@ -124,9 +126,9 @@ struct CSS1Expression
CSS1Expression *pNext; // the following component
public:
- CSS1Expression( CSS1Token eTyp, const OUString &rVal,
+ CSS1Expression( CSS1Token eTyp, OUString aVal,
double nVal, sal_Unicode cO = 0 )
- : cOp(cO), eType(eTyp), aValue(rVal), nValue(nVal), pNext(nullptr)
+ : cOp(cO), eType(eTyp), aValue(std::move(aVal)), nValue(nVal), pNext(nullptr)
{}
~CSS1Expression();
diff --git a/sw/source/filter/html/svxcss1.cxx b/sw/source/filter/html/svxcss1.cxx
index 9ff8244ca50b..d186fc295796 100644
--- a/sw/source/filter/html/svxcss1.cxx
+++ b/sw/source/filter/html/svxcss1.cxx
@@ -19,7 +19,9 @@
#include <sal/config.h>
+#include <algorithm>
#include <cmath>
+#include <limits>
#include <memory>
#include <stdlib.h>
@@ -50,17 +52,18 @@
#include <editeng/widwitem.hxx>
#include <editeng/frmdiritem.hxx>
#include <editeng/orphitem.hxx>
-#include <svtools/svparser.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
+#include <o3tl/string_view.hxx>
+
+#include <hintids.hxx>
#include "css1kywd.hxx"
#include "svxcss1.hxx"
#include "htmlnum.hxx"
-#include <utility>
-
using namespace ::com::sun::star;
/// type of functions to parse CSS1 properties
@@ -244,12 +247,11 @@ CSS1PropertyEnum const aBulletStyleTable[] =
{ nullptr, 0 }
};
-
sal_uInt16 const aBorderWidths[] =
{
- DEF_LINE_WIDTH_0,
- DEF_LINE_WIDTH_5,
- DEF_LINE_WIDTH_1
+ SvxBorderLineWidth::Hairline,
+ SvxBorderLineWidth::VeryThin,
+ SvxBorderLineWidth::Thin
};
#undef SBORDER_ENTRY
@@ -285,8 +287,8 @@ struct SvxCSS1ItemIds
sal_uInt16 nOrphans;
sal_uInt16 nFormatSplit;
- sal_uInt16 nLRSpace;
- sal_uInt16 nULSpace;
+ // this looks a bit superfluous? TypedWhichId<SvxLRSpaceItem> nLRSpace{0};
+ TypedWhichId<SvxULSpaceItem> nULSpace{0};
sal_uInt16 nBox;
sal_uInt16 nBrush;
@@ -400,6 +402,8 @@ SvxCSS1PropertyInfo::SvxCSS1PropertyInfo( const SvxCSS1PropertyInfo& rProp ) :
m_eTopType( rProp.m_eTopType ),
m_eWidthType( rProp.m_eWidthType ),
m_eHeightType( rProp.m_eHeightType ),
+ m_eLeftMarginType( rProp.m_eLeftMarginType ),
+ m_eRightMarginType( rProp.m_eRightMarginType ),
m_eSizeType( rProp.m_eSizeType ),
m_ePageBreakBefore( rProp.m_ePageBreakBefore ),
m_ePageBreakAfter( rProp.m_ePageBreakAfter )
@@ -439,6 +443,8 @@ void SvxCSS1PropertyInfo::Clear()
m_nLeft = m_nTop = m_nWidth = m_nHeight = 0;
m_eLeftType = m_eTopType = m_eWidthType = m_eHeightType = SVX_CSS1_LTYPE_NONE;
+ m_eLeftMarginType = SVX_CSS1_LTYPE_NONE;
+ m_eRightMarginType = SVX_CSS1_LTYPE_NONE;
// Feature: PrintExt
m_eSizeType = SVX_CSS1_STYPE_NONE;
@@ -661,10 +667,10 @@ void SvxCSS1PropertyInfo::SetBoxItem( SfxItemSet& rItemSet,
DestroyBorderInfos();
}
-SvxCSS1MapEntry::SvxCSS1MapEntry( const SfxItemSet& rItemSet,
+SvxCSS1MapEntry::SvxCSS1MapEntry( SfxItemSet aItemSet,
const SvxCSS1PropertyInfo& rProp ) :
- aItemSet( rItemSet ),
- aPropInfo( rProp )
+ m_aItemSet(std::move( aItemSet )),
+ m_aPropInfo( rProp )
{}
void SvxCSS1Parser::StyleParsed( const CSS1Selector * /*pSelector*/,
@@ -678,14 +684,14 @@ void SvxCSS1Parser::SelectorParsed( std::unique_ptr<CSS1Selector> pSelector, boo
{
if( bFirst )
{
- OSL_ENSURE( pSheetItemSet, "Where is the Item-Set for Style-Sheets?" );
+ OSL_ENSURE( m_pSheetItemSet, "Where is the Item-Set for Style-Sheets?" );
for (const std::unique_ptr<CSS1Selector> & rpSelection : m_Selectors)
{
- StyleParsed(rpSelection.get(), *pSheetItemSet, *pSheetPropInfo);
+ StyleParsed(rpSelection.get(), *m_pSheetItemSet, *m_pSheetPropInfo);
}
- pSheetItemSet->ClearItem();
- pSheetPropInfo->Clear();
+ m_pSheetItemSet->ClearItem();
+ m_pSheetPropInfo->Clear();
// prepare the next rule
m_Selectors.clear();
@@ -694,66 +700,73 @@ void SvxCSS1Parser::SelectorParsed( std::unique_ptr<CSS1Selector> pSelector, boo
m_Selectors.push_back(std::move(pSelector));
}
-SvxCSS1Parser::SvxCSS1Parser( SfxItemPool& rPool, const OUString& rBaseURL,
+SvxCSS1Parser::SvxCSS1Parser( SfxItemPool& rPool, OUString aBaseURL,
sal_uInt16 const *pWhichIds, sal_uInt16 nWhichIds ) :
- CSS1Parser(),
- sBaseURL( rBaseURL ),
- pItemSet(nullptr),
- pPropInfo( nullptr ),
- eDfltEnc( RTL_TEXTENCODING_DONTKNOW ),
- bIgnoreFontFamily( false )
+ m_sBaseURL(std::move( aBaseURL )),
+ m_pItemSet(nullptr),
+ m_pPropInfo( nullptr ),
+ m_eDefaultEnc( RTL_TEXTENCODING_DONTKNOW ),
+ m_bIgnoreFontFamily( false )
{
// also initialize item IDs
- aItemIds.nFont = rPool.GetTrueWhich( SID_ATTR_CHAR_FONT, false );
- aItemIds.nFontCJK = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_FONT, false );
- aItemIds.nFontCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_FONT, false );
- aItemIds.nPosture = rPool.GetTrueWhich( SID_ATTR_CHAR_POSTURE, false );
- aItemIds.nPostureCJK = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_POSTURE, false );
- aItemIds.nPostureCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_POSTURE, false );
- aItemIds.nWeight = rPool.GetTrueWhich( SID_ATTR_CHAR_WEIGHT, false );
- aItemIds.nWeightCJK = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_WEIGHT, false );
- aItemIds.nWeightCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_WEIGHT, false );
- aItemIds.nFontHeight = rPool.GetTrueWhich( SID_ATTR_CHAR_FONTHEIGHT, false );
- aItemIds.nFontHeightCJK = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT, false );
- aItemIds.nFontHeightCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT, false );
- aItemIds.nUnderline = rPool.GetTrueWhich( SID_ATTR_CHAR_UNDERLINE, false );
- aItemIds.nOverline = rPool.GetTrueWhich( SID_ATTR_CHAR_OVERLINE, false );
- aItemIds.nCrossedOut = rPool.GetTrueWhich( SID_ATTR_CHAR_STRIKEOUT, false );
- aItemIds.nColor = rPool.GetTrueWhich( SID_ATTR_CHAR_COLOR, false );
- aItemIds.nKerning = rPool.GetTrueWhich( SID_ATTR_CHAR_KERNING, false );
- aItemIds.nCaseMap = rPool.GetTrueWhich( SID_ATTR_CHAR_CASEMAP, false );
- aItemIds.nBlink = rPool.GetTrueWhich( SID_ATTR_FLASH, false );
-
- aItemIds.nLineSpacing = rPool.GetTrueWhich( SID_ATTR_PARA_LINESPACE, false );
- aItemIds.nAdjust = rPool.GetTrueWhich( SID_ATTR_PARA_ADJUST, false );
- aItemIds.nWidows = rPool.GetTrueWhich( SID_ATTR_PARA_WIDOWS, false );
- aItemIds.nOrphans = rPool.GetTrueWhich( SID_ATTR_PARA_ORPHANS, false );
- aItemIds.nFormatSplit = rPool.GetTrueWhich( SID_ATTR_PARA_SPLIT, false );
-
- aItemIds.nLRSpace = rPool.GetTrueWhich( SID_ATTR_LRSPACE, false );
- aItemIds.nULSpace = rPool.GetTrueWhich( SID_ATTR_ULSPACE, false );
- aItemIds.nBox = rPool.GetTrueWhich( SID_ATTR_BORDER_OUTER, false );
- aItemIds.nBrush = rPool.GetTrueWhich( SID_ATTR_BRUSH, false );
-
- aItemIds.nLanguage = rPool.GetTrueWhich( SID_ATTR_CHAR_LANGUAGE, false );
- aItemIds.nLanguageCJK = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_LANGUAGE, false );
- aItemIds.nLanguageCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_LANGUAGE, false );
- aItemIds.nDirection = rPool.GetTrueWhich( SID_ATTR_FRAMEDIRECTION, false );
-
- aWhichMap.insert( aWhichMap.begin(), 0 );
- BuildWhichTable( aWhichMap, reinterpret_cast<sal_uInt16 *>(&aItemIds),
- sizeof(aItemIds) / sizeof(sal_uInt16) );
+ auto initTrueWhich = [&rPool, this](sal_uInt16 rWid)
+ {
+ rWid = rPool.GetTrueWhichIDFromSlotID(rWid, false);
+ m_aWhichMap = m_aWhichMap.MergeRange(rWid, rWid);
+ return rWid;
+ };
+
+ aItemIds.nFont = initTrueWhich( SID_ATTR_CHAR_FONT );
+ aItemIds.nFontCJK = initTrueWhich( SID_ATTR_CHAR_CJK_FONT );
+ aItemIds.nFontCTL = initTrueWhich( SID_ATTR_CHAR_CTL_FONT );
+ aItemIds.nPosture = initTrueWhich( SID_ATTR_CHAR_POSTURE );
+ aItemIds.nPostureCJK = initTrueWhich( SID_ATTR_CHAR_CJK_POSTURE );
+ aItemIds.nPostureCTL = initTrueWhich( SID_ATTR_CHAR_CTL_POSTURE );
+ aItemIds.nWeight = initTrueWhich( SID_ATTR_CHAR_WEIGHT );
+ aItemIds.nWeightCJK = initTrueWhich( SID_ATTR_CHAR_CJK_WEIGHT );
+ aItemIds.nWeightCTL = initTrueWhich( SID_ATTR_CHAR_CTL_WEIGHT );
+ aItemIds.nFontHeight = initTrueWhich( SID_ATTR_CHAR_FONTHEIGHT );
+ aItemIds.nFontHeightCJK = initTrueWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT );
+ aItemIds.nFontHeightCTL = initTrueWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT );
+ aItemIds.nUnderline = initTrueWhich( SID_ATTR_CHAR_UNDERLINE );
+ aItemIds.nOverline = initTrueWhich( SID_ATTR_CHAR_OVERLINE );
+ aItemIds.nCrossedOut = initTrueWhich( SID_ATTR_CHAR_STRIKEOUT );
+ aItemIds.nColor = initTrueWhich( SID_ATTR_CHAR_COLOR );
+ aItemIds.nKerning = initTrueWhich( SID_ATTR_CHAR_KERNING );
+ aItemIds.nCaseMap = initTrueWhich( SID_ATTR_CHAR_CASEMAP );
+ aItemIds.nBlink = initTrueWhich( SID_ATTR_FLASH );
+
+ aItemIds.nLineSpacing = initTrueWhich( SID_ATTR_PARA_LINESPACE );
+ aItemIds.nAdjust = initTrueWhich( SID_ATTR_PARA_ADJUST );
+ aItemIds.nWidows = initTrueWhich( SID_ATTR_PARA_WIDOWS );
+ aItemIds.nOrphans = initTrueWhich( SID_ATTR_PARA_ORPHANS );
+ aItemIds.nFormatSplit = initTrueWhich( SID_ATTR_PARA_SPLIT );
+
+ // every id that is used must be added
+ m_aWhichMap = m_aWhichMap.MergeRange(RES_MARGIN_FIRSTLINE, RES_MARGIN_FIRSTLINE);
+ m_aWhichMap = m_aWhichMap.MergeRange(RES_MARGIN_TEXTLEFT, RES_MARGIN_TEXTLEFT);
+ m_aWhichMap = m_aWhichMap.MergeRange(RES_MARGIN_RIGHT, RES_MARGIN_RIGHT);
+ aItemIds.nULSpace = TypedWhichId<SvxULSpaceItem>(initTrueWhich( SID_ATTR_ULSPACE ));
+ aItemIds.nBox = initTrueWhich( SID_ATTR_BORDER_OUTER );
+ aItemIds.nBrush = initTrueWhich( SID_ATTR_BRUSH );
+
+ aItemIds.nLanguage = initTrueWhich( SID_ATTR_CHAR_LANGUAGE );
+ aItemIds.nLanguageCJK = initTrueWhich( SID_ATTR_CHAR_CJK_LANGUAGE );
+ aItemIds.nLanguageCTL = initTrueWhich( SID_ATTR_CHAR_CTL_LANGUAGE );
+ aItemIds.nDirection = initTrueWhich( SID_ATTR_FRAMEDIRECTION );
+
if( pWhichIds && nWhichIds )
- BuildWhichTable( aWhichMap, pWhichIds, nWhichIds );
+ for (sal_uInt16 i = 0; i < nWhichIds; ++i)
+ m_aWhichMap = m_aWhichMap.MergeRange(pWhichIds[i], pWhichIds[i]);
- pSheetItemSet.reset( new SfxItemSet( rPool, aWhichMap.data() ) );
- pSheetPropInfo.reset( new SvxCSS1PropertyInfo );
+ m_pSheetItemSet.reset( new SfxItemSet( rPool, m_aWhichMap ) );
+ m_pSheetPropInfo.reset( new SvxCSS1PropertyInfo );
}
SvxCSS1Parser::~SvxCSS1Parser()
{
- pSheetItemSet.reset();
- pSheetPropInfo.reset();
+ m_pSheetItemSet.reset();
+ m_pSheetPropInfo.reset();
}
void SvxCSS1Parser::InsertId( const OUString& rId,
@@ -818,23 +831,23 @@ SvxCSS1MapEntry* SvxCSS1Parser::GetTag( const OUString& rTag )
bool SvxCSS1Parser::ParseStyleSheet( const OUString& rIn )
{
- pItemSet = pSheetItemSet.get();
- pPropInfo = pSheetPropInfo.get();
+ m_pItemSet = m_pSheetItemSet.get();
+ m_pPropInfo = m_pSheetPropInfo.get();
CSS1Parser::ParseStyleSheet( rIn );
for (const std::unique_ptr<CSS1Selector> & rpSelector : m_Selectors)
{
- StyleParsed(rpSelector.get(), *pSheetItemSet, *pSheetPropInfo);
+ StyleParsed(rpSelector.get(), *m_pSheetItemSet, *m_pSheetPropInfo);
}
// and clean up a little bit
m_Selectors.clear();
- pSheetItemSet->ClearItem();
- pSheetPropInfo->Clear();
+ m_pSheetItemSet->ClearItem();
+ m_pSheetPropInfo->Clear();
- pItemSet = nullptr;
- pPropInfo = nullptr;
+ m_pItemSet = nullptr;
+ m_pPropInfo = nullptr;
return true;
}
@@ -843,22 +856,22 @@ void SvxCSS1Parser::ParseStyleOption( const OUString& rIn,
SfxItemSet& rItemSet,
SvxCSS1PropertyInfo& rPropInfo )
{
- pItemSet = &rItemSet;
- pPropInfo = &rPropInfo;
+ m_pItemSet = &rItemSet;
+ m_pPropInfo = &rPropInfo;
CSS1Parser::ParseStyleOption( rIn );
rItemSet.ClearItem( aItemIds.nDirection );
- pItemSet = nullptr;
- pPropInfo = nullptr;
+ m_pItemSet = nullptr;
+ m_pPropInfo = nullptr;
}
bool SvxCSS1Parser::GetEnum( const CSS1PropertyEnum *pPropTable,
- const OUString &rValue, sal_uInt16& rEnum )
+ std::u16string_view rValue, sal_uInt16& rEnum )
{
while( pPropTable->pName )
{
- if( !rValue.equalsIgnoreAsciiCaseAscii( pPropTable->pName ) )
+ if( !o3tl::equalsIgnoreAsciiCase( rValue, pPropTable->pName ) )
pPropTable++;
else
break;
@@ -872,15 +885,8 @@ bool SvxCSS1Parser::GetEnum( const CSS1PropertyEnum *pPropTable,
void SvxCSS1Parser::PixelToTwip( tools::Long &rWidth, tools::Long &rHeight )
{
- if( Application::GetDefaultDevice() )
- {
- Size aTwipSz( rWidth, rHeight );
- aTwipSz = Application::GetDefaultDevice()->PixelToLogic( aTwipSz,
- MapMode(MapUnit::MapTwip) );
-
- rWidth = aTwipSz.Width();
- rHeight = aTwipSz.Height();
- }
+ rWidth = o3tl::convert(rWidth, o3tl::Length::px, o3tl::Length::twip);
+ rHeight = o3tl::convert(rHeight, o3tl::Length::px, o3tl::Length::twip);
}
sal_uInt32 SvxCSS1Parser::GetFontHeight( sal_uInt16 nSize ) const
@@ -912,11 +918,9 @@ void SvxCSS1Parser::InsertMapEntry( const OUString& rKey,
const SvxCSS1PropertyInfo& rProp,
CSS1Map& rMap )
{
- CSS1Map::iterator itr = rMap.find(rKey);
- if (itr == rMap.end())
- {
- rMap.insert(std::make_pair(rKey, std::make_unique<SvxCSS1MapEntry>(rItemSet, rProp)));
- }
+ auto [itr,inserted] = rMap.insert(std::make_pair(rKey, nullptr));
+ if (inserted)
+ itr->second = std::make_unique<SvxCSS1MapEntry>(rItemSet, rProp);
else
{
SvxCSS1MapEntry *const p = itr->second.get();
@@ -937,31 +941,28 @@ void SvxCSS1Parser::MergeStyles( const SfxItemSet& rSrcSet,
}
else
{
- SvxLRSpaceItem aLRSpace( static_cast<const SvxLRSpaceItem&>(rTargetSet.Get(aItemIds.nLRSpace)) );
- SvxULSpaceItem aULSpace( static_cast<const SvxULSpaceItem&>(rTargetSet.Get(aItemIds.nULSpace)) );
-
- rTargetSet.Put( rSrcSet );
-
- if( rSrcInfo.m_bLeftMargin || rSrcInfo.m_bRightMargin ||
- rSrcInfo.m_bTextIndent )
+ // not sure if this is really necessary?
+ SfxItemSet copy(rSrcSet);
+ if (!rSrcInfo.m_bTextIndent)
+ {
+ copy.ClearItem(RES_MARGIN_FIRSTLINE);
+ }
+ if (!rSrcInfo.m_bLeftMargin)
{
- const SvxLRSpaceItem& rNewLRSpace =
- static_cast<const SvxLRSpaceItem&>(rSrcSet.Get( aItemIds.nLRSpace ));
+ copy.ClearItem(RES_MARGIN_TEXTLEFT);
+ }
+ if (!rSrcInfo.m_bRightMargin)
+ {
+ copy.ClearItem(RES_MARGIN_RIGHT);
+ }
- if( rSrcInfo.m_bLeftMargin )
- aLRSpace.SetLeft( rNewLRSpace.GetLeft() );
- if( rSrcInfo.m_bRightMargin )
- aLRSpace.SetRight( rNewLRSpace.GetRight() );
- if( rSrcInfo.m_bTextIndent )
- aLRSpace.SetTextFirstLineOffset( rNewLRSpace.GetTextFirstLineOffset() );
+ SvxULSpaceItem aULSpace( rTargetSet.Get(aItemIds.nULSpace) );
- rTargetSet.Put( aLRSpace );
- }
+ rTargetSet.Put(copy);
if( rSrcInfo.m_bTopMargin || rSrcInfo.m_bBottomMargin )
{
- const SvxULSpaceItem& rNewULSpace =
- static_cast<const SvxULSpaceItem&>(rSrcSet.Get( aItemIds.nULSpace ));
+ const SvxULSpaceItem& rNewULSpace = rSrcSet.Get( aItemIds.nULSpace );
if( rSrcInfo.m_bTopMargin )
aULSpace.SetUpper( rNewULSpace.GetUpper() );
@@ -977,7 +978,7 @@ void SvxCSS1Parser::MergeStyles( const SfxItemSet& rSrcSet,
void SvxCSS1Parser::SetDfltEncoding( rtl_TextEncoding eEnc )
{
- eDfltEnc = eEnc;
+ m_eDefaultEnc = eEnc;
}
static void ParseCSS1_font_size( const CSS1Expression *pExpr,
@@ -1013,7 +1014,7 @@ static void ParseCSS1_font_size( const CSS1Expression *pExpr,
break;
case CSS1_PERCENTAGE:
// only for drop caps!
- nPropHeight = static_cast<sal_uInt16>(pExpr->GetNumber());
+ nPropHeight = o3tl::narrowing<sal_uInt16>(pExpr->GetNumber());
break;
case CSS1_IDENT:
{
@@ -1139,7 +1140,7 @@ static void ParseCSS1_font_weight( const CSS1Expression *pExpr,
break;
case CSS1_NUMBER:
{
- sal_uInt16 nWeight = static_cast<sal_uInt16>(pExpr->GetNumber());
+ sal_uInt16 nWeight = o3tl::narrowing<sal_uInt16>(pExpr->GetNumber());
SvxWeightItem aWeight( nWeight>400 ? WEIGHT_BOLD : WEIGHT_NORMAL,
aItemIds.nWeight );
rItemSet.Put( aWeight );
@@ -1448,7 +1449,7 @@ static void ParseCSS1_background( const CSS1Expression *pExpr,
{
// the percentage is converted to an enum
- sal_uInt16 nPerc = static_cast<sal_uInt16>(pExpr->GetNumber());
+ sal_uInt16 nPerc = o3tl::narrowing<sal_uInt16>(pExpr->GetNumber());
if( !bHori )
{
ePos = nPerc < 25 ? GPOS_LT
@@ -1594,7 +1595,7 @@ static void ParseCSS1_line_height( const CSS1Expression *pExpr,
switch( pExpr->GetType() )
{
case CSS1_LENGTH:
- nHeight = static_cast<sal_uInt16>(pExpr->GetULength());
+ nHeight = o3tl::narrowing<sal_uInt16>(pExpr->GetULength());
break;
case CSS1_PIXLENGTH:
{
@@ -1604,18 +1605,18 @@ static void ParseCSS1_line_height( const CSS1Expression *pExpr,
tools::Long nPHeight = static_cast<tools::Long>(fHeight);
tools::Long nPWidth = 0;
SvxCSS1Parser::PixelToTwip(nPWidth, nPHeight);
- nHeight = static_cast<sal_uInt16>(nPHeight);
+ nHeight = o3tl::narrowing<sal_uInt16>(nPHeight);
}
}
break;
case CSS1_PERCENTAGE:
{
- nPropHeight = static_cast<sal_uInt16>(pExpr->GetNumber());
+ nPropHeight = o3tl::narrowing<sal_uInt16>(pExpr->GetNumber());
}
break;
case CSS1_NUMBER:
{
- nPropHeight = static_cast<sal_uInt16>(pExpr->GetNumber() * 100);
+ nPropHeight = o3tl::narrowing<sal_uInt16>(pExpr->GetNumber() * 100);
}
break;
default:
@@ -1711,7 +1712,7 @@ static void ParseCSS1_font( const CSS1Expression *pExpr,
}
else
{
- eWeight = static_cast<sal_uInt16>(pExpr->GetNumber()) > 400 ? WEIGHT_BOLD
+ eWeight = o3tl::narrowing<sal_uInt16>(pExpr->GetNumber()) > 400 ? WEIGHT_BOLD
: WEIGHT_NORMAL;
}
@@ -1951,8 +1952,17 @@ static void ParseCSS1_text_indent( const CSS1Expression *pExpr,
switch( pExpr->GetType() )
{
case CSS1_LENGTH:
- nIndent = static_cast<short>(pExpr->GetSLength());
- bSet = true;
+ {
+ double n = std::round(pExpr->GetNumber());
+ SAL_WARN_IF(
+ n < std::numeric_limits<short>::min() || n > std::numeric_limits<short>::max(),
+ "sw.html", "clamping length " << n << " to short range");
+ nIndent = static_cast<short>(
+ std::clamp(
+ n, double(std::numeric_limits<short>::min()),
+ double(std::numeric_limits<short>::max())));
+ bSet = true;
+ }
break;
case CSS1_PIXLENGTH:
{
@@ -1977,20 +1987,8 @@ static void ParseCSS1_text_indent( const CSS1Expression *pExpr,
if( !bSet )
return;
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( aItemIds.nLRSpace, false,
- &pItem ) )
- {
- SvxLRSpaceItem aLRItem( *static_cast<const SvxLRSpaceItem*>(pItem) );
- aLRItem.SetTextFirstLineOffset( nIndent );
- rItemSet.Put( aLRItem );
- }
- else
- {
- SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
- aLRItem.SetTextFirstLineOffset( nIndent );
- rItemSet.Put( aLRItem );
- }
+ SvxFirstLineIndentItem const firstLine(nIndent, RES_MARGIN_FIRSTLINE);
+ rItemSet.Put(firstLine);
rPropInfo.m_bTextIndent = true;
}
@@ -2034,26 +2032,22 @@ static void ParseCSS1_margin_left( const CSS1Expression *pExpr,
;
}
+ if (pExpr->GetString() == "auto")
+ {
+ rPropInfo.m_bLeftMargin = true;
+ rPropInfo.m_eLeftMarginType = SVX_CSS1_LTYPE_AUTO;
+ }
+
if( !bSet )
return;
rPropInfo.m_nLeftMargin = nLeft;
if( nLeft < 0 )
nLeft = 0;
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( aItemIds.nLRSpace, false,
- &pItem ) )
- {
- SvxLRSpaceItem aLRItem( *static_cast<const SvxLRSpaceItem*>(pItem) );
- aLRItem.SetTextLeft( static_cast<sal_uInt16>(nLeft) );
- rItemSet.Put( aLRItem );
- }
- else
- {
- SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
- aLRItem.SetTextLeft( static_cast<sal_uInt16>(nLeft) );
- rItemSet.Put( aLRItem );
- }
+
+ // TODO: other things may need a SvxLeftMarginItem ? but they currently convert it anyway so they can convert that too.
+ SvxTextLeftMarginItem const leftMargin(o3tl::narrowing<sal_uInt16>(nLeft), RES_MARGIN_TEXTLEFT);
+ rItemSet.Put(leftMargin);
rPropInfo.m_bLeftMargin = true;
}
@@ -2093,26 +2087,21 @@ static void ParseCSS1_margin_right( const CSS1Expression *pExpr,
;
}
+ if (pExpr->GetString() == "auto")
+ {
+ rPropInfo.m_bRightMargin = true;
+ rPropInfo.m_eRightMarginType = SVX_CSS1_LTYPE_AUTO;
+ }
+
if( !bSet )
return;
rPropInfo.m_nRightMargin = nRight;
if( nRight < 0 )
nRight = 0;
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( aItemIds.nLRSpace, false,
- &pItem ) )
- {
- SvxLRSpaceItem aLRItem( *static_cast<const SvxLRSpaceItem*>(pItem) );
- aLRItem.SetRight( static_cast<sal_uInt16>(nRight) );
- rItemSet.Put( aLRItem );
- }
- else
- {
- SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
- aLRItem.SetRight( static_cast<sal_uInt16>(nRight) );
- rItemSet.Put( aLRItem );
- }
+
+ SvxRightMarginItem rightMargin(o3tl::narrowing<sal_uInt16>(nRight), RES_MARGIN_RIGHT);
+ rItemSet.Put(rightMargin);
rPropInfo.m_bRightMargin = true;
}
@@ -2132,7 +2121,7 @@ static void ParseCSS1_margin_top( const CSS1Expression *pExpr,
tools::Long nTmp = pExpr->GetSLength();
if( nTmp < 0 )
nTmp = 0;
- nUpper = static_cast<sal_uInt16>(nTmp);
+ nUpper = o3tl::narrowing<sal_uInt16>(nTmp);
bSet = true;
}
break;
@@ -2146,7 +2135,7 @@ static void ParseCSS1_margin_top( const CSS1Expression *pExpr,
if( nPHeight < 0 )
nPHeight = 0;
SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
- nUpper = static_cast<sal_uInt16>(nPHeight);
+ nUpper = o3tl::narrowing<sal_uInt16>(nPHeight);
bSet = true;
}
}
@@ -2161,11 +2150,9 @@ static void ParseCSS1_margin_top( const CSS1Expression *pExpr,
if( !bSet )
return;
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( aItemIds.nULSpace, false,
- &pItem ) )
+ if( const SvxULSpaceItem* pItem = rItemSet.GetItemIfSet( aItemIds.nULSpace, false ) )
{
- SvxULSpaceItem aULItem( *static_cast<const SvxULSpaceItem*>(pItem) );
+ SvxULSpaceItem aULItem( *pItem );
aULItem.SetUpper( nUpper );
rItemSet.Put( aULItem );
}
@@ -2194,7 +2181,7 @@ static void ParseCSS1_margin_bottom( const CSS1Expression *pExpr,
tools::Long nTmp = pExpr->GetSLength();
if( nTmp < 0 )
nTmp = 0;
- nLower = static_cast<sal_uInt16>(nTmp);
+ nLower = o3tl::narrowing<sal_uInt16>(nTmp);
bSet = true;
}
break;
@@ -2208,7 +2195,7 @@ static void ParseCSS1_margin_bottom( const CSS1Expression *pExpr,
if( nPHeight < 0 )
nPHeight = 0;
SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
- nLower = static_cast<sal_uInt16>(nPHeight);
+ nLower = o3tl::narrowing<sal_uInt16>(nPHeight);
bSet = true;
}
}
@@ -2223,11 +2210,9 @@ static void ParseCSS1_margin_bottom( const CSS1Expression *pExpr,
if( !bSet )
return;
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( aItemIds.nULSpace, false,
- &pItem ) )
+ if( const SvxULSpaceItem* pItem = rItemSet.GetItemIfSet( aItemIds.nULSpace, false ) )
{
- SvxULSpaceItem aULItem( *static_cast<const SvxULSpaceItem*>(pItem) );
+ SvxULSpaceItem aULItem( *pItem );
aULItem.SetLower( nLower );
rItemSet.Put( aULItem );
}
@@ -2333,25 +2318,15 @@ static void ParseCSS1_margin( const CSS1Expression *pExpr,
nMargins[1] = 0;
}
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( aItemIds.nLRSpace, false,
- &pItem ) )
+ if (bSetMargins[3])
{
- SvxLRSpaceItem aLRItem( *static_cast<const SvxLRSpaceItem*>(pItem) );
- if( bSetMargins[3] )
- aLRItem.SetLeft( static_cast<sal_uInt16>(nMargins[3]) );
- if( bSetMargins[1] )
- aLRItem.SetRight( static_cast<sal_uInt16>(nMargins[1]) );
- rItemSet.Put( aLRItem );
+ SvxTextLeftMarginItem const leftMargin(o3tl::narrowing<sal_uInt16>(nMargins[3]), RES_MARGIN_TEXTLEFT);
+ rItemSet.Put(leftMargin);
}
- else
+ if (bSetMargins[1])
{
- SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
- if( bSetMargins[3] )
- aLRItem.SetLeft( static_cast<sal_uInt16>(nMargins[3]) );
- if( bSetMargins[1] )
- aLRItem.SetRight( static_cast<sal_uInt16>(nMargins[1]) );
- rItemSet.Put( aLRItem );
+ SvxRightMarginItem const rightMargin(o3tl::narrowing<sal_uInt16>(nMargins[1]), RES_MARGIN_RIGHT);
+ rItemSet.Put(rightMargin);
}
}
@@ -2363,24 +2338,22 @@ static void ParseCSS1_margin( const CSS1Expression *pExpr,
if( nMargins[2] < 0 )
nMargins[2] = 0;
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( aItemIds.nULSpace, false,
- &pItem ) )
+ if( const SvxULSpaceItem* pItem = rItemSet.GetItemIfSet( aItemIds.nULSpace, false ) )
{
- SvxULSpaceItem aULItem( *static_cast<const SvxULSpaceItem*>(pItem) );
+ SvxULSpaceItem aULItem( *pItem );
if( bSetMargins[0] )
- aULItem.SetUpper( static_cast<sal_uInt16>(nMargins[0]) );
+ aULItem.SetUpper( o3tl::narrowing<sal_uInt16>(nMargins[0]) );
if( bSetMargins[2] )
- aULItem.SetLower( static_cast<sal_uInt16>(nMargins[2]) );
+ aULItem.SetLower( o3tl::narrowing<sal_uInt16>(nMargins[2]) );
rItemSet.Put( aULItem );
}
else
{
SvxULSpaceItem aULItem( aItemIds.nULSpace );
if( bSetMargins[0] )
- aULItem.SetUpper( static_cast<sal_uInt16>(nMargins[0]) );
+ aULItem.SetUpper( o3tl::narrowing<sal_uInt16>(nMargins[0]) );
if( bSetMargins[2] )
- aULItem.SetLower( static_cast<sal_uInt16>(nMargins[2]) );
+ aULItem.SetLower( o3tl::narrowing<sal_uInt16>(nMargins[2]) );
rItemSet.Put( aULItem );
}
@@ -2406,7 +2379,7 @@ static bool ParseCSS1_padding_xxx( const CSS1Expression *pExpr,
nTmp = 0;
else if( nTmp > SvxCSS1PropertyInfo::UNSET_BORDER_DISTANCE-1 )
nTmp = SvxCSS1PropertyInfo::UNSET_BORDER_DISTANCE-1;
- nDist = static_cast<sal_uInt16>(nTmp);
+ nDist = o3tl::narrowing<sal_uInt16>(nTmp);
bSet = true;
}
break;
@@ -2422,7 +2395,7 @@ static bool ParseCSS1_padding_xxx( const CSS1Expression *pExpr,
SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
if( nPWidth > SvxCSS1PropertyInfo::UNSET_BORDER_DISTANCE-1 )
nPWidth = SvxCSS1PropertyInfo::UNSET_BORDER_DISTANCE-1;
- nDist = static_cast<sal_uInt16>(nPWidth);
+ nDist = o3tl::narrowing<sal_uInt16>(nPWidth);
bSet = true;
}
}
@@ -2549,7 +2522,7 @@ static void ParseCSS1_border_xxx( const CSS1Expression *pExpr,
break;
case CSS1_LENGTH:
- nWidth = static_cast<sal_uInt16>(pExpr->GetULength());
+ nWidth = o3tl::narrowing<sal_uInt16>(pExpr->GetULength());
break;
case CSS1_PIXLENGTH:
@@ -2564,7 +2537,7 @@ static void ParseCSS1_border_xxx( const CSS1Expression *pExpr,
tools::Long nPWidth = bHori ? 0 : fWidth;
tools::Long nPHeight = bHori ? fWidth : 0;
SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
- nWidth = static_cast<sal_uInt16>(bHori ? nPHeight : nPWidth);
+ nWidth = o3tl::narrowing<sal_uInt16>(bHori ? nPHeight : nPWidth);
}
else
nWidth = 1;
@@ -2625,7 +2598,7 @@ static void ParseCSS1_border_xxx_width( const CSS1Expression *pExpr,
break;
case CSS1_LENGTH:
- nWidth = static_cast<sal_uInt16>(pExpr->GetULength());
+ nWidth = o3tl::narrowing<sal_uInt16>(pExpr->GetULength());
break;
case CSS1_PIXLENGTH:
@@ -2641,7 +2614,7 @@ static void ParseCSS1_border_xxx_width( const CSS1Expression *pExpr,
tools::Long nPWidth = bHori ? 0 : nWidthL;
tools::Long nPHeight = bHori ? nWidthL : 0;
SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
- nWidth = static_cast<sal_uInt16>(bHori ? nPHeight : nPWidth);
+ nWidth = o3tl::narrowing<sal_uInt16>(bHori ? nPHeight : nPWidth);
}
}
break;
@@ -2862,9 +2835,7 @@ static void ParseCSS1_length( const CSS1Expression *pExpr,
break;
case CSS1_PERCENTAGE:
- rLength = static_cast<tools::Long>(pExpr->GetNumber());
- if( rLength > 100 )
- rLength = 100;
+ rLength = static_cast<tools::Long>(std::min(pExpr->GetNumber(), 100.0));
rLengthType = SVX_CSS1_LTYPE_PERCENTAGE;
break;
@@ -3073,85 +3044,94 @@ static void ParseCSS1_visibility(const CSS1Expression* pExpr, SfxItemSet& /*rIte
rPropInfo.m_bVisible = pExpr->GetString() != "hidden";
}
+static void ParseCSS1_white_space(const CSS1Expression* pExpr, SfxItemSet& /*rItemSet*/,
+ SvxCSS1PropertyInfo& rPropInfo, const SvxCSS1Parser& /*rParser*/)
+{
+ if (pExpr->GetType() == CSS1_IDENT)
+ {
+ if (pExpr->GetString().equalsIgnoreAsciiCase("pre")
+ || pExpr->GetString().equalsIgnoreAsciiCase("pre-wrap"))
+ {
+ rPropInfo.m_bPreserveSpace = true;
+ }
+ }
+}
+
namespace {
// the assignment of property to parsing function
struct CSS1PropEntry
{
- const char * pName;
+ std::string_view pName;
FnParseCSS1Prop pFunc;
};
}
-#define CSS1_PROP_ENTRY(p) \
- { sCSS1_P_##p, ParseCSS1_##p }
-
// the table with assignments
-CSS1PropEntry const aCSS1PropFnTab[] =
-{
- CSS1_PROP_ENTRY(background),
- CSS1_PROP_ENTRY(background_color),
- CSS1_PROP_ENTRY(border),
- CSS1_PROP_ENTRY(border_bottom),
- CSS1_PROP_ENTRY(border_bottom_width),
- CSS1_PROP_ENTRY(border_color),
- CSS1_PROP_ENTRY(border_left),
- CSS1_PROP_ENTRY(border_left_width),
- CSS1_PROP_ENTRY(border_right),
- CSS1_PROP_ENTRY(border_right_width),
- CSS1_PROP_ENTRY(border_style),
- CSS1_PROP_ENTRY(border_top),
- CSS1_PROP_ENTRY(border_top_width),
- CSS1_PROP_ENTRY(border_width),
- CSS1_PROP_ENTRY(color),
- CSS1_PROP_ENTRY(column_count),
- CSS1_PROP_ENTRY(direction),
- CSS1_PROP_ENTRY(float),
- CSS1_PROP_ENTRY(font),
- CSS1_PROP_ENTRY(font_family),
- CSS1_PROP_ENTRY(font_size),
- CSS1_PROP_ENTRY(font_style),
- CSS1_PROP_ENTRY(font_variant),
- CSS1_PROP_ENTRY(font_weight),
- CSS1_PROP_ENTRY(height),
- CSS1_PROP_ENTRY(left),
- CSS1_PROP_ENTRY(letter_spacing),
- CSS1_PROP_ENTRY(line_height),
- CSS1_PROP_ENTRY(list_style_type),
- CSS1_PROP_ENTRY(margin),
- CSS1_PROP_ENTRY(margin_bottom),
- CSS1_PROP_ENTRY(margin_left),
- CSS1_PROP_ENTRY(margin_right),
- CSS1_PROP_ENTRY(margin_top),
- CSS1_PROP_ENTRY(orphans),
- CSS1_PROP_ENTRY(padding),
- CSS1_PROP_ENTRY(padding_bottom),
- CSS1_PROP_ENTRY(padding_left),
- CSS1_PROP_ENTRY(padding_right),
- CSS1_PROP_ENTRY(padding_top),
- CSS1_PROP_ENTRY(page_break_after),
- CSS1_PROP_ENTRY(page_break_before),
- CSS1_PROP_ENTRY(page_break_inside),
- CSS1_PROP_ENTRY(position),
- CSS1_PROP_ENTRY(size),
- CSS1_PROP_ENTRY(so_language),
- CSS1_PROP_ENTRY(text_align),
- CSS1_PROP_ENTRY(text_decoration),
- CSS1_PROP_ENTRY(text_indent),
- CSS1_PROP_ENTRY(text_transform),
- CSS1_PROP_ENTRY(top),
- CSS1_PROP_ENTRY(visibility),
- CSS1_PROP_ENTRY(widows),
- CSS1_PROP_ENTRY(width),
+CSS1PropEntry constexpr aCSS1PropFnTab[] =
+{
+ { sCSS1_P_background, ParseCSS1_background },
+ { sCSS1_P_background_color, ParseCSS1_background_color },
+ { sCSS1_P_border, ParseCSS1_border },
+ { sCSS1_P_border_bottom, ParseCSS1_border_bottom },
+ { sCSS1_P_border_bottom_width, ParseCSS1_border_bottom_width },
+ { sCSS1_P_border_color, ParseCSS1_border_color },
+ { sCSS1_P_border_left, ParseCSS1_border_left },
+ { sCSS1_P_border_left_width, ParseCSS1_border_left_width },
+ { sCSS1_P_border_right, ParseCSS1_border_right },
+ { sCSS1_P_border_right_width, ParseCSS1_border_right_width },
+ { sCSS1_P_border_style, ParseCSS1_border_style },
+ { sCSS1_P_border_top, ParseCSS1_border_top },
+ { sCSS1_P_border_top_width, ParseCSS1_border_top_width },
+ { sCSS1_P_border_width, ParseCSS1_border_width },
+ { sCSS1_P_color, ParseCSS1_color },
+ { sCSS1_P_column_count, ParseCSS1_column_count },
+ { sCSS1_P_direction, ParseCSS1_direction },
+ { sCSS1_P_float, ParseCSS1_float },
+ { sCSS1_P_font, ParseCSS1_font },
+ { sCSS1_P_font_family, ParseCSS1_font_family },
+ { sCSS1_P_font_size, ParseCSS1_font_size },
+ { sCSS1_P_font_style, ParseCSS1_font_style },
+ { sCSS1_P_font_variant, ParseCSS1_font_variant },
+ { sCSS1_P_font_weight, ParseCSS1_font_weight },
+ { sCSS1_P_height, ParseCSS1_height },
+ { sCSS1_P_left, ParseCSS1_left },
+ { sCSS1_P_letter_spacing, ParseCSS1_letter_spacing },
+ { sCSS1_P_line_height, ParseCSS1_line_height },
+ { sCSS1_P_list_style_type, ParseCSS1_list_style_type },
+ { sCSS1_P_margin, ParseCSS1_margin },
+ { sCSS1_P_margin_bottom, ParseCSS1_margin_bottom },
+ { sCSS1_P_margin_left, ParseCSS1_margin_left },
+ { sCSS1_P_margin_right, ParseCSS1_margin_right },
+ { sCSS1_P_margin_top, ParseCSS1_margin_top },
+ { sCSS1_P_orphans, ParseCSS1_orphans },
+ { sCSS1_P_padding, ParseCSS1_padding },
+ { sCSS1_P_padding_bottom, ParseCSS1_padding_bottom },
+ { sCSS1_P_padding_left, ParseCSS1_padding_left },
+ { sCSS1_P_padding_right, ParseCSS1_padding_right },
+ { sCSS1_P_padding_top, ParseCSS1_padding_top },
+ { sCSS1_P_page_break_after, ParseCSS1_page_break_after },
+ { sCSS1_P_page_break_before, ParseCSS1_page_break_before },
+ { sCSS1_P_page_break_inside, ParseCSS1_page_break_inside },
+ { sCSS1_P_position, ParseCSS1_position },
+ { sCSS1_P_size, ParseCSS1_size },
+ { sCSS1_P_so_language, ParseCSS1_so_language },
+ { sCSS1_P_text_align, ParseCSS1_text_align },
+ { sCSS1_P_text_decoration, ParseCSS1_text_decoration },
+ { sCSS1_P_text_indent, ParseCSS1_text_indent },
+ { sCSS1_P_text_transform, ParseCSS1_text_transform },
+ { sCSS1_P_top, ParseCSS1_top },
+ { sCSS1_P_visibility, ParseCSS1_visibility },
+ { sCSS1_white_space, ParseCSS1_white_space },
+ { sCSS1_P_widows, ParseCSS1_widows },
+ { sCSS1_P_width, ParseCSS1_width },
};
-#if !defined NDEBUG
-static bool CSS1PropEntryCompare( const CSS1PropEntry &lhs, const CSS1PropEntry &rhs)
-{
- return strcmp(lhs.pName, rhs.pName) < 0;
-}
-#endif
+static_assert(std::is_sorted(std::begin(aCSS1PropFnTab), std::end(aCSS1PropFnTab),
+ [](const auto& lhs, const auto& rhs) constexpr
+ { return lhs.pName < rhs.pName; }));
+
static bool CSS1PropEntryFindCompare(CSS1PropEntry const & lhs, OUString const & s)
{
return s.compareToIgnoreAsciiCaseAscii(lhs.pName) > 0;
@@ -3160,22 +3140,13 @@ static bool CSS1PropEntryFindCompare(CSS1PropEntry const & lhs, OUString const &
void SvxCSS1Parser::DeclarationParsed( const OUString& rProperty,
std::unique_ptr<CSS1Expression> pExpr )
{
- OSL_ENSURE( pItemSet, "DeclarationParsed() without ItemSet" );
-
- static bool bSortedPropFns = false;
-
- if( !bSortedPropFns )
- {
- assert( std::is_sorted( std::begin(aCSS1PropFnTab), std::end(aCSS1PropFnTab),
- CSS1PropEntryCompare ) );
- bSortedPropFns = true;
- }
+ OSL_ENSURE( m_pItemSet, "DeclarationParsed() without ItemSet" );
auto it = std::lower_bound( std::begin(aCSS1PropFnTab), std::end(aCSS1PropFnTab), rProperty,
CSS1PropEntryFindCompare );
if( it != std::end(aCSS1PropFnTab) && !CSS1PropEntryFindCompare(*it,rProperty) )
{
- it->pFunc( pExpr.get(), *pItemSet, *pPropInfo, *this );
+ it->pFunc( pExpr.get(), *m_pItemSet, *m_pPropInfo, *this );
}
}
diff --git a/sw/source/filter/html/svxcss1.hxx b/sw/source/filter/html/svxcss1.hxx
index e7888ff39813..669ed92a5b95 100644
--- a/sw/source/filter/html/svxcss1.hxx
+++ b/sw/source/filter/html/svxcss1.hxx
@@ -20,11 +20,11 @@
#define INCLUDED_SW_SOURCE_FILTER_HTML_SVXCSS1_HXX
#include <svl/itemset.hxx>
-#include <svx/flagsdef.hxx>
#include <editeng/svxenum.hxx>
#include <rtl/textenc.h>
#include "parcss1.hxx"
#include <o3tl/typed_flags_set.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <array>
#include <map>
@@ -115,6 +115,7 @@ public:
bool m_bTextIndent : 1;
bool m_bNumbering : 1;
bool m_bBullet : 1;
+ bool m_bPreserveSpace : 1 = false;
SvxAdjust m_eFloat;
@@ -136,6 +137,8 @@ public:
SvxCSS1LengthType m_eLeftType, m_eTopType;
SvxCSS1LengthType m_eWidthType, m_eHeightType;
+ SvxCSS1LengthType m_eLeftMarginType;
+ SvxCSS1LengthType m_eRightMarginType;
SvxCSS1SizeType m_eSizeType;
@@ -163,18 +166,18 @@ public:
class SvxCSS1MapEntry
{
- SfxItemSet aItemSet;
- SvxCSS1PropertyInfo aPropInfo;
+ SfxItemSet m_aItemSet;
+ SvxCSS1PropertyInfo m_aPropInfo;
public:
- SvxCSS1MapEntry( const SfxItemSet& rItemSet,
+ SvxCSS1MapEntry( SfxItemSet aItemSet,
const SvxCSS1PropertyInfo& rProp );
- const SfxItemSet& GetItemSet() const { return aItemSet; }
- SfxItemSet& GetItemSet() { return aItemSet; }
+ const SfxItemSet& GetItemSet() const { return m_aItemSet; }
+ SfxItemSet& GetItemSet() { return m_aItemSet; }
- const SvxCSS1PropertyInfo& GetPropertyInfo() const { return aPropInfo; }
- SvxCSS1PropertyInfo& GetPropertyInfo() { return aPropInfo; }
+ const SvxCSS1PropertyInfo& GetPropertyInfo() const { return m_aPropInfo; }
+ SvxCSS1PropertyInfo& GetPropertyInfo() { return m_aPropInfo; }
};
// Class is processing the CSS1-Parser output by converting the CSS1 properties
@@ -194,19 +197,20 @@ class SvxCSS1Parser : public CSS1Parser
CSS1Map m_Pages;
CSS1Map m_Tags;
- OUString sBaseURL;
+ OUString m_sBaseURL;
- std::unique_ptr<SfxItemSet> pSheetItemSet; // item set of Style-Sheet
- SfxItemSet *pItemSet; // current item set
+ std::unique_ptr<SfxItemSet> m_pSheetItemSet; // item set of Style-Sheet
+ SfxItemSet *m_pItemSet; // current item set
- std::unique_ptr<SvxCSS1PropertyInfo> pSheetPropInfo;
- SvxCSS1PropertyInfo *pPropInfo;
+ std::unique_ptr<SvxCSS1PropertyInfo> m_pSheetPropInfo;
+ SvxCSS1PropertyInfo *m_pPropInfo;
- static constexpr sal_uInt16 gnMinFixLineSpace = MM50/2; // minimum spacing for fixed line spacing
+ // minimum spacing for fixed line spacing
+ static constexpr sal_uInt16 gnMinFixLineSpace = o3tl::toTwips(25, o3tl::Length::mm10);
- rtl_TextEncoding eDfltEnc;
- bool bIgnoreFontFamily;
- std::vector<sal_uInt16> aWhichMap; // Which-Map of Parser
+ rtl_TextEncoding m_eDefaultEnc;
+ bool m_bIgnoreFontFamily;
+ WhichRangesContainer m_aWhichMap; // Which-Map of Parser
using CSS1Parser::ParseStyleOption;
@@ -238,12 +242,12 @@ protected:
public:
SvxCSS1Parser( SfxItemPool& rPool,
- const OUString& rBaseURL,
+ OUString aBaseURL,
sal_uInt16 const *pWhichIds, sal_uInt16 nWhichIds );
virtual ~SvxCSS1Parser() override;
- bool IsIgnoreFontFamily() const { return bIgnoreFontFamily; }
- void SetIgnoreFontFamily( bool bSet ) { bIgnoreFontFamily = bSet; }
+ bool IsIgnoreFontFamily() const { return m_bIgnoreFontFamily; }
+ void SetIgnoreFontFamily( bool bSet ) { m_bIgnoreFontFamily = bSet; }
// Parse a style sheet. For every found selector a StyleParsed with
// according item set is called.
@@ -255,7 +259,7 @@ public:
// convert a string to enum value
static bool GetEnum( const CSS1PropertyEnum *pPropTable,
- const OUString& rValue, sal_uInt16 &rEnum );
+ std::u16string_view rValue, sal_uInt16 &rEnum );
static void PixelToTwip( tools::Long &nWidth, tools::Long &nHeight );
@@ -264,7 +268,7 @@ public:
virtual const FontList *GetFontList() const;
- const sal_uInt16 *GetWhichMap() const { return aWhichMap.data(); }
+ const WhichRangesContainer& GetWhichMap() const { return m_aWhichMap; }
static void InsertMapEntry( const OUString& rKey, const SfxItemSet& rItemSet,
const SvxCSS1PropertyInfo& rProp, CSS1Map& rMap );
@@ -299,9 +303,9 @@ public:
static sal_uInt16 GetMinFixLineSpace() { return gnMinFixLineSpace; }
virtual void SetDfltEncoding( rtl_TextEncoding eEnc );
- rtl_TextEncoding GetDfltEncoding() const { return eDfltEnc; }
+ rtl_TextEncoding GetDfltEncoding() const { return m_eDefaultEnc; }
- const OUString& GetBaseURL() const { return sBaseURL;}
+ const OUString& GetBaseURL() const { return m_sBaseURL;}
};
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index d0173d398fa9..dbbbc7cc0207 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -31,24 +31,24 @@
#include <o3tl/safeint.hxx>
#include <rtl/ustrbuf.hxx>
#include <svx/svxids.hrc>
+#include <svx/svdotext.hxx>
#if OSL_DEBUG_LEVEL > 0
#include <stdlib.h>
#endif
#include <hintids.hxx>
+#include <utility>
#include <vcl/errinf.hxx>
#include <svl/stritem.hxx>
#include <vcl/imap.hxx>
#include <svtools/htmltokn.h>
#include <svtools/htmlkywd.hxx>
#include <svtools/ctrltool.hxx>
-#include <unotools/configmgr.hxx>
#include <unotools/pathoptions.hxx>
#include <vcl/svapp.hxx>
#include <sfx2/event.hxx>
#include <sfx2/docfile.hxx>
-#include <svtools/htmlcfg.hxx>
#include <sfx2/linkmgr.hxx>
#include <editeng/kernitem.hxx>
#include <editeng/boxitem.hxx>
@@ -117,6 +117,7 @@
#include <officecfg/Office/Writer.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <comphelper/sequence.hxx>
+#include <officecfg/Office/Common.hxx>
#include <swerror.h>
#include <ndole.hxx>
@@ -169,7 +170,7 @@ OUString HTMLReader::GetTemplateName(SwDoc& rDoc) const
// HTML import into Writer, avoid loading the Writer/Web template.
return OUString();
- const OUString sTemplateWithoutExt("internal/html");
+ static constexpr OUString sTemplateWithoutExt(u"internal/html"_ustr);
SvtPathOptions aPathOpt;
// first search for OpenDocument Writer/Web template
@@ -203,7 +204,7 @@ bool HTMLReader::SetStrmStgPtr()
}
// Call for the general Reader-Interface
-ErrCode HTMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPam, const OUString & rName )
+ErrCodeMsg HTMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPam, const OUString & rName )
{
SetupFilterOptions();
@@ -228,7 +229,7 @@ ErrCode HTMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPam, co
// so nobody steals the document!
rtl::Reference<SwDoc> xHoldAlive(&rDoc);
- ErrCode nRet = ERRCODE_NONE;
+ ErrCodeMsg nRet = ERRCODE_NONE;
tools::SvRef<SwHTMLParser> xParser = new SwHTMLParser( &rDoc, rPam, *m_pStream,
rName, rBaseURL, !m_bInsertMode, m_pMedium,
IsReadUTF8(),
@@ -244,7 +245,7 @@ ErrCode HTMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPam, co
+ "," + OUString::number(static_cast<sal_Int32>(xParser->GetLinePos())));
// use the stream as transport for error number
- nRet = *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
+ nRet = ErrCodeMsg( ERR_FORMAT_ROWCOL, sErr,
DialogMask::ButtonsOk | DialogMask::MessageError );
}
@@ -252,22 +253,21 @@ ErrCode HTMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPam, co
}
SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCursor, SvStream& rIn,
- const OUString& rPath,
- const OUString& rBaseURL,
+ OUString aPath,
+ OUString aBaseURL,
bool bReadNewDoc,
SfxMedium* pMed, bool bReadUTF8,
bool bNoHTMLComments,
const OUString& rNamespace )
: SfxHTMLParser( rIn, bReadNewDoc, pMed ),
- m_aPathToFile( rPath ),
- m_sBaseURL( rBaseURL ),
+ m_aPathToFile(std::move( aPath )),
+ m_sBaseURL(std::move( aBaseURL )),
m_xAttrTab(std::make_shared<HTMLAttrTable>()),
m_pNumRuleInfo( new SwHTMLNumRuleInfo ),
m_xDoc( pD ),
m_pActionViewShell( nullptr ),
m_pSttNdIdx( nullptr ),
m_pFormImpl( nullptr ),
- m_pMarquee( nullptr ),
m_pImageMap( nullptr ),
m_nBaseFontStMin( 0 ),
m_nFontStMin( 0 ),
@@ -286,10 +286,11 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCursor, SvStream& rIn,
m_nContinue( 0 ),
#endif
m_eParaAdjust( SvxAdjust::End ),
- m_bDocInitalized( false ),
+ m_bDocInitialized( false ),
m_bSetModEnabled( false ),
m_bInFloatingFrame( false ),
m_bInField( false ),
+ m_bKeepUnknown( false ),
m_bCallNextToken( false ),
m_bIgnoreRawData( false ),
m_bLBEntrySelected ( false ),
@@ -311,11 +312,17 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCursor, SvStream& rIn,
m_bNotifyMacroEventRead( false ),
m_isInTableStructure(false),
m_nTableDepth( 0 ),
+ m_nFloatingFrames( 0 ),
+ m_nListItems( 0 ),
m_pTempViewFrame(nullptr)
{
// If requested explicitly, then force ignoring of comments (don't create postits for them).
- if (!utl::ConfigManager::IsFuzzing() && officecfg::Office::Writer::Filter::Import::HTML::IgnoreComments::get())
- m_bIgnoreHTMLComments = true;
+ if (!bFuzzing)
+ {
+ if (officecfg::Office::Writer::Filter::Import::HTML::IgnoreComments::get())
+ m_bIgnoreHTMLComments = true;
+ m_bKeepUnknown = officecfg::Office::Common::Filter::HTML::Import::UnknownTag::get();
+ }
m_nEventId = nullptr;
m_bUpperSpace = m_bViewCreated = m_bChkJumpMark = false;
@@ -323,20 +330,25 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCursor, SvStream& rIn,
m_eScriptLang = HTMLScriptLanguage::Unknown;
rCursor.DeleteMark();
- m_pPam = &rCursor; // re-use existing cursor: avoids spurious ~SwIndexReg assert
+ m_pPam = &rCursor; // re-use existing cursor: avoids spurious ~SwContentIndexReg assert
memset(m_xAttrTab.get(), 0, sizeof(HTMLAttrTable));
// Read the font sizes 1-7 from the INI file
- SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
- m_aFontHeights[0] = rHtmlOptions.GetFontSize( 0 ) * 20;
- m_aFontHeights[1] = rHtmlOptions.GetFontSize( 1 ) * 20;
- m_aFontHeights[2] = rHtmlOptions.GetFontSize( 2 ) * 20;
- m_aFontHeights[3] = rHtmlOptions.GetFontSize( 3 ) * 20;
- m_aFontHeights[4] = rHtmlOptions.GetFontSize( 4 ) * 20;
- m_aFontHeights[5] = rHtmlOptions.GetFontSize( 5 ) * 20;
- m_aFontHeights[6] = rHtmlOptions.GetFontSize( 6 ) * 20;
-
- m_bKeepUnknown = rHtmlOptions.IsImportUnknown();
+ if (!bFuzzing)
+ {
+ m_aFontHeights[0] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_1::get() * 20;
+ m_aFontHeights[1] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_2::get() * 20;
+ m_aFontHeights[2] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_3::get() * 20;
+ m_aFontHeights[3] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_4::get() * 20;
+ m_aFontHeights[4] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_5::get() * 20;
+ m_aFontHeights[5] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_6::get() * 20;
+ m_aFontHeights[6] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_7::get() * 20;
+ }
+ else
+ {
+ m_aFontHeights[0] = m_aFontHeights[1] = m_aFontHeights[2] = m_aFontHeights[3] =
+ m_aFontHeights[4] = m_aFontHeights[5] = m_aFontHeights[6] = 12 * 20;
+ }
if(bReadNewDoc)
{
@@ -359,7 +371,8 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCursor, SvStream& rIn,
m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::HTML_MODE, true);
m_pCSS1Parser.reset(new SwCSS1Parser(m_xDoc.get(), *this, m_aFontHeights, m_sBaseURL, IsNewDoc()));
- m_pCSS1Parser->SetIgnoreFontFamily( rHtmlOptions.IsIgnoreFontFamily() );
+ if (!bFuzzing)
+ m_pCSS1Parser->SetIgnoreFontFamily( officecfg::Office::Common::Filter::HTML::Import::FontSetting::get() );
if( bReadUTF8 )
{
@@ -519,7 +532,7 @@ SwHTMLParser::~SwHTMLParser()
// the temporary view frame is hidden, so the hidden flag might need to be removed
if ( m_bRemoveHidden && m_xDoc.is() && m_xDoc->GetDocShell() && m_xDoc->GetDocShell()->GetMedium() )
- m_xDoc->GetDocShell()->GetMedium()->GetItemSet()->ClearItem( SID_HIDDEN );
+ m_xDoc->GetDocShell()->GetMedium()->GetItemSet().ClearItem( SID_HIDDEN );
}
}
@@ -549,7 +562,7 @@ SvParserState SwHTMLParser::CallParser()
m_xDoc->getIDocumentContentOperations().SplitNode( *pPos, false );
- *m_pSttNdIdx = pPos->nNode.GetIndex()-1;
+ *m_pSttNdIdx = pPos->GetNodeIndex()-1;
m_xDoc->getIDocumentContentOperations().SplitNode( *pPos, false );
SwPaM aInsertionRangePam( *pPos );
@@ -595,7 +608,7 @@ SvParserState SwHTMLParser::CallParser()
return eRet;
}
-bool SwHTMLParser::CanRemoveNode(sal_uLong nNodeIdx) const
+bool SwHTMLParser::CanRemoveNode(SwNodeOffset nNodeIdx) const
{
const SwNode *pPrev = m_xDoc->GetNodes()[nNodeIdx - 1];
return pPrev->IsContentNode() || (pPrev->IsEndNode() && pPrev->StartOfSectionNode()->IsSectionNode());
@@ -739,29 +752,28 @@ void SwHTMLParser::Continue( HtmlTokenId nToken )
{
const sal_Int32 nStt = pTextNode->GetText().getLength();
// when the cursor is still in the node, then set him at the end
- if( m_pPam->GetPoint()->nNode == aNxtIdx )
+ if( m_pPam->GetPoint()->GetNode() == aNxtIdx.GetNode() )
{
- m_pPam->GetPoint()->nNode = *m_pSttNdIdx;
- m_pPam->GetPoint()->nContent.Assign( pTextNode, nStt );
+ m_pPam->GetPoint()->Assign( *pTextNode, nStt );
}
#if OSL_DEBUG_LEVEL > 0
// !!! shouldn't be possible, or ??
- OSL_ENSURE( m_pSttNdIdx->GetIndex()+1 != m_pPam->GetBound().nNode.GetIndex(),
+ OSL_ENSURE( m_pSttNdIdx->GetIndex()+1 != m_pPam->GetBound().GetNodeIndex(),
"Pam.Bound1 is still in the node" );
- OSL_ENSURE( m_pSttNdIdx->GetIndex()+1 != m_pPam->GetBound( false ).nNode.GetIndex(),
+ OSL_ENSURE( m_pSttNdIdx->GetIndex()+1 != m_pPam->GetBound( false ).GetNodeIndex(),
"Pam.Bound2 is still in the node" );
- if( m_pSttNdIdx->GetIndex()+1 == m_pPam->GetBound().nNode.GetIndex() )
+ if( m_pSttNdIdx->GetIndex()+1 == m_pPam->GetBound().GetNodeIndex() )
{
- const sal_Int32 nCntPos = m_pPam->GetBound().nContent.GetIndex();
- m_pPam->GetBound().nContent.Assign( pTextNode,
+ const sal_Int32 nCntPos = m_pPam->GetBound().GetContentIndex();
+ m_pPam->GetBound().SetContent(
pTextNode->GetText().getLength() + nCntPos );
}
- if( m_pSttNdIdx->GetIndex()+1 == m_pPam->GetBound( false ).nNode.GetIndex() )
+ if( m_pSttNdIdx->GetIndex()+1 == m_pPam->GetBound( false ).GetNodeIndex() )
{
- const sal_Int32 nCntPos = m_pPam->GetBound( false ).nContent.GetIndex();
- m_pPam->GetBound( false ).nContent.Assign( pTextNode,
+ const sal_Int32 nCntPos = m_pPam->GetBound( false ).GetContentIndex();
+ m_pPam->GetBound( false ).SetContent(
pTextNode->GetText().getLength() + nCntPos );
}
#endif
@@ -787,19 +799,19 @@ void SwHTMLParser::Continue( HtmlTokenId nToken )
// now remove the last useless paragraph
SwPosition* pPos = m_pPam->GetPoint();
- if( !pPos->nContent.GetIndex() && !bLFStripped )
+ if( !pPos->GetContentIndex() && !bLFStripped )
{
SwTextNode* pCurrentNd;
- sal_uLong nNodeIdx = pPos->nNode.GetIndex();
+ SwNodeOffset nNodeIdx = pPos->GetNodeIndex();
bool bHasFlysOrMarks =
HasCurrentParaFlys() || HasCurrentParaBookmarks( true );
if( IsNewDoc() )
{
- if (!m_pPam->GetPoint()->nContent.GetIndex() && CanRemoveNode(nNodeIdx))
+ if (!m_pPam->GetPoint()->GetContentIndex() && CanRemoveNode(nNodeIdx))
{
- SwContentNode* pCNd = m_pPam->GetContentNode();
+ SwContentNode* pCNd = m_pPam->GetPointContentNode();
if( pCNd && pCNd->StartOfSectionIndex()+2 <
pCNd->EndOfSectionIndex() && !bHasFlysOrMarks )
{
@@ -807,32 +819,36 @@ void SwHTMLParser::Continue( HtmlTokenId nToken )
SwCursorShell *pCursorSh = dynamic_cast<SwCursorShell *>( pVSh );
if( pCursorSh &&
pCursorSh->GetCursor()->GetPoint()
- ->nNode.GetIndex() == nNodeIdx )
+ ->GetNodeIndex() == nNodeIdx )
{
pCursorSh->MovePara(GoPrevPara, fnParaEnd );
pCursorSh->SetMark();
pCursorSh->ClearMark();
}
- m_pPam->GetBound().nContent.Assign( nullptr, 0 );
- m_pPam->GetBound(false).nContent.Assign( nullptr, 0 );
- m_xDoc->GetNodes().Delete( m_pPam->GetPoint()->nNode );
+ SwNode& rDelNode = m_pPam->GetPoint()->GetNode();
+ // move so we don't have a dangling SwContentIndex to the deleted node
+ m_pPam->GetPoint()->Adjust(SwNodeOffset(1));
+ if (m_pPam->HasMark())
+ m_pPam->GetMark()->Adjust(SwNodeOffset(1));
+ m_xDoc->GetNodes().Delete( rDelNode );
}
}
}
else if( nullptr != ( pCurrentNd = m_xDoc->GetNodes()[ nNodeIdx ]->GetTextNode()) && !bHasFlysOrMarks )
{
- if( pCurrentNd->CanJoinNext( &pPos->nNode ))
+ if( pCurrentNd->CanJoinNext( pPos ))
{
- SwTextNode* pNextNd = pPos->nNode.GetNode().GetTextNode();
- pPos->nContent.Assign( pNextNd, 0 );
+ SwTextNode* pNextNd = pPos->GetNode().GetTextNode();
m_pPam->SetMark(); m_pPam->DeleteMark();
pNextNd->JoinPrev();
}
else if (pCurrentNd->GetText().isEmpty())
{
- pPos->nContent.Assign( nullptr, 0 );
m_pPam->SetMark(); m_pPam->DeleteMark();
- m_xDoc->GetNodes().Delete( pPos->nNode );
+ SwNode& rDelNode = pPos->GetNode();
+ // move so we don't have a dangling SwContentIndex to the deleted node
+ m_pPam->GetPoint()->Adjust(SwNodeOffset(+1));
+ m_xDoc->GetNodes().Delete( rDelNode );
m_pPam->Move( fnMoveBackward );
}
}
@@ -841,10 +857,10 @@ void SwHTMLParser::Continue( HtmlTokenId nToken )
// annul the SplitNode from the beginning
else if( !IsNewDoc() )
{
- if( pPos->nContent.GetIndex() ) // then there was no <p> at the end
+ if( pPos->GetContentIndex() ) // then there was no <p> at the end
m_pPam->Move( fnMoveForward, GoInNode ); // therefore to the next
- SwTextNode* pTextNode = pPos->nNode.GetNode().GetTextNode();
- SwNodeIndex aPrvIdx( pPos->nNode );
+ SwTextNode* pTextNode = pPos->GetNode().GetTextNode();
+ SwNodeIndex aPrvIdx( pPos->GetNode() );
if( pTextNode && pTextNode->CanJoinPrev( &aPrvIdx ) &&
*m_pSttNdIdx <= aPrvIdx )
{
@@ -861,9 +877,9 @@ void SwHTMLParser::Continue( HtmlTokenId nToken )
if( pPrev->HasSwAttrSet() )
pTextNode->SetAttr( *pPrev->GetpSwAttrSet() );
- if( &m_pPam->GetBound().nNode.GetNode() == pPrev )
+ if( &m_pPam->GetBound().GetNode() == pPrev )
m_pPam->GetBound().nContent.Assign( pTextNode, 0 );
- if( &m_pPam->GetBound(false).nNode.GetNode() == pPrev )
+ if( &m_pPam->GetBound(false).GetNode() == pPrev )
m_pPam->GetBound(false).nContent.Assign( pTextNode, 0 );
pTextNode->JoinPrev();
@@ -871,7 +887,7 @@ void SwHTMLParser::Continue( HtmlTokenId nToken )
}
// adjust AutoLoad in DocumentProperties
- if (!utl::ConfigManager::IsFuzzing() && IsNewDoc())
+ if (!bFuzzing && IsNewDoc())
{
SwDocShell *pDocShell(m_xDoc->GetDocShell());
OSL_ENSURE(pDocShell, "no SwDocShell");
@@ -954,8 +970,8 @@ void SwHTMLParser::Notify(const SfxHint& rHint)
void SwHTMLParser::DocumentDetected()
{
- OSL_ENSURE( !m_bDocInitalized, "DocumentDetected called multiple times" );
- m_bDocInitalized = true;
+ OSL_ENSURE( !m_bDocInitialized, "DocumentDetected called multiple times" );
+ m_bDocInitialized = true;
if( IsNewDoc() )
{
if( IsInHeader() )
@@ -1073,7 +1089,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
// Find out what type of document it is if we don't know already.
// For Controls this has to be finished before the control is inserted
// because for inserting a View is needed.
- if( !m_bDocInitalized )
+ if( !m_bDocInitialized )
DocumentDetected();
bool bGetIDOption = false, bInsertUnknown = false;
@@ -1253,9 +1269,9 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
// (but surely if we are not in the header section) fdo#36080 fdo#34666
if (!aToken.isEmpty() && !IsInHeader() )
{
- if( !m_bDocInitalized )
+ if( !m_bDocInitialized )
DocumentDetected();
- m_xDoc->getIDocumentContentOperations().InsertString( *m_pPam, aToken );
+ m_xDoc->getIDocumentContentOperations().InsertString( *m_pPam, aToken.toString());
// if there are temporary paragraph attributes and the
// paragraph isn't empty then the paragraph attributes
@@ -1450,8 +1466,13 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
break;
case HtmlTokenId::IFRAME_ON:
- InsertFloatingFrame();
- m_bCallNextToken = m_bInFloatingFrame && m_xTable;
+ if (bFuzzing && m_nFloatingFrames > 64)
+ SAL_WARN("sw.html", "Not importing any more FloatingFrames for fuzzing performance");
+ else
+ {
+ InsertFloatingFrame();
+ m_bCallNextToken = m_bInFloatingFrame && m_xTable;
+ }
break;
case HtmlTokenId::LINEBREAK:
@@ -1469,7 +1490,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
// CR in PRE/LISTING/XMP
{
if( HtmlTokenId::NEWPARA==nToken ||
- m_pPam->GetPoint()->nContent.GetIndex() )
+ m_pPam->GetPoint()->GetContentIndex() )
{
AppendTextNode(); // there is no LF at this place
// therefore it will cause no problems
@@ -1490,9 +1511,9 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
break;
case HtmlTokenId::LINEFEEDCHAR:
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if( m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode();
- if (!m_xTable && !m_xDoc->IsInHeaderFooter(m_pPam->GetPoint()->nNode))
+ if (!m_xTable && !m_xDoc->IsInHeaderFooter(m_pPam->GetPoint()->GetNode()))
{
NewAttr(m_xAttrTab, &m_xAttrTab->pBreak, SvxFormatBreakItem(SvxBreak::PageBefore, RES_BREAK));
EndAttr( m_xAttrTab->pBreak, false );
@@ -1500,20 +1521,21 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
break;
case HtmlTokenId::TEXTTOKEN:
+ case HtmlTokenId::CDATA:
// insert string without spanning attributes at the end.
- if( !aToken.isEmpty() && ' '==aToken[0] && !IsReadPRE() )
+ if (!aToken.isEmpty() && ' ' == aToken[0] && !IsReadPRE() && !GetPreserveSpaces())
{
- sal_Int32 nPos = m_pPam->GetPoint()->nContent.GetIndex();
- const SwTextNode* pTextNode = nPos ? m_pPam->GetPoint()->nNode.GetNode().GetTextNode() : nullptr;
+ sal_Int32 nPos = m_pPam->GetPoint()->GetContentIndex();
+ const SwTextNode* pTextNode = nPos ? m_pPam->GetPoint()->GetNode().GetTextNode() : nullptr;
if (pTextNode)
{
const OUString& rText = pTextNode->GetText();
sal_Unicode cLast = rText[--nPos];
if( ' ' == cLast || '\x0a' == cLast)
- aToken = aToken.copy(1);
+ aToken.remove(0, 1);
}
else
- aToken = aToken.copy(1);
+ aToken.remove(0, 1);
if( aToken.isEmpty() )
{
@@ -1524,7 +1546,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
if( !aToken.isEmpty() )
{
- if( !m_bDocInitalized )
+ if( !m_bDocInitialized )
DocumentDetected();
if (!m_aEmbeds.empty())
@@ -1532,6 +1554,12 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
// The text token is inside an OLE object, which means
// alternate text.
SwOLENode* pOLENode = m_aEmbeds.top();
+ if (!pOLENode)
+ {
+ // <object> is mapped to an image -> ignore.
+ break;
+ }
+
if (SwFlyFrameFormat* pFormat
= dynamic_cast<SwFlyFrameFormat*>(pOLENode->GetFlyFormat()))
{
@@ -1543,7 +1571,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
}
}
- m_xDoc->getIDocumentContentOperations().InsertString( *m_pPam, aToken );
+ m_xDoc->getIDocumentContentOperations().InsertString( *m_pPam, aToken.toString());
// if there are temporary paragraph attributes and the
// paragraph isn't empty then the paragraph attributes
@@ -1753,10 +1781,10 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
if( m_nOpenParaToken != HtmlTokenId::NONE )
EndPara();
OSL_ENSURE(!m_xTable, "table in table not allowed here");
- if( !m_xTable && (IsNewDoc() || !m_pPam->GetNode().FindTableNode()) &&
- (m_pPam->GetPoint()->nNode.GetIndex() >
+ if( !m_xTable && (IsNewDoc() || !m_pPam->GetPointNode().FindTableNode()) &&
+ (m_pPam->GetPoint()->GetNodeIndex() >
m_xDoc->GetNodes().GetEndOfExtras().GetIndex() ||
- !m_pPam->GetNode().FindFootnoteStartNode() ) )
+ !m_pPam->GetPointNode().FindFootnoteStartNode() ) )
{
if ( m_nParaCnt < 5 )
Show(); // show what we have up to here
@@ -1795,17 +1823,26 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
case HtmlTokenId::LI_ON:
case HtmlTokenId::LISTHEADER_ON:
if( m_nOpenParaToken != HtmlTokenId::NONE &&
- (m_pPam->GetPoint()->nContent.GetIndex()
+ (m_pPam->GetPoint()->GetContentIndex()
|| HtmlTokenId::PARABREAK_ON==m_nOpenParaToken) )
{
// only finish paragraph for <P><LI>, not for <DD><LI>
EndPara();
}
- EndNumberBulletListItem( HtmlTokenId::NONE, false );// close <LI>/<LH> and don't set a template
- NewNumberBulletListItem( nToken );
- break;
+ if (bFuzzing && m_nListItems > 1024)
+ {
+ SAL_WARN("sw.html", "skipping remaining bullet import for performance during fuzzing");
+ }
+ else
+ {
+ EndNumberBulletListItem( HtmlTokenId::NONE, false );// close <LI>/<LH> and don't set a template
+ NewNumberBulletListItem( nToken );
+ }
+ ++m_nListItems;
+
+ break;
case HtmlTokenId::LI_OFF:
case HtmlTokenId::LISTHEADER_OFF:
EndNumberBulletListItem( nToken, false );
@@ -1909,7 +1946,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
break;
case HtmlTokenId::EMPHASIS_ON:
- case HtmlTokenId::CITIATION_ON:
+ case HtmlTokenId::CITATION_ON:
case HtmlTokenId::STRONG_ON:
case HtmlTokenId::CODE_ON:
case HtmlTokenId::SAMPLE_ON:
@@ -1935,7 +1972,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
break;
case HtmlTokenId::EMPHASIS_OFF:
- case HtmlTokenId::CITIATION_OFF:
+ case HtmlTokenId::CITATION_OFF:
case HtmlTokenId::STRONG_OFF:
case HtmlTokenId::CODE_OFF:
case HtmlTokenId::SAMPLE_OFF:
@@ -2023,8 +2060,8 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
if( ' ' == aToken[ 3 ] &&
' ' == aToken[ aToken.getLength()-3 ] )
{
- OUString aComment( aToken.copy( 3, aToken.getLength()-5 ) );
- InsertComment(comphelper::string::strip(aComment, ' '));
+ std::u16string_view aComment( aToken.subView( 3, aToken.getLength()-5 ) );
+ InsertComment(OUString(comphelper::string::strip(aComment, ' ')));
}
else
{
@@ -2103,7 +2140,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
if( !aToken.isEmpty() )
{
UnescapeToken();
- aComment.append(" ").append(aToken);
+ aComment.append(" " + aToken);
}
aComment.append(">");
InsertComment( aComment.makeStringAndClear() );
@@ -2111,7 +2148,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
// if there are temporary paragraph attributes and the
// paragraph isn't empty then the paragraph attributes are final.
- if( !m_aParaAttrs.empty() && m_pPam->GetPoint()->nContent.GetIndex() )
+ if( !m_aParaAttrs.empty() && m_pPam->GetPoint()->GetContentIndex() )
m_aParaAttrs.clear();
}
@@ -2163,12 +2200,12 @@ bool SwHTMLParser::AppendTextNode( SwHTMLAppendMode eMode, bool bUpdateNum )
m_aParaAttrs.clear();
SwTextNode *pTextNode = (AM_SPACE==eMode || AM_NOSPACE==eMode) ?
- m_pPam->GetPoint()->nNode.GetNode().GetTextNode() : nullptr;
+ m_pPam->GetPoint()->GetNode().GetTextNode() : nullptr;
if (pTextNode)
{
const SvxULSpaceItem& rULSpace =
- static_cast<const SvxULSpaceItem&>(pTextNode->SwContentNode::GetAttr( RES_UL_SPACE ));
+ pTextNode->SwContentNode::GetAttr( RES_UL_SPACE );
bool bChange = AM_NOSPACE==eMode ? rULSpace.GetLower() > 0
: rULSpace.GetLower() == 0;
@@ -2202,8 +2239,7 @@ bool SwHTMLParser::AppendTextNode( SwHTMLAppendMode eMode, bool bUpdateNum )
// split character attributes and maybe set none,
// which are set for the whole paragraph
- const SwNodeIndex& rEndIdx = aOldPos.nNode;
- const sal_Int32 nEndCnt = aOldPos.nContent.GetIndex();
+ const sal_Int32 nEndCnt = aOldPos.GetContentIndex();
const SwPosition& rPos = *m_pPam->GetPoint();
HTMLAttr** pHTMLAttributes = reinterpret_cast<HTMLAttr**>(m_xAttrTab.get());
@@ -2217,14 +2253,14 @@ bool SwHTMLParser::AppendTextNode( SwHTMLAppendMode eMode, bool bUpdateNum )
while( pAttr )
{
HTMLAttr *pNext = pAttr->GetNext();
- if( pAttr->GetSttParaIdx() < rEndIdx.GetIndex() ||
+ if( pAttr->GetStartParagraphIdx() < aOldPos.GetNodeIndex() ||
(!bWholePara &&
- pAttr->GetSttPara() == rEndIdx &&
- pAttr->GetSttCnt() != nEndCnt) )
+ pAttr->GetStartParagraph() == aOldPos.GetNode() &&
+ pAttr->GetStartContent() != nEndCnt) )
{
bWholePara =
- pAttr->GetSttPara() == rEndIdx &&
- pAttr->GetSttCnt() == 0;
+ pAttr->GetStartParagraph() == aOldPos.GetNode() &&
+ pAttr->GetStartContent() == 0;
sal_Int32 nStt = pAttr->m_nStartContent;
bool bScript = false;
@@ -2236,14 +2272,14 @@ bool SwHTMLParser::AppendTextNode( SwHTMLAppendMode eMode, bool bUpdateNum )
if( bScript )
{
const SwTextNode *pTextNd =
- pAttr->GetSttPara().GetNode().GetTextNode();
+ pAttr->GetStartParagraph().GetNode().GetTextNode();
OSL_ENSURE( pTextNd, "No text node" );
if( pTextNd )
{
const OUString& rText = pTextNd->GetText();
sal_uInt16 nScriptText =
g_pBreakIt->GetBreakIter()->getScriptType(
- rText, pAttr->GetSttCnt() );
+ rText, pAttr->GetStartContent() );
sal_Int32 nScriptEnd = g_pBreakIt->GetBreakIter()
->endOfScript( rText, nStt, nScriptText );
while (nScriptEnd < nEndCnt && nScriptEnd != -1)
@@ -2251,7 +2287,7 @@ bool SwHTMLParser::AppendTextNode( SwHTMLAppendMode eMode, bool bUpdateNum )
if( nScriptItem == nScriptText )
{
HTMLAttr *pSetAttr =
- pAttr->Clone( rEndIdx, nScriptEnd );
+ pAttr->Clone( aOldPos.GetNode(), nScriptEnd );
pSetAttr->m_nStartContent = nStt;
pSetAttr->ClearPrev();
if( !pNext || bWholePara )
@@ -2276,7 +2312,7 @@ bool SwHTMLParser::AppendTextNode( SwHTMLAppendMode eMode, bool bUpdateNum )
if( bInsert )
{
HTMLAttr *pSetAttr =
- pAttr->Clone( rEndIdx, nEndCnt );
+ pAttr->Clone( aOldPos.GetNode(), nEndCnt );
pSetAttr->m_nStartContent = nStt;
// When the attribute is for the whole paragraph, the outer
@@ -2327,7 +2363,7 @@ bool SwHTMLParser::AppendTextNode( SwHTMLAppendMode eMode, bool bUpdateNum )
SetNodeNum( nLvl );
}
else
- m_pPam->GetNode().GetTextNode()->ResetAttr( RES_PARATR_NUMRULE );
+ m_pPam->GetPointNode().GetTextNode()->ResetAttr( RES_PARATR_NUMRULE );
}
// We must set the attribute of the paragraph before now (because of JavaScript)
@@ -2335,7 +2371,7 @@ bool SwHTMLParser::AppendTextNode( SwHTMLAppendMode eMode, bool bUpdateNum )
// Now it is time to get rid of all script dependent hints that are
// equal to the settings in the style
- SwTextNode *pTextNd = rEndIdx.GetNode().GetTextNode();
+ SwTextNode *pTextNd = aOldPos.GetNode().GetTextNode();
OSL_ENSURE( pTextNd, "There is the txt node" );
size_t nCntAttr = (pTextNd && pTextNd->GetpSwpHints())
? pTextNd->GetSwpHints().Count() : 0;
@@ -2462,14 +2498,14 @@ void SwHTMLParser::AddParSpace()
m_bNoParSpace = false;
- sal_uLong nNdIdx = m_pPam->GetPoint()->nNode.GetIndex() - 1;
+ SwNodeOffset nNdIdx = m_pPam->GetPoint()->GetNodeIndex() - 1;
SwTextNode *pTextNode = m_xDoc->GetNodes()[nNdIdx]->GetTextNode();
if( !pTextNode )
return;
SvxULSpaceItem rULSpace =
- static_cast<const SvxULSpaceItem&>(pTextNode->SwContentNode::GetAttr( RES_UL_SPACE ));
+ pTextNode->SwContentNode::GetAttr( RES_UL_SPACE );
if( rULSpace.GetLower() )
return;
@@ -2558,7 +2594,7 @@ void SwHTMLParser::Show()
// is the current node not visible anymore, then we use a bigger increment
if( pVSh )
{
- m_nParaCnt = (m_pPam->GetPoint()->nNode.GetNode().IsInVisibleArea(pVSh))
+ m_nParaCnt = (m_pPam->GetPoint()->GetNode().IsInVisibleArea(pVSh))
? 5 : 50;
}
}
@@ -2643,15 +2679,12 @@ SwViewShell *SwHTMLParser::CallEndAction( bool bChkAction, bool bChkPtr )
if( !m_pActionViewShell || (bChkAction && !m_pActionViewShell->ActionPend()) )
return m_pActionViewShell;
- if( dynamic_cast< const SwEditShell *>( m_pActionViewShell ) != nullptr )
+ if (SwEditShell* pEditShell = dynamic_cast<SwEditShell*>(m_pActionViewShell))
{
// Already scrolled?, then make sure that the view doesn't move!
const bool bOldLock = m_pActionViewShell->IsViewLocked();
m_pActionViewShell->LockView( true );
- const bool bOldEndActionByVirDev = m_pActionViewShell->IsEndActionByVirDev();
- m_pActionViewShell->SetEndActionByVirDev( true );
- static_cast<SwEditShell*>(m_pActionViewShell)->EndAction();
- m_pActionViewShell->SetEndActionByVirDev( bOldEndActionByVirDev );
+ pEditShell->EndAction();
m_pActionViewShell->LockView( bOldLock );
// bChkJumpMark is only set when the object was also found
@@ -2710,9 +2743,9 @@ void SwHTMLFrameFormatListener::Notify(const SfxHint& rHint)
void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
std::deque<std::unique_ptr<HTMLAttr>> *pPostIts )
{
- std::unique_ptr<SwPaM> pAttrPam( new SwPaM( *m_pPam->GetPoint() ) );
- const SwNodeIndex& rEndIdx = m_pPam->GetPoint()->nNode;
- const sal_Int32 nEndCnt = m_pPam->GetPoint()->nContent.GetIndex();
+ SwPaM aAttrPam( *m_pPam->GetPoint() );
+ const SwPosition& rEndPos = *m_pPam->GetPoint();
+ const sal_Int32 nEndCnt = m_pPam->GetPoint()->GetContentIndex();
HTMLAttr* pAttr;
SwContentNode* pCNd;
@@ -2723,7 +2756,7 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
pAttr = m_aSetAttrTab[ --n ];
sal_uInt16 nWhich = pAttr->m_pItem->Which();
- sal_uLong nEndParaIdx = pAttr->GetEndParaIdx();
+ SwNodeOffset nEndParaIdx = pAttr->GetEndParagraphIdx();
bool bSetAttr;
if( bChkEnd )
{
@@ -2733,23 +2766,23 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
// the whole paragraph, because they could be from a paragraph style
// which can't be set. Because the attributes are inserted with
// SETATTR_DONTREPLACE, they should be able to be set later.
- bSetAttr = ( nEndParaIdx < rEndIdx.GetIndex() &&
- (RES_LR_SPACE != nWhich || !GetNumInfo().GetNumRule()) ) ||
+ bSetAttr = ( nEndParaIdx < rEndPos.GetNodeIndex() &&
+ ((RES_MARGIN_FIRSTLINE != nWhich && RES_MARGIN_TEXTLEFT != nWhich) || !GetNumInfo().GetNumRule()) ) ||
( !pAttr->IsLikePara() &&
- nEndParaIdx == rEndIdx.GetIndex() &&
- pAttr->GetEndCnt() < nEndCnt &&
+ nEndParaIdx == rEndPos.GetNodeIndex() &&
+ pAttr->GetEndContent() < nEndCnt &&
(isCHRATR(nWhich) || isTXTATR_WITHEND(nWhich)) ) ||
( bBeforeTable &&
- nEndParaIdx == rEndIdx.GetIndex() &&
- !pAttr->GetEndCnt() );
+ nEndParaIdx == rEndPos.GetNodeIndex() &&
+ !pAttr->GetEndContent() );
}
else
{
// Attributes in body nodes array section shouldn't be set if we are in a
// special nodes array section, but vice versa it's possible.
- sal_uLong nEndOfIcons = m_xDoc->GetNodes().GetEndOfExtras().GetIndex();
- bSetAttr = nEndParaIdx < rEndIdx.GetIndex() ||
- rEndIdx.GetIndex() > nEndOfIcons ||
+ SwNodeOffset nEndOfIcons = m_xDoc->GetNodes().GetEndOfExtras().GetIndex();
+ bSetAttr = nEndParaIdx < rEndPos.GetNodeIndex() ||
+ rEndPos.GetNodeIndex() > nEndOfIcons ||
nEndParaIdx <= nEndOfIcons;
}
@@ -2783,7 +2816,7 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
{
// because of the awful deleting of nodes an index can also
// point to an end node :-(
- if ( (pAttr->GetSttPara() == pAttr->GetEndPara()) &&
+ if ( (pAttr->GetStartParagraph() == pAttr->GetEndParagraph()) &&
!isTXTATR_NOEND(nWhich) )
{
// when the end index also points to the node, we don't
@@ -2792,7 +2825,7 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
pAttr = pPrev;
continue;
}
- pCNd = m_xDoc->GetNodes().GoNext( &(pAttr->m_nStartPara) );
+ pCNd = SwNodes::GoNext(&(pAttr->m_nStartPara));
if( pCNd )
pAttr->m_nStartContent = 0;
else
@@ -2803,16 +2836,15 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
continue;
}
}
- pAttrPam->GetPoint()->nNode = pAttr->m_nStartPara;
// because of the deleting of BRs the start index can also
// point behind the end the text
if( pAttr->m_nStartContent > pCNd->Len() )
pAttr->m_nStartContent = pCNd->Len();
- pAttrPam->GetPoint()->nContent.Assign( pCNd, pAttr->m_nStartContent );
+ aAttrPam.GetPoint()->Assign( *pCNd, pAttr->m_nStartContent );
- pAttrPam->SetMark();
- if ( (pAttr->GetSttPara() != pAttr->GetEndPara()) &&
+ aAttrPam.SetMark();
+ if ( (pAttr->GetStartParagraph() != pAttr->GetEndParagraph()) &&
!isTXTATR_NOEND(nWhich) )
{
pCNd = pAttr->m_nEndPara.GetNode().GetContentNode();
@@ -2824,14 +2856,12 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
else
{
OSL_ENSURE( false, "SetAttr: GoPrevious() failed!" );
- pAttrPam->DeleteMark();
+ aAttrPam.DeleteMark();
delete pAttr;
pAttr = pPrev;
continue;
}
}
-
- pAttrPam->GetPoint()->nNode = pAttr->m_nEndPara;
}
else if( pAttr->IsLikePara() )
{
@@ -2843,10 +2873,10 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
if( pAttr->m_nEndContent > pCNd->Len() )
pAttr->m_nEndContent = pCNd->Len();
- pAttrPam->GetPoint()->nContent.Assign( pCNd, pAttr->m_nEndContent );
+ aAttrPam.GetPoint()->Assign( *pCNd, pAttr->m_nEndContent );
if( bBeforeTable &&
- pAttrPam->GetPoint()->nNode.GetIndex() ==
- rEndIdx.GetIndex() )
+ aAttrPam.GetPoint()->GetNodeIndex() ==
+ rEndPos.GetNodeIndex() )
{
// If we're before inserting a table and the attribute ends
// in the current node, then we must end it in the previous
@@ -2854,16 +2884,16 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
if( nWhich != RES_BREAK && nWhich != RES_PAGEDESC &&
!isTXTATR_NOEND(nWhich) )
{
- if( pAttrPam->GetMark()->nNode.GetIndex() !=
- rEndIdx.GetIndex() )
+ if( aAttrPam.GetMark()->GetNodeIndex() !=
+ rEndPos.GetNodeIndex() )
{
- OSL_ENSURE( !pAttrPam->GetPoint()->nContent.GetIndex(),
+ OSL_ENSURE( !aAttrPam.GetPoint()->GetContentIndex(),
"Content-Position before table not 0???" );
- pAttrPam->Move( fnMoveBackward );
+ aAttrPam.Move( fnMoveBackward );
}
else
{
- pAttrPam->DeleteMark();
+ aAttrPam.DeleteMark();
delete pAttr;
pAttr = pPrev;
continue;
@@ -2879,11 +2909,11 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
IDocumentMarkAccess* const pMarkAccess = m_xDoc->getIDocumentMarkAccess();
IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->findMark( sName );
if( ppBkmk != pMarkAccess->getAllMarksEnd() &&
- (*ppBkmk)->GetMarkStart() == *pAttrPam->GetPoint() )
+ (*ppBkmk)->GetMarkStart() == *aAttrPam.GetPoint() )
break; // do not generate duplicates on this position
- pAttrPam->DeleteMark();
+ aAttrPam.DeleteMark();
const ::sw::mark::IMark* const pNewMark = pMarkAccess->makeMark(
- *pAttrPam,
+ aAttrPam,
sName,
IDocumentMarkAccess::MarkType::BOOKMARK,
::sw::mark::InsertMode::New);
@@ -2914,22 +2944,10 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
aFields.emplace_back( pAttr);
}
}
- pAttrPam->DeleteMark();
+ aAttrPam.DeleteMark();
pAttr = pPrev;
continue;
- case RES_LR_SPACE:
- if( pAttrPam->GetPoint()->nNode.GetIndex() ==
- pAttrPam->GetMark()->nNode.GetIndex())
- {
- // because of numbering set this attribute directly at node
- pCNd->SetAttr( *pAttr->m_pItem );
- break;
- }
- OSL_ENSURE( false,
- "LRSpace set over multiple paragraphs!" );
- [[fallthrough]]; // (shouldn't reach this point anyway)
-
// tdf#94088 expand RES_BACKGROUND to the new fill attribute
// definitions in the range [XATTR_FILL_FIRST .. XATTR_FILL_LAST].
// This is the right place in the future if the adapted fill attributes
@@ -2937,12 +2955,30 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
case RES_BACKGROUND:
{
const SvxBrushItem& rBrush = static_cast< SvxBrushItem& >(*pAttr->m_pItem);
- SfxItemSet aNewSet(m_xDoc->GetAttrPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{});
+ SfxItemSetFixed<XATTR_FILL_FIRST, XATTR_FILL_LAST> aNewSet(m_xDoc->GetAttrPool());
setSvxBrushItemAsFillAttributesToTargetSet(rBrush, aNewSet);
- m_xDoc->getIDocumentContentOperations().InsertItemSet(*pAttrPam, aNewSet, SetAttrMode::DONTREPLACE);
+ m_xDoc->getIDocumentContentOperations().InsertItemSet(aAttrPam, aNewSet, SetAttrMode::DONTREPLACE);
break;
}
+
+ case RES_LR_SPACE:
+ assert(false);
+ break;
+
+ case RES_MARGIN_FIRSTLINE:
+ case RES_MARGIN_TEXTLEFT:
+ case RES_MARGIN_RIGHT:
+ if( aAttrPam.GetPoint()->GetNodeIndex() ==
+ aAttrPam.GetMark()->GetNodeIndex())
+ {
+ // because of numbering set this attribute directly at node
+ pCNd->SetAttr( *pAttr->m_pItem );
+ break;
+ }
+ OSL_ENSURE( false,
+ "LRSpace set over multiple paragraphs!" );
+ [[fallthrough]]; // (shouldn't reach this point anyway)
default:
// maybe jump to a bookmark
@@ -2954,9 +2990,9 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
m_eJumpTo = JumpToMarks::NONE;
}
- m_xDoc->getIDocumentContentOperations().InsertPoolItem( *pAttrPam, *pAttr->m_pItem, SetAttrMode::DONTREPLACE );
+ m_xDoc->getIDocumentContentOperations().InsertPoolItem( aAttrPam, *pAttr->m_pItem, SetAttrMode::DONTREPLACE );
}
- pAttrPam->DeleteMark();
+ aAttrPam.DeleteMark();
delete pAttr;
pAttr = pPrev;
@@ -2978,31 +3014,29 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor();
OSL_ENSURE( RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId(),
"Only At-Para flys need special handling" );
- const SwPosition *pFlyPos = rAnchor.GetContentAnchor();
- sal_uLong nFlyParaIdx = pFlyPos->nNode.GetIndex();
+ SwNodeOffset nFlyParaIdx = rAnchor.GetAnchorNode()->GetIndex();
bool bMoveFly;
if( bChkEnd )
{
- bMoveFly = nFlyParaIdx < rEndIdx.GetIndex() ||
- ( nFlyParaIdx == rEndIdx.GetIndex() &&
+ bMoveFly = nFlyParaIdx < rEndPos.GetNodeIndex() ||
+ ( nFlyParaIdx == rEndPos.GetNodeIndex() &&
m_aMoveFlyCnts[n] < nEndCnt );
}
else
{
- sal_uLong nEndOfIcons = m_xDoc->GetNodes().GetEndOfExtras().GetIndex();
- bMoveFly = nFlyParaIdx < rEndIdx.GetIndex() ||
- rEndIdx.GetIndex() > nEndOfIcons ||
+ SwNodeOffset nEndOfIcons = m_xDoc->GetNodes().GetEndOfExtras().GetIndex();
+ bMoveFly = nFlyParaIdx < rEndPos.GetNodeIndex() ||
+ rEndPos.GetNodeIndex() > nEndOfIcons ||
nFlyParaIdx <= nEndOfIcons;
}
if( bMoveFly )
{
pFrameFormat->DelFrames();
- *pAttrPam->GetPoint() = *pFlyPos;
- pAttrPam->GetPoint()->nContent.Assign( pAttrPam->GetContentNode(),
- m_aMoveFlyCnts[n] );
+ *aAttrPam.GetPoint() = *rAnchor.GetContentAnchor();
+ aAttrPam.GetPoint()->SetContent( m_aMoveFlyCnts[n] );
SwFormatAnchor aAnchor( rAnchor );
aAnchor.SetType( RndStdIds::FLY_AT_CHAR );
- aAnchor.SetAnchor( pAttrPam->GetPoint() );
+ aAnchor.SetAnchor( aAttrPam.GetPoint() );
pFrameFormat->SetFormatAttr( aAnchor );
const SwFormatHoriOrient& rHoriOri = pFrameFormat->GetHoriOrient();
@@ -3028,20 +3062,19 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
for (auto & field : aFields)
{
pCNd = field->m_nStartPara.GetNode().GetContentNode();
- pAttrPam->GetPoint()->nNode = field->m_nStartPara;
- pAttrPam->GetPoint()->nContent.Assign( pCNd, field->m_nStartContent );
+ aAttrPam.GetPoint()->Assign( *pCNd, field->m_nStartContent );
if( bBeforeTable &&
- pAttrPam->GetPoint()->nNode.GetIndex() == rEndIdx.GetIndex() )
+ aAttrPam.GetPoint()->GetNodeIndex() == rEndPos.GetNodeIndex() )
{
OSL_ENSURE( !bBeforeTable, "Aha, the case does occur" );
- OSL_ENSURE( !pAttrPam->GetPoint()->nContent.GetIndex(),
+ OSL_ENSURE( !aAttrPam.GetPoint()->GetContentIndex(),
"Content-Position before table not 0???" );
// !!!
- pAttrPam->Move( fnMoveBackward );
+ aAttrPam.Move( fnMoveBackward );
}
- m_xDoc->getIDocumentContentOperations().InsertPoolItem( *pAttrPam, *field->m_pItem );
+ m_xDoc->getIDocumentContentOperations().InsertPoolItem( aAttrPam, *field->m_pItem );
field.reset();
}
@@ -3074,8 +3107,8 @@ bool SwHTMLParser::EndAttr( HTMLAttr* pAttr, bool bChkEmpty )
OSL_ENSURE( ppHead, "No list header attribute found!" );
// save the current position as end position
- const SwNodeIndex* pEndIdx = &m_pPam->GetPoint()->nNode;
- sal_Int32 nEndCnt = m_pPam->GetPoint()->nContent.GetIndex();
+ const SwPosition* pEndPos = m_pPam->GetPoint();
+ sal_Int32 nEndCnt = m_pPam->GetPoint()->GetContentIndex();
// Is the last started or an earlier started attribute being ended?
HTMLAttr *pLast = nullptr;
@@ -3096,11 +3129,11 @@ bool SwHTMLParser::EndAttr( HTMLAttr* pAttr, bool bChkEmpty )
bool bMoveBack = false;
sal_uInt16 nWhich = pAttr->m_pItem->Which();
if( !nEndCnt && RES_PARATR_BEGIN <= nWhich &&
- *pEndIdx != pAttr->GetSttPara() )
+ pEndPos->GetNodeIndex() != pAttr->GetStartParagraph().GetIndex() )
{
// Then move back one position in the content!
bMoveBack = m_pPam->Move( fnMoveBackward );
- nEndCnt = m_pPam->GetPoint()->nContent.GetIndex();
+ nEndCnt = m_pPam->GetPoint()->GetContentIndex();
}
// now end the attribute
@@ -3112,12 +3145,12 @@ bool SwHTMLParser::EndAttr( HTMLAttr* pAttr, bool bChkEmpty )
// does it have a non-empty range?
if( !bChkEmpty || (RES_PARATR_BEGIN <= nWhich && bMoveBack) ||
RES_PAGEDESC == nWhich || RES_BREAK == nWhich ||
- *pEndIdx != pAttr->GetSttPara() ||
- nEndCnt != pAttr->GetSttCnt() )
+ pEndPos->GetNodeIndex() != pAttr->GetStartParagraph().GetIndex() ||
+ nEndCnt != pAttr->GetStartContent() )
{
bInsert = true;
// We do some optimization for script dependent attributes here.
- if( *pEndIdx == pAttr->GetSttPara() )
+ if( pEndPos->GetNodeIndex() == pAttr->GetStartParagraph().GetIndex() )
{
lcl_swhtml_getItemInfo( *pAttr, bScript, nScriptItem );
}
@@ -3128,21 +3161,21 @@ bool SwHTMLParser::EndAttr( HTMLAttr* pAttr, bool bChkEmpty )
}
const SwTextNode *pTextNd = (bInsert && bScript) ?
- pAttr->GetSttPara().GetNode().GetTextNode() :
+ pAttr->GetStartParagraph().GetNode().GetTextNode() :
nullptr;
if (pTextNd)
{
const OUString& rText = pTextNd->GetText();
sal_uInt16 nScriptText = g_pBreakIt->GetBreakIter()->getScriptType(
- rText, pAttr->GetSttCnt() );
+ rText, pAttr->GetStartContent() );
sal_Int32 nScriptEnd = g_pBreakIt->GetBreakIter()
- ->endOfScript( rText, pAttr->GetSttCnt(), nScriptText );
+ ->endOfScript( rText, pAttr->GetStartContent(), nScriptText );
while (nScriptEnd < nEndCnt && nScriptEnd != -1)
{
if( nScriptItem == nScriptText )
{
- HTMLAttr *pSetAttr = pAttr->Clone( *pEndIdx, nScriptEnd );
+ HTMLAttr *pSetAttr = pAttr->Clone( pEndPos->GetNode(), nScriptEnd );
pSetAttr->ClearPrev();
if( pNext )
pNext->InsertPrev( pSetAttr );
@@ -3164,7 +3197,7 @@ bool SwHTMLParser::EndAttr( HTMLAttr* pAttr, bool bChkEmpty )
}
if( bInsert )
{
- pAttr->m_nEndPara = *pEndIdx;
+ pAttr->m_nEndPara = pEndPos->GetNode();
pAttr->m_nEndContent = nEndCnt;
pAttr->m_bInsAtStart = RES_TXTATR_INETFMT != nWhich &&
RES_TXTATR_CHARFMT != nWhich;
@@ -3319,20 +3352,19 @@ void SwHTMLParser::SplitAttrTab( std::shared_ptr<HTMLAttrTable> const & rNewAttr
"Danger: there are non-final paragraph attributes");
m_aParaAttrs.clear();
- const SwNodeIndex& nSttIdx = m_pPam->GetPoint()->nNode;
- SwNodeIndex nEndIdx( nSttIdx );
+ SwNodeIndex nEndIdx( m_pPam->GetPoint()->GetNode() );
// close all still open attributes and re-open them after the table
HTMLAttr** pHTMLAttributes = reinterpret_cast<HTMLAttr**>(m_xAttrTab.get());
HTMLAttr** pSaveAttributes = reinterpret_cast<HTMLAttr**>(rNewAttrTab.get());
bool bSetAttr = true;
- const sal_Int32 nSttCnt = m_pPam->GetPoint()->nContent.GetIndex();
+ const sal_Int32 nSttCnt = m_pPam->GetPoint()->GetContentIndex();
sal_Int32 nEndCnt = nSttCnt;
if( bMoveEndBack )
{
- sal_uLong nOldEnd = nEndIdx.GetIndex();
- sal_uLong nTmpIdx;
+ SwNodeOffset nOldEnd = nEndIdx.GetIndex();
+ SwNodeOffset nTmpIdx;
if( ( nTmpIdx = m_xDoc->GetNodes().GetEndOfExtras().GetIndex()) >= nOldEnd ||
( nTmpIdx = m_xDoc->GetNodes().GetEndOfAutotext().GetIndex()) >= nOldEnd )
{
@@ -3355,15 +3387,15 @@ void SwHTMLParser::SplitAttrTab( std::shared_ptr<HTMLAttrTable> const & rNewAttr
HTMLAttr *pPrev = pAttr->GetPrev();
if( bSetAttr &&
- ( pAttr->GetSttParaIdx() < nEndIdx.GetIndex() ||
- (pAttr->GetSttPara() == nEndIdx &&
- pAttr->GetSttCnt() != nEndCnt) ) )
+ ( pAttr->GetStartParagraphIdx() < nEndIdx.GetIndex() ||
+ (pAttr->GetStartParagraph() == nEndIdx &&
+ pAttr->GetStartContent() != nEndCnt) ) )
{
// The attribute must be set before the list. We need the
// original and therefore we clone it, because pointer to the
// attribute exist in the other contexts. The Next-List is lost
// in doing so, but the Previous-List is preserved.
- HTMLAttr *pSetAttr = pAttr->Clone( nEndIdx, nEndCnt );
+ HTMLAttr *pSetAttr = pAttr->Clone( nEndIdx.GetNode(), nEndCnt );
if( pNext )
pNext->InsertPrev( pSetAttr );
@@ -3391,7 +3423,7 @@ void SwHTMLParser::SplitAttrTab( std::shared_ptr<HTMLAttrTable> const & rNewAttr
}
// set the start of the attribute anew and break link
- pAttr->Reset(nSttIdx, nSttCnt, pSaveAttributes, rNewAttrTab);
+ pAttr->Reset(m_pPam->GetPoint()->GetNode(), nSttCnt, pSaveAttributes, rNewAttrTab);
if (*pSaveAttributes)
{
@@ -3605,7 +3637,7 @@ void SwHTMLParser::NewBasefontAttr()
switch( rOption.GetToken() )
{
case HtmlOptionId::SIZE:
- nSize = static_cast<sal_uInt16>(rOption.GetNumber());
+ nSize = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::ID:
aId = rOption.GetString();
@@ -3721,7 +3753,7 @@ void SwHTMLParser::NewFontAttr( HtmlTokenId nToken )
else if( nSSize > 7 )
nSSize = 7;
- nSize = static_cast<sal_uInt16>(nSSize);
+ nSize = o3tl::narrowing<sal_uInt16>(nSSize);
nFontHeight = m_aFontHeights[nSize-1];
}
break;
@@ -3914,7 +3946,7 @@ void SwHTMLParser::EndFontAttr( HtmlTokenId nToken )
void SwHTMLParser::NewPara()
{
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if( m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode( AM_SPACE );
else
AddParSpace();
@@ -3946,6 +3978,11 @@ void SwHTMLParser::NewPara()
case HtmlOptionId::DIR:
aDir = rOption.GetString();
break;
+ case HtmlOptionId::XML_SPACE:
+ if (rOption.GetString() == "preserve")
+ SetPreserveSpaces(true);
+ break;
+
default: break;
}
}
@@ -3969,6 +4006,9 @@ void SwHTMLParser::NewPara()
"Class is not considered" );
DoPositioning( aItemSet, aPropInfo, xCntxt.get() );
InsertAttrs( aItemSet, aPropInfo, xCntxt.get() );
+
+ if (aPropInfo.m_bPreserveSpace)
+ SetPreserveSpaces(true);
}
}
@@ -3993,15 +4033,16 @@ void SwHTMLParser::EndPara( bool bReal )
if (HtmlTokenId::LI_ON==m_nOpenParaToken && m_xTable)
{
#if OSL_DEBUG_LEVEL > 0
- const SwNumRule *pNumRule = m_pPam->GetNode().GetTextNode()->GetNumRule();
+ const SwNumRule *pNumRule = m_pPam->GetPointNode().GetTextNode()->GetNumRule();
OSL_ENSURE( pNumRule, "Where is the NumRule" );
#endif
}
- // Netscape skips empty paragraphs, we do the same.
+ // Netscape skips empty paragraphs, we do the same; unless in XHTML mode, which prefers mapping
+ // the source document to the doc model 1:1 if possible.
if( bReal )
{
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if (m_pPam->GetPoint()->GetContentIndex() || m_bXHTML)
AppendTextNode( AM_SPACE );
else
AddParSpace();
@@ -4033,6 +4074,7 @@ void SwHTMLParser::EndPara( bool bReal )
SetTextCollAttrs();
m_nOpenParaToken = HtmlTokenId::NONE;
+ SetPreserveSpaces(false);
}
void SwHTMLParser::NewHeading( HtmlTokenId nToken )
@@ -4070,7 +4112,7 @@ void SwHTMLParser::NewHeading( HtmlTokenId nToken )
}
// open a new paragraph
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if( m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode( AM_SPACE );
else
AddParSpace();
@@ -4124,7 +4166,7 @@ void SwHTMLParser::NewHeading( HtmlTokenId nToken )
void SwHTMLParser::EndHeading()
{
// open a new paragraph
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if( m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode( AM_SPACE );
else
AddParSpace();
@@ -4219,7 +4261,7 @@ void SwHTMLParser::NewTextFormatColl( HtmlTokenId nToken, sal_uInt16 nColl )
OSL_ENSURE( false, "unknown style" );
break;
}
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if( m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode( eMode );
else if( AM_SPACE==eMode )
AddParSpace();
@@ -4272,7 +4314,7 @@ void SwHTMLParser::EndTextFormatColl( HtmlTokenId nToken )
OSL_ENSURE( false, "unknown style" );
break;
}
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if( m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode( eMode );
else if( AM_SPACE==eMode )
AddParSpace();
@@ -4323,7 +4365,7 @@ void SwHTMLParser::NewDefList()
// open a new paragraph
bool bSpace = (GetNumInfo().GetDepth() + m_nDefListDeep) == 0;
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if( m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode( bSpace ? AM_SPACE : AM_SOFTNOSPACE );
else if( bSpace )
AddParSpace();
@@ -4367,10 +4409,10 @@ void SwHTMLParser::NewDefList()
{
// and the one of the DT-style of the current level
- SvxLRSpaceItem rLRSpace =
+ SvxTextLeftMarginItem const& rTextLeftMargin =
m_pCSS1Parser->GetTextFormatColl(RES_POOLCOLL_HTML_DD, OUString())
- ->GetLRSpace();
- nLeft = nLeft + static_cast< sal_uInt16 >(rLRSpace.GetTextLeft());
+ ->GetTextLeftMargin();
+ nLeft = nLeft + static_cast<sal_uInt16>(rTextLeftMargin.GetTextLeft());
}
xCntxt->SetMargins( nLeft, nRight, nIndent );
@@ -4398,7 +4440,7 @@ void SwHTMLParser::NewDefList()
void SwHTMLParser::EndDefList()
{
bool bSpace = (GetNumInfo().GetDepth() + m_nDefListDeep) == 1;
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if( m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode( bSpace ? AM_SPACE : AM_SOFTNOSPACE );
else if( bSpace )
AddParSpace();
@@ -4461,7 +4503,7 @@ void SwHTMLParser::NewDefListItem( HtmlTokenId nToken )
void SwHTMLParser::EndDefListItem( HtmlTokenId nToken )
{
// open a new paragraph
- if( nToken == HtmlTokenId::NONE && m_pPam->GetPoint()->nContent.GetIndex() )
+ if( nToken == HtmlTokenId::NONE && m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode( AM_SOFTNOSPACE );
// search context matching the token and fetch it from stack
@@ -4514,14 +4556,12 @@ void SwHTMLParser::EndDefListItem( HtmlTokenId nToken )
bool SwHTMLParser::HasCurrentParaFlys( bool bNoSurroundOnly,
bool bSurroundOnly ) const
{
- SwNodeIndex& rNodeIdx = m_pPam->GetPoint()->nNode;
+ SwNode& rNode = m_pPam->GetPoint()->GetNode();
- const SwFrameFormats& rFrameFormatTable = *m_xDoc->GetSpzFrameFormats();
bool bFound = false;
- for ( size_t i=0; i<rFrameFormatTable.size(); i++ )
+ for(sw::SpzFrameFormat* pFormat: *m_xDoc->GetSpzFrameFormats())
{
- const SwFrameFormat *const pFormat = rFrameFormatTable[i];
SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor();
// A frame was found, when
// - it is paragraph-bound, and
@@ -4529,11 +4569,11 @@ bool SwHTMLParser::HasCurrentParaFlys( bool bNoSurroundOnly,
// - every paragraph-bound frame counts, or
// - (only frames without wrapping count and) the frame doesn't have
// a wrapping
- SwPosition const*const pAPos = pAnchor->GetContentAnchor();
- if (pAPos &&
+ SwNode const*const pAnchorNode = pAnchor->GetAnchorNode();
+ if (pAnchorNode &&
((RndStdIds::FLY_AT_PARA == pAnchor->GetAnchorId()) ||
(RndStdIds::FLY_AT_CHAR == pAnchor->GetAnchorId())) &&
- pAPos->nNode == rNodeIdx )
+ *pAnchorNode == rNode )
{
if( !(bNoSurroundOnly || bSurroundOnly) )
{
@@ -4579,7 +4619,7 @@ bool SwHTMLParser::HasCurrentParaFlys( bool bNoSurroundOnly,
const SwFormatColl *SwHTMLParser::GetCurrFormatColl() const
{
- const SwContentNode* pCNd = m_pPam->GetContentNode();
+ const SwContentNode* pCNd = m_pPam->GetPointContentNode();
return pCNd ? &pCNd->GetAnyFormatColl() : nullptr;
}
@@ -4596,7 +4636,14 @@ void SwHTMLParser::SetTextCollAttrs( HTMLAttrContext *pContext )
sal_uInt16 nLeftMargin = 0, nRightMargin = 0; // the margins and
short nFirstLineIndent = 0; // indentations
- for( auto i = m_nContextStAttrMin; i < m_aContexts.size(); ++i )
+ auto nDepth = m_aContexts.size();
+ if (bFuzzing && nDepth > 128)
+ {
+ SAL_WARN("sw.html", "Not applying any more text collection attributes to a deeply nested node for fuzzing performance");
+ nDepth = 0;
+ }
+
+ for (auto i = m_nContextStAttrMin; i < nDepth; ++i)
{
const HTMLAttrContext *pCntxt = m_aContexts[i].get();
@@ -4673,7 +4720,7 @@ void SwHTMLParser::SetTextCollAttrs( HTMLAttrContext *pContext )
else
{
// Maybe a default style exists?
- nColl = pCntxt->GetDfltTextFormatColl();
+ nColl = pCntxt->GetDefaultTextFormatColl();
if( nColl )
nDfltColl = nColl;
}
@@ -4702,24 +4749,20 @@ void SwHTMLParser::SetTextCollAttrs( HTMLAttrContext *pContext )
const SwTextFormatColl *pTopColl =
m_pCSS1Parser->GetTextFormatColl( nTopColl, rTopClass );
const SfxItemSet& rItemSet = pTopColl->GetAttrSet();
- const SfxPoolItem *pItem;
- if( SfxItemState::SET == rItemSet.GetItemState(RES_LR_SPACE,true, &pItem) )
+ if (rItemSet.GetItemIfSet(RES_MARGIN_FIRSTLINE)
+ || rItemSet.GetItemIfSet(RES_MARGIN_TEXTLEFT)
+ || rItemSet.GetItemIfSet(RES_MARGIN_RIGHT))
{
- const SvxLRSpaceItem *pLRItem =
- static_cast<const SvxLRSpaceItem *>(pItem);
-
- sal_Int32 nLeft = pLRItem->GetTextLeft();
- sal_Int32 nRight = pLRItem->GetRight();
- nFirstLineIndent = pLRItem->GetTextFirstLineOffset();
+ sal_Int32 nLeft = rItemSet.Get(RES_MARGIN_TEXTLEFT).GetTextLeft();
+ sal_Int32 nRight = rItemSet.Get(RES_MARGIN_RIGHT).GetRight();
+ nFirstLineIndent = rItemSet.Get(RES_MARGIN_FIRSTLINE).GetTextFirstLineOffset();
// In Definition lists the margins also contain the margins from the previous levels
if( RES_POOLCOLL_HTML_DD == nTopColl )
{
- const SvxLRSpaceItem& rDTLRSpace = m_pCSS1Parser
- ->GetTextFormatColl(RES_POOLCOLL_HTML_DT, OUString())
- ->GetLRSpace();
- nLeft -= rDTLRSpace.GetTextLeft();
- nRight -= rDTLRSpace.GetRight();
+ auto const*const pColl(m_pCSS1Parser->GetTextFormatColl(RES_POOLCOLL_HTML_DT, OUString()));
+ nLeft -= pColl->GetTextLeftMargin().GetTextLeft();
+ nRight -= pColl->GetRightMargin().GetRight();
}
else if( RES_POOLCOLL_HTML_DT == nTopColl )
{
@@ -4734,10 +4777,8 @@ void SwHTMLParser::SetTextCollAttrs( HTMLAttrContext *pContext )
pContext->SetMargins( nLeftMargin, nRightMargin,
nFirstLineIndent );
}
- if( SfxItemState::SET == rItemSet.GetItemState(RES_UL_SPACE,true, &pItem) )
+ if( const SvxULSpaceItem* pULItem = rItemSet.GetItemIfSet(RES_UL_SPACE) )
{
- const SvxULSpaceItem *pULItem =
- static_cast<const SvxULSpaceItem *>(pItem);
pContext->SetULSpace( pULItem->GetUpper(), pULItem->GetLower() );
}
}
@@ -4746,13 +4787,18 @@ void SwHTMLParser::SetTextCollAttrs( HTMLAttrContext *pContext )
if( !pCollToSet )
{
pCollToSet = m_pCSS1Parser->GetTextCollFromPool( nDfltColl );
- const SvxLRSpaceItem& rLRItem = pCollToSet->GetLRSpace();
if( !nLeftMargin )
- nLeftMargin = static_cast< sal_uInt16 >(rLRItem.GetTextLeft());
+ {
+ nLeftMargin = static_cast<sal_uInt16>(pCollToSet->GetTextLeftMargin().GetTextLeft());
+ }
if( !nRightMargin )
- nRightMargin = static_cast< sal_uInt16 >(rLRItem.GetRight());
+ {
+ nRightMargin = static_cast<sal_uInt16>(pCollToSet->GetRightMargin().GetRight());
+ }
if( !nFirstLineIndent )
- nFirstLineIndent = rLRItem.GetTextFirstLineOffset();
+ {
+ nFirstLineIndent = pCollToSet->GetFirstLineIndent().GetTextFirstLineOffset();
+ }
}
// remove previous hard attribution of paragraph
@@ -4764,25 +4810,41 @@ void SwHTMLParser::SetTextCollAttrs( HTMLAttrContext *pContext )
m_xDoc->SetTextFormatColl( *m_pPam, pCollToSet );
// if applicable correct the paragraph indent
- const SvxLRSpaceItem& rLRItem = pCollToSet->GetLRSpace();
- bool bSetLRSpace = nLeftMargin != rLRItem.GetTextLeft() ||
- nFirstLineIndent != rLRItem.GetTextFirstLineOffset() ||
- nRightMargin != rLRItem.GetRight();
+ const SvxFirstLineIndentItem & rFirstLine = pCollToSet->GetFirstLineIndent();
+ const SvxTextLeftMarginItem & rTextLeftMargin = pCollToSet->GetTextLeftMargin();
+ const SvxRightMarginItem & rRightMargin = pCollToSet->GetRightMargin();
+ bool bSetLRSpace = nLeftMargin != rTextLeftMargin.GetTextLeft() ||
+ nFirstLineIndent != rFirstLine.GetTextFirstLineOffset() ||
+ nRightMargin != rRightMargin.GetRight();
if( bSetLRSpace )
{
- SvxLRSpaceItem aLRItem( rLRItem );
- aLRItem.SetTextLeft( nLeftMargin );
- aLRItem.SetRight( nRightMargin );
- aLRItem.SetTextFirstLineOffset( nFirstLineIndent );
+ SvxFirstLineIndentItem firstLine(rFirstLine);
+ SvxTextLeftMarginItem leftMargin(rTextLeftMargin);
+ SvxRightMarginItem rightMargin(rRightMargin);
+ firstLine.SetTextFirstLineOffset(nFirstLineIndent);
+ leftMargin.SetTextLeft(nLeftMargin);
+ rightMargin.SetRight(nRightMargin);
if( pItemSet )
- pItemSet->Put( aLRItem );
+ {
+ pItemSet->Put(firstLine);
+ pItemSet->Put(leftMargin);
+ pItemSet->Put(rightMargin);
+ }
else
{
- NewAttr(m_xAttrTab, &m_xAttrTab->pLRSpace, aLRItem);
- m_xAttrTab->pLRSpace->SetLikePara();
- m_aParaAttrs.push_back( m_xAttrTab->pLRSpace );
- EndAttr( m_xAttrTab->pLRSpace, false );
+ NewAttr(m_xAttrTab, &m_xAttrTab->pFirstLineIndent, firstLine);
+ m_xAttrTab->pFirstLineIndent->SetLikePara();
+ m_aParaAttrs.push_back(m_xAttrTab->pFirstLineIndent);
+ EndAttr(m_xAttrTab->pFirstLineIndent, false);
+ NewAttr(m_xAttrTab, &m_xAttrTab->pTextLeftMargin, leftMargin);
+ m_xAttrTab->pTextLeftMargin->SetLikePara();
+ m_aParaAttrs.push_back(m_xAttrTab->pTextLeftMargin);
+ EndAttr(m_xAttrTab->pTextLeftMargin, false);
+ NewAttr(m_xAttrTab, &m_xAttrTab->pRightMargin, rightMargin);
+ m_xAttrTab->pRightMargin->SetLikePara();
+ m_aParaAttrs.push_back(m_xAttrTab->pRightMargin);
+ EndAttr(m_xAttrTab->pRightMargin, false);
}
}
@@ -4908,8 +4970,7 @@ void SwHTMLParser::InsertSpacer()
// create an empty text frame
// fetch the ItemSet
- SfxItemSet aFrameSet( m_xDoc->GetAttrPool(),
- svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aFrameSet( m_xDoc->GetAttrPool() );
if( !IsNewDoc() )
Reader::ResetFrameFormatAttrs( aFrameSet );
@@ -4944,23 +5005,18 @@ void SwHTMLParser::InsertSpacer()
case HTML_SPTYPE_VERT:
if( nSize > 0 )
{
- if (Application::GetDefaultDevice())
- {
- nSize = Application::GetDefaultDevice()
- ->PixelToLogic( Size(0,nSize),
- MapMode(MapUnit::MapTwip) ).Height();
- }
+ nSize = o3tl::convert(nSize, o3tl::Length::px, o3tl::Length::twip);
// set a paragraph margin
SwTextNode *pTextNode = nullptr;
- if( !m_pPam->GetPoint()->nContent.GetIndex() )
+ if( !m_pPam->GetPoint()->GetContentIndex() )
{
// if possible change the bottom paragraph margin
// of previous node
SetAttr(); // set still open paragraph attributes
- pTextNode = m_xDoc->GetNodes()[m_pPam->GetPoint()->nNode.GetIndex()-1]
+ pTextNode = m_xDoc->GetNodes()[m_pPam->GetPoint()->GetNodeIndex()-1]
->GetTextNode();
// If the previous paragraph isn't a text node, then now an
@@ -4972,14 +5028,13 @@ void SwHTMLParser::InsertSpacer()
if( pTextNode )
{
- SvxULSpaceItem aULSpace( static_cast<const SvxULSpaceItem&>(pTextNode
- ->SwContentNode::GetAttr( RES_UL_SPACE )) );
- aULSpace.SetLower( aULSpace.GetLower() + static_cast<sal_uInt16>(nSize) );
+ SvxULSpaceItem aULSpace( pTextNode->SwContentNode::GetAttr( RES_UL_SPACE ) );
+ aULSpace.SetLower( aULSpace.GetLower() + o3tl::narrowing<sal_uInt16>(nSize) );
pTextNode->SetAttr( aULSpace );
}
else
{
- NewAttr(m_xAttrTab, &m_xAttrTab->pULSpace, SvxULSpaceItem(0, static_cast<sal_uInt16>(nSize), RES_UL_SPACE));
+ NewAttr(m_xAttrTab, &m_xAttrTab->pULSpace, SvxULSpaceItem(0, o3tl::narrowing<sal_uInt16>(nSize), RES_UL_SPACE));
EndAttr( m_xAttrTab->pULSpace, false );
AppendTextNode(); // Don't change spacing!
@@ -4992,14 +5047,9 @@ void SwHTMLParser::InsertSpacer()
// If the paragraph is still empty, set first line
// indentation, otherwise apply letter spacing over a space.
- if (Application::GetDefaultDevice())
- {
- nSize = Application::GetDefaultDevice()
- ->PixelToLogic( Size(nSize,0),
- MapMode(MapUnit::MapTwip) ).Width();
- }
+ nSize = o3tl::convert(nSize, o3tl::Length::px, o3tl::Length::twip);
- if( !m_pPam->GetPoint()->nContent.GetIndex() )
+ if( !m_pPam->GetPoint()->GetContentIndex() )
{
sal_uInt16 nLeft=0, nRight=0;
short nIndent = 0;
@@ -5007,13 +5057,16 @@ void SwHTMLParser::InsertSpacer()
GetMarginsFromContextWithNumberBullet( nLeft, nRight, nIndent );
nIndent = nIndent + static_cast<short>(nSize);
- SvxLRSpaceItem aLRItem( RES_LR_SPACE );
- aLRItem.SetTextLeft( nLeft );
- aLRItem.SetRight( nRight );
- aLRItem.SetTextFirstLineOffset( nIndent );
+ SvxFirstLineIndentItem const firstLine(nIndent, RES_MARGIN_FIRSTLINE);
+ SvxTextLeftMarginItem const leftMargin(nLeft, RES_MARGIN_TEXTLEFT);
+ SvxRightMarginItem const rightMargin(nRight, RES_MARGIN_RIGHT);
- NewAttr(m_xAttrTab, &m_xAttrTab->pLRSpace, aLRItem);
- EndAttr( m_xAttrTab->pLRSpace, false );
+ NewAttr(m_xAttrTab, &m_xAttrTab->pFirstLineIndent, firstLine);
+ EndAttr(m_xAttrTab->pFirstLineIndent, false);
+ NewAttr(m_xAttrTab, &m_xAttrTab->pTextLeftMargin, leftMargin);
+ EndAttr(m_xAttrTab->pTextLeftMargin, false);
+ NewAttr(m_xAttrTab, &m_xAttrTab->pRightMargin, rightMargin);
+ EndAttr(m_xAttrTab->pRightMargin, false);
}
else
{
@@ -5027,14 +5080,8 @@ void SwHTMLParser::InsertSpacer()
sal_uInt16 SwHTMLParser::ToTwips( sal_uInt16 nPixel )
{
- if( nPixel && Application::GetDefaultDevice() )
- {
- SwTwips nTwips = Application::GetDefaultDevice()->PixelToLogic(
- Size( nPixel, nPixel ), MapMode( MapUnit::MapTwip ) ).Width();
- return static_cast<sal_uInt16>(std::min(nTwips, SwTwips(SAL_MAX_UINT16)));
- }
- else
- return nPixel;
+ return std::min(o3tl::convert(nPixel, o3tl::Length::px, o3tl::Length::twip),
+ sal_Int64(SAL_MAX_UINT16));
}
SwTwips SwHTMLParser::GetCurrentBrowseWidth()
@@ -5082,21 +5129,8 @@ void SwHTMLParser::InsertIDOption()
void SwHTMLParser::InsertLineBreak()
{
- // <BR CLEAR=xxx> is handled as:
- // 1.) Only regard the paragraph-bound frames anchored in current paragraph.
- // 2.) For left-justified aligned frames, CLEAR=LEFT or ALL, and for right-
- // justified aligned frames, CLEAR=RIGHT or ALL, the wrap-through is
- // changed as following:
- // 3.) If the paragraph contains no text, then the frames don't get a wrapping
- // 4.) otherwise a left aligned frame gets a right "only anchor" wrapping
- // and a right aligned frame gets a left "only anchor" wrapping.
- // 5.) if in a non-empty paragraph the wrapping of a frame is changed,
- // then a new paragraph is opened
- // 6.) If no wrappings of frames are changed, a hard line break is inserted.
-
OUString aId, aStyle, aClass; // the id of bookmark
- bool bClearLeft = false, bClearRight = false;
- bool bCleared = false; // Was a CLEAR executed?
+ SwLineBreakClear eClear = SwLineBreakClear::NONE;
// then we fetch the options
const HTMLOptions& rHTMLOptions = GetOptions();
@@ -5110,13 +5144,16 @@ void SwHTMLParser::InsertLineBreak()
const OUString &rClear = rOption.GetString();
if( rClear.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_AL_all ) )
{
- bClearLeft = true;
- bClearRight = true;
+ eClear = SwLineBreakClear::ALL;
}
else if( rClear.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_AL_left ) )
- bClearLeft = true;
+ {
+ eClear = SwLineBreakClear::LEFT;
+ }
else if( rClear.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_AL_right ) )
- bClearRight = true;
+ {
+ eClear = SwLineBreakClear::LEFT;
+ }
}
break;
case HtmlOptionId::ID:
@@ -5132,57 +5169,6 @@ void SwHTMLParser::InsertLineBreak()
}
}
- // CLEAR is only supported for the current paragraph
- if( bClearLeft || bClearRight )
- {
- SwNodeIndex& rNodeIdx = m_pPam->GetPoint()->nNode;
- SwTextNode* pTextNd = rNodeIdx.GetNode().GetTextNode();
- if( pTextNd )
- {
- const SwFrameFormats& rFrameFormatTable = *m_xDoc->GetSpzFrameFormats();
-
- for( size_t i=0; i<rFrameFormatTable.size(); i++ )
- {
- SwFrameFormat *const pFormat = rFrameFormatTable[i];
- SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor();
- SwPosition const*const pAPos = pAnchor->GetContentAnchor();
- if (pAPos &&
- ((RndStdIds::FLY_AT_PARA == pAnchor->GetAnchorId()) ||
- (RndStdIds::FLY_AT_CHAR == pAnchor->GetAnchorId())) &&
- pAPos->nNode == rNodeIdx &&
- pFormat->GetSurround().GetSurround() != css::text::WrapTextMode_NONE )
- {
- sal_Int16 eHori = RES_DRAWFRMFMT == pFormat->Which()
- ? text::HoriOrientation::LEFT
- : pFormat->GetHoriOrient().GetHoriOrient();
-
- css::text::WrapTextMode eSurround = css::text::WrapTextMode_PARALLEL;
- if( m_pPam->GetPoint()->nContent.GetIndex() )
- {
- if( bClearLeft && text::HoriOrientation::LEFT==eHori )
- eSurround = css::text::WrapTextMode_RIGHT;
- else if( bClearRight && text::HoriOrientation::RIGHT==eHori )
- eSurround = css::text::WrapTextMode_LEFT;
- }
- else if( (bClearLeft && text::HoriOrientation::LEFT==eHori) ||
- (bClearRight && text::HoriOrientation::RIGHT==eHori) )
- {
- eSurround = css::text::WrapTextMode_NONE;
- }
-
- if( css::text::WrapTextMode_PARALLEL != eSurround )
- {
- SwFormatSurround aSurround( eSurround );
- if( css::text::WrapTextMode_NONE != eSurround )
- aSurround.SetAnchorOnly( true );
- pFormat->SetFormatAttr( aSurround );
- bCleared = true;
- }
- }
- }
- }
- }
-
// parse styles
std::shared_ptr<SvxFormatBreakItem> aBreakItem(std::make_shared<SvxFormatBreakItem>(SvxBreak::NONE, RES_BREAK));
bool bBreakItem = false;
@@ -5209,12 +5195,26 @@ void SwHTMLParser::InsertLineBreak()
EndAttr( m_xAttrTab->pBreak, false );
}
- if( !bCleared && !bBreakItem )
+ if (!bBreakItem)
{
- // If no CLEAR could or should be executed, a line break will be inserted
- m_xDoc->getIDocumentContentOperations().InsertString( *m_pPam, "\x0A" );
+ if (eClear == SwLineBreakClear::NONE)
+ {
+ // If no CLEAR could or should be executed, a line break will be inserted
+ m_xDoc->getIDocumentContentOperations().InsertString(*m_pPam, "\x0A");
+ }
+ else
+ {
+ // <BR CLEAR=xxx> is mapped an SwFormatLineBreak.
+ SwTextNode* pTextNode = m_pPam->GetPointNode().GetTextNode();
+ if (pTextNode)
+ {
+ SwFormatLineBreak aLineBreak(eClear);
+ sal_Int32 nPos = m_pPam->GetPoint()->GetContentIndex();
+ pTextNode->InsertItem(aLineBreak, nPos, nPos);
+ }
+ }
}
- else if( m_pPam->GetPoint()->nContent.GetIndex() )
+ else if( m_pPam->GetPoint()->GetContentIndex() )
{
// If a CLEAR is executed in a non-empty paragraph, then after it
// a new paragraph has to be opened.
@@ -5255,11 +5255,11 @@ void SwHTMLParser::InsertHorzRule()
aId = rOption.GetString();
break;
case HtmlOptionId::SIZE:
- nSize = static_cast<sal_uInt16>(rOption.GetNumber());
+ nSize = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
break;
case HtmlOptionId::WIDTH:
bPercentWidth = (rOption.GetString().indexOf('%') != -1);
- nWidth = static_cast<sal_uInt16>(rOption.GetNumber());
+ nWidth = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
if( bPercentWidth && nWidth>=100 )
{
// the default case are 100% lines (no attributes necessary)
@@ -5281,7 +5281,7 @@ void SwHTMLParser::InsertHorzRule()
}
}
- if( m_pPam->GetPoint()->nContent.GetIndex() )
+ if( m_pPam->GetPoint()->GetContentIndex() )
AppendTextNode( AM_NOSPACE );
if( m_nOpenParaToken != HtmlTokenId::NONE )
EndPara();
@@ -5320,12 +5320,12 @@ void SwHTMLParser::InsertHorzRule()
}
else if( bNoShade )
{
- aBorderLine.SetWidth( DEF_LINE_WIDTH_2 );
+ aBorderLine.SetWidth( SvxBorderLineWidth::Medium );
}
else
{
aBorderLine.SetBorderLineStyle(SvxBorderLineStyle::DOUBLE);
- aBorderLine.SetWidth( DEF_LINE_WIDTH_0 );
+ aBorderLine.SetWidth(SvxBorderLineWidth::Hairline);
}
SvxBoxItem aBoxItem(RES_BOX);
@@ -5343,35 +5343,44 @@ void SwHTMLParser::InsertHorzRule()
{
// fake length and alignment of line above paragraph indents
tools::Long nBrowseWidth = GetCurrentBrowseWidth();
- nWidth = bPercentWidth ? static_cast<sal_uInt16>((nWidth*nBrowseWidth) / 100)
- : ToTwips( static_cast<sal_uInt16>(nBrowseWidth) );
+ nWidth = bPercentWidth ? o3tl::narrowing<sal_uInt16>((nWidth*nBrowseWidth) / 100)
+ : ToTwips( o3tl::narrowing<sal_uInt16>(nBrowseWidth) );
if( nWidth < MINLAY )
nWidth = MINLAY;
const SwFormatColl *pColl = (static_cast<tools::Long>(nWidth) < nBrowseWidth) ? GetCurrFormatColl() : nullptr;
if (pColl)
{
- SvxLRSpaceItem aLRItem( pColl->GetLRSpace() );
tools::Long nDist = nBrowseWidth - nWidth;
+ ::std::optional<SvxTextLeftMarginItem> oLeft;
+ ::std::optional<SvxRightMarginItem> oRight;
switch( eAdjust )
{
case SvxAdjust::Right:
- aLRItem.SetTextLeft( static_cast<sal_uInt16>(nDist) );
+ oLeft.emplace(o3tl::narrowing<sal_uInt16>(nDist), RES_MARGIN_TEXTLEFT);
break;
case SvxAdjust::Left:
- aLRItem.SetRight( static_cast<sal_uInt16>(nDist) );
+ oRight.emplace(o3tl::narrowing<sal_uInt16>(nDist), RES_MARGIN_RIGHT);
break;
case SvxAdjust::Center:
default:
nDist /= 2;
- aLRItem.SetTextLeft( static_cast<sal_uInt16>(nDist) );
- aLRItem.SetRight( static_cast<sal_uInt16>(nDist) );
+ oLeft.emplace(o3tl::narrowing<sal_uInt16>(nDist), RES_MARGIN_TEXTLEFT);
+ oRight.emplace(o3tl::narrowing<sal_uInt16>(nDist), RES_MARGIN_RIGHT);
break;
}
- HTMLAttr* pTmp = new HTMLAttr(*m_pPam->GetPoint(), aLRItem, nullptr, std::shared_ptr<HTMLAttrTable>());
- m_aSetAttrTab.push_back( pTmp );
+ if (oLeft)
+ {
+ HTMLAttr* pTmp = new HTMLAttr(*m_pPam->GetPoint(), *oLeft, nullptr, std::shared_ptr<HTMLAttrTable>());
+ m_aSetAttrTab.push_back( pTmp );
+ }
+ if (oRight)
+ {
+ HTMLAttr* pTmp = new HTMLAttr(*m_pPam->GetPoint(), *oRight, nullptr, std::shared_ptr<HTMLAttrTable>());
+ m_aSetAttrTab.push_back( pTmp );
+ }
}
}
}
@@ -5440,21 +5449,21 @@ void SwHTMLParser::ParseMoreMetaOptions()
return;
}
- OUStringBuffer sText;
- sText.append("HTML: <");
- sText.append(OOO_STRING_SVTOOLS_HTML_meta);
- sText.append(' ');
+ OUStringBuffer sText(
+ "HTML: <"
+ OOO_STRING_SVTOOLS_HTML_meta
+ " ");
if( bHTTPEquiv )
sText.append(OOO_STRING_SVTOOLS_HTML_O_httpequiv);
else
sText.append(OOO_STRING_SVTOOLS_HTML_O_name);
- sText.append("=\"");
- sText.append(aName);
- sText.append("\" ");
- sText.append(OOO_STRING_SVTOOLS_HTML_O_content);
- sText.append("=\"");
- sText.append(aContent);
- sText.append("\">");
+ sText.append(
+ "=\"" + aName
+ + "\" "
+ OOO_STRING_SVTOOLS_HTML_O_content
+ "=\""
+ + aContent
+ + "\">");
SwPostItField aPostItField(
static_cast<SwPostItFieldType*>(m_xDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Postit )),
@@ -5464,24 +5473,24 @@ void SwHTMLParser::ParseMoreMetaOptions()
}
HTMLAttr::HTMLAttr( const SwPosition& rPos, const SfxPoolItem& rItem,
- HTMLAttr **ppHd, const std::shared_ptr<HTMLAttrTable>& rAttrTab ) :
- m_nStartPara( rPos.nNode ),
- m_nEndPara( rPos.nNode ),
- m_nStartContent( rPos.nContent.GetIndex() ),
- m_nEndContent(rPos.nContent.GetIndex() ),
+ HTMLAttr **ppHd, std::shared_ptr<HTMLAttrTable> xAttrTab ) :
+ m_nStartPara( rPos.GetNode() ),
+ m_nEndPara( rPos.GetNode() ),
+ m_nStartContent( rPos.GetContentIndex() ),
+ m_nEndContent(rPos.GetContentIndex() ),
m_bInsAtStart( true ),
m_bLikePara( false ),
m_bValid( true ),
m_pItem( rItem.Clone() ),
- m_xAttrTab( rAttrTab ),
+ m_xAttrTab(std::move( xAttrTab )),
m_pNext( nullptr ),
m_pPrev( nullptr ),
m_ppHead( ppHd )
{
}
-HTMLAttr::HTMLAttr( const HTMLAttr &rAttr, const SwNodeIndex &rEndPara,
- sal_Int32 nEndCnt, HTMLAttr **ppHd, const std::shared_ptr<HTMLAttrTable>& rAttrTab ) :
+HTMLAttr::HTMLAttr( const HTMLAttr &rAttr, const SwNode &rEndPara,
+ sal_Int32 nEndCnt, HTMLAttr **ppHd, std::shared_ptr<HTMLAttrTable> xAttrTab ) :
m_nStartPara( rAttr.m_nStartPara ),
m_nEndPara( rEndPara ),
m_nStartContent( rAttr.m_nStartContent ),
@@ -5490,7 +5499,7 @@ HTMLAttr::HTMLAttr( const HTMLAttr &rAttr, const SwNodeIndex &rEndPara,
m_bLikePara( rAttr.m_bLikePara ),
m_bValid( rAttr.m_bValid ),
m_pItem( rAttr.m_pItem->Clone() ),
- m_xAttrTab( rAttrTab ),
+ m_xAttrTab(std::move( xAttrTab )),
m_pNext( nullptr ),
m_pPrev( nullptr ),
m_ppHead( ppHd )
@@ -5501,7 +5510,7 @@ HTMLAttr::~HTMLAttr()
{
}
-HTMLAttr *HTMLAttr::Clone(const SwNodeIndex& rEndPara, sal_Int32 nEndCnt) const
+HTMLAttr *HTMLAttr::Clone(const SwNode& rEndPara, sal_Int32 nEndCnt) const
{
// create the attribute anew with old start position
HTMLAttr *pNew = new HTMLAttr( *this, rEndPara, nEndCnt, m_ppHead, m_xAttrTab );
@@ -5512,7 +5521,7 @@ HTMLAttr *HTMLAttr::Clone(const SwNodeIndex& rEndPara, sal_Int32 nEndCnt) const
return pNew;
}
-void HTMLAttr::Reset(const SwNodeIndex& rSttPara, sal_Int32 nSttCnt,
+void HTMLAttr::Reset(const SwNode& rSttPara, sal_Int32 nSttCnt,
HTMLAttr **ppHd, const std::shared_ptr<HTMLAttrTable>& rAttrTab)
{
// reset the start (and the end)
@@ -5581,16 +5590,12 @@ void HTMLReader::SetupFilterOptions()
if (!m_pMedium)
return;
- const SfxItemSet* pItemSet = m_pMedium->GetItemSet();
- if (!pItemSet)
- return;
-
- auto pItem = pItemSet->GetItem<SfxStringItem>(SID_FILE_FILTEROPTIONS);
+ auto pItem = m_pMedium->GetItemSet().GetItem(SID_FILE_FILTEROPTIONS);
if (!pItem)
return;
OUString aFilterOptions = pItem->GetValue();
- const OUString aXhtmlNsKey("xhtmlns=");
+ static constexpr OUString aXhtmlNsKey(u"xhtmlns="_ustr);
if (aFilterOptions.startsWith(aXhtmlNsKey))
{
OUString aNamespace = aFilterOptions.copy(aXhtmlNsKey.getLength());
@@ -5613,8 +5618,8 @@ namespace
bool TestImportHTML(SvStream &rStream)
{
FontCacheGuard aFontCacheGuard;
- std::unique_ptr<Reader> xReader(new HTMLReader);
- xReader->m_pStream = &rStream;
+ HTMLReader aReader;
+ aReader.m_pStream = &rStream;
SwGlobals::ensure();
@@ -5622,13 +5627,12 @@ bool TestImportHTML(SvStream &rStream)
xDocSh->DoInitNew();
SwDoc *pD = static_cast<SwDocShell*>((&xDocSh))->GetDoc();
- SwNodeIndex aIdx(pD->GetNodes().GetEndOfContent(), -1);
- SwPaM aPaM(aIdx);
+ SwPaM aPaM(pD->GetNodes().GetEndOfContent(), SwNodeOffset(-1));
pD->SetInReading(true);
bool bRet = false;
try
{
- bRet = xReader->Read(*pD, OUString(), aPaM, OUString()) == ERRCODE_NONE;
+ bRet = aReader.Read(*pD, OUString(), aPaM, OUString()) == ERRCODE_NONE;
}
catch (const std::runtime_error&)
{
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index 0f4809e23558..33f03ecf3fc3 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -28,13 +28,17 @@
#include <editeng/svxenum.hxx>
#include <rtl/ref.hxx>
#include <rtl/ustrbuf.hxx>
+#include <deletelistener.hxx>
+#include <fmtftn.hxx>
#include <fltshell.hxx>
#include <swtypes.hxx>
+#include <txtftn.hxx>
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/form/XFormComponent.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <memory>
+#include <utility>
#include <vector>
#include <deque>
#include <stack>
@@ -58,11 +62,11 @@ struct SwPending;
class SvxCSS1PropertyInfo;
struct ImplSVEvent;
-#define HTML_CJK_PARSPACE (MM50/2)
-#define HTML_CTL_PARSPACE (MM50/2)
+constexpr tools::Long HTML_CJK_PARSPACE = o3tl::toTwips(25, o3tl::Length::mm10); // 2.5mm
+constexpr tools::Long HTML_CTL_PARSPACE = o3tl::toTwips(25, o3tl::Length::mm10); // 2.5mm
-#define HTML_DFLT_IMG_WIDTH (MM50*4)
-#define HTML_DFLT_IMG_HEIGHT (MM50*2)
+constexpr tools::Long HTML_DFLT_IMG_WIDTH = o3tl::toTwips(2, o3tl::Length::cm); // 2cm
+constexpr tools::Long HTML_DFLT_IMG_HEIGHT = o3tl::toTwips(1, o3tl::Length::cm); // 1cm
// some things you often need
extern HTMLOptionEnum<SvxAdjust> const aHTMLPAlignTable[];
@@ -78,51 +82,51 @@ typedef std::deque<HTMLAttr *> HTMLAttrs;
// beginning of the table will set first in EndAllAttrs.
struct HTMLAttrTable
{
- HTMLAttr
- *pKeep, // frame attributes
- *pBox,
- *pBrush,
- *pBreak,
- *pPageDesc,
-
- *pLRSpace, // paragraph attributes
- *pULSpace,
- *pLineSpacing,
- *pAdjust,
- *pDropCap,
- *pSplit,
- *pWidows,
- *pOrphans,
- *pDirection,
-
- *pCharFormats, // text attributes
- *pINetFormat,
-
- *pBold, // character attributes
- *pBoldCJK,
- *pBoldCTL,
- *pItalic,
- *pItalicCJK,
- *pItalicCTL,
- *pStrike,
- *pUnderline,
- *pBlink,
- *pFont,
- *pFontCJK,
- *pFontCTL,
- *pFontHeight,
- *pFontHeightCJK,
- *pFontHeightCTL,
- *pFontColor,
- *pEscapement,
- *pCaseMap,
- *pKerning, // (only for SPACER)
- *pCharBrush, // character background
- *pLanguage,
- *pLanguageCJK,
- *pLanguageCTL,
- *pCharBox
- ;
+ HTMLAttr* pKeep; // frame attributes
+ HTMLAttr* pBox;
+ HTMLAttr* pBrush;
+ HTMLAttr* pBreak;
+ HTMLAttr* pPageDesc;
+
+ HTMLAttr* pFirstLineIndent; // paragraph attributes
+ HTMLAttr* pTextLeftMargin;
+ HTMLAttr* pRightMargin;
+ HTMLAttr* pULSpace;
+ HTMLAttr* pLineSpacing;
+ HTMLAttr* pAdjust;
+ HTMLAttr* pDropCap;
+ HTMLAttr* pSplit;
+ HTMLAttr* pWidows;
+ HTMLAttr* pOrphans;
+ HTMLAttr* pDirection;
+
+ HTMLAttr* pCharFormats; // text attributes
+ HTMLAttr* pINetFormat;
+
+ HTMLAttr* pBold; // character attributes
+ HTMLAttr* pBoldCJK;
+ HTMLAttr* pBoldCTL;
+ HTMLAttr* pItalic;
+ HTMLAttr* pItalicCJK;
+ HTMLAttr* pItalicCTL;
+ HTMLAttr* pStrike;
+ HTMLAttr* pUnderline;
+ HTMLAttr* pBlink;
+ HTMLAttr* pFont;
+ HTMLAttr* pFontCJK;
+ HTMLAttr* pFontCTL;
+ HTMLAttr* pFontHeight;
+ HTMLAttr* pFontHeightCJK;
+ HTMLAttr* pFontHeightCTL;
+ HTMLAttr* pFontColor;
+ HTMLAttr* pEscapement;
+ HTMLAttr* pCaseMap;
+ HTMLAttr* pKerning; // (only for SPACER)
+ HTMLAttr* pCharBrush; // character background
+ HTMLAttr* pLanguage;
+ HTMLAttr* pLanguageCJK;
+ HTMLAttr* pLanguageCTL;
+ HTMLAttr* pCharBox;
};
class HTMLAttr
@@ -130,8 +134,10 @@ class HTMLAttr
friend class SwHTMLParser;
friend class CellSaveStruct;
- SwNodeIndex m_nStartPara, m_nEndPara;
- sal_Int32 m_nStartContent, m_nEndContent;
+ SwNodeIndex m_nStartPara;
+ SwNodeIndex m_nEndPara;
+ sal_Int32 m_nStartContent;
+ sal_Int32 m_nEndContent;
bool m_bInsAtStart : 1;
bool m_bLikePara : 1; // set attribute above the whole paragraph
bool m_bValid : 1; // is the attribute valid?
@@ -143,28 +149,28 @@ class HTMLAttr
HTMLAttr **m_ppHead; // list head
HTMLAttr( const SwPosition& rPos, const SfxPoolItem& rItem,
- HTMLAttr **pHd, const std::shared_ptr<HTMLAttrTable>& rAttrTab );
+ HTMLAttr **pHd, std::shared_ptr<HTMLAttrTable> xAttrTab );
- HTMLAttr( const HTMLAttr &rAttr, const SwNodeIndex &rEndPara,
- sal_Int32 nEndCnt, HTMLAttr **pHd, const std::shared_ptr<HTMLAttrTable>& rAttrTab );
+ HTMLAttr( const HTMLAttr &rAttr, const SwNode &rEndPara,
+ sal_Int32 nEndCnt, HTMLAttr **pHd, std::shared_ptr<HTMLAttrTable> xAttrTab );
public:
~HTMLAttr();
- HTMLAttr *Clone( const SwNodeIndex& rEndPara, sal_Int32 nEndCnt ) const;
- void Reset( const SwNodeIndex& rSttPara, sal_Int32 nSttCnt,
+ HTMLAttr *Clone( const SwNode& rEndPara, sal_Int32 nEndCnt ) const;
+ void Reset( const SwNode& rSttPara, sal_Int32 nSttCnt,
HTMLAttr **pHd, const std::shared_ptr<HTMLAttrTable>& rAttrTab );
inline void SetStart( const SwPosition& rPos );
- sal_uInt32 GetSttParaIdx() const { return m_nStartPara.GetIndex(); }
- sal_uInt32 GetEndParaIdx() const { return m_nEndPara.GetIndex(); }
+ SwNodeOffset GetStartParagraphIdx() const { return m_nStartPara.GetIndex(); }
+ SwNodeOffset GetEndParagraphIdx() const { return m_nEndPara.GetIndex(); }
- const SwNodeIndex& GetSttPara() const { return m_nStartPara; }
- const SwNodeIndex& GetEndPara() const { return m_nEndPara; }
+ const SwNodeIndex& GetStartParagraph() const { return m_nStartPara; }
+ const SwNodeIndex& GetEndParagraph() const { return m_nEndPara; }
- sal_Int32 GetSttCnt() const { return m_nStartContent; }
- sal_Int32 GetEndCnt() const { return m_nEndContent; }
+ sal_Int32 GetStartContent() const { return m_nStartContent; }
+ sal_Int32 GetEndContent() const { return m_nEndContent; }
bool IsLikePara() const { return m_bLikePara; }
void SetLikePara() { m_bLikePara = true; }
@@ -211,9 +217,9 @@ class HTMLAttrContext
std::unique_ptr<HTMLAttrContext_SaveDoc> m_pSaveDocContext;
std::unique_ptr<SfxItemSet> m_pFrameItemSet;
- HtmlTokenId m_nToken; // the token of the context
+ HtmlTokenId m_nToken; // the token of the context
- sal_uInt16 m_nTextFormatColl; // a style created in the context or zero
+ sal_uInt16 m_nTextFormatColl; // a style created in the context or zero
sal_uInt16 m_nLeftMargin; // a changed left border
sal_uInt16 m_nRightMargin; // a changed right border
@@ -240,7 +246,7 @@ class HTMLAttrContext
public:
void ClearSaveDocContext();
- HTMLAttrContext( HtmlTokenId nTokn, sal_uInt16 nPoolId, const OUString& rClass,
+ HTMLAttrContext( HtmlTokenId nTokn, sal_uInt16 nPoolId, OUString aClass,
bool bDfltColl=false );
explicit HTMLAttrContext( HtmlTokenId nTokn );
~HTMLAttrContext();
@@ -248,7 +254,7 @@ public:
HtmlTokenId GetToken() const { return m_nToken; }
sal_uInt16 GetTextFormatColl() const { return m_bDefaultTextFormatColl ? 0 : m_nTextFormatColl; }
- sal_uInt16 GetDfltTextFormatColl() const { return m_bDefaultTextFormatColl ? m_nTextFormatColl : 0; }
+ sal_uInt16 GetDefaultTextFormatColl() const { return m_bDefaultTextFormatColl ? m_nTextFormatColl : 0; }
const OUString& GetClass() const { return m_aClass; }
@@ -397,7 +403,7 @@ class SwHTMLParser : public SfxHTMLParser, public SvtListener
std::vector<HTMLTable*> m_aTables;
std::shared_ptr<HTMLTable> m_xTable; // current "outermost" table
SwHTMLForm_Impl* m_pFormImpl; // current form
- SdrObject *m_pMarquee; // current marquee
+ rtl::Reference<SdrTextObj> m_pMarquee; // current marquee
std::unique_ptr<SwField> m_xField; // current field
ImageMap *m_pImageMap; // current image map
std::unique_ptr<ImageMaps> m_pImageMaps; ///< all Image-Maps that have been read
@@ -432,7 +438,7 @@ class SwHTMLParser : public SfxHTMLParser, public SvtListener
bool m_bOldIsHTMLMode : 1; // Was it a HTML document?
- bool m_bDocInitalized : 1; // document resp. shell was initialize
+ bool m_bDocInitialized : 1; // document resp. shell was initialize
// flag to prevent double init via recursion
bool m_bViewCreated : 1; // the view was already created (asynchronous)
bool m_bSetModEnabled : 1;
@@ -471,7 +477,9 @@ class SwHTMLParser : public SfxHTMLParser, public SvtListener
bool m_bNotifyMacroEventRead : 1;
bool m_isInTableStructure;
- sal_Int32 m_nTableDepth;
+ int m_nTableDepth;
+ int m_nFloatingFrames;
+ int m_nListItems;
/// the names corresponding to the DOCINFO field subtypes INFO[1-4]
OUString m_InfoNames[4];
@@ -489,6 +497,9 @@ class SwHTMLParser : public SfxHTMLParser, public SvtListener
std::set<OUString> m_aAllowedRTFOLEMimeTypes;
+ /// This is the URL of the outer <object> data if it's not OLE2 or an image.
+ OUString m_aEmbedURL;
+
void DeleteFormImpl();
void DocumentDetected();
@@ -533,7 +544,7 @@ class SwHTMLParser : public SfxHTMLParser, public SvtListener
bool DoPositioning( SfxItemSet &rItemSet,
SvxCSS1PropertyInfo &rPropInfo,
HTMLAttrContext *pContext );
- bool CreateContainer( const OUString& rClass, SfxItemSet &rItemSet,
+ bool CreateContainer( std::u16string_view rClass, SfxItemSet &rItemSet,
SvxCSS1PropertyInfo &rPropInfo,
HTMLAttrContext *pContext );
bool EndSection( bool bLFStripped=false );
@@ -581,7 +592,7 @@ class SwHTMLParser : public SfxHTMLParser, public SvtListener
short& nIndent ) const;
void GetULSpaceFromContext( sal_uInt16 &rUpper, sal_uInt16 &rLower ) const;
- void MovePageDescAttrs( SwNode *pSrcNd, sal_uLong nDestIdx, bool bFormatBreak );
+ void MovePageDescAttrs( SwNode *pSrcNd, SwNodeOffset nDestIdx, bool bFormatBreak );
// Handling of tags at paragraph level
@@ -652,13 +663,11 @@ class SwHTMLParser : public SfxHTMLParser, public SvtListener
// tags realized via character styles
void NewCharFormat( HtmlTokenId nToken );
- void ClearFootnotesMarksInRange(const SwNodeIndex& rSttIdx, const SwNodeIndex& rEndIdx);
-
void DeleteSection(SwStartNode* pSttNd);
// <SDFIELD>
public:
- static SvxNumType GetNumType( const OUString& rStr, SvxNumType eDfltType );
+ static SvxNumType GetNumType( std::u16string_view rStr, SvxNumType eDfltType );
private:
void NewField();
void EndField();
@@ -670,7 +679,7 @@ private:
// Inserting graphics, plug-ins and applets
// search image maps and link with graphic nodes
- ImageMap *FindImageMap( const OUString& rURL ) const;
+ ImageMap *FindImageMap( std::u16string_view rURL ) const;
void ConnectImageMaps();
// find anchor of Fly-Frames and set corresponding attributes
@@ -737,8 +746,8 @@ private:
// insert bookmark
void InsertBookmark( const OUString& rName );
- void InsertCommentText( const char *pTag );
- void InsertComment( const OUString& rName, const char *pTag = nullptr );
+ void InsertCommentText( std::string_view pTag );
+ void InsertComment( const OUString& rName, std::string_view pTag = {} );
// Has the current paragraph bookmarks?
bool HasCurrentParaBookmarks( bool bIgnoreStack=false ) const;
@@ -853,8 +862,8 @@ private:
void InsertLineBreak();
void InsertHorzRule();
- void FillEndNoteInfo( const OUString& rContent );
- void FillFootNoteInfo( const OUString& rContent );
+ void FillEndNoteInfo( std::u16string_view aContent );
+ void FillFootNoteInfo( std::u16string_view aContent );
void InsertFootEndNote( const OUString& rName, bool bEndNote, bool bFixed );
void FinishFootEndNote();
void InsertFootEndNoteText();
@@ -865,14 +874,12 @@ private:
// Remove empty paragraph at the PaM position
void StripTrailingPara();
// If removing an empty node would corrupt the document
- bool CanRemoveNode(sal_uLong nNodeIdx) const;
+ bool CanRemoveNode(SwNodeOffset nNodeIdx) const;
// Are there fly frames in the current paragraph?
bool HasCurrentParaFlys( bool bNoSurroundOnly = false,
bool bSurroundOnly = false ) const;
- bool PendingObjectsInPaM(SwPaM& rPam) const;
-
class TableDepthGuard
{
private:
@@ -912,8 +919,8 @@ protected:
public:
SwHTMLParser( SwDoc* pD, SwPaM & rCursor, SvStream& rIn,
- const OUString& rFileName,
- const OUString& rBaseURL,
+ OUString aFileName,
+ OUString aBaseURL,
bool bReadNewDoc,
SfxMedium* pMed, bool bReadUTF8,
bool bIgnoreHTMLComments,
@@ -946,7 +953,7 @@ public:
void NotifyMacroEventRead();
/// Strips query and fragment from a URL path if base URL is a file:// one.
- static OUString StripQueryFromPath(const OUString& rBase, const OUString& rPath);
+ static OUString StripQueryFromPath(std::u16string_view rBase, const OUString& rPath);
};
struct SwPendingData
@@ -966,8 +973,8 @@ struct SwPending
inline void HTMLAttr::SetStart( const SwPosition& rPos )
{
- m_nStartPara = rPos.nNode;
- m_nStartContent = rPos.nContent.GetIndex();
+ m_nStartPara = rPos.GetNode();
+ m_nStartContent = rPos.GetContentIndex();
m_nEndPara = m_nStartPara;
m_nEndContent = m_nStartContent;
}
@@ -1022,14 +1029,28 @@ inline bool SwHTMLParser::HasStyleOptions( std::u16string_view rStyle,
class SwTextFootnote;
-struct SwHTMLTextFootnote
+class SwHTMLTextFootnote
{
- OUString sName;
- SwTextFootnote* pTextFootnote;
- SwHTMLTextFootnote(const OUString &rName, SwTextFootnote* pInTextFootnote)
- : sName(rName)
- , pTextFootnote(pInTextFootnote)
+private:
+ OUString m_sName;
+ SwTextFootnote* m_pTextFootnote;
+ std::unique_ptr<SvtDeleteListener> m_xDeleteListener;
+public:
+ SwHTMLTextFootnote(OUString rName, SwTextFootnote* pInTextFootnote)
+ : m_sName(std::move(rName))
+ , m_pTextFootnote(pInTextFootnote)
+ , m_xDeleteListener(new SvtDeleteListener(static_cast<SwFormatFootnote&>(pInTextFootnote->GetAttr()).GetNotifier()))
+ {
+ }
+ const OUString& GetName() const
+ {
+ return m_sName;
+ }
+ const SwNodeIndex* GetStartNode() const
{
+ if (m_xDeleteListener->WasDeleted())
+ return nullptr;
+ return m_pTextFootnote->GetStartNode();
}
};
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index 741448d96f7f..093cef850614 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -82,6 +82,10 @@
#include <comphelper/scopeguard.hxx>
#include <unotools/tempfile.hxx>
#include <comphelper/sequenceashashmap.hxx>
+#include <officecfg/Office/Common.hxx>
+#include <officecfg/Office/Writer.hxx>
+#include <comphelper/propertysequence.hxx>
+#include <comphelper/sequence.hxx>
#define MAX_INDENT_LEVEL 20
@@ -90,11 +94,10 @@ using namespace css;
static char sIndentTabs[MAX_INDENT_LEVEL+2] =
"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
-SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL, const OUString& rFilterOptions )
+SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL, std::u16string_view rFilterOptions )
: m_pNumRuleInfo(new SwHTMLNumRuleInfo)
, m_nHTMLMode(0)
, m_eCSS1Unit(FieldUnit::NONE)
- , mxFormComps()
, m_pStartNdIdx(nullptr)
, m_pCurrPageDesc(nullptr)
, m_pFormatFootnote(nullptr)
@@ -114,7 +117,7 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL, const OUString& rFilterOpt
, m_nDfltTopMargin(0)
, m_nDfltBottomMargin(0)
, m_nIndentLvl(0)
- , m_nWishLineLen(0)
+ , m_nWishLineLen(70)
, m_nDefListLvl(0)
, m_nDefListMargin(0)
, m_nHeaderFooterSpace(0)
@@ -123,7 +126,6 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL, const OUString& rFilterOpt
, m_nCSS1OutMode(0)
, m_nCSS1Script(CSS1_OUTMODE_WESTERN)
, m_nDirection(SvxFrameDirection::Horizontal_LR_TB)
- , m_eDestEnc(RTL_TEXTENCODING_MS_1252)
, m_eLang(LANGUAGE_DONTKNOW)
, m_bCfgOutStyles( false )
, m_bCfgPreferStyles( false )
@@ -144,7 +146,6 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL, const OUString& rFilterOpt
, m_bNoAlign( false )
, m_bClearLeft( false )
, m_bClearRight( false )
- , m_bLFPossible( false )
, m_bPreserveForm( false )
, m_bCfgNetscape4( false )
, mbSkipImages(false)
@@ -158,7 +159,7 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL, const OUString& rFilterOpt
if (rBaseURL.isEmpty())
{
// Paste: set base URL to a tempfile, so images are not lost.
- mpTempBaseURL.reset(new utl::TempFile());
+ mpTempBaseURL.reset(new utl::TempFileNamed());
mpTempBaseURL->EnableKillingFile();
SetBaseURL(mpTempBaseURL->GetURL());
}
@@ -182,66 +183,191 @@ std::unique_ptr<SwHTMLNumRuleInfo> SwHTMLWriter::ReleaseNextNumInfo()
void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium)
{
- const SfxItemSet* pSet = rMedium.GetItemSet();
- if (pSet == nullptr)
- return;
-
- const SfxPoolItem* pItem;
- if (pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) != SfxItemState::SET)
- return;
-
+ uno::Sequence<beans::PropertyValue> aArgs = rMedium.GetArgs();
+ if (const SfxStringItem* pItem = rMedium.GetItemSet().GetItemIfSet( SID_FILE_FILTEROPTIONS ))
+ {
+ const OUString sFilterOptions = pItem->GetValue();
- const OUString sFilterOptions = static_cast<const SfxStringItem*>(pItem)->GetValue();
- SetupFilterOptions(sFilterOptions);
+ if (sFilterOptions.startsWith("{"))
+ {
+ std::vector<beans::PropertyValue> aArgsVec
+ = comphelper::JsonToPropertyValues(sFilterOptions.toUtf8());
+ aArgs = comphelper::containerToSequence(aArgsVec);
+ }
- comphelper::SequenceAsHashMap aStoreMap(rMedium.GetArgs());
- auto it = aStoreMap.find("RTFOLEMimeType");
- if (it == aStoreMap.end())
- {
- return;
+ SetupFilterOptions(sFilterOptions);
}
- it->second >>= m_aRTFOLEMimeType;
+ SetupFilterFromPropertyValues(aArgs);
}
-void SwHTMLWriter::SetupFilterOptions(const OUString& rFilterOptions)
+void SwHTMLWriter::SetupFilterOptions(std::u16string_view rFilterOptions)
{
- if (rFilterOptions == "SkipImages")
+ comphelper::SequenceAsHashMap aStoreMap;
+ if (rFilterOptions.find(u"SkipImages") != std::u16string_view::npos)
+ {
+ aStoreMap["SkipImages"] <<= true;
+ }
+ else if (rFilterOptions.find(u"SkipHeaderFooter") != std::u16string_view::npos)
{
- mbSkipImages = true;
+ aStoreMap["SkipHeaderFooter"] <<= true;
}
- else if (rFilterOptions == "SkipHeaderFooter")
+ else if (rFilterOptions.find(u"EmbedImages") != std::u16string_view::npos)
{
- mbSkipHeaderFooter = true;
+ aStoreMap["EmbedImages"] <<= true;
}
- else if (rFilterOptions == "EmbedImages")
+
+ // this option can be "on" together with any of above
+ if (rFilterOptions.find(u"NoLineLimit") != std::u16string_view::npos)
+ {
+ aStoreMap["NoLineLimit"] <<= true;
+ }
+
+ // this option can be "on" together with any of above
+ if (rFilterOptions.find(u"NoPrettyPrint") != std::u16string_view::npos)
{
- mbEmbedImages = true;
+ aStoreMap["NoPrettyPrint"] <<= true;
}
- const uno::Sequence<OUString> aOptionSeq = comphelper::string::convertCommaSeparated(rFilterOptions);
- const OUString aXhtmlNsKey("xhtmlns=");
+ const uno::Sequence<OUString> aOptionSeq
+ = comphelper::string::convertCommaSeparated(rFilterOptions);
+ static constexpr OUString aXhtmlNsKey(u"xhtmlns="_ustr);
for (const auto& rOption : aOptionSeq)
{
if (rOption == "XHTML")
- mbXHTML = true;
+ {
+ aStoreMap["XHTML"] <<= true;
+ }
else if (rOption.startsWith(aXhtmlNsKey))
{
- maNamespace = rOption.copy(aXhtmlNsKey.getLength()).toUtf8();
- if (maNamespace == "reqif-xhtml")
- {
- mbReqIF = true;
- // XHTML is always just a fragment inside ReqIF.
- mbSkipHeaderFooter = true;
- }
- // XHTML namespace implies XHTML.
- mbXHTML = true;
+ aStoreMap["XhtmlNs"] <<= rOption.copy(aXhtmlNsKey.getLength());
}
}
+
+ SetupFilterFromPropertyValues(aStoreMap.getAsConstPropertyValueList());
+}
+
+void SwHTMLWriter::SetupFilterFromPropertyValues(
+ const css::uno::Sequence<css::beans::PropertyValue>& rPropertyValues)
+{
+ comphelper::SequenceAsHashMap aStoreMap(rPropertyValues);
+ auto it = aStoreMap.find("RTFOLEMimeType");
+ if (it != aStoreMap.end())
+ {
+ it->second >>= m_aRTFOLEMimeType;
+ }
+
+ it = aStoreMap.find("ExportImagesAsOLE");
+ if (it != aStoreMap.end())
+ {
+ it->second >>= m_bExportImagesAsOLE;
+ }
+
+ it = aStoreMap.find("ExportFormulasAsPDF");
+ if (it != aStoreMap.end())
+ {
+ it->second >>= m_bExportFormulasAsPDF;
+ }
+
+ it = aStoreMap.find("ShapeDPI");
+ if (it != aStoreMap.end())
+ {
+ sal_Int32 nVal{};
+ it->second >>= nVal;
+ m_nShapeDPI.emplace(nVal);
+ }
+
+ it = aStoreMap.find("SkipImages");
+ if (it != aStoreMap.end())
+ {
+ bool bVal{};
+ it->second >>= bVal;
+ mbSkipImages = bVal;
+ }
+
+ it = aStoreMap.find("SkipHeaderFooter");
+ if (it != aStoreMap.end())
+ {
+ bool bVal{};
+ it->second >>= bVal;
+ mbSkipHeaderFooter = bVal;
+ }
+
+ // this option can be "on" together with any of above
+ it = aStoreMap.find("NoPrettyPrint");
+ if (it != aStoreMap.end())
+ {
+ m_nWishLineLen = -1;
+ m_bPrettyPrint = false;
+ }
+
+ it = aStoreMap.find("EmbedImages");
+ if (it != aStoreMap.end())
+ {
+ bool bVal{};
+ it->second >>= bVal;
+ mbEmbedImages = bVal;
+ }
+
+ it = aStoreMap.find("NoLineLimit");
+ if (it != aStoreMap.end())
+ {
+ bool bVal{};
+ it->second >>= bVal;
+ if (bVal)
+ {
+ m_nWishLineLen = -1;
+ }
+ }
+
+ it = aStoreMap.find("XHTML");
+ if (it != aStoreMap.end())
+ {
+ bool bVal{};
+ it->second >>= bVal;
+ mbXHTML = bVal;
+ }
+
+ it = aStoreMap.find("XhtmlNs");
+ if (it != aStoreMap.end())
+ {
+ OUString aVal;
+ it->second >>= aVal;
+
+ maNamespace = aVal.toUtf8();
+ if (maNamespace == "reqif-xhtml")
+ {
+ mbReqIF = true;
+ // XHTML is always just a fragment inside ReqIF.
+ mbSkipHeaderFooter = true;
+ }
+ // XHTML namespace implies XHTML.
+ mbXHTML = true;
+ }
+
+ it = aStoreMap.find("LeadingTabWidth");
+ if (it != aStoreMap.end())
+ {
+ sal_Int32 nVal{};
+ it->second >>= nVal;
+ m_nLeadingTabWidth.emplace(nVal);
+ }
+
+ it = aStoreMap.find("PreserveSpaces");
+ if (it != aStoreMap.end())
+ {
+ // Paragraphs with leading/trailing/repeated whitespace will have "white-space: pre-wrap"
+ // style; whitespace in content will not be altered (except for "LeadingTabWidth" effects)
+ bool bVal = false;
+ it->second >>= bVal;
+ m_bPreserveSpacesOnWrite = bVal;
+ }
}
ErrCode SwHTMLWriter::WriteStream()
{
+ if (!SW_MOD())
+ return ERRCODE_ABORT;
// Intercept paste output if requested.
char* pPasteEnv = getenv("SW_DEBUG_HTML_PASTE_TO");
std::unique_ptr<SvStream> pPasteStream;
@@ -259,20 +385,18 @@ ErrCode SwHTMLWriter::WriteStream()
}
comphelper::ScopeGuard g([this, pOldPasteStream] { this->SetStream(pOldPasteStream); });
- SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
-
// font heights 1-7
- m_aFontHeights[0] = rHtmlOptions.GetFontSize( 0 ) * 20;
- m_aFontHeights[1] = rHtmlOptions.GetFontSize( 1 ) * 20;
- m_aFontHeights[2] = rHtmlOptions.GetFontSize( 2 ) * 20;
- m_aFontHeights[3] = rHtmlOptions.GetFontSize( 3 ) * 20;
- m_aFontHeights[4] = rHtmlOptions.GetFontSize( 4 ) * 20;
- m_aFontHeights[5] = rHtmlOptions.GetFontSize( 5 ) * 20;
- m_aFontHeights[6] = rHtmlOptions.GetFontSize( 6 ) * 20;
+ m_aFontHeights[0] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_1::get() * 20;
+ m_aFontHeights[1] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_2::get() * 20;
+ m_aFontHeights[2] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_3::get() * 20;
+ m_aFontHeights[3] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_4::get() * 20;
+ m_aFontHeights[4] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_5::get() * 20;
+ m_aFontHeights[5] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_6::get() * 20;
+ m_aFontHeights[6] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_7::get() * 20;
// output styles anyway
// (then also top and bottom paragraph spacing)
- m_nExportMode = rHtmlOptions.GetExportMode();
+ m_nExportMode = SvxHtmlOptions::GetExportMode();
m_nHTMLMode = GetHtmlMode(nullptr);
if( HTML_CFG_WRITER == m_nExportMode || HTML_CFG_NS40 == m_nExportMode )
@@ -284,8 +408,8 @@ ErrCode SwHTMLWriter::WriteStream()
if( HTML_CFG_MSIE == m_nExportMode )
m_nHTMLMode |= HTMLMODE_NBSP_IN_TABLES;
- if( HTML_CFG_WRITER == m_nExportMode || HTML_CFG_NS40 == m_nExportMode || HTML_CFG_MSIE == m_nExportMode )
- m_nHTMLMode |= HTMLMODE_ABS_POS_FLY | HTMLMODE_ABS_POS_DRAW;
+ // For all three of HTML_CFG_WRITER, HTML_CFG_NS40, HTML_CFG_MSIE
+ m_nHTMLMode |= HTMLMODE_ABS_POS_FLY | HTMLMODE_ABS_POS_DRAW;
if( HTML_CFG_WRITER == m_nExportMode )
m_nHTMLMode |= HTMLMODE_FLY_MARGINS;
@@ -306,20 +430,15 @@ ErrCode SwHTMLWriter::WriteStream()
m_eCSS1Unit = SW_MOD()->GetMetric( m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) );
- bool bWriteUTF8 = m_bWriteClipboardDoc;
- m_eDestEnc = bWriteUTF8 ? RTL_TEXTENCODING_UTF8 : rHtmlOptions.GetTextEncoding();
- const char *pCharSet = rtl_getBestMimeCharsetFromTextEncoding( m_eDestEnc );
- m_eDestEnc = rtl_getTextEncodingFromMimeCharset( pCharSet );
-
// Only for the MS-IE we favour the export of styles.
m_bCfgPreferStyles = HTML_CFG_MSIE == m_nExportMode;
- m_bCfgStarBasic = rHtmlOptions.IsStarBasic();
+ m_bCfgStarBasic = officecfg::Office::Common::Filter::HTML::Export::Basic::get();
m_bCfgFormFeed = !IsHTMLMode(HTMLMODE_PRINT_EXT);
- m_bCfgCpyLinkedGrfs = rHtmlOptions.IsSaveGraphicsLocal();
+ m_bCfgCpyLinkedGrfs = officecfg::Office::Common::Filter::HTML::Export::LocalGraphic::get();
- m_bCfgPrintLayout = rHtmlOptions.IsPrintLayoutExtension();
+ m_bCfgPrintLayout = officecfg::Office::Common::Filter::HTML::Export::PrintLayout::get();
// get HTML template
bool bOldHTMLMode = false;
@@ -338,11 +457,11 @@ ErrCode SwHTMLWriter::WriteStream()
}
if( m_bShowProgress )
- ::StartProgress( STR_STATSTR_W4WWRITE, 0, m_pDoc->GetNodes().Count(),
+ ::StartProgress( STR_STATSTR_W4WWRITE, 0, sal_Int32(m_pDoc->GetNodes().Count()),
m_pDoc->GetDocShell());
m_xDfltColor.reset();
- m_pFootEndNotes = nullptr;
+ m_xFootEndNotes.reset();
m_pFormatFootnote = nullptr;
m_bOutTable = m_bOutHeader = m_bOutFooter = m_bOutFlyFrame = false;
mxFormComps.clear();
@@ -350,6 +469,7 @@ ErrCode SwHTMLWriter::WriteStream()
m_bPreserveForm = false;
m_bClearLeft = m_bClearRight = false;
m_bLFPossible = false;
+ m_bSpacePreserve = false;
m_nLeftMargin = m_nDfltLeftMargin = m_nDfltRightMargin = 0;
m_nDfltTopMargin = m_nDfltBottomMargin = 0;
@@ -357,12 +477,11 @@ ErrCode SwHTMLWriter::WriteStream()
m_bFirstCSS1Property = m_bFirstCSS1Rule = false;
m_bCSS1IgnoreFirstPageDesc = false;
m_nIndentLvl = 0;
- m_nWishLineLen = 70;
m_nLastLFPos = 0;
m_nDefListLvl = 0;
m_nDefListMargin = ((m_xTemplate.is() && !m_bCfgOutStyles) ? m_xTemplate.get() : m_pDoc)
->getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_HTML_DD, false )
- ->GetLRSpace().GetTextLeft();
+ ->GetTextLeftMargin().GetTextLeft();
m_nHeaderFooterSpace = 0;
m_nTextAttrsToIgnore = 0;
m_nCSS1OutMode = 0;
@@ -379,8 +498,8 @@ ErrCode SwHTMLWriter::WriteStream()
m_nCSS1Script = CSS1_OUTMODE_WESTERN;
break;
}
- m_eLang = static_cast<const SvxLanguageItem&>(m_pDoc
- ->GetDefault(GetLangWhichIdFromScript(m_nCSS1Script))).GetLanguage();
+ const SvxLanguageItem& rLangitem = m_pDoc->GetDefault(GetLangWhichIdFromScript(m_nCSS1Script));
+ m_eLang = rLangitem.GetLanguage();
m_nFootNote = m_nEndNote = 0;
@@ -392,26 +511,29 @@ ErrCode SwHTMLWriter::WriteStream()
// respect table and section at document beginning
{
- SwTableNode * pTNd = m_pCurrentPam->GetNode().FindTableNode();
- if( pTNd && m_bWriteAll )
+ if (m_bWriteAll)
{
- // start with table node !!
- m_pCurrentPam->GetPoint()->nNode = *pTNd;
+ while (const SwStartNode* pTNd = m_pCurrentPam->GetPointNode().FindTableBoxStartNode())
+ {
+ // start with table node !!
+ m_pCurrentPam->GetPoint()->Assign(*pTNd->FindTableNode());
- if( m_bWriteOnlyFirstTable )
- m_pCurrentPam->GetMark()->nNode = *pTNd->EndOfSectionNode();
+ if (m_bWriteOnlyFirstTable)
+ m_pCurrentPam->GetMark()->Assign(
+ *m_pCurrentPam->GetPointNode().EndOfSectionNode());
+ }
}
- // first node (with can contain a page break)
- m_pStartNdIdx = new SwNodeIndex( m_pCurrentPam->GetPoint()->nNode );
+ // first node (which can contain a page break)
+ m_pStartNdIdx = new SwNodeIndex( m_pCurrentPam->GetPoint()->GetNode() );
- SwSectionNode * pSNd = m_pCurrentPam->GetNode().FindSectionNode();
+ SwSectionNode * pSNd = m_pCurrentPam->GetPointNode().FindSectionNode();
while( pSNd )
{
if( m_bWriteAll )
{
// start with section node !!
- m_pCurrentPam->GetPoint()->nNode = *pSNd;
+ m_pCurrentPam->GetPoint()->Assign(*pSNd);
}
else
{
@@ -420,8 +542,7 @@ ErrCode SwHTMLWriter::WriteStream()
// save only the tag of section
OString aName = HTMLOutFuncs::ConvertStringToHTML(
- pSNd->GetSection().GetSectionName(), m_eDestEnc,
- &m_aNonConvertableCharacters );
+ pSNd->GetSection().GetSectionName() );
aStartTags =
"<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_division
@@ -436,71 +557,80 @@ ErrCode SwHTMLWriter::WriteStream()
// create table of the floating frames, but only when the whole
// document is saved
- m_pHTMLPosFlyFrames = nullptr;
+ m_aHTMLPosFlyFrames.clear();
CollectFlyFrames();
m_nLastParaToken = HtmlTokenId::NONE;
- GetControls();
- CollectLinkTargets();
- sal_uInt16 nHeaderAttrs = 0;
- m_pCurrPageDesc = MakeHeader( nHeaderAttrs );
+ if (mbReqIF && !m_bWriteAll
+ && *m_pCurrentPam->GetPoint() == *m_pCurrentPam->GetMark()
+ && m_pCurrentPam->GetPoint()->GetNode().IsOLENode() && m_aHTMLPosFlyFrames.size() == 1)
+ {
+ // A single OLE object selection must be output: do it directly (without replacement)
+ OutHTML_FrameFormatOLENodeGrf(*this, m_aHTMLPosFlyFrames[0]->GetFormat(), true, false);
+ }
+ else
+ {
+ GetControls();
+ CollectLinkTargets();
- m_bLFPossible = true;
+ sal_uInt16 nHeaderAttrs = 0;
+ m_pCurrPageDesc = MakeHeader( nHeaderAttrs );
- // output forms which contain only HiddenControls
- OutHiddenForms();
+ SetLFPossible(true);
- if( !aStartTags.isEmpty() )
- Strm().WriteOString( aStartTags );
+ // output forms which contain only HiddenControls
+ OutHiddenForms();
- const SfxPoolItem *pItem;
- const SfxItemSet& rPageItemSet = m_pCurrPageDesc->GetMaster().GetAttrSet();
- if( !m_bWriteClipboardDoc && m_pDoc->GetDocShell() &&
- (!m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) &&
- !m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE)) &&
- SfxItemState::SET == rPageItemSet.GetItemState( RES_HEADER, true, &pItem) )
- {
- const SwFrameFormat *pHeaderFormat =
- static_cast<const SwFormatHeader *>(pItem)->GetHeaderFormat();
- if( pHeaderFormat )
- OutHTML_HeaderFooter( *this, *pHeaderFormat, true );
- }
+ if( !aStartTags.isEmpty() )
+ Strm().WriteOString( aStartTags );
- m_nTextAttrsToIgnore = nHeaderAttrs;
- Out_SwDoc( m_pOrigPam );
- m_nTextAttrsToIgnore = 0;
+ const SwFormatHeader *pFormatHeader;
+ const SfxItemSet& rPageItemSet = m_pCurrPageDesc->GetMaster().GetAttrSet();
+ if( !m_bWriteClipboardDoc && m_pDoc->GetDocShell() &&
+ (!m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) &&
+ !m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE)) &&
+ (pFormatHeader = rPageItemSet.GetItemIfSet( RES_HEADER )) )
+ {
+ const SwFrameFormat *pHeaderFormat = pFormatHeader->GetHeaderFormat();
+ if( pHeaderFormat )
+ OutHTML_HeaderFooter( *this, *pHeaderFormat, true );
+ }
- if( mxFormComps.is() )
- OutForm( false, mxFormComps );
+ m_nTextAttrsToIgnore = nHeaderAttrs;
+ Out_SwDoc( m_pOrigPam );
+ m_nTextAttrsToIgnore = 0;
- if( m_pFootEndNotes )
- OutFootEndNotes();
+ if( mxFormComps.is() )
+ OutForm( false, mxFormComps );
- if( !m_bWriteClipboardDoc && m_pDoc->GetDocShell() &&
- (!m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) && !m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE)) &&
- SfxItemState::SET == rPageItemSet.GetItemState( RES_FOOTER, true, &pItem) )
- {
- const SwFrameFormat *pFooterFormat =
- static_cast<const SwFormatFooter *>(pItem)->GetFooterFormat();
- if( pFooterFormat )
- OutHTML_HeaderFooter( *this, *pFooterFormat, false );
- }
+ if( m_xFootEndNotes )
+ OutFootEndNotes();
- if( m_bLFPossible )
- OutNewLine();
- if (!mbSkipHeaderFooter)
- {
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_body, false );
- OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_html, false );
- }
- else if (mbReqIF)
- // ReqIF: end xhtml.BlkStruct.class.
- HTMLOutFuncs::Out_AsciiTag(Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_division, false);
+ const SwFormatFooter* pFormatFooter;
+ if( !m_bWriteClipboardDoc && m_pDoc->GetDocShell() &&
+ (!m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) && !m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE)) &&
+ (pFormatFooter = rPageItemSet.GetItemIfSet( RES_FOOTER )) )
+ {
+ const SwFrameFormat *pFooterFormat = pFormatFooter->GetFooterFormat();
+ if( pFooterFormat )
+ OutHTML_HeaderFooter( *this, *pFooterFormat, false );
+ }
+ if (IsLFPossible())
+ OutNewLine();
+ if (!mbSkipHeaderFooter)
+ {
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_body), false );
+ OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_html), false );
+ }
+ else if (mbReqIF)
+ // ReqIF: end xhtml.BlkStruct.class.
+ HTMLOutFuncs::Out_AsciiTag(Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_division), false);
+ }
// delete the table with floating frames
- OSL_ENSURE( !m_pHTMLPosFlyFrames, "Were not all frames output?" );
- m_pHTMLPosFlyFrames.reset();
+ OSL_ENSURE( m_aHTMLPosFlyFrames.empty(), "Were not all frames output?" );
+ m_aHTMLPosFlyFrames.clear();
m_aHTMLControls.clear();
@@ -521,7 +651,7 @@ ErrCode SwHTMLWriter::WriteStream()
mxFormComps.clear();
- OSL_ENSURE( !m_pFootEndNotes,
+ OSL_ENSURE( !m_xFootEndNotes,
"SwHTMLWriter::Write: Footnotes not deleted by OutFootEndNotes" );
m_pCurrPageDesc = nullptr;
@@ -531,8 +661,6 @@ ErrCode SwHTMLWriter::WriteStream()
for(OUString & s : m_aBulletGrfs)
s.clear();
- m_aNonConvertableCharacters.clear();
-
if( m_bShowProgress )
::EndProgress( m_pDoc->GetDocShell() );
@@ -563,20 +691,17 @@ ErrCode SwHTMLWriter::WriteStream()
static const SwFormatCol *lcl_html_GetFormatCol( const SwSection& rSection,
const SwSectionFormat& rFormat )
{
- const SwFormatCol *pCol = nullptr;
+ if( SectionType::FileLink == rSection.GetType() )
+ return nullptr;
- const SfxPoolItem* pItem;
- if( SectionType::FileLink != rSection.GetType() &&
- SfxItemState::SET == rFormat.GetAttrSet().GetItemState(RES_COL,false,&pItem) &&
- static_cast<const SwFormatCol *>(pItem)->GetNumCols() > 1 )
- {
- pCol = static_cast<const SwFormatCol *>(pItem);
- }
+ const SwFormatCol *pCol = rFormat.GetAttrSet().GetItemIfSet(RES_COL,false);
+ if (pCol->GetNumCols() > 1 )
+ return pCol;
- return pCol;
+ return nullptr;
}
-static bool lcl_html_IsMultiColStart( const SwHTMLWriter& rHTMLWrt, sal_uLong nIndex )
+static bool lcl_html_IsMultiColStart( const SwHTMLWriter& rHTMLWrt, SwNodeOffset nIndex )
{
bool bRet = false;
const SwSectionNode *pSectNd =
@@ -592,7 +717,7 @@ static bool lcl_html_IsMultiColStart( const SwHTMLWriter& rHTMLWrt, sal_uLong nI
return bRet;
}
-static bool lcl_html_IsMultiColEnd( const SwHTMLWriter& rHTMLWrt, sal_uLong nIndex )
+static bool lcl_html_IsMultiColEnd( const SwHTMLWriter& rHTMLWrt, SwNodeOffset nIndex )
{
bool bRet = false;
const SwEndNode *pEndNd = rHTMLWrt.m_pDoc->GetNodes()[nIndex]->GetEndNode();
@@ -611,29 +736,33 @@ static void lcl_html_OutSectionStartTag( SwHTMLWriter& rHTMLWrt,
{
OSL_ENSURE( pCol || !bContinued, "Continuation of DIV" );
- if( rHTMLWrt.m_bLFPossible )
+ if (rHTMLWrt.IsLFPossible())
rHTMLWrt.OutNewLine();
- OStringBuffer sOut;
- sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_division);
+ OStringBuffer sOut("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_division);
const OUString& rName = rSection.GetSectionName();
if( !rName.isEmpty() && !bContinued )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_id "=\"");
- rHTMLWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), rName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ rHTMLWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), rName );
sOut.append('\"');
}
- SvxFrameDirection nDir = rHTMLWrt.GetHTMLDirection( rFormat.GetAttrSet() );
rHTMLWrt.Strm().WriteOString( sOut.makeStringAndClear() );
- rHTMLWrt.OutDirection( nDir );
+ if (!rHTMLWrt.mbXHTML)
+ {
+ SvxFrameDirection nDir = rHTMLWrt.GetHTMLDirection(rFormat.GetAttrSet());
+ rHTMLWrt.OutDirection(nDir);
+ }
if( SectionType::FileLink == rSection.GetType() )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_href "=\"");
- rHTMLWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ rHTMLWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
const OUString& aFName = rSection.GetLinkFileName();
sal_Int32 nIdx{ 0 };
@@ -645,32 +774,19 @@ static void lcl_html_OutSectionStartTag( SwHTMLWriter& rHTMLWrt,
sal_Unicode cDelim = 255U;
bool bURLContainsDelim = (-1 != aEncURL.indexOf( cDelim ) );
- HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aEncURL,
- rHTMLWrt.m_eDestEnc,
- &rHTMLWrt.m_aNonConvertableCharacters );
+ HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aEncURL );
const char* const pDelim = "&#255;";
if( !aFilter.isEmpty() || !aSection.isEmpty() || bURLContainsDelim )
- rHTMLWrt.Strm().WriteCharPtr( pDelim );
+ rHTMLWrt.Strm().WriteOString( pDelim );
if( !aFilter.isEmpty() )
- HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aFilter, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aFilter );
if( !aSection.isEmpty() || bURLContainsDelim )
- rHTMLWrt.Strm().WriteCharPtr( pDelim );
+ rHTMLWrt.Strm().WriteOString( pDelim );
if( !aSection.isEmpty() )
{
- sal_Int32 nPos = aSection.indexOf( '%' );
- while( nPos != -1 )
- {
- aSection = aSection.replaceAt(nPos, 1, "%25");
- nPos = aSection.indexOf( '%', nPos+3 );
- }
- nPos = aSection.indexOf( cDelim );
- while( nPos != -1 )
- {
- aSection = aSection.replaceAt(nPos, 1, "%FF" );
- nPos = aSection.indexOf( cDelim, nPos+3 );
- }
- HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aSection,
- rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
+ aSection = aSection.replaceAll(u"%", u"%25");
+ aSection = aSection.replaceAll(OUStringChar(cDelim), u"%FF");
+ HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aSection );
}
sOut.append('\"');
}
@@ -680,22 +796,19 @@ static void lcl_html_OutSectionStartTag( SwHTMLWriter& rHTMLWrt,
sal_uInt16 nGutter = pCol->GetGutterWidth( true );
if( nGutter!=USHRT_MAX )
{
- if( nGutter && Application::GetDefaultDevice() )
- {
- nGutter = static_cast<sal_uInt16>(Application::GetDefaultDevice()
- ->LogicToPixel( Size(nGutter, 0), MapMode(MapUnit::MapTwip) ).Width());
- }
+ nGutter = SwHTMLWriter::ToPixel(nGutter);
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_gutter "=\"" + OString::number(nGutter) + "\"");
}
}
- rHTMLWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ rHTMLWrt.Strm().WriteOString( sOut );
+ sOut.setLength(0);
if( rHTMLWrt.IsHTMLMode( rHTMLWrt.m_bCfgOutStyles ? HTMLMODE_ON : 0 ) )
rHTMLWrt.OutCSS1_SectionFormatOptions( rFormat, pCol );
rHTMLWrt.Strm().WriteChar( '>' );
- rHTMLWrt.m_bLFPossible = true;
+ rHTMLWrt.SetLFPossible(true);
if( !rName.isEmpty() && !bContinued )
rHTMLWrt.OutImplicitMark( rName, "region" );
@@ -705,20 +818,18 @@ static void lcl_html_OutSectionStartTag( SwHTMLWriter& rHTMLWrt,
static void lcl_html_OutSectionEndTag( SwHTMLWriter& rHTMLWrt )
{
rHTMLWrt.DecIndentLevel();
- if( rHTMLWrt.m_bLFPossible )
+ if (rHTMLWrt.IsLFPossible())
rHTMLWrt.OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( rHTMLWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_division, false );
- rHTMLWrt.m_bLFPossible = true;
+ HTMLOutFuncs::Out_AsciiTag( rHTMLWrt.Strm(), Concat2View(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_division), false );
+ rHTMLWrt.SetLFPossible(true);
}
-static Writer& OutHTML_Section( Writer& rWrt, const SwSectionNode& rSectNd )
+static SwHTMLWriter& OutHTML_Section( SwHTMLWriter& rWrt, const SwSectionNode& rSectNd )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
// End <PRE> and any <DL>, because a definition list's level may
// change inside the section.
- rHTMLWrt.ChangeParaToken( HtmlTokenId::NONE );
- rHTMLWrt.OutAndSetDefList( 0 );
+ rWrt.ChangeParaToken( HtmlTokenId::NONE );
+ rWrt.OutAndSetDefList( 0 );
const SwSection& rSection = rSectNd.GetSection();
const SwSectionFormat *pFormat = rSection.GetFormat();
@@ -731,18 +842,18 @@ static Writer& OutHTML_Section( Writer& rWrt, const SwSectionNode& rSectNd )
const SwSection *pSurrSection = nullptr;
const SwFormatCol *pSurrCol = nullptr;
- sal_uInt32 nSectSttIdx = rSectNd.GetIndex();
- sal_uInt32 nSectEndIdx = rSectNd.EndOfSectionIndex();
+ SwNodeOffset nSectSttIdx = rSectNd.GetIndex();
+ SwNodeOffset nSectEndIdx = rSectNd.EndOfSectionIndex();
const SwFormatCol *pCol = lcl_html_GetFormatCol( rSection, *pFormat );
if( pCol )
{
// If the next node is a columned section node, too, don't export
// an empty section.
- if( lcl_html_IsMultiColStart( rHTMLWrt, nSectSttIdx+1 ) )
+ if( lcl_html_IsMultiColStart( rWrt, nSectSttIdx+1 ) )
bStartTag = false;
// The same applies if the section end with another columned section.
- if( lcl_html_IsMultiColEnd( rHTMLWrt, nSectEndIdx-1 ) )
+ if( lcl_html_IsMultiColEnd( rWrt, nSectEndIdx-1 ) )
bEndTag = false;
// is there a columned section around this one?
@@ -769,32 +880,32 @@ static Writer& OutHTML_Section( Writer& rWrt, const SwSectionNode& rSectNd )
// The surrounding section must be closed before the current one is
// opened, except that it start immediately before the current one or
// another end immediately before the current one
- if( pSurrCol && nSectSttIdx - pSurrSectNd->GetIndex() > 1 &&
- !lcl_html_IsMultiColEnd( rHTMLWrt, nSectSttIdx-1 ) )
- lcl_html_OutSectionEndTag( rHTMLWrt );
+ if( pSurrCol && nSectSttIdx - pSurrSectNd->GetIndex() > SwNodeOffset(1) &&
+ !lcl_html_IsMultiColEnd( rWrt, nSectSttIdx-1 ) )
+ lcl_html_OutSectionEndTag( rWrt );
if( bStartTag )
- lcl_html_OutSectionStartTag( rHTMLWrt, rSection, *pFormat, pCol );
+ lcl_html_OutSectionStartTag( rWrt, rSection, *pFormat, pCol );
{
- HTMLSaveData aSaveData( rHTMLWrt,
- rHTMLWrt.m_pCurrentPam->GetPoint()->nNode.GetIndex()+1,
+ HTMLSaveData aSaveData( rWrt,
+ rWrt.m_pCurrentPam->GetPoint()->GetNodeIndex()+1,
rSectNd.EndOfSectionIndex(),
false, pFormat );
- rHTMLWrt.Out_SwDoc( rHTMLWrt.m_pCurrentPam.get() );
+ rWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() );
}
- rHTMLWrt.m_pCurrentPam->GetPoint()->nNode = *rSectNd.EndOfSectionNode();
+ rWrt.m_pCurrentPam->GetPoint()->Assign(*rSectNd.EndOfSectionNode());
if( bEndTag )
- lcl_html_OutSectionEndTag( rHTMLWrt );
+ lcl_html_OutSectionEndTag( rWrt );
// The surrounding section must be started again, except that it ends
// immediately behind the current one.
if( pSurrCol &&
- pSurrSectNd->EndOfSectionIndex() - nSectEndIdx > 1 &&
- !lcl_html_IsMultiColStart( rHTMLWrt, nSectEndIdx+1 ) )
- lcl_html_OutSectionStartTag( rHTMLWrt, *pSurrSection, *pSurrFormat,
+ pSurrSectNd->EndOfSectionIndex() - nSectEndIdx > SwNodeOffset(1) &&
+ !lcl_html_IsMultiColStart( rWrt, nSectEndIdx+1 ) )
+ lcl_html_OutSectionStartTag( rWrt, *pSurrSection, *pSurrFormat,
pSurrCol, true );
return rWrt;
@@ -803,6 +914,7 @@ static Writer& OutHTML_Section( Writer& rWrt, const SwSectionNode& rSectNd )
void SwHTMLWriter::Out_SwDoc( SwPaM* pPam )
{
bool bSaveWriteAll = m_bWriteAll; // save
+ bool bIncludeHidden = officecfg::Office::Writer::FilterFlags::HTML::IncludeHiddenText::get();
// search next text::Bookmark position from text::Bookmark table
m_nBkmkTabPos = m_bWriteAll ? FindPos_Bkmk( *m_pCurrentPam->GetPoint() ) : -1;
@@ -815,22 +927,25 @@ void SwHTMLWriter::Out_SwDoc( SwPaM* pPam )
// search for first on PaM created FlyFrame
// still missing:
- while( m_pCurrentPam->GetPoint()->nNode.GetIndex() < m_pCurrentPam->GetMark()->nNode.GetIndex() ||
- (m_pCurrentPam->GetPoint()->nNode.GetIndex() == m_pCurrentPam->GetMark()->nNode.GetIndex() &&
- m_pCurrentPam->GetPoint()->nContent.GetIndex() <= m_pCurrentPam->GetMark()->nContent.GetIndex()) )
+ while( m_pCurrentPam->GetPoint()->GetNodeIndex() < m_pCurrentPam->GetMark()->GetNodeIndex() ||
+ (m_pCurrentPam->GetPoint()->GetNodeIndex() == m_pCurrentPam->GetMark()->GetNodeIndex() &&
+ m_pCurrentPam->GetPoint()->GetContentIndex() <= m_pCurrentPam->GetMark()->GetContentIndex()) )
{
- SwNode& rNd = m_pCurrentPam->GetNode();
+ SwNode& rNd = m_pCurrentPam->GetPointNode();
OSL_ENSURE( !(rNd.IsGrfNode() || rNd.IsOLENode()),
"Unexpected Grf- or OLE-Node here" );
+
if( rNd.IsTextNode() )
{
SwTextNode* pTextNd = rNd.GetTextNode();
+ if (!pTextNd->IsHidden() || bIncludeHidden)
+ {
+ if (!m_bFirstLine)
+ m_pCurrentPam->GetPoint()->Assign(*pTextNd, 0);
- if( !m_bFirstLine )
- m_pCurrentPam->GetPoint()->nContent.Assign( pTextNd, 0 );
-
- OutHTML_SwTextNode( *this, *pTextNd );
+ OutHTML_SwTextNode(*this, *pTextNd);
+ }
}
else if( rNd.IsTableNode() )
{
@@ -839,17 +954,21 @@ void SwHTMLWriter::Out_SwDoc( SwPaM* pPam )
}
else if( rNd.IsSectionNode() )
{
- OutHTML_Section( *this, *rNd.GetSectionNode() );
- m_nBkmkTabPos = m_bWriteAll ? FindPos_Bkmk( *m_pCurrentPam->GetPoint() ) : -1;
+ SwSectionNode* pSectionNode = rNd.GetSectionNode();
+ if (!pSectionNode->GetSection().IsHiddenFlag() || bIncludeHidden)
+ {
+ OutHTML_Section( *this, *pSectionNode );
+ m_nBkmkTabPos = m_bWriteAll ? FindPos_Bkmk( *m_pCurrentPam->GetPoint() ) : -1;
+ }
}
else if( &rNd == &m_pDoc->GetNodes().GetEndOfContent() )
break;
- ++m_pCurrentPam->GetPoint()->nNode; // move
- sal_uInt32 nPos = m_pCurrentPam->GetPoint()->nNode.GetIndex();
+ m_pCurrentPam->GetPoint()->Adjust(SwNodeOffset(+1)); // move
+ SwNodeOffset nPos = m_pCurrentPam->GetPoint()->GetNodeIndex();
if( m_bShowProgress )
- ::SetProgressState( nPos, m_pDoc->GetDocShell() ); // How far ?
+ ::SetProgressState( sal_Int32(nPos), m_pDoc->GetDocShell() ); // How far ?
/* If only the selected area should be saved, so only the complete
* nodes should be saved, this means the first and n-th node
@@ -857,7 +976,7 @@ void SwHTMLWriter::Out_SwDoc( SwPaM* pPam )
* all formats!)
*/
m_bWriteAll = bSaveWriteAll ||
- nPos != m_pCurrentPam->GetMark()->nNode.GetIndex();
+ nPos != m_pCurrentPam->GetMark()->GetNodeIndex();
m_bFirstLine = false;
m_bOutFooter = false; // after one node no footer anymore
}
@@ -883,19 +1002,16 @@ static void OutBodyColor( const char* pTag, const SwFormat *pFormat,
const SvxColorItem *pColorItem = nullptr;
const SfxItemSet& rItemSet = pFormat->GetAttrSet();
- const SfxPoolItem *pRefItem = nullptr, *pItem = nullptr;
- bool bItemSet = SfxItemState::SET == rItemSet.GetItemState( RES_CHRATR_COLOR,
- true, &pItem);
- bool bRefItemSet = pRefFormat &&
- SfxItemState::SET == pRefFormat->GetAttrSet().GetItemState( RES_CHRATR_COLOR,
- true, &pRefItem);
- if( bItemSet )
+ const SvxColorItem *pCItem = rItemSet.GetItemIfSet( RES_CHRATR_COLOR );
+ const SvxColorItem *pRefItem = nullptr;
+ if (pRefFormat)
+ pRefItem = pRefFormat->GetAttrSet().GetItemIfSet( RES_CHRATR_COLOR );
+ if( pCItem )
{
// only when the item is set in the template of the current document
// or has a different value as the in HTML template, it will be set
- const SvxColorItem *pCItem = static_cast<const SvxColorItem*>(pItem);
- if( !bRefItemSet )
+ if( !pRefItem )
{
pColorItem = pCItem;
}
@@ -905,7 +1021,7 @@ static void OutBodyColor( const char* pTag, const SwFormat *pFormat,
if( COL_AUTO == aColor )
aColor = COL_BLACK;
- Color aRefColor( static_cast<const SvxColorItem*>(pRefItem)->GetValue() );
+ Color aRefColor( pRefItem->GetValue() );
if( COL_AUTO == aRefColor )
aRefColor = COL_BLACK;
@@ -913,17 +1029,16 @@ static void OutBodyColor( const char* pTag, const SwFormat *pFormat,
pColorItem = pCItem;
}
}
- else if( bRefItemSet )
+ else if( pRefItem )
{
// The item was still set in the HTML template so we output the default
- pColorItem = &rItemSet.GetPool()->GetDefaultItem( RES_CHRATR_COLOR );
+ pColorItem = &rItemSet.GetPool()->GetUserOrPoolDefaultItem( RES_CHRATR_COLOR );
}
if( pColorItem )
{
- OStringBuffer sOut;
- sOut.append(OStringLiteral(" ") + pTag + "=");
- rHWrt.Strm().WriteOString( sOut.makeStringAndClear() );
+ OString sOut = OString::Concat(" ") + pTag + "=";
+ rHWrt.Strm().WriteOString( sOut );
Color aColor( pColorItem->GetValue() );
if( COL_AUTO == aColor )
aColor = COL_BLACK;
@@ -935,8 +1050,8 @@ static void OutBodyColor( const char* pTag, const SwFormat *pFormat,
sal_uInt16 SwHTMLWriter::OutHeaderAttrs()
{
- sal_uLong nIdx = m_pCurrentPam->GetPoint()->nNode.GetIndex();
- sal_uLong nEndIdx = m_pCurrentPam->GetMark()->nNode.GetIndex();
+ SwNodeOffset nIdx = m_pCurrentPam->GetPoint()->GetNodeIndex();
+ SwNodeOffset nEndIdx = m_pCurrentPam->GetMark()->GetNodeIndex();
SwTextNode *pTextNd = nullptr;
while( nIdx<=nEndIdx &&
@@ -986,15 +1101,15 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
if (mbXHTML)
sOut.append(OOO_STRING_SVTOOLS_HTML_doctype " " OOO_STRING_SVTOOLS_XHTML_doctype11);
else
- sOut.append(OOO_STRING_SVTOOLS_HTML_doctype " " OOO_STRING_SVTOOLS_HTML_doctype40);
- HTMLOutFuncs::Out_AsciiTag( Strm(), sOut.makeStringAndClear().getStr() ); // No GetNamespace() here.
+ sOut.append(OOO_STRING_SVTOOLS_HTML_doctype " " OOO_STRING_SVTOOLS_HTML_doctype5);
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sOut.makeStringAndClear() ); // No GetNamespace() here.
// build prelude
OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_html );
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_html) );
OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_head );
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_head) );
IncIndentLevel(); // indent content of <HEAD>
@@ -1012,8 +1127,7 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
// xDocProps may be null here (when copying)
SfxFrameHTMLWriter::Out_DocInfo( Strm(), GetBaseURL(), xDocProps,
- sIndent.getStr(), m_eDestEnc,
- &m_aNonConvertableCharacters );
+ sIndent.getStr() );
// comments and meta-tags of first paragraph
rHeaderAttrs = OutHeaderAttrs();
@@ -1025,15 +1139,14 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
// In none HTML documents the first set template will be exported
// and if none is set the default template
- sal_uLong nNodeIdx = m_pCurrentPam->GetPoint()->nNode.GetIndex();
+ SwNodeOffset nNodeIdx = m_pCurrentPam->GetPoint()->GetNodeIndex();
while( nNodeIdx < m_pDoc->GetNodes().Count() )
{
SwNode *pNd = m_pDoc->GetNodes()[ nNodeIdx ];
if( pNd->IsContentNode() )
{
- pPageDesc = static_cast<const SwFormatPageDesc &>(pNd->GetContentNode()
- ->GetAttr(RES_PAGEDESC)).GetPageDesc();
+ pPageDesc = pNd->GetContentNode()->GetAttr(RES_PAGEDESC).GetPageDesc();
break;
}
else if( pNd->IsTableNode() )
@@ -1063,12 +1176,13 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
DecIndentLevel(); // indent content of <HEAD>
OutNewLine();
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_head, false );
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_head), false );
// the body won't be indented, because then everything would be indented!
OutNewLine();
sOut.append("<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_body);
- Strm().WriteOString( sOut.makeStringAndClear() );
+ Strm().WriteOString( sOut );
+ sOut.setLength(0);
// language
OutLanguage( m_eLang );
@@ -1107,30 +1221,39 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
}
else if (mbReqIF)
// ReqIF: start xhtml.BlkStruct.class.
- HTMLOutFuncs::Out_AsciiTag(Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_division);
+ HTMLOutFuncs::Out_AsciiTag(Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_division));
return pPageDesc;
}
void SwHTMLWriter::OutAnchor( const OUString& rName )
{
- OStringBuffer sOut;
- sOut.append("<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor " ");
+ if (mbReqIF)
+ {
+ // <a id=".."> has to be unique inside the whole document, but
+ // we only write a fragment, so we can't ensure the ID is indeed
+ // unique. Just don't write anchors in the ReqIF case.
+ return;
+ }
+
+ OStringBuffer sOut("<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor " ");
if (!mbXHTML)
{
sOut.append(OOO_STRING_SVTOOLS_HTML_O_name "=\"");
- Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( Strm(), rName, m_eDestEnc, &m_aNonConvertableCharacters ).WriteCharPtr( "\">" );
+ Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( Strm(), rName ).WriteOString( "\">" );
}
else
{
// XHTML wants 'id' instead of 'name', also the value can't contain
// spaces.
sOut.append(OOO_STRING_SVTOOLS_HTML_O_id "=\"");
- Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( Strm(), rName.replace(' ', '_'), m_eDestEnc, &m_aNonConvertableCharacters ).WriteCharPtr( "\">" );
+ Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( Strm(), rName.replace(' ', '_') ).WriteOString( "\">" );
}
- HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor, false );
+ HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor), false );
}
void SwHTMLWriter::OutBookmarks()
@@ -1142,9 +1265,9 @@ void SwHTMLWriter::OutBookmarks()
pBookmark = pMarkAccess->getAllMarksBegin()[m_nBkmkTabPos];
// Output all bookmarks in this paragraph. The content position
// for the moment isn't considered!
- sal_uInt32 nNode = m_pCurrentPam->GetPoint()->nNode.GetIndex();
+ SwNodeOffset nNode = m_pCurrentPam->GetPoint()->GetNodeIndex();
while( m_nBkmkTabPos != -1
- && pBookmark->GetMarkPos().nNode.GetIndex() == nNode )
+ && pBookmark->GetMarkPos().GetNodeIndex() == nNode )
{
// The area of bookmarks is first ignored, because it's not read.
@@ -1202,7 +1325,7 @@ void SwHTMLWriter::OutPointFieldmarks( const SwPosition& rPos )
OOO_STRING_SVTOOLS_HTML_O_type
"=\""
OOO_STRING_SVTOOLS_HTML_IT_checkbox
- "\"");
+ "\""_ostr);
if (pCheckBox->IsChecked())
{
@@ -1255,7 +1378,8 @@ OUString SwHTMLWriter::convertHyperlinkHRefValue(const OUString& rURL)
{
// Link is not started from "#", so looks like external link. Encode this URL.
INetURLObject aURL(sURL);
- sURL = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
+ if (!aURL.HasError())
+ sURL = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
}
return URIHelper::simpleNormalizedMakeRelative( GetBaseURL(), sURL );
}
@@ -1263,7 +1387,7 @@ OUString SwHTMLWriter::convertHyperlinkHRefValue(const OUString& rURL)
void SwHTMLWriter::OutHyperlinkHRefValue( const OUString& rURL )
{
OUString sURL = convertHyperlinkHRefValue(rURL);
- HTMLOutFuncs::Out_String( Strm(), sURL, m_eDestEnc, &m_aNonConvertableCharacters );
+ HTMLOutFuncs::Out_String( Strm(), sURL );
}
void SwHTMLWriter::OutBackground( const SvxBrushItem *pBrushItem, bool bGraphic )
@@ -1291,9 +1415,9 @@ void SwHTMLWriter::OutBackground( const SvxBrushItem *pBrushItem, bool bGraphic
{
m_nWarn = WARN_SWG_POOR_LOAD;
}
- Strm().WriteCharPtr( " " OOO_STRING_SVTOOLS_HTML_O_background "=\"" );
- Strm().WriteCharPtr( OOO_STRING_SVTOOLS_HTML_O_data ":" );
- HTMLOutFuncs::Out_String( Strm(), aGraphicInBase64, m_eDestEnc, &m_aNonConvertableCharacters ).WriteChar( '\"' );
+ Strm().WriteOString( " " OOO_STRING_SVTOOLS_HTML_O_background "=\"" );
+ Strm().WriteOString( OOO_STRING_SVTOOLS_HTML_O_data ":" );
+ HTMLOutFuncs::Out_String( Strm(), aGraphicInBase64 ).WriteChar( '\"' );
}
}
else
@@ -1303,26 +1427,24 @@ void SwHTMLWriter::OutBackground( const SvxBrushItem *pBrushItem, bool bGraphic
CopyLocalFileToINet( GraphicURL );
}
OUString s( URIHelper::simpleNormalizedMakeRelative( GetBaseURL(), GraphicURL));
- Strm().WriteCharPtr(" " OOO_STRING_SVTOOLS_HTML_O_background "=\"" );
- HTMLOutFuncs::Out_String( Strm(), s, m_eDestEnc, &m_aNonConvertableCharacters );
- Strm().WriteCharPtr("\"");
+ Strm().WriteOString(" " OOO_STRING_SVTOOLS_HTML_O_background "=\"" );
+ HTMLOutFuncs::Out_String( Strm(), s );
+ Strm().WriteOString("\"");
}
}
void SwHTMLWriter::OutBackground( const SfxItemSet& rItemSet, bool bGraphic )
{
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false,
- &pItem ))
+ if( const SvxBrushItem* pItem = rItemSet.GetItemIfSet( RES_BACKGROUND, false ) )
{
- OutBackground( static_cast<const SvxBrushItem*>(pItem), bGraphic );
+ OutBackground( pItem, bGraphic );
}
}
-sal_uInt16 SwHTMLWriter::GetLangWhichIdFromScript( sal_uInt16 nScript )
+TypedWhichId<SvxLanguageItem> SwHTMLWriter::GetLangWhichIdFromScript( sal_uInt16 nScript )
{
- sal_uInt16 nWhichId;
+ TypedWhichId<SvxLanguageItem> nWhichId(0);
switch( nScript )
{
case CSS1_OUTMODE_CJK:
@@ -1344,16 +1466,15 @@ void SwHTMLWriter::OutLanguage( LanguageType nLang )
if (!(LANGUAGE_DONTKNOW != nLang && !mbReqIF))
return;
- OStringBuffer sOut;
- sOut.append(' ');
+ OStringBuffer sOut(" ");
if (mbXHTML)
sOut.append(OOO_STRING_SVTOOLS_XHTML_O_lang);
else
sOut.append(OOO_STRING_SVTOOLS_HTML_O_lang);
sOut.append("=\"");
- Strm().WriteOString( sOut.makeStringAndClear() );
- HTMLOutFuncs::Out_String( Strm(), LanguageTag::convertToBcp47(nLang),
- m_eDestEnc, &m_aNonConvertableCharacters ).WriteChar( '"' );
+ Strm().WriteOString( sOut );
+ sOut.setLength(0);
+ HTMLOutFuncs::Out_String( Strm(), LanguageTag::convertToBcp47(nLang) ).WriteChar( '"' );
}
SvxFrameDirection SwHTMLWriter::GetHTMLDirection( const SfxItemSet& rItemSet ) const
@@ -1399,11 +1520,11 @@ OString SwHTMLWriter::convertDirection(SvxFrameDirection nDir)
{
case SvxFrameDirection::Horizontal_LR_TB:
case SvxFrameDirection::Vertical_LR_TB:
- sConverted = "ltr";
+ sConverted = "ltr"_ostr;
break;
case SvxFrameDirection::Horizontal_RL_TB:
case SvxFrameDirection::Vertical_RL_TB:
- sConverted = "rtl";
+ sConverted = "rtl"_ostr;
break;
default: break;
}
@@ -1431,14 +1552,14 @@ void SwHTMLWriter::OutNewLine( bool bCheck )
{
if( !bCheck || (Strm().Tell()-m_nLastLFPos) > m_nIndentLvl )
{
- Strm().WriteCharPtr( SAL_NEWLINE_STRING );
+ Strm().WriteOString( SAL_NEWLINE_STRING );
m_nLastLFPos = Strm().Tell();
}
if( m_nIndentLvl && m_nIndentLvl <= MAX_INDENT_LEVEL)
{
sIndentTabs[m_nIndentLvl] = 0;
- Strm().WriteCharPtr( sIndentTabs );
+ Strm().WriteOString( sIndentTabs );
sIndentTabs[m_nIndentLvl] = '\t';
}
}
@@ -1460,7 +1581,7 @@ sal_uInt16 SwHTMLWriter::GetHTMLFontSize( sal_uInt32 nHeight ) const
// Paragraphs with Table of Contents and other index styles will be typeset with
// dot leaders at the position of the last tabulator in PrintLayout (CSS2) mode
-sal_Int32 SwHTMLWriter::indexOfDotLeaders( sal_uInt16 nPoolId, const OUString& rStr )
+sal_Int32 SwHTMLWriter::indexOfDotLeaders( sal_uInt16 nPoolId, std::u16string_view rStr )
{
if (m_bCfgPrintLayout && ((nPoolId >= RES_POOLCOLL_TOX_CNTNT1 && nPoolId <= RES_POOLCOLL_TOX_CNTNT5) ||
(nPoolId >= RES_POOLCOLL_TOX_IDX1 && nPoolId <= RES_POOLCOLL_TOX_IDX3) ||
@@ -1468,9 +1589,9 @@ sal_Int32 SwHTMLWriter::indexOfDotLeaders( sal_uInt16 nPoolId, const OUString& r
nPoolId == RES_POOLCOLL_TOX_ILLUS1 || nPoolId == RES_POOLCOLL_TOX_TABLES1 ||
nPoolId == RES_POOLCOLL_TOX_OBJECT1 ||
(nPoolId >= RES_POOLCOLL_TOX_AUTHORITIES1 && nPoolId <= RES_POOLCOLL_TOX_USER10))) {
- sal_Int32 i = rStr.lastIndexOf('\t');
+ size_t i = rStr.rfind('\t');
// there are only ASCII (Latin-1) characters after the tabulator
- if (i > -1 && OUStringToOString(rStr.subView(i + 1), RTL_TEXTENCODING_ASCII_US).indexOf('?') == -1)
+ if (i != std::u16string_view::npos && OUStringToOString(rStr.substr(i + 1), RTL_TEXTENCODING_ASCII_US).indexOf('?') == -1)
return i;
}
return -1;
@@ -1486,8 +1607,8 @@ OString SwHTMLWriter::GetNamespace() const
// Structure caches the current data of the writer to output a
// other part of the document, like e.g. header/footer
-HTMLSaveData::HTMLSaveData(SwHTMLWriter& rWriter, sal_uLong nStt,
- sal_uLong nEnd, bool bSaveNum,
+HTMLSaveData::HTMLSaveData(SwHTMLWriter& rWriter, SwNodeOffset nStt,
+ SwNodeOffset nEnd, bool bSaveNum,
const SwFrameFormat *pFrameFormat)
: rWrt(rWriter)
, pOldPam(rWrt.m_pCurrentPam)
@@ -1503,11 +1624,11 @@ HTMLSaveData::HTMLSaveData(SwHTMLWriter& rWriter, sal_uLong nStt,
rWrt.m_pCurrentPam = Writer::NewUnoCursor(*rWrt.m_pDoc, nStt, nEnd);
// recognize table in special areas
- if( nStt != rWrt.m_pCurrentPam->GetMark()->nNode.GetIndex() )
+ if( nStt != rWrt.m_pCurrentPam->GetMark()->GetNodeIndex() )
{
const SwNode *pNd = rWrt.m_pDoc->GetNodes()[ nStt ];
if( pNd->IsTableNode() || pNd->IsSectionNode() )
- rWrt.m_pCurrentPam->GetMark()->nNode = nStt;
+ rWrt.m_pCurrentPam->GetMark()->Assign(*pNd);
}
rWrt.SetEndPaM( rWrt.m_pCurrentPam.get() );
@@ -1565,7 +1686,7 @@ HTMLSaveData::~HTMLSaveData()
}
}
-void GetHTMLWriter( const OUString& rFilterOptions, const OUString& rBaseURL, WriterRef& xRet )
+void GetHTMLWriter( std::u16string_view rFilterOptions, const OUString& rBaseURL, WriterRef& xRet )
{
xRet = new SwHTMLWriter( rBaseURL, rFilterOptions );
}
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index cef3eb788167..aac06fbf8868 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -24,6 +24,7 @@
#include <set>
#include <string_view>
#include <map>
+#include <optional>
#include <com/sun/star/container/XIndexContainer.hpp>
#include <com/sun/star/form/XForm.hpp>
@@ -62,11 +63,11 @@ class SwHTMLPosFlyFrames;
class SwTextFootnote;
enum class HtmlPosition;
enum class HtmlTokenId : sal_Int16;
-namespace utl { class TempFile; }
+namespace utl { class TempFileNamed; }
extern SwAttrFnTab aHTMLAttrFnTab;
-#define HTML_PARSPACE (MM50)
+#define HTML_PARSPACE (o3tl::toTwips(5, o3tl::Length::mm))
// flags for the output of any kind of frames
// BORDER only possible if OutHTML_Image
@@ -190,10 +191,10 @@ struct HTMLControl
{
// the form to which the control belongs
css::uno::Reference<css::container::XIndexContainer> xFormComps;
- sal_uLong nNdIdx; // the node in which it's anchored
+ SwNodeOffset nNdIdx; // the node in which it's anchored
sal_Int32 nCount; // how many controls are on the node
- HTMLControl( const css::uno::Reference<css::container::XIndexContainer>& rForm, sal_uInt32 nIdx );
+ HTMLControl( css::uno::Reference<css::container::XIndexContainer> xForm, SwNodeOffset nIdx );
~HTMLControl();
// operators for the sort array
@@ -203,7 +204,7 @@ struct HTMLControl
}
};
-class HTMLControls : public o3tl::sorted_vector<std::unique_ptr<HTMLControl>, o3tl::less_uniqueptr_to<HTMLControl> > {
+class HTMLControls : public o3tl::sorted_vector<std::unique_ptr<HTMLControl>, o3tl::less_ptr_to > {
};
struct SwHTMLFormatInfo
@@ -213,7 +214,7 @@ struct SwHTMLFormatInfo
OString aToken; // the token to output
OUString aClass; // the class to output
- std::unique_ptr<SfxItemSet> pItemSet; // the attribute set to output
+ std::optional<SfxItemSet> moItemSet; // the attribute set to output
sal_Int32 nLeftMargin; // some default values for
sal_Int32 nRightMargin; // paragraph styles
@@ -254,27 +255,48 @@ typedef std::set<std::unique_ptr<SwHTMLFormatInfo>,
class IDocumentStylePoolAccess;
-class SW_DLLPUBLIC SwHTMLWriter : public Writer
+namespace sw
{
- std::unique_ptr<SwHTMLPosFlyFrames> m_pHTMLPosFlyFrames;
+enum class Css1Background
+{
+ Attr = 1,
+ Page = 2,
+ Table = 3,
+ Fly = 4,
+ Section = 5,
+ TableRow = 6,
+ TableCell = 7,
+};
+}
+
+class SwHTMLWriter : public Writer
+{
+ SwHTMLPosFlyFrames m_aHTMLPosFlyFrames;
std::unique_ptr<SwHTMLNumRuleInfo> m_pNumRuleInfo;// current numbering
std::unique_ptr<SwHTMLNumRuleInfo> m_pNextNumRuleInfo;
sal_uInt32 m_nHTMLMode; // description of export configuration
FieldUnit m_eCSS1Unit;
+ bool m_bPrettyPrint = true; // Allows to add new lines to make it more readable
+ bool m_bLFPossible = false; // a line break can be inserted
+ bool m_bSpacePreserve = false; // Using xml::space="preserve", or "white-space: pre-wrap" style
+ bool m_bPreserveSpacesOnWrite = false; // If export should use m_bSpacePreserve
+
sal_uInt16 OutHeaderAttrs();
const SwPageDesc *MakeHeader( sal_uInt16& rHeaderAtrs );
void GetControls();
- void AddLinkTarget( const OUString& rURL );
+ void AddLinkTarget( std::u16string_view aURL );
void CollectLinkTargets();
- void SetupFilterOptions(const OUString& rFilterOptions);
+ void SetupFilterOptions(std::u16string_view rFilterOptions);
protected:
ErrCode WriteStream() override;
void SetupFilterOptions(SfxMedium& rMedium) override;
+ void SetupFilterFromPropertyValues(
+ const css::uno::Sequence<css::beans::PropertyValue>& rPropertyValues);
public:
std::vector<OUString> m_aImgMapNames; // written image maps
@@ -283,15 +305,14 @@ public:
std::set<OUString> m_aScriptParaStyles; // script dependent para styles
std::set<OUString> m_aScriptTextStyles; // script dependent text styles
std::vector<OUString> m_aOutlineMarks;
- std::vector<sal_uInt32> m_aOutlineMarkPoss;
+ std::vector<SwNodeOffset> m_aOutlineMarkPoss;
HTMLControls m_aHTMLControls; // the forms to be written
SwHTMLFormatInfos m_CharFormatInfos;
SwHTMLFormatInfos m_TextCollInfos;
std::vector<SwFormatINetFormat*> m_aINetFormats; // the "open" INet attributes
- std::unique_ptr<std::vector<SwTextFootnote*>> m_pFootEndNotes;
+ std::optional<std::vector<SwTextFootnote*>> m_xFootEndNotes;
OUString m_aCSS1Selector; // style selector
- OUString m_aNonConvertableCharacters;
OUString m_aBulletGrfs[MAXLEVEL]; // list graphics
css::uno::Reference<css::container::XIndexContainer> mxFormComps; // current form
@@ -305,7 +326,7 @@ public:
sal_uInt32 m_aFontHeights[7]; // font heights 1-7
ErrCode m_nWarn; // warning code
- sal_uInt32 m_nLastLFPos; // last position of LF
+ sal_uInt64 m_nLastLFPos; // last position of LF
HtmlTokenId m_nLastParaToken; // to hold paragraphs together
sal_Int32 m_nBkmkTabPos; // current position in bookmark table
@@ -332,7 +353,6 @@ public:
// that is not contained in class names)
SvxFrameDirection m_nDirection; // the current direction
- rtl_TextEncoding m_eDestEnc;
LanguageType m_eLang;
// description of the export configuration
@@ -377,7 +397,6 @@ public:
bool m_bNoAlign : 1; // HTML tag doesn't allow ALIGN=...
bool m_bClearLeft : 1; // <BR CLEAR=LEFT> write at end of paragraph
bool m_bClearRight : 1; // <BR CLEAR=RIGHT> write at end of paragraph
- bool m_bLFPossible : 1; // a line break can be inserted
// others
@@ -390,7 +409,7 @@ public:
bool mbSkipHeaderFooter : 1;
bool mbEmbedImages : 1;
/// Temporary base URL for paste of images.
- std::unique_ptr<utl::TempFile> mpTempBaseURL;
+ std::unique_ptr<utl::TempFileNamed> mpTempBaseURL;
/// If XHTML markup should be written instead of HTML.
bool mbXHTML = false;
/// XML namespace, in case of XHTML.
@@ -401,16 +420,28 @@ public:
#define sCSS2_P_CLASS_leaders "leaders"
bool m_bCfgPrintLayout : 1; // PrintLayout option for TOC dot leaders
bool m_bParaDotLeaders : 1; // for TOC dot leaders
- // 25
+ // 26
/// Tracks which text portion attributes are currently open: a which id -> open count map.
std::map<sal_uInt16, int> maStartedAttributes;
OUString m_aRTFOLEMimeType;
+ /// ReqIF mode: export images as OLE objects.
+ bool m_bExportImagesAsOLE = false;
+
+ /// ReqIF mode: export formulas as PDFs.
+ bool m_bExportFormulasAsPDF = false;
+
+ /// DPI used when exporting a vector shape as a bitmap.
+ std::optional<sal_Int32> m_nShapeDPI;
+
+ /// If set, replace leading tabs with this many non-breaking spaces.
+ std::optional<sal_Int32> m_nLeadingTabWidth;
+
/// Construct an instance of SwHTMLWriter and optionally give it
/// the filter options directly, which can also be set via SetupFilterOptions().
- explicit SwHTMLWriter( const OUString& rBaseURL, const OUString& rFilterOptions = "" );
+ SW_DLLPUBLIC explicit SwHTMLWriter( const OUString& rBaseURL, std::u16string_view rFilterOptions = std::u16string_view() );
virtual ~SwHTMLWriter() override;
void Out_SwDoc( SwPaM* ); // write the marked range
@@ -426,8 +457,8 @@ public:
void OutHyperlinkHRefValue( const OUString& rURL );
// output the FlyFrame anchored at current position
- bool OutFlyFrame( sal_uLong nNdIdx, sal_Int32 nContentIdx,
- HtmlPosition nPos, HTMLOutContext *pContext = nullptr );
+ bool OutFlyFrame( SwNodeOffset nNdIdx, sal_Int32 nContentIdx,
+ HtmlPosition nPos );
void OutFrameFormat( AllHtmlFlags nType, const SwFrameFormat& rFormat,
const SdrObject *pSdrObj );
@@ -443,25 +474,24 @@ public:
void OutFootEndNoteInfo();
void OutFootEndNotes();
OUString GetFootEndNoteSym( const SwFormatFootnote& rFormatFootnote );
- void OutFootEndNoteSym( const SwFormatFootnote& rFormatFootnote, const OUString& rNum,
+ void OutFootEndNoteSym( const SwFormatFootnote& rFormatFootnote, std::u16string_view rNum,
sal_uInt16 nScript );
void OutBasic(const SwHTMLWriter& rHTMLWrt);
+ // Used to indent inner blocks using dl/dd tags
void OutAndSetDefList( sal_uInt16 nNewLvl );
void OutStyleSheet( const SwPageDesc& rPageDesc );
- inline void OutCSS1_PropertyAscii( const char *pProp,
- const char *pVal );
- inline void OutCSS1_PropertyAscii( const char *pProp,
+ inline void OutCSS1_PropertyAscii( std::string_view pProp,
std::string_view rVal );
- inline void OutCSS1_Property( const char *pProp, const OUString& rVal );
- void OutCSS1_Property( const char *pProp, std::string_view pVal,
- const OUString *pSVal );
- void OutCSS1_UnitProperty( const char *pProp, tools::Long nVal );
- void OutCSS1_PixelProperty( const char *pProp, tools::Long nVal, bool bVert );
- void OutCSS1_SfxItemSet( const SfxItemSet& rItemSet, bool bDeep=true );
+ inline void OutCSS1_Property( std::string_view pProp, const OUString& rVal );
+ void OutCSS1_Property( std::string_view pProp, std::string_view pVal,
+ const OUString *pSVal, std::optional<sw::Css1Background> oBackground = std::nullopt );
+ void OutCSS1_UnitProperty( std::string_view pProp, tools::Long nVal );
+ void OutCSS1_PixelProperty( std::string_view pProp, tools::Long nTwips );
+ void OutCSS1_SfxItemSet( const SfxItemSet& rItemSet, bool bDeep=true, std::string_view rAdd = {} );
// events of BODY tag from SFX configuration
void OutBasicBodyEvents();
@@ -479,13 +509,17 @@ public:
// ALT/ALIGN/WIDTH/HEIGHT/HSPACE/VSPACE option of current
// frame format output and maybe add a <BR CLEAR=...> at the
// beginning of rEndTags
- OString OutFrameFormatOptions( const SwFrameFormat& rFrameFormat, const OUString& rAltText,
+ OString OutFrameFormatOptions( const SwFrameFormat& rFrameFormat, std::u16string_view rAltText,
HtmlFrmOpts nFrameOpts );
- void writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameFormat& rFrameFormat, std::u16string_view rAltText, HtmlFrmOpts nFrameOpts);
+ void writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameFormat& rFrameFormat, const OUString& rAltText, HtmlFrmOpts nFrameOpts);
+ /// Writes the formatting for tables.
void OutCSS1_TableFrameFormatOptions( const SwFrameFormat& rFrameFormat );
- void OutCSS1_TableCellBorderHack(const SwFrameFormat& rFrameFormat);
+
+ /// Writes the borders and background for table cells.
+ void OutCSS1_TableCellBordersAndBG(const SwFrameFormat& rFrameFormat, const SvxBrushItem *pBrushItem);
+
void OutCSS1_SectionFormatOptions( const SwFrameFormat& rFrameFormat, const SwFormatCol *pCol );
void OutCSS1_FrameFormatOptions( const SwFrameFormat& rFrameFormat, HtmlFrmOpts nFrameOpts,
const SdrObject *pSdrObj=nullptr,
@@ -514,11 +548,12 @@ public:
SwPaM* GetEndPaM() { return m_pOrigPam; }
void SetEndPaM( SwPaM* pPam ) { m_pOrigPam = pPam; }
- static sal_uInt32 ToPixel( sal_uInt32 nVal, const bool bVert );
+ static sal_uInt32 ToPixel(sal_uInt32 nTwips);
+ static Size ToPixel(Size aTwips);
- sal_uInt16 GuessFrameType( const SwFrameFormat& rFrameFormat,
+ SwHTMLFrameType GuessFrameType( const SwFrameFormat& rFrameFormat,
const SdrObject*& rpStrObj );
- static sal_uInt16 GuessOLENodeFrameType( const SwNode& rNd );
+ static SwHTMLFrameType GuessOLENodeFrameType( const SwNode& rNd );
void CollectFlyFrames();
@@ -561,7 +596,7 @@ public:
static void GetEEAttrsFromDrwObj( SfxItemSet& rItemSet,
const SdrObject *pObj );
- static sal_uInt16 GetDefListLvl( const OUString& rNm, sal_uInt16 nPoolId );
+ static sal_uInt16 GetDefListLvl( std::u16string_view rNm, sal_uInt16 nPoolId );
sal_uInt32 GetHTMLMode() const
{
@@ -579,14 +614,21 @@ public:
static void PrepareFontList( const SvxFontItem& rFontItem, OUString& rNames,
sal_Unicode cQuote, bool bGeneric );
static sal_uInt16 GetCSS1ScriptForScriptType( sal_uInt16 nScriptType );
- static sal_uInt16 GetLangWhichIdFromScript( sal_uInt16 nScript );
+ static TypedWhichId<SvxLanguageItem> GetLangWhichIdFromScript( sal_uInt16 nScript );
FieldUnit GetCSS1Unit() const { return m_eCSS1Unit; }
- sal_Int32 indexOfDotLeaders( sal_uInt16 nPoolId, const OUString& rText );
+ sal_Int32 indexOfDotLeaders( sal_uInt16 nPoolId, std::u16string_view rText );
/// Determines the prefix string needed to respect the requested namespace alias.
OString GetNamespace() const;
+
+ bool IsPrettyPrint() const { return !m_bSpacePreserve && m_bPrettyPrint; }
+ bool IsLFPossible() const { return !m_bSpacePreserve && m_bLFPossible; }
+ void SetLFPossible(bool val) { m_bLFPossible = val; }
+ bool IsSpacePreserve() const { return m_bSpacePreserve; }
+ void SetSpacePreserve(bool val) { m_bSpacePreserve = val; }
+ bool IsPreserveSpacesOnWritePrefSet() const { return m_bPreserveSpacesOnWrite; }
};
inline bool SwHTMLWriter::IsCSS1Source( sal_uInt16 n ) const
@@ -600,19 +642,13 @@ inline bool SwHTMLWriter::IsCSS1Script( sal_uInt16 n ) const
return CSS1_OUTMODE_ANY_SCRIPT == nScript || n == nScript;
}
-inline void SwHTMLWriter::OutCSS1_PropertyAscii( const char *pProp,
- const char *pVal )
-{
- OutCSS1_Property( pProp, pVal, nullptr );
-}
-
-inline void SwHTMLWriter::OutCSS1_PropertyAscii( const char *pProp,
+inline void SwHTMLWriter::OutCSS1_PropertyAscii( std::string_view pProp,
std::string_view rVal )
{
OutCSS1_Property( pProp, rVal, nullptr );
}
-inline void SwHTMLWriter::OutCSS1_Property( const char *pProp,
+inline void SwHTMLWriter::OutCSS1_Property( std::string_view pProp,
const OUString& rVal )
{
OutCSS1_Property( pProp, std::string_view(), &rVal );
@@ -625,7 +661,7 @@ inline void SwHTMLWriter::OutCSS1_Property( const char *pProp,
// positions in the document.
// In dtor all data is restored and the created PaM is deleted again.
-struct HTMLSaveData
+class HTMLSaveData
{
SwHTMLWriter& rWrt;
std::shared_ptr<SwUnoCursor> pOldPam;
@@ -639,67 +675,73 @@ struct HTMLSaveData
bool bOldOutFooter : 1;
bool bOldOutFlyFrame : 1;
- HTMLSaveData( SwHTMLWriter&, sal_uLong nStt, sal_uLong nEnd,
+public:
+ HTMLSaveData( SwHTMLWriter&, SwNodeOffset nStt, SwNodeOffset nEnd,
bool bSaveNum=true,
const SwFrameFormat *pFrameFormat=nullptr );
~HTMLSaveData();
};
// some function prototypes
-Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFormat,
+SwHTMLWriter& OutHTML_FrameFormatOLENode( SwHTMLWriter& rWrt, const SwFrameFormat& rFormat,
bool bInCntnr );
-Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFormat,
- bool bInCntnr );
+SwHTMLWriter& OutHTML_FrameFormatOLENodeGrf( SwHTMLWriter& rWrt, const SwFrameFormat& rFormat,
+ bool bInCntnr, bool bWriteReplacementGraphic = true );
-Writer& OutHTML_SwTextNode( Writer&, const SwContentNode& );
-Writer& OutHTML_SwTableNode( Writer& , SwTableNode &, const SwFrameFormat *,
+SwHTMLWriter& OutHTML_SwTextNode( SwHTMLWriter&, const SwContentNode& );
+SwHTMLWriter& OutHTML_SwTableNode( SwHTMLWriter& , SwTableNode &, const SwFrameFormat *,
const OUString* pCaption=nullptr, bool bTopCaption=false );
-Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt, const SwDrawFrameFormat& rFormat,
+SwHTMLWriter& OutHTML_DrawFrameFormatAsControl( SwHTMLWriter& rWrt, const SwDrawFrameFormat& rFormat,
const SdrUnoObj& rSdrObj, bool bInCntnr );
-Writer& OutHTML_DrawFrameFormatAsMarquee( Writer& rWrt, const SwDrawFrameFormat& rFormat,
+SwHTMLWriter& OutHTML_DrawFrameFormatAsMarquee( SwHTMLWriter& rWrt, const SwDrawFrameFormat& rFormat,
const SdrObject& rSdrObj );
-Writer& OutHTML_HeaderFooter( Writer& rWrt, const SwFrameFormat& rFrameFormat,
+SwHTMLWriter& OutHTML_HeaderFooter( SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat,
bool bHeader );
-Writer& OutHTML_Image( Writer&, const SwFrameFormat& rFormat,
+SwHTMLWriter& OutHTML_ImageStart( HtmlWriter& rHtml, SwHTMLWriter&, const SwFrameFormat& rFormat,
const OUString& rGraphicURL,
Graphic const & rGraphic, const OUString& rAlternateText,
const Size& rRealSize, HtmlFrmOpts nFrameOpts,
const char *pMarkType,
const ImageMap *pGenImgMap,
- const OUString& rMimeType = OUString() );
+ const OUString& rMimeType = {} );
+SwHTMLWriter& OutHTML_ImageEnd( HtmlWriter& rHtml, SwHTMLWriter& );
-Writer& OutHTML_BulletImage( Writer& rWrt, const char *pTag,
+SwHTMLWriter& OutHTML_BulletImage( SwHTMLWriter& rWrt, const char *pTag,
const SvxBrushItem* pBrush,
const OUString& rGraphicURL);
-Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt );
-Writer& OutHTML_SwFormatFootnote( Writer& rWrt, const SfxPoolItem& rHt );
-Writer& OutHTML_INetFormat( Writer&, const SwFormatINetFormat& rINetFormat, bool bOn );
+SwHTMLWriter& OutHTML_SwFormatField( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
+SwHTMLWriter& OutHTML_SwFormatFootnote( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
+SwHTMLWriter& OutHTML_SwFormatLineBreak(SwHTMLWriter& rWrt, const SfxPoolItem& rHt);
+SwHTMLWriter& OutHTML_INetFormat( SwHTMLWriter&, const SwFormatINetFormat& rINetFormat, bool bOn );
+
+SwHTMLWriter& OutCSS1_BodyTagStyleOpt( SwHTMLWriter& rWrt, const SfxItemSet& rItemSet );
+SwHTMLWriter& OutCSS1_ParaTagStyleOpt( SwHTMLWriter& rWrt, const SfxItemSet& rItemSet, std::string_view rAdd = {} );
-Writer& OutCSS1_BodyTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet );
-Writer& OutCSS1_ParaTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet );
+SwHTMLWriter& OutCSS1_HintSpanTag( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
+SwHTMLWriter& OutCSS1_HintStyleOpt( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
-Writer& OutCSS1_HintSpanTag( Writer& rWrt, const SfxPoolItem& rHt );
-Writer& OutCSS1_HintStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
+/// Writes the background of table rows.
+SwHTMLWriter& OutCSS1_TableBGStyleOpt( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
-Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
-Writer& OutCSS1_NumberBulletListStyleOpt( Writer& rWrt, const SwNumRule& rNumRule,
+SwHTMLWriter& OutCSS1_NumberBulletListStyleOpt( SwHTMLWriter& rWrt, const SwNumRule& rNumRule,
sal_uInt8 nLevel );
-Writer& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt,
+SwHTMLWriter& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt,
const SwHTMLNumRuleInfo& rInfo );
-Writer& OutHTML_NumberBulletListEnd( SwHTMLWriter& rWrt,
+SwHTMLWriter& OutHTML_NumberBulletListEnd( SwHTMLWriter& rWrt,
const SwHTMLNumRuleInfo& rNextInfo );
-Writer& OutCSS1_SvxBox( Writer& rWrt, const SfxPoolItem& rHt );
+SwHTMLWriter& OutCSS1_SvxBox( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
OString GetCSS1_Color(const Color& rColor);
/// Determines if rProperty with a given rValue has to be suppressed due to ReqIF mode.
-bool IgnorePropertyForReqIF(bool bReqIF, std::string_view rProperty, std::string_view rValue);
+bool IgnorePropertyForReqIF(bool bReqIF, std::string_view rProperty, std::string_view rValue,
+ std::optional<sw::Css1Background> oBackground = std::nullopt);
#endif // INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
diff --git a/sw/source/filter/inc/IndexingExport.hxx b/sw/source/filter/inc/IndexingExport.hxx
new file mode 100644
index 000000000000..782ddf7f5f0f
--- /dev/null
+++ b/sw/source/filter/inc/IndexingExport.hxx
@@ -0,0 +1,32 @@
+/* -*- 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/.
+ *
+ */
+
+#pragma once
+
+#include <ModelTraverser.hxx>
+#include <tools/XmlWriter.hxx>
+
+namespace sw
+{
+class SW_DLLPUBLIC IndexingExport
+{
+private:
+ ModelTraverser m_aModelTraverser;
+ tools::XmlWriter m_aXmlWriter;
+
+public:
+ IndexingExport(SvStream& rStream, SwDoc* pDoc);
+
+ bool runExport();
+};
+
+} // end sw namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/inc/IndexingExportFilter.hxx b/sw/source/filter/inc/IndexingExportFilter.hxx
new file mode 100644
index 000000000000..82c56dfa9a61
--- /dev/null
+++ b/sw/source/filter/inc/IndexingExportFilter.hxx
@@ -0,0 +1,68 @@
+/* -*- 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/.
+ */
+
+#pragma once
+
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+namespace sw
+{
+class IndexingExportFilter final
+ : public cppu::WeakImplHelper<css::document::XFilter, css::document::XExporter,
+ css::lang::XInitialization, css::lang::XServiceInfo>
+{
+private:
+ css::uno::Reference<css::lang::XComponent> m_xSourceDocument;
+
+public:
+ IndexingExportFilter() {}
+
+ // XFilter
+ virtual sal_Bool SAL_CALL
+ filter(const css::uno::Sequence<css::beans::PropertyValue>& aDescriptor) override;
+
+ virtual void SAL_CALL cancel() override {}
+
+ // XExporter
+ virtual void SAL_CALL
+ setSourceDocument(const css::uno::Reference<css::lang::XComponent>& xDocument) override
+ {
+ m_xSourceDocument = xDocument;
+ }
+
+ // XInitialization
+ virtual void SAL_CALL
+ initialize(const css::uno::Sequence<css::uno::Any>& /*aArguments*/) override
+ {
+ }
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() override
+ {
+ return "com.sun.star.comp.Writer.IndexingExportFilter";
+ }
+
+ virtual sal_Bool SAL_CALL supportsService(OUString const& rServiceName) override
+ {
+ return cppu::supportsService(this, rServiceName);
+ }
+
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
+ {
+ return { "com.sun.star.document.ExportFilter" };
+ }
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/inc/fltini.hxx b/sw/source/filter/inc/fltini.hxx
index eb48d253d24a..3ee0b3b539a9 100644
--- a/sw/source/filter/inc/fltini.hxx
+++ b/sw/source/filter/inc/fltini.hxx
@@ -29,11 +29,10 @@ class SwNodeIndex;
// the special readers
-class HTMLReader : public Reader
+class HTMLReader final : public Reader
{
// we don't want to have the streams/storages open
virtual bool SetStrmStgPtr() override;
- virtual ErrCode Read(SwDoc&, const OUString& rBaseURL, SwPaM&, const OUString&) override;
virtual OUString GetTemplateName(SwDoc& rDoc) const override;
/// Parse FilterOptions passed to the importer.
@@ -43,11 +42,12 @@ class HTMLReader : public Reader
public:
HTMLReader();
+ virtual ErrCodeMsg Read(SwDoc&, const OUString& rBaseURL, SwPaM&, const OUString&) override;
};
-class XMLReader : public Reader
+class XMLReader final : public Reader
{
- virtual ErrCode Read(SwDoc&, const OUString& rBaseURL, SwPaM&, const OUString&) override;
+ virtual ErrCodeMsg Read(SwDoc&, const OUString& rBaseURL, SwPaM&, const OUString&) override;
public:
virtual SwReaderType GetReaderType() override;
@@ -62,11 +62,10 @@ public:
// the special writers
-void GetWW8Writer(const OUString&, const OUString&, WriterRef&);
+void GetWW8Writer(std::u16string_view, const OUString&, WriterRef&);
// Get size of fly (if 'automatic' in WW) and check if not too small
-SW_DLLPUBLIC void CalculateFlySize(SfxItemSet& rFlySet, const SwNodeIndex& rAnchor,
- SwTwips nPageWidth);
+SW_DLLPUBLIC void CalculateFlySize(SfxItemSet& rFlySet, const SwNode& rAnchor, SwTwips nPageWidth);
#endif
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index e6e74e111e0d..717b79ce8cd1 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -60,17 +60,19 @@ public:
m_nNode = rNode;
m_nContent = nIdx;
}
+
//operators with SwPosition, where the node is hacked to the previous one,
//and the offset to content is de-dynamic-ified
SwFltPosition(const SwPosition &rPos)
- : m_nNode(rPos.nNode, -1)
- , m_nContent(rPos.nContent.GetIndex())
+ : m_nNode(rPos.GetNode(), -1)
+ , m_nContent(rPos.GetContentIndex())
{
}
- void SetPos(const SwPosition &rPos)
+
+ void FromSwPosition(const SwPosition &rPos)
{
- m_nNode = rPos.nNode.GetIndex()-1;
- m_nContent = rPos.nContent.GetIndex();
+ m_nNode = rPos.GetNodeIndex()-1;
+ m_nContent = rPos.GetContentIndex();
}
};
@@ -85,33 +87,22 @@ public:
SwFltPosition m_aMkPos;
SwFltPosition m_aPtPos;
- std::unique_ptr<SfxPoolItem> pAttr;// Format Attribute
+ std::unique_ptr<SfxPoolItem> m_pAttr;// Format Attribute
- bool bOld; // to mark Attributes *before* skipping field results
- bool bOpen; //Entry open, awaiting being closed
- bool bConsumedByField;
+ bool m_bOld; // to mark Attributes *before* skipping field results
+ bool m_bOpen; //Entry open, awaiting being closed
+ bool m_bConsumedByField;
bool m_isAnnotationOnEnd; ///< annotation already moved onto its end pos.
- sal_Int32 mnStartCP;
- sal_Int32 mnEndCP;
- bool bIsParaEnd;
-
SW_DLLPUBLIC SwFltStackEntry(const SwPosition & rStartPos, std::unique_ptr<SfxPoolItem> pHt );
SW_DLLPUBLIC ~SwFltStackEntry();
enum class RegionMode { NoCheck = 0, CheckNodes = 1<<0, CheckFieldmark = 1<<1 };
SW_DLLPUBLIC void SetEndPos( const SwPosition & rEndPos);
- SW_DLLPUBLIC bool MakeRegion(SwDoc& rDoc, SwPaM& rRegion, RegionMode eCheck) const;
- SW_DLLPUBLIC static bool MakeRegion(SwDoc& rDoc, SwPaM& rRegion,
- RegionMode eCheck, const SwFltPosition &rMkPos, const SwFltPosition &rPtPos, bool bIsParaEnd=false,
+ SW_DLLPUBLIC bool MakeRegion(SwPaM& rRegion, RegionMode eCheck) const;
+ SW_DLLPUBLIC static bool MakeRegion(SwPaM& rRegion,
+ RegionMode eCheck, const SwFltPosition &rMkPos, const SwFltPosition &rPtPos,
sal_uInt16 nWhich=0);
-
- void SetStartCP(sal_Int32 nCP) {mnStartCP = nCP;}
- void SetEndCP(sal_Int32 nCP) {mnEndCP = nCP;}
- sal_Int32 GetStartCP() const {return mnStartCP;}
- sal_Int32 GetEndCP() const {return mnEndCP;}
- bool IsParaEnd() const { return bIsParaEnd;}
- void SetIsParaEnd(bool bArg){ bIsParaEnd = bArg;}
};
template<> struct o3tl::typed_flags<SwFltStackEntry::RegionMode>: o3tl::is_typed_flags<SwFltStackEntry::RegionMode, 0x03> {};
@@ -125,23 +116,13 @@ private:
typedef std::vector<std::unique_ptr<SwFltStackEntry>> Entries;
Entries m_Entries;
- sal_uLong nFieldFlags;
-
- bool bHasSdOD;
- bool bSdODChecked;
+ sal_uLong m_nFieldFlags;
protected:
- SwDoc& rDoc;
- bool bIsEndStack;
+ SwDoc& m_rDoc;
+ bool m_bIsEndStack;
virtual void SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry& rEntry);
- virtual sal_Int32 GetCurrAttrCP() const {return -1;}
- virtual bool IsParaEndInCPs(sal_Int32 nStart,sal_Int32 nEnd,bool bSdOD) const;
-
- //Clear the para end position recorded in reader intermittently for the least impact on loading performance
- virtual void ClearParaEndPosition(){};
- virtual bool CheckSdOD(sal_Int32 nStart,sal_Int32 nEnd);
- bool HasSdOD();
public:
enum class MoveAttrsMode { DEFAULT, POSTIT_INSERTED };
@@ -160,13 +141,13 @@ public:
SwFltControlStack(SwDoc& rDo, sal_uLong nFieldFl);
virtual ~SwFltControlStack();
- bool IsFlagSet(Flags no) const { return ::SwFltGetFlag(nFieldFlags, no);}
+ bool IsFlagSet(Flags no) const { return ::SwFltGetFlag(m_nFieldFlags, no);}
void NewAttr(const SwPosition& rPos, const SfxPoolItem & rAttr );
virtual SwFltStackEntry* SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId, bool bTstEnd=true, tools::Long nHand = LONG_MAX, bool consumedByField=false);
- void StealAttr(const SwNodeIndex& rNode);
+ void StealAttr(const SwNode& rNode);
void MarkAllAttrsOld();
void KillUnlockedAttrs(const SwPosition& pPos);
SfxPoolItem* GetFormatStackAttr(sal_uInt16 nWhich, sal_uInt16 * pPos);
@@ -182,10 +163,10 @@ public:
class SwFltAnchorListener;
-class SW_DLLPUBLIC SwFltAnchor: public SfxPoolItem
+class SW_DLLPUBLIC SwFltAnchor final : public SfxPoolItem
{
- SwFrameFormat* pFrameFormat;
- std::unique_ptr<SwFltAnchorListener> pListener;
+ SwFrameFormat* m_pFrameFormat;
+ std::unique_ptr<SwFltAnchorListener> m_pListener;
public:
SwFltAnchor(SwFrameFormat* pFlyFormat);
@@ -196,11 +177,12 @@ public:
virtual bool operator==(const SfxPoolItem&) const override;
virtual SwFltAnchor* Clone(SfxItemPool* = nullptr) const override;
void SetFrameFormat(SwFrameFormat* _pFrameFormat);
- const SwFrameFormat* GetFrameFormat() const { return pFrameFormat; }
- SwFrameFormat* GetFrameFormat() { return pFrameFormat; }
+ const SwFrameFormat* GetFrameFormat() const { return m_pFrameFormat; }
+ SwFrameFormat* GetFrameFormat() { return m_pFrameFormat; }
};
-class SwFltAnchorListener : public SvtListener
+/// Used by SwFltAnchor, to listen to an SwFrameFormat (to be aware when it is replaced or deleted).
+class SwFltAnchorListener final : public SvtListener
{
SwFltAnchor* m_pFltAnchor;
public:
@@ -208,19 +190,19 @@ class SwFltAnchorListener : public SvtListener
virtual void Notify(const SfxHint&) override;
};
-class SW_DLLPUBLIC SwFltRedline : public SfxPoolItem
+class SW_DLLPUBLIC SwFltRedline final : public SfxPoolItem
{
public:
- DateTime aStamp;
- RedlineType eType;
- std::size_t nAutorNo;
+ DateTime m_aStamp;
+ RedlineType m_eType;
+ std::size_t m_nAutorNo;
SwFltRedline(RedlineType eType_,
std::size_t nAutorNo_,
const DateTime& rStamp_)
- : SfxPoolItem(RES_FLTR_REDLINE), aStamp(rStamp_),
- eType(eType_),
- nAutorNo(nAutorNo_)
+ : SfxPoolItem(RES_FLTR_REDLINE), m_aStamp(rStamp_),
+ m_eType(eType_),
+ m_nAutorNo(nAutorNo_)
{
}
@@ -229,7 +211,7 @@ public:
virtual SwFltRedline* Clone(SfxItemPool* = nullptr) const override;
};
-class SW_DLLPUBLIC SwFltBookmark : public SfxPoolItem
+class SW_DLLPUBLIC SwFltBookmark final : public SfxPoolItem
{
private:
@@ -240,7 +222,7 @@ private:
public:
SwFltBookmark( const OUString& rNa,
- const OUString& rVa,
+ OUString aVa,
tools::Long nHand,
const bool bIsTOCBookmark = false );
@@ -258,7 +240,7 @@ public:
};
/// Stores RDF statements on a paragraph (key-value pairs where the subject is the paragraph).
-class SW_DLLPUBLIC SwFltRDFMark : public SfxPoolItem
+class SW_DLLPUBLIC SwFltRDFMark final : public SfxPoolItem
{
tools::Long m_nHandle;
std::vector< std::pair<OUString, OUString> > m_aAttributes;
@@ -271,25 +253,25 @@ public:
void SetHandle(tools::Long nHandle);
tools::Long GetHandle() const;
- void SetAttributes(const std::vector< std::pair<OUString, OUString> >& rAttributes);
+ void SetAttributes(std::vector< std::pair<OUString, OUString> >&& rAttributes);
const std::vector< std::pair<OUString, OUString> >& GetAttributes() const;
};
-class SW_DLLPUBLIC SwFltTOX : public SfxPoolItem
+class SW_DLLPUBLIC SwFltTOX final : public SfxPoolItem
{
std::shared_ptr<SwTOXBase> m_xTOXBase;
- bool bHadBreakItem; // there was a break item BEFORE insertion of the TOX
- bool bHadPageDescItem;
+ bool m_bHadBreakItem; // there was a break item BEFORE insertion of the TOX
+ bool m_bHadPageDescItem;
public:
SwFltTOX(std::shared_ptr<SwTOXBase> xBase);
// "purely virtual methods" of SfxPoolItem
virtual bool operator==(const SfxPoolItem&) const override;
virtual SwFltTOX* Clone(SfxItemPool* = nullptr) const override;
const SwTOXBase& GetBase() const { return *m_xTOXBase; }
- void SetHadBreakItem( bool bVal ) { bHadBreakItem = bVal; }
- void SetHadPageDescItem( bool bVal ) { bHadPageDescItem = bVal; }
- bool HadBreakItem() const { return bHadBreakItem; }
- bool HadPageDescItem() const { return bHadPageDescItem; }
+ void SetHadBreakItem( bool bVal ) { m_bHadBreakItem = bVal; }
+ void SetHadPageDescItem( bool bVal ) { m_bHadPageDescItem = bVal; }
+ bool HadBreakItem() const { return m_bHadBreakItem; }
+ bool HadPageDescItem() const { return m_bHadPageDescItem; }
};
// The WWEndStack behaves like the WWControlStack, except that the attributes
@@ -301,7 +283,7 @@ public:
SwFltEndStack(SwDoc& rDo, sal_uLong nFieldFl)
:SwFltControlStack(rDo, nFieldFl)
{
- bIsEndStack = true;
+ m_bIsEndStack = true;
}
};
diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx
index 209eb0fced41..39c1c465cb16 100644
--- a/sw/source/filter/inc/msfilter.hxx
+++ b/sw/source/filter/inc/msfilter.hxx
@@ -22,7 +22,6 @@
#include <sal/config.h>
-#include <cstddef>
#include <map>
#include <vector>
#include <memory>
@@ -31,7 +30,6 @@
#include <rtl/textenc.h>
#include "fltshell.hxx"
#include <shellio.hxx>
-#include <svl/zforlist.hxx>
#include <svl/listener.hxx>
class SwDoc;
@@ -86,15 +84,15 @@ namespace sw
sal_uLong MSDateTimeFormatToSwFormat(OUString& rParams, SvNumberFormatter *pFormatter, LanguageType &rLang, bool bHijri, LanguageType nDocLang);
/*Used to identify if the previous token is AM time field*/
- bool IsPreviousAM(OUString const & rParams, sal_Int32 nPos);
+ bool IsPreviousAM(std::u16string_view rParams, sal_Int32 nPos);
/*Used to identify if the next token is PM time field*/
- bool IsNextPM(OUString const & rParams, sal_Int32 nPos);
+ bool IsNextPM(std::u16string_view rParams, sal_Int32 nPos);
/** Used by MSDateTimeFormatToSwFormat to identify AM time fields
*/
- bool IsNotAM(OUString const & rParams, sal_Int32 nPos);
+ bool IsNotAM(std::u16string_view rParams, sal_Int32 nPos);
/** Another function used by MSDateTimeFormatToSwFormat
@@ -105,9 +103,6 @@ namespace sw
namespace util
{
- /// Redlining Authors, map word author key to writer author value
- typedef std::map<sal_uInt16, std::size_t> AuthorInfos;
-
/** Clips a value to MAX/MIN 16bit value to make it safe for use
as a position value to give to writer. i.e. +-57.8cm. Sometimes
we see ridiculous values for positioning in rtf and word document,
@@ -167,6 +162,10 @@ namespace sw
in knowing if the style has either a builtin standard id, or is
a user defined style.
+ @param rCollisions
+ Cache of previous name collisions to speed up resolution
+ of later duplicates.
+
@return
The equivalent writer style packaged as a StyleResult to use
for this word style.
@@ -176,7 +175,8 @@ namespace sw
rName and WW-rName[0..SAL_MAX_INT32], which is both unlikely
and impossible.
*/
- StyleResult GetStyle(const OUString& rName, ww::sti eSti);
+ StyleResult GetStyle(const OUString& rName, ww::sti eSti,
+ std::map<OUString, sal_Int32>& rCollisions);
};
/** Knows which writer style a given word style should be imported as
@@ -224,6 +224,10 @@ namespace sw
in knowing if the style has either a builtin standard id, or is
a user defined style.
+ @param rCollisions
+ Cache of previous name collisions to speed up resolution
+ of later duplicates.
+
@return
The equivalent writer style packaged as a StyleResult to use
for this word style.
@@ -233,7 +237,8 @@ namespace sw
rName and WW-rName[0..SAL_MAX_INT32], which is both unlikely
and impossible.
*/
- StyleResult GetStyle(const OUString& rName, ww::sti eSti);
+ StyleResult GetStyle(const OUString& rName, ww::sti eSti,
+ std::map<OUString, sal_Int32>& rCollisions);
};
/** Find suitable names for exporting this font
@@ -248,10 +253,10 @@ namespace sw
public:
OUString msPrimary;
OUString msSecondary;
- explicit FontMapExport(const OUString &rFontDescription);
+ explicit FontMapExport(std::u16string_view rFontDescription);
};
- class InsertedTableListener: public SvtListener
+ class InsertedTableListener final : public SvtListener
{
SwTableNode* m_pTableNode;
public:
@@ -284,9 +289,11 @@ namespace sw
explicit InsertedTablesManager(const SwDoc &rDoc);
private:
bool mbHasRoot;
- std::map<std::unique_ptr<InsertedTableListener>, SwNodeIndex*> maTables;
+ std::map<std::unique_ptr<InsertedTableListener>, SwPosition*> maTables;
};
+ void MoveAttrFieldmarkInserted(SwFltPosition& rMkPos, SwFltPosition& rPtPos, const SwPosition& rPos);
+
class RedlineStack
{
private:
@@ -296,6 +303,8 @@ namespace sw
RedlineStack(RedlineStack const&) = delete;
RedlineStack& operator=(RedlineStack const&) = delete;
+ void ImplDestroy();
+
public:
explicit RedlineStack(SwDoc &rDoc) : mrDoc(rDoc) {}
void MoveAttrsFieldmarkInserted(const SwPosition& rPos);
@@ -313,6 +322,7 @@ namespace sw
SwDoc &mrDoc;
public:
explicit SetInDocAndDelete(SwDoc &rDoc) : mrDoc(rDoc) {}
+ SetInDocAndDelete(SetInDocAndDelete const &) = default;
void operator()(std::unique_ptr<SwFltStackEntry> & pEntry);
private:
SetInDocAndDelete& operator=(const SetInDocAndDelete&) = delete;
@@ -326,9 +336,10 @@ namespace sw
explicit SetEndIfOpen(const SwPosition &rPos) : mrPos(rPos) {}
void operator()(const std::unique_ptr<SwFltStackEntry> & pEntry) const
{
- if (pEntry->bOpen)
+ if (pEntry->m_bOpen)
pEntry->SetEndPos(mrPos);
}
+ SetEndIfOpen(SetEndIfOpen const &) = default;
private:
SetEndIfOpen& operator=(const SetEndIfOpen&) = delete;
};
diff --git a/sw/source/filter/inc/rtf.hxx b/sw/source/filter/inc/rtf.hxx
index f0bff55c5923..ed64c08b76eb 100644
--- a/sw/source/filter/inc/rtf.hxx
+++ b/sw/source/filter/inc/rtf.hxx
@@ -31,17 +31,17 @@ class RTFSurround
sal_uInt8 nJunk : 3;
} Flags;
sal_uInt8 nVal;
- } Value;
+ } m_Value;
public:
RTFSurround(bool bGoldCut, sal_uInt8 nOrder)
{
- Value.Flags.nGoldCut = sal_uInt8(bGoldCut);
- Value.Flags.nOrder = nOrder;
- Value.Flags.nJunk = 0;
+ m_Value.Flags.nGoldCut = sal_uInt8(bGoldCut);
+ m_Value.Flags.nOrder = nOrder;
+ m_Value.Flags.nJunk = 0;
}
- sal_uInt16 GetValue() const { return Value.nVal; }
+ sal_uInt16 GetValue() const { return m_Value.nVal; }
};
#endif // INCLUDED_SW_SOURCE_FILTER_INC_RTF_HXX
diff --git a/sw/source/filter/inc/wrt_fn.hxx b/sw/source/filter/inc/wrt_fn.hxx
index 179fe1f80fb0..b1fdcafa7374 100644
--- a/sw/source/filter/inc/wrt_fn.hxx
+++ b/sw/source/filter/inc/wrt_fn.hxx
@@ -26,13 +26,14 @@ class SwContentNode;
class Writer;
class SfxPoolItem;
class SfxItemSet;
+class SwHTMLWriter;
/* function pointers to the attribute-write functions */
-typedef Writer& (*FnAttrOut)( Writer&, const SfxPoolItem& );
+typedef SwHTMLWriter& (*FnAttrOut)( SwHTMLWriter&, const SfxPoolItem& );
typedef FnAttrOut SwAttrFnTab[ POOLATTR_END - POOLATTR_BEGIN ];
-Writer& Out( const SwAttrFnTab, const SfxPoolItem&, Writer& );
-Writer& Out_SfxItemSet( const SwAttrFnTab, Writer&, const SfxItemSet&,
+SwHTMLWriter& Out( const SwAttrFnTab, const SfxPoolItem&, SwHTMLWriter& );
+SwHTMLWriter& Out_SfxItemSet( const SwAttrFnTab, SwHTMLWriter&, const SfxItemSet&,
bool bDeep );
/* function pointers to the node-write functions */
diff --git a/sw/source/filter/inc/wrtswtbl.hxx b/sw/source/filter/inc/wrtswtbl.hxx
index 98b74fa3d29f..05a9f9f7988b 100644
--- a/sw/source/filter/inc/wrtswtbl.hxx
+++ b/sw/source/filter/inc/wrtswtbl.hxx
@@ -46,50 +46,50 @@ namespace editeng { class SvxBorderLine; }
class SW_DLLPUBLIC SwWriteTableCell
{
- const SwTableBox *pBox; // SwTableBox of the cell
- const SvxBrushItem *pBackground; // inherited background of a row
+ const SwTableBox *m_pBox; // SwTableBox of the cell
+ const SvxBrushItem *m_pBackground; // inherited background of a row
- tools::Long nHeight; // fix/minimum height of a row
+ tools::Long m_nHeight; // fix/minimum height of a row
- sal_uInt32 nWidthOpt; // width from option;
+ sal_uInt32 m_nWidthOpt; // width from option;
- sal_uInt16 nRow; // start row
- sal_uInt16 nCol; // start column
+ sal_uInt16 m_nRow; // start row
+ sal_uInt16 m_nCol; // start column
- sal_uInt16 nRowSpan; // spanned rows
- sal_uInt16 nColSpan; // spanned columns
+ sal_uInt16 m_nRowSpan; // spanned rows
+ sal_uInt16 m_nColSpan; // spanned columns
- bool bPercentWidthOpt;
+ bool m_bPercentWidthOpt;
public:
SwWriteTableCell(const SwTableBox *pB, sal_uInt16 nR, sal_uInt16 nC, sal_uInt16 nRSpan,
sal_uInt16 nCSpan, tools::Long nHght, const SvxBrushItem *pBGround)
- : pBox( pB ), pBackground( pBGround ), nHeight( nHght ), nWidthOpt( 0 ),
- nRow( nR ), nCol( nC ), nRowSpan( nRSpan ), nColSpan( nCSpan ),
- bPercentWidthOpt( false )
+ : m_pBox( pB ), m_pBackground( pBGround ), m_nHeight( nHght ), m_nWidthOpt( 0 ),
+ m_nRow( nR ), m_nCol( nC ), m_nRowSpan( nRSpan ), m_nColSpan( nCSpan ),
+ m_bPercentWidthOpt( false )
{}
- const SwTableBox *GetBox() const { return pBox; }
+ const SwTableBox *GetBox() const { return m_pBox; }
- sal_uInt16 GetRow() const { return nRow; }
- sal_uInt16 GetCol() const { return nCol; }
+ sal_uInt16 GetRow() const { return m_nRow; }
+ sal_uInt16 GetCol() const { return m_nCol; }
- sal_uInt16 GetRowSpan() const { return nRowSpan; }
- sal_uInt16 GetColSpan() const { return nColSpan; }
+ sal_uInt16 GetRowSpan() const { return m_nRowSpan; }
+ sal_uInt16 GetColSpan() const { return m_nColSpan; }
- tools::Long GetHeight() const { return nHeight; }
+ tools::Long GetHeight() const { return m_nHeight; }
sal_Int16 GetVertOri() const;
- const SvxBrushItem *GetBackground() const { return pBackground; }
+ const SvxBrushItem *GetBackground() const { return m_pBackground; }
void SetWidthOpt( sal_uInt16 nWidth, bool bPercent )
{
- nWidthOpt = nWidth; bPercentWidthOpt = bPercent;
+ m_nWidthOpt = nWidth; m_bPercentWidthOpt = bPercent;
}
- sal_uInt32 GetWidthOpt() const { return nWidthOpt; }
- bool HasPercentWidthOpt() const { return bPercentWidthOpt; }
+ sal_uInt32 GetWidthOpt() const { return m_nWidthOpt; }
+ bool HasPercentWidthOpt() const { return m_bPercentWidthOpt; }
};
typedef std::vector<std::unique_ptr<SwWriteTableCell>> SwWriteTableCells;
@@ -97,10 +97,12 @@ typedef std::vector<std::unique_ptr<SwWriteTableCell>> SwWriteTableCells;
class SwWriteTableRow final
{
SwWriteTableCells m_Cells; ///< all cells of the rows
- const SvxBrushItem *pBackground; // background
+ const SvxBrushItem *m_pBackground; // background
- tools::Long nPos; // end position (twips) of the row
+ tools::Long m_nPos; // end position (twips) of the row
bool mbUseLayoutHeights;
+ bool m_bTopBorder; // which borders are there?
+ bool m_bBottomBorder;
SwWriteTableRow & operator= (const SwWriteTableRow &) = delete;
@@ -109,12 +111,6 @@ class SwWriteTableRow final
public:
- sal_uInt16 nTopBorder; // thickness of upper/lower border
- sal_uInt16 nBottomBorder;
-
- bool bTopBorder : 1; // which borders are there?
- bool bBottomBorder : 1;
-
SwWriteTableRow( tools::Long nPos, bool bUseLayoutHeights );
SwWriteTableCell *AddCell( const SwTableBox *pBox,
@@ -125,12 +121,14 @@ public:
void SetBackground( const SvxBrushItem *pBGround )
{
- pBackground = pBGround;
+ m_pBackground = pBGround;
}
- const SvxBrushItem *GetBackground() const { return pBackground; }
+ const SvxBrushItem *GetBackground() const { return m_pBackground; }
- bool HasTopBorder() const { return bTopBorder; }
- bool HasBottomBorder() const { return bBottomBorder; }
+ bool HasTopBorder() const { return m_bTopBorder; }
+ void SetTopBorder(bool value) { m_bTopBorder = value; }
+ bool HasBottomBorder() const { return m_bBottomBorder; }
+ void SetBottomBorder(bool value) { m_bBottomBorder = value; }
const SwWriteTableCells& GetCells() const { return m_Cells; }
@@ -141,7 +139,7 @@ public:
inline bool SwWriteTableRow::operator==( const SwWriteTableRow& rRow ) const
{
// allow for some fuzzyness
- return (nPos >= rRow.nPos ? nPos - rRow.nPos : rRow.nPos - nPos ) <=
+ return (m_nPos >= rRow.m_nPos ? m_nPos - rRow.m_nPos : rRow.m_nPos - m_nPos ) <=
(mbUseLayoutHeights ? 0 : ROWFUZZY);
}
@@ -149,59 +147,62 @@ inline bool SwWriteTableRow::operator<( const SwWriteTableRow& rRow ) const
{
// Since we only know the degrees of truth of 0 and 1 here, we also prefer to
// not let x==y and x<y at the same time ;-)
- return nPos < rRow.nPos - (mbUseLayoutHeights ? 0 : ROWFUZZY);
+ return m_nPos < rRow.m_nPos - (mbUseLayoutHeights ? 0 : ROWFUZZY);
}
using SwWriteTableRows
- = o3tl::sorted_vector< std::unique_ptr<SwWriteTableRow>, o3tl::less_uniqueptr_to<SwWriteTableRow> >;
+ = o3tl::sorted_vector< std::unique_ptr<SwWriteTableRow>, o3tl::less_ptr_to >;
class SwWriteTableCol
{
- sal_uInt32 nPos; // end position of the column
+ sal_uInt32 m_nPos; // end position of the column
- sal_uInt32 nWidthOpt;
+ sal_uInt32 m_nWidthOpt;
- bool bRelWidthOpt : 1;
+ bool m_bRelWidthOpt : 1;
public:
- bool bLeftBorder : 1; // which borders are there?
- bool bRightBorder : 1;
+ bool m_bLeftBorder : 1; // which borders are there?
+ bool m_bRightBorder : 1;
SwWriteTableCol( sal_uInt32 nPosition );
- sal_uInt32 GetPos() const { return nPos; }
+ sal_uInt32 GetPos() const { return m_nPos; }
- bool HasLeftBorder() const { return bLeftBorder; }
+ bool HasLeftBorder() const { return m_bLeftBorder; }
- bool HasRightBorder() const { return bRightBorder; }
+ bool HasRightBorder() const { return m_bRightBorder; }
inline bool operator==( const SwWriteTableCol& rCol ) const;
inline bool operator<( const SwWriteTableCol& rCol ) const;
void SetWidthOpt( sal_uInt32 nWidth, bool bRel )
{
- nWidthOpt = nWidth; bRelWidthOpt = bRel;
+ m_nWidthOpt = nWidth; m_bRelWidthOpt = bRel;
}
- sal_uInt32 GetWidthOpt() const { return nWidthOpt; }
- bool HasRelWidthOpt() const { return bRelWidthOpt; }
+ sal_uInt32 GetWidthOpt() const { return m_nWidthOpt; }
+ bool HasRelWidthOpt() const { return m_bRelWidthOpt; }
};
inline bool SwWriteTableCol::operator==( const SwWriteTableCol& rCol ) const
{
// allow for some fuzzyness
- return (nPos >= rCol.nPos ? nPos - rCol.nPos
- : rCol.nPos - nPos ) <= COLFUZZY;
+ return (m_nPos >= rCol.m_nPos ? m_nPos - rCol.m_nPos
+ : rCol.m_nPos - m_nPos ) <= COLFUZZY;
}
inline bool SwWriteTableCol::operator<( const SwWriteTableCol& rCol ) const
{
// Since we only know the degrees of truth of 0 and 1 here, we also prefer to
// not let x==y and x<y at the same time ;-)
- return nPos + COLFUZZY < rCol.nPos;
+ return m_nPos + COLFUZZY < rCol.m_nPos;
}
struct SwWriteTableColLess {
- bool operator()(std::unique_ptr<SwWriteTableCol> const & lhs, std::unique_ptr<SwWriteTableCol> const & rhs) {
+ template <typename T1, typename T2>
+ requires o3tl::is_reference_to<T1, SwWriteTableCol>
+ && o3tl::is_reference_to<T2, SwWriteTableCol>
+ bool operator()(T1 const& lhs, T2 const& rhs) const {
return lhs->GetPos() < rhs->GetPos();
}
};
@@ -211,7 +212,7 @@ class SwWriteTableCols : public o3tl::sorted_vector<std::unique_ptr<SwWriteTable
class SwTable;
-class SW_DLLPUBLIC SwWriteTable
+class SAL_DLLPUBLIC_RTTI SwWriteTable
{
private:
const SwTable* m_pTable;
@@ -294,10 +295,10 @@ protected:
sal_uInt16 GetRightSpace(size_t nCol, sal_uInt16 nColSpan) const;
public:
- SwWriteTable(const SwTable* pTable, const SwTableLines& rLines, tools::Long nWidth, sal_uInt32 nBWidth,
+ SW_DLLPUBLIC SwWriteTable(const SwTable* pTable, const SwTableLines& rLines, tools::Long nWidth, sal_uInt32 nBWidth,
bool bRel, sal_uInt16 nMaxDepth = USHRT_MAX,
sal_uInt16 nLeftSub=0, sal_uInt16 nRightSub=0, sal_uInt32 nNumOfRowsToRepeat=0);
- SwWriteTable(const SwTable* pTable, const SwHTMLTableLayout *pLayoutInfo);
+ SW_DLLPUBLIC SwWriteTable(const SwTable* pTable, const SwHTMLTableLayout *pLayoutInfo);
virtual ~SwWriteTable();
const SwWriteTableRows& GetRows() const { return m_aRows; }
diff --git a/sw/source/filter/inc/wwstyles.hxx b/sw/source/filter/inc/wwstyles.hxx
index 19faeaad118e..7a253d87c508 100644
--- a/sw/source/filter/inc/wwstyles.hxx
+++ b/sw/source/filter/inc/wwstyles.hxx
@@ -24,7 +24,8 @@
namespace ww
{
- enum sti
+ // When changing, make sure to update GetStiNames in sw/source/filter/ww8/styles.cxx accordingly
+ enum sti : sal_uInt16
{
stiNormal = 0, // 0x0000
stiLev1 = 1, // 0x0001
@@ -147,7 +148,7 @@ namespace ww
@return the sti that word would give it. stiUser if word would treat
it as a user defined style.
*/
- sti GetCanonicalStiFromStc(sal_uInt8 stc) throw();
+ sti GetCanonicalStiFromStc(sal_uInt8 stc) noexcept;
/** Find the WinWord english name from a sti index
@@ -159,7 +160,7 @@ namespace ww
@return the name word would give it if it's an inbuilt name, otherwise
NULL
*/
- const char* GetEnglishNameFromSti(sti eSti) throw();
+ const char* GetEnglishNameFromSti(sti eSti) noexcept;
/** Determine if the WinWord sti is standard Character Style
@@ -168,7 +169,7 @@ namespace ww
@return true if a known inbuild character style
*/
- bool StandardStiIsCharStyle(sti eSti) throw();
+ bool StandardStiIsCharStyle(sti eSti) noexcept;
} // namespace ww
#endif
diff --git a/sw/source/filter/indexing/IndexingExport.cxx b/sw/source/filter/indexing/IndexingExport.cxx
new file mode 100644
index 000000000000..acd7aba45b9c
--- /dev/null
+++ b/sw/source/filter/indexing/IndexingExport.cxx
@@ -0,0 +1,203 @@
+/* -*- 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/.
+ *
+ */
+
+#include <IndexingExport.hxx>
+
+#include <ndtxt.hxx>
+#include <ndole.hxx>
+#include <ndgrf.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdotext.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/editobj.hxx>
+#include <swtable.hxx>
+#include <deque>
+
+namespace sw
+{
+namespace
+{
+class IndexingNodeHandler : public ModelTraverseHandler
+{
+private:
+ tools::XmlWriter& m_rXmlWriter;
+
+ std::deque<SwNode*> maNodeStack;
+
+public:
+ IndexingNodeHandler(tools::XmlWriter& rXmlWriter)
+ : m_rXmlWriter(rXmlWriter)
+ {
+ }
+
+ void handleNode(SwNode* pNode) override
+ {
+ if (pNode->IsOLENode())
+ {
+ handleOLENode(pNode->GetOLENode());
+ }
+ else if (pNode->IsGrfNode())
+ {
+ handleGraphicNode(pNode->GetGrfNode());
+ }
+ else if (pNode->IsTextNode())
+ {
+ handleTextNode(pNode->GetTextNode());
+ }
+ else if (pNode->IsTableNode())
+ {
+ handleTableNode(pNode->GetTableNode());
+ }
+ else if (pNode->IsSectionNode())
+ {
+ handleSectionNode(pNode->GetSectionNode());
+ }
+ else if (pNode->IsEndNode())
+ {
+ handleEndNode(pNode->GetEndNode());
+ }
+ }
+
+ void handleOLENode(const SwOLENode* pOleNode)
+ {
+ auto pFrameFormat = pOleNode->GetFlyFormat();
+ m_rXmlWriter.startElement("object");
+ m_rXmlWriter.attribute("alt", pOleNode->GetTitle());
+ m_rXmlWriter.attribute("name", pFrameFormat->GetName());
+ m_rXmlWriter.attribute("object_type", "ole"_ostr);
+ m_rXmlWriter.endElement();
+ }
+
+ void handleGraphicNode(const SwGrfNode* pGraphicNode)
+ {
+ auto pFrameFormat = pGraphicNode->GetFlyFormat();
+ m_rXmlWriter.startElement("object");
+ m_rXmlWriter.attribute("alt", pGraphicNode->GetTitle());
+ m_rXmlWriter.attribute("name", pFrameFormat->GetName());
+ m_rXmlWriter.attribute("object_type", "graphic"_ostr);
+ m_rXmlWriter.endElement();
+ }
+
+ void handleTextNode(const SwTextNode* pTextNode)
+ {
+ SwNodeOffset nParentIndex(-1);
+ if (!maNodeStack.empty() && maNodeStack.back())
+ {
+ nParentIndex = maNodeStack.back()->GetIndex();
+ }
+ const OUString& rString
+ = pTextNode->GetText().replaceAll(OUStringChar(CH_TXTATR_BREAKWORD), "");
+ if (rString.isEmpty())
+ return;
+ m_rXmlWriter.startElement("paragraph");
+ m_rXmlWriter.attribute("index", sal_Int32(pTextNode->GetIndex()));
+ m_rXmlWriter.attribute("node_type", "writer"_ostr);
+ if (nParentIndex >= SwNodeOffset(0))
+ m_rXmlWriter.attribute("parent_index", sal_Int32(nParentIndex));
+ m_rXmlWriter.content(rString);
+ m_rXmlWriter.endElement();
+ }
+
+ void handleSdrObject(SdrObject* pObject) override
+ {
+ if (pObject->GetName().isEmpty())
+ return;
+
+ m_rXmlWriter.startElement("object");
+ m_rXmlWriter.attribute("name", pObject->GetName());
+ m_rXmlWriter.attribute("alt", pObject->GetTitle());
+ m_rXmlWriter.attribute("object_type", "shape"_ostr);
+ m_rXmlWriter.attribute("description", pObject->GetDescription());
+
+ m_rXmlWriter.endElement();
+
+ SdrTextObj* pTextObject = DynCastSdrTextObj(pObject);
+ if (!pTextObject)
+ return;
+
+ OutlinerParaObject* pOutlinerParagraphObject = pTextObject->GetOutlinerParaObject();
+ if (!pOutlinerParagraphObject)
+ return;
+
+ const EditTextObject& aEdit = pOutlinerParagraphObject->GetTextObject();
+ for (sal_Int32 nParagraph = 0; nParagraph < aEdit.GetParagraphCount(); ++nParagraph)
+ {
+ OUString sText = aEdit.GetText(nParagraph);
+
+ m_rXmlWriter.startElement("paragraph");
+ m_rXmlWriter.attribute("index", nParagraph);
+ m_rXmlWriter.attribute("node_type", "common"_ostr);
+ m_rXmlWriter.attribute("object_name", pObject->GetName());
+ m_rXmlWriter.content(sText);
+ m_rXmlWriter.endElement();
+ }
+ }
+
+ void handleTableNode(SwTableNode* pTableNode)
+ {
+ const SwTableFormat* pFormat = pTableNode->GetTable().GetFrameFormat();
+ OUString sName = pFormat->GetName();
+
+ m_rXmlWriter.startElement("object");
+ m_rXmlWriter.attribute("index", sal_Int32(pTableNode->GetIndex()));
+ m_rXmlWriter.attribute("name", sName);
+ m_rXmlWriter.attribute("object_type", "table"_ostr);
+ m_rXmlWriter.endElement();
+
+ maNodeStack.push_back(pTableNode);
+ }
+
+ void handleSectionNode(SwSectionNode* pSectionNode)
+ {
+ m_rXmlWriter.startElement("object");
+ m_rXmlWriter.attribute("index", sal_Int32(pSectionNode->GetIndex()));
+ m_rXmlWriter.attribute("name", pSectionNode->GetSection().GetSectionName());
+ m_rXmlWriter.attribute("object_type", "section"_ostr);
+ m_rXmlWriter.endElement();
+
+ maNodeStack.push_back(pSectionNode);
+ }
+
+ void handleEndNode(SwEndNode* pEndNode)
+ {
+ if (!maNodeStack.empty() && pEndNode->StartOfSectionNode() == maNodeStack.back())
+ {
+ maNodeStack.pop_back();
+ }
+ }
+};
+
+} // end anonymous namespace
+
+IndexingExport::IndexingExport(SvStream& rStream, SwDoc* pDoc)
+ : m_aModelTraverser(pDoc)
+ , m_aXmlWriter(&rStream)
+{
+}
+
+bool IndexingExport::runExport()
+{
+ bool bResult = m_aXmlWriter.startDocument(2);
+ if (!bResult)
+ return false;
+
+ m_aXmlWriter.startElement("indexing");
+ m_aModelTraverser.addNodeHandler(std::make_shared<IndexingNodeHandler>(m_aXmlWriter));
+ m_aModelTraverser.traverse();
+ m_aXmlWriter.endElement();
+
+ m_aXmlWriter.endDocument();
+
+ return true;
+}
+
+} // end sw namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/indexing/IndexingExportFilter.cxx b/sw/source/filter/indexing/IndexingExportFilter.cxx
new file mode 100644
index 000000000000..6ac3b6e3a88b
--- /dev/null
+++ b/sw/source/filter/indexing/IndexingExportFilter.cxx
@@ -0,0 +1,61 @@
+/* -*- 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/.
+ */
+
+#include <IndexingExportFilter.hxx>
+#include <IndexingExport.hxx>
+
+#include <unotxdoc.hxx>
+#include <docsh.hxx>
+
+#include <unotools/mediadescriptor.hxx>
+#include <comphelper/servicehelper.hxx>
+
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <svl/outstrm.hxx>
+
+using namespace css;
+
+namespace sw
+{
+sal_Bool IndexingExportFilter::filter(const uno::Sequence<beans::PropertyValue>& aDescriptor)
+{
+ bool bReturn = false;
+
+ utl::MediaDescriptor aMediaDesc = aDescriptor;
+
+ // Actually get the SwRootFrame to call dumpAsXml
+ auto pXTextDocument = comphelper::getFromUnoTunnel<SwXTextDocument>(m_xSourceDocument);
+ if (pXTextDocument)
+ {
+ uno::Reference<io::XOutputStream> xOutputStream = aMediaDesc.getUnpackedValueOrDefault(
+ utl::MediaDescriptor::PROP_OUTPUTSTREAM, uno::Reference<io::XOutputStream>());
+
+ std::unique_ptr<SvStream> pStream(new SvOutputStream(xOutputStream));
+ SwDocShell* pShell = pXTextDocument->GetDocShell();
+ SwDoc* pDoc = pShell->GetDoc();
+ if (pDoc)
+ {
+ IndexingExport aIndexingExport(*pStream, pDoc);
+ bReturn = aIndexingExport.runExport();
+ }
+ }
+
+ return bReturn;
+}
+
+} // end namespace sw
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+com_sun_star_comp_Writer_IndexingExportFilter_get_implementation(
+ css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const&)
+{
+ return cppu::acquire(new sw::IndexingExportFilter());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx
index 214322ebafa7..56dd36530224 100644
--- a/sw/source/filter/rtf/swparrtf.cxx
+++ b/sw/source/filter/rtf/swparrtf.cxx
@@ -31,7 +31,7 @@
#include <unotools/streamwrap.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/document/XImporter.hpp>
@@ -45,13 +45,13 @@ namespace
/// Glue class to call RtfImport as an internal filter, needed by copy&paste support.
class SwRTFReader : public Reader
{
- ErrCode Read(SwDoc& rDoc, const OUString& rBaseURL, SwPaM& rPam,
- const OUString& rFileName) override;
+ ErrCodeMsg Read(SwDoc& rDoc, const OUString& rBaseURL, SwPaM& rPam,
+ const OUString& rFileName) override;
};
}
-ErrCode SwRTFReader::Read(SwDoc& rDoc, const OUString& /*rBaseURL*/, SwPaM& rPam,
- const OUString& /*rFileName*/)
+ErrCodeMsg SwRTFReader::Read(SwDoc& rDoc, const OUString& /*rBaseURL*/, SwPaM& rPam,
+ const OUString& /*rFileName*/)
{
if (!m_pStream)
return ERR_SWG_READ_ERROR;
@@ -59,19 +59,19 @@ ErrCode SwRTFReader::Read(SwDoc& rDoc, const OUString& /*rBaseURL*/, SwPaM& rPam
// We want to work in an empty paragraph.
// Step 1: XTextRange will be updated when content is inserted, so we know
// the end position.
- const uno::Reference<text::XTextRange> xInsertPosition
+ const rtl::Reference<SwXTextRange> xInsertPosition
= SwXTextRange::CreateXTextRange(rDoc, *rPam.GetPoint(), nullptr);
auto pSttNdIdx = std::make_shared<SwNodeIndex>(rDoc.GetNodes());
const SwPosition* pPos = rPam.GetPoint();
// Step 2: Split once and remember the node that has been split.
rDoc.getIDocumentContentOperations().SplitNode(*pPos, false);
- *pSttNdIdx = pPos->nNode.GetIndex() - 1;
+ *pSttNdIdx = pPos->GetNodeIndex() - 1;
// Step 3: Split again.
rDoc.getIDocumentContentOperations().SplitNode(*pPos, false);
auto pSttNdIdx2 = std::make_shared<SwNodeIndex>(rDoc.GetNodes());
- *pSttNdIdx2 = pPos->nNode.GetIndex();
+ *pSttNdIdx2 = pPos->GetNodeIndex();
// Step 4: Insert all content into the new node
rPam.Move(fnMoveBackward);
@@ -89,7 +89,7 @@ ErrCode SwRTFReader::Read(SwDoc& rDoc, const OUString& /*rBaseURL*/, SwPaM& rPam
uno::Reference<lang::XComponent> xDstDoc(pDocShell->GetModel(), uno::UNO_QUERY_THROW);
xImporter->setTargetDocument(xDstDoc);
- const uno::Reference<text::XTextRange> xInsertTextRange
+ const rtl::Reference<SwXTextRange> xInsertTextRange
= SwXTextRange::CreateXTextRange(rDoc, *rPam.GetPoint(), nullptr);
uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
@@ -97,7 +97,8 @@ ErrCode SwRTFReader::Read(SwDoc& rDoc, const OUString& /*rBaseURL*/, SwPaM& rPam
{ { "InputStream",
uno::Any(uno::Reference<io::XStream>(new utl::OStreamWrapper(*m_pStream))) },
{ "InsertMode", uno::Any(true) },
- { "TextInsertModeRange", uno::Any(xInsertTextRange) } }));
+ { "TextInsertModeRange",
+ uno::Any(uno::Reference<text::XTextRange>(xInsertTextRange)) } }));
auto ret = ERRCODE_NONE;
try
{
@@ -124,10 +125,9 @@ ErrCode SwRTFReader::Read(SwDoc& rDoc, const OUString& /*rBaseURL*/, SwPaM& rPam
{
// If the PaM points to the first new node, move the PaM to the
// end of the previous node.
- if (aPam.GetPoint()->nNode == aNxtIdx)
+ if (aPam.GetPoint()->GetNode() == aNxtIdx.GetNode())
{
- aPam.GetPoint()->nNode = *pSttNdIdx;
- aPam.GetPoint()->nContent.Assign(pTextNode, pTextNode->GetText().getLength());
+ aPam.GetPoint()->Assign(*pTextNode, pTextNode->GetText().getLength());
}
// If the first new node isn't empty, convert the node's text
// attributes into hints. Otherwise, set the new node's
diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx
index 8076b23a5bb5..3f63f4d3eb5b 100644
--- a/sw/source/filter/writer/writer.cxx
+++ b/sw/source/filter/writer/writer.cxx
@@ -22,7 +22,7 @@
#include <sot/storage.hxx>
#include <sfx2/docfile.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <editeng/fontitem.hxx>
#include <editeng/eeitem.hxx>
#include <osl/diagnose.h>
@@ -38,40 +38,19 @@
using namespace css;
-namespace
-{
- SvStream& lcl_OutLongExt( SvStream& rStrm, sal_uLong nVal, bool bNeg )
- {
- char aBuf[28];
-
- int i = SAL_N_ELEMENTS(aBuf);
- aBuf[--i] = 0;
- do
- {
- aBuf[--i] = '0' + static_cast<char>(nVal % 10);
- nVal /= 10;
- } while (nVal);
-
- if (bNeg)
- aBuf[--i] = '-';
-
- return rStrm.WriteCharPtr( &aBuf[i] );
- }
-}
-
-typedef std::multimap<sal_uLong, const ::sw::mark::IMark*> SwBookmarkNodeTable;
+typedef std::multimap<SwNodeOffset, const ::sw::mark::IMark*> SwBookmarkNodeTable;
struct Writer_Impl
{
SvStream * m_pStream;
- std::unique_ptr< std::map<OUString, OUString> > pFileNameMap;
- std::vector<const SvxFontItem*> aFontRemoveLst;
+ std::map<OUString, OUString> maFileNameMap;
+ std::vector<SfxPoolItemHolder> aFontRemoveLst;
SwBookmarkNodeTable aBkmkNodePos;
Writer_Impl();
- void RemoveFontList( SwDoc& rDoc );
+ void RemoveFontList();
void InsertBkmk( const ::sw::mark::IMark& rBkmk );
};
@@ -80,23 +59,20 @@ Writer_Impl::Writer_Impl()
{
}
-void Writer_Impl::RemoveFontList( SwDoc& rDoc )
+void Writer_Impl::RemoveFontList()
{
- for( const auto& rpFontItem : aFontRemoveLst )
- {
- rDoc.GetAttrPool().Remove( *rpFontItem );
- }
+ aFontRemoveLst.clear();
}
void Writer_Impl::InsertBkmk(const ::sw::mark::IMark& rBkmk)
{
- sal_uLong nNd = rBkmk.GetMarkPos().nNode.GetIndex();
+ SwNodeOffset nNd = rBkmk.GetMarkPos().GetNodeIndex();
aBkmkNodePos.emplace( nNd, &rBkmk );
- if(rBkmk.IsExpanded() && rBkmk.GetOtherMarkPos().nNode != nNd)
+ if(rBkmk.IsExpanded() && rBkmk.GetOtherMarkPos().GetNodeIndex() != nNd)
{
- nNd = rBkmk.GetOtherMarkPos().nNode.GetIndex();
+ nNd = rBkmk.GetOtherMarkPos().GetNodeIndex();
aBkmkNodePos.emplace( nNd, &rBkmk );
}
}
@@ -140,7 +116,7 @@ const IDocumentStylePoolAccess& Writer::getIDocumentStylePoolAccess() const { re
void Writer::ResetWriter()
{
- m_pImpl->RemoveFontList( *m_pDoc );
+ m_pImpl->RemoveFontList();
m_pImpl.reset(new Writer_Impl);
if( m_pCurrentPam )
@@ -181,20 +157,20 @@ bool Writer::CopyNextPam( SwPaM ** ppPam )
sal_Int32 Writer::FindPos_Bkmk(const SwPosition& rPos) const
{
const IDocumentMarkAccess* const pMarkAccess = m_pDoc->getIDocumentMarkAccess();
- const IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->findFirstBookmarkStartsAfter(rPos);
- if(ppBkmk != pMarkAccess->getBookmarksEnd())
- return ppBkmk - pMarkAccess->getBookmarksBegin();
+ const IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->findFirstMarkNotStartsBefore(rPos);
+ if(ppBkmk != pMarkAccess->getAllMarksEnd())
+ return ppBkmk - pMarkAccess->getAllMarksBegin();
return -1;
}
std::shared_ptr<SwUnoCursor>
-Writer::NewUnoCursor(SwDoc & rDoc, sal_uLong const nStartIdx, sal_uLong const nEndIdx)
+Writer::NewUnoCursor(SwDoc & rDoc, SwNodeOffset const nStartIdx, SwNodeOffset const nEndIdx)
{
SwNodes *const pNds = &rDoc.GetNodes();
SwNodeIndex aStt( *pNds, nStartIdx );
SwContentNode* pCNode = aStt.GetNode().GetContentNode();
- if( !pCNode && nullptr == pNds->GoNext( &aStt ) )
+ if (!pCNode && nullptr == SwNodes::GoNext(&aStt))
{
OSL_FAIL( "No more ContentNode at StartPos" );
}
@@ -206,8 +182,7 @@ Writer::NewUnoCursor(SwDoc & rDoc, sal_uLong const nStartIdx, sal_uLong const nE
if (!pCNode)
pCNode = SwNodes::GoPrevious(&aStt);
assert(pCNode && "No more ContentNode at StartPos");
- pCNode->MakeEndIndex( &pNew->GetPoint()->nContent );
- pNew->GetPoint()->nNode = aStt;
+ pNew->GetPoint()->AssignEndIndex( *pCNode );
return pNew;
}
@@ -223,28 +198,14 @@ void Writer::SetStream(SvStream *const pStream)
m_pImpl->m_pStream = pStream;
}
-SvStream& Writer::OutLong( SvStream& rStrm, tools::Long nVal )
-{
- const bool bNeg = nVal < 0;
- if (bNeg)
- nVal = -nVal;
-
- return lcl_OutLongExt(rStrm, static_cast<sal_uLong>(nVal), bNeg);
-}
-
-SvStream& Writer::OutULong( SvStream& rStrm, sal_uLong nVal )
-{
- return lcl_OutLongExt(rStrm, nVal, false);
-}
-
-ErrCode Writer::Write( SwPaM& rPaM, SvStream& rStrm, const OUString* pFName )
+ErrCodeMsg Writer::Write( SwPaM& rPaM, SvStream& rStrm, const OUString* pFName )
{
if ( IsStgWriter() )
{
- ErrCode nResult = ERRCODE_ABORT;
+ ErrCodeMsg nResult = ERRCODE_ABORT;
try
{
- tools::SvRef<SotStorage> aRef = new SotStorage( rStrm );
+ rtl::Reference<SotStorage> aRef = new SotStorage(rStrm);
nResult = Write( rPaM, *aRef, pFName );
if ( nResult == ERRCODE_NONE )
aRef->Commit();
@@ -277,7 +238,7 @@ ErrCode Writer::Write( SwPaM& rPaM, SvStream& rStrm, const OUString* pFName )
void Writer::SetupFilterOptions(SfxMedium& /*rMedium*/)
{}
-ErrCode Writer::Write( SwPaM& rPam, SfxMedium& rMedium, const OUString* pFileName )
+ErrCodeMsg Writer::Write( SwPaM& rPam, SfxMedium& rMedium, const OUString* pFileName )
{
SetupFilterOptions(rMedium);
// This method must be overridden in SwXMLWriter a storage from medium will be used there.
@@ -285,13 +246,13 @@ ErrCode Writer::Write( SwPaM& rPam, SfxMedium& rMedium, const OUString* pFileNam
return Write( rPam, *rMedium.GetOutStream(), pFileName );
}
-ErrCode Writer::Write( SwPaM& /*rPam*/, SotStorage&, const OUString* )
+ErrCodeMsg Writer::Write( SwPaM& /*rPam*/, SotStorage&, const OUString* )
{
OSL_ENSURE( false, "Write in Storages on a stream?" );
return ERR_SWG_WRITE_ERROR;
}
-ErrCode Writer::Write( SwPaM&, const uno::Reference < embed::XStorage >&, const OUString*, SfxMedium* )
+ErrCodeMsg Writer::Write( SwPaM&, const uno::Reference < embed::XStorage >&, const OUString*, SfxMedium* )
{
OSL_ENSURE( false, "Write in Storages on a stream?" );
return ERR_SWG_WRITE_ERROR;
@@ -305,26 +266,23 @@ bool Writer::CopyLocalFileToINet( OUString& rFileNm )
bool bRet = false;
INetURLObject aFileUrl( rFileNm ), aTargetUrl( *m_pOrigFileName );
-// this is our old without the Mail-Export
- if( ! ( INetProtocol::File == aFileUrl.GetProtocol() &&
- INetProtocol::File != aTargetUrl.GetProtocol() &&
- INetProtocol::Ftp <= aTargetUrl.GetProtocol() &&
- INetProtocol::VndSunStarWebdav >= aTargetUrl.GetProtocol() ) )
- return bRet;
-
- if (m_pImpl->pFileNameMap)
+ if (!(INetProtocol::File == aFileUrl.GetProtocol()
+ && (INetProtocol::Http == aTargetUrl.GetProtocol()
+ || INetProtocol::Https == aTargetUrl.GetProtocol()
+ || INetProtocol::VndSunStarWebdav == aTargetUrl.GetProtocol()
+ || INetProtocol::Smb == aTargetUrl.GetProtocol()
+ || INetProtocol::Sftp == aTargetUrl.GetProtocol()
+ || INetProtocol::Cmis == aTargetUrl.GetProtocol())))
{
- // has the file been moved?
- std::map<OUString, OUString>::iterator it = m_pImpl->pFileNameMap->find( rFileNm );
- if ( it != m_pImpl->pFileNameMap->end() )
- {
- rFileNm = it->second;
- return true;
- }
+ return bRet;
}
- else
+
+ // has the file been moved?
+ std::map<OUString, OUString>::iterator it = m_pImpl->maFileNameMap.find( rFileNm );
+ if ( it != m_pImpl->maFileNameMap.end() )
{
- m_pImpl->pFileNameMap.reset( new std::map<OUString, OUString> );
+ rFileNm = it->second;
+ return true;
}
OUString aSrc = rFileNm;
@@ -338,11 +296,11 @@ bool Writer::CopyLocalFileToINet( OUString& rFileNm )
aSrcFile.Close();
aDstFile.Commit();
- bRet = ERRCODE_NONE == aDstFile.GetError();
+ bRet = ERRCODE_NONE == aDstFile.GetErrorIgnoreWarning();
if( bRet )
{
- m_pImpl->pFileNameMap->insert( std::make_pair( aSrc, aDest ) );
+ m_pImpl->maFileNameMap.insert( std::make_pair( aSrc, aDest ) );
rFileNm = aDest;
}
@@ -357,7 +315,6 @@ void Writer::PutNumFormatFontsInAttrPool()
SfxItemPool& rPool = m_pDoc->GetAttrPool();
const SwNumRuleTable& rListTable = m_pDoc->GetNumRuleTable();
const SwNumFormat* pFormat;
- const vcl::Font* pFont;
const vcl::Font* pDefFont = &numfunc::GetDefBulletFont();
bool bCheck = false;
@@ -371,9 +328,9 @@ void Writer::PutNumFormatFontsInAttrPool()
if( SVX_NUM_CHAR_SPECIAL == (pFormat = &pRule->Get( nLvl ))->GetNumberingType() ||
SVX_NUM_BITMAP == pFormat->GetNumberingType() )
{
- pFont = pFormat->GetBulletFont();
- if( nullptr == pFont )
- pFont = pDefFont;
+ std::optional<vcl::Font> pFont = pFormat->GetBulletFont();
+ if( !pFont )
+ pFont = *pDefFont;
if( bCheck )
{
@@ -405,34 +362,35 @@ void Writer::PutEditEngFontsInAttrPool()
void Writer::AddFontItems_( SfxItemPool& rPool, sal_uInt16 nW )
{
- const SvxFontItem* pFont = static_cast<const SvxFontItem*>(&rPool.GetDefaultItem( nW ));
+ const SvxFontItem* pFont = static_cast<const SvxFontItem*>(&rPool.GetUserOrPoolDefaultItem( nW ));
AddFontItem( rPool, *pFont );
- pFont = static_cast<const SvxFontItem*>(rPool.GetPoolDefaultItem( nW ));
+ pFont = static_cast<const SvxFontItem*>(rPool.GetUserDefaultItem( nW ));
if( nullptr != pFont )
AddFontItem( rPool, *pFont );
- for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(nW))
+ ItemSurrogates aSurrogates;
+ rPool.GetItemSurrogates(aSurrogates, nW);
+ for (const SfxPoolItem* pItem : aSurrogates)
AddFontItem( rPool, *static_cast<const SvxFontItem*>(pItem) );
}
void Writer::AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont )
{
- const SvxFontItem* pItem;
+ SfxPoolItemHolder aItem;
if( RES_CHRATR_FONT != rFont.Which() )
{
SvxFontItem aFont( rFont );
aFont.SetWhich( RES_CHRATR_FONT );
- pItem = &rPool.Put( aFont );
+ aItem = SfxPoolItemHolder(rPool, &aFont);
+ assert(aItem.getItem() != &aFont && "Pointer to local outside scope (pushed to aFontRemoveLst)");
}
else
- pItem = &rPool.Put( rFont );
+ aItem = SfxPoolItemHolder(rPool, &rFont);
- if( 1 < pItem->GetRefCount() )
- rPool.Remove( *pItem );
- else
+ if(1 == aItem.getItem()->GetRefCount())
{
- m_pImpl->aFontRemoveLst.push_back( pItem );
+ m_pImpl->aFontRemoveLst.push_back(aItem);
}
}
@@ -455,7 +413,7 @@ bool Writer::GetBookmarks(const SwContentNode& rNd, sal_Int32 nStt,
{
OSL_ENSURE( rArr.empty(), "there are still entries available" );
- sal_uLong nNd = rNd.GetIndex();
+ SwNodeOffset nNd = rNd.GetIndex();
std::pair<SwBookmarkNodeTable::const_iterator, SwBookmarkNodeTable::const_iterator> aIterPair
= m_pImpl->aBkmkNodePos.equal_range( nNd );
if( aIterPair.first != aIterPair.second )
@@ -471,15 +429,15 @@ bool Writer::GetBookmarks(const SwContentNode& rNd, sal_Int32 nStt,
{
const ::sw::mark::IMark& rBkmk = *(it->second);
sal_Int32 nContent;
- if( rBkmk.GetMarkPos().nNode == nNd &&
- (nContent = rBkmk.GetMarkPos().nContent.GetIndex() ) >= nStt &&
+ if( rBkmk.GetMarkPos().GetNode() == rNd &&
+ (nContent = rBkmk.GetMarkPos().GetContentIndex() ) >= nStt &&
nContent < nEnd )
{
rArr.push_back( &rBkmk );
}
- else if( rBkmk.IsExpanded() && nNd ==
- rBkmk.GetOtherMarkPos().nNode.GetIndex() && (nContent =
- rBkmk.GetOtherMarkPos().nContent.GetIndex() ) >= nStt &&
+ else if( rBkmk.IsExpanded() &&
+ (rNd == rBkmk.GetOtherMarkPos().GetNode()) &&
+ (nContent = rBkmk.GetOtherMarkPos().GetContentIndex()) >= nStt &&
nContent < nEnd )
{
rArr.push_back( &rBkmk );
@@ -497,7 +455,7 @@ ErrCode StgWriter::WriteStream()
return ERR_SWG_WRITE_ERROR;
}
-ErrCode StgWriter::Write( SwPaM& rPaM, SotStorage& rStg, const OUString* pFName )
+ErrCodeMsg StgWriter::Write( SwPaM& rPaM, SotStorage& rStg, const OUString* pFName )
{
SetStream(nullptr);
m_pStg = &rStg;
@@ -511,7 +469,7 @@ ErrCode StgWriter::Write( SwPaM& rPaM, SotStorage& rStg, const OUString* pFName
// for comparison secure to the current Pam
m_pOrigPam = &rPaM;
- ErrCode nRet = WriteStorage();
+ ErrCodeMsg nRet = WriteStorage();
m_pStg = nullptr;
ResetWriter();
@@ -519,7 +477,7 @@ ErrCode StgWriter::Write( SwPaM& rPaM, SotStorage& rStg, const OUString* pFName
return nRet;
}
-ErrCode StgWriter::Write( SwPaM& rPaM, const uno::Reference < embed::XStorage >& rStg, const OUString* pFName, SfxMedium* pMedium )
+ErrCodeMsg StgWriter::Write( SwPaM& rPaM, const uno::Reference < embed::XStorage >& rStg, const OUString* pFName, SfxMedium* pMedium )
{
SetStream(nullptr);
m_pStg = nullptr;
@@ -534,7 +492,7 @@ ErrCode StgWriter::Write( SwPaM& rPaM, const uno::Reference < embed::XStorage >&
// for comparison secure to the current Pam
m_pOrigPam = &rPaM;
- ErrCode nRet = pMedium ? WriteMedium( *pMedium ) : WriteStorage();
+ ErrCodeMsg nRet = pMedium ? WriteMedium( *pMedium ) : WriteStorage();
m_pStg = nullptr;
ResetWriter();
diff --git a/sw/source/filter/writer/wrt_fn.cxx b/sw/source/filter/writer/wrt_fn.cxx
index 7935ef672671..cda66d3379cb 100644
--- a/sw/source/filter/writer/wrt_fn.cxx
+++ b/sw/source/filter/writer/wrt_fn.cxx
@@ -28,7 +28,7 @@
#include <wrt_fn.hxx>
#include <node.hxx>
-Writer& Out( const SwAttrFnTab pTab, const SfxPoolItem& rHt, Writer & rWrt )
+SwHTMLWriter& Out( const SwAttrFnTab pTab, const SfxPoolItem& rHt, SwHTMLWriter & rWrt )
{
sal_uInt16 nId = rHt.Which();
OSL_ENSURE( nId < POOLATTR_END && nId >= POOLATTR_BEGIN, "SwAttrFnTab::Out()" );
@@ -39,7 +39,7 @@ Writer& Out( const SwAttrFnTab pTab, const SfxPoolItem& rHt, Writer & rWrt )
}
-Writer& Out_SfxItemSet( const SwAttrFnTab pTab, Writer& rWrt,
+SwHTMLWriter& Out_SfxItemSet( const SwAttrFnTab pTab, SwHTMLWriter& rWrt,
const SfxItemSet& rSet, bool bDeep )
{
// at first give the own attributes out
@@ -88,8 +88,8 @@ Writer& Out_SfxItemSet( const SwAttrFnTab pTab, Writer& rWrt,
sal_uInt16 nWhich = aIter.FirstWhich();
while( nWhich )
{
- if( SfxItemState::SET == pSet->GetItemState( nWhich, bDeep, &pItem ) &&
- ( *pItem != rPool.GetDefaultItem( nWhich )
+ if( SfxItemState::SET == aIter.GetItemState( bDeep, &pItem ) &&
+ ( *pItem != rPool.GetUserOrPoolDefaultItem( nWhich )
|| ( pSet->GetParent() &&
*pItem != pSet->GetParent()->Get( nWhich ))
))
diff --git a/sw/source/filter/writer/wrtswtbl.cxx b/sw/source/filter/writer/wrtswtbl.cxx
index 6c16d3c139ef..223ccf96266b 100644
--- a/sw/source/filter/writer/wrtswtbl.cxx
+++ b/sw/source/filter/writer/wrtswtbl.cxx
@@ -38,14 +38,12 @@ using namespace ::com::sun::star;
sal_Int16 SwWriteTableCell::GetVertOri() const
{
sal_Int16 eCellVertOri = text::VertOrientation::TOP;
- if( pBox->GetSttNd() )
+ if( m_pBox->GetSttNd() )
{
- const SfxItemSet& rItemSet = pBox->GetFrameFormat()->GetAttrSet();
- const SfxPoolItem *pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( RES_VERT_ORIENT, false, &pItem ) )
+ const SfxItemSet& rItemSet = m_pBox->GetFrameFormat()->GetAttrSet();
+ if( const SwFormatVertOrient *pItem = rItemSet.GetItemIfSet( RES_VERT_ORIENT, false ) )
{
- sal_Int16 eBoxVertOri =
- static_cast<const SwFormatVertOrient *>(pItem)->GetVertOrient();
+ sal_Int16 eBoxVertOri = pItem->GetVertOrient();
if( text::VertOrientation::CENTER==eBoxVertOri || text::VertOrientation::BOTTOM==eBoxVertOri)
eCellVertOri = eBoxVertOri;
}
@@ -55,9 +53,8 @@ sal_Int16 SwWriteTableCell::GetVertOri() const
}
SwWriteTableRow::SwWriteTableRow( tools::Long nPosition, bool bUseLayoutHeights )
- : pBackground(nullptr), nPos(nPosition), mbUseLayoutHeights(bUseLayoutHeights),
- nTopBorder(USHRT_MAX), nBottomBorder(USHRT_MAX), bTopBorder(true),
- bBottomBorder(true)
+ : m_pBackground(nullptr), m_nPos(nPosition), mbUseLayoutHeights(bUseLayoutHeights),
+ m_bTopBorder(true), m_bBottomBorder(true)
{
}
@@ -76,8 +73,8 @@ SwWriteTableCell *SwWriteTableRow::AddCell( const SwTableBox *pBox,
}
SwWriteTableCol::SwWriteTableCol(sal_uInt32 nPosition)
- : nPos(nPosition), nWidthOpt(0), bRelWidthOpt(false),
- bLeftBorder(true), bRightBorder(true)
+ : m_nPos(nPosition), m_nWidthOpt(0), m_bRelWidthOpt(false),
+ m_bLeftBorder(true), m_bRightBorder(true)
{
}
@@ -149,12 +146,11 @@ tools::Long SwWriteTable::GetLineHeight( const SwTableBox *pBox )
return 0;
const SwFrameFormat *pLineFrameFormat = pLine->GetFrameFormat();
- const SfxPoolItem* pItem;
const SfxItemSet& rItemSet = pLineFrameFormat->GetAttrSet();
tools::Long nHeight = 0;
- if( SfxItemState::SET == rItemSet.GetItemState( RES_FRM_SIZE, true, &pItem ))
- nHeight = static_cast<const SwFormatFrameSize*>(pItem)->GetHeight();
+ if( const SwFormatFrameSize* pItem = rItemSet.GetItemIfSet( RES_FRM_SIZE ) )
+ nHeight = pItem->GetHeight();
return nHeight;
}
@@ -167,20 +163,18 @@ const SvxBrushItem *SwWriteTable::GetLineBrush( const SwTableBox *pBox,
while( pLine )
{
const SwFrameFormat *pLineFrameFormat = pLine->GetFrameFormat();
- const SfxPoolItem* pItem;
const SfxItemSet& rItemSet = pLineFrameFormat->GetAttrSet();
- if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false,
- &pItem ) )
+ if( const SvxBrushItem* pItem = rItemSet.GetItemIfSet( RES_BACKGROUND, false ) )
{
if( !pLine->GetUpper() )
{
if( !pRow->GetBackground() )
- pRow->SetBackground( static_cast<const SvxBrushItem *>(pItem) );
+ pRow->SetBackground( pItem );
pItem = nullptr;
}
- return static_cast<const SvxBrushItem *>(pItem);
+ return pItem;
}
pBox = pLine->GetUpper();
@@ -336,14 +330,14 @@ sal_uInt16 SwWriteTable::GetAbsWidth( sal_uInt16 nCol, sal_uInt16 nColSpan ) con
nWidth -= GetLeftSpace( nCol ) + GetRightSpace( nCol, nColSpan );
OSL_ENSURE( nWidth > 0, "Column Width <= 0. OK?" );
- return nWidth > 0 ? static_cast<sal_uInt16>(nWidth) : 0;
+ return nWidth > 0 ? o3tl::narrowing<sal_uInt16>(nWidth) : 0;
}
sal_uInt16 SwWriteTable::GetRelWidth( sal_uInt16 nCol, sal_uInt16 nColSpan ) const
{
tools::Long nWidth = GetRawWidth( nCol, nColSpan );
- return static_cast<sal_uInt16>(static_cast<tools::Long>(Fraction( nWidth*256 + GetBaseWidth()/2,
+ return o3tl::narrowing<sal_uInt16>(static_cast<tools::Long>(Fraction( nWidth*256 + GetBaseWidth()/2,
GetBaseWidth() )));
}
@@ -353,7 +347,7 @@ sal_uInt16 SwWriteTable::GetPercentWidth( sal_uInt16 nCol, sal_uInt16 nColSpan )
// Looks funny, but is nothing more than
// [(100 * nWidth) + .5] without rounding errors
- return static_cast<sal_uInt16>(static_cast<tools::Long>(Fraction( nWidth*100 + GetBaseWidth()/2,
+ return o3tl::narrowing<sal_uInt16>(static_cast<tools::Long>(Fraction( nWidth*100 + GetBaseWidth()/2,
GetBaseWidth() )));
}
@@ -586,18 +580,16 @@ void SwWriteTable::FillTableRowsCols( tools::Long nStartRPos, sal_uInt16 nStartR
const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
const SwFrameFormat *pLineFrameFormat = pLine->GetFrameFormat();
- const SfxPoolItem* pItem;
const SfxItemSet& rItemSet = pLineFrameFormat->GetAttrSet();
tools::Long nHeight = 0;
- if( SfxItemState::SET == rItemSet.GetItemState( RES_FRM_SIZE, true, &pItem ))
- nHeight = static_cast<const SwFormatFrameSize*>(pItem)->GetHeight();
+ if( const SwFormatFrameSize* pFrameSizeItem = rItemSet.GetItemIfSet( RES_FRM_SIZE ))
+ nHeight = pFrameSizeItem->GetHeight();
const SvxBrushItem *pBrushItem, *pLineBrush = pParentBrush;
- if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false,
- &pItem ) )
+ if( const SvxBrushItem* pTmpBrush = rItemSet.GetItemIfSet( RES_BACKGROUND, false ) )
{
- pLineBrush = static_cast<const SvxBrushItem *>(pItem);
+ pLineBrush = pTmpBrush;
// If the row spans the entire table, we can
// print out the background to the row. Otherwise
@@ -659,7 +651,7 @@ void SwWriteTable::FillTableRowsCols( tools::Long nStartRPos, sal_uInt16 nStartR
// The new table model may have true row span attributes
const sal_Int32 nAttrRowSpan = pBox->getRowSpan();
if ( 1 < nAttrRowSpan )
- nRowSpan = static_cast<sal_uInt16>(nAttrRowSpan);
+ nRowSpan = o3tl::narrowing<sal_uInt16>(nAttrRowSpan);
else if ( nAttrRowSpan < 1 )
nRowSpan = 0;
@@ -684,7 +676,7 @@ void SwWriteTable::FillTableRowsCols( tools::Long nStartRPos, sal_uInt16 nStartR
SwWriteTableCol *pCol = m_aCols[nOldCol].get();
OSL_ENSURE(pCol, "No TableCol found, panic!");
if (pCol)
- pCol->bLeftBorder = false;
+ pCol->m_bLeftBorder = false;
}
if (!(nBorderMask & 8))
@@ -692,23 +684,14 @@ void SwWriteTable::FillTableRowsCols( tools::Long nStartRPos, sal_uInt16 nStartR
SwWriteTableCol *pCol = m_aCols[nCol].get();
OSL_ENSURE(pCol, "No TableCol found, panic!");
if (pCol)
- pCol->bRightBorder = false;
+ pCol->m_bRightBorder = false;
}
if (!(nBorderMask & 1))
- pRow->bTopBorder = false;
- else if (!pRow->nTopBorder || nTopBorder < pRow->nTopBorder)
- pRow->nTopBorder = nTopBorder;
+ pRow->SetTopBorder(false);
if (!(nBorderMask & 2))
- pEndRow->bBottomBorder = false;
- else if (
- !pEndRow->nBottomBorder ||
- nBottomBorder < pEndRow->nBottomBorder
- )
- {
- pEndRow->nBottomBorder = nBottomBorder;
- }
+ pEndRow->SetBottomBorder(false);
}
}
else
@@ -804,8 +787,6 @@ SwWriteTable::SwWriteTable(const SwTable* pTable, const SwHTMLTableLayout *pLayo
{
std::unique_ptr<SwWriteTableRow> pRow(
new SwWriteTableRow( (nRow+1)*ROW_DFLT_HEIGHT, m_bUseLayoutHeights ));
- pRow->nTopBorder = 0;
- pRow->nBottomBorder = 0;
m_aRows.insert( std::move(pRow) );
}
@@ -854,18 +835,18 @@ SwWriteTable::SwWriteTable(const SwTable* pTable, const SwHTMLTableLayout *pLayo
SwWriteTableCol *pCol = m_aCols[nCol].get();
if( !(nBorderMask & 4) )
- pCol->bLeftBorder = false;
+ pCol->m_bLeftBorder = false;
pCol = m_aCols[nCol+nColSpan-1].get();
if( !(nBorderMask & 8) )
- pCol->bRightBorder = false;
+ pCol->m_bRightBorder = false;
if( !(nBorderMask & 1) )
- pRow->bTopBorder = false;
+ pRow->SetTopBorder(false);
SwWriteTableRow *pEndRow = m_aRows[nRow+nRowSpan-1].get();
if( !(nBorderMask & 2) )
- pEndRow->bBottomBorder = false;
+ pEndRow->SetBottomBorder(false);
// The height requires only to be written once
if( nHeight )
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 2a54795e05cc..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 );
@@ -153,7 +152,7 @@ public:
virtual void RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript ) = 0;
/// Start of the paragraph.
- virtual void StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo ) = 0;
+ virtual sal_Int32 StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo, bool bGenerateParaId ) = 0;
/// End of the paragraph.
virtual void EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) = 0;
@@ -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 ) = 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.
@@ -298,7 +297,7 @@ public:
/// Write a section break
/// msword::ColumnBreak or msword::PageBreak
/// bBreakAfter: the break must be scheduled for insertion in the end of current paragraph
- virtual void SectionBreak( sal_uInt8 nC, bool bBreakAfter, const WW8_SepInfo* pSectionInfo = nullptr ) = 0;
+ virtual void SectionBreak( sal_uInt8 nC, bool bBreakAfter, const WW8_SepInfo* pSectionInfo = nullptr, bool bExtraPageBreak = false ) = 0;
// preserve page vertical alignment
virtual void TextVerticalAdjustment( const css::drawing::TextVerticalAdjust) {};
@@ -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
@@ -620,6 +631,7 @@ protected:
virtual void CharGrabBag( const SfxGrabBagItem& ) = 0;
/// Sfx item RES_PARATR_OUTLINELEVEL
+ void ParaOutlineLevelBase( const SfxUInt16Item& rItem );
virtual void ParaOutlineLevel( const SfxUInt16Item& ) = 0;
/// Write the expanded field
@@ -640,9 +652,12 @@ protected:
ww8::GridColsPtr GetGridCols( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner );
ww8::WidthsPtr GetColumnWidths( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner );
+ /// RES_RTL_GUTTER
+ 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() {}
@@ -666,7 +681,7 @@ public:
( ww8::WW8TableNodeInfoInner const * pTableTextNodeInfoInner,
tools::Long& rPageSize, bool& rRelBoxSize );
- virtual void MaybeOutputBrushItem(SfxItemSet const&) { }
+ virtual bool MaybeOutputBrushItem(SfxItemSet const&) { return false; }
/// Exports the definition (image, size) of a single numbering picture bullet.
virtual void BulletDefinition(int /*nId*/, const Graphic& /*rGraphic*/, Size /*aSize*/) {}
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 1808db7a3369..31711eb4e887 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -30,10 +30,10 @@
#include <fchrfmt.hxx>
#include <tgrditem.hxx>
#include <fmtruby.hxx>
+#include <fmtfollowtextflow.hxx>
#include <fmtanchr.hxx>
#include <breakit.hxx>
#include <redline.hxx>
-#include <unocoll.hxx>
#include <unoframe.hxx>
#include <textboxhelper.hxx>
#include <rdfhelper.hxx>
@@ -47,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>
@@ -89,6 +90,7 @@
#include <editeng/editobj.hxx>
#include <editeng/keepitem.hxx>
#include <editeng/borderline.hxx>
+#include <sax/tools/converter.hxx>
#include <svx/xdef.hxx>
#include <svx/xfillit0.hxx>
#include <svx/xflclit.hxx>
@@ -96,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>
@@ -109,7 +111,6 @@
#include <flddropdown.hxx>
#include <fmtclds.hxx>
#include <fmtinfmt.hxx>
-#include <fmtrowsplt.hxx>
#include <fmtline.hxx>
#include <ftninfo.hxx>
#include <htmltbl.hxx>
@@ -132,7 +133,11 @@
#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>
#include <vcl/embeddedfontshelper.hxx>
@@ -144,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;
@@ -162,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
@@ -288,8 +282,124 @@ class FieldMarkParamsHelper
}
};
+// [ISO/IEC29500-1:2016] 17.18.50 ST_LongHexNumber (Eight Digit Hexadecimal Value)
+OUString NumberToHexBinary(sal_Int32 n)
+{
+ OUStringBuffer aBuf;
+ sax::Converter::convertNumberToHexBinary(aBuf, 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)
@@ -309,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);
@@ -333,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();
@@ -355,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
@@ -367,18 +480,26 @@ 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);
}
}
-void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo )
+sal_Int32 DocxAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo,
+ bool bGenerateParaId)
{
// Paragraphs (in headers/footers/comments/frames etc) can start before another finishes.
// So a stack is needed to keep track of each paragraph's status separately.
@@ -386,13 +507,6 @@ void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pText
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;
@@ -400,9 +514,9 @@ void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pText
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 );
@@ -422,10 +536,10 @@ void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pText
// 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 ) );
@@ -435,18 +549,27 @@ void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pText
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();
@@ -454,17 +577,16 @@ void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pText
{
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;
@@ -473,7 +595,14 @@ void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pText
// We will only know if we have to do that later.
m_pSerializer->mark(Tag_StartParagraph_1);
- m_pSerializer->startElementNS(XML_w, XML_p);
+ std::optional<OUString> aParaId;
+ sal_Int32 nParaId = 0;
+ if (bGenerateParaId)
+ {
+ nParaId = m_nNextParaId++;
+ aParaId = NumberToHexBinary(nParaId);
+ }
+ m_pSerializer->startElementNS(XML_w, XML_p, FSNS(XML_w14, XML_paraId), aParaId);
// postpone the output of the run (we get it before the paragraph
// properties, but must write it after them)
@@ -484,112 +613,472 @@ void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pText
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;
+ }
+}
+
+void FramePrHelper::SetFrame(ww8::Frame* pFrame, sal_Int32 nTableDepth)
+{
+ 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();
}
-static void lcl_deleteAndResetTheLists( rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrTokenChildren, rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrDataBindingAttrs, OUString& rSdtPrAlias)
+void SdtBlockHelper::WriteExtraParams(const ::sax_fastparser::FSHelperPtr& pSerializer)
{
- if( pSdtPrTokenChildren.is() )
- pSdtPrTokenChildren.clear();
- if( pSdtPrDataBindingAttrs.is() )
- pSdtPrDataBindingAttrs.clear();
- if (!rSdtPrAlias.isEmpty())
- rSdtPrAlias.clear();
+ 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)
{
- sax_fastparser::FastAttributeList* attrList = FastSerializerHelper::createAttrList();
+ rtl::Reference<sax_fastparser::FastAttributeList> attrList = FastSerializerHelper::createAttrList();
+
+ const SwFormatHoriOrient& rHoriOrient = pFrameFormat->GetHoriOrient();
+ const SwFormatVertOrient& rVertOrient = pFrameFormat->GetVertOrient();
+ awt::Point aPos(rHoriOrient.GetPos(), rVertOrient.GetPos());
- awt::Point aPos(pFrameFormat->GetHoriOrient().GetPos(), pFrameFormat->GetVertOrient().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.
- attrList->add( FSNS( XML_w, XML_w), OString::number(rSize.Width()));
+ // 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:
@@ -607,33 +1096,32 @@ void DocxAttributeOutput::PopulateFrameProperties(const SwFrameFormat* pFrameFor
attrList->add( FSNS( XML_w, XML_hAnchor), relativeFromH );
attrList->add( FSNS( XML_w, XML_hRule), "exact");
- sax_fastparser::XFastAttributeListRef xAttrList(attrList);
- m_pSerializer->singleElementNS( XML_w, XML_framePr, xAttrList );
+ m_pSerializer->singleElementNS( XML_w, XML_framePr, attrList );
}
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 )
@@ -646,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;
@@ -659,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);
@@ -681,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>();
@@ -708,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();
@@ -748,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)
@@ -771,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);
@@ -788,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);
@@ -812,114 +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
- {
- XFastAttributeListRef xAttrList(pSdtPrTokenAttributes.get());
- pSdtPrTokenAttributes.clear();
- 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
- {
- XFastAttributeListRef xAttrList(pSdtPrTokenAttributes.get());
- pSdtPrTokenAttributes.clear();
- 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())
- {
- XFastAttributeListRef xAttrList( pSdtPrDataBindingAttrs.get() );
- pSdtPrDataBindingAttrs.clear();
- 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)
@@ -957,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)
@@ -1026,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())
{
@@ -1043,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())
{
@@ -1073,6 +1469,7 @@ void DocxAttributeOutput::StartParagraphProperties()
void DocxAttributeOutput::InitCollectedParagraphProperties()
{
+ m_pLRSpaceAttrList.clear();
m_pParagraphSpacingAttrList.clear();
// Write the elements in the spec order
@@ -1118,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));
}
@@ -1125,26 +1523,24 @@ void DocxAttributeOutput::WriteCollectedParagraphProperties()
{
if ( m_rExport.SdrExporter().getFlyAttrList().is() )
{
- XFastAttributeListRef xAttrList( m_rExport.SdrExporter().getFlyAttrList().get() );
- 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() )
{
- XFastAttributeListRef xAttrList( m_pParagraphSpacingAttrList.get() );
- m_pParagraphSpacingAttrList.clear();
-
- m_pSerializer->singleElementNS( XML_w, XML_spacing, xAttrList );
+ m_pSerializer->singleElementNS( XML_w, XML_spacing, detachFrom( m_pParagraphSpacingAttrList ) );
}
if ( m_pBackgroundAttrList.is() )
{
- XFastAttributeListRef xAttrList( m_pBackgroundAttrList.get() );
- m_pBackgroundAttrList.clear();
-
- m_pSerializer->singleElementNS( XML_w, XML_shd, xAttrList );
+ m_pSerializer->singleElementNS( XML_w, XML_shd, detachFrom( m_pBackgroundAttrList ) );
+ m_aFramePr.SetUseFrameBackground(false);
}
}
@@ -1154,23 +1550,30 @@ namespace
/// Outputs an item set, that contains the formatting of the paragraph marker.
void lcl_writeParagraphMarkerProperties(DocxAttributeOutput& rAttributeOutput, const SfxItemSet& rParagraphMarkerProperties)
{
+ const SfxItemSet* pOldI = rAttributeOutput.GetExport().GetCurItemSet();
+ rAttributeOutput.GetExport().SetCurItemSet(&rParagraphMarkerProperties);
+
SfxWhichIter aIter(rParagraphMarkerProperties);
sal_uInt16 nWhichId = aIter.FirstWhich();
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)
{
@@ -1180,6 +1583,7 @@ void lcl_writeParagraphMarkerProperties(DocxAttributeOutput& rAttributeOutput, c
}
nWhichId = aIter.NextWhich();
}
+ rAttributeOutput.GetExport().SetCurItemSet(pOldI);
}
const char *RubyAlignValues[] =
@@ -1229,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);
@@ -1242,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,
@@ -1292,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");
@@ -1304,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");
@@ -1357,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
@@ -1370,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 );
@@ -1382,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;
}
@@ -1404,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++ )
{
@@ -1424,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
@@ -1453,6 +1913,16 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /
}
if (pIt->bSep && !pIt->pField)
{
+ // for TOXMark:
+ // Word ignores bookmarks in field result that is empty;
+ // work around this by writing bookmark into field command.
+ if (!m_sFieldBkm.isEmpty())
+ {
+ DoWriteBookmarkTagStart(m_sFieldBkm);
+ DoWriteBookmarkTagEnd(m_nNextBookmarkId);
+ m_nNextBookmarkId++;
+ m_sFieldBkm.clear();
+ }
CmdEndField_Impl(pNode, nPos, true);
// Remove the field if no end needs to be written
if (!pIt->bClose)
@@ -1490,26 +1960,38 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /
}
newStartedHyperlink = true;
- XFastAttributeListRef xAttrList ( m_pHyperlinkAttrList.get() );
- m_pHyperlinkAttrList.clear();
-
- 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);
@@ -1543,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())
{
@@ -1563,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);
}
@@ -1611,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 )
{
@@ -1636,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)
@@ -1668,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;
}
@@ -1677,22 +2198,57 @@ 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(const OUString & bookmarkName)
+void DocxAttributeOutput::DoWriteBookmarkTagEnd(sal_Int32 const nId)
{
- const auto nameToIdIter = m_rOpenedBookmarksIds.find(bookmarkName);
- if (nameToIdIter != m_rOpenedBookmarksIds.end())
- {
- const sal_Int32 nId = nameToIdIter->second;
+ m_pSerializer->singleElementNS(XML_w, XML_bookmarkEnd,
+ 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 );
- m_pSerializer->singleElementNS(XML_w, XML_bookmarkEnd,
+ 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);
}
}
@@ -1703,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++;
}
}
@@ -1718,22 +2274,35 @@ void DocxAttributeOutput::DoWriteBookmarkEndIfExist(sal_Int32 nRunPos)
if (pPos != m_rOpenedBookmarksIds.end())
{
// Output the bookmark
- DoWriteBookmarkTagEnd(aIter->second);
+ DoWriteBookmarkTagEnd(pPos->second);
m_rOpenedBookmarksIds.erase(aIter->second);
}
}
}
/// 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();
@@ -1746,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(bookmarkName);
+ 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);
}
@@ -1764,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));
}
}
@@ -1798,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
@@ -1859,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;
@@ -1914,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;
@@ -1942,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);
@@ -1962,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)
{
@@ -1984,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)
@@ -2030,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 )
@@ -2038,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 )
{
@@ -2066,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)
{
@@ -2075,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::eNONE ) // HYPERLINK fields are just commands
+ 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;
+ }
+ }
+
+ if ( rInfos.eType != ww::eNONE ) // HYPERLINK fields are just commands
{
if ( bWriteRun )
m_pSerializer->startElementNS(XML_w, XML_r);
@@ -2127,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
@@ -2140,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 );
@@ -2185,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() )
@@ -2312,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
@@ -2323,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 )
{
@@ -2362,7 +3216,7 @@ void DocxAttributeOutput::EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos
// Write the bookmark end if any
if ( !m_sFieldBkm.isEmpty() )
{
- DoWriteBookmarkTagEnd(m_sFieldBkm);
+ DoWriteBookmarkTagEnd(m_nNextBookmarkId);
m_nNextBookmarkId++;
}
@@ -2379,13 +3233,21 @@ void DocxAttributeOutput::EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos
// Write the ref field if a bookmark had to be set and the field
// should be visible
if ( !rInfos.pField )
+ {
+ m_sFieldBkm.clear();
return;
+ }
sal_uInt16 nSubType = rInfos.pField->GetSubType( );
bool bIsSetField = rInfos.pField->GetTyp( )->Which( ) == SwFieldIds::SetExp;
bool bShowRef = bIsSetField && ( nSubType & nsSwExtendedSubType::SUB_INVISIBLE ) == 0;
- if ( m_sFieldBkm.isEmpty() || !bShowRef )
+ if (!bShowRef)
+ {
+ m_sFieldBkm.clear();
+ }
+
+ if (m_sFieldBkm.isEmpty())
return;
// Write the field beginning
@@ -2420,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()
@@ -2483,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 ),
@@ -2499,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));
}
@@ -2614,7 +3480,7 @@ std::optional<sal_Int32> lclGetElementIdForName(std::u16string_view rName)
void lclProcessRecursiveGrabBag(sal_Int32 aElementId, const css::uno::Sequence<css::beans::PropertyValue>& rElements, sax_fastparser::FSHelperPtr const & pSerializer)
{
css::uno::Sequence<css::beans::PropertyValue> aAttributes;
- FastAttributeList* pAttributes = FastSerializerHelper::createAttrList();
+ rtl::Reference<FastAttributeList> pAttributes = FastSerializerHelper::createAttrList();
for (const auto& rElement : rElements)
{
@@ -2624,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;
@@ -2640,12 +3506,10 @@ void lclProcessRecursiveGrabBag(sal_Int32 aElementId, const css::uno::Sequence<c
std::optional<sal_Int32> aSubElementId = lclGetElementIdForName(rAttribute.Name);
if(aSubElementId)
- pAttributes->add(*aSubElementId, aValue.getStr());
+ pAttributes->add(*aSubElementId, aValue);
}
- XFastAttributeListRef xAttributesList( pAttributes );
-
- pSerializer->startElement(aElementId, xAttributesList);
+ pSerializer->startElement(aElementId, pAttributes);
for (const auto& rElement : rElements)
{
@@ -2669,41 +3533,34 @@ void DocxAttributeOutput::WriteCollectedRunProperties()
// Write all differed properties
if ( m_pFontsAttrList.is() )
{
- XFastAttributeListRef xAttrList( m_pFontsAttrList.get() );
- m_pFontsAttrList.clear();
- m_pSerializer->singleElementNS( XML_w, XML_rFonts, xAttrList );
+ m_pSerializer->singleElementNS( XML_w, XML_rFonts, detachFrom( m_pFontsAttrList ) );
}
if ( m_pColorAttrList.is() )
{
- XFastAttributeListRef xAttrList( m_pColorAttrList.get() );
-
- m_pSerializer->singleElementNS( XML_w, XML_color, xAttrList );
+ m_pSerializer->singleElementNS( XML_w, XML_color, m_pColorAttrList );
}
if ( m_pEastAsianLayoutAttrList.is() )
{
- XFastAttributeListRef xAttrList( m_pEastAsianLayoutAttrList.get() );
- m_pEastAsianLayoutAttrList.clear();
- m_pSerializer->singleElementNS( XML_w, XML_eastAsianLayout, xAttrList );
+ m_pSerializer->singleElementNS( XML_w, XML_eastAsianLayout,
+ detachFrom(m_pEastAsianLayoutAttrList ) );
}
if ( m_pCharLangAttrList.is() )
{
- XFastAttributeListRef xAttrList( m_pCharLangAttrList.get() );
- m_pCharLangAttrList.clear();
- 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 (OString("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);
@@ -2730,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();
@@ -2742,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);
@@ -2765,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;
@@ -2781,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()
@@ -2837,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;
@@ -2848,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 )
{
@@ -2874,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;
@@ -2891,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)
{
@@ -2920,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*/)
@@ -2932,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);
@@ -2966,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);
@@ -2986,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 );
@@ -2996,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;
@@ -3032,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 );
}
@@ -3043,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.getStr());
+ 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
{
@@ -3062,27 +3954,33 @@ 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];
}
}
}
+ else if (sMark.endsWith("|toxmark"))
+ {
+ if (auto const it = GetExport().m_TOXMarkBookmarksByURL.find(sMark);
+ it != GetExport().m_TOXMarkBookmarksByURL.end())
+ {
+ sMark = it->second;
+ }
+ }
// Spaces are prohibited in bookmark name.
sMark = sMark.replace(' ', '_');
- m_pHyperlinkAttrList->add( FSNS( XML_w, XML_anchor ),
- OUStringToOString( sMark, RTL_TEXTENCODING_UTF8 ).getStr( ) );
+ 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.getStr());
+ m_pHyperlinkAttrList->add(FSNS(XML_w, XML_tgtFrame), rTarget);
}
}
@@ -3092,16 +3990,18 @@ 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;
}
return true;
}
-void DocxAttributeOutput::FieldVanish( const OUString& rText, ww::eField eType )
+void DocxAttributeOutput::FieldVanish(const OUString& rText,
+ ww::eField const eType, OUString const*const pBookmarkName)
{
- WriteField_Impl( nullptr, eType, rText, FieldFlags::All );
+ WriteField_Impl(nullptr, eType, rText, FieldFlags::All, pBookmarkName);
}
// The difference between 'Redline' and 'StartRedline'+'EndRedline' is that:
@@ -3112,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() )
{
@@ -3125,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())
@@ -3157,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)
@@ -3179,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 );
@@ -3190,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;
@@ -3200,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;
@@ -3238,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:
@@ -3259,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 )
@@ -3274,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:
@@ -3345,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;
@@ -3353,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;
+ }
- FastAttributeList* pAttr = FastSerializerHelper::createAttrList();
- pAttr->add( FSNS( XML_w, XML_val ), OString( pVal ) );
+ rtl::Reference<FastAttributeList> pAttr = FastSerializerHelper::createAttrList();
+ pAttr->add( FSNS( XML_w, XML_val ), pVal );
if ( pBorderLine && !pBorderLine->isEmpty() )
{
@@ -3385,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)
@@ -3394,8 +4381,7 @@ static void impl_borderLine( FSHelperPtr const & pSerializer, sal_Int32 elementT
pAttr->add( FSNS( XML_w, XML_shadow ), "1" );
}
- XFastAttributeListRef xAttrs( pAttr );
- pSerializer->singleElementNS( XML_w, elementToken, xAttrs );
+ pSerializer->singleElementNS( XML_w, elementToken, pAttr );
}
static OutputBorderOptions lcl_getTableCellBorderOptions(bool bEcma)
@@ -3426,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[] =
{
@@ -3447,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)
{
@@ -3506,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) {
@@ -3513,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[] =
{
@@ -3559,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 );
@@ -3574,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
@@ -3610,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),
@@ -3621,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 );
@@ -3653,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 );
@@ -3672,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();
@@ -3727,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")
- {
- 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"));
- }
- }
-
- XFastAttributeListRef xAttributeList(pAttributeList);
- m_pSerializer->singleElementNS(XML_w, XML_tblLook, xAttributeList);
- }
- else if (rGrabBagElement.first == "TablePosition" )
- {
- 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.getStr() );
-
- if( !sTblpYSpec.isEmpty() )
- attrListTablePos->add( FSNS( XML_w, XML_tblpYSpec ), sTblpYSpec.getStr() );
-
- sOrientation = convertToOOXMLHoriOrientRel( pFrame->GetFrameFormat().GetHoriOrient().GetRelationOrient() );
- attrListTablePos->add( FSNS( XML_w, XML_horzAnchor ), sOrientation.getStr() );
-
- if( !sTblpXSpec.isEmpty() )
- attrListTablePos->add( FSNS( XML_w, XML_tblpXSpec ), sTblpXSpec.getStr() );
-
- 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.getStr() );
- }
- 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.getStr() );
- }
- 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.getStr() );
- }
- 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.getStr() );
- }
- 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 ) );
- }
- }
- }
-
- XFastAttributeListRef xAttrListTablePosRef( attrListTablePos );
-
- m_pSerializer->singleElementNS( XML_w, XML_tblpPr, xAttrListTablePosRef);
- 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()
@@ -4564,42 +4843,38 @@ 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;
// Extract default attributes first.
- sax_fastparser::FastAttributeList* pAttributeList = FastSerializerHelper::createAttrList();
+ 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;
}
- XFastAttributeListRef xAttributeList(pAttributeList);
- m_pSerializer->startElementNS(XML_w, XML_latentStyles, xAttributeList);
- 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>());
- xAttributeList = pAttributeList;
- m_pSerializer->singleElementNS(XML_w, XML_lsdException, xAttributeList);
- pAttributeList = nullptr;
+ m_pSerializer->singleElementNS(XML_w, XML_lsdException, detachFrom(pAttributeList));
}
m_pSerializer->endElementNS(XML_w, XML_latentStyles);
@@ -4660,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;
@@ -4728,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;
@@ -4859,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();
@@ -4887,63 +5159,34 @@ void DocxAttributeOutput::WriteSrcRect(
XML_b, OString::number(bottom) );
}
-void DocxAttributeOutput::PopRelIdCache()
-{
- if (!m_aRelIdCache.empty())
- m_aRelIdCache.pop();
- if (!m_aSdrRelIdCache.empty())
- m_aSdrRelIdCache.pop();
-}
-
-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];
-
- return aRet;
-}
-
-void DocxAttributeOutput::CacheRelId(BitmapChecksum nChecksum, const OUString& rRelId)
-{
- if (!m_aSdrRelIdCache.empty())
- m_aSdrRelIdCache.top()[nChecksum] = rRelId;
-}
-
uno::Reference<css::text::XTextFrame> DocxAttributeOutput::GetUnoTextFrame(
css::uno::Reference<css::drawing::XShape> xShape)
{
return SwTextBoxHelper::getUnoTextFrame(xShape);
}
-OString 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)
{
- OString 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)
-{
- if (!m_aRelIdCache.empty())
- m_aRelIdCache.top().emplace(nChecksum, rRelId);
+ 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 )
@@ -4957,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() )
{
@@ -4991,29 +5235,22 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
else
aGraphic = *pOLENode->GetGraphic();
- BitmapChecksum aChecksum = aGraphic.GetChecksum();
- aRelId = getExistingGraphicRelId(aChecksum);
+ 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);
- if (aRelId.isEmpty())
+ if (aGraphic.getVectorGraphicData() && aGraphic.getVectorGraphicData()->getType() == VectorGraphicDataType::Svg)
{
- // Not in cache, then need to write it.
- m_rDrawingML.SetFS( m_pSerializer ); // to be sure that we write to the right stream
-
- OUString aImageId = m_rDrawingML.WriteImage(aGraphic);
-
- aRelId = OUStringToOString( aImageId, RTL_TEXTENCODING_UTF8 );
- cacheGraphicRelId(aChecksum, aRelId);
+ 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);
}
@@ -5030,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));
}
}
@@ -5050,20 +5287,17 @@ 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)
- ::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 ).getStr());
- if( GetExport().GetFilter().getVersion( ) != oox::core::ECMA_DIALECT )
- docPrattrList->add( XML_title, OUStringToOString( pGrfNode ? pGrfNode->GetTitle() : pOLEFrameFormat->GetObjTitle(), RTL_TEXTENCODING_UTF8 ).getStr());
- XFastAttributeListRef docPrAttrListRef( docPrattrList );
- m_pSerializer->startElementNS( XML_wp, XML_docPr, docPrAttrListRef );
+ 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;
if (xShapePropSet)
@@ -5084,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 );
@@ -5105,7 +5340,7 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
m_pSerializer->startElementNS(XML_pic, XML_nvPicPr);
// It seems pic:cNvpr and wp:docPr are pretty much the same thing with the same attributes
- m_pSerializer->startElementNS(XML_pic, XML_cNvPr, docPrAttrListRef);
+ m_pSerializer->startElementNS(XML_pic, XML_cNvPr, docPrattrList);
if(!sURL.isEmpty())
m_pSerializer->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), sRelId);
@@ -5133,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
@@ -5145,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)
@@ -5158,8 +5399,7 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
// TODO setup the right values below
m_pSerializer->startElementNS(XML_pic, XML_spPr, XML_bwMode, "auto");
- m_pSerializer->startElementNS(
- XML_a, XML_xfrm, uno::Reference<xml::sax::XFastAttributeList>(xFrameAttributes.get()));
+ m_pSerializer->startElementNS(XML_a, XML_xfrm, xFrameAttributes);
m_pSerializer->singleElementNS(XML_a, XML_off, XML_x, "0", XML_y, "0");
OString aWidth( OString::number( TwipsToEMU( aSize.Width() ) ) );
@@ -5252,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);
@@ -5329,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)
@@ -5369,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
@@ -5484,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)
{
@@ -5492,15 +5734,17 @@ void DocxAttributeOutput::WriteActiveXControl(const SdrObject* pObject, const Sw
}
else
{
+ SwFormatFollowTextFlow const& rFlow(rFrameFormat.GetFollowTextFlow());
const SwFormatHoriOrient& rHoriOri = rFrameFormat.GetHoriOrient();
const SwFormatVertOrient& rVertOri = rFrameFormat.GetVertOrient();
SwFormatSurround const& rSurround(rFrameFormat.GetSurround());
- std::unique_ptr<sax_fastparser::FastAttributeList> pAttrList(docx::SurroundToVMLWrap(rSurround));
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttrList(docx::SurroundToVMLWrap(rSurround));
sShapeId = m_rExport.VMLExporter().AddSdrObject(*pObject,
+ rFlow.GetValue(),
rHoriOri.GetHoriOrient(), rVertOri.GetVertOrient(),
rHoriOri.GetRelationOrient(),
rVertOri.GetRelationOrient(),
- std::move(pAttrList),
+ pAttrList.get(),
true);
}
// Restore default values
@@ -5555,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 ) );
}
/*
@@ -5567,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 )
@@ -5587,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();
@@ -5608,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" )
{
@@ -5635,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" )
{
@@ -5670,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 );
@@ -5679,20 +5923,20 @@ 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);
//Here is an attribute list where we collect the attributes what we want to export
- FastAttributeList* pAttr = FastSerializerHelper::createAttrList();
- pAttr->add(XML_id, rShapeId.getStr());
+ rtl::Reference<FastAttributeList> pAttr = FastSerializerHelper::createAttrList();
+ pAttr->add(XML_id, rShapeId);
//export the fixed shape type for picture frame
m_pSerializer->write(vml::VMLExport::GetVMLShapeTypeDefinition(rShapeId, true));
- pAttr->add(XML_type, "shapetype_" + 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).getStr());
+ pAttr->add(XML_style, GetOLEStyle(rFrameFormat, rSize));
//Get the OLE frame
const SvxBoxItem& rBox = rFrameFormat.GetAttrSet().GetBox();
OString sLineType;
@@ -5710,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!");
@@ -5854,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());
@@ -5910,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!");
@@ -5944,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);
@@ -5991,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);
@@ -5999,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));
}
}
}
@@ -6009,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++);
@@ -6022,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())));
}
}
}
@@ -6099,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;
}
}
}
@@ -6150,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();
@@ -6167,7 +6483,7 @@ void DocxAttributeOutput::WriteOutliner(const OutlinerParaObject& rParaObj)
sal_Int32 nCurrentPos = 0;
sal_Int32 nEnd = aStr.getLength();
- StartParagraph(ww8::WW8TableNodeInfo::Pointer_t());
+ StartParagraph(ww8::WW8TableNodeInfo::Pointer_t(), false);
// Write paragraph properties.
StartParagraphProperties();
@@ -6205,10 +6521,7 @@ void DocxAttributeOutput::WriteOutliner(const OutlinerParaObject& rParaObj)
aAttrIter.NextPos();
}
while( nCurrentPos < nEnd );
- // Word can't handle nested text boxes, so write them on the same level.
- ++m_nTextFrameLevel;
EndParagraph(ww8::WW8TableNodeInfoInner::Pointer_t());
- --m_nTextFrameLevel;
}
m_pSerializer->endElementNS( XML_w, XML_txbxContent );
}
@@ -6218,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_aParagraphSdt.m_bStartedSdt;
+ m_aParagraphSdt.m_bStartedSdt = false;
+ rContext.m_bStartedRunSdt = m_aRunSdt.m_bStartedSdt;
+ m_aRunSdt.m_bStartedSdt = false;
- rContext.m_bStartedParaSdt = m_bStartedParaSdt;
- m_bStartedParaSdt = 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)
@@ -6243,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?
@@ -6258,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;
}
@@ -6299,14 +6620,14 @@ oox::drawingml::DrawingML& DocxAttributeOutput::GetDrawingML()
return m_rDrawingML;
}
-void DocxAttributeOutput::MaybeOutputBrushItem(SfxItemSet const& rSet)
+bool DocxAttributeOutput::MaybeOutputBrushItem(SfxItemSet const& rSet)
{
const XFillStyleItem* pXFillStyleItem(rSet.GetItem<XFillStyleItem>(XATTR_FILLSTYLE));
if ((pXFillStyleItem && pXFillStyleItem->GetValue() != drawing::FillStyle_NONE)
|| !m_rExport.SdrExporter().getDMLTextFrameSyntax())
{
- return;
+ return false;
}
// sw text frames are opaque by default, even with fill none!
@@ -6318,6 +6639,7 @@ void DocxAttributeOutput::MaybeOutputBrushItem(SfxItemSet const& rSet)
pClone->Put(aSolid);
std::unique_ptr<SvxBrushItem> const pBrush(getSvxBrushItemFromSourceSet(*pClone, RES_BACKGROUND));
FormatBackground(*pBrush);
+ return true;
}
namespace {
@@ -6325,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;
}
};
@@ -6354,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",
@@ -6366,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;
- FastAttributeList* pStyleAttributeList = FastSerializerHelper::createAttrList();
+ 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> >();
@@ -6390,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")
@@ -6408,29 +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).getStr());
+ 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");
- XFastAttributeListRef xStyleAttributeList(pStyleAttributeList);
- m_pSerializer->startElementNS( XML_w, XML_style, xStyleAttributeList);
- m_pSerializer->singleElementNS( XML_w, XML_name,
- FSNS( XML_w, XML_val ), pEnglishName ? pEnglishName : rName.toUtf8() );
+ m_pSerializer->startElementNS( XML_w, XML_style, pStyleAttributeList);
+ m_pSerializer->singleElementNS(XML_w, XML_name, FSNS(XML_w, XML_val), rName);
if ( nBase != 0x0FFF && eType != STYLE_TYPE_LIST)
{
@@ -6438,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);
@@ -6506,20 +6825,6 @@ void DocxAttributeOutput::EndStyleProperties( bool bParProp )
}
}
-namespace
-{
-
-void lcl_OutlineLevel(sax_fastparser::FSHelperPtr const & pSerializer, sal_uInt16 nLevel)
-{
- if (nLevel >= WW8ListManager::nMaxLevel)
- nLevel = WW8ListManager::nMaxLevel - 1;
-
- pSerializer->singleElementNS(XML_w, XML_outlineLvl,
- FSNS(XML_w, XML_val), OString::number(nLevel));
-}
-
-}
-
void DocxAttributeOutput::OutlineNumbering(sal_uInt8 const /*nLvl*/)
{
// Handled by ParaOutlineLevel() instead.
@@ -6527,8 +6832,10 @@ void DocxAttributeOutput::OutlineNumbering(sal_uInt8 const /*nLvl*/)
void DocxAttributeOutput::ParaOutlineLevel(const SfxUInt16Item& rItem)
{
- if (rItem.GetValue() > 0)
- lcl_OutlineLevel(m_pSerializer, rItem.GetValue() - 1);
+ sal_uInt16 nOutLvl = std::min(rItem.GetValue(), sal_uInt16(WW8ListManager::nMaxLevel));
+ // Outline Level: in LO Body Text = 0, in MS Body Text = 9
+ nOutLvl = nOutLvl ? nOutLvl - 1 : 9;
+ m_pSerializer->singleElementNS(XML_w, XML_outlineLvl, FSNS(XML_w, XML_val), OString::number(nOutLvl));
}
void DocxAttributeOutput::PageBreakBefore( bool bBreak )
@@ -6540,7 +6847,7 @@ void DocxAttributeOutput::PageBreakBefore( bool bBreak )
FSNS( XML_w, XML_val ), "false" );
}
-void DocxAttributeOutput::SectionBreak( sal_uInt8 nC, bool bBreakAfter, const WW8_SepInfo* pSectionInfo )
+void DocxAttributeOutput::SectionBreak( sal_uInt8 nC, bool bBreakAfter, const WW8_SepInfo* pSectionInfo, bool bExtraPageBreak)
{
switch ( nC )
{
@@ -6557,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;
@@ -6591,10 +6898,22 @@ void DocxAttributeOutput::SectionBreak( sal_uInt8 nC, bool bBreakAfter, const WW
m_rExport.SectionProperties( *pSectionInfo );
m_pSerializer->endElementNS( XML_w, XML_pPr );
+ if (bExtraPageBreak)
+ {
+ m_pSerializer->startElementNS(XML_w, XML_r);
+ m_pSerializer->singleElementNS(XML_w, XML_br, FSNS(XML_w, XML_type), "page");
+ m_pSerializer->endElementNS(XML_w, XML_r);
+ }
m_pSerializer->endElementNS( XML_w, XML_p );
}
else
{
+ if (bExtraPageBreak && m_bParagraphOpened)
+ {
+ m_pSerializer->startElementNS(XML_w, XML_r);
+ m_pSerializer->singleElementNS(XML_w, XML_br, FSNS(XML_w, XML_type), "page");
+ m_pSerializer->endElementNS(XML_w, XML_r);
+ }
// postpone the output of this; it has to be done inside the
// paragraph properties, so remember it until then
m_pSectionInfo.reset( new WW8_SepInfo( *pSectionInfo ));
@@ -6624,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);
}
}
@@ -6666,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;
}
@@ -6675,10 +6994,7 @@ void DocxAttributeOutput::EndSection()
// Write the section properties
if ( m_pSectionSpacingAttrList.is() )
{
- XFastAttributeListRef xAttrList( m_pSectionSpacingAttrList.get() );
- m_pSectionSpacingAttrList.clear();
-
- m_pSerializer->singleElementNS( XML_w, XML_pgMar, xAttrList );
+ m_pSerializer->singleElementNS( XML_w, XML_pgMar, detachFrom( m_pSectionSpacingAttrList ) );
}
// Order the elements
@@ -6696,18 +7012,61 @@ void DocxAttributeOutput::SectionFormProtection( bool bProtected )
m_pSerializer->singleElementNS(XML_w, XML_formProt, FSNS(XML_w, XML_val), "false");
}
+void DocxAttributeOutput::SectionRtlGutter(const SfxBoolItem& rRtlGutter)
+{
+ if (!rRtlGutter.GetValue())
+ {
+ return;
+ }
+
+ 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 )
{
- FastAttributeList* pAttr = FastSerializerHelper::createAttrList();
- pAttr->add( FSNS( XML_w, XML_countBy ), OString::number(rLnNumInfo.GetCountBy()).getStr());
+ rtl::Reference<FastAttributeList> pAttr = FastSerializerHelper::createAttrList();
+ 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());
- XFastAttributeListRef xAttrs( pAttr );
- m_pSerializer->singleElementNS( XML_w, XML_lnNumType, xAttrs );
+ pAttr->add(FSNS(XML_w, XML_start), OString::number(nRestartNo - 1));
+ m_pSerializer->singleElementNS( XML_w, XML_lnNumType, pAttr );
}
void DocxAttributeOutput::SectionTitlePage()
@@ -6743,10 +7102,19 @@ 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))
+ {
+ aMargins.nTop += pFormat->GetLRSpace().GetGutterMargin();
+ }
+ else
+ {
+ aMargins.nLeft += pFormat->GetLRSpace().GetGutterMargin();
+ }
aOutputBorderOptions.pDistances = std::make_shared<editeng::WordBorderDistances>();
editeng::BorderDistancesToWord(rBox, aMargins, *aOutputBorderOptions.pDistances);
@@ -6769,101 +7137,85 @@ void DocxAttributeOutput::SectionBiDi( bool bBiDi )
m_pSerializer->singleElementNS(XML_w, XML_bidi);
}
-static OString impl_NumberingType( sal_uInt16 nNumberingType )
+// Converting Numbering Format Code to string
+static OString lcl_ConvertNumberingType(sal_Int16 nNumberingType, const SfxItemSet* pOutSet, OString& rFormat, const OString& sDefault = ""_ostr )
{
- OString aType;
+ 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_ROMAN_UPPER: aType = "upperRoman"; break;
- case SVX_NUM_ROMAN_LOWER: aType = "lowerRoman"; break;
+ case SVX_NUM_CHARS_LOWER_LETTER_N: aType = "lowerLetter"_ostr; 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;
-
- default: aType = "none"; break;
- }
-
- return aType;
-}
-
-// Converting Level Numbering Format Code to string
-static OString impl_LevelNFC(sal_uInt16 nNumberingType, const SfxItemSet* pOutSet, OString& rFormat)
-{
- OString aType;
-
- switch ( nNumberingType )
- {
- case style::NumberingType::CHARS_UPPER_LETTER:
- case style::NumberingType::CHARS_UPPER_LETTER_N:
- case style::NumberingType::CHARS_LOWER_LETTER:
- case style::NumberingType::CHARS_LOWER_LETTER_N:
- case style::NumberingType::ROMAN_UPPER:
- case style::NumberingType::ROMAN_LOWER:
- case style::NumberingType::ARABIC:
- case style::NumberingType::BITMAP:
- case style::NumberingType::CHAR_SPECIAL:
- case style::NumberingType::CHARS_HEBREW:
- case style::NumberingType::NUMBER_HEBREW:
- case style::NumberingType::NUMBER_NONE:
- return impl_NumberingType( nNumberingType );
- 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_THAI: aType="thaiLetters"; break;
- case style::NumberingType::CHARS_PERSIAN: aType="hindiVowels"; 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::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"_ostr; break;
+ case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_RU:
+ 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 decimal.
+ Fallback the rest to the suggested default.
case style::NumberingType::NATIVE_NUMBERING:
case style::NumberingType::HANGUL_CIRCLED_JAMO_KO:
case style::NumberingType::HANGUL_CIRCLED_SYLLABLE_KO:
@@ -6871,7 +7223,6 @@ static OString impl_LevelNFC(sal_uInt16 nNumberingType, const SfxItemSet* pOutSe
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:
@@ -6879,18 +7230,17 @@ static OString impl_LevelNFC(sal_uInt16 nNumberingType, const SfxItemSet* pOutSe
case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_BG:
case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_N_BG:
case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_N_BG:
- case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_RU:
- case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_RU:
- case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_N_RU:
- case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_N_RU:
case style::NumberingType::CHARS_MYANMAR:
case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_SR:
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:
- aType = "decimal"; break;
+ default: break;
}
return aType;
}
@@ -6900,19 +7250,19 @@ void DocxAttributeOutput::SectionPageNumbering( sal_uInt16 nNumType, const ::std
{
// FIXME Not called properly with page styles like "First Page"
- FastAttributeList* pAttr = FastSerializerHelper::createAttrList();
+ rtl::Reference<FastAttributeList> pAttr = FastSerializerHelper::createAttrList();
// std::nullopt means no restart: then don't output that attribute if it is negative
if ( oPageRestartNumber )
pAttr->add( FSNS( XML_w, XML_start ), OString::number( *oPageRestartNumber ) );
// nNumType corresponds to w:fmt. See WW8Export::GetNumId() for more precisions
- OString aFormat( impl_NumberingType( nNumType ) );
- if ( !aFormat.isEmpty() )
- pAttr->add( FSNS( XML_w, XML_fmt ), aFormat.getStr() );
+ OString aCustomFormat;
+ OString aFormat(lcl_ConvertNumberingType(nNumType, nullptr, aCustomFormat));
+ if (!aFormat.isEmpty() && aCustomFormat.isEmpty())
+ pAttr->add(FSNS(XML_w, XML_fmt), aFormat);
- XFastAttributeListRef xAttrs( pAttr );
- m_pSerializer->singleElementNS( XML_w, XML_pgNumType, xAttrs );
+ m_pSerializer->singleElementNS( XML_w, XML_pgNumType, pAttr );
// see 2.6.12 pgNumType (Page Numbering Settings)
SAL_INFO("sw.ww8", "TODO DocxAttributeOutput::SectionPageNumbering()" );
@@ -6971,20 +7321,20 @@ void DocxAttributeOutput::FontAlternateName( const OUString& rName ) const
void DocxAttributeOutput::FontCharset( sal_uInt8 nCharSet, rtl_TextEncoding nEncoding ) const
{
- FastAttributeList* pAttr = FastSerializerHelper::createAttrList();
+ rtl::Reference<FastAttributeList> pAttr = FastSerializerHelper::createAttrList();
OString aCharSet( OString::number( nCharSet, 16 ) );
if ( aCharSet.getLength() == 1 )
aCharSet = "0" + aCharSet;
- pAttr->add( FSNS( XML_w, XML_val ), aCharSet.getStr());
+ 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 );
}
- m_pSerializer->singleElementNS( XML_w, XML_charset, XFastAttributeListRef( pAttr ));
+ m_pSerializer->singleElementNS( XML_w, XML_charset, pAttr );
}
void DocxAttributeOutput::FontFamilyType( FontFamily eFamily ) const
@@ -7020,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 )
@@ -7031,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" );
@@ -7064,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;
@@ -7081,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;
@@ -7089,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;
@@ -7097,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),
- "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;
}
}
@@ -7201,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);
@@ -7210,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)
@@ -7255,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));
@@ -7275,11 +7645,14 @@ 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(impl_LevelNFC(nNumberingType, pOutSet, aCustomFormat));
+ OString aFormat(lcl_ConvertNumberingType(nNumberingType, pOutSet, aCustomFormat, "decimal"_ostr));
- if ( !aFormat.isEmpty() )
{
if (aCustomFormat.isEmpty())
{
@@ -7324,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( OUString::number( sal_Int32( *pIt ) + 1 ) );
+ aBuffer.append( OUString::Concat(std::u16string_view(pPrev, pIt - pPrev))
+ + "%"
+ + OUString::number(sal_Int32( *pIt ) + 1 ));
pPrev = pIt + 1;
}
@@ -7363,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;
@@ -7395,6 +7768,7 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
{
m_pSerializer->startElementNS(XML_w, XML_rPr);
+ SfxItemSet aTempSet(*pOutSet);
if ( pFont )
{
GetExport().GetId( *pFont ); // ensure font info is written to fontTable.xml
@@ -7404,11 +7778,10 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
FSNS( XML_w, XML_hAnsi ), aFamilyName,
FSNS( XML_w, XML_cs ), aFamilyName,
FSNS( XML_w, XML_hint ), "default" );
+ aTempSet.ClearItem(RES_CHRATR_FONT);
+ aTempSet.ClearItem(RES_CHRATR_CTL_FONT);
}
- else
- {
- m_rExport.OutputItemSet(*pOutSet, false, true, i18n::ScriptType::LATIN, m_rExport.m_bExportModeRTF);
- }
+ m_rExport.OutputItemSet(aTempSet, false, true, i18n::ScriptType::LATIN, m_rExport.m_bExportModeRTF);
WriteCollectedRunProperties();
@@ -7437,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();
+
+ OString aColorString = msfilter::util::ConvertColor(aColor);
- const char* pExistingValue(nullptr);
- if (m_pColorAttrList.is() && m_pColorAttrList->getAsChar(FSNS(XML_w, XML_val), pExistingValue))
+ 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();
}
@@ -7483,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;
@@ -7492,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 )
{
@@ -7521,18 +7904,18 @@ void DocxAttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement )
if ( !sIss.isEmpty() )
m_pSerializer->singleElementNS(XML_w, XML_vertAlign, FSNS(XML_w, XML_val), sIss);
+ if (!(sIss.isEmpty() || sIss.match("baseline")))
+ return;
+
const SvxFontHeightItem& rItem = m_rExport.GetItem(RES_CHRATR_FONTSIZE);
- if (sIss.isEmpty() || sIss.match("baseline"))
- {
- float fHeight = rItem.GetHeight();
- OString sPos = OString::number( round(( fHeight * nEsc ) / 1000) );
- m_pSerializer->singleElementNS(XML_w, XML_position, FSNS(XML_w, XML_val), sPos);
+ float fHeight = rItem.GetHeight();
+ OString sPos = OString::number( round(( fHeight * nEsc ) / 1000) );
+ m_pSerializer->singleElementNS(XML_w, XML_position, FSNS(XML_w, XML_val), sPos);
- if( ( 100 != nProp || sIss.match( "baseline" ) ) && !m_rExport.m_bFontSizeWritten )
- {
- OString sSize = OString::number( round(( fHeight * nProp ) / 1000) );
- m_pSerializer->singleElementNS(XML_w, XML_sz, FSNS(XML_w, XML_val), sSize);
- }
+ if( ( 100 != nProp || sIss.match( "baseline" ) ) && !m_rExport.m_bFontSizeWritten )
+ {
+ OString sSize = OString::number( round(( fHeight * nProp ) / 1000) );
+ m_pSerializer->singleElementNS(XML_w, XML_sz, FSNS(XML_w, XML_val), sSize);
}
}
@@ -7540,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 &&
@@ -7555,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)
@@ -7584,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;
}
}
@@ -7648,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
{
@@ -7684,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 )
{
@@ -7716,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 )
@@ -7747,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)
@@ -7820,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 )
@@ -7874,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);
@@ -7893,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 )
@@ -7919,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()" );
}
@@ -7950,55 +8317,98 @@ 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;
else
// Otherwise get a new one.
nId = m_nNextAnnotationMarkId++;
- m_postitFields.emplace_back(pPostItField, nId);
+ m_postitFields.emplace_back(pPostItField, PostItDOCXData{ nId });
}
void DocxAttributeOutput::WritePostitFieldReference()
{
while( m_postitFieldsMaxId < m_postitFields.size())
{
- OString idstr = OString::number(m_postitFields[m_postitFieldsMaxId].second);
+ OString idstr = OString::number(m_postitFields[m_postitFieldsMaxId].second.id);
// 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;
}
}
-void DocxAttributeOutput::WritePostitFields()
+DocxAttributeOutput::hasProperties DocxAttributeOutput::WritePostitFields()
{
- for (const auto& rPair : m_postitFields)
+ bool bRemovePersonalInfo = SvtSecurityOptions::IsOptionSet(
+ SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo ) && !SvtSecurityOptions::IsOptionSet(
+ SvtSecurityOptions::EOption::DocWarnKeepRedlineInfo);
+
+ hasProperties eResult = hasProperties::no;
+ for (auto& [f1, data1] : m_postitFields)
{
- OString idstr = OString::number( rPair.second);
- const SwPostItField* f = rPair.first;
- 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() );
+ 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)
+ {
+ 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 = hasProperties::yes;
if (f->GetTextObject() != nullptr)
{
// richtext
- GetExport().WriteOutliner(*f->GetTextObject(), TXT_ATN);
+ data.lastParaId = GetExport().WriteOutliner(*f->GetTextObject(), TXT_ATN, bNeedParaId);
}
else
{
// just plain text - eg. when the field was created via the
// .uno:InsertAnnotation API
- m_pSerializer->startElementNS(XML_w, XML_p);
+ std::optional<OUString> aParaId;
+ if (bNeedParaId)
+ {
+ data.lastParaId = m_nNextParaId++;
+ aParaId = NumberToHexBinary(data.lastParaId);
+ }
+ m_pSerializer->startElementNS(XML_w, XML_p, FSNS(XML_w14, XML_paraId), aParaId);
m_pSerializer->startElementNS(XML_w, XML_r);
RunText(f->GetText());
m_pSerializer->endElementNS(XML_w, XML_r);
@@ -8007,6 +8417,38 @@ void DocxAttributeOutput::WritePostitFields()
m_pSerializer->endElementNS( XML_w, XML_comment );
}
+ return eResult;
+}
+
+void DocxAttributeOutput::WritePostItFieldsResolved()
+{
+ for (auto& [f, data] : m_postitFields)
+ {
+ // 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);
+ 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);
+ }
}
bool DocxAttributeOutput::DropdownField( const SwField* pField )
@@ -8020,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())
@@ -8059,7 +8501,9 @@ void DocxAttributeOutput::WriteExpand( const SwField* pField )
m_rExport.OutputField( pField, ww::eUNKNOWN, OUString() );
}
-void DocxAttributeOutput::WriteField_Impl( const SwField* pField, ww::eField eType, const OUString& rFieldCmd, FieldFlags nMode )
+void DocxAttributeOutput::WriteField_Impl(const SwField *const pField,
+ ww::eField const eType, const OUString& rFieldCmd, FieldFlags const nMode,
+ OUString const*const pBookmarkName)
{
if (m_bPreventDoubleFieldsHandling)
return;
@@ -8074,6 +8518,11 @@ void DocxAttributeOutput::WriteField_Impl( const SwField* pField, ww::eField eTy
infos.bOpen = bool(FieldFlags::Start & nMode);
m_Fields.push_back( infos );
+ if (pBookmarkName)
+ {
+ m_sFieldBkm = *pBookmarkName;
+ }
+
if ( !pField )
return;
@@ -8099,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 )
{
@@ -8111,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();
@@ -8164,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();
}
@@ -8331,44 +8773,9 @@ void DocxAttributeOutput::WriteFootnoteEndnotePr( ::sax_fastparser::FSHelperPtr
const SwEndNoteInfo& info, int listtag )
{
fs->startElementNS(XML_w, tag);
- const char* fmt = nullptr;
- switch( info.m_aFormat.GetNumberingType())
- {
- case SVX_NUM_CHARS_UPPER_LETTER_N: // fall through, map to upper letters
- case SVX_NUM_CHARS_UPPER_LETTER:
- fmt = "upperLetter";
- break;
- case SVX_NUM_CHARS_LOWER_LETTER_N: // fall through, map to lower letters
- case SVX_NUM_CHARS_LOWER_LETTER:
- fmt = "lowerLetter";
- break;
- case SVX_NUM_ROMAN_UPPER:
- fmt = "upperRoman";
- break;
- case SVX_NUM_ROMAN_LOWER:
- fmt = "lowerRoman";
- break;
- case SVX_NUM_ARABIC:
- fmt = "decimal";
- break;
- case SVX_NUM_NUMBER_NONE:
- fmt = "none";
- break;
- case SVX_NUM_CHAR_SPECIAL:
- fmt = "bullet";
- break;
- case SVX_NUM_SYMBOL_CHICAGO:
- fmt = "chicago";
- break;
- case SVX_NUM_ARABIC_ZERO:
- fmt = "decimalZero";
- break;
- case SVX_NUM_PAGEDESC:
- case SVX_NUM_BITMAP:
- default:
- break; // no format
- }
- if( fmt != nullptr )
+ OString aCustomFormat;
+ OString fmt = lcl_ConvertNumberingType(info.m_aFormat.GetNumberingType(), nullptr, aCustomFormat);
+ if (!fmt.isEmpty() && aCustomFormat.isEmpty())
fs->singleElementNS(XML_w, XML_numFmt, FSNS(XML_w, XML_val), fmt);
if( info.m_nFootnoteOffset != 0 )
fs->singleElementNS( XML_w, XML_numStart, FSNS( XML_w, XML_val ),
@@ -8379,11 +8786,11 @@ void DocxAttributeOutput::WriteFootnoteEndnotePr( ::sax_fastparser::FSHelperPtr
{
switch( pFootnoteInfo->m_eNum )
{
- case FTNNUM_PAGE: fmt = "eachPage"; break;
- case FTNNUM_CHAPTER: fmt = "eachSect"; break;
- default: fmt = nullptr; break;
+ case FTNNUM_PAGE: fmt = "eachPage"_ostr; break;
+ case FTNNUM_CHAPTER: fmt = "eachSect"_ostr; break;
+ default: fmt.clear(); break;
}
- if( fmt != nullptr )
+ if (!fmt.isEmpty())
fs->singleElementNS(XML_w, XML_numRestart, FSNS(XML_w, XML_val), fmt);
}
@@ -8407,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 ) );
}
}
@@ -8429,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?
@@ -8505,23 +8912,23 @@ void DocxAttributeOutput::ParaWidows( const SvxWidowsItem& rWidows )
static void impl_WriteTabElement( FSHelperPtr const & pSerializer,
const SvxTabStop& rTab, tools::Long tabsOffset )
{
- FastAttributeList *pTabElementAttrList = FastSerializerHelper::createAttrList();
+ rtl::Reference<FastAttributeList> pTabElementAttrList = FastSerializerHelper::createAttrList();
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;
}
@@ -8534,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);
}
@@ -8578,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;
@@ -8614,26 +9019,34 @@ void DocxAttributeOutput::ParaHyphenZone( const SvxHyphenZoneItem& rHyphenZone )
FSNS( XML_w, XML_val ), OString::boolean( !rHyphenZone.IsHyphen() ) );
}
-void DocxAttributeOutput::ParaNumRule_Impl(const SwTextNode*, sal_Int32 nLvl, sal_Int32 nNumId)
+void DocxAttributeOutput::ParaNumRule_Impl( const SwTextNode* pTextNd, sal_Int32 nLvl, sal_Int32 nNumId )
{
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,
- // neither as style properties - there's w:outlineLvl for that.
- if (!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 )
@@ -8692,8 +9105,8 @@ void DocxAttributeOutput::FormatFrameSize( const SwFormatFrameSize& rSize )
if (m_rExport.SdrExporter().getTextFrameSyntax() && m_rExport.SdrExporter().getFlyFrameSize())
{
const Size* pSize = m_rExport.SdrExporter().getFlyFrameSize();
- m_rExport.SdrExporter().getTextFrameStyle().append(";width:").append(double(pSize->Width()) / 20);
- m_rExport.SdrExporter().getTextFrameStyle().append("pt;height:").append(double(pSize->Height()) / 20).append("pt");
+ m_rExport.SdrExporter().getTextFrameStyle().append(";width:" + OString::number(double(pSize->Width()) / 20));
+ m_rExport.SdrExporter().getTextFrameStyle().append("pt;height:" + OString::number(double(pSize->Height()) / 20) + "pt");
}
else if (m_rExport.SdrExporter().getDMLTextFrameSyntax())
{
@@ -8702,47 +9115,107 @@ 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 )
{
- FastAttributeList *attrList = FastSerializerHelper::createAttrList( );
+ rtl::Reference<FastAttributeList> attrList = FastSerializerHelper::createAttrList( );
if ( m_rExport.m_pCurrentPageDesc->GetLandscape( ) )
attrList->add( FSNS( XML_w, XML_orient ), "landscape" );
attrList->add( FSNS( XML_w, XML_w ), OString::number( rSize.GetWidth( ) ) );
attrList->add( FSNS( XML_w, XML_h ), OString::number( rSize.GetHeight( ) ) );
- XFastAttributeListRef xAttrList( attrList );
- attrList = nullptr;
+ m_pSerializer->singleElementNS( XML_w, XML_pgSz, attrList );
+ }
+}
- m_pSerializer->singleElementNS( XML_w, XML_pgSz, xAttrList );
+void DocxAttributeOutput::FormatPaperBin(const SvxPaperBinItem& rPaperBin)
+{
+ 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::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::FormatPaperBin( const SvxPaperBinItem& )
+void DocxAttributeOutput::FormatTextLeftMargin(SvxTextLeftMarginItem const& rTextLeftMargin)
{
- SAL_INFO("sw.ww8", "TODO DocxAttributeOutput::FormatPaperBin()" );
+ 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::FormatLRSpace( const SvxLRSpaceItem& rLRSpace )
+void DocxAttributeOutput::FormatRightMargin(SvxRightMarginItem const& rRightMargin)
{
- bool bEcma = m_rExport.GetFilter().getVersion( ) == oox::core::ECMA_DIALECT;
+ // (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:").append(double(rLRSpace.GetLeft()) / 20).append("pt");
- m_rExport.SdrExporter().getTextFrameStyle().append(";mso-wrap-distance-right:").append(double(rLRSpace.GetRight()) / 20).append("pt");
+ m_rExport.SdrExporter().getTextFrameStyle().append(";mso-wrap-distance-left:" + OString::number(double(rLRSpace.GetLeft()) / 20) + "pt");
+ m_rExport.SdrExporter().getTextFrameStyle().append(";mso-wrap-distance-right:" + OString::number(double(rLRSpace.GetRight()) / 20) + "pt");
}
else if (m_rExport.SdrExporter().getDMLTextFrameSyntax())
{
@@ -8751,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 );
@@ -8766,23 +9240,29 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace )
m_pageMargins.nLeft += sal::static_int_cast<sal_uInt16>(rLRSpace.GetLeft());
m_pageMargins.nRight += sal::static_int_cast<sal_uInt16>(rLRSpace.GetRight());
+ sal_uInt16 nGutter = rLRSpace.GetGutterMargin();
- AddToAttrList( m_pSectionSpacingAttrList, 2,
- FSNS( XML_w, XML_left ), OString::number( m_pageMargins.nLeft ).getStr(),
- FSNS( XML_w, XML_right ), OString::number( m_pageMargins.nRight ).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
{
- FastAttributeList *pLRSpaceAttrList = FastSerializerHelper::createAttrList();
- if((0 != rLRSpace.GetTextLeft()) || (rLRSpace.IsExplicitZeroMarginValLeft()))
+ // 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 != 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
@@ -8796,8 +9276,8 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
if (m_rExport.SdrExporter().getTextFrameSyntax())
{
- m_rExport.SdrExporter().getTextFrameStyle().append(";mso-wrap-distance-top:").append(double(rULSpace.GetUpper()) / 20).append("pt");
- m_rExport.SdrExporter().getTextFrameStyle().append(";mso-wrap-distance-bottom:").append(double(rULSpace.GetLower()) / 20).append("pt");
+ m_rExport.SdrExporter().getTextFrameStyle().append(";mso-wrap-distance-top:" + OString::number(double(rULSpace.GetUpper()) / 20) + "pt");
+ m_rExport.SdrExporter().getTextFrameStyle().append(";mso-wrap-distance-bottom:" + OString::number(double(rULSpace.GetLower()) / 20) + "pt");
}
else if (m_rExport.SdrExporter().getDMLTextFrameSyntax())
{
@@ -8806,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 )
{
@@ -8818,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());
@@ -8827,27 +9307,36 @@ 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());
+ if (aFirstPageDistances.HasFooter())
+ {
+ // 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.m_DyaHdrBottom);
+ }
+ }
// Page Bottom
- m_pageMargins.nBottom = aDistances.dyaBottom;
+ m_pageMargins.nBottom = aDistances.m_DyaBottom;
- AddToAttrList( m_pSectionSpacingAttrList, 5,
- 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(),
- // FIXME Page Gutter is not handled ATM, setting to 0 as it's mandatory for OOXML
- FSNS( XML_w, XML_gutter ), "0" );
+ 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
{
@@ -8862,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
@@ -8882,29 +9370,39 @@ 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;
if (rULSpace.GetContext())
m_pSerializer->singleElementNS(XML_w, XML_contextualSpacing);
+ else
+ {
+ // Write out Contextual Spacing = false if it would have inherited a true.
+ const SvxULSpaceItem* pInherited = nullptr;
+ if (auto pNd = dynamic_cast<const SwContentNode*>(m_rExport.m_pOutFormatNode)) //paragraph
+ pInherited = &static_cast<SwTextFormatColl&>(pNd->GetAnyFormatColl()).GetAttrSet().GetULSpace();
+ else if (m_rExport.m_bStyDef && m_rExport.m_pCurrentStyle && m_rExport.m_pCurrentStyle->DerivedFrom()) //style
+ pInherited = &m_rExport.m_pCurrentStyle->DerivedFrom()->GetULSpace();
+
+ if (pInherited && pInherited->GetContext())
+ m_pSerializer->singleElementNS(XML_w, XML_contextualSpacing, FSNS(XML_w, XML_val), "false");
+ }
}
}
namespace docx {
-std::unique_ptr<FastAttributeList> SurroundToVMLWrap(SwFormatSurround const& rSurround)
+rtl::Reference<FastAttributeList> SurroundToVMLWrap(SwFormatSurround const& rSurround)
{
- FastAttributeList * pAttrList(nullptr);
- OString sType;
- OString sSide;
+ std::string_view sType;
+ std::string_view sSide;
switch (rSurround.GetSurround())
{
case css::text::WrapTextMode_NONE:
@@ -8931,19 +9429,12 @@ std::unique_ptr<FastAttributeList> SurroundToVMLWrap(SwFormatSurround const& rSu
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);
- }
- }
- return std::unique_ptr<FastAttributeList>(pAttrList);
+ rtl::Reference<FastAttributeList> pAttrList;
+ if (!sType.empty())
+ DocxAttributeOutput::AddToAttrList(pAttrList, XML_type, sType);
+ if (!sSide.empty())
+ DocxAttributeOutput::AddToAttrList(pAttrList, XML_side, sSide);
+ return pAttrList;
}
} // namespace docx
@@ -8952,10 +9443,10 @@ void DocxAttributeOutput::FormatSurround( const SwFormatSurround& rSurround )
{
if (m_rExport.SdrExporter().getTextFrameSyntax())
{
- std::unique_ptr<FastAttributeList> pAttrList(docx::SurroundToVMLWrap(rSurround));
+ rtl::Reference<FastAttributeList> pAttrList(docx::SurroundToVMLWrap(rSurround));
if (pAttrList)
{
- m_rExport.SdrExporter().setFlyWrapAttrList(pAttrList.release());
+ m_rExport.SdrExporter().setFlyWrapAttrList(pAttrList);
}
}
else if (m_rExport.SdrExporter().getDMLTextFrameSyntax())
@@ -8963,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 );
}
}
@@ -8991,10 +9482,10 @@ void DocxAttributeOutput::FormatVertOrientation( const SwFormatVertOrient& rFlyV
if (m_rExport.SdrExporter().getTextFrameSyntax())
{
- m_rExport.SdrExporter().getTextFrameStyle().append(";margin-top:").append(double(rFlyVert.GetPos()) / 20).append("pt");
+ m_rExport.SdrExporter().getTextFrameStyle().append(";margin-top:" + OString::number(double(rFlyVert.GetPos()) / 20) + "pt");
if ( !sAlign.isEmpty() )
- m_rExport.SdrExporter().getTextFrameStyle().append(";mso-position-vertical:").append(sAlign);
- m_rExport.SdrExporter().getTextFrameStyle().append(";mso-position-vertical-relative:").append(sVAnchor);
+ m_rExport.SdrExporter().getTextFrameStyle().append(";mso-position-vertical:" + sAlign);
+ m_rExport.SdrExporter().getTextFrameStyle().append(";mso-position-vertical-relative:" + sVAnchor);
}
else if (m_rExport.SdrExporter().getDMLTextFrameSyntax())
{
@@ -9002,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 );
}
}
@@ -9017,10 +9508,10 @@ void DocxAttributeOutput::FormatHorizOrientation( const SwFormatHoriOrient& rFly
if (m_rExport.SdrExporter().getTextFrameSyntax())
{
- m_rExport.SdrExporter().getTextFrameStyle().append(";margin-left:").append(double(rFlyHori.GetPos()) / 20).append("pt");
+ m_rExport.SdrExporter().getTextFrameStyle().append(";margin-left:" + OString::number(double(rFlyHori.GetPos()) / 20) + "pt");
if ( !sAlign.isEmpty() )
- m_rExport.SdrExporter().getTextFrameStyle().append(";mso-position-horizontal:").append(sAlign);
- m_rExport.SdrExporter().getTextFrameStyle().append(";mso-position-horizontal-relative:").append(sHAnchor);
+ m_rExport.SdrExporter().getTextFrameStyle().append(";mso-position-horizontal:" + sAlign);
+ m_rExport.SdrExporter().getTextFrameStyle().append(";mso-position-horizontal-relative:" + sHAnchor);
}
else if (m_rExport.SdrExporter().getDMLTextFrameSyntax())
{
@@ -9028,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 );
}
}
@@ -9061,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())
@@ -9071,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())
{
@@ -9109,19 +9600,19 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
m_sOriginalBackgroundColor, RTL_TEXTENCODING_UTF8 );
if ( aColor == COL_AUTO )
- sColor = "auto";
+ sColor = "auto"_ostr;
if( !m_pBackgroundAttrList.is() )
{
m_pBackgroundAttrList = FastSerializerHelper::createAttrList();
- m_pBackgroundAttrList->add( FSNS( XML_w, XML_fill ), sColor.getStr() );
+ m_pBackgroundAttrList->add(FSNS(XML_w, XML_fill), sColor);
m_pBackgroundAttrList->add( FSNS( XML_w, XML_val ), "clear" );
}
else if ( sOriginalFill != sColor )
{
// fill was modified during edition, theme fill attribute must be dropped
m_pBackgroundAttrList = FastSerializerHelper::createAttrList();
- m_pBackgroundAttrList->add( FSNS( XML_w, XML_fill ), sColor.getStr() );
+ m_pBackgroundAttrList->add(FSNS(XML_w, XML_fill), sColor);
m_pBackgroundAttrList->add( FSNS( XML_w, XML_val ), "clear" );
}
m_sOriginalBackgroundColor.clear();
@@ -9144,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();
}
@@ -9249,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" );
}
}
@@ -9260,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" );
@@ -9291,10 +9795,10 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox )
double fDistanceBottomTwips = double(rBox.GetDistance(SvxBoxItemLine::BOTTOM));
// Convert 'TWIPS' to 'INCH' (because in Word the default values are in Inches)
- double fDistanceLeftInch = fDistanceLeftTwips / 1440;
- double fDistanceTopInch = fDistanceTopTwips / 1440;
- double fDistanceRightInch = fDistanceRightTwips / 1440;
- double fDistanceBottomInch = fDistanceBottomTwips / 1440;
+ double fDistanceLeftInch = o3tl::convert(fDistanceLeftTwips, o3tl::Length::twip, o3tl::Length::in);
+ double fDistanceTopInch = o3tl::convert(fDistanceTopTwips, o3tl::Length::twip, o3tl::Length::in);
+ double fDistanceRightInch = o3tl::convert(fDistanceRightTwips, o3tl::Length::twip, o3tl::Length::in);
+ double fDistanceBottomInch = o3tl::convert(fDistanceBottomTwips, o3tl::Length::twip, o3tl::Length::in);
// This code will write ONLY the non-default values. The values are in 'left','top','right','bottom' order.
// so 'bottom' is checked if it is default and if it is non-default - all the values will be written
@@ -9302,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;
}
@@ -9350,27 +9854,28 @@ 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 )
{
// Get the columns attributes
- FastAttributeList *pColsAttrList = FastSerializerHelper::createAttrList();
+ 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";
}
@@ -9390,16 +9895,14 @@ void DocxAttributeOutput::FormatColumns_Impl( sal_uInt16 nCols, const SwFormatCo
{
for ( sal_uInt16 n = 0; n < nCols; ++n )
{
- 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( ) );
+ rtl::Reference<FastAttributeList> pColAttrList = FastSerializerHelper::createAttrList();
+ 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 );
@@ -9417,33 +9920,33 @@ void DocxAttributeOutput::FormatKeep( const SvxFormatKeepItem& rItem )
void DocxAttributeOutput::FormatTextGrid( const SwTextGridItem& rGrid )
{
- FastAttributeList *pGridAttrList = FastSerializerHelper::createAttrList();
+ 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.getStr( ) );
+ 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 );
}
@@ -9452,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 )
@@ -9467,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;
}
@@ -9491,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);
}
}
@@ -9506,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")
@@ -9514,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")
@@ -9522,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;
}
@@ -9555,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")
{
@@ -9677,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 )
{
@@ -9699,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
@@ -9714,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" ||
@@ -9781,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);
@@ -9859,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 ),
@@ -9875,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 ),
@@ -9889,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()
@@ -9951,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:").append(double(aSize.Width()) / 20);
- aStyle.append("pt;height:").append(double(aSize.Height()) / 20).append("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);
@@ -9971,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 20781b13ceb3..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
{
@@ -129,7 +204,8 @@ public:
virtual void RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript ) override;
/// Start of the paragraph.
- virtual void StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo ) override;
+ virtual sal_Int32 StartParagraph(ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo,
+ bool bGenerateParaId) override;
/// End of the paragraph.
virtual void EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) override;
@@ -150,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;
@@ -165,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;
@@ -182,7 +258,7 @@ public:
/// Output URL end.
virtual bool EndURL(bool) override;
- virtual void FieldVanish( const OUString& rText, ww::eField eType ) override;
+ virtual void FieldVanish(const OUString& rText, ww::eField eType, OUString const*) override;
/// Output redlining.
///
@@ -193,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;
@@ -210,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.
@@ -251,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.
@@ -273,7 +349,7 @@ public:
/// Write a section break
/// msword::ColumnBreak or msword::PageBreak
/// bBreakAfter: the break must be scheduled for insertion in the end of current paragraph
- virtual void SectionBreak( sal_uInt8 nC, bool bBreakAfter, const WW8_SepInfo* pSectionInfo = nullptr ) override;
+ virtual void SectionBreak( sal_uInt8 nC, bool bBreakAfter, const WW8_SepInfo* pSectionInfo = nullptr, bool bExtraPageBreak = false ) override;
// preserve DOCX page vertical alignment
virtual void TextVerticalAdjustment( const css::drawing::TextVerticalAdjust ) override;
@@ -354,16 +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 );
+ 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();
- void PopRelIdCache();
/// End possibly opened paragraph sdt block.
void EndParaSdtBlock();
@@ -411,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);
@@ -435,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
@@ -613,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;
@@ -681,26 +765,27 @@ protected:
virtual void WriteBookmarkInActParagraph( const OUString& rName, sal_Int32 nFirstRunPos, sal_Int32 nLastRunPos ) override;
- /// Reference to the export, where to get the data from
- DocxExport &m_rExport;
+ void SectionRtlGutter( const SfxBoolItem& rRtlGutter) override;
- /// 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 DoWriteBookmarkTagEnd(const OUString & bookmarkName);
- void DoWriteBookmarksStart(std::vector<OUString>& rStarts);
+ void DoWriteBookmarkTagStart(const OUString& bookmarkName);
+ void DoWriteBookmarkTagEnd(sal_Int32 nId);
+ 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();
@@ -714,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;
@@ -793,11 +876,23 @@ private:
sal_Int32 m_nNextBookmarkId;
sal_Int32 m_nNextAnnotationMarkId;
+ /// [MS-DOCX] section 2.6.2.3
+ sal_Int32 m_nNextParaId = 1; // MUST be greater than 0
+
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;
@@ -812,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;
@@ -837,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;
@@ -863,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
@@ -880,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
{
@@ -895,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
{
@@ -905,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
{
@@ -925,9 +1022,23 @@ 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*, sal_Int32> > m_postitFields;
+ std::vector<std::pair<const SwPostItField*, PostItDOCXData>> m_postitFields;
/// Number of postit fields which already have a commentReference written.
unsigned int m_postitFieldsMaxId;
int m_anchorId;
@@ -938,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.
@@ -960,36 +1071,19 @@ private:
// store hardcoded value which was set during import.
sal_Int32 m_nParaBeforeSpacing,m_nParaAfterSpacing;
- OString getExistingGraphicRelId(BitmapChecksum aChecksum);
- void cacheGraphicRelId(BitmapChecksum nChecksum, OString const & rRelId);
-
- /// RelId <-> Graphic* cache, so that in case of alternate content, the same graphic only gets written once.
- std::stack< std::map<BitmapChecksum, OString> > m_aRelIdCache;
-
- /// RelId <-> BitmapChecksum cache, similar to m_aRelIdCache, but used for non-Writer graphics, handled in oox.
- std::stack< std::map<BitmapChecksum, 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 );
@@ -1018,19 +1112,19 @@ public:
static void WriteFootnoteEndnotePr( ::sax_fastparser::FSHelperPtr const & fs, int tag, const SwEndNoteInfo& info, int listtag );
bool HasPostitFields() const;
- void WritePostitFields();
+ enum class hasProperties { no, yes };
+ hasProperties WritePostitFields();
+ void WritePostItFieldsResolved();
/// VMLTextExport
virtual void WriteOutliner(const OutlinerParaObject& rParaObj) override;
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 void CacheRelId(BitmapChecksum nChecksum, const OUString& rRelId) override;
virtual css::uno::Reference<css::text::XTextFrame> GetUnoTextFrame(
css::uno::Reference<css::drawing::XShape> xShape) override;
virtual oox::drawingml::DrawingML& GetDrawingML() override;
- virtual void MaybeOutputBrushItem(SfxItemSet const&) override;
+ virtual bool MaybeOutputBrushItem(SfxItemSet const&) override;
void BulletDefinition(int nId, const Graphic& rGraphic, Size aSize) override;
@@ -1045,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;
};
/**
@@ -1057,14 +1182,16 @@ 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); }
};
namespace docx {
-std::unique_ptr<sax_fastparser::FastAttributeList> SurroundToVMLWrap(SwFormatSurround const& rSurround);
+rtl::Reference<sax_fastparser::FastAttributeList> SurroundToVMLWrap(SwFormatSurround const& rSurround);
}
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 7115e4e2d664..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() );
@@ -216,7 +227,7 @@ void DocxExport::ExportGrfBullet(const SwTextNode&)
CollectGrfsOfBullets();
}
-OString DocxExport::AddRelation( const OUString& rType, const OUString& rTarget )
+OString DocxExport::AddRelation( const OUString& rType, std::u16string_view rTarget )
{
OUString sId = m_rFilter.addRelation( m_pDocumentFS->getOutputStream(),
rType, rTarget, true );
@@ -247,63 +258,63 @@ bool DocxExport::DisallowInheritingOutlineNumbering( const SwFormat& rFormat )
}
void DocxExport::WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
- const SwFrameFormat& rFormat, const SwFrameFormat& rLeftFormat, const SwFrameFormat& rFirstPageFormat, sal_uInt8 nBreakCode )
+ const SwFrameFormat& rFormat, const SwFrameFormat& rLeftHeaderFormat, const SwFrameFormat& rLeftFooterFormat, const SwFrameFormat& rFirstPageFormat,
+ sal_uInt8 nBreakCode, bool bEvenAndOddHeaders )
{
m_nHeadersFootersInSection = 1;
// document setting indicating the requirement of EVEN and ODD for both headers and footers
- if ( nHeadFootFlags & ( nsHdFtFlags::WW8_FOOTER_EVEN | nsHdFtFlags::WW8_HEADER_EVEN ))
+ if ( nHeadFootFlags & ( nsHdFtFlags::WW8_FOOTER_EVEN | nsHdFtFlags::WW8_HEADER_EVEN ) && bEvenAndOddHeaders )
m_aSettings.evenAndOddHeaders = true;
// 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( &rLeftFormat, true, "even" );
+ WriteHeaderFooter( &rLeftHeaderFormat, true, "even" );
else if ( m_aSettings.evenAndOddHeaders )
{
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 )
- WriteHeaderFooter( &rLeftFormat, false, "even" );
+ WriteHeaderFooter( &rLeftFooterFormat, false, "even" );
else if ( m_aSettings.evenAndOddHeaders )
{
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 );
@@ -321,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,
@@ -384,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();
@@ -392,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 );
}
@@ -474,7 +491,7 @@ std::pair<OString, OString> DocxExport::WriteActiveXObject(const uno::Reference<
const OUString sBinaryId = m_rFilter.addRelation( pActiveXFS->getOutputStream(),
oox::getRelationship(Relationship::ACTIVEXCONTROLBINARY),
- sBinaryFileName.copy(sBinaryFileName.lastIndexOf("/") + 1) );
+ sBinaryFileName.subView(sBinaryFileName.lastIndexOf("/") + 1) );
pActiveXFS->singleElementNS(XML_ax, XML_ocx,
FSNS(XML_xmlns, XML_ax), m_rFilter.getNamespaceURL(OOX_NS(ax)),
@@ -485,9 +502,11 @@ std::pair<OString, OString> DocxExport::WriteActiveXObject(const uno::Reference<
OString sXMLId = OUStringToOString(m_rFilter.addRelation(m_pDocumentFS->getOutputStream(),
oox::getRelationship(Relationship::CONTROL),
- sXMLFileName.copy(sBinaryFileName.indexOf("/") + 1)),
+ sXMLFileName.subView(sBinaryFileName.indexOf("/") + 1)),
RTL_TEXTENCODING_UTF8);
+ pActiveXFS->endDocument();
+
return std::pair<OString, OString>(sXMLId, sName);
}
@@ -514,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();
@@ -537,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;
}
@@ -610,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
@@ -619,11 +643,11 @@ sal_uLong DocxExport::ReplaceCr( sal_uInt8 )
void DocxExport::PrepareNewPageDesc( const SfxItemSet* pSet,
const SwNode& rNd, const SwFormatPageDesc* pNewPgDescFormat,
- const SwPageDesc* pNewPgDesc )
+ const SwPageDesc* pNewPgDesc, bool bExtraPageBreak )
{
// tell the attribute output that we are ready to write the section
// break [has to be output inside paragraph properties]
- AttrOutput().SectionBreak( msword::PageBreak, false, m_pSections->CurrentSectionInfo() );
+ AttrOutput().SectionBreak( msword::PageBreak, false, m_pSections->CurrentSectionInfo(), bExtraPageBreak );
const SwSectionFormat* pFormat = GetSectionFormat( rNd );
const sal_uLong nLnNm = GetSectionLineNo( pSet, rNd );
@@ -648,7 +672,7 @@ void DocxExport::InitStyles()
// setup word/styles.xml and the relations + content type
m_rFilter.addRelation( m_pDocumentFS->getOutputStream(),
oox::getRelationship(Relationship::STYLES),
- "styles.xml" );
+ u"styles.xml" );
::sax_fastparser::FSHelperPtr pStylesFS =
m_rFilter.openFragmentStreamWithSerializer( "word/styles.xml",
@@ -662,6 +686,8 @@ void DocxExport::InitStyles()
// switch the serializer back
m_pAttrOutput->SetSerializer( m_pDocumentFS );
+
+ pStylesFS->endDocument();
}
void DocxExport::WriteFootnotesEndnotes()
@@ -671,7 +697,7 @@ void DocxExport::WriteFootnotesEndnotes()
// setup word/styles.xml and the relations + content type
m_rFilter.addRelation( m_pDocumentFS->getOutputStream(),
oox::getRelationship(Relationship::FOOTNOTES),
- "footnotes.xml" );
+ u"footnotes.xml" );
::sax_fastparser::FSHelperPtr pFootnotesFS =
m_rFilter.openFragmentStreamWithSerializer( "word/footnotes.xml",
@@ -691,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() )
@@ -699,7 +727,7 @@ void DocxExport::WriteFootnotesEndnotes()
// setup word/styles.xml and the relations + content type
m_rFilter.addRelation( m_pDocumentFS->getOutputStream(),
oox::getRelationship(Relationship::ENDNOTES),
- "endnotes.xml" );
+ u"endnotes.xml" );
::sax_fastparser::FSHelperPtr pEndnotesFS =
m_rFilter.openFragmentStreamWithSerializer( "word/endnotes.xml",
@@ -719,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()
@@ -728,7 +758,7 @@ void DocxExport::WritePostitFields()
m_rFilter.addRelation( m_pDocumentFS->getOutputStream(),
oox::getRelationship(Relationship::COMMENTS),
- "comments.xml" );
+ u"comments.xml" );
::sax_fastparser::FSHelperPtr pPostitFS =
m_rFilter.openFragmentStreamWithSerializer( "word/comments.xml",
@@ -736,9 +766,31 @@ void DocxExport::WritePostitFields()
pPostitFS->startElementNS( XML_w, XML_comments, MainXmlNamespaces());
m_pAttrOutput->SetSerializer( pPostitFS );
- m_pAttrOutput->WritePostitFields();
+ const auto eHasProperties = m_pAttrOutput->WritePostitFields();
m_pAttrOutput->SetSerializer( m_pDocumentFS );
pPostitFS->endElementNS( XML_w, XML_comments );
+ pPostitFS->endDocument();
+
+ if (eHasProperties != DocxAttributeOutput::hasProperties::yes)
+ return;
+
+ m_rFilter.addRelation(m_pDocumentFS->getOutputStream(),
+ oox::getRelationship(Relationship::COMMENTSEXTENDED),
+ u"commentsExtended.xml");
+
+ pPostitFS = m_rFilter.openFragmentStreamWithSerializer(
+ "word/commentsExtended.xml",
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml");
+
+ pPostitFS->startElementNS(XML_w15, XML_commentsEx, // Add namespaces manually now
+ FSNS(XML_xmlns, XML_mc), m_rFilter.getNamespaceURL(OOX_NS(mce)),
+ FSNS(XML_xmlns, XML_w15), m_rFilter.getNamespaceURL(OOX_NS(w15)),
+ FSNS(XML_mc, XML_Ignorable), "w15");
+ m_pAttrOutput->SetSerializer(pPostitFS);
+ m_pAttrOutput->WritePostItFieldsResolved();
+ m_pAttrOutput->SetSerializer(m_pDocumentFS);
+ pPostitFS->endElementNS(XML_w15, XML_commentsEx);
+ pPostitFS->endDocument();
}
void DocxExport::WriteNumbering()
@@ -748,7 +800,7 @@ void DocxExport::WriteNumbering()
m_rFilter.addRelation( m_pDocumentFS->getOutputStream(),
oox::getRelationship(Relationship::NUMBERING),
- "numbering.xml" );
+ u"numbering.xml" );
::sax_fastparser::FSHelperPtr pNumberingFS = m_rFilter.openFragmentStreamWithSerializer( "word/numbering.xml",
"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" );
@@ -777,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 )
@@ -818,15 +872,11 @@ void DocxExport::WriteHeaderFooter( const SwFormat* pFormat, bool bHeader, const
SetFS( pFS );
{
DocxTableExportContext aTableExportContext(*m_pAttrOutput);
- //When the stream changes the cache which is maintained for the graphics in case of alternate content is not cleared.
- //So clearing the alternate content graphic cache.
- m_pAttrOutput->PushRelIdCache();
// do the work
if (pFormat == nullptr)
AttrOutput().EmptyParagraph();
else
WriteHeaderFooterText(*pFormat, bHeader);
- m_pAttrOutput->PopRelIdCache();
m_pAttrOutput->EndParaSdtBlock();
}
@@ -853,13 +903,15 @@ 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()
{
m_rFilter.addRelation( m_pDocumentFS->getOutputStream(),
oox::getRelationship(Relationship::FONTTABLE),
- "fontTable.xml" );
+ u"fontTable.xml" );
::sax_fastparser::FSHelperPtr pFS = m_rFilter.openFragmentStreamWithSerializer(
"word/fontTable.xml",
@@ -879,6 +931,8 @@ void DocxExport::WriteFonts()
m_pAttrOutput->SetSerializer( m_pDocumentFS );
pFS->endElementNS( XML_w, XML_fonts );
+
+ pFS->endDocument();
}
void DocxExport::WriteProperties( )
@@ -916,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))
{
@@ -954,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)
@@ -963,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()
@@ -975,9 +1039,11 @@ 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),
- "settings.xml" );
+ u"settings.xml" );
::sax_fastparser::FSHelperPtr pFS = m_rFilter.openFragmentStreamWithSerializer(
"word/settings.xml",
@@ -986,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())
{
@@ -1015,8 +1136,7 @@ void DocxExport::WriteSettings()
OString aZoom(OString::number(pViewShell->GetViewOptions()->GetZoom()));
pAttributeList->add(FSNS(XML_w, XML_percent), aZoom);
- sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList.get());
- pFS->singleElementNS(XML_w, XML_zoom, xAttributeList);
+ pFS->singleElementNS(XML_w, XML_zoom, pAttributeList);
}
// Display Background Shape
@@ -1039,6 +1159,11 @@ void DocxExport::WriteSettings()
if(isMirroredMargin())
pFS->singleElementNS(XML_w, XML_mirrorMargins);
+ if (m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::GUTTER_AT_TOP))
+ {
+ pFS->singleElementNS(XML_w, XML_gutterAtTop);
+ }
+
// Embed Fonts
if( m_rDoc.getIDocumentSettingAccess().get( DocumentSettingId::EMBED_FONTS ))
pFS->singleElementNS(XML_w, XML_embedTrueTypeFonts);
@@ -1068,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 );
}
@@ -1078,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
@@ -1098,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;
@@ -1124,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]
*
@@ -1137,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 ) )
@@ -1145,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];
@@ -1175,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;
@@ -1183,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;
@@ -1232,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[] =
{
@@ -1258,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();
@@ -1282,8 +1413,7 @@ void DocxExport::WriteSettings()
if ( bUseGrabBagProtection )
{
- sax_fastparser::XFastAttributeListRef xFastAttributeList(xAttributeList.get());
- pFS->singleElementNS(XML_w, XML_documentProtection, xFastAttributeList);
+ pFS->singleElementNS(XML_w, XML_documentProtection, xAttributeList);
}
}
@@ -1307,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 );
}
@@ -1337,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),
- "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 );
@@ -1382,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" )
@@ -1409,7 +1536,7 @@ void DocxExport::WriteGlossary()
m_rFilter.addRelation( m_pDocumentFS->getOutputStream(),
oox::getRelationship(Relationship::GLOSSARYDOCUMENT),
- "glossary/document.xml" );
+ u"glossary/document.xml" );
uno::Reference< io::XOutputStream > xOutputStream = GetFilter().openFragmentStream( "word/glossary/document.xml",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml" );
@@ -1420,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 ),
@@ -1441,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++)
@@ -1472,30 +1692,74 @@ void DocxExport::WriteCustomXml()
{
m_rFilter.addRelation( m_pDocumentFS->getOutputStream(),
oox::getRelationship(Relationship::CUSTOMXML),
- "../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())
{
uno::Reference< xml::sax::XSAXSerializable > serializer( customXmlDomProps, uno::UNO_QUERY );
uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() );
- writer->setOutputStream( GetFilter().openFragmentStream( "customXml/itemProps"+OUString::number((j+1))+".xml",
+ writer->setOutputStream( GetFilter().openFragmentStream( "customXml/itemProps"+OUString::number(j+1)+".xml",
"application/vnd.openxmlformats-officedocument.customXmlProperties+xml" ) );
serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
uno::Sequence< beans::StringPair >() );
// Adding itemprops's relationship entry to item.xml.rels file
- m_rFilter.addRelation( GetFilter().openFragmentStream( "customXml/item"+OUString::number((j+1))+".xml",
+ m_rFilter.addRelation( GetFilter().openFragmentStream( "customXml/item"+OUString::number(j+1)+".xml",
"application/xml" ) ,
oox::getRelationship(Relationship::CUSTOMXMLPROPS),
- "itemProps"+OUString::number((j+1))+".xml" );
+ Concat2View("itemProps"+OUString::number(j+1)+".xml" ));
}
}
}
@@ -1529,7 +1793,7 @@ void DocxExport::WriteVBA()
pOut->WriteStream(*pIn);
// Write the relationship.
- m_rFilter.addRelation(m_pDocumentFS->getOutputStream(), oox::getRelationship(Relationship::VBAPROJECT), "vbaProject.bin");
+ m_rFilter.addRelation(m_pDocumentFS->getOutputStream(), oox::getRelationship(Relationship::VBAPROJECT), u"vbaProject.bin");
}
OUString aDataName("_MS_VBA_Macros_XML");
@@ -1556,7 +1820,7 @@ void DocxExport::WriteVBA()
if (!xProjectStream.is())
return;
- m_rFilter.addRelation(xProjectStream, oox::getRelationship(Relationship::WORDVBADATA), "vbaData.xml");
+ m_rFilter.addRelation(xProjectStream, oox::getRelationship(Relationship::WORDVBADATA), u"vbaData.xml");
}
void DocxExport::WriteEmbeddings()
@@ -1571,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;
@@ -1637,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;
- if ( getenv("SW_DEBUG_DOM") )
+ 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
{
- m_rDoc.dumpAsXml();
+ 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);
+
+ m_pDocumentFS->endElementNS(XML_v, XML_background);
+ }
}
+ else if (eFillType == drawing::FillStyle_GRADIENT)
+ {
+ 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();
@@ -1683,22 +1987,23 @@ void DocxExport::WriteMainText()
m_pDocumentFS->endElementNS( XML_w, XML_document );
}
-XFastAttributeListRef DocxExport::MainXmlNamespaces()
+rtl::Reference<FastAttributeList> DocxExport::MainXmlNamespaces()
{
- FastAttributeList* pAttr = FastSerializerHelper::createAttrList();
- pAttr->add( FSNS( XML_xmlns, XML_o ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(vmlOffice)), RTL_TEXTENCODING_UTF8).getStr() );
- pAttr->add( FSNS( XML_xmlns, XML_r ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(officeRel)), RTL_TEXTENCODING_UTF8).getStr() );
- pAttr->add( FSNS( XML_xmlns, XML_v ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(vml)), RTL_TEXTENCODING_UTF8).getStr() );
- pAttr->add( FSNS( XML_xmlns, XML_w ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(doc)), RTL_TEXTENCODING_UTF8).getStr() );
- pAttr->add( FSNS( XML_xmlns, XML_w10 ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(vmlWord)), RTL_TEXTENCODING_UTF8).getStr() );
- pAttr->add( FSNS( XML_xmlns, XML_wp ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(dmlWordDr)), RTL_TEXTENCODING_UTF8).getStr() );
- pAttr->add( FSNS( XML_xmlns, XML_wps ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(wps)), RTL_TEXTENCODING_UTF8).getStr() );
- pAttr->add( FSNS( XML_xmlns, XML_wpg ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(wpg)), RTL_TEXTENCODING_UTF8).getStr() );
- pAttr->add( FSNS( XML_xmlns, XML_mc ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(mce)), RTL_TEXTENCODING_UTF8).getStr() );
- pAttr->add( FSNS( XML_xmlns, XML_wp14 ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(wp14)), RTL_TEXTENCODING_UTF8).getStr() );
- pAttr->add( FSNS( XML_xmlns, XML_w14 ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(w14)), RTL_TEXTENCODING_UTF8).getStr() );
- pAttr->add( FSNS( XML_mc, XML_Ignorable ), "w14 wp14" );
- return XFastAttributeListRef( pAttr );
+ rtl::Reference<FastAttributeList> pAttr = FastSerializerHelper::createAttrList();
+ pAttr->add( FSNS( XML_xmlns, XML_o ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(vmlOffice)), RTL_TEXTENCODING_UTF8) );
+ pAttr->add( FSNS( XML_xmlns, XML_r ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(officeRel)), RTL_TEXTENCODING_UTF8) );
+ pAttr->add( FSNS( XML_xmlns, XML_v ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(vml)), RTL_TEXTENCODING_UTF8) );
+ pAttr->add( FSNS( XML_xmlns, XML_w ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(doc)), RTL_TEXTENCODING_UTF8) );
+ pAttr->add( FSNS( XML_xmlns, XML_w10 ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(vmlWord)), RTL_TEXTENCODING_UTF8) );
+ pAttr->add( FSNS( XML_xmlns, XML_wp ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(dmlWordDr)), RTL_TEXTENCODING_UTF8) );
+ pAttr->add( FSNS( XML_xmlns, XML_wps ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(wps)), RTL_TEXTENCODING_UTF8) );
+ pAttr->add( FSNS( XML_xmlns, XML_wpg ), OUStringToOString(m_rFilter.getNamespaceURL(OOX_NS(wpg)), RTL_TEXTENCODING_UTF8) );
+ 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_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;
}
bool DocxExport::ignoreAttributeForStyleDefaults( sal_uInt16 nWhich ) const
@@ -1710,22 +2015,32 @@ bool DocxExport::ignoreAttributeForStyleDefaults( sal_uInt16 nWhich ) const
return MSWordExportBase::ignoreAttributeForStyleDefaults( nWhich );
}
-void DocxExport::WriteOutliner(const OutlinerParaObject& rParaObj, sal_uInt8 nTyp)
+sal_Int32 DocxExport::WriteOutliner(const OutlinerParaObject& rParaObj, sal_uInt8 nTyp,
+ bool bNeedsLastParaId)
{
const EditTextObject& rEditObj = rParaObj.GetTextObject();
MSWord_SdrAttrIter aAttrIter( *this, rEditObj, nTyp );
sal_Int32 nPara = rEditObj.GetParagraphCount();
+ sal_Int32 nParaId = 0;
for( sal_Int32 n = 0; n < nPara; ++n )
{
if( n )
aAttrIter.NextPara( n );
- AttrOutput().StartParagraph( ww8::WW8TableNodeInfo::Pointer_t());
+ nParaId = AttrOutput().StartParagraph(ww8::WW8TableNodeInfo::Pointer_t(),
+ bNeedsLastParaId && n == nPara - 1);
rtl_TextEncoding eChrSet = aAttrIter.GetNodeCharSet();
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);
@@ -1750,12 +2065,65 @@ void DocxExport::WriteOutliner(const OutlinerParaObject& rParaObj, sal_uInt8 nTy
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 )
@@ -1774,14 +2142,15 @@ 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( );
// relations for the document
m_rFilter.addRelation( oox::getRelationship(Relationship::OFFICEDOCUMENT),
- "word/document.xml" );
+ u"word/document.xml" );
// Set media type depending of document type
OUString aMediaType;
@@ -1829,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 7a3c3a47424f..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;
@@ -150,7 +165,7 @@ public:
virtual void ExportGrfBullet(const SwTextNode&) override;
/// Returns the relationd id
- OString AddRelation( const OUString& rType, const OUString& rTarget );
+ OString AddRelation( const OUString& rType, std::u16string_view rTarget );
virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t()*/ ) override { /* FIXME no-op for docx, most probably should not even be in MSWordExportBase */ }
virtual void WriteChar( sal_Unicode ) override { SAL_WARN("sw.ww8", "FIXME: WriteChar() has nothing to do for docx."); }
@@ -160,7 +175,8 @@ public:
/// Output the actual headers and footers.
virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
- const SwFrameFormat& rFormat, const SwFrameFormat& rLeftFormat, const SwFrameFormat& rFirstPageFormat, sal_uInt8 nBreakCode ) override;
+ const SwFrameFormat& rFormat, const SwFrameFormat& rLeftHeaderFormat, const SwFrameFormat& rLeftFooterFormat, const SwFrameFormat& rFirstPageFormat,
+ sal_uInt8 nBreakCode, bool bEvenAndOddHeaders ) override;
/// Write the field
virtual void OutputField( const SwField* pField, ww::eField eFieldType,
@@ -178,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 );
@@ -189,10 +205,15 @@ public:
/// Writes the shape using drawingML syntax.
void OutputDML( css::uno::Reference< css::drawing::XShape > const & xShape );
- void WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp);
+ sal_Int32 WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp, bool bNeedsLastParaId);
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;
@@ -216,12 +237,16 @@ protected:
virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
const SwNode& rNd,
const SwFormatPageDesc* pNewPgDescFormat,
- const SwPageDesc* pNewPgDesc ) override;
+ const SwPageDesc* pNewPgDesc,
+ bool bExtraPageBreak = false) override;
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();
@@ -265,7 +290,7 @@ private:
public:
/// All xml namespaces to be used at the top of any text .xml file (main doc, headers, footers,...)
- sax_fastparser::XFastAttributeListRef MainXmlNamespaces();
+ rtl::Reference<sax_fastparser::FastAttributeList> MainXmlNamespaces();
/// FIXME this is temporary, remotely reminding the method of the same
/// name in WW8Export.
@@ -294,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 1af1dce13942..4722e7ce4079 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -15,14 +15,21 @@
#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>
#include <fmtcntnt.hxx>
#include <fmtornt.hxx>
#include <fmtfsize.hxx>
+#include <fmtfollowtextflow.hxx>
#include <frmatr.hxx>
#include <fmtwrapinfluenceonobjpos.hxx>
#include "docxattributeoutput.hxx"
@@ -30,12 +37,15 @@
#include <comphelper/flagguard.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/sequenceashashmap.hxx>
-#include <sal/log.hxx>
#include <frmfmt.hxx>
#include <IDocumentDrawModelAccess.hxx>
+#include <svx/svdtrans.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
using namespace com::sun::star;
using namespace oox;
+using namespace sax_fastparser;
namespace
{
@@ -68,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"; });
@@ -81,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.
@@ -112,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);
@@ -141,8 +461,8 @@ private:
bool m_bParagraphSdtOpen;
bool m_bParagraphHasDrawing; ///Flag for checking drawing in a paragraph.
rtl::Reference<sax_fastparser::FastAttributeList> m_pFlyFillAttrList;
- sax_fastparser::FastAttributeList* m_pFlyWrapAttrList;
- sax_fastparser::FastAttributeList* m_pBodyPrAttrList;
+ rtl::Reference<sax_fastparser::FastAttributeList> m_pFlyWrapAttrList;
+ rtl::Reference<sax_fastparser::FastAttributeList> m_pBodyPrAttrList;
rtl::Reference<sax_fastparser::FastAttributeList> m_pDashLineStyleAttr;
bool m_bDMLAndVMLDrawingOpen;
/// List of TextBoxes in this document: they are exported as part of their shape, never alone.
@@ -163,8 +483,6 @@ public:
, m_bDrawingOpen(false)
, m_bParagraphSdtOpen(false)
, m_bParagraphHasDrawing(false)
- , m_pFlyWrapAttrList(nullptr)
- , m_pBodyPrAttrList(nullptr)
, m_bDMLAndVMLDrawingOpen(false)
{
}
@@ -172,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)
{
@@ -243,19 +562,23 @@ public:
return m_pFlyFillAttrList;
}
- void setFlyWrapAttrList(sax_fastparser::FastAttributeList* pFlyWrapAttrList)
+ void
+ setFlyWrapAttrList(rtl::Reference<sax_fastparser::FastAttributeList> const& pFlyWrapAttrList)
{
m_pFlyWrapAttrList = pFlyWrapAttrList;
}
- sax_fastparser::FastAttributeList* getFlyWrapAttrList() const { return m_pFlyWrapAttrList; }
+ sax_fastparser::FastAttributeList* getFlyWrapAttrList() const
+ {
+ return m_pFlyWrapAttrList.get();
+ }
void setBodyPrAttrList(sax_fastparser::FastAttributeList* pBodyPrAttrList)
{
m_pBodyPrAttrList = pBodyPrAttrList;
}
- sax_fastparser::FastAttributeList* getBodyPrAttrList() const { return m_pBodyPrAttrList; }
+ sax_fastparser::FastAttributeList* getBodyPrAttrList() const { return m_pBodyPrAttrList.get(); }
rtl::Reference<sax_fastparser::FastAttributeList>& getDashLineStyleAttr()
{
@@ -338,24 +661,30 @@ rtl::Reference<sax_fastparser::FastAttributeList>& DocxSdrExport::getDashLineSty
return m_pImpl->getDashLineStyleAttr();
}
-void DocxSdrExport::setFlyWrapAttrList(sax_fastparser::FastAttributeList* pAttrList)
+void DocxSdrExport::setFlyWrapAttrList(
+ rtl::Reference<sax_fastparser::FastAttributeList> const& pAttrList)
{
m_pImpl->setFlyWrapAttrList(pAttrList);
}
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
@@ -365,68 +694,156 @@ 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);
}
}
if (isAnchor)
{
- sax_fastparser::FastAttributeList* attrList
+ 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()
@@ -435,36 +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");
- // 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;
- 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;
- 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;
- 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;
- 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)
{
@@ -474,34 +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);
}
- sax_fastparser::XFastAttributeListRef xAttrList(attrList);
- m_pImpl->getSerializer()->startElementNS(XML_wp, XML_anchor, xAttrList);
+
+ 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";
@@ -519,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";
@@ -537,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";
@@ -551,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";
@@ -573,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";
@@ -593,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.
@@ -602,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);
@@ -636,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
@@ -650,7 +1081,7 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
&& (!alignV || strcmp(alignV, "top") == 0))
{
alignV = nullptr;
- nPosYEMU = 635;
+ nPosYEMU = TwipsToEMU(1);
}
if (alignV != nullptr)
@@ -675,27 +1106,25 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
}
m_pImpl->getSerializer()->endElementNS(XML_wp, XML_positionV);
}
- else
+ else // inline
{
- sax_fastparser::FastAttributeList* aAttrList
+ // 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
*
@@ -713,109 +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;
+ }
+
+ if (rSurround.GetValue() == css::text::WrapTextMode_NONE)
+ {
+ m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapTopAndBottom);
+ return;
+ }
- // Or if we have a contour.
- if (!nWrapToken && pFrameFormat->GetSurround().IsContour())
+ // All remaining cases need attribute XML_wrapText
+ OUString sWrapType;
+ switch (rSurround.GetSurround())
{
- if (const SwNoTextNode* pNd = sw::util::GetNoTextNodeFromSwFrameFormat(*pFrameFormat))
+ 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;
}
}
}
- // No? Then just approximate based on what we have.
- if (!isAnchor || nWrapToken)
- return;
-
- switch (pFrameFormat->GetSurround().GetValue())
+ // 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)
{
- 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;
+ uno::Any aAny;
+ pObj->GetGrabBagItem(aAny);
+ comphelper::SequenceAsHashMap aGrabBag(aAny);
+ auto it = aGrabBag.find("CT_WrapPath");
+ if (it != aGrabBag.end())
+ {
+ m_pImpl->getSerializer()->startElementNS(XML_wp, nWrapToken, XML_wrapText, sWrapType);
+
+ 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)
+ {
+ 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;
+ }
}
+
+ // 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)
@@ -841,21 +1364,21 @@ void DocxSdrExport::writeVMLDrawing(const SdrObject* sdrObj, const SwFrameFormat
m_pImpl->getDrawingML()->SetFS(m_pImpl->getSerializer());
// See WinwordAnchoring::SetAnchoring(), these are not part of the SdrObject, have to be passed around manually.
+ SwFormatFollowTextFlow const& rFlow(rFrameFormat.GetFollowTextFlow());
const SwFormatHoriOrient& rHoriOri = rFrameFormat.GetHoriOrient();
const SwFormatVertOrient& rVertOri = rFrameFormat.GetVertOrient();
SwFormatSurround const& rSurround(rFrameFormat.GetSurround());
- std::unique_ptr<sax_fastparser::FastAttributeList> pAttrList(
- docx::SurroundToVMLWrap(rSurround));
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttrList(docx::SurroundToVMLWrap(rSurround));
m_pImpl->getExport().VMLExporter().AddSdrObject(
- *sdrObj, rHoriOri.GetHoriOrient(), rVertOri.GetVertOrient(), rHoriOri.GetRelationOrient(),
- rVertOri.GetRelationOrient(), std::move(pAttrList), true);
+ *sdrObj, rFlow.GetValue(), rHoriOri.GetHoriOrient(), rVertOri.GetVertOrient(),
+ rHoriOri.GetRelationOrient(), rVertOri.GetRelationOrient(), pAttrList.get(), true);
m_pImpl->getSerializer()->endElementNS(XML_w, XML_pict);
}
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
@@ -865,37 +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);
- sax_fastparser::FastAttributeList* pDocPrAttrList
+ 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).getStr());
+ 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());
- sax_fastparser::XFastAttributeListRef xDocPrAttrListRef(pDocPrAttrList);
- pFS->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef);
+ 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";
@@ -1018,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;
}
@@ -1047,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);
@@ -1147,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);
@@ -1160,13 +1725,13 @@ 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);
- m_pImpl->setBodyPrAttrList(sax_fastparser::FastSerializerHelper::createAttrList());
+ m_pImpl->setBodyPrAttrList(sax_fastparser::FastSerializerHelper::createAttrList().get());
::comphelper::FlagRestorationGuard const g(m_pImpl->m_bFlyFrameGraphic, true);
comphelper::ValueRestorationGuard vg(m_pImpl->getExport().m_nTextTyp, TXT_TXTBOX);
m_pImpl->getExport().WriteText();
@@ -1199,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()));
@@ -1225,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);
@@ -1244,7 +1814,7 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho
if (xPropertySet.is())
xPropSetInfo = xPropertySet->getPropertySetInfo();
- m_pImpl->setBodyPrAttrList(sax_fastparser::FastSerializerHelper::createAttrList());
+ m_pImpl->setBodyPrAttrList(sax_fastparser::FastSerializerHelper::createAttrList().get());
{
drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("TextVerticalAdjust"))
@@ -1257,13 +1827,28 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho
{
startDMLAnchorInline(&rFrameFormat, aSize);
- sax_fastparser::FastAttributeList* pDocPrAttrList
+ 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).getStr());
- sax_fastparser::XFastAttributeListRef xDocPrAttrListRef(pDocPrAttrList);
- pFS->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef);
+ 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)));
@@ -1278,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;
@@ -1310,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"
@@ -1423,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);
@@ -1454,7 +2042,7 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho
m_pImpl->getBodyPrAttrList()->add(XML_bIns, OString::number(0));
}
- sax_fastparser::XFastAttributeListRef xBodyPrAttrList(m_pImpl->getBodyPrAttrList());
+ rtl::Reference<FastAttributeList> xBodyPrAttrList(m_pImpl->getBodyPrAttrList());
m_pImpl->setBodyPrAttrList(nullptr);
if (!bTextBoxOnly)
{
@@ -1510,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);
@@ -1527,12 +2115,8 @@ 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));
- m_pImpl->getExport()
- .SdrExporter()
- .getTextFrameStyle()
- .append(";rotation:")
- .append(sRotation);
+ 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);
m_pImpl->getFlyAttrList()->add(XML_style, m_pImpl->getTextFrameStyle().makeStringAndClear());
@@ -1542,12 +2126,20 @@ 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);
}
- sax_fastparser::XFastAttributeListRef xFlyAttrList(m_pImpl->getFlyAttrList().get());
+ rtl::Reference<FastAttributeList> xFlyAttrList(m_pImpl->getFlyAttrList());
m_pImpl->getFlyAttrList().clear();
- sax_fastparser::XFastAttributeListRef xTextboxAttrList(m_pImpl->getTextboxAttrList().get());
+ rtl::Reference<FastAttributeList> xTextboxAttrList(m_pImpl->getTextboxAttrList());
m_pImpl->getTextboxAttrList().clear();
m_pImpl->setTextFrameSyntax(false);
m_pImpl->setFlyFrameSize(nullptr);
@@ -1560,20 +2152,19 @@ void DocxSdrExport::writeVMLTextFrame(ww8::Frame const* pParentFrame, bool bText
m_pImpl->textFrameShadow(rFrameFormat);
if (m_pImpl->getFlyFillAttrList().is())
{
- sax_fastparser::XFastAttributeListRef xFlyFillAttrList(
- m_pImpl->getFlyFillAttrList().get());
- m_pImpl->getFlyFillAttrList().clear();
+ rtl::Reference<FastAttributeList> xFlyFillAttrList(m_pImpl->getFlyFillAttrList());
pFS->singleElementNS(XML_v, XML_fill, xFlyFillAttrList);
}
if (m_pImpl->getDashLineStyleAttr().is())
{
- sax_fastparser::XFastAttributeListRef xDashLineStyleAttr(
- m_pImpl->getDashLineStyleAttr().get());
- m_pImpl->getDashLineStyleAttr().clear();
+ rtl::Reference<FastAttributeList> xDashLineStyleAttr(m_pImpl->getDashLineStyleAttr());
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);
@@ -1592,7 +2183,7 @@ void DocxSdrExport::writeVMLTextFrame(ww8::Frame const* pParentFrame, bool bText
if (m_pImpl->getFlyWrapAttrList())
{
- sax_fastparser::XFastAttributeListRef xFlyWrapAttrList(m_pImpl->getFlyWrapAttrList());
+ rtl::Reference<FastAttributeList> xFlyWrapAttrList(m_pImpl->getFlyWrapAttrList());
m_pImpl->setFlyWrapAttrList(nullptr);
pFS->singleElementNS(XML_w10, XML_wrap, xFlyWrapAttrList);
}
diff --git a/sw/source/filter/ww8/docxsdrexport.hxx b/sw/source/filter/ww8/docxsdrexport.hxx
index c1fa05eeb44f..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();
};
@@ -70,7 +72,7 @@ public:
bool IsParagraphHasDrawing() const;
void setParagraphHasDrawing(bool bParagraphHasDrawing);
rtl::Reference<sax_fastparser::FastAttributeList>& getFlyFillAttrList();
- void setFlyWrapAttrList(sax_fastparser::FastAttributeList* pAttrList);
+ void setFlyWrapAttrList(rtl::Reference<sax_fastparser::FastAttributeList> const & pAttrList);
/// Attributes of <wps:bodyPr>, used during DML export of text frames.
sax_fastparser::FastAttributeList* getBodyPrAttrList();
rtl::Reference<sax_fastparser::FastAttributeList>& getDashLineStyle();
@@ -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 495a1bddc942..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);
@@ -89,13 +89,13 @@ public:
void DocxTableStyleExport::CnfStyle(const uno::Sequence<beans::PropertyValue>& rAttributeList)
{
- sax_fastparser::FastAttributeList* pAttributeList
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
= sax_fastparser::FastSerializerHelper::createAttrList();
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,12 +114,11 @@ 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>());
}
}
- sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
- m_pImpl->getSerializer()->singleElementNS(XML_w, XML_cnfStyle, xAttributeList);
+ m_pImpl->getSerializer()->singleElementNS(XML_w, XML_cnfStyle, pAttributeList);
}
void DocxTableStyleExport::TableStyles(sal_Int32 nCountStylesToWrite)
@@ -131,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;
@@ -189,14 +188,13 @@ void DocxTableStyleExport::Impl::tableStyleTcBorder(
if (!rTcBorder.hasElements())
return;
- sax_fastparser::FastAttributeList* pAttributeList
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
= 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>());
- sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
- m_pSerializer->singleElementNS(XML_w, nToken, xAttributeList);
+ m_pSerializer->singleElementNS(XML_w, nToken, pAttributeList);
}
void DocxTableStyleExport::Impl::tableStyleTcBorders(
@@ -230,27 +228,24 @@ void DocxTableStyleExport::Impl::tableStyleShd(const uno::Sequence<beans::Proper
if (!rShd.hasElements())
return;
- sax_fastparser::FastAttributeList* pAttributeList
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
= sax_fastparser::FastSerializerHelper::createAttrList();
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>());
}
- sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
- m_pSerializer->singleElementNS(XML_w, XML_shd, xAttributeList);
+ m_pSerializer->singleElementNS(XML_w, XML_shd, pAttributeList);
}
void DocxTableStyleExport::Impl::tableStyleRColor(const uno::Sequence<beans::PropertyValue>& rColor)
@@ -258,21 +253,20 @@ void DocxTableStyleExport::Impl::tableStyleRColor(const uno::Sequence<beans::Pro
if (!rColor.hasElements())
return;
- sax_fastparser::FastAttributeList* pAttributeList
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
= sax_fastparser::FastSerializerHelper::createAttrList();
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>());
}
- sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
- m_pSerializer->singleElementNS(XML_w, XML_color, xAttributeList);
+ m_pSerializer->singleElementNS(XML_w, XML_color, pAttributeList);
}
void DocxTableStyleExport::Impl::tableStyleRLang(const uno::Sequence<beans::PropertyValue>& rLang)
@@ -280,19 +274,18 @@ void DocxTableStyleExport::Impl::tableStyleRLang(const uno::Sequence<beans::Prop
if (!rLang.hasElements())
return;
- sax_fastparser::FastAttributeList* pAttributeList
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
= sax_fastparser::FastSerializerHelper::createAttrList();
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>());
}
- sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
- m_pSerializer->singleElementNS(XML_w, XML_lang, xAttributeList);
+ m_pSerializer->singleElementNS(XML_w, XML_lang, pAttributeList);
}
void DocxTableStyleExport::Impl::tableStyleRRFonts(
@@ -301,22 +294,20 @@ void DocxTableStyleExport::Impl::tableStyleRRFonts(
if (!rRFonts.hasElements())
return;
- sax_fastparser::FastAttributeList* pAttributeList
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
= sax_fastparser::FastSerializerHelper::createAttrList();
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>());
}
- sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
- m_pSerializer->singleElementNS(XML_w, XML_rFonts, xAttributeList);
+ m_pSerializer->singleElementNS(XML_w, XML_rFonts, pAttributeList);
}
void DocxTableStyleExport::Impl::tableStylePSpacing(
@@ -325,31 +316,30 @@ void DocxTableStyleExport::Impl::tableStylePSpacing(
if (!rSpacing.hasElements())
return;
- sax_fastparser::FastAttributeList* pAttributeList
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
= sax_fastparser::FastSerializerHelper::createAttrList();
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");
}
- sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
- m_pSerializer->singleElementNS(XML_w, XML_spacing, xAttributeList);
+ m_pSerializer->singleElementNS(XML_w, XML_spacing, pAttributeList);
}
void DocxTableStyleExport::Impl::tableStylePInd(const uno::Sequence<beans::PropertyValue>& rInd)
@@ -357,17 +347,16 @@ void DocxTableStyleExport::Impl::tableStylePInd(const uno::Sequence<beans::Prope
if (!rInd.hasElements())
return;
- sax_fastparser::FastAttributeList* pAttributeList
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
= sax_fastparser::FastSerializerHelper::createAttrList();
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>());
}
- sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
- m_pSerializer->singleElementNS(XML_w, XML_ind, xAttributeList);
+ m_pSerializer->singleElementNS(XML_w, XML_ind, pAttributeList);
}
void DocxTableStyleExport::Impl::tableStyleTableInd(
@@ -376,29 +365,27 @@ void DocxTableStyleExport::Impl::tableStyleTableInd(
if (!rTableInd.hasElements())
return;
- sax_fastparser::FastAttributeList* pAttributeList
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
= sax_fastparser::FastSerializerHelper::createAttrList();
for (const auto& rProp : rTableInd)
{
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>());
}
- sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
- m_pSerializer->singleElementNS(XML_w, XML_tblInd, xAttributeList);
+ 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;
- sax_fastparser::FastAttributeList* pAttributeList
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
= sax_fastparser::FastSerializerHelper::createAttrList();
- if (aValue != "1")
- pAttributeList->add(FSNS(XML_w, XML_val), aValue.toUtf8());
- sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
- m_pSerializer->singleElementNS(XML_w, nToken, xAttributeList);
+ if (aValue != u"1")
+ pAttributeList->add(FSNS(XML_w, XML_val), aValue);
+ m_pSerializer->singleElementNS(XML_w, nToken, pAttributeList);
}
void DocxTableStyleExport::Impl::tableStyleRPr(const uno::Sequence<beans::PropertyValue>& rRPr)
@@ -697,7 +684,7 @@ void DocxTableStyleExport::Impl::TableStyle(const uno::Sequence<beans::PropertyV
aTableStylePrs.push_back(rProp.Value.get<uno::Sequence<beans::PropertyValue>>());
}
- sax_fastparser::FastAttributeList* pAttributeList
+ rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList
= sax_fastparser::FastSerializerHelper::createAttrList();
pAttributeList->add(FSNS(XML_w, XML_type), "table");
if (bDefault)
@@ -705,9 +692,8 @@ 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());
- sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
- m_pSerializer->startElementNS(XML_w, XML_style, xAttributeList);
+ 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);
if (!aBasedOn.isEmpty())
@@ -727,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 68a58d856f33..4c7dd8760028 100644
--- a/sw/source/filter/ww8/fields.cxx
+++ b/sw/source/filter/ww8/fields.cxx
@@ -23,10 +23,12 @@
namespace ww
{
- const char *GetEnglishFieldName(eField eIndex) throw()
+ const char *GetEnglishFieldName(eField eIndex) noexcept
{
//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/fields.hxx b/sw/source/filter/ww8/fields.hxx
index a539c645cf85..d11b92e2ad5b 100644
--- a/sw/source/filter/ww8/fields.hxx
+++ b/sw/source/filter/ww8/fields.hxx
@@ -40,7 +40,7 @@ namespace ww
@return 0 if not found, otherwise the fieldname as a C style ASCII
string
*/
-const char* GetEnglishFieldName(eField eIndex) throw();
+const char* GetEnglishFieldName(eField eIndex) noexcept;
}
#endif
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 3f39c585a0ab..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>
@@ -64,9 +63,9 @@
#include <editeng/keepitem.hxx>
#include <editeng/frmdiritem.hxx>
#include <editeng/opaqitem.hxx>
+#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>
@@ -86,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;
@@ -110,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);
@@ -175,17 +178,22 @@ static OString OutTBLBorderLine(RtfExport const& rExport, const editeng::SvxBord
::editeng::ConvertBorderWidthToWord(pLine->GetBorderLineStyle(), pLine->GetWidth()));
if (255 >= pLine->GetWidth()) // That value comes from RTF specs
{
- aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRW).append(static_cast<sal_Int32>(fConverted));
+ aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRW
+ + OString::number(static_cast<sal_Int32>(fConverted)));
}
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();
}
@@ -194,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();
@@ -210,7 +219,8 @@ void RtfAttributeOutput::RTLAndCJKState(bool bIsRTL, sal_uInt16 nScript)
m_bControlLtrRtl = true;
}
-void RtfAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo)
+sal_Int32 RtfAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo,
+ bool /*bGenerateParaId*/)
{
if (m_bIsBeforeFirstParagraph && m_rExport.m_nTextTyp != TXT_HDFT)
m_bIsBeforeFirstParagraph = false;
@@ -266,6 +276,7 @@ void RtfAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t pTextNo
}
OSL_ENSURE(m_aRun.getLength() == 0, "m_aRun is not empty");
+ return 0;
}
void RtfAttributeOutput::EndParagraph(ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner)
@@ -277,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);
@@ -285,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
@@ -313,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(' ');
}
@@ -326,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())
{
@@ -366,14 +382,12 @@ 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.makeStringAndClear());
+ m_aSectionHeaders.append(aPar);
}
void RtfAttributeOutput::EndParagraphProperties(
@@ -381,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);
}
@@ -401,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);
@@ -425,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)
@@ -448,34 +465,28 @@ OString RtfAttributeOutput::MoveCharacterProperties(bool aAutoWriteRtlLtr)
{
if (!aAssocRtlch.isEmpty())
{
- aBuf.append(OOO_STRING_SVTOOLS_RTF_LTRCH)
- .append(aAssocLtrch)
- .append(' ')
- .append(OOO_STRING_SVTOOLS_RTF_RTLCH)
- .append(aAssocRtlch);
+ aBuf.append(OOO_STRING_SVTOOLS_RTF_LTRCH + aAssocLtrch
+ + " " OOO_STRING_SVTOOLS_RTF_RTLCH + aAssocRtlch);
}
}
else
{
if (!aAssocRtlch.isEmpty())
{
- aBuf.append(OOO_STRING_SVTOOLS_RTF_RTLCH)
- .append(aAssocRtlch)
- .append(' ')
- .append(OOO_STRING_SVTOOLS_RTF_LTRCH)
- .append(aAssocLtrch);
+ aBuf.append(OOO_STRING_SVTOOLS_RTF_RTLCH + aAssocRtlch
+ + " " OOO_STRING_SVTOOLS_RTF_LTRCH + aAssocLtrch);
}
if (!aAssocHich.isEmpty())
{
- aBuf.append(OOO_STRING_SVTOOLS_RTF_HICH).append(aAssocHich);
+ aBuf.append(OOO_STRING_SVTOOLS_RTF_HICH + aAssocHich);
}
if (!aNormal.isEmpty())
{
- aBuf.append(OOO_STRING_SVTOOLS_RTF_LOCH).append(aNormal);
+ aBuf.append(OOO_STRING_SVTOOLS_RTF_LOCH + aNormal);
}
if (!aAssocDbch.isEmpty())
{
- aBuf.append(OOO_STRING_SVTOOLS_RTF_DBCH).append(aAssocDbch);
+ aBuf.append(OOO_STRING_SVTOOLS_RTF_DBCH + aAssocDbch);
}
}
@@ -502,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());
@@ -519,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());
@@ -538,7 +549,7 @@ void RtfAttributeOutput::EndRuby(const SwTextNode& /*rNode*/, sal_Int32 /*nPos*/
bool RtfAttributeOutput::StartURL(const OUString& rUrl, const OUString& rTarget)
{
- m_sURL = rUrl;
+ m_aURLs.push(rUrl);
// Ignore hyperlink without a URL.
if (!rUrl.isEmpty())
{
@@ -553,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()));
@@ -568,7 +581,13 @@ bool RtfAttributeOutput::StartURL(const OUString& rUrl, const OUString& rTarget)
bool RtfAttributeOutput::EndURL(bool const isAtEndOfParagraph)
{
- if (!m_sURL.isEmpty())
+ if (m_aURLs.empty())
+ {
+ return true;
+ }
+
+ const OUString& rURL = m_aURLs.top();
+ if (!rURL.isEmpty())
{
// UGLY: usually EndRun is called earlier, but there is an extra
// call to OutAttrWithRange() when at the end of the paragraph,
@@ -588,12 +607,13 @@ bool RtfAttributeOutput::EndURL(bool const isAtEndOfParagraph)
// close the field group
m_aRun->append('}');
}
- m_sURL.clear();
}
+ m_aURLs.pop();
return true;
}
-void RtfAttributeOutput::FieldVanish(const OUString& /*rText*/, ww::eField /*eType*/)
+void RtfAttributeOutput::FieldVanish(const OUString& /*rText*/, ww::eField /*eType*/,
+ OUString const* /*pBookmarkName*/)
{
SAL_INFO("sw.rtf", "TODO: " << __func__);
}
@@ -634,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.makeStringAndClear());
+ 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)
@@ -657,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);
@@ -676,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,
@@ -700,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.
@@ -724,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
@@ -738,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[]
@@ -771,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();
@@ -793,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())
@@ -809,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();
@@ -850,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();
@@ -862,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();
@@ -874,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();
@@ -888,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);
@@ -897,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);
@@ -914,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,
@@ -923,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();
@@ -948,11 +1087,11 @@ void RtfAttributeOutput::TableOrientation(
break;
}
- m_aRowDefs.append(aTableAdjust.makeStringAndClear());
+ m_aRowDefs.append(aTableAdjust);
}
void RtfAttributeOutput::TableSpacing(
- ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/)
+ const ww8::WW8TableNodeInfoInner::Pointer_t& /*pTableTextNodeInfoInner*/)
{
SAL_INFO("sw.rtf", "TODO: " << __func__);
}
@@ -1010,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; }
@@ -1050,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());
@@ -1076,7 +1216,9 @@ void RtfAttributeOutput::EndTableRow()
m_aAfterRuns.append(m_aTables.back());
m_aTables.pop_back();
}
- m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_ROW).append(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;
}
@@ -1124,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);
@@ -1137,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 << "'");
@@ -1154,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)
{
@@ -1169,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()
@@ -1206,12 +1349,12 @@ 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);
}
}
void RtfAttributeOutput::SectionBreak(sal_uInt8 nC, bool /*bBreakAfter*/,
- const WW8_SepInfo* pSectionInfo)
+ const WW8_SepInfo* pSectionInfo, bool /*bExtraPageBreak*/)
{
switch (nC)
{
@@ -1232,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()
@@ -1252,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);
}
}
@@ -1277,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);
}
@@ -1366,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()
@@ -1436,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,
@@ -1472,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)
@@ -1556,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:
@@ -1573,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)
{
@@ -1588,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)
@@ -1597,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);
+
+ if (isLegal)
+ {
+ m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LEVELLEGAL);
+ }
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LEVELFOLLOW);
- m_rExport.OutULong(nFollow);
+ 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);
@@ -1653,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)
@@ -1663,15 +1833,17 @@ 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)
{
m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_FIELD);
+ if (pField && (pField->GetSubType() & FIXEDFLD))
+ m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLDLOCK);
m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FLDINST
" ");
m_aRunText->append(
@@ -1698,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)
{
@@ -1712,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();
}
@@ -1738,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();
@@ -1753,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);
@@ -1792,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
@@ -1804,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);
@@ -1853,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));
@@ -1872,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));
@@ -1898,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.
@@ -1923,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();
@@ -1938,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;
}
@@ -1992,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;
@@ -2007,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.
@@ -2027,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();
@@ -2057,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:
@@ -2099,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);
@@ -2195,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()));
@@ -2308,13 +2501,11 @@ void RtfAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Poi
}
xPropSet->getPropertyValue("StringItemList") >>= aStrSeq;
- for (const auto& rStr : std::as_const(aStrSeq))
- m_aRun
- ->append(
- "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFL
- " ")
- .append(OUStringToOString(rStr, m_rExport.GetCurrentEncoding()))
- .append('}');
+ for (const auto& rStr : aStrSeq)
+ m_aRun->append(
+ "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFL " "
+ + OUStringToOString(rStr, m_rExport.GetCurrentEncoding())
+ + "}");
m_aRun->append("}}");
@@ -2334,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)
{
@@ -2554,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())
@@ -2877,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("}");
@@ -2935,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++)
{
@@ -3030,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);
@@ -3078,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)
@@ -3138,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)
@@ -3153,18 +3380,40 @@ 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())
+ {
+ m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_GUTTER);
+ 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
{
@@ -3184,9 +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(rLRSpace.GetLeft() * 635)));
+ "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(rLRSpace.GetRight() * 635)));
+ "dxWrapDistRight"_ostr,
+ OString::number(
+ o3tl::convert(rLRSpace.GetRight(), o3tl::Length::twip, o3tl::Length::emu))));
}
}
@@ -3209,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
{
@@ -3276,9 +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(rULSpace.GetUpper() * 635)));
+ "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(rULSpace.GetLower() * 635)));
+ "dyWrapDistBottom"_ostr,
+ OString::number(
+ o3tl::convert(rULSpace.GetLower(), o3tl::Length::twip, o3tl::Length::emu))));
}
}
@@ -3321,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);
}
}
}
@@ -3340,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;
}
@@ -3356,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());
}
}
@@ -3390,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;
}
@@ -3405,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());
}
}
@@ -3458,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())
{
@@ -3478,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)));
}
}
@@ -3520,39 +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(rBox.GetDistance(SvxBoxItemLine::LEFT) * 635)));
+ "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(rBox.GetDistance(SvxBoxItemLine::TOP) * 635)));
+ "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(rBox.GetDistance(SvxBoxItemLine::RIGHT) * 635)));
+ "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(rBox.GetDistance(SvxBoxItemLine::BOTTOM) * 635)));
+ "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 = fConverted * 635; // Twips -> EMUs
- 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;
}
@@ -3567,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());
}
}
}
@@ -3650,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;
}
@@ -3660,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;
}
@@ -3685,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);
}
}
}
@@ -3825,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));
}
@@ -3868,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)
@@ -3891,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)
@@ -3911,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{"
@@ -3955,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("}"); //"}"
@@ -3972,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));
@@ -4004,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();
}
@@ -4026,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));
@@ -4064,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.makeStringAndClear());
+ m_aRunText->append(aBuf);
+ }
+
// Replacement graphic.
m_aRunText->append("{" LO_STRING_SVTOOLS_RTF_MMATHPICT " ");
FlyFrameOLEReplacement(pFlyFrameFormat, rOLENode, rSize);
@@ -4169,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());
@@ -4189,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;
@@ -4217,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())
@@ -4241,21 +4544,19 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat
*pPolyPoly, pNd, /*bCorrectCrop=*/true);
OStringBuffer aVerticies;
for (sal_uInt16 i = 0; i < aPoly.GetSize(); ++i)
- aVerticies.append(";(")
- .append(aPoly[i].X())
- .append(",")
- .append(aPoly[i].Y())
- .append(")");
+ 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)
{
@@ -4272,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 " ");
}
@@ -4301,51 +4602,51 @@ 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);
-
- 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.
+ if (pFrame && !pFrame->IsInline())
+ m_rExport.Strm().WriteOString("}}}}"); // 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)
+{
+ if (!rRtlGutter.GetValue())
+ {
+ return;
+ }
+
+ 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 a7f95813c2c0..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>
@@ -48,7 +49,8 @@ public:
void RTLAndCJKState(bool bIsRTL, sal_uInt16 nScript) override;
/// Start of the paragraph.
- void StartParagraph(ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo) override;
+ sal_Int32 StartParagraph(ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo,
+ bool bGenerateParaId) override;
/// End of the paragraph.
void EndParagraph(ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner) override;
@@ -73,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;
@@ -82,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();
@@ -103,7 +107,8 @@ public:
/// Output URL end.
bool EndURL(bool isAtEndOfParagraph) override;
- void FieldVanish(const OUString& rText, ww::eField eType) override;
+ void FieldVanish(const OUString& rText, ww::eField eType,
+ OUString const* pBookmarkName) override;
/// Output redlining.
///
@@ -117,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.
@@ -145,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;
@@ -165,8 +182,8 @@ public:
/// Write a section break
/// msword::ColumnBreak or msword::PageBreak
- void SectionBreak(sal_uInt8 nC, bool bBreakAfter,
- const WW8_SepInfo* pSectionInfo = nullptr) override;
+ void SectionBreak(sal_uInt8 nC, bool bBreakAfter, const WW8_SepInfo* pSectionInfo = nullptr,
+ bool bExtraPageBreak = false) override;
/// Start of the section properties.
void StartSection() override;
@@ -212,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);
@@ -393,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;
@@ -458,6 +482,10 @@ protected:
bool DropdownField(const SwField* pField) override;
bool PlaceholderField(const SwField* pField) override;
+ 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;
@@ -623,7 +651,7 @@ private:
std::optional<css::drawing::FillStyle> m_oFillStyle;
/// If we're in the process of exporting a hyperlink, then its URL.
- OUString m_sURL;
+ std::stack<OUString> m_aURLs;
/// If original file had \sbauto.
bool m_bParaBeforeAutoSpacing;
@@ -634,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);
@@ -644,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 7f4ceb97dd5f..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,28 +272,29 @@ 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,
- const SwFrameFormat& rLeftFormat,
- const SwFrameFormat& rFirstPageFormat, sal_uInt8 /*nBreakCode*/)
+ const SwFrameFormat& rLeftHeaderFormat,
+ const SwFrameFormat& rLeftFooterFormat,
+ const SwFrameFormat& rFirstPageFormat, sal_uInt8 /*nBreakCode*/,
+ bool /*bEvenAndOddHeaders*/)
{
// headers
if (nHeadFootFlags & nsHdFtFlags::WW8_HEADER_EVEN)
- WriteHeaderFooter(rLeftFormat, true, OOO_STRING_SVTOOLS_RTF_HEADERL);
+ WriteHeaderFooter(rLeftHeaderFormat, true, OOO_STRING_SVTOOLS_RTF_HEADERL);
if (nHeadFootFlags & nsHdFtFlags::WW8_HEADER_ODD)
WriteHeaderFooter(rFormat, true, OOO_STRING_SVTOOLS_RTF_HEADER);
@@ -301,7 +304,7 @@ void RtfExport::WriteHeadersFooters(sal_uInt8 nHeadFootFlags, const SwFrameForma
// footers
if (nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_EVEN)
- WriteHeaderFooter(rLeftFormat, false, OOO_STRING_SVTOOLS_RTF_FOOTERL);
+ WriteHeaderFooter(rLeftFooterFormat, false, OOO_STRING_SVTOOLS_RTF_FOOTERL);
if (nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_ODD)
WriteHeaderFooter(rFormat, false, OOO_STRING_SVTOOLS_RTF_FOOTER);
@@ -316,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*/)
@@ -352,31 +408,26 @@ void RtfExport::DoFormText(const SwInputField* pField)
m_pAttrOutput->RunText().append(OOO_STRING_SVTOOLS_RTF_FFTYPETXT "0");
if (!sName.isEmpty())
- m_pAttrOutput->RunText()
- .append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFNAME " ")
- .append(msfilter::rtfutil::OutString(sName, m_eDefaultEncoding))
- .append("}");
+ m_pAttrOutput->RunText().append(
+ "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFNAME " "
+ + msfilter::rtfutil::OutString(sName, m_eDefaultEncoding) + "}");
if (!rHelp.isEmpty())
- m_pAttrOutput->RunText()
- .append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ")
- .append(msfilter::rtfutil::OutString(rHelp, m_eDefaultEncoding))
- .append("}");
- m_pAttrOutput->RunText()
- .append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFDEFTEXT " ")
- .append(msfilter::rtfutil::OutString(sResult, m_eDefaultEncoding))
- .append("}");
+ m_pAttrOutput->RunText().append(
+ "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " "
+ + msfilter::rtfutil::OutString(rHelp, m_eDefaultEncoding) + "}");
+ m_pAttrOutput->RunText().append(
+ "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFDEFTEXT " "
+ + msfilter::rtfutil::OutString(sResult, m_eDefaultEncoding) + "}");
if (!rStatus.isEmpty())
- m_pAttrOutput->RunText()
- .append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ")
- .append(msfilter::rtfutil::OutString(rStatus, m_eDefaultEncoding))
- .append("}");
+ m_pAttrOutput->RunText().append(
+ "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " "
+ + msfilter::rtfutil::OutString(rStatus, m_eDefaultEncoding) + "}");
m_pAttrOutput->RunText().append("}}}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
- m_pAttrOutput->RunText()
- .append(msfilter::rtfutil::OutString(sResult, m_eDefaultEncoding))
- .append("}}");
+ m_pAttrOutput->RunText().append(msfilter::rtfutil::OutString(sResult, m_eDefaultEncoding)
+ + "}}");
}
-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
@@ -387,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('}');
}
@@ -409,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('}');
}
@@ -420,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();
@@ -467,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;
@@ -522,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());
@@ -572,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.
@@ -629,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())
{
- const SwPageDesc& rPageDesc = m_rDoc.GetPageDesc(n);
+ return;
+ }
- 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()));
+ // 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)
+ {
+ if (!rMasterName.startsWith(aPrefix))
+ {
+ // Not a user field.
+ continue;
+ }
- OutPageDescription(rPageDesc, false);
+ uno::Reference<beans::XPropertySet> xField;
+ xTextFieldMasters->getByName(rMasterName) >>= xField;
+ if (!xField.is())
+ {
+ continue;
+ }
- // 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;
+ OUString aKey = rMasterName.copy(aPrefix.getLength());
+ OUString aValue;
+ xField->getPropertyValue("Content") >>= aValue;
+
+ 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('}');
+
+ Strm().WriteChar('{');
+ Strm().WriteOString(msfilter::rtfutil::OutString(aValue, 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('}');
+ }
}
ErrCode RtfExport::ExportDocument_Impl()
@@ -680,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();
@@ -703,34 +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);
- // Init sections
- m_pSections = new MSWordSections(*this);
+ Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_MARGMIRROR);
- // Page description
- WritePageDescTable();
+ // Gutter at top?
+ IDocumentSettingAccess& rIDSA = m_rDoc.getIDocumentSettingAccess();
+ if (rIDSA.get(DocumentSettingId::GUTTER_AT_TOP))
+ {
+ Strm().WriteOString(LO_STRING_SVTOOLS_RTF_GUTTERPRL);
+ }
+
+ // Init sections
+ 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
@@ -740,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())
@@ -776,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('}');
}
}
}
@@ -787,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)
{
@@ -853,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)
{
@@ -868,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())
{
@@ -893,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())
{
@@ -926,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();
@@ -946,7 +1017,7 @@ ErrCode RtfExport::ExportDocument_Impl()
void RtfExport::PrepareNewPageDesc(const SfxItemSet* pSet, const SwNode& rNd,
const SwFormatPageDesc* pNewPgDescFormat,
- const SwPageDesc* pNewPgDesc)
+ const SwPageDesc* pNewPgDesc, bool bExtraPageBreak)
{
const SwSectionFormat* pFormat = GetSectionFormat(rNd);
const sal_uLong nLnNm = GetSectionLineNo(pSet, rNd);
@@ -961,7 +1032,8 @@ void RtfExport::PrepareNewPageDesc(const SfxItemSet* pSet, const SwNode& rNd,
// Don't insert a page break, when we're changing page style just because the next page has to be a different one.
if (!m_pAttrOutput->GetPrevPageDesc()
|| m_pAttrOutput->GetPrevPageDesc()->GetFollow() != pNewPgDesc)
- AttrOutput().SectionBreak(msword::PageBreak, false, m_pSections->CurrentSectionInfo());
+ AttrOutput().SectionBreak(msword::PageBreak, false, m_pSections->CurrentSectionInfo(),
+ bExtraPageBreak);
}
bool RtfExport::DisallowInheritingOutlineNumbering(const SwFormat& rFormat)
@@ -976,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;
}
@@ -1010,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,
@@ -1026,7 +1098,6 @@ RtfExport::RtfExport(RtfExportFilter* pFilter, SwDoc& rDocument,
: MSWordExportBase(rDocument, pCurrentPam, &rOriginalPam)
, m_pFilter(pFilter)
, m_pWriter(pWriter)
- , m_pSections(nullptr)
, m_bOutOutlineOnly(bOutOutlineOnly)
, m_eDefaultEncoding(
rtl_getTextEncodingFromWindowsCharset(sw::ms::rtl_TextEncodingToWinCharset(DEF_ENCODING)))
@@ -1040,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);
@@ -1072,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
@@ -1187,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)
@@ -1204,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)
@@ -1213,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)
@@ -1228,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)
@@ -1247,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)
@@ -1264,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)
@@ -1276,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)
@@ -1288,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());
@@ -1299,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(';');
}
@@ -1323,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)
@@ -1340,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;
@@ -1373,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)
@@ -1410,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");
@@ -1441,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()
@@ -1464,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 f95e75c5dbfb..1a24aaf3e151 100644
--- a/sw/source/filter/ww8/rtfexport.hxx
+++ b/sw/source/filter/ww8/rtfexport.hxx
@@ -43,7 +43,7 @@ class RtfExport : public MSWordExportBase
std::unique_ptr<RtfAttributeOutput> m_pAttrOutput;
/// Sections/headers/footers
- MSWordSections* m_pSections;
+ std::unique_ptr<MSWordSections> m_pSections;
std::unique_ptr<RtfSdrExport> m_pSdrExport;
bool m_bOutOutlineOnly;
@@ -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;
@@ -94,8 +95,10 @@ public:
/// Output the actual headers and footers.
void WriteHeadersFooters(sal_uInt8 nHeadFootFlags, const SwFrameFormat& rFormat,
- const SwFrameFormat& rLeftFormat,
- const SwFrameFormat& rFirstPageFormat, sal_uInt8 nBreakCode) override;
+ const SwFrameFormat& rLeftHeaderFormat,
+ const SwFrameFormat& rLeftFooterFormat,
+ const SwFrameFormat& rFirstPageFormat, sal_uInt8 nBreakCode,
+ bool bEvenAndOddHeaders) override;
/// Write the field
void OutputField(const SwField* pField, ww::eField eFieldType, const OUString& rFieldCmd,
@@ -111,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; }
@@ -123,8 +126,8 @@ protected:
/// Get ready for a new section.
void PrepareNewPageDesc(const SfxItemSet* pSet, const SwNode& rNd,
- const SwFormatPageDesc* pNewPgDescFormat,
- const SwPageDesc* pNewPgDesc) override;
+ const SwFormatPageDesc* pNewPgDescFormat, const SwPageDesc* pNewPgDesc,
+ bool bExtraPageBreak = false) override;
/// Return value indicates if an inherited outline numbering is suppressed.
bool DisallowInheritingOutlineNumbering(const SwFormat& rFormat) override;
@@ -164,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; }
@@ -175,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();
@@ -183,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);
@@ -210,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 3ad34049f247..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)
{
@@ -178,8 +174,7 @@ void RtfSdrExport::Commit(EscherPropertyContainer& rProps, const tools::Rectangl
break;
}
if (nWrapType)
- m_aShapeStyle.append(OOO_STRING_SVTOOLS_RTF_SHPWR)
- .append(static_cast<sal_Int32>(nWrapType));
+ m_aShapeStyle.append(OOO_STRING_SVTOOLS_RTF_SHPWR + OString::number(nWrapType));
}
break;
case ESCHER_Prop_fillColor:
@@ -293,7 +288,7 @@ void RtfSdrExport::Commit(EscherPropertyContainer& rProps, const tools::Rectangl
// number of segments
sal_uInt16 nSegments = impl_GetUInt16(pSegmentIt);
sal_Int32 nVertices = 0;
- aSegmentInfo.append("2;").append(static_cast<sal_Int32>(nSegments));
+ aSegmentInfo.append("2;" + OString::number(nSegments));
pSegmentIt += 4;
for (; nSegments; --nSegments)
@@ -306,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:
@@ -316,11 +311,8 @@ void RtfSdrExport::Commit(EscherPropertyContainer& rProps, const tools::Rectangl
nPointSize);
sal_Int32 nY = impl_GetPointComponent(pVerticesIt, nVerticesPos,
nPointSize);
- aVerticies.append(";(")
- .append(nX)
- .append(",")
- .append(nY)
- .append(")");
+ aVerticies.append(";(" + OString::number(nX) + ","
+ + OString::number(nY) + ")");
nVertices++;
}
break;
@@ -330,8 +322,8 @@ void RtfSdrExport::Commit(EscherPropertyContainer& rProps, const tools::Rectangl
= impl_GetPointComponent(pVerticesIt, nVerticesPos, nPointSize);
sal_Int32 nY
= impl_GetPointComponent(pVerticesIt, nVerticesPos, nPointSize);
- aVerticies.append(";(").append(nX).append(",").append(nY).append(
- ")");
+ aVerticies.append(";(" + OString::number(nX) + ","
+ + OString::number(nY) + ")");
nVertices++;
break;
}
@@ -344,11 +336,8 @@ void RtfSdrExport::Commit(EscherPropertyContainer& rProps, const tools::Rectangl
pVerticesIt, nVerticesPos, nPointSize);
sal_Int32 nY = impl_GetPointComponent(
pVerticesIt, nVerticesPos, nPointSize);
- aVerticies.append(";(")
- .append(nX)
- .append(",")
- .append(nY)
- .append(")");
+ aVerticies.append(";(" + OString::number(nX) + ","
+ + OString::number(nY) + ")");
nVertices++;
}
}
@@ -376,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>(
@@ -434,18 +422,14 @@ void RtfSdrExport::Commit(EscherPropertyContainer& rProps, const tools::Rectangl
break;
case ESCHER_Prop_fillBlip:
{
- OStringBuffer aBuf;
- aBuf.append('{')
- .append(OOO_STRING_SVTOOLS_RTF_PICT)
- .append(OOO_STRING_SVTOOLS_RTF_PNGBLIP)
- .append(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:
@@ -468,10 +452,10 @@ void RtfSdrExport::AddLineDimensions(const tools::Rectangle& rRectangle)
m_aShapeProps.insert(std::pair<OString, OString>("fFlipH", "1"));
// the actual dimensions
- m_aShapeStyle.append(OOO_STRING_SVTOOLS_RTF_SHPLEFT).append(rRectangle.Left());
- m_aShapeStyle.append(OOO_STRING_SVTOOLS_RTF_SHPTOP).append(rRectangle.Top());
- m_aShapeStyle.append(OOO_STRING_SVTOOLS_RTF_SHPRIGHT).append(rRectangle.Right());
- m_aShapeStyle.append(OOO_STRING_SVTOOLS_RTF_SHPBOTTOM).append(rRectangle.Bottom());
+ m_aShapeStyle.append(OOO_STRING_SVTOOLS_RTF_SHPLEFT + OString::number(rRectangle.Left()));
+ m_aShapeStyle.append(OOO_STRING_SVTOOLS_RTF_SHPTOP + OString::number(rRectangle.Top()));
+ m_aShapeStyle.append(OOO_STRING_SVTOOLS_RTF_SHPRIGHT + OString::number(rRectangle.Right()));
+ m_aShapeStyle.append(OOO_STRING_SVTOOLS_RTF_SHPBOTTOM + OString::number(rRectangle.Bottom()));
}
void RtfSdrExport::AddRectangleDimensions(OStringBuffer& rBuffer,
@@ -480,25 +464,21 @@ void RtfSdrExport::AddRectangleDimensions(OStringBuffer& rBuffer,
// We get the position relative to (the current?) character
m_aShapeProps.insert(std::pair<OString, OString>("posrelh", "3"));
- rBuffer.append(OOO_STRING_SVTOOLS_RTF_SHPLEFT).append(rRectangle.Left());
- rBuffer.append(OOO_STRING_SVTOOLS_RTF_SHPTOP).append(rRectangle.Top());
- rBuffer.append(OOO_STRING_SVTOOLS_RTF_SHPRIGHT).append(rRectangle.Right());
- rBuffer.append(OOO_STRING_SVTOOLS_RTF_SHPBOTTOM).append(rRectangle.Bottom());
+ rBuffer.append(OOO_STRING_SVTOOLS_RTF_SHPLEFT + OString::number(rRectangle.Left()));
+ rBuffer.append(OOO_STRING_SVTOOLS_RTF_SHPTOP + OString::number(rRectangle.Top()));
+ rBuffer.append(OOO_STRING_SVTOOLS_RTF_SHPRIGHT + OString::number(rRectangle.Right()));
+ rBuffer.append(OOO_STRING_SVTOOLS_RTF_SHPBOTTOM + OString::number(rRectangle.Bottom()));
}
-static void lcl_AppendSP(OStringBuffer& rRunText, const char cName[], const OString& rValue)
+static void lcl_AppendSP(OStringBuffer& rRunText, const char* cName, std::string_view rValue)
{
- rRunText.append('{')
- .append(OOO_STRING_SVTOOLS_RTF_SP)
- .append('{')
- .append(OOO_STRING_SVTOOLS_RTF_SN " ")
- .append(cName)
- .append('}')
- .append('{')
- .append(OOO_STRING_SVTOOLS_RTF_SV " ")
- .append(rValue)
- .append('}')
- .append('}');
+ rRunText.append(OString::Concat("{" OOO_STRING_SVTOOLS_RTF_SP "{" OOO_STRING_SVTOOLS_RTF_SN " ")
+ + cName
+ + "}"
+ "{" OOO_STRING_SVTOOLS_RTF_SV " "
+ + rValue
+ + "}"
+ "}");
}
void RtfSdrExport::impl_writeGraphic()
@@ -529,18 +509,17 @@ 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());
// Add it to the properties.
RtfStringBuffer aBuf;
- aBuf->append('{').append(OOO_STRING_SVTOOLS_RTF_PICT).append(OOO_STRING_SVTOOLS_RTF_PNGBLIP);
- aBuf->append(OOO_STRING_SVTOOLS_RTF_PICW).append(sal_Int32(aMapped.Width()));
- aBuf->append(OOO_STRING_SVTOOLS_RTF_PICH)
- .append(sal_Int32(aMapped.Height()))
- .append(SAL_NEWLINE_STRING);
+ aBuf->append("{" OOO_STRING_SVTOOLS_RTF_PICT OOO_STRING_SVTOOLS_RTF_PNGBLIP);
+ aBuf->append(OOO_STRING_SVTOOLS_RTF_PICW + OString::number(aMapped.Width()));
+ aBuf->append(OOO_STRING_SVTOOLS_RTF_PICH + OString::number(aMapped.Height())
+ + SAL_NEWLINE_STRING);
aBuf->append(msfilter::rtfutil::WriteHex(pGraphicAry, nSize));
aBuf->append('}');
m_aShapeProps.insert(std::pair<OString, OString>("pib", aBuf.makeStringAndClear()));
@@ -555,13 +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('{')
- .append(OOO_STRING_SVTOOLS_RTF_IGNORE)
- .append(OOO_STRING_SVTOOLS_RTF_SHPINST);
+ 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.
@@ -573,7 +551,7 @@ sal_Int32 RtfSdrExport::StartShape()
// Order inside the group shape is not relevant for the flat shape list
// we write.
m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_SHPZ);
- m_rAttrOutput.RunText().append(OString::number(m_pSdrObject->GetOrdNum()));
+ m_rAttrOutput.RunText().append(static_cast<sal_Int64>(m_pSdrObject->GetOrdNum()));
}
for (auto it = m_aShapeProps.rbegin(); it != m_aShapeProps.rend(); ++it)
@@ -609,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#
@@ -623,7 +601,8 @@ sal_Int32 RtfSdrExport::StartShape()
if (pTextObj->IsTextEditActive())
{
pOwnedParaObj = pTextObj->CreateEditOutlinerParaObject();
- pParaObj = pOwnedParaObj.get();
+ if (pOwnedParaObj)
+ pParaObj = &*pOwnedParaObj;
}
else
{
@@ -645,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",
@@ -654,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(),
@@ -669,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()));
@@ -691,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)
@@ -742,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 055ace53a429..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);
}
@@ -63,7 +66,7 @@ OString RtfStringBuffer::makeStringAndClear()
OStringBuffer& RtfStringBuffer::getLastBuffer()
{
if (m_aValues.empty() || m_aValues.back().isGraphic())
- m_aValues.emplace_back(RtfStringBufferValue());
+ m_aValues.emplace_back();
return m_aValues.back().getBuffer();
}
@@ -73,13 +76,12 @@ void RtfStringBuffer::clear() { m_aValues.clear(); }
void RtfStringBuffer::append(const SwFlyFrameFormat* pFlyFrameFormat, const SwGrfNode* pGrfNode)
{
- m_aValues.emplace_back(RtfStringBufferValue(pFlyFrameFormat, pGrfNode));
+ m_aValues.emplace_back(pFlyFrameFormat, pGrfNode);
}
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 5da6157f732b..33d0ad3dec5f 100644
--- a/sw/source/filter/ww8/styles.cxx
+++ b/sw/source/filter/ww8/styles.cxx
@@ -23,104 +23,106 @@
namespace
{
- const char **GetStiNames() throw()
+ // 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;
}
@@ -128,7 +130,7 @@ namespace
namespace ww
{
- const char* GetEnglishNameFromSti(sti eSti) throw()
+ const char* GetEnglishNameFromSti(sti eSti) noexcept
{
if (eSti >= stiMax)
return nullptr;
@@ -136,7 +138,7 @@ namespace ww
return GetStiNames()[eSti];
}
- bool StandardStiIsCharStyle(sti eSti) throw()
+ bool StandardStiIsCharStyle(sti eSti) noexcept
{
switch (eSti)
{
@@ -152,7 +154,7 @@ namespace ww
}
}
- sti GetCanonicalStiFromStc(sal_uInt8 stc) throw()
+ sti GetCanonicalStiFromStc(sal_uInt8 stc) noexcept
{
if (stc == 0)
return stiNormal;
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index 641b1168798c..5db0319e2906 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -33,6 +33,7 @@
#include <svx/svdoole2.hxx>
#include <tools/UnitConversion.hxx>
#include <editeng/formatbreakitem.hxx>
+#include <osl/diagnose.h>
#include <ndtxt.hxx>
#include <ndnotxt.hxx>
#include <fmtcntnt.hxx>
@@ -49,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>
@@ -108,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());
}
};
}
@@ -152,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)
@@ -177,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())
{
@@ -269,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;
@@ -278,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);
@@ -395,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;
}
@@ -411,6 +401,7 @@ namespace sw
while ((pItem = aIter.NextItem()));
}
}
+// DeduplicateItems(rItems);
}
const SfxPoolItem *SearchPoolItems(const ww8::PoolItems &rItems,
@@ -516,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;
}
@@ -593,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;
}
@@ -627,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++)
@@ -636,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];
}
}
@@ -712,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));
}
};
@@ -726,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;
@@ -757,45 +748,49 @@ namespace sw
std::for_each(maStack.begin(), maStack.end(), SetEndIfOpen(rPos));
}
- void RedlineStack::MoveAttrsFieldmarkInserted(const SwPosition& rPos)
+ void MoveAttrFieldmarkInserted(SwFltPosition& rMkPos, SwFltPosition& rPtPos, const SwPosition& rPos)
{
- size_t nCnt = maStack.size();
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;
- for (size_t i=0; i < nCnt; ++i)
+ bool const isPoint(rMkPos == rPtPos);
+ if ((rMkPos.m_nNode.GetIndex()+1 == nPosNd) &&
+ (nPosCt <= rMkPos.m_nContent))
{
- SwFltStackEntry& rEntry = *maStack[i];
- bool const isPoint(rEntry.m_aMkPos == rEntry.m_aPtPos);
- if ((rEntry.m_aMkPos.m_nNode.GetIndex()+1 == nPosNd) &&
- (nPosCt <= rEntry.m_aMkPos.m_nContent))
+ rMkPos.m_nContent += nInserted;
+ 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...
{
- rEntry.m_aMkPos.m_nContent += nInserted;
- SAL_WARN_IF(rEntry.m_aMkPos.m_nContent > rPos.nNode.GetNodes()[nPosNd]->GetContentNode()->Len(),
- "sw.ww8", "redline ends after end of line");
- if (isPoint) // sigh ... important special case...
- {
- rEntry.m_aPtPos.m_nContent += nInserted;
- continue;
- }
- }
- // for the end position, leave it alone if it's *on* the dummy
- // char position, that should remain *before*
- if ((rEntry.m_aPtPos.m_nNode.GetIndex()+1 == nPosNd) &&
- (nPosCt < rEntry.m_aPtPos.m_nContent))
- {
- rEntry.m_aPtPos.m_nContent += nInserted;
- SAL_WARN_IF(rEntry.m_aPtPos.m_nContent > rPos.nNode.GetNodes()[nPosNd]->GetContentNode()->Len(),
- "sw.ww8", "redline ends after end of line");
+ rPtPos.m_nContent += nInserted;
+ return;
}
}
+ // for the end position, leave it alone if it's *on* the dummy
+ // char position, that should remain *before*
+ if ((rPtPos.m_nNode.GetIndex()+1 == nPosNd) &&
+ (nPosCt < rPtPos.m_nContent))
+ {
+ rPtPos.m_nContent += nInserted;
+ SAL_WARN_IF(rPtPos.m_nContent > rPos.GetNodes()[nPosNd]->GetContentNode()->Len(),
+ "sw.ww8", "range ends after end of line");
+ }
+ }
+
+ void RedlineStack::MoveAttrsFieldmarkInserted(const SwPosition& rPos)
+ {
+ for (size_t i = 0, nCnt = maStack.size(); i < nCnt; ++i)
+ {
+ SwFltStackEntry& rEntry = *maStack[i];
+ MoveAttrFieldmarkInserted(rEntry.m_aMkPos, rEntry.m_aPtPos, rPos);
+ }
}
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())
)
@@ -803,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 );
@@ -824,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;
@@ -893,7 +893,7 @@ namespace sw
if (pFrameFormat != nullptr)
{
- SwNodeIndex *pIndex = aTable.second;
+ SwPosition *pIndex = aTable.second;
pTable->DelFrames();
pTable->MakeOwnFrames(pIndex);
}
@@ -905,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 fa1c5ea5c48f..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,43 +86,39 @@
#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>
+#include <tools/UnitConversion.hxx>
#include <algorithm>
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);
@@ -273,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;
@@ -316,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;
}
};
@@ -430,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 );
@@ -466,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)
@@ -474,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 );
@@ -497,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);
@@ -614,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)
@@ -677,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;
@@ -725,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;
@@ -753,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)
{
@@ -777,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;
@@ -840,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,
@@ -908,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 );
@@ -926,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
@@ -956,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 )
@@ -973,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())
{
@@ -1013,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 )
@@ -1079,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 );
}
}
}
@@ -1120,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)
{
@@ -1134,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)
{
@@ -1161,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());
@@ -1188,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 ||
@@ -1210,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;
}
}
@@ -1231,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);
@@ -1250,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 )
@@ -1271,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);
@@ -1284,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
@@ -1296,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 ) ) )
@@ -1304,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()));
@@ -1313,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#
@@ -1323,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;
}
}
@@ -1352,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;
@@ -1360,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;
}
@@ -1393,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 )
@@ -1404,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 );
}
@@ -1432,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
@@ -1443,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()
@@ -1468,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;
}
@@ -1485,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();
}
@@ -1513,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();
}
@@ -1587,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);
@@ -1662,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)
{
/*
@@ -1735,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() );
@@ -1774,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 );
}
@@ -1857,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 );
}
@@ -1886,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 )
@@ -1955,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
@@ -1974,56 +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_uInt16 nCstScale = 635; // unit scale between AOO and MS Word
- 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 = pSI->GetWidth() * nCstScale;
- sal_Int32 nOffY = pSI->GetWidth() * nCstScale;
-
- 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 );
}
}
}
@@ -2038,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)
{
@@ -2080,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
{
@@ -2094,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())
@@ -2136,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.
@@ -2144,15 +2123,12 @@ void SwBasicEscherEx::Init()
}
// MS-DFF-Properties mostly are in EMU (English Metric Units)
- // 1mm=36000emu, 1twip=635emu
- Fraction aFact(360, 1);
+ Fraction aFact = conversionFract(o3tl::Length::mm100, o3tl::Length::emu);
aFact /= GetMapFactor(MapUnit::Map100thMM, eMap).X();
- // create little values
- aFact = Fraction(aFact.GetNumerator(), aFact.GetDenominator());
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)
@@ -2178,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()
@@ -2186,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;
@@ -2213,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 );
@@ -2233,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;
@@ -2262,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)
{
@@ -2297,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();
@@ -2337,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;
}
@@ -2418,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;
@@ -2598,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();
@@ -2730,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 );
@@ -2777,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;
@@ -2789,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;
@@ -2815,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);
@@ -2858,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 );
@@ -2926,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");
@@ -2952,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)
{
@@ -2971,7 +2950,7 @@ void SwEscherEx::MakeZOrderArrAndFollowIds(
sal_uLong nShapeId = bNeedsShapeId ? GenerateShapeId() : 0;
- aFollowShpIds.push_back(nShapeId);
+ m_aFollowShpIds.push_back(nShapeId);
}
}
@@ -2982,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
@@ -2998,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 )
{
@@ -3041,16 +3020,16 @@ void SwMSConvertControls::ExportControl(WW8Export &rWW8Wrt, const SdrUnoObj& rFo
tools::Rectangle aRect = rFormObj.GetLogicRect();
aRect.SetPos(Point(0,0));
awt::Size aSize;
- aSize.Width = TWIPS_TO_MM(aRect.Right());
- aSize.Height = TWIPS_TO_MM(aRect.Bottom());
+ aSize.Width = convertTwipToMm100(aRect.Right());
+ 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 77cdab41e879..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)
+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)
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)
//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)
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));
@@ -467,6 +475,7 @@ void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bWriteCombChars)
break;
}
}
+// DeduplicateItems(aRangeItems);
/*
For #i24291# we need to explicitly remove any properties from the
@@ -479,9 +488,9 @@ void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bWriteCombChars)
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
@@ -505,7 +514,7 @@ void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bWriteCombChars)
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 )
@@ -516,7 +525,7 @@ void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bWriteCombChars)
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
@@ -529,7 +538,7 @@ void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bWriteCombChars)
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" );
@@ -558,49 +567,142 @@ void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bWriteCombChars)
// 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);
}
}
@@ -624,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;
@@ -632,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
@@ -640,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;
@@ -710,6 +812,12 @@ FlyProcessingState SwWW8AttrIter::OutFlys(sal_Int32 nSwPos)
++linkedTextboxesIter;
}
+ if (maFlyIter == maFlyFrames.end())
+ {
+ // tdf#143039 postponed prevents fly duplication at end of paragraph
+ return m_rExport.AttrOutput().IsFlyProcessingPostponed() ? FLY_POSTPONED : FLY_NONE;
+ }
+
/*
#i2916#
May have an anchored graphic to be placed, loop through sorted array
@@ -718,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 )
@@ -760,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)
{
@@ -784,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)
{
@@ -813,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;
}
@@ -828,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.
@@ -838,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();
@@ -878,31 +986,36 @@ 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 += OUStringLiteral(u"\\a") + OUStringChar(aWW8Ruby.GetDirective());
+ aStr += OUString::Concat(u"\\a") + OUStringChar(aWW8Ruby.GetDirective());
}
aStr += "(\\s\\up " + OUString::number((aWW8Ruby.GetBaseHeight() + 10) / 20 - 1) + "(";
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 += ";";
@@ -917,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;
@@ -963,7 +1067,7 @@ bool AttributeOutputBase::AnalyzeURL( const OUString& rUrl, const OUString& /*rT
if ( rUrl.getLength() > 1 && rUrl[0] == '#' )
{
- sMark = BookmarkToWriter( rUrl.copy(1) );
+ sMark = BookmarkToWriter( rUrl.subView(1) );
const sal_Int32 nPos = sMark.lastIndexOf( cMarkSeparator );
@@ -979,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;
}
}
@@ -988,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 );
}
}
@@ -1017,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 + "\"";
@@ -1050,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 ?
@@ -1095,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 )
@@ -1153,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 )
{
@@ -1175,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;
}
@@ -1198,18 +1305,7 @@ 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(const OUString &rBookmark)
+OUString BookmarkToWriter(std::u16string_view rBookmark)
{
return INetURLObject::decode(rBookmark,
INetURLObject::DecodeMechanism::Unambiguous, RTL_TEXTENCODING_ASCII_US);
@@ -1218,7 +1314,7 @@ OUString BookmarkToWriter(const OUString &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 ));
}
@@ -1234,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*/ )
+void WW8AttributeOutput::FieldVanish(const OUString& rText, ww::eField /*eType*/, OUString const*const /*pBookmarkName*/)
{
ww::bytes aItems;
m_rWW8Export.GetCurrentItems( aItems );
@@ -1248,7 +1344,7 @@ void WW8AttributeOutput::FieldVanish( const OUString& rText, ww::eField /*eType*
sal_uInt16 nStt_sprmCFSpec = aItems.size();
- // sprmCFSpec -- fSpec-Attribut true
+ // sprmCFSpec -- fSpec-Attribute true
SwWW8Writer::InsUInt16( aItems, 0x855 );
aItems.push_back( 1 );
@@ -1279,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;
@@ -1293,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:
@@ -1315,13 +1426,21 @@ void AttributeOutputBase::TOXMark( const SwTextNode& rNode, const SwTOXMark& rAt
}
if (!sText.isEmpty())
- FieldVanish( sText, eType );
+ {
+ OUString const* pBookmarkName(nullptr);
+ if (auto const it = GetExport().m_TOXMarkBookmarksByTOXMark.find(&rAttr);
+ it != GetExport().m_TOXMarkBookmarksByTOXMark.end())
+ {
+ pBookmarkName = &it->second;
+ }
+ FieldVanish(sText, eType, pBookmarkName);
+ }
}
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;
@@ -1336,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;
@@ -1376,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;
@@ -1395,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;
@@ -1422,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];
@@ -1433,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
@@ -1445,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
@@ -1457,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
@@ -1477,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
@@ -1492,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() );
}
}
}
@@ -1502,44 +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() );
- break;
+ 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() )
{
@@ -1547,9 +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() );
- break;
+ m_pCurRedline = pRedl;
+ return &( m_pCurRedline->GetRedlineData() );
default:
break;
}
@@ -1562,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;
}
}
@@ -1630,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;
@@ -1657,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;
}
@@ -1678,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;
@@ -1732,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);
@@ -1789,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;
}
@@ -1815,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;
@@ -1847,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 ) )
{
@@ -1866,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 )
@@ -1903,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++ )
@@ -1928,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 )
{
@@ -1951,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++ )
@@ -1959,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)
{
@@ -2000,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;
}
@@ -2016,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;
@@ -2027,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 )
@@ -2048,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;
@@ -2059,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 )
@@ -2080,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 );
}
@@ -2114,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 );
}
@@ -2168,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);
}
@@ -2185,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>" );
@@ -2266,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));
}
}
@@ -2295,7 +2425,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
++aBreakIt;
}
- AttrOutput().StartParagraph( pTextNodeInfo );
+ AttrOutput().StartParagraph(pTextNodeInfo, false);
const SwSection* pTOXSect = nullptr;
if( m_bInWriteTOX )
@@ -2309,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;
}
@@ -2318,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 ) );
}
@@ -2329,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;
@@ -2336,15 +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 );
- FlyProcessingState nStateOfFlyFrame = FLY_PROCESSED;
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.
@@ -2367,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 );
}
}
@@ -2387,12 +2528,12 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
bPostponeWritingText = true ;
}
- nStateOfFlyFrame = aAttrIter.OutFlys( nCurrentPos );
+ FlyProcessingState nStateOfFlyFrame = aAttrIter.OutFlys( nCurrentPos );
AttrOutput().SetStateOfFlyFrame( nStateOfFlyFrame );
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);
@@ -2405,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 )
{
@@ -2415,11 +2557,20 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
|| ch == CH_TXT_ATR_FIELDEND
|| ch == CH_TXT_ATR_FORMELEMENT)
? 1 : 0;
+ if (ofs == 1
+ && GetExportFormat() == MSWordExportBase::ExportFormat::DOCX
+ // FLY_PROCESSED: there's at least 1 fly already written
+ && nStateOfFlyFrame == FLY_PROCESSED)
+ {
+ // write flys in a separate run before field character
+ 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);
@@ -2471,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)
{
@@ -2497,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);
@@ -2562,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#
@@ -2581,15 +2741,24 @@ 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 ) )
{
- bPostponeWritingText = true ;
aSavedSnippet = aSnippet ;
}
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);
}
}
@@ -2597,12 +2766,14 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
AttrOutput().FormatDrop( rNode, aAttrIter.GetSwFormatDrop(), nStyle, pTextNodeInfo, pTextNodeInfoInner );
// Only output character attributes if this is not a postponed text run.
- if (0 != nEnd && !(bPostponeWritingText && FLY_PROCESSED == nStateOfFlyFrame))
+ if (0 != nEnd && !(bPostponeWritingText
+ && (FLY_PROCESSED == nStateOfFlyFrame || FLY_NONE == nStateOfFlyFrame)))
{
// Output the character attributes
// #i51277# do this before writing flys at end of paragraph
+ bStartedPostponedRunProperties = true;
AttrOutput().StartRunProperties();
- aAttrIter.OutAttr( nCurrentPos, false );
+ aAttrIter.OutAttr(nCurrentPos, false);
AttrOutput().EndRunProperties( pRedlineData );
}
@@ -2635,6 +2806,9 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
}
WriteCR( pTextNodeInfoInner );
+
+ if (0 != nEnd && bIsEndOfCell)
+ AttrOutput().OutputFKP(/*bforce=*/true);
}
}
}
@@ -2662,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
@@ -2704,30 +2875,34 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
AttrOutput().WritePostitFieldReference();
- if( bPostponeWritingText && FLY_PROCESSED == 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 );
@@ -2756,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 )
@@ -2785,7 +2960,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
#endif
AttrOutput().TableInfoCell( pTextNodeInfoInner );
- if (pTextNodeInfoInner->isFirstInTable())
+ if (pTextNodeInfoInner && pTextNodeInfoInner->isFirstInTable())
{
const SwTable * pTable = pTextNodeInfoInner->getTable();
@@ -2800,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))
{
@@ -2827,7 +3000,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
if( !(ND_HAS_NEXT_LAYNODE & nPrvNxtNd ))
aUL.SetLower( 0 );
}
- pTmpSet->Put( aUL );
+ oTmpSet->Put( aUL );
}
}
@@ -2844,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() )
@@ -2863,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());
}
}
@@ -2924,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();
@@ -2978,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() ));
}
}
@@ -3008,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 );
}
}
@@ -3054,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 )
@@ -3068,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 );
}
}
}
@@ -3081,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();
@@ -3094,9 +3278,6 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
m_pStyAttr = nullptr;
m_pOutFormatNode = pOldMod;
-
- if( pNewSet != rNode.GetpSwAttrSet() )
- delete pNewSet;
}
}
@@ -3109,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);
@@ -3168,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:
@@ -3297,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);
@@ -3341,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
@@ -3372,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
{
@@ -3381,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;
@@ -3390,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;
}
@@ -3403,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();
@@ -3487,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;
@@ -3500,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() ) );
@@ -3584,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
@@ -3599,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();
}
@@ -3614,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 caae58fbb163..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
{
- return m_aStyleIds[nId];
+ assert(!m_aStyles[nSlot].style_id.isEmpty());
+ return m_aStyles[nSlot].style_id;
+}
+
+OUString MSWordStyles::GetStyleWWName(SwFormat const*const pFormat) const
+{
+ 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,36 +1543,36 @@ 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,
- const SwFrameFormat& rFormat, const SwFrameFormat& rLeftFormat, const SwFrameFormat& rFirstPageFormat, sal_uInt8 nBreakCode )
+ const SwFrameFormat& rFormat, const SwFrameFormat& rLeftHeaderFormat, const SwFrameFormat& rLeftFooterFormat, const SwFrameFormat& rFirstPageFormat, sal_uInt8 nBreakCode, bool /*bEvenAndOddHeaders*/ )
{
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, rLeftFormat, 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, rLeftFormat, 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,9 +1794,11 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
titlePage = true;
}
}
-
- if( titlePage )
- AttrOutput().SectionTitlePage();
+ 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;
@@ -1813,6 +1865,9 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
}
}
+ if (titlePage)
+ AttrOutput().SectionTitlePage();
+
AttrOutput().SectionType( nBreakCode );
if( rSepInfo.pPageDesc ) {
@@ -1821,13 +1876,62 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
// Header or Footer
sal_uInt8 nHeadFootFlags = 0;
-
- const SwFrameFormat* pPdLeftFormat = bLeftRightPgChain
- ? &pPd->GetFollow()->GetFirstLeft()
- : &pPd->GetLeft();
+ // Should we output a w:evenAndOddHeaders tag or not?
+ // N.B.: despite its name this tag affects _both_ headers and footers!
+ bool bEvenAndOddHeaders = true;
+ bool bEvenAndOddFooters = true;
+
+ const SwFrameFormat* pPdLeftHeaderFormat = nullptr;
+ const SwFrameFormat* pPdLeftFooterFormat = nullptr;
+ if (bLeftRightPgChain)
+ {
+ const SwFrameFormat* pHeaderFormat = pPd->GetStashedFrameFormat(true, true, true);
+ const SwFrameFormat* pFooterFormat = pPd->GetStashedFrameFormat(false, true, true);
+ if (pHeaderFormat)
+ {
+ pPdLeftHeaderFormat = pHeaderFormat;
+ bEvenAndOddHeaders = false;
+ }
+ else
+ {
+ pPdLeftHeaderFormat = &pPd->GetFollow()->GetFirstLeft();
+ }
+ if (pFooterFormat)
+ {
+ pPdLeftFooterFormat = pFooterFormat;
+ bEvenAndOddFooters = false;
+ }
+ else
+ {
+ pPdLeftFooterFormat = &pPd->GetFollow()->GetFirstLeft();
+ }
+ }
+ else
+ {
+ const SwFrameFormat* pHeaderFormat = pPd->GetStashedFrameFormat(true, true, false);
+ const SwFrameFormat* pFooterFormat = pPd->GetStashedFrameFormat(false, true, false);
+ if (pHeaderFormat)
+ {
+ pPdLeftHeaderFormat = pHeaderFormat;
+ bEvenAndOddHeaders = false;
+ }
+ else
+ {
+ pPdLeftHeaderFormat = &pPd->GetLeft();
+ }
+ if (pFooterFormat)
+ {
+ pPdLeftFooterFormat = pFooterFormat;
+ bEvenAndOddFooters = false;
+ }
+ else
+ {
+ pPdLeftFooterFormat = &pPd->GetLeft();
+ }
+ }
// Ensure that headers are written if section is first paragraph
- if ( nBreakCode != 0 || bEnsureHeaderFooterWritten )
+ if (nBreakCode != 0 || (rSepInfo.pSectionFormat && rSepInfo.bIsFirstParagraph))
{
if ( titlePage )
{
@@ -1835,14 +1939,40 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
MSWordSections::SetHeaderFlag( nHeadFootFlags, *pPdFirstPgFormat, WW8_HEADER_FIRST );
MSWordSections::SetFooterFlag( nHeadFootFlags, *pPdFirstPgFormat, WW8_FOOTER_FIRST );
}
+ else
+ {
+ if ( pPd->GetStashedFrameFormat(true, true, true) && pPdLeftHeaderFormat && pPdLeftHeaderFormat->GetHeader().GetHeaderFormat() )
+ {
+ MSWordSections::SetHeaderFlag( nHeadFootFlags, *pPdLeftHeaderFormat, WW8_HEADER_FIRST );
+ }
+ if ( pPd->GetStashedFrameFormat(false, true, true) && pPdLeftFooterFormat && pPdLeftFooterFormat->GetFooter().GetFooterFormat() )
+ {
+ MSWordSections::SetFooterFlag( nHeadFootFlags, *pPdLeftFooterFormat, WW8_FOOTER_FIRST );
+ }
+ }
+
MSWordSections::SetHeaderFlag( nHeadFootFlags, *pPdFormat, WW8_HEADER_ODD );
MSWordSections::SetFooterFlag( nHeadFootFlags, *pPdFormat, WW8_FOOTER_ODD );
if ( !pPd->IsHeaderShared() || bLeftRightPgChain )
- MSWordSections::SetHeaderFlag( nHeadFootFlags, *pPdLeftFormat, WW8_HEADER_EVEN );
+ {
+ MSWordSections::SetHeaderFlag( nHeadFootFlags, *pPdLeftHeaderFormat, WW8_HEADER_EVEN );
+ }
+ else if ( pPd->IsHeaderShared() && pPd->GetStashedFrameFormat(true, true, false) && pPdLeftHeaderFormat && pPdLeftHeaderFormat->GetHeader().GetHeaderFormat() )
+ {
+ MSWordSections::SetHeaderFlag( nHeadFootFlags, *pPdLeftHeaderFormat, WW8_HEADER_EVEN );
+ bEvenAndOddHeaders = false;
+ }
if ( !pPd->IsFooterShared() || bLeftRightPgChain )
- MSWordSections::SetFooterFlag( nHeadFootFlags, *pPdLeftFormat, WW8_FOOTER_EVEN );
+ {
+ MSWordSections::SetFooterFlag( nHeadFootFlags, *pPdLeftFooterFormat, WW8_FOOTER_EVEN );
+ }
+ else if ( pPd->IsFooterShared() && pPd->GetStashedFrameFormat(false, true, false) && pPdLeftFooterFormat && pPdLeftFooterFormat->GetFooter().GetFooterFormat() )
+ {
+ MSWordSections::SetFooterFlag( nHeadFootFlags, *pPdLeftFooterFormat, WW8_FOOTER_EVEN );
+ bEvenAndOddFooters = false;
+ }
}
// binary filters only
@@ -1873,7 +2003,7 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
MSWordSections::SetFooterFlag(nHeadFootFlags, *pPdFormat, WW8_FOOTER_ODD);
}
- WriteHeadersFooters( nHeadFootFlags, *pPdFormat, *pPdLeftFormat, *pPdFirstPgFormat, nBreakCode );
+ WriteHeadersFooters( nHeadFootFlags, *pPdFormat, *pPdLeftHeaderFormat, *pPdLeftFooterFormat, *pPdFirstPgFormat, nBreakCode, bEvenAndOddHeaders && bEvenAndOddFooters );
SetHdFtPageRoot( pOldPageRoot );
@@ -1881,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 );
@@ -1896,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);
@@ -1910,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
{
@@ -1952,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}};
@@ -1969,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;
}
}
@@ -1995,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
@@ -2002,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();
}
@@ -2011,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 )
@@ -2048,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)
@@ -2095,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() )
{
@@ -2108,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 )
@@ -2126,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 )
@@ -2147,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
@@ -2167,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;
@@ -2181,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 );
@@ -2219,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 );
@@ -2237,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?" );
@@ -2254,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 );
@@ -2279,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 )
@@ -2303,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())
@@ -2336,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
@@ -2352,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;
@@ -2420,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?" );
@@ -2428,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 );
@@ -2446,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() )
@@ -2461,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;
@@ -2484,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 );
@@ -2496,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(),
@@ -2515,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:
@@ -2528,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
@@ -2545,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 )
{
@@ -2565,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 26ef68865bda..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
-#define sMainStream OUString("WordDocument")
-#define sCompObj "\1CompObj"
+constexpr OUStringLiteral sMainStream = u"WordDocument";
+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)
{
@@ -523,6 +526,11 @@ static void WriteDop( WW8Export& rWrt )
rDop.fProtEnabled = false;
}
+ if (rWrt.m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::GUTTER_AT_TOP))
+ {
+ rDop.iGutterPos = true;
+ }
+
if (!xDocProps.is())
{
rDop.dttmCreated = rDop.dttmRevised = rDop.dttmLastPrint = 0x45FBAC69;
@@ -551,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,
@@ -693,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)
)
)
@@ -788,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 )
{
}
@@ -800,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
@@ -848,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:
@@ -891,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;
}
}
@@ -902,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)
@@ -954,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()
@@ -978,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
@@ -1010,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 ) )
@@ -1024,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 )
@@ -1106,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
}
@@ -1127,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++;
@@ -1142,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);
@@ -1154,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" );
@@ -1174,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
}
@@ -1244,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;
@@ -1258,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;
@@ -1299,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 );
}
}
@@ -1309,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()
@@ -1335,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
@@ -1359,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 );
}
@@ -1402,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;
@@ -1429,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()));
}
}
@@ -1460,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()),
@@ -1487,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 );
}
@@ -1506,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;
@@ -1592,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) );
@@ -1644,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 ) );
@@ -1667,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 );
@@ -1789,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;
@@ -1810,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
@@ -1867,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;
@@ -1900,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;
@@ -1939,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
@@ -1963,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();
@@ -1981,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();
@@ -2004,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 );
@@ -2018,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.
@@ -2066,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;
@@ -2092,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();
@@ -2121,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();
@@ -2143,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();
@@ -2160,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();
@@ -2188,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();
@@ -2255,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();
@@ -2277,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());
@@ -2293,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 =
@@ -2315,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 */
/*
@@ -2373,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();
@@ -2383,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)
@@ -2395,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 )
@@ -2507,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).
@@ -2524,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] ) );
}
}
@@ -2585,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;
@@ -2605,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] );
}
}
@@ -2621,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();
@@ -2630,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);
@@ -2696,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++ )
{
@@ -2733,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)
@@ -2744,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;
@@ -2758,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)
@@ -2778,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 )
@@ -2800,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() )
@@ -2833,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;
@@ -2897,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)
@@ -2907,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>" );
@@ -2922,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()) );
@@ -2952,7 +3087,7 @@ bool MSWordExportBase::IsInTable() const
if (m_pCurPam != nullptr)
{
- SwNode& rNode = m_pCurPam->GetNode();
+ SwNode& rNode = m_pCurPam->GetPointNode();
if (m_pTableInfo)
{
@@ -2978,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
@@ -3023,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
@@ -3045,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
@@ -3059,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 );
@@ -3071,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();
@@ -3108,20 +3243,20 @@ 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, ...
}
-void MSWordExportBase::AddLinkTarget(const OUString& rURL)
+void MSWordExportBase::AddLinkTarget(std::u16string_view rURL)
{
- if( rURL.isEmpty() || rURL[0] != '#' )
+ if( rURL.empty() || rURL[0] != '#' )
return;
- OUString aURL( BookmarkToWriter( rURL.copy( 1 ) ) );
+ OUString aURL( BookmarkToWriter( rURL.substr( 1 ) ) );
sal_Int32 nPos = aURL.lastIndexOf( cMarkSeparator );
if( nPos < 2 )
@@ -3132,96 +3267,91 @@ void MSWordExportBase::AddLinkTarget(const OUString& rURL)
return;
sCmp = sCmp.toAsciiLowerCase();
- sal_uLong nIdx = 0;
- bool noBookmark = false;
-
if( sCmp == "outline" )
{
SwPosition aPos(*m_pCurPam->GetPoint());
- OUString aName(BookmarkToWriter(aURL.copy(0, nPos)));
+ OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
// If we can find the outline this bookmark refers to
// 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.copy(0, nPos)));
- const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, SwNodeType::Grf);
- if (pFormat && nullptr != (pIdx = const_cast<SwNodeIndex*>(pFormat->GetContent().GetContentIdx())))
+ OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
+ 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.copy(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;
- }
+ OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
+ 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.copy(0, nPos)));
- const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, SwNodeType::Ole);
- if (pFormat && nullptr != (pIdx = const_cast<SwNodeIndex*>(pFormat->GetContent().GetContentIdx())))
+ OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
+ 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.copy(0, nPos)));
+ 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.copy(0, nPos)));
- const SwTable* pTable = SwTable::FindTable(m_rDoc.FindTableFormatByName(aName));
- if (pTable)
+ OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
+ 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));
+ if (const auto tmp = sw::PrepareJumpToTOXMark(m_rDoc, nameDecoded))
{
- SwTableNode* pTableNode = const_cast<SwTableNode*>(pTable->GetTabSortBoxes()[1]->GetSttNd()->FindTableNode());
- if (pTableNode)
+ SwTOXMark const* pMark(&tmp->first);
+ for (sal_Int32 i = 0; i < tmp->second; ++i)
+ {
+ pMark = &m_rDoc.GotoTOXMark(*pMark, TOX_SAME_NXT, true);
+ }
+ if (!SfxPoolItem::areSame(pMark, &tmp->first))
{
- nIdx = pTableNode->GetIndex() + 2;
- noBookmark = true;
+ 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)
@@ -3241,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)
@@ -3264,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];
@@ -3310,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() )
@@ -3362,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);
@@ -3380,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!" );
@@ -3390,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] = {};
@@ -3409,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
@@ -3425,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);
@@ -3442,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);
@@ -3461,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 ));
@@ -3500,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();
@@ -3529,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;
}
@@ -3562,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:;
}
@@ -3582,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);
}
@@ -3643,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 ();
@@ -3660,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();
@@ -3672,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);
@@ -3691,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
@@ -3710,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);
@@ -3722,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)
@@ -3753,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;
@@ -3779,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
@@ -3804,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;
}
@@ -3821,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)
@@ -3835,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)
@@ -3872,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)
{
@@ -3889,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();
}
@@ -3897,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))
@@ -3916,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
@@ -3939,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 );
}
@@ -3952,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
@@ -4029,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& )
@@ -4043,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 )
@@ -4072,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);
@@ -4132,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;
@@ -4231,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));
}
}
@@ -4267,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 );
}
}
}
@@ -4303,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 );
@@ -4312,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)
@@ -4327,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();
}
}
@@ -4342,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();
@@ -4362,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();
}
}
@@ -4377,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>" );
}
@@ -4465,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 fdee9d097f31..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;
@@ -163,6 +165,7 @@ enum to state the present state of the fly
*/
enum FlyProcessingState
{
+ FLY_NONE,
FLY_PROCESSED,
FLY_POSTPONED,
FLY_NOT_PROCESSED
@@ -194,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);
@@ -221,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; }
@@ -239,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;
@@ -262,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;
@@ -280,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();
@@ -304,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;
@@ -323,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);
@@ -333,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
@@ -405,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
{
@@ -431,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;
@@ -449,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;
@@ -467,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;
@@ -489,16 +492,19 @@ public:
public:
/* implicit bookmark vector containing pairs of node indexes and bookmark names */
std::vector<aBookmarkPair> m_aImplicitBookmarks;
+ std::unordered_map<OUString, OUString> m_TOXMarkBookmarksByURL;
+ 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
{
@@ -534,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
@@ -569,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;
@@ -596,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 );
@@ -634,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 );
@@ -652,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
@@ -700,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;
@@ -728,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();
@@ -781,8 +791,8 @@ public:
/// Output the actual headers and footers.
virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
- const SwFrameFormat& rFormat, const SwFrameFormat& rLeftFormat, const SwFrameFormat& rFirstPageFormat,
- sal_uInt8 nBreakCode) = 0;
+ const SwFrameFormat& rFormat, const SwFrameFormat& rLeftHeaderFormat, const SwFrameFormat& rLeftFooterFormat, const SwFrameFormat& rFirstPageFormat,
+ sal_uInt8 nBreakCode, bool bEvenAndOddHeaders) = 0;
/// Write the field
virtual void OutputField( const SwField* pField, ww::eField eFieldType,
@@ -805,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;
@@ -831,7 +847,7 @@ protected:
/// Setup the chapter fields (maChapterFieldLocs).
void GatherChapterFields();
- void AddLinkTarget( const OUString& rURL );
+ void AddLinkTarget( std::u16string_view rURL );
void CollectOutlineBookmarks( const SwDoc &rDoc );
bool SetCurrentPageDescFromNode(const SwNode &rNd);
@@ -843,7 +859,8 @@ protected:
virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
const SwNode& rNd,
const SwFormatPageDesc* pNewPgDescFormat,
- const SwPageDesc* pNewPgDesc ) = 0;
+ const SwPageDesc* pNewPgDesc,
+ bool bExtraPageBreak = false ) = 0;
/// Return value indicates if an inherited outline numbering is suppressed.
virtual bool DisallowInheritingOutlineNumbering(const SwFormat &rFormat) = 0;
@@ -894,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();
@@ -916,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.
@@ -933,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
@@ -969,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; }
@@ -983,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.
@@ -1000,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.
@@ -1065,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 );
@@ -1085,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;
@@ -1097,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;
@@ -1106,7 +1129,8 @@ public:
virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
const SwNode& rNd,
const SwFormatPageDesc* pNewPgDescFormat,
- const SwPageDesc* pNewPgDesc ) override;
+ const SwPageDesc* pNewPgDesc,
+ bool bExtraPageBreak = false ) override;
static void Out_BorderLine(ww::bytes& rO, const ::editeng::SvxBorderLine* pLine,
sal_uInt16 nDist, sal_uInt16 nSprmNo, sal_uInt16 nSprmNoVer9,
@@ -1143,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.
@@ -1175,15 +1199,15 @@ 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;
/// Output the actual headers and footers.
virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
- const SwFrameFormat& rFormat, const SwFrameFormat& rLeftFormat, const SwFrameFormat& rFirstPageFormat,
- sal_uInt8 nBreakCode) override;
+ const SwFrameFormat& rFormat, const SwFrameFormat& rLeftHeaderFormat, const SwFrameFormat& rLeftFooterFormat, const SwFrameFormat& rFirstPageFormat,
+ sal_uInt8 nBreakCode, bool bEvenAndOddHeaders) override;
virtual ExportFormat GetExportFormat() const override { return ExportFormat::DOC; }
@@ -1209,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();
@@ -1228,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;
@@ -1279,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;
@@ -1325,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:
@@ -1347,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
@@ -1376,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
@@ -1398,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
@@ -1416,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()
@@ -1429,7 +1453,7 @@ public:
class MSWordAttrIter
{
private:
- MSWordAttrIter* pOld;
+ MSWordAttrIter* m_pOld;
MSWordAttrIter(const MSWordAttrIter&) = delete;
MSWordAttrIter& operator=(const MSWordAttrIter&) = delete;
protected:
@@ -1439,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 );
@@ -1474,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.
@@ -1494,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;
@@ -1503,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;
@@ -1523,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 );
@@ -1533,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 );
+ 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);
@@ -1544,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; }
@@ -1553,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.
@@ -1565,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 );
@@ -1594,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;
@@ -1607,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 ]; }
};
@@ -1627,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 5b7e0a3b9a45..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;
@@ -224,12 +228,12 @@ void MSWordExportBase::ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16
if (pINetItem)
{
- const SwFormatINetFormat& rINet = static_cast<const SwFormatINetFormat&>(*pINetItem);
+ const SwFormatINetFormat& rINet = pINetItem->StaticWhichCast(RES_TXTATR_INETFMT);
const SwCharFormat* pINetFormat = GetSwCharFormat(rINet, m_rDoc);
if (!pINetFormat)
continue;
- const SwCharFormat* pFormat = static_cast<const SwFormatCharFormat&>(*pItem).GetCharFormat();
+ const SwCharFormat* pFormat = pItem->StaticWhichCast(RES_TXTATR_CHARFMT).GetCharFormat();
ww8::PoolItems aCharItems, aINetItems;
GetPoolItems(pFormat->GetAttrSet(), aCharItems, false);
GetPoolItems(pINetFormat->GetAttrSet(), aINetItems, false);
@@ -264,11 +268,11 @@ void MSWordExportBase::ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16
}
else if (nWhich == RES_CHRATR_COLOR)
{
- const SvxColorItem& rColor = static_cast<const SvxColorItem&>(*pItem);
+ const SvxColorItem& rColor = pItem->StaticWhichCast(RES_CHRATR_COLOR);
const SfxPoolItem* pBackgroundItem = SearchPoolItems(rItems, RES_CHRATR_BACKGROUND);
if (rColor.GetValue() == COL_AUTO && pBackgroundItem)
{
- const SvxBrushItem& rBrushBackground = static_cast<const SvxBrushItem&>(*pBackgroundItem);
+ const SvxBrushItem& rBrushBackground = pBackgroundItem->StaticWhichCast(RES_CHRATR_BACKGROUND);
SvxColorItem aForeground(rBrushBackground.GetColor().IsDark() ? COL_WHITE : COL_BLACK, RES_CHRATR_COLOR);
AttrOutput().OutputItem(aForeground);
}
@@ -280,7 +284,7 @@ void MSWordExportBase::ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16
}
else if (nWhich == RES_CHRATR_HIGHLIGHT)
{
- const SvxBrushItem& rBrush = static_cast< const SvxBrushItem& >( *pItem );
+ const SvxBrushItem& rBrush = pItem->StaticWhichCast(RES_CHRATR_HIGHLIGHT);
// The UI easily adds unnecessary highlights, so identify and avoid exporting those.
// Highlight is not valid in character styles, so must not check there.
// Check the (para) style hierarchy to find the nearest defined highlight.
@@ -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 ( static_cast<const SwNumRuleItem*>(pItem)->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 );
}
}
@@ -352,11 +364,11 @@ void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, b
ExportPoolItemsToCHP(aItems, nScript, nullptr);
if ( bPapFormat )
{
- AttrOutput().MaybeOutputBrushItem(rSet);
+ const bool bAlreadyOutputBrushItem = AttrOutput().MaybeOutputBrushItem(rSet);
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 ) ||
@@ -365,12 +377,25 @@ void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, b
}
// Has to be called after RES_PARATR_GRABBAG is processed.
- const XFillStyleItem* pXFillStyleItem(rSet.GetItem<XFillStyleItem>(XATTR_FILLSTYLE));
- if (pXFillStyleItem && pXFillStyleItem->GetValue() == drawing::FillStyle_SOLID && !rSet.HasItem(RES_BACKGROUND))
+ const XFillStyleItem* pFill(rSet.GetItem<XFillStyleItem>(XATTR_FILLSTYLE, false));
+ if (!bAlreadyOutputBrushItem && pFill
+ && (pFill->GetValue() == drawing::FillStyle_SOLID || pFill->GetValue() == drawing::FillStyle_NONE)
+ && !rSet.GetItem(RES_BACKGROUND, false))
{
+ const bool bFillStyleNone = pFill->GetValue() == drawing::FillStyle_NONE;
+ // No need to write out a NONE background if it can't inherit something else, or if it already inherits a NONE.
+ std::unique_ptr<SvxBrushItem> pInherited;
+ if (bFillStyleNone)
+ {
+ if ( auto pNd = dynamic_cast<const SwContentNode*>(m_pOutFormatNode)) //paragraph
+ pInherited = getSvxBrushItemFromSourceSet(static_cast<SwTextFormatColl&>(pNd->GetAnyFormatColl()).GetAttrSet(), RES_BACKGROUND);
+ else if (m_bStyDef && m_pCurrentStyle && m_pCurrentStyle->DerivedFrom()) //style
+ pInherited = getSvxBrushItemFromSourceSet(m_pCurrentStyle->DerivedFrom()->GetAttrSet(), RES_BACKGROUND);
+ }
// Construct an SvxBrushItem, as expected by the exporters.
std::unique_ptr<SvxBrushItem> aBrush(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
- AttrOutput().OutputItem(*aBrush);
+ if (!bFillStyleNone || (pInherited && *pInherited != *aBrush))
+ AttrOutput().OutputItem(*aBrush);
}
#if 0
else
@@ -397,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;
}
@@ -468,8 +493,8 @@ 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;
//Output a sectionbreak if there's a new pagedescriptor. Otherwise output a
//pagebreak if there is a pagebreak here, unless the new page (follow
@@ -500,15 +525,43 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode
if ( pSet && pSet->Count() )
{
- if ( SfxItemState::SET == pSet->GetItemState( RES_PAGEDESC, false, &pItem ) &&
- static_cast<const SwFormatPageDesc*>(pItem)->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))
+ {
+ 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;
@@ -546,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 );
}
}
}
@@ -571,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;
}
@@ -595,7 +669,7 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode
if ( bNewPageDesc && m_pCurrentPageDesc )
{
- PrepareNewPageDesc( pSet, rNd, pPgDesc, m_pCurrentPageDesc );
+ PrepareNewPageDesc( pSet, rNd, pPgDesc, m_pCurrentPageDesc, bExtraPageBreakBeforeSectionBreak );
}
m_bBreakBefore = false;
}
@@ -634,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;
@@ -647,7 +721,8 @@ sal_uLong MSWordExportBase::GetSectionLineNo( const SfxItemSet* pSet, const SwNo
void WW8Export::PrepareNewPageDesc( const SfxItemSet*pSet,
const SwNode& rNd,
const SwFormatPageDesc* pNewPgDescFormat,
- const SwPageDesc* pNewPgDesc )
+ const SwPageDesc* pNewPgDesc,
+ bool /*bExtraPageBreak*/ )
{
// The PageDescs will only be inserted in WW8Writer::pSepx with the corresponding
// position by the occurrences of PageDesc attributes. The construction and
@@ -668,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 );
}
}
@@ -701,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;
@@ -712,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:
@@ -730,19 +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 sprmPOutLvl sprmPIlvl and sprmPIlfo
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::POutLvl::val );
- m_rWW8Export.pO->push_back( nLvl );
- 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#
@@ -760,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;
}
@@ -794,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));
@@ -803,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);
@@ -826,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;
@@ -848,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
@@ -877,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:
@@ -960,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 )
{
@@ -968,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) );
}
}
@@ -976,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 )
{
@@ -995,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());
}
}
@@ -1019,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() );
}
}
}
@@ -1033,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));
}
}
@@ -1042,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));
}
}
@@ -1071,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);
}
@@ -1088,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 )
@@ -1119,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 )
@@ -1196,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 )
@@ -1247,24 +1376,31 @@ 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 )
{
m_rWW8Export.InsUInt16( NS_sprm::CKul::val );
- const SfxPoolItem* pItem = m_rWW8Export.HasItem( RES_CHRATR_WORDLINEMODE );
+ // FIXME: this should likely be a StaticWhichCast(), but some we put something dirty in RES_CHRATR_WORDLINEMODE apparently
+ const auto pItem = m_rWW8Export.HasItem(RES_CHRATR_WORDLINEMODE);
bool bWord = false;
- if (pItem)
- bWord = static_cast<const SvxWordLineModeItem*>(pItem)->GetValue();
+ if(pItem)
+ {
+ const auto pWordline = pItem->DynamicWhichCast(RES_CHRATR_WORDLINEMODE);
+ if(pWordline)
+ bWord = pWordline->GetValue();
+ else
+ 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,
// 3 = double, 4 = dotted, 5 = hidden
@@ -1331,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 )
{
@@ -1414,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 )
@@ -1450,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 ) );
}
}
@@ -1473,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) );
}
}
@@ -1491,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));
}
}
@@ -1499,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 )
@@ -1516,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 )
@@ -1541,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 );
}
/**
@@ -1577,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)
{
@@ -1598,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);
@@ -1667,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 };
@@ -1692,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 );
@@ -1769,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;
@@ -1887,6 +2023,13 @@ void WW8Export::OutputField( const SwField* pField, ww::eField eFieldType,
if (nSubType == REF_SEQUENCEFLD)
aField15[0] |= (0x4 << 5);
}
+ // This ought to apply to any field, but just to be safe, start off with DATE/TIME only.
+ if (pField->GetTyp()->Which() == SwFieldIds::DateTime
+ && (pField->GetSubType() & FIXEDFLD))
+ {
+ //bit 5 - Locked: do not recalculate field
+ aField15[1] |= 0x10;
+ }
}
pFieldP->Append( Fc2Cp( Strm().Tell() ), aField15 );
@@ -1978,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);
@@ -2178,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() )
@@ -2188,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;
@@ -2220,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())
@@ -2270,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:
@@ -2283,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;
@@ -2384,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);
}
}
}
@@ -2405,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() )
@@ -2413,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;
}
}
}
@@ -2498,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);
}
}
}
@@ -2543,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));
@@ -2578,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");
@@ -2661,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 )
@@ -2844,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);
@@ -2865,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;
{
@@ -2898,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);
}
@@ -2995,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 + "\"";
}
@@ -3046,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())
{
@@ -3101,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())
{
@@ -3134,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:
@@ -3176,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;
@@ -3205,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;
}
@@ -3231,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;
@@ -3240,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 );
@@ -3250,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;
@@ -3278,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 );
}
@@ -3297,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 )
@@ -3323,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 )
@@ -3390,7 +3661,7 @@ void WW8Export::WriteFootnoteBegin( const SwFormatFootnote& rFootnote, ww::bytes
SwWW8Writer::InsUInt16( aAttrArr, NS_sprm::CIstd::val );
SwWW8Writer::InsUInt16( aAttrArr, GetId( pCFormat ) );
- // fSpec-Attribut true
+ // fSpec-Attribute true
// For Auto-Number a special character must go
// into the text and therefore a fSpec attribute
m_pChpPlc->AppendFkpEntry( Strm().Tell() );
@@ -3418,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 );
@@ -3435,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() );
@@ -3484,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 );
}
@@ -3499,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 )
@@ -3527,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();
@@ -3560,15 +3830,65 @@ 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 )
+{
+ sal_uInt16 nOutLvl = rItem.GetValue();
+
+ // Do not write out default level (Body Text) if there is no inheritance, or if the level matches the inherited value
+ const SfxUInt16Item* pInherited = nullptr;
+ if (auto pNd = dynamic_cast<const SwContentNode*>(GetExport().m_pOutFormatNode)) //paragraph
+ pInherited = static_cast<SwTextFormatColl&>(pNd->GetAnyFormatColl()).GetAttrSet().GetItem<SfxUInt16Item>(RES_PARATR_OUTLINELEVEL);
+ else if (GetExport().m_bStyDef && GetExport().m_pCurrentStyle && GetExport().m_pCurrentStyle->DerivedFrom()) //style
+ pInherited = GetExport().m_pCurrentStyle->DerivedFrom()->GetAttrSet().GetItem<SfxUInt16Item>(RES_PARATR_OUTLINELEVEL);
+ if ((pInherited && pInherited->GetValue() == nOutLvl)
+ || (!pInherited && !nOutLvl))
+ return;
+
+ ParaOutlineLevel(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(
@@ -3579,27 +3899,13 @@ void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule )
sal_uInt16 nNumId = GetExport().GetNumberingId(*pRule) + 1;
sal_uInt8 nLvl = 0;
- if (!GetExport().m_pOutFormatNode)
- {
- ParaNumRule_Impl(pTextNd, nLvl, nNumId);
- return;
- }
-
- if ( dynamic_cast< const SwContentNode *>( GetExport().m_pOutFormatNode ) != nullptr )
+ const SwTextNode* pTextNd = dynamic_cast<const SwTextNode*>(GetExport().m_pOutFormatNode);
+ if (pTextNd)
{
- 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
{
@@ -3607,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(
@@ -3618,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;
@@ -3628,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
@@ -3639,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 )
@@ -3668,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 */
@@ -3688,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() )
@@ -3700,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 );
}
@@ -3712,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*/
@@ -3736,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;
@@ -3754,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 );
@@ -3825,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 );
}
/**
@@ -3924,7 +4245,7 @@ void AttributeOutputBase::FormatBreak( const SvxFormatBreakItem& rBreak )
}
}
-void WW8AttributeOutput::SectionBreak( sal_uInt8 nC, bool /*bBreakAfter*/, const WW8_SepInfo* /*pSectionInfo*/ )
+void WW8AttributeOutput::SectionBreak( sal_uInt8 nC, bool /*bBreakAfter*/, const WW8_SepInfo* /*pSectionInfo*/, bool /*bExtraPageBreak*/ )
{
m_rWW8Export.ReplaceCr( nC );
}
@@ -3938,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( );
@@ -4018,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 )
@@ -4027,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 );
@@ -4042,6 +4389,7 @@ void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR )
m_pageMargins.nLeft += sal::static_int_cast<sal_uInt16>(rLR.GetLeft());
m_pageMargins.nRight += sal::static_int_cast<sal_uInt16>(rLR.GetRight());
+ sal_uInt16 nGutter = rLR.GetGutterMargin();
// sprmSDxaLeft
m_rWW8Export.InsUInt16( NS_sprm::SDxaLeft::val );
@@ -4050,16 +4398,23 @@ void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR )
// sprmSDxaRight
m_rWW8Export.InsUInt16( NS_sprm::SDxaRight::val );
m_rWW8Export.InsUInt16( m_pageMargins.nRight );
+
+ if (nGutter)
+ {
+ // sprmSDzaGutter
+ m_rWW8Export.InsUInt16(NS_sprm::SDzaGutter::val);
+ m_rWW8Export.InsUInt16(nGutter);
+ }
}
else
{ // 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 ?
@@ -4067,6 +4422,28 @@ void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR )
}
}
+void WW8AttributeOutput::SectionRtlGutter(const SfxBoolItem& rRtlGutter)
+{
+ if (!rRtlGutter.GetValue())
+ {
+ return;
+ }
+
+ // sprmSFRTLGutter
+ m_rWW8Export.InsUInt16(NS_sprm::SFRTLGutter::val);
+ 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 )
{
// Flys are still missing ( see RTF )
@@ -4076,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
{
@@ -4090,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
{
@@ -4119,10 +4496,20 @@ void WW8AttributeOutput::FormatULSpace( const SvxULSpaceItem& rUL )
m_rWW8Export.InsUInt16( NS_sprm::PDyaAfter::val );
m_rWW8Export.InsUInt16( rUL.GetLower() );
// sprmPFContextualSpacing
- if (rUL.GetContext())
+
+ // Write out Contextual Spacing = false if it would have inherited a true.
+ const SvxULSpaceItem* pInherited = nullptr;
+ if (!rUL.GetContext())
+ {
+ if (auto pNd = dynamic_cast<const SwContentNode*>(m_rWW8Export.m_pOutFormatNode)) //paragraph
+ pInherited = &static_cast<SwTextFormatColl&>(pNd->GetAnyFormatColl()).GetAttrSet().GetULSpace();
+ else if (m_rWW8Export.m_bStyDef && m_rWW8Export.m_pCurrentStyle && m_rWW8Export.m_pCurrentStyle->DerivedFrom()) //style
+ pInherited = &m_rWW8Export.m_pCurrentStyle->DerivedFrom()->GetULSpace();
+ }
+ 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()) );
}
}
}
@@ -4135,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 );
}
}
@@ -4239,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 )
@@ -4255,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
@@ -4277,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 );
@@ -4305,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;
@@ -4475,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 );
}
}
@@ -4527,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 );
}
}
@@ -4544,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* p = static_cast<const SvxShadowItem*>(pItem);
- bShadow = ( p->GetLocation() != SvxShadowLocation::NONE )
- && ( p->GetWidth() != 0 );
+ bShadow = ( pShadowItem->GetLocation() != SvxShadowLocation::NONE )
+ && ( pShadowItem->GetWidth() != 0 );
}
SvxBoxItem aBox(rBox);
@@ -4593,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;
@@ -4608,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( ) );
}
@@ -4678,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
{
@@ -4701,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
@@ -4710,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 */
@@ -4795,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;
@@ -4805,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,
@@ -4824,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 ) ||
@@ -4836,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 )
@@ -4875,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 );
}
}
@@ -4892,8 +5277,13 @@ void WW8AttributeOutput::CharGrabBag(const SfxGrabBagItem& /*rItem*/)
{
}
-void WW8AttributeOutput::ParaOutlineLevel(const SfxUInt16Item& /*rItem*/)
+void WW8AttributeOutput::ParaOutlineLevel(const SfxUInt16Item& rItem)
{
+ sal_uInt16 nOutLvl = std::min(rItem.GetValue(), sal_uInt16(WW8ListManager::nMaxLevel));
+ // 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.m_pO->push_back( nOutLvl );
}
// "Separate paragraphs"
@@ -4901,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 );
}
/**
@@ -4913,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;
@@ -4940,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] );
}
/**
@@ -4955,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;
@@ -4996,8 +5386,8 @@ void SwWW8WrTabu::Add(const SvxTabStop & rTS, tools::Long nAdjustment)
break;
}
- pAddTyp[nAdd] = nPara;
- ++nAdd;
+ m_pAddTyp[m_nAdd] = nPara;
+ ++m_nAdd;
}
/**
@@ -5007,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;
}
/**
@@ -5016,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,
@@ -5155,10 +5545,16 @@ void WW8AttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStops )
tools::Long nCurrentLeft = 0;
if ( bTabsRelativeToIndex )
{
- const SfxPoolItem* pLR = m_rWW8Export.HasItem( RES_LR_SPACE );
-
- if ( pLR != nullptr )
- nCurrentLeft = static_cast<const SvxLRSpaceItem*>(pLR)->GetTextLeft();
+ if (const SfxPoolItem* pItem = m_rWW8Export.HasItem(RES_MARGIN_TEXTLEFT))
+ {
+ 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 it's of the wrong type.");
+ }
}
// #i100264#
@@ -5179,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 );
@@ -5202,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,
@@ -5218,52 +5614,52 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt )
switch ( rHt.Which() )
{
case RES_CHRATR_CASEMAP:
- CharCaseMap( static_cast< const SvxCaseMapItem& >( rHt ) );
+ CharCaseMap(rHt.StaticWhichCast(RES_CHRATR_CASEMAP));
break;
case RES_CHRATR_COLOR:
- CharColor( static_cast< const SvxColorItem& >( rHt ) );
+ CharColor(rHt.StaticWhichCast(RES_CHRATR_COLOR));
break;
case RES_CHRATR_CONTOUR:
- CharContour( static_cast< const SvxContourItem& >( rHt ) );
+ CharContour(rHt.StaticWhichCast(RES_CHRATR_CONTOUR));
break;
case RES_CHRATR_CROSSEDOUT:
- CharCrossedOut( static_cast< const SvxCrossedOutItem& >( 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:
@@ -5299,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 );
@@ -5391,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;
@@ -5437,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 ) );
@@ -5446,11 +5851,17 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt )
ParaGrabBag(static_cast<const SfxGrabBagItem&>(rHt));
break;
case RES_PARATR_OUTLINELEVEL:
- ParaOutlineLevel(static_cast<const SfxUInt16Item&>(rHt));
+ ParaOutlineLevelBase(static_cast<const SfxUInt16Item&>(rHt));
break;
case RES_CHRATR_GRABBAG:
CharGrabBag(static_cast<const SfxGrabBagItem&>(rHt));
break;
+ 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() );
@@ -5489,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 );
@@ -5558,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() );
@@ -5570,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.
@@ -5599,7 +6010,10 @@ void AttributeOutputBase::CharBackgroundBase( const SvxBrushItem& rBrush )
}
else
{
- CharHighlight(rBrush);
+ // Don't create a duplicate entry when converting to highlight. An existing one has priority.
+ // Character runs seem to need a different method to detect duplicates? Just continue to ignore that situation.
+ if (GetExport().m_aCurrentCharPropStarts.size() || !GetExport().HasItem(RES_CHRATR_HIGHLIGHT))
+ CharHighlight(rBrush);
}
}
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index ac4e931ecf0d..7a0d13a2bc62 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -32,7 +32,7 @@ public:
virtual void RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript ) override;
/// Start of the paragraph.
- virtual void StartParagraph( ww8::WW8TableNodeInfo::Pointer_t /*pTextNodeInfo*/ ) override {}
+ virtual sal_Int32 StartParagraph( ww8::WW8TableNodeInfo::Pointer_t /*pTextNodeInfo*/, bool /*bGenerateParaId*/ ) override { return 0; }
/// End of the paragraph.
virtual void EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) override;
@@ -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 ) 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.
@@ -147,7 +148,7 @@ public:
/// Write a section break
/// msword::ColumnBreak or msword::PageBreak
- virtual void SectionBreak( sal_uInt8 nC, bool bBreakAfter, const WW8_SepInfo* pSectionInfo = nullptr ) override;
+ virtual void SectionBreak( sal_uInt8 nC, bool bBreakAfter, const WW8_SepInfo* pSectionInfo = nullptr, bool bExtraPageBreak = false ) override;
// preserve DOC page vertical alignment
virtual void TextVerticalAdjustment( const css::drawing::TextVerticalAdjust ) override;
@@ -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;
@@ -434,6 +443,40 @@ protected:
virtual void WriteBookmarkInActParagraph( const OUString& rName, sal_Int32 nFirstRunPos, sal_Int32 nLastRunPos ) override;
+ 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;
@@ -441,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.
///
@@ -466,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 91bb6e9ad5f1..ac4338b7921b 100644
--- a/sw/source/filter/ww8/ww8glsy.cxx
+++ b/sw/source/filter/ww8/ww8glsy.cxx
@@ -20,6 +20,7 @@
#include <memory>
#include <tools/urlobj.hxx>
#include <svl/urihelper.hxx>
+#include <osl/diagnose.h>
#include <ndtxt.hxx>
#include <pam.hxx>
#include <poolfmt.hxx>
@@ -33,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; )
@@ -65,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;
}
@@ -114,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
@@ -168,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();
}
@@ -190,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())
@@ -217,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 674ca5649dca..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,21 +1134,21 @@ 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);
}
- GrafikCtor();
+ GraphicCtor();
pNew->SetLogicRect( pTextObj->GetCurrentBoundRect() );
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,
@@ -1161,7 +1192,7 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj,
pFlyFormat->SetFormatAttr( aFlySet );
- MapWrapIntoFlyFormat(pRecord, pFlyFormat);
+ MapWrapIntoFlyFormat(*pRecord, *pFlyFormat);
}
aString.clear();
rbEraseTextObj = (nullptr != pFlyFormat);
@@ -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);
@@ -1419,12 +1450,12 @@ SdrObject* SwWW8ImplReader::ReadGrafPrimitive(short& rLeft, SfxAllItemSet &rSet)
return pRet;
}
-void SwWW8ImplReader::ReadGrafLayer1( WW8PLCFspecial* pPF, tools::Long nGrafAnchorCp )
+void SwWW8ImplReader::ReadGrafLayer1(WW8PLCFspecial& rPF, tools::Long nGrafAnchorCp)
{
- pPF->SeekPos( nGrafAnchorCp );
+ rPF.SeekPos(nGrafAnchorCp);
WW8_FC nStartFc;
void* pF0;
- if( !pPF->Get( nStartFc, pF0 ) )
+ if (!rPF.Get(nStartFc, pF0))
{
OSL_ENSURE( false, "+Where is the graphic (2) ?" );
return;
@@ -1436,7 +1467,16 @@ void SwWW8ImplReader::ReadGrafLayer1( WW8PLCFspecial* pPF, tools::Long nGrafAnch
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* pPF, tools::Long nGrafAnch
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());
@@ -1661,7 +1701,7 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject const * pSdrObj,
*/
// 1. GraphicObject of documents?
- GrafikCtor();
+ GraphicCtor();
const SfxItemSet& rOldSet = pSdrObj->GetMergedItemSet();
@@ -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
{
@@ -1967,33 +2006,29 @@ void SwWW8ImplReader::AdjustULWrapForWordMargins(
rUL.SetUpper(sal_uInt16(0));
}
-void SwWW8ImplReader::MapWrapIntoFlyFormat(SvxMSDffImportRec const * pRecord,
- SwFrameFormat* pFlyFormat)
+void SwWW8ImplReader::MapWrapIntoFlyFormat(const SvxMSDffImportRec& rRecord,
+ SwFrameFormat& rFlyFormat)
{
- if (!pRecord || !pFlyFormat)
- return;
-
- if (pRecord->nDxWrapDistLeft || pRecord->nDxWrapDistRight)
+ if (rRecord.nDxWrapDistLeft || rRecord.nDxWrapDistRight)
{
- SvxLRSpaceItem aLR(writer_cast<sal_uInt16>(pRecord->nDxWrapDistLeft),
- writer_cast<sal_uInt16>(pRecord->nDxWrapDistRight), 0, 0, RES_LR_SPACE);
- AdjustLRWrapForWordMargins(*pRecord, aLR);
- pFlyFormat->SetFormatAttr(aLR);
+ SvxLRSpaceItem aLR(writer_cast<sal_uInt16>(rRecord.nDxWrapDistLeft),
+ writer_cast<sal_uInt16>(rRecord.nDxWrapDistRight), 0, RES_LR_SPACE);
+ AdjustLRWrapForWordMargins(rRecord, aLR);
+ rFlyFormat.SetFormatAttr(aLR);
}
- if (pRecord->nDyWrapDistTop || pRecord->nDyWrapDistBottom)
+ if (rRecord.nDyWrapDistTop || rRecord.nDyWrapDistBottom)
{
- SvxULSpaceItem aUL(writer_cast<sal_uInt16>(pRecord->nDyWrapDistTop),
- writer_cast<sal_uInt16>(pRecord->nDyWrapDistBottom), RES_UL_SPACE);
- AdjustULWrapForWordMargins(*pRecord, aUL);
- pFlyFormat->SetFormatAttr(aUL);
+ SvxULSpaceItem aUL(writer_cast<sal_uInt16>(rRecord.nDyWrapDistTop),
+ writer_cast<sal_uInt16>(rRecord.nDyWrapDistBottom), RES_UL_SPACE);
+ AdjustULWrapForWordMargins(rRecord, aUL);
+ rFlyFormat.SetFormatAttr(aUL);
}
// If we are contoured and have a custom polygon...
- if (pRecord->pWrapPolygon && pFlyFormat->GetSurround().IsContour())
+ if (rRecord.pWrapPolygon && rFlyFormat.GetSurround().IsContour())
{
- if (SwNoTextNode *pNd = GetNoTextNodeFromSwFrameFormat(*pFlyFormat))
+ if (SwNoTextNode* pNd = GetNoTextNodeFromSwFrameFormat(rFlyFormat))
{
-
/*
Gather round children and hear of a tale that will raise the
hairs on the back of your neck this dark halloween night.
@@ -2040,7 +2075,7 @@ void SwWW8ImplReader::MapWrapIntoFlyFormat(SvxMSDffImportRec const * pRecord,
what I actually see in word
*/
- tools::PolyPolygon aPoly(*pRecord->pWrapPolygon);
+ tools::PolyPolygon aPoly(*rRecord.pWrapPolygon);
const Size &rSize = pNd->GetTwipSize();
/*
Move to the left by 15twips, and rescale to
@@ -2068,13 +2103,24 @@ void SwWW8ImplReader::MapWrapIntoFlyFormat(SvxMSDffImportRec const * pRecord,
pNd->SetContour(&aPoly);
}
}
- else if (pFlyFormat->GetSurround().IsContour())
+ 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(pFlyFormat->GetSurround());
- aSurround.SetContour(false);
- pFlyFormat->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);
+ }
+ }
}
}
@@ -2091,11 +2137,10 @@ static sal_Int32 lcl_ConvertCrop(sal_uInt32 const nCrop, sal_Int32 const nSize)
return (nIntegral * nSize) + (((nCrop & 0xffff) * nSize) >> 16);
}
-void
-SwWW8ImplReader::SetAttributesAtGrfNode(SvxMSDffImportRec const*const pRecord,
- SwFrameFormat const *pFlyFormat, WW8_FSPA const *pF )
+void SwWW8ImplReader::SetAttributesAtGrfNode(const SvxMSDffImportRec& rRecord,
+ const SwFrameFormat& rFlyFormat, WW8_FSPA const *pF)
{
- const SwNodeIndex* pIdx = pFlyFormat->GetContent(false).GetContentIdx();
+ const SwNodeIndex* pIdx = rFlyFormat.GetContent(false).GetContentIdx();
SwGrfNode *const pGrfNd(
pIdx ? m_rDoc.GetNodes()[pIdx->GetIndex() + 1]->GetGrfNode() : nullptr);
if (!pGrfNd)
@@ -2111,33 +2156,33 @@ SwWW8ImplReader::SetAttributesAtGrfNode(SvxMSDffImportRec const*const pRecord,
else if (!nHeight && pF)
nHeight = o3tl::saturating_sub(pF->nYaBottom, pF->nYaTop);
- if( pRecord->nCropFromTop || pRecord->nCropFromBottom ||
- pRecord->nCropFromLeft || pRecord->nCropFromRight )
+ if (rRecord.nCropFromTop || rRecord.nCropFromBottom ||
+ rRecord.nCropFromLeft || rRecord.nCropFromRight)
{
SwCropGrf aCrop; // Cropping is stored in 'fixed floats'
// 16.16 (fraction times total
- if( pRecord->nCropFromTop ) // image width or height resp.)
+ if (rRecord.nCropFromTop) // image width or height resp.)
{
- aCrop.SetTop(lcl_ConvertCrop(pRecord->nCropFromTop, nHeight));
+ aCrop.SetTop(lcl_ConvertCrop(rRecord.nCropFromTop, nHeight));
}
- if( pRecord->nCropFromBottom )
+ if (rRecord.nCropFromBottom)
{
- aCrop.SetBottom(lcl_ConvertCrop(pRecord->nCropFromBottom, nHeight));
+ aCrop.SetBottom(lcl_ConvertCrop(rRecord.nCropFromBottom, nHeight));
}
- if( pRecord->nCropFromLeft )
+ if (rRecord.nCropFromLeft)
{
- aCrop.SetLeft(lcl_ConvertCrop(pRecord->nCropFromLeft, nWidth));
+ aCrop.SetLeft(lcl_ConvertCrop(rRecord.nCropFromLeft, nWidth));
}
- if( pRecord->nCropFromRight )
+ if (rRecord.nCropFromRight)
{
- aCrop.SetRight(lcl_ConvertCrop(pRecord->nCropFromRight, nWidth));
+ aCrop.SetRight(lcl_ConvertCrop(rRecord.nCropFromRight, nWidth));
}
pGrfNd->SetAttr( aCrop );
}
- bool bFlipH(pRecord->nFlags & ShapeFlag::FlipH);
- bool bFlipV(pRecord->nFlags & ShapeFlag::FlipV);
+ bool bFlipH(rRecord.nFlags & ShapeFlag::FlipH);
+ bool bFlipV(rRecord.nFlags & ShapeFlag::FlipV);
if ( bFlipH || bFlipV )
{
SwMirrorGrf aMirror = pGrfNd->GetSwAttrSet().GetMirrorGrf();
@@ -2154,10 +2199,10 @@ SwWW8ImplReader::SetAttributesAtGrfNode(SvxMSDffImportRec const*const pRecord,
pGrfNd->SetAttr( aMirror );
}
- if (!pRecord->pObj)
+ if (!rRecord.pObj)
return;
- const SfxItemSet& rOldSet = pRecord->pObj->GetMergedItemSet();
+ const SfxItemSet& rOldSet = rRecord.pObj->GetMergedItemSet();
// contrast
if (WW8ITEMVALUE(rOldSet, SDRATTR_GRAFCONTRAST,
SdrGrafContrastItem))
@@ -2223,24 +2268,18 @@ bool SwWW8ImplReader::MiserableRTLGraphicsHack(SwTwips &rLeft, SwTwips nWidth,
m_aSectionManager.GetPageWidth());
}
-RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec* pRecord,
- WW8_FSPA *pFSPA, SfxItemSet &rFlySet)
+RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec& rRecord, WW8_FSPA& rFSPA,
+ SfxItemSet &rFlySet)
{
- OSL_ENSURE(pRecord || pFSPA, "give me something! to work with for anchoring");
- if (!pRecord && !pFSPA)
- return RndStdIds::FLY_AT_PAGE;
bool bCurSectionVertical = m_aSectionManager.CurrentSectionIsVertical();
- SvxMSDffImportRec aRecordFromFSPA;
- if (!pRecord)
- pRecord = &aRecordFromFSPA;
- if (!(pRecord->nXRelTo) && pFSPA)
+ if (!rRecord.nXRelTo)
{
- pRecord->nXRelTo = sal_Int32(pFSPA->nbx);
+ rRecord.nXRelTo = sal_Int32(rFSPA.nbx);
}
- if (!(pRecord->nYRelTo) && pFSPA)
+ if (!rRecord.nYRelTo)
{
- pRecord->nYRelTo = sal_Int32(pFSPA->nby);
+ rRecord.nYRelTo = sal_Int32(rFSPA.nby);
}
// nXAlign - abs. Position, Left, Centered, Right, Inside, Outside
@@ -2254,29 +2293,22 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec* pRecord,
const sal_uInt32 nCntRelTo = 4;
- sal_uInt32 nXAlign = nCntXAlign > pRecord->nXAlign ? pRecord->nXAlign : 1;
- sal_uInt32 nYAlign = nCntYAlign > pRecord->nYAlign ? pRecord->nYAlign : 1;
+ sal_uInt32 nXAlign = nCntXAlign > rRecord.nXAlign ? rRecord.nXAlign : 1;
+ sal_uInt32 nYAlign = nCntYAlign > rRecord.nYAlign ? rRecord.nYAlign : 1;
- if (pFSPA)
- {
- // #i52565# - try to handle special case for objects in tables regarding its X Rel
+ // #i52565# - try to handle special case for objects in tables regarding its X Rel
- // if X and Y Rel values are on default take it as a hint, that they have not been set
- // by <SwMSDffManager::ProcessObj(..)>
- const bool bXYRelHaveDefaultValues = *pRecord->nXRelTo == 2 && *pRecord->nYRelTo == 2;
- if ( bXYRelHaveDefaultValues
- && m_nInTable > 0
- && !bCurSectionVertical )
- {
- if ( sal_uInt32(pFSPA->nby) != pRecord->nYRelTo )
- {
- pRecord->nYRelTo = sal_uInt32(pFSPA->nby);
- }
- }
+ // if X and Y Rel values are on default take it as a hint, that they have not been set
+ // by <SwMSDffManager::ProcessObj(..)>
+ const bool bXYRelHaveDefaultValues = *rRecord.nXRelTo == 2 && *rRecord.nYRelTo == 2;
+ if (bXYRelHaveDefaultValues && m_nInTable > 0 && !bCurSectionVertical)
+ {
+ if (sal_uInt32(rFSPA.nby) != rRecord.nYRelTo)
+ rRecord.nYRelTo = sal_uInt32(rFSPA.nby);
}
- sal_uInt32 nXRelTo = (pRecord->nXRelTo && nCntRelTo > pRecord->nXRelTo) ? *pRecord->nXRelTo : 1;
- sal_uInt32 nYRelTo = (pRecord->nYRelTo && nCntRelTo > pRecord->nYRelTo) ? *pRecord->nYRelTo : 1;
+ sal_uInt32 nXRelTo = (rRecord.nXRelTo && nCntRelTo > rRecord.nXRelTo) ? *rRecord.nXRelTo : 1;
+ sal_uInt32 nYRelTo = (rRecord.nYRelTo && nCntRelTo > rRecord.nYRelTo) ? *rRecord.nYRelTo : 1;
RndStdIds eAnchor = IsInlineEscherHack() ? RndStdIds::FLY_AS_CHAR : RndStdIds::FLY_AT_CHAR; // #i43718#
@@ -2284,163 +2316,170 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec* pRecord,
aAnchor.SetAnchor( m_pPaM->GetPoint() );
rFlySet.Put( aAnchor );
- if (pFSPA)
+ // #i18732#
+ // Given new layout where everything is changed to be anchored to
+ // character the following 4 tables may need to be changed.
+
+ // horizontal Adjustment
+ static const sal_Int16 aHoriOriTab[ nCntXAlign ] =
+ {
+ text::HoriOrientation::NONE, // From left position
+ text::HoriOrientation::LEFT, // left
+ text::HoriOrientation::CENTER, // centered
+ text::HoriOrientation::RIGHT, // right
+ // #i36649#
+ // - inside -> text::HoriOrientation::LEFT and outside -> text::HoriOrientation::RIGHT
+ text::HoriOrientation::LEFT, // inside
+ text::HoriOrientation::RIGHT // outside
+ };
+
+ // generic vertical Adjustment
+ static const sal_Int16 aVertOriTab[ nCntYAlign ] =
{
- // #i18732#
- // Given new layout where everything is changed to be anchored to
- // character the following 4 tables may need to be changed.
+ text::VertOrientation::NONE, // From Top position
+ text::VertOrientation::TOP, // top
+ text::VertOrientation::CENTER, // centered
+ text::VertOrientation::BOTTOM, // bottom
+ text::VertOrientation::LINE_TOP, // inside (obscure)
+ text::VertOrientation::LINE_BOTTOM // outside (obscure)
+ };
- // horizontal Adjustment
- static const sal_Int16 aHoriOriTab[ nCntXAlign ] =
- {
- text::HoriOrientation::NONE, // From left position
- text::HoriOrientation::LEFT, // left
- text::HoriOrientation::CENTER, // centered
- text::HoriOrientation::RIGHT, // right
- // #i36649#
- // - inside -> text::HoriOrientation::LEFT and outside -> text::HoriOrientation::RIGHT
- text::HoriOrientation::LEFT, // inside
- text::HoriOrientation::RIGHT // outside
- };
-
- // generic vertical Adjustment
- static const sal_Int16 aVertOriTab[ nCntYAlign ] =
- {
- text::VertOrientation::NONE, // From Top position
- text::VertOrientation::TOP, // top
- text::VertOrientation::CENTER, // centered
- text::VertOrientation::BOTTOM, // bottom
- text::VertOrientation::LINE_TOP, // inside (obscure)
- text::VertOrientation::LINE_BOTTOM // outside (obscure)
- };
-
- // #i22673# - to-line vertical alignment
- static const sal_Int16 aToLineVertOriTab[ nCntYAlign ] =
- {
- text::VertOrientation::NONE, // below
- text::VertOrientation::LINE_BOTTOM, // top
- text::VertOrientation::LINE_CENTER, // centered
- text::VertOrientation::LINE_TOP, // bottom
- text::VertOrientation::LINE_BOTTOM, // inside (obscure)
- text::VertOrientation::LINE_TOP // outside (obscure)
- };
-
- // Adjustment is horizontally relative to...
- static const sal_Int16 aHoriRelOriTab[nCntRelTo] =
- {
- text::RelOrientation::PAGE_PRINT_AREA, // 0 is page textarea margin
- text::RelOrientation::PAGE_FRAME, // 1 is page margin
- text::RelOrientation::FRAME, // 2 is relative to column
- text::RelOrientation::CHAR // 3 is relative to character
- };
-
- // Adjustment is vertically relative to...
- // #i22673# - adjustment for new vertical alignment at top of line.
- static const sal_Int16 aVertRelOriTab[nCntRelTo] =
- {
- text::RelOrientation::PAGE_PRINT_AREA, // 0 is page textarea margin
- text::RelOrientation::PAGE_FRAME, // 1 is page margin
- text::RelOrientation::FRAME, // 2 is relative to paragraph
- text::RelOrientation::TEXT_LINE // 3 is relative to line
- };
+ // #i22673# - to-line vertical alignment
+ static const sal_Int16 aToLineVertOriTab[ nCntYAlign ] =
+ {
+ text::VertOrientation::NONE, // below
+ text::VertOrientation::LINE_BOTTOM, // top
+ text::VertOrientation::LINE_CENTER, // centered
+ text::VertOrientation::LINE_TOP, // bottom
+ text::VertOrientation::LINE_BOTTOM, // inside (obscure)
+ text::VertOrientation::LINE_TOP // outside (obscure)
+ };
- sal_Int16 eHoriOri = aHoriOriTab[ nXAlign ];
- sal_Int16 eHoriRel = aHoriRelOriTab[ nXRelTo ];
+ // Adjustment is horizontally relative to...
+ static const sal_Int16 aHoriRelOriTab[nCntRelTo] =
+ {
+ text::RelOrientation::PAGE_PRINT_AREA, // 0 is page textarea margin
+ text::RelOrientation::PAGE_FRAME, // 1 is page margin
+ text::RelOrientation::FRAME, // 2 is relative to column
+ text::RelOrientation::CHAR // 3 is relative to character
+ };
- // #i36649# - adjustments for certain alignments
- if ( eHoriOri == text::HoriOrientation::LEFT && eHoriRel == text::RelOrientation::PAGE_FRAME )
- {
- // convert 'left to page' to 'from left -<width> to page text area'
- eHoriOri = text::HoriOrientation::NONE;
- eHoriRel = text::RelOrientation::PAGE_PRINT_AREA;
- const tools::Long nWidth = pFSPA->nXaRight - pFSPA->nXaLeft;
- pFSPA->nXaLeft = -nWidth;
- pFSPA->nXaRight = 0;
- }
- else if ( eHoriOri == text::HoriOrientation::RIGHT && eHoriRel == text::RelOrientation::PAGE_FRAME )
- {
- // convert 'right to page' to 'from left 0 to right page border'
- eHoriOri = text::HoriOrientation::NONE;
- eHoriRel = text::RelOrientation::PAGE_RIGHT;
- const tools::Long nWidth = pFSPA->nXaRight - pFSPA->nXaLeft;
- pFSPA->nXaLeft = 0;
- pFSPA->nXaRight = nWidth;
- }
+ // Adjustment is vertically relative to...
+ // #i22673# - adjustment for new vertical alignment at top of line.
+ static const sal_Int16 aVertRelOriTab[nCntRelTo] =
+ {
+ text::RelOrientation::PAGE_PRINT_AREA, // 0 is page textarea margin
+ text::RelOrientation::PAGE_FRAME, // 1 is page margin
+ text::RelOrientation::FRAME, // 2 is relative to paragraph
+ text::RelOrientation::TEXT_LINE // 3 is relative to line
+ };
- // #i24255# - position of floating screen objects in
- // R2L layout are given in L2R layout, thus convert them of all
- // floating screen objects, which are imported.
- {
- // Miserable miserable hack.
- SwTwips nWidth = o3tl::saturating_sub(pFSPA->nXaRight, pFSPA->nXaLeft);
- SwTwips nLeft = pFSPA->nXaLeft;
- if (MiserableRTLGraphicsHack(nLeft, nWidth, eHoriOri,
- eHoriRel))
- {
- pFSPA->nXaLeft = nLeft;
- pFSPA->nXaRight = pFSPA->nXaLeft + nWidth;
- }
- }
+ // 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];
- // if the object is anchored inside a table cell, is horizontal aligned
- // at frame|character and has wrap through, but its attribute
- // 'layout in table cell' isn't set, convert its horizontal alignment to page text area.
- // #i84783# - use new method <IsObjectLayoutInTableCell()>
- if ( m_nInTable &&
- ( eHoriRel == text::RelOrientation::FRAME || eHoriRel == text::RelOrientation::CHAR ) &&
- pFSPA->nwr == 3 &&
- !IsObjectLayoutInTableCell( pRecord->nLayoutInTableCell ) )
- {
- eHoriRel = text::RelOrientation::PAGE_PRINT_AREA;
- }
+ // #i36649# - adjustments for certain alignments
+ if (eHoriOri == text::HoriOrientation::LEFT && eHoriRel == text::RelOrientation::PAGE_FRAME)
+ {
+ // convert 'left to page' to 'from left -<width> to page text area'
+ eHoriOri = text::HoriOrientation::NONE;
+ eHoriRel = text::RelOrientation::PAGE_PRINT_AREA;
+ const tools::Long nWidth = rFSPA.nXaRight - rFSPA.nXaLeft;
+ rFSPA.nXaLeft = -nWidth;
+ rFSPA.nXaRight = 0;
+ }
+ else if (eHoriOri == text::HoriOrientation::RIGHT && eHoriRel == text::RelOrientation::PAGE_FRAME)
+ {
+ // convert 'right to page' to 'from left 0 to right page border'
+ eHoriOri = text::HoriOrientation::NONE;
+ eHoriRel = text::RelOrientation::PAGE_RIGHT;
+ const tools::Long nWidth = rFSPA.nXaRight - rFSPA.nXaLeft;
+ 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;
+ }
- // Writer honours this wrap distance when aligned as "left" or "right",
- // Word doesn't. Writer doesn't honour it when its "from left".
- if (eHoriOri == text::HoriOrientation::LEFT)
- pRecord->nDxWrapDistLeft=0;
- else if (eHoriOri == text::HoriOrientation::RIGHT)
- pRecord->nDxWrapDistRight=0;
-
- sal_Int16 eVertRel;
-
- eVertRel = aVertRelOriTab[ nYRelTo ]; // #i18732#
- if ( bCurSectionVertical && nYRelTo == 2 )
- eVertRel = text::RelOrientation::PAGE_PRINT_AREA;
- // #i22673# - fill <eVertOri> in dependence of <eVertRel>
- sal_Int16 eVertOri;
- if ( eVertRel == text::RelOrientation::TEXT_LINE )
- {
- eVertOri = aToLineVertOriTab[ nYAlign ];
- }
- else
+ // #i24255# - position of floating screen objects in
+ // R2L layout are given in L2R layout, thus convert them of all
+ // floating screen objects, which are imported.
+ {
+ // Miserable miserable hack.
+ SwTwips nWidth = o3tl::saturating_sub(rFSPA.nXaRight, rFSPA.nXaLeft);
+ SwTwips nLeft = rFSPA.nXaLeft;
+ if (MiserableRTLGraphicsHack(nLeft, nWidth, eHoriOri,
+ eHoriRel))
{
- eVertOri = aVertOriTab[ nYAlign ];
+ rFSPA.nXaLeft = nLeft;
+ rFSPA.nXaRight = rFSPA.nXaLeft + nWidth;
}
+ }
+
+ // if the object is anchored inside a table cell, is horizontal aligned
+ // at frame|character and has wrap through, but its attribute
+ // 'layout in table cell' isn't set, convert its horizontal alignment to page text area.
+ // #i84783# - use new method <IsObjectLayoutInTableCell()>
+ if (m_nInTable &&
+ (eHoriRel == text::RelOrientation::FRAME || eHoriRel == text::RelOrientation::CHAR) &&
+ rFSPA.nwr == 3 &&
+ !IsObjectLayoutInTableCell(rRecord.nGroupShapeBooleanProperties))
+ {
+ eHoriRel = text::RelOrientation::PAGE_PRINT_AREA;
+ }
- // Below line in word is a positive value, while in writer its
- // negative
- tools::Long nYPos = pFSPA->nYaTop;
- // #i22673#
- if ((eVertRel == text::RelOrientation::TEXT_LINE) && (eVertOri == text::VertOrientation::NONE))
- nYPos = -nYPos;
+ // Writer honours this wrap distance when aligned as "left" or "right",
+ // Word doesn't. Writer doesn't honour it when its "from left".
+ if (eHoriOri == text::HoriOrientation::LEFT)
+ rRecord.nDxWrapDistLeft = 0;
+ else if (eHoriOri == text::HoriOrientation::RIGHT)
+ rRecord.nDxWrapDistRight = 0;
- SwFormatHoriOrient aHoriOri(MakeSafePositioningValue( bCurSectionVertical ? nYPos : pFSPA->nXaLeft ),
- bCurSectionVertical ? eVertOri : eHoriOri,
- bCurSectionVertical ? eVertRel : eHoriRel);
- if( 4 <= nXAlign )
- aHoriOri.SetPosToggle(true);
- rFlySet.Put( aHoriOri );
+ sal_Int16 eVertRel;
- rFlySet.Put(SwFormatVertOrient(MakeSafePositioningValue( !bCurSectionVertical ? nYPos : -pFSPA->nXaRight ),
- !bCurSectionVertical ? eVertOri : eHoriOri,
- !bCurSectionVertical ? eVertRel : eHoriRel ));
+ eVertRel = aVertRelOriTab[ nYRelTo ]; // #i18732#
+ if (bCurSectionVertical && nYRelTo == 2)
+ eVertRel = text::RelOrientation::PAGE_PRINT_AREA;
+ // #i22673# - fill <eVertOri> in dependence of <eVertRel>
+ sal_Int16 eVertOri;
+ if (eVertRel == text::RelOrientation::TEXT_LINE)
+ {
+ eVertOri = aToLineVertOriTab[ nYAlign ];
+ }
+ else
+ {
+ eVertOri = aVertOriTab[ nYAlign ];
}
+ // Below line in word is a positive value, while in writer its
+ // negative
+ tools::Long nYPos = rFSPA.nYaTop;
+ // #i22673#
+ if ((eVertRel == text::RelOrientation::TEXT_LINE) && (eVertOri == text::VertOrientation::NONE))
+ nYPos = -nYPos;
+
+ SwFormatHoriOrient aHoriOri(MakeSafePositioningValue(bCurSectionVertical ? nYPos : rFSPA.nXaLeft),
+ bCurSectionVertical ? eVertOri : eHoriOri,
+ bCurSectionVertical ? eVertRel : eHoriRel);
+ if (4 <= nXAlign)
+ aHoriOri.SetPosToggle(true);
+ rFlySet.Put(aHoriOri);
+
+ rFlySet.Put(SwFormatVertOrient(MakeSafePositioningValue(!bCurSectionVertical ? nYPos : -rFSPA.nXaRight),
+ !bCurSectionVertical ? eVertOri : eHoriOri,
+ !bCurSectionVertical ? eVertRel : eHoriRel));
+
return eAnchor;
}
// #i84783#
-bool SwWW8ImplReader::IsObjectLayoutInTableCell( const sal_uInt32 nLayoutInTableCell ) const
+bool SwWW8ImplReader::IsObjectLayoutInTableCell(const sal_uInt32 nGroupShapeBooleanProperties) const
{
bool bIsObjectLayoutInTableCell = false;
@@ -2462,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;
@@ -2473,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:
@@ -2512,7 +2539,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
m_nDrawCpO = 0;
m_bDrawCpOValid = m_xWwFib->GetBaseCp(m_xPlcxMan->GetManType() == MAN_HDFT ? MAN_TXBX_HDFT : MAN_TXBX, &m_nDrawCpO);
- GrafikCtor();
+ GraphicCtor();
WW8PLCFspecial* pPF = m_xPlcxMan->GetFdoa();
if( !pPF )
@@ -2523,10 +2550,10 @@ 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 );
+ ReadGrafLayer1(*pPF, nGrafAnchorCp);
m_pStrm->Seek( nOldPos );
return nullptr;
@@ -2537,17 +2564,16 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
WW8_FC nStartFc;
void* pF0;
- if( !pPF->Get( nStartFc, pF0 ) ){
+ if (!pPF->Get(nStartFc, pF0))
+ {
OSL_ENSURE( false, "+Where is the graphic (2) ?" );
return nullptr;
}
- WW8_FSPA_SHADOW* pFS = static_cast<WW8_FSPA_SHADOW*>(pF0);
- WW8_FSPA* pF;
+ WW8_FSPA_SHADOW& rFS = *static_cast<WW8_FSPA_SHADOW*>(pF0);
WW8_FSPA aFSFA;
- pF = &aFSFA;
- WW8FSPAShadowToReal( pFS, pF );
- if( !pF->nSpId )
+ WW8FSPAShadowToReal(rFS, aFSFA);
+ if (!aFSFA.nSpId)
{
OSL_ENSURE( false, "+Where is the graphic (3) ?" );
return nullptr;
@@ -2556,21 +2582,11 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
if (!m_xMSDffManager->GetModel())
m_xMSDffManager->SetModel(m_pDrawModel, 1440);
- tools::Rectangle aRect(pF->nXaLeft, pF->nYaTop, pF->nXaRight, pF->nYaBottom);
+ 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;
- bool bOk = (m_xMSDffManager->GetShape(pF->nSpId, pObject, aData) && pObject);
-
- m_rDoc.SetDocShell(pPersist); // #i20540# Persist guard
+ rtl::Reference<SdrObject> pObject;
+ bool bOk = (m_xMSDffManager->GetShape(aFSFA.nSpId, pObject, aData) && pObject);
if (!bOk)
{
@@ -2583,23 +2599,23 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
if (pObject->GetRotateAngle())
{
tools::Rectangle aObjSnapRect(pObject->GetSnapRect()); // recalculates the SnapRect
- pF->nXaLeft = aObjSnapRect.Left();
- pF->nYaTop = aObjSnapRect.Top();
- pF->nXaRight = aObjSnapRect.Right();
- pF->nYaBottom = aObjSnapRect.Bottom();
+ aFSFA.nXaLeft = aObjSnapRect.Left();
+ aFSFA.nYaTop = aObjSnapRect.Top();
+ aFSFA.nXaRight = aObjSnapRect.Right();
+ aFSFA.nYaBottom = aObjSnapRect.Bottom();
}
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:
@@ -2610,11 +2626,11 @@ 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;
- switch (pF->nwr)
+ switch (aFSFA.nwr)
{
case 0: // 0 like 2, but doesn't require absolute object
case 2: // 2 wrap around absolute object
@@ -2624,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
@@ -2634,9 +2654,9 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
}
// if mode 2 or 4 also regard the additional parameters
- if ( (2 == pF->nwr) || (4 == pF->nwr) )
+ if ((2 == aFSFA.nwr) || (4 == aFSFA.nwr))
{
- switch( pF->nwrk )
+ switch (aFSFA.nwrk)
{
// 0 wrap both sides
case 0:
@@ -2674,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
@@ -2700,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;
}
@@ -2717,7 +2733,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
&& pData->GetId() == SW_UD_IMAPDATA)
{
SwMacroInfo* macInf = dynamic_cast<SwMacroInfo*>(pData);
- if( macInf && macInf->GetShapeId() == pF->nSpId )
+ if (macInf && macInf->GetShapeId() == aFSFA.nSpId)
{
lnName = macInf->GetHlink();
aObjName = macInf->GetName();
@@ -2726,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
@@ -2742,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 ||
- ( ( m_bIsHeader || m_bIsFooter ) && pF->nwr == 3 );
- if ( bMoveToBackgrd )
+ const bool bMoveToBackground = pRecord->bDrawHell ||
+ ((m_bIsHeader || m_bIsFooter) && aFSFA.nwr == 3);
+ if ( bMoveToBackground )
aFlySet.Put(SvxOpaqueItem(RES_OPAQUE,false));
OUString aObjName = pObject->GetName();
@@ -2756,27 +2772,26 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
if (bReplaceable)
{
// Single graphics or ole objects
- pRetFrameFormat = ImportReplaceableDrawables(pObject, pOurNewObject, pRecord,
- pF, aFlySet);
+ pRetFrameFormat = ImportReplaceableDrawables(pObject, pOurNewObject, *pRecord, aFSFA, aFlySet);
}
else
{
bDrawObj = true;
// Drawing objects, (e.g. ovals or drawing groups)
- if (pF->bRcaSimple)
+ if (aFSFA.bRcaSimple)
{
- pF->nbx = WW8_FSPA::RelPageBorder;
- pF->nby = WW8_FSPA::RelPageBorder;
+ aFSFA.nbx = WW8_FSPA::RelPageBorder;
+ aFSFA.nby = WW8_FSPA::RelPageBorder;
}
- RndStdIds eAnchor = ProcessEscherAlign(pRecord, pF, aFlySet);
+ RndStdIds eAnchor = ProcessEscherAlign(*pRecord, aFSFA, aFlySet);
// Should we, and is it possible to make this into a writer textbox
if ((!(m_nIniFlags1 & WW8FL_NO_FLY_FOR_TXBX)) && pRecord->bReplaceByFly)
{
- pRetFrameFormat = ConvertDrawTextToFly(pObject, pOurNewObject, pRecord,
- eAnchor, pF, aFlySet);
+ pRetFrameFormat
+ = ConvertDrawTextToFly(pObject, pOurNewObject, *pRecord, eAnchor, aFSFA, aFlySet);
if (pRetFrameFormat)
{
bDone = true;
@@ -2788,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);
@@ -2797,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, pF->nSpId,
- m_bIsHeader || m_bIsFooter );
+ 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 );
@@ -2819,7 +2834,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
if (pRecord->pObj && pRecord->aTextId.nTxBxS)
{ // #i52825# pRetFrameFormat can be NULL
pRetFrameFormat = MungeTextIntoDrawBox(
- pRecord, nGrafAnchorCp, pRetFrameFormat);
+ *pRecord, nGrafAnchorCp, pRetFrameFormat);
}
}
}
@@ -2829,20 +2844,20 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
// #i44344#, #i44681# - positioning attributes already set
if (pDrawFrameFormat)
pDrawFrameFormat->PosAttrSet();
- if (!IsInlineEscherHack())
- MapWrapIntoFlyFormat(pRecord, pRetFrameFormat);
+ if (!IsInlineEscherHack() && pRetFrameFormat)
+ MapWrapIntoFlyFormat(*pRecord, *pRetFrameFormat);
// Set frame name with object name
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);
@@ -2863,21 +2878,21 @@ SwFrameFormat *SwWW8ImplReader::AddAutoAnchor(SwFrameFormat *pFormat)
return pFormat;
}
-SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec *pRecord,
+SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
tools::Long nGrafAnchorCp, SwFrameFormat* pRetFrameFormat)
{
- SdrObject* pTrueObject = pRecord->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*>( pRecord->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());
@@ -2888,10 +2903,10 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec *pRecord,
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*>( pRecord->pObj );
+ pSdrTextObj = DynCastSdrTextObj(rRecord.pObj.get());
if( pSdrTextObj )
{
@@ -2903,35 +2918,33 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec *pRecord,
const size_t nOrdNum = pSdrTextObj->GetOrdNum();
bool bEraseThisObject;
- InsertTxbxText( pSdrTextObj, &aObjSize, pRecord->aTextId.nTxBxS,
- pRecord->aTextId.nSequence, nGrafAnchorCp, pRetFrameFormat,
- (pSdrTextObj != pTrueObject) || (nullptr != pGroupObject),
- bEraseThisObject, nullptr, nullptr, nullptr, nullptr, pRecord);
+ InsertTxbxText(pSdrTextObj.get(), &aObjSize, rRecord.aTextId.nTxBxS, rRecord.aTextId.nSequence,
+ nGrafAnchorCp, pRetFrameFormat,
+ (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( pRecord->pObj );
+ m_xMSDffManager->ExchangeInShapeOrder(pSdrTextObj.get(), 0, pNewObj);
// and save the new object.
- pRecord->pObj = pNewObj;
+ rRecord.pObj = pNewObj;
}
}
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() );
@@ -2940,27 +2953,29 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec *pRecord,
m_rDoc.DelFrameFormat( pRetFrameFormat );
pRetFrameFormat = nullptr;
// also delete the object record
- pRecord->pObj = nullptr;
+ rRecord.pObj = nullptr;
}
}
else
{
// use ww8-default border distance
- SfxItemSet aItemSet(m_pDrawModel->GetItemPool(),
- svl::Items<SDRATTR_TEXT_LEFTDIST, SDRATTR_TEXT_LOWERDIST>{});
- aItemSet.Put( makeSdrTextLeftDistItem( pRecord->nDxTextLeft ) );
- aItemSet.Put( makeSdrTextRightDistItem( pRecord->nDxTextRight ) );
- aItemSet.Put( makeSdrTextUpperDistItem( pRecord->nDyTextTop ) );
- aItemSet.Put( makeSdrTextLowerDistItem( pRecord->nDyTextBottom ) );
+ 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));
+ aItemSet.Put(makeSdrTextLowerDistItem(rRecord.nDyTextBottom));
pSdrTextObj->SetMergedItemSetAndBroadcast(aItemSet);
}
}
return pRetFrameFormat;
}
-SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject* &rpObject,
- SdrObject* &rpOurNewObject, SvxMSDffImportRec const * pRecord, RndStdIds eAnchor,
- WW8_FSPA const *pF, SfxItemSet &rFlySet)
+SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(rtl::Reference<SdrObject>& rpObject,
+ rtl::Reference<SdrObject>& rpOurNewObject,
+ const SvxMSDffImportRec& rRecord,
+ RndStdIds eAnchor, const WW8_FSPA& rF,
+ SfxItemSet &rFlySet)
{
SwFlyFrameFormat* pRetFrameFormat = nullptr;
tools::Long nStartCp;
@@ -2968,24 +2983,26 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject* &rpObject,
// Check if this textbox chain contains text as conversion of an empty
// chain would not make sense.
- if ( TxbxChainContainsRealText(pRecord->aTextId.nTxBxS,nStartCp,nEndCp) )
+ if (TxbxChainContainsRealText(rRecord.aTextId.nTxBxS, nStartCp, nEndCp))
{
// The Text is not read into SdrTextObj! Rather insert a frame and
// insert the text from nStartCp to nEndCp.
// More attributes can be used in a frame compared to the
// Edit-Engine, and it can contain field, OLEs or graphics...
- tools::Rectangle aInnerDist(pRecord->nDxTextLeft, pRecord->nDyTextTop,
- pRecord->nDxTextRight, pRecord->nDyTextBottom);
+ tools::Rectangle aInnerDist(rRecord.nDxTextLeft, rRecord.nDyTextTop, rRecord.nDxTextRight,
+ rRecord.nDyTextBottom);
- SwFormatFrameSize aFrameSize(SwFrameSize::Fixed, pF->nXaRight - pF->nXaLeft, pF->nYaBottom - pF->nYaTop);
- aFrameSize.SetWidthSizeType(pRecord->bAutoWidth ? SwFrameSize::Variable : SwFrameSize::Fixed);
+ SwFormatFrameSize aFrameSize(SwFrameSize::Fixed, rF.nXaRight - rF.nXaLeft,
+ rF.nYaBottom - rF.nYaTop);
+ aFrameSize.SetWidthSizeType(rRecord.bAutoWidth ? SwFrameSize::Variable
+ : SwFrameSize::Fixed);
rFlySet.Put(aFrameSize);
- MatchSdrItemsIntoFlySet( rpObject, rFlySet, pRecord->eLineStyle,
- pRecord->eLineDashing, pRecord->eShapeType, aInnerDist );
+ 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));
@@ -2998,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!
*/
@@ -3019,29 +3036,29 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject* &rpObject,
contact object, while a raw rpOutNewObject stored here becomes
deleted and useless.
*/
- m_xMSDffManager->StoreShapeOrder(pF->nSpId,
- (static_cast<sal_uLong>(pRecord->aTextId.nTxBxS) << 16) +
- pRecord->aTextId.nSequence, nullptr, pRetFrameFormat);
+ m_xMSDffManager->StoreShapeOrder(rF.nSpId,
+ (static_cast<sal_uLong>(rRecord.aTextId.nTxBxS) << 16) +
+ rRecord.aTextId.nSequence, nullptr, pRetFrameFormat);
// The Contact object has to be inserted into the draw page, so
// SwWW8ImplReader::LoadDoc1() can determine the z-order.
if (!rpOurNewObject->IsInserted())
{
// pass information, if object is in page header|footer to method.
- m_xWWZOrder->InsertEscherObject( rpOurNewObject, pF->nSpId,
- m_bIsHeader || m_bIsFooter );
+ m_xWWZOrder->InsertEscherObject(rpOurNewObject.get(), rF.nSpId, rRecord.bDrawHell,
+ m_bIsHeader || m_bIsFooter);
}
}
// Box-0 receives the text for the whole chain!
- if( !pRecord->aTextId.nSequence )
+ if (!rRecord.aTextId.nSequence)
{
// save flags etc and reset them
WW8ReaderSave aSave( this );
MoveInsideFly(pRetFrameFormat);
- m_xWWZOrder->InsideEscher(pF->nSpId);
+ m_xWWZOrder->InsideEscher(rF.nSpId);
// read in the text
m_bTxbxFlySection = true;
@@ -3062,8 +3079,7 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject* &rpObject,
return pRetFrameFormat;
}
-void MatchEscherMirrorIntoFlySet(const SvxMSDffImportRec &rRecord,
- SfxItemSet &rFlySet)
+void MatchEscherMirrorIntoFlySet(const SvxMSDffImportRec &rRecord, SfxItemSet &rFlySet)
{
if (rRecord.bVFlip || rRecord.bHFlip)
{
@@ -3078,42 +3094,41 @@ void MatchEscherMirrorIntoFlySet(const SvxMSDffImportRec &rRecord,
}
}
-SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables( SdrObject* &rpObject,
- SdrObject* &rpOurNewObject, SvxMSDffImportRec* pRecord, WW8_FSPA *pF,
- SfxItemSet &rFlySet )
+SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(rtl::Reference<SdrObject> &rpObject,
+ rtl::Reference<SdrObject> &rpOurNewObject,
+ SvxMSDffImportRec& rRecord,
+ WW8_FSPA& rF,
+ SfxItemSet &rFlySet )
{
SwFlyFrameFormat* pRetFrameFormat = nullptr;
- sal_Int32 nWidthTw = o3tl::saturating_sub(pF->nXaRight, pF->nXaLeft);
+ sal_Int32 nWidthTw = o3tl::saturating_sub(rF.nXaRight, rF.nXaLeft);
if (0 > nWidthTw)
nWidthTw = 0;
- sal_Int32 nHeightTw = o3tl::saturating_sub(pF->nYaBottom, pF->nYaTop);
+ sal_Int32 nHeightTw = o3tl::saturating_sub(rF.nYaBottom, rF.nYaTop);
if (0 > nHeightTw)
nHeightTw = 0;
- ProcessEscherAlign(pRecord, pF, rFlySet);
+ ProcessEscherAlign(rRecord, rF, rFlySet);
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());
- if (pRecord)
- {
- // 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);
+ // 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, pRecord->eLineStyle,
- pRecord->eLineDashing, pRecord->eShapeType, aInnerDist);
+ MatchSdrItemsIntoFlySet(rpObject.get(), rFlySet, rRecord.eLineStyle, rRecord.eLineDashing,
+ rRecord.eShapeType, aInnerDist);
- MatchEscherMirrorIntoFlySet(*pRecord, aGrSet);
- }
+ 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())
{
@@ -3144,11 +3159,8 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables( SdrObject* &rpObj
if (pRetFrameFormat)
{
- if( pRecord )
- {
- if( OBJ_OLE2 != rpObject->GetObjIdentifier() )
- SetAttributesAtGrfNode( pRecord, pRetFrameFormat, pF );
- }
+ if (SdrObjKind::OLE2 != rpObject->GetObjIdentifier())
+ SetAttributesAtGrfNode(rRecord, *pRetFrameFormat, &rF);
// avoid multiple occurrences of the same graphic name
m_aGrfNameGenerator.SetUniqueGraphName(pRetFrameFormat, aObjectName);
}
@@ -3157,13 +3169,14 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables( SdrObject* &rpObj
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!
*/
@@ -3172,21 +3185,21 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables( SdrObject* &rpObj
if (rpOurNewObject)
{
if (!m_bHdFtFootnoteEdn)
- m_xMSDffManager->StoreShapeOrder(pF->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, pF->nSpId,
- m_bIsHeader || m_bIsFooter );
+ m_xWWZOrder->InsertEscherObject(rpOurNewObject.get(), rF.nSpId, rRecord.bDrawHell,
+ m_bIsHeader || m_bIsFooter);
}
}
return pRetFrameFormat;
}
-void SwWW8ImplReader::GrafikCtor() // For SVDraw and VCControls and Escher
+void SwWW8ImplReader::GraphicCtor() // For SVDraw and VCControls and Escher
{
if (m_pDrawModel)
return;
@@ -3208,7 +3221,7 @@ void SwWW8ImplReader::GrafikCtor() // For SVDraw and VCControls and Escher
m_xMSDffManager->GetShapeOrders()));
}
-void SwWW8ImplReader::GrafikDtor()
+void SwWW8ImplReader::GraphicDtor()
{
m_pDrawEditEngine.reset(); // maybe created by graphic
m_xWWZOrder.reset(); // same
diff --git a/sw/source/filter/ww8/ww8graf.hxx b/sw/source/filter/ww8/ww8graf.hxx
index 3b05c53d2c5d..92f302545f48 100644
--- a/sw/source/filter/ww8/ww8graf.hxx
+++ b/sw/source/filter/ww8/ww8graf.hxx
@@ -33,12 +33,14 @@ struct EscherShape
{
sal_uLong mnEscherShapeOrder;
sal_uLong mnNoInlines;
- // new member <mbInHeaderFooter>
+ bool mbInHellLayer;
bool mbInHeaderFooter;
EscherShape( sal_uLong nEscherShapeOrder,
+ bool bInHellLayer,
bool _bInHeaderFooter )
: mnEscherShapeOrder(nEscherShapeOrder),
mnNoInlines(0),
+ mbInHellLayer(bInHellLayer),
mbInHeaderFooter( _bInHeaderFooter )
{}
};
@@ -71,6 +73,7 @@ private:
// new parameter <_bInHeaderFooter>, indicating
// that object is in header or footer
sal_uLong GetEscherObjectPos( sal_uLong nSpId,
+ const bool bInHellLayer,
const bool _bInHeaderFooter );
sal_uLong GetDrawingObjectPos(short nWwHeight);
void InsertObject(SdrObject *pObject, sal_uLong nPos);
@@ -86,12 +89,13 @@ public:
// new parameter <_bInHeaderFooter>, indicating that object is in header or footer
void InsertEscherObject( SdrObject* pObject,
sal_uLong nSpId,
+ const bool bInHellLayer,
const bool _bInHeaderFooter );
void InsideEscher(sal_uLong nIndex);
void OutsideEscher();
};
-void WW8FSPAShadowToReal( WW8_FSPA_SHADOW const * pFSPAS, WW8_FSPA* pPic );
+void WW8FSPAShadowToReal(const WW8_FSPA_SHADOW& rFSPAS, WW8_FSPA& rPic);
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index 3cb16f6422b8..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>
@@ -69,9 +68,10 @@ void wwZOrderer::OutsideEscher()
// consider new parameter <_bInHeaderFooter>
void wwZOrderer::InsertEscherObject( SdrObject* pObject,
sal_uLong nSpId,
+ const bool bInHellLayer,
const bool _bInHeaderFooter )
{
- sal_uLong nInsertPos = GetEscherObjectPos( nSpId, _bInHeaderFooter );
+ sal_uLong nInsertPos = GetEscherObjectPos( nSpId, bInHellLayer, _bInHeaderFooter );
InsertObject(pObject, nInsertPos + mnNoInitialObjects + mnInlines);
}
@@ -100,6 +100,7 @@ sal_uInt16 wwZOrderer::GetEscherObjectIdx(sal_uLong nSpId)
// consider new parameter <_bInHeaderFooter>
sal_uLong wwZOrderer::GetEscherObjectPos( sal_uLong nSpId,
+ const bool bInHellLayer,
const bool _bInHeaderFooter )
{
/*
@@ -129,6 +130,16 @@ sal_uLong wwZOrderer::GetEscherObjectPos( sal_uLong nSpId,
++aIter;
}
}
+ if (!bInHellLayer)
+ {
+ while (aIter != aEnd)
+ {
+ if (!aIter->mbInHellLayer || (_bInHeaderFooter && !aIter->mbInHeaderFooter))
+ break;
+ nRet += aIter->mnNoInlines + 1;
+ ++aIter;
+ }
+ }
while (aIter != aEnd)
{
// insert object in page header|footer
@@ -137,12 +148,15 @@ sal_uLong wwZOrderer::GetEscherObjectPos( sal_uLong nSpId,
{
break;
}
+ if ( bInHellLayer && !aIter->mbInHellLayer )
+ break;
+
if ( aIter->mnEscherShapeOrder > nFound )
break;
nRet += aIter->mnNoInlines+1;
++aIter;
}
- maEscherLayer.insert(aIter, EscherShape( nFound, _bInHeaderFooter ) );
+ maEscherLayer.insert(aIter, EscherShape( nFound, bInHellLayer, _bInHeaderFooter ) );
return nRet;
}
@@ -218,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
@@ -243,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;
}
@@ -270,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
}
@@ -341,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);
@@ -401,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)
{
@@ -419,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
@@ -448,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();
}
}
@@ -467,7 +483,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
::SetProgressState(m_nProgress, m_pDocShell); // Update
- GrafikCtor();
+ GraphicCtor();
/*
* Little joke from Microsoft: sometimes a stream named DATA exists. This
@@ -476,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 )
{
@@ -510,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)
@@ -540,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;
@@ -595,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 );
@@ -606,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 )
{
@@ -639,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();
@@ -670,11 +682,11 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
if (pRet)
{
if (pRecord)
- SetAttributesAtGrfNode(pRecord, pRet, nullptr);
+ SetAttributesAtGrfNode(*pRecord, *pRet, nullptr);
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);
@@ -682,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())
@@ -745,25 +757,25 @@ void WW8PicShadowToReal( WW8_PIC_SHADOW const * pPicS, WW8_PIC * pPic )
pPic->bpp = pPicS->aBits2;
}
-void WW8FSPAShadowToReal( WW8_FSPA_SHADOW const * pFSPAS, WW8_FSPA * pFSPA )
+void WW8FSPAShadowToReal(const WW8_FSPA_SHADOW& rFSPAS, WW8_FSPA& rFSPA)
{
- pFSPA->nSpId = SVBT32ToUInt32( pFSPAS->nSpId );
- pFSPA->nXaLeft = SVBT32ToUInt32( pFSPAS->nXaLeft );
- pFSPA->nYaTop = SVBT32ToUInt32( pFSPAS->nYaTop );
- pFSPA->nXaRight = SVBT32ToUInt32( pFSPAS->nXaRight );
- pFSPA->nYaBottom = SVBT32ToUInt32( pFSPAS->nYaBottom );
-
- sal_uInt16 nBits = SVBT16ToUInt16( pFSPAS->aBits1 );
-
- pFSPA->bHdr = sal_uInt16(0 != ( nBits & 0x0001 ));
- pFSPA->nbx = ( nBits & 0x0006 ) >> 1;
- pFSPA->nby = ( nBits & 0x0018 ) >> 3;
- pFSPA->nwr = ( nBits & 0x01E0 ) >> 5;
- pFSPA->nwrk = ( nBits & 0x1E00 ) >> 9;
- pFSPA->bRcaSimple = sal_uInt16(0 != ( nBits & 0x2000 ));
- pFSPA->bBelowText = sal_uInt16(0 != ( nBits & 0x4000 ));
- pFSPA->bAnchorLock = sal_uInt16(0 != ( nBits & 0x8000 ));
- pFSPA->nTxbx = SVBT32ToUInt32( pFSPAS->nTxbx );
+ rFSPA.nSpId = SVBT32ToUInt32(rFSPAS.nSpId);
+ rFSPA.nXaLeft = SVBT32ToUInt32(rFSPAS.nXaLeft);
+ rFSPA.nYaTop = SVBT32ToUInt32(rFSPAS.nYaTop);
+ rFSPA.nXaRight = SVBT32ToUInt32(rFSPAS.nXaRight);
+ rFSPA.nYaBottom = SVBT32ToUInt32(rFSPAS.nYaBottom);
+
+ sal_uInt16 nBits = SVBT16ToUInt16(rFSPAS.aBits1);
+
+ rFSPA.bHdr = sal_uInt16(0 != (nBits & 0x0001));
+ rFSPA.nbx = (nBits & 0x0006) >> 1;
+ rFSPA.nby = (nBits & 0x0018) >> 3;
+ rFSPA.nwr = (nBits & 0x01E0) >> 5;
+ rFSPA.nwrk = (nBits & 0x1E00) >> 9;
+ rFSPA.bRcaSimple = sal_uInt16(0 != (nBits & 0x2000));
+ rFSPA.bBelowText = sal_uInt16(0 != (nBits & 0x4000));
+ rFSPA.bAnchorLock = sal_uInt16(0 != (nBits & 0x8000));
+ rFSPA.nTxbx = SVBT32ToUInt32(rFSPAS.nTxbx);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 3bb0686b2d85..bbdc70048c01 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,25 +120,22 @@
#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>
#include "ww8toolbar.hxx"
+#include <o3tl/unit_conversion.hxx>
#include <o3tl/safeint.hxx>
#include <osl/file.hxx>
#include <breakit.hxx>
-#if OSL_DEBUG_LEVEL > 1
-#include <iostream>
-#include <dbgoutsw.hxx>
-#endif
-
#include <sfx2/docfile.hxx>
#include <swdll.hxx>
#include "WW8Sttbf.hxx"
@@ -144,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>
@@ -160,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 )
{
@@ -268,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 ) )
@@ -284,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
@@ -316,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
@@ -337,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 );
@@ -422,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;
@@ -441,9 +442,9 @@ public:
}
Sttb::Sttb()
- : fExtend(0)
- , cData(0)
- , cbExtra(0)
+ : m_fExtend(0)
+ , m_cData(0)
+ , m_cbExtra(0)
{
}
@@ -451,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;
@@ -473,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;
}
@@ -482,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();
@@ -491,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;
}
@@ -509,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,
@@ -523,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
{
@@ -552,7 +552,7 @@ SdrObject* SwMSDffManager::ImportOLE( sal_uInt32 nOLEId,
nError,
nSvxMSDffOLEConvFlags,
css::embed::Aspects::MSOLE_CONTENT,
- rReader.GetBaseURL());
+ m_rReader.GetBaseURL());
}
}
return pRet;
@@ -560,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
@@ -598,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);
@@ -630,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,
@@ -664,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
@@ -785,10 +784,9 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
if (bIsSimpleDrawingTextBox)
{
- SdrObject::Free( pObj );
pObj = new SdrRectObj(
*pSdrModel,
- OBJ_TEXT,
+ SdrObjKind::Text,
rTextRect);
}
@@ -915,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);
}
@@ -934,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;
@@ -980,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);
@@ -999,18 +995,19 @@ 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 = GetPropertyValue(
- DFF_Prop_dxWrapDistLeft, 114935 ) / 635;
- pImpRec->nDyWrapDistTop = GetPropertyValue(
- DFF_Prop_dyWrapDistTop, 0 ) / 635;
- pImpRec->nDxWrapDistRight = GetPropertyValue(
- DFF_Prop_dxWrapDistRight, 114935 ) / 635;
- pImpRec->nDyWrapDistBottom = GetPropertyValue(
- DFF_Prop_dyWrapDistBottom, 0 ) / 635;
+ pImpRec->nDxWrapDistLeft = o3tl::convert(GetPropertyValue(DFF_Prop_dxWrapDistLeft, 114935),
+ o3tl::Length::emu, o3tl::Length::twip);
+ pImpRec->nDyWrapDistTop = o3tl::convert(GetPropertyValue(DFF_Prop_dyWrapDistTop, 0),
+ o3tl::Length::emu, o3tl::Length::twip);
+ pImpRec->nDxWrapDistRight
+ = o3tl::convert(GetPropertyValue(DFF_Prop_dxWrapDistRight, 114935), o3tl::Length::emu,
+ o3tl::Length::twip);
+ pImpRec->nDyWrapDistBottom = o3tl::convert(GetPropertyValue(DFF_Prop_dyWrapDistBottom, 0),
+ o3tl::Length::emu, o3tl::Length::twip);
// 16.16 fraction times total image width or height, as appropriate.
if (SeekToContent(DFF_Prop_pWrapPolygonVertices, rSt))
@@ -1020,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);
@@ -1091,7 +1089,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
&& (rObjData.nCalledByGroup < 2) )
)
{
- StoreShapeOrder(nShapeId, nShapeOrder, pObj);
+ StoreShapeOrder(nShapeId, nShapeOrder, pObj.get());
}
}
else
@@ -1110,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 );
@@ -1195,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;
@@ -1229,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();
@@ -1248,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 )
@@ -1256,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());
}
}
}
@@ -1296,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());
}
@@ -1304,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:
{
@@ -1342,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;
}
@@ -1368,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
@@ -1380,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);
@@ -1407,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);
+ }
}
}
}
@@ -1446,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
@@ -1456,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());
@@ -1464,7 +1469,7 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
}
else
{
- rDoc.getIDocumentContentOperations().InsertPoolItem(aRegion, *rEntry.pAttr);
+ m_rDoc.getIDocumentContentOperations().InsertPoolItem(aRegion, *rEntry.m_pAttr);
}
}
}
@@ -1481,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
{
/*
@@ -1492,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;
+ }
+ }
}
/*
@@ -1507,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);
}
@@ -1529,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) &&
@@ -1544,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();
}
}
}
@@ -1561,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())
@@ -1577,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
@@ -1588,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))
@@ -1599,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();
@@ -1621,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;
@@ -1693,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
{
@@ -1796,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);
}
}
@@ -1847,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;
@@ -1857,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)
@@ -1876,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);
}
@@ -1886,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);
@@ -1914,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);
@@ -1937,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.
@@ -1954,9 +2001,13 @@ 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)
+ {
+ m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::GUTTER_AT_TOP, true);
+ }
}
void SwWW8ImplReader::ImportDopTypography(const WW8DopTypography &rTypo)
@@ -1967,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
@@ -2004,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)),
@@ -2087,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;
@@ -2112,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
@@ -2179,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();
@@ -2208,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
@@ -2257,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
@@ -2420,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)
@@ -2486,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();
@@ -2508,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;
}
@@ -2556,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
@@ -2817,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);
@@ -2835,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);
@@ -3035,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)
@@ -3099,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();
@@ -3129,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)
@@ -3144,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;
@@ -3302,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());
@@ -3309,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();
@@ -3324,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)
@@ -3356,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
@@ -3378,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);
}
}
@@ -3388,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])
{
@@ -3427,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);
@@ -3447,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");
@@ -3476,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);
}
@@ -3548,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));
}
@@ -3567,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));
@@ -3609,6 +3614,7 @@ bool SwWW8ImplReader::ReadChar(tools::Long nPosCp, tools::Long nCpOfs)
switch (nWCharVal)
{
case 0:
+ if (!m_bFuzzing)
{
// Page number
SwPageNumberField aField(
@@ -3616,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.
@@ -3624,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;
@@ -3702,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 )
@@ -3723,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)
@@ -3835,7 +3854,7 @@ void SwWW8ImplReader::ProcessCurrentCollChange(WW8PLCFManResult& rRes,
// Frame/Table/Autonumbering List Level
bTabRowEnd = ProcessSpecial(bReSync, rRes.nCurrentCp + m_xPlcxMan->GetCpOfs());
if( bReSync )
- *pStartAttr = m_xPlcxMan->Get( &rRes ); // Get Attribut-Pos again
+ *pStartAttr = m_xPlcxMan->Get( &rRes ); // Get Attribute-Pos again
}
if (!bTabRowEnd && StyleExists(m_nCurrentColl))
@@ -3852,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
@@ -3968,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?
@@ -4000,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;
@@ -4064,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;
@@ -4084,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();
@@ -4096,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)
@@ -4166,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)
@@ -4177,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();
@@ -4200,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
}
}
@@ -4228,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));
@@ -4238,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);
@@ -4253,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)
@@ -4271,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)
@@ -4306,7 +4297,8 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SotStorage* pStorage,
, m_nWantedVersion(nVersionPara)
, m_nSwNumLevel(0xff)
, m_nWwNumType(0xff)
- , m_nListLevel(WW8ListManager::nMaxLevel)
+ , m_pChosenWW8OutlineStyle(nullptr)
+ , m_nListLevel(MAXLEVEL)
, m_bNewDoc(bNewDoc)
, m_bSkipImages(bSkipImages)
, m_bReadNoTable(false)
@@ -4350,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);
@@ -4391,21 +4380,21 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
SwFrameFormat &rFormat = rPage.GetMaster();
if(mrReader.m_xWDop->fUseBackGroundInAllmodes) // #i56806# Make sure mrReader is initialized
- mrReader.GrafikCtor();
+ mrReader.GraphicCtor();
if (mrReader.m_xWDop->fUseBackGroundInAllmodes && mrReader.m_xMSDffManager)
{
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));
@@ -4413,7 +4402,6 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
rFormat.SetFormatAttr(aSet);
}
}
- SdrObject::Free(pObject);
}
wwULSpaceData aULData;
GetPageULData(rSection, aULData);
@@ -4471,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);
}
}
@@ -4548,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)
@@ -4597,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;
@@ -4609,7 +4590,10 @@ void wwSectionManager::InsertSegments()
aDesc.GetPageDesc()->SetFollow( aFollow.GetPageDesc() );
}
- GiveNodePageDesc(aIter->maStart, aDesc, mrReader.m_rDoc);
+ // Avoid setting the page style at the very beginning since it is always the default style anyway,
+ // unless it is needed to specify a page number.
+ if (aIter != aStart || aDesc.GetNumOffset())
+ GiveNodePageDesc(aIter->maStart, aDesc, mrReader.m_rDoc);
}
SwTextNode* pTextNd = nullptr;
@@ -4617,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;
/*
@@ -4671,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];
@@ -4714,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;
}
@@ -4727,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)
@@ -4775,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);
}
}
@@ -4873,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& )
@@ -4905,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!!!! ");
@@ -4928,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;
@@ -4941,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 );
@@ -4954,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())
{
@@ -5042,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);
@@ -5059,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
@@ -5157,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)
@@ -5173,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 );
@@ -5182,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 );
}
@@ -5204,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);
}
@@ -5232,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 );
@@ -5244,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)
@@ -5264,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
@@ -5349,14 +5391,14 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
m_xStyles.reset();
m_xFormImpl.reset();
- GrafikDtor();
+ GraphicDtor();
m_xMSDffManager.reset();
m_xHdFt.reset();
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;
@@ -5365,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
@@ -5375,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
{
@@ -5390,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 )
{
@@ -5401,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);
@@ -5410,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);
}
@@ -5460,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;
@@ -5479,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"
@@ -5500,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();
@@ -5527,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
@@ -5576,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
@@ -5588,13 +5623,12 @@ namespace
uno::Reference< task::XInteractionHandler > xHandler( rMedium.GetInteractionHandler() );
if( xHandler.is() )
{
- ::comphelper::DocPasswordRequest* pRequest = new ::comphelper::DocPasswordRequest(
+ rtl::Reference<::comphelper::DocPasswordRequest> pRequest = new ::comphelper::DocPasswordRequest(
::comphelper::DocPasswordRequestType::MS, task::PasswordRequestMode_PASSWORD_ENTER,
INetURLObject(rMedium.GetOrigURL())
.GetLastName(INetURLObject::DecodeMechanism::WithCharset));
- uno::Reference< task::XInteractionRequest > xRequest( pRequest );
- xHandler->handle( xRequest );
+ xHandler->handle( pRequest );
if( pRequest->isPassword() )
aPassw = pRequest->getPassword();
@@ -5611,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 );
@@ -5641,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] = {};
@@ -5664,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 );
@@ -5756,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;
@@ -5816,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;
@@ -5884,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;
@@ -5920,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)
@@ -5931,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;
@@ -5964,16 +6000,61 @@ void SwWW8ImplReader::SetOutlineStyles()
// - Populate temporary list of WW8 Built-In Heading Styles for further
// iteration
std::vector<SwWW8StyInf*> aWW8BuiltInHeadingStyles;
- const SwNumRule* pChosenWW8ListStyle = nullptr;
{
+ 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();
@@ -5995,10 +6076,13 @@ void SwWW8ImplReader::SetOutlineStyles()
int nCurrentMaxCount = 0;
for (const auto& rEntry : aWW8ListStyleCounts)
{
+ if (aPreventUseAsChapterNumbering[rEntry.first])
+ continue;
+
if (rEntry.second > nCurrentMaxCount)
{
nCurrentMaxCount = rEntry.second;
- pChosenWW8ListStyle = rEntry.first;
+ m_pChosenWW8OutlineStyle = rEntry.first;
}
}
}
@@ -6014,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
@@ -6028,21 +6119,12 @@ void SwWW8ImplReader::SetOutlineStyles()
continue;
}
- if (pChosenWW8ListStyle != nullptr && pStyleInf->mnWW8OutlineLevel
- == pStyleInf->m_nListLevel)
- {
- const SwNumFormat& rRule
- = pChosenWW8ListStyle->Get(pStyleInf->mnWW8OutlineLevel);
- aOutlineRule.Set(pStyleInf->mnWW8OutlineLevel, rRule);
- bAppliedChangedOutlineStyle = true;
- }
-
// in case that there are more styles on this level ignore them
nOutlineStyleListLevelWithAssignment
|= nOutlineStyleListLevelOfWW8BuiltInHeadingStyle;
SwTextFormatColl* pTextFormatColl = static_cast<SwTextFormatColl*>(pStyleInf->m_pFormat);
- if (pStyleInf->GetOutlineNumrule() != pChosenWW8ListStyle
+ if (pStyleInf->GetOutlineNumrule() != m_pChosenWW8OutlineStyle
|| (pStyleInf->m_nListLevel < WW8ListManager::nMaxLevel
&& pStyleInf->mnWW8OutlineLevel != pStyleInf->m_nListLevel))
{
@@ -6071,7 +6153,7 @@ void SwWW8ImplReader::SetOutlineStyles()
}
}
- if (bAppliedChangedOutlineStyle)
+ if (m_pChosenWW8OutlineStyle)
{
m_rDoc.SetOutlineNumRule(aOutlineRule);
}
@@ -6079,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;
}
@@ -6155,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)
@@ -6208,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;
@@ -6262,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;
}
@@ -6286,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);
@@ -6311,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?");
@@ -6332,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();
@@ -6377,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();
@@ -6387,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;
@@ -6411,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&)
{
@@ -6421,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;
@@ -6453,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();
@@ -6517,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() );
@@ -6527,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
@@ -6546,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))
@@ -6590,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;
}
@@ -6647,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 57b53e05589c..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
@@ -273,11 +279,13 @@ public:
m_nBase( 0 ),
m_nFollow( 0 ),
m_nLFOIndex( USHRT_MAX ),
- m_nListLevel(WW8ListManager::nMaxLevel),
+ m_nListLevel(MAXLEVEL),
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
@@ -573,12 +567,12 @@ class WW8FieldEntry
sw::hack::Position maStartPos;
sal_uInt16 mnFieldId;
sal_uLong mnObjLocFc;
- WW8FieldEntry(SwPosition const &rPos, sal_uInt16 nFieldId) throw();
- WW8FieldEntry(const WW8FieldEntry &rOther) throw();
- WW8FieldEntry &operator=(const WW8FieldEntry &rOther) throw();
- void Swap(WW8FieldEntry &rOther) throw();
+ WW8FieldEntry(SwPosition const &rPos, sal_uInt16 nFieldId) noexcept;
+ WW8FieldEntry(const WW8FieldEntry &rOther) noexcept;
+ 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,15 +783,17 @@ 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 m_nPgWidth;
+ sal_uInt32 m_nPgLeft;
+ sal_uInt32 m_nPgRight;
+ sal_uInt32 m_nPgGutter;
+ bool m_bRtlGutter = false;
css::drawing::TextVerticalAdjust mnVerticalAdjustment;
sal_uInt8 mnBorders;
@@ -812,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() - 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; }
@@ -869,7 +865,7 @@ private:
static bool SetCols(SwFrameFormat &rFormat, const wwSection &rSection,
sal_uInt32 nNetWidth);
bool SectionIsProtected(const wwSection &rSection) const;
- void SetLeftRight(wwSection &rSection);
+ static void SetLeftRight(wwSection &rSection);
/*
The segment we're inserting, the start of the segments container, and the
nodeindex of where we want the page break to (normally the segments start
@@ -889,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);
@@ -900,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.
@@ -915,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();
};
@@ -943,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)
{
}
};
@@ -959,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)
{ }
};
@@ -977,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
@@ -1030,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];
@@ -1105,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.
@@ -1148,6 +1180,8 @@ private:
*/
std::deque<FootnoteDescriptor> m_aFootnoteStack;
+ std::optional<SwLineBreakClear> m_oLineBreakClear;
+
/*
A queue of the ms sections in the document
*/
@@ -1174,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
@@ -1223,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;
@@ -1257,15 +1291,16 @@ 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;
- sw::util::AuthorInfos m_aAuthorInfos;
+ /// Redlining Authors, map word author key to writer author value
+ std::map<sal_uInt16, std::size_t> m_aAuthorInfos;
OUString m_sBaseURL;
// Ini-Flags:
@@ -1304,6 +1339,7 @@ private:
sal_uInt8 m_nSwNumLevel; // level number for outline / enumeration
sal_uInt8 m_nWwNumType; // outline / number / enumeration
+ const SwNumRule* m_pChosenWW8OutlineStyle; // copied to the "Outline" Chapter Numbering style
sal_uInt8 m_nListLevel;
bool m_bNewDoc; // new document?
@@ -1368,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);
@@ -1419,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);
@@ -1458,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);
@@ -1490,10 +1529,10 @@ private:
SvxLRSpaceItem &rLR);
static void AdjustULWrapForWordMargins(const SvxMSDffImportRec &rRecord,
SvxULSpaceItem &rUL);
- static void MapWrapIntoFlyFormat(SvxMSDffImportRec const * pRecord, SwFrameFormat* pFlyFormat);
+ static void MapWrapIntoFlyFormat(const SvxMSDffImportRec& rRecord, SwFrameFormat& rFlyFormat);
- void SetAttributesAtGrfNode(SvxMSDffImportRec const* pRecord,
- SwFrameFormat const *pFlyFormat, WW8_FSPA const *pF);
+ void SetAttributesAtGrfNode(const SvxMSDffImportRec& rRecord, const SwFrameFormat& rFlyFormat,
+ WW8_FSPA const* pF);
bool IsDropCap() const;
bool IsListOrDropcap() const { return (!m_xCurrentItemSet || m_bDropCap); };
@@ -1512,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,
@@ -1530,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,
@@ -1547,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();
@@ -1569,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 );
@@ -1584,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,
@@ -1605,28 +1644,27 @@ 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);
- void ReadGrafLayer1( WW8PLCFspecial* pPF, tools::Long nGrafAnchorCp );
+ 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* pRecord, WW8_FSPA *pFSPA,
- SfxItemSet &rFlySet);
+ 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, SvxMSDffImportRec* pRecord, WW8_FSPA *pF,
- SfxItemSet &rFlySet );
- SwFlyFrameFormat *ConvertDrawTextToFly( SdrObject* &rpObject,
- SdrObject* &rpOurNewObject, SvxMSDffImportRec const * pRecord,
- RndStdIds eAnchor, WW8_FSPA const *pF, SfxItemSet &rFlySet );
- SwFrameFormat* MungeTextIntoDrawBox(SvxMSDffImportRec *pRecord,
- tools::Long nGrafAnchorCp, SwFrameFormat *pRetFrameFormat);
-
- void GrafikCtor();
- void GrafikDtor();
+ SwFlyFrameFormat* ImportReplaceableDrawables(rtl::Reference<SdrObject>& rpObject, rtl::Reference<SdrObject>& rpOurNewObject,
+ SvxMSDffImportRec& rRecord, WW8_FSPA& rF,
+ SfxItemSet& rFlySet);
+ 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,
+ SwFrameFormat* pRetFrameFormat);
+
+ void GraphicCtor();
+ void GraphicDtor();
// other stuff
OUString GetFieldResult( WW8FieldDesc const * pF );
@@ -1694,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;
@@ -1704,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();
@@ -1754,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 );
@@ -1794,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 );
@@ -1835,7 +1870,7 @@ public: // really private, but can only be done public
void Read_UnderlineColor(sal_uInt16, const sal_uInt8* pData, short nLen);
tools::Long MapBookmarkVariables(const WW8FieldDesc* pF, OUString &rOrigName,
const OUString &rData);
- OUString GetMappedBookmark(const OUString &rOrigName);
+ OUString GetMappedBookmark(std::u16string_view rOrigName);
// fields
eF_ResT Read_F_Input(WW8FieldDesc*, OUString& rStr);
@@ -1844,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 );
@@ -1886,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; }
@@ -1899,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
@@ -1925,12 +1957,13 @@ 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 );
tools::Long GetListFirstLineIndent(const SwNumFormat &rFormat);
-OUString BookmarkToWriter(const OUString &rBookmark);
+OUString BookmarkToWriter(std::u16string_view rBookmark);
bool RTLGraphicsHack(SwTwips &rLeft, SwTwips nWidth,
sal_Int16 eHoriOri, sal_Int16 eHoriRel, SwTwips nPageLeft,
SwTwips nPageRight, SwTwips nPageSize);
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index e6901f360f84..c1e80efd2d38 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -21,6 +21,7 @@
#include <sal/log.hxx>
#include <comphelper/string.hxx>
+#include <osl/diagnose.h>
#include <o3tl/safeint.hxx>
#include <o3tl/temporary.hxx>
#include <tools/solar.h>
@@ -38,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>
@@ -56,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"
@@ -77,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)
@@ -143,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
@@ -166,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;
}
@@ -187,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 );
}
@@ -291,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;
}
@@ -376,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)
{
@@ -445,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;
@@ -580,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)
@@ -599,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)
@@ -640,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;
}
}
}
@@ -672,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 );
@@ -682,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.
@@ -705,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);
}
@@ -725,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#
@@ -807,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 );
@@ -848,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);
}
@@ -1027,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;
@@ -1054,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);
@@ -1101,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;
@@ -1791,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;
@@ -1812,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
{
@@ -2059,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
@@ -2097,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;
@@ -2357,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);
}
@@ -2368,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;
/*
@@ -2380,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;
@@ -2403,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]
@@ -2440,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())
@@ -2458,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));
}
}
}
@@ -2484,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);
@@ -2497,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))
@@ -2511,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.
@@ -2552,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 );
@@ -2587,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();
@@ -2641,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();
}
}
@@ -2673,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.
@@ -2682,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
@@ -2698,7 +2696,7 @@ void WW8TabDesc::MergeCells()
// (that can be a newly created or another group)
UpdateTableMergeGroup( rCell, pActMGroup, m_pTabBox, i );
}
- }
+ }
}
}
@@ -2710,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])
{
@@ -2725,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));
}
}
@@ -2745,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);
@@ -2767,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
@@ -2779,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)
{
@@ -2831,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
@@ -2886,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)
@@ -2956,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));
@@ -2974,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;
@@ -2987,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);
}
@@ -3084,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));
}
}
@@ -3158,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 )
@@ -3222,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);
@@ -3409,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;
}
}
}
@@ -3428,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 );
@@ -3454,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
@@ -3485,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();
@@ -3606,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();
}
@@ -3781,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;
@@ -3790,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;
}
@@ -3798,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;
}
@@ -3884,10 +3898,12 @@ void WW8RStyle::PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp)
mpIo->m_bNoAttrImport = bOldNoImp;
// reset the list-remember-fields, if used when reading styles
mpIo->m_nLFOPosition = USHRT_MAX;
- mpIo->m_nListLevel = WW8ListManager::nMaxLevel;
+ 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;
@@ -3902,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 );
@@ -3923,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
@@ -4021,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);
@@ -4135,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;
@@ -4148,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;
@@ -4161,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;
@@ -4174,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;
@@ -4187,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;
@@ -4203,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;
@@ -4211,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;
@@ -4416,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);
@@ -4447,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);
@@ -4465,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 b7df7589a5e7..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)
{
@@ -146,7 +145,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormTextBox( WW8FieldDesc* pF, OUString& rStr )
OUString aBookmarkFind=pB->GetBookmark(currentCP-1, nEnd, bkmFindIdx);
if (!aBookmarkFind.isEmpty()) {
- pB->SetStatus(bkmFindIdx, BOOK_FIELD); // mark bookmark as consumed, such that tl'll not get inserted as a "normal" bookmark again
+ pB->SetStatus(bkmFindIdx, BOOK_FIELD); // mark bookmark as consumed, such that it'll not get inserted as a "normal" bookmark again
if (!aBookmarkFind.isEmpty()) {
aBookmarkName=aBookmarkFind;
}
@@ -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,
@@ -1785,9 +1822,14 @@ void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nCurrentLFO,
return;
if (bSetAttr && pTextNd->GetNumRule() != pRule
- && pTextNd->GetNumRule() != m_rDoc.GetOutlineNumRule())
+ && (pTextNd->GetNumRule() != m_rDoc.GetOutlineNumRule()
+ || pRule != m_pChosenWW8OutlineStyle))
{
- pTextNd->SetAttr(SwNumRuleItem(pRule->GetName()));
+ // 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.
+ OUString sName = pRule == m_pChosenWW8OutlineStyle ? m_rDoc.GetOutlineNumRule()->GetName()
+ : pRule->GetName();
+ pTextNd->SetAttr(SwNumRuleItem(sName));
}
pTextNd->SetAttrListLevel(nCurrentLevel);
@@ -1816,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
@@ -1831,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)
@@ -1841,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);
}
}
@@ -1869,7 +1918,7 @@ void SwWW8ImplReader::Read_ListLevel(sal_uInt16, const sal_uInt8* pData,
if( nLen < 0 )
{
// the current level is finished, what should we do ?
- m_nListLevel = WW8ListManager::nMaxLevel;
+ m_nListLevel = MAXLEVEL;
if (m_xStyles && !m_bVer67)
m_xStyles->mnWwNumLevel = 0;
}
@@ -1893,13 +1942,16 @@ 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 = WW8ListManager::nMaxLevel;
+ m_nListLevel = MAXLEVEL;
}
}
}
@@ -1914,7 +1966,7 @@ void SwWW8ImplReader::Read_LFOPosition(sal_uInt16, const sal_uInt8* pData,
{
// the current level is finished, what should we do ?
m_nLFOPosition = USHRT_MAX;
- m_nListLevel = WW8ListManager::nMaxLevel;
+ m_nListLevel = MAXLEVEL;
}
else
{
@@ -1945,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
@@ -1956,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
@@ -1989,14 +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)
- m_nListLevel = 0;
- if (WW8ListManager::nMaxLevel > m_nListLevel)
- {
- RegisterNumFormat(m_nLFOPosition, m_nListLevel);
- m_nLFOPosition = USHRT_MAX;
- m_nListLevel = WW8ListManager::nMaxLevel;
- }
+ RegisterNumFormat(m_nLFOPosition, m_nListLevel);
+ m_nLFOPosition = USHRT_MAX;
+ m_nListLevel = MAXLEVEL;
}
else if (m_xPlcxMan && m_xPlcxMan->HasParaSprm(NS_sprm::LN_PAnld).pSprm)
{
@@ -2004,6 +2059,7 @@ void SwWW8ImplReader::Read_LFOPosition(sal_uInt16, const sal_uInt8* pData,
#i8114# Horrific backwards compatible ww7- lists in ww8+
docs
*/
+ m_nListLevel = std::min<sal_uInt8>(WW8ListManager::nMaxLevel, m_nListLevel);
Read_ANLevelNo(13 /*equiv ww7- sprm no*/, &m_nListLevel, 1);
}
}
@@ -2036,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;
}
}
@@ -2046,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;
@@ -2141,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
@@ -2297,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;
@@ -2336,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);
@@ -2374,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 );
@@ -2400,11 +2456,9 @@ bool WW8FormulaListBox::Import(const uno::Reference <
}
else
{
- static const sal_Unicode aBlank[] =
- {
- 0x2002,0x2002,0x2002,0x2002,0x2002
- };
- rSz = mrRdr.MiserableDropDownFormHack(OUString(aBlank, SAL_N_ELEMENTS(aBlank)), xPropSet);
+ static constexpr OUStringLiteral aBlank =
+ u"\u2002\u2002\u2002\u2002\u2002";
+ rSz = mrRdr.MiserableDropDownFormHack(aBlank, xPropSet);
}
return true;
@@ -2521,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 1c5bc2a09b6c..981cc95faffa 100644
--- a/sw/source/filter/ww8/ww8par4.cxx
+++ b/sw/source/filter/ww8/ww8par4.cxx
@@ -31,8 +31,8 @@
#include <svx/svdoole2.hxx>
#include <filter/msfilter/msdffimp.hxx>
#include "sprmids.hxx"
-#include <svx/unoapi.hxx>
#include <sal/log.hxx>
+#include <osl/diagnose.h>
#include <sot/exchange.hxx>
#include <fmtanchr.hxx>
@@ -64,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)
@@ -79,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,
@@ -122,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 );
@@ -175,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?
@@ -203,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() )
{
@@ -212,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);
}
}
@@ -231,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;
@@ -243,19 +242,19 @@ SwFrameFormat* SwWW8ImplReader::ImportOle(const Graphic* pGrf,
::SetProgressState(m_nProgress, m_pDocShell); // Update
SwFrameFormat* pFormat = nullptr;
- GrafikCtor();
+ 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 );
@@ -281,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 );
@@ -301,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;
@@ -324,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)
@@ -341,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)
{
@@ -380,7 +379,7 @@ SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
}
}
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
if (!(m_bIsHeader || m_bIsFooter))
{
@@ -389,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);
@@ -404,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 );
@@ -416,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() )
{
@@ -428,7 +426,7 @@ SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
}
ErrCode nError = ERRCODE_NONE;
- GrafikCtor();
+ GraphicCtor();
pRet = SvxMSDffManager::CreateSdrOLEFromStorage(
*m_pDrawModel,
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 7c67e6702d3a..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,10 +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
@@ -89,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)
@@ -154,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 );
@@ -180,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
@@ -298,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;
@@ -327,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
@@ -375,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;
}
@@ -386,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;
@@ -423,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;
@@ -433,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;
@@ -496,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;
@@ -505,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())
@@ -522,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
@@ -552,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);
}
@@ -562,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();
}
}
}
@@ -583,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
@@ -612,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( );
@@ -638,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 )
{
@@ -650,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();
@@ -659,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() )
{
@@ -677,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 ) ) );
}
}
}
@@ -710,23 +759,23 @@ static bool AcceptableNestedField(sal_uInt16 nFieldCode)
}
}
-WW8FieldEntry::WW8FieldEntry(SwPosition const &rPos, sal_uInt16 nFieldId) throw()
+WW8FieldEntry::WW8FieldEntry(SwPosition const &rPos, sal_uInt16 nFieldId) noexcept
: maStartPos(rPos), mnFieldId(nFieldId), mnObjLocFc(0)
{
}
-WW8FieldEntry::WW8FieldEntry(const WW8FieldEntry &rOther) throw()
+WW8FieldEntry::WW8FieldEntry(const WW8FieldEntry &rOther) noexcept
: maStartPos(rOther.maStartPos), mnFieldId(rOther.mnFieldId), mnObjLocFc(rOther.mnObjLocFc)
{
}
-void WW8FieldEntry::Swap(WW8FieldEntry &rOther) throw()
+void WW8FieldEntry::Swap(WW8FieldEntry &rOther) noexcept
{
std::swap(maStartPos, rOther.maStartPos);
std::swap(mnFieldId, rOther.mnFieldId);
}
-WW8FieldEntry &WW8FieldEntry::operator=(const WW8FieldEntry &rOther) throw()
+WW8FieldEntry &WW8FieldEntry::operator=(const WW8FieldEntry &rOther) noexcept
{
WW8FieldEntry aTemp(rOther);
Swap(aTemp);
@@ -888,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
@@ -919,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);
@@ -930,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]
@@ -950,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 );
@@ -976,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
}
}
@@ -1051,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;
@@ -1129,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
@@ -1189,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
@@ -1297,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;
}
@@ -1326,21 +1384,21 @@ 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;
}
}
return pRet;
}
-OUString SwWW8ImplReader::GetMappedBookmark(const OUString &rOrigName)
+OUString SwWW8ImplReader::GetMappedBookmark(std::u16string_view rOrigName)
{
OUString sName(BookmarkToWriter(rOrigName));
OSL_ENSURE(m_xPlcxMan, "no pPlcxMan");
@@ -1349,9 +1407,9 @@ OUString SwWW8ImplReader::GetMappedBookmark(const OUString &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;
}
@@ -1416,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;
@@ -1529,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 )
{
@@ -1638,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;
}
@@ -1665,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;
@@ -1682,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;
@@ -1745,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;
}
@@ -1818,17 +1922,22 @@ eF_ResT SwWW8ImplReader::Read_F_DateTime( WW8FieldDesc*pF, OUString& rStr )
}
}
- if (nDT & SvNumFormatType::DATE)
+ if (nDT & SvNumFormatType::DATE || nDT == SvNumFormatType::TIME)
{
SwDateTimeField aField(static_cast<SwDateTimeFieldType*>(
- m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DateTime )), DATEFLD, 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, nFormat);
+ m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DateTime)),
+ 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 ) );
}
@@ -2084,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)
{
@@ -2144,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);
@@ -2192,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
{
@@ -2200,7 +2309,7 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, OUString& rStr )
}
OUString sURL = "#" + sBookmarkName;
SwFormatINetFormat aURL( sURL, "" );
- const OUString sLinkStyle("Index Link");
+ static constexpr OUString sLinkStyle(u"Index Link"_ustr);
const sal_uInt16 nPoolId =
SwStyleNameMapper::GetPoolIdFromUIName( sLinkStyle, SwGetPoolIdFromName::ChrFmt );
aURL.SetVisitedFormatAndId( sLinkStyle, nPoolId);
@@ -2217,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;
@@ -2265,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();
@@ -2279,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();
@@ -2308,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
@@ -2351,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;
@@ -2372,11 +2455,11 @@ bool CanUseRemoteLink(const OUString &rGrfName)
task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(), nullptr));
uno::Reference< ucb::XProgressHandler > xProgress;
- ::ucbhelper::CommandEnvironment* pCommandEnv =
+ rtl::Reference<::ucbhelper::CommandEnvironment> pCommandEnv =
new ::ucbhelper::CommandEnvironment(new comphelper::SimpleFileAccessInteraction( xIH ), xProgress);
::ucbhelper::Content aCnt(rGrfName,
- static_cast< ucb::XCommandEnvironment* >(pCommandEnv),
+ static_cast< ucb::XCommandEnvironment* >(pCommandEnv.get()),
comphelper::getProcessComponentContext());
if ( !INetURLObject( rGrfName ).isAnyKnownWebDAVScheme() )
@@ -2446,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 =
@@ -2527,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;
}
@@ -2540,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
@@ -2581,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(),
@@ -2594,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),
@@ -2660,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" ) )
{
@@ -2757,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)
{
@@ -2872,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) )
@@ -2918,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;
}
@@ -3008,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;
@@ -3055,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;
@@ -3177,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;
}
@@ -3229,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;
}
@@ -3276,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);
@@ -3322,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) );
}
}
}
@@ -3364,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) );
}
@@ -3389,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 )
@@ -3417,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
@@ -3427,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);
@@ -3439,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 );
@@ -3448,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
@@ -3513,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)
@@ -3601,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;
@@ -3669,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 815c3ef97bef..bc89199c4904 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <o3tl/safeint.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <svl/itemiter.hxx>
#include <svl/grabbagitem.hxx>
#include <rtl/tencinfo.h>
@@ -67,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>
@@ -98,6 +100,7 @@
#include "ww8graf.hxx"
#include <fmtwrapinfluenceonobjpos.hxx>
+#include <formatflysplit.hxx>
using namespace sw::util;
using namespace sw::types;
@@ -106,8 +109,10 @@ using namespace nsHdFtFlags;
// various
-#define MM_250 1417 // WW default for horizontal borders: 2.5 cm
-#define MM_200 1134 // WW default for lower border: 2.0 cm
+// WW default for horizontal borders: 2.5 cm
+constexpr auto MM_250 = o3tl::convert(25, o3tl::Length::mm, o3tl::Length::twip); // 1417
+// WW default for lower border: 2.0 cm
+constexpr auto MM_200 = o3tl::convert(20, o3tl::Length::mm, o3tl::Length::twip); // 1134
static sal_uInt8 lcl_ReadBorders(bool bVer67, WW8_BRCVer9* brc, WW8PLCFx_Cp_FKP* pPap,
@@ -216,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();
@@ -258,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);
@@ -273,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;
}
}
@@ -389,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
@@ -482,12 +489,12 @@ void wwSectionManager::SetLeftRight(wwSection &rSection)
case is handled in GetPageULData.
*/
if (rSection.maSep.fRTLGutter)
- nWWRi += nWWGu;
- else if (!mrReader.m_xWDop->iGutterPos)
- nWWLe += nWWGu;
+ {
+ rSection.m_bRtlGutter = true;
+ }
// 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
@@ -502,11 +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.m_nPgLeft = nWWLe;
+ rSection.m_nPgRight = nWWRi;
+ rSection.m_nPgGutter = nWWGu;
}
void wwSectionManager::SetPage(SwPageDesc &rInPageDesc, SwFrameFormat &rFormat,
@@ -521,8 +529,12 @@ void wwSectionManager::SetPage(SwPageDesc &rInPageDesc, SwFrameFormat &rFormat,
aSz.SetHeight(SvxPaperInfo::GetSloppyPaperDimension(rSection.GetPageHeight()));
rFormat.SetFormatAttr(aSz);
- rFormat.SetFormatAttr(
- SvxLRSpaceItem(rSection.GetPageLeft(), rSection.GetPageRight(), 0, 0, RES_LR_SPACE));
+ 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);
+ rFormat.SetFormatAttr(aRtlGutter);
if (!bIgnoreCols)
SetCols(rFormat, rSection, rSection.GetTextAreaWidth());
@@ -548,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()));
@@ -609,7 +621,7 @@ void wwSectionManager::GetPageULData(const wwSection &rSection,
// #i19922# - correction:
// consider that <nWWUp> can be negative, compare only if it's positive
if ( nWWUp > 0 &&
- o3tl::make_unsigned(abs(nWWUp)) >= nWWHTop )
+ o3tl::make_unsigned(nWWUp) >= nWWHTop )
rData.nSwHLo = nWWUp - nWWHTop;
else
rData.nSwHLo = 0;
@@ -627,7 +639,7 @@ void wwSectionManager::GetPageULData(const wwSection &rSection,
rData.nSwLo = nWWFBot; // footer -> convert
// #i19922# - correction: consider that <nWWLo> can be negative, compare only if it's positive
if ( nWWLo > 0 &&
- o3tl::make_unsigned(abs(nWWLo)) >= nWWFBot )
+ o3tl::make_unsigned(nWWLo) >= nWWFBot )
rData.nSwFUp = nWWLo - nWWFBot;
else
rData.nSwFUp = 0;
@@ -661,8 +673,10 @@ void wwSectionManager::SetPageULSpaceItems(SwFrameFormat &rFormat,
}
else
{
+ // Hack alert: these calculations are based on
+ // #112727# import negative height headers/footers as floating frames inside fixed height headers/footer
// #i48832# - set correct spacing between header and body.
- const sal_Int32 nHdLowerSpace( std::abs(rSection.maSep.dyaTop) - rData.nSwUp - rData.nSwHLo );
+ const sal_Int32 nHdLowerSpace(std::max<sal_Int32>(0, std::abs(rSection.maSep.dyaTop) - rData.nSwUp - rData.nSwHLo));
pHdFormat->SetFormatAttr(SwFormatFrameSize(SwFrameSize::Fixed, 0, rData.nSwHLo + nHdLowerSpace));
aHdUL.SetLower( static_cast< sal_uInt16 >(nHdLowerSpace) );
pHdFormat->SetFormatAttr(SwHeaderAndFooterEatSpacingItem(
@@ -689,7 +703,7 @@ void wwSectionManager::SetPageULSpaceItems(SwFrameFormat &rFormat,
else
{
// #i48832# - set correct spacing between footer and body.
- const SwTwips nFtUpperSpace( std::abs(rSection.maSep.dyaBottom) - rData.nSwLo - rData.nSwFUp );
+ const sal_Int32 nFtUpperSpace(std::max<sal_Int32>(0, std::abs(rSection.maSep.dyaBottom) - rData.nSwLo - rData.nSwFUp));
pFtFormat->SetFormatAttr(SwFormatFrameSize(SwFrameSize::Fixed, 0, rData.nSwFUp + nFtUpperSpace));
aFtUL.SetUpper( static_cast< sal_uInt16 >(nFtUpperSpace) );
pFtFormat->SetFormatAttr(SwHeaderAndFooterEatSpacingItem(
@@ -753,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);
}
@@ -799,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() );
}
@@ -810,13 +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)
+ , 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)
@@ -858,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();
@@ -1068,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);
@@ -1089,7 +1103,8 @@ void wwSectionManager::CreateSep(const tools::Long nTextPos)
aNewSection.maSep.dzaGutter = ReadUSprm( pSep, pIds[5], 0);
- aNewSection.maSep.fRTLGutter = static_cast< sal_uInt8 >(eVer >= ww::eWW8 ? ReadUSprm( pSep, NS_sprm::SFRTLGutter::val, 0 ) : 0);
+ aNewSection.maSep.fRTLGutter = static_cast<sal_uInt8>(
+ eVer >= ww::eWW8 ? ReadBSprm(pSep, NS_sprm::SFRTLGutter::val, 0) : 0);
// Page Number Restarts - sprmSFPgnRestart
aNewSection.maSep.fPgnRestart = ReadBSprm(pSep, pIds[6], 0);
@@ -1185,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
@@ -1625,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;
}
}
@@ -1642,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;
@@ -1668,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
@@ -1728,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 */ )
@@ -1747,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;
@@ -1777,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);
@@ -1799,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
@@ -1845,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
@@ -1858,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;
}
@@ -1872,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),
@@ -1887,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
@@ -1939,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)
{
@@ -1955,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;
@@ -1968,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;
@@ -1997,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
}
@@ -2046,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 )
{
@@ -2057,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 )
{
@@ -2069,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 )
{
@@ -2079,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)
{
@@ -2123,14 +2167,29 @@ void WW8SwFlyPara::BoxUpWidth( tools::Long nInWidth )
{
if( bAutoWidth && nInWidth > nNewNetWidth )
nNewNetWidth = nInWidth;
-};
+}
+
+SwFlyFrameFormat* WW8SwFlyPara::GetFlyFormat() const
+{
+ if (!m_xFlyFormat)
+ return nullptr;
+ return static_cast<SwFlyFrameFormat*>(m_xFlyFormat->GetFormat());
+}
-// The class WW8FlySet is derived from SfxItemSet and does not
+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
@@ -2144,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);
@@ -2185,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);
@@ -2206,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;
@@ -2236,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 );
}
}
}
@@ -2263,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() )
{
@@ -2271,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()));
}
}
@@ -2286,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());
}
@@ -2380,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);
@@ -2437,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;
}
@@ -2452,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)
- GrafikCtor();
+ 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
@@ -2487,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.
@@ -2503,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
@@ -2534,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();
}
@@ -2579,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;
@@ -2624,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);
@@ -2635,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#
@@ -2648,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
@@ -2656,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)
@@ -2680,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));
}
/*
@@ -2695,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();
@@ -2722,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();
@@ -2748,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;
@@ -2780,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 );
}
}
@@ -2807,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())
{
@@ -2823,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);
@@ -3051,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
{
@@ -3307,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:
@@ -3389,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 (
@@ -3431,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);
@@ -3465,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.
@@ -4081,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);
}
}
@@ -4106,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);
}
}
@@ -4143,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() );
}
@@ -4171,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 )
@@ -4197,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);
}
}
}
@@ -4240,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;
@@ -4267,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() );
}
@@ -4304,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
@@ -4361,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);
}
@@ -4397,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())
@@ -4424,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())
@@ -4465,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 )
{
@@ -4493,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.
@@ -4563,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;
}
@@ -4662,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;
@@ -4727,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 );
@@ -4877,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:
{
@@ -4891,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;
}
@@ -4915,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) );
}
}
@@ -4958,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 )
@@ -5022,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());
@@ -5035,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 );
@@ -5071,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());
@@ -5104,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 !
@@ -5236,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;
@@ -6061,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));
@@ -6108,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 302c6c62318d..80f9102dcb1b 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -31,6 +31,7 @@
#include <rtl/tencinfo.h>
#include <sal/macros.h>
#include <sal/log.hxx>
+#include <osl/diagnose.h>
#include <swerror.h>
@@ -43,10 +44,6 @@
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
-#ifdef DEBUGSPRMREADER
-#include <stdio.h>
-#endif
-
using namespace ::com::sun::star::lang;
namespace
@@ -62,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);
@@ -215,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
@@ -396,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
@@ -700,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>(), // ;;;
@@ -873,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;
}
}
@@ -951,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)
{
}
@@ -976,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)
@@ -984,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;
@@ -1022,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
{
@@ -1119,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;
}
}
}
@@ -1136,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()
@@ -1149,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 )
@@ -1178,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 )
@@ -1198,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;
@@ -1214,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;
@@ -1261,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;
@@ -2136,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;
@@ -2149,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);
}
@@ -2176,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;
}
@@ -2211,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;
}
@@ -2261,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)
{
@@ -2269,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);
@@ -2283,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);
@@ -2312,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();
}
@@ -2339,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
@@ -2366,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)
@@ -2393,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)
{
@@ -2407,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());
}
@@ -2419,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))
@@ -2433,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);
@@ -2442,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;
}
}
@@ -2462,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;
@@ -2529,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 );
@@ -2550,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 );
@@ -2560,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<
@@ -2640,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;
}
@@ -2648,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);
@@ -2657,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;
@@ -2668,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)
@@ -2684,7 +2688,7 @@ WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(const WW8Fib& rFib, SvStream* pSt,
if (nOfs)
{
- switch (ePLCF)
+ switch (m_ePLCF)
{
case CHP:
{
@@ -2697,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)
@@ -2783,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);
@@ -2825,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
@@ -3088,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)
{
@@ -3132,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));
}
}
@@ -3152,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;
}
@@ -3168,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
}
}
}
@@ -3189,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
}
@@ -3223,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;
@@ -3237,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
@@ -3280,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)
{
@@ -3293,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);
}
}
@@ -3304,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
@@ -3312,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 );
@@ -3323,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())
{
@@ -3340,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
@@ -3355,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()
@@ -3370,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)
@@ -3424,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;
/*
@@ -3453,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
@@ -3477,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;
}
@@ -3500,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;
}
@@ -3511,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;
}
}
@@ -3521,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;
}
@@ -3532,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;
}
@@ -3543,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
@@ -3571,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;
@@ -3658,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;
}
}
@@ -3682,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()
@@ -3717,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;
@@ -3751,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;
@@ -3763,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);
@@ -3814,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)
@@ -3867,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;
@@ -3882,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)
@@ -3928,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;
@@ -3948,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;
@@ -3973,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;
@@ -3990,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()
@@ -4029,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;
@@ -4086,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;
@@ -4104,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;
@@ -4113,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;
}
@@ -4169,6 +4159,7 @@ void WW8ReadSTTBF(bool bVer8, SvStream& rStrm, sal_uInt32 nStart, sal_Int32 nLen
const size_t nMinStringLen = bUnicode ? sizeof(sal_uInt16) : sizeof(sal_uInt8);
const size_t nMinRecordSize = nExtraLen + nMinStringLen;
+ assert(nMinRecordSize != 0 && "impossible to be zero");
const size_t nMaxPossibleStrings = rStrm.remainingSize() / nMinRecordSize;
if (nStrings > nMaxPossibleStrings)
{
@@ -4234,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; )
@@ -4272,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);
}
}
@@ -4306,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 )
@@ -4352,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,
@@ -4377,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;
@@ -4455,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
{
@@ -4471,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))
{
@@ -4482,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
@@ -4508,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;
@@ -4526,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;
}
@@ -4537,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();
}
}
@@ -4556,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;
@@ -4575,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);
@@ -4605,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;
@@ -4617,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();
@@ -5072,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;
@@ -5224,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;
}
@@ -5398,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.
@@ -5628,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
@@ -5851,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
@@ -5912,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;
@@ -6003,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)
{
@@ -6211,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 );
@@ -6331,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];
}
@@ -6552,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
@@ -6701,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);
}
};
@@ -6723,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);
@@ -6772,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);
@@ -6833,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
@@ -6953,7 +6945,7 @@ WW8Style::WW8Style(SvStream& rStream, WW8Fib& rFibPara)
OSL_ENSURE(m_cstd <= nMaxPossibleRecords,
"allegedly more styles that available data");
- m_cstd = std::min(m_cstd, nMaxPossibleRecords);
+ m_cstd = o3tl::sanitizing_min(m_cstd, nMaxPossibleRecords);
}
// Read1STDFixed() reads a style. If the style is completely existent,
@@ -6963,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;
@@ -7203,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;
}
@@ -7311,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;
@@ -7362,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
@@ -7461,7 +7452,7 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib const & rFib )
#ifdef OSL_BIGENDIAN
swapEndian(pSecondary);
#endif
- p->sFontname += OUStringLiteral(u";") + pSecondary;
+ p->sFontname += OUString::Concat(";") + pSecondary;
}
// #i43762# check font name for illegal characters
@@ -7503,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
@@ -7521,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 )
@@ -7543,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);
@@ -7558,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;
}
@@ -7568,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);
@@ -7588,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):
@@ -7600,16 +7591,16 @@ WW8Dop::WW8Dop(SvStream& rSt, sal_Int16 nFib, sal_Int32 nPos, sal_uInt32 nSize):
fMirrorMargins(false), fReadOnlyRecommended(false), fDfltTrueType(false),
fPagSuppressTopSpacing(false), fProtEnabled(false), fDispFormFieldSel(false), fRMView(false),
fRMPrint(false), fWriteReservation(false), fLockRev(false), fEmbedFonts(false),
- copts_fNoTabForInd(false), copts_fNoSpaceRaiseLower(false), copts_fSupressSpbfAfterPgBrk(false),
+ copts_fNoTabForInd(false), copts_fNoSpaceRaiseLower(false), copts_fSuppressSpbfAfterPgBrk(false),
copts_fWrapTrailSpaces(false), copts_fMapPrintTextColor(false), copts_fNoColumnBalance(false),
- copts_fConvMailMergeEsc(false), copts_fSupressTopSpacing(false),
+ copts_fConvMailMergeEsc(false), copts_fSuppressTopSpacing(false),
copts_fOrigWordTableRules(false), copts_fTransparentMetafiles(false),
copts_fShowBreaksInFrames(false), copts_fSwapBordersFacingPgs(false), copts_fExpShRtn(false),
rncEdn(0), nEdn(0), epc(0), fPrintFormData(false), fSaveFormData(false), fShadeFormData(false),
fWCFootnoteEdn(false), wvkSaved(0), wScaleSaved(0), zkSaved(0), fRotateFontW6(false),
iGutterPos(false), fNoTabForInd(false), fNoSpaceRaiseLower(false),
- fSupressSpbfAfterPageBreak(false), fWrapTrailSpaces(false), fMapPrintTextColor(false),
- fNoColumnBalance(false), fConvMailMergeEsc(false), fSupressTopSpacing(false),
+ fSuppressSpbfAfterPageBreak(false), fWrapTrailSpaces(false), fMapPrintTextColor(false),
+ fNoColumnBalance(false), fConvMailMergeEsc(false), fSuppressTopSpacing(false),
fOrigWordTableRules(false), fTransparentMetafiles(false), fShowBreaksInFrames(false),
fSwapBordersFacingPgs(false), fCompatibilityOptions_Unknown1_13(false), fExpShRtn(false),
fCompatibilityOptions_Unknown1_15(false), fCompatibilityOptions_Unknown1_16(false),
@@ -7627,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),
@@ -7713,12 +7704,12 @@ WW8Dop::WW8Dop(SvStream& rSt, sal_Int16 nFib, sal_Int32 nPos, sal_uInt32 nSize):
a8Bit = Get_Byte( pData ); // 8 0x08
copts_fNoTabForInd = 0 != ( a8Bit & 0x01 );
copts_fNoSpaceRaiseLower = 0 != ( a8Bit & 0x02 );
- copts_fSupressSpbfAfterPgBrk = 0 != ( a8Bit & 0x04 );
+ copts_fSuppressSpbfAfterPgBrk = 0 != ( a8Bit & 0x04 );
copts_fWrapTrailSpaces = 0 != ( a8Bit & 0x08 );
copts_fMapPrintTextColor = 0 != ( a8Bit & 0x10 );
copts_fNoColumnBalance = 0 != ( a8Bit & 0x20 );
copts_fConvMailMergeEsc = 0 != ( a8Bit & 0x40 );
- copts_fSupressTopSpacing = 0 != ( a8Bit & 0x80 );
+ copts_fSuppressTopSpacing = 0 != ( a8Bit & 0x80 );
a8Bit = Get_Byte( pData ); // 9 0x09
copts_fOrigWordTableRules = 0 != ( a8Bit & 0x01 );
@@ -7869,17 +7860,17 @@ WW8Dop::WW8Dop():
fMirrorMargins(false), fReadOnlyRecommended(false), fDfltTrueType(true),
fPagSuppressTopSpacing(false), fProtEnabled(false), fDispFormFieldSel(false), fRMView(true),
fRMPrint(true), fWriteReservation(false), fLockRev(false), fEmbedFonts(false),
- copts_fNoTabForInd(false), copts_fNoSpaceRaiseLower(false), copts_fSupressSpbfAfterPgBrk(false),
+ copts_fNoTabForInd(false), copts_fNoSpaceRaiseLower(false), copts_fSuppressSpbfAfterPgBrk(false),
copts_fWrapTrailSpaces(false), copts_fMapPrintTextColor(false), copts_fNoColumnBalance(false),
- copts_fConvMailMergeEsc(false), copts_fSupressTopSpacing(false),
+ copts_fConvMailMergeEsc(false), copts_fSuppressTopSpacing(false),
copts_fOrigWordTableRules(false), copts_fTransparentMetafiles(false),
copts_fShowBreaksInFrames(false), copts_fSwapBordersFacingPgs(false), copts_fExpShRtn(false),
dxaTab(0x2d0), dxaHotZ(0x168), nRevision(1),
rncEdn(0), nEdn(1), epc(3), fPrintFormData(false), fSaveFormData(false), fShadeFormData(true),
fWCFootnoteEdn(false), wvkSaved(2), wScaleSaved(100), zkSaved(0), fRotateFontW6(false),
iGutterPos(false), fNoTabForInd(false), fNoSpaceRaiseLower(false),
- fSupressSpbfAfterPageBreak(false), fWrapTrailSpaces(false), fMapPrintTextColor(false),
- fNoColumnBalance(false), fConvMailMergeEsc(false), fSupressTopSpacing(false),
+ fSuppressSpbfAfterPageBreak(false), fWrapTrailSpaces(false), fMapPrintTextColor(false),
+ fNoColumnBalance(false), fConvMailMergeEsc(false), fSuppressTopSpacing(false),
fOrigWordTableRules(false), fTransparentMetafiles(false), fShowBreaksInFrames(false),
fSwapBordersFacingPgs(false), fCompatibilityOptions_Unknown1_13(false), fExpShRtn(false),
fCompatibilityOptions_Unknown1_15(false), fCompatibilityOptions_Unknown1_16(false),
@@ -7898,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),
@@ -7931,12 +7922,12 @@ void WW8Dop::SetCompatibilityOptions(sal_uInt32 a32Bit)
{
fNoTabForInd = ( a32Bit & 0x00000001 ) ;
fNoSpaceRaiseLower = ( a32Bit & 0x00000002 ) >> 1 ;
- fSupressSpbfAfterPageBreak = ( a32Bit & 0x00000004 ) >> 2 ;
+ fSuppressSpbfAfterPageBreak = ( a32Bit & 0x00000004 ) >> 2 ;
fWrapTrailSpaces = ( a32Bit & 0x00000008 ) >> 3 ;
fMapPrintTextColor = ( a32Bit & 0x00000010 ) >> 4 ;
fNoColumnBalance = ( a32Bit & 0x00000020 ) >> 5 ;
fConvMailMergeEsc = ( a32Bit & 0x00000040 ) >> 6 ;
- fSupressTopSpacing = ( a32Bit & 0x00000080 ) >> 7 ;
+ fSuppressTopSpacing = ( a32Bit & 0x00000080 ) >> 7 ;
fOrigWordTableRules = ( a32Bit & 0x00000100 ) >> 8 ;
fTransparentMetafiles = ( a32Bit & 0x00000200 ) >> 9 ;
fShowBreaksInFrames = ( a32Bit & 0x00000400 ) >> 10 ;
@@ -7969,12 +7960,12 @@ sal_uInt32 WW8Dop::GetCompatibilityOptions() const
sal_uInt32 a32Bit = 0;
if (fNoTabForInd) a32Bit |= 0x00000001;
if (fNoSpaceRaiseLower) a32Bit |= 0x00000002;
- if (fSupressSpbfAfterPageBreak) a32Bit |= 0x00000004;
+ if (fSuppressSpbfAfterPageBreak) a32Bit |= 0x00000004;
if (fWrapTrailSpaces) a32Bit |= 0x00000008;
if (fMapPrintTextColor) a32Bit |= 0x00000010;
if (fNoColumnBalance) a32Bit |= 0x00000020;
if (fConvMailMergeEsc) a32Bit |= 0x00000040;
- if (fSupressTopSpacing) a32Bit |= 0x00000080;
+ if (fSuppressTopSpacing) a32Bit |= 0x00000080;
if (fOrigWordTableRules) a32Bit |= 0x00000100;
if (fTransparentMetafiles) a32Bit |= 0x00000200;
if (fShowBreaksInFrames) a32Bit |= 0x00000400;
@@ -8015,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 ;
@@ -8052,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
@@ -8152,12 +8143,12 @@ void WW8Dop::Write(SvStream& rStrm, WW8Fib& rFib) const
a8Bit = 0; // 8 0x08
if( copts_fNoTabForInd ) a8Bit |= 0x01;
if( copts_fNoSpaceRaiseLower ) a8Bit |= 0x02;
- if( copts_fSupressSpbfAfterPgBrk ) a8Bit |= 0x04;
+ if( copts_fSuppressSpbfAfterPgBrk ) a8Bit |= 0x04;
if( copts_fWrapTrailSpaces ) a8Bit |= 0x08;
if( copts_fMapPrintTextColor ) a8Bit |= 0x10;
if( copts_fNoColumnBalance ) a8Bit |= 0x20;
if( copts_fConvMailMergeEsc ) a8Bit |= 0x40;
- if( copts_fSupressTopSpacing ) a8Bit |= 0x80;
+ if( copts_fSuppressTopSpacing ) a8Bit |= 0x80;
Set_UInt8( pData, a8Bit );
a8Bit = 0; // 9 0x09
@@ -8211,6 +8202,11 @@ void WW8Dop::Write(SvStream& rStrm, WW8Fib& rFib) const
a16Bit |= 0x0007;
a16Bit |= (0x0ff8 & (wScaleSaved << 3));
a16Bit |= (0x3000 & (zkSaved << 12));
+ if (iGutterPos)
+ {
+ // Last bit: gutter at top.
+ a16Bit |= 0x8000;
+ }
Set_UInt16( pData, a16Bit );
if( 8 == rFib.m_nVersion )
@@ -8399,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)
{
@@ -8418,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)
@@ -8434,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 187bd0b513f3..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
@@ -1655,12 +1656,12 @@ public:
// compatibility options
bool copts_fNoTabForInd : 1 /*= false*/; // when 1, don't add automatic tab stops for hanging indent
bool copts_fNoSpaceRaiseLower : 1 /*= false*/; // when 1, don't add extra space for raised or lowered characters
- bool copts_fSupressSpbfAfterPgBrk : 1 /*= false*/; // when 1, suppress the paragraph Space Before and Space After options after a page break
+ bool copts_fSuppressSpbfAfterPgBrk : 1 /*= false*/; // when 1, suppress the paragraph Space Before and Space After options after a page break
bool copts_fWrapTrailSpaces : 1 /*= false*/; // when 1, wrap trailing spaces at the end of a line to the next line
bool copts_fMapPrintTextColor : 1 /*= false*/; // when 1, print colors as black on non-color printers
bool copts_fNoColumnBalance : 1 /*= false*/; // when 1, don't balance columns for Continuous Section starts
bool copts_fConvMailMergeEsc : 1 /*= false*/;
- bool copts_fSupressTopSpacing : 1 /*= false*/; // when 1, suppress extra line spacing at top of page
+ bool copts_fSuppressTopSpacing : 1 /*= false*/; // when 1, suppress extra line spacing at top of page
bool copts_fOrigWordTableRules : 1 /*= false*/; // when 1, combine table borders like Word 5.x for the Macintosh
bool copts_fTransparentMetafiles : 1 /*= false*/; // when 1, don't blank area between metafile pictures
bool copts_fShowBreaksInFrames : 1 /*= false*/; // when 1, show hard page or column breaks in frames
@@ -1710,12 +1711,12 @@ public:
*/
bool fNoTabForInd : 1 /*= false*/; // see above in compatibility options
bool fNoSpaceRaiseLower : 1 /*= false*/; // see above
- bool fSupressSpbfAfterPageBreak : 1 /*= false*/; // see above
+ bool fSuppressSpbfAfterPageBreak : 1 /*= false*/; // see above
bool fWrapTrailSpaces : 1 /*= false*/; // see above
bool fMapPrintTextColor : 1 /*= false*/; // see above
bool fNoColumnBalance : 1 /*= false*/; // see above
bool fConvMailMergeEsc : 1 /*= false*/; // see above
- bool fSupressTopSpacing : 1 /*= false*/; // see above
+ bool fSuppressTopSpacing : 1 /*= false*/; // see above
bool fOrigWordTableRules : 1 /*= false*/; // see above
bool fTransparentMetafiles : 1 /*= false*/; // see above
bool fShowBreaksInFrames : 1 /*= false*/; // see above
@@ -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 fea93ae66850..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
- const OUString sMenuBar( "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;
diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
index 34cf4ac4b6d0..1c7df7bee964 100644
--- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx
+++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
@@ -33,9 +33,13 @@
#include <IDocumentStylePoolAccess.hxx>
#include <tools/datetime.hxx>
#include <poolfmt.hxx>
+#include <fmtanchr.hxx>
+#include <ftnidx.hxx>
+#include <txtftn.hxx>
#include <unoredline.hxx>
#include <DocumentRedlineManager.hxx>
#include "xmlimp.hxx"
+#include <comphelper/servicehelper.hxx>
#include <o3tl/any.hxx>
#include <xmloff/xmltoken.hxx>
#include <vcl/svapp.hxx>
@@ -47,7 +51,6 @@ using namespace ::xmloff::token;
using ::com::sun::star::text::XTextCursor;
using ::com::sun::star::text::XTextRange;
using ::com::sun::star::text::XWordCursor;
-using ::com::sun::star::lang::XUnoTunnel;
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::beans::XPropertySetInfo;
// collision with tools/DateTime: use UNO DateTime as util::DateTime
@@ -56,20 +59,16 @@ using ::com::sun::star::beans::XPropertySetInfo;
// a few helper functions
static SwDoc* lcl_GetDocViaTunnel( Reference<XTextCursor> const & rCursor )
{
- Reference<XUnoTunnel> xTunnel( rCursor, UNO_QUERY);
- OSL_ENSURE(xTunnel.is(), "missing XUnoTunnel for XTextCursor");
OTextCursorHelper *const pXCursor =
- ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xTunnel);
+ dynamic_cast<OTextCursorHelper*>(rCursor.get());
OSL_ENSURE( pXCursor, "OTextCursorHelper missing" );
return pXCursor ? pXCursor->GetDoc() : nullptr;
}
static SwDoc* lcl_GetDocViaTunnel( Reference<XTextRange> const & rRange )
{
- Reference<XUnoTunnel> xTunnel(rRange, UNO_QUERY);
- OSL_ENSURE(xTunnel.is(), "missing XUnoTunnel for XTextRange");
- SwXTextRange *const pXRange =
- ::sw::UnoTunnelGetImplementation<SwXTextRange>(xTunnel);
+ SwXTextRange *const pXRange = dynamic_cast<SwXTextRange*>(rRange.get());
+ OSL_ENSURE(pXRange, "missing SwXTextRange for XTextRange");
// #i115174#: this may be a SvxUnoTextRange
// OSL_ENSURE( pXRange, "SwXTextRange missing" );
return pXRange ? &pXRange->GetDoc() : nullptr;
@@ -87,14 +86,14 @@ namespace {
class XTextRangeOrNodeIndexPosition
{
- Reference<XTextRange> xRange;
- std::unique_ptr<SwNodeIndex> pIndex; // pIndex will point to the *previous* node
+ Reference<XTextRange> m_xRange;
+ std::optional<SwNodeIndex> m_oIndex; // pIndex will point to the *previous* node
public:
XTextRangeOrNodeIndexPosition();
void Set( Reference<XTextRange> const & rRange );
- void Set( SwNodeIndex const & rIndex );
+ void Set( SwNode const & rIndex );
void SetAsNodeIndex( Reference<XTextRange> const & rRange );
void CopyPositionInto(SwPosition& rPos, SwDoc & rDoc);
@@ -111,15 +110,15 @@ XTextRangeOrNodeIndexPosition::XTextRangeOrNodeIndexPosition()
void XTextRangeOrNodeIndexPosition::Set( Reference<XTextRange> const & rRange )
{
- xRange = rRange->getStart(); // set bookmark
- pIndex.reset();
+ m_xRange = rRange->getStart(); // set bookmark
+ m_oIndex.reset();
}
-void XTextRangeOrNodeIndexPosition::Set( SwNodeIndex const & rIndex )
+void XTextRangeOrNodeIndexPosition::Set( SwNode const & rIndex )
{
- pIndex.reset( new SwNodeIndex(rIndex) );
- (*pIndex)-- ; // previous node!!!
- xRange = nullptr;
+ m_oIndex = rIndex;
+ --(*m_oIndex) ; // previous node!!!
+ m_xRange = nullptr;
}
void XTextRangeOrNodeIndexPosition::SetAsNodeIndex(
@@ -140,7 +139,7 @@ void XTextRangeOrNodeIndexPosition::SetAsNodeIndex(
OSL_ENSURE(bSuccess, "illegal range");
// PaM -> Index
- Set(aPaM.GetPoint()->nNode);
+ Set(aPaM.GetPoint()->GetNode());
}
void
@@ -149,19 +148,17 @@ XTextRangeOrNodeIndexPosition::CopyPositionInto(SwPosition& rPos, SwDoc & rDoc)
OSL_ENSURE(IsValid(), "Can't get Position");
// create PAM from start cursor (if no node index is present)
- if (nullptr == pIndex)
+ if (!m_oIndex.has_value())
{
SwUnoInternalPaM aUnoPaM(rDoc);
- bool bSuccess = ::sw::XTextRangeToSwPaM(aUnoPaM, xRange);
+ bool bSuccess = ::sw::XTextRangeToSwPaM(aUnoPaM, m_xRange);
OSL_ENSURE(bSuccess, "illegal range");
rPos = *aUnoPaM.GetPoint();
}
else
{
- rPos.nNode = *pIndex;
- rPos.nNode++; // pIndex points to previous index !!!
- rPos.nContent.Assign( rPos.nNode.GetNode().GetContentNode(), 0 );
+ rPos.Assign( m_oIndex->GetNode(), SwNodeOffset(1) ); // pIndex points to previous index !!!
}
}
@@ -169,12 +166,12 @@ SwDoc* XTextRangeOrNodeIndexPosition::GetDoc()
{
OSL_ENSURE(IsValid(), "Can't get Doc");
- return (nullptr != pIndex) ? &pIndex->GetNodes().GetDoc() : lcl_GetDocViaTunnel(xRange);
+ return m_oIndex.has_value() ? &m_oIndex->GetNodes().GetDoc() : lcl_GetDocViaTunnel(m_xRange);
}
bool XTextRangeOrNodeIndexPosition::IsValid() const
{
- return ( xRange.is() || (pIndex != nullptr) );
+ return m_xRange.is() || m_oIndex.has_value();
}
// RedlineInfo: temporary storage for redline data
@@ -191,6 +188,7 @@ public:
OUString sAuthor; // change author string
OUString sComment; // change comment string
util::DateTime aDateTime; // change DateTime
+ OUString sMovedID; // change move id string
bool bMergeLastParagraph; // the SwRangeRedline::IsDelLastPara flag
// each position can may be either empty, an XTextRange, or an SwNodeIndex
@@ -213,12 +211,7 @@ public:
RedlineInfo::RedlineInfo() :
eType(RedlineType::Insert),
- sAuthor(),
- sComment(),
- aDateTime(),
bMergeLastParagraph( false ),
- aAnchorStart(),
- aAnchorEnd(),
pContentIndex(nullptr),
pNextRedline(nullptr),
bNeedsAdjustment( false )
@@ -231,21 +224,19 @@ RedlineInfo::~RedlineInfo()
delete pNextRedline;
}
-constexpr OUStringLiteral g_sShowChanges = u"ShowChanges";
-constexpr OUStringLiteral g_sRecordChanges = u"RecordChanges";
-constexpr OUStringLiteral g_sRedlineProtectionKey = u"RedlineProtectionKey";
+constexpr OUString g_sShowChanges = u"ShowChanges"_ustr;
+constexpr OUString g_sRecordChanges = u"RecordChanges"_ustr;
+constexpr OUString g_sRedlineProtectionKey = u"RedlineProtectionKey"_ustr;
XMLRedlineImportHelper::XMLRedlineImportHelper(
- SvXMLImport & rImport,
+ SwXMLImport & rImport,
bool bNoRedlinesPlease,
const Reference<XPropertySet> & rModel,
const Reference<XPropertySet> & rImportInfo )
- : m_rImport(rImport)
- ,
+ : m_rImport(rImport),
m_sInsertion( GetXMLToken( XML_INSERTION )),
m_sDeletion( GetXMLToken( XML_DELETION )),
m_sFormatChange( GetXMLToken( XML_FORMAT_CHANGE )),
- m_aRedlineMap(),
m_bIgnoreRedlines(bNoRedlinesPlease),
m_xModelPropertySet(rModel),
m_xImportInfoPropertySet(rImportInfo)
@@ -281,7 +272,7 @@ XMLRedlineImportHelper::XMLRedlineImportHelper(
// set redline mode to "don't record changes"
if( bHandleRecordChanges )
{
- m_xModelPropertySet->setPropertyValue( g_sRecordChanges, makeAny(false) );
+ m_xModelPropertySet->setPropertyValue( g_sRecordChanges, Any(false) );
}
}
@@ -348,7 +339,7 @@ XMLRedlineImportHelper::~XMLRedlineImportHelper()
aAny <<= true;
m_xModelPropertySet->setPropertyValue( g_sShowChanges, aAny );
// TODO maybe we need some property for the view-setting?
- SwDoc *const pDoc(SwImport::GetDocFromXMLImport(m_rImport));
+ SwDoc *const pDoc(m_rImport.getDoc());
assert(pDoc);
pDoc->GetDocumentRedlineManager().SetHideRedlines(!m_bShowChanges);
}
@@ -379,6 +370,7 @@ void XMLRedlineImportHelper::Add(
const OUString& rAuthor,
const OUString& rComment,
const util::DateTime& rDateTime,
+ const OUString& rMovedID,
bool bMergeLastPara)
{
// we need to do the following:
@@ -416,8 +408,17 @@ void XMLRedlineImportHelper::Add(
pInfo->sAuthor = rAuthor;
pInfo->sComment = rComment;
pInfo->aDateTime = rDateTime;
+ pInfo->sMovedID = rMovedID;
pInfo->bMergeLastParagraph = bMergeLastPara;
+ //reserve MoveID so it won't be reused by others
+ if (!rMovedID.isEmpty())
+ {
+ SwDoc* const pDoc(m_rImport.getDoc());
+ assert(pDoc);
+ pDoc->GetDocumentRedlineManager().GetRedlineTable().setMovedIDIfNeeded(rMovedID.toInt32());
+ }
+
// ad 3)
auto itPair = m_aRedlineMap.emplace(rId, pInfo);
if (itPair.second)
@@ -476,11 +477,11 @@ Reference<XTextCursor> XMLRedlineImportHelper::CreateRedlineTextSection(
// create (UNO-) cursor
SwPosition aPos(*pRedlineNode);
- SwXTextCursor *const pXCursor =
- new SwXTextCursor(*pDoc, pXText.get(), CursorType::Redline, aPos);
+ rtl::Reference<SwXTextCursor> pXCursor =
+ new SwXTextCursor(*pDoc, pXText, CursorType::Redline, aPos);
pXCursor->GetCursor().Move(fnMoveForward, GoInNode);
// cast to avoid ambiguity
- xReturn = static_cast<text::XWordCursor*>(pXCursor);
+ xReturn = static_cast<text::XWordCursor*>(pXCursor.get());
}
// else: unknown redline -> Ignore
@@ -572,6 +573,73 @@ inline bool XMLRedlineImportHelper::IsReady(const RedlineInfo* pRedline)
!pRedline->bNeedsAdjustment );
}
+/// recursively check if rPos or its anchor (if in fly or footnote) is in redline section
+static auto RecursiveContains(SwStartNode const& rRedlineSection, SwNode const& rPos) -> bool
+{
+ if (rRedlineSection.GetIndex() <= rPos.GetIndex()
+ && rPos.GetIndex() <= rRedlineSection.EndOfSectionIndex())
+ {
+ return true;
+ }
+ // loop to iterate "up" in the node tree and find an anchored XText
+ for (SwStartNode const* pStartNode = rPos.StartOfSectionNode();
+ pStartNode != nullptr && pStartNode->GetIndex() != SwNodeOffset(0);
+ pStartNode = pStartNode->StartOfSectionNode())
+ {
+ switch (pStartNode->GetStartNodeType())
+ {
+ case SwNormalStartNode:
+ case SwTableBoxStartNode:
+ continue;
+ break;
+ case SwFlyStartNode:
+ {
+ SwFrameFormat const*const pFormat(pStartNode->GetFlyFormat());
+ assert(pFormat);
+ SwFormatAnchor const& rAnchor(pFormat->GetAnchor());
+ if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PAGE)
+ {
+ return false;
+ }
+ else if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_FLY)
+ { // anchor is on a start node, avoid skipping it:
+ pStartNode = rAnchor.GetAnchorNode()->GetStartNode();
+ assert(pStartNode);
+ // pass the next node to recursive call - it will call
+ // call StartOfSectionNode on it and go back to pStartNode
+ SwNodeIndex const next(*pStartNode, +1);
+ return RecursiveContains(rRedlineSection, next.GetNode());
+ }
+ else
+ {
+ return RecursiveContains(rRedlineSection, *rAnchor.GetAnchorNode());
+ }
+ }
+ break;
+ case SwFootnoteStartNode:
+ { // sigh ... need to search
+ for (SwTextFootnote const*const pFootnote : rRedlineSection.GetDoc().GetFootnoteIdxs())
+ {
+ if (pStartNode == pFootnote->GetStartNode()->GetNode().GetStartNode())
+ {
+ return RecursiveContains(rRedlineSection, pFootnote->GetTextNode());
+ }
+ }
+ assert(false);
+ }
+ break;
+ case SwHeaderStartNode:
+ case SwFooterStartNode:
+ return false; // headers aren't anchored
+ break;
+ default:
+ assert(false);
+ break;
+ }
+ }
+ return false;
+}
+
void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo)
{
OSL_ENSURE(nullptr != pRedlineInfo, "need redline info");
@@ -619,8 +687,8 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo)
// in sw3io), so no action here
}
else if ( m_bIgnoreRedlines ||
- !CheckNodesRange( aPaM.GetPoint()->nNode,
- aPaM.GetMark()->nNode,
+ !CheckNodesRange( aPaM.GetPoint()->GetNode(),
+ aPaM.GetMark()->GetNode(),
true )
|| (pRedlineInfo->pContentIndex
&& (pRedlineInfo->pContentIndex->GetIndex() + 2
@@ -628,7 +696,7 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo)
&& (pTempNode = pDoc->GetNodes()[pRedlineInfo->pContentIndex->GetIndex() + 1]->GetTextNode()) != nullptr
&& pTempNode->GetText().isEmpty()
&& !pTempNode->GetpSwpHints()
- && !pTempNode->GetAnchoredFlys()))
+ && pTempNode->GetAnchoredFlys().empty()))
{
// ignore redline (e.g. file loaded in insert mode):
// delete 'deleted' redlines and forget about the whole thing
@@ -639,17 +707,26 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo)
// They have to be deleted as well (#i80689)!
if( m_bIgnoreRedlines && pRedlineInfo->pContentIndex != nullptr )
{
- SwNodeIndex aIdx( *pRedlineInfo->pContentIndex );
- const SwNode* pEnd = aIdx.GetNode().EndOfSectionNode();
+ const SwNodeIndex& rIdx( *pRedlineInfo->pContentIndex );
+ const SwNode* pEnd = rIdx.GetNode().EndOfSectionNode();
if( pEnd )
{
- SwNodeIndex aEnd( *pEnd, 1 );
- SwPaM aDel( aIdx, aEnd );
+ SwPaM aDel( rIdx.GetNode(), 0, *pEnd, 1 );
pDoc->getIDocumentContentOperations().DeleteRange(aDel);
}
}
}
}
+ else if (pRedlineInfo->pContentIndex != nullptr
+ // should be enough to check 1 position of aPaM bc CheckNodesRange() above
+ && RecursiveContains(*pRedlineInfo->pContentIndex->GetNode().GetStartNode(), aPaM.GetPoint()->GetNode()))
+ {
+ SAL_WARN("sw.xml", "Recursive change tracking, removing");
+ // reuse aPaM to remove it from nodes that will be deleted
+ aPaM.GetPoint()->Assign(pRedlineInfo->pContentIndex->GetNode());
+ aPaM.DeleteMark();
+ pDoc->getIDocumentContentOperations().DeleteSection(&aPaM.GetPoint()->GetNode());
+ }
else
{
// regular file loading: insert redline
@@ -660,6 +737,22 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo)
new SwRangeRedline( pRedlineData, *aPaM.GetPoint(),
!pRedlineInfo->bMergeLastParagraph );
+ // tdf#107292 fix order of delete redlines at the same position by removing
+ // the already inserted redlines temporarily and inserting them back in reverse
+ // order after inserting pRedline
+ std::vector<const SwRangeRedline*> aSwapRedlines;
+ if ( RedlineType::Delete == pRedlineInfo->eType )
+ {
+ SwRedlineTable::size_type n = 0;
+ while ( const SwRangeRedline* pRedline2 =
+ pDoc->getIDocumentRedlineAccess().GetRedline( *pRedline->Start(), &n ) )
+ {
+ SwRedlineTable& aRedlineTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
+ aSwapRedlines.push_back(pRedline2);
+ aRedlineTable.Remove(n);
+ }
+ }
+
// set mark
if( aPaM.HasMark() )
{
@@ -670,19 +763,22 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo)
// set content node (if necessary)
if (nullptr != pRedlineInfo->pContentIndex)
{
- sal_uLong nPoint = aPaM.GetPoint()->nNode.GetIndex();
+ SwNodeOffset nPoint = aPaM.GetPoint()->GetNodeIndex();
if( nPoint < pRedlineInfo->pContentIndex->GetIndex() ||
nPoint > pRedlineInfo->pContentIndex->GetNode().EndOfSectionIndex() )
- pRedline->SetContentIdx(pRedlineInfo->pContentIndex);
-#if OSL_DEBUG_LEVEL > 1
+ pRedline->SetContentIdx(*pRedlineInfo->pContentIndex);
else
- OSL_FAIL( "Recursive change tracking" );
-#endif
+ SAL_WARN("sw", "Recursive change tracking");
}
// set redline mode (without doing the associated book-keeping)
pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern(RedlineFlags::On);
pDoc->getIDocumentRedlineAccess().AppendRedline(pRedline, false);
+
+ // restore the correct order of the delete redlines at the same position
+ for (auto i = aSwapRedlines.rbegin(); i != aSwapRedlines.rend(); ++i)
+ pDoc->getIDocumentRedlineAccess().AppendRedline(const_cast<SwRangeRedline*>(*i), false);
+
pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern(RedlineFlags::NONE);
}
}
@@ -706,6 +802,8 @@ SwRedlineData* XMLRedlineImportHelper::ConvertRedline(
aDT.SetSec( pRedlineInfo->aDateTime.Seconds );
aDT.SetNanoSec( pRedlineInfo->aDateTime.NanoSeconds );
+ sal_uInt32 nMovedID = pRedlineInfo->sMovedID.toInt32();
+
// 3) recursively convert next redline
// ( check presence and sanity of hierarchical redline info )
SwRedlineData* pNext = nullptr;
@@ -718,7 +816,7 @@ SwRedlineData* XMLRedlineImportHelper::ConvertRedline(
// create redline data
SwRedlineData* pData = new SwRedlineData(pRedlineInfo->eType,
- nAuthorId, aDT,
+ nAuthorId, aDT, nMovedID,
pRedlineInfo->sComment,
pNext); // next data (if available)
diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.hxx b/sw/source/filter/xml/XMLRedlineImportHelper.hxx
index 69e530fbd91e..8a15f53dfb88 100644
--- a/sw/source/filter/xml/XMLRedlineImportHelper.hxx
+++ b/sw/source/filter/xml/XMLRedlineImportHelper.hxx
@@ -32,6 +32,7 @@ class SvXMLImport;
class RedlineInfo;
class SwRedlineData;
class SwDoc;
+class SwXMLImport;
namespace com::sun::star {
namespace text { class XTextCursor; }
namespace text { class XTextRange; }
@@ -42,7 +43,7 @@ typedef std::map< OUString, RedlineInfo* > RedlineMapType;
class XMLRedlineImportHelper final
{
- SvXMLImport & m_rImport;
+ SwXMLImport & m_rImport;
const OUString m_sInsertion;
const OUString m_sDeletion;
@@ -64,7 +65,7 @@ class XMLRedlineImportHelper final
public:
XMLRedlineImportHelper(
- SvXMLImport & rImport,
+ SwXMLImport & rImport,
bool bIgnoreRedlines, // ignore redlines mode
// property sets of model + import info for saving + restoring the
// redline mode
@@ -81,6 +82,7 @@ public:
const OUString& rAuthor, // name of the author
const OUString& rComment, // redline comment
const css::util::DateTime& rDateTime, // date+time
+ const OUString& rMovedID, // redline move id
bool bMergeLastParagraph); // merge last paragraph?
// create a text section for the redline, and return an
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index c3d9c50556da..16ae089113b8 100644
--- a/sw/source/filter/xml/swxml.cxx
+++ b/sw/source/filter/xml/swxml.cxx
@@ -56,6 +56,7 @@
#include <docfunc.hxx>
#include <IDocumentSettingAccess.hxx>
#include <IDocumentDrawModelAccess.hxx>
+#include <IDocumentMarkAccess.hxx>
#include <IDocumentRedlineAccess.hxx>
#include <DocumentRedlineManager.hxx>
#include <docary.hxx>
@@ -78,7 +79,7 @@
#include <istyleaccess.hxx>
#include <sfx2/DocumentMetadataAccess.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -89,18 +90,18 @@ using namespace ::com::sun::star::lang;
static void lcl_EnsureValidPam( SwPaM& rPam )
{
- if( rPam.GetContentNode() != nullptr )
+ if( rPam.GetPointContentNode() != nullptr )
{
// set proper point content
- if( rPam.GetContentNode() != rPam.GetPoint()->nContent.GetIdxReg() )
+ if( rPam.GetPointContentNode() != rPam.GetPoint()->GetContentNode() )
{
- rPam.GetPoint()->nContent.Assign( rPam.GetContentNode(), 0 );
+ rPam.GetPoint()->nContent.Assign( rPam.GetPointContentNode(), 0 );
}
// else: point was already valid
// if mark is invalid, we delete it
- if( ( rPam.GetContentNode( false ) == nullptr ) ||
- ( rPam.GetContentNode( false ) != rPam.GetMark()->nContent.GetIdxReg() ) )
+ if( ( rPam.GetMarkContentNode() == nullptr ) ||
+ ( rPam.GetMarkContentNode() != rPam.GetMark()->GetContentNode() ) )
{
rPam.DeleteMark();
}
@@ -109,9 +110,9 @@ static void lcl_EnsureValidPam( SwPaM& rPam )
{
// point is not valid, so move it into the first content
rPam.DeleteMark();
- rPam.GetPoint()->nNode =
- *rPam.GetDoc().GetNodes().GetEndOfContent().StartOfSectionNode();
- ++ rPam.GetPoint()->nNode;
+ rPam.GetPoint()->Assign(
+ *rPam.GetDoc().GetNodes().GetEndOfContent().StartOfSectionNode() );
+ rPam.GetPoint()->Adjust(SwNodeOffset(+1));
rPam.Move( fnMoveForward, GoInContent ); // go into content
}
}
@@ -129,7 +130,7 @@ namespace
{
/// read a component (file + filter version)
-ErrCode ReadThroughComponent(
+ErrCodeMsg ReadThroughComponent(
uno::Reference<io::XInputStream> const & xInputStream,
uno::Reference<XComponent> const & xModelComponent,
const OUString& rStreamName,
@@ -137,7 +138,7 @@ ErrCode ReadThroughComponent(
const char* pFilterName,
const Sequence<Any>& rFilterArguments,
const OUString& rName,
- bool bMustBeSuccessfull,
+ bool bMustBeSuccessful,
bool bEncrypted )
{
OSL_ENSURE(xInputStream.is(), "input stream missing");
@@ -218,16 +219,16 @@ ErrCode ReadThroughComponent(
if( !rStreamName.isEmpty() )
{
- return *new TwoStringErrorInfo(
- (bMustBeSuccessfull ? ERR_FORMAT_FILE_ROWCOL
+ return ErrCodeMsg(
+ (bMustBeSuccessful ? ERR_FORMAT_FILE_ROWCOL
: WARN_FORMAT_FILE_ROWCOL),
rStreamName, sErr,
DialogMask::ButtonsOk | DialogMask::MessageError );
}
else
{
- OSL_ENSURE( bMustBeSuccessfull, "Warnings are not supported" );
- return *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
+ OSL_ENSURE( bMustBeSuccessful, "Warnings are not supported" );
+ return ErrCodeMsg( ERR_FORMAT_ROWCOL, sErr,
DialogMask::ButtonsOk | DialogMask::MessageError );
}
}
@@ -265,7 +266,7 @@ ErrCode ReadThroughComponent(
}
// read a component (storage version)
-ErrCode ReadThroughComponent(
+ErrCodeMsg ReadThroughComponent(
uno::Reference<embed::XStorage> const & xStorage,
uno::Reference<XComponent> const & xModelComponent,
const char* pStreamName,
@@ -273,7 +274,7 @@ ErrCode ReadThroughComponent(
const char* pFilterName,
const Sequence<Any>& rFilterArguments,
const OUString& rName,
- bool bMustBeSuccessfull)
+ bool bMustBeSuccessful)
{
OSL_ENSURE(xStorage.is(), "Need storage!");
OSL_ENSURE(nullptr != pStreamName, "Please, please, give me a name!");
@@ -302,7 +303,7 @@ ErrCode ReadThroughComponent(
OSL_ENSURE( xInfoSet.is(), "missing property set" );
if( xInfoSet.is() )
{
- xInfoSet->setPropertyValue( "StreamName", makeAny( sStreamName ) );
+ xInfoSet->setPropertyValue( "StreamName", Any( sStreamName ) );
}
try
@@ -313,8 +314,8 @@ ErrCode ReadThroughComponent(
Any aAny = xProps->getPropertyValue("Encrypted");
- auto b = o3tl::tryAccess<bool>(aAny);
- bool bEncrypted = b && *b;
+ std::optional<const bool> b = o3tl::tryAccess<bool>(aAny);
+ bool bEncrypted = b.has_value() && *b;
uno::Reference <io::XInputStream> xInputStream = xStream->getInputStream();
@@ -322,7 +323,7 @@ ErrCode ReadThroughComponent(
return ReadThroughComponent(
xInputStream, xModelComponent, sStreamName, rxContext,
pFilterName, rFilterArguments,
- rName, bMustBeSuccessfull, bEncrypted );
+ rName, bMustBeSuccessful, bEncrypted );
}
catch ( packages::WrongPasswordException& )
{
@@ -411,9 +412,9 @@ static void lcl_AdjustOutlineStylesForOOo(SwDoc& _rDoc)
aCreatedDefaultOutlineStyles[ i ]->AssignToListLevelOfOutlineStyle(i);
// apply outline numbering rule, if none is set.
- const SfxPoolItem& rItem =
+ const SwNumRuleItem& rItem =
aCreatedDefaultOutlineStyles[ i ]->GetFormatAttr( RES_PARATR_NUMRULE, false );
- if ( static_cast<const SwNumRuleItem&>(rItem).GetValue().isEmpty() )
+ if ( rItem.GetValue().isEmpty() )
{
SwNumRuleItem aItem( pOutlineRule->GetName() );
aCreatedDefaultOutlineStyles[ i ]->SetFormatAttr( aItem );
@@ -449,7 +450,7 @@ static void lcl_ConvertSdrOle2ObjsToSdrGrafObjs(SwDoc& _rDoc)
pOle2Obj->Disconnect();
// create new graphic shape with the ole graphic and shape size
- SdrGrafObj* pGraphicObj = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGraphicObj = new SdrGrafObj(
pOle2Obj->getSdrModelFromSdrObject(),
aGraphic,
pOle2Obj->GetCurrentBoundRect());
@@ -458,13 +459,12 @@ static void lcl_ConvertSdrOle2ObjsToSdrGrafObjs(SwDoc& _rDoc)
pGraphicObj->SetLayer( pOle2Obj->GetLayer() );
// replace ole2 shape with the new graphic object and delete the ol2 shape
- SdrObject* pReplaced = pObjList->ReplaceObject( pGraphicObj, pOle2Obj->GetOrdNum() );
- SdrObject::Free( pReplaced );
+ pObjList->ReplaceObject( pGraphicObj.get(), pOle2Obj->GetOrdNum() );
}
}
}
-ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, const OUString & rName )
+ErrCodeMsg XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, const OUString & rName )
{
// needed for relative URLs, but in clipboard copy/paste there may be none
// and also there is the SwXMLTextBlocks special case
@@ -517,7 +517,7 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
// the user.
// create XPropertySet with three properties for status indicator
- comphelper::PropertyMapEntry const aInfoMap[] =
+ static comphelper::PropertyMapEntry const aInfoMap[] =
{
{ OUString("ProgressRange"), 0,
::cppu::UnoType<sal_Int32>::get(),
@@ -591,7 +591,6 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
beans::PropertyAttribute::MAYBEVOID, 0 },
{ OUString("SourceStorage"), 0, cppu::UnoType<embed::XStorage>::get(),
css::beans::PropertyAttribute::MAYBEVOID, 0 },
- { OUString(), 0, css::uno::Type(), 0, 0 }
};
uno::Reference< beans::XPropertySet > xInfoSet(
comphelper::GenericPropertySet_CreateInstance(
@@ -605,7 +604,7 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
if( xParentSet.is() )
{
uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xParentSet->getPropertySetInfo() );
- const OUString sPropName("BuildId" );
+ static constexpr OUString sPropName(u"BuildId"_ustr );
if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(sPropName) )
{
xInfoSet->setPropertyValue( sPropName, xParentSet->getPropertyValue(sPropName) );
@@ -618,15 +617,11 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
if (pDocSh->GetMedium())
{
- SfxItemSet* pSet = pDocSh->GetMedium()->GetItemSet();
- if (pSet)
+ const SfxUnoAnyItem* pItem =
+ pDocSh->GetMedium()->GetItemSet().GetItem(SID_PROGRESS_STATUSBAR_CONTROL);
+ if (pItem)
{
- const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>(
- pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) );
- if (pItem)
- {
- pItem->GetValue() >>= xStatusIndicator;
- }
+ pItem->GetValue() >>= xStatusIndicator;
}
}
@@ -641,7 +636,7 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
xInfoSet->setPropertyValue("ProgressRange", aProgRange);
Reference< container::XNameAccess > xLateInitSettings( document::NamedPropertyValues::create(xContext), UNO_QUERY_THROW );
- beans::NamedValue aLateInitSettings( "LateInitSettings", makeAny( xLateInitSettings ) );
+ beans::NamedValue aLateInitSettings( "LateInitSettings", Any( xLateInitSettings ) );
xInfoSet->setPropertyValue( "SourceStorage", Any( xStorage ) );
@@ -683,16 +678,16 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
*pSeq++ = "NumberingStyles";
xInfoSet->setPropertyValue( "StyleInsertModeFamilies",
- makeAny(aFamiliesSeq) );
+ Any(aFamiliesSeq) );
- xInfoSet->setPropertyValue( "StyleInsertModeOverwrite", makeAny(!m_aOption.IsMerge()) );
+ xInfoSet->setPropertyValue( "StyleInsertModeOverwrite", Any(!m_aOption.IsMerge()) );
}
else if( m_bInsertMode )
{
- const uno::Reference<text::XTextRange> xInsertTextRange =
+ const rtl::Reference<SwXTextRange> xInsertTextRange =
SwXTextRange::CreateXTextRange(rDoc, *rPaM.GetPoint(), nullptr);
xInfoSet->setPropertyValue( "TextInsertModeRange",
- makeAny(xInsertTextRange) );
+ Any(uno::Reference<text::XTextRange>(xInsertTextRange)) );
}
else
{
@@ -702,11 +697,11 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
if( IsBlockMode() )
{
- xInfoSet->setPropertyValue( "AutoTextMode", makeAny(true) );
+ xInfoSet->setPropertyValue( "AutoTextMode", Any(true) );
}
if( IsOrganizerMode() )
{
- xInfoSet->setPropertyValue( "OrganizerMode", makeAny(true) );
+ xInfoSet->setPropertyValue( "OrganizerMode", Any(true) );
}
// Set base URI
@@ -715,16 +710,16 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
SfxMedium* pMedDescrMedium = m_pMedium ? m_pMedium : pDocSh->GetMedium();
OSL_ENSURE( pMedDescrMedium, "There is no medium to get MediaDescriptor from!" );
- xInfoSet->setPropertyValue( "BaseURI", makeAny( rBaseURL ) );
+ xInfoSet->setPropertyValue( "BaseURI", Any( rBaseURL ) );
// TODO/LATER: separate links from usual embedded objects
OUString StreamPath;
if( SfxObjectCreateMode::EMBEDDED == rDoc.GetDocShell()->GetCreateMode() )
{
- if ( pMedDescrMedium && pMedDescrMedium->GetItemSet() )
+ if (pMedDescrMedium)
{
- const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
- pMedDescrMedium->GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
+ const SfxStringItem* pDocHierarchItem =
+ pMedDescrMedium->GetItemSet().GetItem(SID_DOC_HIERARCHICALNAME);
if ( pDocHierarchItem )
StreamPath = pDocHierarchItem->GetValue();
}
@@ -735,23 +730,23 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
if( !StreamPath.isEmpty() )
{
- xInfoSet->setPropertyValue( "StreamRelPath", makeAny( StreamPath ) );
+ xInfoSet->setPropertyValue( "StreamRelPath", Any( StreamPath ) );
}
}
rtl::Reference<SwDoc> aHoldRef(&rDoc); // prevent deletion
- ErrCode nRet = ERRCODE_NONE;
+ ErrCodeMsg nRet = ERRCODE_NONE;
// save redline mode into import info property set
- const OUString sShowChanges("ShowChanges");
- const OUString sRecordChanges("RecordChanges");
- const OUString sRedlineProtectionKey("RedlineProtectionKey");
+ static constexpr OUString sShowChanges(u"ShowChanges"_ustr);
+ static constexpr OUString sRecordChanges(u"RecordChanges"_ustr);
+ static constexpr OUString sRedlineProtectionKey(u"RedlineProtectionKey"_ustr);
xInfoSet->setPropertyValue( sShowChanges,
- makeAny(IDocumentRedlineAccess::IsShowChanges(rDoc.getIDocumentRedlineAccess().GetRedlineFlags())) );
+ Any(IDocumentRedlineAccess::IsShowChanges(rDoc.getIDocumentRedlineAccess().GetRedlineFlags())) );
xInfoSet->setPropertyValue( sRecordChanges,
- makeAny(IDocumentRedlineAccess::IsRedlineOn(rDoc.getIDocumentRedlineAccess().GetRedlineFlags())) );
+ Any(IDocumentRedlineAccess::IsRedlineOn(rDoc.getIDocumentRedlineAccess().GetRedlineFlags())) );
xInfoSet->setPropertyValue( sRedlineProtectionKey,
- makeAny(rDoc.getIDocumentRedlineAccess().GetRedlinePassword()) );
+ Any(rDoc.getIDocumentRedlineAccess().GetRedlinePassword()) );
// force redline mode to "none"
rDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::NONE );
@@ -762,13 +757,13 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
const bool bShapePositionInHoriL2R = !bOASIS;
xInfoSet->setPropertyValue(
"ShapePositionInHoriL2R",
- makeAny( bShapePositionInHoriL2R ) );
+ Any( bShapePositionInHoriL2R ) );
}
{
const bool bTextDocInOOoFileFormat = !bOASIS;
xInfoSet->setPropertyValue(
"TextDocInOOoFileFormat",
- makeAny( bTextDocInOOoFileFormat ) );
+ Any( bTextDocInOOoFileFormat ) );
}
ErrCode nWarnRDF = ERRCODE_NONE;
@@ -811,13 +806,13 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
// read storage streams
// #i103539#: always read meta.xml for generator
- ErrCode const nWarn = ReadThroughComponent(
+ ErrCodeMsg const nWarn = ReadThroughComponent(
xStorage, xModelComp, "meta.xml", xContext,
(bOASIS ? "com.sun.star.comp.Writer.XMLOasisMetaImporter"
: "com.sun.star.comp.Writer.XMLMetaImporter"),
aEmptyArgs, rName, false );
- ErrCode nWarn2 = ERRCODE_NONE;
+ ErrCodeMsg nWarn2 = ERRCODE_NONE;
if( !(IsOrganizerMode() || IsBlockMode() || m_aOption.IsFormatsOnly() ||
m_bInsertMode) )
{
@@ -844,7 +839,10 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
if( !IsOrganizerMode() && !IsBlockMode() && !m_bInsertMode &&
!m_aOption.IsFormatsOnly() &&
// sw_redlinehide: disable layout cache for now
- *o3tl::doAccess<bool>(xInfoSet->getPropertyValue(sShowChanges)))
+ *o3tl::doAccess<bool>(xInfoSet->getPropertyValue(sShowChanges)) &&
+ // sw_fieldmarkhide: also disable if there is a fieldmark
+ rDoc.getIDocumentMarkAccess()->getFieldmarksBegin()
+ == rDoc.getIDocumentMarkAccess()->getFieldmarksEnd())
{
try
{
@@ -866,6 +864,8 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
nRet = nRet ? nRet : (nWarn ? nWarn : (nWarn2 ? nWarn2 : nWarnRDF ) );
+ ::svx::DropUnusedNamedItems(xModelComp);
+
m_aOption.ResetAllFormatsOnly();
// redline password
@@ -946,7 +946,7 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
if( xModelSet.is() )
{
uno::Reference< beans::XPropertySetInfo > xModelSetInfo( xModelSet->getPropertySetInfo() );
- const OUString sName("BuildId" );
+ static constexpr OUString sName(u"BuildId"_ustr );
if( xModelSetInfo.is() && xModelSetInfo->hasPropertyByName(sName) )
{
xModelSet->setPropertyValue( sName, xInfoSet->getPropertyValue(sName) );
@@ -954,6 +954,9 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
}
}
+ // tdf#115815 restore annotation ranges stored in temporary bookmarks
+ rDoc.getIDocumentMarkAccess()->restoreAnnotationMarks();
+
if (xStatusIndicator.is())
{
xStatusIndicator->end();
@@ -976,7 +979,7 @@ size_t XMLReader::GetSectionList( SfxMedium& rMedium,
try
{
xml::sax::InputSource aParserInput;
- const OUString sDocName( "content.xml" );
+ static constexpr OUString sDocName( u"content.xml"_ustr );
aParserInput.sSystemId = sDocName;
uno::Reference < io::XStream > xStm = xStg2->openStreamElement( sDocName, embed::ElementModes::READ );
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx
index 71445d932f4e..17bffab2ca10 100644
--- a/sw/source/filter/xml/wrtxml.cxx
+++ b/sw/source/filter/xml/wrtxml.cxx
@@ -23,20 +23,21 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/task/XStatusIndicator.hpp>
#include <com/sun/star/xml/sax/Writer.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/frame/XModule.hpp>
-#include <com/sun/star/frame/XModel.hpp>
+#include <officecfg/Office/Common.hxx>
#include <comphelper/fileformat.h>
#include <comphelper/processfactory.hxx>
#include <comphelper/genericpropertyset.hxx>
#include <comphelper/propertysetinfo.hxx>
#include <vcl/errinf.hxx>
+#include <osl/diagnose.h>
#include <sal/log.hxx>
#include <svx/xmlgrhlp.hxx>
#include <svx/xmleohlp.hxx>
-#include <unotools/saveopt.hxx>
#include <svl/stritem.hxx>
#include <sfx2/frame.hxx>
#include <sfx2/docfile.hxx>
@@ -45,15 +46,18 @@
#include <doc.hxx>
#include <docfunc.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <IDocumentMarkAccess.hxx>
#include <IDocumentStatistics.hxx>
#include <IDocumentLayoutAccess.hxx>
#include <rootfrm.hxx>
#include <docstat.hxx>
#include <docsh.hxx>
+#include <xmloff/shapeexport.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <swerror.h>
#include "wrtxml.hxx"
+#include "zorder.hxx"
#include <strings.hrc>
#include <comphelper/documentconstants.hxx>
@@ -61,7 +65,6 @@
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::container;
using namespace ::com::sun::star::document;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::lang;
@@ -75,9 +78,27 @@ SwXMLWriter::~SwXMLWriter()
{
}
-ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xStatusIndicator,
- const OUString& aDocHierarchicalName )
+ErrCodeMsg SwXMLWriter::Write_(const SfxItemSet* pMediumItemSet)
{
+ uno::Reference<task::XStatusIndicator> xStatusIndicator;
+ OUString aDocHierarchicalName;
+ bool bNoEmbDS(false);
+
+ if (pMediumItemSet)
+ {
+ const SfxUnoAnyItem* pStatusBarItem =
+ pMediumItemSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL);
+ if (pStatusBarItem)
+ pStatusBarItem->GetValue() >>= xStatusIndicator;
+ const SfxStringItem* pDocHierarchItem =
+ pMediumItemSet->GetItem(SID_DOC_HIERARCHICALNAME);
+ if (pDocHierarchItem)
+ aDocHierarchicalName = pDocHierarchItem->GetValue();
+ const SfxBoolItem* pNoEmbDS = pMediumItemSet->GetItem(SID_NO_EMBEDDED_DS);
+ if (pNoEmbDS)
+ bNoEmbDS = pNoEmbDS->GetValue();
+ }
+
// Get service factory
uno::Reference< uno::XComponentContext > xContext =
comphelper::getProcessComponentContext();
@@ -107,7 +128,7 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
// the user.
// create XPropertySet with three properties for status indicator
- comphelper::PropertyMapEntry const aInfoMap[] =
+ static comphelper::PropertyMapEntry const aInfoMap[] =
{
{ OUString("ProgressRange"), 0,
::cppu::UnoType<sal_Int32>::get(),
@@ -154,7 +175,10 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
beans::PropertyAttribute::MAYBEVOID, 0 },
{ OUString("TargetStorage"),0, cppu::UnoType<embed::XStorage>::get(),
css::beans::PropertyAttribute::MAYBEVOID, 0 },
- { OUString(), 0, css::uno::Type(), 0, 0 }
+ // tdf#144532
+ { OUString("NoEmbDataSet"), 0,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::MAYBEVOID, 0 },
};
uno::Reference< beans::XPropertySet > xInfoSet(
comphelper::GenericPropertySet_CreateInstance(
@@ -162,6 +186,8 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
xInfoSet->setPropertyValue( "TargetStorage", Any( m_xStg ) );
+ xInfoSet->setPropertyValue("NoEmbDataSet", Any(bNoEmbDS));
+
if (m_bShowProgress)
{
// set progress range and start status indicator
@@ -176,8 +202,12 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
xInfoSet->setPropertyValue("ProgressMax", Any(static_cast < sal_Int32 >( -1 )));
}
- SvtSaveOptions aSaveOpt;
- xInfoSet->setPropertyValue( "UsePrettyPrinting", makeAny(aSaveOpt.IsPrettyPrinting()) );
+ xInfoSet->setPropertyValue( "UsePrettyPrinting", Any(officecfg::Office::Common::Save::Document::PrettyPrinting::get()) );
+
+ uno::Reference<lang::XComponent> const xModelComp(m_pDoc->GetDocShell()->GetModel());
+ uno::Reference<drawing::XDrawPageSupplier> const xDPS(xModelComp, uno::UNO_QUERY);
+ assert(xDPS.is());
+ xmloff::FixZOrder(xDPS->getDrawPage(), sw::GetZOrderLayer(m_pDoc->getIDocumentDrawModelAccess()));
// save show redline mode ...
RedlineFlags const nOrigRedlineFlags = m_pDoc->getIDocumentRedlineAccess().GetRedlineFlags();
@@ -186,14 +216,14 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
// TODO: ideally this would be stored per-view...
SwRootFrame const*const pLayout(m_pDoc->getIDocumentLayoutAccess().GetCurrentLayout());
isShowChanges = pLayout == nullptr || !pLayout->IsHideRedlines();
- xInfoSet->setPropertyValue("ShowChanges", makeAny(isShowChanges));
+ xInfoSet->setPropertyValue("ShowChanges", Any(isShowChanges));
// ... and hide redlines for export
nRedlineFlags &= ~RedlineFlags::ShowMask;
nRedlineFlags |= RedlineFlags::ShowInsert;
m_pDoc->getIDocumentRedlineAccess().SetRedlineFlags( nRedlineFlags );
// Set base URI
- xInfoSet->setPropertyValue( "BaseURI", makeAny( GetBaseURL() ) );
+ xInfoSet->setPropertyValue( "BaseURI", Any( GetBaseURL() ) );
if( SfxObjectCreateMode::EMBEDDED == m_pDoc->GetDocShell()->GetCreateMode() )
{
@@ -201,12 +231,12 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
? aDocHierarchicalName
: OUString( "dummyObjectName" ) );
- xInfoSet->setPropertyValue( "StreamRelPath", makeAny( aName ) );
+ xInfoSet->setPropertyValue( "StreamRelPath", Any( aName ) );
}
if( m_bBlock )
{
- xInfoSet->setPropertyValue( "AutoTextMode", makeAny(true) );
+ xInfoSet->setPropertyValue( "AutoTextMode", Any(true) );
}
// #i69627#
@@ -214,7 +244,7 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
if ( bOASIS &&
docfunc::HasOutlineStyleToBeWrittenAsNormalListStyle( *m_pDoc ) )
{
- xInfoSet->setPropertyValue( "OutlineStyleAsNormalListStyle", makeAny( true ) );
+ xInfoSet->setPropertyValue( "OutlineStyleAsNormalListStyle", Any( true ) );
}
// filter arguments
@@ -247,12 +277,6 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
if( xStatusIndicator.is() )
*pArgs++ <<= xStatusIndicator;
- //Get model
- uno::Reference< lang::XComponent > xModelComp = m_pDoc->GetDocShell()->GetModel();
- OSL_ENSURE( xModelComp.is(), "XMLWriter::Write: got no model" );
- if( !xModelComp.is() )
- return ERR_SWG_WRITE_ERROR;
-
PutNumFormatFontsInAttrPool();
PutEditEngFontsInAttrPool();
@@ -409,6 +433,9 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
nRedlineFlags |= nOrigRedlineFlags & RedlineFlags::ShowMask;
m_pDoc->getIDocumentRedlineAccess().SetRedlineFlags( nRedlineFlags );
+ // tdf#115815 restore annotation ranges collapsed by hide redlines
+ m_pDoc->getIDocumentMarkAccess()->restoreAnnotationMarks();
+
if (xStatusIndicator.is())
{
xStatusIndicator->end();
@@ -417,14 +444,14 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
if( bErr )
{
if( !sErrFile.isEmpty() )
- return *new StringErrorInfo( ERR_WRITE_ERROR_FILE, sErrFile,
+ return ErrCodeMsg( ERR_WRITE_ERROR_FILE, sErrFile,
DialogMask::ButtonsOk | DialogMask::MessageError );
return ERR_SWG_WRITE_ERROR;
}
else if( bWarn )
{
if( !sWarnFile.isEmpty() )
- return *new StringErrorInfo( WARN_WRITE_ERROR_FILE, sWarnFile,
+ return ErrCodeMsg( WARN_WRITE_ERROR_FILE, sWarnFile,
DialogMask::ButtonsOk | DialogMask::MessageError );
return WARN_SWG_FEATURES_LOST;
}
@@ -432,28 +459,17 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
return ERRCODE_NONE;
}
-ErrCode SwXMLWriter::WriteStorage()
+ErrCodeMsg SwXMLWriter::WriteStorage()
{
- return Write_( uno::Reference < task::XStatusIndicator >(), OUString() );
+ return Write_(nullptr);
}
-ErrCode SwXMLWriter::WriteMedium( SfxMedium& aTargetMedium )
+ErrCodeMsg SwXMLWriter::WriteMedium( SfxMedium& aTargetMedium )
{
- uno::Reference < task::XStatusIndicator > xStatusIndicator;
- OUString aName;
- const SfxUnoAnyItem* pStatusBarItem = static_cast<const SfxUnoAnyItem*>(
- aTargetMedium.GetItemSet()->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) );
- if ( pStatusBarItem )
- pStatusBarItem->GetValue() >>= xStatusIndicator;
- const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
- aTargetMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
- if ( pDocHierarchItem )
- aName = pDocHierarchItem->GetValue();
-
- return Write_( xStatusIndicator, aName );
+ return Write_(&aTargetMedium.GetItemSet());
}
-ErrCode SwXMLWriter::Write( SwPaM& rPaM, SfxMedium& rMed,
+ErrCodeMsg SwXMLWriter::Write( SwPaM& rPaM, SfxMedium& rMed,
const OUString* pFileName )
{
return IsStgWriter()
@@ -490,7 +506,7 @@ bool SwXMLWriter::WriteThroughComponent(
xSet->setPropertyValue("MediaType", Any(OUString("text/xml")) );
// even plain stream should be encrypted in encrypted documents
- xSet->setPropertyValue( "UseCommonStoragePasswordEncryption", makeAny(true) );
+ xSet->setPropertyValue( "UseCommonStoragePasswordEncryption", Any(true) );
// set buffer and create outputstream
uno::Reference< io::XOutputStream > xOutputStream = xStream->getOutputStream();
@@ -502,7 +518,7 @@ bool SwXMLWriter::WriteThroughComponent(
OSL_ENSURE( xInfoSet.is(), "missing property set" );
if( xInfoSet.is() )
{
- xInfoSet->setPropertyValue( "StreamName", makeAny( sStreamName ) );
+ xInfoSet->setPropertyValue( "StreamName", Any( sStreamName ) );
}
// write the stuff
@@ -538,8 +554,9 @@ bool SwXMLWriter::WriteThroughComponent(
// prepare arguments (prepend doc handler to given arguments)
Sequence<Any> aArgs( 1 + rArguments.getLength() );
- aArgs[0] <<= xSaxWriter;
- std::copy(rArguments.begin(), rArguments.end(), std::next(aArgs.begin()));
+ auto pArgs = aArgs.getArray();
+ *pArgs <<= xSaxWriter;
+ std::copy(rArguments.begin(), rArguments.end(), std::next(pArgs));
// get filter component
uno::Reference< document::XExporter > xExporter(
@@ -560,7 +577,7 @@ bool SwXMLWriter::WriteThroughComponent(
}
void GetXMLWriter(
- [[maybe_unused]] const OUString& /*rName*/, const OUString& rBaseURL, WriterRef& xRet )
+ [[maybe_unused]] std::u16string_view /*rName*/, const OUString& rBaseURL, WriterRef& xRet )
{
xRet = new SwXMLWriter( rBaseURL );
}
diff --git a/sw/source/filter/xml/wrtxml.hxx b/sw/source/filter/xml/wrtxml.hxx
index c82afcc97436..abbdd7aa7bde 100644
--- a/sw/source/filter/xml/wrtxml.hxx
+++ b/sw/source/filter/xml/wrtxml.hxx
@@ -20,7 +20,6 @@
#define INCLUDED_SW_SOURCE_FILTER_XML_WRTXML_HXX
#include <com/sun/star/io/XOutputStream.hpp>
-#include <com/sun/star/task/XStatusIndicator.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
@@ -40,20 +39,20 @@ namespace com::sun::star {
class SwXMLWriter : public StgWriter
{
- ErrCode Write_( const css::uno::Reference < css::task::XStatusIndicator>&, const OUString& );
+ ErrCodeMsg Write_(const SfxItemSet* pMediumItemSet);
using StgWriter::Write;
protected:
- virtual ErrCode WriteStorage() override;
- virtual ErrCode WriteMedium( SfxMedium& aTargetMedium ) override;
+ virtual ErrCodeMsg WriteStorage() override;
+ virtual ErrCodeMsg WriteMedium( SfxMedium& aTargetMedium ) override;
public:
SwXMLWriter( const OUString& rBaseURL );
virtual ~SwXMLWriter() override;
- virtual ErrCode Write( SwPaM&, SfxMedium&, const OUString* ) override;
+ virtual ErrCodeMsg Write( SwPaM&, SfxMedium&, const OUString* ) override;
private:
diff --git a/sw/source/filter/xml/xmlbrsh.cxx b/sw/source/filter/xml/xmlbrsh.cxx
index 317e49bc2927..b31dc0cfa40a 100644
--- a/sw/source/filter/xml/xmlbrsh.cxx
+++ b/sw/source/filter/xml/xmlbrsh.cxx
@@ -56,15 +56,15 @@ void SwXMLBrushItemImportContext::ProcessAttrs(
break;
case XML_ELEMENT(STYLE, XML_POSITION):
SvXMLImportItemMapper::PutXMLValue(
- *pItem, sValue, MID_GRAPHIC_POSITION, rUnitConv );
+ *m_pItem, sValue, MID_GRAPHIC_POSITION, rUnitConv );
break;
case XML_ELEMENT(STYLE, XML_REPEAT):
SvXMLImportItemMapper::PutXMLValue(
- *pItem, sValue, MID_GRAPHIC_REPEAT, rUnitConv );
+ *m_pItem, sValue, MID_GRAPHIC_REPEAT, rUnitConv );
break;
case XML_ELEMENT(STYLE, XML_FILTER_NAME):
SvXMLImportItemMapper::PutXMLValue(
- *pItem, sValue, MID_GRAPHIC_FILTER, rUnitConv );
+ *m_pItem, sValue, MID_GRAPHIC_FILTER, rUnitConv );
break;
default:
XMLOFF_WARN_UNKNOWN("sw", aIter);
@@ -101,16 +101,16 @@ void SwXMLBrushItemImportContext::endFastElement(sal_Int32 )
if (m_xGraphic.is())
{
Graphic aGraphic(m_xGraphic);
- SvxGraphicPosition eOldGraphicPos = pItem->GetGraphicPos();
- pItem->SetGraphic(aGraphic);
- if (GPOS_NONE == eOldGraphicPos && GPOS_NONE != pItem->GetGraphicPos())
- pItem->SetGraphicPos(GPOS_TILED);
+ SvxGraphicPosition eOldGraphicPos = m_pItem->GetGraphicPos();
+ m_pItem->SetGraphic(aGraphic);
+ if (GPOS_NONE == eOldGraphicPos && GPOS_NONE != m_pItem->GetGraphicPos())
+ m_pItem->SetGraphicPos(GPOS_TILED);
}
- if (!(pItem->GetGraphic()))
- pItem->SetGraphicPos(GPOS_NONE);
- else if (GPOS_NONE == pItem->GetGraphicPos())
- pItem->SetGraphicPos(GPOS_TILED);
+ if (!(m_pItem->GetGraphic()))
+ m_pItem->SetGraphicPos(GPOS_NONE);
+ else if (GPOS_NONE == m_pItem->GetGraphicPos())
+ m_pItem->SetGraphicPos(GPOS_TILED);
}
SwXMLBrushItemImportContext::SwXMLBrushItemImportContext(
@@ -119,10 +119,10 @@ SwXMLBrushItemImportContext::SwXMLBrushItemImportContext(
const SvXMLUnitConverter& rUnitConv,
const SvxBrushItem& rItem ) :
SvXMLImportContext( rImport ),
- pItem( new SvxBrushItem( rItem ) )
+ m_pItem( new SvxBrushItem( rItem ) )
{
// delete any graphic that is existing
- pItem->SetGraphicPos( GPOS_NONE );
+ m_pItem->SetGraphicPos( GPOS_NONE );
ProcessAttrs( xAttrList, rUnitConv );
}
@@ -133,7 +133,7 @@ SwXMLBrushItemImportContext::SwXMLBrushItemImportContext(
const SvXMLUnitConverter& rUnitConv,
sal_uInt16 nWhich ) :
SvXMLImportContext( rImport ),
- pItem( new SvxBrushItem( nWhich ) )
+ m_pItem( new SvxBrushItem( nWhich ) )
{
ProcessAttrs( xAttrList, rUnitConv );
}
@@ -143,11 +143,7 @@ SwXMLBrushItemImportContext::~SwXMLBrushItemImportContext()
}
SwXMLBrushItemExport::SwXMLBrushItemExport( SwXMLExport& rExp ) :
- rExport( rExp )
-{
-}
-
-SwXMLBrushItemExport::~SwXMLBrushItemExport()
+ m_rExport( rExp )
{
}
diff --git a/sw/source/filter/xml/xmlbrshe.hxx b/sw/source/filter/xml/xmlbrshe.hxx
index 807f454645f3..0253a6f06891 100644
--- a/sw/source/filter/xml/xmlbrshe.hxx
+++ b/sw/source/filter/xml/xmlbrshe.hxx
@@ -25,13 +25,12 @@ class SwXMLExport;
class SwXMLBrushItemExport
{
- SwXMLExport& rExport;
+ SwXMLExport& m_rExport;
- SwXMLExport& GetExport() { return rExport; }
+ SwXMLExport& GetExport() { return m_rExport; }
public:
explicit SwXMLBrushItemExport(SwXMLExport& rExport);
- ~SwXMLBrushItemExport();
// core API
void exportXML(const SvxBrushItem& rItem);
diff --git a/sw/source/filter/xml/xmlbrshi.hxx b/sw/source/filter/xml/xmlbrshi.hxx
index 117cfa0b34dd..0e5cb43c84e9 100644
--- a/sw/source/filter/xml/xmlbrshi.hxx
+++ b/sw/source/filter/xml/xmlbrshi.hxx
@@ -40,7 +40,7 @@ private:
css::uno::Reference<css::io::XOutputStream> m_xBase64Stream;
css::uno::Reference<css::graphic::XGraphic> m_xGraphic;
- std::unique_ptr<SvxBrushItem> pItem;
+ std::unique_ptr<SvxBrushItem> m_pItem;
void ProcessAttrs(
const css::uno::Reference<css::xml::sax::XFastAttributeList > & xAttrList,
@@ -69,7 +69,7 @@ public:
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
- const SvxBrushItem& GetItem() const { return *pItem; }
+ const SvxBrushItem& GetItem() const { return *m_pItem; }
};
#endif // _XMLBRSHI_HXX
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index 99e95e9a5381..9137749820ba 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -21,10 +21,11 @@
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XIndexContainer.hpp>
-#include <com/sun/star/document/IndexedPropertyValues.hpp>
#include <com/sun/star/xforms/XFormsSupplier.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/indexedpropertyvalues.hxx>
+#include <osl/diagnose.h>
#include <o3tl/any.hxx>
#include <sax/tools/converter.hxx>
#include <svx/svdpage.hxx>
@@ -32,6 +33,7 @@
#include <svx/xmlgrhlp.hxx>
#include <editeng/eeitem.hxx>
#include <svx/svddef.hxx>
+#include <tools/UnitConversion.hxx>
#include <xmloff/namespacemap.hxx>
#include <xmloff/xmlnamespace.hxx>
#include <editeng/xmlcnitm.hxx>
@@ -50,6 +52,7 @@
#include "xmltexte.hxx"
#include "xmlexp.hxx"
#include "xmlexpit.hxx"
+#include "zorder.hxx"
#include <comphelper/processfactory.hxx>
#include <docary.hxx>
#include <frameformats.hxx>
@@ -66,14 +69,11 @@
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::xml::sax;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::text;
using namespace ::com::sun::star::container;
-using namespace ::com::sun::star::document;
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::i18n;
using namespace ::com::sun::star::xforms;
using namespace ::xmloff::token;
@@ -104,7 +104,7 @@ ErrCode SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
Reference<XPropertySet> rInfoSet = getExportInfo();
if( rInfoSet.is() )
{
- const OUString sAutoTextMode("AutoTextMode");
+ static constexpr OUString sAutoTextMode(u"AutoTextMode"_ustr);
if( rInfoSet->getPropertySetInfo()->hasPropertyByName(
sAutoTextMode ) )
{
@@ -146,7 +146,9 @@ ErrCode SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
for( int j=0; j < nWhichIds; ++j )
{
const sal_uInt16 nWhichId = aWhichIds[j];
- for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(nWhichId))
+ ItemSurrogates aSurrogates;
+ rPool.GetItemSurrogates(aSurrogates, nWhichId);
+ for (const SfxPoolItem* pItem : aSurrogates)
{
auto pUnknown = dynamic_cast<const SvXMLAttrContainerItem*>( pItem );
OSL_ENSURE( pUnknown, "illegal attribute container item" );
@@ -232,7 +234,7 @@ ErrCode SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
if (!GetGraphicStorageHandler().is())
{
xGraphicStorageHandler = SvXMLGraphicHelper::Create(SvXMLGraphicHelperMode::Write, GetImageFilterName());
- SetGraphicStorageHandler(xGraphicStorageHandler.get());
+ SetGraphicStorageHandler(xGraphicStorageHandler);
}
rtl::Reference<SvXMLEmbeddedObjectHelper> xEmbeddedResolver;
@@ -244,7 +246,7 @@ ErrCode SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
xEmbeddedResolver = SvXMLEmbeddedObjectHelper::Create(
*pPersist,
SvXMLEmbeddedObjectHelperMode::Write );
- SetEmbeddedResolver( Reference<XEmbeddedObjectResolver>( xEmbeddedResolver.get() ) );
+ SetEmbeddedResolver( xEmbeddedResolver );
}
}
@@ -269,6 +271,11 @@ ErrCode SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
m_bSavedShowChanges = pLayout == nullptr || !pLayout->IsHideRedlines();
if( bSaveRedline )
{
+ // tdf#133487 call this once in flat-ODF case
+ uno::Reference<drawing::XDrawPageSupplier> const xDPS(GetModel(), uno::UNO_QUERY);
+ assert(xDPS.is());
+ xmloff::FixZOrder(xDPS->getDrawPage(), sw::GetZOrderLayer(m_pDoc->getIDocumentDrawModelAccess()));
+
// now save and switch redline mode
nRedlineFlags = pDoc->getIDocumentRedlineAccess().GetRedlineFlags();
pDoc->getIDocumentRedlineAccess().SetRedlineFlags(
@@ -331,9 +338,9 @@ void SwXMLExport::GetViewSettings(Sequence<PropertyValue>& aProps)
// Currently exporting 9 properties
PropertyValue *pValue = aProps.getArray();
- Reference < XIndexContainer > xBox = IndexedPropertyValues::create( comphelper::getProcessComponentContext() );
+ rtl::Reference< comphelper::IndexedPropertyValuesContainer > xBox = new comphelper::IndexedPropertyValuesContainer();
pValue[0].Name = "Views";
- pValue[0].Value <<= xBox;
+ pValue[0].Value <<= uno::Reference< container::XIndexContainer >(xBox);
SwDoc *pDoc = getDoc();
const tools::Rectangle rRect =
@@ -361,7 +368,7 @@ void SwXMLExport::GetViewSettings(Sequence<PropertyValue>& aProps)
Reference<XPropertySet> xInfoSet( getExportInfo() );
if ( xInfoSet.is() )
{
- const OUString sShowChanges( "ShowChanges" );
+ static constexpr OUString sShowChanges( u"ShowChanges"_ustr );
if( xInfoSet->getPropertySetInfo()->hasPropertyByName( sShowChanges ) )
{
bShowRedlineChanges = *o3tl::doAccess<bool>(xInfoSet->
@@ -379,12 +386,47 @@ void SwXMLExport::GetViewSettings(Sequence<PropertyValue>& aProps)
void SwXMLExport::GetConfigurationSettings( Sequence < PropertyValue >& rProps)
{
Reference< XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
- if( xFac.is() )
+ if (!xFac.is())
+ return;
+
+ Reference< XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY );
+ if (!xProps.is())
+ return;
+
+ static const std::initializer_list<std::u16string_view> vOmitFalseValues = {
+ u"DoNotBreakWrappedTables",
+ u"AllowTextAfterFloatingTableBreak",
+ };
+ SvXMLUnitConverter::convertPropertySet( rProps, xProps, &vOmitFalseValues );
+
+ // tdf#144532 if NoEmbDataSet was set, to indicate not to write an embedded
+ // database for the case of a temporary mail merge preview document, then
+ // also filter out the "EmbeddedDatabaseName" property from the document
+ // settings so that when the temp mailmerge preview document is closed it
+ // doesn't unregister the database of the same name which was registered by
+ // the document this is a copy of
+ Reference<XPropertySet> rInfoSet = getExportInfo();
+
+ if (!rInfoSet.is() || !rInfoSet->getPropertySetInfo()->hasPropertyByName(u"NoEmbDataSet"_ustr))
+ return;
+
+ Any aAny = rInfoSet->getPropertyValue(u"NoEmbDataSet"_ustr);
+ bool bNoEmbDataSet = *o3tl::doAccess<bool>(aAny);
+ if (!bNoEmbDataSet)
+ return;
+
+ Sequence<PropertyValue> aFilteredProps(rProps.getLength());
+ auto aFilteredPropsRange = asNonConstRange(aFilteredProps);
+ sal_Int32 nFilteredPropLen = 0;
+ for (sal_Int32 i = 0; i < rProps.getLength(); ++i)
{
- Reference< XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY );
- if( xProps.is() )
- SvXMLUnitConverter::convertPropertySet( rProps, xProps );
+ if (rProps[i].Name == "EmbeddedDatabaseName")
+ continue;
+ aFilteredPropsRange[nFilteredPropLen] = rProps[i];
+ ++nFilteredPropLen;
}
+ aFilteredProps.realloc(nFilteredPropLen);
+ std::swap(rProps, aFilteredProps);
}
sal_Int32 SwXMLExport::GetDocumentSpecificSettings( std::vector< SettingsGroup >& _out_rSettings )
@@ -469,25 +511,6 @@ void SwXMLExport::ExportContent_()
GetTextParagraphExport()->exportText( xText, m_bShowProgress );
}
-namespace
-{
- class theSwXMLExportUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXMLExportUnoTunnelId > {};
-}
-
-const Sequence< sal_Int8 > & SwXMLExport::getUnoTunnelId() throw()
-{
- return theSwXMLExportUnoTunnelId::get().getSeq();
-}
-
-sal_Int64 SAL_CALL SwXMLExport::getSomething( const Sequence< sal_Int8 >& rId )
-{
- if( isUnoTunnelId<SwXMLExport>(rId) )
- {
- return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
- }
- return SvXMLExport::getSomething( rId );
-}
-
SwDoc* SwXMLExport::getDoc()
{
if( m_pDoc != nullptr )
@@ -500,10 +523,7 @@ SwDoc* SwXMLExport::getDoc()
}
Reference < XText > xText = xTextDoc->getText();
- Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
- assert( xTextTunnel.is());
- SwXText *pText = reinterpret_cast< SwXText *>(
- sal::static_int_cast< sal_IntPtr >( xTextTunnel->getSomething( SwXText::getUnoTunnelId() )));
+ SwXText* pText = dynamic_cast<SwXText*>(xText.get());
assert( pText != nullptr );
m_pDoc = pText->GetDoc();
assert( m_pDoc != nullptr );
diff --git a/sw/source/filter/xml/xmlexp.hxx b/sw/source/filter/xml/xmlexp.hxx
index 42c5034c3f1c..6e095396db61 100644
--- a/sw/source/filter/xml/xmlexp.hxx
+++ b/sw/source/filter/xml/xmlexp.hxx
@@ -24,6 +24,7 @@
#include "xmlitmap.hxx"
#include <xmloff/xmltoken.hxx>
+#include <optional>
#include <string_view>
#include <vector>
@@ -75,7 +76,8 @@ class SwXMLExport : public SvXMLExport
SwXMLTableInfo_Impl& rTableInfo,
bool bTop=false );
- void ExportFormat( const SwFormat& rFormat, enum ::xmloff::token::XMLTokenEnum eClass );
+ void ExportFormat(const SwFormat& rFormat, enum ::xmloff::token::XMLTokenEnum eClass,
+ ::std::optional<OUString> const oStyleName);
void ExportTableFormat( const SwFrameFormat& rFormat, sal_uInt32 nAbsWidth );
void ExportTableColumnStyle( const SwXMLTableColumn_Impl& rCol );
@@ -88,6 +90,8 @@ class SwXMLExport : public SvXMLExport
SwXMLTableInfo_Impl& rTableInfo,
sal_uInt32 nHeaderRows = 0 );
+ void exportTheme();
+
virtual void ExportMeta_() override;
virtual void ExportFontDecls_() override;
virtual void ExportStyles_( bool bUsed ) override;
@@ -128,10 +132,6 @@ public:
bool IsShowProgress() const { return m_bShowProgress; }
void SetShowProgress( bool b ) { m_bShowProgress = b; }
- // XUnoTunnel
- static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
- virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
-
const SwDoc* getDoc() const;
SwDoc* getDoc();
};
diff --git a/sw/source/filter/xml/xmlexpit.cxx b/sw/source/filter/xml/xmlexpit.cxx
index 4ab794cc8a9c..a39d12228c0a 100644
--- a/sw/source/filter/xml/xmlexpit.cxx
+++ b/sw/source/filter/xml/xmlexpit.cxx
@@ -26,7 +26,6 @@
#include <svl/itemset.hxx>
#include <utility>
#include <xmloff/xmluconv.hxx>
-#include <xmloff/attrlist.hxx>
#include <xmloff/namespacemap.hxx>
#include <xmloff/xmlnamespace.hxx>
#include <xmloff/prhdlfac.hxx>
@@ -46,6 +45,7 @@
#include <editeng/keepitem.hxx>
#include <editeng/brushitem.hxx>
#include <editeng/frmdiritem.hxx>
+#include <editeng/prntitem.hxx>
#include <fmtpdsc.hxx>
#include <fmtornt.hxx>
#include <fmtfsize.hxx>
@@ -61,7 +61,7 @@ using uno::Any;
// fills the given attribute list with the items in the given set
void SvXMLExportItemMapper::exportXML( const SvXMLExport& rExport,
- SvXMLAttributeList& rAttrList,
+ comphelper::AttributeList& rAttrList,
const SfxItemSet& rSet,
const SvXMLUnitConverter& rUnitConverter,
const SvXMLNamespaceMap& rNamespaceMap,
@@ -105,7 +105,7 @@ void SvXMLExportItemMapper::exportXML( const SvXMLExport& rExport,
}
void SvXMLExportItemMapper::exportXML(const SvXMLExport&,
- SvXMLAttributeList& rAttrList,
+ comphelper::AttributeList& rAttrList,
const SfxPoolItem& rItem,
const SvXMLItemMapEntry& rEntry,
const SvXMLUnitConverter& rUnitConverter,
@@ -193,7 +193,7 @@ void SvXMLExportItemMapper::exportXML(const SvXMLExport&,
{
case RES_FRAMEDIR:
{
- // Write bt-lr to the extension namespace, handle other values
+ // Write bt-lr and tb-rl90 to the extension namespace, handle other values
// below.
auto pDirection = static_cast<const SvxFrameDirectionItem*>(&rItem);
if (rEntry.nNameSpace == XML_NAMESPACE_LO_EXT
@@ -206,6 +206,17 @@ void SvXMLExportItemMapper::exportXML(const SvXMLExport&,
if (rEntry.nNameSpace == XML_NAMESPACE_LO_EXT
|| pDirection->GetValue() == SvxFrameDirection::Vertical_LR_BT)
bDone = true;
+
+ if (rEntry.nNameSpace == XML_NAMESPACE_LO_EXT
+ && pDirection->GetValue() == SvxFrameDirection::Vertical_RL_TB90)
+ {
+ const OUString sName(rNamespaceMap.GetQNameByKey(
+ XML_NAMESPACE_LO_EXT, GetXMLToken(XML_WRITING_MODE)));
+ rAttrList.AddAttribute(sName, GetXMLToken(XML_TB_RL90));
+ }
+ if (rEntry.nNameSpace == XML_NAMESPACE_LO_EXT
+ || pDirection->GetValue() == SvxFrameDirection::Vertical_RL_TB90)
+ bDone = true;
break;
}
}
@@ -256,7 +267,7 @@ void SvXMLExportItemMapper::exportElementItems(
rExport.IgnorableWhitespace();
}
-/** returns the item with the given WhichId from the given ItemSet if its
+/** returns the item with the given WhichId from the given ItemSet if it's
set
*/
const SfxPoolItem* SvXMLExportItemMapper::GetItem( const SfxItemSet& rSet,
@@ -307,7 +318,7 @@ void SvXMLExportItemMapper::exportXML( SvXMLExport& rExport,
/** this method is called for every item that has the
MID_SW_FLAG_SPECIAL_ITEM_EXPORT flag set */
-void SvXMLExportItemMapper::handleSpecialItem( SvXMLAttributeList& /*rAttrList*/,
+void SvXMLExportItemMapper::handleSpecialItem( comphelper::AttributeList& /*rAttrList*/,
const SvXMLItemMapEntry& /*rEntry*/,
const SfxPoolItem& /*rItem*/,
const SvXMLUnitConverter& /*rUnitConverter*/,
@@ -357,6 +368,11 @@ bool SvXMLExportItemMapper::QueryXMLValue(
switch ( rItem.Which() )
{
+ case RES_MARGIN_FIRSTLINE:
+ case RES_MARGIN_TEXTLEFT:
+ case RES_MARGIN_RIGHT:
+ assert(false); // is only called for frame formats?
+ break;
case RES_LR_SPACE:
{
@@ -760,9 +776,9 @@ bool SvXMLExportItemMapper::QueryXMLValue(
::sax::Converter::convertMeasure(aOut, nWidth,
util::MeasureUnit::TWIP,
util::MeasureUnit::POINT);
- aOut.append( ' ' );
- aOut.append( GetXMLToken( eStyle ) );
- aOut.append( ' ' );
+ aOut.append( " "
+ + GetXMLToken( eStyle )
+ + " " );
::sax::Converter::convertColor(aOut,
pLine->GetColor());
}
@@ -871,6 +887,17 @@ bool SvXMLExportItemMapper::QueryXMLValue(
}
break;
+ case RES_PRINT:
+ {
+ const SvxPrintItem* pHasTextChangesOnly = dynamic_cast<const SvxPrintItem*>( &rItem );
+ if (pHasTextChangesOnly && !pHasTextChangesOnly->GetValue())
+ {
+ aOut.append( "false" );
+ bOk = true;
+ }
+ }
+ break;
+
case RES_BACKGROUND:
{
const SvxBrushItem& rBrush = dynamic_cast<const SvxBrushItem&>(rItem);
diff --git a/sw/source/filter/xml/xmlexpit.hxx b/sw/source/filter/xml/xmlexpit.hxx
index 7639dd063c65..f4ad52ce8a38 100644
--- a/sw/source/filter/xml/xmlexpit.hxx
+++ b/sw/source/filter/xml/xmlexpit.hxx
@@ -27,25 +27,25 @@
class SvXMLUnitConverter;
class SfxPoolItem;
class SfxItemSet;
-class SvXMLAttributeList;
+namespace comphelper { class AttributeList; }
class SvXMLNamespaceMap;
class SvXMLExport;
class SvXMLExportItemMapper
{
-protected:
SvXMLItemMapEntriesRef mrMapEntries;
+protected:
/** fills the given attribute list with the items in the given set */
void exportXML( const SvXMLExport& rExport,
- SvXMLAttributeList& rAttrList,
+ comphelper::AttributeList& rAttrList,
const SfxItemSet& rSet,
const SvXMLUnitConverter& rUnitConverter,
const SvXMLNamespaceMap& rNamespaceMap,
std::vector<sal_uInt16> *pIndexArray ) const;
void exportXML( const SvXMLExport& rExport,
- SvXMLAttributeList& rAttrList,
+ comphelper::AttributeList& rAttrList,
const SfxPoolItem& rItem,
const SvXMLItemMapEntry &rEntry,
const SvXMLUnitConverter& rUnitConverter,
@@ -70,7 +70,7 @@ public:
/** this method is called for every item that has the
MID_SW_FLAG_SPECIAL_ITEM_EXPORT flag set */
- virtual void handleSpecialItem( SvXMLAttributeList& rAttrList,
+ virtual void handleSpecialItem( comphelper::AttributeList& rAttrList,
const SvXMLItemMapEntry& rEntry,
const SfxPoolItem& rItem,
const SvXMLUnitConverter& rUnitConverter,
@@ -82,19 +82,16 @@ public:
virtual void handleElementItem( const SvXMLItemMapEntry& rEntry,
const SfxPoolItem& rItem ) const;
- inline void setMapEntries( SvXMLItemMapEntriesRef rMapEntries );
+ void setMapEntries(const SvXMLItemMapEntriesRef& rMapEntries)
+ {
+ mrMapEntries = rMapEntries;
+ }
static bool QueryXMLValue( const SfxPoolItem& rItem,
OUString& rValue, sal_uInt16 nMemberId,
const SvXMLUnitConverter& rUnitConverter );
};
-inline void
-SvXMLExportItemMapper::setMapEntries( SvXMLItemMapEntriesRef rMapEntries )
-{
- mrMapEntries = rMapEntries;
-}
-
#endif // INCLUDED_SW_SOURCE_FILTER_XML_XMLEXPIT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
index ad82cb3ba14d..2ce04b52f63e 100644
--- a/sw/source/filter/xml/xmlfmt.cxx
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -20,7 +20,7 @@
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <fmtcol.hxx>
#include <hints.hxx>
#include <doc.hxx>
@@ -62,13 +62,13 @@ namespace {
class SwXMLConditionParser_Impl
{
- OUString sInput;
+ OUString m_sInput;
- Master_CollCondition nCondition;
- sal_uInt32 nSubCondition;
+ Master_CollCondition m_nCondition;
+ sal_uInt32 m_nSubCondition;
- sal_Int32 nPos;
- sal_Int32 nLength;
+ sal_Int32 m_nPos;
+ sal_Int32 m_nLength;
inline bool SkipWS();
inline bool MatchChar( sal_Unicode c );
@@ -79,27 +79,27 @@ public:
explicit SwXMLConditionParser_Impl( const OUString& rInp );
- bool IsValid() const { return Master_CollCondition::NONE != nCondition; }
+ bool IsValid() const { return Master_CollCondition::NONE != m_nCondition; }
- Master_CollCondition GetCondition() const { return nCondition; }
- sal_uInt32 GetSubCondition() const { return nSubCondition; }
+ Master_CollCondition GetCondition() const { return m_nCondition; }
+ sal_uInt32 GetSubCondition() const { return m_nSubCondition; }
};
}
inline bool SwXMLConditionParser_Impl::SkipWS()
{
- while( nPos < nLength && ' ' == sInput[nPos] )
- nPos++;
+ while( m_nPos < m_nLength && ' ' == m_sInput[m_nPos] )
+ m_nPos++;
return true;
}
inline bool SwXMLConditionParser_Impl::MatchChar( sal_Unicode c )
{
bool bRet = false;
- if( nPos < nLength && c == sInput[nPos] )
+ if( m_nPos < m_nLength && c == m_sInput[m_nPos] )
{
- nPos++;
+ m_nPos++;
bRet = true;
}
return bRet;
@@ -107,13 +107,13 @@ inline bool SwXMLConditionParser_Impl::MatchChar( sal_Unicode c )
inline bool SwXMLConditionParser_Impl::MatchName( OUString& rName )
{
- OUStringBuffer sBuffer( nLength );
- while( nPos < nLength &&
- ( ('a' <= sInput[nPos] && sInput[nPos] <= 'z') ||
- '-' == sInput[nPos] ) )
+ OUStringBuffer sBuffer( m_nLength );
+ while( m_nPos < m_nLength &&
+ ( ('a' <= m_sInput[m_nPos] && m_sInput[m_nPos] <= 'z') ||
+ '-' == m_sInput[m_nPos] ) )
{
- sBuffer.append( sInput[nPos] );
- nPos++;
+ sBuffer.append( m_sInput[m_nPos] );
+ m_nPos++;
}
rName = sBuffer.makeStringAndClear();
return !rName.isEmpty();
@@ -121,11 +121,11 @@ inline bool SwXMLConditionParser_Impl::MatchName( OUString& rName )
inline bool SwXMLConditionParser_Impl::MatchNumber( sal_uInt32& rNumber )
{
- OUStringBuffer sBuffer( nLength );
- while( nPos < nLength && '0' <= sInput[nPos] && sInput[nPos] <= '9' )
+ OUStringBuffer sBuffer( m_nLength );
+ while( m_nPos < m_nLength && '0' <= m_sInput[m_nPos] && m_sInput[m_nPos] <= '9' )
{
- sBuffer.append( sInput[nPos] );
- nPos++;
+ sBuffer.append( m_sInput[m_nPos] );
+ m_nPos++;
}
OUString sNum( sBuffer.makeStringAndClear() );
@@ -135,11 +135,11 @@ inline bool SwXMLConditionParser_Impl::MatchNumber( sal_uInt32& rNumber )
}
SwXMLConditionParser_Impl::SwXMLConditionParser_Impl( const OUString& rInp ) :
- sInput( rInp ),
- nCondition( Master_CollCondition::NONE ),
- nSubCondition( 0 ),
- nPos( 0 ),
- nLength( rInp.getLength() )
+ m_sInput( rInp ),
+ m_nCondition( Master_CollCondition::NONE ),
+ m_nSubCondition( 0 ),
+ m_nPos( 0 ),
+ m_nLength( rInp.getLength() )
{
OUString sFunc;
bool bHasSub = false;
@@ -152,46 +152,46 @@ SwXMLConditionParser_Impl::SwXMLConditionParser_Impl( const OUString& rInp ) :
bHasSub = true;
}
- bOK &= nPos == nLength;
+ bOK &= m_nPos == m_nLength;
if( !bOK )
return;
if( IsXMLToken( sFunc, XML_ENDNOTE ) && !bHasSub )
- nCondition = Master_CollCondition::PARA_IN_ENDNOTE;
+ m_nCondition = Master_CollCondition::PARA_IN_ENDNOTE;
else if( IsXMLToken( sFunc, XML_FOOTER ) && !bHasSub )
- nCondition = Master_CollCondition::PARA_IN_FOOTER;
+ m_nCondition = Master_CollCondition::PARA_IN_FOOTER;
else if( IsXMLToken( sFunc, XML_FOOTNOTE ) && !bHasSub )
- nCondition = Master_CollCondition::PARA_IN_FOOTNOTE;
+ m_nCondition = Master_CollCondition::PARA_IN_FOOTNOTE;
else if( IsXMLToken( sFunc, XML_HEADER ) && !bHasSub )
- nCondition = Master_CollCondition::PARA_IN_HEADER;
+ m_nCondition = Master_CollCondition::PARA_IN_HEADER;
else if( IsXMLToken( sFunc, XML_LIST_LEVEL) &&
nSub >=1 && nSub <= MAXLEVEL )
{
- nCondition = Master_CollCondition::PARA_IN_LIST;
- nSubCondition = nSub-1;
+ m_nCondition = Master_CollCondition::PARA_IN_LIST;
+ m_nSubCondition = nSub-1;
}
else if( IsXMLToken( sFunc, XML_OUTLINE_LEVEL) &&
nSub >=1 && nSub <= MAXLEVEL )
{
- nCondition = Master_CollCondition::PARA_IN_OUTLINE;
- nSubCondition = nSub-1;
+ m_nCondition = Master_CollCondition::PARA_IN_OUTLINE;
+ m_nSubCondition = nSub-1;
}
else if( IsXMLToken( sFunc, XML_SECTION ) && !bHasSub )
{
- nCondition = Master_CollCondition::PARA_IN_SECTION;
+ m_nCondition = Master_CollCondition::PARA_IN_SECTION;
}
else if( IsXMLToken( sFunc, XML_TABLE ) && !bHasSub )
{
- nCondition = Master_CollCondition::PARA_IN_TABLEBODY;
+ m_nCondition = Master_CollCondition::PARA_IN_TABLEBODY;
}
else if( IsXMLToken( sFunc, XML_TABLE_HEADER ) && !bHasSub )
{
- nCondition = Master_CollCondition::PARA_IN_TABLEHEAD;
+ m_nCondition = Master_CollCondition::PARA_IN_TABLEHEAD;
}
else if( IsXMLToken( sFunc, XML_TEXT_BOX ) && !bHasSub )
{
- nCondition = Master_CollCondition::PARA_IN_FRAME;
+ m_nCondition = Master_CollCondition::PARA_IN_FRAME;
}
}
@@ -199,10 +199,10 @@ namespace {
class SwXMLConditionContext_Impl : public SvXMLImportContext
{
- Master_CollCondition nCondition;
- sal_uInt32 nSubCondition;
+ Master_CollCondition m_nCondition;
+ sal_uInt32 m_nSubCondition;
- OUString sApplyStyle;
+ OUString m_sApplyStyle;
public:
@@ -210,11 +210,11 @@ public:
SvXMLImport& rImport, sal_Int32 nElement,
const uno::Reference< xml::sax::XFastAttributeList > & xAttrList );
- bool IsValid() const { return Master_CollCondition::NONE != nCondition; }
+ bool IsValid() const { return Master_CollCondition::NONE != m_nCondition; }
- Master_CollCondition getCondition() const { return nCondition; }
- sal_uInt32 getSubCondition() const { return nSubCondition; }
- OUString const &getApplyStyle() const { return sApplyStyle; }
+ Master_CollCondition getCondition() const { return m_nCondition; }
+ sal_uInt32 getSubCondition() const { return m_nSubCondition; }
+ OUString const &getApplyStyle() const { return m_sApplyStyle; }
};
}
@@ -223,8 +223,8 @@ SwXMLConditionContext_Impl::SwXMLConditionContext_Impl(
SvXMLImport& rImport, sal_Int32 /*nElement*/,
const uno::Reference< xml::sax::XFastAttributeList > & xAttrList ) :
SvXMLImportContext( rImport ),
- nCondition( Master_CollCondition::NONE ),
- nSubCondition( 0 )
+ m_nCondition( Master_CollCondition::NONE ),
+ m_nSubCondition( 0 )
{
for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
{
@@ -236,13 +236,13 @@ SwXMLConditionContext_Impl::SwXMLConditionContext_Impl(
SwXMLConditionParser_Impl aCondParser( sValue );
if( aCondParser.IsValid() )
{
- nCondition = aCondParser.GetCondition();
- nSubCondition = aCondParser.GetSubCondition();
+ m_nCondition = aCondParser.GetCondition();
+ m_nSubCondition = aCondParser.GetSubCondition();
}
break;
}
case XML_ELEMENT(STYLE, XML_APPLY_STYLE_NAME):
- sApplyStyle = sValue;
+ m_sApplyStyle = sValue;
break;
default:
XMLOFF_WARN_UNKNOWN("sw", aIter);
@@ -256,7 +256,7 @@ namespace {
class SwXMLTextStyleContext_Impl : public XMLTextStyleContext
{
- std::unique_ptr<SwXMLConditions_Impl> pConditions;
+ std::unique_ptr<SwXMLConditions_Impl> m_pConditions;
protected:
@@ -279,7 +279,7 @@ public:
uno::Reference < style::XStyle > SwXMLTextStyleContext_Impl::Create()
{
uno::Reference < style::XStyle > xNewStyle;
- if( pConditions && XmlStyleFamily::TEXT_PARAGRAPH == GetFamily() )
+ if( m_pConditions && XmlStyleFamily::TEXT_PARAGRAPH == GetFamily() )
{
uno::Reference< lang::XMultiServiceFactory > xFactory( GetImport().GetModel(),
uno::UNO_QUERY );
@@ -302,29 +302,30 @@ uno::Reference < style::XStyle > SwXMLTextStyleContext_Impl::Create()
void
SwXMLTextStyleContext_Impl::Finish( bool bOverwrite )
{
- if( pConditions && XmlStyleFamily::TEXT_PARAGRAPH == GetFamily() && GetStyle().is() )
+ if( m_pConditions && XmlStyleFamily::TEXT_PARAGRAPH == GetFamily() && GetStyle().is() )
{
CommandStruct const*const pCommands = SwCondCollItem::GetCmds();
Reference< XPropertySet > xPropSet( GetStyle(), UNO_QUERY );
- uno::Sequence< beans::NamedValue > aSeq( pConditions->size() );
+ uno::Sequence< beans::NamedValue > aSeq( m_pConditions->size() );
+ auto aSeqRange = asNonConstRange(aSeq);
for (std::vector<rtl::Reference<SwXMLConditionContext_Impl>>::size_type i = 0;
- i < pConditions->size(); ++i)
+ i < m_pConditions->size(); ++i)
{
- assert((*pConditions)[i]->IsValid()); // checked before inserting
- Master_CollCondition nCond = (*pConditions)[i]->getCondition();
- sal_uInt32 nSubCond = (*pConditions)[i]->getSubCondition();
+ assert((*m_pConditions)[i]->IsValid()); // checked before inserting
+ Master_CollCondition nCond = (*m_pConditions)[i]->getCondition();
+ sal_uInt32 nSubCond = (*m_pConditions)[i]->getSubCondition();
for (size_t j = 0; j < COND_COMMAND_COUNT; ++j)
{
if (pCommands[j].nCnd == nCond &&
pCommands[j].nSubCond == nSubCond)
{
- aSeq[i].Name = GetCommandContextByIndex( j );
- aSeq[i].Value <<= GetImport().GetStyleDisplayName(
- GetFamily(), (*pConditions)[i]->getApplyStyle() );
+ aSeqRange[i].Name = GetCommandContextByIndex( j );
+ aSeqRange[i].Value <<= GetImport().GetStyleDisplayName(
+ GetFamily(), (*m_pConditions)[i]->getApplyStyle() );
break;
}
}
@@ -332,7 +333,7 @@ SwXMLTextStyleContext_Impl::Finish( bool bOverwrite )
try
{
- xPropSet->setPropertyValue(UNO_NAME_PARA_STYLE_CONDITIONS, uno::makeAny(aSeq));
+ xPropSet->setPropertyValue(UNO_NAME_PARA_STYLE_CONDITIONS, uno::Any(aSeq));
}
catch (uno::Exception const&)
{
@@ -359,11 +360,11 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SwXMLTextStyleContext_
new SwXMLConditionContext_Impl( GetImport(), nElement, xAttrList )};
if( xCond->IsValid() )
{
- if( !pConditions )
- pConditions = std::make_unique<SwXMLConditions_Impl>();
- pConditions->push_back( xCond );
+ if( !m_pConditions )
+ m_pConditions = std::make_unique<SwXMLConditions_Impl>();
+ m_pConditions->push_back( xCond );
}
- return xCond.get();
+ return xCond;
}
return XMLTextStyleContext::createFastChildContext( nElement, xAttrList );
@@ -383,16 +384,16 @@ public:
class SwXMLItemSetStyleContext_Impl : public SvXMLStyleContext
{
- OUString sMasterPageName;
- std::unique_ptr<SfxItemSet> pItemSet;
- SwXMLTextStyleContext_Impl *pTextStyle;
- SvXMLStylesContext &rStyles;
+ OUString m_sMasterPageName;
+ std::optional<SfxItemSet> m_oItemSet;
+ SwXMLTextStyleContext_Impl *m_pTextStyle;
+ SvXMLStylesContext &m_rStyles;
- OUString sDataStyleName;
+ OUString m_sDataStyleName;
- bool bHasMasterPageName : 1;
- bool bPageDescConnected : 1;
- bool bDataStyleIsResolved;
+ bool m_bHasMasterPageName : 1;
+ bool m_bPageDescConnected : 1;
+ bool m_bDataStyleIsResolved;
SvXMLImportContext *CreateItemSetContext(
sal_Int32 nElement,
@@ -419,11 +420,11 @@ public:
sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
// The item set may be empty!
- SfxItemSet *GetItemSet() { return pItemSet.get(); }
+ SfxItemSet *GetItemSet() { return m_oItemSet ? &*m_oItemSet : nullptr; }
- bool HasMasterPageName() const { return bHasMasterPageName; }
+ bool HasMasterPageName() const { return m_bHasMasterPageName; }
- bool IsPageDescConnected() const { return bPageDescConnected; }
+ bool IsPageDescConnected() const { return m_bPageDescConnected; }
void ConnectPageDesc();
bool ResolveDataStyleName();
@@ -472,7 +473,7 @@ void SwXMLCellStyleContext::AddDataFormat()
if (aIter != GetProperties().end())
aIter->maValue <<= nNumberFormat;
else
- GetProperties().push_back(XMLPropertyState(nIndex, makeAny(nNumberFormat)));
+ GetProperties().emplace_back(nIndex, Any(nNumberFormat));
}
void SwXMLCellStyleContext::FillPropertySet(const css::uno::Reference<css::beans::XPropertySet>& rPropSet)
@@ -496,8 +497,8 @@ void SwXMLItemSetStyleContext_Impl::SetAttribute( sal_Int32 nElement,
{
case XML_ELEMENT(STYLE, XML_MASTER_PAGE_NAME):
{
- sMasterPageName = rValue;
- bHasMasterPageName = true;
+ m_sMasterPageName = rValue;
+ m_bHasMasterPageName = true;
break;
}
case XML_ELEMENT(STYLE, XML_DATA_STYLE_NAME):
@@ -505,8 +506,8 @@ void SwXMLItemSetStyleContext_Impl::SetAttribute( sal_Int32 nElement,
// if we have a valid data style name
if (!rValue.isEmpty())
{
- sDataStyleName = rValue;
- bDataStyleIsResolved = false; // needs to be resolved
+ m_sDataStyleName = rValue;
+ m_bDataStyleIsResolved = false; // needs to be resolved
}
break;
}
@@ -519,40 +520,40 @@ SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateItemSetContext(
sal_Int32 nElement,
const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
{
- OSL_ENSURE( !pItemSet,
+ OSL_ENSURE( !m_oItemSet,
"SwXMLItemSetStyleContext_Impl::CreateItemSetContext: item set exists" );
SvXMLImportContext *pContext = nullptr;
- SwDoc* pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
+ SwDoc* pDoc = GetSwImport().getDoc();
SfxItemPool& rItemPool = pDoc->GetAttrPool();
switch( GetFamily() )
{
case XmlStyleFamily::TABLE_TABLE:
- pItemSet.reset( new SfxItemSet( rItemPool, aTableSetRange ) );
+ m_oItemSet.emplace( rItemPool, aTableSetRange );
break;
case XmlStyleFamily::TABLE_COLUMN:
- pItemSet.reset( new SfxItemSet( rItemPool, svl::Items<RES_FRM_SIZE, RES_FRM_SIZE>{} ) );
+ m_oItemSet.emplace( rItemPool, svl::Items<RES_FRM_SIZE, RES_FRM_SIZE> );
break;
case XmlStyleFamily::TABLE_ROW:
- pItemSet.reset( new SfxItemSet( rItemPool, aTableLineSetRange ) );
+ m_oItemSet.emplace( rItemPool, aTableLineSetRange );
break;
case XmlStyleFamily::TABLE_CELL:
- pItemSet.reset( new SfxItemSet( rItemPool, aTableBoxSetRange ) );
+ m_oItemSet.emplace( rItemPool, aTableBoxSetRange );
break;
default:
OSL_ENSURE( false,
"SwXMLItemSetStyleContext_Impl::CreateItemSetContext: unknown family" );
break;
}
- if( pItemSet )
+ if( m_oItemSet )
pContext = GetSwImport().CreateTableItemImportContext(
nElement, xAttrList, GetFamily(),
- *pItemSet );
+ *m_oItemSet );
if( !pContext )
{
- pItemSet.reset();
+ m_oItemSet.reset();
}
return pContext;
@@ -563,18 +564,18 @@ SwXMLItemSetStyleContext_Impl::SwXMLItemSetStyleContext_Impl( SwXMLImport& rImpo
SvXMLStylesContext& rStylesC,
XmlStyleFamily nFamily ) :
SvXMLStyleContext( rImport, nFamily ),
- pTextStyle( nullptr ),
- rStyles( rStylesC ),
- bHasMasterPageName( false ),
- bPageDescConnected( false ),
- bDataStyleIsResolved( true )
+ m_pTextStyle( nullptr ),
+ m_rStyles( rStylesC ),
+ m_bHasMasterPageName( false ),
+ m_bPageDescConnected( false ),
+ m_bDataStyleIsResolved( true )
{
}
void SwXMLItemSetStyleContext_Impl::CreateAndInsert( bool bOverwrite )
{
- if( pTextStyle )
- pTextStyle->CreateAndInsert( bOverwrite );
+ if( m_pTextStyle )
+ m_pTextStyle->CreateAndInsert( bOverwrite );
}
css::uno::Reference< css::xml::sax::XFastContextHandler > SwXMLItemSetStyleContext_Impl::createFastChildContext(
@@ -588,19 +589,18 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SwXMLItemSetStyleConte
case XML_ELEMENT(STYLE, XML_TABLE_ROW_PROPERTIES):
case XML_ELEMENT(STYLE, XML_TABLE_CELL_PROPERTIES):
return CreateItemSetContext( nElement, xAttrList );
- break;
case XML_ELEMENT(STYLE, XML_TEXT_PROPERTIES):
case XML_ELEMENT(STYLE, XML_PARAGRAPH_PROPERTIES):
{
- if( !pTextStyle )
+ if( !m_pTextStyle )
{
- pTextStyle = new SwXMLTextStyleContext_Impl( GetSwImport(), XmlStyleFamily::TEXT_PARAGRAPH, rStyles );
+ m_pTextStyle = new SwXMLTextStyleContext_Impl( GetSwImport(), XmlStyleFamily::TEXT_PARAGRAPH, m_rStyles );
rtl::Reference<sax_fastparser::FastAttributeList> xTmpAttrList = new sax_fastparser::FastAttributeList(nullptr);
xTmpAttrList->add(XML_ELEMENT(STYLE, XML_NAME), GetName().toUtf8() );
- pTextStyle->startFastElement( nElement, xTmpAttrList.get() );
- rStyles.AddStyle( *pTextStyle );
+ m_pTextStyle->startFastElement( nElement, xTmpAttrList );
+ m_rStyles.AddStyle( *m_pTextStyle );
}
- return pTextStyle->createFastChildContext( nElement, xAttrList );
+ return m_pTextStyle->createFastChildContext( nElement, xAttrList );
}
default:
XMLOFF_WARN_UNKNOWN_ELEMENT("sw", nElement);
@@ -611,16 +611,16 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SwXMLItemSetStyleConte
void SwXMLItemSetStyleContext_Impl::ConnectPageDesc()
{
- if( bPageDescConnected || !HasMasterPageName() )
+ if( m_bPageDescConnected || !HasMasterPageName() )
return;
- bPageDescConnected = true;
+ m_bPageDescConnected = true;
- SwDoc *pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
+ SwDoc *pDoc = GetSwImport().getDoc();
// #i40788# - first determine the display name of the page style,
// then map this name to the corresponding user interface name.
OUString sName = GetImport().GetStyleDisplayName( XmlStyleFamily::MASTER_PAGE,
- sMasterPageName );
+ m_sMasterPageName );
SwStyleNameMapper::FillUIName( sName,
sName,
SwGetPoolIdFromName::PageDesc);
@@ -637,19 +637,17 @@ void SwXMLItemSetStyleContext_Impl::ConnectPageDesc()
if( !pPageDesc )
return;
- if( !pItemSet )
+ if( !m_oItemSet )
{
SfxItemPool& rItemPool = pDoc->GetAttrPool();
- pItemSet.reset( new SfxItemSet( rItemPool, aTableSetRange ) );
+ m_oItemSet.emplace( rItemPool, aTableSetRange );
}
- const SfxPoolItem *pItem;
std::unique_ptr<SwFormatPageDesc> pFormatPageDesc;
- if( SfxItemState::SET == pItemSet->GetItemState( RES_PAGEDESC, false,
- &pItem ) )
+ if( const SwFormatPageDesc* pItem = m_oItemSet->GetItemIfSet( RES_PAGEDESC, false ) )
{
- if( static_cast<const SwFormatPageDesc *>(pItem)->GetPageDesc() != pPageDesc )
- pFormatPageDesc.reset(new SwFormatPageDesc( *static_cast<const SwFormatPageDesc *>(pItem) ));
+ if( pItem->GetPageDesc() != pPageDesc )
+ pFormatPageDesc.reset(new SwFormatPageDesc( *pItem ));
}
else
pFormatPageDesc.reset(new SwFormatPageDesc());
@@ -657,35 +655,35 @@ void SwXMLItemSetStyleContext_Impl::ConnectPageDesc()
if( pFormatPageDesc )
{
pFormatPageDesc->RegisterToPageDesc( *pPageDesc );
- pItemSet->Put( *pFormatPageDesc );
+ m_oItemSet->Put( std::move(pFormatPageDesc) );
}
}
bool SwXMLItemSetStyleContext_Impl::ResolveDataStyleName()
{
// resolve, if not already done
- if (! bDataStyleIsResolved)
+ if (! m_bDataStyleIsResolved)
{
// get the format key
sal_Int32 nFormat =
- GetImport().GetTextImport()->GetDataStyleKey(sDataStyleName);
+ GetImport().GetTextImport()->GetDataStyleKey(m_sDataStyleName);
// if the key is valid, insert Item into ItemSet
if( -1 != nFormat )
{
- if( !pItemSet )
+ if( !m_oItemSet )
{
- SwDoc *pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
+ SwDoc *pDoc = GetSwImport().getDoc();
SfxItemPool& rItemPool = pDoc->GetAttrPool();
- pItemSet.reset( new SfxItemSet( rItemPool, aTableBoxSetRange ) );
+ m_oItemSet.emplace( rItemPool, aTableBoxSetRange );
}
SwTableBoxNumFormat aNumFormatItem(nFormat);
- pItemSet->Put(aNumFormatItem);
+ m_oItemSet->Put(aNumFormatItem);
}
// now resolved
- bDataStyleIsResolved = true;
+ m_bDataStyleIsResolved = true;
return true;
}
else
@@ -921,6 +919,8 @@ OUString SwXMLStylesContext_Impl::GetServiceName( XmlStyleFamily nFamily ) const
void SwXMLStylesContext_Impl::endFastElement(sal_Int32 )
{
GetSwImport().InsertStyles( IsAutomaticStyle() );
+ if (!IsAutomaticStyle())
+ GetImport().GetShapeImport()->GetShapeTableImport()->finishStyles();
}
namespace {
@@ -1008,7 +1008,7 @@ void SwXMLImport::FinishStyles()
void SwXMLImport::UpdateTextCollConditions( SwDoc *pDoc )
{
if( !pDoc )
- pDoc = SwImport::GetDocFromXMLImport( *this );
+ pDoc = getDoc();
const SwTextFormatColls& rColls = *pDoc->GetTextFormatColls();
const size_t nCount = rColls.size();
diff --git a/sw/source/filter/xml/xmlfmte.cxx b/sw/source/filter/xml/xmlfmte.cxx
index fc582dd39eda..4a70f2953868 100644
--- a/sw/source/filter/xml/xmlfmte.cxx
+++ b/sw/source/filter/xml/xmlfmte.cxx
@@ -19,7 +19,6 @@
#include <com/sun/star/text/XTextDocument.hpp>
#include <xmloff/xmlnamespace.hxx>
-#include <xmloff/attrlist.hxx>
#include "xmlexpit.hxx"
#include <xmloff/namespacemap.hxx>
#include <xmloff/XMLTextListAutoStylePool.hxx>
@@ -35,18 +34,26 @@
#include <pagedesc.hxx>
#include <cellatr.hxx>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/util/Color.hpp>
#include "xmlexp.hxx"
#include <SwStyleNameMapper.hxx>
#include <osl/diagnose.h>
+#include <comphelper/sequenceashashmap.hxx>
+
+#include <svx/unoapi.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdmodel.hxx>
+#include <docmodel/theme/ThemeColorType.hxx>
+#include <docmodel/theme/Theme.hxx>
+
-using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::text;
using namespace ::com::sun::star::drawing;
-using namespace ::com::sun::star::lang;
using namespace ::xmloff::token;
-void SwXMLExport::ExportFormat( const SwFormat& rFormat, enum XMLTokenEnum eFamily )
+void SwXMLExport::ExportFormat(const SwFormat& rFormat, enum XMLTokenEnum eFamily,
+ ::std::optional<OUString> const oStyleName)
{
// <style:style ...>
CheckAttrList();
@@ -57,11 +64,14 @@ void SwXMLExport::ExportFormat( const SwFormat& rFormat, enum XMLTokenEnum eFami
return;
OSL_ENSURE( eFamily != XML_TOKEN_INVALID, "family must be specified" );
// style:name="..."
+ assert(oStyleName || (eFamily != XML_TABLE_ROW && eFamily != XML_TABLE_CELL));
bool bEncoded = false;
- AddAttribute( XML_NAMESPACE_STYLE, XML_NAME, EncodeStyleName(
- rFormat.GetName(), &bEncoded ) );
+ OUString const name(oStyleName ? *oStyleName : rFormat.GetName());
+ AddAttribute(XML_NAMESPACE_STYLE, XML_NAME, EncodeStyleName(name, &bEncoded));
if( bEncoded )
- AddAttribute( XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, rFormat.GetName() );
+ {
+ AddAttribute(XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, name);
+ }
if( eFamily != XML_TOKEN_INVALID )
AddAttribute( XML_NAMESPACE_STYLE, XML_FAMILY, eFamily );
@@ -81,13 +91,11 @@ void SwXMLExport::ExportFormat( const SwFormat& rFormat, enum XMLTokenEnum eFami
// style:master-page-name
if( RES_FRMFMT == rFormat.Which() && XML_TABLE == eFamily )
{
- const SfxPoolItem *pItem;
- if( SfxItemState::SET == rFormat.GetAttrSet().GetItemState( RES_PAGEDESC,
- false, &pItem ) )
+ if( const SwFormatPageDesc* pItem = rFormat.GetAttrSet().GetItemIfSet( RES_PAGEDESC,
+ false ) )
{
OUString sName;
- const SwPageDesc *pPageDesc =
- static_cast<const SwFormatPageDesc *>(pItem)->GetPageDesc();
+ const SwPageDesc *pPageDesc = pItem->GetPageDesc();
if( pPageDesc )
SwStyleNameMapper::FillProgName(
pPageDesc->GetName(),
@@ -102,12 +110,10 @@ void SwXMLExport::ExportFormat( const SwFormat& rFormat, enum XMLTokenEnum eFami
{
OSL_ENSURE(RES_FRMFMT == rFormat.Which(), "only frame format");
- const SfxPoolItem *pItem;
- if( SfxItemState::SET ==
- rFormat.GetAttrSet().GetItemState( RES_BOXATR_FORMAT,
- false, &pItem ) )
+ if( const SwTableBoxNumFormat *pItem =
+ rFormat.GetAttrSet().GetItemIfSet( RES_BOXATR_FORMAT, false ) )
{
- sal_Int32 nFormat = static_cast<sal_Int32>(static_cast<const SwTableBoxNumFormat *>(pItem)->GetValue());
+ sal_Int32 nFormat = static_cast<sal_Int32>(pItem->GetValue());
if ( (nFormat != -1) && (nFormat != static_cast<sal_Int32>(getSwDefaultTextFormat())) )
{
@@ -170,6 +176,35 @@ void SwXMLExport::ExportStyles_( bool bUsed )
GetShapeExport()->GetShapeTableExport()->exportTableStyles();
//page defaults
GetPageExport()->exportDefaultStyle();
+
+ // Theme
+ exportTheme();
+}
+
+void SwXMLExport::exportTheme()
+{
+ if ((getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED) == 0)
+ return;
+
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(GetModel(), UNO_QUERY);
+ if (!xDrawPageSupplier.is())
+ return;
+
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+ if (!xDrawPage.is())
+ return;
+
+ SdrPage* pPage = GetSdrPageFromXDrawPage(xDrawPage);
+ SAL_WARN_IF(!pPage, "oox", "Can't get SdrPage from XDrawPage");
+
+ if (!pPage)
+ return;
+
+ auto const& pTheme = pPage->getSdrModelFromSdrPage().getTheme();
+ if (!pTheme)
+ return;
+
+ ExportThemeElement(pTheme);
}
void SwXMLExport::collectAutoStyles()
@@ -212,7 +247,7 @@ void SwXMLExport::collectAutoStyles()
GetFormExport()->examineForms(xPage);
}
- GetTextParagraphExport()->collectTextAutoStylesOptimized( m_bShowProgress );
+ GetTextParagraphExport()->collectTextAutoStylesAndNodeExportOrder(m_bShowProgress);
}
mbAutoStylesCollected = true;
@@ -228,12 +263,6 @@ void SwXMLExport::ExportAutoStyles_()
if( !(getExportFlags() & SvXMLExportFlags::STYLES) )
GetTextParagraphExport()->exportUsedDeclarations();
- // exported in ExportContent_
- if( getExportFlags() & SvXMLExportFlags::CONTENT )
- {
- GetTextParagraphExport()->exportTrackedChanges( true );
- }
-
GetTextParagraphExport()->exportTextAutoStyles();
GetShapeExport()->exportAutoStyles();
if( getExportFlags() & SvXMLExportFlags::MASTERSTYLES )
@@ -263,14 +292,14 @@ namespace {
class SwXMLAutoStylePoolP : public SvXMLAutoStylePoolP
{
- SvXMLExport& rExport;
- const OUString sListStyleName;
- const OUString sMasterPageName;
+ SvXMLExport& m_rExport;
+ const OUString m_sListStyleName;
+ const OUString m_sMasterPageName;
protected:
virtual void exportStyleAttributes(
- SvXMLAttributeList& rAttrList,
+ comphelper::AttributeList& rAttrList,
XmlStyleFamily nFamily,
const std::vector< XMLPropertyState >& rProperties,
const SvXMLExportPropertyMapper& rPropExp
@@ -285,7 +314,7 @@ public:
}
void SwXMLAutoStylePoolP::exportStyleAttributes(
- SvXMLAttributeList& rAttrList,
+ comphelper::AttributeList& rAttrList,
XmlStyleFamily nFamily,
const std::vector< XMLPropertyState >& rProperties,
const SvXMLExportPropertyMapper& rPropExp
@@ -312,12 +341,12 @@ void SwXMLAutoStylePoolP::exportStyleAttributes(
// #i70748# - export also empty list styles
if( !sStyleName.isEmpty() )
{
- OUString sTmp = rExport.GetTextParagraphExport()->GetListAutoStylePool().Find( sStyleName );
+ OUString sTmp = m_rExport.GetTextParagraphExport()->GetListAutoStylePool().Find( sStyleName );
if( !sTmp.isEmpty() )
sStyleName = sTmp;
}
GetExport().AddAttribute( XML_NAMESPACE_STYLE,
- sListStyleName,
+ m_sListStyleName,
GetExport().EncodeStyleName( sStyleName ) );
}
break;
@@ -326,7 +355,7 @@ void SwXMLAutoStylePoolP::exportStyleAttributes(
OUString sStyleName;
rProperty.maValue >>= sStyleName;
GetExport().AddAttribute( XML_NAMESPACE_STYLE,
- sMasterPageName,
+ m_sMasterPageName,
GetExport().EncodeStyleName( sStyleName ) );
}
break;
@@ -337,9 +366,9 @@ void SwXMLAutoStylePoolP::exportStyleAttributes(
SwXMLAutoStylePoolP::SwXMLAutoStylePoolP(SvXMLExport& rExp ) :
SvXMLAutoStylePoolP( rExp ),
- rExport( rExp ),
- sListStyleName( GetXMLToken( XML_LIST_STYLE_NAME ) ),
- sMasterPageName( GetXMLToken( XML_MASTER_PAGE_NAME ) )
+ m_rExport( rExp ),
+ m_sListStyleName( GetXMLToken( XML_LIST_STYLE_NAME ) ),
+ m_sMasterPageName( GetXMLToken( XML_MASTER_PAGE_NAME ) )
{
}
diff --git a/sw/source/filter/xml/xmlfonte.cxx b/sw/source/filter/xml/xmlfonte.cxx
index ce415aeb41e5..8566a1a69497 100644
--- a/sw/source/filter/xml/xmlfonte.cxx
+++ b/sw/source/filter/xml/xmlfonte.cxx
@@ -25,10 +25,6 @@
#include "xmlimp.hxx"
#include <IDocumentSettingAccess.hxx>
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::text;
-
namespace {
class SwXMLFontAutoStylePool_Impl: public XMLFontAutoStylePool
@@ -39,6 +35,24 @@ public:
}
+namespace
+{
+sal_Int32 CompareTo(sal_Int32 nA, sal_Int32 nB)
+{
+ if (nA < nB)
+ {
+ return -1;
+ }
+
+ if (nA > nB)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+}
+
SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(SwXMLExport& _rExport, bool bFontEmbedding)
: XMLFontAutoStylePool(_rExport, bFontEmbedding)
{
@@ -46,21 +60,56 @@ SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(SwXMLExport& _rExport,
RES_CHRATR_CTL_FONT };
const SfxItemPool& rPool = _rExport.getDoc()->GetAttrPool();
+ std::vector<const SvxFontItem *> aFonts;
for(sal_uInt16 nWhichId : aWhichIds)
{
const SvxFontItem& rFont =
- static_cast<const SvxFontItem&>(rPool.GetDefaultItem( nWhichId ));
- Add( rFont.GetFamilyName(), rFont.GetStyleName(),
- rFont.GetFamily(), rFont.GetPitch(),
- rFont.GetCharSet() );
- for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(nWhichId))
+ static_cast<const SvxFontItem&>(rPool.GetUserOrPoolDefaultItem( nWhichId ));
+ aFonts.push_back(&rFont);
+ ItemSurrogates aSurrogates;
+ rPool.GetItemSurrogates(aSurrogates, nWhichId);
+ for (const SfxPoolItem* pItem : aSurrogates)
{
auto pFont = static_cast<const SvxFontItem *>(pItem);
- Add( pFont->GetFamilyName(), pFont->GetStyleName(),
- pFont->GetFamily(), pFont->GetPitch(),
- pFont->GetCharSet() );
+ aFonts.push_back(pFont);
}
}
+
+ std::sort(aFonts.begin(), aFonts.end(),
+ [](const SvxFontItem* pA, const SvxFontItem* pB) -> bool
+ {
+ sal_Int32 nRet = pA->GetFamilyName().compareTo(pB->GetFamilyName());
+ if (nRet != 0)
+ {
+ return nRet < 0;
+ }
+
+ nRet = pA->GetStyleName().compareTo(pB->GetStyleName());
+ if (nRet != 0)
+ {
+ return nRet < 0;
+ }
+
+ nRet = CompareTo(pA->GetFamily(), pB->GetFamily());
+ if (nRet != 0)
+ {
+ return nRet < 0;
+ }
+
+ nRet = CompareTo(pA->GetPitch(), pB->GetPitch());
+ if (nRet != 0)
+ {
+ return nRet < 0;
+ }
+
+ return pA->GetCharSet() < pB->GetCharSet();
+ });
+ for (const auto& pFont : aFonts)
+ {
+ Add(pFont->GetFamilyName(), pFont->GetStyleName(), pFont->GetFamily(), pFont->GetPitch(),
+ pFont->GetCharSet());
+ }
+
auto const & pDocument = _rExport.getDoc();
m_bEmbedUsedOnly = pDocument->getIDocumentSettingAccess().get(DocumentSettingId::EMBED_USED_FONTS);
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index cd5f2b18f115..febdff27872b 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -23,14 +23,15 @@
#include <cassert>
#include <com/sun/star/document/PrinterIndependentLayout.hpp>
+#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/drawing/XDrawPage.hpp>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/XTextRange.hpp>
#include <o3tl/any.hxx>
#include <xmloff/xmlnamespace.hxx>
-#include <xmloff/xmltkmap.hxx>
#include <xmloff/xmlictxt.hxx>
#include <xmloff/txtimp.hxx>
#include <xmloff/XMLTextShapeImportHelper.hxx>
@@ -61,11 +62,14 @@
#include <svx/xmlgrhlp.hxx>
#include <svx/xmleohlp.hxx>
#include <sfx2/printer.hxx>
+#include <sfx2/sfxmodelfactory.hxx>
#include <xmloff/xmluconv.hxx>
-#include <unotools/saveopt.hxx>
+#include <unotools/fcm.hxx>
+#include <unotools/mediadescriptor.hxx>
#include <unotools/streamwrap.hxx>
-#include <tools/helpers.hxx>
-#include <tools/diagnose_ex.h>
+#include <unotools/tempfile.hxx>
+#include <tools/UnitConversion.hxx>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/svapp.hxx>
#include <unotxdoc.hxx>
@@ -76,6 +80,7 @@
#include <comphelper/servicehelper.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
+#include <officecfg/Office/Common.hxx>
#include <unordered_set>
@@ -85,11 +90,9 @@ using namespace ::com::sun::star::text;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
-using namespace ::com::sun::star::i18n;
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::xforms;
using namespace ::xmloff::token;
-using namespace ::std;
namespace {
@@ -177,37 +180,29 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SwXMLDocContext_Impl::c
{
case XML_ELEMENT(OFFICE, XML_SCRIPTS):
return GetSwImport().CreateScriptContext();
- break;
case XML_ELEMENT(OFFICE, XML_SETTINGS):
return new XMLDocumentSettingsContext( GetImport() );
- break;
case XML_ELEMENT(OFFICE, XML_STYLES):
GetSwImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
return GetSwImport().CreateStylesContext( false );
- break;
case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES):
// don't use the autostyles from the styles-document for the progress
if ( mnElement != 0 && (mnElement & TOKEN_MASK) != XML_DOCUMENT_STYLES )
GetSwImport().GetProgressBarHelper()->Increment
( PROGRESS_BAR_STEP );
return GetSwImport().CreateStylesContext( true );
- break;
case XML_ELEMENT(OFFICE, XML_MASTER_STYLES):
return GetSwImport().CreateMasterStylesContext();
- break;
case XML_ELEMENT(OFFICE, XML_FONT_FACE_DECLS):
return GetSwImport().CreateFontDeclsContext();
- break;
case XML_ELEMENT(OFFICE, XML_META):
OSL_FAIL(" XML_ELEMENT(OFFICE, XML_META): should not have come here, maybe document is invalid?");
break;
case XML_ELEMENT(OFFICE, XML_BODY):
GetSwImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
return new SwXMLBodyContext_Impl( GetSwImport() );
- break;
case XML_ELEMENT(XFORMS, XML_MODEL):
return createXFormsModelContext(GetImport());
- break;
default:
XMLOFF_WARN_UNKNOWN_ELEMENT("sw", nElement);
}
@@ -333,12 +328,13 @@ SwXMLImport::SwXMLImport(
m_bBlock( false ),
m_bOrganizerMode( false ),
m_bInititedXForms( false ),
- m_pDoc( nullptr )
+ m_pDoc( nullptr ),
+ m_sDefTableName(SwResId(STR_TABLE_DEFNAME))
{
InitItemImport();
}
-SwXMLImport::~SwXMLImport() throw ()
+SwXMLImport::~SwXMLImport() noexcept
{
if (HasShapeImport())
{
@@ -346,6 +342,9 @@ SwXMLImport::~SwXMLImport() throw ()
ClearShapeImport();
}
FinitItemImport();
+ // Call cleanup() here because the destruction of some stuff like XMLRedlineImportHelper will cast
+ // to cast their mrImport to SwXMLImport and that is illegal after this destructor is done.
+ cleanup();
}
void SwXMLImport::setTextInsertMode(
@@ -367,33 +366,9 @@ void SwXMLImport::setStyleInsertMode( SfxStyleFamily nFamilies,
m_bLoadDoc = false;
}
-namespace
-{
- class theSwXMLImportUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXMLImportUnoTunnelId > {};
-}
-
-const Sequence< sal_Int8 > & SwXMLImport::getUnoTunnelId() throw()
-{
- return theSwXMLImportUnoTunnelId::get().getSeq();
-}
-
-sal_Int64 SAL_CALL SwXMLImport::getSomething( const Sequence< sal_Int8 >& rId )
-{
- if( isUnoTunnelId<SwXMLImport>(rId) )
- {
- return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
- }
- return SvXMLImport::getSomething( rId );
-}
-
static OTextCursorHelper *lcl_xml_GetSwXTextCursor( const Reference < XTextCursor >& rTextCursor )
{
- Reference<XUnoTunnel> xCursorTunnel( rTextCursor, UNO_QUERY );
- OSL_ENSURE( xCursorTunnel.is(), "missing XUnoTunnel for Cursor" );
- if( !xCursorTunnel.is() )
- return nullptr;
- OTextCursorHelper *pTextCursor = reinterpret_cast< OTextCursorHelper *>(
- sal::static_int_cast< sal_IntPtr >( xCursorTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
+ OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(rTextCursor.get());
OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
return pTextCursor;
}
@@ -426,7 +401,7 @@ void SwXMLImport::startDocument()
if( aAny >>= aFamiliesSeq )
{
SfxStyleFamily nFamilyMask = SfxStyleFamily::None;
- for( const OUString& rFamily : std::as_const(aFamiliesSeq) )
+ for (const OUString& rFamily : aFamiliesSeq)
{
if( rFamily=="FrameStyles" )
nFamilyMask |= SfxStyleFamily::Frame;
@@ -441,7 +416,7 @@ void SwXMLImport::startDocument()
}
bool bOverwrite = false;
- const OUString sStyleInsertModeOverwrite("StyleInsertModeOverwrite");
+ static constexpr OUString sStyleInsertModeOverwrite(u"StyleInsertModeOverwrite"_ustr);
if( xPropertySetInfo->hasPropertyByName(sStyleInsertModeOverwrite) )
{
aAny = xImportInfo->getPropertyValue(sStyleInsertModeOverwrite);
@@ -457,7 +432,7 @@ void SwXMLImport::startDocument()
}
// text insert mode?
- const OUString sTextInsertModeRange("TextInsertModeRange");
+ static constexpr OUString sTextInsertModeRange(u"TextInsertModeRange"_ustr);
if( xPropertySetInfo->hasPropertyByName(sTextInsertModeRange) )
{
aAny = xImportInfo->getPropertyValue(sTextInsertModeRange);
@@ -467,7 +442,7 @@ void SwXMLImport::startDocument()
}
// auto text mode
- const OUString sAutoTextMode("AutoTextMode");
+ static constexpr OUString sAutoTextMode(u"AutoTextMode"_ustr);
if( xPropertySetInfo->hasPropertyByName(sAutoTextMode) )
{
aAny = xImportInfo->getPropertyValue(sAutoTextMode);
@@ -479,7 +454,7 @@ void SwXMLImport::startDocument()
}
// organizer mode
- const OUString sOrganizerMode("OrganizerMode");
+ static constexpr OUString sOrganizerMode(u"OrganizerMode"_ustr);
if( xPropertySetInfo->hasPropertyByName(sOrganizerMode) )
{
aAny = xImportInfo->getPropertyValue(sOrganizerMode);
@@ -491,7 +466,7 @@ void SwXMLImport::startDocument()
}
// default document properties
- const OUString sDefSettings("DefaultDocumentSettings");
+ static constexpr OUString sDefSettings(u"DefaultDocumentSettings"_ustr);
if (xPropertySetInfo->hasPropertyByName(sDefSettings))
{
aAny = xImportInfo->getPropertyValue(sDefSettings);
@@ -505,7 +480,7 @@ void SwXMLImport::startDocument()
if (xProps.is() && xInfo.is())
{
- for (const auto& rProp : std::as_const(aProps))
+ for (const auto& rProp : aProps)
{
if (xInfo->hasPropertyByName(rProp.Name))
{
@@ -553,7 +528,7 @@ void SwXMLImport::startDocument()
}
if( pCursorSh )
{
- const uno::Reference<text::XTextRange> xInsertTextRange(
+ const rtl::Reference<SwXTextRange> xInsertTextRange(
SwXTextRange::CreateXTextRange(
*pDoc, *pCursorSh->GetCursor()->GetPoint(), nullptr ) );
setTextInsertMode( xInsertTextRange );
@@ -587,7 +562,7 @@ void SwXMLImport::startDocument()
if( (getImportFlags() & SvXMLImportFlags::CONTENT) && !IsStylesOnlyMode() )
{
- m_pSttNdIdx.reset(new SwNodeIndex( pDoc->GetNodes() ));
+ m_oSttNdIdx.emplace( pDoc->GetNodes() );
if( IsInsertMode() )
{
SwPaM *pPaM = pTextCursor->GetPaM();
@@ -595,7 +570,7 @@ void SwXMLImport::startDocument()
// Split once and remember the node that has been split.
pDoc->getIDocumentContentOperations().SplitNode( *pPos, false );
- *m_pSttNdIdx = pPos->nNode.GetIndex()-1;
+ *m_oSttNdIdx = pPos->GetNodeIndex()-1;
// Split again.
pDoc->getIDocumentContentOperations().SplitNode( *pPos, false );
@@ -618,7 +593,7 @@ void SwXMLImport::startDocument()
if (!GetGraphicStorageHandler().is())
{
m_xGraphicStorageHandler = SvXMLGraphicHelper::Create(SvXMLGraphicHelperMode::Read);
- SetGraphicStorageHandler(m_xGraphicStorageHandler.get());
+ SetGraphicStorageHandler(m_xGraphicStorageHandler);
}
if( !GetEmbeddedResolver().is() )
@@ -629,8 +604,7 @@ void SwXMLImport::startDocument()
m_xEmbeddedResolver = SvXMLEmbeddedObjectHelper::Create(
*pPersist,
SvXMLEmbeddedObjectHelperMode::Read );
- Reference< document::XEmbeddedObjectResolver > xEmbeddedResolver( m_xEmbeddedResolver.get() );
- SetEmbeddedResolver( xEmbeddedResolver );
+ SetEmbeddedResolver( m_xEmbeddedResolver );
}
}
}
@@ -660,55 +634,53 @@ void SwXMLImport::endDocument()
SwDoc *pDoc = nullptr;
if( (getImportFlags() & SvXMLImportFlags::CONTENT) && !IsStylesOnlyMode() )
{
- Reference<XUnoTunnel> xCursorTunnel( GetTextImport()->GetCursor(),
+ Reference<XInterface> xCursorTunnel( GetTextImport()->GetCursor(),
UNO_QUERY);
assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor");
- OTextCursorHelper *pTextCursor = reinterpret_cast< OTextCursorHelper *>(
- sal::static_int_cast< sal_IntPtr >( xCursorTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
+ OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(xCursorTunnel.get());
assert(pTextCursor && "SwXTextCursor missing");
SwPaM *pPaM = pTextCursor->GetPaM();
- if( IsInsertMode() && m_pSttNdIdx->GetIndex() )
+ if( IsInsertMode() && m_oSttNdIdx->GetIndex() )
{
// If we are in insert mode, join the split node that is in front
// of the new content with the first new node. Or in other words:
// Revert the first split node.
- SwTextNode* pTextNode = m_pSttNdIdx->GetNode().GetTextNode();
- SwNodeIndex aNxtIdx( *m_pSttNdIdx );
+ SwTextNode* pTextNode = m_oSttNdIdx->GetNode().GetTextNode();
+ SwNodeIndex aNxtIdx( *m_oSttNdIdx );
if( pTextNode && pTextNode->CanJoinNext( &aNxtIdx ) &&
- m_pSttNdIdx->GetIndex() + 1 == aNxtIdx.GetIndex() )
+ m_oSttNdIdx->GetIndex() + 1 == aNxtIdx.GetIndex() )
{
// If the PaM points to the first new node, move the PaM to the
// end of the previous node.
- if( pPaM->GetPoint()->nNode == aNxtIdx )
+ if( pPaM->GetPoint()->GetNode() == aNxtIdx.GetNode() )
{
- pPaM->GetPoint()->nNode = *m_pSttNdIdx;
- pPaM->GetPoint()->nContent.Assign( pTextNode,
+ pPaM->GetPoint()->Assign( *pTextNode,
pTextNode->GetText().getLength());
}
#if OSL_DEBUG_LEVEL > 0
// !!! This should be impossible !!!!
- OSL_ENSURE( m_pSttNdIdx->GetIndex()+1 !=
- pPaM->GetBound().nNode.GetIndex(),
+ OSL_ENSURE( m_oSttNdIdx->GetIndex()+1 !=
+ pPaM->GetBound().GetNodeIndex(),
"PaM.Bound1 point to new node " );
- OSL_ENSURE( m_pSttNdIdx->GetIndex()+1 !=
- pPaM->GetBound( false ).nNode.GetIndex(),
+ OSL_ENSURE( m_oSttNdIdx->GetIndex()+1 !=
+ pPaM->GetBound( false ).GetNodeIndex(),
"PaM.Bound2 points to new node" );
- if( m_pSttNdIdx->GetIndex()+1 ==
- pPaM->GetBound().nNode.GetIndex() )
+ if( m_oSttNdIdx->GetIndex()+1 ==
+ pPaM->GetBound().GetNodeIndex() )
{
const sal_Int32 nCntPos =
- pPaM->GetBound().nContent.GetIndex();
- pPaM->GetBound().nContent.Assign( pTextNode,
+ pPaM->GetBound().GetContentIndex();
+ pPaM->GetBound().SetContent(
pTextNode->GetText().getLength() + nCntPos );
}
- if( m_pSttNdIdx->GetIndex()+1 ==
- pPaM->GetBound( false ).nNode.GetIndex() )
+ if( m_oSttNdIdx->GetIndex()+1 ==
+ pPaM->GetBound( false ).GetNodeIndex() )
{
const sal_Int32 nCntPos =
- pPaM->GetBound( false ).nContent.GetIndex();
- pPaM->GetBound( false ).nContent.Assign( pTextNode,
+ pPaM->GetBound( false ).GetContentIndex();
+ pPaM->GetBound( false ).SetContent(
pTextNode->GetText().getLength() + nCntPos );
}
#endif
@@ -734,14 +706,14 @@ void SwXMLImport::endDocument()
}
SwPosition* pPos = pPaM->GetPoint();
- OSL_ENSURE( !pPos->nContent.GetIndex(), "last paragraph isn't empty" );
- if( !pPos->nContent.GetIndex() )
+ OSL_ENSURE( !pPos->GetContentIndex(), "last paragraph isn't empty" );
+ if( !pPos->GetContentIndex() )
{
SwTextNode* pCurrNd;
- sal_uLong nNodeIdx = pPos->nNode.GetIndex();
+ SwNodeOffset nNodeIdx = pPos->GetNodeIndex();
pDoc = &pPaM->GetDoc();
- OSL_ENSURE( pPos->nNode.GetNode().IsContentNode(),
+ OSL_ENSURE( pPos->GetNode().IsContentNode(),
"insert position is not a content node" );
if( !IsInsertMode() )
{
@@ -751,13 +723,16 @@ void SwXMLImport::endDocument()
( pPrev->IsEndNode() &&
pPrev->StartOfSectionNode()->IsSectionNode() ) )
{
- SwContentNode* pCNd = pPaM->GetContentNode();
+ SwContentNode* pCNd = pPaM->GetPointContentNode();
if( pCNd && pCNd->StartOfSectionIndex()+2 <
pCNd->EndOfSectionIndex() )
{
- pPaM->GetBound().nContent.Assign( nullptr, 0 );
- pPaM->GetBound(false).nContent.Assign( nullptr, 0 );
- pDoc->GetNodes().Delete( pPaM->GetPoint()->nNode );
+ SwNode& rDelNode = pPaM->GetPoint()->GetNode();
+ // move so we don't have a dangling SwContentIndex to the deleted node
+ pPaM->GetPoint()->Adjust(SwNodeOffset(+1));
+ if (pPaM->HasMark())
+ pPaM->GetMark()->Adjust(SwNodeOffset(+1));
+ pDoc->GetNodes().Delete( rDelNode );
}
}
}
@@ -765,36 +740,38 @@ void SwXMLImport::endDocument()
{
// Id we're in insert mode, the empty node is joined with
// the next and the previous one.
- if( pCurrNd->CanJoinNext( &pPos->nNode ))
+ if( pCurrNd->CanJoinNext( pPos ))
{
- SwTextNode* pNextNd = pPos->nNode.GetNode().GetTextNode();
-
+ SwTextNode* pNextNd = pPos->GetNode().GetTextNode();
+ bool endNodeFound = pDoc->GetNodes()[nNodeIdx-1]->IsEndNode();
SwNode *pLastPar = pDoc->GetNodes()[nNodeIdx -2];
if ( !pLastPar->IsTextNode() ) {
pLastPar = pDoc->GetNodes()[nNodeIdx -1];
}
- if ( pLastPar->IsTextNode() )
+ if ( !endNodeFound && pLastPar->IsTextNode() )
{
pNextNd->ChgFormatColl(pLastPar->GetTextNode()->GetTextColl());
}
- pPos->nContent.Assign( pNextNd, 0 );
pPaM->SetMark(); pPaM->DeleteMark();
pNextNd->JoinPrev();
// Remove line break that has been inserted by the import,
- // but only if one has been inserted!
- if( pNextNd->CanJoinPrev(/* &pPos->nNode*/ ) &&
- *m_pSttNdIdx != pPos->nNode )
+ // but only if one has been inserted and
+ // no endNode found to avoid removing section
+ if( pNextNd->CanJoinPrev(/* &pPos->nNode*/ ) && !endNodeFound &&
+ *m_oSttNdIdx != pPos->GetNode() )
{
pNextNd->JoinPrev();
}
}
else if (pCurrNd->GetText().isEmpty())
{
- pPos->nContent.Assign( nullptr, 0 );
pPaM->SetMark(); pPaM->DeleteMark();
- pDoc->GetNodes().Delete( pPos->nNode );
+ SwNode& rDelNode = pPos->GetNode();
+ // move so we don't have a dangling SwContentIndex to the deleted node
+ pPaM->GetPoint()->Adjust(SwNodeOffset(+1));
+ pDoc->GetNodes().Delete( rDelNode );
pPaM->Move( fnMoveBackward );
}
}
@@ -842,31 +819,33 @@ void SwXMLImport::endDocument()
GetTextImport()->ResetCursor();
- m_pSttNdIdx.reset();
+ m_oSttNdIdx.reset();
+ // tdf#150753: pDoc may be null e.g. when the package lacks content.xml;
+ // we should not forget to tidy up here, including unlocking draw model
+ if (!pDoc)
+ pDoc = getDoc();
+ assert(pDoc);
// SJ: #i49801# -> now permitting repaints
- if ( pDoc )
+ if (getImportFlags() == SvXMLImportFlags::ALL)
{
- if( getImportFlags() == SvXMLImportFlags::ALL )
- {
- // Notify math objects. If we are in the package filter this will
- // be done by the filter object itself
- if( IsInsertMode() )
- pDoc->PrtOLENotify( false );
- else if ( pDoc->IsOLEPrtNotifyPending() )
- pDoc->PrtOLENotify( true );
-
- assert(pDoc->IsInReading());
- assert(pDoc->IsInXMLImport());
- pDoc->SetInReading(false);
- pDoc->SetInXMLImport(false);
- }
-
- SwDrawModel* pDrawModel = pDoc->getIDocumentDrawModelAccess().GetDrawModel();
- if ( pDrawModel )
- pDrawModel->setLock(false);
+ // Notify math objects. If we are in the package filter this will
+ // be done by the filter object itself
+ if (IsInsertMode())
+ pDoc->PrtOLENotify(false);
+ else if (pDoc->IsOLEPrtNotifyPending())
+ pDoc->PrtOLENotify(true);
+
+ assert(pDoc->IsInReading());
+ assert(pDoc->IsInXMLImport());
+ pDoc->SetInReading(false);
+ pDoc->SetInXMLImport(false);
}
+ SwDrawModel* pDrawModel = pDoc->getIDocumentDrawModelAccess().GetDrawModel();
+ if (pDrawModel)
+ pDrawModel->setLock(false);
+
// #i90243#
if ( m_bInititedXForms )
{
@@ -894,9 +873,7 @@ void SwXMLImport::endDocument()
}
}
-#if 1
- if (!pDoc) { pDoc = SwImport::GetDocFromXMLImport(*this); }
- for (sal_uLong i = 0; i < pDoc->GetNodes().Count(); ++i)
+ for (SwNodeOffset i(0); i < pDoc->GetNodes().Count(); ++i)
{
if (SwTableNode *const pTableNode = pDoc->GetNodes()[i]->GetTableNode())
{
@@ -908,7 +885,6 @@ void SwXMLImport::endDocument()
}
// don't skip to the end; nested tables could have subtables too...
}
-#endif
// delegate to parent: takes care of error handling
SvXMLImport::endDocument();
@@ -967,16 +943,16 @@ void SwXMLImport::MergeListsAtDocumentInsertPosition(SwDoc *pDoc)
if (! pDoc)
return;
- if (! IsInsertMode() || ! m_pSttNdIdx->GetIndex())
+ if (! IsInsertMode() || ! m_oSttNdIdx->GetIndex())
return;
- sal_uLong index = 1;
+ SwNodeOffset index(1);
// the last node of the main document where we have inserted a document
- const SwNodePtr node1 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + 0];
+ SwNode* const node1 = pDoc->GetNodes()[m_oSttNdIdx->GetIndex() + 0];
// the first node of the inserted document
- SwNodePtr node2 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + index];
+ SwNode* node2 = pDoc->GetNodes()[m_oSttNdIdx->GetIndex() + index];
if (! (node1 && node2
&& (node1->GetNodeType() == node2->GetNodeType())
@@ -1089,7 +1065,7 @@ void SwXMLImport::MergeListsAtDocumentInsertPosition(SwDoc *pDoc)
return;
}
- node2 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + index];
+ node2 = pDoc->GetNodes()[m_oSttNdIdx->GetIndex() + index];
}
}
@@ -1194,25 +1170,25 @@ void SwXMLImport::SetViewSettings(const Sequence < PropertyValue > & aViewProps)
if ( rValue.Name == "ViewAreaTop" )
{
rValue.Value >>= nTmp;
- aRect.setY( static_cast< tools::Long >(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp) );
+ aRect.SetPosY(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp);
}
else if ( rValue.Name == "ViewAreaLeft" )
{
rValue.Value >>= nTmp;
- aRect.setX( static_cast< tools::Long >(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp) );
+ aRect.SetPosX(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp);
}
else if ( rValue.Name == "ViewAreaWidth" )
{
rValue.Value >>= nTmp;
Size aSize( aRect.GetSize() );
- aSize.setWidth( static_cast< tools::Long >(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp) );
+ aSize.setWidth(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp);
aRect.SetSize( aSize );
}
else if ( rValue.Name == "ViewAreaHeight" )
{
rValue.Value >>= nTmp;
Size aSize( aRect.GetSize() );
- aSize.setHeight( static_cast< tools::Long >(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp) );
+ aSize.setHeight(bTwip ? sanitiseMm100ToTwip(nTmp) : nTmp);
aRect.SetSize( aSize );
}
else if ( rValue.Name == "ShowRedlineChanges" )
@@ -1271,19 +1247,15 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
"PrintAnnotationMode",
"PrintBlackFonts",
"PrintControls",
- "PrintDrawings",
"PrintGraphics",
"PrintHiddenText",
"PrintLeftPages",
"PrintPageBackground",
"PrintProspect",
- "PrintReversed",
"PrintRightPages",
"PrintFaxName",
"PrintPaperFromSetup",
- "PrintTables",
"PrintTextPlaceholder",
- "PrintSingleJobs",
"UpdateFromTemplate",
"PrinterIndependentLayout",
"PrintEmptyPages",
@@ -1292,11 +1264,11 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
"ProtectForm",
"MsWordCompTrailingBlanks",
"SubtractFlysAnchoredAtFlys",
- "EmptyDbFieldHidesPara"
+ "EmptyDbFieldHidesPara",
+ "UseVariableWidthNBSP",
};
- SvtSaveOptions aSaveOpt;
- bool bAreUserSettingsFromDocument = aSaveOpt.IsLoadUserSettings();
+ bool bAreUserSettingsFromDocument = officecfg::Office::Common::Load::UserDefinedSettings::get();
// for some properties we don't want to use the application
// default if they're missing. So we watch for them in the loop
@@ -1313,21 +1285,22 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
bool bIgnoreFirstLineIndentInNumbering = false;
bool bDoNotJustifyLinesWithManualBreak = false;
bool bDoNotResetParaAttrsForNumFont = false;
- bool bLoadReadonly = false;
bool bDoNotCaptureDrawObjsOnPage( false );
bool bClipAsCharacterAnchoredWriterFlyFrames( false );
bool bUnixForceZeroExtLeading = false;
bool bSmallCapsPercentage66 = false;
bool bTabOverflow = false;
- bool bUnbreakableNumberings = false;
- bool bClippedPictures = false;
- bool bBackgroundParaOverDrawings = false;
- bool bTabOverMargin = false;
bool bTabOverMarginValue = false;
bool bPropLineSpacingShrinksFirstLine = false;
bool bSubtractFlysAnchoredAtFlys = false;
bool bEmptyDbFieldHidesPara = false;
bool bCollapseEmptyCellPara = false;
+ bool bAutoFirstLineIndentDisregardLineSpace = false;
+ bool bHyphenateURLs = false;
+ bool bApplyTextAttrToEmptyLineAtEndOfParagraph = false;
+ bool bDoNotBreakWrappedTables = false;
+ bool bAllowTextAfterFloatingTableBreak = false;
+ bool bDropCapPunctuation = false;
const PropertyValue* currentDatabaseDataSource = nullptr;
const PropertyValue* currentDatabaseCommand = nullptr;
@@ -1397,8 +1370,6 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
bDoNotJustifyLinesWithManualBreak = true;
else if ( rValue.Name == "DoNotResetParaAttrsForNumFont" )
bDoNotResetParaAttrsForNumFont = true;
- else if ( rValue.Name == "LoadReadonly" )
- bLoadReadonly = true;
else if ( rValue.Name == "DoNotCaptureDrawObjsOnPage" )
bDoNotCaptureDrawObjsOnPage = true;
else if ( rValue.Name == "ClipAsCharacterAnchoredWriterFlyFrames" )
@@ -1409,15 +1380,8 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
bSmallCapsPercentage66 = true;
else if ( rValue.Name == "TabOverflow" )
bTabOverflow = true;
- else if ( rValue.Name == "UnbreakableNumberings" )
- bUnbreakableNumberings = true;
- else if ( rValue.Name == "ClippedPictures" )
- bClippedPictures = true;
- else if ( rValue.Name == "BackgroundParaOverDrawings" )
- bBackgroundParaOverDrawings = true;
else if ( rValue.Name == "TabOverMargin" )
{
- bTabOverMargin = true;
rValue.Value >>= bTabOverMarginValue;
}
else if ( rValue.Name == "PropLineSpacingShrinksFirstLine" )
@@ -1428,6 +1392,26 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
bEmptyDbFieldHidesPara = true;
else if (rValue.Name == "CollapseEmptyCellPara")
bCollapseEmptyCellPara = true;
+ else if (rValue.Name == "AutoFirstLineIndentDisregardLineSpace")
+ bAutoFirstLineIndentDisregardLineSpace = true;
+ else if (rValue.Name == "HyphenateURLs")
+ {
+ bHyphenateURLs = true;
+ }
+ else if (rValue.Name == "ApplyTextAttrToEmptyLineAtEndOfParagraph")
+ {
+ bApplyTextAttrToEmptyLineAtEndOfParagraph = true;
+ }
+ else if (rValue.Name == "DoNotBreakWrappedTables")
+ {
+ rValue.Value >>= bDoNotBreakWrappedTables;
+ }
+ else if (rValue.Name == "AllowTextAfterFloatingTableBreak")
+ {
+ rValue.Value >>= bAllowTextAfterFloatingTableBreak;
+ }
+ else if ( rValue.Name == "DropCapPunctuation" )
+ bDropCapPunctuation = true;
}
catch( Exception& )
{
@@ -1465,42 +1449,42 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
if( ! bAddExternalLeading )
{
- xProps->setPropertyValue( "AddExternalLeading", makeAny( false ) );
+ xProps->setPropertyValue( "AddExternalLeading", Any( false ) );
}
if( ! bUseFormerLineSpacing )
{
- xProps->setPropertyValue( "UseFormerLineSpacing", makeAny( true ) );
+ xProps->setPropertyValue( "UseFormerLineSpacing", Any( true ) );
}
if( !bUseFormerObjectPositioning )
{
- xProps->setPropertyValue( "UseFormerObjectPositioning", makeAny( true ) );
+ xProps->setPropertyValue( "UseFormerObjectPositioning", Any( true ) );
}
if( !bUseOldNumbering )
{
- xProps->setPropertyValue( "UseOldNumbering", makeAny(true) );
+ xProps->setPropertyValue( "UseOldNumbering", Any(true) );
}
if( !bAddParaSpacingToTableCells )
{
xProps->setPropertyValue( "AddParaSpacingToTableCells",
- makeAny( false ) );
+ Any( false ) );
}
if (!bAddParaLineSpacingToTableCells)
{
- xProps->setPropertyValue("AddParaLineSpacingToTableCells", makeAny(false));
+ xProps->setPropertyValue("AddParaLineSpacingToTableCells", Any(false));
}
if( !bUseFormerTextWrapping )
{
- xProps->setPropertyValue( "UseFormerTextWrapping", makeAny( true ) );
+ xProps->setPropertyValue( "UseFormerTextWrapping", Any( true ) );
}
if (!bConsiderWrapOnObjPos && bAreUserSettingsFromDocument)
{
- xProps->setPropertyValue( "ConsiderTextWrapOnObjPos", makeAny( false ) );
+ xProps->setPropertyValue( "ConsiderTextWrapOnObjPos", Any( false ) );
}
// #i47448#
@@ -1517,45 +1501,40 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
if( !bIgnoreFirstLineIndentInNumbering && bDocumentPriorSO8 )
{
xProps->setPropertyValue( "IgnoreFirstLineIndentInNumbering",
- makeAny( true ) );
+ Any( true ) );
}
// This flag has to be set for all documents < SO8
if ( !bDoNotJustifyLinesWithManualBreak && bDocumentPriorSO8 )
{
xProps->setPropertyValue( "DoNotJustifyLinesWithManualBreak",
- makeAny( true ) );
+ Any( true ) );
}
// This flag has to be set for all documents < SO8
if ( !bDoNotResetParaAttrsForNumFont && bDocumentPriorSO8 )
{
xProps->setPropertyValue( "DoNotResetParaAttrsForNumFont",
- makeAny( true ) );
- }
-
- if ( !bLoadReadonly )
- {
- xProps->setPropertyValue( "LoadReadonly", makeAny( false ) );
+ Any( true ) );
}
// This flag has to be set for all documents < SO8
if ( !bDoNotCaptureDrawObjsOnPage && bDocumentPriorSO8 )
{
xProps->setPropertyValue( "DoNotCaptureDrawObjsOnPage",
- makeAny( true ) );
+ Any( true ) );
}
// This flag has to be set for all documents < SO8
if ( !bClipAsCharacterAnchoredWriterFlyFrames && bDocumentPriorSO8 )
{
xProps->setPropertyValue( "ClipAsCharacterAnchoredWriterFlyFrames",
- makeAny( true ) );
+ Any( true ) );
}
if ( !bUnixForceZeroExtLeading )
{
- xProps->setPropertyValue( "UnxForceZeroExtLeading", makeAny( true ) );
+ xProps->setPropertyValue( "UnxForceZeroExtLeading", Any( true ) );
}
// Old LO versions had 66 as the value for small caps percentage, later changed to 80.
@@ -1564,30 +1543,14 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
// are considered to be old files, so set the compatibility option too.
if ( !bSmallCapsPercentage66 )
{
- xProps->setPropertyValue( "SmallCapsPercentage66", makeAny( true ) );
+ xProps->setPropertyValue( "SmallCapsPercentage66", Any( true ) );
}
if ( !bTabOverflow )
{
- xProps->setPropertyValue( "TabOverflow", makeAny( false ) );
+ xProps->setPropertyValue( "TabOverflow", Any( false ) );
}
- if ( !bUnbreakableNumberings )
- {
- xProps->setPropertyValue( "UnbreakableNumberings", makeAny( false ) );
- }
-
- if ( !bClippedPictures )
- {
- xProps->setPropertyValue( "ClippedPictures", makeAny( false ) );
- }
-
- if ( !bBackgroundParaOverDrawings )
- xProps->setPropertyValue("BackgroundParaOverDrawings", makeAny( false ) );
-
- if ( !bTabOverMargin )
- xProps->setPropertyValue("TabOverMargin", makeAny( false ) );
-
if (bTabOverMarginValue)
// Let TabOverMargin imply the new default for
// PrinterIndependentLayout, knowing the first is set by Word import
@@ -1597,16 +1560,48 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
uno::Any(document::PrinterIndependentLayout::HIGH_RESOLUTION));
if (!bPropLineSpacingShrinksFirstLine)
- xProps->setPropertyValue("PropLineSpacingShrinksFirstLine", makeAny(false));
+ xProps->setPropertyValue("PropLineSpacingShrinksFirstLine", Any(false));
if (!bSubtractFlysAnchoredAtFlys && bAreUserSettingsFromDocument)
- xProps->setPropertyValue("SubtractFlysAnchoredAtFlys", makeAny(true));
+ xProps->setPropertyValue("SubtractFlysAnchoredAtFlys", Any(true));
if (!bEmptyDbFieldHidesPara && bAreUserSettingsFromDocument)
- xProps->setPropertyValue("EmptyDbFieldHidesPara", makeAny(false));
+ xProps->setPropertyValue("EmptyDbFieldHidesPara", Any(false));
if (!bCollapseEmptyCellPara)
- xProps->setPropertyValue("CollapseEmptyCellPara", makeAny(false));
+ xProps->setPropertyValue("CollapseEmptyCellPara", Any(false));
+
+ if (!bAutoFirstLineIndentDisregardLineSpace)
+ xProps->setPropertyValue("AutoFirstLineIndentDisregardLineSpace", Any(false));
+
+ if (!bHyphenateURLs)
+ {
+ xProps->setPropertyValue("HyphenateURLs", Any(true));
+ }
+
+ if (!bApplyTextAttrToEmptyLineAtEndOfParagraph)
+ {
+ xProps->setPropertyValue("ApplyTextAttrToEmptyLineAtEndOfParagraph", Any(false));
+ }
+
+ if (bDoNotBreakWrappedTables)
+ {
+ xProps->setPropertyValue("DoNotBreakWrappedTables", Any(true));
+ }
+
+ if (bAllowTextAfterFloatingTableBreak)
+ {
+ xProps->setPropertyValue("AllowTextAfterFloatingTableBreak", Any(true));
+ }
+
+ // LO 7.4 and previous versions had different drop cap punctuation: very long dashes.
+ // In order to keep backwards compatibility, DropCapPunctuation option is written to .odt
+ // files, and the default for new documents is 'true'. Files without this option
+ // are considered to be old files, so set the compatibility option too.
+ if ( !bDropCapPunctuation )
+ {
+ xProps->setPropertyValue( "DropCapPunctuation", Any( false ) );
+ }
SwDoc *pDoc = getDoc();
SfxPrinter *pPrinter = pDoc->getIDocumentDeviceAccess().getPrinter( false );
@@ -1639,11 +1634,11 @@ void SwXMLImport::SetDocumentSpecificSettings(
{
if ( m_xLateInitSettings->hasByName( _rSettingsGroupName ) )
{
- m_xLateInitSettings->replaceByName( _rSettingsGroupName, makeAny( _rSettings ) );
+ m_xLateInitSettings->replaceByName( _rSettingsGroupName, Any( _rSettings ) );
OSL_FAIL( "SwXMLImport::SetDocumentSpecificSettings: already have settings for this model!" );
}
else
- m_xLateInitSettings->insertByName( _rSettingsGroupName, makeAny( _rSettings ) );
+ m_xLateInitSettings->insertByName( _rSettingsGroupName, Any( _rSettings ) );
}
catch( const Exception& )
{
@@ -1670,20 +1665,10 @@ void SwXMLImport::initialize(
}
}
-SwDoc* SwImport::GetDocFromXMLImport( SvXMLImport const & rImport )
-{
- auto pTextDoc = comphelper::getUnoTunnelImplementation<SwXTextDocument>(rImport.GetModel());
- assert( pTextDoc );
- assert( pTextDoc->GetDocShell() );
- SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
- OSL_ENSURE( pDoc, "Where is my document?" );
- return pDoc;
-}
-
void SwXMLImport::initXForms()
{
// obtain SwDoc
- auto pXTextDocument = comphelper::getUnoTunnelImplementation<SwXTextDocument>(GetModel());
+ auto pXTextDocument = comphelper::getFromUnoTunnel<SwXTextDocument>(GetModel());
if( pXTextDocument == nullptr )
return;
@@ -1703,10 +1688,7 @@ SwDoc* SwXMLImport::getDoc()
return m_pDoc;
Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
Reference < XText > xText = xTextDoc->getText();
- Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
- assert( xTextTunnel.is());
- SwXText *pText = reinterpret_cast< SwXText *>(
- sal::static_int_cast< sal_IntPtr >( xTextTunnel->getSomething( SwXText::getUnoTunnelId() )));
+ SwXText* pText = dynamic_cast<SwXText*>(xText.get());
assert( pText != nullptr );
m_pDoc = pText->GetDoc();
assert( m_pDoc != nullptr );
@@ -1775,17 +1757,21 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportFODT(SvStream &rStream)
uno::Reference<io::XInputStream> xStream(new utl::OSeekableInputStreamWrapper(rStream));
uno::Reference<uno::XInterface> xInterface(xMultiServiceFactory->createInstance("com.sun.star.comp.Writer.XmlFilterAdaptor"), uno::UNO_SET_THROW);
- css::uno::Sequence<OUString> aUserData(7);
- aUserData[0] = "com.sun.star.comp.filter.OdfFlatXml";
- aUserData[2] = "com.sun.star.comp.Writer.XMLOasisImporter";
- aUserData[3] = "com.sun.star.comp.Writer.XMLOasisExporter";
- aUserData[6] = "true";
+ css::uno::Sequence<OUString> aUserData
+ {
+ "com.sun.star.comp.filter.OdfFlatXml",
+ "",
+ "com.sun.star.comp.Writer.XMLOasisImporter",
+ "com.sun.star.comp.Writer.XMLOasisExporter",
+ "",
+ "",
+ "true"
+ };
uno::Sequence<beans::PropertyValue> aAdaptorArgs(comphelper::InitPropertySequence(
{
{ "UserData", uno::Any(aUserData) },
}));
- css::uno::Sequence<uno::Any> aOuterArgs(1);
- aOuterArgs[0] <<= aAdaptorArgs;
+ css::uno::Sequence<uno::Any> aOuterArgs{ uno::Any(aAdaptorArgs) };
uno::Reference<lang::XInitialization> xInit(xInterface, uno::UNO_QUERY_THROW);
xInit->initialize(aOuterArgs);
@@ -1812,6 +1798,123 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportFODT(SvStream &rStream)
return ret;
}
+extern "C" SAL_DLLPUBLIC_EXPORT bool TestPDFExportFODT(SvStream &rStream)
+{
+ // do the same sort of check as FilterDetect::detect
+ OString const str(read_uInt8s_ToOString(rStream, 4000));
+ rStream.Seek(STREAM_SEEK_TO_BEGIN);
+ OUString resultString(str.getStr(), str.getLength(), RTL_TEXTENCODING_ASCII_US,
+ RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT|RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT|RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT);
+ if (!resultString.startsWith("<?xml") || resultString.indexOf("office:mimetype=\"application/vnd.oasis.opendocument.text\"") == -1)
+ return false;
+
+ Reference<css::frame::XDesktop2> xDesktop = css::frame::Desktop::create(comphelper::getProcessComponentContext());
+ Reference<css::frame::XFrame> xTargetFrame = xDesktop->findFrame("_blank", 0);
+
+ Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
+ Reference<css::frame::XModel2> xModel(xContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.text.TextDocument", xContext), UNO_QUERY_THROW);
+
+ Reference<css::frame::XLoadable> xModelLoad(xModel, UNO_QUERY_THROW);
+ xModelLoad->initNew();
+
+ uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(comphelper::getProcessServiceFactory());
+ uno::Reference<io::XInputStream> xStream(new utl::OSeekableInputStreamWrapper(rStream));
+ uno::Reference<uno::XInterface> xInterface(xMultiServiceFactory->createInstance("com.sun.star.comp.Writer.XmlFilterAdaptor"), uno::UNO_SET_THROW);
+
+ css::uno::Sequence<OUString> aUserData
+ {
+ "com.sun.star.comp.filter.OdfFlatXml",
+ "",
+ "com.sun.star.comp.Writer.XMLOasisImporter",
+ "com.sun.star.comp.Writer.XMLOasisExporter",
+ "",
+ "",
+ "true"
+ };
+ uno::Sequence<beans::PropertyValue> aAdaptorArgs(comphelper::InitPropertySequence(
+ {
+ { "UserData", uno::Any(aUserData) },
+ }));
+ css::uno::Sequence<uno::Any> aOuterArgs{ uno::Any(aAdaptorArgs) };
+
+ uno::Reference<lang::XInitialization> xInit(xInterface, uno::UNO_QUERY_THROW);
+ xInit->initialize(aOuterArgs);
+
+ uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW);
+ uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
+ {
+ { "InputStream", uno::Any(xStream) },
+ { "URL", uno::Any(OUString("private:stream")) },
+ }));
+ xImporter->setTargetDocument(xModel);
+
+ uno::Reference<document::XFilter> xFODTFilter(xInterface, uno::UNO_QUERY_THROW);
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(xModel.get());
+ SfxObjectShell* pObjSh = pTextDoc ? pTextDoc->GetDocShell() : nullptr;
+
+ //SetLoading hack because the document properties will be re-initted
+ //by the xml filter and during the init, while it's considered uninitialized,
+ //setting a property will inform the document it's modified, which attempts
+ //to update the properties, which throws cause the properties are uninitialized
+ if (pObjSh)
+ pObjSh->SetLoading(SfxLoadedFlags::NONE);
+ bool ret = xFODTFilter->filter(aArgs);
+ if (pObjSh)
+ pObjSh->SetLoading(SfxLoadedFlags::ALL);
+
+ if (ret)
+ {
+ uno::Reference<text::XTextDocument> xTextDocument(xModel, uno::UNO_QUERY);
+ uno::Reference<text::XText> xText(xTextDocument->getText());
+ uno::Reference<container::XEnumerationAccess> xParaAccess(xText, uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xParaEnum(xParaAccess->createEnumeration());
+ while (xParaEnum->hasMoreElements())
+ {
+ uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
+ // discourage very long paragraphs for fuzzing performance
+ if (xPara && xPara->getString().getLength() > 15000)
+ {
+ ret = false;
+ break;
+ }
+ }
+ }
+
+ if (ret)
+ {
+ css::uno::Reference<css::frame::XController2> xController(xModel->createDefaultViewController(xTargetFrame), UNO_SET_THROW);
+ utl::ConnectFrameControllerModel(xTargetFrame, xController, xModel);
+
+ utl::TempFileFast aTempFile;
+
+ uno::Reference<document::XFilter> xPDFFilter(
+ xMultiServiceFactory->createInstance("com.sun.star.document.PDFFilter"), uno::UNO_QUERY);
+ uno::Reference<document::XExporter> xExporter(xPDFFilter, uno::UNO_QUERY);
+ xExporter->setSourceDocument(xModel);
+
+ uno::Reference<io::XOutputStream> xOutputStream(new utl::OStreamWrapper(*aTempFile.GetStream(StreamMode::READWRITE)));
+
+ // ofz#60533 fuzzer learned to use fo:font-size="842pt" which generate timeouts trying
+ // to export thousands of pages from minimal input size
+ uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence({
+ { "PageRange", uno::Any(OUString("1-100")) }
+ }));
+ uno::Sequence<beans::PropertyValue> aDescriptor(comphelper::InitPropertySequence({
+ { "FilterName", uno::Any(OUString("writer_pdf_Export")) },
+ { "OutputStream", uno::Any(xOutputStream) },
+ { "FilterData", uno::Any(aFilterData) }
+ }));
+ xPDFFilter->filter(aDescriptor);
+ }
+
+ css::uno::Reference<css::util::XCloseable> xClose(xModel, css::uno::UNO_QUERY);
+ xClose->close(false);
+
+ return ret;
+}
+
extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportDOCX(SvStream &rStream)
{
SwGlobals::ensure();
@@ -1828,8 +1931,8 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportDOCX(SvStream &rStream)
uno::Reference<document::XImporter> xImporter(xFilter, uno::UNO_QUERY_THROW);
uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
{
- { "InputStream", uno::makeAny(xStream) },
- { "InputMode", uno::makeAny(true) },
+ { "InputStream", uno::Any(xStream) },
+ { "InputMode", uno::Any(true) },
}));
xImporter->setTargetDocument(xModel);
diff --git a/sw/source/filter/xml/xmlimp.hxx b/sw/source/filter/xml/xmlimp.hxx
index 83cee154bbc0..4c528155f24c 100644
--- a/sw/source/filter/xml/xmlimp.hxx
+++ b/sw/source/filter/xml/xmlimp.hxx
@@ -23,6 +23,7 @@
#include <sal/config.h>
#include <memory>
+#include <optional>
#include <com/sun/star/document/XDocumentProperties.hpp>
@@ -31,13 +32,13 @@
#include "xmlitmap.hxx"
#include <o3tl/typed_flags_set.hxx>
+#include <ndindex.hxx>
class SwDoc;
class SvXMLUnitConverter;
class SvXMLTokenMap;
class SvXMLImportItemMapper;
class SfxItemSet;
-class SwNodeIndex;
class XMLTextImportHelper;
class SvXMLGraphicHelper;
class SvXMLEmbeddedObjectHelper;
@@ -47,10 +48,6 @@ enum class SfxStyleFamily;
// for styles, autostyles and settings + meta
#define PROGRESS_BAR_STEP 20
-namespace SwImport {
- SwDoc* GetDocFromXMLImport( SvXMLImport const & );
-}
-
// we only need this scoped enum to be flags here, in sw
namespace o3tl
{
@@ -59,7 +56,7 @@ namespace o3tl
class SwXMLImport: public SvXMLImport
{
- std::unique_ptr<SwNodeIndex> m_pSttNdIdx;
+ std::optional<SwNodeIndex> m_oSttNdIdx;
std::unique_ptr<SvXMLUnitConverter> m_pTwipUnitConv;
std::unique_ptr<SvXMLImportItemMapper> m_pTableItemMapper;// paragraph item import
@@ -87,6 +84,10 @@ class SwXMLImport: public SvXMLImport
SwDoc* m_pDoc; // cached for getDoc()
+ // Optimization for new table name lookup
+ OUString m_sDefTableName; // See STR_TABLE_DEFNAME
+ std::map<OUString, sal_uInt32> m_aTableNameMap; // Last used indices for duplicating table names
+
void InitItemImport();
void FinitItemImport();
void UpdateTextCollConditions( SwDoc *pDoc );
@@ -110,16 +111,12 @@ public:
const css::uno::Reference< css::uno::XComponentContext >& rContext,
OUString const & implementationName, SvXMLImportFlags nImportFlags);
- virtual ~SwXMLImport() throw() override;
+ virtual ~SwXMLImport() noexcept override;
// css::xml::sax::XDocumentHandler
virtual void SAL_CALL startDocument() override;
virtual void SAL_CALL endDocument() override;
- // XUnoTunnel
- static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
- virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
-
// XInitialization
virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
@@ -170,6 +167,9 @@ public:
const SwDoc* getDoc() const;
SwDoc* getDoc();
+
+ const OUString& GetDefTableName() { return m_sDefTableName; }
+ std::map<OUString, sal_uInt32>& GetTableNameMap() { return m_aTableNameMap; }
};
inline const SvXMLImportItemMapper& SwXMLImport::GetTableItemMapper() const
diff --git a/sw/source/filter/xml/xmlimpit.cxx b/sw/source/filter/xml/xmlimpit.cxx
index bfb29a7af264..141491db92de 100644
--- a/sw/source/filter/xml/xmlimpit.cxx
+++ b/sw/source/filter/xml/xmlimpit.cxx
@@ -62,8 +62,8 @@ using uno::Any;
constexpr sal_uInt16 nUnknownWhich = RES_UNKNOWNATR_CONTAINER;
SvXMLImportItemMapper::SvXMLImportItemMapper(
- SvXMLItemMapEntriesRef const & rMapEntries ) :
- mrMapEntries( rMapEntries )
+ SvXMLItemMapEntriesRef aMapEntries ) :
+ mrMapEntries(std::move( aMapEntries ))
{
}
@@ -72,9 +72,9 @@ SvXMLImportItemMapper::~SvXMLImportItemMapper()
}
void
-SvXMLImportItemMapper::setMapEntries( SvXMLItemMapEntriesRef rMapEntries )
+SvXMLImportItemMapper::setMapEntries(const SvXMLItemMapEntriesRef& rMapEntries)
{
- mrMapEntries = std::move(rMapEntries);
+ mrMapEntries = rMapEntries;
}
// fills the given itemset with the attributes in the given list
@@ -112,7 +112,7 @@ void SvXMLImportItemMapper::importXML( SfxItemSet& rSet,
// if it's not set, try the pool
if (SfxItemState::SET != eState && SfxItemPool::IsWhich(pEntry->nWhichId))
- pItem = &rSet.GetPool()->GetDefaultItem(pEntry->nWhichId);
+ pItem = &rSet.GetPool()->GetUserOrPoolDefaultItem(pEntry->nWhichId);
// do we have an item?
if(eState >= SfxItemState::DEFAULT && pItem)
@@ -123,7 +123,7 @@ void SvXMLImportItemMapper::importXML( SfxItemSet& rSet,
if( 0 == (pEntry->nMemberId&MID_SW_FLAG_SPECIAL_ITEM_IMPORT) )
{
bPut = PutXMLValue( *pNewItem, sValue,
- static_cast<sal_uInt16>( pEntry->nMemberId & MID_SW_FLAG_MASK ),
+ o3tl::narrowing<sal_uInt16>( pEntry->nMemberId & MID_SW_FLAG_MASK ),
rUnitConverter );
}
@@ -134,7 +134,7 @@ void SvXMLImportItemMapper::importXML( SfxItemSet& rSet,
}
if( bPut )
- rSet.Put( *pNewItem );
+ rSet.Put( std::move(pNewItem) );
}
else
{
@@ -317,6 +317,12 @@ bool SvXMLImportItemMapper::PutXMLValue(
switch (rItem.Which())
{
+ case RES_MARGIN_FIRSTLINE:
+ case RES_MARGIN_TEXTLEFT:
+ case RES_MARGIN_RIGHT:
+ assert(false); // is only called for frame formats?
+ break;
+
case RES_LR_SPACE:
{
SvxLRSpaceItem& rLRSpace = dynamic_cast<SvxLRSpaceItem&>(rItem);
@@ -339,10 +345,10 @@ bool SvXMLImportItemMapper::PutXMLValue(
switch( nMemberId )
{
case MID_L_MARGIN:
- rLRSpace.SetTextLeft( nAbs, static_cast<sal_uInt16>(nProp) );
+ rLRSpace.SetTextLeft( nAbs, o3tl::narrowing<sal_uInt16>(nProp) );
break;
case MID_R_MARGIN:
- rLRSpace.SetRight( nAbs, static_cast<sal_uInt16>(nProp) );
+ rLRSpace.SetRight( nAbs, o3tl::narrowing<sal_uInt16>(nProp) );
break;
}
}
@@ -351,6 +357,7 @@ bool SvXMLImportItemMapper::PutXMLValue(
case MID_FIRST_LINE_INDENT:
{
+ assert(false); // it looks like this can't be called? (frame formats only, aTableItemMap)
sal_Int32 nProp = 100;
sal_Int32 nAbs = 0;
@@ -360,12 +367,13 @@ bool SvXMLImportItemMapper::PutXMLValue(
bOk = rUnitConverter.convertMeasureToCore(nAbs, rValue,
-0x7fff, 0x7fff );
- rLRSpace.SetTextFirstLineOffset( static_cast<short>(nAbs), static_cast<sal_uInt16>(nProp) );
+ rLRSpace.SetTextFirstLineOffset( static_cast<short>(nAbs), o3tl::narrowing<sal_uInt16>(nProp) );
}
break;
case MID_FIRST_AUTO:
{
+ assert(false); // it looks like this can't be called? (frame formats only, aTableItemMap)
bool bAutoFirst(false);
bOk = ::sax::Converter::convertBool( bAutoFirst, rValue );
if( bOk )
@@ -394,10 +402,10 @@ bool SvXMLImportItemMapper::PutXMLValue(
switch( nMemberId )
{
case MID_UP_MARGIN:
- rULSpace.SetUpper( static_cast<sal_uInt16>(nAbs), static_cast<sal_uInt16>(nProp) );
+ rULSpace.SetUpper( o3tl::narrowing<sal_uInt16>(nAbs), o3tl::narrowing<sal_uInt16>(nProp) );
break;
case MID_LO_MARGIN:
- rULSpace.SetLower( static_cast<sal_uInt16>(nAbs), static_cast<sal_uInt16>(nProp) );
+ rULSpace.SetLower( o3tl::narrowing<sal_uInt16>(nAbs), o3tl::narrowing<sal_uInt16>(nProp) );
break;
default:
OSL_FAIL("unknown MemberId");
@@ -507,16 +515,16 @@ bool SvXMLImportItemMapper::PutXMLValue(
if( nMemberId == LEFT_BORDER_PADDING ||
nMemberId == ALL_BORDER_PADDING )
- rBox.SetDistance( static_cast<sal_uInt16>(nTemp), SvxBoxItemLine::LEFT );
+ rBox.SetDistance( o3tl::narrowing<sal_uInt16>(nTemp), SvxBoxItemLine::LEFT );
if( nMemberId == RIGHT_BORDER_PADDING ||
nMemberId == ALL_BORDER_PADDING )
- rBox.SetDistance( static_cast<sal_uInt16>(nTemp), SvxBoxItemLine::RIGHT );
+ rBox.SetDistance( o3tl::narrowing<sal_uInt16>(nTemp), SvxBoxItemLine::RIGHT );
if( nMemberId == TOP_BORDER_PADDING ||
nMemberId == ALL_BORDER_PADDING )
- rBox.SetDistance( static_cast<sal_uInt16>(nTemp), SvxBoxItemLine::TOP );
+ rBox.SetDistance( o3tl::narrowing<sal_uInt16>(nTemp), SvxBoxItemLine::TOP );
if( nMemberId == BOTTOM_BORDER_PADDING ||
nMemberId == ALL_BORDER_PADDING )
- rBox.SetDistance( static_cast<sal_uInt16>(nTemp), SvxBoxItemLine::BOTTOM);
+ rBox.SetDistance( o3tl::narrowing<sal_uInt16>(nTemp), SvxBoxItemLine::BOTTOM);
break;
case ALL_BORDER:
@@ -831,7 +839,7 @@ bool SvXMLImportItemMapper::PutXMLValue(
// "auto" as "0" for tables - now that we support a real offset
// 0, this fake "0" MUST NOT be imported as offset 0!
if( bOk && nVal > 0 )
- rPageDesc.SetNumOffset( static_cast<sal_uInt16>(nVal) );
+ rPageDesc.SetNumOffset( o3tl::narrowing<sal_uInt16>(nVal) );
}
}
break;
@@ -856,6 +864,23 @@ bool SvXMLImportItemMapper::PutXMLValue(
}
break;
+ case RES_PRINT:
+ {
+ SfxBoolItem& rHasTextChangesOnly = dynamic_cast<SfxBoolItem&>(rItem);
+
+ if( IsXMLToken( rValue, XML_TRUE ) )
+ {
+ rHasTextChangesOnly.SetValue( true );
+ bOk = true;
+ }
+ else if( IsXMLToken( rValue, XML_FALSE ) )
+ {
+ rHasTextChangesOnly.SetValue( false );
+ bOk = true;
+ }
+ }
+ break;
+
case RES_HORI_ORIENT:
{
SwFormatHoriOrient& rHoriOrient = dynamic_cast<SwFormatHoriOrient&>(rItem);
@@ -944,7 +969,7 @@ bool SvXMLImportItemMapper::PutXMLValue(
else if( nValue > SAL_MAX_UINT16 )
nValue = SAL_MAX_UINT16;
- rFrameSize.SetWidth( static_cast<sal_uInt16>(nValue) );
+ rFrameSize.SetWidth( o3tl::narrowing<sal_uInt16>(nValue) );
rFrameSize.SetHeightSizeType( SwFrameSize::Variable );
bOk = true;
}
@@ -960,9 +985,9 @@ bool SvXMLImportItemMapper::PutXMLValue(
if( bOk )
{
if( bSetWidth )
- rFrameSize.SetWidth( static_cast<sal_uInt16>(nValue) );
+ rFrameSize.SetWidth( o3tl::narrowing<sal_uInt16>(nValue) );
if( bSetHeight )
- rFrameSize.SetHeight( static_cast<sal_uInt16>(nValue) );
+ rFrameSize.SetHeight( o3tl::narrowing<sal_uInt16>(nValue) );
if( bSetSizeType )
rFrameSize.SetHeightSizeType( eSizeType );
}
@@ -980,6 +1005,13 @@ bool SvXMLImportItemMapper::PutXMLValue(
aAny <<= static_cast<sal_uInt16>(SvxFrameDirection::Vertical_LR_BT);
bOk = rItem.PutValue(aAny, 0);
}
+ else if (IsXMLToken(rValue, XML_TB_RL90))
+ {
+ // Read tb-rl90 from the extension namespace.
+ Any aAny;
+ aAny <<= static_cast<sal_uInt16>(SvxFrameDirection::Vertical_RL_TB90);
+ bOk = rItem.PutValue(aAny, 0);
+ }
else
{
std::unique_ptr<XMLPropertyHandler> pWritingModeHandler =
diff --git a/sw/source/filter/xml/xmlimpit.hxx b/sw/source/filter/xml/xmlimpit.hxx
index 3973623515d7..5df248fac6a8 100644
--- a/sw/source/filter/xml/xmlimpit.hxx
+++ b/sw/source/filter/xml/xmlimpit.hxx
@@ -31,11 +31,10 @@ class SvXMLAttrContainerItem;
class SvXMLImportItemMapper
{
-protected:
SvXMLItemMapEntriesRef mrMapEntries;
public:
- explicit SvXMLImportItemMapper( SvXMLItemMapEntriesRef const & rMapEntries );
+ explicit SvXMLImportItemMapper( SvXMLItemMapEntriesRef aMapEntries );
virtual ~SvXMLImportItemMapper();
/** fills the given itemset with the attributes in the given list */
@@ -65,7 +64,7 @@ public:
virtual void finished(SfxItemSet & rSet,
SvXMLUnitConverter const& rUnitConverter) const;
- virtual void setMapEntries( SvXMLItemMapEntriesRef rMapEntries );
+ virtual void setMapEntries(const SvXMLItemMapEntriesRef& rMapEntries);
inline const SvXMLItemMapEntriesRef& getMapEntries() const;
/** This method is called for every item that should be set based
diff --git a/sw/source/filter/xml/xmlitem.cxx b/sw/source/filter/xml/xmlitem.cxx
index 899c0b6bb1ad..ff98d2ff691b 100644
--- a/sw/source/filter/xml/xmlitem.cxx
+++ b/sw/source/filter/xml/xmlitem.cxx
@@ -33,21 +33,20 @@ SwXMLItemSetContext::SwXMLItemSetContext( SvXMLImport& rImp, sal_Int32 /*nElemen
SvXMLImportItemMapper& rIMap,
const SvXMLUnitConverter& rUnitConverter ):
SvXMLImportContext( rImp ),
- rItemSet( rISet ),
- rIMapper( rIMap ),
- rUnitConv( rUnitConverter )
+ m_rItemSet( rISet ),
+ m_rIMapper( rIMap ),
+ m_rUnitConv( rUnitConverter )
{
- rIMap.importXML( rItemSet, xAttrList, rUnitConv,
+ rIMap.importXML( m_rItemSet, xAttrList, m_rUnitConv,
GetImport().GetNamespaceMap() );
}
SwXMLItemSetContext::~SwXMLItemSetContext()
{
- if( xBackground.is() )
+ if( m_xBackground.is() )
{
- const SvxBrushItem& rItem =
- static_cast<SwXMLBrushItemImportContext*>(xBackground.get())->GetItem();
- rItemSet.Put( rItem );
+ const SvxBrushItem& rItem = m_xBackground->GetItem();
+ m_rItemSet.Put( rItem );
}
}
@@ -55,12 +54,12 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SwXMLItemSetContext::c
sal_Int32 nElement,
const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
{
- SvXMLItemMapEntriesRef xMapEntries = rIMapper.getMapEntries();
+ SvXMLItemMapEntriesRef xMapEntries = m_rIMapper.getMapEntries();
SvXMLItemMapEntry const * pEntry = xMapEntries->getByName( nElement );
if( pEntry && 0 != (pEntry->nMemberId & MID_SW_FLAG_ELEMENT_ITEM_IMPORT) )
{
- return createFastChildContext( nElement, xAttrList, *pEntry ).get();
+ return createFastChildContext( nElement, xAttrList, *pEntry );
}
else
XMLOFF_WARN_UNKNOWN_ELEMENT("sw", nElement);
@@ -75,27 +74,26 @@ SvXMLImportContextRef SwXMLItemSetContext::createFastChildContext( sal_Int32 nEl
const uno::Reference< xml::sax::XFastAttributeList >& xAttrList,
const SvXMLItemMapEntry& rEntry )
{
- SvXMLImportContextRef xContext;
+ rtl::Reference<SwXMLBrushItemImportContext> xContext;
switch( rEntry.nWhichId )
{
case RES_BACKGROUND:
{
- const SfxPoolItem *pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND,
- false, &pItem ) )
+ if( const SvxBrushItem* pItem = m_rItemSet.GetItemIfSet( RES_BACKGROUND,
+ false ) )
{
xContext = new SwXMLBrushItemImportContext(
GetImport(), nElement, xAttrList,
- rUnitConv, *static_cast<const SvxBrushItem *>(pItem) );
+ m_rUnitConv, *pItem );
}
else
{
xContext = new SwXMLBrushItemImportContext(
GetImport(), nElement, xAttrList,
- rUnitConv, RES_BACKGROUND );
+ m_rUnitConv, RES_BACKGROUND );
}
- xBackground = xContext;
+ m_xBackground = xContext;
}
break;
}
diff --git a/sw/source/filter/xml/xmlitem.hxx b/sw/source/filter/xml/xmlitem.hxx
index 2993ab2d0b7e..cd6f9c8db62e 100644
--- a/sw/source/filter/xml/xmlitem.hxx
+++ b/sw/source/filter/xml/xmlitem.hxx
@@ -28,13 +28,14 @@ class SfxItemSet;
class SvXMLImportItemMapper;
class SvXMLUnitConverter;
struct SvXMLItemMapEntry;
+class SwXMLBrushItemImportContext;
class SwXMLItemSetContext final : public SvXMLImportContext
{
- SfxItemSet &rItemSet;
- const SvXMLImportItemMapper &rIMapper;
- const SvXMLUnitConverter &rUnitConv;
- SvXMLImportContextRef xBackground;
+ SfxItemSet &m_rItemSet;
+ const SvXMLImportItemMapper &m_rIMapper;
+ const SvXMLUnitConverter &m_rUnitConv;
+ rtl::Reference<SwXMLBrushItemImportContext> m_xBackground;
public:
diff --git a/sw/source/filter/xml/xmliteme.cxx b/sw/source/filter/xml/xmliteme.cxx
index ca590f6ddef6..84ea82ab3017 100644
--- a/sw/source/filter/xml/xmliteme.cxx
+++ b/sw/source/filter/xml/xmliteme.cxx
@@ -33,25 +33,25 @@
#include <frmfmt.hxx>
#include "xmlexp.hxx"
#include <editeng/memberids.h>
+#include <editeng/prntitem.hxx>
using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
using namespace ::xmloff::token;
namespace {
class SwXMLTableItemMapper_Impl: public SvXMLExportItemMapper
{
- SwXMLBrushItemExport aBrushItemExport;
+ SwXMLBrushItemExport m_aBrushItemExport;
protected:
- sal_uInt32 nAbsWidth;
+ sal_uInt32 m_nAbsWidth;
static void AddAttribute( sal_uInt16 nPrefix, enum XMLTokenEnum eLName,
const OUString& rValue,
const SvXMLNamespaceMap& rNamespaceMap,
- SvXMLAttributeList& rAttrList );
+ comphelper::AttributeList& rAttrList );
public:
@@ -59,7 +59,7 @@ public:
SvXMLItemMapEntriesRef rMapEntries,
SwXMLExport& rExp );
- virtual void handleSpecialItem( SvXMLAttributeList& rAttrList,
+ virtual void handleSpecialItem( comphelper::AttributeList& rAttrList,
const SvXMLItemMapEntry& rEntry,
const SfxPoolItem& rItem,
const SvXMLUnitConverter& rUnitConverter,
@@ -79,8 +79,8 @@ SwXMLTableItemMapper_Impl::SwXMLTableItemMapper_Impl(
SvXMLItemMapEntriesRef rMapEntries,
SwXMLExport& rExp ) :
SvXMLExportItemMapper( std::move(rMapEntries) ),
- aBrushItemExport( rExp ),
- nAbsWidth( USHRT_MAX )
+ m_aBrushItemExport( rExp ),
+ m_nAbsWidth( USHRT_MAX )
{
}
@@ -88,7 +88,7 @@ void SwXMLTableItemMapper_Impl::AddAttribute( sal_uInt16 nPrefix,
enum XMLTokenEnum eLName,
const OUString& rValue,
const SvXMLNamespaceMap& rNamespaceMap,
- SvXMLAttributeList& rAttrList )
+ comphelper::AttributeList& rAttrList )
{
OUString sName( rNamespaceMap.GetQNameByKey( nPrefix,
GetXMLToken(eLName) ) );
@@ -96,7 +96,7 @@ void SwXMLTableItemMapper_Impl::AddAttribute( sal_uInt16 nPrefix,
}
void SwXMLTableItemMapper_Impl::handleSpecialItem(
- SvXMLAttributeList& rAttrList,
+ comphelper::AttributeList& rAttrList,
const SvXMLItemMapEntry& rEntry,
const SfxPoolItem& rItem,
const SvXMLUnitConverter& rUnitConverter,
@@ -105,18 +105,41 @@ void SwXMLTableItemMapper_Impl::handleSpecialItem(
{
switch( rEntry.nWhichId )
{
+
+ case RES_PRINT:
+ {
+ const SvxPrintItem *pItem;
+ if( pSet &&
+ (pItem = pSet->GetItemIfSet( RES_PRINT )) )
+ {
+ bool bHasTextChangesOnly = pItem->GetValue();
+ if ( !bHasTextChangesOnly )
+ {
+ OUString sValue;
+ sal_uInt16 nMemberId =
+ static_cast<sal_uInt16>( rEntry.nMemberId & MID_SW_FLAG_MASK );
+
+ if( SvXMLExportItemMapper::QueryXMLValue(
+ rItem, sValue, nMemberId, rUnitConverter ) )
+ {
+ AddAttribute( rEntry.nNameSpace, rEntry.eLocalName,
+ sValue, rNamespaceMap, rAttrList );
+ }
+ }
+ }
+ }
+ break;
+
case RES_LR_SPACE:
{
- const SfxPoolItem *pItem;
+ const SwFormatHoriOrient *pItem;
if( pSet &&
- SfxItemState::SET == pSet->GetItemState( RES_HORI_ORIENT, true,
- &pItem ) )
+ (pItem = pSet->GetItemIfSet( RES_HORI_ORIENT )) )
{
- sal_Int16 eHoriOrient =
- static_cast<const SwFormatHoriOrient *>(pItem)->GetHoriOrient();
+ sal_Int16 eHoriOrient = pItem->GetHoriOrient();
bool bExport = false;
sal_uInt16 nMemberId =
- static_cast<sal_uInt16>( rEntry.nMemberId & MID_SW_FLAG_MASK );
+ o3tl::narrowing<sal_uInt16>( rEntry.nMemberId & MID_SW_FLAG_MASK );
switch( nMemberId )
{
case MID_L_MARGIN:
@@ -141,14 +164,14 @@ void SwXMLTableItemMapper_Impl::handleSpecialItem(
case RES_FRM_SIZE:
{
sal_uInt16 nMemberId =
- static_cast<sal_uInt16>( rEntry.nMemberId & MID_SW_FLAG_MASK );
+ o3tl::narrowing<sal_uInt16>( rEntry.nMemberId & MID_SW_FLAG_MASK );
switch( nMemberId )
{
case MID_FRMSIZE_WIDTH:
- if( nAbsWidth )
+ if( m_nAbsWidth )
{
OUStringBuffer sBuffer;
- rUnitConverter.convertMeasureToXML( sBuffer, nAbsWidth );
+ rUnitConverter.convertMeasureToXML( sBuffer, m_nAbsWidth );
AddAttribute( rEntry.nNameSpace, rEntry.eLocalName,
sBuffer.makeStringAndClear(),
rNamespaceMap, rAttrList );
@@ -181,7 +204,7 @@ void SwXMLTableItemMapper_Impl::handleElementItem(
{
case RES_BACKGROUND:
{
- const_cast<SwXMLTableItemMapper_Impl *>(this)->aBrushItemExport.exportXML(
+ const_cast<SwXMLTableItemMapper_Impl *>(this)->m_aBrushItemExport.exportXML(
static_cast<const SvxBrushItem&>(rItem) );
}
break;
@@ -190,13 +213,14 @@ void SwXMLTableItemMapper_Impl::handleElementItem(
inline void SwXMLTableItemMapper_Impl::SetAbsWidth( sal_uInt32 nAbs )
{
- nAbsWidth = nAbs;
+ m_nAbsWidth = nAbs;
}
void SwXMLExport::InitItemExport()
{
m_pTwipUnitConverter.reset(new SvXMLUnitConverter(getComponentContext(),
- util::MeasureUnit::TWIP, GetMM100UnitConverter().GetXMLMeasureUnit()));
+ util::MeasureUnit::TWIP, GetMM100UnitConverter().GetXMLMeasureUnit(),
+ getSaneDefaultVersion()));
m_xTableItemMap = new SvXMLItemMapEntries( aXMLTableItemMap );
m_xTableRowItemMap = new SvXMLItemMapEntries( aXMLTableRowItemMap );
@@ -215,7 +239,7 @@ void SwXMLExport::ExportTableFormat( const SwFrameFormat& rFormat, sal_uInt32 nA
{
static_cast<SwXMLTableItemMapper_Impl *>(m_pTableItemMapper.get())
->SetAbsWidth( nAbsWidth );
- ExportFormat( rFormat, XML_TABLE );
+ ExportFormat(rFormat, XML_TABLE, {});
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/xml/xmlitemi.cxx b/sw/source/filter/xml/xmlitemi.cxx
index 6284be492afc..e4655143b4ea 100644
--- a/sw/source/filter/xml/xmlitemi.cxx
+++ b/sw/source/filter/xml/xmlitemi.cxx
@@ -66,7 +66,7 @@ public:
virtual void finished(SfxItemSet & rSet,
SvXMLUnitConverter const& rUnitConverter) const override;
- virtual void setMapEntries( SvXMLItemMapEntriesRef rMapEntries ) override;
+ virtual void setMapEntries(const SvXMLItemMapEntriesRef& rMapEntries) override;
private:
void Reset();
@@ -95,7 +95,7 @@ void SwXMLImportTableItemMapper_Impl::Reset()
}
void SwXMLImportTableItemMapper_Impl::setMapEntries(
- SvXMLItemMapEntriesRef rMapEntries )
+ const SvXMLItemMapEntriesRef& rMapEntries)
{
Reset();
SvXMLImportItemMapper::setMapEntries(rMapEntries);
@@ -201,7 +201,7 @@ void SwXMLImportTableItemMapper_Impl::finished(
// if not set, try the pool
if ((SfxItemState::SET != eState) && SfxItemPool::IsWhich(Ids[i][0]))
{
- pItem = &rSet.GetPool()->GetDefaultItem(Ids[i][0]);
+ pItem = &rSet.GetPool()->GetUserOrPoolDefaultItem(Ids[i][0]);
}
// do we have an item?
@@ -225,7 +225,8 @@ void SwXMLImportTableItemMapper_Impl::finished(
void SwXMLImport::InitItemImport()
{
m_pTwipUnitConv.reset( new SvXMLUnitConverter( GetComponentContext(),
- util::MeasureUnit::TWIP, util::MeasureUnit::TWIP ) );
+ util::MeasureUnit::TWIP, util::MeasureUnit::TWIP,
+ SvtSaveOptions::ODFSVER_LATEST_EXTENDED) );
m_xTableItemMap = new SvXMLItemMapEntries( aXMLTableItemMap );
m_xTableColItemMap = new SvXMLItemMapEntries( aXMLTableColItemMap );
diff --git a/sw/source/filter/xml/xmlitemm.cxx b/sw/source/filter/xml/xmlitemm.cxx
index 95462b8ac7b9..0d25da02c109 100644
--- a/sw/source/filter/xml/xmlitemm.cxx
+++ b/sw/source/filter/xml/xmlitemm.cxx
@@ -23,23 +23,22 @@
#include <xmloff/xmlnamespace.hxx>
#include "xmlitmap.hxx"
#include <xmloff/xmltoken.hxx>
+#include <o3tl/safeint.hxx>
#include <unomid.h>
using namespace ::xmloff::token;
#define MAP_ENTRY( p, l, w, m ) \
- { XML_NAMESPACE_##p, XML_##l, static_cast<sal_uInt16>(w), m }
+ { XML_NAMESPACE_##p, XML_##l, o3tl::narrowing<sal_uInt16>(w), m }
#define M_E_SI( p, l, w, m ) \
- { XML_NAMESPACE_##p, XML_##l, static_cast<sal_uInt16>(w), MID_SW_FLAG_SPECIAL_ITEM_IMPORT|m }
+ { XML_NAMESPACE_##p, XML_##l, o3tl::narrowing<sal_uInt16>(w), MID_SW_FLAG_SPECIAL_ITEM_IMPORT|m }
#define M_E_SE( p, l, w, m ) \
- { XML_NAMESPACE_##p, XML_##l, static_cast<sal_uInt16>(w), MID_SW_FLAG_SPECIAL_ITEM_EXPORT|m }
+ { XML_NAMESPACE_##p, XML_##l, o3tl::narrowing<sal_uInt16>(w), MID_SW_FLAG_SPECIAL_ITEM_EXPORT|m }
#define M_E_SIE( p, l, w, m ) \
- { XML_NAMESPACE_##p, XML_##l, static_cast<sal_uInt16>(w), MID_SW_FLAG_SPECIAL_ITEM_EXPORT|MID_SW_FLAG_SPECIAL_ITEM_IMPORT|m }
+ { XML_NAMESPACE_##p, XML_##l, o3tl::narrowing<sal_uInt16>(w), MID_SW_FLAG_SPECIAL_ITEM_EXPORT|MID_SW_FLAG_SPECIAL_ITEM_IMPORT|m }
-#define M_END { 0, XML_TOKEN_INVALID, 0, 0 }
-
-SvXMLItemMapEntry const aXMLTableItemMap[] =
+const SvXMLItemMapEntry aTableItemMap[] =
{
// RES_FILL_ORDER
// not required
@@ -48,7 +47,6 @@ SvXMLItemMapEntry const aXMLTableItemMap[] =
M_E_SE( STYLE, REL_WIDTH, RES_FRM_SIZE, MID_FRMSIZE_REL_WIDTH ),
// RES_PAPER_BIN
// not required
- // TODO: RES_LR_SPACE
M_E_SE( FO, MARGIN, 0xFFFF/*invalid*/, MID_SW_FLAG_NO_ITEM_IMPORT),
M_E_SIE( FO, MARGIN_LEFT, RES_LR_SPACE, MID_L_MARGIN ),
M_E_SIE( FO, MARGIN_RIGHT, RES_LR_SPACE, MID_R_MARGIN ),
@@ -114,19 +112,18 @@ SvXMLItemMapEntry const aXMLTableItemMap[] =
MAP_ENTRY( STYLE, WRITING_MODE, RES_FRAMEDIR, 0 ),
// RES_COLLAPSING_BORDERS
- MAP_ENTRY( TABLE, BORDER_MODEL, RES_COLLAPSING_BORDERS, 0 ),
-
- M_END
+ MAP_ENTRY( TABLE, BORDER_MODEL, RES_COLLAPSING_BORDERS, 0 )
};
+const std::span<SvXMLItemMapEntry const> aXMLTableItemMap(aTableItemMap);
-SvXMLItemMapEntry const aXMLTableColItemMap[] =
+const SvXMLItemMapEntry aTableColItemMap[] =
{
M_E_SI( STYLE, COLUMN_WIDTH, RES_FRM_SIZE, MID_FRMSIZE_COL_WIDTH ),
MAP_ENTRY( STYLE, REL_COLUMN_WIDTH, RES_FRM_SIZE, MID_FRMSIZE_REL_COL_WIDTH ),
- M_END
};
+const std::span<SvXMLItemMapEntry const> aXMLTableColItemMap(aTableColItemMap);
-SvXMLItemMapEntry const aXMLTableRowItemMap[] =
+const SvXMLItemMapEntry aTableRowItemMap[] =
{
// RES_FILL_ORDER
// not required
@@ -150,7 +147,8 @@ SvXMLItemMapEntry const aXMLTableRowItemMap[] =
// RES_FOOTER
// not required
// RES_PRINT
- // not required
+ // M_E_SE( STYLE, TEXT_CHANGES_ONLY, RES_PRINT, 0 ),
+ M_E_SE( LO_EXT, TEXT_CHANGES_ONLY, RES_PRINT, 0 ),
// RES_OPAQUE
// not required
// RES_PROTECT
@@ -194,11 +192,11 @@ SvXMLItemMapEntry const aXMLTableRowItemMap[] =
// RES_END_AT_TXTEND
// not required
// RES_UNKNOWNATR_CONTAINER
- M_E_SE( TEXT, XMLNS, RES_UNKNOWNATR_CONTAINER, 0 ),
- M_END
+ M_E_SE( TEXT, XMLNS, RES_UNKNOWNATR_CONTAINER, 0 )
};
+const std::span<SvXMLItemMapEntry const> aXMLTableRowItemMap(aTableRowItemMap);
-SvXMLItemMapEntry const aXMLTableCellItemMap[] =
+const SvXMLItemMapEntry aTableCellItemMap[] =
{
// RES_FILL_ORDER
// not required
@@ -221,7 +219,8 @@ SvXMLItemMapEntry const aXMLTableCellItemMap[] =
// RES_FOOTER
// not required
// RES_PRINT
- // not required
+ // M_E_SE( STYLE, TEXT_CHANGES_ONLY, RES_PRINT, 0 ),
+ M_E_SE( LO_EXT, TEXT_CHANGES_ONLY, RES_PRINT, 0 ),
// RES_OPAQUE
// not required
// RES_PROTECT
@@ -281,8 +280,7 @@ SvXMLItemMapEntry const aXMLTableCellItemMap[] =
// RES_FRAMEDIR
MAP_ENTRY( STYLE, WRITING_MODE, RES_FRAMEDIR, 0 ),
MAP_ENTRY( LO_EXT, WRITING_MODE, RES_FRAMEDIR, 0 ),
-
- M_END
};
+const std::span<SvXMLItemMapEntry const> aXMLTableCellItemMap(aTableCellItemMap);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/xml/xmlithlp.cxx b/sw/source/filter/xml/xmlithlp.cxx
index 552170949d91..d629765d7843 100644
--- a/sw/source/filter/xml/xmlithlp.cxx
+++ b/sw/source/filter/xml/xmlithlp.cxx
@@ -26,6 +26,7 @@
#include <xmloff/xmluconv.hxx>
#include <osl/diagnose.h>
+#include <o3tl/safeint.hxx>
#include <com/sun/star/table/BorderLineStyle.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
@@ -67,11 +68,10 @@ const struct SvXMLEnumMapEntry<sal_uInt16> psXML_NamedBorderWidths[] =
};
// mapping tables to map external xml input to internal box line widths
-const sal_uInt16 aBorderWidths[] =
-{
- DEF_LINE_WIDTH_0,
- DEF_LINE_WIDTH_5,
- DEF_LINE_WIDTH_1,
+const sal_uInt16 aBorderWidths[] = {
+ SvxBorderLineWidth::Hairline,
+ SvxBorderLineWidth::VeryThin,
+ SvxBorderLineWidth::Thin
};
bool sw_frmitems_parseXMLBorder( std::u16string_view rValue,
@@ -114,7 +114,7 @@ bool sw_frmitems_parseXMLBorder( std::u16string_view rValue,
else if( !rHasWidth &&
rUnitConverter.convertMeasureToCore(nTemp, aToken, 0, USHRT_MAX))
{
- rWidth = static_cast<sal_uInt16>(nTemp);
+ rWidth = o3tl::narrowing<sal_uInt16>(nTemp);
rHasWidth = true;
}
else
@@ -163,7 +163,7 @@ bool sw_frmitems_setXMLBorder( std::unique_ptr<SvxBorderLine>& rpLine,
( bHasStyle &&
((table::BorderLineStyle::SOLID == nStyle && rpLine->GetDistance()) ||
(table::BorderLineStyle::DOUBLE == nStyle && !rpLine->GetDistance())) ) )
- {
+ {
bool bDouble = (bHasWidth && table::BorderLineStyle::DOUBLE == nStyle ) ||
rpLine->GetDistance();
@@ -189,7 +189,7 @@ bool sw_frmitems_setXMLBorder( std::unique_ptr<SvxBorderLine>& rpLine,
}
}
sw_frmitems_setXMLBorderStyle( *rpLine, nStyle );
- }
+ }
// set color
if( bHasColor )
diff --git a/sw/source/filter/xml/xmlitmap.hxx b/sw/source/filter/xml/xmlitmap.hxx
index 8d5adb4af4f9..5c7f731cc1b5 100644
--- a/sw/source/filter/xml/xmlitmap.hxx
+++ b/sw/source/filter/xml/xmlitmap.hxx
@@ -24,6 +24,7 @@
#include <tools/ref.hxx>
#include <xmloff/xmltoken.hxx>
#include <memory>
+#include <span>
#define MID_SW_FLAG_MASK 0x0000ffff
@@ -57,31 +58,29 @@ struct SvXMLItemMapEntry
: nNameSpace(nameSpace), nWhichId(whichId), eLocalName(localName), nMemberId(memberId) {}
};
-class SvXMLItemMapEntries_impl;
-
/** this class manages an array of SvXMLItemMapEntry. It is
used for optimizing the static array on startup of import
or export */
class SvXMLItemMapEntries final : public SvRefBase
{
- std::unique_ptr<SvXMLItemMapEntries_impl> mpImpl;
+ std::span<SvXMLItemMapEntry const> mpEntries;
public:
- explicit SvXMLItemMapEntries(SvXMLItemMapEntry const * pEntrys);
+ explicit SvXMLItemMapEntries(std::span<SvXMLItemMapEntry const> pEntries) : mpEntries(pEntries) {}
virtual ~SvXMLItemMapEntries() override;
SvXMLItemMapEntry const * getByName( sal_Int32 nElement ) const;
- SvXMLItemMapEntry const & getByIndex( sal_uInt16 nIndex ) const;
+ SvXMLItemMapEntry const & getByIndex( sal_uInt16 nIndex ) const { return mpEntries[nIndex]; }
- sal_uInt16 getCount() const;
+ sal_uInt16 getCount() const { return mpEntries.size(); }
};
typedef tools::SvRef<SvXMLItemMapEntries> SvXMLItemMapEntriesRef;
-extern SvXMLItemMapEntry const aXMLTableItemMap[];
-extern SvXMLItemMapEntry const aXMLTableColItemMap[];
-extern SvXMLItemMapEntry const aXMLTableRowItemMap[];
-extern SvXMLItemMapEntry const aXMLTableCellItemMap[];
+extern const std::span<SvXMLItemMapEntry const> aXMLTableItemMap;
+extern const std::span<SvXMLItemMapEntry const> aXMLTableColItemMap;
+extern const std::span<SvXMLItemMapEntry const> aXMLTableRowItemMap;
+extern const std::span<SvXMLItemMapEntry const> aXMLTableCellItemMap;
#endif // INCLUDED_SW_SOURCE_FILTER_XML_XMLITMAP_HXX
diff --git a/sw/source/filter/xml/xmlitmpr.cxx b/sw/source/filter/xml/xmlitmpr.cxx
index 9250d079bcba..e7cf7ec90d78 100644
--- a/sw/source/filter/xml/xmlitmpr.cxx
+++ b/sw/source/filter/xml/xmlitmpr.cxx
@@ -20,56 +20,20 @@
#include "xmlitmap.hxx"
#include <xmloff/xmlimp.hxx>
-using ::xmloff::token::IsXMLToken;
-using ::xmloff::token::XML_TOKEN_INVALID;
-
-// TODO: optimize this!
-class SvXMLItemMapEntries_impl
-{
-public:
- SvXMLItemMapEntry const * mpEntries;
- sal_uInt16 mnCount;
-};
-
-SvXMLItemMapEntries::SvXMLItemMapEntries( SvXMLItemMapEntry const * pEntries )
- : mpImpl( new SvXMLItemMapEntries_impl )
-{
- mpImpl->mpEntries = pEntries;
-
- mpImpl->mnCount = 0;
- while( pEntries->eLocalName != XML_TOKEN_INVALID )
- {
- pEntries++;
- mpImpl->mnCount++;
- }
-}
-
SvXMLItemMapEntries::~SvXMLItemMapEntries()
{
}
SvXMLItemMapEntry const * SvXMLItemMapEntries::getByName( sal_Int32 nElement ) const
{
- SvXMLItemMapEntry const * pMap = mpImpl->mpEntries;
- while( pMap && (pMap->eLocalName != XML_TOKEN_INVALID) )
+ for (const SvXMLItemMapEntry& rEntry : mpEntries)
{
- if( IsTokenInNamespace(nElement, pMap->nNameSpace) &&
- (nElement & TOKEN_MASK) == pMap->eLocalName )
- break;
- pMap++;
+ if( IsTokenInNamespace(nElement, rEntry.nNameSpace) &&
+ (nElement & TOKEN_MASK) == rEntry.eLocalName )
+ return &rEntry;
}
- return (pMap && (pMap->eLocalName != XML_TOKEN_INVALID)) ? pMap : nullptr;
-}
-
-SvXMLItemMapEntry const & SvXMLItemMapEntries::getByIndex( sal_uInt16 nIndex ) const
-{
- return mpImpl->mpEntries[nIndex];
-}
-
-sal_uInt16 SvXMLItemMapEntries::getCount() const
-{
- return mpImpl->mnCount;
+ return nullptr;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/xml/xmlmeta.cxx b/sw/source/filter/xml/xmlmeta.cxx
index 50c8f8b1c9c7..21f79d61f474 100644
--- a/sw/source/filter/xml/xmlmeta.cxx
+++ b/sw/source/filter/xml/xmlmeta.cxx
@@ -22,6 +22,7 @@
#include <osl/diagnose.h>
#include <xmloff/xmlmetai.hxx>
#include <xmloff/ProgressBarHelper.hxx>
+#include <xmloff/xmltkmap.hxx>
#include <o3tl/safeint.hxx>
#include <xmloff/xmluconv.hxx>
#include <docstat.hxx>
@@ -32,9 +33,6 @@
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::text;
-using namespace ::xmloff::token;
uno::Reference<document::XDocumentProperties>
SwXMLImport::GetDocumentProperties() const
@@ -108,7 +106,7 @@ void SwXMLImport::SetStatistics(
SvXMLImport::SetStatistics(i_rStats);
- SwDoc *pDoc = SwImport::GetDocFromXMLImport( *this );
+ SwDoc *pDoc = getDoc();
SwDocStat aDocStat( pDoc->getIDocumentStatistics().GetDocStat() );
sal_uInt32 nTokens = 0;
@@ -121,7 +119,7 @@ void SwXMLImport::SetStatistics(
if (rStat.Value >>= val) {
if (pStat->target16 != nullptr) {
aDocStat.*(pStat->target16)
- = static_cast<sal_uInt16> (val);
+ = o3tl::narrowing<sal_uInt16> (val);
} else {
aDocStat.*(pStat->target32)
= static_cast<sal_uInt32> (val);
diff --git a/sw/source/filter/xml/xmlscript.cxx b/sw/source/filter/xml/xmlscript.cxx
index 07a94e8a5af4..ebe0680e17e7 100644
--- a/sw/source/filter/xml/xmlscript.cxx
+++ b/sw/source/filter/xml/xmlscript.cxx
@@ -20,8 +20,6 @@
#include <xmloff/xmlscripti.hxx>
#include "xmlimp.hxx"
-using namespace ::com::sun::star;
-
SvXMLImportContext* SwXMLImport::CreateScriptContext()
{
SvXMLImportContext* pContext = nullptr;
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index ad79a92e3732..e34a900def70 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -32,6 +32,7 @@
#include <xmloff/numehelp.hxx>
#include <editeng/brushitem.hxx>
#include <editeng/boxitem.hxx>
+#include <editeng/prntitem.hxx>
#include <editeng/xmlcnitm.hxx>
#include <fmtrowsplt.hxx>
#include <editeng/frmdiritem.hxx>
@@ -58,8 +59,6 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::text;
using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::container;
using namespace ::xmloff::token;
using table::XCell;
using std::vector;
@@ -68,21 +67,21 @@ using std::advance;
class SwXMLTableColumn_Impl : public SwWriteTableCol
{
- OUString sStyleName;
- sal_uInt32 nRelWidth;
+ OUString m_sStyleName;
+ sal_uInt32 m_nRelWidth;
public:
explicit SwXMLTableColumn_Impl(sal_uInt32 nPosition)
: SwWriteTableCol(nPosition)
- , nRelWidth(0)
+ , m_nRelWidth(0)
{};
- void SetStyleName( const OUString& rName ) { sStyleName = rName; }
- const OUString& GetStyleName() const { return sStyleName; }
+ void SetStyleName( const OUString& rName ) { m_sStyleName = rName; }
+ const OUString& GetStyleName() const { return m_sStyleName; }
- void SetRelWidth( sal_uInt32 nSet ) { nRelWidth = nSet; }
- sal_uInt32 GetRelWidth() const { return nRelWidth; }
+ void SetRelWidth( sal_uInt32 nSet ) { m_nRelWidth = nSet; }
+ sal_uInt32 GetRelWidth() const { return m_nRelWidth; }
};
namespace {
@@ -98,7 +97,7 @@ struct SwXMLTableColumnCmpWidth_Impl
}
};
-class SwXMLTableColumns_Impl : public o3tl::sorted_vector<std::unique_ptr<SwXMLTableColumn_Impl>, o3tl::less_uniqueptr_to<SwXMLTableColumn_Impl> > {
+class SwXMLTableColumns_Impl : public o3tl::sorted_vector<std::unique_ptr<SwXMLTableColumn_Impl>, o3tl::less_ptr_to > {
};
}
@@ -107,23 +106,23 @@ class SwXMLTableColumnsSortByWidth_Impl : public o3tl::sorted_vector<SwXMLTableC
class SwXMLTableLines_Impl
{
- SwXMLTableColumns_Impl aCols;
- const SwTableLines *pLines;
- sal_uInt32 nWidth;
+ SwXMLTableColumns_Impl m_aCols;
+ const SwTableLines *m_pLines;
+ sal_uInt32 m_nWidth;
public:
explicit SwXMLTableLines_Impl( const SwTableLines& rLines );
- sal_uInt32 GetWidth() const { return nWidth; }
- const SwTableLines *GetLines() const { return pLines; }
+ sal_uInt32 GetWidth() const { return m_nWidth; }
+ const SwTableLines *GetLines() const { return m_pLines; }
- const SwXMLTableColumns_Impl& GetColumns() const { return aCols; }
+ const SwXMLTableColumns_Impl& GetColumns() const { return m_aCols; }
};
SwXMLTableLines_Impl::SwXMLTableLines_Impl( const SwTableLines& rLines ) :
- pLines( &rLines ),
- nWidth( 0 )
+ m_pLines( &rLines ),
+ m_nWidth( 0 )
{
#if OSL_DEBUG_LEVEL > 0
sal_uInt32 nEndCPos = 0U;
@@ -140,19 +139,19 @@ SwXMLTableLines_Impl::SwXMLTableLines_Impl( const SwTableLines& rLines ) :
{
const SwTableBox *pBox = rBoxes[nBox];
- if( nBox < nBoxes-1U || nWidth==0 )
+ if( nBox < nBoxes-1U || m_nWidth==0 )
{
nCPos = nCPos + SwWriteTable::GetBoxWidth( pBox );
std::unique_ptr<SwXMLTableColumn_Impl> pCol(
new SwXMLTableColumn_Impl( nCPos ));
- aCols.insert( std::move(pCol) );
+ m_aCols.insert( std::move(pCol) );
if( nBox==nBoxes-1U )
{
- OSL_ENSURE( nLine==0U && nWidth==0,
+ OSL_ENSURE( nLine==0U && m_nWidth==0,
"parent width will be lost" );
- nWidth = nCPos;
+ m_nWidth = nCPos;
}
}
else
@@ -165,10 +164,10 @@ SwXMLTableLines_Impl::SwXMLTableLines_Impl( const SwTableLines& rLines ) :
nEndCPos = nCheckPos;
}
#endif
- nCPos = nWidth;
+ nCPos = m_nWidth;
#if OSL_DEBUG_LEVEL > 0
- SwXMLTableColumn_Impl aCol( nWidth );
- OSL_ENSURE( aCols.find(&aCol) != aCols.end(), "couldn't find last column" );
+ SwXMLTableColumn_Impl aCol( m_nWidth );
+ OSL_ENSURE( m_aCols.find(&aCol) != m_aCols.end(), "couldn't find last column" );
OSL_ENSURE( SwXMLTableColumn_Impl(nCheckPos) ==
SwXMLTableColumn_Impl(nCPos),
"rows have different total widths" );
@@ -183,53 +182,52 @@ typedef vector< SwFrameFormat* > SwXMLFrameFormats_Impl;
class SwXMLTableFrameFormatsSort_Impl
{
private:
- SwXMLFrameFormats_Impl aFormatList;
+ SwXMLFrameFormats_Impl m_aFormatList;
+ SwXMLTextParagraphExport::FormatMap & m_rFormatMap;
+
public:
- bool AddRow( SwFrameFormat& rFrameFormat, std::u16string_view rNamePrefix, sal_uInt32 nLine );
- bool AddCell( SwFrameFormat& rFrameFormat, std::u16string_view rNamePrefix,
+ SwXMLTableFrameFormatsSort_Impl(SwXMLTextParagraphExport::FormatMap & rFormatMap)
+ : m_rFormatMap(rFormatMap)
+ {}
+ ::std::optional<OUString> AddRow(SwFrameFormat& rFrameFormat, std::u16string_view rNamePrefix, sal_uInt32 nLine );
+ ::std::optional<OUString> AddCell(SwFrameFormat& rFrameFormat, std::u16string_view rNamePrefix,
sal_uInt32 nCol, sal_uInt32 nRow, bool bTop );
};
-bool SwXMLTableFrameFormatsSort_Impl::AddRow( SwFrameFormat& rFrameFormat,
+::std::optional<OUString> SwXMLTableFrameFormatsSort_Impl::AddRow(SwFrameFormat& rFrameFormat,
std::u16string_view rNamePrefix,
sal_uInt32 nLine )
{
- const SwFormatFrameSize *pFrameSize = nullptr;
- const SwFormatRowSplit* pRowSplit = nullptr;
- const SvxBrushItem *pBrush = nullptr;
-
const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
- const SfxPoolItem *pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( RES_FRM_SIZE, false, &pItem ) )
- pFrameSize = static_cast<const SwFormatFrameSize *>(pItem);
- if( SfxItemState::SET == rItemSet.GetItemState( RES_ROW_SPLIT, false, &pItem ) )
- pRowSplit = static_cast<const SwFormatRowSplit *>(pItem);
-
- if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false, &pItem ) )
- pBrush = static_cast<const SvxBrushItem *>(pItem);
+ const SwFormatFrameSize *pFrameSize = rItemSet.GetItemIfSet( RES_FRM_SIZE, false );
+ const SwFormatRowSplit* pRowSplit = rItemSet.GetItemIfSet( RES_ROW_SPLIT, false );
+ const SvxBrushItem *pBrush = rItemSet.GetItemIfSet( RES_BACKGROUND, false );
+ const SvxPrintItem *pHasTextChangesOnly = rItemSet.GetItemIfSet( RES_PRINT, false);
// empty styles have not to be exported
- if( !pFrameSize && !pBrush && !pRowSplit )
- return false;
+ if( !pFrameSize && !pBrush && !pRowSplit && !pHasTextChangesOnly )
+ {
+ m_rFormatMap.try_emplace(&rFrameFormat); // empty just to enable assert
+ return {};
+ }
// order is: -/brush, size/-, size/brush
- bool bInsert = true;
SwXMLFrameFormats_Impl::iterator i;
- for( i = aFormatList.begin(); i < aFormatList.end(); ++i )
+ for( i = m_aFormatList.begin(); i < m_aFormatList.end(); ++i )
{
const SwFormatFrameSize *pTestFrameSize = nullptr;
const SwFormatRowSplit* pTestRowSplit = nullptr;
const SvxBrushItem *pTestBrush = nullptr;
+ const SvxPrintItem *pTestHasTextChangesOnly = nullptr;
const SwFrameFormat *pTestFormat = *i;
const SfxItemSet& rTestSet = pTestFormat->GetAttrSet();
- if( SfxItemState::SET == rTestSet.GetItemState( RES_FRM_SIZE, false,
- &pItem ) )
+ if( const SwFormatFrameSize* pItem = rTestSet.GetItemIfSet( RES_FRM_SIZE, false ) )
{
if( !pFrameSize )
break;
- pTestFrameSize = static_cast<const SwFormatFrameSize *>(pItem);
+ pTestFrameSize = pItem;
}
else
{
@@ -237,13 +235,12 @@ bool SwXMLTableFrameFormatsSort_Impl::AddRow( SwFrameFormat& rFrameFormat,
continue;
}
- if( SfxItemState::SET == rTestSet.GetItemState( RES_BACKGROUND, false,
- &pItem ) )
+ if( const SvxBrushItem* pItem = rTestSet.GetItemIfSet( RES_BACKGROUND, false) )
{
if( !pBrush )
break;
- pTestBrush = static_cast<const SvxBrushItem *>(pItem);
+ pTestBrush = pItem;
}
else
{
@@ -251,13 +248,12 @@ bool SwXMLTableFrameFormatsSort_Impl::AddRow( SwFrameFormat& rFrameFormat,
continue;
}
- if( SfxItemState::SET == rTestSet.GetItemState( RES_ROW_SPLIT, false,
- &pItem ) )
+ if( const SwFormatRowSplit* pItem = rTestSet.GetItemIfSet( RES_ROW_SPLIT, false ) )
{
if( !pRowSplit )
break;
- pTestRowSplit = static_cast<const SwFormatRowSplit *>(pItem);
+ pTestRowSplit = pItem;
}
else
{
@@ -265,6 +261,19 @@ bool SwXMLTableFrameFormatsSort_Impl::AddRow( SwFrameFormat& rFrameFormat,
continue;
}
+ if( const SvxPrintItem* pItem = rTestSet.GetItemIfSet( RES_PRINT, false ) )
+ {
+ if( !pHasTextChangesOnly )
+ break;
+
+ pTestHasTextChangesOnly = pItem;
+ }
+ else
+ {
+ if( pHasTextChangesOnly )
+ continue;
+ }
+
if( pFrameSize &&
( pFrameSize->GetHeightSizeType() != pTestFrameSize->GetHeightSizeType() ||
pFrameSize->GetHeight() != pTestFrameSize->GetHeight() ) )
@@ -276,20 +285,23 @@ bool SwXMLTableFrameFormatsSort_Impl::AddRow( SwFrameFormat& rFrameFormat,
if( pRowSplit && (!pRowSplit->GetValue() != !pTestRowSplit->GetValue()) )
continue;
+ if( pHasTextChangesOnly && (!pHasTextChangesOnly->GetValue() != !pTestHasTextChangesOnly->GetValue()) )
+ continue;
+
// found!
- rFrameFormat.SetName( pTestFormat->GetName() );
- bInsert = false;
- break;
+ auto const oName(m_rFormatMap.find(pTestFormat)->second);
+ assert(oName);
+ m_rFormatMap.try_emplace(&rFrameFormat, oName);
+ return {};
}
- if( bInsert )
{
- rFrameFormat.SetName( OUString::Concat(rNamePrefix) + "." + OUString::number(nLine+1) );
- if ( i != aFormatList.end() ) ++i;
- aFormatList.insert( i, &rFrameFormat );
+ OUString const name(OUString::Concat(rNamePrefix) + "." + OUString::number(nLine+1));
+ m_rFormatMap.try_emplace(&rFrameFormat, name);
+ if ( i != m_aFormatList.end() ) ++i;
+ m_aFormatList.insert( i, &rFrameFormat );
+ return ::std::optional<OUString>(name);
}
-
- return bInsert;
}
static OUString lcl_xmltble_appendBoxPrefix(std::u16string_view rNamePrefix,
@@ -298,7 +310,7 @@ static OUString lcl_xmltble_appendBoxPrefix(std::u16string_view rNamePrefix,
if( bTop )
{
OUString sTmp;
- sw_GetTableBoxColStr( static_cast<sal_uInt16>(nCol), sTmp );
+ sw_GetTableBoxColStr( o3tl::narrowing<sal_uInt16>(nCol), sTmp );
return OUString::Concat(rNamePrefix) + "." + sTmp + OUString::number(nRow + 1);
}
return OUString::Concat(rNamePrefix)
@@ -306,42 +318,29 @@ static OUString lcl_xmltble_appendBoxPrefix(std::u16string_view rNamePrefix,
+ "." + OUString::number(nRow + 1);
}
-bool SwXMLTableFrameFormatsSort_Impl::AddCell( SwFrameFormat& rFrameFormat,
+::std::optional<OUString> SwXMLTableFrameFormatsSort_Impl::AddCell(SwFrameFormat& rFrameFormat,
std::u16string_view rNamePrefix,
sal_uInt32 nCol, sal_uInt32 nRow, bool bTop )
{
- const SwFormatVertOrient *pVertOrient = nullptr;
- const SvxBrushItem *pBrush = nullptr;
- const SvxBoxItem *pBox = nullptr;
- const SwTableBoxNumFormat *pNumFormat = nullptr;
- const SvxFrameDirectionItem *pFrameDir = nullptr;
- const SvXMLAttrContainerItem *pAttCnt = nullptr;
-
const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
- const SfxPoolItem *pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( RES_VERT_ORIENT, false,
- &pItem ) )
- pVertOrient = static_cast<const SwFormatVertOrient *>(pItem);
-
- if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false, &pItem ) )
- pBrush = static_cast<const SvxBrushItem *>(pItem);
-
- if( SfxItemState::SET == rItemSet.GetItemState( RES_BOX, false, &pItem ) )
- pBox = static_cast<const SvxBoxItem *>(pItem);
-
- if ( SfxItemState::SET == rItemSet.GetItemState( RES_BOXATR_FORMAT,
- false, &pItem ) )
- pNumFormat = static_cast<const SwTableBoxNumFormat *>(pItem);
- if ( SfxItemState::SET == rItemSet.GetItemState( RES_FRAMEDIR,
- false, &pItem ) )
- pFrameDir = static_cast<const SvxFrameDirectionItem *>(pItem);
- if ( SfxItemState::SET == rItemSet.GetItemState( RES_UNKNOWNATR_CONTAINER,
- false, &pItem ) )
- pAttCnt = static_cast<const SvXMLAttrContainerItem *>(pItem);
+ const SwFormatVertOrient *pVertOrient = rItemSet.GetItemIfSet( RES_VERT_ORIENT, false );
+ const SvxBrushItem *pBrush = rItemSet.GetItemIfSet( RES_BACKGROUND, false );
+ const SvxBoxItem *pBox = rItemSet.GetItemIfSet( RES_BOX, false );
+ const SwTableBoxNumFormat *pNumFormat = rItemSet.GetItemIfSet( RES_BOXATR_FORMAT,
+ false );
+ const SvxFrameDirectionItem *pFrameDir = rItemSet.GetItemIfSet( RES_FRAMEDIR,
+ false );
+ const SvXMLAttrContainerItem *pAttCnt = rItemSet.GetItemIfSet( RES_UNKNOWNATR_CONTAINER,
+ false );
+ const SvxPrintItem *pHasTextChangesOnly = rItemSet.GetItemIfSet( RES_PRINT, false);
// empty styles have not to be exported
- if( !pVertOrient && !pBrush && !pBox && !pNumFormat && !pFrameDir && !pAttCnt )
- return false;
+ if( !pVertOrient && !pBrush && !pBox && !pNumFormat && !pFrameDir && !pAttCnt &&
+ !pHasTextChangesOnly )
+ {
+ m_rFormatMap.try_emplace(&rFrameFormat); // empty just to enable assert
+ return {};
+ }
// order is: -/-/-/num,
// -/-/box/-, -/-/box/num,
@@ -349,9 +348,8 @@ bool SwXMLTableFrameFormatsSort_Impl::AddCell( SwFrameFormat& rFrameFormat,
// vert/-/-/-, vert/-/-/num, vert/-/box/-, ver/-/box/num,
// vert/brush/-/-, vert/brush/-/num, vert/brush/box/-,
// vert/brush/box/num
- bool bInsert = true;
SwXMLFrameFormats_Impl::iterator i;
- for( i = aFormatList.begin(); i < aFormatList.end(); ++i )
+ for( i = m_aFormatList.begin(); i < m_aFormatList.end(); ++i )
{
const SwFormatVertOrient *pTestVertOrient = nullptr;
const SvxBrushItem *pTestBrush = nullptr;
@@ -359,15 +357,15 @@ bool SwXMLTableFrameFormatsSort_Impl::AddCell( SwFrameFormat& rFrameFormat,
const SwTableBoxNumFormat *pTestNumFormat = nullptr;
const SvxFrameDirectionItem *pTestFrameDir = nullptr;
const SvXMLAttrContainerItem *pTestAttCnt = nullptr;
+ const SvxPrintItem *pTestHasTextChangesOnly = rItemSet.GetItemIfSet( RES_PRINT, false);
const SwFrameFormat* pTestFormat = *i;
const SfxItemSet& rTestSet = pTestFormat->GetAttrSet();
- if( SfxItemState::SET == rTestSet.GetItemState( RES_VERT_ORIENT, false,
- &pItem ) )
+ if( const SwFormatVertOrient* pItem = rTestSet.GetItemIfSet( RES_VERT_ORIENT, false ) )
{
if( !pVertOrient )
break;
- pTestVertOrient = static_cast<const SwFormatVertOrient *>(pItem);
+ pTestVertOrient = pItem;
}
else
{
@@ -375,13 +373,12 @@ bool SwXMLTableFrameFormatsSort_Impl::AddCell( SwFrameFormat& rFrameFormat,
continue;
}
- if( SfxItemState::SET == rTestSet.GetItemState( RES_BACKGROUND, false,
- &pItem ) )
+ if( const SvxBrushItem* pItem = rTestSet.GetItemIfSet( RES_BACKGROUND, false ) )
{
if( !pBrush )
break;
- pTestBrush = static_cast<const SvxBrushItem *>(pItem);
+ pTestBrush = pItem;
}
else
{
@@ -389,12 +386,12 @@ bool SwXMLTableFrameFormatsSort_Impl::AddCell( SwFrameFormat& rFrameFormat,
continue;
}
- if( SfxItemState::SET == rTestSet.GetItemState( RES_BOX, false, &pItem ) )
+ if( const SvxBoxItem* pItem = rTestSet.GetItemIfSet( RES_BOX, false ) )
{
if( !pBox )
break;
- pTestBox = static_cast<const SvxBoxItem *>(pItem);
+ pTestBox = pItem;
}
else
{
@@ -402,13 +399,13 @@ bool SwXMLTableFrameFormatsSort_Impl::AddCell( SwFrameFormat& rFrameFormat,
continue;
}
- if ( SfxItemState::SET == rTestSet.GetItemState( RES_BOXATR_FORMAT,
- false, &pItem ) )
+ if ( const SwTableBoxNumFormat* pItem = rTestSet.GetItemIfSet( RES_BOXATR_FORMAT,
+ false ) )
{
if( !pNumFormat )
break;
- pTestNumFormat = static_cast<const SwTableBoxNumFormat *>(pItem);
+ pTestNumFormat = pItem;
}
else
{
@@ -417,13 +414,13 @@ bool SwXMLTableFrameFormatsSort_Impl::AddCell( SwFrameFormat& rFrameFormat,
}
- if ( SfxItemState::SET == rTestSet.GetItemState( RES_FRAMEDIR,
- false, &pItem ) )
+ if ( const SvxFrameDirectionItem* pItem = rTestSet.GetItemIfSet( RES_FRAMEDIR,
+ false ) )
{
if( !pFrameDir )
break;
- pTestFrameDir = static_cast<const SvxFrameDirectionItem *>(pItem);
+ pTestFrameDir = pItem;
}
else
{
@@ -432,13 +429,13 @@ bool SwXMLTableFrameFormatsSort_Impl::AddCell( SwFrameFormat& rFrameFormat,
}
- if ( SfxItemState::SET == rTestSet.GetItemState( RES_UNKNOWNATR_CONTAINER,
- false, &pItem ) )
+ if ( const SvXMLAttrContainerItem* pItem = rTestSet.GetItemIfSet( RES_UNKNOWNATR_CONTAINER,
+ false ) )
{
if( !pAttCnt )
break;
- pTestAttCnt = static_cast<const SvXMLAttrContainerItem *>(pItem);
+ pTestAttCnt = pItem;
}
else
{
@@ -447,6 +444,19 @@ bool SwXMLTableFrameFormatsSort_Impl::AddCell( SwFrameFormat& rFrameFormat,
}
+ if( const SvxPrintItem* pItem = rTestSet.GetItemIfSet( RES_PRINT, false ) )
+ {
+ if( !pHasTextChangesOnly )
+ break;
+
+ pTestHasTextChangesOnly = pItem;
+ }
+ else
+ {
+ if( pHasTextChangesOnly )
+ continue;
+ }
+
if( pVertOrient &&
pVertOrient->GetVertOrient() != pTestVertOrient->GetVertOrient() )
continue;
@@ -466,20 +476,23 @@ bool SwXMLTableFrameFormatsSort_Impl::AddCell( SwFrameFormat& rFrameFormat,
if( pAttCnt && ( *pAttCnt != *pTestAttCnt ) )
continue;
+ if( pHasTextChangesOnly && (!pHasTextChangesOnly->GetValue() != !pTestHasTextChangesOnly->GetValue()) )
+ continue;
+
// found!
- rFrameFormat.SetName( pTestFormat->GetName() );
- bInsert = false;
- break;
+ auto const oName(m_rFormatMap.find(pTestFormat)->second);
+ assert(oName);
+ m_rFormatMap.try_emplace(&rFrameFormat, oName);
+ return {};
}
- if( bInsert )
{
- rFrameFormat.SetName( lcl_xmltble_appendBoxPrefix( rNamePrefix, nCol, nRow, bTop ) );
- if ( i != aFormatList.end() ) ++i;
- aFormatList.insert( i, &rFrameFormat );
+ OUString const name(lcl_xmltble_appendBoxPrefix(rNamePrefix, nCol, nRow, bTop));
+ m_rFormatMap.try_emplace(&rFrameFormat, name);
+ if ( i != m_aFormatList.end() ) ++i;
+ m_aFormatList.insert( i, &rFrameFormat );
+ return ::std::optional<OUString>(name);
}
-
- return bInsert;
}
class SwXMLTableInfo_Impl
@@ -488,10 +501,21 @@ class SwXMLTableInfo_Impl
Reference<XTextSection> m_xBaseSection;
bool m_bBaseSectionValid;
sal_uInt32 m_nPrefix;
+ SwXMLTextParagraphExport::FormatMap const& m_rLineFormats;
+ SwXMLTextParagraphExport::FormatMap const& m_rBoxFormats;
public:
- inline SwXMLTableInfo_Impl( const SwTable *pTable, sal_uInt16 nPrefix );
+ inline SwXMLTableInfo_Impl( const SwTable *pTable, sal_uInt16 nPrefix,
+ SwXMLTextParagraphExport::FormatMap const& rLineFormats,
+ SwXMLTextParagraphExport::FormatMap const& rBoxFormats)
+ : m_pTable(pTable)
+ , m_bBaseSectionValid(false)
+ , m_nPrefix(nPrefix)
+ , m_rLineFormats(rLineFormats)
+ , m_rBoxFormats(rBoxFormats)
+ {
+ }
const SwTable *GetTable() const { return m_pTable; }
const SwFrameFormat *GetTableFormat() const { return m_pTable->GetFrameFormat(); }
@@ -501,15 +525,10 @@ public:
inline void SetBaseSection( const Reference < XTextSection >& rBase );
/// The namespace (table or loext) that should be used for the elements.
sal_uInt16 GetPrefix() const { return m_nPrefix; }
+ SwXMLTextParagraphExport::FormatMap const& GetLineFormats() const { return m_rLineFormats; }
+ SwXMLTextParagraphExport::FormatMap const& GetBoxFormats() const { return m_rBoxFormats; }
};
-inline SwXMLTableInfo_Impl::SwXMLTableInfo_Impl(const SwTable *pTable, sal_uInt16 nPrefix) :
- m_pTable(pTable),
- m_bBaseSectionValid(false),
- m_nPrefix(nPrefix)
-{
-}
-
inline void SwXMLTableInfo_Impl::SetBaseSection(
const Reference < XTextSection >& rBaseSection )
{
@@ -535,9 +554,9 @@ void SwXMLExport::ExportTableColumnStyle( const SwXMLTableColumn_Impl& rCol )
{
SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE, XML_STYLE, true,
true );
- OUStringBuffer sValue;
if( rCol.GetWidthOpt() )
{
+ OUStringBuffer sValue;
GetTwipUnitConverter().convertMeasureToXML( sValue,
rCol.GetWidthOpt() );
AddAttribute( XML_NAMESPACE_STYLE, XML_COLUMN_WIDTH,
@@ -545,10 +564,9 @@ void SwXMLExport::ExportTableColumnStyle( const SwXMLTableColumn_Impl& rCol )
}
if( rCol.GetRelWidth() )
{
- sValue.append( static_cast<sal_Int32>(rCol.GetRelWidth()) );
- sValue.append( '*' );
+ OUString sValue = OUString::number(static_cast<sal_Int32>(rCol.GetRelWidth()) ) + "*";
AddAttribute( XML_NAMESPACE_STYLE, XML_REL_COLUMN_WIDTH,
- sValue.makeStringAndClear() );
+ sValue );
}
{
@@ -644,8 +662,10 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
SwTableLine *pLine = rLines[nLine];
SwFrameFormat *pFrameFormat = pLine->GetFrameFormat();
- if( rExpRows.AddRow( *pFrameFormat, rNamePrefix, nLine ) )
- ExportFormat( *pFrameFormat, XML_TABLE_ROW );
+ if (auto oNew = rExpRows.AddRow(*pFrameFormat, rNamePrefix, nLine))
+ {
+ ExportFormat(*pFrameFormat, XML_TABLE_ROW, std::move(oNew));
+ }
const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
const size_t nBoxes = rBoxes.size();
@@ -672,22 +692,21 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
if( pBoxSttNd )
{
SwFrameFormat *pFrameFormat2 = pBox->GetFrameFormat();
- if( rExpCells.AddCell( *pFrameFormat2, rNamePrefix, nOldCol, nLine,
+ if (auto oNew = rExpCells.AddCell(*pFrameFormat2, rNamePrefix, nOldCol, nLine,
bTop) )
- ExportFormat( *pFrameFormat2, XML_TABLE_CELL );
+ {
+ ExportFormat(*pFrameFormat2, XML_TABLE_CELL, std::move(oNew));
+ }
- Reference < XCell > xCell = SwXCell::CreateXCell(
+ rtl::Reference < SwXCell > xCell = SwXCell::CreateXCell(
const_cast<SwFrameFormat *>(rTableInfo.GetTableFormat()),
pBox,
const_cast<SwTable *>(rTableInfo.GetTable()) );
if (xCell.is())
{
- Reference < XText > xText( xCell, UNO_QUERY );
if( !rTableInfo.IsBaseSectionValid() )
{
- Reference<XPropertySet> xCellPropertySet( xCell,
- UNO_QUERY );
- Any aAny = xCellPropertySet->getPropertyValue("TextSection");
+ Any aAny = xCell->getPropertyValue("TextSection");
Reference < XTextSection > xTextSection;
aAny >>= xTextSection;
rTableInfo.SetBaseSection( xTextSection );
@@ -698,7 +717,7 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
{
// AUTOSTYLES - not needed anymore if we are currently exporting content.xml
GetTextParagraphExport()->collectTextAutoStyles(
- xText, rTableInfo.GetBaseSection(), IsShowProgress() );
+ xCell, rTableInfo.GetBaseSection(), IsShowProgress() );
}
}
else {
@@ -720,8 +739,13 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
}
}
-void SwXMLExport::ExportTableAutoStyles( const SwTableNode& rTableNd )
+void SwXMLExport::ExportTableAutoStyles(const SwTableNode& rTableNd)
{
+ auto & rFormats(static_cast<SwXMLTextParagraphExport *>(GetTextParagraphExport().get())->GetTableFormats());
+ auto const it(rFormats.find(&rTableNd));
+ assert(it != rFormats.end());
+ SwXMLTextParagraphExport::FormatMap & rRowFormats(it->second.first);
+ SwXMLTextParagraphExport::FormatMap & rBoxFormats(it->second.second);
const SwTable& rTable = rTableNd.GetTable();
const SwFrameFormat *pTableFormat = rTable.GetFrameFormat();
@@ -749,9 +773,9 @@ void SwXMLExport::ExportTableAutoStyles( const SwTableNode& rTableNd )
ExportTableFormat( *pTableFormat, nAbsWidth );
SwXMLTableColumnsSortByWidth_Impl aExpCols;
- SwXMLTableFrameFormatsSort_Impl aExpRows;
- SwXMLTableFrameFormatsSort_Impl aExpCells;
- SwXMLTableInfo_Impl aTableInfo( &rTable, XML_NAMESPACE_TABLE );
+ SwXMLTableFrameFormatsSort_Impl aExpRows(rRowFormats);
+ SwXMLTableFrameFormatsSort_Impl aExpCells(rBoxFormats);
+ SwXMLTableInfo_Impl aTableInfo(&rTable, XML_NAMESPACE_TABLE, rRowFormats, rBoxFormats);
ExportTableLinesAutoStyles( rTable.GetTabLines(), nAbsWidth, nBaseWidth,
pTableFormat->GetName(), aExpCols, aExpRows, aExpCells,
aTableInfo, true);
@@ -769,10 +793,12 @@ void SwXMLExport::ExportTableBox( const SwTableBox& rBox,
const SwFrameFormat *pFrameFormat = rBox.GetFrameFormat();
if( pFrameFormat )
{
- const OUString& sName = pFrameFormat->GetName();
- if( !sName.isEmpty() )
+ auto const it(rTableInfo.GetBoxFormats().find(pFrameFormat));
+ assert(it != rTableInfo.GetBoxFormats().end());
+ if (it->second)
{
- AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME, EncodeStyleName(sName) );
+ assert(!it->second->isEmpty());
+ AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, EncodeStyleName(*it->second));
}
}
}
@@ -794,14 +820,12 @@ void SwXMLExport::ExportTableBox( const SwTableBox& rBox,
{
// start node -> normal cell
// get cell range for table
- Reference<XCell> xCell = SwXCell::CreateXCell( const_cast<SwFrameFormat *>(rTableInfo.GetTableFormat()),
+ rtl::Reference<SwXCell> xCell = SwXCell::CreateXCell( const_cast<SwFrameFormat *>(rTableInfo.GetTableFormat()),
const_cast<SwTableBox *>(&rBox),
const_cast<SwTable *>(rTableInfo.GetTable()) );
if (xCell.is())
{
- Reference<XText> xText( xCell, UNO_QUERY );
-
// get formula (and protection)
const OUString sCellFormula = xCell->getFormula();
@@ -817,45 +841,40 @@ void SwXMLExport::ExportTableBox( const SwTableBox& rBox,
}
// value and format (if NumberFormat != -1)
- Reference<XPropertySet> xCellPropertySet(xCell,
- UNO_QUERY);
- if (xCellPropertySet.is())
- {
- sal_Int32 nNumberFormat = 0;
- Any aAny = xCellPropertySet->getPropertyValue("NumberFormat");
- aAny >>= nNumberFormat;
+ sal_Int32 nNumberFormat = 0;
+ Any aAny = xCell->getPropertyValue("NumberFormat");
+ aAny >>= nNumberFormat;
- if (static_cast<sal_Int32>(getSwDefaultTextFormat()) == nNumberFormat)
- {
- // text format
- AddAttribute( XML_NAMESPACE_OFFICE,
- XML_VALUE_TYPE, XML_STRING );
- }
- else if ( (-1 != nNumberFormat) && !xText->getString().isEmpty() )
- {
- // number format key:
- // (export values only if cell contains text;)
- XMLNumberFormatAttributesExportHelper::
- SetNumberFormatAttributes(
- *this, nNumberFormat, xCell->getValue() );
- }
- // else: invalid key; ignore
+ if (static_cast<sal_Int32>(getSwDefaultTextFormat()) == nNumberFormat)
+ {
+ // text format
+ AddAttribute( XML_NAMESPACE_OFFICE,
+ XML_VALUE_TYPE, XML_STRING );
+ }
+ else if ( (-1 != nNumberFormat) && !xCell->getString().isEmpty() )
+ {
+ // number format key:
+ // (export values only if cell contains text;)
+ XMLNumberFormatAttributesExportHelper::
+ SetNumberFormatAttributes(
+ *this, nNumberFormat, xCell->getValue() );
+ }
+ // else: invalid key; ignore
- // cell protection
- aAny = xCellPropertySet->getPropertyValue("IsProtected");
- if (*o3tl::doAccess<bool>(aAny))
- {
- AddAttribute( XML_NAMESPACE_TABLE, XML_PROTECTED,
- XML_TRUE );
- }
+ // cell protection
+ aAny = xCell->getPropertyValue("IsProtected");
+ if (*o3tl::doAccess<bool>(aAny))
+ {
+ AddAttribute( XML_NAMESPACE_TABLE, XML_PROTECTED,
+ XML_TRUE );
+ }
- if( !rTableInfo.IsBaseSectionValid() )
- {
- aAny = xCellPropertySet->getPropertyValue("TextSection");
- Reference < XTextSection > xTextSection;
- aAny >>= xTextSection;
- rTableInfo.SetBaseSection( xTextSection );
- }
+ if( !rTableInfo.IsBaseSectionValid() )
+ {
+ aAny = xCell->getPropertyValue("TextSection");
+ Reference < XTextSection > xTextSection;
+ aAny >>= xTextSection;
+ rTableInfo.SetBaseSection( xTextSection );
}
// export cell element
@@ -863,7 +882,7 @@ void SwXMLExport::ExportTableBox( const SwTableBox& rBox,
XML_TABLE_CELL, true, true );
// export cell content
- GetTextParagraphExport()->exportText( xText,
+ GetTextParagraphExport()->exportText( xCell,
rTableInfo.GetBaseSection(),
IsShowProgress() );
}
@@ -902,10 +921,12 @@ void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
const SwFrameFormat *pFrameFormat = rLine.GetFrameFormat();
if( pFrameFormat )
{
- const OUString& sName = pFrameFormat->GetName();
- if( !sName.isEmpty() )
+ auto const it(rTableInfo.GetLineFormats().find(pFrameFormat));
+ assert(it != rTableInfo.GetLineFormats().end());
+ if (it->second)
{
- AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME, EncodeStyleName(sName) );
+ assert(!it->second->isEmpty());
+ AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, EncodeStyleName(*it->second));
}
}
@@ -924,6 +945,19 @@ void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
const sal_Int32 nRowSpan = pBox->getRowSpan();
if( nRowSpan < 1 )
{
+ // Export style of covered cell, it includes border information.
+ const SwFrameFormat* pFormat = pBox->GetFrameFormat();
+ if (pFormat)
+ {
+ auto const it(rTableInfo.GetBoxFormats().find(pFormat));
+ assert(it != rTableInfo.GetBoxFormats().end());
+ if (it->second)
+ {
+ assert(!it->second->isEmpty());
+ AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, EncodeStyleName(*it->second));
+ }
+ }
+
SvXMLElementExport aElem2( *this, rTableInfo.GetPrefix(),
XML_COVERED_TABLE_CELL, true,
false );
@@ -1057,29 +1091,6 @@ void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
delete pLines;
}
-static void lcl_xmltble_ClearName_Line( SwTableLine* pLine );
-
-static void lcl_xmltble_ClearName_Box( SwTableBox* pBox )
-{
- if( !pBox->GetSttNd() )
- {
- for( SwTableLine* pLine : pBox->GetTabLines() )
- lcl_xmltble_ClearName_Line( pLine );
- }
- else
- {
- SwFrameFormat *pFrameFormat = pBox->GetFrameFormat();
- if( pFrameFormat && !pFrameFormat->GetName().isEmpty() )
- pFrameFormat->SetName( OUString() );
- }
-}
-
-void lcl_xmltble_ClearName_Line( SwTableLine* pLine )
-{
- for( SwTableBox* pBox : pLine->GetTabBoxes() )
- lcl_xmltble_ClearName_Box( pBox );
-}
-
void SwXMLExport::ExportTable( const SwTableNode& rTableNd )
{
::std::optional<sal_uInt16> oPrefix = XML_NAMESPACE_TABLE;
@@ -1153,20 +1164,45 @@ void SwXMLExport::ExportTable( const SwTableNode& rTableNd )
XML_DDE_SOURCE, true, false);
}
- SwXMLTableInfo_Impl aTableInfo(&rTable, *oPrefix);
+ auto const& rFormats(static_cast<SwXMLTextParagraphExport const*>(GetTextParagraphExport().get())->GetTableFormats());
+ auto const it(rFormats.find(&rTableNd));
+ assert(it != rFormats.end());
+ SwXMLTableInfo_Impl aTableInfo(&rTable, *oPrefix, it->second.first, it->second.second);
ExportTableLines( rTable.GetTabLines(), aTableInfo, rTable.GetRowsToRepeat() );
-
- for( SwTableLine *pLine : const_cast<SwTable &>(rTable).GetTabLines() )
- lcl_xmltble_ClearName_Line( pLine );
}
void SwXMLTextParagraphExport::exportTableAutoStyles() {
+ // note: maTableNodes is used here only to keep the iteration order as before
for (const auto* pTableNode : maTableNodes)
{
static_cast<SwXMLExport&>(GetExport()).ExportTableAutoStyles(*pTableNode);
}
}
+void SwXMLTextParagraphExport::CollectTableLinesAutoStyles(const SwTableLines& rLines,
+ SwFrameFormat& rFormat, bool _bProgress)
+{
+ // Follow SwXMLExport::ExportTableLines/ExportTableLine/ExportTableBox
+ for (const SwTableLine* pLine : rLines)
+ {
+ for (SwTableBox* pBox : pLine->GetTabBoxes())
+ {
+ if (pBox->getRowSpan() <= 0)
+ continue;
+ if (pBox->GetSttNd())
+ {
+ if (rtl::Reference<SwXCell> xCell = SwXCell::CreateXCell(&rFormat, pBox))
+ exportText(xCell, true /*bAutoStyles*/, _bProgress, true /*bExportParagraph*/);
+ }
+ else
+ {
+ // no start node -> merged cells: export subtable in cell
+ CollectTableLinesAutoStyles(pBox->GetTabLines(), rFormat, _bProgress);
+ }
+ }
+ }
+}
+
void SwXMLTextParagraphExport::exportTable(
const Reference < XTextContent > & rTextContent,
bool bAutoStyles, bool _bProgress )
@@ -1178,14 +1214,7 @@ void SwXMLTextParagraphExport::exportTable(
OSL_ENSURE( xTextTable.is(), "text table missing" );
if( xTextTable.is() )
{
- SwXTextTable *pXTable = nullptr;
- Reference<XUnoTunnel> xTableTunnel( rTextContent, UNO_QUERY);
- if( xTableTunnel.is() )
- {
- pXTable = reinterpret_cast< SwXTextTable * >(
- sal::static_int_cast< sal_IntPtr >( xTableTunnel->getSomething( SwXTextTable::getUnoTunnelId() )));
- OSL_ENSURE( pXTable, "SwXTextTable missing" );
- }
+ SwXTextTable* pXTable = dynamic_cast<SwXTextTable*>(rTextContent.get());
if( pXTable )
{
SwFrameFormat *const pFormat = pXTable->GetFrameFormat();
@@ -1196,7 +1225,6 @@ void SwXMLTextParagraphExport::exportTable(
OSL_ENSURE( pTableNd, "table node missing" );
if( bAutoStyles )
{
- SwNodeIndex aIdx( *pTableNd );
// AUTOSTYLES: Optimization: Do not export table autostyle if
// we are currently exporting the content.xml stuff and
// the table is located in header/footer:
@@ -1204,25 +1232,12 @@ void SwXMLTextParagraphExport::exportTable(
// ALL flags are set at the same time.
const bool bExportStyles = bool( GetExport().getExportFlags() & SvXMLExportFlags::STYLES );
if (!isAutoStylesCollected()
- && (bExportStyles || !pFormat->GetDoc()->IsInHeaderFooter(aIdx)))
+ && (bExportStyles || !pFormat->GetDoc()->IsInHeaderFooter(*pTableNd)))
{
maTableNodes.push_back(pTableNd);
+ m_TableFormats.try_emplace(pTableNd);
// Collect all tables inside cells of this table, too
- const auto aCellNames = pXTable->getCellNames();
- for (const OUString& rCellName : aCellNames)
- {
- css::uno::Reference<css::container::XEnumerationAccess> xCell(
- pXTable->getCellByName(rCellName), css::uno::UNO_QUERY);
- if (!xCell)
- continue;
- auto xEnumeration = xCell->createEnumeration();
- while (xEnumeration->hasMoreElements())
- {
- if (css::uno::Reference<css::text::XTextTable> xInnerTable{
- xEnumeration->nextElement(), css::uno::UNO_QUERY })
- exportTable(xInnerTable, bAutoStyles, _bProgress);
- }
- }
+ CollectTableLinesAutoStyles(pTable->GetTabLines(), *pFormat, _bProgress);
}
}
else
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index 061ea32d63e5..b426ec88bc85 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -24,15 +24,17 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/table/XCellRange.hpp>
+#include <comphelper/servicehelper.hxx>
#include <o3tl/numeric.hxx>
#include <o3tl/safeint.hxx>
#include <sal/log.hxx>
#include <svl/itemset.hxx>
+#include <svl/numformat.hxx>
#include <svl/zformat.hxx>
#include <sax/tools/converter.hxx>
-#include <unotools/configmgr.hxx>
+#include <comphelper/configuration.hxx>
+#include <utility>
#include <xmloff/xmlnamespace.hxx>
-#include <xmloff/xmltkmap.hxx>
#include <xmloff/namespacemap.hxx>
#include <xmloff/families.hxx>
@@ -51,6 +53,7 @@
#include <swtable.hxx>
#include <swtblfmt.hxx>
#include <pam.hxx>
+#include <unoprnms.hxx>
#include <unotbl.hxx>
#include <unotextrange.hxx>
#include <cellatr.hxx>
@@ -61,7 +64,9 @@
#include "xmltbli.hxx"
#include <vcl/svapp.hxx>
#include <ndtxt.hxx>
+#include <unotextcursor.hxx>
#include <SwStyleNameMapper.hxx>
+#include <IDocumentSettingAccess.hxx>
#include <algorithm>
#include <vector>
@@ -80,33 +85,33 @@ using namespace ::xmloff::token;
class SwXMLTableCell_Impl
{
- OUString aStyleName;
+ OUString m_aStyleName;
OUString m_StringValue;
- OUString sFormula; // cell formula; valid if length > 0
- double dValue; // formula value
+ OUString m_sFormula; // cell formula; valid if length > 0
+ double m_dValue; // formula value
- SvXMLImportContextRef xSubTable;
+ rtl::Reference<SwXMLTableContext> m_xSubTable;
- const SwStartNode *pStartNode;
- sal_uInt32 nRowSpan;
- sal_uInt32 nColSpan;
+ const SwStartNode *m_pStartNode;
+ sal_uInt32 m_nRowSpan;
+ sal_uInt32 m_nColSpan;
- bool bProtected : 1;
- bool bHasValue; // determines whether dValue attribute is valid
+ bool m_bProtected : 1;
+ bool m_bHasValue; // determines whether dValue attribute is valid
bool mbCovered;
bool m_bHasStringValue;
public:
SwXMLTableCell_Impl( sal_uInt32 nRSpan=1, sal_uInt32 nCSpan=1 ) :
- dValue( 0.0 ),
- pStartNode( nullptr ),
- nRowSpan( nRSpan ),
- nColSpan( nCSpan ),
- bProtected( false ),
- bHasValue( false ),
+ m_dValue( 0.0 ),
+ m_pStartNode( nullptr ),
+ m_nRowSpan( nRSpan ),
+ m_nColSpan( nCSpan ),
+ m_bProtected( false ),
+ m_bHasValue( false ),
mbCovered( false )
, m_bHasStringValue(false)
{}
@@ -121,24 +126,25 @@ public:
double dVal,
OUString const*const pStringValue);
- bool IsUsed() const { return pStartNode!=nullptr ||
- xSubTable.is() || bProtected;}
-
- sal_uInt32 GetRowSpan() const { return nRowSpan; }
- void SetRowSpan( sal_uInt32 nSet ) { nRowSpan = nSet; }
- sal_uInt32 GetColSpan() const { return nColSpan; }
- const OUString& GetStyleName() const { return aStyleName; }
- const OUString& GetFormula() const { return sFormula; }
- double GetValue() const { return dValue; }
- bool HasValue() const { return bHasValue; }
- bool IsProtected() const { return bProtected; }
+ bool IsUsed() const { return m_pStartNode!=nullptr ||
+ m_xSubTable.is() || m_bProtected;}
+
+ sal_uInt32 GetRowSpan() const { return m_nRowSpan; }
+ void SetRowSpan( sal_uInt32 nSet ) { m_nRowSpan = nSet; }
+ sal_uInt32 GetColSpan() const { return m_nColSpan; }
+ void SetStyleName(const OUString& rStyleName) { m_aStyleName = rStyleName; }
+ const OUString& GetStyleName() const { return m_aStyleName; }
+ const OUString& GetFormula() const { return m_sFormula; }
+ double GetValue() const { return m_dValue; }
+ bool HasValue() const { return m_bHasValue; }
+ bool IsProtected() const { return m_bProtected; }
bool IsCovered() const { return mbCovered; }
bool HasStringValue() const { return m_bHasStringValue; }
OUString const* GetStringValue() const {
return m_bHasStringValue ? &m_StringValue : nullptr;
}
- const SwStartNode *GetStartNode() const { return pStartNode; }
+ const SwStartNode *GetStartNode() const { return m_pStartNode; }
inline void SetStartNode( const SwStartNode *pSttNd );
inline SwXMLTableContext *GetSubTable() const;
@@ -157,55 +163,55 @@ inline void SwXMLTableCell_Impl::Set( const OUString& rStyleName,
double dVal,
OUString const*const pStringValue )
{
- aStyleName = rStyleName;
- nRowSpan = nRSpan;
- nColSpan = nCSpan;
- pStartNode = pStNd;
- xSubTable = pTable;
- dValue = dVal;
- bHasValue = bHasVal;
+ m_aStyleName = rStyleName;
+ m_nRowSpan = nRSpan;
+ m_nColSpan = nCSpan;
+ m_pStartNode = pStNd;
+ m_xSubTable = pTable;
+ m_dValue = dVal;
+ m_bHasValue = bHasVal;
mbCovered = bCov;
if (pStringValue)
{
m_StringValue = *pStringValue;
}
m_bHasStringValue = (pStringValue != nullptr);
- bProtected = bProtect;
+ m_bProtected = bProtect;
// set formula, if valid
if (pFormula != nullptr)
{
- sFormula = *pFormula;
+ m_sFormula = *pFormula;
}
}
inline void SwXMLTableCell_Impl::SetStartNode( const SwStartNode *pSttNd )
{
- pStartNode = pSttNd;
- xSubTable = nullptr;
+ m_pStartNode = pSttNd;
+ m_xSubTable = nullptr;
}
inline SwXMLTableContext *SwXMLTableCell_Impl::GetSubTable() const
{
- return static_cast<SwXMLTableContext *>(xSubTable.get());
+ return m_xSubTable.get();
}
inline void SwXMLTableCell_Impl::Dispose()
{
- if( xSubTable.is() )
- xSubTable = nullptr;
+ if( m_xSubTable.is() )
+ m_xSubTable = nullptr;
}
class SwXMLTableRow_Impl
{
- OUString aStyleName;
- OUString aDfltCellStyleName;
+ OUString m_aStyleName;
+ OUString m_aDefaultCellStyleName;
std::vector<std::unique_ptr<SwXMLTableCell_Impl>> m_Cells;
- bool bSplitable;
+ bool m_bSplitable;
public:
- SwXMLTableRow_Impl( const OUString& rStyleName, sal_uInt32 nCells,
+ SwXMLTableRow_Impl( OUString aStyleName, sal_uInt32 nCells,
const OUString *pDfltCellStyleName = nullptr );
inline SwXMLTableCell_Impl *GetCell( sal_uInt32 nCol );
@@ -215,23 +221,23 @@ public:
void Expand( sal_uInt32 nCells, bool bOneCell );
- void SetSplitable( bool bSet ) { bSplitable = bSet; }
- bool IsSplitable() const { return bSplitable; }
+ void SetSplitable( bool bSet ) { m_bSplitable = bSet; }
+ bool IsSplitable() const { return m_bSplitable; }
- const OUString& GetStyleName() const { return aStyleName; }
- const OUString& GetDefaultCellStyleName() const { return aDfltCellStyleName; }
+ const OUString& GetStyleName() const { return m_aStyleName; }
+ const OUString& GetDefaultCellStyleName() const { return m_aDefaultCellStyleName; }
void Dispose();
};
-SwXMLTableRow_Impl::SwXMLTableRow_Impl( const OUString& rStyleName,
+SwXMLTableRow_Impl::SwXMLTableRow_Impl( OUString aStyleName,
sal_uInt32 nCells,
const OUString *pDfltCellStyleName ) :
- aStyleName( rStyleName ),
- bSplitable( false )
+ m_aStyleName(std::move( aStyleName )),
+ m_bSplitable( false )
{
if( pDfltCellStyleName )
- aDfltCellStyleName = *pDfltCellStyleName;
+ m_aDefaultCellStyleName = *pDfltCellStyleName;
OSL_ENSURE( nCells <= USHRT_MAX,
"SwXMLTableRow_Impl::SwXMLTableRow_Impl: too many cells" );
if( nCells > USHRT_MAX )
@@ -275,8 +281,8 @@ void SwXMLTableRow_Impl::Expand( sal_uInt32 nCells, bool bOneCell )
inline void SwXMLTableRow_Impl::Set( const OUString& rStyleName,
const OUString& rDfltCellStyleName )
{
- aStyleName = rStyleName;
- aDfltCellStyleName = rDfltCellStyleName;
+ m_aStyleName = rStyleName;
+ m_aDefaultCellStyleName = rDfltCellStyleName;
}
void SwXMLTableRow_Impl::Dispose()
@@ -296,7 +302,7 @@ class SwXMLTableCellContext_Impl : public SvXMLImportContext
OUString m_sSaveParaDefault;
OUString m_StringValue;
- SvXMLImportContextRef m_xMyTable;
+ rtl::Reference<SwXMLTableContext> m_xMyTable;
double m_fValue;
bool m_bHasValue;
@@ -311,7 +317,7 @@ class SwXMLTableCellContext_Impl : public SvXMLImportContext
bool m_bHasTextContent : 1;
bool m_bHasTableContent : 1;
- SwXMLTableContext *GetTable() { return static_cast<SwXMLTableContext *>(m_xMyTable.get()); }
+ SwXMLTableContext *GetTable() { return m_xMyTable.get(); }
bool HasContent() const { return m_bHasTextContent || m_bHasTableContent; }
inline void InsertContent_();
@@ -333,6 +339,36 @@ public:
SwXMLImport& GetSwImport() { return static_cast<SwXMLImport&>(GetImport()); }
};
+/// Handles <table:covered-table-cell>.
+class SwXMLCoveredTableCellContext : public SvXMLImportContext
+{
+public:
+ SwXMLCoveredTableCellContext(SwXMLImport& rImport,
+ const Reference<xml::sax::XFastAttributeList>& xAttrList,
+ SwXMLTableContext& rTable);
+};
+
+SwXMLCoveredTableCellContext::SwXMLCoveredTableCellContext(
+ SwXMLImport& rImport, const Reference<xml::sax::XFastAttributeList>& xAttrList,
+ SwXMLTableContext& rTable)
+ : SvXMLImportContext(rImport)
+{
+ OUString aStyleName;
+ for (auto& rIter : sax_fastparser::castToFastAttributeList(xAttrList))
+ {
+ switch (rIter.getToken())
+ {
+ case XML_ELEMENT(TABLE, XML_STYLE_NAME):
+ aStyleName = rIter.toString();
+ break;
+ }
+ }
+
+ if (!aStyleName.isEmpty())
+ {
+ rTable.InsertCoveredCell(aStyleName);
+ }
+}
}
SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl(
@@ -340,7 +376,6 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl(
const Reference< xml::sax::XFastAttributeList > & xAttrList,
SwXMLTableContext *pTable ) :
SvXMLImportContext( rImport ),
- m_sFormula(),
m_xMyTable( pTable ),
m_fValue( 0.0 ),
m_bHasValue( false ),
@@ -372,7 +407,7 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl(
break;
case XML_ELEMENT(TABLE, XML_NUMBER_ROWS_SPANNED):
m_nRowSpan = static_cast<sal_uInt32>(std::max<sal_Int32>(1, aIter.toInt32()));
- if (m_nRowSpan > 8192 || (m_nRowSpan > 256 && utl::ConfigManager::IsFuzzing()))
+ if (m_nRowSpan > 8192 || (m_nRowSpan > 256 && comphelper::IsFuzzing()))
{
SAL_INFO("sw.xml", "ignoring huge table:number-rows-spanned " << m_nRowSpan);
m_nRowSpan = 1;
@@ -409,7 +444,7 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl(
case XML_ELEMENT(OFFICE, XML_TIME_VALUE):
{
double fTmp;
- if (::sax::Converter::convertDuration(fTmp, aIter.toString()))
+ if (::sax::Converter::convertDuration(fTmp, aIter.toView()))
{
m_fValue = fTmp;
m_bHasValue = true;
@@ -420,7 +455,7 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl(
{
double fTmp;
if (GetImport().GetMM100UnitConverter().convertDateTime(fTmp,
- aIter.toString()))
+ aIter.toView()))
{
m_fValue = fTmp;
m_bHasValue = true;
@@ -430,7 +465,7 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl(
case XML_ELEMENT(OFFICE, XML_BOOLEAN_VALUE):
{
bool bTmp(false);
- if (::sax::Converter::convertBool(bTmp, aIter.toString()))
+ if (::sax::Converter::convertBool(bTmp, aIter.toView()))
{
m_fValue = (bTmp ? 1.0 : 0.0);
m_bHasValue = true;
@@ -441,7 +476,7 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl(
case XML_ELEMENT(TABLE, XML_PROTECTED):
{
bool bTmp(false);
- if (::sax::Converter::convertBool(bTmp, aIter.toString()))
+ if (::sax::Converter::convertBool(bTmp, aIter.toView()))
{
m_bProtect = bTmp;
}
@@ -455,7 +490,7 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl(
break;
case XML_ELEMENT(OFFICE, XML_VALUE_TYPE):
{
- if ("string" == aIter.toString())
+ if ("string" == aIter.toView())
{
m_bValueTypeIsString = true;
}
@@ -562,10 +597,7 @@ void SwXMLTableCellContext_Impl::endFastElement(sal_Int32 )
xSrcTextCursor->gotoEnd( true );
// Until we have an API for copying we have to use the core.
- Reference<XUnoTunnel> xSrcCursorTunnel( xSrcTextCursor, UNO_QUERY);
- assert(xSrcCursorTunnel.is() && "missing XUnoTunnel for Cursor");
- OTextCursorHelper *pSrcTextCursor = reinterpret_cast< OTextCursorHelper * >(
- sal::static_int_cast< sal_IntPtr >( xSrcCursorTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
+ OTextCursorHelper *pSrcTextCursor = dynamic_cast<OTextCursorHelper*>(xSrcTextCursor.get());
assert(pSrcTextCursor && "SwXTextCursor missing");
SwDoc *pDoc = pSrcTextCursor->GetDoc();
const SwPaM *pSrcPaM = pSrcTextCursor->GetPaM();
@@ -574,11 +606,7 @@ void SwXMLTableCellContext_Impl::endFastElement(sal_Int32 )
{
InsertContent_();
- Reference<XUnoTunnel> xDstCursorTunnel(
- GetImport().GetTextImport()->GetCursor(), UNO_QUERY);
- assert(xDstCursorTunnel.is() && "missing XUnoTunnel for Cursor");
- OTextCursorHelper *pDstTextCursor = reinterpret_cast< OTextCursorHelper * >(
- sal::static_int_cast< sal_IntPtr >( xDstCursorTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )) );
+ OTextCursorHelper *pDstTextCursor = dynamic_cast<OTextCursorHelper*>(GetImport().GetTextImport()->GetCursor().get());
assert(pDstTextCursor && "SwXTextCursor missing");
SwPaM aSrcPaM(*pSrcPaM->GetMark(), *pSrcPaM->GetPoint());
SwPosition aDstPos( *pDstTextCursor->GetPaM()->GetPoint() );
@@ -608,9 +636,9 @@ namespace {
class SwXMLTableColContext_Impl : public SvXMLImportContext
{
- SvXMLImportContextRef xMyTable;
+ rtl::Reference<SwXMLTableContext> m_xMyTable;
- SwXMLTableContext *GetTable() { return static_cast<SwXMLTableContext *>(xMyTable.get()); }
+ SwXMLTableContext *GetTable() { return m_xMyTable.get(); }
public:
@@ -629,7 +657,7 @@ SwXMLTableColContext_Impl::SwXMLTableColContext_Impl(
const Reference< xml::sax::XFastAttributeList > & xAttrList,
SwXMLTableContext *pTable ) :
SvXMLImportContext( rImport ),
- xMyTable( pTable )
+ m_xMyTable( pTable )
{
sal_uInt32 nColRep = 1;
OUString aStyleName, aDfltCellStyleName;
@@ -668,16 +696,14 @@ SwXMLTableColContext_Impl::SwXMLTableColContext_Impl(
bool bRelWidth = true;
if( !aStyleName.isEmpty() )
{
- const SfxPoolItem *pItem;
+ const SwFormatFrameSize *pSize;
const SfxItemSet *pAutoItemSet = nullptr;
if( GetSwImport().FindAutomaticStyle(
XmlStyleFamily::TABLE_COLUMN,
aStyleName, &pAutoItemSet ) &&
pAutoItemSet &&
- SfxItemState::SET == pAutoItemSet->GetItemState( RES_FRM_SIZE, false,
- &pItem ) )
+ (pSize = pAutoItemSet->GetItemIfSet( RES_FRM_SIZE, false )) )
{
- const SwFormatFrameSize *pSize = static_cast<const SwFormatFrameSize *>(pItem);
nWidth = pSize->GetWidth();
bRelWidth = SwFrameSize::Variable == pSize->GetHeightSizeType();
}
@@ -694,9 +720,9 @@ namespace {
class SwXMLTableColsContext_Impl : public SvXMLImportContext
{
- SvXMLImportContextRef xMyTable;
+ rtl::Reference<SwXMLTableContext> m_xMyTable;
- SwXMLTableContext *GetTable() { return static_cast<SwXMLTableContext *>(xMyTable.get()); }
+ SwXMLTableContext *GetTable() { return m_xMyTable.get(); }
public:
@@ -716,7 +742,7 @@ SwXMLTableColsContext_Impl::SwXMLTableColsContext_Impl(
SwXMLImport& rImport,
SwXMLTableContext *pTable ) :
SvXMLImportContext( rImport ),
- xMyTable( pTable )
+ m_xMyTable( pTable )
{
}
@@ -738,11 +764,11 @@ namespace {
class SwXMLTableRowContext_Impl : public SvXMLImportContext
{
- SvXMLImportContextRef xMyTable;
+ rtl::Reference<SwXMLTableContext> m_xMyTable;
- sal_uInt32 nRowRepeat;
+ sal_uInt32 m_nRowRepeat;
- SwXMLTableContext *GetTable() { return static_cast<SwXMLTableContext *>(xMyTable.get()); }
+ SwXMLTableContext *GetTable() { return m_xMyTable.get(); }
public:
@@ -767,11 +793,10 @@ SwXMLTableRowContext_Impl::SwXMLTableRowContext_Impl( SwXMLImport& rImport,
SwXMLTableContext *pTable,
bool bInHead ) :
SvXMLImportContext( rImport ),
- xMyTable( pTable ),
- nRowRepeat( 1 )
+ m_xMyTable( pTable ),
+ m_nRowRepeat( 1 )
{
OUString aStyleName, aDfltCellStyleName;
- OUString sXmlId;
for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
{
@@ -782,11 +807,11 @@ SwXMLTableRowContext_Impl::SwXMLTableRowContext_Impl( SwXMLImport& rImport,
break;
case XML_ELEMENT(STYLE, XML_NUMBER_ROWS_REPEATED):
{
- nRowRepeat = static_cast<sal_uInt32>(std::max<sal_Int32>(1, aIter.toInt32()));
- if (nRowRepeat > 8192 || (nRowRepeat > 256 && utl::ConfigManager::IsFuzzing()))
+ m_nRowRepeat = static_cast<sal_uInt32>(std::max<sal_Int32>(1, aIter.toInt32()));
+ if (m_nRowRepeat > 8192 || (m_nRowRepeat > 256 && comphelper::IsFuzzing()))
{
- SAL_INFO("sw.xml", "ignoring huge table:number-rows-repeated " << nRowRepeat);
- nRowRepeat = 1;
+ SAL_INFO("sw.xml", "ignoring huge table:number-rows-repeated " << m_nRowRepeat);
+ m_nRowRepeat = 1;
}
break;
}
@@ -794,7 +819,6 @@ SwXMLTableRowContext_Impl::SwXMLTableRowContext_Impl( SwXMLImport& rImport,
aDfltCellStyleName = aIter.toString();
break;
case XML_ELEMENT(XML, XML_ID):
- sXmlId = aIter.toString();
break;
default:
XMLOFF_WARN_UNKNOWN("sw", aIter);
@@ -810,8 +834,8 @@ void SwXMLTableRowContext_Impl::endFastElement(sal_Int32 )
{
GetTable()->FinishRow();
- if( nRowRepeat > 1 )
- GetTable()->InsertRepRows( nRowRepeat );
+ if( m_nRowRepeat > 1 )
+ GetTable()->InsertRepRows( m_nRowRepeat );
}
}
@@ -831,7 +855,16 @@ css::uno::Reference<css::xml::sax::XFastContextHandler> SwXMLTableRowContext_Imp
}
else if( nElement == XML_ELEMENT(TABLE, XML_COVERED_TABLE_CELL) ||
nElement == XML_ELEMENT(LO_EXT, XML_COVERED_TABLE_CELL) )
- pContext = new SvXMLImportContext( GetImport() );
+ {
+ if (GetTable()->IsValid() && GetTable()->IsInsertCoveredCellPossible())
+ {
+ pContext = new SwXMLCoveredTableCellContext(GetSwImport(), xAttrList, *GetTable());
+ }
+ else
+ {
+ pContext = new SvXMLImportContext(GetImport());
+ }
+ }
else
SAL_WARN("sw", "unknown element " << SvXMLImport::getPrefixAndNameFromToken(nElement));
@@ -842,11 +875,11 @@ namespace {
class SwXMLTableRowsContext_Impl : public SvXMLImportContext
{
- SvXMLImportContextRef xMyTable;
+ rtl::Reference<SwXMLTableContext> m_xMyTable;
- bool bHeader;
+ bool m_bHeader;
- SwXMLTableContext *GetTable() { return static_cast<SwXMLTableContext *>(xMyTable.get()); }
+ SwXMLTableContext *GetTable() { return m_xMyTable.get(); }
public:
@@ -867,8 +900,8 @@ SwXMLTableRowsContext_Impl::SwXMLTableRowsContext_Impl( SwXMLImport& rImport,
SwXMLTableContext *pTable,
bool bHead ) :
SvXMLImportContext( rImport ),
- xMyTable( pTable ),
- bHeader( bHead )
+ m_xMyTable( pTable ),
+ m_bHeader( bHead )
{
}
@@ -881,18 +914,18 @@ css::uno::Reference<css::xml::sax::XFastContextHandler> SwXMLTableRowsContext_Im
return new SwXMLTableRowContext_Impl( GetSwImport(), nElement,
xAttrList,
GetTable(),
- bHeader );
+ m_bHeader );
SAL_WARN("sw", "unknown element " << SvXMLImport::getPrefixAndNameFromToken(nElement));
return nullptr;
}
class SwXMLDDETableContext_Impl : public SvXMLImportContext
{
- OUString sConnectionName;
- OUString sDDEApplication;
- OUString sDDEItem;
- OUString sDDETopic;
- bool bIsAutomaticUpdate;
+ OUString m_sConnectionName;
+ OUString m_sDDEApplication;
+ OUString m_sDDEItem;
+ OUString m_sDDETopic;
+ bool m_bIsAutomaticUpdate;
public:
@@ -903,21 +936,17 @@ public:
sal_Int32 nElement,
const Reference<xml::sax::XFastAttributeList> & xAttrList) override;
- OUString& GetConnectionName() { return sConnectionName; }
- OUString& GetDDEApplication() { return sDDEApplication; }
- OUString& GetDDEItem() { return sDDEItem; }
- OUString& GetDDETopic() { return sDDETopic; }
- bool GetIsAutomaticUpdate() const { return bIsAutomaticUpdate; }
+ OUString& GetConnectionName() { return m_sConnectionName; }
+ OUString& GetDDEApplication() { return m_sDDEApplication; }
+ OUString& GetDDEItem() { return m_sDDEItem; }
+ OUString& GetDDETopic() { return m_sDDETopic; }
+ bool GetIsAutomaticUpdate() const { return m_bIsAutomaticUpdate; }
};
SwXMLDDETableContext_Impl::SwXMLDDETableContext_Impl(SwXMLImport& rImport) :
SvXMLImportContext(rImport),
- sConnectionName(),
- sDDEApplication(),
- sDDEItem(),
- sDDETopic(),
- bIsAutomaticUpdate(false)
+ m_bIsAutomaticUpdate(false)
{
}
@@ -930,23 +959,23 @@ void SwXMLDDETableContext_Impl::startFastElement(
switch (aIter.getToken())
{
case XML_ELEMENT(OFFICE, XML_DDE_APPLICATION):
- sDDEApplication = aIter.toString();
+ m_sDDEApplication = aIter.toString();
break;
case XML_ELEMENT(OFFICE, XML_DDE_TOPIC):
- sDDETopic = aIter.toString();
+ m_sDDETopic = aIter.toString();
break;
case XML_ELEMENT(OFFICE, XML_DDE_ITEM):
- sDDEItem = aIter.toString();
+ m_sDDEItem = aIter.toString();
break;
case XML_ELEMENT(OFFICE, XML_NAME):
- sConnectionName = aIter.toString();
+ m_sConnectionName = aIter.toString();
break;
case XML_ELEMENT(OFFICE, XML_AUTOMATIC_UPDATE):
{
bool bTmp(false);
if (::sax::Converter::convertBool(bTmp, aIter.toView()))
{
- bIsAutomaticUpdate = bTmp;
+ m_bIsAutomaticUpdate = bTmp;
}
break;
}
@@ -1048,9 +1077,9 @@ public:
sal_Int32 mnWidth;
bool mbProtected;
- TableBoxIndex( const OUString& rName, sal_Int32 nWidth,
+ TableBoxIndex( OUString aName, sal_Int32 nWidth,
bool bProtected ) :
- msName( rName ),
+ msName(std::move( aName )),
mnWidth( nWidth ),
mbProtected( bProtected )
{ }
@@ -1101,6 +1130,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
m_nHeaderRows( 0 ),
m_nCurRow( 0 ),
m_nCurCol( 0 ),
+ m_nNonMergedCurCol( 0 ),
m_nWidth( 0 )
{
OUString aName;
@@ -1134,7 +1164,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
}
}
- SwDoc *pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
+ SwDoc *pDoc = GetSwImport().getDoc();
OUString sTableName;
if( !aName.isEmpty() )
@@ -1145,7 +1175,19 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
}
if( sTableName.isEmpty() )
{
- sTableName = pDoc->GetUniqueTableName();
+ // Optimization: use import's own map to create unique names, because
+ // SwDoc::GetUniqueTableName scans all the already present tables,
+ // builds a bitset using rather complex rules, and that has quadratic
+ // complexity. Try once, then fallback to SwDoc::GetUniqueTableName
+ auto& tableNameMap = rImport.GetTableNameMap();
+ sal_Int32 nextIx = ++tableNameMap[aName];
+ OUString test = aName.isEmpty()
+ ? OUString(rImport.GetDefTableName() + OUString::number(nextIx))
+ : OUString(aName + "_" + OUString::number(nextIx));
+ if (const SwTableFormat* pExisting = pDoc->FindTableFormatByName(test); !pExisting)
+ sTableName = test;
+ else
+ sTableName = pDoc->GetUniqueTableName();
GetImport().GetTextImport()
->GetRenameMap().Add( XML_TEXT_RENAME_TYPE_TABLE, aName, sTableName );
}
@@ -1167,6 +1209,8 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
if( xTable.is() )
{
xTable->initialize( 1, 1 );
+ if (auto xPropSet = xTable.query<css::beans::XPropertySet>())
+ xPropSet->setPropertyValue(UNO_NAME_TABLE_NAME, css::uno::Any(sTableName));
try
{
@@ -1185,13 +1229,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
// xml:id for RDF metadata
GetImport().SetXmlId(xTable, sXmlId);
- Reference<XUnoTunnel> xTableTunnel( xTable, UNO_QUERY);
- if( xTableTunnel.is() )
- {
- pXTable = reinterpret_cast< SwXTextTable * >(
- sal::static_int_cast< sal_IntPtr >( xTableTunnel->getSomething( SwXTextTable::getUnoTunnelId() )));
- OSL_ENSURE( pXTable, "SwXTextTable missing" );
- }
+ pXTable = dynamic_cast<SwXTextTable*>(xTable.get());
Reference < XCellRange > xCellRange( xTable, UNO_QUERY );
Reference < XCell > xCell = xCellRange->getCellByPosition( 0, 0 );
@@ -1212,8 +1250,6 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
m_pTableNode = pTable->GetTableNode();
OSL_ENSURE( m_pTableNode, "table node missing" );
- pTableFrameFormat->SetName( sTableName );
-
SwTableLine *pLine1 = m_pTableNode->GetTable().GetTabLines()[0U];
m_pBox1 = pLine1->GetTabBoxes()[0U];
m_pSttNd1 = m_pBox1->GetSttNd();
@@ -1236,6 +1272,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
m_nHeaderRows( 0 ),
m_nCurRow( 0 ),
m_nCurCol( 0 ),
+ m_nNonMergedCurCol( 0 ),
m_nWidth( 0 )
{
}
@@ -1244,7 +1281,7 @@ SwXMLTableContext::~SwXMLTableContext()
{
if (m_bOwnsBox1)
delete m_pBox1;
- m_pColumnDefaultCellStyleNames.reset();
+ m_xColumnDefaultCellStyleNames.reset();
m_pSharedBoxFormats.reset();
m_pRows.reset();
@@ -1269,7 +1306,6 @@ css::uno::Reference<css::xml::sax::XFastContextHandler> SwXMLTableContext::creat
[[fallthrough]];
case XML_ELEMENT(TABLE, XML_TABLE_ROWS):
return new SwXMLTableRowsContext_Impl( GetSwImport(), this, bHeader );
- break;
case XML_ELEMENT(TABLE, XML_TABLE_HEADER_COLUMNS):
case XML_ELEMENT(TABLE, XML_TABLE_COLUMNS):
// There are slight differences between <table:table-columns> and
@@ -1292,7 +1328,7 @@ css::uno::Reference<css::xml::sax::XFastContextHandler> SwXMLTableContext::creat
if( IsValid() )
{
m_xDDESource.set(new SwXMLDDETableContext_Impl( GetSwImport() ));
- return m_xDDESource.get();
+ return m_xDDESource;
}
break;
}
@@ -1313,21 +1349,21 @@ void SwXMLTableContext::InsertColumn( sal_Int32 nWidth2, bool bRelWidth2,
nWidth2 = MAX_WIDTH;
m_aColumnWidths.emplace_back(nWidth2, bRelWidth2 );
if( !((pDfltCellStyleName && !pDfltCellStyleName->isEmpty()) ||
- m_pColumnDefaultCellStyleNames) )
+ m_xColumnDefaultCellStyleNames) )
return;
- if( !m_pColumnDefaultCellStyleNames )
+ if( !m_xColumnDefaultCellStyleNames )
{
- m_pColumnDefaultCellStyleNames.reset(new std::vector<OUString>);
+ m_xColumnDefaultCellStyleNames.emplace();
sal_uLong nCount = m_aColumnWidths.size() - 1;
while( nCount-- )
- m_pColumnDefaultCellStyleNames->push_back(OUString());
+ m_xColumnDefaultCellStyleNames->emplace_back();
}
if(pDfltCellStyleName)
- m_pColumnDefaultCellStyleNames->push_back(*pDfltCellStyleName);
+ m_xColumnDefaultCellStyleNames->push_back(*pDfltCellStyleName);
else
- m_pColumnDefaultCellStyleNames->push_back(OUString());
+ m_xColumnDefaultCellStyleNames->push_back(OUString());
}
sal_Int32 SwXMLTableContext::GetColumnWidth( sal_uInt32 nCol,
@@ -1346,8 +1382,8 @@ sal_Int32 SwXMLTableContext::GetColumnWidth( sal_uInt32 nCol,
OUString SwXMLTableContext::GetColumnDefaultCellStyleName( sal_uInt32 nCol ) const
{
- if( m_pColumnDefaultCellStyleNames && nCol < m_pColumnDefaultCellStyleNames->size())
- return (*m_pColumnDefaultCellStyleNames)[static_cast<size_t>(nCol)];
+ if( m_xColumnDefaultCellStyleNames && nCol < m_xColumnDefaultCellStyleNames->size())
+ return (*m_xColumnDefaultCellStyleNames)[static_cast<size_t>(nCol)];
return OUString();
}
@@ -1435,7 +1471,7 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName,
if( sStyleName.isEmpty() )
{
sStyleName = (*m_pRows)[m_nCurRow]->GetDefaultCellStyleName();
- if( sStyleName.isEmpty() && m_pColumnDefaultCellStyleNames )
+ if( sStyleName.isEmpty() && m_xColumnDefaultCellStyleNames )
{
sStyleName = GetColumnDefaultCellStyleName( m_nCurCol );
if( sStyleName.isEmpty() )
@@ -1460,10 +1496,31 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName,
// Set current col to the next (free) column
m_nCurCol = nColsReq;
+ m_nNonMergedCurCol = nColsReq;
while( m_nCurCol<GetColumnCount() && GetCell(m_nCurRow,m_nCurCol)->IsUsed() )
m_nCurCol++;
}
+void SwXMLTableContext::InsertCoveredCell(const OUString& rStyleName)
+{
+ const IDocumentSettingAccess& rIDSA = GetSwImport().getDoc()->getIDocumentSettingAccess();
+ bool bWordTableCell = rIDSA.get(DocumentSettingId::TABLE_ROW_KEEP);
+ if (!bWordTableCell)
+ {
+ // Compatibility flag not active, ignore formatting of covered cells.
+ return;
+ }
+
+ SwXMLTableCell_Impl* pCell = GetCell(m_nCurRow, m_nNonMergedCurCol);
+ ++m_nNonMergedCurCol;
+ if (!pCell)
+ {
+ return;
+ }
+
+ pCell->SetStyleName(rStyleName);
+}
+
void SwXMLTableContext::InsertRow( const OUString& rStyleName,
const OUString& rDfltCellStyleName,
bool bInHead )
@@ -1494,6 +1551,7 @@ void SwXMLTableContext::InsertRow( const OUString& rStyleName,
// We start at the first column ...
m_nCurCol=0;
+ m_nNonMergedCurCol = 0;
// ... but this cell may be occupied already.
while( m_nCurCol<GetColumnCount() && GetCell(m_nCurRow,m_nCurCol)->IsUsed() )
@@ -1621,8 +1679,7 @@ SwTableBox *SwXMLTableContext::NewTableBox( const SwStartNode *pStNd,
// The topmost table is the only table that maintains the two members
// pBox1 and bFirstSection.
if( m_xParentTable.is() )
- return static_cast<SwXMLTableContext *>(m_xParentTable.get())->NewTableBox( pStNd,
- pUpper );
+ return m_xParentTable->NewTableBox( pStNd, pUpper );
SwTableBox *pBox;
@@ -1852,7 +1909,7 @@ SwTableBox *SwXMLTableContext::MakeTableBox(
SAL_WARN_IF(!pTextNode->GetText().isEmpty(), "sw",
"why text here?");
pTextNode->InsertText(*pCell->GetStringValue(),
- SwIndex(pTextNode, 0));
+ SwContentIndex(pTextNode, 0));
}
}
@@ -1869,18 +1926,14 @@ SwTableBox *SwXMLTableContext::MakeTableBox(
!sStyleName.isEmpty() )
{
// default num format?
- const SfxPoolItem* pItem = nullptr;
- if( pBoxFormat2->GetItemState( RES_BOXATR_FORMAT, false, &pItem )
- == SfxItemState::SET )
+ if( const SwTableBoxNumFormat* pNumFormat = pBoxFormat2->GetItemIfSet( RES_BOXATR_FORMAT, false ) )
{
- const SwTableBoxNumFormat* pNumFormat =
- static_cast<const SwTableBoxNumFormat*>( pItem );
- if( ( pNumFormat != nullptr ) && ( pNumFormat->GetValue() == 0 ) )
+ if (pNumFormat && (pNumFormat->GetValue() % SV_COUNTRY_LANGUAGE_OFFSET) == 0)
{
// only one text node?
SwNodeIndex aNodeIndex( *(pCell->GetStartNode()), 1 );
if( ( aNodeIndex.GetNode().EndOfSectionIndex() -
- aNodeIndex.GetNode().StartOfSectionIndex() ) == 2 )
+ aNodeIndex.GetNode().StartOfSectionIndex() ) == SwNodeOffset(2) )
{
SwTextNode* pTextNode= aNodeIndex.GetNode().GetTextNode();
if( pTextNode != nullptr )
@@ -1924,15 +1977,11 @@ SwTableBox *SwXMLTableContext::MakeTableBox(
// No value but a non-textual format, i.e. a number format
// Solution: the number format will be removed,
// the cell gets the default text format.
- const SfxPoolItem* pItem = nullptr;
- if( m_pBoxFormat->GetItemState( RES_BOXATR_FORMAT, false, &pItem )
- == SfxItemState::SET )
+ if( const SwTableBoxNumFormat* pNumFormat = m_pBoxFormat->GetItemIfSet( RES_BOXATR_FORMAT, false ) )
{
const SwDoc* pDoc = m_pBoxFormat->GetDoc();
const SvNumberFormatter* pNumberFormatter = pDoc ?
pDoc->GetNumberFormatter() : nullptr;
- const SwTableBoxNumFormat* pNumFormat =
- static_cast<const SwTableBoxNumFormat*>( pItem );
if( pNumFormat != nullptr && pNumberFormatter &&
!pNumberFormatter->GetEntry( pNumFormat->GetValue() )->IsTextFormat() )
m_pBoxFormat->ResetFormatAttr( RES_BOXATR_FORMAT );
@@ -2168,7 +2217,6 @@ SwTableLine *SwXMLTableContext::MakeTableLine( SwTableBox *pUpper,
void SwXMLTableContext::MakeTable_( SwTableBox *pBox )
{
// fix column widths
- std::vector<ColumnWidthInfo>::iterator colIter;
sal_uInt32 nCols = GetColumnCount();
// If there are empty rows (because of some row span of previous rows)
@@ -2178,7 +2226,7 @@ void SwXMLTableContext::MakeTable_( SwTableBox *pBox )
{
SwXMLTableRow_Impl *pPrevRow = (*m_pRows)[m_nCurRow - 1U].get();
const SwXMLTableCell_Impl *pCell;
- for( sal_uLong i = 0; i < m_aColumnWidths.size(); ++i )
+ for( size_t i = 0; i < m_aColumnWidths.size(); ++i )
{
pCell = pPrevRow->GetCell(i);
if( pCell->GetRowSpan() > 1 )
@@ -2186,7 +2234,7 @@ void SwXMLTableContext::MakeTable_( SwTableBox *pBox )
FixRowSpan( m_nCurRow-1, i, 1UL );
}
}
- for (sal_uLong i = m_pRows->size() - 1; i >= m_nCurRow; --i)
+ for (size_t i = m_pRows->size() - 1; i >= m_nCurRow; --i)
m_pRows->pop_back();
}
@@ -2266,10 +2314,10 @@ void SwXMLTableContext::MakeTable_( SwTableBox *pBox )
{
double n = static_cast<double>(m_nWidth) / static_cast<double>(nRelWidth);
nRelWidth = 0;
- for( colIter = m_aColumnWidths.begin(); colIter < m_aColumnWidths.end() - 1; ++colIter)
+ for( auto colIter = m_aColumnWidths.begin(); colIter != (m_aColumnWidths.end() - 1); ++colIter)
{
sal_Int32 nW = static_cast<sal_Int32>( colIter->width * n);
- colIter->width = static_cast<sal_uInt16>(nW);
+ colIter->width = o3tl::narrowing<sal_uInt16>(nW);
nRelWidth += nW;
}
m_aColumnWidths.back().width = (m_nWidth-nRelWidth);
@@ -2367,7 +2415,7 @@ void SwXMLTableContext::MakeTable_( SwTableBox *pBox )
// column widths, every column get some extra width.
sal_Int32 nExtraAbs = m_nWidth - nAbsWidth;
sal_Int32 nAbsLastCol = m_aColumnWidths.back().width + nExtraAbs;
- for( colIter = m_aColumnWidths.begin(); colIter < m_aColumnWidths.end()-1; ++colIter )
+ for( auto colIter = m_aColumnWidths.begin(); colIter != (m_aColumnWidths.end() - 1); ++colIter )
{
sal_Int32 nAbsCol = colIter->width;
sal_Int32 nExtraAbsCol = (nAbsCol * nExtraAbs) /
@@ -2385,7 +2433,7 @@ void SwXMLTableContext::MakeTable_( SwTableBox *pBox )
// Every column gets the minimum width plus some extra width.
sal_Int32 nExtraAbs = m_nWidth - (nCols * MINLAY);
sal_Int32 nAbsLastCol = MINLAY + nExtraAbs;
- for( colIter = m_aColumnWidths.begin(); colIter < m_aColumnWidths.end()-1; ++colIter )
+ for( auto colIter = m_aColumnWidths.begin(); colIter != (m_aColumnWidths.end() - 1); ++colIter )
{
sal_Int32 nAbsCol = colIter->width;
sal_Int32 nExtraAbsCol = (nAbsCol * nExtraAbs) /
@@ -2471,16 +2519,12 @@ void SwXMLTableContext::MakeTable()
XmlStyleFamily::TABLE_TABLE, m_aStyleName, &pAutoItemSet ) &&
pAutoItemSet )
{
- const SfxPoolItem *pItem;
- const SvxLRSpaceItem *pLRSpace = nullptr;
- if( SfxItemState::SET == pAutoItemSet->GetItemState( RES_LR_SPACE, false,
- &pItem ) )
- pLRSpace = static_cast<const SvxLRSpaceItem *>(pItem);
+ const SvxLRSpaceItem *pLRSpace =
+ pAutoItemSet->GetItemIfSet( RES_LR_SPACE, false );
- if( SfxItemState::SET == pAutoItemSet->GetItemState( RES_HORI_ORIENT, false,
- &pItem ) )
+ if( const SwFormatHoriOrient* pItem = pAutoItemSet->GetItemIfSet( RES_HORI_ORIENT, false ) )
{
- eHoriOrient = static_cast<const SwFormatHoriOrient *>(pItem)->GetHoriOrient();
+ eHoriOrient = pItem->GetHoriOrient();
switch( eHoriOrient )
{
case text::HoriOrientation::FULL:
@@ -2506,10 +2550,8 @@ void SwXMLTableContext::MakeTable()
bSetHoriOrient = true;
}
- const SwFormatFrameSize *pSize = nullptr;
- if( SfxItemState::SET == pAutoItemSet->GetItemState( RES_FRM_SIZE, false,
- &pItem ) )
- pSize = static_cast<const SwFormatFrameSize *>(pItem);
+ const SwFormatFrameSize *pSize =
+ pAutoItemSet->GetItemIfSet( RES_FRM_SIZE, false );
switch( eHoriOrient )
{
@@ -2599,7 +2641,7 @@ void SwXMLTableContext::MakeTable()
m_pTableNode );
// 2) release the DDE source context,
- m_xDDESource.set(nullptr);
+ m_xDDESource.clear();
// 3) create new DDE table, and
std::unique_ptr<SwDDETable> pDDETable( new SwDDETable( m_pTableNode->GetTable(),
@@ -2613,8 +2655,7 @@ void SwXMLTableContext::MakeTable()
if( m_pTableNode->GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell() )
{
m_pTableNode->DelFrames();
- SwNodeIndex aIdx( *m_pTableNode->EndOfSectionNode(), 1 );
- m_pTableNode->MakeOwnFrames(&aIdx);
+ m_pTableNode->MakeOwnFrames();
}
}
@@ -2642,28 +2683,27 @@ const SwStartNode *SwXMLTableContext::InsertTableSection(
// The topmost table is the only table that maintains the two members
// pBox1 and bFirstSection.
if( m_xParentTable.is() )
- return static_cast<SwXMLTableContext *>(m_xParentTable.get())
- ->InsertTableSection(pPrevSttNd, pStringValueStyleName);
+ return m_xParentTable->InsertTableSection(pPrevSttNd, pStringValueStyleName);
const SwStartNode *pStNd;
- Reference<XUnoTunnel> xCursorTunnel( GetImport().GetTextImport()->GetCursor(),
- UNO_QUERY);
- OSL_ENSURE( xCursorTunnel.is(), "missing XUnoTunnel for Cursor" );
- OTextCursorHelper *pTextCursor = reinterpret_cast< OTextCursorHelper * >(
- sal::static_int_cast< sal_IntPtr >( xCursorTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
- OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
if( m_bFirstSection )
{
+ Reference<XInterface> xCursorTunnel( GetImport().GetTextImport()->GetCursor(),
+ UNO_QUERY);
+ OSL_ENSURE( xCursorTunnel.is(), "missing XUnoTunnel for Cursor" );
+ OTextCursorHelper *pTextCursor = dynamic_cast<OTextCursorHelper*>(xCursorTunnel.get());
+ assert(pTextCursor && "SwXTextCursor missing");
+
// The Cursor already is in the first section
- pStNd = pTextCursor->GetPaM()->GetNode().FindTableBoxStartNode();
+ pStNd = pTextCursor->GetPaM()->GetPointNode().FindTableBoxStartNode();
m_bFirstSection = false;
GetImport().GetTextImport()->SetStyleAndAttrs( GetImport(),
GetImport().GetTextImport()->GetCursor(), "Standard", true );
}
else
{
- SwDoc* pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
+ SwDoc* pDoc = GetSwImport().getDoc();
const SwEndNode *pEndNd = pPrevSttNd ? pPrevSttNd->EndOfSectionNode()
: m_pTableNode->EndOfSectionNode();
// #i78921# - make code robust
@@ -2672,28 +2712,26 @@ const SwStartNode *SwXMLTableContext::InsertTableSection(
{
pDoc = &const_cast<SwDoc&>(pEndNd->GetDoc());
}
- sal_uInt32 nOffset = pPrevSttNd ? 1UL : 0UL;
+ SwNodeOffset nOffset(pPrevSttNd ? 1 : 0);
SwNodeIndex aIdx( *pEndNd, nOffset );
SwTextFormatColl *pColl =
pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_STANDARD, false );
- pStNd = pDoc->GetNodes().MakeTextSection( aIdx, SwTableBoxStartNode,
+ pStNd = pDoc->GetNodes().MakeTextSection( aIdx.GetNode(), SwTableBoxStartNode,
pColl );
// Consider the case that a table is defined without a row.
if( !pPrevSttNd && m_pBox1 != nullptr )
-
{
m_pBox1->m_pStartNode = pStNd;
SwContentNode *pCNd = pDoc->GetNodes()[ pStNd->GetIndex() + 1 ]
->GetContentNode();
- SwPosition aPos( *pCNd );
- aPos.nContent.Assign( pCNd, 0U );
-
- const uno::Reference< text::XTextRange > xTextRange =
- SwXTextRange::CreateXTextRange( *pDoc, aPos, nullptr );
- Reference < XText > xText = xTextRange->getText();
- Reference < XTextCursor > xTextCursor =
- xText->createTextCursorByRange( xTextRange );
- GetImport().GetTextImport()->SetCursor( xTextCursor );
+ SwFrameFormat *const pTableFormat = m_pTableNode->GetTable().GetFrameFormat();
+ rtl::Reference<SwXCell> xParent = SwXCell::CreateXCell( pTableFormat, m_pBox1 );
+ DBG_TESTSOLARMUTEX();
+ SwPaM aPam(*pCNd, *pCNd);
+ rtl::Reference<SwXTextCursor> xTextCursor =
+ new SwXTextCursor(*pDoc, xParent, CursorType::TableText,
+ *aPam.GetPoint(), aPam.GetMark());
+ GetImport().GetTextImport()->SetCursor( static_cast<XWordCursor*>(xTextCursor.get()) );
}
}
diff --git a/sw/source/filter/xml/xmltbli.hxx b/sw/source/filter/xml/xmltbli.hxx
index fc544f6c6886..400fc8ba0cda 100644
--- a/sw/source/filter/xml/xmltbli.hxx
+++ b/sw/source/filter/xml/xmltbli.hxx
@@ -60,7 +60,7 @@ class SwXMLTableContext : public XMLTextTableContext
ColumnWidthInfo(sal_uInt16 wdth, bool isRel) : width(wdth), isRelative(isRel) {};
};
std::vector<ColumnWidthInfo> m_aColumnWidths;
- std::unique_ptr<std::vector<OUString>> m_pColumnDefaultCellStyleNames;
+ std::optional<std::vector<OUString>> m_xColumnDefaultCellStyleNames;
css::uno::Reference< css::text::XTextCursor > m_xOldCursor;
css::uno::Reference< css::text::XTextContent > m_xTextContent;
@@ -81,7 +81,7 @@ class SwXMLTableContext : public XMLTextTableContext
TableBoxIndexHasher> map_BoxFormat;
std::unique_ptr<map_BoxFormat> m_pSharedBoxFormats;
- SvXMLImportContextRef m_xParentTable; // if table is a sub table
+ rtl::Reference<SwXMLTableContext> m_xParentTable; // if table is a sub table
rtl::Reference<SwXMLDDETableContext_Impl> m_xDDESource;
@@ -92,6 +92,8 @@ class SwXMLTableContext : public XMLTextTableContext
sal_uInt16 m_nHeaderRows;
sal_uInt32 m_nCurRow;
sal_uInt32 m_nCurCol;
+ /// Same as m_nCurCol, but not incremented multiple times for table cells with row span.
+ sal_uInt32 m_nNonMergedCurCol;
sal_Int32 m_nWidth;
// The maximum table width (i.e., maximum value for m_nWidth); must be >= MINLAY and must also
@@ -156,6 +158,10 @@ public:
inline sal_uInt32 GetColumnCount() const;
bool IsInsertCellPossible() const { return m_nCurCol < GetColumnCount(); }
+
+ /// Determines if it's OK to insert a covered cell, given the total column count.
+ bool IsInsertCoveredCellPossible() const { return m_nNonMergedCurCol < GetColumnCount(); }
+
bool IsInsertColPossible() const { return m_nCurCol < USHRT_MAX; }
bool IsInsertRowPossible() const { return m_nCurRow < USHRT_MAX; }
bool IsValid() const { return m_pTableNode != nullptr; }
@@ -169,6 +175,10 @@ public:
bool bHasValue = false,
double fValue = 0.0,
OUString const*const pStringValue = nullptr);
+
+ /// Sets formatting of an already created covered cell.
+ void InsertCoveredCell(const OUString& rStyleName);
+
void InsertRow( const OUString& rStyleName,
const OUString& rDfltCellStyleName,
bool bInHead );
@@ -186,7 +196,7 @@ public:
inline SwXMLTableContext *SwXMLTableContext::GetParentTable() const
{
- return static_cast<SwXMLTableContext *>(m_xParentTable.get());
+ return m_xParentTable.get();
}
inline sal_uInt32 SwXMLTableContext::GetColumnCount() const
diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx
index dc1706333efa..c5cba4dae173 100644
--- a/sw/source/filter/xml/xmltexte.cxx
+++ b/sw/source/filter/xml/xmltexte.cxx
@@ -19,8 +19,6 @@
#include <sal/config.h>
-#include <string_view>
-
#include <comphelper/classids.hxx>
#include <com/sun/star/embed/XEmbeddedObject.hpp>
#include <com/sun/star/embed/XLinkageSupport.hpp>
@@ -47,11 +45,9 @@
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::style;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::document;
-using namespace ::com::sun::star::io;
using namespace ::xmloff::token;
namespace {
@@ -70,10 +66,7 @@ enum SvEmbeddedObjectTypes
SwNoTextNode *SwXMLTextParagraphExport::GetNoTextNode(
const Reference < XPropertySet >& rPropSet )
{
- Reference<XUnoTunnel> xCursorTunnel( rPropSet, UNO_QUERY );
- assert(xCursorTunnel.is() && "missing XUnoTunnel for embedded");
- SwXFrame *pFrame = reinterpret_cast< SwXFrame * >(
- sal::static_int_cast< sal_IntPtr >( xCursorTunnel->getSomething( SwXFrame::getUnoTunnelId() )));
+ SwXFrame* pFrame = dynamic_cast<SwXFrame*>(rPropSet.get());
assert(pFrame && "SwXFrame missing");
SwFrameFormat *pFrameFormat = pFrame->GetFrameFormat();
const SwFormatContent& rContent = pFrameFormat->GetContent();
@@ -81,15 +74,15 @@ SwNoTextNode *SwXMLTextParagraphExport::GetNoTextNode(
return pNdIdx->GetNodes()[pNdIdx->GetIndex() + 1]->GetNoTextNode();
}
-constexpr OUStringLiteral gsEmbeddedObjectProtocol( u"vnd.sun.star.EmbeddedObject:" );
+constexpr OUString gsEmbeddedObjectProtocol( u"vnd.sun.star.EmbeddedObject:"_ustr );
SwXMLTextParagraphExport::SwXMLTextParagraphExport(
SwXMLExport& rExp,
SvXMLAutoStylePoolP& _rAutoStylePool ) :
XMLTextParagraphExport( rExp, _rAutoStylePool ),
- aAppletClassId( SO3_APPLET_CLASSID ),
- aPluginClassId( SO3_PLUGIN_CLASSID ),
- aIFrameClassId( SO3_IFRAME_CLASSID )
+ m_aAppletClassId( SO3_APPLET_CLASSID ),
+ m_aPluginClassId( SO3_PLUGIN_CLASSID ),
+ m_aIFrameClassId( SO3_IFRAME_CLASSID )
{
}
@@ -115,19 +108,17 @@ static void lcl_addURL ( SvXMLExport &rExport, const OUString &rURL,
static void lcl_addAspect(
const svt::EmbeddedObjectRef& rObj,
- const XMLPropertyState **pStates,
+ std::vector<XMLPropertyState>& rStates,
const rtl::Reference < XMLPropertySetMapper >& rMapper )
{
sal_Int64 nAspect = rObj.GetViewAspect();
if ( nAspect )
- {
- *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_DRAW_ASPECT ), uno::makeAny( nAspect ) );
- }
+ rStates.emplace_back( rMapper->FindEntryIndex( CTF_OLE_DRAW_ASPECT ), uno::Any( nAspect ) );
}
static void lcl_addOutplaceProperties(
const svt::EmbeddedObjectRef& rObj,
- const XMLPropertyState **pStates,
+ std::vector<XMLPropertyState>& rStates,
const rtl::Reference < XMLPropertySetMapper >& rMapper )
{
MapMode aMode( MapUnit::Map100thMM ); // the API expects this map mode for the embedded objects
@@ -136,21 +127,15 @@ static void lcl_addOutplaceProperties(
if( !(aSize.Width() && aSize.Height()) )
return;
- *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_LEFT ), Any(sal_Int32(0)) );
- pStates++;
-
- *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_TOP ), Any(sal_Int32(0)) );
- pStates++;
-
- *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_WIDTH ), Any(static_cast<sal_Int32>(aSize.Width())) );
- pStates++;
-
- *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_HEIGHT ), Any(static_cast<sal_Int32>(aSize.Height())) );
+ rStates.emplace_back( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_LEFT ), Any(sal_Int32(0)) );
+ rStates.emplace_back( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_TOP ), Any(sal_Int32(0)) );
+ rStates.emplace_back( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_WIDTH ), Any(static_cast<sal_Int32>(aSize.Width())) );
+ rStates.emplace_back( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_HEIGHT ), Any(static_cast<sal_Int32>(aSize.Height())) );
}
static void lcl_addFrameProperties(
const uno::Reference < embed::XEmbeddedObject >& xObj,
- const XMLPropertyState **pStates,
+ std::vector<XMLPropertyState>& rStates,
const rtl::Reference < XMLPropertySetMapper >& rMapper )
{
if ( !::svt::EmbeddedObjectRef::TryRunningState( xObj ) )
@@ -185,24 +170,13 @@ static void lcl_addFrameProperties(
aAny >>= nHeight;
if( !bIsAutoScroll )
- {
- *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_DISPLAY_SCROLLBAR ), makeAny(bIsScrollingMode) );
- pStates++;
- }
+ rStates.emplace_back( rMapper->FindEntryIndex( CTF_FRAME_DISPLAY_SCROLLBAR ), Any(bIsScrollingMode) );
if( !bIsAutoBorder )
- {
- *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_DISPLAY_BORDER ), makeAny(bIsBorderSet) );
- pStates++;
- }
+ rStates.emplace_back( rMapper->FindEntryIndex( CTF_FRAME_DISPLAY_BORDER ), Any(bIsBorderSet) );
if( SIZE_NOT_SET != nWidth )
- {
- *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_MARGIN_HORI ), Any(nWidth) );
- pStates++;
- }
+ rStates.emplace_back( rMapper->FindEntryIndex( CTF_FRAME_MARGIN_HORI ), Any(nWidth) );
if( SIZE_NOT_SET != nHeight )
- {
- *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_MARGIN_VERT ), Any(nHeight) );
- }
+ rStates.emplace_back( rMapper->FindEntryIndex( CTF_FRAME_MARGIN_VERT ), Any(nHeight) );
}
void SwXMLTextParagraphExport::_collectTextEmbeddedAutoStyles(
@@ -213,10 +187,11 @@ void SwXMLTextParagraphExport::_collectTextEmbeddedAutoStyles(
if( !rObjRef.is() )
return;
- const XMLPropertyState *aStates[8] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
+ std::vector<XMLPropertyState> aStates;
+ aStates.reserve(8);
SvGlobalName aClassId( rObjRef->getClassID() );
- if( aIFrameClassId == aClassId )
+ if( m_aIFrameClassId == aClassId )
{
lcl_addFrameProperties( rObjRef.GetObject(), aStates,
GetAutoFramePropMapper()->getPropertySetMapper() );
@@ -231,13 +206,6 @@ void SwXMLTextParagraphExport::_collectTextEmbeddedAutoStyles(
GetAutoFramePropMapper()->getPropertySetMapper() );
Add( XmlStyleFamily::TEXT_FRAME, rPropSet, aStates );
-
- const XMLPropertyState **pStates = aStates;
- while( *pStates )
- {
- delete *pStates;
- pStates++;
- }
}
void SwXMLTextParagraphExport::_exportTextEmbedded(
@@ -253,15 +221,15 @@ void SwXMLTextParagraphExport::_exportTextEmbedded(
SvGlobalName aClassId( rObjRef->getClassID() );
SvEmbeddedObjectTypes nType = SV_EMBEDDED_OWN;
- if( aPluginClassId == aClassId )
+ if( m_aPluginClassId == aClassId )
{
nType = SV_EMBEDDED_PLUGIN;
}
- else if( aAppletClassId == aClassId )
+ else if( m_aAppletClassId == aClassId )
{
nType = SV_EMBEDDED_APPLET;
}
- else if( aIFrameClassId == aClassId )
+ else if( m_aIFrameClassId == aClassId )
{
nType = SV_EMBEDDED_FRAME;
}
@@ -282,7 +250,8 @@ void SwXMLTextParagraphExport::_exportTextEmbedded(
aAny >>= sStyle;
}
- const XMLPropertyState *aStates[8] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
+ std::vector<XMLPropertyState> aStates;
+ aStates.reserve(8);
switch( nType )
{
case SV_EMBEDDED_FRAME:
@@ -302,12 +271,7 @@ void SwXMLTextParagraphExport::_exportTextEmbedded(
const OUString sAutoStyle = Find( XmlStyleFamily::TEXT_FRAME,
rPropSet, sStyle, aStates );
- const XMLPropertyState **pStates = aStates;
- while( *pStates )
- {
- delete *pStates;
- pStates++;
- }
+ aStates.clear();
if( !sAutoStyle.isEmpty() )
rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_STYLE_NAME, sAutoStyle );
@@ -364,8 +328,7 @@ void SwXMLTextParagraphExport::_exportTextEmbedded(
case '\\':
if( aBuffer.isEmpty() )
{
- aBuffer.append( '\'' );
- aBuffer.append( std::u16string_view(sRange).substr(0, i) );
+ aBuffer.append( OUString::Concat("\'") + sRange.subView(0, i) );
}
if( '\'' == c || '\\' == c )
aBuffer.append( '\\' );
@@ -420,7 +383,7 @@ void SwXMLTextParagraphExport::_exportTextEmbedded(
sal_Int32 i = aProps.getLength();
while ( i > 0 )
{
- beans::PropertyValue& aProp = aProps[--i];
+ const beans::PropertyValue& aProp = aProps[--i];
const SwHtmlOptType nType2 = SwApplet_Impl::GetOptionType( aProp.Name, true );
if ( nType2 == SwHtmlOptType::TAG)
{
@@ -515,7 +478,7 @@ void SwXMLTextParagraphExport::_exportTextEmbedded(
sal_Int32 i = aProps.getLength();
while ( i > 0 )
{
- beans::PropertyValue& aProp = aProps[--i];
+ const beans::PropertyValue& aProp = aProps[--i];
const SwHtmlOptType nType2 = SwApplet_Impl::GetOptionType( aProp.Name, true );
if (SwHtmlOptType::PARAM == nType2 || SwHtmlOptType::SIZE == nType2 )
{
@@ -541,7 +504,7 @@ void SwXMLTextParagraphExport::_exportTextEmbedded(
sal_Int32 i = aProps.getLength();
while ( i > 0 )
{
- beans::PropertyValue& aProp = aProps[--i];
+ const beans::PropertyValue& aProp = aProps[--i];
const SwHtmlOptType nType2 = SwApplet_Impl::GetOptionType( aProp.Name, false );
if ( nType2 == SwHtmlOptType::TAG)
{
diff --git a/sw/source/filter/xml/xmltexte.hxx b/sw/source/filter/xml/xmltexte.hxx
index 3fc9530e6303..09ce6c46f4ca 100644
--- a/sw/source/filter/xml/xmltexte.hxx
+++ b/sw/source/filter/xml/xmltexte.hxx
@@ -23,26 +23,37 @@
#include <xmloff/txtparae.hxx>
#include <tools/globname.hxx>
+#include <optional>
+#include <unordered_map>
+
#define XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE "vnd.sun.star.GraphicObject:"
class SwXMLExport;
class SvXMLAutoStylePoolP;
class SwNoTextNode;
class SwTableNode;
+class SwTableLines;
namespace com::sun::star::style { class XStyle; }
class SwXMLTextParagraphExport : public XMLTextParagraphExport
{
- const SvGlobalName aAppletClassId;
- const SvGlobalName aPluginClassId;
- const SvGlobalName aIFrameClassId;
+ const SvGlobalName m_aAppletClassId;
+ const SvGlobalName m_aPluginClassId;
+ const SvGlobalName m_aIFrameClassId;
// Collected autostyles for use in exportTextAutoStyles
std::vector<const SwTableNode*> maTableNodes;
+public:
+ typedef ::std::unordered_map<SwFrameFormat const*, ::std::optional<OUString>> FormatMap;
+private:
+ ::std::unordered_map<SwTableNode const*, ::std::pair<FormatMap, FormatMap>> m_TableFormats;
static SwNoTextNode *GetNoTextNode(
const css::uno::Reference < css::beans::XPropertySet >& rPropSet );
+ void CollectTableLinesAutoStyles(const SwTableLines& rLines, SwFrameFormat& rFormat,
+ bool bProgress);
+
protected:
virtual void _collectTextEmbeddedAutoStyles(
const css::uno::Reference< css::beans::XPropertySet > & rPropSet ) override;
@@ -61,6 +72,11 @@ public:
SwXMLExport& rExp,
SvXMLAutoStylePoolP& rAutoStylePool );
virtual ~SwXMLTextParagraphExport() override;
+
+ ::std::unordered_map<SwTableNode const*, ::std::pair<FormatMap, FormatMap>> const&
+ GetTableFormats() const { return m_TableFormats; }
+ ::std::unordered_map<SwTableNode const*, ::std::pair<FormatMap, FormatMap>> &
+ GetTableFormats() { return m_TableFormats; }
};
#endif // INCLUDED_SW_SOURCE_FILTER_XML_XMLTEXTE_HXX
diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx
index be863f65bfa3..508cb428dc62 100644
--- a/sw/source/filter/xml/xmltexti.cxx
+++ b/sw/source/filter/xml/xmltexti.cxx
@@ -20,6 +20,8 @@
#include <comphelper/storagehelper.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/propertyvalue.hxx>
+#include <comphelper/servicehelper.hxx>
#include <com/sun/star/embed/EmbeddedObjectCreator.hpp>
#include <com/sun/star/embed/OOoEmbeddedObjectFactory.hpp>
#include <com/sun/star/embed/XEmbeddedObject.hpp>
@@ -61,7 +63,9 @@
#include <svl/urihelper.hxx>
#include <sfx2/frmdescr.hxx>
#include <tools/globname.hxx>
-#include <tools/UnitConversion.hxx>
+
+#include <algorithm>
+#include <utility>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -71,33 +75,13 @@ using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::beans;
using namespace xml::sax;
-namespace {
-
-struct XMLServiceMapEntry_Impl
-{
- const char *sFilterService;
- sal_Int32 nFilterServiceLen;
-
- sal_uInt32 n1;
- sal_uInt16 n2, n3;
- sal_uInt8 n4, n5, n6, n7, n8, n9, n10, n11;
-};
-
-}
-
-#define SERVICE_MAP_ENTRY( app, s ) \
- { XML_IMPORT_FILTER_##app, sizeof(XML_IMPORT_FILTER_##app)-1, \
- SO3_##s##_CLASSID }
-
-const XMLServiceMapEntry_Impl aServiceMap[] =
-{
- SERVICE_MAP_ENTRY( WRITER, SW ),
- SERVICE_MAP_ENTRY( CALC, SC ),
- SERVICE_MAP_ENTRY( DRAW, SDRAW ),
- SERVICE_MAP_ENTRY( IMPRESS, SIMPRESS ),
- SERVICE_MAP_ENTRY( CHART, SCH ),
- SERVICE_MAP_ENTRY( MATH, SM ),
- { nullptr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+const std::pair<OUString, SvGUID> aServiceMap[] = {
+ { XML_IMPORT_FILTER_WRITER, { SO3_SW_CLASSID } },
+ { XML_IMPORT_FILTER_CALC, { SO3_SC_CLASSID } },
+ { XML_IMPORT_FILTER_DRAW, { SO3_SDRAW_CLASSID } },
+ { XML_IMPORT_FILTER_IMPRESS, { SO3_SIMPRESS_CLASSID } },
+ { XML_IMPORT_FILTER_CHART, { SO3_SCH_CLASSID } },
+ { XML_IMPORT_FILTER_MATH, { SO3_SM_CLASSID } },
};
static void lcl_putHeightAndWidth ( SfxItemSet &rItemSet,
sal_Int32 nHeight, sal_Int32 nWidth,
@@ -105,10 +89,10 @@ static void lcl_putHeightAndWidth ( SfxItemSet &rItemSet,
{
if( nWidth > 0 && nHeight > 0 )
{
- nWidth = convertMm100ToTwip( nWidth );
+ nWidth = o3tl::toTwips(nWidth, o3tl::Length::mm100);
if( nWidth < MINFLY )
nWidth = MINFLY;
- nHeight = convertMm100ToTwip( nHeight );
+ nHeight = o3tl::toTwips(nHeight, o3tl::Length::mm100);
if( nHeight < MINFLY )
nHeight = MINFLY;
rItemSet.Put( SwFormatFrameSize( SwFrameSize::Fixed, nWidth, nHeight ) );
@@ -151,16 +135,16 @@ static void lcl_setObjectVisualArea( const uno::Reference< embed::XEmbeddedObjec
SwXMLTextImportHelper::SwXMLTextImportHelper(
const uno::Reference < XModel>& rModel,
- SvXMLImport& rImport,
+ SwXMLImport& rImport,
const uno::Reference<XPropertySet> & rInfoSet,
bool bInsertM, bool bStylesOnlyM,
bool bBlockM, bool bOrganizerM ) :
XMLTextImportHelper( rModel, rImport, bInsertM, bStylesOnlyM, true/*bProgress*/,
bBlockM, bOrganizerM ),
- pRedlineHelper( nullptr )
+ m_pRedlineHelper( nullptr )
{
uno::Reference<XPropertySet> xDocPropSet( rModel, UNO_QUERY );
- pRedlineHelper = new XMLRedlineImportHelper(rImport,
+ m_pRedlineHelper = new XMLRedlineImportHelper(rImport,
bInsertM || bBlockM, xDocPropSet, rInfoSet );
}
@@ -170,7 +154,7 @@ SwXMLTextImportHelper::~SwXMLTextImportHelper()
// and may throw an exception while doing so... catch this
try
{
- delete pRedlineHelper;
+ delete m_pRedlineHelper;
}
catch ( const RuntimeException& )
{
@@ -188,15 +172,11 @@ SvXMLImportContext *SwXMLTextImportHelper::CreateTableChildContext(
bool SwXMLTextImportHelper::IsInHeaderFooter() const
{
- uno::Reference<XUnoTunnel> xCursorTunnel(
- const_cast<SwXMLTextImportHelper *>(this)->GetCursor(), UNO_QUERY );
- assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor");
- OTextCursorHelper *pTextCursor = reinterpret_cast< OTextCursorHelper * >(
- sal::static_int_cast< sal_IntPtr >( xCursorTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
+ OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(const_cast<SwXMLTextImportHelper *>(this)->GetCursor().get());
SAL_WARN_IF(!pTextCursor, "sw.uno", "SwXTextCursor missing");
SwDoc *pDoc = pTextCursor ? pTextCursor->GetDoc() : nullptr;
- return pDoc && pDoc->IsInHeaderFooter( pTextCursor->GetPaM()->GetPoint()->nNode );
+ return pDoc && pDoc->IsInHeaderFooter( pTextCursor->GetPaM()->GetPoint()->GetNode() );
}
static SwOLENode *lcl_GetOLENode( const SwFrameFormat *pFrameFormat )
@@ -233,15 +213,11 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOLEObject(
if( aObjName.isEmpty() )
return xPropSet;
- uno::Reference<XUnoTunnel> xCursorTunnel( GetCursor(), UNO_QUERY );
- assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor");
- OTextCursorHelper *pTextCursor = reinterpret_cast< OTextCursorHelper * >(
- sal::static_int_cast< sal_IntPtr >( xCursorTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
+ OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(GetCursor().get());
SAL_WARN_IF(!pTextCursor, "sw.uno", "SwXTextCursor missing");
- SwDoc *pDoc = SwImport::GetDocFromXMLImport( rImport );
+ SwDoc *pDoc = static_cast<SwXMLImport&>(rImport).getDoc();
- SfxItemSet aItemSet( pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN,
- RES_FRMATR_END>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END> aItemSet( pDoc->GetAttrPool() );
Size aTwipSize( 0, 0 );
tools::Rectangle aVisArea( 0, 0, nWidth, nHeight );
lcl_putHeightAndWidth( aItemSet, nHeight, nWidth,
@@ -253,22 +229,14 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOLEObject(
{
bool bInsert = false;
SvGlobalName aClassName;
- const XMLServiceMapEntry_Impl *pEntry = aServiceMap;
- while( pEntry->sFilterService )
+ for (const auto& [sFilterService, rCLASSID] : aServiceMap)
{
- if( aObjName.equalsAsciiL( pEntry->sFilterService,
- pEntry->nFilterServiceLen ) )
+ if (aObjName == sFilterService)
{
- aClassName = SvGlobalName( pEntry->n1, pEntry->n2,
- pEntry->n3, pEntry->n4,
- pEntry->n5, pEntry->n6,
- pEntry->n7, pEntry->n8,
- pEntry->n9, pEntry->n10,
- pEntry->n11 );
+ aClassName = SvGlobalName(rCLASSID);
bInsert = true;
break;
}
- pEntry++;
}
if( bInsert )
@@ -364,8 +332,8 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOLEObject(
pOLENd->SetOLESizeInvalid( true );
}
- xPropSet.set(SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
- *pDoc, pFrameFormat), uno::UNO_QUERY);
+ xPropSet = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
+ *pDoc, pFrameFormat);
if( pDoc->getIDocumentDrawModelAccess().GetDrawModel() )
{
// req for z-order
@@ -478,14 +446,14 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOLEObject(
{
sal_Int32 nVal = 0;
rProp.maValue >>= nVal;
- aVisArea.setX( nVal );
+ aVisArea.SetPosX( nVal );
}
break;
case CTF_OLE_VIS_AREA_TOP:
{
sal_Int32 nVal = 0;
rProp.maValue >>= nVal;
- aVisArea.setY( nVal );
+ aVisArea.SetPosY( nVal );
}
break;
case CTF_OLE_VIS_AREA_WIDTH:
@@ -545,15 +513,11 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOOoLink(
uno::Reference < XPropertySet > xPropSet;
- uno::Reference<XUnoTunnel> xCursorTunnel( GetCursor(), UNO_QUERY );
- assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor");
- OTextCursorHelper *pTextCursor = reinterpret_cast< OTextCursorHelper * >(
- sal::static_int_cast< sal_IntPtr >( xCursorTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
- OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
- SwDoc *pDoc = SwImport::GetDocFromXMLImport( rImport );
+ OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(GetCursor().get());
+ assert( pTextCursor && "SwXTextCursor missing" );
+ SwDoc *pDoc = static_cast<SwXMLImport&>(rImport).getDoc();
- SfxItemSet aItemSet( pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN,
- RES_FRMATR_END>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END> aItemSet( pDoc->GetAttrPool() );
Size aTwipSize( 0, 0 );
lcl_putHeightAndWidth( aItemSet, nHeight, nWidth,
&aTwipSize );
@@ -574,9 +538,8 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOOoLink(
uno::Reference < embed::XEmbeddedObjectCreator > xFactory =
embed::OOoEmbeddedObjectFactory::create(::comphelper::getProcessComponentContext());
- uno::Sequence< beans::PropertyValue > aMediaDescriptor( 1 );
- aMediaDescriptor[0].Name = "URL";
- aMediaDescriptor[0].Value <<= aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ uno::Sequence< beans::PropertyValue > aMediaDescriptor{ comphelper::makePropertyValue(
+ "URL", aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE )) };
if (SfxMedium* pMedium = pDoc->GetDocShell() ? pDoc->GetDocShell()->GetMedium() : nullptr)
{
@@ -584,14 +547,16 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOOoLink(
if ( xInteraction.is() )
{
aMediaDescriptor.realloc( 2 );
- aMediaDescriptor[1].Name = "InteractionHandler";
- aMediaDescriptor[1].Value <<= xInteraction;
+ auto pMediaDescriptor = aMediaDescriptor.getArray();
+ pMediaDescriptor[1].Name = "InteractionHandler";
+ pMediaDescriptor[1].Value <<= xInteraction;
}
const auto nLen = aMediaDescriptor.getLength() + 1;
aMediaDescriptor.realloc(nLen);
- aMediaDescriptor[nLen - 1].Name = "Referer";
- aMediaDescriptor[nLen - 1].Value <<= pMedium->GetName();
+ auto pMediaDescriptor = aMediaDescriptor.getArray();
+ pMediaDescriptor[nLen - 1].Name = "Referer";
+ pMediaDescriptor[nLen - 1].Value <<= pMedium->GetName();
}
uno::Reference < embed::XEmbeddedObject > xObj(
@@ -608,8 +573,8 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOOoLink(
// TODO/LATER: in future may need a way to set replacement image url to the link ( may be even to the object ), needs oasis cws???
- xPropSet.set(SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
- *pDoc, pFrameFormat), uno::UNO_QUERY);
+ xPropSet = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
+ *pDoc, pFrameFormat);
if( pDoc->getIDocumentDrawModelAccess().GetDrawModel() )
{
SwXFrame::GetOrCreateSdrObject(*
@@ -637,18 +602,14 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertApplet(
SolarMutexGuard aGuard;
uno::Reference < XPropertySet > xPropSet;
- uno::Reference<XUnoTunnel> xCursorTunnel( GetCursor(), UNO_QUERY );
- assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor");
- OTextCursorHelper *pTextCursor = reinterpret_cast< OTextCursorHelper * >(
- sal::static_int_cast< sal_IntPtr >( xCursorTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
- OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
+ OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(GetCursor().get());
+ assert( pTextCursor && "SwXTextCursor missing" );
SwDoc *pDoc = pTextCursor->GetDoc();
- SfxItemSet aItemSet( pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN,
- RES_FRMATR_END>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END> aItemSet( pDoc->GetAttrPool() );
lcl_putHeightAndWidth( aItemSet, nHeight, nWidth);
- SwApplet_Impl aAppletImpl ( aItemSet );
+ SwApplet_Impl aAppletImpl ( std::move(aItemSet) );
OUString sCodeBase;
if( !rHRef.isEmpty() )
@@ -666,8 +627,8 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertApplet(
pDoc->getIDocumentContentOperations().InsertEmbObject( *pTextCursor->GetPaM(),
::svt::EmbeddedObjectRef(aAppletImpl.GetApplet(), embed::Aspects::MSOLE_CONTENT),
&aAppletImpl.GetItemSet());
- xPropSet.set(SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
- *pDoc, pFrameFormat), uno::UNO_QUERY);
+ xPropSet = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
+ *pDoc, pFrameFormat);
if( pDoc->getIDocumentDrawModelAccess().GetDrawModel() )
{
// req for z-order
@@ -683,15 +644,11 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertPlugin(
sal_Int32 nWidth, sal_Int32 nHeight )
{
uno::Reference < XPropertySet > xPropSet;
- uno::Reference<XUnoTunnel> xCursorTunnel( GetCursor(), UNO_QUERY );
- assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor");
- OTextCursorHelper *pTextCursor = reinterpret_cast< OTextCursorHelper * >(
- sal::static_int_cast< sal_IntPtr >( xCursorTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
- OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
+ OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(GetCursor().get());
+ assert( pTextCursor && "SwXTextCursor missing" );
SwDoc *pDoc = pTextCursor->GetDoc();
- SfxItemSet aItemSet( pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN,
- RES_FRMATR_END>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END> aItemSet( pDoc->GetAttrPool() );
lcl_putHeightAndWidth( aItemSet, nHeight, nWidth);
// We'll need a (valid) URL, or we need a MIME type. If we don't have
@@ -728,10 +685,10 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertPlugin(
{
if( bValidURL )
xSet->setPropertyValue("PluginURL",
- makeAny( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ) );
+ Any( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ) );
if( bValidMimeType )
xSet->setPropertyValue("PluginMimeType",
- makeAny( rMimeType ) );
+ Any( rMimeType ) );
}
SwFrameFormat *const pFrameFormat =
@@ -739,8 +696,8 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertPlugin(
*pTextCursor->GetPaM(),
::svt::EmbeddedObjectRef(xObj, embed::Aspects::MSOLE_CONTENT),
&aItemSet);
- xPropSet.set(SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
- *pDoc, pFrameFormat), uno::UNO_QUERY);
+ xPropSet = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
+ *pDoc, pFrameFormat);
if( pDoc->getIDocumentDrawModelAccess().GetDrawModel() )
{
SwXFrame::GetOrCreateSdrObject(*
@@ -764,15 +721,11 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertFloatingFra
SolarMutexGuard aGuard;
uno::Reference < XPropertySet > xPropSet;
- uno::Reference<XUnoTunnel> xCursorTunnel( GetCursor(), UNO_QUERY );
- assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor");
- OTextCursorHelper *pTextCursor = reinterpret_cast< OTextCursorHelper * >(
- sal::static_int_cast< sal_IntPtr >( xCursorTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() )));
- OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
+ OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(GetCursor().get());
+ assert( pTextCursor && "SwXTextCursor missing" );
SwDoc *pDoc = pTextCursor->GetDoc();
- SfxItemSet aItemSet( pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN,
- RES_FRMATR_END>{} );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END> aItemSet( pDoc->GetAttrPool() );
lcl_putHeightAndWidth( aItemSet, nHeight, nWidth);
ScrollingMode eScrollMode = ScrollingMode::Auto;
@@ -857,32 +810,37 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertFloatingFra
uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
if ( xSet.is() )
{
+ OUString sHRef = URIHelper::SmartRel2Abs(
+ INetURLObject( GetXMLImport().GetBaseURL() ), rHRef );
+
+ if (INetURLObject(sHRef).IsExoticProtocol())
+ GetXMLImport().NotifyMacroEventRead();
+
xSet->setPropertyValue("FrameURL",
- makeAny( URIHelper::SmartRel2Abs(
- INetURLObject( GetXMLImport().GetBaseURL() ), rHRef ) ) );
+ Any( sHRef ) );
xSet->setPropertyValue("FrameName",
- makeAny( rName ) );
+ Any( rName ) );
if ( eScrollMode == ScrollingMode::Auto )
xSet->setPropertyValue("FrameIsAutoScroll",
- makeAny( true ) );
+ Any( true ) );
else
xSet->setPropertyValue("FrameIsScrollingMode",
- makeAny( eScrollMode == ScrollingMode::Yes ) );
+ Any( eScrollMode == ScrollingMode::Yes ) );
if ( bIsBorderSet )
xSet->setPropertyValue("FrameIsBorder",
- makeAny( bHasBorder ) );
+ Any( bHasBorder ) );
else
xSet->setPropertyValue("FrameIsAutoBorder",
- makeAny( true ) );
+ Any( true ) );
xSet->setPropertyValue("FrameMarginWidth",
- makeAny( sal_Int32( aMargin.Width() ) ) );
+ Any( sal_Int32( aMargin.Width() ) ) );
xSet->setPropertyValue("FrameMarginHeight",
- makeAny( sal_Int32( aMargin.Height() ) ) );
+ Any( sal_Int32( aMargin.Height() ) ) );
}
SwFrameFormat *const pFrameFormat =
@@ -890,8 +848,8 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertFloatingFra
*pTextCursor->GetPaM(),
::svt::EmbeddedObjectRef(xObj, embed::Aspects::MSOLE_CONTENT),
&aItemSet);
- xPropSet.set(SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
- *pDoc, pFrameFormat), uno::UNO_QUERY);
+ xPropSet = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
+ *pDoc, pFrameFormat);
if( pDoc->getIDocumentDrawModelAccess().GetDrawModel() )
{
// req for z-order
@@ -914,11 +872,8 @@ void SwXMLTextImportHelper::endAppletOrPlugin(
// this method will modify the document directly -> lock SolarMutex
SolarMutexGuard aGuard;
- uno::Reference<XUnoTunnel> xCursorTunnel( rPropSet, UNO_QUERY );
- assert(xCursorTunnel.is() && "missing XUnoTunnel for embedded");
- SwXFrame *pFrame = reinterpret_cast< SwXFrame * >(
- sal::static_int_cast< sal_IntPtr >( xCursorTunnel->getSomething( SwXFrame::getUnoTunnelId() )));
- OSL_ENSURE( pFrame, "SwXFrame missing" );
+ SwXFrame* pFrame = dynamic_cast<SwXFrame*>(rPropSet.get());
+ assert(pFrame && "SwXFrame missing");
SwFrameFormat *pFrameFormat = pFrame->GetFrameFormat();
const SwFormatContent& rContent = pFrameFormat->GetContent();
const SwNodeIndex *pNdIdx = rContent.GetContentIdx();
@@ -936,28 +891,27 @@ void SwXMLTextImportHelper::endAppletOrPlugin(
const sal_Int32 nCount = rParamMap.size();
uno::Sequence< beans::PropertyValue > aCommandSequence( nCount );
- sal_Int32 nIndex=0;
- for (const auto& rParam : rParamMap )
- {
- aCommandSequence[nIndex].Name = rParam.first;
- aCommandSequence[nIndex].Handle = -1;
- aCommandSequence[nIndex].Value <<= rParam.second;
- aCommandSequence[nIndex].State = beans::PropertyState_DIRECT_VALUE;
- ++nIndex;
- }
+ std::transform(rParamMap.begin(), rParamMap.end(), aCommandSequence.getArray(),
+ [](const auto& rParam)
+ {
+ return beans::PropertyValue(/* Name */ rParam.first,
+ /* Handle */ -1,
+ /* Value */ uno::Any(rParam.second),
+ /* State */ beans::PropertyState_DIRECT_VALUE);
+ });
// unfortunately the names of the properties are depending on the object
OUString aParaName("AppletCommands");
try
{
- xSet->setPropertyValue( aParaName, makeAny( aCommandSequence ) );
+ xSet->setPropertyValue( aParaName, Any( aCommandSequence ) );
}
catch ( uno::Exception& )
{
aParaName = "PluginCommands";
try
{
- xSet->setPropertyValue( aParaName, makeAny( aCommandSequence ) );
+ xSet->setPropertyValue( aParaName, Any( aCommandSequence ) );
}
catch ( uno::Exception& )
{
@@ -973,12 +927,13 @@ void SwXMLTextImportHelper::RedlineAdd(
const OUString& rAuthor,
const OUString& rComment,
const util::DateTime& rDateTime,
+ const OUString& rMovedID,
bool bMergeLastPara)
{
// create redline helper on demand
- OSL_ENSURE(nullptr != pRedlineHelper, "helper should have been created in constructor");
- if (nullptr != pRedlineHelper)
- pRedlineHelper->Add(rType, rId, rAuthor, rComment, rDateTime,
+ OSL_ENSURE(nullptr != m_pRedlineHelper, "helper should have been created in constructor");
+ if (nullptr != m_pRedlineHelper)
+ m_pRedlineHelper->Add(rType, rId, rAuthor, rComment, rDateTime, rMovedID,
bMergeLastPara);
}
@@ -988,9 +943,9 @@ uno::Reference<XTextCursor> SwXMLTextImportHelper::RedlineCreateText(
{
uno::Reference<XTextCursor> xRet;
- if (nullptr != pRedlineHelper)
+ if (nullptr != m_pRedlineHelper)
{
- xRet = pRedlineHelper->CreateRedlineTextSection(rOldCursor, rId);
+ xRet = m_pRedlineHelper->CreateRedlineTextSection(rOldCursor, rId);
}
return xRet;
@@ -1001,9 +956,9 @@ void SwXMLTextImportHelper::RedlineSetCursor(
bool bStart,
bool bIsOutsideOfParagraph)
{
- if (nullptr != pRedlineHelper) {
+ if (nullptr != m_pRedlineHelper) {
uno::Reference<XTextRange> xTextRange( GetCursor()->getStart() );
- pRedlineHelper->SetCursor(rId, bStart, xTextRange,
+ m_pRedlineHelper->SetCursor(rId, bStart, xTextRange,
bIsOutsideOfParagraph);
}
// else: ignore redline (wasn't added before, else we'd have a helper)
@@ -1012,9 +967,9 @@ void SwXMLTextImportHelper::RedlineSetCursor(
void SwXMLTextImportHelper::RedlineAdjustStartNodeCursor()
{
OUString rId = GetOpenRedlineId();
- if ((nullptr != pRedlineHelper) && !rId.isEmpty())
+ if ((nullptr != m_pRedlineHelper) && !rId.isEmpty())
{
- pRedlineHelper->AdjustStartNodeCursor(rId);
+ m_pRedlineHelper->AdjustStartNodeCursor(rId);
ResetOpenRedlineId();
}
// else: ignore redline (wasn't added before, or no open redline ID
@@ -1022,21 +977,21 @@ void SwXMLTextImportHelper::RedlineAdjustStartNodeCursor()
void SwXMLTextImportHelper::SetShowChanges( bool bShowChanges )
{
- if ( nullptr != pRedlineHelper )
- pRedlineHelper->SetShowChanges( bShowChanges );
+ if ( nullptr != m_pRedlineHelper )
+ m_pRedlineHelper->SetShowChanges( bShowChanges );
}
void SwXMLTextImportHelper::SetRecordChanges( bool bRecordChanges )
{
- if ( nullptr != pRedlineHelper )
- pRedlineHelper->SetRecordChanges( bRecordChanges );
+ if ( nullptr != m_pRedlineHelper )
+ m_pRedlineHelper->SetRecordChanges( bRecordChanges );
}
void SwXMLTextImportHelper::SetChangesProtectionKey(
const Sequence<sal_Int8> & rKey )
{
- if ( nullptr != pRedlineHelper )
- pRedlineHelper->SetProtectionKey( rKey );
+ if ( nullptr != m_pRedlineHelper )
+ m_pRedlineHelper->SetProtectionKey( rKey );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/xml/xmltexti.hxx b/sw/source/filter/xml/xmltexti.hxx
index 067472e5a98f..886ce4c7ac1c 100644
--- a/sw/source/filter/xml/xmltexti.hxx
+++ b/sw/source/filter/xml/xmltexti.hxx
@@ -26,7 +26,7 @@ class SvXMLImport;
class SwXMLTextImportHelper : public XMLTextImportHelper
{
- XMLRedlineImportHelper *pRedlineHelper;
+ XMLRedlineImportHelper *m_pRedlineHelper;
protected:
virtual SvXMLImportContext *CreateTableChildContext(
@@ -37,7 +37,7 @@ protected:
public:
SwXMLTextImportHelper(
const css::uno::Reference<css::frame::XModel>& rModel,
- SvXMLImport& rImport,
+ SwXMLImport& rImport,
const css::uno::Reference<css::beans::XPropertySet>& rInfoSet,
bool bInsertM, bool bStylesOnlyM,
bool bBlockM, bool bOrganizerM );
@@ -90,6 +90,7 @@ public:
const OUString& rAuthor, /// name of the author
const OUString& rComment, /// redline comment
const css::util::DateTime& rDateTime, /// date+time
+ const OUString& rMovedID, /// redline move id, to find moveFrom/MoveTo parts
bool bMergeLastPara) override; /// merge last paragraph
virtual css::uno::Reference<css::text::XTextCursor> RedlineCreateText(
css::uno::Reference<css::text::XTextCursor> & rOldCursor, /// needed to get the document
diff --git a/sw/source/filter/xml/zorder.hxx b/sw/source/filter/xml/zorder.hxx
new file mode 100644
index 000000000000..11cf17ef9c5d
--- /dev/null
+++ b/sw/source/filter/xml/zorder.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#pragma once
+
+#include <IDocumentDrawModelAccess.hxx>
+
+#include <o3tl/any.hxx>
+#include <o3tl/unreachable.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+
+namespace sw
+{
+struct GetZOrderLayer
+{
+ GetZOrderLayer(IDocumentDrawModelAccess const& rIDDMA)
+ : m_nHeavenId(rIDDMA.GetHeavenId().get())
+ , m_nHellId(rIDDMA.GetHellId().get())
+ , m_nControlsId(rIDDMA.GetControlsId().get())
+ , m_nInvisibleHeavenId(rIDDMA.GetInvisibleHeavenId().get())
+ , m_nInvisibleHellId(rIDDMA.GetInvisibleHellId().get())
+ , m_nInvisibleControlsId(rIDDMA.GetInvisibleControlsId().get())
+ {
+ }
+
+ auto operator()(css::uno::Reference<css::beans::XPropertySet> const& xShape) -> unsigned int
+ {
+ sal_Int16 nLayerID(0);
+ if (xShape->getPropertySetInfo()->hasPropertyByName("LayerID"))
+ {
+ xShape->getPropertyValue("LayerID") >>= nLayerID;
+ if (nLayerID == m_nHellId || nLayerID == m_nInvisibleHellId)
+ {
+ return 0;
+ }
+ else if (nLayerID == m_nHeavenId || nLayerID == m_nInvisibleHeavenId)
+ {
+ return 1;
+ }
+ else if (nLayerID == m_nControlsId || nLayerID == m_nInvisibleControlsId)
+ {
+ return 2;
+ }
+ O3TL_UNREACHABLE;
+ }
+ else // SwXFrame only has "Opaque"
+ {
+ if (*o3tl::doAccess<bool>(xShape->getPropertyValue("Opaque")))
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ }
+
+private:
+ sal_Int16 m_nHeavenId;
+ sal_Int16 m_nHellId;
+ sal_Int16 m_nControlsId;
+ sal_Int16 m_nInvisibleHeavenId;
+ sal_Int16 m_nInvisibleHellId;
+ sal_Int16 m_nInvisibleControlsId;
+};
+
+} // namespace sw
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */