21#include <osl/diagnose.h>
34#include <officecfg/Office/Writer.hxx>
120 mxDoc->SetInReading(
true );
121 mxDoc->SetInXMLImport(
dynamic_cast< XMLReader*
>(po) !=
nullptr );
144 bool bReadPageDescs =
false;
145 bool const bDocUndo =
mxDoc->GetIDocumentUndoRedo().DoesUndo();
146 bool bSaveUndo = bDocUndo &&
mpCursor;
154 mxDoc->GetIDocumentUndoRedo().DelAllUndoObj();
158 mxDoc->GetIDocumentUndoRedo().ClearRedo();
162 mxDoc->GetIDocumentUndoRedo().DoUndo(
false);
174 std::unique_ptr<SwUndoInsDoc> pUndo;
180 std::optional<SwPaM> pUndoPam;
191 aFlyFrameArr.
insert( aFlyFrameArr.
end(),
mxDoc->GetSpzFrameFormats()->begin(),
192 mxDoc->GetSpzFrameFormats()->end() );
199 sal_Int32 nEndContent = pCNd ? pCNd->
Len() - nSttContent : 0;
202 mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
207 ePostReadRedlineFlags =
mxDoc->getIDocumentRedlineAccess().GetRedlineFlags();
216 pCNd =
mxDoc->GetNodes().GoNext( &aEndPos );
218 const sal_Int32 nLen = pCNd->
Len();
219 if( nLen < nEndContent )
222 nEndContent = nLen - nEndContent;
226 if ( pTableBoxStart )
231 mxDoc->ChkBoxNumFormat( *pBox,
true );
238 *pUndoPam->GetMark() = *pPam->
GetPoint();
240 SwNode& rNd = pUndoPam->GetPointNode();
242 pUndoPam->GetPoint()->SetContent( nSttContent );
253 if (!aFlyFrameArr.
IsAlive(pFrameFormat))
255 if ( (RndStdIds::FLY_AT_PAGE == rAnchor.
GetAnchorId())
258 pUndoPam->GetPoint()->GetNodeIndex(),
259 pUndoPam->GetMark()->GetNodeIndex()))
261 if( bChkHeaderFooter &&
262 (RndStdIds::FLY_AT_PARA == rAnchor.
GetAnchorId()) &&
267 mxDoc->DelFrameFormat( pFrameFormat );
274 mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
276 mxDoc->GetIDocumentUndoRedo().DoUndo(
true);
277 mxDoc->GetIDocumentUndoRedo().AppendUndo(
278 std::make_unique<SwUndoInsLayFormat>( pFrameFormat,
SwNodeOffset(0), 0 ) );
279 mxDoc->GetIDocumentUndoRedo().DoUndo(
false);
282 if( pFrameFormat->HasWriterListeners() )
288 if (RndStdIds::FLY_AT_PAGE == rAnchor.
GetAnchorId())
296 mxDoc->SetContainsAtPageObjWithContentAnchor(
true );
305 aFlyFrameArr.
clear();
307 mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
308 if(
mxDoc->getIDocumentRedlineAccess().IsRedlineOn() )
309 mxDoc->getIDocumentRedlineAccess().AppendRedline(
new SwRangeRedline( RedlineType::Insert, *pUndoPam ),
true);
311 mxDoc->getIDocumentRedlineAccess().SplitRedline( *pUndoPam );
316 mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
317 pUndo->SetInsertRange( *pUndoPam,
false );
319 mxDoc->GetIDocumentUndoRedo().DoUndo(
true);
320 mxDoc->GetIDocumentUndoRedo().AppendUndo( std::move(pUndo) );
321 mxDoc->GetIDocumentUndoRedo().DoUndo(
false);
354 mxDoc->SetInReading(
false );
355 mxDoc->SetInXMLImport(
false );
356 mxDoc->SetInWriterfilterImport(
false);
358 mxDoc->InvalidateNumRules();
359 mxDoc->UpdateNumRule();
360 mxDoc->ChkCondColls();
361 mxDoc->SetAllUniqueFlyNames();
363 mxDoc->GetCellStyles().clear();
365 mxDoc->GetIDocumentUndoRedo().DoUndo(bDocUndo);
366 if (!bReadPageDescs && bSaveUndo )
368 mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
381 mxDoc->getIDocumentLinksAdministration().UpdateLinks();
386 mxDoc->getIDocumentFieldsAccess().SetFieldsDirty(
true,
nullptr,
SwNodeOffset(0));
389 mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
390 mxDoc->SetOle2Link( aOLELink );
393 mxDoc->getIDocumentState().SetModified();
398 if (
mxDoc->getIDocumentLinksAdministration().LinksUpdated() )
400 mxDoc->getIDocumentState().SetModified();
413 :
SwDocFac(pDocument), mpStrm(nullptr), mpMedium(&rMedium), mpCursor(nullptr),
414 maFileName(
std::move(aFileName)), mbSkipImages(false)
423 :
SwDocFac(&rPam.GetDoc()), mpStrm(&
rStrm), mpMedium(nullptr), mpCursor(&rPam),
424 maFileName(
std::move(aFileName)), mbSkipImages(false)
430 :
SwDocFac(&rPam.GetDoc()), mpStrm(nullptr), mpMedium(&rMedium),
431 mpCursor(&rPam), maFileName(
std::move(aFileName)), mbSkipImages(false)
437 :
SwDocFac(&rPam.GetDoc()), mpStrm(nullptr), mxStg(
std::move(xStg) ), mpMedium(nullptr), mpCursor(&rPam), maFileName(
std::move(aFilename)), mbSkipImages(false)
445 m_pStream(nullptr), m_pMedium(nullptr), m_bInsertMode(false),
446 m_bTemplateBrowseMode(false), m_bReadUTF8(false), m_bBlockMode(false), m_bOrganizerMode(false),
447 m_bHasAskTemplateName(false), m_bIgnoreHTMLComments(false), m_bSkipImages(false)
475 OSL_ENSURE( !aTDir.
HasError(),
"No absolute path for template name!" );
486 &aTstDate, &aTstTime ) &&
502 OSL_ENSURE( !
mxTemplate.is(),
"Who holds the template doc?" );
518 mxTemplate->GetIDocumentUndoRedo().DoUndo(
false );
520 mxTemplate->RemoveAllFormatLanguageDependencies();
523 SfxMedium aMedium( aFileName, StreamMode::NONE );
532 "TemplatePtr but no template exist!" );
573 mxTemplate->getIDocumentDeviceAccess().getPrinter(
true );
574 mxTemplate->RemoveAllFormatLanguageDependencies();
583 OSL_ENSURE(
m_pMedium,
"Where is the Media??" );
630 sal_uInt16
const s_ids[3] = {
633 for (sal_uInt16
i : s_ids)
705 : m_pStrm(&
rStrm), m_pMedium(nullptr), m_pOutPam(nullptr),
m_pShell(&rShell),
706 m_rDoc(*rShell.GetDoc()), m_bWriteAll(bInWriteAll)
711 : m_pStrm(&
rStrm), m_pMedium(nullptr), m_pOutPam(nullptr),
m_pShell(nullptr),
m_rDoc(rDocument),
717 : m_pStrm(&
rStrm), m_pMedium(nullptr), m_pOutPam(&rPam),
m_pShell(nullptr),
718 m_rDoc(rPam.GetDoc()), m_bWriteAll(bInWriteAll)
723 : m_pStrm(nullptr), m_xStg(
std::move(xStg) ), m_pMedium(nullptr), m_pOutPam(nullptr),
m_pShell(nullptr),
m_rDoc(rDocument), m_bWriteAll(true)
728 : m_pStrm(nullptr), m_pMedium(&rMedium), m_pOutPam(nullptr),
m_pShell(&rShell),
729 m_rDoc(*rShell.GetDoc()), m_bWriteAll(bInWriteAll)
734 : m_pStrm(nullptr), m_pMedium(&rMedium), m_pOutPam(nullptr),
m_pShell(nullptr),
m_rDoc(rDocument),
750 bool bHasMark =
false;
751 std::shared_ptr<SwUnoCursor> pTempCursor;
768 const SwTableNode* pTableNd =
static_cast<const SwTableNode*
>(aBoxes[0]->GetSttNd()->StartOfSectionNode());
769 SwNodeIndex aIdx( xDoc->GetNodes().GetEndOfExtras(), 2 );
771 OSL_ENSURE( pNd,
"Node not found" );
790 }
while (!bHasMark && pPam != pEnd);
804 pPam =
new SwPaM( *pPam, pPam );
818 pPam = pTempCursor.get();
858 bool bLockedView(
false);
867 std::unique_ptr<PurgeGuard, o3tl::default_delete<PurgeGuard>> xGuard(
new PurgeGuard(*pOutDoc));
872 nError = rxWriter->Write( *pPam, *
m_pMedium, pRealFileName );
874 nError = rxWriter->Write( *pPam, *
m_pStrm, pRealFileName );
876 nError = rxWriter->Write( *pPam,
m_xStg, pRealFileName );
901 if ( !nError.
IsError() && !xDoc.is() )
virtual SfxPrinter * getPrinter(bool bCreate) const =0
Return the printer set at the document.
virtual void SetFixFields(const DateTime *pNewDateTime)=0
virtual void SetLinksUpdated(const bool bNewLinksUpdated)=0
virtual void ResetModified()=0
virtual SwFrameFormat * GetFrameFormatFromPool(sal_uInt16 nId)=0
Return required automatic format.
virtual SwPageDesc * GetPageDescFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return required automatic page style.
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool SetTemplate(SwDoc &rDoc)
virtual bool HasGlossaries() const
SwDoc * GetTemplateDoc(SwDoc &rDoc)
static void ResetFrameFormats(SwDoc &rDoc)
bool m_bTemplateBrowseMode
bool m_bHasAskTemplateName
tools::SvRef< SotStorage > m_pStorage
virtual bool ReadGlossaries(SwTextBlocks &, bool bSaveRelFiles) const
virtual OUString GetTemplateName(SwDoc &rDoc) const
rtl::Reference< SwDoc > mxTemplate
SwgReaderOption m_aOption
void MakeHTMLDummyTemplateDoc()
DateTime m_aCheckDateTime
void SetReadUTF8(bool bSet)
void SetBlockMode(bool bSet)
void SetIgnoreHTMLComments(bool bSet)
virtual void SetFltName(const OUString &rFltNm)
virtual bool SetStrmStgPtr()
void SetTemplateName(const OUString &rDir)
virtual SwReaderType GetReaderType()
virtual size_t GetSectionList(SfxMedium &rMedium, std::vector< OUString > &rStrings) const
void SetOrganizerMode(bool bSet)
virtual ErrCode Read(SwDoc &, const OUString &rBaseURL, SwPaM &, const OUString &)=0
css::uno::Reference< css::embed::XStorage > m_xStorage
static void ResetFrameFormatAttrs(SfxItemSet &rFrameSet)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const std::shared_ptr< const SfxFilter > & GetFilter() const
OUString GetBaseURL(bool bForSaving=false)
bool IsSkipImages() const
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static bool IsStorageFile(OUString const &rFileName)
virtual SwReaderType GetReaderType() override
virtual void ResetError()
sal_uInt64 Seek(sal_uInt64 nPos)
static Size GetPaperSize(Paper ePaper, MapUnit eUnit=MapUnit::MapTwip)
tools::Long GetHeight() const
tools::Long GetWidth() const
void SetHeight(tools::Long n)
void SetWidth(tools::Long n)
rtl_TextEncoding m_eCharSet
virtual bool SetAttr(const SfxPoolItem &)
made virtual
virtual sal_Int32 Len() const
virtual SwFormatColl * ChgFormatColl(SwFormatColl *)
bool Pop(PopMode, ::std::optional< SwCallLink > &roLink)
void Push()
store a copy of the current cursor on the cursor stack
bool SttEndDoc(bool bStt)
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
SwDoc & GetDoc()
Document is created after calling Read(...).
rtl::Reference< SwDoc > mxDoc
SwDoc * GetDoc()
returns Doc. But be careful!
IDocumentState const & getIDocumentState() const
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
void RemoveAllFormatLanguageDependencies()
IDocumentLinksAdministration const & getIDocumentLinksAdministration() const
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
SwEditShell const * GetEditShell() const
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
void ChgPageDesc(const OUString &rName, const SwPageDesc &)
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
void ReplaceStyles(const SwDoc &rSource, bool bIncludePageStyles=true)
void SetInWriting(bool bNew)
const SwPageDesc & GetPageDesc(const size_t i) const
void StartAllAction()
For all views of this document.
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Marks a node in the document model.
Base class of the Writer document model elements.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
const SwStartNode * FindTableBoxStartNode() const
const SwStartNode * FindFooterStartNode() const
SwTableBox * GetTableBox() const
If node is in a table return the respective table box.
bool IsContentNode() const
const SwStartNode * FindHeaderStartNode() const
SwContentNode * GetContentNode()
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
static SwContentNode * GoPrevious(SwNodeIndex *)
SwContentNode * GoNext(SwNodeIndex *) const
PaM is Point and Mark: a selection of the document model.
const SwPosition * GetMark() const
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
SwContentNode * GetPointContentNode() const
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
const SwPosition * GetPoint() const
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
SwFrameFormat & GetMaster()
Helper class to pause starting of threads during existence of an instance of this class.
SwReader(SfxMedium &, OUString aFilename, SwDoc *pDoc=nullptr)
ErrCode Read(const Reader &)
bool ReadGlossaries(const Reader &, SwTextBlocks &, bool bSaveRelFiles)
tools::SvRef< SotStorage > mpStg
bool HasGlossaries(const Reader &)
void SetSkipImages(bool bSkipImages)
void SetBaseURL(const OUString &rURL)
css::uno::Reference< css::embed::XStorage > mxStg
Starts a section of nodes in the document model.
SwTableBox is one table cell in the document model.
const SwTable & GetTable() const
bool MakeCopy(SwDoc &, const SwPosition &, const SwSelBoxes &, bool bCpyName=false, const OUString &rStyleName="") const
void FileLoadedInitHints()
initialize the hints after file loading (which takes shortcuts)
Undo for Insert -> Text from file.
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...
iterator insert(iterator aIt, Value const &rVal)
bool IsAlive(typename std::remove_pointer< Value >::type const *const p) const
check that given format is still alive (i.e. contained here)
bool IsViewLocked() const
SwWriter(SvStream &, SwCursorShell &, bool bWriteAll=false)
ErrCode Write(WriterRef const &rxWriter, const OUString *=nullptr)
css::uno::Reference< css::embed::XStorage > m_xStg
bool IsFormatsOnly() const
GtkMediaStream * m_pStream
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(165)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(112)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(97)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(98)
constexpr OUStringLiteral sRtfWH
constexpr OUStringLiteral FILTER_RTF
RTF filter.
constexpr OUStringLiteral FILTER_DOCX
LineEnd GetSystemLineEnd()
SVL_DLLPUBLIC bool IsDocument(const OUString &rURL)
SVL_DLLPUBLIC bool GetModifiedDateTimeOfFile(const OUString &rURL, Date *pDate, tools::Time *pTime)
constexpr OUStringLiteral EMPTY
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
bool GoInDoc(SwPaM &rPam, SwMoveFnCollection const &fnMove)
SwMoveFnCollection const & fnMoveBackward
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
@ RES_POOLCOLL_TEXT
Text body.
@ RES_POOLFRM_FRAME
Frame.
@ RES_POOLFRM_GRAPHIC
Graphics.
bool SetHTMLTemplate(SwDoc &rDoc)
static bool isFlyNode(const SwPaM &pam)
static bool sw_MergePortions(SwNode *pNode, void *)
Marks a position in the document model.
void Adjust(SwNodeOffset nDelta)
Adjust node position, and resets content position to zero.
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
sal_Int32 GetContentIndex() const
#define ERR_SWG_FILE_FORMAT_ERROR
void GetTableSel(const SwCursorShell &rShell, SwSelBoxes &rBoxes, const SwTableSearchType eSearchType)