21 #include <osl/diagnose.h>
107 mxDoc->SetInReading(
true );
108 mxDoc->SetInXMLImport( dynamic_cast< XMLReader* >(po) !=
nullptr );
121 pPam =
new SwPaM( nNode );
132 bool bReadPageDescs =
false;
133 bool const bDocUndo =
mxDoc->GetIDocumentUndoRedo().DoesUndo();
134 bool bSaveUndo = bDocUndo &&
mpCursor;
142 mxDoc->GetIDocumentUndoRedo().DelAllUndoObj();
146 mxDoc->GetIDocumentUndoRedo().ClearRedo();
150 mxDoc->GetIDocumentUndoRedo().DoUndo(
false);
162 std::unique_ptr<SwUndoInsDoc> pUndo;
168 std::optional<SwPaM> pUndoPam;
169 if( bDocUndo || mpCursor )
179 aFlyFrameArr.
insert( aFlyFrameArr.
end(),
mxDoc->GetSpzFrameFormats()->begin(),
180 mxDoc->GetSpzFrameFormats()->end() );
187 sal_Int32 nEndContent = pCNd ? pCNd->
Len() - nSttContent : 0;
190 mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
195 ePostReadRedlineFlags =
mxDoc->getIDocumentRedlineAccess().GetRedlineFlags();
204 pCNd =
mxDoc->GetNodes().GoNext( &aEndPos );
207 const sal_Int32 nLen = pCNd->
Len();
208 if( nLen < nEndContent )
211 nEndContent = nLen - nEndContent;
215 if ( pTableBoxStart )
220 mxDoc->ChkBoxNumFormat( *pBox,
true );
227 *pUndoPam->GetMark() = *pPam->
GetPoint();
228 ++pUndoPam->GetPoint()->
nNode;
229 SwNode& rNd = pUndoPam->GetNode();
231 pUndoPam->GetPoint()->nContent.Assign(
232 static_cast<SwContentNode*>(&rNd), nSttContent );
234 pUndoPam->GetPoint()->nContent.Assign(
nullptr, 0 );
245 if (!aFlyFrameArr.
IsAlive(pFrameFormat))
247 if ( (RndStdIds::FLY_AT_PAGE == rAnchor.
GetAnchorId())
250 pUndoPam->GetPoint()->nNode.GetIndex(),
251 pUndoPam->GetMark()->nNode.GetIndex()))
253 if( bChkHeaderFooter &&
254 (RndStdIds::FLY_AT_PARA == rAnchor.
GetAnchorId()) &&
259 mxDoc->DelFrameFormat( pFrameFormat );
266 mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
268 mxDoc->GetIDocumentUndoRedo().DoUndo(
true);
269 mxDoc->GetIDocumentUndoRedo().AppendUndo(
270 std::make_unique<SwUndoInsLayFormat>( pFrameFormat,
SwNodeOffset(0), 0 ) );
271 mxDoc->GetIDocumentUndoRedo().DoUndo(
false);
280 if (RndStdIds::FLY_AT_PAGE == rAnchor.
GetAnchorId())
288 mxDoc->SetContainsAtPageObjWithContentAnchor(
true );
297 aFlyFrameArr.
clear();
299 mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
300 if(
mxDoc->getIDocumentRedlineAccess().IsRedlineOn() )
301 mxDoc->getIDocumentRedlineAccess().AppendRedline(
new SwRangeRedline( RedlineType::Insert, *pUndoPam ),
true);
303 mxDoc->getIDocumentRedlineAccess().SplitRedline( *pUndoPam );
308 mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
309 pUndo->SetInsertRange( *pUndoPam,
false );
311 mxDoc->GetIDocumentUndoRedo().DoUndo(
true);
312 mxDoc->GetIDocumentUndoRedo().AppendUndo( std::move(pUndo) );
313 mxDoc->GetIDocumentUndoRedo().DoUndo(
false);
346 mxDoc->SetInReading(
false );
347 mxDoc->SetInXMLImport(
false );
348 mxDoc->SetInWriterfilterImport(
false);
350 mxDoc->InvalidateNumRules();
351 mxDoc->UpdateNumRule();
352 mxDoc->ChkCondColls();
353 mxDoc->SetAllUniqueFlyNames();
355 mxDoc->GetCellStyles().clear();
357 mxDoc->GetIDocumentUndoRedo().DoUndo(bDocUndo);
358 if (!bReadPageDescs && bSaveUndo )
360 mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
373 mxDoc->getIDocumentLinksAdministration().UpdateLinks();
378 mxDoc->getIDocumentFieldsAccess().SetFieldsDirty(
false,
nullptr,
SwNodeOffset(0));
381 mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
382 mxDoc->SetOle2Link( aOLELink );
385 mxDoc->getIDocumentState().SetModified();
390 if (
mxDoc->getIDocumentLinksAdministration().LinksUpdated() )
392 mxDoc->getIDocumentState().SetModified();
405 :
SwDocFac(pDocument), mpStrm(nullptr), mpMedium(&rMedium), mpCursor(nullptr),
406 maFileName(rFileName), mbSkipImages(
false)
415 :
SwDocFac(&rPam.GetDoc()), mpStrm(&rStrm), mpMedium(nullptr), mpCursor(&rPam),
416 maFileName(rFileName), mbSkipImages(
false)
422 :
SwDocFac(&rPam.GetDoc()), mpStrm(nullptr), mpMedium(&rMedium),
423 mpCursor(&rPam), maFileName(rFileName), mbSkipImages(
false)
429 :
SwDocFac(&rPam.GetDoc()), mpStrm(nullptr), mxStg( rStg ), mpMedium(nullptr), mpCursor(&rPam), maFileName(rFilename), mbSkipImages(
false)
439 m_bHasAskTemplateName(
false), m_bIgnoreHTMLComments(
false), m_bSkipImages(
false)
467 OSL_ENSURE( !aTDir.
HasError(),
"No absolute path for template name!" );
478 &aTstDate, &aTstTime ) &&
494 OSL_ENSURE( !
mxTemplate.is(),
"Who holds the template doc?" );
501 if (aModuleOptions.IsWriter())
510 mxTemplate->GetIDocumentUndoRedo().DoUndo(
false );
512 mxTemplate->RemoveAllFormatLanguageDependencies();
515 SfxMedium aMedium( aFileName, StreamMode::NONE );
524 "TemplatePtr but no template exist!" );
565 mxTemplate->getIDocumentDeviceAccess().getPrinter(
true );
566 mxTemplate->RemoveAllFormatLanguageDependencies();
575 OSL_ENSURE(
m_pMedium,
"Where is the Media??" );
622 sal_uInt16
const s_ids[3] = {
625 for (sal_uInt16
i : s_ids)
697 : m_pStrm(&rStrm), m_pMedium(nullptr), m_pOutPam(nullptr),
m_pShell(&rShell),
698 m_rDoc(*rShell.GetDoc()), m_bWriteAll(bInWriteAll)
703 : m_pStrm(&rStrm), m_pMedium(nullptr), m_pOutPam(nullptr),
m_pShell(nullptr),
m_rDoc(rDocument),
709 : m_pStrm(&rStrm), m_pMedium(nullptr), m_pOutPam(&rPam),
m_pShell(nullptr),
710 m_rDoc(rPam.GetDoc()), m_bWriteAll(bInWriteAll)
715 : m_pStrm(nullptr), m_xStg( rStg ), m_pMedium(nullptr), m_pOutPam(nullptr),
m_pShell(nullptr),
m_rDoc(rDocument), m_bWriteAll(true)
720 : m_pStrm(nullptr), m_pMedium(&rMedium), m_pOutPam(nullptr),
m_pShell(&rShell),
721 m_rDoc(*rShell.GetDoc()), m_bWriteAll(bInWriteAll)
726 : m_pStrm(nullptr), m_pMedium(&rMedium), m_pOutPam(nullptr),
m_pShell(nullptr),
m_rDoc(rDocument),
736 bool bHasMark =
false;
737 std::shared_ptr<SwUnoCursor> pTempCursor;
754 const SwTableNode* pTableNd =
static_cast<const SwTableNode*
>(aBoxes[0]->GetSttNd()->StartOfSectionNode());
755 SwNodeIndex aIdx( xDoc->GetNodes().GetEndOfExtras(), 2 );
757 OSL_ENSURE( pNd,
"Node not found" );
774 bHasMark = bHasMark || pPam->
HasMark();
776 if(bHasMark || pPam == pEnd)
792 pPam =
new SwPaM( *pPam, pPam );
806 pPam = pTempCursor.get();
846 bool bLockedView(
false);
855 std::unique_ptr<PurgeGuard, o3tl::default_delete<PurgeGuard>> xGuard(
new PurgeGuard(*pOutDoc));
860 nError = rxWriter->Write( *pPam, *
m_pMedium, pRealFileName );
862 nError = rxWriter->Write( *pPam, *
m_pStrm, pRealFileName );
864 nError = rxWriter->Write( *pPam,
m_xStg, pRealFileName );
889 if ( !nError.
IsError() && !xDoc.is() )
Starts a section of nodes in the document model.
bool IsSkipImages() const
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
virtual sal_Int32 Len() const
tools::Long GetWidth() const
SVL_DLLPUBLIC bool IsDocument(const OUString &rURL)
virtual bool ReadGlossaries(SwTextBlocks &, bool bSaveRelFiles) const
GtkMediaStream * m_pStream
const SwStartNode * FindHeaderStartNode() const
Marks a position in the document model.
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
void SetHeight(tools::Long n)
bool ReadGlossaries(const Reader &, SwTextBlocks &, bool bSaveRelFiles)
SwTableBox * GetTableBox() const
If node is in a table return the respective table box.
const SwStartNode * FindFooterStartNode() const
bool SttEndDoc(bool bStt)
tools::SvRef< SotStorage > mpStg
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
css::uno::Reference< css::embed::XStorage > mxStg
virtual void SetLinksUpdated(const bool bNewLinksUpdated)=0
rtl::Reference< SwDoc > mxDoc
bool IsFormatsOnly() const
IDocumentLinksAdministration const & getIDocumentLinksAdministration() const
virtual SwReaderType GetReaderType() override
bool SetTemplate(SwDoc &rDoc)
void SetOrganizerMode(bool bSet)
bool m_bTemplateBrowseMode
sal_uInt64 Seek(sal_uInt64 nPos)
tools::SvRef< SotStorage > m_pStorage
static SwContentNode * GoPrevious(SwNodeIndex *)
ErrCode Write(WriterRef const &rxWriter, const OUString *=nullptr)
bool m_bHasAskTemplateName
constexpr OUStringLiteral FILTER_RTF
RTF filter.
void SetReadUTF8(bool bSet)
virtual SwFrameFormat * GetFrameFormatFromPool(sal_uInt16 nId)=0
Return required automatic format.
static bool IsStorageFile(OUString const &rFileName)
bool HasWriterListeners() const
void ReplaceStyles(const SwDoc &rSource, bool bIncludePageStyles=true)
SwContentNode * GetContentNode(bool bPoint=true) const
constexpr tools::Long Width() const
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
void SetSkipImages(bool bSkipImages)
static void ResetFrameFormatAttrs(SfxItemSet &rFrameSet)
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
void SetBlockMode(bool bSet)
const SwTable & GetTable() const
SwReader(SfxMedium &, const OUString &rFilename, SwDoc *pDoc=nullptr)
virtual SwPageDesc * GetPageDescFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return required automatic page style.
bool IsAlive(typename std::remove_pointer< Value >::type const *const p) const
check that given format is still alive (i.e. contained here)
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
SwDoc * GetDoc()
returns Doc. But be careful!
bool IsContentNode() const
PaM is Point and Mark: a selection of the document model.
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
void GetTableSel(const SwCursorShell &rShell, SwSelBoxes &rBoxes, const SwTableSearchType eSearchType)
const SwPosition * GetPoint() const
void SetIgnoreHTMLComments(bool bSet)
virtual bool SetStrmStgPtr()
SwIndex & Assign(SwIndexReg *, sal_Int32)
const SwPageDesc & GetPageDesc(const size_t i) const
SwEditShell const * GetEditShell() const
void SetInWriting(bool bNew)
Helper class to pause starting of threads during existence of an instance of this class...
SwWriter(SvStream &, SwCursorShell &, bool bWriteAll=false)
void Push()
store a copy of the current cursor on the cursor stack
SwContentNode * GetContentNode()
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Marks a character position inside a document model node.
SwDoc * GetTemplateDoc(SwDoc &rDoc)
OUString GetBaseURL(bool bForSaving=false)
IDocumentState const & getIDocumentState() const
void ChgPageDesc(const OUString &rName, const SwPageDesc &)
constexpr OUStringLiteral sRtfWH
Marks a node in the document model.
bool GoInDoc(SwPaM &rPam, SwMoveFnCollection const &fnMove)
static Size GetPaperSize(Paper ePaper, MapUnit eUnit=MapUnit::MapTwip)
tools::Long GetHeight() const
bool SetHTMLTemplate(SwDoc &rDoc)
virtual SfxPrinter * getPrinter(bool bCreate) const =0
Return the printer set at the document.
const std::shared_ptr< const SfxFilter > & GetFilter() const
virtual OUString GetTemplateName(SwDoc &rDoc) const
iterator insert(iterator aIt, Value const &rVal)
void SetWidth(tools::Long n)
void SetBaseURL(const OUString &rURL)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
void MakeHTMLDummyTemplateDoc()
ErrCode Read(const Reader &)
css::uno::Reference< css::embed::XStorage > m_xStg
SwFrameFormat & GetMaster()
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
virtual void SetFltName(const OUString &rFltNm)
SwgReaderOption m_aOption
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
virtual bool SetAttr(const SfxPoolItem &)
made virtual
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
constexpr tools::Long Height() const
virtual bool HasGlossaries() const
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
virtual ErrCode Read(SwDoc &, const OUString &rBaseURL, SwPaM &, const OUString &)=0
virtual void SetFixFields(const DateTime *pNewDateTime)=0
sal_Int32 GetIndex() const
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
void FileLoadedInitHints()
initialize the hints after file loading (which takes shortcuts)
SwTableBox is one table cell in the document model.
static bool sw_MergePortions(SwNode *pNode, void *)
SVL_DLLPUBLIC bool GetModifiedDateTimeOfFile(const OUString &rURL, Date *pDate, tools::Time *pTime)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
const SwStartNode * FindTableBoxStartNode() const
SwMoveFnCollection const & fnMoveBackward
rtl::Reference< SwDoc > mxTemplate
void RemoveAllFormatLanguageDependencies()
virtual size_t GetSectionList(SfxMedium &rMedium, std::vector< OUString > &rStrings) const
css::uno::Reference< css::embed::XStorage > m_xStorage
virtual void ResetError()
constexpr OUStringLiteral FILTER_DOCX
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
DateTime m_aCheckDateTime
static void ResetFrameFormats(SwDoc &rDoc)
bool Pop(PopMode)
delete cursor
void SetTemplateName(const OUString &rDir)
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
void StartAllAction()
For all views of this document.
static bool IsCreateUndoForNewFly(SwFormatAnchor const &rAnchor, SwNodeOffset const nStartNode, SwNodeOffset const nEndNode)
This is not the same as IsDestroyFrameAnchoredAtChar() and intentionally so: because the SwUndoInsert...
SwContentNode * GoNext(SwNodeIndex *) const
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
bool HasGlossaries(const Reader &)
#define ERR_SWG_FILE_FORMAT_ERROR
bool IsViewLocked() const
bool MakeCopy(SwDoc &, const SwPosition &, const SwSelBoxes &, bool bCpyName=false, const OUString &rStyleName="") const
virtual SwReaderType GetReaderType()
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
bool m_bDetectedRangeSegmentation false
virtual void ResetModified()=0
SwDoc & GetDoc()
Document is created after calling Read(...).
Base class of the Writer document model elements.