Bug Summary

File:home/maarten/src/libreoffice/core/sw/inc/ring.hxx
Warning:line 85, column 19
Use of memory after it is freed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name docnew.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -isystem /usr/include/libxml2 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D SW_DLLIMPLEMENTATION -D SWUI_DLL_NAME="libswuilo.so" -D SYSTEM_LIBXML -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/i18n -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/common -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/sw/source/core/inc -I /home/maarten/src/libreoffice/core/sw/source/filter/inc -I /home/maarten/src/libreoffice/core/sw/source/uibase/inc -I /home/maarten/src/libreoffice/core/sw/inc -I /home/maarten/src/libreoffice/core/workdir/SdiTarget/sw/sdi -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/sw/generated -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/oovbaapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx

/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx

1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <config_features.h>
21
22#include <o3tl/sorted_vector.hxx>
23
24#include <doc.hxx>
25#include <proofreadingiterator.hxx>
26#include <com/sun/star/text/XFlatParagraphIteratorProvider.hpp>
27#include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
28#include <com/sun/star/frame/XModel.hpp>
29#include <com/sun/star/i18n/ScriptType.hpp>
30
31#include <comphelper/processfactory.hxx>
32#include <comphelper/random.hxx>
33#include <sfx2/viewfrm.hxx>
34#include <sfx2/XmlIdRegistry.hxx>
35#include <sal/log.hxx>
36
37#include <sfx2/linkmgr.hxx>
38#include <editeng/ulspitem.hxx>
39#include <editeng/lrspitem.hxx>
40#include <svl/zforlist.hxx>
41#include <unotools/lingucfg.hxx>
42#include <svx/svdpage.hxx>
43#include <fmtcntnt.hxx>
44#include <fmtanchr.hxx>
45#include <fmtfsize.hxx>
46#include <fmtfordr.hxx>
47#include <fmtpdsc.hxx>
48#include <pvprtdat.hxx>
49#include <rootfrm.hxx>
50#include <pagedesc.hxx>
51#include <ndtxt.hxx>
52#include <ftninfo.hxx>
53#include <ftnidx.hxx>
54#include <charfmt.hxx>
55#include <frmfmt.hxx>
56#include <poolfmt.hxx>
57#include <dbmgr.hxx>
58#include <docsh.hxx>
59#include <acorrect.hxx>
60#include <visiturl.hxx>
61#include <docary.hxx>
62#include <lineinfo.hxx>
63#include <drawdoc.hxx>
64#include <extinput.hxx>
65#include <viewsh.hxx>
66#include <doctxm.hxx>
67#include <shellres.hxx>
68#include <laycache.hxx>
69#include <mvsave.hxx>
70#include <istyleaccess.hxx>
71#include "swstylemanager.hxx"
72#include <IGrammarContact.hxx>
73#include <tblafmt.hxx>
74#include <MarkManager.hxx>
75#include <UndoManager.hxx>
76#include <DocumentDeviceManager.hxx>
77#include <DocumentSettingManager.hxx>
78#include <DocumentDrawModelManager.hxx>
79#include <DocumentChartDataProviderManager.hxx>
80#include <DocumentTimerManager.hxx>
81#include <DocumentLinksAdministrationManager.hxx>
82#include <DocumentListItemsManager.hxx>
83#include <DocumentListsManager.hxx>
84#include <DocumentOutlineNodesManager.hxx>
85#include <DocumentContentOperationsManager.hxx>
86#include <DocumentRedlineManager.hxx>
87#include <DocumentFieldsManager.hxx>
88#include <DocumentStatisticsManager.hxx>
89#include <DocumentStateManager.hxx>
90#include <DocumentLayoutManager.hxx>
91#include <DocumentStylePoolManager.hxx>
92#include <DocumentExternalDataManager.hxx>
93#include <wrtsh.hxx>
94#include <unocrsr.hxx>
95#include <fmthdft.hxx>
96#include <frameformats.hxx>
97
98#include <numrule.hxx>
99
100#include <sfx2/Metadatable.hxx>
101#include <fmtmeta.hxx>
102
103#include <svx/xfillit0.hxx>
104#include <unotools/configmgr.hxx>
105#include <i18nlangtag/mslangid.hxx>
106#include <editeng/langitem.hxx>
107
108using namespace ::com::sun::star;
109using namespace ::com::sun::star::document;
110
111/*
112 * global functions...
113 */
114 uno::Reference< linguistic2::XProofreadingIterator > const & SwDoc::GetGCIterator() const
115{
116 if (!m_xGCIterator.is() && SvtLinguConfig().HasGrammarChecker())
117 {
118 uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
119 try
120 {
121 m_xGCIterator = sw::proofreadingiterator::get( xContext );
122 }
123 catch (const uno::Exception &)
124 {
125 OSL_FAIL( "No GCIterator" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "125" ": "), "%s", "No GCIterator"); } } while (false)
;
126 }
127 }
128
129 return m_xGCIterator;
130}
131
132bool SwDoc::StartGrammarChecking( bool bSkipStart )
133{
134 // check for a visible view
135 bool bVisible = false;
136 bool bStarted = false;
137 const SwDocShell *pDocShell = GetDocShell();
138 SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocShell, false );
139 while (pFrame && !bVisible)
140 {
141 if (pFrame->IsVisible())
142 bVisible = true;
143 pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, false );
144 }
145
146 //!! only documents with visible views need to be checked
147 //!! (E.g. don't check temporary documents created for printing, see printing of notes and selections.
148 //!! Those get created on the fly and get hard deleted a bit later as well, and no one should have
149 //!! a UNO reference to them)
150 if (bVisible)
151 {
152 uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( GetGCIterator() );
153 if ( xGCIterator.is() )
154 {
155 uno::Reference< lang::XComponent > xDoc = GetDocShell()->GetBaseModel();
156 uno::Reference< text::XFlatParagraphIteratorProvider > xFPIP( xDoc, uno::UNO_QUERY );
157
158 // start automatic background checking if not active already
159 if ( xFPIP.is() && !xGCIterator->isProofreading( xDoc ) )
160 {
161 bStarted = true;
162 if ( !bSkipStart )
163 {
164 for (auto pLayout : GetAllLayouts())
165 { // we're starting it now, don't start grammar checker
166 // again until the user modifies the document
167 pLayout->SetNeedGrammarCheck(false);
168 }
169 xGCIterator->startProofreading( xDoc, xFPIP );
170 }
171 }
172 }
173 }
174
175 return bStarted;
176}
177
178/*
179 * internal functions
180 */
181static void lcl_DelFormatIndices( SwFormat const * pFormat )
182{
183 SwFormatContent &rFormatContent = const_cast<SwFormatContent&>(pFormat->GetContent());
184 if ( rFormatContent.GetContentIdx() )
185 rFormatContent.SetNewContentIdx( nullptr );
186 SwFormatAnchor &rFormatAnchor = const_cast<SwFormatAnchor&>(pFormat->GetAnchor());
187 if ( rFormatAnchor.GetContentAnchor() )
188 rFormatAnchor.SetAnchor( nullptr );
189}
190
191/*
192 * exported methods
193 */
194SwDoc::SwDoc()
195 : m_pNodes(new SwNodes(*this)),
196 mpAttrPool(new SwAttrPool(this)),
197 mpMarkManager(new ::sw::mark::MarkManager(*this)),
198 m_pMetaFieldManager(new ::sw::MetaFieldManager()),
199 m_pDocumentDrawModelManager( new ::sw::DocumentDrawModelManager( *this ) ),
200 m_pDocumentRedlineManager( new ::sw::DocumentRedlineManager( *this ) ),
201 m_pDocumentStateManager( new ::sw::DocumentStateManager( *this ) ),
202 m_pUndoManager(new ::sw::UndoManager(
203 std::shared_ptr<SwNodes>(new SwNodes(*this)), *m_pDocumentDrawModelManager, *m_pDocumentRedlineManager, *m_pDocumentStateManager)),
204 m_pDocumentSettingManager(new ::sw::DocumentSettingManager(*this)),
205 m_pDocumentChartDataProviderManager( new sw::DocumentChartDataProviderManager( *this ) ),
206 m_pDeviceAccess( new ::sw::DocumentDeviceManager( *this ) ),
207 m_pDocumentTimerManager( new ::sw::DocumentTimerManager( *this ) ),
208 m_pDocumentLinksAdministrationManager( new ::sw::DocumentLinksAdministrationManager( *this ) ),
209 m_pDocumentListItemsManager( new ::sw::DocumentListItemsManager() ),
210 m_pDocumentListsManager( new ::sw::DocumentListsManager( *this ) ),
211 m_pDocumentOutlineNodesManager( new ::sw::DocumentOutlineNodesManager( *this ) ),
212 m_pDocumentContentOperationsManager( new ::sw::DocumentContentOperationsManager( *this ) ),
213 m_pDocumentFieldsManager( new ::sw::DocumentFieldsManager( *this ) ),
214 m_pDocumentStatisticsManager( new ::sw::DocumentStatisticsManager( *this ) ),
215 m_pDocumentLayoutManager( new ::sw::DocumentLayoutManager( *this ) ),
216 m_pDocumentStylePoolManager( new ::sw::DocumentStylePoolManager( *this ) ),
217 m_pDocumentExternalDataManager( new ::sw::DocumentExternalDataManager ),
218 mpDfltFrameFormat( new SwFrameFormat( GetAttrPool(), "Frameformat", nullptr ) ),
219 mpEmptyPageFormat( new SwFrameFormat( GetAttrPool(), "Empty Page", mpDfltFrameFormat.get() ) ),
220 mpColumnContFormat( new SwFrameFormat( GetAttrPool(), "Columncontainer", mpDfltFrameFormat.get() ) ),
221 mpDfltCharFormat( new SwCharFormat( GetAttrPool(), "Character style", nullptr ) ),
222 mpDfltTextFormatColl( new SwTextFormatColl( GetAttrPool(), "Paragraph style" ) ),
223 mpDfltGrfFormatColl( new SwGrfFormatColl( GetAttrPool(), "Graphikformatvorlage" ) ),
224 mpFrameFormatTable( new SwFrameFormats() ),
225 mpCharFormatTable( new SwCharFormats ),
226 mpSpzFrameFormatTable( new SwFrameFormats() ),
227 mpSectionFormatTable( new SwSectionFormats ),
228 mpTableFrameFormatTable( new SwFrameFormats() ),
229 mpTextFormatCollTable( new SwTextFormatColls() ),
230 mpGrfFormatCollTable( new SwGrfFormatColls() ),
231 mpTOXTypes( new SwTOXTypes ),
232 mpDefTOXBases( new SwDefTOXBase_Impl() ),
233 mpOutlineRule( nullptr ),
234 mpFootnoteInfo( new SwFootnoteInfo ),
235 mpEndNoteInfo( new SwEndNoteInfo ),
236 mpLineNumberInfo( new SwLineNumberInfo ),
237 mpFootnoteIdxs( new SwFootnoteIdxs ),
238 mpDocShell( nullptr ),
239 mpNumberFormatter( nullptr ),
240 mpNumRuleTable( new SwNumRuleTable ),
241 mpExtInputRing( nullptr ),
242 mpGrammarContact(createGrammarContact()),
243 mpCellStyles(new SwCellStyleTable),
244 m_pXmlIdRegistry(),
245 mReferenceCount(0),
246 mbDtor(false),
247 mbCopyIsMove(false),
248 mbInReading(false),
249 mbInWriting(false),
250 mbInMailMerge(false),
251 mbInXMLImport(false),
252 mbInWriterfilterImport(false),
253 mbUpdateTOX(false),
254 mbInLoadAsynchron(false),
255 mbIsAutoFormatRedline(false),
256 mbOLEPrtNotifyPending(false),
257 mbAllOLENotify(false),
258 mbInsOnlyTextGlssry(false),
259 mbContains_MSVBasic(false),
260 mbClipBoard( false ),
261 mbColumnSelection( false ),
262 mbIsPrepareSelAll(false),
263 meDictionaryMissing( MissingDictionary::Undefined ),
264 mbContainsAtPageObjWithContentAnchor(false), //#i119292#, fdo#37024
265
266 meDocType(DOCTYPE_NATIVE)
267{
268 // The DrawingLayer ItemPool which is used as 2nd pool for Writer documents' pool
269 // has a default for the XFillStyleItem of XFILL_SOLID and the color for it is the default
270 // fill color (blue7 or similar). This is a problem, in Writer we want the default fill
271 // style to be drawing::FillStyle_NONE. This cannot simply be done by changing it in the 2nd pool at the
272 // pool defaults when the DrawingLayer ItemPool is used for Writer, that would lead to
273 // countless problems like DrawObjects initial fill and others.
274 // It is also hard to find all places where the initial ItemSets for Writer (including
275 // style hierarchies) are created and to always set (but only at the root) the FillStyle
276 // to NONE fixed; that will add that attribute to the file format. It will be hard to reset
277 // attribute sets (which is done at import and using UI). Also not a good solution.
278 // Luckily Writer uses pDfltTextFormatColl as default parent for all paragraphs and similar, thus
279 // it is possible to set this attribute here. It will be not reset when importing.
280 mpDfltTextFormatColl->SetFormatAttr(XFillStyleItem(drawing::FillStyle_NONE));
281 mpDfltFrameFormat->SetFormatAttr(XFillStyleItem(drawing::FillStyle_NONE));
282 // prevent paragraph default margins being applied to everything
283 mpDfltFrameFormat->SetFormatAttr(SvxULSpaceItem(RES_UL_SPACE));
284 mpDfltFrameFormat->SetFormatAttr(SvxLRSpaceItem(RES_LR_SPACE));
285
286 /*
287 * DefaultFormats and DefaultFormatCollections (FormatColl)
288 * are inserted at position 0 at the respective array.
289 * The formats in the FormatColls are derived from the
290 * DefaultFormats and are also in the list.
291 */
292 /* Formats */
293 mpFrameFormatTable->push_back(mpDfltFrameFormat.get());
294 mpCharFormatTable->push_back(mpDfltCharFormat.get());
295
296 /* FormatColls */
297 // TXT
298 mpTextFormatCollTable->push_back(mpDfltTextFormatColl.get());
299 // GRF
300 mpGrfFormatCollTable->push_back(mpDfltGrfFormatColl.get());
301
302 // Create PageDesc, EmptyPageFormat and ColumnFormat
303 if (m_PageDescs.empty())
304 getIDocumentStylePoolAccess().GetPageDescFromPool( RES_POOLPAGE_STANDARD );
305
306 // Set to "Empty Page"
307 mpEmptyPageFormat->SetFormatAttr( SwFormatFrameSize( SwFrameSize::Fixed ) );
308 // Set BodyFormat for columns
309 mpColumnContFormat->SetFormatAttr( SwFormatFillOrder( ATT_LEFT_TO_RIGHT ) );
310
311 GetDocumentFieldsManager().InitFieldTypes();
312
313 // Create a default OutlineNumRule (for Filters)
314 mpOutlineRule = new SwNumRule( SwNumRule::GetOutlineRuleName(),
315 // #i89178#
316 numfunc::GetDefaultPositionAndSpaceMode(),
317 OUTLINE_RULE );
318 AddNumRule(mpOutlineRule);
319 // Counting of phantoms depends on <IsOldNumbering()>
320 mpOutlineRule->SetCountPhantoms( !GetDocumentSettingManager().get(DocumentSettingId::OLD_NUMBERING) );
321
322 new SwTextNode(
323 SwNodeIndex(GetUndoManager().GetUndoNodes().GetEndOfContent()),
324 mpDfltTextFormatColl.get() );
325 new SwTextNode( SwNodeIndex( GetNodes().GetEndOfContent() ),
326 getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_STANDARD ));
327
328 maOLEModifiedIdle.SetPriority( TaskPriority::LOWEST );
329 maOLEModifiedIdle.SetInvokeHandler( LINK( this, SwDoc, DoUpdateModifiedOLE )::tools::detail::makeLink( ::tools::detail::castTo<SwDoc *
>(this), &SwDoc::LinkStubDoUpdateModifiedOLE)
);
330 maOLEModifiedIdle.SetDebugName( "sw::SwDoc maOLEModifiedIdle" );
331
332#if HAVE_FEATURE_DBCONNECTIVITY1
333 // Create DBManager
334 m_pOwnDBManager.reset(new SwDBManager(this));
335 m_pDBManager = m_pOwnDBManager.get();
336#else
337 m_pDBManager = nullptr;
338#endif
339
340 // create TOXTypes
341 InitTOXTypes();
342
343 // pass empty item set containing the paragraph's list attributes
344 // as ignorable items to the stype manager.
345 {
346 SfxItemSet aIgnorableParagraphItems( GetAttrPool(), svl::Items<RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1>{});
347 mpStyleAccess = createStyleManager( &aIgnorableParagraphItems );
348 }
349
350 static bool bHack = (getenv("LIBO_ONEWAY_STABLE_ODF_EXPORT") != nullptr);
351
352 if (bHack)
353 {
354 mnRsid = 0;
355 }
356 else
357 {
358 // Initialize the session id of the current document to a random number
359 // smaller than 2^21.
360 mnRsid = comphelper::rng::uniform_uint_distribution(1, (1 << 21) - 1);
361 }
362 mnRsidRoot = mnRsid;
363
364 if (!utl::ConfigManager::IsFuzzing())
365 {
366 // Make sure that in case the document language is not set, then we don't return
367 // LANGUAGE_DONTKNOW, but the UI locale.
368 const SvtLinguConfig aLinguConfig;
369 SvtLinguOptions aOptions;
370 aLinguConfig.GetOptions(aOptions);
371 LanguageType eLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage,
372 i18n::ScriptType::LATIN);
373 SetLanguage(eLang, RES_CHRATR_LANGUAGE);
374 eLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK,
375 i18n::ScriptType::ASIAN);
376 SetLanguage(eLang, RES_CHRATR_CJK_LANGUAGE);
377 eLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL,
378 i18n::ScriptType::COMPLEX);
379 SetLanguage(eLang, RES_CHRATR_CTL_LANGUAGE);
380 }
381
382 getIDocumentState().ResetModified();
383}
384
385/**
386 * Speciality: a member of the class SwDoc is located at
387 * position 0 in the array of the Format and GDI objects.
388 * This MUST not be destroyed using 'delete' in any case!
389 */
390SwDoc::~SwDoc()
391{
392 // nothing here should create Undo actions!
393 GetIDocumentUndoRedo().DoUndo(false);
394
395 if (mpDocShell)
1
Assuming field 'mpDocShell' is null
2
Taking false branch
396 {
397 mpDocShell->SetUndoManager(nullptr);
398 }
399
400 mpGrammarContact.reset();
401
402 getIDocumentTimerAccess().StopIdling(); // stop idle timer
403
404 mpURLStateChgd.reset();
405
406 // Deactivate Undo notification from Draw
407 if( GetDocumentDrawModelManager().GetDrawModel() )
3
Assuming the condition is false
4
Taking false branch
408 {
409 GetDocumentDrawModelManager().DrawNotifyUndoHdl();
410 ClrContourCache();
411 }
412
413 m_pPgPViewPrtData.reset();
414
415 mbDtor = true;
416
417 //Clear the redline table before the nodes array is destroyed
418 getIDocumentRedlineAccess().GetRedlineTable().DeleteAndDestroyAll();
419 getIDocumentRedlineAccess().GetExtraRedlineTable().DeleteAndDestroyAll();
420
421 const sw::UnoCursorHint aHint;
422 cleanupUnoCursorTable();
423 for(const auto& pWeakCursor : mvUnoCursorTable)
424 {
425 auto pCursor(pWeakCursor.lock());
426 if(pCursor)
427 pCursor->m_aNotifier.Broadcast(aHint);
428 }
429 mpACEWord.reset();
430
431 // Release the BaseLinks
432 {
433 ::sfx2::SvLinkSources aTemp(getIDocumentLinksAdministration().GetLinkManager().GetServers());
434 for( const auto& rpLinkSrc : aTemp )
435 rpLinkSrc->Closed();
436
437 if( !getIDocumentLinksAdministration().GetLinkManager().GetLinks().empty() )
5
Assuming the condition is false
6
Taking false branch
438 getIDocumentLinksAdministration().GetLinkManager().Remove( 0, getIDocumentLinksAdministration().GetLinkManager().GetLinks().size() );
439 }
440
441 // The ChapterNumbers/Numbers need to be deleted before the styles
442 // or we update all the time!
443 m_pNodes->m_pOutlineNodes->clear();
444 SwNodes & rUndoNodes( GetUndoManager().GetUndoNodes() );
445 rUndoNodes.m_pOutlineNodes->clear();
446
447 mpFootnoteIdxs->clear();
448
449 // indices could be registered in attributes
450 m_pUndoManager->DelAllUndoObj();
451
452 // The BookMarks contain indices to the Content. These must be deleted
453 // before deleting the Nodes.
454 mpMarkManager->clearAllMarks();
455
456 if( mpExtInputRing )
7
Assuming field 'mpExtInputRing' is non-null
8
Taking true branch
457 {
458 SwPaM* pTmp = mpExtInputRing;
459 mpExtInputRing = nullptr;
460 while( pTmp->GetNext() != pTmp )
9
Assuming the condition is true
10
Loop condition is true. Entering loop body
12
Calling 'SwPaM::GetNext'
461 delete pTmp->GetNext();
11
Memory is released
462 delete pTmp;
463 }
464
465 // Old - deletion without a Flag is expensive, because we send a Modify
466 // aTOXTypes.DeleteAndDestroy( 0, aTOXTypes.Count() );
467 {
468 for( auto n = mpTOXTypes->size(); n; )
469 {
470 (*mpTOXTypes)[ --n ]->SetInDocDTOR();
471 (*mpTOXTypes)[ n ].reset();
472 }
473 mpTOXTypes->clear();
474 }
475 mpDefTOXBases.reset();
476
477 // Any of the FrameFormats can still have indices registered.
478 // These need to be destroyed now at the latest.
479 for( SwFrameFormat* pFormat : *mpFrameFormatTable )
480 lcl_DelFormatIndices( pFormat );
481 for( SwFrameFormat* pFormat : *mpSpzFrameFormatTable )
482 lcl_DelFormatIndices( pFormat );
483 for( SwSectionFormat* pFormat : *mpSectionFormatTable )
484 lcl_DelFormatIndices( pFormat );
485
486 // The formats/styles that follow depend on the default formats.
487 // Destroy these only after destroying the FormatIndices, because the content
488 // of headers/footers has to be deleted as well. If in the headers/footers
489 // there are still Flys registered at that point, we have a problem.
490 for( SwPageDesc *pPageDesc : m_PageDescs )
491 delete pPageDesc;
492 m_PageDescs.clear();
493
494 // Delete content selections.
495 // Don't wait for the SwNodes dtor to destroy them; so that Formats
496 // do not have any dependencies anymore.
497 m_pNodes->DelNodes( SwNodeIndex(*m_pNodes), m_pNodes->Count() );
498 rUndoNodes.DelNodes( SwNodeIndex( rUndoNodes ), rUndoNodes.Count() );
499
500 // Delete Formats, make it permanent some time in the future
501
502 // Delete for Collections
503 // So that we get rid of the dependencies
504 mpFootnoteInfo->EndListeningAll();
505 mpEndNoteInfo->EndListeningAll();
506
507 assert(mpDfltTextFormatColl.get() == (*mpTextFormatCollTable)[0](static_cast <bool> (mpDfltTextFormatColl.get() == (*mpTextFormatCollTable
)[0] && "Default-Text-Collection must always be at the start"
) ? void (0) : __assert_fail ("mpDfltTextFormatColl.get() == (*mpTextFormatCollTable)[0] && \"Default-Text-Collection must always be at the start\""
, "/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
, 508, __extension__ __PRETTY_FUNCTION__))
508 && "Default-Text-Collection must always be at the start")(static_cast <bool> (mpDfltTextFormatColl.get() == (*mpTextFormatCollTable
)[0] && "Default-Text-Collection must always be at the start"
) ? void (0) : __assert_fail ("mpDfltTextFormatColl.get() == (*mpTextFormatCollTable)[0] && \"Default-Text-Collection must always be at the start\""
, "/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
, 508, __extension__ __PRETTY_FUNCTION__))
;
509
510 // Optimization: Based on the fact that Standard is always 2nd in the
511 // array, we should delete it as the last. With this we avoid
512 // reparenting the Formats all the time!
513 if( 2 < mpTextFormatCollTable->size() )
514 mpTextFormatCollTable->DeleteAndDestroy(2, mpTextFormatCollTable->size());
515 mpTextFormatCollTable->DeleteAndDestroy(1, mpTextFormatCollTable->size());
516 mpTextFormatCollTable.reset();
517
518 assert(mpDfltGrfFormatColl.get() == (*mpGrfFormatCollTable)[0](static_cast <bool> (mpDfltGrfFormatColl.get() == (*mpGrfFormatCollTable
)[0] && "DefaultGrfCollection must always be at the start"
) ? void (0) : __assert_fail ("mpDfltGrfFormatColl.get() == (*mpGrfFormatCollTable)[0] && \"DefaultGrfCollection must always be at the start\""
, "/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
, 519, __extension__ __PRETTY_FUNCTION__))
519 && "DefaultGrfCollection must always be at the start")(static_cast <bool> (mpDfltGrfFormatColl.get() == (*mpGrfFormatCollTable
)[0] && "DefaultGrfCollection must always be at the start"
) ? void (0) : __assert_fail ("mpDfltGrfFormatColl.get() == (*mpGrfFormatCollTable)[0] && \"DefaultGrfCollection must always be at the start\""
, "/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
, 519, __extension__ __PRETTY_FUNCTION__))
;
520
521 mpGrfFormatCollTable->DeleteAndDestroy(1, mpGrfFormatCollTable->size());
522 mpGrfFormatCollTable.reset();
523
524 // Without explicitly freeing the DocumentDeviceManager
525 // and relying on the implicit freeing there would be a crash
526 // due to it happening after SwAttrPool is freed.
527 m_pDeviceAccess.reset();
528
529 /*
530 * DefaultFormats and DefaultFormatCollections (FormatColl)
531 * are at position 0 of their respective arrays.
532 * In order to not be deleted by the array's dtor, we remove them
533 * now.
534 */
535 mpFrameFormatTable->erase( mpFrameFormatTable->begin() );
536 mpCharFormatTable->erase( mpCharFormatTable->begin() );
537
538#if HAVE_FEATURE_DBCONNECTIVITY1
539 // On load, SwDBManager::setEmbeddedName() may register a data source.
540 // If we have an embedded one, then sDataSource points to the registered name, so revoke it here.
541 if (!m_pOwnDBManager->getEmbeddedName().isEmpty() && !maDBData.sDataSource.isEmpty())
542 {
543 // Remove the revoke listener here first, so that we don't remove the data source from the document.
544 m_pOwnDBManager->releaseRevokeListener();
545 SwDBManager::RevokeDataSource(maDBData.sDataSource);
546 SwDBManager::RevokeDataSource(m_pOwnDBManager->getEmbeddedName());
547 }
548 else if (!m_pOwnDBManager->getEmbeddedName().isEmpty())
549 {
550 // Remove the revoke listener here first, so that we don't remove the data source from the document.
551 m_pOwnDBManager->releaseRevokeListener();
552 // Remove connections which was committed but not used.
553 m_pOwnDBManager->RevokeNotUsedConnections();
554 }
555
556 m_pOwnDBManager.reset();
557#endif
558
559 // All Flys need to be destroyed before the Drawing Model,
560 // because Flys can still contain DrawContacts, when no
561 // Layout could be constructed due to a read error.
562 mpSpzFrameFormatTable->DeleteAndDestroyAll();
563
564 // Only now destroy the Model, the drawing objects - which are also
565 // contained in the Undo - need to remove their attributes from the
566 // Model. Also, DrawContacts could exist before this.
567 GetDocumentDrawModelManager().ReleaseDrawModel();
568 // Destroy DrawModel before the LinkManager, because it's always set
569 // in the DrawModel.
570 //The LinkManager gets destroyed automatically with m_pLinksAdministrationManager
571
572 // Clear the Tables before deleting the defaults, or we crash due to
573 // dependencies on defaults.
574 mpFrameFormatTable.reset();
575 mpSpzFrameFormatTable.reset();
576
577 mpStyleAccess.reset();
578
579 mpCharFormatTable.reset();
580 mpSectionFormatTable.reset();
581 mpTableFrameFormatTable.reset();
582 mpDfltTextFormatColl.reset();
583 mpDfltGrfFormatColl.reset();
584 mpNumRuleTable.reset();
585
586 disposeXForms(); // #i113606#, dispose the XForms objects
587
588 delete mpNumberFormatter.load(); mpNumberFormatter= nullptr;
589 mpFootnoteInfo.reset();
590 mpEndNoteInfo.reset();
591 mpLineNumberInfo.reset();
592 mpFootnoteIdxs.reset();
593 mpTOXTypes.reset();
594 mpEmptyPageFormat.reset();
595 mpColumnContFormat.reset();
596 mpDfltCharFormat.reset();
597 mpDfltFrameFormat.reset();
598 mpLayoutCache.reset();
599
600 SfxItemPool::Free(mpAttrPool);
601}
602
603void SwDoc::SetDocShell( SwDocShell* pDSh )
604{
605 if( mpDocShell == pDSh )
606 return;
607
608 if (mpDocShell)
609 {
610 mpDocShell->SetUndoManager(nullptr);
611 }
612 mpDocShell = pDSh;
613 if (mpDocShell)
614 {
615 mpDocShell->SetUndoManager(& GetUndoManager());
616 GetUndoManager().SetDocShell(mpDocShell);
617 }
618
619 getIDocumentLinksAdministration().GetLinkManager().SetPersist( mpDocShell );
620
621 // set DocShell pointer also on DrawModel
622 InitDrawModelAndDocShell(mpDocShell, GetDocumentDrawModelManager().GetDrawModel());
623 assert(!GetDocumentDrawModelManager().GetDrawModel() ||(static_cast <bool> (!GetDocumentDrawModelManager().GetDrawModel
() || GetDocumentDrawModelManager().GetDrawModel()->GetPersist
() == GetPersist()) ? void (0) : __assert_fail ("!GetDocumentDrawModelManager().GetDrawModel() || GetDocumentDrawModelManager().GetDrawModel()->GetPersist() == GetPersist()"
, "/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
, 624, __extension__ __PRETTY_FUNCTION__))
624 GetDocumentDrawModelManager().GetDrawModel()->GetPersist() == GetPersist())(static_cast <bool> (!GetDocumentDrawModelManager().GetDrawModel
() || GetDocumentDrawModelManager().GetDrawModel()->GetPersist
() == GetPersist()) ? void (0) : __assert_fail ("!GetDocumentDrawModelManager().GetDrawModel() || GetDocumentDrawModelManager().GetDrawModel()->GetPersist() == GetPersist()"
, "/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
, 624, __extension__ __PRETTY_FUNCTION__))
;
625}
626
627// Convenience method; to avoid excessive includes from docsh.hxx
628uno::Reference < embed::XStorage > SwDoc::GetDocStorage()
629{
630 if( mpDocShell )
631 return mpDocShell->GetStorage();
632 if( getIDocumentLinksAdministration().GetLinkManager().GetPersist() )
633 return getIDocumentLinksAdministration().GetLinkManager().GetPersist()->GetStorage();
634 return nullptr;
635}
636
637SfxObjectShell* SwDoc::GetPersist() const
638{
639 return mpDocShell ? mpDocShell : getIDocumentLinksAdministration().GetLinkManager().GetPersist();
640}
641
642void SwDoc::ClearDoc()
643{
644 GetIDocumentUndoRedo().DelAllUndoObj();
645 ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
646
647 // Deactivate Undo notification from Draw
648 if( GetDocumentDrawModelManager().GetDrawModel() )
649 {
650 GetDocumentDrawModelManager().DrawNotifyUndoHdl();
651 ClrContourCache();
652 }
653
654 // if there are still FlyFrames dangling around, delete them too
655 while ( !mpSpzFrameFormatTable->empty() )
656 getIDocumentLayoutAccess().DelLayoutFormat((*mpSpzFrameFormatTable)[mpSpzFrameFormatTable->size()-1]);
657 assert(!GetDocumentDrawModelManager().GetDrawModel()(static_cast <bool> (!GetDocumentDrawModelManager().GetDrawModel
() || !GetDocumentDrawModelManager().GetDrawModel()->GetPage
(0)->GetObjCount()) ? void (0) : __assert_fail ("!GetDocumentDrawModelManager().GetDrawModel() || !GetDocumentDrawModelManager().GetDrawModel()->GetPage(0)->GetObjCount()"
, "/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
, 658, __extension__ __PRETTY_FUNCTION__))
658 || !GetDocumentDrawModelManager().GetDrawModel()->GetPage(0)->GetObjCount())(static_cast <bool> (!GetDocumentDrawModelManager().GetDrawModel
() || !GetDocumentDrawModelManager().GetDrawModel()->GetPage
(0)->GetObjCount()) ? void (0) : __assert_fail ("!GetDocumentDrawModelManager().GetDrawModel() || !GetDocumentDrawModelManager().GetDrawModel()->GetPage(0)->GetObjCount()"
, "/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
, 658, __extension__ __PRETTY_FUNCTION__))
;
659
660 getIDocumentRedlineAccess().GetRedlineTable().DeleteAndDestroyAll();
661 getIDocumentRedlineAccess().GetExtraRedlineTable().DeleteAndDestroyAll();
662
663 mpACEWord.reset();
664
665 // The BookMarks contain indices to the Content. These must be deleted
666 // before deleting the Nodes.
667 mpMarkManager->clearAllMarks();
668 InitTOXTypes();
669
670 // create a dummy pagedesc for the layout
671 SwPageDesc* pDummyPgDsc = MakePageDesc("?DUMMY?");
672
673 SwNodeIndex aSttIdx( *GetNodes().GetEndOfContent().StartOfSectionNode(), 1 );
674 // create the first one over and over again (without attributes/style etc.
675 SwTextNode* pFirstNd = GetNodes().MakeTextNode( aSttIdx, mpDfltTextFormatColl.get() );
676
677 if( getIDocumentLayoutAccess().GetCurrentViewShell() )
678 {
679 // set the layout to the dummy pagedesc
680 pFirstNd->SetAttr( SwFormatPageDesc( pDummyPgDsc ));
681
682 SwPosition aPos( *pFirstNd, SwIndex( pFirstNd ));
683 SwPaM const tmpPaM(aSttIdx, SwNodeIndex(GetNodes().GetEndOfContent()));
684 ::PaMCorrAbs(tmpPaM, aPos);
685 }
686
687 GetNodes().Delete( aSttIdx,
688 GetNodes().GetEndOfContent().GetIndex() - aSttIdx.GetIndex() );
689
690 // #i62440#
691 // destruction of numbering rules and creation of new outline rule
692 // *after* the document nodes are deleted.
693 mpOutlineRule = nullptr;
694 for( SwNumRule* pNumRule : *mpNumRuleTable )
695 {
696 getIDocumentListsAccess().deleteListForListStyle(pNumRule->GetName());
697 delete pNumRule;
698 }
699 mpNumRuleTable->clear();
700 maNumRuleMap.clear();
701
702 // creation of new outline numbering rule
703 mpOutlineRule = new SwNumRule( SwNumRule::GetOutlineRuleName(),
704 // #i89178#
705 numfunc::GetDefaultPositionAndSpaceMode(),
706 OUTLINE_RULE );
707 AddNumRule(mpOutlineRule);
708 // Counting of phantoms depends on <IsOldNumbering()>
709 mpOutlineRule->SetCountPhantoms( !GetDocumentSettingManager().get(DocumentSettingId::OLD_NUMBERING) );
710
711 // remove the dummy pagedesc from the array and delete all the old ones
712 size_t nDummyPgDsc = 0;
713 if (FindPageDesc(pDummyPgDsc->GetName(), &nDummyPgDsc))
714 m_PageDescs.erase( nDummyPgDsc );
715 for( SwPageDesc *pPageDesc : m_PageDescs )
716 delete pPageDesc;
717 m_PageDescs.clear();
718
719 // Delete for Collections
720 // So that we get rid of the dependencies
721 mpFootnoteInfo->EndListeningAll();
722 mpEndNoteInfo->EndListeningAll();
723
724 // Optimization: Based on the fact that Standard is always 2nd in the
725 // array, we should delete it as the last. With this we avoid
726 // reparenting the Formats all the time!
727 if( 2 < mpTextFormatCollTable->size() )
728 mpTextFormatCollTable->DeleteAndDestroy(2, mpTextFormatCollTable->size());
729 mpTextFormatCollTable->DeleteAndDestroy(1, mpTextFormatCollTable->size());
730 mpGrfFormatCollTable->DeleteAndDestroy(1, mpGrfFormatCollTable->size());
731 mpCharFormatTable->DeleteAndDestroy(1, mpCharFormatTable->size());
732
733 if( getIDocumentLayoutAccess().GetCurrentViewShell() )
734 {
735 // search the FrameFormat of the root frm. This is not allowed to delete
736 mpFrameFormatTable->erase( getIDocumentLayoutAccess().GetCurrentViewShell()->GetLayout()->GetFormat() );
737 mpFrameFormatTable->DeleteAndDestroyAll( true );
738 mpFrameFormatTable->push_back( getIDocumentLayoutAccess().GetCurrentViewShell()->GetLayout()->GetFormat() );
739 }
740 else
741 mpFrameFormatTable->DeleteAndDestroyAll( true );
742
743 GetDocumentFieldsManager().ClearFieldTypes();
744
745 delete mpNumberFormatter.load(); mpNumberFormatter= nullptr;
746
747 getIDocumentStylePoolAccess().GetPageDescFromPool( RES_POOLPAGE_STANDARD );
748 pFirstNd->ChgFormatColl( getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_STANDARD ));
749 nDummyPgDsc = m_PageDescs.size();
750 m_PageDescs.push_back( pDummyPgDsc );
751 // set the layout back to the new standard pagedesc
752 pFirstNd->ResetAllAttr();
753 // delete now the dummy pagedesc
754 DelPageDesc( nDummyPgDsc );
755}
756
757void SwDoc::SetPreviewPrtData( const SwPagePreviewPrtData* pNew )
758{
759 if( pNew )
760 {
761 if (m_pPgPViewPrtData)
762 {
763 *m_pPgPViewPrtData = *pNew;
764 }
765 else
766 {
767 m_pPgPViewPrtData.reset(new SwPagePreviewPrtData(*pNew));
768 }
769 }
770 else if (m_pPgPViewPrtData)
771 {
772 m_pPgPViewPrtData.reset();
773 }
774 getIDocumentState().SetModified();
775}
776
777void SwDoc::SetOLEObjModified()
778{
779 if( getIDocumentLayoutAccess().GetCurrentViewShell() ) maOLEModifiedIdle.Start();
780}
781
782/** SwDoc: Reading and writing of the layout cache. */
783void SwDoc::ReadLayoutCache( SvStream& rStream )
784{
785 if( !mpLayoutCache )
786 mpLayoutCache.reset( new SwLayoutCache() );
787 if( !mpLayoutCache->IsLocked() )
788 {
789 mpLayoutCache->GetLockCount() |= 0x8000;
790 mpLayoutCache->Read( rStream );
791 mpLayoutCache->GetLockCount() &= 0x7fff;
792 }
793}
794
795void SwDoc::WriteLayoutCache( SvStream& rStream )
796{
797 SwLayoutCache::Write( rStream, *this );
798}
799
800IGrammarContact* getGrammarContact( const SwTextNode& rTextNode )
801{
802 const SwDoc& rDoc = rTextNode.GetDoc();
803 if (rDoc.IsInDtor())
804 return nullptr;
805 return rDoc.getGrammarContact();
806}
807
808::sfx2::IXmlIdRegistry&
809SwDoc::GetXmlIdRegistry()
810{
811 // UGLY: this relies on SetClipBoard being called before GetXmlIdRegistry!
812 if (!m_pXmlIdRegistry)
813 {
814 m_pXmlIdRegistry.reset( ::sfx2::createXmlIdRegistry( IsClipBoard() ) );
815 }
816 return *m_pXmlIdRegistry;
817}
818
819void SwDoc::InitTOXTypes()
820{
821 ShellResource* pShellRes = SwViewShell::GetShellRes();
822 SwTOXType * pNew = new SwTOXType(TOX_CONTENT, pShellRes->aTOXContentName );
823 mpTOXTypes->emplace_back( pNew );
824 pNew = new SwTOXType(TOX_INDEX, pShellRes->aTOXIndexName );
825 mpTOXTypes->emplace_back( pNew );
826 pNew = new SwTOXType(TOX_USER, pShellRes->aTOXUserName );
827 mpTOXTypes->emplace_back( pNew );
828 pNew = new SwTOXType(TOX_ILLUSTRATIONS, pShellRes->aTOXIllustrationsName );
829 mpTOXTypes->emplace_back( pNew );
830 pNew = new SwTOXType(TOX_OBJECTS, pShellRes->aTOXObjectsName );
831 mpTOXTypes->emplace_back( pNew );
832 pNew = new SwTOXType(TOX_TABLES, pShellRes->aTOXTablesName );
833 mpTOXTypes->emplace_back( pNew );
834 pNew = new SwTOXType(TOX_AUTHORITIES, pShellRes->aTOXAuthoritiesName );
835 mpTOXTypes->emplace_back( pNew );
836 pNew = new SwTOXType(TOX_CITATION, pShellRes->aTOXCitationName );
837 mpTOXTypes->emplace_back( pNew );
838}
839
840void SwDoc::ReplaceDefaults(const SwDoc& rSource)
841{
842 // copy property defaults
843 const sal_uInt16 aRangeOfDefaults[] =
844 {
845 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
846 RES_CHRATR_BEGIN, RES_CHRATR_END-1,
847 RES_PARATR_BEGIN, RES_PARATR_END-1,
848 RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
849 RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
850 XATTR_START, XATTR_END-1,
851 0
852 };
853
854 SfxItemSet aNewDefaults(GetAttrPool(), aRangeOfDefaults);
855
856 for (auto nRange = 0; aRangeOfDefaults[nRange] != 0; nRange += 2)
857 {
858 for (sal_uInt16 nWhich = aRangeOfDefaults[nRange];
859 nWhich <= aRangeOfDefaults[nRange + 1]; ++nWhich)
860 {
861 const SfxPoolItem& rSourceAttr =
862 rSource.mpAttrPool->GetDefaultItem(nWhich);
863 if (rSourceAttr != mpAttrPool->GetDefaultItem(nWhich))
864 aNewDefaults.Put(rSourceAttr);
865 }
866 }
867
868 if (aNewDefaults.Count())
869 SetDefault(aNewDefaults);
870}
871
872void SwDoc::ReplaceCompatibilityOptions(const SwDoc& rSource)
873{
874 m_pDocumentSettingManager->ReplaceCompatibilityOptions(rSource.GetDocumentSettingManager());
875}
876
877#ifdef DBG_UTIL
878#define CNTNT_DOC( doc ) \
879 ((doc)->GetNodes().GetEndOfContent().GetIndex() - (doc)->GetNodes().GetEndOfExtras().GetIndex() - 2)
880#define CNTNT_IDX( idx ) \
881 ((idx).GetNode().GetIndex() - GetNodes().GetEndOfExtras().GetIndex() - 1)
882#endif
883
884SfxObjectShell* SwDoc::CreateCopy( bool bCallInitNew, bool bEmpty ) const
885{
886 SAL_INFO( "sw.pageframe", "(SwDoc::CreateCopy in" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.pageframe")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "(SwDoc::CreateCopy in"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "886" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "(SwDoc::CreateCopy in"), 0); } else {
::std::ostringstream sal_detail_stream; sal_detail_stream <<
"(SwDoc::CreateCopy in"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "886" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "(SwDoc::CreateCopy in") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "886" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "(SwDoc::CreateCopy in"), 0); } else {
::std::ostringstream sal_detail_stream; sal_detail_stream <<
"(SwDoc::CreateCopy in"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "886" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
887 rtl::Reference<SwDoc> xRet( new SwDoc );
888
889 // we have to use pointer here, since the callee has to decide whether
890 // SfxObjectShellLock or SfxObjectShellRef should be used sometimes the
891 // object will be returned with refcount set to 0 ( if no DoInitNew is done )
892 SfxObjectShell* pRetShell = new SwDocShell( *xRet, SfxObjectCreateMode::STANDARD );
893 if( bCallInitNew )
894 {
895 // it could happen that DoInitNew creates model,
896 // that increases the refcount of the object
897 pRetShell->DoInitNew();
898 }
899
900 xRet->ReplaceDefaults(*this);
901
902 xRet->ReplaceCompatibilityOptions(*this);
903
904 xRet->ReplaceStyles(*this);
905
906 if( !bEmpty )
907 {
908#ifdef DBG_UTIL
909 SAL_INFO( "sw.createcopy", "CC-Nd-Src: " << CNTNT_DOC( this ) )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.createcopy")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "CC-Nd-Src: " <<
CNTNT_DOC( this )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.createcopy"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "909" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "CC-Nd-Src: " << CNTNT_DOC( this
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "CC-Nd-Src: " << CNTNT_DOC( this ); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.createcopy"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "909" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "CC-Nd-Src: " << CNTNT_DOC( this )) == 1) {
::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.createcopy"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "909" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "CC-Nd-Src: " << CNTNT_DOC( this
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "CC-Nd-Src: " << CNTNT_DOC( this ); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.createcopy"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "909" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
910 SAL_INFO( "sw.createcopy", "CC-Nd: " << CNTNT_DOC( xRet ) )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.createcopy")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "CC-Nd: " << CNTNT_DOC
( xRet )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.createcopy"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "910" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "CC-Nd: " << CNTNT_DOC( xRet )),
0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "CC-Nd: " << CNTNT_DOC( xRet ); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.createcopy"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "910" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "CC-Nd: " << CNTNT_DOC( xRet )) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.createcopy"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "910" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "CC-Nd: " << CNTNT_DOC( xRet )),
0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "CC-Nd: " << CNTNT_DOC( xRet ); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.createcopy"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "910" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
911#endif
912 xRet->AppendDoc(*this, 0, bCallInitNew, 0, 0);
913#ifdef DBG_UTIL
914 SAL_INFO( "sw.createcopy", "CC-Nd: " << CNTNT_DOC( xRet ) )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.createcopy")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "CC-Nd: " << CNTNT_DOC
( xRet )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.createcopy"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "914" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "CC-Nd: " << CNTNT_DOC( xRet )),
0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "CC-Nd: " << CNTNT_DOC( xRet ); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.createcopy"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "914" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "CC-Nd: " << CNTNT_DOC( xRet )) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.createcopy"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "914" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "CC-Nd: " << CNTNT_DOC( xRet )),
0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "CC-Nd: " << CNTNT_DOC( xRet ); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.createcopy"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "914" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
915#endif
916 }
917
918 // remove the temporary shell if it is there as it was done before
919 xRet->SetTmpDocShell( nullptr );
920
921 SAL_INFO( "sw.pageframe", "SwDoc::CreateCopy out)" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.pageframe")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "SwDoc::CreateCopy out)"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "921" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwDoc::CreateCopy out)"), 0); } else {
::std::ostringstream sal_detail_stream; sal_detail_stream <<
"SwDoc::CreateCopy out)"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "921" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "SwDoc::CreateCopy out)") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "921" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwDoc::CreateCopy out)"), 0); } else {
::std::ostringstream sal_detail_stream; sal_detail_stream <<
"SwDoc::CreateCopy out)"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "921" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
922 return pRetShell;
923}
924
925// save bulk letters as single documents
926static OUString lcl_FindUniqueName(SwWrtShell* pTargetShell, const OUString& rStartingPageDesc, sal_uLong nDocNo )
927{
928 do
929 {
930 OUString sTest = rStartingPageDesc + OUString::number( nDocNo );
931 if( !pTargetShell->FindPageDescByName( sTest ) )
932 return sTest;
933 ++nDocNo;
934 }
935 while( true );
936}
937
938/** Returns whether the passed SwPageDesc& or any of its (transitive) follows
939 contains a header or footer. */
940static bool lcl_PageDescOrFollowContainsHeaderFooter(const SwPageDesc& rPageDesc)
941{
942 // remember already checked page descs to avoid cycle
943 o3tl::sorted_vector<const SwPageDesc*> aCheckedPageDescs;
944 const SwPageDesc* pCurPageDesc = &rPageDesc;
945 while (aCheckedPageDescs.count(pCurPageDesc) == 0)
946 {
947 const SwFrameFormat& rMaster = pCurPageDesc->GetMaster();
948 if (rMaster.GetHeader().IsActive() || rMaster.GetFooter().IsActive())
949 return true;
950
951 aCheckedPageDescs.insert(pCurPageDesc);
952 pCurPageDesc = pCurPageDesc->GetFollow();
953 }
954 return false;
955}
956
957static void lcl_CopyFollowPageDesc(
958 SwWrtShell& rTargetShell,
959 const SwPageDesc& rSourcePageDesc,
960 const SwPageDesc& rTargetPageDesc,
961 const sal_uLong nDocNo )
962{
963 //now copy the follow page desc, too
964 // note: these may at any point form a cycle, so a loop is needed and it
965 // must be detected that the last iteration closes the cycle and doesn't
966 // copy the first page desc of the cycle again.
967 std::map<OUString, OUString> followMap{ { rSourcePageDesc.GetName(), rTargetPageDesc.GetName() } };
968 SwPageDesc const* pCurSourcePageDesc(&rSourcePageDesc);
969 SwPageDesc const* pCurTargetPageDesc(&rTargetPageDesc);
970 do
971 {
972 const SwPageDesc* pFollowPageDesc = pCurSourcePageDesc->GetFollow();
973 OUString sFollowPageDesc = pFollowPageDesc->GetName();
974 if (sFollowPageDesc == pCurSourcePageDesc->GetName())
975 {
976 break;
977 }
978 SwDoc* pTargetDoc = rTargetShell.GetDoc();
979 SwPageDesc* pTargetFollowPageDesc(nullptr);
980 auto const itMapped(followMap.find(sFollowPageDesc));
981 if (itMapped == followMap.end())
982 {
983 OUString sNewFollowPageDesc = lcl_FindUniqueName(&rTargetShell, sFollowPageDesc, nDocNo);
984 pTargetFollowPageDesc = pTargetDoc->MakePageDesc(sNewFollowPageDesc);
985 pTargetDoc->CopyPageDesc(*pFollowPageDesc, *pTargetFollowPageDesc, false);
986 }
987 else
988 {
989 pTargetFollowPageDesc = pTargetDoc->FindPageDesc(itMapped->second);
990 }
991 SwPageDesc aDesc(*pCurTargetPageDesc);
992 aDesc.SetFollow(pTargetFollowPageDesc);
993 pTargetDoc->ChgPageDesc(pCurTargetPageDesc->GetName(), aDesc);
994 if (itMapped != followMap.end())
995 {
996 break; // was already copied
997 }
998 pCurSourcePageDesc = pCurSourcePageDesc->GetFollow();
999 pCurTargetPageDesc = pTargetFollowPageDesc;
1000 followMap[pCurSourcePageDesc->GetName()] = pCurTargetPageDesc->GetName();
1001 }
1002 while (true);
1003}
1004
1005// appends all pages of source SwDoc - based on SwFEShell::Paste( SwDoc* )
1006SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNumber,
1007 bool const bDeletePrevious, int pageOffset, const sal_uLong nDocNo)
1008{
1009 SAL_INFO( "sw.pageframe", "(SwDoc::AppendDoc in " << bDeletePrevious )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.pageframe")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "(SwDoc::AppendDoc in "
<< bDeletePrevious) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1009" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "(SwDoc::AppendDoc in " << bDeletePrevious
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "(SwDoc::AppendDoc in " << bDeletePrevious; ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1009" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "(SwDoc::AppendDoc in " << bDeletePrevious)
== 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1009" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "(SwDoc::AppendDoc in " << bDeletePrevious
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "(SwDoc::AppendDoc in " << bDeletePrevious; ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1009" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1010
1011 // GetEndOfExtras + 1 = StartOfContent == no content node!
1012 // This ensures it won't be merged in the SwTextNode at the position.
1013 SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 1 );
1014 // CopyRange works on the range a [mark, point[ and considers an
1015 // index < point outside the selection.
1016 // @see IDocumentContentOperations::CopyRange
1017 SwNodeIndex aSourceEndIdx( rSource.GetNodes().GetEndOfContent(), 0 );
1018 SwPaM aCpyPam( aSourceIdx, aSourceEndIdx );
1019
1020#ifdef DBG_UTIL
1021 SAL_INFO( "sw.docappend", "NodeType 0x" << std::hex << static_cast<int>(aSourceIdx.GetNode().GetNodeType())do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "NodeType 0x" <<
std::hex << static_cast<int>(aSourceIdx.GetNode(
).GetNodeType()) << std::dec << " " << aSourceIdx
.GetNode().GetIndex()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1022" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceIdx.GetNode().GetNodeType()) <<
std::dec << " " << aSourceIdx.GetNode().GetIndex
()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "NodeType 0x" << std::hex << static_cast
<int>(aSourceIdx.GetNode().GetNodeType()) << std::
dec << " " << aSourceIdx.GetNode().GetIndex(); ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1022" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "NodeType 0x" << std::hex << static_cast
<int>(aSourceIdx.GetNode().GetNodeType()) << std::
dec << " " << aSourceIdx.GetNode().GetIndex()) ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1022" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceIdx.GetNode().GetNodeType()) <<
std::dec << " " << aSourceIdx.GetNode().GetIndex
()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "NodeType 0x" << std::hex << static_cast
<int>(aSourceIdx.GetNode().GetNodeType()) << std::
dec << " " << aSourceIdx.GetNode().GetIndex(); ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1022" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
1022 << std::dec << " " << aSourceIdx.GetNode().GetIndex() )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "NodeType 0x" <<
std::hex << static_cast<int>(aSourceIdx.GetNode(
).GetNodeType()) << std::dec << " " << aSourceIdx
.GetNode().GetIndex()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1022" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceIdx.GetNode().GetNodeType()) <<
std::dec << " " << aSourceIdx.GetNode().GetIndex
()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "NodeType 0x" << std::hex << static_cast
<int>(aSourceIdx.GetNode().GetNodeType()) << std::
dec << " " << aSourceIdx.GetNode().GetIndex(); ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1022" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "NodeType 0x" << std::hex << static_cast
<int>(aSourceIdx.GetNode().GetNodeType()) << std::
dec << " " << aSourceIdx.GetNode().GetIndex()) ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1022" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceIdx.GetNode().GetNodeType()) <<
std::dec << " " << aSourceIdx.GetNode().GetIndex
()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "NodeType 0x" << std::hex << static_cast
<int>(aSourceIdx.GetNode().GetNodeType()) << std::
dec << " " << aSourceIdx.GetNode().GetIndex(); ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1022" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1023 aSourceIdx++;
1024 SAL_INFO( "sw.docappend", "NodeType 0x" << std::hex << static_cast<int>(aSourceIdx.GetNode().GetNodeType())do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "NodeType 0x" <<
std::hex << static_cast<int>(aSourceIdx.GetNode(
).GetNodeType()) << std::dec << " " << aSourceIdx
.GetNode().GetIndex()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1025" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceIdx.GetNode().GetNodeType()) <<
std::dec << " " << aSourceIdx.GetNode().GetIndex
()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "NodeType 0x" << std::hex << static_cast
<int>(aSourceIdx.GetNode().GetNodeType()) << std::
dec << " " << aSourceIdx.GetNode().GetIndex(); ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1025" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "NodeType 0x" << std::hex << static_cast
<int>(aSourceIdx.GetNode().GetNodeType()) << std::
dec << " " << aSourceIdx.GetNode().GetIndex()) ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1025" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceIdx.GetNode().GetNodeType()) <<
std::dec << " " << aSourceIdx.GetNode().GetIndex
()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "NodeType 0x" << std::hex << static_cast
<int>(aSourceIdx.GetNode().GetNodeType()) << std::
dec << " " << aSourceIdx.GetNode().GetIndex(); ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1025" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
1025 << std::dec << " " << aSourceIdx.GetNode().GetIndex() )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "NodeType 0x" <<
std::hex << static_cast<int>(aSourceIdx.GetNode(
).GetNodeType()) << std::dec << " " << aSourceIdx
.GetNode().GetIndex()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1025" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceIdx.GetNode().GetNodeType()) <<
std::dec << " " << aSourceIdx.GetNode().GetIndex
()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "NodeType 0x" << std::hex << static_cast
<int>(aSourceIdx.GetNode().GetNodeType()) << std::
dec << " " << aSourceIdx.GetNode().GetIndex(); ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1025" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "NodeType 0x" << std::hex << static_cast
<int>(aSourceIdx.GetNode().GetNodeType()) << std::
dec << " " << aSourceIdx.GetNode().GetIndex()) ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1025" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceIdx.GetNode().GetNodeType()) <<
std::dec << " " << aSourceIdx.GetNode().GetIndex
()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "NodeType 0x" << std::hex << static_cast
<int>(aSourceIdx.GetNode().GetNodeType()) << std::
dec << " " << aSourceIdx.GetNode().GetIndex(); ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1025" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1026 if ( aSourceIdx.GetNode().GetNodeType() != SwNodeType::End ) {
1027 aSourceIdx++;
1028 SAL_INFO( "sw.docappend", "NodeType 0x" << std::hex << static_cast<int>(aSourceIdx.GetNode().GetNodeType()) << std::dec )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "NodeType 0x" <<
std::hex << static_cast<int>(aSourceIdx.GetNode(
).GetNodeType()) << std::dec) == 1) { ::sal_detail_log(
(::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1028" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceIdx.GetNode().GetNodeType()) <<
std::dec), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceIdx.GetNode().GetNodeType()) <<
std::dec; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO),
("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1028" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "NodeType 0x" << std::hex << static_cast
<int>(aSourceIdx.GetNode().GetNodeType()) << std::
dec) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO),
("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1028" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceIdx.GetNode().GetNodeType()) <<
std::dec), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceIdx.GetNode().GetNodeType()) <<
std::dec; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO),
("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1028" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1029 aSourceIdx--;
1030 }
1031 aSourceIdx--;
1032 SAL_INFO( "sw.docappend", ".." )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "..") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1032" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << ".."), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << ".."; ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1032" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "..") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1032" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << ".."), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << ".."; ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1032" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1033 SAL_INFO( "sw.docappend", "NodeType 0x" << std::hex << static_cast<int>(aSourceEndIdx.GetNode().GetNodeType())do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "NodeType 0x" <<
std::hex << static_cast<int>(aSourceEndIdx.GetNode
().GetNodeType()) << std::dec << " " << aSourceEndIdx
.GetNode().GetIndex()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1034" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex()), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1034" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "NodeType 0x" << std::hex << static_cast
<int>(aSourceEndIdx.GetNode().GetNodeType()) << std
::dec << " " << aSourceEndIdx.GetNode().GetIndex(
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), (
"sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1034" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex()), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1034" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
1034 << std::dec << " " << aSourceEndIdx.GetNode().GetIndex() )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "NodeType 0x" <<
std::hex << static_cast<int>(aSourceEndIdx.GetNode
().GetNodeType()) << std::dec << " " << aSourceEndIdx
.GetNode().GetIndex()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1034" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex()), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1034" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "NodeType 0x" << std::hex << static_cast
<int>(aSourceEndIdx.GetNode().GetNodeType()) << std
::dec << " " << aSourceEndIdx.GetNode().GetIndex(
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), (
"sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1034" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex()), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1034" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1035 SAL_INFO( "sw.docappend", "NodeType 0x" << std::hex << static_cast<int>(aSourceEndIdx.GetNode().GetNodeType())do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "NodeType 0x" <<
std::hex << static_cast<int>(aSourceEndIdx.GetNode
().GetNodeType()) << std::dec << " " << aSourceEndIdx
.GetNode().GetIndex()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1036" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex()), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1036" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "NodeType 0x" << std::hex << static_cast
<int>(aSourceEndIdx.GetNode().GetNodeType()) << std
::dec << " " << aSourceEndIdx.GetNode().GetIndex(
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), (
"sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1036" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex()), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1036" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
1036 << std::dec << " " << aSourceEndIdx.GetNode().GetIndex() )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "NodeType 0x" <<
std::hex << static_cast<int>(aSourceEndIdx.GetNode
().GetNodeType()) << std::dec << " " << aSourceEndIdx
.GetNode().GetIndex()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1036" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex()), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1036" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "NodeType 0x" << std::hex << static_cast
<int>(aSourceEndIdx.GetNode().GetNodeType()) << std
::dec << " " << aSourceEndIdx.GetNode().GetIndex(
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), (
"sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1036" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex()), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "NodeType 0x" << std::hex <<
static_cast<int>(aSourceEndIdx.GetNode().GetNodeType()
) << std::dec << " " << aSourceEndIdx.GetNode
().GetIndex(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1036" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1037 SAL_INFO( "sw.docappend", "Src-Nd: " << CNTNT_DOC( &rSource ) )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Src-Nd: " << CNTNT_DOC
( &rSource )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1037" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Src-Nd: " << CNTNT_DOC( &
rSource )), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "Src-Nd: " << CNTNT_DOC( &
rSource ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO),
("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1037" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Src-Nd: " << CNTNT_DOC( &rSource )) ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1037" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Src-Nd: " << CNTNT_DOC( &
rSource )), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "Src-Nd: " << CNTNT_DOC( &
rSource ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO),
("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1037" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1038 SAL_INFO( "sw.docappend", "Nd: " << CNTNT_DOC( this ) )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Nd: " << CNTNT_DOC
( this )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1038" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Nd: " << CNTNT_DOC( this )), 0
); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Nd: " << CNTNT_DOC( this ); ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1038" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Nd: " << CNTNT_DOC( this )) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1038" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Nd: " << CNTNT_DOC( this )), 0
); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Nd: " << CNTNT_DOC( this ); ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1038" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1039#endif
1040
1041 SwWrtShell* pTargetShell = GetDocShell()->GetWrtShell();
1042 SwPageDesc* pTargetPageDesc = nullptr;
1043
1044 if ( pTargetShell ) {
1045#ifdef DBG_UTIL
1046 SAL_INFO( "sw.docappend", "Has target write shell" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Has target write shell"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1046" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Has target write shell"), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"Has target write shell"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1046" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Has target write shell") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1046" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Has target write shell"), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"Has target write shell"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1046" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1047#endif
1048 pTargetShell->StartAllAction();
1049
1050 if( nDocNo > 0 )
1051 {
1052 // #i72517# put the styles to the target document
1053 // if the source uses headers or footers the target document
1054 // needs individual page styles
1055 const SwWrtShell *pSourceShell = rSource.GetDocShell()->GetWrtShell();
1056 const SwPageDesc& rSourcePageDesc = pSourceShell->GetPageDesc(
1057 pSourceShell->GetCurPageDesc());
1058 const OUString sStartingPageDesc = rSourcePageDesc.GetName();
1059 const bool bPageStylesWithHeaderFooter = lcl_PageDescOrFollowContainsHeaderFooter(rSourcePageDesc);
1060 if( bPageStylesWithHeaderFooter )
1061 {
1062 // create a new pagestyle
1063 // copy the pagedesc from the current document to the new
1064 // document and change the name of the to-be-applied style
1065 OUString sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo );
1066 pTargetPageDesc = MakePageDesc( sNewPageDescName );
1067 if( pTargetPageDesc )
1068 {
1069 CopyPageDesc( rSourcePageDesc, *pTargetPageDesc, false );
1070 lcl_CopyFollowPageDesc( *pTargetShell, rSourcePageDesc, *pTargetPageDesc, nDocNo );
1071 }
1072 }
1073 else
1074 pTargetPageDesc = pTargetShell->FindPageDescByName( sStartingPageDesc );
1075 }
1076
1077 // Otherwise we have to handle SwPlaceholderNodes as first node
1078 if ( pTargetPageDesc )
1079 {
1080 SwNodeIndex aBreakIdx( GetNodes().GetEndOfContent(), -1 );
1081 SwPosition aBreakPos( aBreakIdx );
1082 // InsertPageBreak just works on SwTextNode nodes, so make
1083 // sure the last node is one!
1084 bool bIsTextNode = aBreakIdx.GetNode().IsTextNode();
1085 if ( !bIsTextNode )
1086 getIDocumentContentOperations().AppendTextNode( aBreakPos );
1087 const OUString name = pTargetPageDesc->GetName();
1088 pTargetShell->InsertPageBreak( &name, nStartPageNumber );
1089 if ( !bIsTextNode )
1090 {
1091 pTargetShell->SttEndDoc( false );
1092 --aBreakIdx;
1093 GetNodes().Delete( aBreakIdx );
1094 }
1095
1096 // There is now a new empty text node on the new page. If it has
1097 // any marks, those are from the previous page: move them back
1098 // there, otherwise later we can't delete that empty text node.
1099 SwNodeIndex aNodeIndex(GetNodes().GetEndOfContent(), -1);
1100 if (SwTextNode* pTextNode = aNodeIndex.GetNode().GetTextNode())
1101 {
1102 // Position of the last paragraph on the previous page.
1103 --aNodeIndex;
1104 SwPaM aPaM(aNodeIndex);
1105 // Collect the marks starting or ending at this text node.
1106 o3tl::sorted_vector<sw::mark::IMark*> aSeenMarks;
1107 IDocumentMarkAccess* pMarkAccess = getIDocumentMarkAccess();
1108 for (const SwIndex* pIndex = pTextNode->GetFirstIndex(); pIndex; pIndex = pIndex->GetNext())
1109 {
1110 sw::mark::IMark* pMark = const_cast<sw::mark::IMark*>(pIndex->GetMark());
1111 if (!pMark)
1112 continue;
1113 if (!aSeenMarks.insert(pMark).second)
1114 continue;
1115 }
1116 // And move them back.
1117 for (sw::mark::IMark* pMark : aSeenMarks)
1118 pMarkAccess->repositionMark(pMark, aPaM);
1119 }
1120
1121 // Flush the page break, if we want to keep it
1122 if ( !bDeletePrevious )
1123 {
1124 SAL_INFO( "sw.pageframe", "(Flush pagebreak AKA EndAllAction" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.pageframe")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "(Flush pagebreak AKA EndAllAction"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1124" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "(Flush pagebreak AKA EndAllAction")
, 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "(Flush pagebreak AKA EndAllAction"; ::sal::detail::
log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1124" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "(Flush pagebreak AKA EndAllAction") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1124" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "(Flush pagebreak AKA EndAllAction")
, 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "(Flush pagebreak AKA EndAllAction"; ::sal::detail::
log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1124" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1125 pTargetShell->EndAllAction();
1126 SAL_INFO( "sw.pageframe", "Flush changes AKA EndAllAction)" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.pageframe")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Flush changes AKA EndAllAction)"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1126" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Flush changes AKA EndAllAction)"), 0
); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Flush changes AKA EndAllAction)"; ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1126" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Flush changes AKA EndAllAction)") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1126" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Flush changes AKA EndAllAction)"), 0
); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Flush changes AKA EndAllAction)"; ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1126" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1127 pTargetShell->StartAllAction();
1128 }
1129 }
1130 }
1131#ifdef DBG_UTIL
1132 SAL_INFO( "sw.docappend", "Nd: " << CNTNT_DOC( this ) )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Nd: " << CNTNT_DOC
( this )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1132" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Nd: " << CNTNT_DOC( this )), 0
); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Nd: " << CNTNT_DOC( this ); ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1132" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Nd: " << CNTNT_DOC( this )) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1132" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Nd: " << CNTNT_DOC( this )), 0
); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Nd: " << CNTNT_DOC( this ); ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1132" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1133#endif
1134
1135 // -1, otherwise aFixupIdx would move to new EOC
1136 SwNodeIndex aFixupIdx( GetNodes().GetEndOfContent(), -1 );
1137
1138 // append at the end of document / content
1139 SwNodeIndex aTargetIdx( GetNodes().GetEndOfContent() );
1140 SwPaM aInsertPam( aTargetIdx );
1141
1142#ifdef DBG_UTIL
1143 SAL_INFO( "sw.docappend", "Pam-Nd: " << aCpyPam.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex() + 1do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Pam-Nd: " << aCpyPam
.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex() +
1 << " (0x" << std::hex << static_cast<
int>(aCpyPam.GetNode( false ).GetNodeType()) << std::
dec << " " << aCpyPam.GetNode( false ).GetIndex()
<< " - 0x" << std::hex << static_cast<int
>(aCpyPam.GetNode().GetNodeType()) << std::dec <<
" " << aCpyPam.GetNode().GetIndex() << ")") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Pam-Nd: " << aCpyPam.GetNode(
).GetIndex() - aCpyPam.GetNode( false ).GetIndex() + 1 <<
" (0x" << std::hex << static_cast<int>(aCpyPam
.GetNode( false ).GetNodeType()) << std::dec << " "
<< aCpyPam.GetNode( false ).GetIndex() << " - 0x"
<< std::hex << static_cast<int>(aCpyPam.GetNode
().GetNodeType()) << std::dec << " " << aCpyPam
.GetNode().GetIndex() << ")"), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "Pam-Nd: " <<
aCpyPam.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex
() + 1 << " (0x" << std::hex << static_cast
<int>(aCpyPam.GetNode( false ).GetNodeType()) << std
::dec << " " << aCpyPam.GetNode( false ).GetIndex
() << " - 0x" << std::hex << static_cast<
int>(aCpyPam.GetNode().GetNodeType()) << std::dec <<
" " << aCpyPam.GetNode().GetIndex() << ")"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Pam-Nd: " << aCpyPam.GetNode().GetIndex() -
aCpyPam.GetNode( false ).GetIndex() + 1 << " (0x" <<
std::hex << static_cast<int>(aCpyPam.GetNode( false
).GetNodeType()) << std::dec << " " << aCpyPam
.GetNode( false ).GetIndex() << " - 0x" << std::hex
<< static_cast<int>(aCpyPam.GetNode().GetNodeType
()) << std::dec << " " << aCpyPam.GetNode()
.GetIndex() << ")") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Pam-Nd: " << aCpyPam.GetNode(
).GetIndex() - aCpyPam.GetNode( false ).GetIndex() + 1 <<
" (0x" << std::hex << static_cast<int>(aCpyPam
.GetNode( false ).GetNodeType()) << std::dec << " "
<< aCpyPam.GetNode( false ).GetIndex() << " - 0x"
<< std::hex << static_cast<int>(aCpyPam.GetNode
().GetNodeType()) << std::dec << " " << aCpyPam
.GetNode().GetIndex() << ")"), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "Pam-Nd: " <<
aCpyPam.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex
() + 1 << " (0x" << std::hex << static_cast
<int>(aCpyPam.GetNode( false ).GetNodeType()) << std
::dec << " " << aCpyPam.GetNode( false ).GetIndex
() << " - 0x" << std::hex << static_cast<
int>(aCpyPam.GetNode().GetNodeType()) << std::dec <<
" " << aCpyPam.GetNode().GetIndex() << ")"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
1144 << " (0x" << std::hex << static_cast<int>(aCpyPam.GetNode( false ).GetNodeType()) << std::decdo { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Pam-Nd: " << aCpyPam
.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex() +
1 << " (0x" << std::hex << static_cast<
int>(aCpyPam.GetNode( false ).GetNodeType()) << std::
dec << " " << aCpyPam.GetNode( false ).GetIndex()
<< " - 0x" << std::hex << static_cast<int
>(aCpyPam.GetNode().GetNodeType()) << std::dec <<
" " << aCpyPam.GetNode().GetIndex() << ")") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Pam-Nd: " << aCpyPam.GetNode(
).GetIndex() - aCpyPam.GetNode( false ).GetIndex() + 1 <<
" (0x" << std::hex << static_cast<int>(aCpyPam
.GetNode( false ).GetNodeType()) << std::dec << " "
<< aCpyPam.GetNode( false ).GetIndex() << " - 0x"
<< std::hex << static_cast<int>(aCpyPam.GetNode
().GetNodeType()) << std::dec << " " << aCpyPam
.GetNode().GetIndex() << ")"), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "Pam-Nd: " <<
aCpyPam.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex
() + 1 << " (0x" << std::hex << static_cast
<int>(aCpyPam.GetNode( false ).GetNodeType()) << std
::dec << " " << aCpyPam.GetNode( false ).GetIndex
() << " - 0x" << std::hex << static_cast<
int>(aCpyPam.GetNode().GetNodeType()) << std::dec <<
" " << aCpyPam.GetNode().GetIndex() << ")"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Pam-Nd: " << aCpyPam.GetNode().GetIndex() -
aCpyPam.GetNode( false ).GetIndex() + 1 << " (0x" <<
std::hex << static_cast<int>(aCpyPam.GetNode( false
).GetNodeType()) << std::dec << " " << aCpyPam
.GetNode( false ).GetIndex() << " - 0x" << std::hex
<< static_cast<int>(aCpyPam.GetNode().GetNodeType
()) << std::dec << " " << aCpyPam.GetNode()
.GetIndex() << ")") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Pam-Nd: " << aCpyPam.GetNode(
).GetIndex() - aCpyPam.GetNode( false ).GetIndex() + 1 <<
" (0x" << std::hex << static_cast<int>(aCpyPam
.GetNode( false ).GetNodeType()) << std::dec << " "
<< aCpyPam.GetNode( false ).GetIndex() << " - 0x"
<< std::hex << static_cast<int>(aCpyPam.GetNode
().GetNodeType()) << std::dec << " " << aCpyPam
.GetNode().GetIndex() << ")"), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "Pam-Nd: " <<
aCpyPam.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex
() + 1 << " (0x" << std::hex << static_cast
<int>(aCpyPam.GetNode( false ).GetNodeType()) << std
::dec << " " << aCpyPam.GetNode( false ).GetIndex
() << " - 0x" << std::hex << static_cast<
int>(aCpyPam.GetNode().GetNodeType()) << std::dec <<
" " << aCpyPam.GetNode().GetIndex() << ")"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
1145 << " " << aCpyPam.GetNode( false ).GetIndex()do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Pam-Nd: " << aCpyPam
.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex() +
1 << " (0x" << std::hex << static_cast<
int>(aCpyPam.GetNode( false ).GetNodeType()) << std::
dec << " " << aCpyPam.GetNode( false ).GetIndex()
<< " - 0x" << std::hex << static_cast<int
>(aCpyPam.GetNode().GetNodeType()) << std::dec <<
" " << aCpyPam.GetNode().GetIndex() << ")") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Pam-Nd: " << aCpyPam.GetNode(
).GetIndex() - aCpyPam.GetNode( false ).GetIndex() + 1 <<
" (0x" << std::hex << static_cast<int>(aCpyPam
.GetNode( false ).GetNodeType()) << std::dec << " "
<< aCpyPam.GetNode( false ).GetIndex() << " - 0x"
<< std::hex << static_cast<int>(aCpyPam.GetNode
().GetNodeType()) << std::dec << " " << aCpyPam
.GetNode().GetIndex() << ")"), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "Pam-Nd: " <<
aCpyPam.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex
() + 1 << " (0x" << std::hex << static_cast
<int>(aCpyPam.GetNode( false ).GetNodeType()) << std
::dec << " " << aCpyPam.GetNode( false ).GetIndex
() << " - 0x" << std::hex << static_cast<
int>(aCpyPam.GetNode().GetNodeType()) << std::dec <<
" " << aCpyPam.GetNode().GetIndex() << ")"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Pam-Nd: " << aCpyPam.GetNode().GetIndex() -
aCpyPam.GetNode( false ).GetIndex() + 1 << " (0x" <<
std::hex << static_cast<int>(aCpyPam.GetNode( false
).GetNodeType()) << std::dec << " " << aCpyPam
.GetNode( false ).GetIndex() << " - 0x" << std::hex
<< static_cast<int>(aCpyPam.GetNode().GetNodeType
()) << std::dec << " " << aCpyPam.GetNode()
.GetIndex() << ")") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Pam-Nd: " << aCpyPam.GetNode(
).GetIndex() - aCpyPam.GetNode( false ).GetIndex() + 1 <<
" (0x" << std::hex << static_cast<int>(aCpyPam
.GetNode( false ).GetNodeType()) << std::dec << " "
<< aCpyPam.GetNode( false ).GetIndex() << " - 0x"
<< std::hex << static_cast<int>(aCpyPam.GetNode
().GetNodeType()) << std::dec << " " << aCpyPam
.GetNode().GetIndex() << ")"), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "Pam-Nd: " <<
aCpyPam.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex
() + 1 << " (0x" << std::hex << static_cast
<int>(aCpyPam.GetNode( false ).GetNodeType()) << std
::dec << " " << aCpyPam.GetNode( false ).GetIndex
() << " - 0x" << std::hex << static_cast<
int>(aCpyPam.GetNode().GetNodeType()) << std::dec <<
" " << aCpyPam.GetNode().GetIndex() << ")"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
1146 << " - 0x" << std::hex << static_cast<int>(aCpyPam.GetNode().GetNodeType()) << std::decdo { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Pam-Nd: " << aCpyPam
.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex() +
1 << " (0x" << std::hex << static_cast<
int>(aCpyPam.GetNode( false ).GetNodeType()) << std::
dec << " " << aCpyPam.GetNode( false ).GetIndex()
<< " - 0x" << std::hex << static_cast<int
>(aCpyPam.GetNode().GetNodeType()) << std::dec <<
" " << aCpyPam.GetNode().GetIndex() << ")") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Pam-Nd: " << aCpyPam.GetNode(
).GetIndex() - aCpyPam.GetNode( false ).GetIndex() + 1 <<
" (0x" << std::hex << static_cast<int>(aCpyPam
.GetNode( false ).GetNodeType()) << std::dec << " "
<< aCpyPam.GetNode( false ).GetIndex() << " - 0x"
<< std::hex << static_cast<int>(aCpyPam.GetNode
().GetNodeType()) << std::dec << " " << aCpyPam
.GetNode().GetIndex() << ")"), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "Pam-Nd: " <<
aCpyPam.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex
() + 1 << " (0x" << std::hex << static_cast
<int>(aCpyPam.GetNode( false ).GetNodeType()) << std
::dec << " " << aCpyPam.GetNode( false ).GetIndex
() << " - 0x" << std::hex << static_cast<
int>(aCpyPam.GetNode().GetNodeType()) << std::dec <<
" " << aCpyPam.GetNode().GetIndex() << ")"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Pam-Nd: " << aCpyPam.GetNode().GetIndex() -
aCpyPam.GetNode( false ).GetIndex() + 1 << " (0x" <<
std::hex << static_cast<int>(aCpyPam.GetNode( false
).GetNodeType()) << std::dec << " " << aCpyPam
.GetNode( false ).GetIndex() << " - 0x" << std::hex
<< static_cast<int>(aCpyPam.GetNode().GetNodeType
()) << std::dec << " " << aCpyPam.GetNode()
.GetIndex() << ")") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Pam-Nd: " << aCpyPam.GetNode(
).GetIndex() - aCpyPam.GetNode( false ).GetIndex() + 1 <<
" (0x" << std::hex << static_cast<int>(aCpyPam
.GetNode( false ).GetNodeType()) << std::dec << " "
<< aCpyPam.GetNode( false ).GetIndex() << " - 0x"
<< std::hex << static_cast<int>(aCpyPam.GetNode
().GetNodeType()) << std::dec << " " << aCpyPam
.GetNode().GetIndex() << ")"), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "Pam-Nd: " <<
aCpyPam.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex
() + 1 << " (0x" << std::hex << static_cast
<int>(aCpyPam.GetNode( false ).GetNodeType()) << std
::dec << " " << aCpyPam.GetNode( false ).GetIndex
() << " - 0x" << std::hex << static_cast<
int>(aCpyPam.GetNode().GetNodeType()) << std::dec <<
" " << aCpyPam.GetNode().GetIndex() << ")"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
1147 << " " << aCpyPam.GetNode().GetIndex() << ")" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Pam-Nd: " << aCpyPam
.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex() +
1 << " (0x" << std::hex << static_cast<
int>(aCpyPam.GetNode( false ).GetNodeType()) << std::
dec << " " << aCpyPam.GetNode( false ).GetIndex()
<< " - 0x" << std::hex << static_cast<int
>(aCpyPam.GetNode().GetNodeType()) << std::dec <<
" " << aCpyPam.GetNode().GetIndex() << ")") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Pam-Nd: " << aCpyPam.GetNode(
).GetIndex() - aCpyPam.GetNode( false ).GetIndex() + 1 <<
" (0x" << std::hex << static_cast<int>(aCpyPam
.GetNode( false ).GetNodeType()) << std::dec << " "
<< aCpyPam.GetNode( false ).GetIndex() << " - 0x"
<< std::hex << static_cast<int>(aCpyPam.GetNode
().GetNodeType()) << std::dec << " " << aCpyPam
.GetNode().GetIndex() << ")"), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "Pam-Nd: " <<
aCpyPam.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex
() + 1 << " (0x" << std::hex << static_cast
<int>(aCpyPam.GetNode( false ).GetNodeType()) << std
::dec << " " << aCpyPam.GetNode( false ).GetIndex
() << " - 0x" << std::hex << static_cast<
int>(aCpyPam.GetNode().GetNodeType()) << std::dec <<
" " << aCpyPam.GetNode().GetIndex() << ")"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Pam-Nd: " << aCpyPam.GetNode().GetIndex() -
aCpyPam.GetNode( false ).GetIndex() + 1 << " (0x" <<
std::hex << static_cast<int>(aCpyPam.GetNode( false
).GetNodeType()) << std::dec << " " << aCpyPam
.GetNode( false ).GetIndex() << " - 0x" << std::hex
<< static_cast<int>(aCpyPam.GetNode().GetNodeType
()) << std::dec << " " << aCpyPam.GetNode()
.GetIndex() << ")") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Pam-Nd: " << aCpyPam.GetNode(
).GetIndex() - aCpyPam.GetNode( false ).GetIndex() + 1 <<
" (0x" << std::hex << static_cast<int>(aCpyPam
.GetNode( false ).GetNodeType()) << std::dec << " "
<< aCpyPam.GetNode( false ).GetIndex() << " - 0x"
<< std::hex << static_cast<int>(aCpyPam.GetNode
().GetNodeType()) << std::dec << " " << aCpyPam
.GetNode().GetIndex() << ")"), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "Pam-Nd: " <<
aCpyPam.GetNode().GetIndex() - aCpyPam.GetNode( false ).GetIndex
() + 1 << " (0x" << std::hex << static_cast
<int>(aCpyPam.GetNode( false ).GetNodeType()) << std
::dec << " " << aCpyPam.GetNode( false ).GetIndex
() << " - 0x" << std::hex << static_cast<
int>(aCpyPam.GetNode().GetNodeType()) << std::dec <<
" " << aCpyPam.GetNode().GetIndex() << ")"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1147" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1148#endif
1149
1150 GetIDocumentUndoRedo().StartUndo( SwUndoId::INSGLOSSARY, nullptr );
1151 getIDocumentFieldsAccess().LockExpFields();
1152
1153 // Position where the appended doc starts. Will be filled in later.
1154 // Initially uses GetEndOfContent() because SwNodeIndex has no default ctor.
1155 SwNodeIndex aStartAppendIndex( GetNodes().GetEndOfContent() );
1156
1157 {
1158 // **
1159 // ** refer to SwFEShell::Paste, if you change the following code **
1160 // **
1161
1162 SwPosition& rInsPos = *aInsertPam.GetPoint();
1163
1164 {
1165 SwNodeIndex aIndexBefore(rInsPos.nNode);
1166
1167 aIndexBefore--;
1168#ifdef DBG_UTIL
1169 SAL_INFO( "sw.docappend", "CopyRange In: " << CNTNT_DOC( this ) )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "CopyRange In: " <<
CNTNT_DOC( this )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1169" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "CopyRange In: " << CNTNT_DOC(
this )), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "CopyRange In: " << CNTNT_DOC
( this ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), (
"sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1169" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "CopyRange In: " << CNTNT_DOC( this )) == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1169" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "CopyRange In: " << CNTNT_DOC(
this )), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "CopyRange In: " << CNTNT_DOC
( this ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), (
"sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1169" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1170#endif
1171 rSource.getIDocumentContentOperations().CopyRange(aCpyPam, rInsPos, SwCopyFlags::CopyAll|SwCopyFlags::CheckPosInFly);
1172 // Note: aCpyPam is invalid now
1173#ifdef DBG_UTIL
1174 SAL_INFO( "sw.docappend", "CopyRange Out: " << CNTNT_DOC( this ) )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "CopyRange Out: " <<
CNTNT_DOC( this )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1174" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "CopyRange Out: " << CNTNT_DOC
( this )), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "CopyRange Out: " << CNTNT_DOC
( this ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), (
"sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1174" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "CopyRange Out: " << CNTNT_DOC( this )) == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1174" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "CopyRange Out: " << CNTNT_DOC
( this )), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "CopyRange Out: " << CNTNT_DOC
( this ); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), (
"sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1174" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1175#endif
1176
1177 ++aIndexBefore;
1178 SwPaM aPaM(SwPosition(aIndexBefore),
1179 SwPosition(rInsPos.nNode));
1180
1181 aPaM.GetDoc().MakeUniqueNumRules(aPaM);
1182
1183 // Update the rsid of each pasted text node
1184 SwNodes &rDestNodes = GetNodes();
1185 sal_uLong const nEndIdx = aPaM.End()->nNode.GetIndex();
1186
1187 for (sal_uLong nIdx = aPaM.Start()->nNode.GetIndex();
1188 nIdx <= nEndIdx; ++nIdx)
1189 {
1190 SwTextNode *const pTextNode = rDestNodes[nIdx]->GetTextNode();
1191 if ( pTextNode )
1192 UpdateParRsid( pTextNode );
1193 }
1194 }
1195
1196 {
1197 sal_uLong iDelNodes = 0;
1198 SwNodeIndex aDelIdx( aFixupIdx );
1199
1200 // we just need to set the new page description and reset numbering
1201 // this keeps all other settings as in the pasted document
1202 if ( nStartPageNumber || pTargetPageDesc ) {
1203 std::unique_ptr<SfxPoolItem> pNewItem;
1204 SwTextNode *aTextNd = nullptr;
1205 SwFormat *pFormat = nullptr;
1206
1207 // find the first node allowed to contain a RES_PAGEDESC
1208 while (true) {
1209 aFixupIdx++;
1210
1211 SwNode &node = aFixupIdx.GetNode();
1212 if ( node.IsTextNode() ) {
1213 // every document contains at least one text node!
1214 aTextNd = node.GetTextNode();
1215 pNewItem.reset(aTextNd->GetAttr( RES_PAGEDESC ).Clone());
1216 break;
1217 }
1218 else if ( node.IsTableNode() ) {
1219 pFormat = node.GetTableNode()->GetTable().GetFrameFormat();
1220 pNewItem.reset(pFormat->GetFormatAttr( RES_PAGEDESC ).Clone());
1221 break;
1222 }
1223 }
1224
1225#ifdef DBG_UTIL
1226 SAL_INFO( "sw.docappend", "Idx Del " << CNTNT_IDX( aDelIdx ) )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Idx Del " << CNTNT_IDX
( aDelIdx )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1226" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Idx Del " << CNTNT_IDX( aDelIdx
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Idx Del " << CNTNT_IDX( aDelIdx ); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1226" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Idx Del " << CNTNT_IDX( aDelIdx )) == 1) {
::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1226" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Idx Del " << CNTNT_IDX( aDelIdx
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Idx Del " << CNTNT_IDX( aDelIdx ); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1226" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1227 SAL_INFO( "sw.docappend", "Idx Fix " << CNTNT_IDX( aFixupIdx ) )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Idx Fix " << CNTNT_IDX
( aFixupIdx )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1227" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Idx Fix " << CNTNT_IDX( aFixupIdx
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Idx Fix " << CNTNT_IDX( aFixupIdx ); ::sal::
detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"),
("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1227" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Idx Fix " << CNTNT_IDX( aFixupIdx )) == 1)
{ ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1227" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Idx Fix " << CNTNT_IDX( aFixupIdx
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Idx Fix " << CNTNT_IDX( aFixupIdx ); ::sal::
detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"),
("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1227" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1228#endif
1229 // just update the original instead of overwriting
1230 SwFormatPageDesc *aDesc = static_cast< SwFormatPageDesc* >( pNewItem.get() );
1231#ifdef DBG_UTIL
1232 if ( aDesc->GetPageDesc() )
1233 SAL_INFO( "sw.docappend", "PD Update " << aDesc->GetPageDesc()->GetName() )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "PD Update " <<
aDesc->GetPageDesc()->GetName()) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1233" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "PD Update " << aDesc->GetPageDesc
()->GetName()), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "PD Update " << aDesc->
GetPageDesc()->GetName(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1233" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "PD Update " << aDesc->GetPageDesc()->
GetName()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1233" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "PD Update " << aDesc->GetPageDesc
()->GetName()), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "PD Update " << aDesc->
GetPageDesc()->GetName(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1233" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1234 else
1235 SAL_INFO( "sw.docappend", "PD New" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "PD New") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1235" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "PD New"), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "PD New"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1235" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "PD New") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1235" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "PD New"), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "PD New"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1235" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1236#endif
1237 if ( nStartPageNumber )
1238 aDesc->SetNumOffset( nStartPageNumber );
1239 if ( pTargetPageDesc )
1240 aDesc->RegisterToPageDesc( *pTargetPageDesc );
1241 if ( aTextNd )
1242 aTextNd->SetAttr( *aDesc );
1243 else
1244 pFormat->SetFormatAttr( *aDesc );
1245
1246#ifdef DBG_UTIL
1247 SAL_INFO( "sw.docappend", "Idx " << CNTNT_IDX( aDelIdx ) )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Idx " << CNTNT_IDX
( aDelIdx )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1247" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Idx " << CNTNT_IDX( aDelIdx )
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Idx " << CNTNT_IDX( aDelIdx ); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1247" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Idx " << CNTNT_IDX( aDelIdx )) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1247" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Idx " << CNTNT_IDX( aDelIdx )
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Idx " << CNTNT_IDX( aDelIdx ); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1247" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1248#endif
1249 iDelNodes++;
1250 }
1251
1252 if ( bDeletePrevious )
1253 iDelNodes++;
1254
1255 if ( iDelNodes ) {
1256 // delete leading empty page(s), e.g. from InsertPageBreak or
1257 // new SwDoc. this has to be done before copying the page bound
1258 // frames, otherwise the drawing layer gets confused.
1259 if ( pTargetShell )
1260 pTargetShell->SttEndDoc( false );
1261 aDelIdx -= iDelNodes - 1;
1262#ifdef DBG_UTIL
1263 SAL_INFO( "sw.docappend", "iDelNodes: " << iDelNodesdo { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "iDelNodes: " <<
iDelNodes << " Idx: " << aDelIdx.GetNode().GetIndex
() << " EOE: " << GetNodes().GetEndOfExtras().GetIndex
()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), (
"sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1265" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "iDelNodes: " << iDelNodes <<
" Idx: " << aDelIdx.GetNode().GetIndex() << " EOE: "
<< GetNodes().GetEndOfExtras().GetIndex()), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"iDelNodes: " << iDelNodes << " Idx: " <<
aDelIdx.GetNode().GetIndex() << " EOE: " << GetNodes
().GetEndOfExtras().GetIndex(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1265" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "iDelNodes: " << iDelNodes << " Idx: "
<< aDelIdx.GetNode().GetIndex() << " EOE: " <<
GetNodes().GetEndOfExtras().GetIndex()) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1265" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "iDelNodes: " << iDelNodes <<
" Idx: " << aDelIdx.GetNode().GetIndex() << " EOE: "
<< GetNodes().GetEndOfExtras().GetIndex()), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"iDelNodes: " << iDelNodes << " Idx: " <<
aDelIdx.GetNode().GetIndex() << " EOE: " << GetNodes
().GetEndOfExtras().GetIndex(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1265" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
1264 << " Idx: " << aDelIdx.GetNode().GetIndex()do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "iDelNodes: " <<
iDelNodes << " Idx: " << aDelIdx.GetNode().GetIndex
() << " EOE: " << GetNodes().GetEndOfExtras().GetIndex
()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), (
"sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1265" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "iDelNodes: " << iDelNodes <<
" Idx: " << aDelIdx.GetNode().GetIndex() << " EOE: "
<< GetNodes().GetEndOfExtras().GetIndex()), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"iDelNodes: " << iDelNodes << " Idx: " <<
aDelIdx.GetNode().GetIndex() << " EOE: " << GetNodes
().GetEndOfExtras().GetIndex(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1265" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "iDelNodes: " << iDelNodes << " Idx: "
<< aDelIdx.GetNode().GetIndex() << " EOE: " <<
GetNodes().GetEndOfExtras().GetIndex()) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1265" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "iDelNodes: " << iDelNodes <<
" Idx: " << aDelIdx.GetNode().GetIndex() << " EOE: "
<< GetNodes().GetEndOfExtras().GetIndex()), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"iDelNodes: " << iDelNodes << " Idx: " <<
aDelIdx.GetNode().GetIndex() << " EOE: " << GetNodes
().GetEndOfExtras().GetIndex(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1265" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
1265 << " EOE: " << GetNodes().GetEndOfExtras().GetIndex() )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "iDelNodes: " <<
iDelNodes << " Idx: " << aDelIdx.GetNode().GetIndex
() << " EOE: " << GetNodes().GetEndOfExtras().GetIndex
()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), (
"sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1265" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "iDelNodes: " << iDelNodes <<
" Idx: " << aDelIdx.GetNode().GetIndex() << " EOE: "
<< GetNodes().GetEndOfExtras().GetIndex()), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"iDelNodes: " << iDelNodes << " Idx: " <<
aDelIdx.GetNode().GetIndex() << " EOE: " << GetNodes
().GetEndOfExtras().GetIndex(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1265" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "iDelNodes: " << iDelNodes << " Idx: "
<< aDelIdx.GetNode().GetIndex() << " EOE: " <<
GetNodes().GetEndOfExtras().GetIndex()) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1265" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "iDelNodes: " << iDelNodes <<
" Idx: " << aDelIdx.GetNode().GetIndex() << " EOE: "
<< GetNodes().GetEndOfExtras().GetIndex()), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"iDelNodes: " << iDelNodes << " Idx: " <<
aDelIdx.GetNode().GetIndex() << " EOE: " << GetNodes
().GetEndOfExtras().GetIndex(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1265" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1266#endif
1267 GetNodes().Delete( aDelIdx, iDelNodes );
1268 aStartAppendIndex = aFixupIdx;
1269 }
1270 else
1271 {
1272 aStartAppendIndex = aFixupIdx;
1273 ++aStartAppendIndex;
1274 }
1275 }
1276
1277 // finally copy page bound frames
1278 for ( auto pCpyFormat : *rSource.GetSpzFrameFormats() )
1279 {
1280 const SwFrameFormat& rCpyFormat = *pCpyFormat;
1281 SwFormatAnchor aAnchor( rCpyFormat.GetAnchor() );
1282 if (RndStdIds::FLY_AT_PAGE != aAnchor.GetAnchorId())
1283 continue;
1284 SAL_INFO( "sw.docappend", "PaAn: " << aAnchor.GetPageNum()do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "PaAn: " << aAnchor
.GetPageNum() << " => " << aAnchor.GetPageNum(
) + pageOffset) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1285" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "PaAn: " << aAnchor.GetPageNum
() << " => " << aAnchor.GetPageNum() + pageOffset
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "PaAn: " << aAnchor.GetPageNum() << " => "
<< aAnchor.GetPageNum() + pageOffset; ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1285" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "PaAn: " << aAnchor.GetPageNum() << " => "
<< aAnchor.GetPageNum() + pageOffset) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1285" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "PaAn: " << aAnchor.GetPageNum
() << " => " << aAnchor.GetPageNum() + pageOffset
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "PaAn: " << aAnchor.GetPageNum() << " => "
<< aAnchor.GetPageNum() + pageOffset; ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1285" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
1285 << " => " << aAnchor.GetPageNum() + pageOffset )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.docappend")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "PaAn: " << aAnchor
.GetPageNum() << " => " << aAnchor.GetPageNum(
) + pageOffset) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1285" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "PaAn: " << aAnchor.GetPageNum
() << " => " << aAnchor.GetPageNum() + pageOffset
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "PaAn: " << aAnchor.GetPageNum() << " => "
<< aAnchor.GetPageNum() + pageOffset; ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1285" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "PaAn: " << aAnchor.GetPageNum() << " => "
<< aAnchor.GetPageNum() + pageOffset) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1285" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "PaAn: " << aAnchor.GetPageNum
() << " => " << aAnchor.GetPageNum() + pageOffset
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "PaAn: " << aAnchor.GetPageNum() << " => "
<< aAnchor.GetPageNum() + pageOffset; ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.docappend"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1285" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1286 if ( pageOffset != 0 )
1287 aAnchor.SetPageNum( aAnchor.GetPageNum() + pageOffset );
1288 getIDocumentLayoutAccess().CopyLayoutFormat( rCpyFormat, aAnchor, true, true );
1289 }
1290 }
1291
1292 GetIDocumentUndoRedo().EndUndo( SwUndoId::INSGLOSSARY, nullptr );
1293
1294 getIDocumentFieldsAccess().UnlockExpFields();
1295 getIDocumentFieldsAccess().UpdateFields(false);
1296
1297 if ( pTargetShell )
1298 pTargetShell->EndAllAction();
1299
1300 SAL_INFO( "sw.pageframe", "SwDoc::AppendDoc out)" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.pageframe")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "SwDoc::AppendDoc out)"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"
), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1300" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "SwDoc::AppendDoc out)"), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"SwDoc::AppendDoc out)"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1300" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "SwDoc::AppendDoc out)") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1300" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "SwDoc::AppendDoc out)"), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"SwDoc::AppendDoc out)"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.pageframe"), ("/home/maarten/src/libreoffice/core/sw/source/core/doc/docnew.cxx"
":" "1300" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1301 return aStartAppendIndex;
1302}
1303
1304/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/sw/inc/pam.hxx

1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#ifndef INCLUDED_SW_INC_PAM_HXX
20#define INCLUDED_SW_INC_PAM_HXX
21
22#include <sal/types.h>
23#include "ring.hxx"
24#include "index.hxx"
25#include "ndindex.hxx"
26#include "swdllapi.h"
27
28#include <iostream>
29
30class SwDoc;
31class SwPaM;
32class Point;
33
34/// Marks a position in the document model.
35struct SAL_WARN_UNUSED__attribute__((warn_unused)) SW_DLLPUBLIC__attribute__ ((visibility("default"))) SwPosition
36{
37 SwNodeIndex nNode;
38 SwIndex nContent;
39
40 SwPosition( const SwNodeIndex &rNode, const SwIndex &rContent );
41 explicit SwPosition( const SwNodeIndex &rNode );
42 explicit SwPosition( const SwNode& rNode );
43 explicit SwPosition( SwContentNode& rNode, const sal_Int32 nOffset = 0 );
44
45 /**
46 Returns the document this position is in.
47
48 @return the document this position is in.
49 */
50 SwDoc& GetDoc() const;
51
52 bool operator < (const SwPosition &) const;
53 bool operator > (const SwPosition &) const;
54 bool operator <=(const SwPosition &) const;
55 bool operator >=(const SwPosition &) const;
56 bool operator ==(const SwPosition &) const;
57 bool operator !=(const SwPosition &) const;
58 void dumpAsXml(xmlTextWriterPtr pWriter) const;
59};
60
61SW_DLLPUBLIC__attribute__ ((visibility("default"))) std::ostream &operator <<(std::ostream& s, const SwPosition& position);
62
63// Result of comparing positions.
64enum class SwComparePosition {
65 Before, ///< Pos1 before Pos2.
66 Behind, ///< Pos1 behind Pos2.
67 Inside, ///< Pos1 completely contained in Pos2.
68 Outside, ///< Pos2 completely contained in Pos1.
69 Equal, ///< Pos1 is as large as Pos2.
70 OverlapBefore, ///< Pos1 overlaps Pos2 at the beginning.
71 OverlapBehind, ///< Pos1 overlaps Pos2 at the end.
72 CollideStart, ///< Pos1 start touches at Pos2 end.
73 CollideEnd ///< Pos1 end touches at Pos2 start.
74};
75
76template<typename T>
77SwComparePosition ComparePosition(
78 const T& rStt1, const T& rEnd1,
79 const T& rStt2, const T& rEnd2 )
80{
81 SwComparePosition nRet;
82 if( rStt1 < rStt2 )
83 {
84 if( rEnd1 > rStt2 )
85 {
86 if( rEnd1 >= rEnd2 )
87 nRet = SwComparePosition::Outside;
88 else
89 nRet = SwComparePosition::OverlapBefore;
90
91 }
92 else if( rEnd1 == rStt2 )
93 nRet = SwComparePosition::CollideEnd;
94 else
95 nRet = SwComparePosition::Before;
96 }
97 else if( rEnd2 > rStt1 )
98 {
99 if( rEnd2 >= rEnd1 )
100 {
101 if( rEnd2 == rEnd1 && rStt2 == rStt1 )
102 nRet = SwComparePosition::Equal;
103 else
104 nRet = SwComparePosition::Inside;
105 }
106 else
107 {
108 if (rStt1 == rStt2)
109 nRet = SwComparePosition::Outside;
110 else
111 nRet = SwComparePosition::OverlapBehind;
112 }
113 }
114 else if( rEnd2 == rStt1 )
115 nRet = SwComparePosition::CollideStart;
116 else
117 nRet = SwComparePosition::Behind;
118 return nRet;
119}
120
121/// SwPointAndMark / SwPaM
122struct SwMoveFnCollection;
123SW_DLLPUBLIC__attribute__ ((visibility("default"))) extern SwMoveFnCollection const & fnMoveForward; ///< SwPam::Move()/Find() default argument.
124SW_DLLPUBLIC__attribute__ ((visibility("default"))) extern SwMoveFnCollection const & fnMoveBackward;
125
126using SwGoInDoc = auto (*)(SwPaM& rPam, SwMoveFnCollection const & fnMove) -> bool;
127SW_DLLPUBLIC__attribute__ ((visibility("default"))) bool GoInDoc( SwPaM&, SwMoveFnCollection const &);
128bool GoInSection( SwPaM&, SwMoveFnCollection const &);
129SW_DLLPUBLIC__attribute__ ((visibility("default"))) bool GoInNode( SwPaM&, SwMoveFnCollection const &);
130SW_DLLPUBLIC__attribute__ ((visibility("default"))) bool GoInContent( SwPaM&, SwMoveFnCollection const &);
131bool GoInContentCells( SwPaM&, SwMoveFnCollection const &);
132bool GoInContentSkipHidden( SwPaM&, SwMoveFnCollection const &);
133bool GoInContentCellsSkipHidden( SwPaM&, SwMoveFnCollection const &);
134
135/// PaM is Point and Mark: a selection of the document model.
136class SAL_WARN_UNUSED__attribute__((warn_unused)) SW_DLLPUBLIC__attribute__ ((visibility("default"))) SwPaM : public sw::Ring<SwPaM>
137{
138 SwPosition m_Bound1;
139 SwPosition m_Bound2;
140 SwPosition * m_pPoint; ///< points at either m_Bound1 or m_Bound2
141 SwPosition * m_pMark; ///< points at either m_Bound1 or m_Bound2
142 bool m_bIsInFrontOfLabel;
143
144 SwPaM(SwPaM const& rPaM) = delete;
145
146public:
147 explicit SwPaM( const SwPosition& rPos, SwPaM* pRing = nullptr );
148 SwPaM( const SwPosition& rMk, const SwPosition& rPt, SwPaM* pRing = nullptr );
149 SwPaM( const SwNodeIndex& rMk, const SwNodeIndex& rPt,
150 long nMkOffset = 0, long nPtOffset = 0, SwPaM* pRing = nullptr );
151 SwPaM( const SwNode& rMk, const SwNode& rPt,
152 long nMkOffset = 0, long nPtOffset = 0, SwPaM* pRing = nullptr );
153 SwPaM( const SwNodeIndex& rMk, sal_Int32 nMkContent,
154 const SwNodeIndex& rPt, sal_Int32 nPtContent, SwPaM* pRing = nullptr );
155 SwPaM( const SwNode& rMk, sal_Int32 nMkContent,
156 const SwNode& rPt, sal_Int32 nPtContent, SwPaM* pRing = nullptr );
157 SwPaM( const SwNode& rNd, sal_Int32 nContent = 0, SwPaM* pRing = nullptr );
158 SwPaM( const SwNodeIndex& rNd, sal_Int32 nContent = 0, SwPaM* pRing = nullptr );
159 virtual ~SwPaM() override;
160
161 /// this takes a second parameter, which indicates the Ring that
162 /// the new PaM should be part of (may be null)
163 SwPaM(SwPaM const& rPaM, SwPaM * pRing);
164 /// @@@ semantic: no copy assignment for super class Ring.
165 SwPaM& operator=( const SwPaM & );
166
167 /// Movement of cursor.
168 bool Move( SwMoveFnCollection const & fnMove = fnMoveForward,
169 SwGoInDoc fnGo = GoInContent );
170
171 bool IsInFrontOfLabel() const { return m_bIsInFrontOfLabel; }
172 void SetInFrontOfLabel_( bool bNew ) { m_bIsInFrontOfLabel = bNew; }
173
174 /// Unless this is called, the getter method of Mark will return Point.
175 virtual void SetMark();
176
177 void DeleteMark()
178 {
179 if (m_pMark != m_pPoint)
180 {
181 /** clear the mark position; this helps if mark's SwIndex is
182 registered at some node, and that node is then deleted */
183 *m_pMark = SwPosition( SwNodeIndex( GetNode().GetNodes() ) );
184 m_pMark = m_pPoint;
185 }
186 }
187#ifdef DBG_UTIL
188 void Exchange();
189
190#else
191 void Exchange()
192 {
193 if (m_pPoint != m_pMark)
194 {
195 SwPosition *pTmp = m_pPoint;
196 m_pPoint = m_pMark;
197 m_pMark = pTmp;
198 }
199 }
200#endif
201
202 /** A PaM marks a selection if Point and Mark are distinct positions.
203 @return true if the PaM spans a selection
204 */
205 bool HasMark() const { return m_pPoint != m_pMark; }
206
207 const SwPosition *GetPoint() const { return m_pPoint; }
208 SwPosition *GetPoint() { return m_pPoint; }
209 const SwPosition *GetMark() const { return m_pMark; }
210 SwPosition *GetMark() { return m_pMark; }
211
212 const SwPosition *Start() const
213 { return (*m_pPoint) <= (*m_pMark) ? m_pPoint : m_pMark; }
214 SwPosition *Start()
215 { return (*m_pPoint) <= (*m_pMark) ? m_pPoint : m_pMark; }
216
217 const SwPosition *End() const
218 { return (*m_pPoint) > (*m_pMark) ? m_pPoint : m_pMark; }
219 SwPosition *End()
220 { return (*m_pPoint) > (*m_pMark) ? m_pPoint : m_pMark; }
221
222 /// @return current Node at Point/Mark
223 SwNode & GetNode ( bool bPoint = true ) const
224 {
225 return ( bPoint ? m_pPoint->nNode : m_pMark->nNode ).GetNode();
226 }
227
228 /// @return current ContentNode at Point/Mark
229 SwContentNode* GetContentNode( bool bPoint = true ) const
230 {
231 return GetNode(bPoint).GetContentNode();
232 }
233
234 /**
235 Normalizes PaM, i.e. sort point and mark.
236
237 @param bPointFirst true: If the point is behind the mark then swap.
238 false: If the mark is behind the point then swap.
239 */
240 void Normalize(bool bPointFirst = true);
241
242 /// @return the document (SwDoc) at which the PaM is registered
243 SwDoc& GetDoc() const { return m_pPoint->nNode.GetNode().GetDoc(); }
244
245 SwPosition& GetBound( bool bOne = true )
246 { return bOne ? m_Bound1 : m_Bound2; }
247 const SwPosition& GetBound( bool bOne = true ) const
248 { return bOne ? m_Bound1 : m_Bound2; }
249
250 /// Get number of page which contains cursor.
251 sal_uInt16 GetPageNum( bool bAtPoint = true, const Point* pLayPos = nullptr );
252
253 /** Is in something protected (readonly) or selection contains
254 something protected. */
255 bool HasReadonlySel( bool bFormView ) const;
256
257 bool ContainsPosition(const SwPosition & rPos) const
258 {
259 return *Start() <= rPos && rPos <= *End();
260 }
261
262 OUString GetText() const;
263 void InvalidatePaM();
264 SwPaM* GetNext()
265 { return GetNextInRing(); }
13
Calling 'Ring::GetNextInRing'
266 const SwPaM* GetNext() const
267 { return GetNextInRing(); }
268 SwPaM* GetPrev()
269 { return GetPrevInRing(); }
270 const SwPaM* GetPrev() const
271 { return GetPrevInRing(); }
272 bool IsMultiSelection() const
273 { return !unique(); }
274
275 void dumpAsXml(xmlTextWriterPtr pWriter) const;
276};
277
278SW_DLLPUBLIC__attribute__ ((visibility("default"))) std::ostream &operator <<(std::ostream& s, const SwPaM& pam);
279
280bool CheckNodesRange(const SwNodeIndex&, const SwNodeIndex&, bool bChkSection);
281
282#endif // INCLUDED_SW_INC_PAM_HXX
283
284/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/sw/inc/ring.hxx

1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#ifndef INCLUDED_SW_INC_RING_HXX
20#define INCLUDED_SW_INC_RING_HXX
21
22#include <utility>
23#include <sal/types.h>
24#include <iterator>
25#include <type_traits>
26#include <boost/iterator/iterator_facade.hpp>
27#include <boost/intrusive/circular_list_algorithms.hpp>
28
29namespace sw
30{
31 template <typename value_type> class RingContainer;
32 template <typename value_type> class RingIterator;
33 /**
34 * An intrusive container class double linking the contained nodes
35 * @example sw/qa/core/uwriter.cxx
36 */
37 template <typename value_type>
38 class SAL_WARN_UNUSED__attribute__((warn_unused)) Ring
39 {
40 public:
41 typedef typename std::add_const<value_type>::type const_value_type;
42 typedef RingContainer<value_type> ring_container;
43 typedef RingContainer<const_value_type> const_ring_container;
44 virtual ~Ring() COVERITY_NOEXCEPT_FALSE
45 { unlink(); };
46 /** algo::unlink is buggy! don't call it directly! */
47 void unlink()
48 {
49 algo::unlink(this);
50 m_pNext = this; // don't leave pointers to old list behind!
51 m_pPrev = this;
52 }
53 /**
54 * Removes this item from its current ring container and adds it to
55 * another ring container. If the item was not alone in the original
56 * ring container, the other items in the ring will stay in the old
57 * ring container.
58 * Note: the newly created item will be inserted just before item pDestRing.
59 * @param pDestRing the container to add this item to
60 */
61 void MoveTo( value_type* pDestRing );
62 /** @return a stl-like container with begin()/end() for iteration */
63 ring_container GetRingContainer();
64 /** @return a stl-like container with begin()/end() for const iteration */
65 const_ring_container GetRingContainer() const;
66
67 protected:
68 /**
69 * Creates a new item in a ring container all by itself.
70 * Note: Ring instances can newer be outside a container. At most, they
71 * are alone in one.
72 */
73 Ring()
74 : m_pNext(this)
75 , m_pPrev(this)
76 { }
77 /**
78 * Creates a new item and add it to an existing ring container.
79 * Note: the newly created item will be inserted just before item pRing.
80 * @param pRing ring container to add the created item to
81 */
82 Ring( value_type* pRing );
83 /** @return the next item in the ring container */
84 value_type* GetNextInRing()
85 { return static_cast<value_type *>(m_pNext); }
14
Use of memory after it is freed
86 /** @return the previous item in the ring container */
87 value_type* GetPrevInRing()
88 { return static_cast<value_type *>(m_pPrev); }
89 /** @return the next item in the ring container */
90 const_value_type* GetNextInRing() const
91 { return static_cast<value_type *>(m_pNext); }
92 /** @return the previous item in the ring container */
93 const_value_type* GetPrevInRing() const
94 { return static_cast<value_type *>(m_pPrev); }
95 /** @return true if and only if this item is alone in its ring */
96 bool unique() const
97 { return algo::unique(static_cast< const_value_type* >(this)); }
98
99 private:
100 /** internal implementation class -- not for external use */
101 struct Ring_node_traits
102 {
103 typedef Ring node;
104 typedef Ring* node_ptr;
105 typedef const Ring* const_node_ptr;
106 static node_ptr get_next(const_node_ptr n) { return const_cast<node_ptr>(n)->m_pNext; };
107 static void set_next(node_ptr n, node_ptr next) { n->m_pNext = next; };
108 static node_ptr get_previous(const_node_ptr n) { return const_cast<node_ptr>(n)->m_pPrev; };
109 static void set_previous(node_ptr n, node_ptr previous) { n->m_pPrev = previous; };
110 };
111 friend ring_container;
112 friend const_ring_container;
113 friend typename ring_container::iterator;
114 friend typename ring_container::const_iterator;
115 friend typename const_ring_container::iterator;
116 friend typename const_ring_container::const_iterator;
117 friend class boost::iterator_core_access;
118 typedef boost::intrusive::circular_list_algorithms<Ring_node_traits> algo;
119 Ring* m_pNext;
120 Ring* m_pPrev;
121 };
122
123 template <typename value_type>
124 inline Ring<value_type>::Ring( value_type* pObj )
125 : m_pNext(this)
126 , m_pPrev(this)
127 {
128 if( pObj )
129 {
130 algo::link_before(pObj, this);
131 }
132 }
133
134 template <typename value_type>
135 inline void Ring<value_type>::MoveTo(value_type* pDestRing)
136 {
137 value_type* pThis = static_cast< value_type* >(this);
138 unlink();
139 // insert into "new"
140 if (pDestRing)
141 {
142 algo::link_before(pDestRing, pThis);
143 }
144 }
145
146 /**
147 * helper class that provides Svalue_typeL-style container iteration to the ring
148 */
149 template <typename value_type>
150 class SAL_WARN_UNUSED__attribute__((warn_unused)) RingContainer final
151 {
152 private:
153 /** the item in the ring where iteration starts */
154 value_type* m_pStart;
155 typedef typename std::remove_const<value_type>::type nonconst_value_type;
156
157 public:
158 RingContainer( value_type* pRing ) : m_pStart(pRing) {};
159 typedef RingIterator<value_type> iterator;
160 typedef RingIterator<const value_type> const_iterator;
161 /**
162 * iterator access
163 * @code
164 * for(SwPaM& rCurrentPaM : pPaM->GetRingContainer())
165 * do_stuff(rCurrentPaM); // this gets called on every SwPaM in the same ring as pPaM
166 * @endcode
167 */
168 iterator begin();
169 iterator end();
170 const_iterator begin() const;
171 const_iterator end() const;
172 /** @return the number of elements in the container */
173 size_t size() const
174 { return std::distance(begin(), end()); }
175 /**
176 * Merges two ring containers. All item from both ring containers will
177 * be in the same ring container in the end.
178 * Note: The items of this ring container will be inserted just before
179 * item pDestRing
180 * @param pDestRing the container to merge this container with
181 */
182 void merge( RingContainer< value_type > aDestRing )
183 {
184 // first check that we aren't merged already, swapping would
185 // actually un-merge in this case!
186 assert(m_pStart->m_pPrev != aDestRing.m_pStart)(static_cast <bool> (m_pStart->m_pPrev != aDestRing.
m_pStart) ? void (0) : __assert_fail ("m_pStart->m_pPrev != aDestRing.m_pStart"
, "/home/maarten/src/libreoffice/core/sw/inc/ring.hxx", 186, __extension__
__PRETTY_FUNCTION__))
;
187 assert(m_pStart != aDestRing.m_pStart->m_pPrev)(static_cast <bool> (m_pStart != aDestRing.m_pStart->
m_pPrev) ? void (0) : __assert_fail ("m_pStart != aDestRing.m_pStart->m_pPrev"
, "/home/maarten/src/libreoffice/core/sw/inc/ring.hxx", 187, __extension__
__PRETTY_FUNCTION__))
;
188 std::swap(m_pStart->m_pPrev->m_pNext, aDestRing.m_pStart->m_pPrev->m_pNext);
189 std::swap(m_pStart->m_pPrev, aDestRing.m_pStart->m_pPrev);
190 }
191 };
192
193 template <typename value_type>
194 class RingIterator final : public boost::iterator_facade<
195 RingIterator<value_type>
196 , value_type
197 , boost::forward_traversal_tag
198 >
199 {
200 private:
201 typedef typename std::remove_const<value_type>::type nonconst_value_type;
202 public:
203 RingIterator()
204 : m_pCurrent(nullptr)
205 , m_pStart(nullptr)
206 {}
207 explicit RingIterator(nonconst_value_type* pRing, bool bStart = true)
208 : m_pCurrent(nullptr)
209 , m_pStart(pRing)
210 {
211 if(!bStart)
212 m_pCurrent = m_pStart;
213 }
214
215 private:
216 friend class boost::iterator_core_access;
217 void increment()
218 { m_pCurrent = m_pCurrent ? m_pCurrent->GetNextInRing() : m_pStart->GetNextInRing(); }
219 bool equal(RingIterator const& other) const
220 {
221 // we never want to compare iterators from
222 // different rings or starting points
223 assert(m_pStart == other.m_pStart)(static_cast <bool> (m_pStart == other.m_pStart) ? void
(0) : __assert_fail ("m_pStart == other.m_pStart", "/home/maarten/src/libreoffice/core/sw/inc/ring.hxx"
, 223, __extension__ __PRETTY_FUNCTION__))
;
224 return m_pCurrent == other.m_pCurrent;
225 }
226 value_type& dereference() const
227 { return m_pCurrent ? *m_pCurrent : * m_pStart; }
228 /**
229 * value_type is:
230 * - pointing to the current item in the iteration in general
231 * - nullptr if on the first item (begin())
232 * - m_pStart when beyond the last item (end())
233 */
234 nonconst_value_type* m_pCurrent;
235 /** the first item of the iteration */
236 nonconst_value_type* m_pStart;
237 };
238
239 template <typename value_type>
240 inline typename Ring<value_type>::ring_container Ring<value_type>::GetRingContainer()
241 { return Ring<value_type>::ring_container(static_cast< value_type* >(this)); };
242
243 template <typename value_type>
244 inline typename Ring<value_type>::const_ring_container Ring<value_type>::GetRingContainer() const
245 { return Ring<value_type>::const_ring_container(static_cast< const_value_type* >(this)); };
246
247 template <typename value_type>
248 inline typename RingContainer<value_type>::iterator RingContainer<value_type>::begin()
249 { return RingContainer<value_type>::iterator(const_cast< nonconst_value_type* >(m_pStart)); };
250
251 template <typename value_type>
252 inline typename RingContainer<value_type>::iterator RingContainer<value_type>::end()
253 { return RingContainer<value_type>::iterator(const_cast< nonconst_value_type* >(m_pStart), false); };
254
255 template <typename value_type>
256 inline typename RingContainer<value_type>::const_iterator RingContainer<value_type>::begin() const
257 { return RingContainer<value_type>::const_iterator(const_cast< nonconst_value_type* >(m_pStart)); };
258
259 template <typename value_type>
260 inline typename RingContainer<value_type>::const_iterator RingContainer<value_type>::end() const
261 { return RingContainer<value_type>::const_iterator(const_cast< nonconst_value_type* >(m_pStart), false); };
262}
263#endif
264
265/* vim:set shiftwidth=4 softtabstop=4 expandtab: */