From 267c6f2ac71f92999e969232431ba04678e7437e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 07:54:39 +0200 Subject: Adding upstream version 4:24.2.0. Signed-off-by: Daniel Baumann --- sw/source/core/inc/AccessibilityCheck.hxx | 59 + sw/source/core/inc/AccessibilityIssue.hxx | 89 ++ sw/source/core/inc/DateFormFieldButton.hxx | 47 + .../core/inc/DocumentChartDataProviderManager.hxx | 65 + .../core/inc/DocumentContentOperationsManager.hxx | 190 +++ sw/source/core/inc/DocumentDeviceManager.hxx | 81 ++ sw/source/core/inc/DocumentDrawModelManager.hxx | 86 ++ sw/source/core/inc/DocumentExternalDataManager.hxx | 44 + sw/source/core/inc/DocumentFieldsManager.hxx | 111 ++ sw/source/core/inc/DocumentLayoutManager.hxx | 76 + .../inc/DocumentLinksAdministrationManager.hxx | 86 ++ sw/source/core/inc/DocumentListItemsManager.hxx | 71 + sw/source/core/inc/DocumentListsManager.hxx | 74 + sw/source/core/inc/DocumentOutlineNodesManager.hxx | 65 + sw/source/core/inc/DocumentRedlineManager.hxx | 189 +++ sw/source/core/inc/DocumentSettingManager.hxx | 227 +++ sw/source/core/inc/DocumentStateManager.hxx | 62 + sw/source/core/inc/DocumentStatisticsManager.hxx | 69 + sw/source/core/inc/DocumentStylePoolManager.hxx | 61 + sw/source/core/inc/DocumentTimerManager.hxx | 87 ++ sw/source/core/inc/DropDownFormFieldButton.hxx | 41 + sw/source/core/inc/FormFieldButton.hxx | 52 + sw/source/core/inc/GraphicSizeCheck.hxx | 111 ++ sw/source/core/inc/MarkManager.hxx | 168 +++ sw/source/core/inc/ModelTraverser.hxx | 51 + sw/source/core/inc/SearchResultLocator.hxx | 71 + sw/source/core/inc/SwGrammarMarkUp.hxx | 71 + sw/source/core/inc/SwPortionHandler.hxx | 98 ++ sw/source/core/inc/SwUndoFmt.hxx | 257 ++++ sw/source/core/inc/SwUndoPageDesc.hxx | 88 ++ sw/source/core/inc/SwUndoTOXChange.hxx | 45 + sw/source/core/inc/SwXMLBlockExport.hxx | 63 + sw/source/core/inc/SwXMLBlockImport.hxx | 126 ++ sw/source/core/inc/SwXMLTextBlocks.hxx | 98 ++ sw/source/core/inc/SwXTextDefaults.hxx | 65 + sw/source/core/inc/TextFrameIndex.hxx | 26 + sw/source/core/inc/ThemeColorChanger.hxx | 33 + sw/source/core/inc/UndoAttribute.hxx | 269 ++++ sw/source/core/inc/UndoBookmark.hxx | 157 +++ sw/source/core/inc/UndoCore.hxx | 297 ++++ sw/source/core/inc/UndoDelete.hxx | 112 ++ sw/source/core/inc/UndoDraw.hxx | 134 ++ sw/source/core/inc/UndoInsert.hxx | 228 +++ sw/source/core/inc/UndoManager.hxx | 143 ++ sw/source/core/inc/UndoNumbering.hxx | 142 ++ sw/source/core/inc/UndoOverwrite.hxx | 93 ++ sw/source/core/inc/UndoRedline.hxx | 148 ++ sw/source/core/inc/UndoSection.hxx | 101 ++ sw/source/core/inc/UndoSort.hxx | 76 + sw/source/core/inc/UndoSplitMove.hxx | 85 ++ sw/source/core/inc/UndoTable.hxx | 429 ++++++ sw/source/core/inc/UndoThemeChange.hxx | 35 + sw/source/core/inc/acorrect.hxx | 121 ++ sw/source/core/inc/anchoredobjectposition.hxx | 447 ++++++ sw/source/core/inc/annotationmark.hxx | 48 + .../core/inc/ascharanchoredobjectposition.hxx | 160 +++ sw/source/core/inc/attrhint.hxx | 31 + sw/source/core/inc/bodyfrm.hxx | 42 + sw/source/core/inc/bookmark.hxx | 367 +++++ sw/source/core/inc/cellfrm.hxx | 78 ++ sw/source/core/inc/cntfrm.hxx | 147 ++ sw/source/core/inc/colfrm.hxx | 42 + sw/source/core/inc/contentcontrolbutton.hxx | 53 + sw/source/core/inc/crossrefbookmark.hxx | 88 ++ sw/source/core/inc/datecontentcontrolbutton.hxx | 41 + sw/source/core/inc/dbg_lay.hxx | 105 ++ sw/source/core/inc/dflyobj.hxx | 154 +++ sw/source/core/inc/dialoghelp.hxx | 30 + sw/source/core/inc/docedt.hxx | 31 + sw/source/core/inc/docfld.hxx | 188 +++ sw/source/core/inc/docredln.hxx | 35 + sw/source/core/inc/docsort.hxx | 152 ++ sw/source/core/inc/doctxm.hxx | 114 ++ sw/source/core/inc/drawfont.hxx | 639 +++++++++ .../core/inc/dropdowncontentcontrolbutton.hxx | 39 + sw/source/core/inc/dumpfilter.hxx | 59 + sw/source/core/inc/dview.hxx | 125 ++ sw/source/core/inc/environmentofanchoredobject.hxx | 94 ++ sw/source/core/inc/fefly.hxx | 30 + sw/source/core/inc/fieldhint.hxx | 44 + sw/source/core/inc/flowfrm.hxx | 280 ++++ sw/source/core/inc/flyfrm.hxx | 316 +++++ sw/source/core/inc/flyfrms.hxx | 254 ++++ sw/source/core/inc/fntcache.hxx | 146 ++ sw/source/core/inc/fntcap.hxx | 37 + sw/source/core/inc/frame.hxx | 1446 ++++++++++++++++++++ sw/source/core/inc/frminf.hxx | 75 + sw/source/core/inc/frmtool.hxx | 626 +++++++++ sw/source/core/inc/ftnboss.hxx | 131 ++ sw/source/core/inc/ftnfrm.hxx | 171 +++ sw/source/core/inc/hffrm.hxx | 68 + sw/source/core/inc/ifinishedthreadlistener.hxx | 46 + sw/source/core/inc/layact.hxx | 235 ++++ sw/source/core/inc/laycache.hxx | 69 + sw/source/core/inc/layfrm.hxx | 225 +++ sw/source/core/inc/layouter.hxx | 146 ++ sw/source/core/inc/movedfwdfrmsbyobjpos.hxx | 58 + sw/source/core/inc/mvsave.hxx | 201 +++ sw/source/core/inc/node2lay.hxx | 90 ++ sw/source/core/inc/noteurl.hxx | 32 + sw/source/core/inc/notxtfrm.hxx | 116 ++ sw/source/core/inc/objectformatter.hxx | 175 +++ sw/source/core/inc/observablethread.hxx | 87 ++ sw/source/core/inc/pagedeschint.hxx | 40 + sw/source/core/inc/pagefrm.hxx | 468 +++++++ sw/source/core/inc/paintfrm.hxx | 37 + sw/source/core/inc/pamtyp.hxx | 122 ++ sw/source/core/inc/prevwpage.hxx | 53 + sw/source/core/inc/ptqueue.hxx | 57 + sw/source/core/inc/retrievedinputstreamdata.hxx | 90 ++ sw/source/core/inc/retrieveinputstream.hxx | 55 + sw/source/core/inc/retrieveinputstreamconsumer.hxx | 59 + sw/source/core/inc/rolbck.hxx | 443 ++++++ sw/source/core/inc/rootfrm.hxx | 489 +++++++ sw/source/core/inc/rowfrm.hxx | 131 ++ sw/source/core/inc/scriptinfo.hxx | 398 ++++++ sw/source/core/inc/sectfrm.hxx | 189 +++ sw/source/core/inc/sortedobjs.hxx | 100 ++ sw/source/core/inc/swblocks.hxx | 129 ++ sw/source/core/inc/swcache.hxx | 268 ++++ sw/source/core/inc/swfntcch.hxx | 76 + sw/source/core/inc/swfont.hxx | 1010 ++++++++++++++ sw/source/core/inc/swselectionlist.hxx | 91 ++ sw/source/core/inc/swthreadjoiner.hxx | 42 + sw/source/core/inc/swthreadmanager.hxx | 78 ++ sw/source/core/inc/tabfrm.hxx | 265 ++++ sw/source/core/inc/tblrwcl.hxx | 197 +++ sw/source/core/inc/textapi.hxx | 66 + sw/source/core/inc/threadlistener.hxx | 55 + .../core/inc/tocntntanchoredobjectposition.hxx | 93 ++ .../core/inc/tolayoutanchoredobjectposition.hxx | 52 + sw/source/core/inc/txmsrt.hxx | 310 +++++ sw/source/core/inc/txtfly.hxx | 389 ++++++ sw/source/core/inc/txtfrm.hxx | 1060 ++++++++++++++ sw/source/core/inc/txttypes.hxx | 98 ++ sw/source/core/inc/undoflystrattr.hxx | 66 + sw/source/core/inc/unobookmark.hxx | 240 ++++ sw/source/core/inc/unocontentcontrol.hxx | 170 +++ sw/source/core/inc/unoevent.hxx | 95 ++ sw/source/core/inc/unofield.hxx | 229 ++++ sw/source/core/inc/unoflatpara.hxx | 138 ++ sw/source/core/inc/unofldmid.h | 58 + sw/source/core/inc/unofootnote.hxx | 136 ++ sw/source/core/inc/unoidx.hxx | 214 +++ sw/source/core/inc/unolinebreak.hxx | 86 ++ sw/source/core/inc/unometa.hxx | 265 ++++ sw/source/core/inc/unoparaframeenum.hxx | 79 ++ sw/source/core/inc/unoport.hxx | 314 +++++ sw/source/core/inc/unorefmark.hxx | 108 ++ sw/source/core/inc/unosection.hxx | 155 +++ sw/source/core/inc/unotextmarkup.hxx | 103 ++ sw/source/core/inc/viewimp.hxx | 317 +++++ sw/source/core/inc/visiturl.hxx | 40 + sw/source/core/inc/vprint.hxx | 34 + sw/source/core/inc/wrong.hxx | 413 ++++++ 155 files changed, 24556 insertions(+) create mode 100644 sw/source/core/inc/AccessibilityCheck.hxx create mode 100644 sw/source/core/inc/AccessibilityIssue.hxx create mode 100644 sw/source/core/inc/DateFormFieldButton.hxx create mode 100644 sw/source/core/inc/DocumentChartDataProviderManager.hxx create mode 100644 sw/source/core/inc/DocumentContentOperationsManager.hxx create mode 100644 sw/source/core/inc/DocumentDeviceManager.hxx create mode 100644 sw/source/core/inc/DocumentDrawModelManager.hxx create mode 100644 sw/source/core/inc/DocumentExternalDataManager.hxx create mode 100644 sw/source/core/inc/DocumentFieldsManager.hxx create mode 100644 sw/source/core/inc/DocumentLayoutManager.hxx create mode 100644 sw/source/core/inc/DocumentLinksAdministrationManager.hxx create mode 100644 sw/source/core/inc/DocumentListItemsManager.hxx create mode 100644 sw/source/core/inc/DocumentListsManager.hxx create mode 100644 sw/source/core/inc/DocumentOutlineNodesManager.hxx create mode 100644 sw/source/core/inc/DocumentRedlineManager.hxx create mode 100644 sw/source/core/inc/DocumentSettingManager.hxx create mode 100644 sw/source/core/inc/DocumentStateManager.hxx create mode 100644 sw/source/core/inc/DocumentStatisticsManager.hxx create mode 100644 sw/source/core/inc/DocumentStylePoolManager.hxx create mode 100644 sw/source/core/inc/DocumentTimerManager.hxx create mode 100644 sw/source/core/inc/DropDownFormFieldButton.hxx create mode 100644 sw/source/core/inc/FormFieldButton.hxx create mode 100644 sw/source/core/inc/GraphicSizeCheck.hxx create mode 100644 sw/source/core/inc/MarkManager.hxx create mode 100644 sw/source/core/inc/ModelTraverser.hxx create mode 100644 sw/source/core/inc/SearchResultLocator.hxx create mode 100644 sw/source/core/inc/SwGrammarMarkUp.hxx create mode 100644 sw/source/core/inc/SwPortionHandler.hxx create mode 100644 sw/source/core/inc/SwUndoFmt.hxx create mode 100644 sw/source/core/inc/SwUndoPageDesc.hxx create mode 100644 sw/source/core/inc/SwUndoTOXChange.hxx create mode 100644 sw/source/core/inc/SwXMLBlockExport.hxx create mode 100644 sw/source/core/inc/SwXMLBlockImport.hxx create mode 100644 sw/source/core/inc/SwXMLTextBlocks.hxx create mode 100644 sw/source/core/inc/SwXTextDefaults.hxx create mode 100644 sw/source/core/inc/TextFrameIndex.hxx create mode 100644 sw/source/core/inc/ThemeColorChanger.hxx create mode 100644 sw/source/core/inc/UndoAttribute.hxx create mode 100644 sw/source/core/inc/UndoBookmark.hxx create mode 100644 sw/source/core/inc/UndoCore.hxx create mode 100644 sw/source/core/inc/UndoDelete.hxx create mode 100644 sw/source/core/inc/UndoDraw.hxx create mode 100644 sw/source/core/inc/UndoInsert.hxx create mode 100644 sw/source/core/inc/UndoManager.hxx create mode 100644 sw/source/core/inc/UndoNumbering.hxx create mode 100644 sw/source/core/inc/UndoOverwrite.hxx create mode 100644 sw/source/core/inc/UndoRedline.hxx create mode 100644 sw/source/core/inc/UndoSection.hxx create mode 100644 sw/source/core/inc/UndoSort.hxx create mode 100644 sw/source/core/inc/UndoSplitMove.hxx create mode 100644 sw/source/core/inc/UndoTable.hxx create mode 100644 sw/source/core/inc/UndoThemeChange.hxx create mode 100644 sw/source/core/inc/acorrect.hxx create mode 100644 sw/source/core/inc/anchoredobjectposition.hxx create mode 100644 sw/source/core/inc/annotationmark.hxx create mode 100644 sw/source/core/inc/ascharanchoredobjectposition.hxx create mode 100644 sw/source/core/inc/attrhint.hxx create mode 100644 sw/source/core/inc/bodyfrm.hxx create mode 100644 sw/source/core/inc/bookmark.hxx create mode 100644 sw/source/core/inc/cellfrm.hxx create mode 100644 sw/source/core/inc/cntfrm.hxx create mode 100644 sw/source/core/inc/colfrm.hxx create mode 100644 sw/source/core/inc/contentcontrolbutton.hxx create mode 100644 sw/source/core/inc/crossrefbookmark.hxx create mode 100644 sw/source/core/inc/datecontentcontrolbutton.hxx create mode 100644 sw/source/core/inc/dbg_lay.hxx create mode 100644 sw/source/core/inc/dflyobj.hxx create mode 100644 sw/source/core/inc/dialoghelp.hxx create mode 100644 sw/source/core/inc/docedt.hxx create mode 100644 sw/source/core/inc/docfld.hxx create mode 100644 sw/source/core/inc/docredln.hxx create mode 100644 sw/source/core/inc/docsort.hxx create mode 100644 sw/source/core/inc/doctxm.hxx create mode 100644 sw/source/core/inc/drawfont.hxx create mode 100644 sw/source/core/inc/dropdowncontentcontrolbutton.hxx create mode 100644 sw/source/core/inc/dumpfilter.hxx create mode 100644 sw/source/core/inc/dview.hxx create mode 100644 sw/source/core/inc/environmentofanchoredobject.hxx create mode 100644 sw/source/core/inc/fefly.hxx create mode 100644 sw/source/core/inc/fieldhint.hxx create mode 100644 sw/source/core/inc/flowfrm.hxx create mode 100644 sw/source/core/inc/flyfrm.hxx create mode 100644 sw/source/core/inc/flyfrms.hxx create mode 100644 sw/source/core/inc/fntcache.hxx create mode 100644 sw/source/core/inc/fntcap.hxx create mode 100644 sw/source/core/inc/frame.hxx create mode 100644 sw/source/core/inc/frminf.hxx create mode 100644 sw/source/core/inc/frmtool.hxx create mode 100644 sw/source/core/inc/ftnboss.hxx create mode 100644 sw/source/core/inc/ftnfrm.hxx create mode 100644 sw/source/core/inc/hffrm.hxx create mode 100644 sw/source/core/inc/ifinishedthreadlistener.hxx create mode 100644 sw/source/core/inc/layact.hxx create mode 100644 sw/source/core/inc/laycache.hxx create mode 100644 sw/source/core/inc/layfrm.hxx create mode 100644 sw/source/core/inc/layouter.hxx create mode 100644 sw/source/core/inc/movedfwdfrmsbyobjpos.hxx create mode 100644 sw/source/core/inc/mvsave.hxx create mode 100644 sw/source/core/inc/node2lay.hxx create mode 100644 sw/source/core/inc/noteurl.hxx create mode 100644 sw/source/core/inc/notxtfrm.hxx create mode 100644 sw/source/core/inc/objectformatter.hxx create mode 100644 sw/source/core/inc/observablethread.hxx create mode 100644 sw/source/core/inc/pagedeschint.hxx create mode 100644 sw/source/core/inc/pagefrm.hxx create mode 100644 sw/source/core/inc/paintfrm.hxx create mode 100644 sw/source/core/inc/pamtyp.hxx create mode 100644 sw/source/core/inc/prevwpage.hxx create mode 100644 sw/source/core/inc/ptqueue.hxx create mode 100644 sw/source/core/inc/retrievedinputstreamdata.hxx create mode 100644 sw/source/core/inc/retrieveinputstream.hxx create mode 100644 sw/source/core/inc/retrieveinputstreamconsumer.hxx create mode 100644 sw/source/core/inc/rolbck.hxx create mode 100644 sw/source/core/inc/rootfrm.hxx create mode 100644 sw/source/core/inc/rowfrm.hxx create mode 100644 sw/source/core/inc/scriptinfo.hxx create mode 100644 sw/source/core/inc/sectfrm.hxx create mode 100644 sw/source/core/inc/sortedobjs.hxx create mode 100644 sw/source/core/inc/swblocks.hxx create mode 100644 sw/source/core/inc/swcache.hxx create mode 100644 sw/source/core/inc/swfntcch.hxx create mode 100644 sw/source/core/inc/swfont.hxx create mode 100644 sw/source/core/inc/swselectionlist.hxx create mode 100644 sw/source/core/inc/swthreadjoiner.hxx create mode 100644 sw/source/core/inc/swthreadmanager.hxx create mode 100644 sw/source/core/inc/tabfrm.hxx create mode 100644 sw/source/core/inc/tblrwcl.hxx create mode 100644 sw/source/core/inc/textapi.hxx create mode 100644 sw/source/core/inc/threadlistener.hxx create mode 100644 sw/source/core/inc/tocntntanchoredobjectposition.hxx create mode 100644 sw/source/core/inc/tolayoutanchoredobjectposition.hxx create mode 100644 sw/source/core/inc/txmsrt.hxx create mode 100644 sw/source/core/inc/txtfly.hxx create mode 100644 sw/source/core/inc/txtfrm.hxx create mode 100644 sw/source/core/inc/txttypes.hxx create mode 100644 sw/source/core/inc/undoflystrattr.hxx create mode 100644 sw/source/core/inc/unobookmark.hxx create mode 100644 sw/source/core/inc/unocontentcontrol.hxx create mode 100644 sw/source/core/inc/unoevent.hxx create mode 100644 sw/source/core/inc/unofield.hxx create mode 100644 sw/source/core/inc/unoflatpara.hxx create mode 100644 sw/source/core/inc/unofldmid.h create mode 100644 sw/source/core/inc/unofootnote.hxx create mode 100644 sw/source/core/inc/unoidx.hxx create mode 100644 sw/source/core/inc/unolinebreak.hxx create mode 100644 sw/source/core/inc/unometa.hxx create mode 100644 sw/source/core/inc/unoparaframeenum.hxx create mode 100644 sw/source/core/inc/unoport.hxx create mode 100644 sw/source/core/inc/unorefmark.hxx create mode 100644 sw/source/core/inc/unosection.hxx create mode 100644 sw/source/core/inc/unotextmarkup.hxx create mode 100644 sw/source/core/inc/viewimp.hxx create mode 100644 sw/source/core/inc/visiturl.hxx create mode 100644 sw/source/core/inc/vprint.hxx create mode 100644 sw/source/core/inc/wrong.hxx (limited to 'sw/source/core/inc') diff --git a/sw/source/core/inc/AccessibilityCheck.hxx b/sw/source/core/inc/AccessibilityCheck.hxx new file mode 100644 index 0000000000..caaff19448 --- /dev/null +++ b/sw/source/core/inc/AccessibilityCheck.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include +#include +#include + +namespace sw +{ +/** Base class for accessibility checks */ +class BaseCheck +{ +protected: + sfx::AccessibilityIssueCollection& m_rIssueCollection; + +public: + BaseCheck(sfx::AccessibilityIssueCollection& rIssueCollection) + : m_rIssueCollection(rIssueCollection) + { + } + virtual ~BaseCheck() {} +}; + +class SW_DLLPUBLIC AccessibilityCheck final : public sfx::AccessibilityCheck +{ +private: + SwDoc* m_pDoc; + + std::vector> m_aDocumentChecks; + std::vector> m_aNodeChecks; + + AccessibilityCheck() = delete; + + void init(); + +public: + AccessibilityCheck(SwDoc* pDoc) + : m_pDoc(pDoc) + { + } + + void check() override; + void checkObject(SwNode* pNode, SdrObject* pObject); + void checkNode(SwNode* pNode); + void checkDocumentProperties(); +}; + +} // end sw namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/AccessibilityIssue.hxx b/sw/source/core/inc/AccessibilityIssue.hxx new file mode 100644 index 0000000000..5fe9857b99 --- /dev/null +++ b/sw/source/core/inc/AccessibilityIssue.hxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_ACCESSIBILITYISSUE_HXX +#define INCLUDED_SW_SOURCE_CORE_ACCESSIBILITYISSUE_HXX + +#include +#include +#include + +namespace sw +{ +enum class IssueObject +{ + UNKNOWN, + GRAPHIC, + OLE, + SHAPE, + FORM, + TABLE, + TEXT, + DOCUMENT_TITLE, + DOCUMENT_BACKGROUND, + LANGUAGE_NOT_SET, + FOOTENDNOTE, + TEXTFRAME, + LINKED, +}; + +class SW_DLLPUBLIC AccessibilityIssue final : public sfx::AccessibilityIssue +{ +private: + IssueObject m_eIssueObject; + SwDoc* m_pDoc; + OUString m_sObjectID; + std::vector m_aIssueAdditionalInfo; + SwNode* m_pNode; + SwTextFootnote* m_pTextFootnote; + + sal_Int32 m_nStart; + sal_Int32 m_nEnd; + +public: + AccessibilityIssue(sfx::AccessibilityIssueID eIssueID = sfx::AccessibilityIssueID::UNSPECIFIED); + AccessibilityIssue(AccessibilityIssue const&) = default; + + void setIssueObject(IssueObject eIssueObject); + void setDoc(SwDoc& rDoc); + void setObjectID(OUString const& rID); + void setNode(SwNode* pNode) { m_pNode = pNode; } + void setTextFootnote(SwTextFootnote* pTextFootnote) { m_pTextFootnote = pTextFootnote; } + + void setStart(sal_Int32 nStart) { m_nStart = nStart; } + + void setEnd(sal_Int32 nEnd) { m_nEnd = nEnd; } + + std::vector const& getAdditionalInfo() const { return m_aIssueAdditionalInfo; } + + void setAdditionalInfo(std::vector&& rIssueAdditionalInfo) + { + m_aIssueAdditionalInfo = std::move(rIssueAdditionalInfo); + } + + bool canGotoIssue() const override; + void gotoIssue() const override; + + bool canQuickFixIssue() const override; + void quickFixIssue() const override; + + sal_Int32 getStart() { return m_nStart; } + sal_Int32 getEnd() { return m_nEnd; } + SwNode* getNode() { return m_pNode; } + SwTextFootnote* getTextFootnote() { return m_pTextFootnote; } + + AccessibilityIssue& operator=(const AccessibilityIssue&) = default; +}; + +} // end sw namespace + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DateFormFieldButton.hxx b/sw/source/core/inc/DateFormFieldButton.hxx new file mode 100644 index 0000000000..3d74706a8a --- /dev/null +++ b/sw/source/core/inc/DateFormFieldButton.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_TEXT_DATEFORMEFIELDBUTTO_HXX +#define INCLUDED_SW_SOURCE_CORE_TEXT_DATEFORMEFIELDBUTTO_HXX + +#include "FormFieldButton.hxx" + +class SwEditWin; +class SvNumberFormatter; +namespace sw::mark +{ +class DateFieldmark; +} + +/** + * This button is shown when the cursor is on a date form field. + * The user can select a date from a date picker while filling in a form. + */ +class DateFormFieldButton final : public FormFieldButton +{ +private: + SvNumberFormatter* m_pNumberFormatter; + sw::mark::DateFieldmark* m_pDateFieldmark; + + std::unique_ptr m_xCalendar; + + DECL_LINK(ImplSelectHdl, weld::Calendar&, void); + +public: + DateFormFieldButton(SwEditWin* pEditWin, sw::mark::DateFieldmark& rFieldMark, + SvNumberFormatter* pNumberFormatter); + virtual ~DateFormFieldButton() override; + + virtual void LaunchPopup() override; + virtual void DestroyPopup() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sw/source/core/inc/DocumentChartDataProviderManager.hxx b/sw/source/core/inc/DocumentChartDataProviderManager.hxx new file mode 100644 index 0000000000..f887702bb5 --- /dev/null +++ b/sw/source/core/inc/DocumentChartDataProviderManager.hxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTCHARTDATAPROVIDEMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTCHARTDATAPROVIDEMANAGER_HXX + +#include +#include +#include + +class SwTable; +class SwChartDataProvider; +class SwChartLockController_Helper; +class SwDoc; + + +namespace sw { + +class DocumentChartDataProviderManager final : public IDocumentChartDataProviderAccess +{ + +public: + + DocumentChartDataProviderManager( SwDoc& i_rSwdoc ); + + SwChartDataProvider * GetChartDataProvider( bool bCreate = false ) const override; + + void CreateChartInternalDataProviders( const SwTable *pTable ) override; + + SwChartLockController_Helper & GetChartControllerHelper() override; + + virtual ~DocumentChartDataProviderManager() override; + +private: + + DocumentChartDataProviderManager(DocumentChartDataProviderManager const&) = delete; + DocumentChartDataProviderManager& operator=(DocumentChartDataProviderManager const&) = delete; + + SwDoc& m_rDoc; + + mutable rtl::Reference maChartDataProviderImplRef; + std::unique_ptr mpChartControllerHelper; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DocumentContentOperationsManager.hxx b/sw/source/core/inc/DocumentContentOperationsManager.hxx new file mode 100644 index 0000000000..8332cf34bf --- /dev/null +++ b/sw/source/core/inc/DocumentContentOperationsManager.hxx @@ -0,0 +1,190 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include //Only for lcl_RstTxtAttr + +class SwDoc; +class SwNoTextNode; +class SwFormatColl; +class SwHistory; + +namespace sw +{ + +class DocumentContentOperationsManager final : public IDocumentContentOperations +{ +public: + DocumentContentOperationsManager( SwDoc& i_rSwdoc ); + + //Interface methods: + bool CopyRange(SwPaM&, SwPosition&, SwCopyFlags, sal_uInt32 nMovedID = 0) const override; + + void DeleteSection(SwNode* pNode) override; + + void DeleteRange(SwPaM&) override; + + bool DelFullPara(SwPaM&) override; + + bool DeleteAndJoin(SwPaM&, SwDeleteFlags flags = SwDeleteFlags::Default) override; + + bool MoveRange(SwPaM&, SwPosition&, SwMoveFlags) override; + + bool MoveNodeRange(SwNodeRange&, SwNode&, SwMoveFlags) override; + + void MoveAndJoin(SwPaM&, SwPosition&) override; + + bool Overwrite(const SwPaM &rRg, const OUString& rStr) override; + + bool InsertString(const SwPaM &rRg, const OUString&, + const SwInsertFlags nInsertMode = SwInsertFlags::EMPTYEXPAND ) override; + + void SetIME(bool bIME) override; + + bool GetIME() const override; + + void TransliterateText(const SwPaM& rPaM, utl::TransliterationWrapper&) override; + + SwFlyFrameFormat* InsertGraphic(const SwPaM &rRg, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic, + const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrameFormat*) override; + + void ReRead(SwPaM&, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic) override; + + SwDrawFrameFormat* InsertDrawObj( const SwPaM &rRg, SdrObject& rDrawObj, const SfxItemSet& rFlyAttrSet ) override; + + SwFlyFrameFormat* InsertEmbObject(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj, SfxItemSet* pFlyAttrSet) override; + + SwFlyFrameFormat* InsertOLE(const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect, const SfxItemSet* pFlyAttrSet, + const SfxItemSet* pGrfAttrSet) override; + + bool SplitNode(const SwPosition &rPos, bool bChkTableStart) override; + + bool AppendTextNode(SwPosition& rPos) override; + + bool ReplaceRange(SwPaM& rPam, const OUString& rNewStr, + const bool bRegExReplace) override; + + // Add a para for the char attribute exp... + bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem&, + const SetAttrMode nFlags = SetAttrMode::DEFAULT, + SwRootFrame const* pLayout = nullptr, + SwTextAttr **ppNewTextAttr = nullptr) override; + + void InsertItemSet (const SwPaM &rRg, const SfxItemSet&, + const SetAttrMode nFlags = SetAttrMode::DEFAULT, + SwRootFrame const* pLayout = nullptr) override; + + void RemoveLeadingWhiteSpace(const SwPosition & rPos ) override; + void RemoveLeadingWhiteSpace(SwPaM& rPaM) override; + + + //Non-Interface methods + + void DeleteDummyChar(SwPosition const& rPos, sal_Unicode cDummy); + + void CopyWithFlyInFly( const SwNodeRange& rRg, + SwNode& rInsPos, + const std::pair * pCopiedPaM = nullptr, + bool bMakeNewFrames = true, + bool bDelRedlines = true, + bool bCopyFlyAtFly = false, + SwCopyFlags flags = SwCopyFlags::Default) const; + void CopyFlyInFlyImpl( const SwNodeRange& rRg, + SwPaM const*const pCopiedPaM, + SwNode& rStartIdx, + const bool bCopyFlyAtFly = false, + SwCopyFlags flags = SwCopyFlags::Default) const; + + /// Parameters for _Rst and lcl_SetTextFormatColl + //originallyfrom docfmt.cxx + struct ParaRstFormat + { + SwTextFormatColl* pFormatColl; + SwHistory* pHistory; + const SwPosition *pSttNd, *pEndNd; + const SfxItemSet* pDelSet; + SwRootFrame const*const pLayout; + sal_uInt16 nWhich; + bool bReset; + bool bResetListAttrs; // #i62575# + bool bResetAll; + bool bInclRefToxMark; + /// From the attributes included in the range, delete only the ones which have exactly same range. Don't delete the ones which are simply included in the range. + bool bExactRange; + + ParaRstFormat(const SwPosition* pStt, const SwPosition* pEnd, + SwHistory* pHst, const SfxItemSet* pSet = nullptr, + SwRootFrame const*const pLay = nullptr) + : pFormatColl(nullptr) + , pHistory(pHst) + , pSttNd(pStt) + , pEndNd(pEnd) + , pDelSet(pSet) + , pLayout(pLay) + , nWhich(0) + , bReset(false) // #i62675# + , bResetListAttrs(false) + , bResetAll(true) + , bInclRefToxMark(false) + , bExactRange(false) + { + } + }; + static bool lcl_RstTextAttr( SwNode* pNd, void* pArgs ); //originally from docfmt.cxx + + + virtual ~DocumentContentOperationsManager() override; + +private: + SwDoc& m_rDoc; + + bool m_bIME = false; + + bool DeleteAndJoinImpl(SwPaM &, SwDeleteFlags); + bool DeleteAndJoinWithRedlineImpl(SwPaM &, SwDeleteFlags); + bool DeleteRangeImpl(SwPaM &, SwDeleteFlags); + bool DeleteRangeImplImpl(SwPaM &, SwDeleteFlags); + bool ReplaceRangeImpl(SwPaM&, OUString const&, const bool); + SwFlyFrameFormat* InsNoTextNode( const SwPosition&rPos, SwNoTextNode*, + const SfxItemSet* pFlyAttrSet, + const SfxItemSet* pGrfAttrSet, + SwFrameFormat* ); + /* Copy a range within the same or to another document. + Position may not lie within range! */ + bool CopyImpl( SwPaM&, SwPosition&, + SwCopyFlags flags, SwPaM *const pCpyRng /*= 0*/) const; + bool CopyImplImpl(SwPaM&, SwPosition&, + SwCopyFlags flags, SwPaM *const pCpyRng /*= 0*/) const; + + DocumentContentOperationsManager(DocumentContentOperationsManager const&) = delete; + DocumentContentOperationsManager& operator=(DocumentContentOperationsManager const&) = delete; +}; + + +void CopyBookmarks(const SwPaM& rPam, const SwPosition& rTarget, + SwCopyFlags flags = SwCopyFlags::Default); + +void CalcBreaks(std::vector> & rBreaks, + SwPaM const & rPam, bool const isOnlyFieldmarks = false); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DocumentDeviceManager.hxx b/sw/source/core/inc/DocumentDeviceManager.hxx new file mode 100644 index 0000000000..e99c54c100 --- /dev/null +++ b/sw/source/core/inc/DocumentDeviceManager.hxx @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTDEVICEMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTDEVICEMANAGER_HXX + +#include +#include +#include + +class SwDoc; +class SfxPrinter; +class VirtualDevice; +class OutputDevice; +class JobSetup; +class SwPrintData; + +namespace sw +{ +class DocumentDeviceManager final : public IDocumentDeviceAccess +{ +public: + DocumentDeviceManager(SwDoc& i_rSwdoc); + + SfxPrinter* getPrinter(/*[in]*/ bool bCreate) const override; + + void setPrinter(/*[in]*/ SfxPrinter* pP, /*[in]*/ bool bDeleteOld, + /*[in]*/ bool bCallPrtDataChanged) override; + + VirtualDevice* getVirtualDevice(/*[in]*/ bool bCreate) const override; + + void setVirtualDevice(/*[in]*/ VirtualDevice* pVd) override; + + OutputDevice* getReferenceDevice(/*[in]*/ bool bCreate) const override; + + void setReferenceDeviceType(/*[in]*/ bool bNewVirtual, /*[in]*/ bool bNewHiRes) override; + + const JobSetup* getJobsetup() const override; + + void setJobsetup(/*[in]*/ const JobSetup& rJobSetup) override; + + const SwPrintData& getPrintData() const override; + + void setPrintData(/*[in]*/ const SwPrintData& rPrtData) override; + + virtual ~DocumentDeviceManager() override; + +private: + DocumentDeviceManager(DocumentDeviceManager const&) = delete; + DocumentDeviceManager& operator=(DocumentDeviceManager const&) = delete; + + VirtualDevice& CreateVirtualDevice_() const; + SfxPrinter& CreatePrinter_() const; + void PrtDataChanged(); /**< Printer or JobSetup altered. + Care has to be taken of the necessary + invalidations and notifications. */ + + SwDoc& m_rDoc; + VclPtr mpPrt; + VclPtr mpVirDev; + std::unique_ptr mpPrtData; +}; +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DocumentDrawModelManager.hxx b/sw/source/core/inc/DocumentDrawModelManager.hxx new file mode 100644 index 0000000000..26fd603a67 --- /dev/null +++ b/sw/source/core/inc/DocumentDrawModelManager.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTDRAWMODELMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTDRAWMODELMANAGER_HXX + +#include +#include +#include +#include + +class SdrPageView; +class SwDoc; + +namespace sw +{ +class DocumentDrawModelManager final : public IDocumentDrawModelAccess +{ +public: + DocumentDrawModelManager(SwDoc& i_rSwdoc); + + void InitDrawModel(); + void ReleaseDrawModel(); + void DrawNotifyUndoHdl(); + + //IDocumentDrawModelAccess + virtual const SwDrawModel* GetDrawModel() const override; + virtual SwDrawModel* GetDrawModel() override; + virtual SwDrawModel* MakeDrawModel_() override; + virtual SwDrawModel* GetOrCreateDrawModel() override; + virtual SdrLayerID GetHeavenId() const override; + virtual SdrLayerID GetHellId() const override; + virtual SdrLayerID GetControlsId() const override; + virtual SdrLayerID GetInvisibleHeavenId() const override; + virtual SdrLayerID GetInvisibleHellId() const override; + virtual SdrLayerID GetInvisibleControlsId() const override; + + virtual void NotifyInvisibleLayers(SdrPageView& _rSdrPageView) override; + + virtual bool IsVisibleLayerId(SdrLayerID _nLayerId) const override; + + virtual SdrLayerID GetInvisibleLayerIdByVisibleOne(SdrLayerID _nVisibleLayerId) override; + + virtual bool Search(const SwPaM& rPaM, const SvxSearchItem& rSearchItem) override; + +private: + DocumentDrawModelManager(DocumentDrawModelManager const&) = delete; + DocumentDrawModelManager& operator=(DocumentDrawModelManager const&) = delete; + + SwDoc& m_rDoc; + + std::unique_ptr mpDrawModel; + + /** Draw Model Layer IDs + * LayerIds, Heaven == above document + * Hell == below document + * Controls == at the very top + */ + SdrLayerID mnHeaven; + SdrLayerID mnHell; + SdrLayerID mnControls; + SdrLayerID mnInvisibleHeaven; + SdrLayerID mnInvisibleHell; + SdrLayerID mnInvisibleControls; +}; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DocumentExternalDataManager.hxx b/sw/source/core/inc/DocumentExternalDataManager.hxx new file mode 100644 index 0000000000..bc80ac429f --- /dev/null +++ b/sw/source/core/inc/DocumentExternalDataManager.hxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTEXTERNALDATAMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTEXTERNALDATAMANAGER_HXX + +#include + +namespace sw +{ +class DocumentExternalDataManager final : public IDocumentExternalData +{ +private: + DocumentExternalDataManager(DocumentExternalDataManager const&) = delete; + DocumentExternalDataManager& operator=(DocumentExternalDataManager const&) = delete; + +public: + DocumentExternalDataManager() = default; + + void setExternalData(::sw::tExternalDataType eType, + ::sw::tExternalDataPointer pPayload) override; + ::sw::tExternalDataPointer getExternalData(::sw::tExternalDataType eType) override; +}; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DocumentFieldsManager.hxx b/sw/source/core/inc/DocumentFieldsManager.hxx new file mode 100644 index 0000000000..accf7a53e8 --- /dev/null +++ b/sw/source/core/inc/DocumentFieldsManager.hxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTFIELDSMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTFIELDSMANAGER_HXX + +#include +#include +#include + +class SwDoc; +class SwDBNameInfField; + +namespace sw { + +class DocumentFieldsManager final : public IDocumentFieldsAccess +{ + +public: + + DocumentFieldsManager( SwDoc& i_rSwdoc ); + + virtual const SwFieldTypes *GetFieldTypes() const override; + virtual SwFieldType *InsertFieldType(const SwFieldType &) override; + virtual SwFieldType *GetSysFieldType( const SwFieldIds eWhich ) const override; + virtual SwFieldType* GetFieldType(SwFieldIds nResId, const OUString& rName, bool bDbFieldMatching) const override; + virtual void RemoveFieldType(size_t nField) override; + virtual void UpdateFields(bool bCloseDB) override; + virtual void InsDeletedFieldType(SwFieldType &) override; + virtual void PutValueToField(const SwPosition & rPos, const css::uno::Any& rVal, sal_uInt16 nWhich) override; + virtual bool UpdateField(SwTextField* rDstFormatField, SwField& rSrcField, bool bUpdateTableFields) override; + virtual void UpdateRefFields() override; + virtual void UpdateTableFields(const SwTable* pTable) override; + virtual void UpdateExpFields(SwTextField* pField, bool bUpdateRefFields) override; + virtual void UpdateUsrFields() override; + virtual void UpdatePageFields(const SwTwips) override; + virtual void LockExpFields() override; + virtual void UnlockExpFields() override; + virtual bool IsExpFieldsLocked() const override; + virtual SwDocUpdateField& GetUpdateFields() const override; + virtual bool SetFieldsDirty(bool b, const SwNode* pChk, SwNodeOffset nLen) override; + virtual void SetFixFields(const DateTime* pNewDateTime) override; + virtual void FieldsToCalc(SwCalc& rCalc, SwNodeOffset nLastNd, sal_Int32 nLastCnt) override; + virtual void FieldsToCalc(SwCalc& rCalc, const SetGetExpField& rToThisField, SwRootFrame const* pLayout) override; + virtual void FieldsToExpand(std::unordered_map& rTable, const SetGetExpField& rToThisField, SwRootFrame const& rLayout) override; + virtual bool IsNewFieldLst() const override; + virtual void SetNewFieldLst( bool bFlag) override; + virtual void InsDelFieldInFieldLst(bool bIns, const SwTextField& rField) override; + virtual sal_Int32 GetRecordsPerDocument() const override; + + //Non Interface methods + + /** Returns the field at a certain position. + @param rPos position to search at + @return pointer to field at the given position or NULL in case no field is found + */ + static SwField* GetFieldAtPos(const SwPosition& rPos); + + /** Returns the field at a certain position. + @param rPos position to search at + @return pointer to field at the given position or NULL in case no field is found + */ + static SwTextField* GetTextFieldAtPos(const SwPosition& rPos); + + bool containsUpdatableFields(); + + // Delete all unreferenced field types. + void GCFieldTypes(); + + void InitFieldTypes(); + + void ClearFieldTypes(); + + void UpdateDBNumFields( SwDBNameInfField& rDBField, SwCalc& rCalc ); + + virtual ~DocumentFieldsManager() override; + +private: + + DocumentFieldsManager(DocumentFieldsManager const&) = delete; + DocumentFieldsManager& operator=(DocumentFieldsManager const&) = delete; + + void UpdateExpFieldsImpl(SwTextField* pField, SwRootFrame const* pLayout); + + SwDoc& m_rDoc; + + bool mbNewFieldLst; //< TRUE: Rebuild field-list. + std::unique_ptr mpUpdateFields; //< Struct for updating fields + std::unique_ptr mpFieldTypes; + sal_Int8 mnLockExpField; //< If != 0 UpdateExpFields() has no effect! +}; + +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DocumentLayoutManager.hxx b/sw/source/core/inc/DocumentLayoutManager.hxx new file mode 100644 index 0000000000..8db5cbe328 --- /dev/null +++ b/sw/source/core/inc/DocumentLayoutManager.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLAYOUTMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLAYOUTMANAGER_HXX + +#include +#include + +class SwDoc; +class SwViewShell; +class SwLayouter; + +namespace sw { + +class DocumentLayoutManager final : public IDocumentLayoutAccess +{ + +public: + + DocumentLayoutManager( SwDoc& i_rSwdoc ); + + virtual const SwViewShell *GetCurrentViewShell() const override; + virtual SwViewShell *GetCurrentViewShell() override; //< It must be able to communicate to a SwViewShell.This is going to be removed later. + virtual void SetCurrentViewShell( SwViewShell* pNew ) override; + + virtual const SwRootFrame *GetCurrentLayout() const override; + virtual SwRootFrame *GetCurrentLayout() override; + virtual bool HasLayout() const override; + + virtual const SwLayouter* GetLayouter() const override; + virtual SwLayouter* GetLayouter() override; + virtual void SetLayouter( SwLayouter* pNew ) override; + + virtual SwFrameFormat* MakeLayoutFormat( RndStdIds eRequest, const SfxItemSet* pSet ) override; + virtual void DelLayoutFormat( SwFrameFormat *pFormat ) override; + virtual SwFrameFormat* CopyLayoutFormat( const SwFrameFormat& rSrc, const SwFormatAnchor& rNewAnchor, bool bSetTextFlyAtt, bool bMakeFrames ) override; + + //Non Interface methods + void ClearSwLayouterEntries(); + + virtual ~DocumentLayoutManager() override; + +private: + + DocumentLayoutManager(DocumentLayoutManager const&) = delete; + DocumentLayoutManager& operator=(DocumentLayoutManager const&) = delete; + + SwDoc& m_rDoc; + + SwViewShell *mpCurrentView; //< SwDoc should get a new member mpCurrentView + std::unique_ptr mpLayouter; /**< css::frame::Controller for complex layout formatting + like footnote/endnote in sections */ +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DocumentLinksAdministrationManager.hxx b/sw/source/core/inc/DocumentLinksAdministrationManager.hxx new file mode 100644 index 0000000000..28dcd7544a --- /dev/null +++ b/sw/source/core/inc/DocumentLinksAdministrationManager.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLINKSADMINISTRATIONMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLINKSADMINISTRATIONMANAGER_HXX + +#include + +#include +#include +#include + +namespace sfx2 { class LinkManager; } +class SwDoc; +class SwPaM; +class SwNodeRange; + +namespace sw +{ + +class DocumentLinksAdministrationManager final : public IDocumentLinksAdministration +{ +public: + + DocumentLinksAdministrationManager( SwDoc& i_rSwdoc ); + + bool IsVisibleLinks() const override; + + void SetVisibleLinks(bool bFlag) override; + + sfx2::LinkManager& GetLinkManager() override; + + const sfx2::LinkManager& GetLinkManager() const override; + + void UpdateLinks() override; + + bool GetData(const OUString& rItem, const OUString& rMimeType, css::uno::Any& rValue) const override; + + void SetData(const OUString& rItem) override; + + ::sfx2::SvLinkSource* CreateLinkSource(const OUString& rItem) override; + + bool EmbedAllLinks() override; + + void SetLinksUpdated(const bool bNewLinksUpdated) override; + + bool LinksUpdated() const override; + + //Non-Interface method + bool SelectServerObj( std::u16string_view rStr, SwPaM*& rpPam, std::optional& rpRange ) const; + + virtual ~DocumentLinksAdministrationManager() override; + +private: + + DocumentLinksAdministrationManager(DocumentLinksAdministrationManager const&) = delete; + DocumentLinksAdministrationManager& operator=(DocumentLinksAdministrationManager const&) = delete; + + bool mbVisibleLinks; //< TRUE: Links are inserted visibly. + bool mbLinksUpdated; //< #i38810# flag indicating, that the links have been updated. + std::unique_ptr m_pLinkMgr; //< List of linked stuff (graphics/DDE/OLE). + + SwDoc& m_rDoc; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DocumentListItemsManager.hxx b/sw/source/core/inc/DocumentListItemsManager.hxx new file mode 100644 index 0000000000..eb31e4e25a --- /dev/null +++ b/sw/source/core/inc/DocumentListItemsManager.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLISTITEMSMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLISTITEMSMANAGER_HXX + +#include +#include +#include + +namespace sw +{ + +class DocumentListItemsManager final : public IDocumentListItems +{ +public: + + DocumentListItemsManager(); + + void addListItem( const SwNodeNum& rNodeNum ) override; + void removeListItem( const SwNodeNum& rNodeNum ) override; + + OUString getListItemText(const SwNodeNum& rNodeNum, + SwRootFrame const& rLayout) const override; + + bool isNumberedInLayout(SwNodeNum const& rNodeNum, + SwRootFrame const& rLayout) const override; + + void getNumItems( IDocumentListItems::tSortedNodeNumList& orNodeNumList ) const override; + + virtual ~DocumentListItemsManager() override; + + + //Non Interface + struct lessThanNodeNum + { + bool operator()( const SwNodeNum* pNodeNumOne, + const SwNodeNum* pNodeNumTwo ) const; + }; + + typedef std::set< const SwNodeNum*, lessThanNodeNum > tImplSortedNodeNumList; + +private: + + DocumentListItemsManager(DocumentListItemsManager const&) = delete; + DocumentListItemsManager& operator=(DocumentListItemsManager const&) = delete; + + std::unique_ptr mpListItemsList; +}; + +} + + #endif // INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLISTITEMSMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DocumentListsManager.hxx b/sw/source/core/inc/DocumentListsManager.hxx new file mode 100644 index 0000000000..caab21e358 --- /dev/null +++ b/sw/source/core/inc/DocumentListsManager.hxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLISTSMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLISTSMANAGER_HXX + +#include +#include +#include +#include + +class SwList; +class SwDoc; + +namespace sw +{ + +class DocumentListsManager final : public IDocumentListsAccess +{ + public: + + DocumentListsManager( SwDoc& i_rSwdoc ); + + SwList* createList( const OUString& rListId, + const OUString& rDefaultListStyleName ) override; + SwList* getListByName( const OUString& rListId ) const override; + + void createListForListStyle( const OUString& rListStyleName ) override; + SwList* getListForListStyle( const OUString& rListStyleName ) const override; + void deleteListForListStyle( const OUString& rListStyleName ) override; + void deleteListsByDefaultListStyle( const OUString& rListStyleName ) override; + // #i91400# + void trackChangeOfListStyleName( const OUString& rListStyleName, + const OUString& rNewListStyleName ) override; + virtual ~DocumentListsManager() override; + + private: + + DocumentListsManager(DocumentListsManager const&) = delete; + DocumentListsManager& operator=(DocumentListsManager const&) = delete; + + SwDoc& m_rDoc; + + typedef std::unique_ptr> SwListPtr; + // container to hold the lists of the text document + std::unordered_map maLists; + // relation between list style and its default list + std::unordered_map maListStyleLists; + + OUString CreateUniqueListId(); + OUString MakeListIdUnique( const OUString& aSuggestedUniqueListId ); +}; + +} + +#endif // INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLISTSMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DocumentOutlineNodesManager.hxx b/sw/source/core/inc/DocumentOutlineNodesManager.hxx new file mode 100644 index 0000000000..2489d23972 --- /dev/null +++ b/sw/source/core/inc/DocumentOutlineNodesManager.hxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTOUTLINENODESMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTOUTLINENODESMANAGER_HXX + +#include + +class SwDoc; + +namespace sw +{ + +class DocumentOutlineNodesManager final : public IDocumentOutlineNodes +{ +public: + + DocumentOutlineNodesManager( SwDoc& i_rSwdoc ); + + //typedef std::vector< const SwTextNode* > tSortedOutlineNodeList; + + tSortedOutlineNodeList::size_type getOutlineNodesCount() const override; + + int getOutlineLevel( const tSortedOutlineNodeList::size_type nIdx ) const override; + OUString getOutlineText( const tSortedOutlineNodeList::size_type nIdx, + SwRootFrame const* pLayout, + const bool bWithNumber = true, + const bool bWithSpacesForLevel = false, + const bool bWithFootnote = true ) const override; + SwTextNode* getOutlineNode( const tSortedOutlineNodeList::size_type nIdx ) const override; + bool isOutlineInLayout(tSortedOutlineNodeList::size_type nIdx, + SwRootFrame const& rLayout) const override; + void getOutlineNodes( IDocumentOutlineNodes::tSortedOutlineNodeList& orOutlineNodeList ) const override; + + virtual ~DocumentOutlineNodesManager() override; + +private: + + DocumentOutlineNodesManager(DocumentOutlineNodesManager const&) = delete; + DocumentOutlineNodesManager& operator=(DocumentOutlineNodesManager const&) = delete; + + SwDoc& m_rDoc; +}; + +} + +#endif // INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTOUTLINENODESMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DocumentRedlineManager.hxx b/sw/source/core/inc/DocumentRedlineManager.hxx new file mode 100644 index 0000000000..a164dbbeab --- /dev/null +++ b/sw/source/core/inc/DocumentRedlineManager.hxx @@ -0,0 +1,189 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTREDLINEMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTREDLINEMANAGER_HXX + +#include + +class SwDoc; + +namespace sw +{ + +class SAL_DLLPUBLIC_RTTI DocumentRedlineManager final : public IDocumentRedlineAccess +{ +public: + DocumentRedlineManager( SwDoc& i_rSwdoc ); + + /** + * Replaced by SwRootFrame::IsHideRedlines() (this is model-level redline + * hiding). + */ + virtual RedlineFlags GetRedlineFlags() const override; + + virtual void SetRedlineFlags_intern(/*[in]*/RedlineFlags eMode) override; + + virtual void SetRedlineFlags(/*[in]*/RedlineFlags eMode) override; + + virtual bool IsRedlineOn() const override; + + virtual bool IsIgnoreRedline() const override; + + virtual const SwRedlineTable& GetRedlineTable() const override; + virtual SwRedlineTable& GetRedlineTable() override; + virtual const SwExtraRedlineTable& GetExtraRedlineTable() const override; + virtual SwExtraRedlineTable& GetExtraRedlineTable() override; + + virtual bool IsInRedlines(const SwNode& rNode) const override; + + virtual AppendResult AppendRedline( + /*[in]*/ SwRangeRedline* pPtr, + /*[in]*/ bool bCallDelete, + /*[in]*/ sal_uInt32 nMoveIDToDelete = 0) override; + + virtual bool AppendTableRowRedline(/*[in]*/SwTableRowRedline* pPtr) override; + virtual bool AppendTableCellRedline(/*[in]*/SwTableCellRedline* pPtr) override; + + virtual bool SplitRedline(/*[in]*/const SwPaM& rPam) override; + + virtual bool DeleteRedline( + /*[in]*/const SwPaM& rPam, + /*[in]*/bool bSaveInUndo, + /*[in]*/RedlineType nDelType) override; + + virtual bool DeleteRedline( + /*[in]*/const SwStartNode& rSection, + /*[in]*/bool bSaveInUndo, + /*[in]*/RedlineType nDelType) override; + + virtual SwRedlineTable::size_type GetRedlinePos( + /*[in]*/const SwNode& rNode, + /*[in]*/RedlineType nType) const override; + + virtual SwRedlineTable::size_type GetRedlineEndPos( + /*[in]*/ SwRedlineTable::size_type nStartPos, + /*[in]*/ const SwNode& rNode, + /*[in]*/ RedlineType nType) const override; + + virtual bool HasRedline( + /*[in]*/const SwPaM& rPam, + /*[in]*/RedlineType nType, + /*[in]*/bool bStartOrEndInRange) const override; + + virtual void CompressRedlines(size_t nStartIdx = 0) override; + + virtual const SwRangeRedline* GetRedline( + /*[in]*/const SwPosition& rPos, + /*[in]*/SwRedlineTable::size_type* pFndPos) const override; + + virtual bool IsRedlineMove() const override; + + virtual void SetRedlineMove(/*[in]*/bool bFlag) override; + + virtual bool AcceptRedline(/*[in]*/ SwRedlineTable::size_type nPos, /*[in]*/ bool bCallDelete, + /*[in]*/ bool bRange = false) override; + + virtual bool AcceptRedline(/*[in]*/ const SwPaM& rPam, /*[in]*/ bool bCallDelete, + /*[in]*/ sal_Int8 nDepth = 0) override; + + virtual void AcceptRedlineParagraphFormatting(/*[in]*/const SwPaM& rPam) override; + + virtual bool RejectRedline(/*[in]*/ SwRedlineTable::size_type nPos, /*[in]*/ bool bCallDelete, + /*[in]*/ bool bRange = false) override; + + virtual bool RejectRedline(/*[in]*/ const SwPaM& rPam, /*[in]*/ bool bCallDelete, + /*[in]*/ sal_Int8 nDepth = 0) override; + + virtual void AcceptAllRedline(/*[in]*/bool bAcceptReject) override; + + virtual const SwRangeRedline* SelNextRedline(/*[in]*/SwPaM& rPam) const override; + + virtual const SwRangeRedline* SelPrevRedline(/*[in]*/SwPaM& rPam) const override; + + virtual void UpdateRedlineAttr() override; + + virtual std::size_t GetRedlineAuthor() override; + + virtual std::size_t InsertRedlineAuthor(const OUString& rAuthor) override; + + virtual bool SetRedlineComment( + /*[in]*/const SwPaM& rPam, + /*[in]*/const OUString& rComment) override; + + virtual const css::uno::Sequence & GetRedlinePassword() const override; + + virtual void SetRedlinePassword( + /*[in]*/const css::uno::Sequence & rNewPassword) override; + + // After nodes are removed, m_pContentNode's may not updated + virtual void UpdateRedlineContentNode( + /*[in]*/ SwRedlineTable::size_type nStartPos, + /*[in]*/ SwRedlineTable::size_type nEndPos) const override; + + //Non Interface methods; + + /** Set comment-text for Redline. It then comes in via AppendRedLine. + Used by AutoFormat. 0-pointer resets mode. + Sequence number is for conjoining of Redlines by the UI. */ + void SetAutoFormatRedlineComment( const OUString* pText, sal_uInt16 nSeqNo = 0 ); + + bool IsHideRedlines() const { return m_bHideRedlines; } + void SetHideRedlines(bool const bHideRedlines) { m_bHideRedlines = bHideRedlines; } + + void HideAll(bool bDeletion); + void ShowAll(); + + virtual ~DocumentRedlineManager() override; + +private: + + bool RejectRedlineRange(SwRedlineTable::size_type nPosOrigin, + SwRedlineTable::size_type& nPosStart, + SwRedlineTable::size_type& nPosEnd, bool bCallDelete); + bool AcceptRedlineRange(SwRedlineTable::size_type nPosOrigin, + SwRedlineTable::size_type& nPosStart, + SwRedlineTable::size_type& nPosEnd, bool bCallDelete); + bool AcceptMovedRedlines(sal_uInt32 nMovedID, bool bCallDelete); + bool RejectMovedRedlines(sal_uInt32 nMovedID, bool bCallDelete); + + DocumentRedlineManager(DocumentRedlineManager const&) = delete; + DocumentRedlineManager& operator=(DocumentRedlineManager const&) = delete; + + SwDoc& m_rDoc; + + RedlineFlags meRedlineFlags; //< Current Redline Mode. + SwRedlineTable maRedlineTable; //< List of all Ranged Redlines. + SwExtraRedlineTable maExtraRedlineTable; //< List of all Extra Redlines. + std::optional moAutoFormatRedlnComment; //< Comment for Redlines inserted via AutoFormat. + bool mbIsRedlineMove; //< true: Redlines are moved into to / out of the section. + sal_uInt16 mnAutoFormatRedlnCommentNo; /**< SeqNo for conjoining of AutoFormat-Redlines. + by the UI. Managed by SwAutoFormat! */ + css::uno::Sequence maRedlinePasswd; + + /// this flag is necessary for file import because the ViewShell/layout is + /// created "too late" and the ShowRedlineChanges item is not below "Views" + bool m_bHideRedlines = false; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx new file mode 100644 index 0000000000..284dccf9cf --- /dev/null +++ b/sw/source/core/inc/DocumentSettingManager.hxx @@ -0,0 +1,227 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTSETTINGMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTSETTINGMANAGER_HXX + +#include +class SwDoc; +typedef struct _xmlTextWriter* xmlTextWriterPtr; + +namespace sw { +class DocumentSettingManager final : + public IDocumentSettingAccess +{ + std::shared_ptr mxForbiddenCharsTable; + SwDoc &m_rDoc; + + sal_uInt16 mnLinkUpdMode; //< UpdateMode for links. + + SwFieldUpdateFlags meFieldUpdMode;//< Automatically Update Mode for fields/charts. + CharCompressType meChrCmprType;//< for ASIAN: compress punctuation/kana + + sal_uInt32 mn32DummyCompatibilityOptions1; + sal_uInt32 mn32DummyCompatibilityOptions2; + + // COMPATIBILITY FLAGS START + // + // + // HISTORY OF THE COMPATIBILITY FLAGS: + // + // SO5: + // mbParaSpaceMax def = false, true since SO8 + // mbParaSpaceMaxAtPages def = false, true since SO8 + // + // SO6: + // mbTabCompat def = false, true since SO8 + // + // SO7: + // mbUseVirtualDevice def = true + // mbAddFlyOffsets def = false, hidden + // + // SO7pp1: + // bOldNumbering def = false, hidden + // + // SO8: + // mbAddExternalLeading def = true + // mbUseHiResolutionVirtualDevice def = true, hidden + // mbOldLineSpacing def = false + // mbAddParaSpacingToTableCells def = true + // mbUseFormerObjectPos def = false + // mbUseFormerTextWrapping def = false + // mbConsiderWrapOnObjPos def = false + // + // SO8pp1: + // mbIgnoreFirstLineIndentInNumbering def = false, hidden + // mbDoNotJustifyLinesWithManualBreak def = false, hidden + // mbDoNotResetParaAttrsForNumFont def = false, hidden + // + // SO8pp3 + // mbDoNotCaptureDrawObjsOnPage def = false, hidden + // - Relevant for drawing objects, which don't follow the text flow, but + // whose position is outside the page area: + // false: Such drawing objects are captured on the page area of its anchor. + // true: Such drawing objects can leave the page area, they aren't captured. + // mbTableRowKeep def = false, hidden + // mbIgnoreTabsAndBlanksForLineCalculation def = false, hidden + // mbClipAsCharacterAnchoredWriterFlyFrame def = false, hidden + // - Introduced in order to re-activate clipping of as-character anchored + // Writer fly frames in method for documents, + // which are created with version prior SO8/OOo 2.0 + // + // SO8pp4 + // mbUnixForceZeroExtLeading def = false, hidden + // + // SO8pu8 + // + // SO9 + // #i24363# tab stops relative to indent + // mbTabRelativeToIndent def = true, hidden + // #i89181# suppress tab stop at left indent for paragraphs in lists, whose + // list level position and space mode equals LABEL_ALIGNMENT and whose list + // label is followed by a tab character. + // mbTabAtLeftIndentForParagraphsInList def = false, hidden + + bool mbHTMLMode : 1; //< true: Document is in HTMLMode. + bool mbIsGlobalDoc : 1; //< true: It's a global document. + bool mbGlblDocSaveLinks : 1; //< true: Save sections linked in global document. + bool mbIsLabelDoc : 1; //< true: It's a label document. + bool mbPurgeOLE : 1; //< true: Purge OLE-Objects + bool mbKernAsianPunctuation : 1; //< true: kerning also for ASIAN punctuation + + bool mbParaSpaceMax : 1; + bool mbParaSpaceMaxAtPages : 1; + bool mbTabCompat : 1; + bool mbUseVirtualDevice : 1; + bool mbAddFlyOffsets : 1; + bool mbAddVerticalFlyOffsets : 1; + bool mbAddExternalLeading : 1; + bool mbUseHiResolutionVirtualDevice : 1; + bool mbOldLineSpacing : 1; // #i11859# + bool mbAddParaSpacingToTableCells : 1; + bool mbUseFormerObjectPos : 1; // #i11860# + bool mbUseFormerTextWrapping : 1; + bool mbConsiderWrapOnObjPos : 1; // #i28701# + // true: object positioning algorithm has consider the wrapping style of // the floating screen objects as given by its attribute 'WrapInfluenceOnObjPos' + // floating screen objects as given by its + // attribute 'WrapInfluenceOnObjPos'. + bool mbMathBaselineAlignment : 1; // TL 2010-10-29 #i972# + bool mbStylesNoDefault : 1; + bool mEmbedFonts : 1; //< Whether to embed fonts when saving. + bool mEmbedUsedFonts : 1; //< Whether to embed fonts that are used by the document when saving. + bool mEmbedLatinScriptFonts : 1; //< Whether to embed latin script fonts when saving. + bool mEmbedAsianScriptFonts : 1; //< Whether to embed asian script fonts when saving. + bool mEmbedComplexScriptFonts : 1; //< Whether to embed complex script fonts when saving. + bool mEmbedSystemFonts : 1; //< Whether to embed also system fonts. + + // non-ui-compatibility flags: + bool mbOldNumbering : 1; + bool mbIgnoreFirstLineIndentInNumbering : 1; // #i47448# + bool mbDoNotJustifyLinesWithManualBreak : 1; // #i49277# + bool mbDoNotResetParaAttrsForNumFont : 1; // #i53199# + bool mbTableRowKeep : 1; + bool mbIgnoreTabsAndBlanksForLineCalculation : 1; // #i3952# + bool mbDoNotCaptureDrawObjsOnPage : 1; // #i62875# + bool mbClipAsCharacterAnchoredWriterFlyFrames : 1; + bool mbUnixForceZeroExtLeading : 1; // #i60945# + bool mbTabRelativeToIndent : 1; // #i24363# tab stops relative to indent + bool mbProtectForm : 1; + bool mbMsWordCompTrailingBlanks : 1; // tdf#104349 tdf#104668 + bool mbMsWordCompMinLineHeightByFly : 1; + bool mbInvertBorderSpacing : 1; + bool mbCollapseEmptyCellPara : 1; + bool mbTabAtLeftIndentForParagraphsInList; // #i89181# - see above + bool mbSmallCapsPercentage66; + bool mbTabOverflow; + bool mbUnbreakableNumberings; + bool mbClippedPictures; + bool mbBackgroundParaOverDrawings; + bool mbTabOverMargin; + bool mbTabOverSpacing; + bool mbTreatSingleColumnBreakAsPageBreak; // tdf#76349 + bool mbSurroundTextWrapSmall; + bool mbPropLineSpacingShrinksFirstLine; // fdo#79602 + bool mbSubtractFlys; // tdf#86578 + bool mApplyParagraphMarkFormatToNumbering; + bool mbAddParaLineSpacingToTableCells; // tdf#125300 tdf#134782 + + bool mbLastBrowseMode : 1; + bool mbDisableOffPagePositioning; // tdf#112443 + bool mbEmptyDbFieldHidesPara; + bool mbContinuousEndnotes = false; + bool mbProtectBookmarks; + bool mbProtectFields; + bool mbHeaderSpacingBelowLastPara; + bool mbFrameAutowidthWithMorePara; //tdf#124423 + /// Gutter position: false means left (not a compatibility setting). + bool mbGutterAtTop; + bool mbFootnoteInColumnToPageEnd; + sal_Int32 mnImagePreferredDPI; + bool mbAutoFirstLineIndentDisregardLineSpace; + bool mbHyphenateURLs = false; + bool mbDoNotBreakWrappedTables = false; + bool mbAllowTextAfterFloatingTableBreak = false; + bool mbJustifyLinesWithShrinking = false; + // If this is on as_char flys wrapping will be handled the same like in Word + bool mbNoNumberingShowFollowBy; + bool mbDropCapPunctuation; // tdf#150200, tdf#150438 + bool mbUseVariableWidthNBSP : 1; // tdf#41652 + +public: + + DocumentSettingManager(SwDoc &rDoc); + virtual ~DocumentSettingManager() override; + + // IDocumentSettingAccess + virtual bool get(/*[in]*/ DocumentSettingId id) const override; + virtual void set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value) override; + virtual const css::i18n::ForbiddenCharacters* getForbiddenCharacters(/*[in]*/ LanguageType nLang, /*[in]*/ bool bLocaleData ) const override; + virtual void setForbiddenCharacters(/*[in]*/ LanguageType nLang, /*[in]*/ const css::i18n::ForbiddenCharacters& rForbiddenCharacters ) override; + virtual std::shared_ptr& getForbiddenCharacterTable() override; + virtual const std::shared_ptr& getForbiddenCharacterTable() const override; + virtual sal_uInt16 getLinkUpdateMode( /*[in]*/bool bGlobalSettings ) const override; + virtual void setLinkUpdateMode( /*[in]*/ sal_uInt16 nMode ) override; + virtual SwFieldUpdateFlags getFieldUpdateFlags( /*[in]*/bool bGlobalSettings ) const override; + virtual void setFieldUpdateFlags( /*[in]*/ SwFieldUpdateFlags eMode ) override; + virtual CharCompressType getCharacterCompressionType() const override; + virtual void setCharacterCompressionType( /*[in]*/CharCompressType nType ) override; + + sal_Int32 getImagePreferredDPI() override + { + return mnImagePreferredDPI; + } + void setImagePreferredDPI(sal_Int32 nValue) override + { + mnImagePreferredDPI = nValue; + } + +// Replace all compatibility options with those from rSource. + void ReplaceCompatibilityOptions(const DocumentSettingManager& rSource); + + sal_uInt32 Getn32DummyCompatibilityOptions1() const override; + void Setn32DummyCompatibilityOptions1( const sal_uInt32 CompatibilityOptions1 ) override; + sal_uInt32 Getn32DummyCompatibilityOptions2() const override; + void Setn32DummyCompatibilityOptions2( const sal_uInt32 CompatibilityOptions2 ) override; + void dumpAsXml(xmlTextWriterPtr pWriter) const; +}; + +} + +#endif //_DOCSETTING_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DocumentStateManager.hxx b/sw/source/core/inc/DocumentStateManager.hxx new file mode 100644 index 0000000000..60c8c4923c --- /dev/null +++ b/sw/source/core/inc/DocumentStateManager.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include + +class SwDoc; + + +namespace sw { + +class DocumentStateManager final : public IDocumentState +{ + +public: + DocumentStateManager( SwDoc& i_rSwdoc ); + + void SetModified() override; + void ResetModified() override; + bool IsModified() const override; + bool IsEnableSetModified() const override; + void SetEnableSetModified(bool bEnableSetModified) override; + bool IsInCallModified() const override; + bool IsUpdateExpField() const override; + bool IsNewDoc() const override; + void SetNewDoc(bool b) override; + void SetUpdateExpFieldStat(bool b) override; + +private: + + DocumentStateManager(DocumentStateManager const&) = delete; + DocumentStateManager& operator=(DocumentStateManager const&) = delete; + + SwDoc& m_rDoc; + + bool mbEnableSetModified; //< FALSE: changing document modification status (temporarily) locked + bool mbModified ; //< TRUE: document has changed. + bool mbUpdateExpField; //< TRUE: Update expression fields. + bool mbNewDoc ; //< TRUE: new Doc. + bool mbInCallModified; //< TRUE: in Set/Reset-Modified link. +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DocumentStatisticsManager.hxx b/sw/source/core/inc/DocumentStatisticsManager.hxx new file mode 100644 index 0000000000..430fcff7ca --- /dev/null +++ b/sw/source/core/inc/DocumentStatisticsManager.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTSTATISTICSMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTSTATISTICSMANAGER_HXX + +#include +#include +#include +#include + +class SwDoc; +struct SwDocStat; + +namespace sw +{ +class DocumentStatisticsManager final : public IDocumentStatistics +{ +public: + DocumentStatisticsManager(SwDoc& i_rSwdoc); + + void DocInfoChgd(bool isEnableSetModified) override; + const SwDocStat& GetDocStat() const override; + void SetDocStatModified(bool bSet); + const SwDocStat& GetUpdatedDocStat(bool bCompleteAsync, bool bFields) override; + void SetDocStat(const SwDocStat& rStat) override; + void UpdateDocStat(bool bCompleteAsync, bool bFields) override; + virtual ~DocumentStatisticsManager() override; + +private: + DocumentStatisticsManager(DocumentStatisticsManager const&) = delete; + DocumentStatisticsManager& operator=(DocumentStatisticsManager const&) = delete; + + SwDoc& m_rDoc; + + /** continue computing a chunk of document statistics + * \param nChars number of characters to count before exiting + * \param bFields if stat. fields should be updated + * + * returns false when there is no more to calculate + */ + bool IncrementalDocStatCalculate(tools::Long nChars, bool bFields = true); + + // Our own 'StatsUpdateTimer' calls the following method + DECL_LINK(DoIdleStatsUpdate, Timer*, void); + + std::unique_ptr mpDocStat; //< Statistics information + bool mbInitialized; //< allow first time update + SwDocIdle maStatsUpdateIdle; //< Idle for asynchronous stats calculation +}; +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DocumentStylePoolManager.hxx b/sw/source/core/inc/DocumentStylePoolManager.hxx new file mode 100644 index 0000000000..f410d0d092 --- /dev/null +++ b/sw/source/core/inc/DocumentStylePoolManager.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTSTYLEPOOLMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTSTYLEPOOLMANAGER_HXX + +#include + +class SwDoc; + +namespace sw { + +class DocumentStylePoolManager final : public IDocumentStylePoolAccess +{ + +public: + + DocumentStylePoolManager( SwDoc& i_rSwdoc ); + + virtual SwTextFormatColl* GetTextCollFromPool( sal_uInt16 nId, bool bRegardLanguage = true ) override; + virtual SwFormat* GetFormatFromPool( sal_uInt16 nId ) override; + virtual SwFrameFormat* GetFrameFormatFromPool( sal_uInt16 nId ) override; + virtual SwCharFormat* GetCharFormatFromPool( sal_uInt16 nId ) override; + virtual SwPageDesc* GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage = true ) override; + virtual SwNumRule* GetNumRuleFromPool( sal_uInt16 nId ) override; + virtual bool IsPoolTextCollUsed( sal_uInt16 nId ) const override; + virtual bool IsPoolFormatUsed( sal_uInt16 nId ) const override; + virtual bool IsPoolPageDescUsed( sal_uInt16 nId ) const override; + + virtual ~DocumentStylePoolManager() override; + +private: + + DocumentStylePoolManager(DocumentStylePoolManager const&) = delete; + DocumentStylePoolManager& operator=(DocumentStylePoolManager const&) = delete; + + SwDoc& m_rDoc; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + diff --git a/sw/source/core/inc/DocumentTimerManager.hxx b/sw/source/core/inc/DocumentTimerManager.hxx new file mode 100644 index 0000000000..895aa4b86b --- /dev/null +++ b/sw/source/core/inc/DocumentTimerManager.hxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTTIMERMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTTIMERMANAGER_HXX + +#include +#include + +#include +#include + +class SwDoc; + +namespace sw +{ +class DocumentTimerManager final : public IDocumentTimerAccess +{ +public: + enum class IdleJob + { + None, ///< document has no idle jobs to do + Busy, ///< document is busy and idle jobs are postponed + Grammar, + Layout, + Fields, + }; + + DocumentTimerManager(SwDoc& i_rSwdoc); + virtual ~DocumentTimerManager() override; + + void StartIdling() override; + + void StopIdling() override; + + void BlockIdling() override; + + void UnblockIdling() override; + + bool IsDocIdle() const override; + +private: + DocumentTimerManager(DocumentTimerManager const&) = delete; + DocumentTimerManager& operator=(DocumentTimerManager const&) = delete; + + /// Delay starting idle jobs to allow for post-load activity. + /// Used by LOK only. + DECL_LINK(FireIdleJobsTimeout, Timer*, void); + + DECL_LINK(DoIdleJobs, Timer*, void); + + IdleJob GetNextIdleJob() const; + + SwDoc& m_rDoc; + + sal_uInt32 m_nIdleBlockCount; ///< Don't run the Idle, if > 0 + bool m_bStartOnUnblock; ///< true, if the last unblock should start the timer + SwDocIdle m_aDocIdle; + Timer m_aFireIdleJobsTimer; + bool m_bWaitForLokInit; ///< true if we waited for LOK to initialize already. +}; + +inline bool DocumentTimerManager::IsDocIdle() const +{ + return ((0 == m_nIdleBlockCount) && (GetNextIdleJob() != IdleJob::Busy)); +} +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/DropDownFormFieldButton.hxx b/sw/source/core/inc/DropDownFormFieldButton.hxx new file mode 100644 index 0000000000..6f8aa42edd --- /dev/null +++ b/sw/source/core/inc/DropDownFormFieldButton.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include "FormFieldButton.hxx" + +class SwEditWin; +namespace sw::mark +{ +class DropDownFieldmark; +} + +/** + * This button is shown when the cursor is on a drop-down form field. + * The user can select an item of the field using this button while filling in a form. + */ +class DropDownFormFieldButton final : public FormFieldButton +{ +private: + std::unique_ptr m_xTreeView; + + DECL_LINK(MyListBoxHandler, weld::TreeView&, bool); + + void InitDropdown(); + +public: + DropDownFormFieldButton(SwEditWin* pEditWin, sw::mark::DropDownFieldmark& rFieldMark); + virtual ~DropDownFormFieldButton() override; + + virtual void LaunchPopup() override; + virtual void DestroyPopup() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sw/source/core/inc/FormFieldButton.hxx b/sw/source/core/inc/FormFieldButton.hxx new file mode 100644 index 0000000000..22a9b3e8c7 --- /dev/null +++ b/sw/source/core/inc/FormFieldButton.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include +#include +#include + +class SwEditWin; +namespace sw::mark +{ +class Fieldmark; +} + +/** + * This button is shown when the cursor is on a form field with drop-down capability. + */ +class FormFieldButton : public Control +{ +public: + FormFieldButton(SwEditWin* pEditWin, sw::mark::Fieldmark& rFieldMark); + virtual ~FormFieldButton() override; + virtual void dispose() override; + + void CalcPosAndSize(const SwRect& rPortionPaintArea); + + virtual void MouseButtonDown(const MouseEvent& rMEvt) override; + DECL_LINK(FieldPopupModeEndHdl, weld::Popover&, void); + + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual WindowHitTest ImplHitTest(const Point& rFramePos) override; + + virtual void LaunchPopup(); + virtual void DestroyPopup(); + +private: + tools::Rectangle m_aFieldFramePixel; + +protected: + sw::mark::Fieldmark& m_rFieldmark; + std::unique_ptr m_xFieldPopupBuilder; + std::unique_ptr m_xFieldPopup; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sw/source/core/inc/GraphicSizeCheck.hxx b/sw/source/core/inc/GraphicSizeCheck.hxx new file mode 100644 index 0000000000..a58a7f4324 --- /dev/null +++ b/sw/source/core/inc/GraphicSizeCheck.hxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include +#include + +namespace sw +{ +/** + * Class responsible to check if a graphic object violates the size + * constraints and store the results. + */ +class GraphicSizeViolation final +{ +private: + const SwGrfNode* m_pGraphicNode; + + sal_Int32 m_nLowDPILimit = 0; + sal_Int32 m_nHighDPILimit = 0; + + sal_Int32 m_nDPIX = 0; + sal_Int32 m_nDPIY = 0; + +public: + GraphicSizeViolation(sal_Int32 nDPI, const SwGrfNode* pGraphicNode); + bool check(); + + const OUString& getGraphicName(); + + bool isDPITooLow() { return m_nDPIX < m_nLowDPILimit || m_nDPIY < m_nLowDPILimit; } + + bool isDPITooHigh() { return m_nDPIX > m_nHighDPILimit || m_nDPIY > m_nHighDPILimit; } + + sal_Int32 getDPIX() { return m_nDPIX; } + + sal_Int32 getDPIY() { return m_nDPIY; } +}; + +/** + * Run the graphic size checks for all the graphic objects in the DOM + * and store a list of violations. + */ +class GraphicSizeCheck final +{ +private: + SwDoc* m_pDocument; + std::vector> m_aGraphicSizeViolationList; + +public: + GraphicSizeCheck(SwDoc* pDocument) + : m_pDocument(pDocument) + { + } + + void check(); + + std::vector>& getViolationList() + { + return m_aGraphicSizeViolationList; + } +}; + +/** The UI part of the GraphicSizeViolation used by GenericCheckDialog */ +class GraphicSizeCheckGUIEntry final : public svx::CheckData +{ +private: + SwDoc* m_pDocument; + std::unique_ptr m_pViolation; + +public: + GraphicSizeCheckGUIEntry(SwDoc* pDocument, std::unique_ptr&& pViolation) + : m_pDocument(pDocument) + , m_pViolation(std::move(pViolation)) + { + } + + OUString getText() override; + + bool canMarkObject() override { return true; } + + void markObject() override; + + bool hasProperties() override { return true; } + + void runProperties() override; +}; + +/** + * The UI part presenting the graphic size check results, which is + * used by GenericCheckDialog + */ +class GraphicSizeCheckGUIResult final : public svx::CheckDataCollection +{ +public: + GraphicSizeCheckGUIResult(SwDoc* pDocument); + + OUString getTitle() override; +}; + +} // end sw namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/MarkManager.hxx b/sw/source/core/inc/MarkManager.hxx new file mode 100644 index 0000000000..ef0e79d74c --- /dev/null +++ b/sw/source/core/inc/MarkManager.hxx @@ -0,0 +1,168 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_MARKMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_MARKMANAGER_HXX + +#include +#include +#include +#include + +class SwCursorShell; +class SfxViewShell; + +namespace sw::mark { + typedef std::unordered_map MarkBasenameMapUniqueOffset_t; + + class FieldmarkWithDropDownButton; + + class MarkManager final + : virtual public IDocumentMarkAccess + { + public: + MarkManager(/*[in/out]*/ SwDoc& rDoc); + // IDocumentMarkAccess + virtual ::sw::mark::IMark* makeMark(const SwPaM& rPaM, + const OUString& rName, IDocumentMarkAccess::MarkType eMark, + sw::mark::InsertMode eMode, + SwPosition const* pSepPos = nullptr) override; + + virtual sw::mark::IFieldmark* makeFieldBookmark( const SwPaM& rPaM, + const OUString& rName, + const OUString& rType, + SwPosition const* pSepPos = nullptr) override; + virtual sw::mark::IFieldmark* makeNoTextFieldBookmark( const SwPaM& rPaM, + const OUString& rName, + const OUString& rType) override; + + virtual ::sw::mark::IMark* getMarkForTextNode(const SwTextNode& rTextNode, IDocumentMarkAccess::MarkType eMark) override; + + virtual sw::mark::IMark* makeAnnotationMark( + const SwPaM& rPaM, + const OUString& rName ) override; + + virtual void repositionMark(::sw::mark::IMark* io_pMark, const SwPaM& rPaM) override; + virtual bool renameMark(::sw::mark::IMark* io_pMark, const OUString& rNewName) override; + virtual void correctMarksAbsolute(const SwNode& rOldNode, const SwPosition& rNewPos, const sal_Int32 nOffset) override; + virtual void correctMarksRelative(const SwNode& rOldNode, const SwPosition& rNewPos, const sal_Int32 nOffset) override; + + virtual void deleteMarks(const SwNode& rStt, + const SwNode& rEnd, + std::vector< ::sw::mark::SaveBookmark>* pSaveBkmk, + std::optional oStartContentIdx, + std::optional oEndContentIdx, + bool isReplace) override; + + // deleters + virtual std::unique_ptr + deleteMark(const const_iterator_t& ppMark, bool isMoveNodes) override; + virtual void deleteMark(const ::sw::mark::IMark* const pMark) override; + virtual void clearAllMarks() override; + + // marks + virtual const_iterator_t getAllMarksBegin() const override; + virtual const_iterator_t getAllMarksEnd() const override; + virtual sal_Int32 getAllMarksCount() const override; + virtual const_iterator_t findMark(const OUString& rName) const override; + + // bookmarks + virtual bool isBookmarkDeleted(SwPaM const& rPaM, bool isReplace) const override; + virtual const_iterator_t getBookmarksBegin() const override; + virtual const_iterator_t getBookmarksEnd() const override; + virtual sal_Int32 getBookmarksCount() const override; + virtual const_iterator_t findBookmark(const OUString& rName) const override; + virtual const_iterator_t findFirstBookmarkStartsAfter(const SwPosition& rPos) const override; + virtual ::sw::mark::IMark* getOneInnermostBookmarkFor(const SwPosition& rPos) const override; + + // Fieldmarks + virtual const_iterator_t getFieldmarksBegin() const override; + virtual const_iterator_t getFieldmarksEnd() const override; + virtual sal_Int32 getFieldmarksCount() const override; + virtual ::sw::mark::IFieldmark* getFieldmarkAt(const SwPosition& rPos) const override; + virtual sw::mark::IFieldmark* getInnerFieldmarkFor(const SwPosition& rPos) const override; + virtual sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& rPos, bool bLoop) const override; + virtual sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& rPos, bool bLoop) const override; + + virtual ::sw::mark::IFieldmark* getDropDownFor(const SwPosition &rPos) const override; + virtual std::vector<::sw::mark::IFieldmark*> getNoTextFieldmarksIn(const SwPaM &rPaM) const override; + + virtual void deleteFieldmarkAt(const SwPosition& rPos) override; + virtual ::sw::mark::IFieldmark* changeFormFieldmarkType(::sw::mark::IFieldmark* pFieldmark, const OUString& rNewType) override; + + virtual void NotifyCursorUpdate(const SwCursorShell& rCursorShell) override; + virtual void ClearFieldActivation() override; + void LOKUpdateActiveField(const SfxViewShell* pViewShell); + + void dumpAsXml(xmlTextWriterPtr pWriter) const; + + // Annotation Marks + virtual const_iterator_t getAnnotationMarksBegin() const override; + virtual const_iterator_t getAnnotationMarksEnd() const override; + virtual sal_Int32 getAnnotationMarksCount() const override; + virtual const_iterator_t findAnnotationMark( const OUString& rName ) const override; + virtual sw::mark::IMark* getAnnotationMarkFor(const SwPosition& rPos) const override; + virtual const_iterator_t findFirstAnnotationStartsAfter(const SwPosition& rPos) const override; + + virtual void assureSortedMarkContainers() const override; + + typedef std::vector container_t; + + // helper bookmark to store annotation range of redlines + virtual ::sw::mark::IMark* makeAnnotationBookmark(const SwPaM& rPaM, + const OUString& rName, IDocumentMarkAccess::MarkType eMark, + sw::mark::InsertMode eMode, + SwPosition const* pSepPos = nullptr) override; + virtual const_iterator_t findAnnotationBookmark( const OUString& rName ) const override; + virtual void restoreAnnotationMarks(bool bDelete = true) override; + + private: + + MarkManager(MarkManager const&) = delete; + MarkManager& operator=(MarkManager const&) = delete; + + // make names + OUString getUniqueMarkName(const OUString& rName) const; + + void sortSubsetMarks(); + void sortMarks(); + + // container for all marks, this container owns the objects it points to + container_t m_vAllMarks; + + // additional container for bookmarks + container_t m_vBookmarks; + // additional container for fieldmarks + container_t m_vFieldmarks; + + mutable MarkBasenameMapUniqueOffset_t m_aMarkBasenameMapUniqueOffset; + + // container for annotation marks + container_t m_vAnnotationMarks; + + SwDoc& m_rDoc; + + sw::mark::FieldmarkWithDropDownButton* m_pLastActiveFieldmark; + }; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/ModelTraverser.hxx b/sw/source/core/inc/ModelTraverser.hxx new file mode 100644 index 0000000000..f3c6acb9c6 --- /dev/null +++ b/sw/source/core/inc/ModelTraverser.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include + +class SwNode; +class SdrObject; + +namespace sw +{ +class SW_DLLPUBLIC ModelTraverseHandler +{ +public: + virtual ~ModelTraverseHandler() {} + + virtual void handleNode(SwNode* pNode) = 0; + virtual void handleSdrObject(SdrObject* pObject) = 0; +}; + +class ModelTraverser +{ +private: + std::vector> mpNodeHandler; + SwDoc* m_pDoc; + +public: + ModelTraverser(SwDoc* pDoc) + : m_pDoc(pDoc) + { + } + + void traverse(); + + void addNodeHandler(std::shared_ptr pHandler) + { + mpNodeHandler.push_back(pHandler); + } +}; + +} // end sw namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/SearchResultLocator.hxx b/sw/source/core/inc/SearchResultLocator.hxx new file mode 100644 index 0000000000..ad48e075d2 --- /dev/null +++ b/sw/source/core/inc/SearchResultLocator.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include +#include +#include +#include + +namespace sw::search +{ +enum class NodeType +{ + Undefined = 0, + WriterNode = 1, + CommonNode = 2 // node in a SdrObject +}; + +struct SearchIndexData +{ + NodeType meType = NodeType::Undefined; + SwNodeOffset mnNodeIndex{ 0 }; + OUString maObjectName; + + SearchIndexData() {} + + SearchIndexData(NodeType eType, SwNodeOffset nNodeIndex, OUString aObjectName = OUString()) + : meType(eType) + , mnNodeIndex(nNodeIndex) + , maObjectName(std::move(aObjectName)) + { + } +}; + +struct LocationResult +{ + bool mbFound = false; + std::vector maRectangles; +}; + +class SW_DLLPUBLIC SearchResultLocator +{ + SwDoc* mpDocument; + + void findOne(LocationResult& rResult, SearchIndexData const& rSearchIndexData); + static bool tryParseJSON(const char* pPayload, + std::vector& rDataVector); + static bool tryParseXML(const char* pPayload, + std::vector& rDataVector); + +public: + SearchResultLocator(SwDoc* pDoc) + : mpDocument(pDoc) + { + } + + LocationResult find(std::vector const& rSearchIndexDataVector); + LocationResult findForPayload(const char* pPayload); +}; + +} // end sw namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/SwGrammarMarkUp.hxx b/sw/source/core/inc/SwGrammarMarkUp.hxx new file mode 100644 index 0000000000..efefadf83a --- /dev/null +++ b/sw/source/core/inc/SwGrammarMarkUp.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_SWGRAMMARMARKUP_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_SWGRAMMARMARKUP_HXX + +#include "wrong.hxx" +#include + +/* SwGrammarMarkUp extends the functionality of a "normal" SwWrongList by memorizing + the start positions of sentences in the paragraph + + The whole class is only a temporary solution without usage of virtual functions. + At the end the whole SwWrongList stuff should be reworked and replaced by interfaces + to deal with all the different wronglists like + spell, grammar, smarttag, sentence... + "MarkUpList" would be a better name than WrongList. +*/ + +class SwGrammarMarkUp final : public SwWrongList +{ + std::vector maSentence; + +public: + SwGrammarMarkUp() + : SwWrongList(WRONGLIST_GRAMMAR) + { + } + + virtual ~SwGrammarMarkUp() override; + virtual SwWrongList* Clone() override; + virtual void CopyFrom(const SwWrongList& rCopy) override; + + /* SwWrongList::Move() + handling of maSentence */ + void MoveGrammar(sal_Int32 nPos, sal_Int32 nDiff); + /* SwWrongList::SplitList() + handling of maSentence */ + std::unique_ptr SplitGrammarList(sal_Int32 nSplitPos); + /* SwWrongList::JoinList() + handling of maSentence */ + void JoinGrammarList(SwGrammarMarkUp* pNext, sal_Int32 nInsertPos); + /* SwWrongList::ClearList() + handling of maSentence */ + void ClearGrammarList(sal_Int32 nSentenceEnd = COMPLETE_STRING); + /* setSentence to define the start position of a sentence, + at the moment the end position is given by the next start position */ + void setSentence(sal_Int32 nStart); + /* getSentenceStart returns the last start position of a sentence + which is lower or equal to the given parameter */ + sal_Int32 getSentenceStart(sal_Int32 nPos); + /* getSentenceEnd returns the first start position of a sentence + which is greater than the given parameter */ + sal_Int32 getSentenceEnd(sal_Int32 nPos); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/SwPortionHandler.hxx b/sw/source/core/inc/SwPortionHandler.hxx new file mode 100644 index 0000000000..29625efbca --- /dev/null +++ b/sw/source/core/inc/SwPortionHandler.hxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_SWPORTIONHANDLER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_SWPORTIONHANDLER_HXX + +#include +#include +#include "TextFrameIndex.hxx" + +class SwFont; +enum class PortionType; + +/** The SwPortionHandler interface implements a visitor for the layout + * engine's text portions. This can be used to gather information of + * the on-screen representation of a single paragraph. + * + * For each text portion, one of the methods text(...) or special(...) + * is called, depending on whether it is a 'normal' run of text, or + * any other portion. Additionally, the linebreak() method is called + * once at the end of every on-screen line. + * + * All parameters relate to the 'view string', which is the text string + * held by the sequence of all corresponding SwTextFrames. + * + * The SwPortionHandler can be used with the + * SwTextFrame::VisitPortions(...) method. + */ +class SW_DLLPUBLIC SwPortionHandler +{ +public: + + virtual ~SwPortionHandler() {} /// (empty) destructor + + /** text portion. A run of nLength characters from the view + * string, that contains no special characters like embedded + * fields, etc. Thus, the on-screen text of this portion + * corresponds exactly to the corresponding characters in the + * view string. + */ + virtual void Text( + TextFrameIndex nLength, ///< length of this portion in the view string + PortionType nType /// type of this portion + ) = 0; + + /** special portion. This method is called for every non-text + * portion. The parameters describe the length of the + * corresponding characters in the view string (often 0 or 1), + * the text which is displayed, and the type of the portion. + */ + virtual void Special( + TextFrameIndex nLength, ///< length of this portion in the view string + const OUString& rText, /// text which is painted on-screen + PortionType nType /// type of this portion + ) = 0; + + /** line break. This method is called whenever a line break in the + * layout occurs. + */ + virtual void LineBreak() = 0; + + /** skip characters. The SwTextFrame may only display partially + * display a certain paragraph (e.g. when the paragraph is split + * across multiple pages). In this case, the Skip() method must be + * called to inform the portion handler to ignore a certain run of + * characters in the 'view string'. Skip(), if used at all, must + * be called before any of the other methods is called. Calling + * Skip() between portions is not allowed. + */ + virtual void Skip( + TextFrameIndex nLength /// number of 'view string' characters to be skipped + ) = 0; + + /** end of paragraph. This method is to be called when all the + * paragraph's portions have been processed. + */ + virtual void Finish() = 0; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/SwUndoFmt.hxx b/sw/source/core/inc/SwUndoFmt.hxx new file mode 100644 index 0000000000..c3f0a256f1 --- /dev/null +++ b/sw/source/core/inc/SwUndoFmt.hxx @@ -0,0 +1,257 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_SWUNDOFMT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_SWUNDOFMT_HXX + +#include +#include +#include +#include + +class SwDoc; +class SwTextFormatColl; +class SwConditionTextFormatColl; +class SwRewriter; + +class SwUndoFormatCreate : public SwUndo +{ +protected: + SwFormat * m_pNew; + OUString m_sDerivedFrom; + SwDoc& m_rDoc; + mutable OUString m_sNewName; + std::unique_ptr m_pNewSet; + sal_uInt16 m_nId; // FormatId related + bool m_bAuto; + +public: + SwUndoFormatCreate(SwUndoId nUndoId, SwFormat * pNew, SwFormat const * pDerivedFrom, + SwDoc& rDoc); + virtual ~SwUndoFormatCreate() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + virtual SwRewriter GetRewriter() const override; + + virtual SwFormat * Create(SwFormat * pDerivedFrom) = 0; + virtual void Delete() = 0; + virtual SwFormat * Find(const OUString & rName) const = 0; +}; + +class SwUndoFormatDelete : public SwUndo +{ +protected: + OUString m_sDerivedFrom; + SwDoc& m_rDoc; + OUString m_sOldName; + SfxItemSet m_aOldSet; + sal_uInt16 m_nId; // FormatId related + bool m_bAuto; + +public: + SwUndoFormatDelete(SwUndoId nUndoId, SwFormat const * pOld, SwDoc& rDoc); + virtual ~SwUndoFormatDelete() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + virtual SwRewriter GetRewriter() const override; + + virtual SwFormat * Create(SwFormat * pDerivedFrom) = 0; + virtual void Delete(SwFormat * pFormat) = 0; + virtual SwFormat * Find(const OUString & rName) const = 0; +}; + +class SwUndoRenameFormat : public SwUndo +{ +protected: + OUString m_sOldName, m_sNewName; + SwDoc& m_rDoc; + +public: + SwUndoRenameFormat(SwUndoId nUndoId, OUString sOldName, + OUString sNewName, + SwDoc& rDoc); + virtual ~SwUndoRenameFormat() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + SwRewriter GetRewriter() const override; + + virtual SwFormat * Find(const OUString & rName) const = 0; +}; + +class SwUndoTextFormatCollCreate : public SwUndoFormatCreate +{ +public: + SwUndoTextFormatCollCreate(SwTextFormatColl * pNew, SwTextFormatColl const * pDerivedFrom, + SwDoc& rDoc); + + virtual SwFormat * Create(SwFormat * pDerivedFrom) override; + virtual void Delete() override; + virtual SwFormat * Find(const OUString & rName) const override; +}; + +class SwUndoTextFormatCollDelete : public SwUndoFormatDelete +{ +public: + SwUndoTextFormatCollDelete(SwTextFormatColl const * pOld, SwDoc& rDoc); + + virtual SwFormat * Create(SwFormat * pDerivedFrom) override; + virtual void Delete(SwFormat * pFormat) override; + virtual SwFormat * Find(const OUString & rName) const override; +}; + +class SwUndoCondTextFormatCollCreate final : public SwUndoTextFormatCollCreate +{ +public: + SwUndoCondTextFormatCollCreate(SwConditionTextFormatColl * pNew, SwTextFormatColl const * pDerivedFrom, SwDoc& rDoc); + virtual SwFormat * Create(SwFormat * pDerivedFrom) override; +}; + +class SwUndoCondTextFormatCollDelete final : public SwUndoTextFormatCollDelete +{ +public: + SwUndoCondTextFormatCollDelete(SwTextFormatColl const * pOld, SwDoc& rDoc); + virtual SwFormat * Create(SwFormat * pDerivedFrom) override; +}; + +class SwUndoRenameFormatColl final : public SwUndoRenameFormat +{ +public: + SwUndoRenameFormatColl(const OUString & sOldName, + const OUString & sNewName, + SwDoc& rDoc); + + virtual SwFormat * Find(const OUString & rName) const override; +}; + +class SwUndoCharFormatCreate final : public SwUndoFormatCreate +{ +public: + SwUndoCharFormatCreate(SwCharFormat * pNew, SwCharFormat const * pDerivedFrom, + SwDoc& rDoc); + + virtual SwFormat * Create(SwFormat * pDerivedFrom) override; + virtual void Delete() override; + virtual SwFormat * Find(const OUString & rName) const override; +}; + +class SwUndoCharFormatDelete final : public SwUndoFormatDelete +{ +public: + SwUndoCharFormatDelete(SwCharFormat const * pOld, SwDoc& rDoc); + + virtual SwFormat * Create(SwFormat * pDerivedFrom) override; + virtual void Delete(SwFormat * pFormat) override; + virtual SwFormat * Find(const OUString & rName) const override; +}; + +class SwUndoRenameCharFormat final : public SwUndoRenameFormat +{ +public: + SwUndoRenameCharFormat(const OUString & sOldName, + const OUString & sNewName, + SwDoc& rDoc); + + virtual SwFormat * Find(const OUString & rName) const override; +}; + +class SwUndoFrameFormatCreate final : public SwUndoFormatCreate +{ +public: + SwUndoFrameFormatCreate(SwFrameFormat * pNew, SwFrameFormat const * pDerivedFrom, + SwDoc& rDoc); + + virtual SwFormat * Create(SwFormat * pDerivedFrom) override; + virtual void Delete() override; + virtual SwFormat * Find(const OUString & rName) const override; +}; + +class SwUndoFrameFormatDelete final : public SwUndoFormatDelete +{ +public: + SwUndoFrameFormatDelete(SwFrameFormat const * pOld, SwDoc& rDoc); + + virtual SwFormat * Create(SwFormat * pDerivedFrom) override; + virtual void Delete(SwFormat * pFormat) override; + virtual SwFormat * Find(const OUString & rName) const override; +}; + +class SwUndoRenameFrameFormat final : public SwUndoRenameFormat +{ +public: + SwUndoRenameFrameFormat(const OUString & sOldName, + const OUString & sNewName, + SwDoc& rDoc); + + virtual SwFormat * Find(const OUString & rName) const override; +}; + +class SwUndoNumruleCreate final : public SwUndo +{ + const SwNumRule * m_pNew; + mutable SwNumRule m_aNew; + SwDoc& m_rDoc; + mutable bool m_bInitialized; + +public: + SwUndoNumruleCreate(const SwNumRule * pNew, SwDoc& rDoc); + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + SwRewriter GetRewriter() const override; +}; + +class SwUndoNumruleDelete final : public SwUndo +{ + SwNumRule m_aOld; + SwDoc& m_rDoc; + +public: + SwUndoNumruleDelete(const SwNumRule& rRule, SwDoc& rDoc); + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + SwRewriter GetRewriter() const override; +}; + +class SwUndoNumruleRename final : public SwUndo +{ + OUString m_aOldName, m_aNewName; + SwDoc& m_rDoc; + + public: + SwUndoNumruleRename(OUString aOldName, OUString aNewName, + SwDoc& rDoc); + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + SwRewriter GetRewriter() const override; +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_SWUNDOFMT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/SwUndoPageDesc.hxx b/sw/source/core/inc/SwUndoPageDesc.hxx new file mode 100644 index 0000000000..ab90a3a65b --- /dev/null +++ b/sw/source/core/inc/SwUndoPageDesc.hxx @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_SWUNDOPAGEDESC_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_SWUNDOPAGEDESC_HXX + +#include +#include + +class SwDoc; + +class SwUndoPageDesc final : public SwUndo +{ + SwPageDescExt m_aOld, m_aNew; + SwDoc * m_pDoc; + bool m_bExchange; + + // To avoid duplication of (header/footer)content nodes for simple page desc changes + void ExchangeContentNodes( SwPageDesc& rSource, SwPageDesc &rDest ); + + // tdf#153220 use to Exit HeaderFooter EditMode + void ExitHeaderFooterEdit(); +public: + SwUndoPageDesc(const SwPageDesc & aOld, const SwPageDesc & aNew, + SwDoc * pDoc); + virtual ~SwUndoPageDesc() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + virtual SwRewriter GetRewriter() const override; +}; + +class SwUndoPageDescCreate final : public SwUndo +{ + const SwPageDesc * m_pDesc; + SwPageDescExt m_aNew; + SwDoc * m_pDoc; + + void DoImpl(); + +public: + SwUndoPageDescCreate(const SwPageDesc * pNew, SwDoc * pDoc); + virtual ~SwUndoPageDescCreate() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + virtual SwRewriter GetRewriter() const override; +}; + +class SwUndoPageDescDelete final : public SwUndo +{ + SwPageDescExt m_aOld; + SwDoc * m_pDoc; + + void DoImpl(); + +public: + SwUndoPageDescDelete(const SwPageDesc & aOld, SwDoc * pDoc); + virtual ~SwUndoPageDescDelete() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + virtual SwRewriter GetRewriter() const override; +}; +#endif // _SW_UNDO_PAGE_DESC_CHANGE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/SwUndoTOXChange.hxx b/sw/source/core/inc/SwUndoTOXChange.hxx new file mode 100644 index 0000000000..a7aabf41e4 --- /dev/null +++ b/sw/source/core/inc/SwUndoTOXChange.hxx @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +class SwDoc; +class SwTOXBaseSection; + +class SwUndoTOXChange final : public SwUndo +{ +private: + SwTOXBase m_Old; + SwTOXBase m_New; + + SwNodeOffset const m_nNodeIndex; + +public: + SwUndoTOXChange(const SwDoc& rDoc, SwTOXBaseSection const& rTOX, const SwTOXBase& rNew); + virtual ~SwUndoTOXChange() override; + + virtual void UndoImpl(::sw::UndoRedoContext&) override; + virtual void RedoImpl(::sw::UndoRedoContext&) override; + virtual void RepeatImpl(::sw::RepeatContext&) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/SwXMLBlockExport.hxx b/sw/source/core/inc/SwXMLBlockExport.hxx new file mode 100644 index 0000000000..90f8c59595 --- /dev/null +++ b/sw/source/core/inc/SwXMLBlockExport.hxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include + +class SwXMLTextBlocks; + +class SwXMLBlockListExport final : public SvXMLExport +{ +private: + SwXMLTextBlocks &m_rBlockList; + +public: + SwXMLBlockListExport( + const css::uno::Reference< css::uno::XComponentContext >& rContext, + SwXMLTextBlocks & rBlocks, + const OUString &rFileName, + css::uno::Reference< css::xml::sax::XDocumentHandler> const &rHandler); + + ErrCode exportDoc( enum ::xmloff::token::XMLTokenEnum eClass = ::xmloff::token::XML_TOKEN_INVALID ) override; + void ExportAutoStyles_() override {} + void ExportMasterStyles_ () override {} + void ExportContent_() override {} +}; + +class SwXMLTextBlockExport final : public SvXMLExport +{ +private: + SwXMLTextBlocks &m_rBlockList; + +public: + SwXMLTextBlockExport( + const css::uno::Reference< css::uno::XComponentContext >& rContext, + SwXMLTextBlocks & rBlocks, + const OUString &rFileName, + css::uno::Reference< css::xml::sax::XDocumentHandler> const &rHandler); + + ErrCode exportDoc(enum ::xmloff::token::XMLTokenEnum /*eClass*/) override { return ERRCODE_NONE; } + void exportDoc(std::u16string_view rText); + void ExportAutoStyles_() override {} + void ExportMasterStyles_ () override {} + void ExportContent_() override {} +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/SwXMLBlockImport.hxx b/sw/source/core/inc/SwXMLBlockImport.hxx new file mode 100644 index 0000000000..821033c1e1 --- /dev/null +++ b/sw/source/core/inc/SwXMLBlockImport.hxx @@ -0,0 +1,126 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace com::sun::star::xml::sax { class XFastTokenHandler; } + +using namespace css::xml::sax; +using namespace xmloff::token; + +class SwXMLTextBlocks; +class SwXMLBlockListImport final : public SvXMLImport +{ +private: + SwXMLTextBlocks &m_rBlockList; + + // This method is called after the namespace map has been updated, but + // before a context for the current element has been pushed. + virtual SvXMLImportContext* CreateFastContext( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override; + +public: + SwXMLBlockListImport( + const css::uno::Reference< css::uno::XComponentContext >& rContext, + SwXMLTextBlocks &rBlocks ); + + SwXMLTextBlocks& getBlockList() + { + return m_rBlockList; + } + virtual ~SwXMLBlockListImport() + noexcept override; +}; + +class SwXMLTextBlockImport final : public SvXMLImport +{ + // This method is called after the namespace map has been updated, but + // before a context for the current element has been pushed. + virtual SvXMLImportContext* CreateFastContext( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override; + +public: + bool m_bTextOnly; + OUString &m_rText; + SwXMLTextBlockImport( + const css::uno::Reference< css::uno::XComponentContext >& rContext, + OUString &rNewText, bool bNewTextOnly ); + + virtual ~SwXMLTextBlockImport() + noexcept override; + virtual void SAL_CALL endDocument() override; +}; + +enum SwXMLTextBlockToken : sal_Int32 +{ + OFFICE_BODY = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_BODY, + OFFICE_TEXT = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_TEXT, + OFFICE_DOCUMENT = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_DOCUMENT, + OFFICE_DOCUMENT_CONTENT = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_DOCUMENT_CONTENT, + TEXT_P = FastToken::NAMESPACE | XML_NAMESPACE_TEXT | XML_P +}; + +class SwXMLTextBlockTokenHandler final : + public sax_fastparser::FastTokenHandlerBase +{ +public: + SwXMLTextBlockTokenHandler(); + virtual ~SwXMLTextBlockTokenHandler() override; + + //XFastTokenHandler + sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< sal_Int8 >& Identifier ) override; + css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 Token ) override; + + //Much fast direct C++ shortcut to the method that matters + virtual sal_Int32 getTokenDirect( const char *pTag, sal_Int32 nLength ) const override; +}; + +enum SwXMLBlockListToken : sal_Int32 +{ + ABBREVIATED_NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_ABBREVIATED_NAME, + BLOCK = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_BLOCK, + BLOCK_LIST = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_BLOCK_LIST, + LIST_NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_LIST_NAME, + NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_NAME, + PACKAGE_NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_PACKAGE_NAME, + UNFORMATTED_TEXT = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_UNFORMATTED_TEXT +}; + +class SwXMLBlockListTokenHandler final : + public sax_fastparser::FastTokenHandlerBase +{ +public: + SwXMLBlockListTokenHandler(); + virtual ~SwXMLBlockListTokenHandler() override; + + //XFastTokenHandler + sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< sal_Int8 >& Identifier ) override; + css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 Token ) override; + + //Much fast direct C++ shortcut to the method that matters + virtual sal_Int32 getTokenDirect( const char *pTag, sal_Int32 nLength ) const override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/SwXMLTextBlocks.hxx b/sw/source/core/inc/SwXMLTextBlocks.hxx new file mode 100644 index 0000000000..05a97ded59 --- /dev/null +++ b/sw/source/core/inc/SwXMLTextBlocks.hxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include + +#include + +#include +#include "swblocks.hxx" +#include + +class SwDoc; +class SvxMacroTableDtor; + +enum class SwXmlFlags { + NONE = 0x0000, + NoRootCommit = 0x0002, +}; +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +} + +class SwXMLTextBlocks final : public SwImpBlocks +{ + SfxObjectShellRef m_xDocShellRef; + SwXmlFlags m_nFlags; + OUString m_aPackageName; + tools::SvRef m_xMedium; + css::uno::Reference < css::embed::XStorage > m_xBlkRoot; + css::uno::Reference < css::embed::XStorage > m_xRoot; + + void ReadInfo(); + void WriteInfo(); + void InitBlockMode ( const css::uno::Reference < css::embed::XStorage >& rStorage ); + void ResetBlockMode(); + +public: + SwXMLTextBlocks( const OUString& rFile ); + SwXMLTextBlocks( const css::uno::Reference < css::embed::XStorage >&, const OUString& rFile ); + void AddName( const OUString&, const OUString&, const OUString&, bool bOnlyText ); + virtual void AddName( const OUString&, const OUString&, bool bOnlyText = false ) override; + static OUString GeneratePackageName ( std::u16string_view rShort ); + virtual ~SwXMLTextBlocks() override; + virtual ErrCode Delete( sal_uInt16 ) override; + virtual ErrCode Rename( sal_uInt16, const OUString& ) override; + virtual ErrCode CopyBlock( SwImpBlocks& rImp, OUString& rShort, const OUString& rLong) override; + virtual void ClearDoc() override; + virtual ErrCode GetDoc( sal_uInt16 ) override; + virtual ErrCode BeginPutDoc( const OUString&, const OUString& ) override; + virtual ErrCode PutDoc() override; + virtual ErrCode PutText( const OUString&, const OUString&, const OUString& ) override; + virtual ErrCode MakeBlockList() override; + + virtual ErrCode OpenFile( bool bReadOnly = true ) override; + virtual void CloseFile() override; + + static bool IsFileUCBStorage( const OUString & rFileName); + + // Methods for the new Autocorrecter + ErrCode GetText( std::u16string_view rShort, OUString& ); + + virtual bool IsOnlyTextBlock( const OUString& rShort ) const override; + bool IsOnlyTextBlock( sal_uInt16 nIdx ) const; + void SetIsTextOnly( const OUString& rShort, bool bNewValue ); + + virtual ErrCode GetMacroTable( sal_uInt16, SvxMacroTableDtor& rMacroTable ) override; + virtual ErrCode SetMacroTable( sal_uInt16 nIdx, + const SvxMacroTableDtor& rMacroTable ) override; + virtual bool PutMuchEntries( bool bOn ) override; + + SwDoc* GetDoc() const { return m_xDoc.get(); } + //void SetDoc( SwDoc * pNewDoc); + ErrCode StartPutBlock( const OUString& rShort, const OUString& rPackageName ); + ErrCode PutBlock(); + ErrCode GetBlockText( std::u16string_view rShort, OUString& rText ); + ErrCode PutBlockText( const OUString& rShort, std::u16string_view rText, const OUString& rPackageName ); + void MakeBlockText( std::u16string_view rText ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/SwXTextDefaults.hxx b/sw/source/core/inc/SwXTextDefaults.hxx new file mode 100644 index 0000000000..0acab2a7d2 --- /dev/null +++ b/sw/source/core/inc/SwXTextDefaults.hxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include + +class SwDoc; +class SfxItemPropertySet; + +class SwXTextDefaults final : public cppu::WeakImplHelper + < + css::beans::XPropertyState, + css::beans::XPropertySet, + css::lang::XServiceInfo + > +{ + const SfxItemPropertySet* m_pPropSet; + SwDoc * m_pDoc; + +public: + SwXTextDefaults ( SwDoc * pNewDoc ); + virtual ~SwXTextDefaults () override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + virtual void SAL_CALL setPropertyValue( const OUString& rPropertyName, const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& rPropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XPropertyState + virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& rPropertyName ) override; + virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& rPropertyNames ) override; + virtual void SAL_CALL setPropertyToDefault( const OUString& rPropertyName ) override; + virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& rPropertyName ) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/TextFrameIndex.hxx b/sw/source/core/inc/TextFrameIndex.hxx new file mode 100644 index 0000000000..3987bd5903 --- /dev/null +++ b/sw/source/core/inc/TextFrameIndex.hxx @@ -0,0 +1,26 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_TEXTFRAMEINDEX_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_TEXTFRAMEINDEX_HXX + +#include +#include + +/** + * Denotes a character index in a text frame at a layout level, after extent + * mapping from a text node at a document model level. + * + * @see SwTextFrame::MapViewToModelPos(). + */ +typedef o3tl::strong_int TextFrameIndex; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_TEXTFRAMEINDEX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sw/source/core/inc/ThemeColorChanger.hxx b/sw/source/core/inc/ThemeColorChanger.hxx new file mode 100644 index 0000000000..6eeb3a25f6 --- /dev/null +++ b/sw/source/core/inc/ThemeColorChanger.hxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ +#pragma once + +#include +#include +#include +#include + +namespace sw +{ +class SW_DLLPUBLIC ThemeColorChanger : public svx::IThemeColorChanger +{ +private: + SwDocShell* mpDocSh; + +public: + ThemeColorChanger(SwDocShell* pDocSh); + virtual ~ThemeColorChanger() override; + + void apply(std::shared_ptr const& pColorSet) override; +}; + +} // end sw namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/UndoAttribute.hxx b/sw/source/core/inc/UndoAttribute.hxx new file mode 100644 index 0000000000..f6905cafc6 --- /dev/null +++ b/sw/source/core/inc/UndoAttribute.hxx @@ -0,0 +1,269 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOATTRIBUTE_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNDOATTRIBUTE_HXX + +#include +#include +#include +#include +#include +#include +#include + +class SvxTabStopItem; +class SwFormat; +class SwFootnoteInfo; +class SwEndNoteInfo; +class SwDoc; + +class SwUndoAttr final : public SwUndo, private SwUndRng +{ + SfxItemSet m_AttrSet; // attributes for Redo + const std::unique_ptr m_pHistory; // History for Undo + std::unique_ptr m_pRedlineData; // Redlining + std::unique_ptr m_pRedlineSaveData; + SwNodeOffset m_nNodeIndex; // Offset: for Redlining + const SetAttrMode m_nInsertFlags; // insert flags + OUString m_aChrFormatName; + + void RemoveIdx( SwDoc& rDoc ); + void redoAttribute(SwPaM& rPam, sw::UndoRedoContext& rContext); +public: + SwUndoAttr( const SwPaM&, SfxItemSet, const SetAttrMode nFlags ); + SwUndoAttr( const SwPaM&, const SfxPoolItem&, const SetAttrMode nFlags ); + + virtual ~SwUndoAttr() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + void SaveRedlineData( const SwPaM& rPam, bool bInsContent ); + + SwHistory& GetHistory() { return *m_pHistory; } +}; + +class SwUndoResetAttr final : public SwUndo, private SwUndRng +{ + const std::unique_ptr m_pHistory; + o3tl::sorted_vector m_Ids; + const sal_uInt16 m_nFormatId; // Format-Id for Redo + +public: + SwUndoResetAttr( const SwPaM&, sal_uInt16 nFormatId ); + SwUndoResetAttr( const SwPosition&, sal_uInt16 nFormatId ); + + virtual ~SwUndoResetAttr() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + void SetAttrs( o3tl::sorted_vector && rAttrs ); + + SwHistory& GetHistory() { return *m_pHistory; } +}; + +class SwUndoFormatAttr final : public SwUndo +{ + friend class SwUndoDefaultAttr; + OUString m_sFormatName; + std::optional m_oOldSet; // old attributes + sal_Int32 m_nAnchorContentOffset; + SwNodeOffset m_nNodeIndex; + const sal_uInt16 m_nFormatWhich; + const bool m_bSaveDrawPt; + + void SaveFlyAnchor( const SwFormat * pFormat, bool bSaveDrawPt = false ); + // #i35443# - Add return value, type . + // Return value indicates, if anchor attribute is restored. + // Notes: - If anchor attribute is restored, all other existing attributes + // are also restored. + // - Anchor attribute isn't restored successfully, if it contains + // an invalid anchor position and all other existing attributes + // aren't restored. + // This situation occurs for undo of styles. + bool RestoreFlyAnchor(::sw::UndoRedoContext & rContext); + // --> OD 2008-02-27 #refactorlists# - removed + void Init( const SwFormat & rFormat ); + +public: + // register at the Format and save old attributes + // --> OD 2008-02-27 #refactorlists# - removed + SwUndoFormatAttr( SfxItemSet&& rOldSet, + SwFormat& rFormat, + bool bSaveDrawPt ); + SwUndoFormatAttr( const SfxPoolItem& rItem, + SwFormat& rFormat, + bool bSaveDrawPt ); + + virtual ~SwUndoFormatAttr() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + virtual SwRewriter GetRewriter() const override; + + void PutAttr( const SfxPoolItem& rItem, const SwDoc& rDoc ); + SwFormat* GetFormat( const SwDoc& rDoc ); // checks if it is still in the Doc! +}; + +// --> OD 2008-02-12 #newlistlevelattrs# +class SwUndoFormatResetAttr final : public SwUndo +{ + public: + SwUndoFormatResetAttr( SwFormat& rChangedFormat, + const std::vector& rIds ); + virtual ~SwUndoFormatResetAttr() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + private: + // format at which a certain attribute is reset. + SwFormat * const m_pChangedFormat; + // old attribute which has been reset - needed for undo. + SfxItemSet m_aSet; + + void BroadcastStyleChange(); +}; + +class SwUndoDontExpandFormat final : public SwUndo +{ + const SwNodeOffset m_nNodeIndex; + const sal_Int32 m_nContentIndex; + +public: + SwUndoDontExpandFormat( const SwPosition& rPos ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; +}; + +// helper class to receive changed attribute sets +class SwUndoFormatAttrHelper final : public SwClient +{ + SwFormat& m_rFormat; + std::unique_ptr m_pUndo; + const bool m_bSaveDrawPt; + +public: + SwUndoFormatAttrHelper(SwFormat& rFormat, bool bSaveDrawPt = true); + + virtual void SwClientNotify(const SwModify&, const SfxHint&) override; + + SwUndoFormatAttr* GetUndo() const { return m_pUndo.get(); } + // release the undo object (so it is not deleted here), and return it + std::unique_ptr ReleaseUndo() { return std::move(m_pUndo); } +}; + +class SwDocModifyAndUndoGuard final +{ + SwDoc* doc; + std::unique_ptr helper; + +public: + SwDocModifyAndUndoGuard(SwFormat& format); + ~SwDocModifyAndUndoGuard(); +}; + +class SwUndoMoveLeftMargin final : public SwUndo, private SwUndRng +{ + const std::unique_ptr m_pHistory; + const bool m_bModulus; + +public: + SwUndoMoveLeftMargin( const SwPaM&, bool bRight, bool bModulus ); + + virtual ~SwUndoMoveLeftMargin() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + SwHistory& GetHistory() { return *m_pHistory; } + +}; + +class SwUndoDefaultAttr final : public SwUndo +{ + std::optional m_oOldSet; // the old attributes + std::unique_ptr m_pTabStop; + +public: + // registers at the format and saves old attributes + SwUndoDefaultAttr( const SfxItemSet& rOldSet, const SwDoc& rDoc ); + + virtual ~SwUndoDefaultAttr() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; +}; + +class SwUndoChangeFootNote final : public SwUndo, private SwUndRng +{ + const std::unique_ptr m_pHistory; + const OUString m_Text; + const bool m_bEndNote; + +public: + SwUndoChangeFootNote( const SwPaM& rRange, OUString aText, + bool bIsEndNote ); + virtual ~SwUndoChangeFootNote() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + SwHistory& GetHistory() { return *m_pHistory; } +}; + +class SwUndoFootNoteInfo final : public SwUndo +{ + std::unique_ptr m_pFootNoteInfo; + +public: + SwUndoFootNoteInfo( const SwFootnoteInfo &rInfo, const SwDoc& rDoc ); + + virtual ~SwUndoFootNoteInfo() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; +}; + +class SwUndoEndNoteInfo final : public SwUndo +{ + std::unique_ptr m_pEndNoteInfo; + +public: + SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo, const SwDoc& rDoc ); + + virtual ~SwUndoEndNoteInfo() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOATTRIBUTE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/UndoBookmark.hxx b/sw/source/core/inc/UndoBookmark.hxx new file mode 100644 index 0000000000..368a997571 --- /dev/null +++ b/sw/source/core/inc/UndoBookmark.hxx @@ -0,0 +1,157 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOBOOKMARK_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNDOBOOKMARK_HXX + +#include +#include +#include "rolbck.hxx" + +class SwHistoryBookmark; +class SwHistoryNoTextFieldmark; +class SwHistoryTextFieldmark; + +namespace sw::mark +{ +class IMark; +class IFieldmark; +} + +class SwDoc; + +class SwUndoBookmark : public SwUndo +{ + const std::unique_ptr m_pHistoryBookmark; + +protected: + SwUndoBookmark(SwUndoId nUndoId, const ::sw::mark::IMark&); + + void SetInDoc(SwDoc*); + void ResetInDoc(SwDoc&); + +public: + virtual ~SwUndoBookmark() override; + + /** + Returns the rewriter for this undo object. + + The rewriter contains the following rule: + + $1 -> + + is the name of the bookmark whose + insertion/deletion is recorded by this undo object. + + @return the rewriter for this undo object + */ + virtual SwRewriter GetRewriter() const override; +}; + +class SwUndoInsBookmark final : public SwUndoBookmark +{ +public: + SwUndoInsBookmark(const ::sw::mark::IMark&); + + virtual void UndoImpl(::sw::UndoRedoContext&) override; + virtual void RedoImpl(::sw::UndoRedoContext&) override; +}; + +class SwUndoDeleteBookmark final : public SwUndoBookmark +{ +public: + SwUndoDeleteBookmark(const ::sw::mark::IMark&); + + virtual void UndoImpl(::sw::UndoRedoContext&) override; + virtual void RedoImpl(::sw::UndoRedoContext&) override; +}; + +class SwUndoRenameBookmark final : public SwUndo +{ + const OUString m_sOldName; + const OUString m_sNewName; + +public: + SwUndoRenameBookmark(OUString aOldName, OUString aNewName, const SwDoc& rDoc); + virtual ~SwUndoRenameBookmark() override; + +private: + virtual SwRewriter GetRewriter() const override; + static void Rename(::sw::UndoRedoContext const&, const OUString& sFrom, const OUString& sTo); + virtual void UndoImpl(::sw::UndoRedoContext&) override; + virtual void RedoImpl(::sw::UndoRedoContext&) override; +}; + +/// Handling undo / redo of checkbox and drop-down form field insertion +class SwUndoInsNoTextFieldmark final : public SwUndo +{ +private: + const std::unique_ptr m_pHistoryNoTextFieldmark; + +public: + SwUndoInsNoTextFieldmark(const ::sw::mark::IFieldmark& rFieldmark); + + virtual void UndoImpl(::sw::UndoRedoContext&) override; + virtual void RedoImpl(::sw::UndoRedoContext&) override; +}; + +/// Handling undo / redo of checkbox and drop-down form field deletion +class SwUndoDelNoTextFieldmark final : public SwUndo +{ +private: + const std::unique_ptr m_pHistoryNoTextFieldmark; + +public: + SwUndoDelNoTextFieldmark(const ::sw::mark::IFieldmark& rFieldmark); + ~SwUndoDelNoTextFieldmark(); + + virtual void UndoImpl(::sw::UndoRedoContext&) override; + virtual void RedoImpl(::sw::UndoRedoContext&) override; +}; + +/// Handling undo / redo of text form field insertion +class SwUndoInsTextFieldmark final : public SwUndo +{ +private: + const std::unique_ptr m_pHistoryTextFieldmark; + +public: + SwUndoInsTextFieldmark(const ::sw::mark::IFieldmark& rFieldmark); + + virtual void UndoImpl(::sw::UndoRedoContext&) override; + virtual void RedoImpl(::sw::UndoRedoContext&) override; +}; + +/// Handling undo / redo of text form field deletion +class SwUndoDelTextFieldmark final : public SwUndo +{ +private: + const std::unique_ptr m_pHistoryTextFieldmark; + +public: + SwUndoDelTextFieldmark(const ::sw::mark::IFieldmark& rFieldmark); + ~SwUndoDelTextFieldmark(); + + virtual void UndoImpl(::sw::UndoRedoContext&) override; + virtual void RedoImpl(::sw::UndoRedoContext&) override; +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOBOOKMARK_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/UndoCore.hxx b/sw/source/core/inc/UndoCore.hxx new file mode 100644 index 0000000000..94891df09e --- /dev/null +++ b/sw/source/core/inc/UndoCore.hxx @@ -0,0 +1,297 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOCORE_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNDOCORE_HXX + +#include +#include +#include +#include +#include + +#include +#include + +class SfxItemSet; +class SwFormatColl; +class SwFormatAnchor; +class SdrMarkList; +class SwUndoDelete; + +namespace sw { + class UndoManager; + class IShellCursorSupplier; +} + +class SwRedlineSaveData final : public SwUndRng, public SwRedlineData, private SwUndoSaveSection +{ +public: + SwRedlineSaveData( + SwComparePosition eCmpPos, + const SwPosition& rSttPos, + const SwPosition& rEndPos, + SwRangeRedline& rRedl, + bool bCopyNext ); + + ~SwRedlineSaveData(); + + void RedlineToDoc( SwPaM const & rPam ); + + const SwNodeIndex* GetMvSttIdx() const + { + return SwUndoSaveSection::GetMvSttIdx(); + } + +#if OSL_DEBUG_LEVEL > 0 + sal_uInt16 m_nRedlineCount; + bool m_bRedlineCountDontCheck; + bool m_bRedlineMoved; +#endif +}; + +class SwRedlineSaveDatas { +private: + std::vector> m_Data; + +public: + SwRedlineSaveDatas() : m_Data() {} + + void clear() { m_Data.clear(); } + bool empty() const { return m_Data.empty(); } + size_t size() const { return m_Data.size(); } + void push_back(std::unique_ptr pNew) { m_Data.push_back(std::move(pNew)); } + const SwRedlineSaveData& operator[](size_t const nIdx) const { return *m_Data[ nIdx ]; } + SwRedlineSaveData& operator[](size_t const nIdx) { return *m_Data[ nIdx ]; } +#if OSL_DEBUG_LEVEL > 0 + void SetRedlineCountDontCheck(bool bCheck) { m_Data[0]->m_bRedlineCountDontCheck=bCheck; } +#endif +}; + +namespace sw { +class UndoRedoContext final + : public SfxUndoContext +{ +public: + UndoRedoContext(SwDoc & rDoc, IShellCursorSupplier & rCursorSupplier) + : m_rDoc(rDoc) + , m_rCursorSupplier(rCursorSupplier) + , m_pSelFormat(nullptr) + , m_pMarkList(nullptr) + { } + + SwDoc & GetDoc() const { return m_rDoc; } + + IShellCursorSupplier & GetCursorSupplier() { return m_rCursorSupplier; } + + void SetSelections(SwFrameFormat *const pSelFormat, SdrMarkList *const pMarkList) + { + m_pSelFormat = pSelFormat; + m_pMarkList = pMarkList; + } + void GetSelections(SwFrameFormat *& o_rpSelFormat, SdrMarkList *& o_rpMarkList) + { + o_rpSelFormat = m_pSelFormat; + o_rpMarkList = m_pMarkList; + } + + void SetUndoOffset(size_t nUndoOffset) { m_nUndoOffset = nUndoOffset; } + + size_t GetUndoOffset() override { return m_nUndoOffset; } + +private: + SwDoc & m_rDoc; + IShellCursorSupplier & m_rCursorSupplier; + SwFrameFormat * m_pSelFormat; + SdrMarkList * m_pMarkList; + size_t m_nUndoOffset = 0; +}; + +class RepeatContext final + : public SfxRepeatTarget +{ +public: + RepeatContext(SwDoc & rDoc, SwPaM & rPaM) + : m_rDoc(rDoc) + , m_pCurrentPaM(& rPaM) + , m_bDeleteRepeated(false) + { } + + SwDoc & GetDoc() const { return m_rDoc; } + + SwPaM & GetRepeatPaM() + { + return *m_pCurrentPaM; + } + +private: + friend class ::sw::UndoManager; + friend class ::SwUndoDelete; + + SwDoc & m_rDoc; + SwPaM * m_pCurrentPaM; + bool m_bDeleteRepeated; /// has a delete action been repeated? +}; + +} // namespace sw + +class SwUndoFormatColl final : public SwUndo, private SwUndRng +{ + OUString maFormatName; + std::unique_ptr mpHistory; + // for correct and + // boolean, which indicates that the attributes are reset at the nodes + // before the format has been applied. + const bool mbReset; + // boolean, which indicates that the list attributes had been reset at + // the nodes before the format has been applied. + const bool mbResetListAttrs; + + void DoSetFormatColl(SwDoc & rDoc, SwPaM const & rPaM); + +public: + SwUndoFormatColl( const SwPaM&, const SwFormatColl*, + const bool bReset, + const bool bResetListAttrs ); + virtual ~SwUndoFormatColl() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + /** + Returns the rewriter for this undo object. + + The rewriter contains one rule: + + $1 -> + + is the name of the format + collection that is applied by the action recorded by this undo + object. + + @return the rewriter for this undo object + */ + virtual SwRewriter GetRewriter() const override; + + SwHistory* GetHistory() { return mpHistory.get(); } + +}; + +class SwUndoSetFlyFormat final : public SwUndo, public SwClient +{ + SwFrameFormat* m_pFrameFormat; // saved FlyFormat + const OUString m_DerivedFromFormatName; + const OUString m_NewFormatName; + std::optional m_oItemSet; // the re-/ set attributes + SwNodeOffset m_nOldNode, m_nNewNode; + sal_Int32 m_nOldContent, m_nNewContent; + RndStdIds m_nOldAnchorType, m_nNewAnchorType; + bool m_bAnchorChanged; + + void PutAttr( sal_uInt16 nWhich, const SfxPoolItem* pItem ); + void SwClientNotify(const SwModify&, const SfxHint&) override; + void GetAnchor( SwFormatAnchor& rAnhor, SwNodeOffset nNode, sal_Int32 nContent ); + +public: + SwUndoSetFlyFormat( SwFrameFormat& rFlyFormat, const SwFrameFormat& rNewFrameFormat ); + virtual ~SwUndoSetFlyFormat() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + virtual SwRewriter GetRewriter() const override; +}; + +class SwUndoOutlineLeftRight final : public SwUndo, private SwUndRng +{ + short m_nOffset; + +public: + SwUndoOutlineLeftRight( const SwPaM& rPam, short nOffset ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; +}; + +class SwUndoOutlineEdit final : public SwUndo, private SwUndRng +{ + SwNumRule m_aNewNumRule; + SwNumRule m_aOldNumRule; + +public: + SwUndoOutlineEdit(const SwNumRule& rOldRule, const SwNumRule& rNewRule, const SwDoc& rDoc); + + virtual void UndoImpl(::sw::UndoRedoContext&) override; + virtual void RedoImpl(::sw::UndoRedoContext&) override; + virtual void RepeatImpl(::sw::RepeatContext&) override; +}; + +const int nUndoStringLength = 20; + +/** + Shortens a string to a maximum length. + + @param rStr the string to be shortened + @param nLength the maximum length for rStr + @param aFillStr string to replace cut out characters with + + If rStr has less than nLength characters it will be returned unaltered. + + If rStr has more than nLength characters the following algorithm + generates the shortened string: + + frontLength = (nLength - length(aFillStr)) / 2 + rearLength = nLength - length(aFillStr) - frontLength + shortenedString = concat() + + Preconditions: + - nLength - length(aFillStr) >= 2 + + @return the shortened string + */ +OUString +ShortenString(const OUString & rStr, sal_Int32 nLength, std::u16string_view aFillStr); +/** + Denotes special characters in a string. + + The rStr is split into parts containing special characters and + parts not containing special characters. In a part containing + special characters all characters are equal. These parts are + maximal. + + @param aStr the string to denote in + @param bQuoted add quotation marks to the text + + The resulting string is generated by concatenating the found + parts. The parts without special characters are surrounded by + "'". The parts containing special characters are denoted as "n x", + where n is the length of the part and x is the representation of + the special character (i. e. "tab(s)"). + + @return the denoted string +*/ +OUString DenoteSpecialCharacters(std::u16string_view aStr, bool bQuoted = true); + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOCORE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/UndoDelete.hxx b/sw/source/core/inc/UndoDelete.hxx new file mode 100644 index 0000000000..70e91367cb --- /dev/null +++ b/sw/source/core/inc/UndoDelete.hxx @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDODELETE_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNDODELETE_HXX + +#include +#include +#include +#include +#include + +class SwRedlineSaveDatas; +class SwTextNode; +typedef struct _xmlTextWriter* xmlTextWriterPtr; +enum class SwDeleteFlags; + +namespace sfx2 { + class MetadatableUndo; +} + +class SwUndoDelete final + : public SwUndo + , private SwUndRng + , private SwUndoSaveContent +{ + std::optional m_oMvStt; // Position of Nodes in UndoNodes-Array + std::optional m_aSttStr, m_aEndStr; + std::unique_ptr m_pRedlSaveData; + std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart; + std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd; + + OUString m_sTableName; + + SwNodeOffset m_nNode; + SwNodeOffset m_nNdDiff; // difference of Nodes before/after Delete + SwNodeOffset m_nSectDiff; // diff. of Nodes before/after Move w/ SectionNodes + SwNodeOffset m_nReplaceDummy; // diff. to a temporary dummy object + sal_uInt16 m_nSetPos; + + bool m_bGroup : 1; // TRUE: is already Grouped; see CanGrouping() + bool m_bBackSp : 1; // TRUE: if Grouped and preceding content deleted + bool m_bJoinNext: 1; // TRUE: if range is selected forwards + bool m_bTableDelLastNd : 1; // TRUE: TextNode following Table inserted/deleted + bool m_bDelFullPara : 1; // TRUE: entire Nodes were deleted + bool m_bResetPgDesc : 1; // TRUE: reset PgDsc on following node + bool m_bResetPgBrk : 1; // TRUE: reset PgBreak on following node + bool m_bFromTableCopy : 1; // TRUE: called by SwUndoTableCpyTable + SwDeleteFlags m_DeleteFlags; + + bool SaveContent( const SwPosition* pStt, const SwPosition* pEnd, + SwTextNode* pSttTextNd, SwTextNode* pEndTextNd ); + +public: + SwUndoDelete( + SwPaM&, + SwDeleteFlags flags, + bool bFullPara = false, + bool bCalledByTableCpy = false ); + virtual ~SwUndoDelete() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + /** + Returns rewriter for this undo object. + + The rewriter consists of the following rule: + + $1 -> '' + + is shortened to nUndoStringLength characters. + + @return rewriter for this undo object + */ + virtual SwRewriter GetRewriter() const override; + + bool CanGrouping( SwDoc&, const SwPaM& ); + + void SetTableDelLastNd() { m_bTableDelLastNd = true; } + + // for PageDesc/PageBreak Attributes of a table + void SetPgBrkFlags( bool bPageBreak, bool bPageDesc ) + { m_bResetPgDesc = bPageDesc; m_bResetPgBrk = bPageBreak; } + + void SetTableName(const OUString & rName); + + // SwUndoTableCpyTable needs this information: + bool IsDelFullPara() const { return m_bDelFullPara; } + + void dumpAsXml(xmlTextWriterPtr pWriter) const override; +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDODELETE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/UndoDraw.hxx b/sw/source/core/inc/UndoDraw.hxx new file mode 100644 index 0000000000..951902817b --- /dev/null +++ b/sw/source/core/inc/UndoDraw.hxx @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDODRAW_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNDODRAW_HXX + +#include +#include + +struct SwUndoGroupObjImpl; +class SdrMark; +class SdrMarkList; +class SdrObject; +class SdrObjGroup; +class SdrUndoAction; +class SwDrawFrameFormat; +class SwDoc; + +// Undo for Draw Objects +class SwSdrUndo final : public SwUndo +{ + std::unique_ptr m_pSdrUndo; + std::unique_ptr m_pMarkList; // MarkList for all selected SdrObjects + +public: + SwSdrUndo(std::unique_ptr, const SdrMarkList* pMarkList, const SwDoc& rDoc); + + virtual ~SwSdrUndo() override; + + virtual void UndoImpl(::sw::UndoRedoContext&) override; + virtual void RedoImpl(::sw::UndoRedoContext&) override; + + virtual OUString GetComment() const override; +}; + +class SwUndoDrawGroup final : public SwUndo +{ + std::unique_ptr m_pObjArray; + sal_uInt16 m_nSize; + bool m_bDeleteFormat; + +public: + SwUndoDrawGroup(sal_uInt16 nCnt, const SwDoc& rDoc); + + virtual ~SwUndoDrawGroup() override; + + virtual void UndoImpl(::sw::UndoRedoContext&) override; + virtual void RedoImpl(::sw::UndoRedoContext&) override; + + void AddObj(sal_uInt16 nPos, SwDrawFrameFormat*, SdrObject*); + void SetGroupFormat(SwDrawFrameFormat*); +}; + +// Action "ungroup drawing object" is now split into three parts - see +// method : +// - creation for instances for the group members of the +// selected group objects +// - intrinsic ungroup of the selected group objects +// - creation of instances for the former group members and +// connection to the Writer layout. +// Thus, two undo actions (instances of ) are needed: +// - Existing class takes over the part for the formats. +// - New class takes over the part for +// contact object. +class SwUndoDrawUnGroup final : public SwUndo +{ + std::unique_ptr m_pObjArray; + sal_uInt16 m_nSize; + bool m_bDeleteFormat; + +public: + SwUndoDrawUnGroup(SdrObjGroup*, const SwDoc& rDoc); + + virtual ~SwUndoDrawUnGroup() override; + + virtual void UndoImpl(::sw::UndoRedoContext&) override; + virtual void RedoImpl(::sw::UndoRedoContext&) override; + + void AddObj(sal_uInt16 nPos, SwDrawFrameFormat*); +}; + +class SwUndoDrawUnGroupConnectToLayout final : public SwUndo +{ +private: + std::vector> m_aDrawFormatsAndObjs; + +public: + SwUndoDrawUnGroupConnectToLayout(const SwDoc& rDoc); + + virtual ~SwUndoDrawUnGroupConnectToLayout() override; + + virtual void UndoImpl(::sw::UndoRedoContext&) override; + virtual void RedoImpl(::sw::UndoRedoContext&) override; + + void AddFormatAndObj(SwDrawFrameFormat* pDrawFrameFormat, SdrObject* pDrawObject); +}; + +class SwUndoDrawDelete final : public SwUndo +{ + std::unique_ptr m_pObjArray; + std::unique_ptr m_pMarkList; // MarkList for all selected SdrObjects + bool m_bDeleteFormat; + +public: + SwUndoDrawDelete(sal_uInt16 nCnt, const SwDoc& rDoc); + + virtual ~SwUndoDrawDelete() override; + + virtual void UndoImpl(::sw::UndoRedoContext&) override; + virtual void RedoImpl(::sw::UndoRedoContext&) override; + + void AddObj(SwDrawFrameFormat*, const SdrMark&); + void dumpAsXml(xmlTextWriterPtr pWriter) const override; +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDODRAW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/UndoInsert.hxx b/sw/source/core/inc/UndoInsert.hxx new file mode 100644 index 0000000000..348cc57af0 --- /dev/null +++ b/sw/source/core/inc/UndoInsert.hxx @@ -0,0 +1,228 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOINSERT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNDOINSERT_HXX + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +class SwGrfNode; +class SwUndoDelete; +class SwUndoFormatAttr; +class SwDoc; +namespace sw { class DocumentContentOperationsManager; } +enum class MirrorGraph; + +/// Typing one or more characters to a single paragraph. +class SwUndoInsert final : public SwUndo, private SwUndoSaveContent +{ + /// start of Content in UndoNodes for Redo + std::optional m_oUndoNodeIndex; + std::optional maText; + std::optional maUndoText; + std::unique_ptr m_pRedlData; + SwNodeOffset m_nNode; + sal_Int32 m_nContent, m_nLen; + bool m_bIsWordDelim : 1; + bool m_bIsAppend : 1; + bool m_bWithRsid : 1; + + const SwInsertFlags m_nInsertFlags; + + friend class ::sw::DocumentContentOperationsManager; // actually only DocumentContentOperationsManager::InsertString, because it uses CanGrouping + bool CanGrouping( sal_Unicode cIns ); + bool CanGrouping( const SwPosition& rPos ); + + SwDoc * m_pDoc; + + void Init(const SwNode & rNode); + std::optional GetTextFromDoc() const; + +public: + SwUndoInsert( const SwNode& rNode, sal_Int32 nContent, sal_Int32 nLen, + const SwInsertFlags nInsertFlags, + bool bWDelim = true ); + SwUndoInsert( const SwNode& rNode ); + virtual ~SwUndoInsert() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + /** + Returns rewriter for this undo object. + + The returned rewriter has the following rule: + + $1 -> '' + + is shortened to a length of nUndoStringLength. + + @return rewriter for this undo object + */ + virtual SwRewriter GetRewriter() const override; + + void SetWithRsid() { m_bWithRsid = true; } + + bool IsIndependent(const SwUndoInsert& rOther) const; +}; + +SwRewriter +MakeUndoReplaceRewriter(sal_uLong const occurrences, + OUString const& sOld, OUString const& sNew); + +class SwUndoReplace final + : public SwUndo +{ +public: + SwUndoReplace(SwPaM const& rPam, + OUString const& rInsert, bool const bRegExp); + + virtual ~SwUndoReplace() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + /** + Returns the rewriter of this undo object. + + If this undo object represents several replacements the + rewriter contains the following rules: + + $1 -> + $2 -> occurrences of + $3 -> + + If this undo object represents one replacement the rewriter + contains these rules: + + $1 -> + $2 -> "->" (STR_YIELDS) + $3 -> + + @return the rewriter of this undo object + */ + virtual SwRewriter GetRewriter() const override; + + void SetEnd( const SwPaM& rPam ); + +private: + class Impl; + std::unique_ptr m_pImpl; +}; + +/// Handles the undo/redo of the 'Replace...' context menu item for an image. +class SwUndoReRead final : public SwUndo +{ + std::optional moGraphic; + std::optional maNm; + std::optional maFltr; + SwNodeOffset mnPosition; + MirrorGraph mnMirror; + + void SaveGraphicData( const SwGrfNode& ); + void SetAndSave( ::sw::UndoRedoContext & ); + +public: + SwUndoReRead( const SwPaM& rPam, const SwGrfNode& pGrfNd ); + + virtual ~SwUndoReRead() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; +}; + +class SwUndoInsertLabel final : public SwUndo +{ + union { + struct { + // for NoTextFrames + SwUndoInsLayFormat* pUndoFly; + SwUndoFormatAttr* pUndoAttr; + } OBJECT; + struct { + // for tables or TextFrames + SwUndoDelete* pUndoInsNd; + SwNodeOffset nNode; + } NODE; + }; + + OUString m_sText; + // #i39983# the separator is drawn with a character style + OUString m_sSeparator; + OUString m_sNumberSeparator; + OUString m_sCharacterStyle; + // #i26791# - re-store of drawing object position no longer needed + sal_uInt16 m_nFieldId; + SwLabelType m_eType; + SdrLayerID m_nLayerId; // for character objects + bool m_bBefore :1; + bool m_bUndoKeep :1; + bool m_bCopyBorder :1; + +public: + SwUndoInsertLabel( const SwLabelType eTyp, OUString rText, + // #i39983# the separator is drawn with a character style + OUString aSeparator, + OUString aNumberSeparator, //#i61007# order of captions + const bool bBefore, const sal_uInt16 nId, + OUString aCharacterStyle, + const bool bCpyBrd, + const SwDoc* pDoc ); + virtual ~SwUndoInsertLabel() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + /** + Returns the rewriter of this undo object. + + The rewriter contains this rule: + + $1 -> '' + + is shortened to nUndoStringLength + characters. + + @return the rewriter of this undo object + */ + virtual SwRewriter GetRewriter() const override; + static SwRewriter CreateRewriter(const OUString &rStr); + + void SetNodePos( SwNodeOffset nNd ) + { if( SwLabelType::Object != m_eType ) NODE.nNode = nNd; } + + void SetUndoKeep() { m_bUndoKeep = true; } + void SetFlys( SwFrameFormat& rOldFly, SfxItemSet const & rChgSet, SwFrameFormat& rNewFly ); + void SetDrawObj( SdrLayerID nLayerId ); +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOINSERT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/UndoManager.hxx b/sw/source/core/inc/UndoManager.hxx new file mode 100644 index 0000000000..3376393573 --- /dev/null +++ b/sw/source/core/inc/UndoManager.hxx @@ -0,0 +1,143 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNDOMANAGER_HXX + +#include +#include +#include +#include + +class IDocumentDrawModelAccess; +class IDocumentRedlineAccess; +class IDocumentState; +class SwDocShell; +class SwView; + +namespace sw { + +/** + * Stores the undo/redo information, implementing the IDocumentUndoRedo interface. + * It contains a stack of SwUndo actions, each of which represents one user-visible + * undo / redo step. + */ +class SW_DLLPUBLIC UndoManager final + : public IDocumentUndoRedo + , public SdrUndoManager +{ +public: + UndoManager(std::shared_ptr pUndoNodes, + IDocumentDrawModelAccess & rDrawModelAccess, + IDocumentRedlineAccess & rRedlineAccess, + IDocumentState & rState); + + /** IDocumentUndoRedo */ + virtual void DoUndo(bool const bDoUndo) override; + virtual bool DoesUndo() const override; + virtual void DoGroupUndo(bool const bDoUndo) override; + virtual bool DoesGroupUndo() const override; + virtual void DoDrawUndo(bool const bDoUndo) override; + virtual bool DoesDrawUndo() const override; + void DoRepair(bool bRepair) override; + bool DoesRepair() const override; + virtual void SetUndoNoModifiedPosition() override; + virtual void LockUndoNoModifiedPosition() override; + virtual void UnLockUndoNoModifiedPosition() override; + virtual void SetUndoNoResetModified() override; + virtual bool IsUndoNoResetModified() const override; + + virtual SwUndoId StartUndo(SwUndoId const eUndoId, + SwRewriter const*const pRewriter) override; + virtual SwUndoId EndUndo(SwUndoId const eUndoId, + SwRewriter const*const pRewriter) override; + virtual void DelAllUndoObj() override; + virtual bool GetLastUndoInfo(OUString *const o_pStr, + SwUndoId *const o_pId, + const SwView* pView = nullptr) const override; + virtual SwUndoComments_t GetUndoComments() const override; + virtual bool GetFirstRedoInfo(OUString *const o_pStr, + SwUndoId *const o_pId, + const SwView* pView = nullptr) const override; + virtual SwUndoComments_t GetRedoComments() const override; + virtual bool Repeat(::sw::RepeatContext & rContext, + sal_uInt16 const nRepeatCnt) override; + virtual SwUndoId GetRepeatInfo(OUString *const o_pStr) const override; + virtual void AppendUndo(std::unique_ptr pUndo) override; + virtual void ClearRedo() override; + virtual bool IsUndoNodes(SwNodes const& rNodes) const override; + virtual size_t GetUndoActionCount(const bool bCurrentLevel = true) const override; + size_t GetRedoActionCount(const bool bCurrentLevel = true) const override; + void SetView(SwView* pView) override; + bool UndoWithOffset(size_t nUndoOffset) override; + + // SfxUndoManager + virtual void AddUndoAction(std::unique_ptr pAction, + bool bTryMerg = false) override; + virtual bool Undo() override; + virtual bool Redo() override; + void dumpAsXml(xmlTextWriterPtr pWriter) const; + + SwUndo * RemoveLastUndo(); + SwUndo * GetLastUndo(); + + SwNodes const& GetUndoNodes() const; + SwNodes & GetUndoNodes(); + void SetDocShell(SwDocShell* pDocShell); + + /** + * Checks if the topmost undo action owned by pView is independent from the topmost action undo + * action. Sets rOffset to the offset of that independent undo action on success. + */ + bool IsViewUndoActionIndependent(const SwView* pView, sal_uInt16& rOffset) const; + +private: + virtual void EmptyActionsChanged() override; + + IDocumentDrawModelAccess & m_rDrawModelAccess; + IDocumentRedlineAccess & m_rRedlineAccess; + IDocumentState & m_rState; + + /// Undo nodes array: content not currently in document, but required for undo/redo. + std::shared_ptr m_xUndoNodes; + + bool m_bGroupUndo : 1; // TRUE: Undo grouping enabled + bool m_bDrawUndo : 1; // TRUE: Draw Undo enabled + /// If true, then repair mode is enabled. + bool m_bRepair; + bool m_bLockUndoNoModifiedPosition : 1; + /// set the IgnoreRepeat flag on every added action + bool m_isAddWithIgnoreRepeat; + /// position in Undo-Array at which Doc was saved (and is not modified) + UndoStackMark m_UndoSaveMark; + SwDocShell* m_pDocShell; + SwView* m_pView; + + enum class UndoOrRedoType { Undo, Redo }; + bool impl_DoUndoRedo(UndoOrRedoType undoOrRedo, size_t nUndoOffset); + + // UGLY: should not be called + using SdrUndoManager::Repeat; +}; + +} // namespace sw + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/UndoNumbering.hxx b/sw/source/core/inc/UndoNumbering.hxx new file mode 100644 index 0000000000..660c14d2bd --- /dev/null +++ b/sw/source/core/inc/UndoNumbering.hxx @@ -0,0 +1,142 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDONUMBERING_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNDONUMBERING_HXX + +#include +#include +#include +#include +#include + +class SwUndoInsNum final : public SwUndo, private SwUndRng +{ + SwNumRule m_aNumRule; + std::unique_ptr m_pHistory; + std::unique_ptr m_pOldNumRule; + OUString m_sReplaceRule; + sal_uInt16 m_nLRSavePos; + +public: + SwUndoInsNum( const SwPaM& rPam, const SwNumRule& rRule ); + SwUndoInsNum( const SwNumRule& rOldRule, const SwNumRule& rNewRule, + const SwDoc& rDoc, SwUndoId nUndoId = SwUndoId::INSFMTATTR ); + SwUndoInsNum( const SwPosition& rPos, const SwNumRule& rRule, + OUString aReplaceRule ); + + virtual ~SwUndoInsNum() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + virtual SwRewriter GetRewriter() const override; + + SwHistory* GetHistory(); // will be created if necessary + void SaveOldNumRule( const SwNumRule& rOld ); + + void SetLRSpaceEndPos(); + +}; + +class SwUndoDelNum final : public SwUndo, private SwUndRng +{ + struct NodeLevel + { + SwNodeOffset index; + int level; + NodeLevel(SwNodeOffset idx, int lvl) : index(idx), level(lvl) {}; + }; + std::vector m_aNodes; + std::unique_ptr m_pHistory; + +public: + SwUndoDelNum( const SwPaM& rPam ); + + virtual ~SwUndoDelNum() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + void AddNode( const SwTextNode& rNd ); + SwHistory* GetHistory() { return m_pHistory.get(); } +}; + +class SwUndoMoveNum final : public SwUndo, private SwUndRng +{ + SwNodeOffset m_nNewStart; + SwNodeOffset m_nOffset; + +public: + SwUndoMoveNum( const SwPaM& rPam, SwNodeOffset nOffset, bool bIsOutlMv ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + void SetStartNode( SwNodeOffset nValue ) { m_nNewStart = nValue; } +}; + +class SwUndoNumUpDown final : public SwUndo, private SwUndRng +{ + short m_nOffset; + +public: + SwUndoNumUpDown( const SwPaM& rPam, short nOffset ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; +}; + +class SwUndoNumOrNoNum final : public SwUndo +{ + SwNodeOffset m_nIndex; + bool mbNewNum, mbOldNum; + +public: + SwUndoNumOrNoNum( const SwNode& rIdx, bool mbOldNum, + bool mbNewNum ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; +}; + +class SwUndoNumRuleStart final : public SwUndo +{ + SwNodeOffset m_nIndex; + sal_uInt16 m_nOldStart, m_nNewStart; + bool m_bSetStartValue : 1; + bool m_bFlag : 1; + +public: + SwUndoNumRuleStart( const SwPosition& rPos, bool bDelete ); + SwUndoNumRuleStart( const SwPosition& rPos, sal_uInt16 nStt ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDONUMBERING_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/UndoOverwrite.hxx b/sw/source/core/inc/UndoOverwrite.hxx new file mode 100644 index 0000000000..ddbf23262d --- /dev/null +++ b/sw/source/core/inc/UndoOverwrite.hxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOOVERWRITE_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNDOOVERWRITE_HXX + +#include +#include +#include + +class SwRedlineSaveDatas; +class SwTextNode; +enum class TransliterationFlags; +namespace utl { + class TransliterationWrapper; +} + +class SwUndoOverwrite final : public SwUndo, private SwUndoSaveContent +{ + OUString m_aDelStr, m_aInsStr; + std::unique_ptr m_pRedlSaveData; + SwNodeOffset m_nStartNode; + sal_Int32 m_nStartContent; + bool m_bInsChar : 1; // no Overwrite, but Insert + bool m_bGroup : 1; // TRUE: is already grouped; evaluated in CanGrouping() + +public: + SwUndoOverwrite( SwDoc&, SwPosition&, sal_Unicode cIns ); + + virtual ~SwUndoOverwrite() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + /** + Returns the rewriter of this undo object. + + The rewriter contains the following rule: + + $1 -> '' + + is shortened to nUndoStringLength characters. + + @return the rewriter of this undo object + */ + virtual SwRewriter GetRewriter() const override; + + bool CanGrouping( SwDoc&, SwPosition&, sal_Unicode cIns ); +}; + +struct UndoTransliterate_Data; +class SwUndoTransliterate final : public SwUndo, public SwUndRng +{ + std::vector< std::unique_ptr > m_aChanges; + TransliterationFlags m_nType; + + void DoTransliterate(SwDoc & rDoc, SwPaM const & rPam); + +public: + SwUndoTransliterate( const SwPaM& rPam, + const utl::TransliterationWrapper& rTrans ); + + virtual ~SwUndoTransliterate() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + void AddChanges( SwTextNode& rTNd, sal_Int32 nStart, sal_Int32 nLen, + css::uno::Sequence const & rOffsets ); + bool HasData() const { return m_aChanges.size() > 0; } +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOOVERWRITE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/UndoRedline.hxx b/sw/source/core/inc/UndoRedline.hxx new file mode 100644 index 0000000000..127aeae0aa --- /dev/null +++ b/sw/source/core/inc/UndoRedline.hxx @@ -0,0 +1,148 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOREDLINE_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNDOREDLINE_HXX + +#include +#include +#include + +struct SwSortOptions; +class SwRangeRedline; +class SwRedlineSaveDatas; +class SwUndoDelete; + +class SwUndoRedline : public SwUndo, public SwUndRng +{ +protected: + std::unique_ptr mpRedlData; + std::unique_ptr mpRedlSaveData; + SwUndoId mnUserId; + bool mbHiddenRedlines; + sal_Int8 mnDepth; // index of the SwRedlineData in SwRangeRedline + + virtual void UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam); + virtual void RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam); + +public: + SwUndoRedline( SwUndoId nUserId, const SwPaM& rRange, sal_Int8 nDepth = 0 ); + + virtual ~SwUndoRedline() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + sal_uInt16 GetRedlSaveCount() const; +#if OSL_DEBUG_LEVEL > 0 + void SetRedlineCountDontCheck(bool bCheck); +#endif +}; + +class SwUndoRedlineDelete final : public SwUndoRedline +{ +private: + std::unique_ptr m_pHistory; ///< for moved fly anchors + + bool m_bCanGroup : 1; + bool m_bIsDelim : 1; + bool m_bIsBackspace : 1; + + OUString m_sRedlineText; + + void InitHistory(SwPaM const& rRange); + + virtual void UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam) override; + virtual void RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam) override; + +public: + SwUndoRedlineDelete(const SwPaM& rRange, SwUndoId nUserId, SwDeleteFlags flags = SwDeleteFlags::Default); + virtual SwRewriter GetRewriter() const override; + + bool CanGrouping( const SwUndoRedlineDelete& rPrev ); + + // SwUndoTableCpyTable needs this information: + SwNodeOffset NodeDiff() const { return m_nSttNode - m_nEndNode; } + sal_Int32 ContentStart() const { return m_nSttContent; } + + void SetRedlineText(const OUString & rText); +}; + +class SwUndoRedlineSort final : public SwUndoRedline +{ + std::unique_ptr m_pOpt; + SwNodeOffset m_nSaveEndNode; + sal_Int32 m_nSaveEndContent; + + virtual void UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam) override; + virtual void RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam) override; + +public: + SwUndoRedlineSort( const SwPaM& rRange, const SwSortOptions& rOpt ); + + virtual ~SwUndoRedlineSort() override; + + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + void SetSaveRange( const SwPaM& rRange ); +}; + +/// Undo for Edit -> track changes -> accept. +class SwUndoAcceptRedline final : public SwUndoRedline +{ +private: + virtual void RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam) override; + +public: + SwUndoAcceptRedline( const SwPaM& rRange, sal_Int8 nDepth = 0 ); + + virtual void RepeatImpl( ::sw::RepeatContext & ) override; +}; + +class SwUndoRejectRedline final : public SwUndoRedline +{ +private: + virtual void RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam) override; + +public: + SwUndoRejectRedline( const SwPaM& rRange, sal_Int8 nDepth = 0 ); + + virtual void RepeatImpl( ::sw::RepeatContext & ) override; +}; + +class SwUndoCompDoc final : public SwUndo, public SwUndRng +{ + std::unique_ptr m_pRedlineData; + std::unique_ptr m_pUndoDelete, m_pUndoDelete2; + std::unique_ptr m_pRedlineSaveDatas; + bool m_bInsert; + +public: + SwUndoCompDoc( const SwPaM& rRg, bool bIns ); + SwUndoCompDoc( const SwRangeRedline& rRedl ); + + virtual ~SwUndoCompDoc() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOREDLINE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/UndoSection.hxx b/sw/source/core/inc/UndoSection.hxx new file mode 100644 index 0000000000..5be018a2e1 --- /dev/null +++ b/sw/source/core/inc/UndoSection.hxx @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOSECTION_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNDOSECTION_HXX + +#include +#include +#include +#include +#include + +class SfxItemSet; +class SwTextNode; +class SwSectionData; +class SwSectionFormat; +class SwTOXBase; + +namespace sw { + enum class RedlineMode; + enum class FieldmarkMode; + enum class ParagraphBreakMode; +}; + +class SwUndoInsSection final : public SwUndo, private SwUndRng +{ +private: + const std::unique_ptr m_pSectionData; + std::optional, sw::RedlineMode, sw::FieldmarkMode, sw::ParagraphBreakMode>> m_xTOXBase; /// set iff section is TOX + const std::unique_ptr m_pAttrSet; + std::unique_ptr m_pHistory; + std::unique_ptr m_pRedlData; + std::unique_ptr m_pRedlineSaveData; + SwNodeOffset m_nSectionNodePos; + bool m_bSplitAtStart : 1; + bool m_bSplitAtEnd : 1; + bool m_bUpdateFootnote : 1; + + void Join( SwDoc& rDoc, SwNodeOffset nNode ); + +public: + SwUndoInsSection(SwPaM const&, SwSectionData const&, + SfxItemSet const* pSet, + std::tuple const* pTOXBase); + + virtual ~SwUndoInsSection() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + void SetSectNdPos(SwNodeOffset const nPos) { m_nSectionNodePos = nPos; } + void SaveSplitNode(SwTextNode *const pTextNd, bool const bAtStart); + void SetUpdateFootnoteFlag(bool const bFlag) { m_bUpdateFootnote = bFlag; } +}; + +std::unique_ptr MakeUndoDelSection(SwSectionFormat const&); + +std::unique_ptr MakeUndoUpdateSection(SwSectionFormat const&, bool const); + + +class SwTOXBaseSection; +class SwUndoDelSection; + +class SwUndoUpdateIndex final : public SwUndo +{ +private: + std::unique_ptr m_pTitleSectionUpdated; + std::unique_ptr> const m_pSaveSectionOriginal; + std::unique_ptr> const m_pSaveSectionUpdated; + SwNodeOffset const m_nStartIndex; + +public: + SwUndoUpdateIndex(SwTOXBaseSection &); + virtual ~SwUndoUpdateIndex() override; + + void TitleSectionInserted(SwSectionFormat & rSectionFormat); + + virtual void UndoImpl(::sw::UndoRedoContext &) override; + virtual void RedoImpl(::sw::UndoRedoContext &) override; +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOSECTION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/UndoSort.hxx b/sw/source/core/inc/UndoSort.hxx new file mode 100644 index 0000000000..432dd41133 --- /dev/null +++ b/sw/source/core/inc/UndoSort.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOSORT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNDOSORT_HXX + +#include + +#include +#include + +#include +#include + +struct SwSortOptions; +class SwTableNode; +class SwUndoAttrTable; + +struct SwSortUndoElement +{ + OUString maSourceString; + OUString maTargetString; + SwNodeOffset mnSourceNodeOffset; + SwNodeOffset mnTargetNodeOffset; + + SwSortUndoElement(const OUString& aSource, const OUString& aTarget) + : maSourceString(aSource) + , maTargetString(aTarget) + {} + + SwSortUndoElement(SwNodeOffset nSource, SwNodeOffset nTarget) + : mnSourceNodeOffset(nSource) + , mnTargetNodeOffset(nTarget) + {} +}; + +class SwUndoSort final : public SwUndo, private SwUndRng +{ + std::unique_ptr m_pSortOptions; + std::vector> m_SortList; + std::unique_ptr m_pUndoAttrTable; + SwNodeOffset m_nTableNode; + +public: SwUndoSort( const SwPaM&, const SwSortOptions& ); + SwUndoSort( SwNodeOffset nStt, SwNodeOffset nEnd, const SwTableNode&, + const SwSortOptions&, bool bSaveTable ); + + virtual ~SwUndoSort() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + void Insert( const OUString& rOrgPos, const OUString& rNewPos ); + void Insert( SwNodeOffset nOrgPos, SwNodeOffset nNewPos ); +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOSORT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/UndoSplitMove.hxx b/sw/source/core/inc/UndoSplitMove.hxx new file mode 100644 index 0000000000..cd8b653df9 --- /dev/null +++ b/sw/source/core/inc/UndoSplitMove.hxx @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOSPLITMOVE_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNDOSPLITMOVE_HXX + +#include + +class SwUndoSplitNode final : public SwUndo +{ + std::unique_ptr m_pHistory; + std::unique_ptr m_pRedlineData; + SwNodeOffset m_nNode; + sal_Int32 m_nContent; + bool m_bTableFlag : 1; + bool m_bCheckTableStart : 1; + sal_uInt32 m_nParRsid; + +public: + SwUndoSplitNode( SwDoc& rDoc, const SwPosition& rPos, bool bChkTable ); + + virtual ~SwUndoSplitNode() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + void SetTableFlag() { m_bTableFlag = true; } +}; + +class SwUndoMove final : public SwUndo, private SwUndRng, private SwUndoSaveContent +{ + // nDest... - destination range of move (after move!) + // nIns... - source Position of move (after move!) + // nMv... - destination position of move (before move!); for REDO + SwNodeOffset m_nDestStartNode, m_nDestEndNode, m_nInsPosNode, m_nMoveDestNode; + sal_Int32 m_nDestStartContent, m_nDestEndContent, m_nInsPosContent, m_nMoveDestContent; + + sal_uInt16 m_nFootnoteStart; // StartPos of Footnotes in History + + bool m_bJoinNext : 1, + m_bMoveRange : 1; + + bool m_bMoveRedlines; // use DOC_MOVEREDLINES when calling SwDoc::Move + + void DelFootnote( const SwPaM& ); + +public: + SwUndoMove( const SwPaM&, const SwPosition& ); + SwUndoMove( SwDoc& rDoc, const SwNodeRange&, const SwNode& ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + /// set the destination range after the move + void SetDestRange( const SwNode& rStt, const SwNode& rEnd, + const SwNodeIndex& rInsPos ); + + bool IsMoveRange() const { return m_bMoveRange; } + SwNodeOffset GetEndNode() const { return m_nEndNode; } + SwNodeOffset GetDestSttNode() const { return m_nDestStartNode; } + sal_Int32 GetDestSttContent() const { return m_nDestStartContent; } + + void SetMoveRedlines( bool b ) { m_bMoveRedlines = b; } +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOSPLITMOVE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx new file mode 100644 index 0000000000..29850d2f07 --- /dev/null +++ b/sw/source/core/inc/UndoTable.hxx @@ -0,0 +1,429 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOTABLE_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNDOTABLE_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class SfxItemSet; + +struct SwSaveRowSpan; +class SaveTable; +class SwDDEFieldType; +class SwUndoDelete; +class SwSelBoxes; +class SwTable; +class SwTableBox; +class SwStartNode; +class SwTableNode; +class SwTableAutoFormat; +class SwTableSortBoxes; +class SwContentNode; +class SwCursorShell; + +namespace sw { + +void NotifyTableCollapsedParagraph(const SwContentNode* pNode, SwCursorShell *const pShell); + +} + +/// Implements undo/redo for Table -> Insert Table. +class SwUndoInsTable final : public SwUndo +{ + OUString m_sTableName; + SwInsertTableOptions m_aInsTableOptions; + std::unique_ptr m_pDDEFieldType; + std::optional> m_oColumnWidth; + std::unique_ptr m_pRedlineData; + std::unique_ptr m_pAutoFormat; + SwNodeOffset m_nStartNode; + sal_uInt16 m_nRows, m_nColumns; + sal_uInt16 const m_nAdjust; + +public: + SwUndoInsTable( const SwPosition&, sal_uInt16 nCols, sal_uInt16 nRows, + sal_uInt16 eAdjust, const SwInsertTableOptions& rInsTableOpts, + const SwTableAutoFormat* pTAFormat, const std::vector *pColArr, + const OUString & rName); + + virtual ~SwUndoInsTable() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + virtual SwRewriter GetRewriter() const override; +}; + +class SwUndoTextToTable final : public SwUndo, public SwUndRng +{ + OUString m_sTableName; + SwInsertTableOptions m_aInsertTableOpts; + std::vector mvDelBoxes; + std::unique_ptr m_pAutoFormat; + SwHistory* m_pHistory; + sal_Unicode m_cSeparator; + sal_uInt16 m_nAdjust; + bool m_bSplitEnd : 1; + +public: + SwUndoTextToTable( const SwPaM&, const SwInsertTableOptions&, sal_Unicode, + sal_uInt16, + const SwTableAutoFormat* pAFormat ); + + virtual ~SwUndoTextToTable() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + SwHistory& GetHistory(); // will be created if necessary + void AddFillBox( const SwTableBox& rBox ); +}; + +class SwUndoTableToText final : public SwUndo +{ + OUString m_sTableName; + std::unique_ptr m_pDDEFieldType; + std::unique_ptr m_pTableSave; + SwTableToTextSaves m_vBoxSaves; + std::unique_ptr m_pHistory; + SwNodeOffset m_nStartNode, m_nEndNode; + sal_Unicode m_cSeparator; + sal_uInt16 m_nHeadlineRepeat; + bool m_bCheckNumFormat : 1; + +public: + SwUndoTableToText( const SwTable& rTable, sal_Unicode cCh ); + + virtual ~SwUndoTableToText() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + void SetRange( const SwNodeRange& ); + void AddBoxPos( SwDoc& rDoc, SwNodeOffset nNdIdx, SwNodeOffset nEndIdx, + sal_Int32 nContentIdx = SAL_MAX_INT32); +}; + +class SwUndoAttrTable final : public SwUndo +{ + SwNodeOffset m_nStartNode; + std::unique_ptr m_pSaveTable; + bool m_bClearTableCol : 1; + +public: + SwUndoAttrTable( const SwTableNode& rTableNd, bool bClearTabCols = false ); + + virtual ~SwUndoAttrTable() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; +}; + +class SwUndoTableNumFormat; + +class SwUndoTableAutoFormat final : public SwUndo +{ + OUString m_TableStyleName; + SwNodeOffset m_nStartNode; + std::unique_ptr m_pSaveTable; + std::vector< std::shared_ptr > m_Undos; + bool m_bSaveContentAttr; + sal_uInt16 m_nRepeatHeading; + + void UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext); + +public: + SwUndoTableAutoFormat( const SwTableNode& rTableNd, const SwTableAutoFormat& ); + + virtual ~SwUndoTableAutoFormat() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + void SaveBoxContent( const SwTableBox& rBox ); +}; + +using SwUndoSaveSections = std::vector>>; + +class SwUndoTableNdsChg final : public SwUndo +{ + std::unique_ptr m_pSaveTable; + std::set m_Boxes; + struct BoxMove + { + SwNodeOffset index; ///< Index of this box. + bool hasMoved; ///< Has this box been moved already. + BoxMove(SwNodeOffset idx, bool moved=false) : index(idx), hasMoved(moved) {}; + bool operator<(const BoxMove& other) const { return index < other.index; }; + }; + std::optional< std::set > m_xNewSttNds; + std::unique_ptr m_pDelSects; + tools::Long m_nMin, m_nMax; // for redo of delete column + SwNodeOffset m_nSttNode; + sal_uInt16 m_nCount; + bool m_bFlag; + bool m_bSameHeight; // only used for SplitRow + + SwUndoTableNdsChg(SwUndoTableNdsChg const&) = delete; + SwUndoTableNdsChg& operator=(SwUndoTableNdsChg const&) = delete; + +public: + SwUndoTableNdsChg( SwUndoId UndoId, + const SwSelBoxes& rBoxes, + const SwTableNode& rTableNd, + tools::Long nMn, tools::Long nMx, + sal_uInt16 nCnt, bool bFlg, bool bSameHeight ); + + virtual ~SwUndoTableNdsChg() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + void SaveNewBoxes( const SwTableNode& rTableNd, const SwTableSortBoxes& rOld ); + void SaveNewBoxes( const SwTableNode& rTableNd, const SwTableSortBoxes& rOld, + const SwSelBoxes& rBoxes, const std::vector &rNodeCnts ); + void SaveSection( SwStartNode* pSttNd ); + void ReNewBoxes( const SwSelBoxes& rBoxes ); + +}; + +class SwUndoMove; + +class SwUndoTableMerge final : public SwUndo, private SwUndRng +{ + SwNodeOffset m_nTableNode; + std::unique_ptr m_pSaveTable; + std::set m_Boxes; + std::vector m_aNewStartNodes; + std::vector> m_vMoves; + std::unique_ptr m_pHistory; + +public: + SwUndoTableMerge( const SwPaM& rTableSel ); + + virtual ~SwUndoTableMerge() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + void MoveBoxContent( SwDoc& rDoc, SwNodeRange& rRg, SwNode& rPos ); + + void SetSelBoxes( const SwSelBoxes& rBoxes ); + + void AddNewBox( SwNodeOffset nSttNdIdx ) + { m_aNewStartNodes.push_back( nSttNdIdx ); } + + void SaveCollection( const SwTableBox& rBox ); +}; + +class SwUndoTableNumFormat final : public SwUndo +{ + std::unique_ptr m_pBoxSet; + std::unique_ptr m_pHistory; + OUString m_aStr, m_aNewFormula; + + sal_uLong m_nFormatIdx, m_nNewFormatIdx; + double m_fNum, m_fNewNum; + SwNodeOffset m_nNode; + SwNodeOffset m_nNodePos; + + bool m_bNewFormat : 1; + bool m_bNewFormula : 1; + bool m_bNewValue : 1; + +public: + SwUndoTableNumFormat( const SwTableBox& rBox, const SfxItemSet* pNewSet = nullptr ); + + virtual ~SwUndoTableNumFormat() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + void SetNumFormat( sal_uLong nNewNumFormatIdx, const double& rNewNumber ) + { m_nFormatIdx = nNewNumFormatIdx; m_fNum = rNewNumber; } + void SetBox( const SwTableBox& rBox ); +}; + +struct UndoTableCpyTable_Entry; + +class SwUndoTableCpyTable final : public SwUndo +{ + std::vector> m_vArr; + std::unique_ptr m_pInsRowUndo; + + //b6341295: When redlining is active, PrepareRedline has to create the + //redlining attributes for the new and the old table cell content + static std::unique_ptr PrepareRedline( SwDoc* pDoc, const SwTableBox& rBox, + SwPosition& rPos, bool& rJoin, bool bRedo ); + +public: + SwUndoTableCpyTable(const SwDoc& rDoc); + + virtual ~SwUndoTableCpyTable() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + void AddBoxBefore( const SwTableBox& rBox, bool bDelContent ); + void AddBoxAfter( const SwTableBox& rBox, const SwNodeIndex& rIdx, + bool bDelContent ); + + bool IsEmpty() const; + bool InsertRow( SwTable& rTable, const SwSelBoxes& rBoxes, sal_uInt16 nCnt ); + void dumpAsXml(xmlTextWriterPtr pWriter) const override; +}; + +class SwUndoCpyTable final : public SwUndo +{ + std::unique_ptr m_pDelete; + SwNodeOffset m_nTableNode; + +public: + SwUndoCpyTable(const SwDoc& rDoc); + + virtual ~SwUndoCpyTable() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + void SetTableSttIdx( SwNodeOffset nIdx ) { m_nTableNode = nIdx; } +}; + +class SwUndoSplitTable final : public SwUndo +{ + SwNodeOffset m_nTableNode, m_nOffset; + std::unique_ptr mpSaveRowSpan; // stores row span values at the splitting row + std::unique_ptr m_pSavedTable; + std::unique_ptr m_pHistory; + SplitTable_HeadlineOption const m_nMode; + sal_uInt16 m_nFormulaEnd; + bool m_bCalcNewSize; + +public: + SwUndoSplitTable( const SwTableNode& rTableNd, std::unique_ptr pRowSp, + SplitTable_HeadlineOption nMode, bool bCalcNewSize ); + + virtual ~SwUndoSplitTable() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + void SetTableNodeOffset( SwNodeOffset nIdx ) { m_nOffset = nIdx - m_nTableNode; } + SwHistory* GetHistory() { return m_pHistory.get(); } + void SaveFormula( SwHistory& rHistory ); +}; + +class SwUndoMergeTable final : public SwUndo +{ + OUString m_aName; + SwNodeOffset m_nTableNode; + std::unique_ptr m_pSaveTable, m_pSaveHdl; + std::unique_ptr m_pHistory; + bool m_bWithPrev; + +public: + SwUndoMergeTable( const SwTableNode& rTableNd, const SwTableNode& rDelTableNd, + bool bWithPrev ); + + virtual ~SwUndoMergeTable() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; + + void SaveFormula( SwHistory& rHistory ); +}; + +class SwUndoTableHeadline final : public SwUndo +{ + SwNodeOffset m_nTableNode; + sal_uInt16 m_nOldHeadline; + sal_uInt16 m_nNewHeadline; + +public: + SwUndoTableHeadline( const SwTable&, sal_uInt16 nOldHdl, sal_uInt16 nNewHdl ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + virtual void RepeatImpl( ::sw::RepeatContext & ) override; +}; + +void InsertSort( std::vector& rArr, sal_uInt16 nIdx ); + +class SwUndoTableStyleMake final : public SwUndo +{ + OUString m_sName; + std::unique_ptr m_pAutoFormat; +public: + SwUndoTableStyleMake(OUString aName, const SwDoc& rDoc); + + virtual ~SwUndoTableStyleMake() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + virtual SwRewriter GetRewriter() const override; +}; + +class SwUndoTableStyleDelete final : public SwUndo +{ + std::unique_ptr m_pAutoFormat; + std::vector m_rAffectedTables; +public: + SwUndoTableStyleDelete(std::unique_ptr pAutoFormat, std::vector&& rAffectedTables, const SwDoc& rDoc); + + virtual ~SwUndoTableStyleDelete() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + virtual SwRewriter GetRewriter() const override; +}; + +class SwUndoTableStyleUpdate final : public SwUndo +{ + std::unique_ptr m_pOldFormat, m_pNewFormat; +public: + SwUndoTableStyleUpdate(const SwTableAutoFormat& rNewFormat, const SwTableAutoFormat& rOldFormat, const SwDoc& rDoc); + + virtual ~SwUndoTableStyleUpdate() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + virtual SwRewriter GetRewriter() const override; +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOTABLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/UndoThemeChange.hxx b/sw/source/core/inc/UndoThemeChange.hxx new file mode 100644 index 0000000000..5ce4900801 --- /dev/null +++ b/sw/source/core/inc/UndoThemeChange.hxx @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include +#include +#include + +namespace sw +{ +class UndoThemeChange final : public SwUndo +{ +private: + SwDoc& mrDocument; + std::shared_ptr mpOldColorSet; + std::shared_ptr mpNewColorSet; + +public: + UndoThemeChange(SwDoc& rDocument, std::shared_ptr const& pOld, + std::shared_ptr const& pNew); + virtual ~UndoThemeChange() override; + + virtual void UndoImpl(UndoRedoContext& rUndoRedoContext) override; + virtual void RedoImpl(UndoRedoContext& rUndoRedoContext) override; +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/acorrect.hxx b/sw/source/core/inc/acorrect.hxx new file mode 100644 index 0000000000..0b9fce1787 --- /dev/null +++ b/sw/source/core/inc/acorrect.hxx @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_ACORRECT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_ACORRECT_HXX + +#include + +#include +#include +#include +#include +#include + +class SwEditShell; +class SwPaM; +struct SwPosition; +class SfxItemSet; + +class SwDontExpandItem +{ + std::unique_ptr m_pDontExpandItems; + +public: + SwDontExpandItem() {} + ~SwDontExpandItem(); + + void SaveDontExpandItems( const SwPosition& rPos ); + void RestoreDontExpandItems( const SwPosition& rPos ); + +}; + +class SwAutoCorrDoc final : public SvxAutoCorrDoc +{ + SwEditShell& m_rEditSh; + SwPaM& m_rCursor; + std::optional m_oIndex; + int m_nEndUndoCounter; + bool m_bUndoIdInitialized; + + void DeleteSel( SwPaM& rDelPam ); + void DeleteSelImpl(SwPaM & rDelPam); + +public: + SwAutoCorrDoc( SwEditShell& rEditShell, SwPaM& rPam, sal_Unicode cIns = 0 ); + virtual ~SwAutoCorrDoc() override; + + virtual bool Delete( sal_Int32 nStt, sal_Int32 nEnd ) override; + virtual bool Insert( sal_Int32 nPos, const OUString& rText ) override; + virtual bool Replace( sal_Int32 nPos, const OUString& rText ) override; + virtual bool ReplaceRange( sal_Int32 nPos, sal_Int32 nLen, const OUString& rText ) override; + + virtual void SetAttr( sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId, + SfxPoolItem& ) override; + + virtual bool SetINetAttr( sal_Int32 nStt, sal_Int32 nEnd, const OUString& rURL ) override; + + // return text of a previous paragraph + // If it does not exist or if there is nothing before, return blank. + // - true: paragraph before "normal" insertion position + // - false: paragraph in that the corrected word was inserted + // (does not need to be the same paragraph) + virtual OUString const* GetPrevPara(bool bAtNormalPos) override; + + virtual bool ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, + SvxAutoCorrect& rACorrect, + OUString* pPara ) override; + virtual bool TransliterateRTLWord( sal_Int32& rSttPos, sal_Int32 nEndPos, + bool bApply = false ) override; + + // Will be called after swapping characters by the functions + // - FnCapitalStartWord and + // - FnCapitalStartSentence. + // Afterwards the words can be added into exception list if needed. + virtual void SaveCpltSttWord( ACFlags nFlag, sal_Int32 nPos, + const OUString& rExceptWord, sal_Unicode cChar ) override; + virtual LanguageType GetLanguage( sal_Int32 nPos ) const override; +}; + +class SwAutoCorrExceptWord +{ + OUString m_sWord; + SwNodeOffset m_nNode; + ACFlags m_nFlags; + sal_Int32 m_nContent; + sal_Unicode m_cChar; + LanguageType m_eLanguage; + bool m_bDeleted; + +public: + SwAutoCorrExceptWord(ACFlags nAFlags, SwNodeOffset nNd, sal_Int32 nContent, + OUString aWord, sal_Unicode cChr, + LanguageType eLang) + : m_sWord(std::move(aWord)), m_nNode(nNd), m_nFlags(nAFlags), m_nContent(nContent), + m_cChar(cChr), m_eLanguage(eLang), m_bDeleted(false) + {} + + bool IsDeleted() const { return m_bDeleted; } + void CheckChar(const SwPosition& rPos, sal_Unicode cChar); + bool CheckDelChar(const SwPosition& rPos); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/anchoredobjectposition.hxx b/sw/source/core/inc/anchoredobjectposition.hxx new file mode 100644 index 0000000000..a366833000 --- /dev/null +++ b/sw/source/core/inc/anchoredobjectposition.hxx @@ -0,0 +1,447 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_ANCHOREDOBJECTPOSITION_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_ANCHOREDOBJECTPOSITION_HXX + +#include +#include "frame.hxx" +#include + +class SdrObject; +class SwFlyFrame; +class SwContact; +class SwFrameFormat; +class SwRect; +class SvxLRSpaceItem; +class SvxULSpaceItem; +class SwFormatHoriOrient; +class SwAnchoredObject; + +namespace objectpositioning +{ + class SwEnvironmentOfAnchoredObject; + + class SwAnchoredObjectPosition + { + private: + // object to be positioned + SdrObject& mrDrawObj; + // #i26791# - anchored object the object belongs to; + SwAnchoredObject* mpAnchoredObj; + // frame the object is anchored at + SwFrame* mpAnchorFrame; + // contact object + SwContact* mpContact; + // frame format + const SwFrameFormat* mpFrameFormat; + // does the object represents a Writer fly frame + bool mbIsObjFly; + // #i62875# + bool mbFollowTextFlow; + // #i62875# + // for compatibility option + bool mbDoNotCaptureAnchoredObj; + + /** determine information about object + + member , , , + and are set + */ + void GetInfoAboutObj(); + + // #i62875# + // --> OD 2009-09-01 #mongolianlayout# - add parameter + SwTwips ImplAdjustVertRelPos( const SwTwips nTopOfAnch, + const bool bVert, + const bool bVertL2R, + const SwFrame& rPageAlignLayFrame, + const SwTwips nProposedRelPosY, + const bool bFollowTextFlow, + const bool bCheckBottom ) const; + SwTwips ImplAdjustHoriRelPos( const SwFrame& _rPageAlignLayFrame, + const SwTwips _nProposedRelPosX ) const; + + protected: + SwAnchoredObjectPosition( SdrObject& _rDrawObj ); + virtual ~SwAnchoredObjectPosition(); + + // accessors for object and its corresponding data/information + SdrObject& GetObject() const + { + return mrDrawObj; + } + bool IsObjFly() const + { + return mbIsObjFly; + } + SwAnchoredObject& GetAnchoredObj() const + { + return *mpAnchoredObj; + } + SwFrame& GetAnchorFrame() const + { + return *mpAnchorFrame; + } + const SwFrameFormat& GetFrameFormat() const + { + return *mpFrameFormat; + } + // #i62875# + bool DoesObjFollowsTextFlow() const + { + return mbFollowTextFlow; + } + + // virtual methods providing data for to character anchored objects. + virtual bool IsAnchoredToChar() const; + virtual const SwFrame* ToCharOrientFrame() const; + virtual const SwRect* ToCharRect() const; + // #i22341# + virtual SwTwips ToCharTopOfLine() const; + + /** helper method to determine top of a frame for the vertical object + positioning + + #i11860# + */ + SwTwips GetTopForObjPos( const SwFrame& _rFrame, + const SwRectFn& _fnRect, + const bool _bVert ) const; + + void GetVertAlignmentValues( const SwFrame& _rVertOrientFrame, + const SwFrame& _rPageAlignLayFrame, + const sal_Int16 _eRelOrient, + SwTwips& _orAlignAreaHeight, + SwTwips& _orAlignAreaOffset ) const; + + // #i26791# - add output parameter <_roVertOffsetToFrameAnchorPos> + SwTwips GetVertRelPos( const SwFrame& _rVertOrientFrame, + const SwFrame& _rPageAlignLayFrame, + const sal_Int16 _eVertOrient, + const sal_Int16 _eRelOrient, + const SwTwips _nVertPos, + const SvxLRSpaceItem& _rLRSpacing, + const SvxULSpaceItem& _rULSpacing, + SwTwips& _roVertOffsetToFrameAnchorPos ) const; + + /** adjust calculated vertical in order to keep object inside + 'page' alignment layout frame. + + #i31805# - add parameter <_bCheckBottom> + #i26945# - add parameter <_bFollowTextFlow> + #i62875# - made inline, intrinsic actions moved + to private method , which is only + called, if not set. + OD 2009-09-01 #mongolianlayout# - add parameter + + @param nTopOfAnch + input parameter - 'vertical' position, at which the relative + position of the object is calculated from. + + @param bVert + input parameter - boolean, indicating, if object is in vertical + layout. + + @param bVertL2R + input parameter - boolean, indicating, if object is in mongolian + layout (vertical left-to-right layout). + + @param rPageAlignLayFrame + input parameter - layout frame, which determines the 'page area' + the object has to be vertical positioned in. + + @param nProposedRelPosY + input parameter - proposed relative vertical position, which + will be adjusted. + + @param bFollowTextFlow + input parameter - value of attribute 'Follow text flow' of the + anchored object. + + @param bCheckBottom + input parameter - boolean indicating, if bottom of anchored + object has to be checked and thus, (if needed) the proposed + relative position has to be adjusted. default value + */ + SwTwips AdjustVertRelPos( const SwTwips nTopOfAnch, + const bool bVert, + const bool bVertL2R, + const SwFrame& rPageAlignLayFrame, + const SwTwips nProposedRelPosY, + const bool bFollowTextFlow, + const bool bCheckBottom = true ) const + { + return !mbDoNotCaptureAnchoredObj + ? ImplAdjustVertRelPos( nTopOfAnch, bVert, bVertL2R, + rPageAlignLayFrame, + nProposedRelPosY, + bFollowTextFlow, + bCheckBottom ) + : nProposedRelPosY; + } + + /** calculate relative horizontal position + + #i26791# - add output parameter + <_roHoriOffsetToFrameAnchorPos> + + @param _rHoriOrientFrame + input parameter - frame the horizontal position of the object + is oriented at. + + @param _rEnvOfObj + input parameter - object instance to retrieve environment + information about the object + + @param _rHoriOrient + input parameter - horizontal positioning and alignment, for which + the relative position is calculated. + + @param _rLRSpacing + input parameter - left and right spacing of the object to the text + + @param _rULSpacing + input parameter - upper and lower spacing of the object to the text + + @param _bObjWrapThrough + input parameter - boolean indicating, if object has wrap mode + 'wrap through'. + + @param _nRelPosY + input parameter - relative vertical position + + @param _roHoriOffsetToFrameAnchorPos + output parameter - 'horizontal' offset to frame anchor position + according to the alignment + + @return relative horizontal position in SwTwips + */ + SwTwips CalcRelPosX( const SwFrame& _rHoriOrientFrame, + const SwEnvironmentOfAnchoredObject& _rEnvOfObj, + const SwFormatHoriOrient& _rHoriOrient, + const SvxLRSpaceItem& _rLRSpacing, + const SvxULSpaceItem& _rULSpacing, + const bool _bObjWrapThrough, + const SwTwips _nRelPosY, + SwTwips& _roHoriOffsetToFrameAnchorPos + ) const; + + /** adjust calculated horizontal in order to keep object inside + 'page' alignment layout frame for object type position TO_CNTNT + + #i62875# - made inline, intrinsic actions moved + to private method , which is only + called, if not set. + + @param _rPageAlignLayFrame + input parameter - layout frame, which determines the 'page area' + the object has to be horizontal positioned in. + + @param _nProposedRelPosX + input parameter - proposed relative horizontal position, which + will be adjusted. + + @return adjusted relative horizontal position in SwTwips. + */ + SwTwips AdjustHoriRelPos( const SwFrame& _rPageAlignLayFrame, + const SwTwips _nProposedRelPosX ) const + { + return !mbDoNotCaptureAnchoredObj + ? ImplAdjustHoriRelPos( _rPageAlignLayFrame, _nProposedRelPosX ) + : _nProposedRelPosX; + } + + /** toggle given horizontal orientation and relative alignment + + @param _bToggleLeftRight + input parameter - boolean indicating, if horizontal orientation + and relative alignment has to be toggled. + + @param _ioeHoriOrient + input/output parameter - horizontal orientation, that is toggled, + if needed. + + @param _iopeRelOrient + optional input/output parameter (default value NULL) + - if set, relative alignment, that is toggled, if needed. + */ + static void ToggleHoriOrientAndAlign( const bool _bToggleLeftRight, + sal_Int16& _ioeHoriOrient, + sal_Int16& _iopeRelOrient + ); + + /** determine alignment values for horizontal position of object + + @param _rHoriOrientFrame + input parameter - frame the horizontal position of the object + is oriented at. + + @param _rPageAlignLayFrame + input parameter - layout frame, which determines the 'page area' + the object has to be horizontal positioned in. + + @param _eRelOrient + input parameter - horizontal relative alignment, for which + the relative position is calculated. + + @param _bToggleLeftRight + input parameter - boolean indicating, if left/right alignments + have to be toggled. + + @param _bObjWrapThrough + input parameter - boolean indicating, if object has wrap mode + 'wrap through'. + important note: value is only relevant, if _rHoriOrientFrame is + a text frame. + + @param _orAlignAreaWidth + output parameter - width in SwTwips of the area the horizontal + position is aligned to. + + @param _orAlignAreaOffset + output parameter - offset in SwTwips of the area the horizontal + position is aligned to. offset is given to the 'left' of the + anchor position. + + @param _obAlignedRelToPage + output parameter - boolean indicating, that object is aligned + to 'page area'. + */ + void GetHoriAlignmentValues( const SwFrame& _rHoriOrientFrame, + const SwFrame& _rPageAlignLayFrame, + const sal_Int16 _eRelOrient, + const bool _bObjWrapThrough, + SwTwips& _orAlignAreaWidth, + SwTwips& _orAlignAreaOffset, + bool& _obAlignedRelToPage ) const; + + /** adjust calculated horizontal position in order to draw object + aside other objects with same positioning + + @param _rHoriOrientFrame + input parameter - frame the horizontal position of the object + is oriented at. + + @param _nProposedRelPosX + input parameter - proposed relative horizontal position, which + will be adjusted. + + @param _nRelPosY + input parameter - relative vertical position + + @param _eHoriOrient + input parameter - horizontal position of object + + @param _eRelOrient + input parameter - alignment of object + + @param _rLRSpacing + input parameter - left and right spacing of the object to the text + + @param _rULSpacing + input parameter - upper and lower spacing of the object to the text + + @param _bEvenPage + input parameter - boolean indicating, if object is on an even page. + + @return adjusted relative horizontal position in SwTwips + */ + SwTwips AdjustHoriRelPosForDrawAside( const SwFrame& _rHoriOrientFrame, + const SwTwips _nProposedRelPosX, + const SwTwips _nRelPosY, + const sal_Int16 _eHoriOrient, + const sal_Int16 _eRelOrient, + const SvxLRSpaceItem& _rLRSpacing, + const SvxULSpaceItem& _rULSpacing, + const bool _bEvenPage + ) const; + + /** determine, if object has to draw aside given fly frame + + method used by + + @param _pFly + input parameter - fly frame the draw aside check is done for. + + @param _rObjRect + input parameter - proposed object rectangle + + @param _pObjContext + input parameter - context of the object + + @param _nObjIndex + input parameter - index of the anchor frame of the object + + @param _bEvenPage + input parameter - boolean indicating, if object is on an even page. + + @param _eHoriOrient + input parameter - horizontal position of object + + @param _eRelOrient + input parameter - alignment of object + + @return boolean indicating, if object has to be drawn aside + given fly frame. + */ + bool DrawAsideFly( const SwFlyFrame* _pFly, + const SwRect& _rObjRect, + const SwFrame* _pObjContext, + const SwNodeOffset _nObjIndex, + const bool _bEvenPage, + const sal_Int16 _eHoriOrient, + const sal_Int16 _eRelOrient + ) const; + + /** determine, if object has to draw aside another object + + the different alignments of the objects determines, if one has + to draw aside another one. Thus, the given alignment are checked + against each other, which one has to be drawn aside the other one. + depending on parameter _bLeft check is done for left or right + positioning. + method used by + + @param _eRelOrient1 + input parameter - alignment 1 + + @param _eRelOrient2 + input parameter - alignment 2 + + @param _bLeft + input parameter - boolean indicating, if check is done for left + or for right positioning. + + @return boolean indicating, if an object with an alignment + <_eRelOrient1> has to be drawn aside an object with an + alignment <_eRelOrient2> + */ + static bool Minor_( sal_Int16 _eRelOrient1, + sal_Int16 _eRelOrient2, + bool _bLeft ); + + public: + virtual void CalcPosition() = 0; + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/annotationmark.hxx b/sw/source/core/inc/annotationmark.hxx new file mode 100644 index 0000000000..c4c2bc1288 --- /dev/null +++ b/sw/source/core/inc/annotationmark.hxx @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_ANNOTATIONMARK_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_ANNOTATIONMARK_HXX + +#include "bookmark.hxx" +#include + +class SwFormatField; + +namespace sw::mark +{ + class AnnotationMark final : public MarkBase + { + public: + AnnotationMark( + const SwPaM& rPaM, + const OUString& rName ); + + virtual ~AnnotationMark() override; + + virtual void InitDoc(SwDoc& io_Doc, sw::mark::InsertMode eMode, SwPosition const* pSepPos) override; + + const SwFormatField* GetAnnotationFormatField() const; + }; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/ascharanchoredobjectposition.hxx b/sw/source/core/inc/ascharanchoredobjectposition.hxx new file mode 100644 index 0000000000..34f42e3643 --- /dev/null +++ b/sw/source/core/inc/ascharanchoredobjectposition.hxx @@ -0,0 +1,160 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_ASCHARANCHOREDOBJECTPOSITION_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_ASCHARANCHOREDOBJECTPOSITION_HXX + +#include "anchoredobjectposition.hxx" +#include +#include +#include + +class SwTextFrame; +class SwFormatVertOrient; + +// flags for positioning algorithm of as-character-anchored objects +enum class AsCharFlags { + None = 0x00, + Quick = 0x01, + UlSpace = 0x02, + Init = 0x04, + Rotate = 0x08, + Reverse = 0x10, + Bidi = 0x20, +}; +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +}; + +namespace sw +{ + // TODO: merge/migrate this to com::sun::star::VertOrientation instead of duplicating? + enum class LineAlign + { + NONE, + TOP, + CENTER, + BOTTOM + }; +}; +namespace objectpositioning +{ + class SwAsCharAnchoredObjectPosition final : public SwAnchoredObjectPosition + { + private: + // data to calculate object position + // Proposed anchor position, starting point for the calculation + // of the object position. + const Point& mrProposedAnchorPos; + // flags that influences the calculation of the anchor position + // AsCharFlags::Quick : quick formatting - calculated position not set at object + // AsCharFlags::UlSpace : consider upper/lower spacing - adjustment of anchor position + // AsCharFlags::Init : initial calculation + // AsCharFlags::Rotate : object is rotated by 90 degrees + // AsCharFlags::Reverse : object is reversed (rotated by 270 degrees) + // AsCharFlags::Bidi : object belongs to a BIDI-multi-portion + const AsCharFlags mnFlags; + // needed line values for the different alignments. + const SwTwips mnLineAscent; + const SwTwips mnLineDescent; + const SwTwips mnLineAscentInclObjs; + const SwTwips mnLineDescentInclObjs; + + // calculated data for object position + Point maAnchorPos; + SwTwips mnRelPos; + SwRect maObjBoundRect; + // line alignment relative to line height + sw::LineAlign mnLineAlignment; + + // method to cast + const SwTextFrame& GetAnchorTextFrame() const; + + /** determine the relative position to base line for object position + + @param _ObjBoundHeight + height including corresponding spacing of the object, for which + the Y-position has to be calculated. + + @param _rVert + given vertical positioning and alignment + + @return relative position to the base line + */ + SwTwips GetRelPosToBase( const SwTwips _nObjBoundHeight, + const SwFormatVertOrient& _rVert ); + + public: + /** constructor; provided object to be positioned and needed data + for calculation of the object position + + @param _rDrawObj + input parameter - object, that is be positioned. + + @param _rProposedAnchorPos + proposed anchor position; starting point for the calculation + of the anchor position + + @param _nFlags + flags that influences the calculation of the anchor position + AsCharFlags::Quick : quick formatting - calculated position not set at object + AsCharFlags::UlSpace : consider upper/lower spacing - adjustment of anchor position + AsCharFlags::Init : initial calculation + AsCharFlags::Rotate : object is rotated by 90 degrees + AsCharFlags::Reverse : object is reversed (rotated by 270 degrees) + AsCharFlags::Bidi : object belongs to a BIDI-multi-portion + + @param _nLineAscent, _nLineDescent, _nLineAscentInclObjs, + _nLineDescentInclObjs - needed line values for the different + alignments. + */ + SwAsCharAnchoredObjectPosition( SdrObject& _rDrawObj, + const Point& _rProposedAnchorPos, + const AsCharFlags _nFlags, + const SwTwips _nLineAscent, + const SwTwips _nLineDescent, + const SwTwips _nLineAscentInclObjs, + const SwTwips _nLineDescentInclObjs ); + virtual ~SwAsCharAnchoredObjectPosition() override; + + /** calculate position for object position + + members , , and + are calculated. + calculated position is set at the given object. + */ + virtual void CalcPosition() override; + + // calculated anchored position for object position type AS_CHAR + const Point& GetAnchorPos() const { return maAnchorPos;} + + // calculated relative position to base line for object position type AS_CHAR + SwTwips GetRelPosY() const { return mnRelPos;} + + // determined object rectangle including spacing for object position type AS_CHAR + const SwRect& GetObjBoundRectInclSpacing() const { return maObjBoundRect;} + + // determined line alignment relative to line height + sw::LineAlign GetLineAlignment() const { return mnLineAlignment;} + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/attrhint.hxx b/sw/source/core/inc/attrhint.hxx new file mode 100644 index 0000000000..e098b26952 --- /dev/null +++ b/sw/source/core/inc/attrhint.hxx @@ -0,0 +1,31 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_ATTRHINT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_ATTRHINT_HXX + +#include + +class SwAttrHint final : public SfxHint +{ +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/bodyfrm.hxx b/sw/source/core/inc/bodyfrm.hxx new file mode 100644 index 0000000000..fe7418177c --- /dev/null +++ b/sw/source/core/inc/bodyfrm.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_BODYFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_BODYFRM_HXX + +#include "layfrm.hxx" + +class SwBorderAttrs; + +/// Container of body content (i.e. not header or footer). Typical parent is an +/// SwPageFrame, typical lower is an SwTextFrame. +class SAL_DLLPUBLIC_RTTI SwBodyFrame final : public SwLayoutFrame +{ + virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override; + +public: + SwBodyFrame( SwFrameFormat*, SwFrame* ); + + virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override; + + void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/bookmark.hxx b/sw/source/core/inc/bookmark.hxx new file mode 100644 index 0000000000..8a3fc98f26 --- /dev/null +++ b/sw/source/core/inc/bookmark.hxx @@ -0,0 +1,367 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include "FormFieldButton.hxx" + +class SwDoc; +class SwEditWin; +class SwServerObject; +class SvNumberFormatter; +class SfxViewShell; +class SwXBookmark; + +namespace sw::mark { + class MarkBase + : virtual public IMark + { + public: + //getters + SwPosition& GetMarkPos() const override + { return const_cast(*m_oPos1); } + const OUString& GetName() const override + { return m_aName; } + SwPosition& GetOtherMarkPos() const override + { + OSL_PRECOND(IsExpanded(), " - I have no other Pos set." ); + return const_cast(*m_oPos2); + } + SwPosition& GetMarkStart() const override + { + if( !IsExpanded() ) return GetMarkPos( ); + if ( GetMarkPos( ) < GetOtherMarkPos( ) ) + return GetMarkPos(); + else + return GetOtherMarkPos( ); + } + SwPosition& GetMarkEnd() const override + { + if( !IsExpanded() ) return GetMarkPos(); + if ( GetMarkPos( ) >= GetOtherMarkPos( ) ) + return GetMarkPos( ); + else + return GetOtherMarkPos( ); + } + + bool IsCoveringPosition(const SwPosition& rPos) const override; + bool IsExpanded() const override + { return m_oPos2.has_value(); } + + void SetName(const OUString& rName) + { m_aName = rName; } + virtual void SetMarkPos(const SwPosition& rNewPos); + virtual void SetOtherMarkPos(const SwPosition& rNewPos); + virtual void ClearOtherMarkPos() + { m_oPos2.reset(); } + + virtual auto InvalidateFrames() -> void; + + OUString ToString( ) const override; + void dumpAsXml(xmlTextWriterPtr pWriter) const override; + + void Swap() + { + if(m_oPos2) + m_oPos1.swap(m_oPos2); + } + + virtual void InitDoc(SwDoc&, sw::mark::InsertMode, SwPosition const*) + { + } + + ~MarkBase() override; + + const unotools::WeakReference & GetXBookmark() const + { return m_wXBookmark; } + void SetXBookmark(rtl::Reference const& xBkmk); + + static OUString GenerateNewName(std::u16string_view rPrefix); + protected: + // SwClient + void SwClientNotify(const SwModify&, const SfxHint&) override; + + MarkBase(const SwPaM& rPaM, OUString aName); + std::optional m_oPos1; + std::optional m_oPos2; + OUString m_aName; + + unotools::WeakReference m_wXBookmark; + }; + + class NavigatorReminder final + : public MarkBase + { + public: + NavigatorReminder(const SwPaM& rPaM); + }; + + class UnoMark final + : public MarkBase + { + public: + UnoMark(const SwPaM& rPaM); + }; + + class DdeBookmark + : public MarkBase + { + public: + DdeBookmark(const SwPaM& rPaM); + + const SwServerObject* GetRefObject() const { return m_aRefObj.get(); } + SwServerObject* GetRefObject() { return m_aRefObj.get(); } + + bool IsServer() const { return m_aRefObj.is(); } + + void SetRefObject( SwServerObject* pObj ); + + virtual void DeregisterFromDoc(SwDoc& rDoc); + ~DdeBookmark() override; + + private: + tools::SvRef m_aRefObj; + }; + + class Bookmark + : virtual public IBookmark + , public DdeBookmark + , public ::sfx2::Metadatable + { + public: + Bookmark(const SwPaM& rPaM, + const vcl::KeyCode& rCode, + const OUString& rName); + void InitDoc(SwDoc& io_Doc, sw::mark::InsertMode eMode, SwPosition const* pSepPos) override; + + void DeregisterFromDoc(SwDoc& io_rDoc) override; + + auto InvalidateFrames() -> void override; + + const OUString& GetShortName() const override + { return m_sShortName; } + const vcl::KeyCode& GetKeyCode() const override + { return m_aCode; } + void SetShortName(const OUString& rShortName) override + { m_sShortName = rShortName; } + void SetKeyCode(const vcl::KeyCode& rCode) override + { m_aCode = rCode; } + bool IsHidden() const override + { return m_bHidden; } + const OUString& GetHideCondition() const override + { return m_sHideCondition; } + void Hide(bool rHide) override; + void SetHideCondition(const OUString& rHideCondition) override; + + // ::sfx2::Metadatable + ::sfx2::IXmlIdRegistry& GetRegistry() override; + bool IsInClipboard() const override; + bool IsInUndo() const override; + bool IsInContent() const override; + void sendLOKDeleteCallback(); + css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() override; + + private: + vcl::KeyCode m_aCode; + OUString m_sShortName; + bool m_bHidden; + OUString m_sHideCondition; + }; + + class Fieldmark + : virtual public IFieldmark + , public MarkBase + { + public: + Fieldmark(const SwPaM& rPaM); + + OUString GetFieldname() const override + { return m_aFieldname; } + OUString GetFieldHelptext() const override + { return m_aFieldHelptext; } + + IFieldmark::parameter_map_t* GetParameters() override + { return &m_vParams; } + + const IFieldmark::parameter_map_t* GetParameters() const override + { return &m_vParams; } + + void SetFieldname(const OUString& aFieldname) override + { m_aFieldname = aFieldname; } + void SetFieldHelptext(const OUString& aFieldHelptext) override + { m_aFieldHelptext = aFieldHelptext; } + + virtual void ReleaseDoc(SwDoc&) = 0; + + void SetMarkStartPos( const SwPosition& rNewStartPos ); + + void Invalidate() override; + OUString ToString() const override; + void dumpAsXml(xmlTextWriterPtr pWriter) const override; + + private: + OUString m_aFieldname; + OUString m_aFieldHelptext; + IFieldmark::parameter_map_t m_vParams; + }; + + class TextFieldmark final + : public Fieldmark + { + public: + TextFieldmark(const SwPaM& rPaM, const OUString& rName); + ~TextFieldmark(); + void InitDoc(SwDoc& io_rDoc, sw::mark::InsertMode eMode, SwPosition const* pSepPos) override; + void ReleaseDoc(SwDoc& rDoc) override; + + OUString GetContent() const override; + void ReplaceContent(const OUString& sNewContent) override; + + private: + sw::DocumentContentOperationsManager* m_pDocumentContentOperationsManager; + }; + + // Non text fieldmarks have no content between the start and end marks. + class NonTextFieldmark + : public Fieldmark + { + public: + NonTextFieldmark(const SwPaM& rPaM); + void InitDoc(SwDoc& io_rDoc, sw::mark::InsertMode eMode, SwPosition const* pSepPos) override; + void ReleaseDoc(SwDoc& rDoc) override; + }; + + /// Fieldmark representing a checkbox form field. + class CheckboxFieldmark final + : virtual public ICheckboxFieldmark + , public NonTextFieldmark + { + public: + CheckboxFieldmark(const SwPaM& rPaM, const OUString& rName); + bool IsChecked() const override; + void SetChecked(bool checked) override; + OUString GetContent() const override; + void ReplaceContent(const OUString& sNewContent) override; + }; + + /// Fieldmark with a drop down button (e.g. this button opens the date picker for a date field) + class FieldmarkWithDropDownButton + : public NonTextFieldmark + { + public: + FieldmarkWithDropDownButton(const SwPaM& rPaM); + ~FieldmarkWithDropDownButton() override; + + virtual void ShowButton(SwEditWin* pEditWin) = 0; + virtual void RemoveButton(); + void LaunchPopup(); + + protected: + VclPtr m_pButton; + }; + + /// Fieldmark representing a drop-down form field. + class DropDownFieldmark final + : virtual public IDropdownFieldmark + , public FieldmarkWithDropDownButton + { + public: + DropDownFieldmark(const SwPaM& rPaM, const OUString& rName); + ~DropDownFieldmark() override; + + void ShowButton(SwEditWin* pEditWin) override; + void RemoveButton() override; + OUString GetContent(sal_Int32* pIndex) const override; + OUString GetContent() const override; + void AddContent(const OUString& rText, sal_Int32* pIndex = nullptr) override; + void DelContent(sal_Int32 nDelIndex = -1) override; + void ReplaceContent(const OUString* pText, sal_Int32* pIndex) override; + void ReplaceContent(const OUString& sNewContent) override; + + // This method should be called only by the portion so we can now the portion's painting area + void SetPortionPaintArea(const SwRect& rPortionPaintArea); + + void SendLOKShowMessage(const SfxViewShell* pViewShell); + static void SendLOKHideMessage(const SfxViewShell* pViewShell); + + private: + SwRect m_aPortionPaintArea; + }; + + /// Fieldmark representing a date form field. + /// TODO: this was an SDT in DOCX, which is modelled suboptimally here + /// as a fieldmark; as it cannot contain paragraph breaks, must be + /// well-formed XML element, and does not have field separator, it + /// should be a nesting text attribute similar to SwTextMeta. + class DateFieldmark final + : virtual public IDateFieldmark + , public FieldmarkWithDropDownButton + { + public: + DateFieldmark(const SwPaM& rPaM); + ~DateFieldmark() override; + + void InitDoc(SwDoc& io_rDoc, sw::mark::InsertMode eMode, SwPosition const* pSepPos) override; + void ReleaseDoc(SwDoc& rDoc) override; + + void ShowButton(SwEditWin* pEditWin) override; + + void SetPortionPaintAreaStart(const SwRect& rPortionPaintArea); + void SetPortionPaintAreaEnd(const SwRect& rPortionPaintArea); + + OUString GetContent() const override; + void ReplaceContent(const OUString& sNewContent) override; + + std::pair GetCurrentDate() const override; + void SetCurrentDate(double fDate) override; + OUString GetDateInStandardDateFormat(double fDate) const override; + + private: + OUString GetDateInCurrentDateFormat(double fDate) const; + std::pair ParseCurrentDateParam() const; + void InvalidateCurrentDateParam(); + + SvNumberFormatter* m_pNumberFormatter; + sw::DocumentContentOperationsManager* m_pDocumentContentOperationsManager; + SwRect m_aPaintAreaStart; + SwRect m_aPaintAreaEnd; + }; + + /// return position of the CH_TXT_ATR_FIELDSEP for rMark + SwPosition FindFieldSep(IFieldmark const& rMark); + + /// check if rPaM is valid range of new fieldmark + bool IsFieldmarkOverlap(SwPaM const& rPaM); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/cellfrm.hxx b/sw/source/core/inc/cellfrm.hxx new file mode 100644 index 0000000000..796cb1d3df --- /dev/null +++ b/sw/source/core/inc/cellfrm.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_CELLFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_CELLFRM_HXX + +#include "layfrm.hxx" + +class SwTableBox; +struct SwCursorMoveState; +class SwBorderAttrs; + +/// SwCellFrame is one table cell in the document layout. +class SW_DLLPUBLIC SwCellFrame final : public SwLayoutFrame +{ + const SwTableBox* m_pTabBox; + + virtual void DestroyImpl() override; + virtual ~SwCellFrame() override; + + virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override; + virtual void SwClientNotify(const SwModify&, const SfxHint&) override; + virtual const SwCellFrame* DynCastCellFrame() const override { return this; } + +public: + SwCellFrame( const SwTableBox &, SwFrame*, bool bInsertContent ); + + virtual bool GetModelPositionForViewPoint( SwPosition *, Point&, SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override; + virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&, + SwPrintData const*const pPrintData = nullptr ) const override; + virtual void CheckDirection( bool bVert ) override; + + // #i103961# + virtual void Cut() override; + + const SwTableBox *GetTabBox() const { return m_pTabBox; } + + // used for breaking table rows: + SwCellFrame* GetFollowCell() const; + SwCellFrame* GetPreviousCell() const; + + virtual bool IsLeaveUpperAllowed() const override; + virtual bool IsCoveredCell() const override; + + // used for rowspan stuff: + const SwCellFrame& FindStartEndOfRowSpanCell( bool bStart ) const; + tools::Long GetLayoutRowSpan() const; + + /// If this is a vertically merged cell, then looks up its covered cell in rRow. + const SwCellFrame* GetCoveredCellInRow(const SwRowFrame& rRow) const; + + /// If this is a vertically merged cell, then looks up its covered cells. + std::vector GetCoveredCells() const; + + void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override; + + void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/cntfrm.hxx b/sw/source/core/inc/cntfrm.hxx new file mode 100644 index 0000000000..2f6c8b5ba3 --- /dev/null +++ b/sw/source/core/inc/cntfrm.hxx @@ -0,0 +1,147 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_CNTFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_CNTFRM_HXX + +#include +#include "frame.hxx" +#include "flowfrm.hxx" +#include + +class SwLayoutFrame; +class SwContentNode; +class SwBorderAttrs; +class SwAttrSetChg; +class SwTextFrame; + +// implemented in cntfrm.cxx, used in cntfrm.cxx and crsrsh.cxx +extern bool GetFrameInPage( const SwContentFrame*, SwWhichPage, SwPosPage, SwPaM* ); + +enum class SwContentFrameInvFlags : sal_uInt8 +{ + NONE = 0x00, + SetCompletePaint = 0x01, + InvalidatePos = 0x02, + InvalidateSize = 0x04, + InvalidateSectPrt = 0x08, + InvalidateNextPrt = 0x10, + InvalidatePrevPrt = 0x20, + InvalidateNextPos = 0x40, + SetNextCompletePaint = 0x80, +}; + +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +} + +/** + * SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and + * non-text (e.g. graphic) frames. + */ +class SW_DLLPUBLIC SwContentFrame: public SwFrame, public SwFlowFrame +{ + friend void MakeNxt( SwFrame *pFrame, SwFrame *pNxt ); // calls MakePrtArea + + // parameter indicates that objects exist in remaining + // area of new upper + bool WouldFit_( SwTwips nSpace, + SwLayoutFrame *pNewUpper, + bool bTstMove, + const bool bObjsInNewUpper ); + + virtual void MakeAll(vcl::RenderContext* pRenderContext) override; + + void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, SwContentFrameInvFlags &, + SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr ); + + virtual bool ShouldBwdMoved( SwLayoutFrame *pNewUpper, bool& ) override; + + const SwContentFrame* ImplGetNextContentFrame( bool bFwd ) const; + +protected: + void MakePrtArea( const SwBorderAttrs & ); + + virtual void SwClientNotify(const SwModify&, const SfxHint&) override; + virtual SwTwips ShrinkFrame( SwTwips, bool bTst = false, bool bInfo = false ) override; + virtual SwTwips GrowFrame ( SwTwips, bool bTst = false, bool bInfo = false ) override; + + SwContentFrame( SwContentNode * const, SwFrame* ); + + virtual void DestroyImpl() override; + virtual ~SwContentFrame() override; + +public: + + virtual void Cut() override; + virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override; + + inline const SwContentFrame *GetFollow() const; + inline SwContentFrame *GetFollow(); + SwTextFrame* FindMaster() const; + + // layout dependent cursor travelling + virtual bool LeftMargin(SwPaM *) const = 0; + virtual bool RightMargin(SwPaM *, bool bAPI = false) const = 0; + virtual bool UnitUp( SwPaM *, const SwTwips nOffset, + bool bSetInReadOnly ) const; + virtual bool UnitDown( SwPaM *, const SwTwips nOffset, + bool bSetInReadOnly ) const; + + // nMaxHeight is the required height + // bSplit indicates that the paragraph has to be split + // bTst indicates that we are currently doing a test formatting + virtual bool WouldFit(SwTwips &nMaxHeight, bool &bSplit, bool bTst, bool); + + bool MoveFootnoteCntFwd( bool, SwFootnoteBossFrame* ); // called by MoveFwd if content + + inline SwContentFrame* GetNextContentFrame() const; + inline SwContentFrame* GetPrevContentFrame() const; + static bool CalcLowers(SwLayoutFrame & rLay, SwLayoutFrame const& rDontLeave, + tools::Long nBottom, bool bSkipRowSpanCells); +}; + +inline SwContentFrame* SwContentFrame::GetNextContentFrame() const +{ + if ( GetNext() && GetNext()->IsContentFrame() ) + return const_cast(static_cast(GetNext())); + else + return const_cast(ImplGetNextContentFrame( true )); +} + +inline SwContentFrame* SwContentFrame::GetPrevContentFrame() const +{ + if ( GetPrev() && GetPrev()->IsContentFrame() ) + return const_cast(static_cast(GetPrev())); + else + return const_cast(ImplGetNextContentFrame( false )); +} + +inline const SwContentFrame *SwContentFrame::GetFollow() const +{ + return static_cast(SwFlowFrame::GetFollow()); +} +inline SwContentFrame *SwContentFrame::GetFollow() +{ + return static_cast(SwFlowFrame::GetFollow()); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/colfrm.hxx b/sw/source/core/inc/colfrm.hxx new file mode 100644 index 0000000000..a223dfa803 --- /dev/null +++ b/sw/source/core/inc/colfrm.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_COLFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_COLFRM_HXX + +#include "ftnboss.hxx" + +class SwColumnFrame final : public SwFootnoteBossFrame +{ +private: + virtual void DestroyImpl() override; + virtual ~SwColumnFrame() override; + +public: + SwColumnFrame(SwFrameFormat*, SwFrame*); + + virtual void PaintBreak() const override; + virtual void PaintSubsidiaryLines(const SwPageFrame*, const SwRect&) const override; + + void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_COLFRM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/contentcontrolbutton.hxx b/sw/source/core/inc/contentcontrolbutton.hxx new file mode 100644 index 0000000000..28b9e49c30 --- /dev/null +++ b/sw/source/core/inc/contentcontrolbutton.hxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include +#include +#include + +class SwEditWin; +class SwContentControl; + +/// This button is shown when the cursor is inside a content control with drop-down capability. +class SwContentControlButton : public Control +{ +public: + SwContentControlButton(SwEditWin* pEditWin, std::shared_ptr pContentControl); + virtual ~SwContentControlButton() override; + virtual void dispose() override; + + void CalcPosAndSize(const SwRect& rPortionPaintArea); + void SetRTL(bool bRTL) { m_bRTL = bRTL; } + + virtual void MouseButtonDown(const MouseEvent& rMEvt) override; + DECL_LINK(PopupModeEndHdl, weld::Popover&, void); + /// Shared MouseButtonDown() and KeyInput() code. + void StartPopup(); + + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual WindowHitTest ImplHitTest(const Point& rFramePos) override; + + virtual void LaunchPopup(); + virtual void DestroyPopup(); + + const std::shared_ptr& GetContentControl() const { return m_pContentControl; } + +private: + tools::Rectangle m_aFramePixel; + +protected: + std::shared_ptr m_pContentControl; + std::unique_ptr m_xPopupBuilder; + std::unique_ptr m_xPopup; + bool m_bRTL = false; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/crossrefbookmark.hxx b/sw/source/core/inc/crossrefbookmark.hxx new file mode 100644 index 0000000000..3ee770e8d6 --- /dev/null +++ b/sw/source/core/inc/crossrefbookmark.hxx @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_CROSSREFBOOKMARK_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_CROSSREFBOOKMARK_HXX + +#include + +#include + +#include "bookmark.hxx" +#include +#include + +namespace sw::mark { + class CrossRefBookmark + : public Bookmark + { + public: + CrossRefBookmark(const SwPaM& rPaM, + const vcl::KeyCode& rCode, + const OUString& rName, + std::u16string_view rPrefix); + + // getters + virtual SwPosition& GetOtherMarkPos() const override; + virtual SwPosition& GetMarkStart() const override + { return const_cast(*m_oPos1); } + virtual SwPosition& GetMarkEnd() const override + { return const_cast(*m_oPos1); } + virtual bool IsExpanded() const override + { return false; } + + virtual void SetMarkPos(const SwPosition& rNewPos) override; + virtual void SetOtherMarkPos(const SwPosition&) override + { + assert(false && + "" + " - misusage of CrossRefBookmark: other bookmark position isn't allowed to be set." ); + } + virtual void ClearOtherMarkPos() override + { + assert(false && + "" + " - misusage of CrossRefBookmark: other bookmark position isn't allowed to be set or cleared." ); + } + }; + + class CrossRefHeadingBookmark final + : public CrossRefBookmark + { + public: + CrossRefHeadingBookmark(const SwPaM& rPaM, + const vcl::KeyCode& rCode, + const OUString& rName); + static bool IsLegalName(std::u16string_view rName); + }; + + class CrossRefNumItemBookmark final + : public CrossRefBookmark + { + public: + CrossRefNumItemBookmark(const SwPaM& rPaM, + const vcl::KeyCode& rCode, + const OUString& rName); + static bool IsLegalName(std::u16string_view rName); + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/datecontentcontrolbutton.hxx b/sw/source/core/inc/datecontentcontrolbutton.hxx new file mode 100644 index 0000000000..48b08f2db9 --- /dev/null +++ b/sw/source/core/inc/datecontentcontrolbutton.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include "contentcontrolbutton.hxx" + +class SwEditWin; +class SvNumberFormatter; +class SwContentControl; + +/** + * This button is shown when the cursor is on a date content control. The user can select a date + * from a date picker. + */ +class SwDateContentControlButton final : public SwContentControlButton +{ +private: + SvNumberFormatter* m_pNumberFormatter; + + std::unique_ptr m_xCalendar; + + DECL_LINK(SelectHandler, weld::Calendar&, void); + +public: + SwDateContentControlButton(SwEditWin* pEditWin, + const std::shared_ptr& pContentControl, + SvNumberFormatter* pNumberFormatter); + ~SwDateContentControlButton() override; + + void LaunchPopup() override; + void DestroyPopup() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/dbg_lay.hxx b/sw/source/core/inc/dbg_lay.hxx new file mode 100644 index 0000000000..d340153abc --- /dev/null +++ b/sw/source/core/inc/dbg_lay.hxx @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DBG_LAY_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DBG_LAY_HXX + +#include +#include + +enum class PROT { + FileInit = 0x00000000, + Init = 0x00000001, + MakeAll = 0x00000002, + MoveFwd = 0x00000004, + MoveBack = 0x00000008, + Grow = 0x00000010, + Shrink = 0x00000020, + GrowTest = 0x00000040, + ShrinkTest = 0x00000080, + Size = 0x00000100, + PrintArea = 0x00000200, + AdjustN = 0x00000800, + Section = 0x00001000, + Cut = 0x00002000, + Paste = 0x00004000, + Leaf = 0x00008000, + TestFormat = 0x00010000, + FrmChanges = 0x00020000, +}; +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +} + +enum class DbgAction { + NONE, + Start, End, + CreateMaster, CreateFollow, + DelMaster, DelFollow, + Merge, + NextSect, PrevSect +}; + +#ifdef DBG_UTIL + +class SwImplProtocol; +class SwFrame; +class SwImplEnterLeave; + +class SwProtocol +{ + static PROT s_nRecord; + static SwImplProtocol* s_pImpl; + static bool Start() { return bool( PROT::Init & s_nRecord ); } + +public: + static PROT Record() { return s_nRecord; } + static void SetRecord( PROT nNew ) { s_nRecord = nNew; } + static bool Record( PROT nFunc ) { return bool(( nFunc | PROT::Init ) & s_nRecord); } + static void Record( const SwFrame* pFrame, PROT nFunction, DbgAction nAction, void* pParam ); + static void Init(); + static void Stop(); +}; + +class SwEnterLeave +{ + std::unique_ptr pImpl; +public: + SwEnterLeave( const SwFrame* pFrame, PROT nFunc, DbgAction nAct, void* pPar ); + ~SwEnterLeave(); +}; + +#define PROTOCOL( pFrame, nFunc, nAct, pPar ) { if( SwProtocol::Record( nFunc ) )\ + SwProtocol::Record( pFrame, nFunc, nAct, pPar ); } +#define PROTOCOL_INIT SwProtocol::Init(); +#define PROTOCOL_STOP SwProtocol::Stop(); +#define PROTOCOL_ENTER( pFrame, nFunc, nAct, pPar ) SwEnterLeave aEnter( pFrame, nFunc, nAct, pPar ); + +#else + +#define PROTOCOL( pFrame, nFunc, nAct, pPar ) +#define PROTOCOL_INIT +#define PROTOCOL_STOP +#define PROTOCOL_ENTER( pFrame, nFunc, nAct, pPar ) + +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx new file mode 100644 index 0000000000..701d633289 --- /dev/null +++ b/sw/source/core/inc/dflyobj.hxx @@ -0,0 +1,154 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DFLYOBJ_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DFLYOBJ_HXX + +#include +#include + +#include + +namespace drawinglayer::geometry { class ViewInformation2D; } + +class SwFlyFrame; +class SwFrameFormat; + +// DrawObjects for Flys +class SwFlyDrawObj final : public SdrObject +{ +private: + virtual std::unique_ptr CreateObjectSpecificProperties() override; + bool mbIsTextBox; + + // #i95264# SwFlyDrawObj needs an own VC since createViewIndependentPrimitive2DSequence() + // is called when RecalcBoundRect() is used + virtual std::unique_ptr CreateObjectSpecificViewContact() override; + + // protected destructor + virtual ~SwFlyDrawObj() override; + +public: + SwFlyDrawObj(SdrModel& rSdrModel); + + // for instantiation of this class while loading (via factory + virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; + + virtual SdrInventor GetObjInventor() const override; + virtual SdrObjKind GetObjIdentifier() const override; + virtual bool IsTextBox() const override { return mbIsTextBox; } + void SetTextBox(bool bIsTextBox) { mbIsTextBox = bIsTextBox; } + + virtual void NbcRotate(const Point& rRef, Degree100 nAngle, double sinAngle, double cosAngle) override; +}; + +// virtual objects for Flys +// Flys will always be shown with virtual objects. By doing that, they can be +// shown multiple times if needed (header/footer). +// For example, if an SwFlyFrameFormat is anchored in a header, then all pages will have a separate +// SwVirtFlyDrawObj in their headers. +class SW_DLLPUBLIC SwVirtFlyDrawObj final : public SdrVirtObj +{ +private: + SwFlyFrame *m_pFlyFrame; + + // RotGrfFlyFrame: Helper to access the rotation angle (in 10th degrees, left-handed) + // of a GraphicFrame + Degree10 getPossibleRotationFromFraphicFrame(Size& rSize) const; + + // AW: Need own sdr::contact::ViewContact since AnchorPos from parent is + // not used but something own (top left of new SnapRect minus top left + // of original SnapRect) + virtual std::unique_ptr CreateObjectSpecificViewContact() override; + + // protected destructor + virtual ~SwVirtFlyDrawObj() override; + +public: + // for paints triggered form ExecutePrimitive + void wrap_DoPaintObject( + drawinglayer::geometry::ViewInformation2D const&) const; + + // for simple access to inner and outer bounds + basegfx::B2DRange getOuterBound() const; + basegfx::B2DRange getInnerBound() const; + + // RotGrfFlyFrame: Check if this is a SwGrfNode + bool ContainsSwGrfNode() const; + + SwVirtFlyDrawObj( + SdrModel& rSdrModel, + SdrObject& rNew, + SwFlyFrame* pFly); + + // override method of base class SdrVirtObj + virtual void TakeObjInfo( SdrObjTransformInfoRec& rInfo ) const override; + + // we treat the size calculation completely on ourself here + virtual const tools::Rectangle& GetCurrentBoundRect() const override; + virtual const tools::Rectangle& GetLastBoundRect() const override; + virtual Degree100 GetRotateAngle() const override; + virtual void RecalcBoundRect() override; + virtual void RecalcSnapRect() override; + virtual const tools::Rectangle& GetSnapRect() const override; + virtual void SetSnapRect(const tools::Rectangle& rRect) override; + virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override; + virtual const tools::Rectangle& GetLogicRect() const override; + virtual void SetLogicRect(const tools::Rectangle& rRect) override; + virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override; + virtual ::basegfx::B2DPolyPolygon TakeXorPoly() const override; + virtual void NbcMove (const Size& rSiz) override; + virtual void NbcResize(const Point& rRef, const Fraction& xFact, + const Fraction& yFact) override; + virtual void NbcCrop(const basegfx::B2DPoint& rRef, double fxFact, double fyFact) override; + virtual void Move (const Size& rSiz) override; + virtual void Resize(const Point& rRef, const Fraction& xFact, + const Fraction& yFact, bool bUnsetRelative = true) override; + virtual void Crop(const basegfx::B2DPoint& rRef, double fxFact, double fyFact) override; + virtual void addCropHandles(SdrHdlList& rTarget) const override; + virtual void Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs) override; + + + // FullDrag support + virtual rtl::Reference getFullDragClone() const override; + + const SwFrameFormat *GetFormat() const; + SwFrameFormat *GetFormat(); + + // methods to get pointers for the Fly + SwFlyFrame* GetFlyFrame() { return m_pFlyFrame; } + const SwFlyFrame* GetFlyFrame() const { return m_pFlyFrame; } + + void SetRect() const; + + // if a URL is attached to a graphic than this is a macro object + virtual bool HasMacro() const override; + virtual SdrObject* CheckMacroHit (const SdrObjMacroHitRec& rRec) const override; + virtual PointerStyle GetMacroPointer (const SdrObjMacroHitRec& rRec) const override; + + // RotGrfFlyFrame: If true, this SdrObject supports only limited rotation. + virtual bool HasLimitedRotation() const override; + + virtual bool IsTextBox() const override; + void dumpAsXml(xmlTextWriterPtr pWriter) const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/dialoghelp.hxx b/sw/source/core/inc/dialoghelp.hxx new file mode 100644 index 0000000000..a549523658 --- /dev/null +++ b/sw/source/core/inc/dialoghelp.hxx @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DIALOGHELP_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DIALOGHELP_HXX + +class SwDoc; +class SwDocShell; +class SfxFrame; +class SfxMedium; + +namespace weld +{ +class Window; +} + +weld::Window* GetFrameWeld(const SfxFrame* pFrame); +weld::Window* GetFrameWeld(const SfxMedium* pMedium); +weld::Window* GetFrameWeld(SwDocShell* pDocSh); +weld::Window* GetFrameWeld(SwDoc* pDoc); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sw/source/core/inc/docedt.hxx b/sw/source/core/inc/docedt.hxx new file mode 100644 index 0000000000..036d516d99 --- /dev/null +++ b/sw/source/core/inc/docedt.hxx @@ -0,0 +1,31 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCEDT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCEDT_HXX + +class SwPaM; + +bool sw_JoinText(SwPaM& rPam, bool bJoinPrev); + +void sw_GetJoinFlags(SwPaM& rPam, bool& rJoinText, bool& rJoinPrev); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/docfld.hxx b/sw/source/core/inc/docfld.hxx new file mode 100644 index 0000000000..f09116978f --- /dev/null +++ b/sw/source/core/inc/docfld.hxx @@ -0,0 +1,188 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCFLD_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCFLD_HXX + +#include +#include +#include +#include +#include +#include +#include + +class SwTextField; +class SwContentIndex; +class SwNodeIndex; +class SwContentFrame; +class SwSectionNode; +class SwSection; +class SwTextTOXMark; +class SwTableBox; +class SwTextINetFormat; +class SwFlyFrameFormat; +class SwNode; +struct SwPosition; +enum class SwFieldIds : sal_uInt16; + +// Update expression fields +class SetGetExpField +{ + // TODO: in case of multiple layouts, storing this only once isn't going to work (although already a problem for cached field value) + sal_uInt16 m_nPageNumber = 0; + SwNodeOffset m_nNode; + union { + const SwTextField* pTextField; + const SwSection* pSection; + const SwPosition* pPos; + const SwTextTOXMark* pTextTOX; + const SwTableBox* pTBox; + const SwTextINetFormat* pTextINet; + const SwFlyFrameFormat* pFlyFormat; + ::sw::mark::IBookmark const* pBookmark; + } m_CNTNT; + sal_Int32 m_nContent; + enum SetGetExpFieldType + { + TEXTFIELD, TEXTTOXMARK, SECTIONNODE, BOOKMARK, CRSRPOS, TABLEBOX, + TEXTINET, FLYFRAME + } m_eSetGetExpFieldType; + +public: + SetGetExpField( const SwNode& rNd, const SwTextField* pField = nullptr, + std::optional oContentIdx = std::nullopt, + sal_uInt16 nPageNumber = 0); + + SetGetExpField( const SwNode& rNd, const SwTextINetFormat& rINet ); + + SetGetExpField( const SwSectionNode& rSectNode, + const SwPosition* pPos = nullptr, + sal_uInt16 nPageNumber = 0); + + SetGetExpField( ::sw::mark::IBookmark const& rBookmark, + SwPosition const* pPos = nullptr, + sal_uInt16 nPageNumber = 0); + + SetGetExpField( const SwTableBox& rTableBox ); + + SetGetExpField( const SwNode& rNd, const SwTextTOXMark& rTOX ); + + SetGetExpField( const SwPosition& rPos ); + + SetGetExpField( const SwFlyFrameFormat& rFlyFormat, const SwPosition* pPos ); + + bool operator==( const SetGetExpField& rField ) const; + bool operator<( const SetGetExpField& rField ) const; + + const SwTextField* GetTextField() const + { return TEXTFIELD == m_eSetGetExpFieldType ? m_CNTNT.pTextField : nullptr; } + const SwSection* GetSection() const + { return SECTIONNODE == m_eSetGetExpFieldType ? m_CNTNT.pSection : nullptr; } + ::sw::mark::IBookmark const* GetBookmark() const + { return BOOKMARK == m_eSetGetExpFieldType ? m_CNTNT.pBookmark : nullptr; } + const SwTextINetFormat* GetINetFormat() const + { return TEXTINET == m_eSetGetExpFieldType ? m_CNTNT.pTextINet : nullptr; } + const SwFlyFrameFormat* GetFlyFormat() const + { return FLYFRAME == m_eSetGetExpFieldType ? m_CNTNT.pFlyFormat : nullptr; } + + SwNodeOffset GetNode() const { return m_nNode; } + sal_Int32 GetContent() const { return m_nContent; } + const void* GetPointer() const { return m_CNTNT.pTextField; } + + void GetPosOfContent( SwPosition& rPos ) const; + + const SwNode* GetNodeFromContent() const; + sal_Int32 GetCntPosFromContent() const; + + void SetBodyPos( const SwContentFrame& rFrame ); +}; + +class SetGetExpFields : public o3tl::sorted_vector, o3tl::less_uniqueptr_to > +{ +}; + + +//struct SwCalcFieldType final : public SwHash +//{ +// const SwFieldType* pFieldType; +// +// SwCalcFieldType( const OUString& rStr, const SwFieldType* pFieldTyp ) +// : SwHash( rStr ), pFieldType( pFieldTyp ) +// {} +//}; + +// search for the string that was saved under rName in the hash table +OUString LookString( std::unordered_map const & rTable, const OUString& rName ); + +const int GETFLD_ALL = 3; // combine flags via OR +const int GETFLD_CALC = 1; +const int GETFLD_EXPAND = 2; + +class SwDocUpdateField +{ + std::unique_ptr m_pFieldSortList; ///< current field list for calculation + std::unordered_multimap m_FieldTypeTable; + + SwNodeOffset m_nNodes; ///< to check if the node count changed + int m_nFieldListGetMode; + SwDoc& m_rDoc; + + bool m_bInUpdateFields : 1; ///< currently in an UpdateFields call + bool m_bFieldsDirty : 1; ///< some fields are invalid + + void MakeFieldList_( SwDoc& pDoc, int eGetMode ); + void GetBodyNode( const SwTextField& , SwFieldIds nFieldWhich ); + template + void GetBodyNodeGeneric(SwNode const& rNode, T const&); + +public: + SwDocUpdateField(SwDoc& rDocument); + ~SwDocUpdateField(); + + const SetGetExpFields* GetSortList() const { return m_pFieldSortList.get(); } + + void MakeFieldList( SwDoc& rDoc, bool bAll, int eGetMode ); + + void InsDelFieldInFieldLst( bool bIns, const SwTextField& rField ); + + void InsertFieldType( const SwFieldType& rType ); + void RemoveFieldType( const SwFieldType& rType ); + + bool IsInUpdateFields() const { return m_bInUpdateFields; } + void SetInUpdateFields( bool b ) { m_bInUpdateFields = b; } + + bool IsFieldsDirty() const { return m_bFieldsDirty; } + void SetFieldsDirty( bool b ) + { + m_bFieldsDirty = b; + + if (b) + { + m_rDoc.getIDocumentTimerAccess().StartIdling(); + } + } + + std::unordered_multimap const& GetFieldTypeTable() const { return m_FieldTypeTable; } + std::unordered_multimap & GetFieldTypeTable() { return m_FieldTypeTable; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/docredln.hxx b/sw/source/core/inc/docredln.hxx new file mode 100644 index 0000000000..f60cb930dc --- /dev/null +++ b/sw/source/core/inc/docredln.hxx @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCREDLN_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCREDLN_HXX + +#include + +#if defined DBG_UTIL + +class SwDoc; + +void sw_DebugRedline(const SwDoc* pDoc); + +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/docsort.hxx b/sw/source/core/inc/docsort.hxx new file mode 100644 index 0000000000..0aad16da4a --- /dev/null +++ b/sw/source/core/inc/docsort.hxx @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCSORT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCSORT_HXX + +#include + +#include +#include + +class SwDoc; +class SwTableBox; +class SwUndoSort; +class FlatFndBox; +struct SwSortOptions; +class FndBox_; +class FndLine_; +class CollatorWrapper; +class LocaleDataWrapper; +namespace com::sun::star::lang { struct Locale; } + +class SwMovedBoxes +{ +private: + std::vector mBoxes; + +public: + void push_back(const SwTableBox* &rpTableBox) {mBoxes.push_back(rpTableBox);} + + sal_uInt16 GetPos(const SwTableBox* pTableBox) const; +}; + +// Functions for moving boxes +void MoveCol(SwDoc* pDoc, const FlatFndBox& rBox, + sal_uInt16 nS, sal_uInt16 nT, SwMovedBoxes& rMovedList, SwUndoSort* pUD); +void MoveRow(SwDoc* pDoc, const FlatFndBox& rBox, + sal_uInt16 nS, sal_uInt16 nT, SwMovedBoxes& rMovedList, SwUndoSort* pUD); +void MoveCell(SwDoc* pDoc, const SwTableBox* pSource, + const SwTableBox* pTar, bool bMovedBefore, SwUndoSort* pUD=nullptr); + +// Elements for sorting text and table content +struct SwSortElement +{ + static SwSortOptions* pOptions; + static SwDoc* pDoc; + static const FlatFndBox* pBox; + static CollatorWrapper* pSortCollator; + static css::lang::Locale* pLocale; + static std::optional xLastAlgorithm; + static LocaleDataWrapper* pLclData; + + static void Init( SwDoc*, const SwSortOptions& rOpt, FlatFndBox const * = nullptr ); + static void Finit(); + + SwSortElement() = default; + SwSortElement(SwSortElement const &) = default; + SwSortElement(SwSortElement &&) = default; + SwSortElement & operator =(SwSortElement const &) = default; + SwSortElement & operator =(SwSortElement &&) = default; + + virtual ~SwSortElement(); + + virtual OUString GetKey(sal_uInt16 nKey ) const = 0; + virtual double GetValue(sal_uInt16 nKey ) const; + + bool operator<(const SwSortElement& ) const; + + static double StrToDouble(std::u16string_view rStr); +private: + int keycompare(const SwSortElement& rCmp, sal_uInt16 nKey) const; +}; + +// sort text +struct SwSortTextElement final : public SwSortElement +{ + SwNodeOffset nOrg; + SwNodeIndex aPos; + + SwSortTextElement( const SwNodeIndex& rPos ); + + virtual OUString GetKey( sal_uInt16 nKey ) const override; +}; + +// sort table +struct SwSortBoxElement final : public SwSortElement +{ + sal_uInt16 nRow; + + SwSortBoxElement( sal_uInt16 nRC ); + + virtual OUString GetKey( sal_uInt16 nKey ) const override; + virtual double GetValue( sal_uInt16 nKey ) const override; +}; + +// two-dimensional array of FndBoxes +class FlatFndBox +{ +public: + FlatFndBox(SwDoc* pDocPtr, const FndBox_& rBox); + ~FlatFndBox(); + + bool IsSymmetric() const { return m_bSym; } + sal_uInt16 GetRows() const { return m_nRows; } + sal_uInt16 GetCols() const { return m_nCols; } + + const FndBox_* GetBox(sal_uInt16 nCol, sal_uInt16 nRow) const; + + inline bool HasItemSets() const; + const SfxItemSet* GetItemSet(sal_uInt16 nCol, sal_uInt16 nRow) const; + +private: + bool CheckLineSymmetry(const FndBox_& rBox); + bool CheckBoxSymmetry(const FndLine_& rLn); + sal_uInt16 GetColCount(const FndBox_& rBox); + sal_uInt16 GetRowCount(const FndBox_& rBox); + void FillFlat(const FndBox_&, bool bLastBox=false); + + SwDoc* m_pDoc; + std::unique_ptr m_pArr; + /// using optional because SfxItemSet has no default constructor + std::vector> m_vItemSets; + + sal_uInt16 m_nRows; + sal_uInt16 m_nCols; + sal_uInt16 m_nRow; + sal_uInt16 m_nCol; + + bool m_bSym; +}; + +inline bool FlatFndBox::HasItemSets() const { return !m_vItemSets.empty(); } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/doctxm.hxx b/sw/source/core/inc/doctxm.hxx new file mode 100644 index 0000000000..d33809d5d8 --- /dev/null +++ b/sw/source/core/inc/doctxm.hxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCTXM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCTXM_HXX + +#include +#include +#include +#include + +class SwTOXInternational; +class SwPageDesc; +class SwTextNode; +class SwTextFormatColl; +struct SwPosition; +struct SwTOXSortTabBase; + +class SwTOXBaseSection final : public SwTOXBase, public SwSection +{ + std::vector> m_aSortArr; + + void UpdateMarks( const SwTOXInternational& rIntl, + const SwTextNode* pOwnChapterNode, + SwRootFrame const* pLayout ); + void UpdateOutline( const SwTextNode* pOwnChapterNode, + SwRootFrame const* pLayout ); + void UpdateTemplate( const SwTextNode* pOwnChapterNode, + SwRootFrame const* pLayout ); + void UpdateContent( SwTOXElement eType, + const SwTextNode* pOwnChapterNode, + SwRootFrame const* pLayout ); + void UpdateTable( const SwTextNode* pOwnChapterNode, + SwRootFrame const* pLayout ); + void UpdateSequence( const SwTextNode* pOwnChapterNode, + SwRootFrame const* pLayout ); + void UpdateAuthorities( const SwTOXInternational& rIntl, + SwRootFrame const* pLayout ); + + // insert sorted into array for creation + void InsertSorted(std::unique_ptr pBase); + + // insert alpha delimiter at creation + void InsertAlphaDelimiter( const SwTOXInternational& rIntl ); + + // replace page num placeholder with actual page number + void UpdatePageNum_( SwTextNode* pNd, + const std::vector& rNums, + const std::vector& rDescs, + const std::vector* pMainEntryNums, + const SwTOXInternational& rIntl ); + + // get section for entering keywords + Range GetKeyRange( const OUString& rStr, const OUString& rStrReading, + const SwTOXSortTabBase& rNew, sal_uInt16 nLevel, + const Range& rRange ); + + // return text collection via name/ from format pool + SwTextFormatColl* GetTextFormatColl( sal_uInt16 nLevel ); + virtual void SwClientNotify(const SwModify& rModify, const SfxHint& rHint) override; + +public: + SwTOXBaseSection(SwTOXBase const& rBase, SwSectionFormat & rFormat); + virtual ~SwTOXBaseSection() override; + + // <_bNewTOX> : distinguish between the creation of a new table-of-content + // (true) or an update of a table-of-content (false) + void Update( const SfxItemSet* pAttr = nullptr, + SwRootFrame const* pLayout = nullptr, + const bool _bNewTOX = false ); + void UpdatePageNum(); // insert page numbering + + bool SetPosAtStartEnd( SwPosition& rPos ) const; + bool IsVisible() const override + { + return GetFormat() && GetFormat()->IsVisible(); + } +}; + +struct SwDefTOXBase_Impl +{ + std::unique_ptr pContBase; + std::unique_ptr pIdxBase; + std::unique_ptr pUserBase; + std::unique_ptr pTableBase; + std::unique_ptr pObjBase; + std::unique_ptr pIllBase; + std::unique_ptr pAuthBase; + std::unique_ptr pBiblioBase; + + SwDefTOXBase_Impl() + { + } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/drawfont.hxx b/sw/source/core/inc/drawfont.hxx new file mode 100644 index 0000000000..fe6a442647 --- /dev/null +++ b/sw/source/core/inc/drawfont.hxx @@ -0,0 +1,639 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DRAWFONT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DRAWFONT_HXX + +#include +#include +#include +#include +#include "TextFrameIndex.hxx" +#include + +class SwTextFrame; +class SwViewShell; +class SwScriptInfo; +namespace sw { class WrongListIterator; } +class SwFont; +namespace vcl { + class Font; + namespace text { + class TextLayoutCache; + } + typedef OutputDevice RenderContext; +} +class SwUnderlineFont; + +// encapsulates information for drawing text +class SW_DLLPUBLIC SwDrawTextInfo +{ + const SwTextFrame* m_pFrame; + VclPtr m_pOut; + SwViewShell const * m_pSh; + const SwScriptInfo* m_pScriptInfo; + Point m_aPos; + vcl::text::TextLayoutCache const* m_pCachedVclData; + OUString m_aText; + sw::WrongListIterator* m_pWrong; + sw::WrongListIterator* m_pGrammarCheck; + sw::WrongListIterator* m_pSmartTags; + Size m_aSize; + SwFont *m_pFnt; + SwUnderlineFont* m_pUnderFnt; + TextFrameIndex* m_pHyphPos; + tools::Long m_nKanaDiff; + TextFrameIndex m_nIdx; + TextFrameIndex m_nLen; + TextFrameIndex m_nMeasureLen; + /// this is not a string index + sal_Int32 m_nOfst; + sal_uInt16 m_nWidth; + sal_uInt16 m_nAscent; + sal_uInt16 m_nCompress; + tools::Long m_nCharacterSpacing; + tools::Long m_nSpace; + tools::Long m_nKern; + TextFrameIndex m_nNumberOfBlanks; + sal_uInt8 m_nCursorBidiLevel; + bool m_bBullet : 1; + bool m_bUpper : 1; // for small caps: upper case flag + bool m_bDrawSpace : 1; // for small caps: underline/ line through + bool m_bGreyWave : 1; // grey wave line for extended text input + // For underlining we need to know, if a section is right in front of a + // whole block or a fix margin section. + bool m_bSpaceStop : 1; + bool m_bSnapToGrid : 1; // Does paragraph snap to grid? + // Paint text as if text has LTR direction, used for line numbering + bool m_bIgnoreFrameRTL : 1; + // GetModelPositionForViewPoint should not return the next position if screen position is + // inside second half of bound rect, used for Accessibility + bool m_bPosMatchesBounds :1; + +#ifdef DBG_UTIL + // These flags should control that the appropriate Set-function has been + // called before calling the Get-function of a member + bool m_bPos : 1; + bool m_bWrong : 1; + bool m_bGrammarCheck : 1; + bool m_bSize : 1; + bool m_bFnt : 1; + bool m_bHyph : 1; + bool m_bKana : 1; + bool m_bOfst : 1; + bool m_bAscent: 1; + bool m_bCharacterSpacing : 1; + bool m_bSpace : 1; + bool m_bNumberOfBlanks : 1; + bool m_bUppr : 1; + bool m_bDrawSp: 1; +#endif + +public: + + /// constructor for simple strings + SwDrawTextInfo( SwViewShell const *pSh, OutputDevice &rOut, + const OUString &rText, sal_Int32 const nIdx, sal_Int32 const nLen, + sal_uInt16 nWidth = 0, bool bBullet = false) + : SwDrawTextInfo(pSh, rOut, nullptr, rText, TextFrameIndex(nIdx), TextFrameIndex(nLen), nWidth, bBullet) + {} + /// constructor for text frame contents + SwDrawTextInfo( SwViewShell const *pSh, OutputDevice &rOut, const SwScriptInfo* pSI, + const OUString &rText, TextFrameIndex const nIdx, TextFrameIndex const nLen, + sal_uInt16 nWidth = 0, bool bBullet = false, + vcl::text::TextLayoutCache const*const pCachedVclData = nullptr) + : m_pCachedVclData(pCachedVclData) + { + assert( (nLen == TextFrameIndex(COMPLETE_STRING)) ? (nIdx.get() < rText.getLength()) : (nIdx + nLen).get() <= rText.getLength() ); + m_pFrame = nullptr; + m_pSh = pSh; + m_pOut = &rOut; + m_pScriptInfo = pSI; + m_aText = rText; + m_nIdx = nIdx; + m_nLen = nLen; + m_nMeasureLen = TextFrameIndex(COMPLETE_STRING); + m_nKern = 0; + m_nCompress = 0; + m_nWidth = nWidth; + m_nNumberOfBlanks = TextFrameIndex(0); + m_nCursorBidiLevel = 0; + m_bBullet = bBullet; + m_pUnderFnt = nullptr; + m_bGreyWave = false; + m_bSpaceStop = false; + m_bSnapToGrid = false; + m_bIgnoreFrameRTL = false; + m_bPosMatchesBounds = false; + + // These values are initialized but have to be set explicitly via their + // Set-function before they may be accessed by their Get-function: + m_pWrong = nullptr; + m_pGrammarCheck = nullptr; + m_pSmartTags = nullptr; + m_pFnt = nullptr; + m_pHyphPos = nullptr; + m_nKanaDiff = 0; + m_nOfst = 0; + m_nAscent = 0; + m_nCharacterSpacing = 0; + m_nSpace = 0; + m_bUpper = false; + m_bDrawSpace = false; + +#ifdef DBG_UTIL + // these flags control whether the matching member variables have been + // set by using the Set-function before they may be accessed by their + // Get-function: + m_bPos = m_bWrong = m_bGrammarCheck = m_bSize = m_bFnt = m_bAscent = + m_bSpace = m_bNumberOfBlanks = m_bUppr = + m_bDrawSp = m_bKana = m_bOfst = m_bHyph = + m_bCharacterSpacing = false; +#endif + } + + const SwTextFrame* GetFrame() const + { + return m_pFrame; + } + + void SetFrame( const SwTextFrame* pNewFrame ) + { + m_pFrame = pNewFrame; + } + + SwViewShell const *GetShell() const + { + return m_pSh; + } + + vcl::RenderContext& GetOut() const + { + return *m_pOut; + } + + vcl::RenderContext *GetpOut() const + { + return m_pOut; + } + + const SwScriptInfo* GetScriptInfo() const + { + return m_pScriptInfo; + } + + const Point &GetPos() const + { +#ifdef DBG_UTIL + OSL_ENSURE( m_bPos, "DrawTextInfo: Undefined Position" ); +#endif + return m_aPos; + } + + TextFrameIndex *GetHyphPos() const + { +#ifdef DBG_UTIL + OSL_ENSURE( m_bHyph, "DrawTextInfo: Undefined Hyph Position" ); +#endif + return m_pHyphPos; + } + + vcl::text::TextLayoutCache const* GetVclCache() const + { + return m_pCachedVclData; + } + + const OUString &GetText() const + { + return m_aText; + } + + sw::WrongListIterator* GetWrong() const + { +#ifdef DBG_UTIL + OSL_ENSURE( m_bWrong, "DrawTextInfo: Undefined WrongList" ); +#endif + return m_pWrong; + } + + sw::WrongListIterator* GetGrammarCheck() const + { +#ifdef DBG_UTIL + OSL_ENSURE( m_bGrammarCheck, "DrawTextInfo: Undefined GrammarCheck List" ); +#endif + return m_pGrammarCheck; + } + + sw::WrongListIterator* GetSmartTags() const + { + return m_pSmartTags; + } + + const Size &GetSize() const + { +#ifdef DBG_UTIL + OSL_ENSURE( m_bSize, "DrawTextInfo: Undefined Size" ); +#endif + return m_aSize; + } + + SwFont* GetFont() const + { +#ifdef DBG_UTIL + OSL_ENSURE( m_bFnt, "DrawTextInfo: Undefined Font" ); +#endif + return m_pFnt; + } + + SwUnderlineFont* GetUnderFnt() const + { + return m_pUnderFnt; + } + + TextFrameIndex GetIdx() const + { + return m_nIdx; + } + + TextFrameIndex GetLen() const + { + return m_nLen; + } + + TextFrameIndex GetMeasureLen() const + { + return m_nMeasureLen; + } + + sal_Int32 GetOffset() const + { +#ifdef DBG_UTIL + OSL_ENSURE( m_bOfst, "DrawTextInfo: Undefined Offset" ); +#endif + return m_nOfst; + } + + TextFrameIndex GetEnd() const + { + return m_nIdx + m_nLen; + } + + tools::Long GetKanaDiff() const + { +#ifdef DBG_UTIL + OSL_ENSURE( m_bKana, "DrawTextInfo: Undefined kana difference" ); +#endif + return m_nKanaDiff; + } + + sal_uInt16 GetWidth() const + { + return m_nWidth; + } + + sal_uInt16 GetAscent() const + { +#ifdef DBG_UTIL + OSL_ENSURE( m_bAscent, "DrawTextInfo: Undefined Ascent" ); +#endif + return m_nAscent; + } + + sal_uInt16 GetKanaComp() const + { + return m_nCompress; + } + + tools::Long GetCharacterSpacing() const + { +#ifdef DBG_UTIL + OSL_ENSURE( m_bCharacterSpacing, "DrawTextInfo: Undefined CharacterSpacing" ); +#endif + return m_nCharacterSpacing; + } + + tools::Long GetKern() const + { + return m_nKern; + } + + tools::Long GetSpace() const + { +#ifdef DBG_UTIL + OSL_ENSURE( m_bSpace, "DrawTextInfo: Undefined Spacing" ); +#endif + return m_nSpace; + } + + TextFrameIndex GetNumberOfBlanks() const + { +#ifdef DBG_UTIL + OSL_ENSURE( m_bNumberOfBlanks, "DrawTextInfo::Undefined NumberOfBlanks" ); +#endif + return m_nNumberOfBlanks; + } + + sal_uInt8 GetCursorBidiLevel() const + { + return m_nCursorBidiLevel; + } + + bool GetBullet() const + { + return m_bBullet; + } + + bool GetUpper() const + { +#ifdef DBG_UTIL + OSL_ENSURE( m_bUppr, "DrawTextInfo: Undefined Upperflag" ); +#endif + return m_bUpper; + } + + bool GetDrawSpace() const + { +#ifdef DBG_UTIL + OSL_ENSURE( m_bDrawSp, "DrawTextInfo: Undefined DrawSpaceflag" ); +#endif + return m_bDrawSpace; + } + + bool GetGreyWave() const + { + return m_bGreyWave; + } + + bool IsSpaceStop() const + { + return m_bSpaceStop; + } + + bool SnapToGrid() const + { + return m_bSnapToGrid; + } + + bool IsIgnoreFrameRTL() const + { + return m_bIgnoreFrameRTL; + } + + bool IsPosMatchesBounds() const + { + return m_bPosMatchesBounds; + } + + void SetOut( OutputDevice &rNew ) + { + m_pOut = &rNew; + } + + void SetPos( const Point &rNew ) + { + m_aPos = rNew; +#ifdef DBG_UTIL + m_bPos = true; +#endif + } + + void SetHyphPos(TextFrameIndex *const pNew) + { + m_pHyphPos = pNew; +#ifdef DBG_UTIL + m_bHyph = true; +#endif + } + + void SetText( const OUString &rNew ) + { + assert( (m_nLen == TextFrameIndex(COMPLETE_STRING)) ? (m_nIdx.get() < rNew.getLength()) : (m_nIdx + m_nLen).get() <= rNew.getLength() ); + m_aText = rNew; + m_pCachedVclData = nullptr; // would any case benefit from save/restore? + } + + // These methods are here so we can set all the related fields together to preserve the invariants that we assert + void SetTextIdxLen( const OUString &rNewStr, TextFrameIndex const nNewIdx, TextFrameIndex const nNewLen ) + { + assert( (nNewLen == TextFrameIndex(COMPLETE_STRING)) ? (nNewIdx.get() < rNewStr.getLength()) : (nNewIdx + nNewLen).get() <= rNewStr.getLength() ); + m_aText = rNewStr; + m_nIdx = nNewIdx; + m_nLen = nNewLen; + m_pCachedVclData = nullptr; // would any case benefit from save/restore? + } + + // These methods are here so we can set all the related fields together to preserve the invariants that we assert + void SetIdxLen( TextFrameIndex const nNewIdx, TextFrameIndex const nNewLen ) + { + assert( (nNewLen == TextFrameIndex(COMPLETE_STRING)) ? (nNewIdx.get() < m_aText.getLength()) : (nNewIdx + nNewLen).get() <= m_aText.getLength() ); + m_nIdx = nNewIdx; + m_nLen = nNewLen; + } + + void SetWrong(sw::WrongListIterator *const pNew) + { + m_pWrong = pNew; +#ifdef DBG_UTIL + m_bWrong = true; +#endif + } + + void SetGrammarCheck(sw::WrongListIterator *const pNew) + { + m_pGrammarCheck = pNew; +#ifdef DBG_UTIL + m_bGrammarCheck = true; +#endif + } + + void SetSmartTags(sw::WrongListIterator *const pNew) + { + m_pSmartTags = pNew; + } + + void SetSize( const Size &rNew ) + { + m_aSize = rNew; +#ifdef DBG_UTIL + m_bSize = true; +#endif + } + + void SetFont( SwFont* pNew ) + { + m_pFnt = pNew; +#ifdef DBG_UTIL + m_bFnt = true; +#endif + } + + void SetIdx(TextFrameIndex const nNew) + { + assert( (m_nLen == TextFrameIndex(COMPLETE_STRING)) ? (nNew.get() < m_aText.getLength()) : (nNew + m_nLen).get() <= m_aText.getLength() ); + m_nIdx = nNew; + } + + void SetLen(TextFrameIndex const nNew) + { + assert( (nNew == TextFrameIndex(COMPLETE_STRING)) ? (m_nIdx.get() < m_aText.getLength()) : (m_nIdx + nNew).get() <= m_aText.getLength() ); + m_nLen = nNew; + } + + void SetMeasureLen(TextFrameIndex const nNew) + { + assert( nNew == TextFrameIndex(COMPLETE_STRING) || nNew <= m_nLen ); + m_nMeasureLen = nNew; + } + + void SetOffset( sal_Int32 nNew ) + { + m_nOfst = nNew; +#ifdef DBG_UTIL + m_bOfst = true; +#endif + } + + void SetKanaDiff( tools::Long nNew ) + { + m_nKanaDiff = nNew; +#ifdef DBG_UTIL + m_bKana = true; +#endif + } + + void SetWidth( sal_uInt16 nNew ) + { + m_nWidth = nNew; + } + + void SetAscent( sal_uInt16 nNew ) + { + m_nAscent = nNew; +#ifdef DBG_UTIL + m_bAscent = true; +#endif + } + + void SetKern( tools::Long nNew ) + { + m_nKern = nNew; + } + + void SetSpace( tools::Long nNew ) + { + if( nNew < 0 ) + { + m_nCharacterSpacing = -nNew; + m_nSpace = 0; + } + else + { + // negative space (shrinking) stored over LONG_MAX/2 + if ( nNew < LONG_MAX/2 ) + m_nSpace = nNew; + else + m_nSpace = LONG_MAX/2 - nNew; + m_nCharacterSpacing = 0; + } +#ifdef DBG_UTIL + m_bSpace = true; + m_bCharacterSpacing = true; +#endif + } + + void SetNumberOfBlanks( TextFrameIndex const nNew ) + { +#ifdef DBG_UTIL + m_bNumberOfBlanks = true; +#endif + m_nNumberOfBlanks = nNew; + } + + void SetCursorBidiLevel( sal_uInt8 nNew ) + { + m_nCursorBidiLevel = nNew; + } + + void SetKanaComp( short nNew ) + { + m_nCompress = nNew; + } + + void SetBullet( bool bNew ) + { + m_bBullet = bNew; + } + + void SetUnderFnt( SwUnderlineFont* pULFnt ) + { + m_pUnderFnt = pULFnt; + } + + void SetUpper( bool bNew ) + { + m_bUpper = bNew; +#ifdef DBG_UTIL + m_bUppr = true; +#endif + } + + void SetDrawSpace( bool bNew ) + { + m_bDrawSpace = bNew; +#ifdef DBG_UTIL + m_bDrawSp = true; +#endif + } + + void SetGreyWave( bool bNew ) + { + m_bGreyWave = bNew; + } + + void SetSpaceStop( bool bNew ) + { + m_bSpaceStop = bNew; + } + + void SetSnapToGrid( bool bNew ) + { + m_bSnapToGrid = bNew; + } + + void SetIgnoreFrameRTL( bool bNew ) + { + m_bIgnoreFrameRTL = bNew; + } + + void SetPosMatchesBounds( bool bNew ) + { + m_bPosMatchesBounds = bNew; + } + + void Shift( Degree10 nDir ); + + // sets a new color at the output device if necessary if a font is passed + // as argument, the change if made to the font otherwise the font at the + // output device is changed returns if the font has been changed + bool ApplyAutoColor( vcl::Font* pFnt = nullptr ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/dropdowncontentcontrolbutton.hxx b/sw/source/core/inc/dropdowncontentcontrolbutton.hxx new file mode 100644 index 0000000000..6ca32974e1 --- /dev/null +++ b/sw/source/core/inc/dropdowncontentcontrolbutton.hxx @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include "contentcontrolbutton.hxx" + +class SwEditWin; +class SwContentControl; + +/** + * This button is shown when the cursor is inside a drop-down content control. + * The user can select a list item using this button while filling in a form. + */ +class SwDropDownContentControlButton final : public SwContentControlButton +{ +private: + std::unique_ptr m_xTreeView; + + DECL_LINK(ListBoxHandler, weld::TreeView&, bool); + + void InitDropdown(); + +public: + SwDropDownContentControlButton(SwEditWin* pEditWin, + const std::shared_ptr& pContentControl); + virtual ~SwDropDownContentControlButton() override; + + virtual void LaunchPopup() override; + virtual void DestroyPopup() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/dumpfilter.hxx b/sw/source/core/inc/dumpfilter.hxx new file mode 100644 index 0000000000..6ebc6e8c9e --- /dev/null +++ b/sw/source/core/inc/dumpfilter.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DUMPFILTER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DUMPFILTER_HXX + +#include +#include +#include +#include +#include + +namespace sw { + + /** Implementation of UNO export service to dump the layout of the + document as XML. This filter should be mostly be used for testing + purpose. + */ + class LayoutDumpFilter final : public cppu::WeakImplHelper + < + css::document::XFilter, + css::document::XExporter, + css::lang::XInitialization, + css::lang::XServiceInfo + > + { + css::uno::Reference< css::lang::XComponent > m_xSrcDoc; + + public: + LayoutDumpFilter(); + virtual ~LayoutDumpFilter() override; + + // XFilter + virtual sal_Bool SAL_CALL filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override; + virtual void SAL_CALL cancel( ) override; + + // XExporter + virtual void SAL_CALL setSourceDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/dview.hxx b/sw/source/core/inc/dview.hxx new file mode 100644 index 0000000000..cdcf3f2659 --- /dev/null +++ b/sw/source/core/inc/dview.hxx @@ -0,0 +1,125 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DVIEW_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DVIEW_HXX + +#include + +class FmFormModel; +class OutputDevice; +class SwViewShellImp; +class SwFrame; +class SwFlyFrame; +class SwAnchoredObject; +class SdrUndoManager; + +class SwDrawView final : public FmFormView +{ + Point m_aAnchorPoint; // anchor position + SwViewShellImp &m_rImp; // a view is always part of a shell + + const SwFrame *CalcAnchor(); + + /** determine maximal order number for a 'child' object of given 'parent' object + + The maximal order number will be determined on the current object + order hierarchy. It's the order number of the 'child' object with the + highest order number. The calculation can be influenced by parameter + <_pExclChildObj> - this 'child' object won't be considered. + + @param <_rParentObj> + input parameter - 'parent' object, for which the maximal order number + for its 'children' will be determined. + + @param <_pExclChildObj> + optional input parameter - 'child' object, which will not be considered + on the calculation of the maximal order number + */ + static sal_uInt32 GetMaxChildOrdNum( const SwFlyFrame& _rParentObj, + const SdrObject* _pExclChildObj = nullptr ); + + /** method to move 'repeated' objects of the given moved object to the + according level + + @param <_rMovedAnchoredObj> + input parameter - moved object, for which the 'repeated' ones have also + to be moved. + + @param <_rMovedChildrenObjs> + input parameter - data collection of moved 'child' objects - the 'repeated' + ones of these 'children' will also been moved. + */ + void MoveRepeatedObjs( const SwAnchoredObject& _rMovedAnchoredObj, + const std::vector& _rMovedChildObjs ) const; + + // add custom handles (used by other apps, e.g. AnchorPos) + virtual void AddCustomHdl() override; + + // override to allow extra handling when picking SwVirtFlyDrawObj's + using FmFormView::CheckSingleSdrObjectHit; + virtual SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, SdrSearchOptions nOptions, const SdrLayerIDSet* pMVisLay) const override; + + // Create a local UndoManager + std::unique_ptr createLocalTextUndoManager() override; + +public: + SwDrawView( + SwViewShellImp &rI, + FmFormModel& rFmFormModel, + OutputDevice* pOutDev); + + // from base class + virtual SdrObject* GetMaxToTopObj(SdrObject* pObj) const override; + virtual SdrObject* GetMaxToBtmObj(SdrObject* pObj) const override; + virtual void MarkListHasChanged() override; + + // #i7672# + // Override to reuse edit background color in active text edit view (OutlinerView) + virtual void ModelHasChanged() override; + + virtual void ObjOrderChanged( SdrObject* pObj, size_t nOldPos, + size_t nNewPos ) override; + virtual bool TakeDragLimit(SdrDragMode eMode, tools::Rectangle& rRect) const override; + virtual void MakeVisible( const tools::Rectangle&, vcl::Window &rWin ) override; + virtual void CheckPossibilities() override; + + const SwViewShellImp &Imp() const { return m_rImp; } + SwViewShellImp &Imp() { return m_rImp; } + + // anchor and Xor for dragging + void ShowDragAnchor(); + + virtual void DeleteMarked() override; + + void ValidateMarkList() { FlushComeBackTimer(); } + + // #i99665# + static bool IsAntiAliasing(); + + // method to replace marked/selected + // by its reference object for delete of selection and group selection + static void ReplaceMarkedDrawVirtObjs( SdrMarkView& _rMarkView ); + + /// See SdrMarkView::GetSfxViewShell(). + SfxViewShell* GetSfxViewShell() const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/environmentofanchoredobject.hxx b/sw/source/core/inc/environmentofanchoredobject.hxx new file mode 100644 index 0000000000..610bd934f8 --- /dev/null +++ b/sw/source/core/inc/environmentofanchoredobject.hxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_ENVIRONMENTOFANCHOREDOBJECT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_ENVIRONMENTOFANCHOREDOBJECT_HXX + +class SwFrame; +class SwLayoutFrame; + +namespace objectpositioning +{ +class SwEnvironmentOfAnchoredObject +{ +private: + const bool mbFollowTextFlow; + +public: + /** constructor + + @param _bFollowTextFlow + input parameter - indicates, if the anchored object, for which + this environment is instantiated, follow the text flow or not + */ + SwEnvironmentOfAnchoredObject(const bool _bFollowTextFlow); + + /** determine environment layout frame for possible horizontal object + positions respectively for alignment to 'page areas' + + this is, if object has to follow the text flow: + - cell frame, if anchored inside a cell + - fly frame, if anchored inside a fly frame + otherwise it's the page frame + + this is, if object hasn't to follow the text flow: + - page frame. + - no exception any more. Thus remove + parameter <_bForPageAlignment> + + @param _rHoriOrientFrame + input parameter - frame, at which the horizontal position is + oriented at (typically it's the anchor frame). + starting point for the search of the layout frame. + + @return reference to the layout frame, which determines the + horizontal environment the object has to be positioned in. + */ + const SwLayoutFrame& GetHoriEnvironmentLayoutFrame(const SwFrame& _rHoriOrientFrame) const; + + /** determine environment layout frame for possible vertical object + positions respectively for alignments to 'page areas' + + this is, if object has to follow the text flow: + - cell frame, if anchored inside a cell + - fly frame, if anchored inside a fly frame + - header/footer frame, if anchored inside page header/footer + - footnote frame, if anchored inside footnote + otherwise it's the document body frame + + this is, if object hasn't to follow the text flow: + - page frame. + - no exception any more. Thus remove + parameter <_bForPageAlignment> + + @param _rVertOrientFrame + input parameter - frame, at which the vertical position is + oriented at (typically it's the anchor frame). + starting point for the search of the layout frame. + + @return reference to the layout frame, which determines the + vertical environment the object has to be positioned in. + */ + const SwLayoutFrame& GetVertEnvironmentLayoutFrame(const SwFrame& _rVertOrientFrame) const; +}; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/fefly.hxx b/sw/source/core/inc/fefly.hxx new file mode 100644 index 0000000000..411bf75861 --- /dev/null +++ b/sw/source/core/inc/fefly.hxx @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_FEFLY_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_FEFLY_HXX + +class SwFlyFrame; +class SfxItemSet; + +bool sw_ChkAndSetNewAnchor(const SwFlyFrame& rFly, SfxItemSet& rSet); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/fieldhint.hxx b/sw/source/core/inc/fieldhint.hxx new file mode 100644 index 0000000000..27d31f86f6 --- /dev/null +++ b/sw/source/core/inc/fieldhint.hxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_FIELDHINT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_FIELDHINT_HXX + +#include + +class SwPaM; +class SwRootFrame; + +class SwFieldHint final : public SfxHint +{ +public: + SwPaM* m_pPaM; + SwRootFrame const* m_pLayout; + + SwFieldHint(SwPaM* const pPaM, SwRootFrame const* const pLayout) + : SfxHint(SfxHintId::SwField) + , m_pPaM(pPaM) + , m_pLayout(pLayout) + { + } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/flowfrm.hxx b/sw/source/core/inc/flowfrm.hxx new file mode 100644 index 0000000000..3d271613bf --- /dev/null +++ b/sw/source/core/inc/flowfrm.hxx @@ -0,0 +1,280 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_FLOWFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_FLOWFRM_HXX + +#include "frame.hxx" +#include "layfrm.hxx" +#include + +class SvxFormatKeepItem; +class SvxFormatBreakItem; +class SwPageFrame; +class SwRect; +class SwBorderAttrs; +class SwDoc; +class SwNode; +class SwNodeIndex; + +/** Base class that provides the general functionalities for frames that are + allowed at page breaks (flow) and shall continue on the next page (can be + split), e.g. paragraphs (ContentFrame) or tables (TabFrame). + + Some parts of these functionalities are implemented in FlowFrame while the + specific ones are done in the corresponding Frame classes. The FlowFrame has to + be seen as a base class. As such it is no Frame by itself and thus no direct + instances of FlowFrame can exist. + + Actually it is not even a real Frame. The obvious implementation would be a + FlowFrame that is virtually inherited from SwFrame and that works with its own + member data. Further classes would need to inherit from FlowFrame and (via + multiple base classes since the class tree splits exactly at the branch + from SwFrame to SwContentFrame and SwLayoutFrame) also virtually from SwFrame as + well. Unfortunately, this leads - besides problems with compilers and + debugging programs - to high additional costs, that we IMHO are not able to + afford nowadays. + + Hence, we use another technique: A FlowFrame keeps a reference to a SwFrame + - which it is actually itself - and they are friends. As a result, the + FlowFrame can work with the reference to the SwFrame instead of working with + its own this-pointer. + */ +class SAL_DLLPUBLIC_RTTI SAL_LOPLUGIN_ANNOTATE("crosscast") SwFlowFrame +{ + // PrepareMake is allowed to lock/unlock (robustness) + friend inline void PrepareLock ( SwFlowFrame * ); + friend inline void PrepareUnlock( SwFlowFrame * ); + friend inline void TableSplitRecalcLock( SwFlowFrame * ); + friend inline void TableSplitRecalcUnlock( SwFlowFrame * ); + // #i44049# + friend class SwObjectFormatterTextFrame; + friend class FlowFrameJoinLockGuard; + + // TableSel is allowed to reset the follow-bit + friend inline void UnsetFollow( SwFlowFrame *pFlow ); + + friend void MakeFrames( SwDoc *, SwNode &, SwNode & ); + + friend class SwNode2LayImpl; + + SwFrame& m_rThis; + + // helper methods for MoveSubTree() + static SwLayoutFrame *CutTree( SwFrame* ); + static bool PasteTree( SwFrame *, SwLayoutFrame *, SwFrame *, SwFrame* ); + + /** indicates that a backward move was done over multiple pages + + Needed for the interaction of _GetPrevxxx and MoveBwd so that multiple + pages can be skipped at the same time. In addition, it is evaluated by + the MoveBwd() method in TabFrame. + */ + static bool s_bMoveBwdJump; + + /** helper method to determine previous frame for calculation of the + upper space + + #i11860# + + @param _pProposedPrevFrame + optional input parameter - pointer to frame, which should be used + instead of the direct previous frame. + */ + const SwFrame* GetPrevFrameForUpperSpaceCalc_( const SwFrame* _pProposedPrevFrame = nullptr ) const; + + /** method to determine the upper space amount, which is considered for + the previous frame + + #i11860# + */ + SwTwips GetUpperSpaceAmountConsideredForPrevFrame() const; + + /** method to determine the upper space amount, which is considered for + the page grid + + #i11860# + */ + SwTwips GetUpperSpaceAmountConsideredForPageGrid_( + const SwTwips _nUpperSpaceWithoutGrid ) const; + +protected: + SwFlowFrame *m_pFollow; + SwFlowFrame *m_pPrecede; + + bool m_bLockJoin :1; // if true than joins (and thus deletes) are prohibited! + bool m_bUndersized:1; // I am smaller than needed + bool m_bFlyLock :1; // stop positioning of at-character flyframes + + // checks if forward flow makes sense to prevent infinite moves + inline bool IsFwdMoveAllowed() const; + // #i44049# - method has to check this property. + friend void CalcContent( SwLayoutFrame *pLay, bool bNoColl ); + bool IsKeepFwdMoveAllowed( bool bIgnoreMyOwnKeepValue = false ); // like above, forward flow for Keep. + + /** method to determine overlapping of an object that requests floating + + 0: no overlapping + 1: objects that are anchored at the FlowFrame overlap + 2: objects that are anchored somewhere else overlap + 3: both types of objects overlap + */ + sal_uInt8 BwdMoveNecessary( const SwPageFrame *pPage, const SwRect &rRect ); + + void LockJoin() { m_bLockJoin = true; } + void UnlockJoin() { m_bLockJoin = false; } + + bool CheckMoveFwd( bool& rbMakePage, bool bKeep, bool bIgnoreMyOwnKeepValue ); + bool MoveFwd( bool bMakePage, bool bPageBreak, bool bMoveAlways = false ); + bool MoveBwd( bool &rbReformat ); + virtual bool ShouldBwdMoved( SwLayoutFrame *pNewUpper, bool &rReformat )=0; + +public: + SwFlowFrame( SwFrame &rFrame ); + virtual ~SwFlowFrame(); + + const SwFrame& GetFrame() const { return m_rThis; } + SwFrame& GetFrame() { return m_rThis; } + + static bool IsMoveBwdJump() { return s_bMoveBwdJump; } + static void SetMoveBwdJump( bool bNew ){ s_bMoveBwdJump = bNew; } + + void SetUndersized( const bool bNew ) { m_bUndersized = bNew; } + bool IsUndersized() const { return m_bUndersized; } + + bool IsPrevObjMove() const; + + /** hook tree onto new parent with minimal operations and notifications */ + void MoveSubTree( SwLayoutFrame* pParent, SwFrame* pSibling = nullptr ); + + bool HasFollow() const { return m_pFollow != nullptr; } + bool IsFollow() const { return nullptr != m_pPrecede; } + bool IsAnFollow( const SwFlowFrame *pFlow ) const; + const SwFlowFrame *GetFollow() const { return m_pFollow; } + SwFlowFrame *GetFollow() { return m_pFollow; } + void SetFollow(SwFlowFrame *const pFollow); + + const SwFlowFrame *GetPrecede() const { return m_pPrecede; } + SwFlowFrame *GetPrecede() { return m_pPrecede; } + + bool IsJoinLocked() const { return m_bLockJoin; } + bool IsAnyJoinLocked() const { return m_bLockJoin || HasLockedFollow(); } + + bool IsPageBreak( bool bAct ) const; + bool IsColBreak( bool bAct ) const; + + /** method to determine if a Keep needs to be considered (Breaks!) */ + bool IsKeep(SvxFormatKeepItem const& rKeep, + SvxFormatBreakItem const& rBreak, + bool bBreakCheck = false ) const; + + bool HasLockedFollow() const; + + bool HasParaSpaceAtPages( bool bSct ) const; + + /** method to determine the upper space hold by the frame + + #i11860# + + @param _bConsiderGrid + optional input parameter - consider the page grid while calculating? + */ + SwTwips CalcUpperSpace( const SwBorderAttrs *pAttrs = nullptr, + const SwFrame* pPr = nullptr, + const bool _bConsiderGrid = true ) const; + + /** method to determine the upper space amount, which is considered for + the previous frame and the page grid, if option 'Use former object + positioning' is OFF + + #i11860# + */ + SwTwips GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid() const; + + /** calculation of lower space */ + SwTwips CalcLowerSpace( const SwBorderAttrs* _pAttrs = nullptr ) const; + + /** calculation of the additional space to be considered, if flow frame + is the last inside a table cell + + #i26250 + + @param _pAttrs + optional input parameter - border attributes of the flow frame. + Used for optimization, if caller has already determined the border + attributes. + + @return SwTwips + */ + SwTwips CalcAddLowerSpaceAsLastInTableCell( + const SwBorderAttrs* _pAttrs = nullptr ) const; + + void CheckKeep(); + + void SetFlyLock( bool bNew ){ m_bFlyLock = bNew; } + bool IsFlyLock() const { return m_bFlyLock; } + + bool ForbiddenForFootnoteCntFwd() const; + + // Casting of a Frame into a FlowFrame (if it is one, otherwise 0) + // These methods need to be customized in subclasses! + static SwFlowFrame *CastFlowFrame( SwFrame *pFrame ); + static const SwFlowFrame *CastFlowFrame( const SwFrame *pFrame ); +}; + +inline bool SwFlowFrame::IsFwdMoveAllowed() const +{ + return m_rThis.GetIndPrev() != nullptr; +} + +//use this to protect a SwLayoutFrame for a given scope from getting merged with +//its neighbour and thus deleted +class FlowFrameJoinLockGuard +{ +private: + SwFlowFrame *m_pFlow; + bool m_bOldJoinLocked; +public: + //JoinLock pParent for the lifetime of the Cut/Paste call, etc. to avoid + //SwSectionFrame::MergeNext removing the pParent we're trying to reparent + //into + FlowFrameJoinLockGuard(SwLayoutFrame* pFrame) + { + m_pFlow = SwFlowFrame::CastFlowFrame(pFrame); + if (m_pFlow) + { + m_bOldJoinLocked = m_pFlow->IsJoinLocked(); + m_pFlow->LockJoin(); + } + else + { + m_bOldJoinLocked = false; + } + } + + ~FlowFrameJoinLockGuard() + { + if (m_pFlow && !m_bOldJoinLocked) + m_pFlow->UnlockJoin(); + } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx new file mode 100644 index 0000000000..d1f14591bc --- /dev/null +++ b/sw/source/core/inc/flyfrm.hxx @@ -0,0 +1,316 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_FLYFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_FLYFRM_HXX + +#include "layfrm.hxx" +#include +#include +#include +#include + +class SwFormatAnchor; +class SwPageFrame; +class SwFormatFrameSize; +struct SwCursorMoveState; +class SwBorderAttrs; +class SwVirtFlyDrawObj; +class SwAttrSetChg; +namespace tools { class PolyPolygon; } +class SwFormat; +class SwViewShell; +class SwFEShell; +class SwWrtShell; +class SwFlyAtContentFrame; + + +/** search an anchor for paragraph bound frames starting from pOldAnch + + needed for dragging of objects bound to a paragraph for showing an anchor + indicator as well as for changing the anchor. + + implemented in layout/flycnt.cxx + */ +const SwContentFrame *FindAnchor( const SwFrame *pOldAnch, const Point &rNew, + const bool bBody = false ); + +/** calculate rectangle in that the object can be moved or rather be resized */ +bool CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, bool bMove = true ); + +enum class SwFlyFrameInvFlags : sal_uInt8 +{ + NONE = 0x00, + InvalidatePos = 0x01, + InvalidateSize = 0x02, + InvalidatePrt = 0x04, + SetNotifyBack = 0x08, + SetCompletePaint = 0x10, + InvalidateBrowseWidth = 0x20, + ClearContourCache = 0x40, + UpdateObjInSortedList = 0x80, +}; + +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +} + + +/** general base class for all free-flowing frames + + #i26791# - inherit also from +*/ +class SW_DLLPUBLIC SwFlyFrame : public SwLayoutFrame, public SwAnchoredObject +{ + // is allowed to lock, implemented in frmtool.cxx + friend void AppendObj(SwFrame *const pFrame, SwPageFrame *const pPage, SwFrameFormat *const pFormat, const SwFormatAnchor & rAnch); + friend void Notify( SwFlyFrame *, SwPageFrame *pOld, const SwRect &rOld, + const SwRect* pOldPrt ); + + void InitDrawObj(SwFrame const&); // these to methods are called in the + void FinitDrawObj(); // constructors + + void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, SwFlyFrameInvFlags &, + SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr ); + + using SwLayoutFrame::CalcRel; + +protected: + // Predecessor/Successor for chaining with text flow + SwFlyFrame *m_pPrevLink, *m_pNextLink; + static const SwFormatAnchor* GetAnchorFromPoolItem(const SfxPoolItem& rItem); + +private: + // It must be possible to block Content-bound flys so that they will be not + // formatted; in this case MakeAll() returns immediately. This is necessary + // for page changes during formatting. In addition, it is needed during + // the constructor call of the root object since otherwise the anchor will + // be formatted before the root is anchored correctly to a shell and + // because too much would be formatted as a result. + bool m_bLocked :1; + // true if the background of NotifyDTor needs to be notified at the end + // of a MakeAll() call. + bool m_bNotifyBack :1; + +protected: + // Pos, PrtArea or SSize have been invalidated - they will be evaluated + // again immediately because they have to be valid _at all time_. + // The invalidation is tracked here so that LayAction knows about it and + // can handle it properly. Exceptions prove the rule. + bool m_bInvalid :1; + + // true if the proposed height of an attribute is a minimal height + // (this means that the frame can grow higher if needed) + bool m_bMinHeight :1; + // true if the fly frame could not format position/size based on its + // attributes, e.g. because there was not enough space. + bool m_bHeightClipped :1; + bool m_bWidthClipped :1; + // If true then call only the format after adjusting the width (CheckClip); + // but the width will not be re-evaluated based on the attributes. + bool m_bFormatHeightOnly :1; + + bool m_bInCnt :1; ///< RndStdIds::FLY_AS_CHAR, anchored as character + bool m_bAtCnt :1; ///< RndStdIds::FLY_AT_PARA, anchored at paragraph + ///< or RndStdIds::FLY_AT_CHAR + bool m_bLayout :1; ///< RndStdIds::FLY_AT_PAGE, RndStdIds::FLY_AT_FLY, at page or at frame + bool m_bAutoPosition :1; ///< RndStdIds::FLY_AT_CHAR, anchored at character + bool m_bDeleted :1; ///< Anchored to a tracked deletion + size_t m_nAuthor; ///< Redline author index for colored crossing out + + friend class SwNoTextFrame; // is allowed to call NotifyBackground + + Point m_aContentPos; // content area's position relatively to Frame + bool m_bValidContentPos; + + virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override; + void MakePrtArea( const SwBorderAttrs &rAttrs ); + void MakeContentPos( const SwBorderAttrs &rAttrs ); + + void Lock() { m_bLocked = true; } + void Unlock() { m_bLocked = false; } + + Size CalcRel( const SwFormatFrameSize &rSz ) const; + + SwFlyFrame( SwFlyFrameFormat*, SwFrame*, SwFrame *pAnchor, bool bFollow = false ); + + virtual void DestroyImpl() override; + virtual ~SwFlyFrame() override; + + /** method to assure that anchored object is registered at the correct + page frame + */ + virtual void RegisterAtCorrectPage() override; + + virtual bool SetObjTop_( const SwTwips _nTop ) override; + virtual bool SetObjLeft_( const SwTwips _nLeft ) override; + + virtual SwRect GetObjBoundRect() const override; + virtual void SwClientNotify(const SwModify& rMod, const SfxHint& rHint) override; + + virtual const IDocumentDrawModelAccess& getIDocumentDrawModelAccess( ) override; + + SwTwips CalcContentHeight(const SwBorderAttrs *pAttrs, const SwTwips nMinHeight, const SwTwips nUL); + +public: + // #i26791# + virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&, + SwPrintData const*const pPrintData = nullptr ) const override; + virtual Size ChgSize( const Size& aNewSize ) override; + virtual bool GetModelPositionForViewPoint( SwPosition *, Point&, + SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override; + + virtual void CheckDirection( bool bVert ) override; + virtual void Cut() override; +#ifdef DBG_UTIL + virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override; +#endif + + SwTwips Shrink_( SwTwips, bool bTst ); + SwTwips Grow_ ( SwTwips, bool bTst ); + void Invalidate_( SwPageFrame const *pPage = nullptr ); + + bool FrameSizeChg( const SwFormatFrameSize & ); + + SwFlyFrame *GetPrevLink() const { return m_pPrevLink; } + SwFlyFrame *GetNextLink() const { return m_pNextLink; } + + static void ChainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow ); + static void UnchainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow ); + + SwFlyFrame *FindChainNeighbour( SwFrameFormat const &rFormat, SwFrame *pAnch = nullptr ); + + /// Is this fly allowed to split across pages? (Disabled by default.) + bool IsFlySplitAllowed() const; + + // #i26791# + const SwVirtFlyDrawObj* GetVirtDrawObj() const; + SwVirtFlyDrawObj *GetVirtDrawObj(); + void NotifyDrawObj(); + + void ChgRelPos( const Point &rAbsPos ); + bool IsInvalid() const { return m_bInvalid; } + void Invalidate() const { const_cast(this)->m_bInvalid = true; } + void Validate() const { const_cast(this)->m_bInvalid = false; } + + bool IsMinHeight() const { return m_bMinHeight; } + bool IsLocked() const { return m_bLocked; } + bool IsAutoPos() const { return m_bAutoPosition; } + bool IsFlyInContentFrame() const { return m_bInCnt; } + bool IsFlyFreeFrame() const { return m_bAtCnt || m_bLayout; } + bool IsFlyLayFrame() const { return m_bLayout; } + bool IsFlyAtContentFrame() const { return m_bAtCnt; } + bool IsDeleted() const { return m_bDeleted; } + void SetDeleted(bool bDeleted) { m_bDeleted = bDeleted; } + void SetAuthor( size_t nAuthor ) { m_nAuthor = nAuthor; } + size_t GetAuthor() const { return m_nAuthor; } + + bool IsNotifyBack() const { return m_bNotifyBack; } + void SetNotifyBack() { m_bNotifyBack = true; } + void ResetNotifyBack() { m_bNotifyBack = false; } + + bool IsClipped() const { return m_bHeightClipped || m_bWidthClipped; } + bool IsHeightClipped() const { return m_bHeightClipped; } + + bool IsLowerOf( const SwLayoutFrame* pUpper ) const; + bool IsUpperOf( const SwFlyFrame& _rLower ) const + { + return _rLower.IsLowerOf( this ); + } + + SwFrame *FindLastLower(); + + // #i13147# - add parameter <_bForPaint> to avoid load of + // the graphic during paint. Default value: false + bool GetContour( tools::PolyPolygon& rContour, + const bool _bForPaint = false ) const; + + // Paint on this shell (consider Preview, print flag, etc. recursively)? + static bool IsPaint( SdrObject *pObj, const SwViewShell *pSh ); + + /** SwFlyFrame::IsBackgroundTransparent + + determines if background of fly frame has to be drawn transparently + + definition found in /core/layout/paintfrm.cxx + + @return true, if background color is transparent or an existing background + graphic is transparent. + */ + bool IsBackgroundTransparent() const; + + void Chain( SwFrame* _pAnchor ); + void Unchain(); + void InsertCnt(); + void DeleteCnt(); + void InsertColumns(); + + // #i26791# - pure virtual methods of base class + virtual void MakeObjPos() override; + virtual void InvalidateObjPos() override; + virtual void RegisterAtPage(SwPageFrame&) override; + + virtual SwFrameFormat& GetFrameFormat() override; + virtual const SwFrameFormat& GetFrameFormat() const override; + + virtual SwRect GetObjRect() const override; + + /** method to determine if a format on the Writer fly frame is possible + + #i28701# + refine 'IsFormatPossible'-conditions of method + by: + format isn't possible, if Writer fly frame is locked resp. col-locked. + */ + virtual bool IsFormatPossible() const override; + static void GetAnchoredObjects( std::vector&, const SwFormat& rFormat ); + + // overwriting "SwFrameFormat *SwLayoutFrame::GetFormat" to provide the correct derived return type. + // (This is in order to skip on the otherwise necessary casting of the result to + // 'SwFlyFrameFormat *' after calls to this function. The casting is now done in this function.) + virtual const SwFlyFrameFormat *GetFormat() const override; + virtual SwFlyFrameFormat *GetFormat() override; + + virtual void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; + + virtual void Calc(vcl::RenderContext* pRenderContext) const override; + + const Point& ContentPos() const { return m_aContentPos; } + Point& ContentPos() { return m_aContentPos; } + + void InvalidateContentPos(); + + void SelectionHasChanged(SwFEShell* pShell); + bool IsShowUnfloatButton(SwWrtShell* pWrtSh) const; + + // For testing only (see uiwriter) + void ActiveUnfloatButton(SwWrtShell* pWrtSh); + + virtual const SwFlyFrame* DynCastFlyFrame() const override; + virtual SwFlyFrame* DynCastFlyFrame() override; + + SwFlyAtContentFrame* DynCastFlyAtContentFrame(); + +private: + void UpdateUnfloatButton(SwWrtShell* pWrtSh, bool bShow) const; + void PaintDecorators() const; +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/flyfrms.hxx b/sw/source/core/inc/flyfrms.hxx new file mode 100644 index 0000000000..051d514fd3 --- /dev/null +++ b/sw/source/core/inc/flyfrms.hxx @@ -0,0 +1,254 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_FLYFRMS_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_FLYFRMS_HXX + +#include + +#include + +#include "flyfrm.hxx" +#include "flowfrm.hxx" + +class SwNoTextFrame; + +double getLocalFrameRotation_from_SwNoTextFrame(const SwNoTextFrame& rNoTextFrame); + +// Base class for those Flys that can "move freely" or better that are not +// bound in Content. +class SW_DLLPUBLIC SwFlyFreeFrame : public SwFlyFrame +{ +private: + // #i34753# - flag for at-page anchored Writer fly frames + // to prevent a positioning - call of method -, if Writer + // fly frame is already clipped during its format by the object formatter. + bool mbNoMakePos : 1; + + // #i37068# - flag to prevent move in method + bool mbNoMoveOnCheckClip : 1; + + SwRect maUnclippedFrame; + + // RotateFlyFrame3 add TransformableSwFrame + std::unique_ptr< TransformableSwFrame > mpTransformableSwFrame; + + void CheckClip( const SwFormatFrameSize &rSz ); //'Emergency' Clipping. + + /** determines, if direct environment of fly frame has 'auto' size + + #i17297# + start with anchor frame and search for a header, footer, row or fly frame + stopping at page frame. + return , if such a frame is found and it has 'auto' size. + otherwise is returned. + + @return boolean indicating, that direct environment has 'auto' size + */ + bool HasEnvironmentAutoSize() const; + + // RotateFlyFrame3 - Support for outer Frame of a SwGrfNode + // Only for local data extraction. To uniquely access information + // for local transformation, use getFrameArea(Print)Transformation + double getLocalFrameRotation() const; + +protected: + // #i28701# - new friend class for access to + // method + friend class SwFlyNotify; + virtual void NotifyBackground( SwPageFrame *pPage, + const SwRect& rRect, PrepareHint eHint) override; + SwFlyFreeFrame( SwFlyFrameFormat*, SwFrame*, SwFrame *pAnchor, bool bFollow = false ); + + virtual void DestroyImpl() override; + virtual ~SwFlyFreeFrame() override; + +public: + // #i28701# + + virtual void MakeAll(vcl::RenderContext* pRenderContext) override; + + // #i37068# - accessors for member + void SetNoMoveOnCheckClip( const bool _bNewNoMoveOnCheckClip ) + { + mbNoMoveOnCheckClip = _bNewNoMoveOnCheckClip; + } + bool IsNoMoveOnCheckClip() const + { + return mbNoMoveOnCheckClip; + } + // #i34753# - accessors for member + void SetNoMakePos( const bool _bNoMakePos ) + { + if ( IsFlyLayFrame() ) + { + mbNoMakePos = _bNoMakePos; + } + } + bool IsNoMakePos() const + { + if ( IsFlyLayFrame() ) + { + return mbNoMakePos; + } + else + { + return false; + } + } + + const SwRect& GetUnclippedFrame( ) const + { + if ( maUnclippedFrame.HasArea( ) ) + return maUnclippedFrame; + else + return getFrameArea(); + } + + /** method to determine, if a format on the Writer fly frame is possible + + #i28701# + refine 'IsFormatPossible'-conditions of method + by: + format isn't possible, if Writer fly frame isn't registered at a page frame + and its anchor frame isn't inside another Writer fly frame. + */ + virtual bool IsFormatPossible() const override; + + // RotateFlyFrame3 - Support for Transformations + bool isTransformableSwFrame() const { return bool(mpTransformableSwFrame); } + TransformableSwFrame* getTransformableSwFrame() { return mpTransformableSwFrame.get(); } + const TransformableSwFrame* getTransformableSwFrame() const { return mpTransformableSwFrame.get(); } + + // RotateFlyFrame3 - Support for AutoContour + bool supportsAutoContour() const; + + // RotateFlyFrame3 - Support for Transformations + virtual basegfx::B2DHomMatrix getFrameAreaTransformation() const override; + virtual basegfx::B2DHomMatrix getFramePrintAreaTransformation() const override; + + // RotateFlyFrame3 - Support for Transformations + virtual void transform_translate(const Point& rOffset) override; +}; + +/// Flys that are bound to layout frames (to-frame) and not to/as content +class SwFlyLayFrame final: public SwFlyFreeFrame +{ +public: + // #i28701# + + SwFlyLayFrame( SwFlyFrameFormat*, SwFrame*, SwFrame *pAnchor ); + + virtual void RegisterAtPage(SwPageFrame &) override; + virtual void SwClientNotify(const SwModify&, const SfxHint&) override; +}; + +/// Flys that are anchored to content (at-para, at-char) but not in content (as-char). +class SW_DLLPUBLIC SwFlyAtContentFrame final: public SwFlyFreeFrame, public SwFlowFrame +{ + virtual void MakeAll(vcl::RenderContext* pRenderContext) override; + + // #i28701# + virtual bool InvalidationAllowed( const InvalidationType _nInvalid ) const override; + + /** method to assure that anchored object is registered at the correct + page frame + + #i28701# + */ + virtual void RegisterAtCorrectPage() override; + virtual void RegisterAtPage(SwPageFrame &) override; + virtual void SwClientNotify(const SwModify&, const SfxHint&) override; + bool ShouldBwdMoved(SwLayoutFrame* pNewUpper, bool& rReformat) override; + +public: + // #i28701# + + SwFlyAtContentFrame( SwFlyFrameFormat*, SwFrame*, SwFrame *pAnchor, bool bFollow = false ); + SwFlyAtContentFrame(SwFlyAtContentFrame& rPrecede); + ~SwFlyAtContentFrame(); + + void SetAbsPos( const Point &rNew ); + + // #i26791# + virtual void MakeObjPos() override; + + /** method to determine, if a format on the Writer fly frame is possible + + #i28701# + refine 'IsFormatPossible'-conditions of method + by: + format isn't possible, if method is already in progress. + */ + virtual bool IsFormatPossible() const override; + const SwFlyAtContentFrame* GetFollow() const; + SwFlyAtContentFrame* GetFollow(); + const SwFlyAtContentFrame* GetPrecede() const; + SwFlyAtContentFrame* GetPrecede(); + /// Like Cut(), except that follow chaining is maintained. + void DelEmpty(); + bool IsWrapOnAllPages() const; + void dumpAsXmlAttributes(xmlTextWriterPtr pWriter) const override; +}; + +/// Flys that are anchored as a character in the content. +class SwFlyInContentFrame final: public SwFlyFrame +{ + Point m_aRef; // relative to this point AbsPos is being calculated + + virtual void DestroyImpl() override; + virtual ~SwFlyInContentFrame() override; + + virtual void NotifyBackground(SwPageFrame *pPage, const SwRect& rRect, PrepareHint eHint) override; + virtual void MakeAll(vcl::RenderContext* pRenderContext) override; + virtual void SwClientNotify(const SwModify&, const SfxHint&) override; + +public: + // #i28701# + + SwFlyInContentFrame( SwFlyFrameFormat*, SwFrame*, SwFrame *pAnchor ); + + virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override; + + void SetRefPoint( const Point& rPoint, const Point &rRelAttr, + const Point &rRelPos ); + const Point &GetRefPoint() const { return m_aRef; } + Point const & GetRelPos() const; + + // (26.11.93, see tabfrm.hxx, but might also be valid for others) + // For creation of a Fly after a FlyCnt was created _and_ inserted. + // Must be called by creator because can be pasted only after creation. + // Sometimes the page for registering the Flys is not visible until then + // as well. + void RegistFlys(); + + //see layact.cxx + void AddRefOfst( tools::Long nOfst ) { m_aRef.AdjustY( nOfst ); } + void AddRefOfst(Point const& rOfst) { m_aRef += rOfst; } + + // #i26791# + virtual void MakeObjPos() override; + + // invalidate anchor frame on invalidation of the position, because the + // position is calculated during the format of the anchor frame + virtual void ActionOnInvalidation( const InvalidationType _nInvalid ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/fntcache.hxx b/sw/source/core/inc/fntcache.hxx new file mode 100644 index 0000000000..bea6663e14 --- /dev/null +++ b/sw/source/core/inc/fntcache.hxx @@ -0,0 +1,146 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_FNTCACHE_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_FNTCACHE_HXX + +#include + +#include +#include + +#include +#include +#include +#include +#include "swcache.hxx" +#include "TextFrameIndex.hxx" + +class FontMetric; +class SwFntObj; +class SwDrawTextInfo; +class SwViewShell; +class SwSubFont; +class MapMode; + +class SwFntCache : public SwCache +{ +public: + SwFntCache() : SwCache(50 +#ifdef DBG_UTIL + , OString(RTL_CONSTASCII_STRINGPARAM("Global Font-Cache pFntCache")) +#endif + ) {} + + inline SwFntObj *First( ); + static inline SwFntObj *Next( SwFntObj *pFntObj); + void Flush(); +}; + +// Font cache, global variable, created/destroyed in txtinit.cxx +extern SwFntCache *pFntCache; +extern SwFntObj *pLastFont; + +class SwFntObj final : public SwCacheObj +{ + friend class SwFntAccess; + friend void InitCore(); + friend void FinitCore(); + + vcl::Font m_aFont; + vcl::Font *m_pScrFont; + vcl::Font *m_pPrtFont; + VclPtr m_pPrinter; + sal_uInt16 m_nGuessedLeading; + sal_uInt16 m_nExtLeading; + sal_uInt16 m_nScrAscent; + sal_uInt16 m_nPrtAscent; + sal_uInt16 m_nScrHeight; + sal_uInt16 m_nPrtHeight; + sal_uInt16 m_nPropWidth; + sal_uInt16 m_nScrHangingBaseline; + sal_uInt16 m_nPrtHangingBaseline; + sal_uInt16 m_nZoom; + bool m_bSymbol : 1; + bool m_bPaintBlank : 1; + + static tools::Long s_nPixWidth; + static MapMode *s_pPixMap; + +public: + SwFntObj( const SwSubFont &rFont, std::uintptr_t nFontCacheId, + SwViewShell const *pSh ); + + virtual ~SwFntObj() override; + + vcl::Font *GetScrFont() { return m_pScrFont; } + vcl::Font& GetFont() { return m_aFont; } + const vcl::Font& GetFont() const { return m_aFont; } + + sal_uInt16 GetGuessedLeading() const { return m_nGuessedLeading; } + sal_uInt16 GetExternalLeading() const { return m_nExtLeading; } + + sal_uInt16 GetFontAscent( const SwViewShell *pSh, const OutputDevice& rOut ); + sal_uInt16 GetFontHeight( const SwViewShell *pSh, const OutputDevice& rOut ); + sal_uInt16 GetFontLeading( const SwViewShell *pSh, const OutputDevice& rOut ); + sal_uInt16 GetFontHangingBaseline( const SwViewShell *pSh, const OutputDevice& rOut ); + + void GuessLeading( const SwViewShell& rSh, const FontMetric& rMet ); + + void SetDevFont( const SwViewShell *pSh, OutputDevice& rOut ); + OutputDevice* GetPrt() const { return m_pPrinter; } + sal_uInt16 GetZoom() const { return m_nZoom; } + sal_uInt16 GetPropWidth() const { return m_nPropWidth; } + bool IsSymbol() const { return m_bSymbol; } + + void DrawText( SwDrawTextInfo &rInf ); + /// determine the TextSize (of the printer) + Size GetTextSize( SwDrawTextInfo &rInf ); + TextFrameIndex GetModelPositionForViewPoint(SwDrawTextInfo &rInf); + + void CreateScrFont( const SwViewShell& rSh, const OutputDevice& rOut ); + void CreatePrtFont( const OutputDevice& rOut ); +}; + +SwFntObj *SwFntCache::First( ) +{ + return static_cast(SwCache::First()); +} + +SwFntObj *SwFntCache::Next( SwFntObj *pFntObj) +{ + return static_cast(SwCache::Next( pFntObj )); +} + +class SwFntAccess final : public SwCacheAccess +{ + SwViewShell const *m_pShell; + + virtual SwCacheObj *NewObj( ) override; + +public: + SwFntAccess( const void*& rnFontCacheId, sal_uInt16 &rIndex, const void *pOwner, + SwViewShell const *pShell, + bool bCheck = false ); + SwFntObj* Get() { return static_cast( SwCacheAccess::Get() ); } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/fntcap.hxx b/sw/source/core/inc/fntcap.hxx new file mode 100644 index 0000000000..0b1cee67cd --- /dev/null +++ b/sw/source/core/inc/fntcap.hxx @@ -0,0 +1,37 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_FNTCAP_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_FNTCAP_HXX + +#include +#include "TextFrameIndex.hxx" + +class SwFont; + +TextFrameIndex sw_CalcCaseMap( const SwFont& rFnt, + const OUString& rOrigString, + TextFrameIndex nOfst, + TextFrameIndex nLen, + TextFrameIndex nIdx ); + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx new file mode 100644 index 0000000000..d57654f6a9 --- /dev/null +++ b/sw/source/core/inc/frame.hxx @@ -0,0 +1,1446 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_FRAME_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_FRAME_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace drawinglayer::processor2d { class BaseProcessor2D; } + +class SwLayoutFrame; +class SwRootFrame; +class SwPageFrame; +class SwBodyFrame; +class SwFlyFrame; +class SwSectionFrame; +class SwFootnoteFrame; +class SwFootnoteBossFrame; +class SwTabFrame; +class SwRowFrame; +class SwContentFrame; +class SwAttrSet; +class Color; +class SwBorderAttrs; +class SwCache; +class SvxBrushItem; +class SvxFormatBreakItem; +class SwFormatPageDesc; +class SwSelectionList; +struct SwPosition; +struct SwCursorMoveState; +class SwFormat; +class SwPrintData; +class SwSortedObjs; +class SwAnchoredObject; +enum class SvxFrameDirection; +class IDocumentDrawModelAccess; +class SwTextFrame; + +// Each FrameType is represented here as a bit. +// The bits must be set in a way that it can be determined with masking of +// which kind of FrameType an instance is _and_ from what classes it was derived. +// Each frame has in its base class a member that must be set by the +// constructors accordingly. +enum class SwFrameType +{ + None = 0x0000, + Root = 0x0001, + Page = 0x0002, + Column = 0x0004, + Header = 0x0008, + Footer = 0x0010, + FtnCont = 0x0020, + Ftn = 0x0040, + Body = 0x0080, + Fly = 0x0100, + Section = 0x0200, +// UNUSED 0x0400 + Tab = 0x0800, + Row = 0x1000, + Cell = 0x2000, + Txt = 0x4000, + NoTxt = 0x8000, +}; + +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +}; + +// for internal use some common combinations +#define FRM_LAYOUT SwFrameType(0x3bFF) +#define FRM_ALL SwFrameType(0xfbff) +#define FRM_CNTNT (SwFrameType::Txt | SwFrameType::NoTxt) +#define FRM_FTNBOSS (SwFrameType::Page | SwFrameType::Column) +#define FRM_ACCESSIBLE (SwFrameType::Root | SwFrameType::Page | SwFrameType::Header | SwFrameType::Footer | SwFrameType::Ftn | SwFrameType::Fly | SwFrameType::Tab | SwFrameType::Cell | SwFrameType::Txt) +#define FRM_NEIGHBOUR (SwFrameType::Column | SwFrameType::Cell) +#define FRM_NOTE_VERT (SwFrameType::FtnCont | SwFrameType::Ftn | SwFrameType::Section | SwFrameType::Tab | SwFrameType::Row | SwFrameType::Cell | SwFrameType::Txt) +#define FRM_HEADFOOT (SwFrameType::Header | SwFrameType::Footer) +#define FRM_BODYFTNC (SwFrameType::FtnCont | SwFrameType::Body) + +// for GetNextLeaf/GetPrevLeaf. +enum MakePageType +{ + MAKEPAGE_NONE, // do not create page/footnote + MAKEPAGE_APPEND, // only append page if needed + MAKEPAGE_INSERT, // add or append page if needed + MAKEPAGE_FTN, // add footnote if needed + MAKEPAGE_NOSECTION // Don't create section frames +}; + +namespace drawinglayer::attribute { + class SdrAllFillAttributesHelper; + typedef std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr; +} + +/// Helper class to isolate geometry-defining members of SwFrame +/// and to control their accesses. Moved to own class to have no +/// hidden accesses to 'private' members anymore. +/// +/// Added most important flags about the state of this geometric +/// information and if it is valid or not +class SAL_DLLPUBLIC_RTTI SwFrameAreaDefinition +{ +private: + friend void FriendHackInvalidateRowFrame(SwFrameAreaDefinition &); + + // The absolute position and size of the SwFrame in the document. + // This values are set by the layouter implementations + SwRect maFrameArea; + + // The 'inner' Frame Area defined by a SwRect relative to FrameArea: + // When identical to FrameArea, Pos() will be (0, 0) and Size identical. + SwRect maFramePrintArea; + + // bitfield + bool mbFrameAreaPositionValid : 1; + bool mbFrameAreaSizeValid : 1; + bool mbFramePrintAreaValid : 1; + + // #i65250# + // frame ID is now in general available - used for layout loop control + static sal_uInt32 snLastFrameId; + const sal_uInt32 mnFrameId; + +protected: + // write access to mb*Valid flags + void setFrameAreaPositionValid(bool bNew); + void setFrameAreaSizeValid(bool bNew); + void setFramePrintAreaValid(bool bNew); + +public: + SwFrameAreaDefinition(); + virtual ~SwFrameAreaDefinition(); + + // read access to mb*Valid flags + bool isFrameAreaPositionValid() const { return mbFrameAreaPositionValid; } + bool isFrameAreaSizeValid() const { return mbFrameAreaSizeValid; } + bool isFramePrintAreaValid() const { return mbFramePrintAreaValid; } + + // syntactic sugar: test whole FrameAreaDefinition + bool isFrameAreaDefinitionValid() const { return isFrameAreaPositionValid() && isFrameAreaSizeValid() && isFramePrintAreaValid(); } + + // #i65250# + sal_uInt32 GetFrameId() const { return mnFrameId; } + + // read accesses to FrameArea definitions - only const access allowed. + // Do *not* const_cast results, it is necessary to track changes. use + // the below offered WriteAccess helper classes instead + const SwRect& getFrameArea() const { return maFrameArea; } + const SwRect& getFramePrintArea() const { return maFramePrintArea; } + + // helper class(es) for FrameArea manipulation. These + // have to be used to apply changes to FrameAreas. They hold a copy of the + // SwRect for manipulation. It gets written back at destruction. Thus, this + // mechanism depends on scope usage, take care. It prevents errors using + // different instances of SwFrame in get/set methods which is more safe + class FrameAreaWriteAccess : public SwRect + { + private: + SwFrameAreaDefinition& mrTarget; + + FrameAreaWriteAccess(const FrameAreaWriteAccess&) = delete; + FrameAreaWriteAccess& operator=(const FrameAreaWriteAccess&) = delete; + + public: + FrameAreaWriteAccess(SwFrameAreaDefinition& rTarget) : SwRect(rTarget.getFrameArea()), mrTarget(rTarget) {} + ~FrameAreaWriteAccess(); + void setSwRect(const SwRect& rNew) { *static_cast< SwRect* >(this) = rNew; } + }; + + // same helper for FramePrintArea + class FramePrintAreaWriteAccess : public SwRect + { + private: + SwFrameAreaDefinition& mrTarget; + + FramePrintAreaWriteAccess(const FramePrintAreaWriteAccess&) = delete; + FramePrintAreaWriteAccess& operator=(const FramePrintAreaWriteAccess&) = delete; + + public: + FramePrintAreaWriteAccess(SwFrameAreaDefinition& rTarget) : SwRect(rTarget.getFramePrintArea()), mrTarget(rTarget) {} + ~FramePrintAreaWriteAccess(); + void setSwRect(const SwRect& rNew) { *static_cast< SwRect* >(this) = rNew; } + }; + + // RotateFlyFrame3 - Support for Transformations + // Hand out the Transformations for the current FrameAreaDefinition + // for the FrameArea and FramePrintArea. + // FramePrintArea is not relative to FrameArea in this + // transformation representation (to make it easier to use and understand). + // There is no 'set' method since SwFrame is a layout object. For + // some cases rotation will be included (used for SwGrfNode in inner + // SwFrame of a SwFlyFrame) + virtual basegfx::B2DHomMatrix getFrameAreaTransformation() const; + virtual basegfx::B2DHomMatrix getFramePrintAreaTransformation() const; + + // RotateFlyFrame3 - Support for Transformations + // Modify current transformations by applying given translation + virtual void transform_translate(const Point& rOffset); +}; + +/// RotateFlyFrame3: Helper class when you want to make your SwFrame derivate +/// transformable. It provides some tooling to do so. To use, add as member +/// (see e.g. SwFlyFreeFrame which uses 'std::unique_ptr< TransformableSwFrame >') +class TransformableSwFrame +{ +private: + // The SwFrameAreaDefinition to work on + SwFrameAreaDefinition& mrSwFrameAreaDefinition; + + // FrameAreaTransformation and FramePrintAreaTransformation + // !identity when needed (translate/scale is used (e.g. rotation)) + basegfx::B2DHomMatrix maFrameAreaTransformation; + basegfx::B2DHomMatrix maFramePrintAreaTransformation; + +public: + TransformableSwFrame(SwFrameAreaDefinition& rSwFrameAreaDefinition) + : mrSwFrameAreaDefinition(rSwFrameAreaDefinition), + maFrameAreaTransformation(), + maFramePrintAreaTransformation() + { + } + + // get SwFrameArea in transformation form + const basegfx::B2DHomMatrix& getLocalFrameAreaTransformation() const + { + return maFrameAreaTransformation; + } + + // get SwFramePrintArea in transformation form + const basegfx::B2DHomMatrix& getLocalFramePrintAreaTransformation() const + { + return maFramePrintAreaTransformation; + } + + // Helpers to re-create the untransformed SwRect(s) originally + // in the SwFrameAreaDefinition, based on the current Transformations. + SwRect getUntransformedFrameArea() const; + SwRect getUntransformedFramePrintArea() const; + + // Helper method to re-create FrameAreaTransformations based on the + // current FrameAreaDefinition transformed by given rotation and Center + void createFrameAreaTransformations( + double fRotation, + const basegfx::B2DPoint& rCenter); + + // Tooling method to reset the SwRect(s) in the current + // SwFrameAreaDefinition which are already adapted to + // Transformation back to the untransformed state, using + // the getUntransformedFrame*Area calls above when needed. + // Only the SwRect(s) are changed back, not the transformations. + void restoreFrameAreas(); + + // Re-Creates the SwRect(s) as BoundAreas based on the current + // set Transformations. + void adaptFrameAreasToTransformations(); + + // Modify current definitions by applying the given transformation + void transform(const basegfx::B2DHomMatrix& aTransform); +}; + +enum class SwFrameInvFlags : sal_uInt8 +{ + NONE = 0x00, + InvalidatePrt = 0x01, + InvalidateSize = 0x02, + InvalidatePos = 0x04, + SetCompletePaint = 0x08, + NextInvalidatePos = 0x10, + NextSetCompletePaint = 0x20, +}; + +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +} + +/** + * Base class of the Writer layout elements. + * + * This includes not only fly frames, but everything down to the paragraph + * level: pages, headers, footers, etc. (Inside a paragraph SwLinePortion + * instances are used.) + */ +class SW_DLLPUBLIC SwFrame : public SwFrameAreaDefinition, public SwClient, public SfxBroadcaster +{ + // the hidden Frame + friend class SwFlowFrame; + friend class SwLayoutFrame; + friend class SwLooping; + friend class SwDeletionChecker; // for GetDep() + + // voids lower during creation of a column + friend SwFrame *SaveContent( SwLayoutFrame *, SwFrame* pStart ); + friend void RestoreContent( SwFrame *, SwLayoutFrame *, SwFrame *pSibling ); + + // for validating a mistakenly invalidated one in SwContentFrame::MakeAll + friend void ValidateSz( SwFrame *pFrame ); + // implemented in text/txtftn.cxx, prevents Footnote oscillation + friend void ValidateText( SwFrame *pFrame ); + + friend void MakeNxt( SwFrame *pFrame, SwFrame *pNxt ); + + // cache for (border) attributes + static SwCache *spCache; + + SwRootFrame *mpRoot; + SwLayoutFrame *mpUpper; + SwFrame *mpNext; + SwFrame *mpPrev; + + // sw_redlinehide: hide these dangerous SwClient functions + using SwClient::GetRegisteredInNonConst; + using SwClient::GetRegisteredIn; + + SwFrame *FindNext_(); + SwFrame *FindPrev_(); + + /** method to determine next content frame in the same environment + for a flow frame (content frame, table frame, section frame) + + #i27138# - adding documentation: + Travelling downwards through the layout to determine the next content + frame in the same environment. There are several environments in a + document, which form a closed context regarding this function. These + environments are: + - Each page header + - Each page footer + - Each unlinked fly frame + - Each group of linked fly frames + - All footnotes + - All document body frames + #i27138# - adding parameter <_bInSameFootnote> + Its default value is . If its value is , the environment + 'All footnotes' is no longer treated. Instead each footnote is treated + as an own environment. + + @param _bInSameFootnote + input parameter - boolean indicating, that the found next content + frame has to be in the same footnote frame. This parameter is only + relevant for flow frames in footnotes. + + @return SwContentFrame* + pointer to the found next content frame. It's NULL, if none exists. + */ + SwContentFrame* FindNextCnt_( const bool _bInSameFootnote ); + + /** method to determine previous content frame in the same environment + for a flow frame (content frame, table frame, section frame) + + #i27138# + Travelling upwards through the layout to determine the previous content + frame in the same environment. There are several environments in a + document, which form a closed context regarding this function. These + environments are: + - Each page header + - Each page footer + - Each unlinked fly frame + - Each group of linked fly frames + - All footnotes + - All document body frames + #i27138# - adding parameter <_bInSameFootnote> + Its default value is . If its value is , the environment + 'All footnotes' is no longer treated. Instead each footnote is treated + as an own environment. + + The found previous content frame has to be in the same footnote frame. This is only + relevant for flow frames in footnotes. + + @return SwContentFrame* + pointer to the found previous content frame. It's NULL, if none exists. + */ + SwContentFrame* FindPrevCnt_(); + + void UpdateAttrFrame( const SfxPoolItem*, const SfxPoolItem*, SwFrameInvFlags & ); + SwFrame* GetIndNext_(); + void SetDirFlags( bool bVert ); + + const SwLayoutFrame* ImplGetNextLayoutLeaf( bool bFwd ) const; + + SwPageFrame* ImplFindPageFrame(); + +protected: + std::unique_ptr m_pDrawObjs; // draw objects, can be null + SwFrameType mnFrameType; //Who am I? + + bool mbInDtor : 1; + bool mbInvalidR2L : 1; + bool mbDerivedR2L : 1; + bool mbRightToLeft : 1; + bool mbInvalidVert : 1; + bool mbDerivedVert : 1; + bool mbVertical : 1; + + bool mbVertLR : 1; + bool mbVertLRBT : 1; + + bool mbValidLineNum : 1; + bool mbFixSize : 1; + + // if true, frame will be painted completely even content was changed + // only partially. For ContentFrames a border (from Action) will exclusively + // painted if is true. + bool mbCompletePaint : 1; + + bool mbRetouche : 1; // frame is responsible for retouching + + bool mbInfInvalid : 1; // InfoFlags are invalid + bool mbInfBody : 1; // Frame is in document body + bool mbInfTab : 1; // Frame is in a table + bool mbInfFly : 1; // Frame is in a Fly + bool mbInfFootnote : 1; // Frame is in a footnote + bool mbInfSct : 1; // Frame is in a section + bool mbColLocked : 1; // lock Grow/Shrink for column-wise section + // or fly frames, will be set in Format + bool m_isInDestroy : 1; + int mnForbidDelete; + + void ColLock() { mbColLocked = true; } + void ColUnlock() { mbColLocked = false; } + + virtual void DestroyImpl(); + virtual ~SwFrame() override; + + // Only used by SwRootFrame Ctor to get 'this' into mpRoot... + void setRootFrame( SwRootFrame* pRoot ) { mpRoot = pRoot; } + + SwPageFrame *InsertPage( SwPageFrame *pSibling, bool bFootnote ); + void PrepareMake(vcl::RenderContext* pRenderContext); + void OptPrepareMake(); + /// Calculates the frame area position, in case it's invalid. The frame area size and the print + /// area is not considered here. + virtual void MakePos(); + // Format next frame of table frame to assure keeping attributes. + // In case of nested tables method is called to + // avoid formatting of superior table frame. + friend SwFrame* sw_FormatNextContentForKeep( SwTabFrame* pTabFrame ); + + virtual void MakeAll(vcl::RenderContext* pRenderContext) = 0; + // adjust frames of a page + SwTwips AdjustNeighbourhood( SwTwips nDiff, bool bTst = false ); + + // change only frame size not the size of PrtArea + virtual SwTwips ShrinkFrame( SwTwips, bool bTst = false, bool bInfo = false ) = 0; + virtual SwTwips GrowFrame ( SwTwips, bool bTst = false, bool bInfo = false ) = 0; + + /// use these so we can grep for SwFrame's GetRegisteredIn accesses + /// beware that SwTextFrame may return sw::WriterMultiListener + sw::BroadcastingModify* GetDep() + { return static_cast(GetRegisteredInNonConst()); } + const sw::BroadcastingModify* GetDep() const + { return static_cast(GetRegisteredIn()); } + + SwFrame( sw::BroadcastingModify*, SwFrame* ); + + void CheckDir( SvxFrameDirection nDir, bool bVert, bool bOnlyBiDi, bool bBrowse ); + + /** enumeration for the different invalidations + #i28701# + */ + enum InvalidationType + { + INVALID_SIZE, INVALID_PRTAREA, INVALID_POS, INVALID_LINENUM, INVALID_ALL + }; + + /** method to determine, if an invalidation is allowed. + #i28701 + */ + virtual bool InvalidationAllowed( const InvalidationType _nInvalid ) const; + + /** method to perform additional actions on an invalidation + + #i28701# + Method has *only* to contain actions, which has to be performed on + *every* assignment of the corresponding flag to . + */ + virtual void ActionOnInvalidation( const InvalidationType _nInvalid ); + + // draw shadow and borders + void PaintShadow( const SwRect&, SwRect&, const SwBorderAttrs& ) const; + virtual void SwClientNotify(const SwModify&, const SfxHint&) override; + + virtual const IDocumentDrawModelAccess& getIDocumentDrawModelAccess( ); + +public: + virtual css::uno::Sequence< css::style::TabStop > GetTabStopInfo( SwTwips ) + { + return css::uno::Sequence< css::style::TabStop >(); + } + + + SwFrameType GetType() const { return mnFrameType; } + + static SwCache &GetCache() { return *spCache; } + static SwCache *GetCachePtr() { return spCache; } + static void SetCache( SwCache *pNew ) { spCache = pNew; } + + // change PrtArea size and FrameSize + SwTwips Shrink( SwTwips, bool bTst = false, bool bInfo = false ); + SwTwips Grow ( SwTwips, bool bTst = false, bool bInfo = false ); + + // different methods for inserting in layout tree (for performance reasons) + + // insert before pBehind or at the end of the chain below mpUpper + void InsertBefore( SwLayoutFrame* pParent, SwFrame* pBehind ); + // insert after pBefore or at the beginning of the chain below mpUpper + void InsertBehind( SwLayoutFrame *pParent, SwFrame *pBefore ); + // insert before pBehind or at the end of the chain while considering + // the siblings of pSct + bool InsertGroupBefore( SwFrame* pParent, SwFrame* pWhere, SwFrame* pSct ); + void RemoveFromLayout(); + + // For internal use only - who ignores this will be put in a sack and has + // to stay there for two days + // Does special treatment for Get_[Next|Prev]Leaf() (for tables). + SwLayoutFrame *GetLeaf( MakePageType eMakePage, bool bFwd ); + SwLayoutFrame *GetNextLeaf ( MakePageType eMakePage ); + SwLayoutFrame *GetNextFootnoteLeaf( MakePageType eMakePage ); + SwLayoutFrame *GetNextSctLeaf( MakePageType eMakePage ); + SwLayoutFrame *GetNextFlyLeaf( MakePageType eMakePage ); + SwLayoutFrame *GetNextCellLeaf(); + SwLayoutFrame *GetPrevLeaf (); + SwLayoutFrame *GetPrevFootnoteLeaf( MakePageType eMakeFootnote ); + SwLayoutFrame *GetPrevSctLeaf(); + SwLayoutFrame *GetPrevFlyLeaf(); + SwLayoutFrame *GetPrevCellLeaf(); + const SwLayoutFrame *GetLeaf ( MakePageType eMakePage, bool bFwd, + const SwFrame *pAnch ) const; + + bool WrongPageDesc( SwPageFrame* pNew ); + + //#i28701# - new methods to append/remove drawing objects + void AppendDrawObj( SwAnchoredObject& _rNewObj ); + void RemoveDrawObj( SwAnchoredObject& _rToRemoveObj ); + + // work with chain of FlyFrames + void AppendFly( SwFlyFrame *pNew ); + void RemoveFly( SwFlyFrame *pToRemove ); + const SwSortedObjs *GetDrawObjs() const { return m_pDrawObjs.get(); } + SwSortedObjs *GetDrawObjs() { return m_pDrawObjs.get(); } + void SetDrawObjsAsDeleted( bool bDeleted ); // change tracking of objects anchored to character + // #i28701# - change purpose of method and adjust its name + void InvalidateObjs( const bool _bNoInvaOfAsCharAnchoredObjs = true ); + + virtual void PaintSwFrameShadowAndBorder( + const SwRect&, + const SwPageFrame* pPage, + const SwBorderAttrs&) const; + void PaintBaBo( const SwRect&, const SwPageFrame *pPage, + const bool bOnlyTextBackground = false) const; + void PaintSwFrameBackground( const SwRect&, const SwPageFrame *pPage, + const SwBorderAttrs &, + const bool bLowerMode = false, + const bool bLowerBorder = false, + const bool bOnlyTextBackground = false ) const; + void PaintBorderLine( const SwRect&, const SwRect&, const SwPageFrame*, + const Color *pColor, + const SvxBorderLineStyle = SvxBorderLineStyle::SOLID ) const; + + std::unique_ptr CreateProcessor2D( ) const; + void ProcessPrimitives( const drawinglayer::primitive2d::Primitive2DContainer& rSequence ) const; + + // retouch, not in the area of the given Rect! + void Retouch( const SwPageFrame *pPage, const SwRect &rRect ) const; + + bool GetBackgroundBrush( + drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes, + const SvxBrushItem*& rpBrush, + std::optional& rxColor, + SwRect &rOrigRect, + bool bLowerMode, + bool bConsiderTextBox ) const; + + inline void SetCompletePaint() const; + inline void ResetCompletePaint() const; + bool IsCompletePaint() const { return mbCompletePaint; } + + inline void SetRetouche() const; + inline void ResetRetouche() const; + bool IsRetouche() const { return mbRetouche; } + + void SetInfFlags(); + void InvalidateInfFlags() { mbInfInvalid = true; } + inline bool IsInDocBody() const; // use InfoFlags, determine flags + inline bool IsInFootnote() const; // if necessary + inline bool IsInTab() const; + inline bool IsInFly() const; + inline bool IsInSct() const; + + // If frame is inside a split table row, this function returns + // the corresponding row frame in the follow table. + const SwRowFrame* IsInSplitTableRow() const; + + // If frame is inside a follow flow row, this function returns + // the corresponding row frame master table + const SwRowFrame* IsInFollowFlowRow() const; + + bool IsInBalancedSection() const; + + inline bool IsVertical() const; + inline bool IsVertLR() const; + inline bool IsVertLRBT() const; + + void SetDerivedVert( bool bNew ){ mbDerivedVert = bNew; } + void SetInvalidVert( bool bNew) { mbInvalidVert = bNew; } + inline bool IsRightToLeft() const; + void SetDerivedR2L( bool bNew ) { mbDerivedR2L = bNew; } + + void CheckDirChange(); + // returns upper left frame position for LTR and + // upper right frame position for Asian / RTL frames + Point GetFrameAnchorPos( bool bIgnoreFlysAnchoredAtThisFrame ) const; + + /** determine, if frame is moveable in given environment + + method replaced 'old' method . + Determines, if frame is moveable in given environment. if no environment + is given (parameter _pLayoutFrame == 0), the movability in the actual + environment ((this) : ImplFindPageFrame(); } + SwFrame *FindColFrame(); + SwRowFrame *FindRowFrame(); + SwFootnoteBossFrame *FindFootnoteBossFrame( bool bFootnotes = false ); + SwTabFrame *ImplFindTabFrame(); + SwFootnoteFrame *ImplFindFootnoteFrame(); + SwFlyFrame *ImplFindFlyFrame(); + SwSectionFrame *ImplFindSctFrame(); + const SwBodyFrame *ImplFindBodyFrame() const; + SwFrame *FindFooterOrHeader(); + SwFrame *GetLower(); + const SwFrame *GetNext() const { return mpNext; } + const SwFrame *GetPrev() const { return mpPrev; } + const SwLayoutFrame *GetUpper() const { return mpUpper; } + const SwRootFrame *getRootFrame() const { return mpRoot; } + inline SwTabFrame *FindTabFrame(); + inline SwFootnoteFrame *FindFootnoteFrame(); + inline SwFlyFrame *FindFlyFrame(); + inline SwSectionFrame *FindSctFrame(); + inline SwFrame *FindNext(); + // #i27138# - add parameter <_bInSameFootnote> + SwContentFrame* FindNextCnt( const bool _bInSameFootnote = false ); + inline SwFrame *FindPrev(); + inline const SwPageFrame *FindPageFrame() const; + inline const SwFootnoteBossFrame *FindFootnoteBossFrame( bool bFootnote = false ) const; + inline const SwFrame *FindColFrame() const; + inline const SwFrame *FindFooterOrHeader() const; + inline const SwTabFrame *FindTabFrame() const; + inline const SwFootnoteFrame *FindFootnoteFrame() const; + inline const SwFlyFrame *FindFlyFrame() const; + inline const SwSectionFrame *FindSctFrame() const; + inline const SwBodyFrame *FindBodyFrame() const; + inline const SwFrame *FindNext() const; + // #i27138# - add parameter <_bInSameFootnote> + const SwContentFrame* FindNextCnt( const bool _bInSameFootnote = false ) const; + inline const SwFrame *FindPrev() const; + const SwFrame *GetLower() const; + + SwContentFrame* FindPrevCnt(); + + const SwContentFrame* FindPrevCnt() const; + + // #i79774# + SwFrame* GetIndPrev_() const; + SwFrame* GetIndPrev() const + { return ( mpPrev || !IsInSct() ) ? mpPrev : GetIndPrev_(); } + + SwFrame* GetIndNext() + { return ( mpNext || !IsInSct() ) ? mpNext : GetIndNext_(); } + const SwFrame* GetIndNext() const { return const_cast(this)->GetIndNext(); } + + sal_uInt16 GetPhyPageNum() const; // page number without offset + sal_uInt16 GetVirtPageNum() const; // page number with offset + bool OnRightPage() const { return 0 != GetPhyPageNum() % 2; }; + bool WannaRightPage() const; + bool OnFirstPage() const; + + inline const SwLayoutFrame *GetPrevLayoutLeaf() const; + inline const SwLayoutFrame *GetNextLayoutLeaf() const; + inline SwLayoutFrame *GetPrevLayoutLeaf(); + inline SwLayoutFrame *GetNextLayoutLeaf(); + + virtual void Calc(vcl::RenderContext* pRenderContext) const; // here might be "formatted" + inline void OptCalc() const; // here we assume (for optimization) that + // the predecessors are already formatted + Point GetRelPos() const; + + // PaintArea is the area where content might be displayed. + // The margin of a page or the space between columns belongs to it. + SwRect GetPaintArea() const; + + // UnionFrame is the union of Frame- and PrtArea, normally identical + // to the FrameArea except in case of negative Prt margins. + SwRect UnionFrame( bool bBorder = false ) const; + + virtual Size ChgSize( const Size& aNewSize ); + + virtual void Cut() = 0; + virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) = 0; + + void ValidateLineNum() { mbValidLineNum = true; } + + bool GetValidLineNumFlag()const { return mbValidLineNum; } + + // Only invalidate Frame + // #i28701# - add call to method + // for all invalidation methods. + // #i28701# - use method to + // decide, if invalidation will to be performed or not. + // #i26945# - no additional invalidation, if it's already + // invalidate. + void InvalidateSize_() + { + if ( isFrameAreaSizeValid() && InvalidationAllowed( INVALID_SIZE ) ) + { + setFrameAreaSizeValid(false); + ActionOnInvalidation( INVALID_SIZE ); + } + } + void InvalidatePrt_() + { + if ( isFramePrintAreaValid() && InvalidationAllowed( INVALID_PRTAREA ) ) + { + setFramePrintAreaValid(false); + ActionOnInvalidation( INVALID_PRTAREA ); + } + } + void InvalidatePos_() + { + if ( isFrameAreaPositionValid() && InvalidationAllowed( INVALID_POS ) ) + { + setFrameAreaPositionValid(false); + ActionOnInvalidation( INVALID_POS ); + } + } + void InvalidateLineNum_() + { + if ( mbValidLineNum && InvalidationAllowed( INVALID_LINENUM ) ) + { + mbValidLineNum = false; + ActionOnInvalidation( INVALID_LINENUM ); + } + } + void InvalidateAll_() + { + if ( ( isFrameAreaSizeValid() || isFramePrintAreaValid() || isFrameAreaPositionValid() ) && InvalidationAllowed( INVALID_ALL ) ) + { + setFrameAreaSizeValid(false); + setFrameAreaPositionValid(false); + setFramePrintAreaValid(false); + ActionOnInvalidation( INVALID_ALL ); + } + } + // also notify page at the same time + inline void InvalidateSize(); + inline void InvalidatePrt(); + inline void InvalidatePos(); + inline void InvalidateLineNum(); + inline void InvalidateAll(); + void ImplInvalidateSize(); + void ImplInvalidatePrt(); + void ImplInvalidatePos(); + void ImplInvalidateLineNum(); + + inline void InvalidateNextPos( bool bNoFootnote = false ); + void ImplInvalidateNextPos( bool bNoFootnote ); + + /** method to invalidate printing area of next frame + #i11859# + */ + void InvalidateNextPrtArea(); + + void InvalidatePage( const SwPageFrame *pPage = nullptr ) const; + + virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const; + + virtual bool GetModelPositionForViewPoint( SwPosition *, Point&, + SwCursorMoveState* = nullptr, bool bTestBackground = false ) const; + virtual bool GetCharRect( SwRect &, const SwPosition&, + SwCursorMoveState* = nullptr, bool bAllowFarAway = true ) const; + virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&, + SwPrintData const*const pPrintData = nullptr ) const; + + // HACK: shortcut between frame and formatting + // It's your own fault if you cast void* incorrectly! In any case check + // the void* for 0. + virtual bool Prepare( const PrepareHint ePrep = PrepareHint::Clear, + const void *pVoid = nullptr, bool bNotify = true ); + + // true if it is the correct class, false otherwise + inline bool IsLayoutFrame() const; + inline bool IsRootFrame() const; + inline bool IsPageFrame() const; + inline bool IsColumnFrame() const; + inline bool IsFootnoteBossFrame() const; // footnote bosses might be PageFrames or ColumnFrames + inline bool IsHeaderFrame() const; + inline bool IsFooterFrame() const; + inline bool IsFootnoteContFrame() const; + inline bool IsFootnoteFrame() const; + inline bool IsBodyFrame() const; + inline bool IsColBodyFrame() const; // implemented in layfrm.hxx, BodyFrame above ColumnFrame + inline bool IsPageBodyFrame() const; // implemented in layfrm.hxx, BodyFrame above PageFrame + inline bool IsFlyFrame() const; + inline bool IsSctFrame() const; + inline bool IsTabFrame() const; + inline bool IsRowFrame() const; + inline bool IsCellFrame() const; + inline bool IsContentFrame() const; + inline bool IsTextFrame() const; + SwTextFrame* DynCastTextFrame(); + const SwTextFrame* DynCastTextFrame() const; + SwPageFrame* DynCastPageFrame(); + const SwPageFrame* DynCastPageFrame() const; + inline bool IsNoTextFrame() const; + // Frames where its PrtArea depends on their neighbors and that are + // positioned in the content flow + inline bool IsFlowFrame() const; + // Frames that are capable of retouching or that might need to retouch behind + // themselves + inline bool IsRetoucheFrame() const; + inline bool IsAccessibleFrame() const; + + void PrepareCursor(); // CursorShell is allowed to call this + + // Is the Frame (or the section containing it) protected? Same for Fly in + // Fly in ... and footnotes + bool IsProtected() const; + + bool IsColLocked() const { return mbColLocked; } + virtual bool IsDeleteForbidden() const { return mnForbidDelete > 0; } + + /// this is the only way to delete a SwFrame instance + static void DestroyFrame(SwFrame *const pFrame); + + bool IsInDtor() const { return mbInDtor; } + + // No inline cause we need the function pointers + tools::Long GetTopMargin() const; + tools::Long GetBottomMargin() const; + tools::Long GetLeftMargin() const; + tools::Long GetRightMargin() const; + void SetTopBottomMargins( tools::Long, tools::Long ); + void SetLeftRightMargins( tools::Long, tools::Long ); + void SetRightLeftMargins( tools::Long, tools::Long ); + tools::Long GetPrtLeft() const; + tools::Long GetPrtBottom() const; + tools::Long GetPrtRight() const; + tools::Long GetPrtTop() const; + bool SetMinLeft( tools::Long ); + bool SetMaxBottom( tools::Long ); + bool SetMaxRight( tools::Long ); + void MakeBelowPos( const SwFrame*, const SwFrame*, bool ); + void MakeLeftPos( const SwFrame*, const SwFrame*, bool ); + void MakeRightPos( const SwFrame*, const SwFrame*, bool ); + bool IsNeighbourFrame() const + { return bool(GetType() & FRM_NEIGHBOUR); } + + // NEW TABLES + // Some functions for covered/covering table cells. This way unnecessary + // includes can be avoided + virtual bool IsLeaveUpperAllowed() const; + virtual bool IsCoveredCell() const; + bool IsInCoveredCell() const; + + // #i81146# new loop control + bool KnowsFormat( const SwFormat& rFormat ) const; + void RegisterToFormat( SwFormat& rFormat ); + void ValidateThisAndAllLowers( const sal_uInt16 nStage ); + + void ForbidDelete() { ++mnForbidDelete; } + void AllowDelete() { assert(mnForbidDelete > 0); --mnForbidDelete; } + + drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const; + bool supportsFullDrawingLayerFillAttributeSet() const; + +public: + // if writer is NULL, dumps the layout structure as XML in layout.xml + virtual void dumpAsXml(xmlTextWriterPtr writer = nullptr) const = 0; + void dumpTopMostAsXml(xmlTextWriterPtr writer = nullptr) const; + void dumpInfosAsXml(xmlTextWriterPtr writer) const; + virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const; + void dumpChildrenAsXml(xmlTextWriterPtr writer) const; + bool IsCollapse() const; +}; + +inline bool SwFrame::IsInDocBody() const +{ + if ( mbInfInvalid ) + const_cast(this)->SetInfFlags(); + return mbInfBody; +} +inline bool SwFrame::IsInFootnote() const +{ + if ( mbInfInvalid ) + const_cast(this)->SetInfFlags(); + return mbInfFootnote; +} +inline bool SwFrame::IsInTab() const +{ + if ( mbInfInvalid ) + const_cast(this)->SetInfFlags(); + return mbInfTab; +} +inline bool SwFrame::IsInFly() const +{ + if ( mbInfInvalid ) + const_cast(this)->SetInfFlags(); + return mbInfFly; +} +inline bool SwFrame::IsInSct() const +{ + if ( mbInfInvalid ) + const_cast(this)->SetInfFlags(); + return mbInfSct; +} +bool SwFrame::IsVertical() const +{ + if( mbInvalidVert ) + const_cast(this)->SetDirFlags( true ); + return mbVertical; +} +inline bool SwFrame::IsVertLR() const +{ + return mbVertLR; +} +inline bool SwFrame::IsVertLRBT() const +{ + return mbVertLRBT; +} +inline bool SwFrame::IsRightToLeft() const +{ + if( mbInvalidR2L ) + const_cast(this)->SetDirFlags( false ); + return mbRightToLeft; +} + +inline void SwFrame::SetCompletePaint() const +{ + const_cast(this)->mbCompletePaint = true; +} +inline void SwFrame::ResetCompletePaint() const +{ + const_cast(this)->mbCompletePaint = false; +} + +inline void SwFrame::SetRetouche() const +{ + const_cast(this)->mbRetouche = true; +} +inline void SwFrame::ResetRetouche() const +{ + const_cast(this)->mbRetouche = false; +} + +inline SwLayoutFrame *SwFrame::GetNextLayoutLeaf() +{ + return const_cast(static_cast(this)->GetNextLayoutLeaf()); +} +inline SwLayoutFrame *SwFrame::GetPrevLayoutLeaf() +{ + return const_cast(static_cast(this)->GetPrevLayoutLeaf()); +} +inline const SwLayoutFrame *SwFrame::GetNextLayoutLeaf() const +{ + return ImplGetNextLayoutLeaf( true ); +} +inline const SwLayoutFrame *SwFrame::GetPrevLayoutLeaf() const +{ + return ImplGetNextLayoutLeaf( false ); +} + +inline void SwFrame::InvalidateSize() +{ + if ( isFrameAreaSizeValid() ) + { + ImplInvalidateSize(); + } +} +inline void SwFrame::InvalidatePrt() +{ + if ( isFramePrintAreaValid() ) + { + ImplInvalidatePrt(); + } +} +inline void SwFrame::InvalidatePos() +{ + if ( isFrameAreaPositionValid() ) + { + ImplInvalidatePos(); + } +} +inline void SwFrame::InvalidateLineNum() +{ + if ( mbValidLineNum ) + ImplInvalidateLineNum(); +} +inline void SwFrame::InvalidateAll() +{ + if ( InvalidationAllowed( INVALID_ALL ) ) + { + if ( isFrameAreaDefinitionValid() ) + { + ImplInvalidatePos(); + } + + setFrameAreaSizeValid(false); + setFrameAreaPositionValid(false); + setFramePrintAreaValid(false); + + // #i28701# + ActionOnInvalidation( INVALID_ALL ); + } +} +inline void SwFrame::InvalidateNextPos( bool bNoFootnote ) +{ + if ( mpNext && !mpNext->IsSctFrame() ) + mpNext->InvalidatePos(); + else + ImplInvalidateNextPos( bNoFootnote ); +} + +inline void SwFrame::OptCalc() const +{ + if ( !isFrameAreaPositionValid() || !isFramePrintAreaValid() || !isFrameAreaSizeValid() ) + { + const_cast(this)->OptPrepareMake(); + } +} +inline const SwPageFrame *SwFrame::FindPageFrame() const +{ + return const_cast(this)->FindPageFrame(); +} +inline const SwFrame *SwFrame::FindColFrame() const +{ + return const_cast(this)->FindColFrame(); +} +inline const SwFrame *SwFrame::FindFooterOrHeader() const +{ + return const_cast(this)->FindFooterOrHeader(); +} +inline SwTabFrame *SwFrame::FindTabFrame() +{ + return IsInTab() ? ImplFindTabFrame() : nullptr; +} +inline const SwFootnoteBossFrame *SwFrame::FindFootnoteBossFrame( bool bFootnote ) const +{ + return const_cast(this)->FindFootnoteBossFrame( bFootnote ); +} +inline SwFootnoteFrame *SwFrame::FindFootnoteFrame() +{ + return IsInFootnote() ? ImplFindFootnoteFrame() : nullptr; +} +inline SwFlyFrame *SwFrame::FindFlyFrame() +{ + return IsInFly() ? ImplFindFlyFrame() : nullptr; +} +inline SwSectionFrame *SwFrame::FindSctFrame() +{ + return IsInSct() ? ImplFindSctFrame() : nullptr; +} + +inline const SwBodyFrame *SwFrame::FindBodyFrame() const +{ + return IsInDocBody() ? ImplFindBodyFrame() : nullptr; +} + +inline const SwTabFrame *SwFrame::FindTabFrame() const +{ + return IsInTab() ? const_cast(this)->ImplFindTabFrame() : nullptr; +} +inline const SwFootnoteFrame *SwFrame::FindFootnoteFrame() const +{ + return IsInFootnote() ? const_cast(this)->ImplFindFootnoteFrame() : nullptr; +} +inline const SwFlyFrame *SwFrame::FindFlyFrame() const +{ + return IsInFly() ? const_cast(this)->ImplFindFlyFrame() : nullptr; +} +inline const SwSectionFrame *SwFrame::FindSctFrame() const +{ + return IsInSct() ? const_cast(this)->ImplFindSctFrame() : nullptr; +} +inline SwFrame *SwFrame::FindNext() +{ + if ( mpNext ) + return mpNext; + else + return FindNext_(); +} +inline const SwFrame *SwFrame::FindNext() const +{ + if ( mpNext ) + return mpNext; + else + return const_cast(this)->FindNext_(); +} +inline SwFrame *SwFrame::FindPrev() +{ + if ( mpPrev && !mpPrev->IsSctFrame() ) + return mpPrev; + else + return FindPrev_(); +} +inline const SwFrame *SwFrame::FindPrev() const +{ + if ( mpPrev && !mpPrev->IsSctFrame() ) + return mpPrev; + else + return const_cast(this)->FindPrev_(); +} + +inline bool SwFrame::IsLayoutFrame() const +{ + return bool(GetType() & FRM_LAYOUT); +} +inline bool SwFrame::IsRootFrame() const +{ + return mnFrameType == SwFrameType::Root; +} +inline bool SwFrame::IsPageFrame() const +{ + return mnFrameType == SwFrameType::Page; +} +inline bool SwFrame::IsColumnFrame() const +{ + return mnFrameType == SwFrameType::Column; +} +inline bool SwFrame::IsFootnoteBossFrame() const +{ + return bool(GetType() & FRM_FTNBOSS); +} +inline bool SwFrame::IsHeaderFrame() const +{ + return mnFrameType == SwFrameType::Header; +} +inline bool SwFrame::IsFooterFrame() const +{ + return mnFrameType == SwFrameType::Footer; +} +inline bool SwFrame::IsFootnoteContFrame() const +{ + return mnFrameType == SwFrameType::FtnCont; +} +inline bool SwFrame::IsFootnoteFrame() const +{ + return mnFrameType == SwFrameType::Ftn; +} +inline bool SwFrame::IsBodyFrame() const +{ + return mnFrameType == SwFrameType::Body; +} +inline bool SwFrame::IsFlyFrame() const +{ + return mnFrameType == SwFrameType::Fly; +} +inline bool SwFrame::IsSctFrame() const +{ + return mnFrameType == SwFrameType::Section; +} +inline bool SwFrame::IsTabFrame() const +{ + return mnFrameType == SwFrameType::Tab; +} +inline bool SwFrame::IsRowFrame() const +{ + return mnFrameType == SwFrameType::Row; +} +inline bool SwFrame::IsCellFrame() const +{ + return mnFrameType == SwFrameType::Cell; +} +inline bool SwFrame::IsContentFrame() const +{ + return bool(GetType() & FRM_CNTNT); +} +inline bool SwFrame::IsTextFrame() const +{ + return mnFrameType == SwFrameType::Txt; +} +inline bool SwFrame::IsNoTextFrame() const +{ + return mnFrameType == SwFrameType::NoTxt; +} +inline bool SwFrame::IsFlowFrame() const +{ + return bool(GetType() & (FRM_CNTNT|SwFrameType::Tab|SwFrameType::Section)); +} +inline bool SwFrame::IsRetoucheFrame() const +{ + return bool(GetType() & (FRM_CNTNT|SwFrameType::Tab|SwFrameType::Section|SwFrameType::Ftn)); +} +inline bool SwFrame::IsAccessibleFrame() const +{ + return bool(GetType() & FRM_ACCESSIBLE); +} + +//use this to protect a SwFrame for a given scope from getting deleted +class SwFrameDeleteGuard +{ +private: + SwFrame *m_pForbidFrame; +public: + //Flag pFrame for SwFrameDeleteGuard lifetime that we shouldn't delete + //it in e.g. SwSectionFrame::MergeNext etc because we will need it + //again after the SwFrameDeleteGuard dtor + explicit SwFrameDeleteGuard(SwFrame* pFrame) + : m_pForbidFrame(pFrame) + { + if (m_pForbidFrame) + m_pForbidFrame->ForbidDelete(); + } + + SwFrameDeleteGuard(const SwFrameDeleteGuard&) =delete; + + ~SwFrameDeleteGuard() + { + if (m_pForbidFrame) + m_pForbidFrame->AllowDelete(); + } + + SwFrameDeleteGuard& operator=(const SwFrameDeleteGuard&) =delete; +}; + +typedef tools::Long (SwFrame::*SwFrameGet)() const; +typedef bool (SwFrame::*SwFrameMax)( tools::Long ); +typedef void (SwFrame::*SwFrameMakePos)( const SwFrame*, const SwFrame*, bool ); +typedef tools::Long (*SwOperator)( tools::Long, tools::Long ); +typedef void (SwFrame::*SwFrameSet)( tools::Long, tools::Long ); + +struct SwRectFnCollection +{ + SwRectGet fnGetTop; + SwRectGet fnGetBottom; + SwRectGet fnGetLeft; + SwRectGet fnGetRight; + SwRectGet fnGetWidth; + SwRectGet fnGetHeight; + SwRectPoint fnGetPos; + SwRectSize fnGetSize; + + SwRectSet fnSetTop; + SwRectSet fnSetBottom; + SwRectSet fnSetLeft; + SwRectSet fnSetRight; + SwRectSet fnSetWidth; + SwRectSet fnSetHeight; + + SwRectSet fnSubTop; + SwRectSet fnAddBottom; + SwRectSet fnSubLeft; + SwRectSet fnAddRight; + SwRectSet fnAddWidth; + SwRectSet fnAddHeight; + + SwRectSet fnSetPosX; + SwRectSet fnSetPosY; + + SwFrameGet fnGetTopMargin; + SwFrameGet fnGetBottomMargin; + SwFrameGet fnGetLeftMargin; + SwFrameGet fnGetRightMargin; + SwFrameSet fnSetXMargins; + SwFrameSet fnSetYMargins; + SwFrameGet fnGetPrtTop; + SwFrameGet fnGetPrtBottom; + SwFrameGet fnGetPrtLeft; + SwFrameGet fnGetPrtRight; + SwRectDist fnTopDist; + SwRectDist fnBottomDist; + SwRectDist fnLeftDist; + SwRectDist fnRightDist; + SwFrameMax fnSetLimit; + SwRectMax fnOverStep; + + SwRectSetPos fnSetPos; + SwFrameMakePos fnMakePos; + SwOperator fnXDiff; + SwOperator fnYDiff; + SwOperator fnXInc; + SwOperator fnYInc; + + SwRectSetTwice fnSetLeftAndWidth; + SwRectSetTwice fnSetTopAndHeight; +}; + +typedef SwRectFnCollection* SwRectFn; + +// This class allows to use proper methods regardless of orientation (LTR/RTL, horizontal or vertical) +extern SwRectFn fnRectHori, fnRectVert, fnRectVertL2R, fnRectVertL2RB2T; +class SwRectFnSet { +public: + explicit SwRectFnSet(const SwFrame *pFrame) + : m_bVert(pFrame->IsVertical()) + , m_bVertL2R(pFrame->IsVertLR()) + , m_bVertL2RB2T(pFrame->IsVertLRBT()) + { + m_fnRect = m_bVert ? (m_bVertL2R ? (m_bVertL2RB2T ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert) : fnRectHori; + } + + void Refresh(const SwFrame *pFrame) + { + m_bVert = pFrame->IsVertical(); + m_bVertL2R = pFrame->IsVertLR(); + m_bVertL2RB2T = pFrame->IsVertLRBT(); + m_fnRect = m_bVert ? (m_bVertL2R ? (m_bVertL2RB2T ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert) : fnRectHori; + } + + bool IsVert() const { return m_bVert; } + bool IsVertL2R() const { return m_bVertL2R; } + SwRectFn FnRect() const { return m_fnRect; } + + bool PosDiff(const SwRect &rRect1, const SwRect &rRect2) const + { + return ((rRect1.*m_fnRect->fnGetTop)() != (rRect2.*m_fnRect->fnGetTop)() + || (rRect1.*m_fnRect->fnGetLeft)() != (rRect2.*m_fnRect->fnGetLeft)()); + } + + tools::Long GetTop (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetTop) (); } + tools::Long GetBottom(const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetBottom)(); } + tools::Long GetLeft (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetLeft) (); } + tools::Long GetRight (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetRight) (); } + tools::Long GetWidth (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetWidth) (); } + tools::Long GetHeight(const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetHeight)(); } + Point GetPos (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetPos) (); } + Size GetSize (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetSize) (); } + + void SetTop (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetTop) (nNew); } + void SetBottom(SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetBottom)(nNew); } + void SetLeft (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetLeft) (nNew); } + void SetRight (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetRight) (nNew); } + void SetWidth (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetWidth) (nNew); } + void SetHeight(SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetHeight)(nNew); } + + void SubTop (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSubTop) (nNew); } + void AddBottom(SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnAddBottom)(nNew); } + void SubLeft (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSubLeft) (nNew); } + void AddRight (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnAddRight) (nNew); } + void AddWidth (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnAddWidth) (nNew); } + void AddHeight(SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnAddHeight)(nNew); } + + void SetPosX(SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetPosX)(nNew); } + void SetPosY(SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetPosY)(nNew); } + + tools::Long GetTopMargin (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetTopMargin) (); } + tools::Long GetBottomMargin(const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetBottomMargin)(); } + tools::Long GetLeftMargin (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetLeftMargin) (); } + tools::Long GetRightMargin (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetRightMargin) (); } + void SetXMargins(SwFrame& rFrame, tools::Long nLeft, tools::Long nRight) const { (rFrame.*m_fnRect->fnSetXMargins)(nLeft, nRight); } + void SetYMargins(SwFrame& rFrame, tools::Long nTop, tools::Long nBottom) const { (rFrame.*m_fnRect->fnSetYMargins)(nTop, nBottom); } + tools::Long GetPrtTop (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetPrtTop) (); } + tools::Long GetPrtBottom (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetPrtBottom) (); } + tools::Long GetPrtLeft (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetPrtLeft) (); } + tools::Long GetPrtRight (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetPrtRight) (); } + tools::Long TopDist (const SwRect& rRect, tools::Long nPos) const { return (rRect.*m_fnRect->fnTopDist) (nPos); } + tools::Long BottomDist(const SwRect& rRect, tools::Long nPos) const { return (rRect.*m_fnRect->fnBottomDist) (nPos); } + tools::Long LeftDist (const SwRect& rRect, tools::Long nPos) const { return (rRect.*m_fnRect->fnLeftDist) (nPos); } + tools::Long RightDist (const SwRect& rRect, tools::Long nPos) const { return (rRect.*m_fnRect->fnRightDist) (nPos); } + void SetLimit (SwFrame& rFrame, tools::Long nNew) const { (rFrame.*m_fnRect->fnSetLimit) (nNew); } + bool OverStep (const SwRect& rRect, tools::Long nPos) const { return (rRect.*m_fnRect->fnOverStep) (nPos); } + + void SetPos(SwRect& rRect, const Point& rNew) const { (rRect.*m_fnRect->fnSetPos)(rNew); } + void MakePos(SwFrame& rFrame, const SwFrame* pUp, const SwFrame* pPrv, bool bNotify) const { (rFrame.*m_fnRect->fnMakePos)(pUp, pPrv, bNotify); } + tools::Long XDiff(tools::Long n1, tools::Long n2) const { return (m_fnRect->fnXDiff) (n1, n2); } + tools::Long YDiff(tools::Long n1, tools::Long n2) const { return (m_fnRect->fnYDiff) (n1, n2); } + tools::Long XInc (tools::Long n1, tools::Long n2) const { return (m_fnRect->fnXInc) (n1, n2); } + tools::Long YInc (tools::Long n1, tools::Long n2) const { return (m_fnRect->fnYInc) (n1, n2); } + + void SetLeftAndWidth(SwRect& rRect, tools::Long nLeft, tools::Long nWidth) const { (rRect.*m_fnRect->fnSetLeftAndWidth)(nLeft, nWidth); } + void SetTopAndHeight(SwRect& rRect, tools::Long nTop, tools::Long nHeight) const { (rRect.*m_fnRect->fnSetTopAndHeight)(nTop, nHeight); } + +private: + bool m_bVert; + bool m_bVertL2R; + bool m_bVertL2RB2T; + SwRectFn m_fnRect; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/frminf.hxx b/sw/source/core/inc/frminf.hxx new file mode 100644 index 0000000000..1e1d433c47 --- /dev/null +++ b/sw/source/core/inc/frminf.hxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_FRMINF_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_FRMINF_HXX + +#include + +#include "TextFrameIndex.hxx" + +#include + +class SwTextFrame; +class SwTextCursor; + +class SwTextFrameInfo +{ + const SwTextFrame *m_pFrame; + + // Where does the text (w/o whitespaces) start (document is global!)? + static SwTwips GetLineStart( const SwTextCursor &rLine ); + +public: + SwTextFrameInfo( const SwTextFrame *pTextFrame ) : m_pFrame(pTextFrame) { } + + // Does the paragraph fit into a single line? + bool IsOneLine() const; + + // Is the line filled to X%? + bool IsFilled( const sal_uInt8 nPercent ) const; + + // Where does the text (w/o whitespaces) start (rel. in frame)? + SwTwips GetLineStart() const; + + // return center position of the next character + SwTwips GetCharPos(TextFrameIndex nChar, bool bCenter = true) const; + + // collect all whitespaces at the beginning and end of a line in Pam + void GetSpaces(std::vector> &, + bool bWithLineBreak) const; + + // Is a bullet point/symbol/etc. at the first text position? + bool IsBullet(TextFrameIndex nTextPos) const; + + // determine indentation for first line + SwTwips GetFirstIndent() const; + + const SwTextFrame* GetFrame() const { return m_pFrame; } + SwTextFrameInfo& SetFrame( const SwTextFrame* pNew ) + { m_pFrame = pNew; return *this; } + + // Is it a comparison? Returns position in frame. + sal_Int32 GetBigIndent( TextFrameIndex & rFndPos, + const SwTextFrame *pNextFrame ) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx new file mode 100644 index 0000000000..ffc218b550 --- /dev/null +++ b/sw/source/core/inc/frmtool.hxx @@ -0,0 +1,626 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_FRMTOOL_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_FRMTOOL_HXX + +#include +#include +#include +#include "frame.hxx" +#include "txtfrm.hxx" +#include "swcache.hxx" +#include + +class SwLayoutFrame; +class SwFont; +class SwTextFrame; +class SwFormatAnchor; +class SwViewShell; +class SwPageFrame; +class SwFlyFrame; +class SwContentFrame; +class SwRootFrame; +class SwDoc; +class SdrObject; +class SvxBrushItem; +class SdrMarkList; +class SwNodeIndex; +class GraphicObject; +class GraphicAttr; +class SwPageDesc; +class SwRegionRects; +class SwTextNode; +namespace sw { struct Extent; } +namespace basegfx::utils { class B2DClipState; } + +#define FAR_AWAY (SAL_MAX_INT32 - 20000) // initial position of a Fly +constexpr tools::Long BROWSE_HEIGHT = 56700 * 10; // 10 Meters +#define GRFNUM_NO 0 +#define GRFNUM_YES 1 +#define GRFNUM_REPLACE 2 + +void AppendObjs(const sw::FrameFormats* pSpz, SwNodeOffset nIndex, SwFrame* pFrame, SwPageFrame* pPage, SwDoc* doc); + +void AppendObjsOfNode(sw::FrameFormats const* pTable, SwNodeOffset nIndex, + SwFrame * pFrame, SwPageFrame * pPage, SwDoc * pDoc, + std::vector::const_iterator const* pIter, + std::vector::const_iterator const* pEnd, + SwTextNode const* pFirstNode, SwTextNode const* pLastNode); + +void RemoveHiddenObjsOfNode(SwTextNode const& rNode, + std::vector::const_iterator const* pIter, + std::vector::const_iterator const* pEnd, + SwTextNode const* pFirstNode, SwTextNode const* pLastNode); + +bool IsAnchoredObjShown(SwTextFrame const& rFrame, SwFormatAnchor const& rAnchor); + +void AppendAllObjs(const sw::FrameFormats* pSpzs, const SwFrame* pSib); + +// draw background with brush or graphics +// The 6th parameter indicates that the method should consider background +// transparency, saved in the color of the brush item. +void DrawGraphic( + const SvxBrushItem *, + vcl::RenderContext &, + const SwRect &rOrg, + const SwRect &rOut, + const sal_uInt8 nGrfNum = GRFNUM_NO, + const bool bConsiderBackgroundTransparency = false ); +bool DrawFillAttributes( + const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes, + const SwRect& rOriginalLayoutRect, + const SwRegionRects& rPaintRegion, + const basegfx::utils::B2DClipState& rClipState, + vcl::RenderContext& rOut); + +// RotGrfFlyFrame: Adapted to rotation +void paintGraphicUsingPrimitivesHelper( + vcl::RenderContext & rOutputDevice, + GraphicObject const& rGraphicObj, + GraphicAttr const& rGraphicAttr, + const basegfx::B2DHomMatrix& rGraphicTransform, + const OUString& rName, + const OUString& rTitle, + const OUString& rDescription); + +// MM02 new VOC and primitive-based version +void paintGraphicUsingPrimitivesHelper( + vcl::RenderContext & rOutputDevice, + drawinglayer::primitive2d::Primitive2DContainer& rContent, + const basegfx::B2DHomMatrix& rGraphicTransform, + const OUString& rName, + const OUString& rTitle, + const OUString& rDescription); + +// method to align rectangle. +// Created declaration here to avoid declarations +void SwAlignRect( SwRect &rRect, const SwViewShell *pSh, const vcl::RenderContext* pRenderContext ); + +// method to align graphic rectangle +// Created declaration here to avoid declarations +void SwAlignGrfRect( SwRect *pGrfRect, const vcl::RenderContext &rOut ); + +/** + * Paint border around a run of characters using frame painting code. + * + * @param[in] rFont font object of actual text, which specify the border + * @param[in] rPaintArea rectangle area in which line portion takes place + * @param[in] bVerticalLayout corresponding text frame verticality + * @param[in] bVerticalLayoutLRBT corresponding text frame verticality (LRBT subset) + * @param[in] bJoinWithPrev leave border with which actual border joins to the previous portion + * @param[in] bJoinWithNext leave border with which actual border joins to the next portion +**/ +void PaintCharacterBorder(const SwFont& rFont, const SwRect& rPaintArea, const bool bVerticalLayout, + const bool bVerticalLayoutLRBT, const bool bJoinWithPrev, + const bool bJoinWithNext); + +// get Fly, if no List is given use the current shell +// Implementation in feshview.cxx +SwFlyFrame *GetFlyFromMarked( const SdrMarkList *pLst, SwViewShell *pSh ); + +SwFrame *SaveContent( SwLayoutFrame *pLay, SwFrame *pStart = nullptr ); +void RestoreContent( SwFrame *pSav, SwLayoutFrame *pParent, SwFrame *pSibling ); + +// Get ContentNodes, create ContentFrames, and add them to LayFrame. +void InsertCnt_( SwLayoutFrame *pLay, SwDoc *pDoc, SwNodeOffset nIndex, + bool bPages = false, SwNodeOffset nEndIndex = SwNodeOffset(0), + SwFrame *pPrv = nullptr, sw::FrameMode eMode = sw::FrameMode::New); + +// Creation of frames for a specific section (uses InsertCnt_) +void MakeFrames( SwDoc *pDoc, SwNode &rSttIdx, + SwNode &rEndIdx ); + +extern bool bObjsDirect; + +// for FlyCnts, see SwFlyAtContentFrame::MakeAll() +extern bool bSetCompletePaintOnInvalidate; + +// for table settings via keyboard +SwTwips CalcRowRstHeight( SwLayoutFrame *pRow ); +tools::Long CalcHeightWithFlys( const SwFrame *pFrame ); + +namespace sw { + bool HasPageBreakBefore(SwPageFrame const& rPage); + bool IsRightPageByNumber(SwRootFrame const& rLayout, sal_uInt16 nPageNum); + class FlyCreationSuppressor + { + const bool m_wasAlreadySuppressed; + public: + FlyCreationSuppressor(bool isAlreadySuppressedAllowed = true); + ~FlyCreationSuppressor(); + }; +} // namespace sw + +SwPageFrame *InsertNewPage( SwPageDesc &rDesc, SwFrame *pUpper, + bool isRightPage, bool bFirst, bool bInsertEmpty, bool bFootnote, + SwFrame *pSibling, bool bVeryFirstPage = false ); + +// connect Flys with page +void RegistFlys( SwPageFrame*, const SwLayoutFrame* ); + +// notification of Fly's background if needed +void Notify( SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, + const SwRect* pOldRect = nullptr ); + +void Notify_Background( const SdrObject* pObj, + SwPageFrame* pPage, + const SwRect& rRect, + const PrepareHint eHint, + const bool bInva ); + +const SwFrame* GetVirtualUpper( const SwFrame* pFrame, const Point& rPos ); + +bool Is_Lower_Of( const SwFrame *pCurrFrame, const SdrObject* pObj ); + +// FIXME: EasyHack (refactoring): rename method and parameter name in all files +const SwFrame *FindContext( const SwFrame *pFrame, SwFrameType nAdditionalContextTyp ); + +bool IsFrameInSameContext( const SwFrame *pInnerFrame, const SwFrame *pFrame ); + +const SwFrame * FindPage( const SwRect &rRect, const SwFrame *pPage ); + +/** @see SwContentNode::getLayoutFrame() + @param pPos + Document model position; for a text frame, the returned frame will be + one containing this position. + @param pViewPosAndCalcFrame + First is a point in the document view; the returned frame will be the one + with the minimal distance to this point. To get the first frame in the + document, pass in a default-initialized Point with coordinates 0,0. + Second indicates whether the frames should be formatted before retrieving + their position for the test; this cannot be done by every caller so use + with care! + */ +SwFrame* GetFrameOfModify( const SwRootFrame* pLayout, + sw::BroadcastingModify const&, + SwFrameType const nFrameType, + const SwPosition *pPos = nullptr, + std::pair const* pViewPosAndCalcFrame = nullptr); + +// Should extra data (redline stroke, line numbers) be painted? +bool IsExtraData( const SwDoc *pDoc ); + +// #i11760# - method declaration +void CalcContent( SwLayoutFrame *pLay, bool bNoColl = false ); + +// Notify classes memorize the current sizes in their constructor and do +// the necessary notifications in their destructor if needed +class SwFrameNotify +{ +private: + void ImplDestroy(); + +protected: + SwFrame *mpFrame; + const SwRect maFrame; + const SwRect maPrt; + SwTwips mnFlyAnchorOfst; + SwTwips mnFlyAnchorOfstNoWrap; + bool mbHadFollow; + bool mbInvaKeep; + bool mbValidSize; + +public: + SwFrameNotify( SwFrame *pFrame ); + ~SwFrameNotify(); + + const SwRect &getFrameArea() const { return maFrame; } + void SetInvaKeep() { mbInvaKeep = true; } +}; + +class SwLayNotify : public SwFrameNotify +{ + bool m_bLowersComplete; + + void ImplDestroy(); + +public: + SwLayNotify( SwLayoutFrame *pLayFrame ); + ~SwLayNotify(); + + void SetLowersComplete( bool b ) { m_bLowersComplete = b; } + bool IsLowersComplete() const { return m_bLowersComplete; } +}; + +class SwFlyNotify : public SwLayNotify +{ + SwPageFrame *m_pOldPage; + const SwRect m_aFrameAndSpace; + + void ImplDestroy(); + +public: + SwFlyNotify( SwFlyFrame *pFlyFrame ); + ~SwFlyNotify(); +}; + +class SwContentNotify : public SwFrameNotify +{ +private: + // #i11859# + bool mbChkHeightOfLastLine; + SwTwips mnHeightOfLastLine; + + // #i25029# + bool mbInvalidatePrevPrtArea; + bool mbBordersJoinedWithPrev; + + void ImplDestroy(); + +public: + SwContentNotify( SwContentFrame *pContentFrame ); + ~SwContentNotify(); + + // #i25029# + void SetInvalidatePrevPrtArea() + { + mbInvalidatePrevPrtArea = true; + } + + void SetBordersJoinedWithPrev() + { + mbBordersJoinedWithPrev = true; + } +}; + +// SwBorderAttrs encapsulates the calculation for margin attributes including +// border. The whole class is cached. + +// WARNING! If more attributes should be cached also adjust the method +// Modify::Modify! +class SwBorderAttrs final : public SwCacheObj +{ + const SwAttrSet &m_rAttrSet; + const SvxULSpaceItem &m_rUL; + std::unique_ptr m_pFirstLineIndent; + std::unique_ptr m_pTextLeftMargin; + std::unique_ptr m_pRightMargin; + std::shared_ptr m_xLR; + const SvxBoxItem &m_rBox; + const SvxShadowItem &m_rShadow; + const Size m_aFrameSize; + + // the following bool values set the cached values to INVALID - until they + // are calculated for the first time + bool m_bTopLine : 1; + bool m_bBottomLine : 1; + bool m_bLeftLine : 1; + bool m_bRightLine : 1; + bool m_bTop : 1; + bool m_bBottom : 1; + bool m_bLine : 1; + bool m_bLineSpacing : 1; + + bool m_bIsLine : 1; // border on at least one side? + + bool m_bCacheGetLine : 1; // cache GetTopLine(), GetBottomLine()? + bool m_bCachedGetTopLine : 1; // is GetTopLine() cached? + bool m_bCachedGetBottomLine : 1; // is GetBottomLine() cached? + // Booleans indicate that and are + // cached and valid. + // Caching depends on value of . + mutable bool m_bCachedJoinedWithPrev : 1; + mutable bool m_bCachedJoinedWithNext : 1; + // Booleans indicate that borders are joined with previous/next frame. + bool m_bJoinedWithPrev :1; + bool m_bJoinedWithNext :1; + + // The cached values (un-defined until calculated for the first time) + sal_uInt16 m_nTopLine, + m_nBottomLine, + m_nLeftLine, + m_nRightLine, + m_nTop, + m_nBottom, + m_nGetTopLine, + m_nGetBottomLine, + m_nLineSpacing; + + // only calculate lines and shadow + void CalcTopLine_(); + void CalcBottomLine_(); + void CalcLeftLine_(); + void CalcRightLine_(); + + // lines + shadow + margin + void CalcTop_(); + void CalcBottom_(); + + void IsLine_(); + + // #i25029# - If <_pPrevFrame> is set, its value is taken for testing, if + // borders/shadow have to be joined with previous frame. + void GetTopLine_ ( const SwFrame& _rFrame, + const SwFrame* _pPrevFrame ); + void GetBottomLine_( const SwFrame& _rFrame ); + + // calculate cached values and + // #i25029# - If <_pPrevFrame> is set, its value is taken for testing, if + // borders/shadow have to be joined with previous frame. + void CalcJoinedWithPrev( const SwFrame& _rFrame, + const SwFrame* _pPrevFrame ); + void CalcJoinedWithNext( const SwFrame& _rFrame ); + + // internal helper method for CalcJoinedWithPrev and CalcJoinedWithNext + bool JoinWithCmp( const SwFrame& _rCallerFrame, + const SwFrame& _rCmpFrame ) const; + + // Are the left and right line and the LRSpace equal? + bool CmpLeftRight( const SwBorderAttrs &rCmpAttrs, + const SwFrame *pCaller, + const SwFrame *pCmp ) const; + + // tdf#125300 line spacing before cell border + void CalcLineSpacing_(); + +public: + SwBorderAttrs( const sw::BorderCacheOwner* pOwner, const SwFrame *pConstructor ); + virtual ~SwBorderAttrs() override; + + const SwAttrSet &GetAttrSet() const { return m_rAttrSet; } + const SvxULSpaceItem &GetULSpace() const { return m_rUL; } + const SvxBoxItem &GetBox() const { return m_rBox; } + const SvxShadowItem &GetShadow() const { return m_rShadow; } + + inline sal_uInt16 CalcTopLine() const; + inline sal_uInt16 CalcBottomLine() const; + inline sal_uInt16 CalcLeftLine() const; + inline sal_uInt16 CalcRightLine() const; + inline sal_uInt16 CalcTop() const; + inline sal_uInt16 CalcBottom() const; + inline sal_uInt16 CalcLineSpacing() const; + tools::Long CalcLeft( const SwFrame *pCaller ) const; + tools::Long CalcRight( const SwFrame *pCaller ) const; + + inline bool IsLine() const; + + const Size &GetSize() const { return m_aFrameSize; } + + // Should upper (or lower) border be evaluated for this frame? + // #i25029# - If <_pPrevFrame> is set, its value is taken for testing, if + // borders/shadow have to be joined with previous frame. + inline sal_uInt16 GetTopLine ( const SwFrame& _rFrame, + const SwFrame* _pPrevFrame = nullptr ) const; + inline sal_uInt16 GetBottomLine( const SwFrame& _rFrame ) const; + inline void SetGetCacheLine( bool bNew ) const; + + // Accessors for cached values and + // #i25029# - If <_pPrevFrame> is set, its value is taken for testing, if + // borders/shadow have to be joined with previous frame. + bool JoinedWithPrev( const SwFrame& _rFrame, + const SwFrame* _pPrevFrame = nullptr ) const; + bool JoinedWithNext( const SwFrame& _rFrame ) const; +}; + +class SwBorderAttrAccess final : public SwCacheAccess +{ + const SwFrame *m_pConstructor; //opt: for passing on to SwBorderAttrs + + virtual SwCacheObj *NewObj() override; + +public: + SwBorderAttrAccess( SwCache &rCache, const SwFrame *pOwner ); + + SwBorderAttrs *Get(); +}; + +// Iterator for draw objects of a page. The objects will be iterated sorted by +// their Z-order. Iterating is not cheap since for each operation the _whole_ +// SortArray needs to be traversed. +class SwOrderIter +{ + const SwPageFrame *m_pPage; + const SdrObject *m_pCurrent; + +public: + SwOrderIter( const SwPageFrame *pPage ); + + void Current( const SdrObject *pNew ) { m_pCurrent = pNew; } + const SdrObject *operator()() const { return m_pCurrent; } + void Top(); + const SdrObject *Bottom(); + const SdrObject *Next(); + void Prev(); +}; + +class StackHack +{ + static sal_uInt8 s_nCnt; + static bool s_bLocked; + +public: + StackHack() + { + if ( ++StackHack::s_nCnt > 50 ) + StackHack::s_bLocked = true; + } + ~StackHack() + { + if ( --StackHack::s_nCnt < 5 ) + StackHack::s_bLocked = false; + } + + static bool IsLocked() { return StackHack::s_bLocked; } + static sal_uInt8 Count() { return StackHack::s_nCnt; } +}; + +// Should upper (or lower) border be evaluated for this frame? +// #i25029# - If <_pPrevFrame> is set, its value is taken for testing, if +// borders/shadow have to be joined with previous frame. +inline sal_uInt16 SwBorderAttrs::GetTopLine ( const SwFrame& _rFrame, + const SwFrame* _pPrevFrame ) const +{ + if ( !m_bCachedGetTopLine || _pPrevFrame ) + { + const_cast(this)->GetTopLine_( _rFrame, _pPrevFrame ); + } + return m_nGetTopLine; +} +inline sal_uInt16 SwBorderAttrs::GetBottomLine( const SwFrame& _rFrame ) const +{ + if ( !m_bCachedGetBottomLine ) + const_cast(this)->GetBottomLine_( _rFrame ); + return m_nGetBottomLine; +} +inline void SwBorderAttrs::SetGetCacheLine( bool bNew ) const +{ + const_cast(this)->m_bCacheGetLine = bNew; + const_cast(this)->m_bCachedGetBottomLine = + const_cast(this)->m_bCachedGetTopLine = false; + // invalidate cache for values and + m_bCachedJoinedWithPrev = false; + m_bCachedJoinedWithNext = false; +} + +inline sal_uInt16 SwBorderAttrs::CalcTopLine() const +{ + if ( m_bTopLine ) + const_cast(this)->CalcTopLine_(); + return m_nTopLine; +} +inline sal_uInt16 SwBorderAttrs::CalcBottomLine() const +{ + if ( m_bBottomLine ) + const_cast(this)->CalcBottomLine_(); + return m_nBottomLine; +} +inline sal_uInt16 SwBorderAttrs::CalcLeftLine() const +{ + if ( m_bLeftLine ) + const_cast(this)->CalcLeftLine_(); + return m_nLeftLine; +} +inline sal_uInt16 SwBorderAttrs::CalcRightLine() const +{ + if ( m_bRightLine ) + const_cast(this)->CalcRightLine_(); + return m_nRightLine; +} +inline sal_uInt16 SwBorderAttrs::CalcTop() const +{ + if ( m_bTop ) + const_cast(this)->CalcTop_(); + return m_nTop; +} +inline sal_uInt16 SwBorderAttrs::CalcBottom() const +{ + if ( m_bBottom ) + const_cast(this)->CalcBottom_(); + return m_nBottom; +} +inline sal_uInt16 SwBorderAttrs::CalcLineSpacing() const +{ + if ( m_bLineSpacing ) + const_cast(this)->CalcLineSpacing_(); + return m_nLineSpacing; +} +inline bool SwBorderAttrs::IsLine() const +{ + if ( m_bLine ) + const_cast(this)->IsLine_(); + return m_bIsLine; +} + +/** method to determine the spacing values of a frame + + #i28701# + Values only provided for flow frames (table, section or text frames) + Note: line spacing value is only determined for text frames + #i102458# + Add output parameter + + @param rFrame + input parameter - frame, for which the spacing values are determined. + + @param onPrevLowerSpacing + output parameter - lower spacing of the frame in SwTwips + + @param onPrevLineSpacing + output parameter - line spacing of the frame in SwTwips + + @param obIsLineSpacingProportional + + @param bIdenticalStyles true if the styles of the actual and the next paragraphs (text-frames) are the same +*/ +void GetSpacingValuesOfFrame( const SwFrame& rFrame, + SwTwips& onLowerSpacing, + SwTwips& onLineSpacing, + bool& obIsLineSpacingProportional, + bool bIdenticalStyles ); + +/** method to get the content of the table cell + + Content from any nested tables will be omitted. + Note: line spacing value is only determined for text frames + + @param rCell_ + input parameter - the cell which should be searched for content. + + return + pointer to the found content frame or 0 +*/ + +const SwContentFrame* GetCellContent( const SwLayoutFrame& rCell_ ); + +/** helper class to check if a frame has been deleted during an operation + * WARNING! This should only be used as a last and desperate means to make the + * code robust. + */ + +class SwDeletionChecker +{ +private: + const SwFrame* mpFrame; + const sw::BroadcastingModify* mpRegIn; + +public: + SwDeletionChecker(const SwFrame* pFrame); + + /** + * return + * true if mpFrame != 0 and mpFrame is not client of pRegIn + * false otherwise + */ + bool HasBeenDeleted() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/ftnboss.hxx b/sw/source/core/inc/ftnboss.hxx new file mode 100644 index 0000000000..109c9df74e --- /dev/null +++ b/sw/source/core/inc/ftnboss.hxx @@ -0,0 +1,131 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_FTNBOSS_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_FTNBOSS_HXX + +#include "layfrm.hxx" + +class SwFootnoteBossFrame; +class SwFootnoteContFrame; +class SwFootnoteFrame; +class SwTextFootnote; + +// Set max. footnote area. +// Restoration of the old value in DTor. Implementation in ftnfrm.cxx +class SwSaveFootnoteHeight +{ + SwFrameDeleteGuard aGuard; + SwFootnoteBossFrame *pBoss; + const SwTwips nOldHeight; + SwTwips nNewHeight; +public: + SwSaveFootnoteHeight( SwFootnoteBossFrame *pBs, const SwTwips nDeadLine ); + ~SwSaveFootnoteHeight(); +}; + +enum class SwNeighbourAdjust { + OnlyAdjust, GrowShrink, GrowAdjust, AdjustGrow +}; + +typedef std::vector SwFootnoteFrames; + +class SW_DLLPUBLIC SwFootnoteBossFrame: public SwLayoutFrame +{ + // for private footnote operations + friend class SwFrame; + friend class SwSaveFootnoteHeight; + friend class SwPageFrame; // for setting of MaxFootnoteHeight + + // max. height of the footnote container on this page + SwTwips m_nMaxFootnoteHeight; + + SwFootnoteContFrame *MakeFootnoteCont(); + SwFootnoteFrame *FindFirstFootnote(); + SwNeighbourAdjust NeighbourhoodAdjustment_() const; + + static void CollectFootnotes_(const SwContentFrame*, SwFootnoteFrame*, + SwFootnoteFrames&, const SwFootnoteBossFrame*); + +protected: + void InsertFootnote( SwFootnoteFrame * ); + static void ResetFootnote( const SwFootnoteFrame *pAssumed ); + +public: + SwFootnoteBossFrame( SwFrameFormat* pFormat, SwFrame* pSib ) + : SwLayoutFrame( pFormat, pSib ) + , m_nMaxFootnoteHeight(0) + {} + + SwLayoutFrame *FindBodyCont(); + inline const SwLayoutFrame *FindBodyCont() const; + void SetMaxFootnoteHeight( const SwTwips nNewMax ) { m_nMaxFootnoteHeight = nNewMax; } + + // footnote interface + void AppendFootnote( SwContentFrame *, SwTextFootnote * ); + bool RemoveFootnote(const SwContentFrame *, const SwTextFootnote *, bool bPrep = true); + static SwFootnoteFrame *FindFootnote( const SwContentFrame *, const SwTextFootnote * ); + SwFootnoteContFrame *FindFootnoteCont(); + inline const SwFootnoteContFrame *FindFootnoteCont() const; + const SwFootnoteFrame *FindFirstFootnote( SwContentFrame const * ) const; + SwFootnoteContFrame *FindNearestFootnoteCont( bool bDontLeave = false ); + + static void ChangeFootnoteRef( const SwContentFrame *pOld, const SwTextFootnote *, + SwContentFrame *pNew ); + void RearrangeFootnotes( const SwTwips nDeadLine, const bool bLock, + const SwTextFootnote *pAttr = nullptr ); + + // Set DeadLine (in document coordinates) so that the text formatter can + // temporarily limit footnote height. + void SetFootnoteDeadLine( const SwTwips nDeadLine ); + SwTwips GetMaxFootnoteHeight() const { return m_nMaxFootnoteHeight; } + + // returns value for remaining space until the body reaches minimal height + SwTwips GetVarSpace() const; + + // methods needed for layouting + // The parameter <_bCollectOnlyPreviousFootnotes> controls if only footnotes + // that are positioned before the this footnote boss-frame have to be + // collected. + void CollectFootnotes( const SwContentFrame* _pRef, + SwFootnoteBossFrame* _pOld, + SwFootnoteFrames& _rFootnoteArr, + const bool _bCollectOnlyPreviousFootnotes = false ); + void MoveFootnotes_( SwFootnoteFrames &rFootnoteArr, bool bCalc = false ); + void MoveFootnotes( const SwContentFrame *pSrc, SwContentFrame *pDest, + SwTextFootnote const *pAttr ); + + // should AdjustNeighbourhood be called (or Grow/Shrink)? + SwNeighbourAdjust NeighbourhoodAdjustment() const + { return IsPageFrame() ? SwNeighbourAdjust::OnlyAdjust : NeighbourhoodAdjustment_(); } +}; + +inline const SwLayoutFrame *SwFootnoteBossFrame::FindBodyCont() const +{ + return const_cast(this)->FindBodyCont(); +} + +inline const SwFootnoteContFrame *SwFootnoteBossFrame::FindFootnoteCont() const +{ + return const_cast(this)->FindFootnoteCont(); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/ftnfrm.hxx b/sw/source/core/inc/ftnfrm.hxx new file mode 100644 index 0000000000..558c4941bf --- /dev/null +++ b/sw/source/core/inc/ftnfrm.hxx @@ -0,0 +1,171 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_FTNFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_FTNFRM_HXX + +#include "layfrm.hxx" + +class SwContentFrame; +class SwRootFrame; +class SwTextNode; +class SwTextFootnote; +class SwBorderAttrs; +class SwFootnoteFrame; + +void sw_RemoveFootnotes( SwFootnoteBossFrame* pBoss, bool bPageOnly, bool bEndNotes ); + +namespace sw { + +void RemoveFootnotesForNode( + SwRootFrame const& rLayout, SwTextNode const& rTextNode, + std::vector> const*const pExtents); + +} + +// There exists a special container frame on a page for footnotes. It's called +// SwFootnoteContFrame. Each footnote is separated by a SwFootnoteFrame which contains +// the text frames of a footnote. SwFootnoteFrame can be split and will then +// continue on another page. +class SwFootnoteContFrame final : public SwLayoutFrame +{ + static SwFootnoteFrame* AddChained(bool bAppend, SwFrame *pNewUpper, bool bDefaultFormat); + +public: + SwFootnoteContFrame( SwFrameFormat*, SwFrame* ); + + const SwFootnoteFrame* FindFootNote() const; + + static inline SwFootnoteFrame* AppendChained(SwFrame* pThis, bool bDefaultFormat); + static inline SwFootnoteFrame* PrependChained(SwFrame* pThis, bool bDefaultFormat); + + virtual SwTwips ShrinkFrame( SwTwips, bool bTst = false, bool bInfo = false ) override; + virtual SwTwips GrowFrame ( SwTwips, bool bTst = false, bool bInfo = false ) override; + virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override; + virtual void PaintSwFrameShadowAndBorder( + const SwRect&, + const SwPageFrame* pPage, + const SwBorderAttrs&) const override; + virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override; + void PaintLine( const SwRect &, const SwPageFrame * ) const; + + void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; +}; + +inline SwFootnoteFrame* SwFootnoteContFrame::AppendChained(SwFrame* pThis, bool bDefaultFormat) +{ + return AddChained(true, pThis, bDefaultFormat); +} + +inline SwFootnoteFrame* SwFootnoteContFrame::PrependChained(SwFrame* pThis, bool bDefaultFormat) +{ + return AddChained(false, pThis, bDefaultFormat); +} + +/// Represents one footnote or endnote in the layout. Typical upper is an SwFootnoteContFrame, +/// typical lower is an SwTextFrame. +class SwFootnoteFrame final : public SwLayoutFrame +{ + // Pointer to FootnoteFrame in which the footnote will be continued: + // - 0 no following existent + // - otherwise the following FootnoteFrame + SwFootnoteFrame *mpFollow; + SwFootnoteFrame *mpMaster; // FootnoteFrame from which I am the following + SwContentFrame *mpReference; // in this ContentFrame is the footnote reference + SwTextFootnote *mpAttribute; // footnote attribute (for recognition) + + // if true paragraphs in this footnote are NOT permitted to flow backwards + bool mbBackMoveLocked : 1; + // #i49383# - control unlock of position of lower anchored objects. + bool mbUnlockPosOfLowerObjs : 1; + +public: + SwFootnoteFrame( SwFrameFormat*, SwFrame*, SwContentFrame*, SwTextFootnote* ); + + virtual bool IsDeleteForbidden() const override; + virtual void Cut() override; + virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override; + + virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override; + + bool operator<( const SwTextFootnote* pTextFootnote ) const; + +#ifdef DBG_UTIL + const SwContentFrame *GetRef() const; + SwContentFrame *GetRef(); +#else + const SwContentFrame *GetRef() const { return mpReference; } + SwContentFrame *GetRef() { return mpReference; } +#endif + const SwContentFrame *GetRefFromAttr() const; + SwContentFrame *GetRefFromAttr(); + + const SwFootnoteFrame *GetFollow() const { return mpFollow; } + SwFootnoteFrame *GetFollow() { return mpFollow; } + + const SwFootnoteFrame *GetMaster() const { return mpMaster; } + SwFootnoteFrame *GetMaster() { return mpMaster; } + + const SwTextFootnote *GetAttr() const { return mpAttribute; } + SwTextFootnote *GetAttr() { return mpAttribute; } + + void SetFollow( SwFootnoteFrame *pNew ) { mpFollow = pNew; } + void SetMaster( SwFootnoteFrame *pNew ) { mpMaster = pNew; } + void SetRef ( SwContentFrame *pNew ) { mpReference = pNew; } + + void InvalidateNxtFootnoteCnts( SwPageFrame const * pPage ); + + void LockBackMove() { mbBackMoveLocked = true; } + void UnlockBackMove() { mbBackMoveLocked = false;} + bool IsBackMoveLocked() const { return mbBackMoveLocked; } + + // prevents that the last content deletes the SwFootnoteFrame as well (Cut()) + void ColLock() { mbColLocked = true; } + void ColUnlock() { mbColLocked = false; } + + // #i49383# + void UnlockPosOfLowerObjs() + { + mbUnlockPosOfLowerObjs = true; + } + void KeepLockPosOfLowerObjs() + { + mbUnlockPosOfLowerObjs = false; + } + bool IsUnlockPosOfLowerObjs() const + { + return mbUnlockPosOfLowerObjs; + } + + /** search for last content in the current footnote frame + + OD 2005-12-02 #i27138# + + @return SwContentFrame* + pointer to found last content frame. NULL, if none is found. + */ + SwContentFrame* FindLastContent(); + + void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; + void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/hffrm.hxx b/sw/source/core/inc/hffrm.hxx new file mode 100644 index 0000000000..4fed2517db --- /dev/null +++ b/sw/source/core/inc/hffrm.hxx @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_HFFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_HFFRM_HXX + +#include "layfrm.hxx" + +class SwViewShell; + +class SwHeadFootFrame : public SwLayoutFrame +{ +private: + std::vector GetSubsidiaryLinesPolygons(const SwViewShell& rViewShell) const; + +protected: + void FormatSize(SwTwips nUL, const SwBorderAttrs * pAttrs); + void FormatPrt(SwTwips & nUL, const SwBorderAttrs * pAttrs); + inline bool GetEatSpacing() const; // in hffrm.cxx + +public: + SwHeadFootFrame(SwFrameFormat * pFrame, SwFrame*, SwFrameType aType); + virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override; + virtual SwTwips GrowFrame( SwTwips, + bool bTst = false, bool bInfo = false ) override; + virtual SwTwips ShrinkFrame( SwTwips, + bool bTst = false, bool bInfo = false ) override; + virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override; + void AddSubsidiaryLinesBounds(const SwViewShell& rViewShell, RectangleVector& rRects) const; +}; + +/// Header in the document layout, inside a page. +class SwHeaderFrame final : public SwHeadFootFrame +{ +public: + SwHeaderFrame( SwFrameFormat* pFrame, SwFrame* pSib ) : SwHeadFootFrame(pFrame, pSib, SwFrameType::Header) {}; + + void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; +}; + +/// Footer in the document layout, inside a page. +class SwFooterFrame final : public SwHeadFootFrame +{ +public: + SwFooterFrame( SwFrameFormat* pFrame, SwFrame* pSib ) : SwHeadFootFrame(pFrame, pSib, SwFrameType::Footer) {}; + + void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/ifinishedthreadlistener.hxx b/sw/source/core/inc/ifinishedthreadlistener.hxx new file mode 100644 index 0000000000..2ff8197d2c --- /dev/null +++ b/sw/source/core/inc/ifinishedthreadlistener.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_IFINISHEDTHREADLISTENER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_IFINISHEDTHREADLISTENER_HXX + +#include + +/** interface class to listen on the finish of a thread + + OD 2007-03-30 #i73788# + Note: The thread provides its ThreadID on the finish notification +*/ +class IFinishedThreadListener +{ +public: + virtual ~IFinishedThreadListener() + { + }; + + virtual void NotifyAboutFinishedThread( const oslInterlockedCount nThreadID ) = 0; + +protected: + IFinishedThreadListener() + { + }; +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/layact.hxx b/sw/source/core/inc/layact.hxx new file mode 100644 index 0000000000..417d75deeb --- /dev/null +++ b/sw/source/core/inc/layact.hxx @@ -0,0 +1,235 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_LAYACT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_LAYACT_HXX + +#include + +#include +#include + +#include +#include +#include + +#include + +class OutputDevice; +class SwFrame; +class SwFrameDeleteGuard; +class SwRootFrame; +class SwLayoutFrame; +class SwPageFrame; +class SwFlyFrame; +class SwContentFrame; +class SwTabFrame; +class SwViewShellImp; +class SwContentNode; +class SwWait; + +/** + * The usage of LayAction is always the same: + * + * 1. Generation of the LayAction object. + * 2. Specifying the wanted behaviour via the Set-methods + * 3. Calling Action() + * 4. Soon after that the destruction of the object + * + * The object registers at the SwViewShellImp in the ctor and deregisters not until + * the dtor! + * It's a typical stack object. + */ +class SwLayAction +{ + SwRootFrame *m_pRoot; + SwViewShellImp *m_pImp; // here the action logs in and off + + // For the sake of optimization, so that the tables stick a bit better to + // the Cursor when hitting return/backspace in front of one. + // The first TabFrame that paints itself (per page) adds itself to the pointer. + // The ContentFrames beneath the page do not need to deregister at the Shell for + // painting. + const SwTabFrame *m_pOptTab; + + std::unique_ptr m_pWait; + + std::vector m_aFrameStack; + std::vector> m_aFrameDeleteGuards; + + // If a paragraph (or anything else) moved more than one page when + // formatting, it adds its new page number here. + // The InternalAction can then take the appropriate steps. + sal_uInt16 m_nPreInvaPage; + + std::clock_t m_nStartTicks; // The Action's starting time; if too much time passes the + // WaitCursor can be enabled via CheckWaitCursor() + + VclInputFlags m_nInputType; // Which input should terminate processing + sal_uInt16 m_nEndPage; // StatBar control + sal_uInt16 m_nCheckPageNum; // CheckPageDesc() was delayed if != USHRT_MAX + // check from this page onwards + + bool m_bPaint; // painting or only formatting? + bool m_bComplete; // Format everything or just the visible Area? + bool m_bCalcLayout; // Complete reformatting? + bool m_bAgain; // For the automatically repeated Action if Pages are deleted + bool m_bNextCycle; // Reset on the first invalid Page + bool m_bInterrupt; // For terminating processing on interrupt + bool m_bIdle; // True if the LayAction was triggered by the Idler + bool m_bReschedule; // Call Reschedule depending on Progress? + bool m_bCheckPages; // Run CheckPageDescs() or delay it + bool m_bUpdateExpFields; // Is set if, after Formatting, we need to do another round for ExpField + bool m_bBrowseActionStop; // Terminate Action early (as per bInput) and leave the rest to the Idler + bool m_bWaitAllowed; // Waitcursor allowed? + bool m_bPaintExtraData; // Painting line numbers (or similar) enabled? + bool m_bActionInProgress; // Is set in Action() at the beginning and deleted at the end + + // OD 14.04.2003 #106346# - new flag for content formatting on interrupt. + bool mbFormatContentOnInterrupt; + + void PaintContent( const SwContentFrame *, const SwPageFrame *, + const SwRect &rOldRect, tools::Long nOldBottom ); + bool PaintWithoutFlys( const SwRect &, const SwContentFrame *, + const SwPageFrame * ); + inline bool PaintContent_( const SwContentFrame *, const SwPageFrame *, + const SwRect & ); + + bool FormatLayout( OutputDevice* pRenderContext, SwLayoutFrame *, bool bAddRect = true ); + bool FormatLayoutTab( SwTabFrame *, bool bAddRect ); + bool FormatContent(SwPageFrame * pPage); + void FormatContent_( const SwContentFrame* pContent, + const SwPageFrame* pPage ); + bool IsShortCut( SwPageFrame *& ); + + bool TurboAction(); + bool TurboAction_( const SwContentFrame * ); + void InternalAction(OutputDevice* pRenderContext); + + static SwPageFrame *CheckFirstVisPage( SwPageFrame *pPage ); + + bool RemoveEmptyBrowserPages(); + + void PushFormatLayout(SwFrame* pLow); + void PopFormatLayout(); + + inline void CheckIdleEnd(); + +public: + SwLayAction( SwRootFrame *pRt, SwViewShellImp *pImp ); + ~SwLayAction(); + + void SetIdle ( bool bNew ) { m_bIdle = bNew; } + void SetCheckPages ( bool bNew ) { m_bCheckPages = bNew; } + void SetBrowseActionStop( bool bNew ) { m_bBrowseActionStop = bNew; } + void SetNextCycle ( bool bNew ) { m_bNextCycle = bNew; } + + bool IsWaitAllowed() const { return m_bWaitAllowed; } + bool IsNextCycle() const { return m_bNextCycle; } + bool IsPaint() const { return m_bPaint; } + bool IsIdle() const { return m_bIdle; } + bool IsReschedule() const { return m_bReschedule; } + bool IsPaintExtraData() const { return m_bPaintExtraData;} + bool IsInterrupt() const { return m_bInterrupt; } + + VclInputFlags GetInputType() const { return m_nInputType; } + + // adjusting Action to the wanted behaviour + void SetPaint ( bool bNew ) { m_bPaint = bNew; } + void SetComplete ( bool bNew ) { m_bComplete = bNew; } + void SetStatBar ( bool bNew ); + void SetInputType ( VclInputFlags nNew ) { m_nInputType = nNew; } + void SetCalcLayout ( bool bNew ) { m_bCalcLayout = bNew; } + void SetReschedule ( bool bNew ) { m_bReschedule = bNew; } + void SetWaitAllowed ( bool bNew ) { m_bWaitAllowed = bNew; } + + void SetAgain(bool bAgain); + void SetUpdateExpFields() {m_bUpdateExpFields = true; } + + inline void SetCheckPageNum( sal_uInt16 nNew ); + void SetCheckPageNumDirect( sal_uInt16 nNew ) { m_nCheckPageNum = nNew; } + + void Action(OutputDevice* pRenderContext); // here it begins + void Reset(); // back to CTor-defaults + + bool IsAgain() const { return m_bAgain; } + bool IsComplete() const { return m_bComplete; } + bool IsExpFields() const { return m_bUpdateExpFields; } + bool IsCalcLayout() const { return m_bCalcLayout; } + bool IsCheckPages() const { return m_bCheckPages; } + bool IsBrowseActionStop() const { return m_bBrowseActionStop; } + bool IsActionInProgress() const { return m_bActionInProgress; } + + sal_uInt16 GetCheckPageNum() const { return m_nCheckPageNum; } + + // others should be able to activate the WaitCursor, too + void CheckWaitCursor(); + + // #i28701# - method is now public; + // delete 2nd parameter, because it's not used; + void FormatLayoutFly( SwFlyFrame * ); + // #i28701# - method is now public + void FormatFlyContent( const SwFlyFrame * ); + +}; + +enum class IdleJobType +{ + ONLINE_SPELLING, + AUTOCOMPLETE_WORDS, + WORD_COUNT, + SMART_TAGS +}; + +enum class IdleJobArea +{ + ALL, + VISIBLE +}; + +class SwLayIdle +{ + SwRootFrame *m_pRoot; + SwViewShellImp *m_pImp; // The Idler registers and deregisters here + SwContentNode *m_pContentNode; // The current cursor position is saved here + sal_Int32 m_nTextPos; + bool m_bPageValid; // Were we able to evaluate everything on the whole page? +#ifdef DBG_UTIL + bool m_bIndicator; + + void ShowIdle( Color eName ); +#endif + + bool DoIdleJob_( const SwContentFrame*, IdleJobType ); + bool DoIdleJob(IdleJobType eJobType, IdleJobArea eJobArea); + + static bool isJobEnabled(IdleJobType eJob, const SwViewShell* pViewShell); +public: + SwLayIdle( SwRootFrame *pRt, SwViewShellImp *pImp ); + ~SwLayIdle(); +}; + +inline void SwLayAction::SetCheckPageNum( sal_uInt16 nNew ) +{ + if ( nNew < m_nCheckPageNum ) + m_nCheckPageNum = nNew; +} + +#endif // INCLUDED_SW_SOURCE_CORE_INC_LAYACT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/laycache.hxx b/sw/source/core/inc/laycache.hxx new file mode 100644 index 0000000000..27f36a96fa --- /dev/null +++ b/sw/source/core/inc/laycache.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_LAYCACHE_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_LAYCACHE_HXX + +#include +#include + +class SwDoc; +class SwLayCacheImpl; +class SvStream; + +/* + * This class allows to save layout information in the file and it contains + * this information after loading of a file. + * Call Write(..) with a stream and the document to save and the page break + * information of the document will be written. + * Call Read(..) with a stream and the member pLayCacheImpl will + * read the information from the stream and store it in an internal structure. + * There's a simple locking mechanism at these classes, + * if somebody reads the information, he increments the lock count by 1, + * during the Read(..) function the lock count will set to $8000. + */ +class SwLayoutCache +{ + std::unique_ptr m_pImpl; + sal_uInt16 m_nLockCount; + +public: + SwLayoutCache(); + ~SwLayoutCache(); + + void Read( SvStream &rStream ); + static void Write( SvStream &rStream, const SwDoc& rDoc ); + + void ClearImpl(); + bool IsLocked() const { return m_nLockCount > 0; } + sal_uInt16& GetLockCount() { return m_nLockCount; } + SwLayCacheImpl *LockImpl() + { if( m_nLockCount & 0x8000 ) return nullptr; + if ( m_pImpl ) + ++m_nLockCount; + return m_pImpl.get(); } + void UnlockImpl() { --m_nLockCount; } + +#ifdef DBG_UTIL + bool CompareLayout( const SwDoc& rDoc ) const; +#endif +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/layfrm.hxx b/sw/source/core/inc/layfrm.hxx new file mode 100644 index 0000000000..981fbb34f6 --- /dev/null +++ b/sw/source/core/inc/layfrm.hxx @@ -0,0 +1,225 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_LAYFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_LAYFRM_HXX + +#include "frame.hxx" +#include + +class SwAnchoredObject; +class SwContentFrame; +class SwFormatCol; +struct SwCursorMoveState; +class SwFrameFormat; +class SwBorderAttrs; +class SwFormatFrameSize; +class SwCellFrame; + +/// A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame. +class SW_DLLPUBLIC SwLayoutFrame: public SwFrame +{ + // The SwFrame in disguise + friend class SwFlowFrame; + friend class SwFrame; + + // Releases the Lower while restructuring columns + friend SwFrame* SaveContent( SwLayoutFrame *, SwFrame * ); + friend void RestoreContent( SwFrame *, SwLayoutFrame *, SwFrame *pSibling ); + +protected: + + virtual void DestroyImpl() override; + virtual ~SwLayoutFrame() override; + + virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override; + virtual void MakeAll(vcl::RenderContext* pRenderContext) override; + + SwFrame * m_pLower; + std::vector m_VertPosOrientFramesFor; + + virtual SwTwips ShrinkFrame( SwTwips, bool bTst = false, bool bInfo = false ) override; + virtual SwTwips GrowFrame ( SwTwips, bool bTst = false, bool bInfo = false ) override; + + tools::Long CalcRel( const SwFormatFrameSize &rSz ) const; + +public: + // --> #i28701# + + virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const; + void RefreshLaySubsidiary( const SwPageFrame*, const SwRect& ) const; + void RefreshExtraData( const SwRect & ) const; + + /// Change size of lowers proportionally + void ChgLowersProp( const Size& rOldSize ); + + void AdjustColumns( const SwFormatCol *pCol, bool bAdjustAttributes ); + + void ChgColumns( const SwFormatCol &rOld, const SwFormatCol &rNew, + const bool bChgFootnote = false ); + + /// Paints the column separation line for the inner columns + void PaintColLines( const SwRect &, const SwFormatCol &, + const SwPageFrame * ) const; + + virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const override; + + virtual bool GetModelPositionForViewPoint( SwPosition *, Point&, + SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override; + + virtual void Cut() override; + virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override; + + /** + * Finds the closest Content for the SPoint + * Is used for Pages, Flys and Cells if GetModelPositionForViewPoint failed + */ + const SwContentFrame* GetContentPos( Point &rPoint, const bool bDontLeave, + const bool bBodyOnly = false, + SwCursorMoveState *pCMS = nullptr, + const bool bDefaultExpand = true ) const; + + SwLayoutFrame( SwFrameFormat*, SwFrame* ); + + virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&, + SwPrintData const*const pPrintData = nullptr ) const override; + const SwFrame *Lower() const { return m_pLower; } + SwFrame *Lower() { return m_pLower; } + bool ContainsDeleteForbiddenLayFrame() const; + const SwContentFrame *ContainsContent() const; + inline SwContentFrame *ContainsContent(); + const SwCellFrame *FirstCell() const; + inline SwCellFrame *FirstCell(); + + /** + * Method doesn't investigate content of footnotes by default. + * But under certain circumstances this investigation is intended. + * Thus, introduce new optional parameter <_bInvestigateFootnoteForSections>. + * It's default is , still indicating that content of footnotes isn't + * investigated for sections. + */ + const SwFrame *ContainsAny( const bool _bInvestigateFootnoteForSections = false ) const; + inline SwFrame *ContainsAny( const bool _bInvestigateFootnoteForSections = false ); + bool IsAnLower( const SwFrame * ) const; + + virtual const SwFrameFormat *GetFormat() const; + virtual SwFrameFormat *GetFormat(); + void SetFrameFormat( SwFrameFormat* ); + + /** + * Moving the Footnotes of all Lowers - starting from StartContent + * + * @returns true if at least one Footnote was moved + * Calls the page number update if bFootnoteNums is set + */ + bool MoveLowerFootnotes( SwContentFrame *pStart, SwFootnoteBossFrame *pOldBoss, + SwFootnoteBossFrame *pNewBoss, const bool bFootnoteNums ); + + // --> #i28701# - change purpose of method and its name + // --> #i44016# - add parameter <_bUnlockPosOfObjs> to + /// force an unlockposition call for the lower objects. + void NotifyLowerObjs( const bool _bUnlockPosOfObjs = false ); + + /** + * Invalidates the inner Frames, whose width and/or height are + * calculated using percentages. + * Frames that are anchored to this or inner Frames, are also invalidated. + */ + void InvaPercentLowers( SwTwips nDiff = 0 ); + + /// Called by Format for Frames and Areas with columns + void FormatWidthCols( const SwBorderAttrs &, const SwTwips nBorder, + const SwTwips nMinHeight ); + + /** + * InnerHeight returns the height of the content and may be bigger or + * less than the PrtArea-Height of the layoutframe himself + */ + SwTwips InnerHeight() const; + + /** method to check relative position of layout frame to + a given layout frame. + + refactoring of pseudo-local method in + for #104840#. + + @param _aCheckRefLayFrame + constant reference of an instance of class which + is used as the reference for the relative position check. + + @return true, if is positioned before the layout frame

+ */ + bool IsBefore( const SwLayoutFrame* _pCheckRefLayFrame ) const; + + const SwFrame* GetLastLower() const; + inline SwFrame* GetLastLower(); + + virtual void PaintBreak() const; + + void SetVertPosOrientFrameFor(SwAnchoredObject *pObj) + { + m_VertPosOrientFramesFor.push_back(pObj); + } + + void ClearVertPosOrientFrameFor(SwAnchoredObject *pObj) + { + std::erase(m_VertPosOrientFramesFor, pObj); + } + void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override; +}; + +/** + * In order to save us from duplicating implementations, we cast here + * a little. + */ +inline SwContentFrame* SwLayoutFrame::ContainsContent() +{ + return const_cast(static_cast(this)->ContainsContent()); +} + +inline SwCellFrame* SwLayoutFrame::FirstCell() +{ + return const_cast(static_cast(this)->FirstCell()); +} + +inline SwFrame* SwLayoutFrame::ContainsAny( const bool _bInvestigateFootnoteForSections ) +{ + return const_cast(static_cast(this)->ContainsAny( _bInvestigateFootnoteForSections )); +} + +/** + * These SwFrame inlines are here, so that frame.hxx does not need to include layfrm.hxx + */ +inline bool SwFrame::IsColBodyFrame() const +{ + return mnFrameType == SwFrameType::Body && GetUpper()->IsColumnFrame(); +} + +inline bool SwFrame::IsPageBodyFrame() const +{ + return mnFrameType == SwFrameType::Body && GetUpper()->IsPageFrame(); +} + +inline SwFrame* SwLayoutFrame::GetLastLower() +{ + return const_cast(static_cast(this)->GetLastLower()); +} + +#endif // INCLUDED_SW_SOURCE_CORE_INC_LAYFRM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/layouter.hxx b/sw/source/core/inc/layouter.hxx new file mode 100644 index 0000000000..a3979cf467 --- /dev/null +++ b/sw/source/core/inc/layouter.hxx @@ -0,0 +1,146 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_LAYOUTER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_LAYOUTER_HXX + +#include +#include +#include + +class SwEndnoter; +class SwDoc; +class SwSectionFrame; +class SwFootnoteFrame; +class SwPageFrame; +class SwLooping; + +class SwMovedFwdFramesByObjPos; +class SwTextFrame; +class SwRowFrame; +class SwObjsMarkedAsTmpConsiderWrapInfluence; +class SwAnchoredObject; +class SwFlowFrame; +class SwLayoutFrame; + +#define LOOP_PAGE 1 + +class SwLayouter +{ + std::unique_ptr mpEndnoter; + std::unique_ptr mpLooping; + void CollectEndnotes_( SwSectionFrame* pSect ); + bool StartLooping( SwPageFrame const * pPage ); + + // --> #i28701# + std::unique_ptr mpMovedFwdFrames; + // --> #i35911# + std::unique_ptr mpObjsTmpConsiderWrapInfl; + +public: + // --> #i65250# + // - data structure to collect moving backward layout information + struct tMoveBwdLayoutInfoKey + { + // frame ID of flow frame + sal_uInt32 mnFrameId; + // position of new upper frame + SwTwips mnNewUpperPosX; + SwTwips mnNewUpperPosY; + // size of new upper frame + SwTwips mnNewUpperWidth; + SwTwips mnNewUpperHeight; + // free space in new upper frame + SwTwips mnFreeSpaceInNewUpper; + + }; +private: + struct fMoveBwdLayoutInfoKeyHash + { + size_t operator()( const tMoveBwdLayoutInfoKey& p_key ) const + { + return p_key.mnFrameId; + } + }; + struct fMoveBwdLayoutInfoKeyEq + { + bool operator()( const tMoveBwdLayoutInfoKey& p_key1, + const tMoveBwdLayoutInfoKey& p_key2 ) const + { + return p_key1.mnFrameId == p_key2.mnFrameId && + p_key1.mnNewUpperPosX == p_key2.mnNewUpperPosX && + p_key1.mnNewUpperPosY == p_key2.mnNewUpperPosY && + p_key1.mnNewUpperWidth == p_key2.mnNewUpperWidth && + p_key1.mnNewUpperHeight == p_key2.mnNewUpperHeight && + p_key1.mnFreeSpaceInNewUpper == p_key2.mnFreeSpaceInNewUpper; + } + }; + std::unordered_map< tMoveBwdLayoutInfoKey, sal_uInt16, + fMoveBwdLayoutInfoKeyHash, + fMoveBwdLayoutInfoKeyEq > maMoveBwdLayoutInfo; +public: + SwLayouter(); + ~SwLayouter(); + void InsertEndnotes( SwSectionFrame const * pSect ); + void CollectEndnote( SwFootnoteFrame* pFootnote ); + bool HasEndnotes() const; + + void LoopControl( SwPageFrame* pPage ); + void EndLoopControl(); + void LoopingLouieLight( const SwDoc& rDoc, const SwTextFrame& rFrame ); + + static void CollectEndnotes( SwDoc* pDoc, SwSectionFrame* pSect ); + static bool Collecting( SwDoc* pDoc, SwSectionFrame const * pSect, SwFootnoteFrame* pFootnote ); + static bool StartLoopControl( SwDoc* pDoc, SwPageFrame const *pPage ); + + // --> #i28701# + static void ClearMovedFwdFrames( const SwDoc& _rDoc ); + static void InsertMovedFwdFrame( const SwDoc& _rDoc, + const SwTextFrame& _rMovedFwdFrameByObjPos, + const sal_uInt32 _nToPageNum ); + static bool FrameMovedFwdByObjPos( const SwDoc& _rDoc, + const SwTextFrame& _rTextFrame, + sal_uInt32& _ornToPageNum ); + // --> #i40155# - unmark given frame as to be moved forward. + static void RemoveMovedFwdFrame( const SwDoc& _rDoc, + const SwTextFrame& _rTextFrame ); + // --> #i26945# + static bool DoesRowContainMovedFwdFrame( const SwDoc& _rDoc, + const SwRowFrame& _rRowFrame ); + + // --> #i35911# + static void ClearObjsTmpConsiderWrapInfluence( const SwDoc& _rDoc ); + static void InsertObjForTmpConsiderWrapInfluence( + const SwDoc& _rDoc, + SwAnchoredObject& _rAnchoredObj ); + static void RemoveObjForTmpConsiderWrapInfluence( + const SwDoc& _rDoc, + SwAnchoredObject& _rAnchoredObj ); + + // --> #i65250# + static bool MoveBwdSuppressed( const SwDoc& p_rDoc, + const SwFlowFrame& p_rFlowFrame, + const SwLayoutFrame& p_rNewUpperFrame ); + static void ClearMoveBwdLayoutInfo( const SwDoc& p_rDoc ); +}; + +extern void LOOPING_LOUIE_LIGHT( bool bCondition, const SwTextFrame& rTextFrame ); + +#endif // INCLUDED_SW_SOURCE_CORE_INC_LAYOUTER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/movedfwdfrmsbyobjpos.hxx b/sw/source/core/inc/movedfwdfrmsbyobjpos.hxx new file mode 100644 index 0000000000..c42944060c --- /dev/null +++ b/sw/source/core/inc/movedfwdfrmsbyobjpos.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_MOVEDFWDFRMSBYOBJPOS_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_MOVEDFWDFRMSBYOBJPOS_HXX + +#include +#include + +class SwTextNode; +class SwTextFrame; +// --> #i26945# +class SwRowFrame; + +typedef std::map< const SwTextNode*, const sal_uInt32 > NodeMap; + +class SwMovedFwdFramesByObjPos +{ + private: + NodeMap maMovedFwdFrames; + + public: + SwMovedFwdFramesByObjPos(); + ~SwMovedFwdFramesByObjPos(); + + void Insert( const SwTextFrame& _rMovedFwdFrameByObjPos, + const sal_uInt32 _nToPageNum ); + + // --> #i40155# + void Remove( const SwTextFrame& _rTextFrame ); + + bool FrameMovedFwdByObjPos( const SwTextFrame& _rTextFrame, + sal_uInt32& _ornToPageNum ) const; + + // --> #i26945# + bool DoesRowContainMovedFwdFrame( const SwRowFrame& _rRowFrame ) const; + + void Clear() { maMovedFwdFrames.clear(); }; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx new file mode 100644 index 0000000000..7491718191 --- /dev/null +++ b/sw/source/core/inc/mvsave.hxx @@ -0,0 +1,201 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX + +#include +#include +#include +#include +#include +#include +#include + +namespace sfx2 { + class MetadatableUndo; +} + +class SvNumberFormatter; +class SwDoc; +class SwFormatAnchor; +class SwFrameFormat; +class SwContentIndex; +class SwNodeRange; +class SwPaM; +class SwNode; +struct SwPosition; + +namespace sw::mark +{ + class IMark; + + class SaveBookmark + { + public: + SaveBookmark( + const ::sw::mark::IMark& rBkmk, + const SwNode& rMvPos, + std::optional oContentIdx); + void SetInDoc(SwDoc* pDoc, + const SwNode&, + std::optional oContentIdx = std::nullopt); + + private: + OUString m_aName; + OUString m_aShortName; + bool m_bHidden; + OUString m_aHideCondition; + vcl::KeyCode m_aCode; + IDocumentMarkAccess::MarkType m_eOrigBkmType; + SwNodeOffset m_nNode1; + SwNodeOffset m_nNode2; + sal_Int32 m_nContent1; + sal_Int32 m_nContent2; + std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo; + }; + + enum class RestoreMode { Flys = 1, NonFlys = 2, All = 3 }; + + /// Takes care of storing relevant attributes of an SwTextNode before split, then restore them on the new node. + class ContentIdxStore + { + public: + virtual bool Empty() =0; + virtual void Save(SwDoc& rDoc, SwNodeOffset nNode, sal_Int32 nContent, bool bSaveFlySplit=false) =0; + virtual void Restore(SwDoc& rDoc, SwNodeOffset nNode, sal_Int32 nOffset=0, bool bAuto = false, bool bAtStart = false, RestoreMode = RestoreMode::All) =0; + virtual void Restore(SwNode& rNd, sal_Int32 nLen, sal_Int32 nCorrLen, RestoreMode = RestoreMode::All) =0; + virtual ~ContentIdxStore() {}; + static std::shared_ptr Create(); + }; +} + +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +} + +void DelBookmarks(SwNode& rStt, + const SwNode& rEnd, + std::vector< ::sw::mark::SaveBookmark> * SaveBkmk =nullptr, + std::optional oStartContentIdx = std::nullopt, + std::optional oEndContentIdx = std::nullopt, + bool isReplace = false); + +/** data structure to temporarily hold fly anchor positions relative to some + * location. */ +struct SaveFly +{ + SwFrameFormat* pFrameFormat; /// the fly's frame format + SwNodeOffset nNdDiff; /// relative node difference + sal_Int32 nContentIndex; ///< index in node + bool isAtInsertNode; ///< if true, anchor _at_ insert node index + + SaveFly( SwNodeOffset nNodeDiff, sal_Int32 const nCntntIdx, SwFrameFormat* pFormat, bool bInsert ) + : pFrameFormat(pFormat) + , nNdDiff(nNodeDiff) + , nContentIndex(nCntntIdx) + , isAtInsertNode(bInsert) + { } +}; + +typedef std::deque< SaveFly > SaveFlyArr; + +void RestFlyInRange( SaveFlyArr& rArr, const SwPosition& rSttIdx, + const SwNode* pInsPos, bool isForceToStartPos = false); +void SaveFlyInRange( const SwNodeRange& rRg, SaveFlyArr& rArr ); +void SaveFlyInRange( const SwPaM& rPam, const SwPosition& rInsPos, + SaveFlyArr& rArr, bool bMoveAllFlys, SwHistory * pHistory = nullptr); + +void DelFlyInRange( SwNode& rMkNd, + SwNode& rPtNd, + std::optional nMkContentIdx = std::nullopt, + std::optional pPtContentIdx = std::nullopt); + +class SwDataChanged +{ + const SwPaM* m_pPam; + const SwPosition* m_pPos; + SwDoc& m_rDoc; + sal_Int32 m_nContent; + +public: + SwDataChanged( const SwPaM& rPam ); + SwDataChanged( SwDoc& rDoc, const SwPosition& rPos ); + ~SwDataChanged(); + + sal_Int32 GetContent() const { return m_nContent; } +}; + +/** + * Function declarations so that everything below the CursorShell can + * move the Cursor once in a while. + * These functions do not call the SwDoc::Corr methods! + */ +void PaMCorrAbs( const SwPaM& rRange, + const SwPosition& rNewPos ); + +/// Sets all PaMs in OldNode to relative Pos +void PaMCorrRel( const SwNode &rOldNode, + const SwPosition &rNewPos, + const sal_Int32 nOffset = 0 ); + +/** + * Helper to copy paragraph-bound Flys. + * By sorting by order number, we try to retain the layout. + */ +class ZSortFly +{ + const SwFrameFormat* m_pFormat; + const SwFormatAnchor* m_pAnchor; + sal_uInt32 m_nOrdNum; + +public: + ZSortFly( const SwFrameFormat* pFrameFormat, const SwFormatAnchor* pFlyAnchor, + sal_uInt32 nArrOrdNum ); + + bool operator==( const ZSortFly& ) const { return false; } + bool operator<( const ZSortFly& rCmp ) const + { return m_nOrdNum < rCmp.m_nOrdNum; } + + const SwFrameFormat* GetFormat() const { return m_pFormat; } + const SwFormatAnchor* GetAnchor() const { return m_pAnchor; } +}; + +class SwTableNumFormatMerge +{ + SvNumberFormatter* pNFormat; +public: + SwTableNumFormatMerge( const SwDoc& rSrc, SwDoc& rDest ); + ~SwTableNumFormatMerge(); +}; + +class SaveRedlEndPosForRestore +{ + std::vector mvSavArr; + std::optional moSaveIndex; + sal_Int32 mnSaveContent; + +public: + SaveRedlEndPosForRestore( const SwNode& rInsIdx, sal_Int32 nContent ); + ~SaveRedlEndPosForRestore(); + void Restore(); +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/node2lay.hxx b/sw/source/core/inc/node2lay.hxx new file mode 100644 index 0000000000..0ba712f197 --- /dev/null +++ b/sw/source/core/inc/node2lay.hxx @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_NODE2LAY_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_NODE2LAY_HXX + +#include + +#include + +/** + * This class connects the Nodes with the Layouts. + * It provides an intelligent iterator over Frames belonging to the Node or + * Node Range. Depending on the purpose of iterating (e.g. to insert other + * Frames before or after the Frames) Master/Follows are recognized and only + * the relevant ones are returned. Repeated table headers are also taken + * into account. + * It's possible to iterate over SectionNodes that are either not directly + * assigned to a SectionFrame or to multiple ones due to nesting. + * + * This class is an interface between the method and a SwClientIter: it + * chooses the right sw::BroadcastingModify depending on the task, creates a SwClientIter + * and filters its iterations depending on the task. + * The task is determined by the choice of class. + * + * 1. Collecting the UpperFrames (so that later RestoreUpperFrames can be called) + * is called by MakeFrames, if there's no PrevNext (before/after we can insert + * the Frames). + * 2. Inserting the Frames before/after which the new Frames of a Node need to + * be inserted, is also called by MakeFrames. + */ + +class SwNode2LayImpl; +class SwFrame; +class SwLayoutFrame; +class SwNode; +class SwNodes; +class Point; + +class SwNode2Layout +{ + std::unique_ptr m_pImpl; + +public: + /// Use this ctor for inserting before/after rNd + /// @param nIdx is the index of the to-be-inserted Node + SwNode2Layout(const SwNode& rNd, SwNodeOffset nIdx); + ~SwNode2Layout(); + SwFrame* NextFrame(); + SwLayoutFrame* UpperFrame(SwFrame*& rpFrame, const SwNode& rNode); + + SwFrame* GetFrame(const Point* pDocPos) const; +}; + +class SwNode2LayoutSaveUpperFrames +{ + std::unique_ptr m_pImpl; + +public: + /// Use this ctor for collecting the UpperFrames + SwNode2LayoutSaveUpperFrames(const SwNode& rNd); + ~SwNode2LayoutSaveUpperFrames(); + + void RestoreUpperFrames(SwNodes& rNds, SwNodeOffset nStt, SwNodeOffset nEnd); +}; + +namespace sw +{ +SwFrame const* FindNeighbourFrameForNode(SwNode const& rNode); + +} // namespace sw + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/noteurl.hxx b/sw/source/core/inc/noteurl.hxx new file mode 100644 index 0000000000..1e5775d3c0 --- /dev/null +++ b/sw/source/core/inc/noteurl.hxx @@ -0,0 +1,32 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_NOTEURL_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_NOTEURL_HXX + +class SwNoteURL +{ +}; + +// globale Variable, in NoteURL.Cxx angelegt +extern SwNoteURL* pNoteURL; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/notxtfrm.hxx b/sw/source/core/inc/notxtfrm.hxx new file mode 100644 index 0000000000..50612e396a --- /dev/null +++ b/sw/source/core/inc/notxtfrm.hxx @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_NOTXTFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_NOTXTFRM_HXX + +#include "cntfrm.hxx" +#include +// MM02 +#include + +class SwNoTextNode; +class OutputDevice; +class SwBorderAttrs; +struct SwCursorMoveState; + +class SwNoTextFrame final : public SwContentFrame +{ +private: + friend void FrameFinit(); + const Size& GetSize() const; + + void Format ( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override; + void PaintPicture( vcl::RenderContext*, const SwRect& ) const; + + virtual void DestroyImpl() override; + virtual ~SwNoTextFrame() override; + + // RotateFlyFrame3 add TransformableSwFrame + std::unique_ptr< TransformableSwFrame > mpTransformableSwFrame; + + // RotateFlyFrame3 - Support for inner frame of a SwGrfNode. + // Only for local data extraction. To uniquely access information + // for local transformation, use getFrameArea(Print)Transformation. + friend double getLocalFrameRotation_from_SwNoTextFrame(const SwNoTextFrame& rNoTextFrame); + double getLocalFrameRotation() const; + + void ClearCache(); + + // MM02 + std::unique_ptr mpViewContact; + sdr::contact::ViewContact& GetViewContact() const; + void OnGraphicArrived(); + + virtual void MakeAll(vcl::RenderContext* pRenderContext) override; + virtual void SwClientNotify(const SwModify&, const SfxHint&) override; + + void ImplPaintPictureGraphic( vcl::RenderContext* pOut, + SwGrfNode* pGrfNd, bool bPrn, + const SwRect& rAlignedGrfArea, SwViewShell* pShell, SwNoTextNode& rNoTNd ) const; + void ImplPaintPictureBitmap( vcl::RenderContext* pOut, + SwOLENode* pOLENd, bool bIsChart, bool bPrn, + const SwRect& rAlignedGrfArea, SwViewShell* pShell ) const; + void ImplPaintPictureAnimate(vcl::RenderContext* pOut, SwViewShell* pShell, + SwGrfNode* pGrfNd, const SwRect& rAlignedGrfArea) const; + void ImplPaintPictureReplacement(const GraphicObject& rGrfObj, SwGrfNode* pGrfNd, + const SwRect& rAlignedGrfArea, SwViewShell* pShell) const; + +public: + SwNoTextFrame( SwNoTextNode * const, SwFrame* ); + + const SwContentNode *GetNode() const + { return static_cast(GetDep()); } + SwContentNode *GetNode() + { return static_cast(GetDep()); } + + virtual bool LeftMargin(SwPaM *) const override; + virtual bool RightMargin(SwPaM *, bool bAPI = false) const override; + + virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&, + SwPrintData const*const pPrintData = nullptr ) const override; + virtual bool GetCharRect( SwRect &, const SwPosition&, + SwCursorMoveState* = nullptr, bool bAllowFarAway = true ) const override; + virtual bool GetModelPositionForViewPoint(SwPosition* pPos, Point& aPoint, + SwCursorMoveState* = nullptr, bool bTestBackground = false) const override; + + void GetGrfArea( SwRect &rRect, SwRect * ) const; + + bool IsTransparent() const; + + void StopAnimation( const OutputDevice* = nullptr ) const; + bool HasAnimation() const; + + // RotateFlyFrame3 - Support for Transformations + bool isTransformableSwFrame() const { return bool(mpTransformableSwFrame); } + TransformableSwFrame* getTransformableSwFrame() { return mpTransformableSwFrame.get(); } + const TransformableSwFrame* getTransformableSwFrame() const { return mpTransformableSwFrame.get(); } + + // RotateFlyFrame3 - Support for Transformations + virtual basegfx::B2DHomMatrix getFrameAreaTransformation() const override; + virtual basegfx::B2DHomMatrix getFramePrintAreaTransformation() const override; + + // RotateFlyFrame3 - Support for Transformations + virtual void transform_translate(const Point& rOffset) override; + + void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/objectformatter.hxx b/sw/source/core/inc/objectformatter.hxx new file mode 100644 index 0000000000..f85c12dc5f --- /dev/null +++ b/sw/source/core/inc/objectformatter.hxx @@ -0,0 +1,175 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_OBJECTFORMATTER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_OBJECTFORMATTER_HXX + +#include +#include + +class SwFrame; +// #i26945# +class SwTextFrame; +class SwLayoutFrame; +class SwPageFrame; +class SwAnchoredObject; +class SwLayAction; +// OD 2004-10-04 #i26945# +class SwPageNumAndTypeOfAnchors; + +// #i28701# +// Format floating screen objects, which are anchored at the given anchor frame +// and registered at the given page frame. + +class SwObjectFormatter +{ + private: + // page frame, at which the floating screen objects are registered. + const SwPageFrame& mrPageFrame; + + // value of document compatibility option 'Consider wrapping style on + // object positioning' + const bool mbConsiderWrapOnObjPos; + + // layout action calling the format of the floating screen objects + SwLayAction* mpLayAction; + + // data structure to collect page number of object's 'anchor' + // #i26945# + std::unique_ptr mpPgNumAndTypeOfAnchors; + + /** helper method for method - performs the intrinsic + format of the layout of the given layout frame and all its lower + layout frames. + + #i28701# + IMPORTANT NOTE: + Method corresponds to methods and + . Thus, its code for the formatting have + to be synchronised. + */ + void FormatLayout_( SwLayoutFrame& _rLayoutFrame ); + + /** helper method for method - performs the intrinsic + format of the content of the given floating screen object. + + #i28701# + */ + void FormatObjContent( SwAnchoredObject& _rAnchoredObj ); + + protected: + SwObjectFormatter( const SwPageFrame& _rPageFrame, + SwLayAction* _pLayAction, + const bool _bCollectPgNumOfAnchors = false ); + + static std::unique_ptr CreateObjFormatter( SwFrame& _rAnchorFrame, + const SwPageFrame& _rPageFrame, + SwLayAction* _pLayAction ); + + virtual SwFrame& GetAnchorFrame() = 0; + + const SwPageFrame& GetPageFrame() const + { + return mrPageFrame; + } + + bool ConsiderWrapOnObjPos() const + { + return mbConsiderWrapOnObjPos; + } + + SwLayAction* GetLayAction() + { + return mpLayAction; + } + + /** performs the intrinsic format of a given floating screen object and its content. + */ + void FormatObj_( SwAnchoredObject& _rAnchoredObj ); + + /** invokes the intrinsic format method for all floating screen objects, + anchored at anchor frame on the given page frame + + for format of floating screen objects for + follow text frames, the 'master' text frame is passed to the method. + Thus, the objects, whose anchor character is inside the follow text + frame can be formatted. + + @param _pMasterTextFrame + input parameter - pointer to 'master' text frame. default value: NULL + */ + bool FormatObjsAtFrame_( SwTextFrame* _pMasterTextFrame = nullptr ); + + /** accessor to collected anchored object + */ + SwAnchoredObject* GetCollectedObj( const sal_uInt32 _nIndex ); + + /** accessor to 'anchor' page number of collected anchored object + */ + sal_uInt32 GetPgNumOfCollected( const sal_uInt32 _nIndex ); + + /** accessor to 'anchor' type of collected anchored object + */ + bool IsCollectedAnchoredAtMaster( const sal_uInt32 _nIndex ); + + /** accessor to total number of collected anchored objects + */ + sal_uInt32 CountOfCollected(); + + public: + virtual ~SwObjectFormatter(); + + /** intrinsic method to format a certain floating screen object + + #i40147# - add parameter <_bCheckForMovedFwd> + + @param _rAnchoredObj + input parameter - anchored object, which have to be formatted. + + @param _bCheckForMovedFwd + input parameter - boolean indicating, that after a successful + format of the anchored object the anchor frame has to be checked, + if it would moved forward due to the positioning of the anchored object. + default value: false + value only considered, if wrapping style influence has to be + considered for the positioning of the anchored object. + */ + virtual bool DoFormatObj( SwAnchoredObject& _rAnchoredObj, + const bool _bCheckForMovedFwd = false ) = 0; + + /** intrinsic method to format all floating screen objects + */ + virtual bool DoFormatObjs() = 0; + + /** method to format all floating screen objects at the given anchor frame + */ + static bool FormatObjsAtFrame( SwFrame& _rAnchorFrame, + const SwPageFrame& _rPageFrame, + SwLayAction* _pLayAction = nullptr ); + + /** method to format a given floating screen object + */ + static bool FormatObj( SwAnchoredObject& _rAnchoredObj, + SwFrame* _pAnchorFrame = nullptr, + const SwPageFrame* _pPageFrame = nullptr, + SwLayAction* pLayAction = nullptr ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/observablethread.hxx b/sw/source/core/inc/observablethread.hxx new file mode 100644 index 0000000000..3d10a7f384 --- /dev/null +++ b/sw/source/core/inc/observablethread.hxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_OBSERVABLETHREAD_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_OBSERVABLETHREAD_HXX + +#include +#include +#include +#include + +class IFinishedThreadListener; + +/** class for an observable thread + + OD 2007-01-29 #i73788# + Note: A thread is ref-counted. Thus, an instance of a derived class has to + to be hold via a reference. The thread itself assures during its execution, + that the ref-count is increased. Its execution starts with its method + and ends with its method. + Note: A thread can be only observed by one or none thread observer in order + to notify, that the thread has finished its work. +*/ +class ObservableThread : public osl::Thread, + public salhelper::SimpleReferenceObject +{ + public: + + virtual ~ObservableThread() override; + + void SetListener( std::weak_ptr< IFinishedThreadListener > const & pThreadListener, + const oslInterlockedCount nThreadID ); + + // resolve ambiguity + using SimpleReferenceObject::operator new; + using SimpleReferenceObject::operator delete; + + protected: + + ObservableThread(); + + /** intrinsic function of the thread + + Important note: + Do not override this method again. Instead override . + Otherwise, it's not guaranteed, that its ref-count is increased + during the execution of the thread. + */ + virtual void SAL_CALL run() override; + + virtual void threadFunction() = 0; + + /** method called, when thread has finished its work + + Important note: + Do not override this method again. Instead override . + Otherwise, it's not guaranteed, that the ref-count is decreased at + the end of its execution and that the observer is notified, that + the thread has finished its work. + */ + virtual void SAL_CALL onTerminated() override; + + private: + + oslInterlockedCount mnThreadID; + + std::weak_ptr< IFinishedThreadListener > mpThreadListener; + +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/pagedeschint.hxx b/sw/source/core/inc/pagedeschint.hxx new file mode 100644 index 0000000000..2dbfec18da --- /dev/null +++ b/sw/source/core/inc/pagedeschint.hxx @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_PAGEDESCHINT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_PAGEDESCHINT_HXX + +#include + +class SwPageDesc; + +class SwPageDescHint final : public SfxHint +{ + SwPageDesc* m_pPageDesc; +public: + SwPageDescHint( SwPageDesc* p ) + : m_pPageDesc(p) + {} + + SwPageDesc* GetPageDesc() const { return m_pPageDesc; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx new file mode 100644 index 0000000000..54458032f1 --- /dev/null +++ b/sw/source/core/inc/pagefrm.hxx @@ -0,0 +1,468 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX + +#include +#include +#include "ftnboss.hxx" +#include "hffrm.hxx" + +#include + +class SwFlyFrame; +class SwFlyFrameFormat; +class SwPageDesc; +class SwContentFrame; +struct SwPosition; +struct SwCursorMoveState; +class SwAttrSetChg; +namespace vcl { class Font; } +class SwSortedObjs; +class SwAnchoredObject; +namespace sw { + class VirtPageNumHint; +} + +enum class SwPageFrameInvFlags : sal_uInt8 +{ + NONE = 0x00, + InvalidatePrt = 0x01, + SetCompletePaint = 0x02, + InvalidateNextPos = 0x04, + PrepareHeader = 0x08, + PrepareFooter = 0x10, + CheckGrid = 0x20, + InvalidateGrid = 0x40, +}; + +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +} + +/// A page of the document layout. Upper frame is expected to be an SwRootFrame +/// instance. At least an SwBodyFrame lower is expected. +class SW_DLLPUBLIC SwPageFrame final: public SwFootnoteBossFrame +{ + friend class SwFrame; + + std::unique_ptr m_pSortedObjs; + + SwPageDesc *m_pDesc; //PageDesc that describes the Page + + /// Physical page number: index into list of SwRootFrame lowers + sal_uInt16 m_nPhyPageNum; + + bool m_bInvalidContent :1; + bool m_bInvalidLayout :1; + bool m_bInvalidFlyContent :1; + bool m_bInvalidFlyLayout :1; + bool m_bInvalidFlyInCnt :1; + bool m_bFootnotePage :1; // This Page is for document end footnotes + bool m_bEmptyPage :1; // This Page is an explicitly empty page + bool m_bEndNotePage :1; // 'Footnote page' for end notes + bool m_bInvalidSpelling :1; // We need online spelling + bool m_bInvalidSmartTags :1; // We need checking for smarttags + bool m_bInvalidAutoCmplWrds :1; // Update auto complete word list + bool m_bInvalidWordCount :1; + bool m_bHasGrid :1; // Grid for Asian layout + + static const sal_Int8 snShadowPxWidth; + + void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, SwPageFrameInvFlags &, + SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr ); + + /// Adapt the max. footnote height in each single column + void SetColMaxFootnoteHeight(); + + /** determine rectangle for horizontal page shadow + + #i9719# + + @param _rPageRect + input parameter - constant instance reference of the page rectangle. + Generally, it's the frame area of the page, but for empty pages in print + preview, this parameter is useful. + + @param _pViewShell + input parameter - instance of the view shell, for which the rectangle + has to be generated. + + @param _orBottomShadowRect + output parameter - instance reference of the bottom shadow rectangle for + the given page rectangle + */ + + static void GetHorizontalShadowRect( const SwRect& _rPageRect, + const SwViewShell* _pViewShell, + OutputDevice const * pRenderContext, + SwRect& _orBottomShadowRect, + bool bPaintLeftShadow, + bool bPaintRightShadow, + bool bRightSidebar ); + + virtual void DestroyImpl() override; + virtual ~SwPageFrame() override; + virtual void MakeAll(vcl::RenderContext* pRenderContext) override; + virtual void SwClientNotify(const SwModify&, const SfxHint&) override; + + /// Calculate the content height of a page (without columns). + size_t GetContentHeight(const tools::Long nTop, const tools::Long nBottom) const; + + std::vector GetSubsidiaryLinesPolygons(const SwViewShell& rViewShell) const; + +public: + SwPageFrame( SwFrameFormat*, SwFrame*, SwPageDesc* ); + + /// Make this public, so that the SwViewShell can access it when switching from browse mode + /// Add/remove header/footer + void PrepareHeader(); + void PrepareFooter(); + + const SwSortedObjs *GetSortedObjs() const { return m_pSortedObjs.get(); } + SwSortedObjs *GetSortedObjs() { return m_pSortedObjs.get(); } + + void AppendDrawObjToPage( SwAnchoredObject& _rNewObj ); + void RemoveDrawObjFromPage( SwAnchoredObject& _rToRemoveObj ); + + void AppendFlyToPage( SwFlyFrame *pNew ); + void RemoveFlyFromPage( SwFlyFrame *pToRemove ); + void MoveFly( SwFlyFrame *pToMove, SwPageFrame *pDest ); // Optimized Remove/Append + + void SetPageDesc( SwPageDesc *, SwFrameFormat * ); + SwPageDesc *GetPageDesc() { return m_pDesc; } + const SwPageDesc *GetPageDesc() const { return m_pDesc; } + SwPageDesc *FindPageDesc(); + + SwContentFrame *FindLastBodyContent(); + inline SwContentFrame *FindFirstBodyContent(); + inline const SwContentFrame *FindFirstBodyContent() const; + inline const SwContentFrame *FindLastBodyContent() const; + + SwRect GetBoundRect(OutputDevice const * pOutputDevice) const; + + // Specialized GetContentPos() for Field in Frames + void GetContentPosition( const Point &rPt, SwPosition &rPos ) const; + + bool IsEmptyPage() const { return m_bEmptyPage; } // Explicitly empty page + + void UpdateFootnoteNum(); + + /// Always call after Paste + /// Creates the page-bound frames and formats the generic content + void PreparePage( bool bFootnote ); + + // Sends a Prepare() to all ContentFrames caused by a changed register template + void PrepareRegisterChg(); + + // Appends a fly frame - the given one or a new one - at the page frame. + // Needed for and + // - return value not needed any more + // - second parameter is of type + // - third parameter only needed for assertion, but calling method assures + // this assertion. Thus, delete it. + void PlaceFly( SwFlyFrame* pFly, SwFlyFrameFormat* pFormat ); + + virtual bool GetModelPositionForViewPoint( SwPosition *, Point&, + SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override; + virtual void Cut() override; + virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override; + virtual void CheckDirection( bool bVert ) override; + void CheckGrid( bool bInvalidate ); + void PaintGrid( OutputDevice const * pOut, SwRect const &rRect ) const; + bool HasGrid() const { return m_bHasGrid; } + + void PaintDecorators( ) const; + virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override; + void AddSubsidiaryLinesBounds(const SwViewShell& rShell, RectangleVector& rRects) const; + virtual void PaintBreak() const override; + + /// Paint line number etc. + void RefreshExtraData( const SwRect & ) const; + + /// Paint helper lines + void RefreshSubsidiary( const SwRect& ) const; + + /// Foot note interface + bool IsFootnotePage() const { return m_bFootnotePage; } + bool IsEndNotePage() const { return m_bEndNotePage; } + void SetFootnotePage( bool b ) { m_bFootnotePage = b; } + void SetEndNotePage( bool b ) { m_bEndNotePage = b; } + + sal_uInt16 GetPhyPageNum() const { return m_nPhyPageNum;} + void SetPhyPageNum( sal_uInt16 nNum ) { m_nPhyPageNum = nNum;} + + /// Validate, invalidate and query the Page status + /// Layout/Content and Fly/non-Fly respectively are inspected separately + inline void InvalidateFlyLayout() const; + inline void InvalidateFlyContent() const; + inline void InvalidateFlyInCnt() const; + inline void InvalidateLayout() const; + inline void InvalidateContent() const; + inline void InvalidateSpelling() const; + inline void InvalidateSmartTags() const; + inline void InvalidateAutoCompleteWords() const; + inline void InvalidateWordCount() const; + inline void ValidateFlyLayout() const; + inline void ValidateFlyContent() const; + inline void ValidateFlyInCnt() const; + inline void ValidateLayout() const; + inline void ValidateContent() const; + inline void ValidateSpelling() const; + inline void ValidateSmartTags() const; + inline void ValidateAutoCompleteWords() const; + inline void ValidateWordCount() const; + inline bool IsInvalid() const; + inline bool IsInvalidFly() const; + bool IsRightShadowNeeded() const; + bool IsLeftShadowNeeded() const; + bool IsInvalidFlyLayout() const { return m_bInvalidFlyLayout; } + bool IsInvalidFlyContent() const { return m_bInvalidFlyContent; } + bool IsInvalidFlyInCnt() const { return m_bInvalidFlyInCnt; } + bool IsInvalidLayout() const { return m_bInvalidLayout; } + bool IsInvalidContent() const { return (m_bInvalidContent || m_bInvalidFlyInCnt); } + bool IsInvalidSpelling() const { return m_bInvalidSpelling; } + bool IsInvalidSmartTags() const { return m_bInvalidSmartTags; } + bool IsInvalidAutoCompleteWords() const { return m_bInvalidAutoCmplWrds; } + bool IsInvalidWordCount() const { return m_bInvalidWordCount; } + + /** SwPageFrame::GetDrawBackgroundColor + + determine the color, that is respectively will be drawn as background + for the page frame. + + @return reference to an instance of class Color + */ + Color GetDrawBackgroundColor() const; + + /** paint margin area of a page + + implement paint of margin area; margin area will be painted for a + view shell with a window and if the document is not in online layout. + + @param _rOutputRect + input parameter - constant instance reference of the rectangle, for + which an output has to be generated. + + @param _pViewShell + input parameter - instance of the view shell, on which the output + has to be generated. + */ + void PaintMarginArea( const SwRect& _rOutputRect, + SwViewShell const * _pViewShell ) const; + + /** paint page border and shadow + + @param _rPageRect + input parameter - constant instance reference of the page rectangle. + Generally, it's the frame area of the page, but for empty pages in print + preview, this parameter is useful. + + @param _pViewShell + input parameter - instance of the view shell, on which the output + has to be generated. + + @param bPaintRightShadow + Should we paint shadow on the right or not (used in book mode) + + @param bFullBottomShadow + Should we have a bottom shadow of the same size as the pages or + not (for right pages in book mode in a LTR environment). + + @param bRightSidebar + Is the note sidebar on the right or not (used to adjust the + shadow with & position). + */ + static void PaintBorderAndShadow( const SwRect& _rPageRect, + const SwViewShell* _pViewShell, + bool bPaintLeftShadow, + bool bPaintRightShadow, + bool bRightSidebar ); + + /** get bound rectangle of border and shadow for repaints + + @param _rPageRect + input parameter - constant instance reference of the page rectangle. + Generally, it's the frame area of the page, but for empty pages in print + preview, this parameter is useful. + + @param _pViewShell + input parameter - instance of the view shell, for which the rectangle + has to be generated. + + @param _orBorderAndShadowBoundRect + output parameter - instance reference of the bounded border and shadow + rectangle for the given page rectangle + */ + static void GetBorderAndShadowBoundRect( const SwRect& _rPageRect, + const SwViewShell* _pViewShell, + OutputDevice const * pRenderContext, + SwRect& _orBorderAndShadowBoundRect, + const bool bLeftShadow, + const bool bRightShadow, + const bool bRightSidebar + ); + + static void PaintNotesSidebar(const SwRect& _rPageRect, SwViewShell* _pViewShell, sal_uInt16 nPageNum, bool bRight); + static void PaintNotesSidebarArrows(const Point &rMiddleFirst, const Point &rMiddleSecond, SwViewShell const * _pViewShell, const Color& rColorUp, const Color& rColorDown); + /** + asks the page on which side a margin should be shown, e.g for notes + returns true for left side, false for right side + */ + sw::sidebarwindows::SidebarPosition SidebarPosition() const; + + virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const override; + + SwRect PrtWithoutHeaderAndFooter() const; + + // in case this is an empty page, this function returns the 'reference' page + const SwPageFrame& GetFormatPage() const; + + /// If in header or footer area, it also indicates the exact area in rControl. + /// Header or footer must be active, otherwise returns false. + bool IsOverHeaderFooterArea( const Point& rPt, FrameControlType &rControl ) const; + + // return font used to paint the "empty page" string + static const vcl::Font& GetEmptyPageFont(); + + static SwTwips GetSidebarBorderWidth( const SwViewShell* ); + + /// Is bottom-of-page-frame - bottom-of-text-frame difference valid in case whitespace is hidden? + /// If false is returned, then the caller should handle negative difference as (at least) zero difference instead. + bool CheckPageHeightValidForHideWhitespace(SwTwips nDiff); + + const SwHeaderFrame* GetHeaderFrame() const; + const SwFooterFrame* GetFooterFrame() const; + + void UpdateVirtPageNumInfo(sw::VirtPageNumHint& rHint, const SwFrame* pFrame) const; + + void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; +}; + +inline SwContentFrame *SwPageFrame::FindFirstBodyContent() +{ + SwLayoutFrame *pBody = FindBodyCont(); + return pBody ? pBody->ContainsContent() : nullptr; +} +inline const SwContentFrame *SwPageFrame::FindFirstBodyContent() const +{ + const SwLayoutFrame *pBody = FindBodyCont(); + return pBody ? pBody->ContainsContent() : nullptr; +} +inline const SwContentFrame *SwPageFrame::FindLastBodyContent() const +{ + return const_cast(this)->FindLastBodyContent(); +} +inline void SwPageFrame::InvalidateFlyLayout() const +{ + const_cast(this)->m_bInvalidFlyLayout = true; +} +inline void SwPageFrame::InvalidateFlyContent() const +{ + const_cast(this)->m_bInvalidFlyContent = true; +} +inline void SwPageFrame::InvalidateFlyInCnt() const +{ + const_cast(this)->m_bInvalidFlyInCnt = true; +} +inline void SwPageFrame::InvalidateLayout() const +{ + const_cast(this)->m_bInvalidLayout = true; +} +inline void SwPageFrame::InvalidateContent() const +{ + const_cast(this)->m_bInvalidContent = true; +} +inline void SwPageFrame::InvalidateSpelling() const +{ + const_cast(this)->m_bInvalidSpelling = true; +} + +inline void SwPageFrame::InvalidateSmartTags() const +{ + const_cast(this)->m_bInvalidSmartTags = true; +} +inline void SwPageFrame::InvalidateAutoCompleteWords() const +{ + const_cast(this)->m_bInvalidAutoCmplWrds = true; +} +inline void SwPageFrame::InvalidateWordCount() const +{ + const_cast(this)->m_bInvalidWordCount = true; +} +inline void SwPageFrame::ValidateFlyLayout() const +{ + const_cast(this)->m_bInvalidFlyLayout = false; +} +inline void SwPageFrame::ValidateFlyContent() const +{ + const_cast(this)->m_bInvalidFlyContent = false; +} +inline void SwPageFrame::ValidateFlyInCnt() const +{ + const_cast(this)->m_bInvalidFlyInCnt = false; +} +inline void SwPageFrame::ValidateLayout() const +{ + const_cast(this)->m_bInvalidLayout = false; +} +inline void SwPageFrame::ValidateContent() const +{ + const_cast(this)->m_bInvalidContent = false; +} +inline void SwPageFrame::ValidateSpelling() const +{ + const_cast(this)->m_bInvalidSpelling = false; +} + +inline void SwPageFrame::ValidateSmartTags() const +{ + const_cast(this)->m_bInvalidSmartTags = false; +} +inline void SwPageFrame::ValidateAutoCompleteWords() const +{ + const_cast(this)->m_bInvalidAutoCmplWrds = false; +} +inline void SwPageFrame::ValidateWordCount() const +{ + const_cast(this)->m_bInvalidWordCount = false; +} + +inline bool SwPageFrame::IsInvalid() const +{ + return (m_bInvalidContent || m_bInvalidLayout || m_bInvalidFlyInCnt); +} +inline bool SwPageFrame::IsInvalidFly() const +{ + return m_bInvalidFlyLayout || m_bInvalidFlyContent; +} + + +class SwTextGridItem; + +SwTextGridItem const* GetGridItem(SwPageFrame const*const); + +sal_uInt16 GetGridWidth(SwTextGridItem const&, SwDoc const&); + +namespace sw { bool IsPageFrameEmpty(SwPageFrame const& rPage); } + + +#endif // INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/paintfrm.hxx b/sw/source/core/inc/paintfrm.hxx new file mode 100644 index 0000000000..dca4a3871b --- /dev/null +++ b/sw/source/core/inc/paintfrm.hxx @@ -0,0 +1,37 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_PAINTFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_PAINTFRM_HXX + +#include + +extern Color aGlobalRetoucheColor; + +class OutputDevice; +namespace vcl +{ +typedef OutputDevice RenderContext; +}; + +void SwCalcPixStatics(vcl::RenderContext const* pOut); + +#endif // INCLUDED_SW_SOURCE_CORE_INC_PAINTFRM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/pamtyp.hxx b/sw/source/core/inc/pamtyp.hxx new file mode 100644 index 0000000000..d8c1110dea --- /dev/null +++ b/sw/source/core/inc/pamtyp.hxx @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_PAMTYP_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_PAMTYP_HXX + +#include + +#include +#include + +class SwpHints; +struct SwPosition; +class SwPaM; +class SwTextAttr; +class SwFormat; +class SfxPoolItem; +class SwRootFrame; +class SwNode; +class SwNodeIndex; +class SwContentNode; +class SwContentIndex; +class SvxSearchItem; +enum class SwCursorSkipMode; + +namespace i18nutil { + struct SearchOptions2; +} + +// function prototypes for the move/find methods of SwPaM + +void GoStartDoc( SwPosition*); +void GoEndDoc( SwPosition*); +void GoStartSection( SwPosition*); +void GoEndSection( SwPosition*); +void GoStartOfSection( SwPosition*); +void GoEndOfSection( SwPosition*); +const SwTextAttr* GetFrwrdTextHint( const SwpHints&, size_t&, sal_Int32 ); +const SwTextAttr* GetBkwrdTextHint( const SwpHints&, size_t&, sal_Int32 ); + +bool GoNext(SwNode* pNd, SwContentIndex * pIdx, SwCursorSkipMode nMode ); +bool GoPrevious(SwNode* pNd, SwContentIndex * pIdx, SwCursorSkipMode nMode ); +SwContentNode* GoNextNds( SwNodeIndex * pIdx, bool ); +SwContentNode* GoPreviousNds( SwNodeIndex * pIdx, bool ); +SwContentNode* GoNextPos( SwPosition * pIdx, bool ); +SwContentNode* GoPreviousPos( SwPosition * pIdx, bool ); + +// type definitions of functions +typedef bool (*GoNd)( SwNode*, SwContentIndex*, SwCursorSkipMode ); +typedef SwContentNode* (*GoNds)( SwNodeIndex*, bool ); +typedef SwContentNode* (*GoPos)( SwPosition*, bool ); +typedef void (*GoDoc)( SwPosition* ); +typedef void (*GoSection)( SwPosition* ); +typedef bool (SwPosition::*CmpOp)( const SwPosition& ) const; +typedef const SwTextAttr* (*GetHint)( const SwpHints&, size_t&, sal_Int32 ); +typedef bool (utl::TextSearch::*SearchText)( const OUString&, sal_Int32*, + sal_Int32*, css::util::SearchResult* ); +typedef void (*MvSection)( SwPosition * ); + +struct SwMoveFnCollection +{ + GoNd fnNd; + GoNds fnNds; + GoPos fnPos; + GoDoc fnDoc; + GoSection fnSections; + CmpOp fnCmpOp; + GetHint fnGetHint; + SearchText fnSearch; + MvSection fnSection; +}; + +// function prototype for searching +SwContentNode* GetNode(SwPaM&, bool&, SwMoveFnCollection const &, + bool bInReadOnly = false, SwRootFrame const* pLayout = nullptr); + +namespace sw { + + void MakeRegion(SwMoveFnCollection const & fnMove, + const SwPaM & rOrigRg, std::optional& rDestinaton); + + /// Search. + bool FindTextImpl(SwPaM & rSearchPam, + const i18nutil::SearchOptions2& rSearchOpt, + bool bSearchInNotes, + utl::TextSearch& rSText, + SwMoveFnCollection const & fnMove, + const SwPaM & rRegion, bool bInReadOnly, + SwRootFrame const* pLayout, + std::unique_ptr& xSearchItem); + bool FindFormatImpl(SwPaM & rSearchPam, + const SwFormat& rFormat, + SwMoveFnCollection const & fnMove, + const SwPaM & rRegion, bool bInReadOnly, + SwRootFrame const* pLayout); + bool FindAttrImpl(SwPaM & rSearchPam, + const SfxPoolItem& rAttr, + SwMoveFnCollection const & fnMove, + const SwPaM & rPam, bool bInReadOnly, + SwRootFrame const* pLayout); + +} // namespace sw + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/prevwpage.hxx b/sw/source/core/inc/prevwpage.hxx new file mode 100644 index 0000000000..d9c8d1df0f --- /dev/null +++ b/sw/source/core/inc/prevwpage.hxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_PREVWPAGE_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_PREVWPAGE_HXX + +// classes , and +#include + +class SwPageFrame; + +/** data structure for a preview page in the current preview layout +*/ +struct PreviewPage +{ + const SwPageFrame* pPage; + bool bVisible; + Size aPageSize; + Point aPreviewWinPos; + Point aLogicPos; + Point aMapOffset; + + inline PreviewPage(); +}; + +inline PreviewPage::PreviewPage() + : pPage( nullptr ), + bVisible( false ), + aPageSize( Size(0,0) ), + aPreviewWinPos( Point(0,0) ), + aLogicPos( Point(0,0) ), + aMapOffset( Point(0,0) ) +{}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/ptqueue.hxx b/sw/source/core/inc/ptqueue.hxx new file mode 100644 index 0000000000..a5e40f2e3f --- /dev/null +++ b/sw/source/core/inc/ptqueue.hxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_PTQUEUE_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_PTQUEUE_HXX + +/** + * Unfortunately we have some problems with processing more than one Paint() + * at a time. This happens especially often during printing. + * + * SwRootFrame::PaintSwFrame() determines that it's called a second time and adds the + * rectangle and the corresponding Shell to the PaintCollector. + * The call sites that are causing the double Paint() only need to process the + * collected Paint()s at the right point in time. + * Doing this during printing (after having printed one page) is very suitable + * for doing that. + * + * Invalidating windows directly from the RootFrame::PaintSwFrame was not a successful + * approach, because the Paint()s arrive at a very unfavourable point in time. + * Triggering an update for all windows after printing each page does not seem + * appropriate either: on the one hand we don't have direct access to the edit + * windows and on the other hand the updates can become very costly on some + * platforms. + */ + +class SwQueuedPaint; +class SwViewShell; +class SwRect; + +class SwPaintQueue +{ +public: + static SwQueuedPaint* s_pPaintQueue; + + static void Add(SwViewShell* pSh, const SwRect& rNew); + static void Remove(SwViewShell const* pSh); + static void Repaint(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/retrievedinputstreamdata.hxx b/sw/source/core/inc/retrievedinputstreamdata.hxx new file mode 100644 index 0000000000..ddb2c564a1 --- /dev/null +++ b/sw/source/core/inc/retrievedinputstreamdata.hxx @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_RETRIEVEDINPUTSTREAMDATA_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_RETRIEVEDINPUTSTREAMDATA_HXX + +#include +#include +#include +#include + +#include +#include +#include + +namespace com::sun::star::io { class XInputStream; } + +class SwAsyncRetrieveInputStreamThreadConsumer; + +/** Singleton class to manage retrieved input stream data in Writer + + OD 2007-01-29 #i73788# + The instance of this class provides data container for retrieved input + stream data. The data container is accessed via a key, which the data + manager provides on creation of the data container. + When a certain data container is filled with data, an user event is submitted + to trigger the processing of with data. +*/ +class SwRetrievedInputStreamDataManager +{ + public: + + typedef sal_uInt64 tDataKey; + + struct tData + { + std::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer; + css::uno::Reference mxInputStream; + bool mbIsStreamReadOnly; + + tData() + : mpThreadConsumer(), + mbIsStreamReadOnly( false ) + {}; + + tData( std::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > pThreadConsumer ) + : mpThreadConsumer(std::move( pThreadConsumer )), + mbIsStreamReadOnly( false ) + {}; + }; + + static SwRetrievedInputStreamDataManager& GetManager(); + + tDataKey ReserveData( std::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > const & pThreadConsumer ); + + void PushData( const tDataKey nDataKey, + css::uno::Reference const & xInputStream, + const bool bIsStreamReadOnly ); + + bool PopData( const tDataKey nDataKey, + tData& rData ); + + DECL_STATIC_LINK( SwRetrievedInputStreamDataManager, LinkedInputStreamReady, void*, void ); + + private: + + static tDataKey snNextKeyValue; + + std::mutex maMutex; + + std::map< tDataKey, tData > maInputStreamData; +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/retrieveinputstream.hxx b/sw/source/core/inc/retrieveinputstream.hxx new file mode 100644 index 0000000000..b030ed0fc5 --- /dev/null +++ b/sw/source/core/inc/retrieveinputstream.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_RETRIEVEINPUTSTREAM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_RETRIEVEINPUTSTREAM_HXX + +#include "observablethread.hxx" +#include +#include +#include "retrievedinputstreamdata.hxx" + +/** class for a thread to retrieve an input stream given by a URL + + OD 2007-01-29 #i73788# +*/ +class SwAsyncRetrieveInputStreamThread final : public ObservableThread +{ + public: + + static ::rtl::Reference< ObservableThread > createThread( + const SwRetrievedInputStreamDataManager::tDataKey nDataKey, + const OUString& rLinkedURL, const OUString& rReferer ); + + virtual ~SwAsyncRetrieveInputStreamThread() override; + + private: + + virtual void threadFunction() override; + + SwAsyncRetrieveInputStreamThread( const SwRetrievedInputStreamDataManager::tDataKey nDataKey, + OUString aLinkedURL, + OUString aReferer ); + + const SwRetrievedInputStreamDataManager::tDataKey mnDataKey; + const OUString mrLinkedURL; + const OUString mrReferer; +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/retrieveinputstreamconsumer.hxx b/sw/source/core/inc/retrieveinputstreamconsumer.hxx new file mode 100644 index 0000000000..ba6424e9a1 --- /dev/null +++ b/sw/source/core/inc/retrieveinputstreamconsumer.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_RETRIEVEINPUTSTREAMCONSUMER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_RETRIEVEINPUTSTREAMCONSUMER_HXX + +#include +#include + +namespace com::sun::star::io { class XInputStream; } +namespace com::sun::star::uno { template class Reference; } + +class SwGrfNode; + +/** class to provide creation of a thread to retrieve an input stream given by + a URL and to consume the retrieved input stream. + + #i73788# +*/ +class SwAsyncRetrieveInputStreamThreadConsumer +{ + public: + + SwAsyncRetrieveInputStreamThreadConsumer( SwGrfNode& rGrfNode ); + ~SwAsyncRetrieveInputStreamThreadConsumer() COVERITY_NOEXCEPT_FALSE; + + /** method to create thread + */ + void CreateThread( const OUString& rURL, const OUString& rReferer ); + + /** method called to provide the retrieved input stream to the thread Consumer + */ + void ApplyInputStream( + css::uno::Reference const & xInputStream, + const bool bIsStreamReadOnly ); + + private: + + SwGrfNode& mrGrfNode; + oslInterlockedCount mnThreadID; +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/rolbck.hxx b/sw/source/core/inc/rolbck.hxx new file mode 100644 index 0000000000..9d74a6a9e6 --- /dev/null +++ b/sw/source/core/inc/rolbck.hxx @@ -0,0 +1,443 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_ROLBCK_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_ROLBCK_HXX + +#include +#include +#include +#include +#include + +#include + +#include +#include + +namespace sfx2 { + class MetadatableUndo; +} +namespace sw { + class SpzFrameFormat; +} + +class SwDoc; +class SwFormatColl; +class SwTextAttr; +class SfxPoolItem; +class SwUndoSaveSection; +class SwTextFootnote; +class SwUndoDelLayFormat; +class SwFlyFrameFormat; +class SwFormatField; +class SwTextField; +class SwFieldType; +class SwTextTOXMark; +class SwTextRefMark; +class SwFrameFormat; +class SwpHints; +class SwFormatChain; +class SwNode; +class SwCharFormat; +enum class SwFieldIds : sal_uInt16; +typedef struct _xmlTextWriter* xmlTextWriterPtr; + +enum HISTORY_HINT { + HSTRY_SETFMTHNT, + HSTRY_RESETFMTHNT, + HSTRY_SETTXTHNT, + HSTRY_SETTXTFLDHNT, + HSTRY_SETREFMARKHNT, + HSTRY_SETTOXMARKHNT, + HSTRY_RESETTXTHNT, + HSTRY_SETFTNHNT, + HSTRY_CHGFMTCOLL, + HSTRY_FLYCNT, + HSTRY_BOOKMARK, + HSTRY_SETATTRSET, + HSTRY_CHGFLYANCHOR, + HSTRY_CHGFLYCHAIN, + HSTRY_CHGCHARFMT, + HSTRY_NOTEXTFIELDMARK, + HSTRY_TEXTFIELDMARK, +}; + +class SwHistoryHint +{ + const HISTORY_HINT m_eWhichId; + +public: + SwHistoryHint( HISTORY_HINT eWhich ) : m_eWhichId( eWhich ) {} + virtual ~SwHistoryHint() {} + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) = 0; + HISTORY_HINT Which() const { return m_eWhichId; } + virtual OUString GetDescription() const; + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const; +}; + +class SwHistorySetFormat final : public SwHistoryHint +{ + std::unique_ptr m_pAttr; + const SwNodeOffset m_nNodeIndex; + +public: + SwHistorySetFormat( const SfxPoolItem* pFormatHt, SwNodeOffset nNode ); + virtual ~SwHistorySetFormat() override; + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; + virtual OUString GetDescription() const override; + + void dumpAsXml(xmlTextWriterPtr pWriter) const override; +}; + +class SwHistoryResetFormat final : public SwHistoryHint +{ + const SwNodeOffset m_nNodeIndex; + const sal_uInt16 m_nWhich; + +public: + SwHistoryResetFormat( const SfxPoolItem* pFormatHt, SwNodeOffset nNodeIdx ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; + +}; + +class SwHistorySetText final : public SwHistoryHint +{ + std::unique_ptr m_pAttr; + const SwNodeOffset m_nNodeIndex; + const sal_Int32 m_nStart; + const sal_Int32 m_nEnd; + bool m_bFormatIgnoreStart : 1; + bool m_bFormatIgnoreEnd : 1; + +public: + SwHistorySetText( SwTextAttr* pTextHt, SwNodeOffset nNode ); + virtual ~SwHistorySetText() override; + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; + +}; + +class SwHistorySetTextField final : public SwHistoryHint +{ + //!! beware of the order for the declaration of the unique_ptrs. + //!! If they get destroyed in the wrong order sw may crash (namely mail-merge as well) + std::unique_ptr m_pFieldType; + const std::unique_ptr m_pField; + + SwNodeOffset m_nNodeIndex; + sal_Int32 m_nPos; + SwFieldIds m_nFieldWhich; + +public: + SwHistorySetTextField( const SwTextField* pTextField, SwNodeOffset nNode ); + virtual ~SwHistorySetTextField() override; + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; + + virtual OUString GetDescription() const override; + +}; + +class SwHistorySetRefMark final : public SwHistoryHint +{ + const OUString m_RefName; + const SwNodeOffset m_nNodeIndex; + const sal_Int32 m_nStart; + const sal_Int32 m_nEnd; + +public: + SwHistorySetRefMark( const SwTextRefMark* pTextHt, SwNodeOffset nNode ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; + const OUString& GetRefName() {return m_RefName;} +}; + +class SwHistorySetTOXMark final : public SwHistoryHint +{ + SwTOXMark m_TOXMark; + const OUString m_TOXName; + const TOXTypes m_eTOXTypes; + const SwNodeOffset m_nNodeIndex; + const sal_Int32 m_nStart; + const sal_Int32 m_nEnd; + +public: + SwHistorySetTOXMark( const SwTextTOXMark* pTextHt, SwNodeOffset nNode ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; + bool IsEqual( const SwTOXMark& rCmp ) const; + + static SwTOXType* GetSwTOXType(SwDoc& rDoc, TOXTypes eTOXTypes, const OUString& rTOXName); +}; + +class SwHistoryResetText final : public SwHistoryHint +{ + const SwNodeOffset m_nNodeIndex; + const sal_Int32 m_nStart; + const sal_Int32 m_nEnd; + const sal_uInt16 m_nAttr; + +public: + SwHistoryResetText( sal_uInt16 nWhich, sal_Int32 nStt, sal_Int32 nEnd, + SwNodeOffset nNode ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; + + sal_uInt16 GetWhich() const { return m_nAttr; } + SwNodeOffset GetNode() const { return m_nNodeIndex; } + sal_Int32 GetContent() const { return m_nStart; } + +}; + +class SwHistorySetFootnote final : public SwHistoryHint +{ + const std::unique_ptr> m_pUndo; + const OUString m_FootnoteNumber; + SwNodeOffset m_nNodeIndex; + const sal_Int32 m_nStart; + const bool m_bEndNote; + +public: + SwHistorySetFootnote( SwTextFootnote* pTextFootnote, SwNodeOffset nNode ); + SwHistorySetFootnote( const SwTextFootnote& ); + virtual ~SwHistorySetFootnote() override; + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; + + virtual OUString GetDescription() const override; + +}; + +class SwHistoryChangeFormatColl final : public SwHistoryHint +{ + SwFormatColl * const m_pColl; + const SwNodeOffset m_nNodeIndex; + const SwNodeType m_nNodeType; + +public: + SwHistoryChangeFormatColl( SwFormatColl* pColl, SwNodeOffset nNode, SwNodeType nNodeWhich ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; + +}; + +class SwHistoryTextFlyCnt final : public SwHistoryHint +{ + std::unique_ptr m_pUndo; + +public: + SwHistoryTextFlyCnt( SwFrameFormat* const pFlyFormat ); + virtual ~SwHistoryTextFlyCnt() override; + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; + SwUndoDelLayFormat* GetUDelLFormat() { return m_pUndo.get(); } + + void dumpAsXml(xmlTextWriterPtr pWriter) const override; +}; + +class SwHistoryBookmark final : public SwHistoryHint +{ + public: + SwHistoryBookmark(const ::sw::mark::IMark& rBkmk, + bool bSavePos, bool bSaveOtherPos); + virtual void SetInDoc(SwDoc * pDoc, bool) override; + + bool IsEqualBookmark(const ::sw::mark::IMark& rBkmk); + const OUString& GetName() const { return m_aName;} + + private: + const OUString m_aName; + OUString m_aShortName; + bool m_bHidden; + OUString m_aHideCondition; + vcl::KeyCode m_aKeycode; + const SwNodeOffset m_nNode; + const SwNodeOffset m_nOtherNode; + const sal_Int32 m_nContent; + const sal_Int32 m_nOtherContent; + const bool m_bSavePos; + const bool m_bSaveOtherPos; + const bool m_bHadOtherPos; + const IDocumentMarkAccess::MarkType m_eBkmkType; + std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo; +}; + +/// History object containing all information used during undo / redo +/// of checkbox and drop-down form field insertion. +class SwHistoryNoTextFieldmark final : public SwHistoryHint +{ + public: + SwHistoryNoTextFieldmark(const ::sw::mark::IFieldmark& rFieldMark); + virtual void SetInDoc(SwDoc* pDoc, bool) override; + void ResetInDoc(SwDoc& rDoc); + + private: + const OUString m_sType; + const SwNodeOffset m_nNode; + const sal_Int32 m_nContent; +}; + +/// History object containing all information used during undo / redo +/// of text form field insertion. +class SwHistoryTextFieldmark final : public SwHistoryHint +{ + public: + SwHistoryTextFieldmark(const ::sw::mark::IFieldmark& rFieldMark); + virtual void SetInDoc(SwDoc* pDoc, bool) override; + void ResetInDoc(SwDoc& rDoc); + + private: + const OUString m_sName; + const OUString m_sType; + const SwNodeOffset m_nStartNode; + const sal_Int32 m_nStartContent; + const SwNodeOffset m_nEndNode; + const sal_Int32 m_nEndContent; + /*const*/ SwNodeOffset m_nSepNode; + /*const*/ sal_Int32 m_nSepContent; +}; + +class SwHistorySetAttrSet final : public SwHistoryHint +{ + SfxItemSet m_OldSet; + std::vector m_ResetArray; + const SwNodeOffset m_nNodeIndex; + +public: + SwHistorySetAttrSet( const SfxItemSet& rSet, SwNodeOffset nNode, + const o3tl::sorted_vector &rSetArr ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; + +}; + +class SwHistoryChangeFlyAnchor final : public SwHistoryHint +{ + sw::SpzFrameFormat& m_rFormat; // despite the name, this is not only used for flys, but also for draw formats(!) + const SwNodeOffset m_nOldNodeIndex; + const sal_Int32 m_nOldContentIndex; + +public: + SwHistoryChangeFlyAnchor(sw::SpzFrameFormat& rFormat); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; +}; + +class SwHistoryChangeFlyChain final : public SwHistoryHint +{ + SwFlyFrameFormat * const m_pPrevFormat; + SwFlyFrameFormat * const m_pNextFormat; + SwFlyFrameFormat * const m_pFlyFormat; + +public: + SwHistoryChangeFlyChain( SwFlyFrameFormat& rFormat, const SwFormatChain& rAttr ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; +}; + +class SwHistoryChangeCharFormat final : public SwHistoryHint +{ + const SfxItemSet m_OldSet; + const OUString m_Format; + +public: + SwHistoryChangeCharFormat( SfxItemSet aSet, OUString sFormat); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; + +}; + +class SwHistory +{ + friend class SwDoc; // actually only SwDoc::DelUndoObj may access + friend class SwRegHistory; // for inserting History attributes + + std::vector> m_SwpHstry; + sal_uInt16 m_nEndDiff; + +public: + SwHistory(); + ~SwHistory(); + + // call and delete all objects between nStart and array end + bool Rollback( SwDoc* pDoc, sal_uInt16 nStart = 0 ); + // call all objects between nStart and TmpEnd; store nStart as TmpEnd + bool TmpRollback( SwDoc* pDoc, sal_uInt16 nStart, bool ToFirst = true ); + + void AddPoolItem(const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue, + SwNodeOffset nNodeIdx ); + void AddTextAttr(SwTextAttr* pTextHt, SwNodeOffset nNodeIdx, bool bNewAttr); + void AddColl(SwFormatColl*, SwNodeOffset nNodeIdx, SwNodeType nWhichNd); + void AddIMark(const ::sw::mark::IMark&, bool bSavePos, bool bSaveOtherPos); + void AddChangeFlyAnchor(sw::SpzFrameFormat& rFormat); + void AddDeleteFly( SwFrameFormat&, sal_uInt16& rSetPos ); + void AddFootnote( const SwTextFootnote& ); + void AddCharFormat(const SfxItemSet & rSet, const SwCharFormat & rCharFormat); + + sal_uInt16 Count() const { return m_SwpHstry.size(); } + sal_uInt16 GetTmpEnd() const { return m_SwpHstry.size() - m_nEndDiff; } + sal_uInt16 SetTmpEnd( sal_uInt16 nTmpEnd ); // return previous value + SwHistoryHint * operator[]( sal_uInt16 nPos ) { return m_SwpHstry[nPos].get(); } + SwHistoryHint const* operator[]( sal_uInt16 nPos ) const + { return m_SwpHstry[nPos].get(); } + + // for SwUndoDelete::Undo/Redo + void Move( sal_uInt16 nPos, SwHistory *pIns, + sal_uInt16 const nStart = 0) + { + auto itSourceBegin = pIns->m_SwpHstry.begin() + nStart; + auto itSourceEnd = pIns->m_SwpHstry.end(); + if (itSourceBegin == itSourceEnd) + return; + m_SwpHstry.insert(m_SwpHstry.begin() + nPos, std::make_move_iterator(itSourceBegin), std::make_move_iterator(itSourceEnd)); + pIns->m_SwpHstry.erase( itSourceBegin, itSourceEnd ); + } + + // helper methods for recording attribute in History + // used by Undo classes (Delete/Overwrite/Inserts) + void CopyAttr( + SwpHints const * pHts, + const SwNodeOffset nNodeIdx, + const sal_Int32 nStart, + const sal_Int32 nEnd, + const bool bCopyFields ); + + void CopyFormatAttr( const SfxItemSet& rSet, SwNodeOffset nNodeIdx ); + + void dumpAsXml(xmlTextWriterPtr pWriter) const; +}; + +class SwRegHistory final: public SwClient +{ +private: + o3tl::sorted_vector m_WhichIdSet; + SwHistory * const m_pHistory; + SwNodeOffset m_nNodeIndex; + + void MakeSetWhichIds(); + +public: + SwRegHistory( SwHistory* pHst ); + SwRegHistory( const SwNode& rNd, SwHistory* pHst ); + SwRegHistory( sw::BroadcastingModify* pRegIn, const SwNode& rNd, SwHistory* pHst ); + virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override; + + /// @return true if at least 1 item was inserted + bool InsertItems( const SfxItemSet& rSet, + sal_Int32 const nStart, sal_Int32 const nEnd, + SetAttrMode const nFlags, + SwTextAttr **ppNewTextAttr ); + + void AddHint( SwTextAttr* pHt, const bool bNew ); + + void RegisterInModify( sw::BroadcastingModify* pRegIn, const SwNode& rNd ); + void ChangeNodeIndex( SwNodeOffset nNew ) { m_nNodeIndex = nNew; } +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_ROLBCK_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx new file mode 100644 index 0000000000..90d18fcf0e --- /dev/null +++ b/sw/source/core/inc/rootfrm.hxx @@ -0,0 +1,489 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_ROOTFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_ROOTFRM_HXX + +#include "layfrm.hxx" +#include +#include +#include +#include +#include +#include +#include + +class SwContentFrame; +class SdrPage; +class SwFrameFormat; +class SwPaM; +class SwCursor; +class SwShellCursor; +class SwTableCursor; +class SwLayVout; +class SwViewOption; +class SwSelectionList; +struct SwPosition; +struct SwCursorMoveState; + +namespace sw { + enum class RedlineMode + { + Shown, Hidden + }; + + enum class FieldmarkMode { ShowCommand = 1, ShowResult = 2, ShowBoth = 3 }; + enum class ParagraphBreakMode { Shown, Hidden }; +}; + +enum class SwInvalidateFlags +{ + Size = 0x01, + PrtArea = 0x02, + Pos = 0x04, + Table = 0x08, + Section = 0x10, + LineNum = 0x20, + Direction = 0x40, +}; + +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +}; + +enum class SwRemoveResult +{ + Next, + Prev +}; + +using SwCurrShells = std::set; + +class SwSectionFrame; +using SwDestroyList = o3tl::sorted_vector; +class SwFlyFrame; +using SwFlyDestroyList = o3tl::sorted_vector; + +/// The root element of a Writer document layout. Lower frames are expected to +/// be SwPageFrame instances. +class SW_DLLPUBLIC SwRootFrame final : public SwLayoutFrame +{ + // Needs to disable the Superfluous temporarily + friend void AdjustSizeChgNotify( SwRootFrame *pRoot ); + + // Maintains the mpLastPage (Cut() and Paste() of SwPageFrame + friend inline void SetLastPage( SwPageFrame* ); + + // For creating and destroying of the virtual output device manager + friend void FrameInit(); // Creates s_pVout + friend void FrameFinit(); // Destroys s_pVout + + std::vector maPageRects;// returns the current rectangle for each page frame + // the rectangle is extended to the top/bottom/left/right + // for pages located at the outer margins + SwRect maPagesArea; // the area covered by the pages + tools::Long mnViewWidth; // the current page layout bases on this view width + sal_uInt16 mnColumns; // the current page layout bases on this number of columns + bool mbBookMode; // the current page layout is in book view + bool mbSidebarChanged; // the notes sidebar state has changed + + bool mbNeedGrammarCheck; // true when sth needs to be checked (not necessarily started yet!) + + static SwLayVout *s_pVout; + static bool s_isInPaint; // Protection against double Paints + static bool s_isNoVirDev;// No virt. Device for SystemPaints + /// The last, still alive SwRootFrame instance, for debugging. + static SwRootFrame* s_pLast; + + /// Width of the HTML / Web document if not defined otherwise: 20cm. + static constexpr sal_Int64 MIN_BROWSE_WIDTH = o3tl::toTwips(20000, o3tl::Length::mm100); + + bool mbCheckSuperfluous :1; // Search for empty Pages? + bool mbIdleFormat :1; // Trigger Idle Formatter? + bool mbBrowseWidthValid :1; // Is mnBrowseWidth valid? + bool mbTurboAllowed :1; + bool mbAssertFlyPages :1; // Insert more Pages for Flys if needed? + bool mbTableUpdateInProgress : 1; // tdf#139426 to allow suppression of AssertFlyPages during TableUpdate + bool mbIsVirtPageNum :1; // Do we have a virtual pagenumber? + bool mbIsNewLayout :1; // Layout loaded or newly created + bool mbCallbackActionEnabled:1; // No Action in Notification desired + // @see dcontact.cxx, ::Changed() + bool mbLayoutFreezed; + bool mbHideRedlines; + sw::FieldmarkMode m_FieldmarkMode; + sw::ParagraphBreakMode m_ParagraphBreakMode; + + /** + * For BrowseMode + * mnBrowseWidth is the outer margin of the object most to the right. + * The page's right edge should not be smaller than this value. + */ + tools::Long mnBrowseWidth; + + /// If we only have to format one ContentFrame, its in mpTurbo + const SwContentFrame *mpTurbo; + + /// We should not need to always struggle to find the last page, so store it here + SwPageFrame *mpLastPage; + + /** [ Comment from the original StarOffice checkin ]: + * The root takes care of the shell access. Via the document + * it should be possible to get at the root frame, and thus always + * have access to the shell. + * the pointer mpCurrShell is the pointer to any of the shells for + * the document. + * Because sometimes it matters which shell is used, it is necessary to + * know the active shell. + * this is approximated by setting the pointer mpCurrShell when a + * shell gets the focus (FEShell). Additionally the pointer will be + * set temporarily by SwCurrShell typically via CurrShell + * The class can be found in the SwViewShell. These object can + * be created nested (also for different kinds of Shells). They are + * collected into the Array mpCurrShells. + * Furthermore it can happen that a shell is activated while a curshell + * object is still 'active'. This one will be entered into mpWaitingCurrShell + * and will be activated by the last d'tor of CurrShell. + * One other problem is the destruction of a shell while it is active. + * The pointer mpCurrShell is then reset to an arbitrary other shell. + * If at the time of the destruction of a shell, which is still referenced + * by a curshell object, that will be cleaned up as well. + */ + friend class CurrShell; + friend void SetShell( SwViewShell *pSh ); + friend void InitCurrShells( SwRootFrame *pRoot ); + SwViewShell *mpCurrShell; + SwViewShell *mpWaitingCurrShell; + std::unique_ptr mpCurrShells; + + /// One Page per DrawModel per Document; is always the size of the Root + SdrPage *mpDrawPage; + + std::unique_ptr mpDestroy; + std::unique_ptr mpFlyDestroy; + + sal_uInt16 mnPhyPageNums; /// Page count + sal_uInt16 mnAccessibleShells; // Number of accessible shells + + void ImplCalcBrowseWidth(); + void ImplInvalidateBrowseWidth(); + + void DeleteEmptySct_(); // Destroys the registered SectionFrames + /// Destroys the registered FlyFrames. + void DeleteEmptyFlys_(); + void RemoveFromList_( SwSectionFrame* pSct ); // Removes SectionFrames from the Delete List + + virtual void DestroyImpl() override; + virtual ~SwRootFrame() override; + + virtual void MakeAll(vcl::RenderContext* pRenderContext) override; + +public: + + /// Remove MasterObjects from the Page (called by the ctors) + static void RemoveMasterObjs( SdrPage *pPg ); + + void AllCheckPageDescs() const; + void AllInvalidateAutoCompleteWords() const; + void AllAddPaintRect() const; + void AllRemoveFootnotes() ; + void AllInvalidateSmartTagsOrSpelling(bool bSmartTags) const; + + /// Output virtual Device (e.g. for animations) + static bool FlushVout(); + + /// Save Clipping if exactly the ClipRect is outputted + static bool HasSameRect( const SwRect& rRect ); + + SwRootFrame( SwFrameFormat*, SwViewShell* ); + void Init(SwFrameFormat*); + + SwViewShell *GetCurrShell() const { return mpCurrShell; } + void DeRegisterShell( SwViewShell *pSh ); + + /** + * Set up Start-/EndAction for all Shells on an as high as possible + * (Shell section) level. + * For the StarONE binding, which does not know the Shells directly. + * The ChangeLinkd of the CursorShell (UI notifications) is called + * automatically in the EndAllAction. + */ + void StartAllAction(); + void EndAllAction(); + + /** + * Certain UNO Actions (e.g. table cursor) require that all Actions are reset temporarily + * In order for that to work, every SwViewShell needs to remember its old Action counter + */ + void UnoRemoveAllActions(); + void UnoRestoreAllActions(); + + const SdrPage* GetDrawPage() const { return mpDrawPage; } + SdrPage* GetDrawPage() { return mpDrawPage; } + void SetDrawPage( SdrPage* pNew ){ mpDrawPage = pNew; } + + virtual bool GetModelPositionForViewPoint( SwPosition *, Point&, + SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override; + + virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&, + SwPrintData const*const pPrintData = nullptr ) const override; + virtual SwTwips ShrinkFrame( SwTwips, bool bTst = false, bool bInfo = false ) override; + virtual SwTwips GrowFrame ( SwTwips, bool bTst = false, bool bInfo = false ) override; +#ifdef DBG_UTIL + virtual void Cut() override; + virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override; +#endif + + virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const override; + + Point GetNextPrevContentPos( const Point &rPoint, bool bNext ) const; + + virtual Size ChgSize( const Size& aNewSize ) override; + + void SetIdleFlags() + { + mbIdleFormat = true; + + SwViewShell* pCurrShell = GetCurrShell(); + // May be NULL if called from SfxBaseModel::dispose + // (this happens in the build test 'rtfexport'). + if (pCurrShell != nullptr) + pCurrShell->GetDoc()->getIDocumentTimerAccess().StartIdling(); + } + bool IsIdleFormat() const { return mbIdleFormat; } + void ResetIdleFormat() { mbIdleFormat = false; } + + bool IsNeedGrammarCheck() const { return mbNeedGrammarCheck; } + void SetNeedGrammarCheck( bool bVal ) + { + mbNeedGrammarCheck = bVal; + + if ( bVal ) + { + SwViewShell* pCurrShell = GetCurrShell(); + // May be NULL if called from SfxBaseModel::dispose + // (this happens in the build test 'rtfexport'). + if (pCurrShell != nullptr) + pCurrShell->GetDoc()->getIDocumentTimerAccess().StartIdling(); + } + } + + /// Makes sure that all requested page-bound Flys find a Page + void SetAssertFlyPages() { mbAssertFlyPages = true; } + void AssertFlyPages(); + bool IsAssertFlyPages() const { return mbAssertFlyPages; } + + void SetTableUpdateInProgress(bool bValue) { mbTableUpdateInProgress = bValue; } + bool IsTableUpdateInProgress() const { return mbTableUpdateInProgress; } + + /** + * Makes sure that, starting from the passed Page, all page-bound Frames + * are on the right Page (pagenumber). + */ + static void AssertPageFlys( SwPageFrame * ); + + /// Invalidate all Content, Size or PrtArea + void InvalidateAllContent( SwInvalidateFlags nInvalidate ); + + /** + * Invalidate/re-calculate the position of all floating + * screen objects (Writer fly frames and drawing objects), which are + * anchored to paragraph or to character. + */ + void InvalidateAllObjPos(); + + /// Remove superfluous Pages + void SetSuperfluous() { mbCheckSuperfluous = true; } + bool IsSuperfluous() const { return mbCheckSuperfluous; } + void RemoveSuperfluous(); + + /** + * Query/set the current Page and the collective Page count + * We'll format as much as necessary + */ + sal_uInt16 GetCurrPage( const SwPaM* ) const; + sal_uInt16 SetCurrPage( SwCursor*, sal_uInt16 nPageNum ); + Point GetPagePos( sal_uInt16 nPageNum ) const; + sal_uInt16 GetPageNum() const { return mnPhyPageNums; } + void DecrPhyPageNums() { --mnPhyPageNums; } + void IncrPhyPageNums() { ++mnPhyPageNums; } + bool IsVirtPageNum() const { return mbIsVirtPageNum; } + inline void SetVirtPageNum( const bool bOf ) const; + bool IsDummyPage( sal_uInt16 nPageNum ) const; + + /** + * Point rPt: The point that should be used to find the page + * Size pSize: If given, we return the (first) page that overlaps with the + * rectangle defined by rPt and pSize + * bool bExtend: Extend each page to the left/right/top/bottom up to the + * next page margin + */ + const SwPageFrame* GetPageAtPos( const Point& rPt, const Size* pSize = nullptr, bool bExtend = false ) const; + + /** + * Point rPt: The point to test + * @returns true: if rPt is between top/bottom margins of two pages + * in hide-whitespace, rPt can be near the gap, but + * not strictly between pages (in a page) as gap is small. + * @returns false: if rPt is in a page or not strictly between two pages + */ + bool IsBetweenPages(const Point& rPt) const; + + enum class RectsMode { Default, NoAnchoredFlys }; + void CalcFrameRects(SwShellCursor const&, SwRects &, RectsMode eMode = RectsMode::Default); + + /** + * Calculates the cells included from the current selection + * + * @returns false: There was no result because of an invalid layout + * @returns true: Everything worked fine. + */ + bool MakeTableCursors( SwTableCursor& ); + + void DisallowTurbo() const { const_cast(this)->mbTurboAllowed = false; } + void ResetTurboFlag() const { const_cast(this)->mbTurboAllowed = true; } + bool IsTurboAllowed() const { return mbTurboAllowed; } + void SetTurbo( const SwContentFrame *pContent ) { mpTurbo = pContent; } + void ResetTurbo() { mpTurbo = nullptr; } + const SwContentFrame *GetTurbo() const { return mpTurbo; } + + /// Update the footnote numbers of all Pages + void UpdateFootnoteNums(); // Only for page by page numbering! + + /// Remove all footnotes (but no references) + void RemoveFootnotes( SwPageFrame *pPage = nullptr, bool bPageOnly = false, + bool bEndNotes = false ); + void CheckFootnotePageDescs( bool bEndNote ); + + const SwPageFrame *GetLastPage() const { return mpLastPage; } + SwPageFrame *GetLastPage() { return mpLastPage; } + + static bool IsInPaint() { return s_isInPaint; } + + static void SetNoVirDev(const bool bNew) { s_isNoVirDev = bNew; } + + inline tools::Long GetBrowseWidth() const; + inline void InvalidateBrowseWidth(); + + bool IsNewLayout() const { return mbIsNewLayout; } + void ResetNewLayout() { mbIsNewLayout = false;} + + /** + * Empty SwSectionFrames are registered here for deletion and + * destroyed later on or deregistered. + */ + void InsertEmptySct( SwSectionFrame* pDel ); + /// Empty SwFlyFrames are registered here for deletion and destroyed later if they are not + /// de-registered in the meantime. + void InsertEmptyFly(SwFlyFrame* pDel); + void DeleteEmptySct() { if( mpDestroy ) DeleteEmptySct_(); } + void DeleteEmptyFlys() { if( mpFlyDestroy ) DeleteEmptyFlys_(); } + void RemoveFromList( SwSectionFrame* pSct ) { if( mpDestroy ) RemoveFromList_( pSct ); } +#ifdef DBG_UTIL + bool IsInDelList( SwSectionFrame* pSct ) const; +#endif + bool IsInFlyDelList( SwFlyFrame* pFly ) const; + + void SetCallbackActionEnabled( bool b ) { mbCallbackActionEnabled = b; } + bool IsCallbackActionEnabled() const { return mbCallbackActionEnabled; } + + bool IsAnyShellAccessible() const { return mnAccessibleShells > 0; } + void AddAccessibleShell() { ++mnAccessibleShells; } + void RemoveAccessibleShell() { --mnAccessibleShells; } + + /** + * Get page frame by physical page number + * looping through the lowers, which are page frame, in order to find the + * page frame with the given physical page number. + * if no page frame is found, 0 is returned. + * Note: Empty page frames are also returned. + * + * @param _nPageNum: physical page number of page frame to be searched and + * returned. + * + * @return pointer to the page frame with the given physical page number + */ + SwPageFrame* GetPageByPageNum( sal_uInt16 _nPageNum ) const; + + void CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVisArea ); + bool IsLeftToRightViewLayout() const; + const SwRect& GetPagesArea() const { return maPagesArea; } + void SetSidebarChanged() { mbSidebarChanged = true; } + + bool IsLayoutFreezed() const { return mbLayoutFreezed; } + void FreezeLayout( bool freeze ) { mbLayoutFreezed = freeze; } + + void RemovePage( SwPageFrame **pDel, SwRemoveResult eResult ); + + /** + * Replacement for sw::DocumentRedlineManager::GetRedlineFlags() + * (this is layout-level redline hiding). + */ + bool IsHideRedlines() const { return mbHideRedlines; } + void SetHideRedlines(bool); + sw::FieldmarkMode GetFieldmarkMode() const { return m_FieldmarkMode; } + void SetFieldmarkMode(sw::FieldmarkMode, sw::ParagraphBreakMode); + sw::ParagraphBreakMode GetParagraphBreakMode() const { return m_ParagraphBreakMode; } + bool HasMergedParas() const; + + void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; +}; + +inline tools::Long SwRootFrame::GetBrowseWidth() const +{ + if ( !mbBrowseWidthValid ) + const_cast(this)->ImplCalcBrowseWidth(); + return mnBrowseWidth; +} + +inline void SwRootFrame::InvalidateBrowseWidth() +{ + if ( mbBrowseWidthValid ) + ImplInvalidateBrowseWidth(); +} + +inline void SwRootFrame::SetVirtPageNum( const bool bOf) const +{ + const_cast(this)->mbIsVirtPageNum = bOf; +} + +/// helper class to disable creation of an action by a callback event +/// in particular, change event from a drawing object (SwDrawContact::Changed()) +class DisableCallbackAction +{ + private: + SwRootFrame & m_rRootFrame; + bool m_bOldCallbackActionState; + + public: + explicit DisableCallbackAction(SwRootFrame & rRootFrame) + : m_rRootFrame(rRootFrame) + , m_bOldCallbackActionState(rRootFrame.IsCallbackActionEnabled()) + { + m_rRootFrame.SetCallbackActionEnabled(false); + } + + ~DisableCallbackAction() + { + m_rRootFrame.SetCallbackActionEnabled(m_bOldCallbackActionState); + } +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_ROOTFRM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/rowfrm.hxx b/sw/source/core/inc/rowfrm.hxx new file mode 100644 index 0000000000..a48dacf6a3 --- /dev/null +++ b/sw/source/core/inc/rowfrm.hxx @@ -0,0 +1,131 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_ROWFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_ROWFRM_HXX + +#include "layfrm.hxx" + +class SwTableLine; +class SwBorderAttrs; + +/// SwRowFrame is one table row in the document layout. +class SwRowFrame final : public SwLayoutFrame +{ + virtual void Format(vcl::RenderContext* pRenderContext, + const SwBorderAttrs* pAttrs = nullptr) override; + /// Only change the Frame size, not the PrtArea SSize + virtual SwTwips ShrinkFrame(SwTwips, bool bTst = false, bool bInfo = false) override; + virtual SwTwips GrowFrame(SwTwips, bool bTst = false, bool bInfo = false) override; + + const SwTableLine* m_pTabLine; + SwRowFrame* m_pFollowRow; ///< note: this is *only* set on old-style tables! + // #i29550# + sal_uInt16 mnTopMarginForLowers; + sal_uInt16 mnBottomMarginForLowers; + sal_uInt16 mnBottomLineSize; + // <-- collapsing + bool m_bIsFollowFlowRow; ///< note: this is *only* set on old-style tables! + bool m_bIsRepeatedHeadline; + bool m_bIsRowSpanLine; + + bool m_bForceRowSplitAllowed; + bool m_bIsInSplit; + + virtual void DestroyImpl() override; + virtual ~SwRowFrame() override; + + virtual void MakeAll(vcl::RenderContext* pRenderContext) override; + virtual void SwClientNotify(const SwModify&, const SfxHint&) override; + virtual const SwRowFrame* DynCastRowFrame() const override { return this; } + +public: + SwRowFrame(const SwTableLine&, SwFrame*, bool bInsertContent = true); + + virtual void Cut() override; + + /** + * Register Flys after a line was created _AND_ inserted + * Must be called by the creator; the Fly is inserted _after_ it has + * been created; the same holds true for the Page at which the Flys + * are to be registered at. + */ + void RegistFlys(SwPageFrame* pPage = nullptr); + + const SwTableLine* GetTabLine() const { return m_pTabLine; } + + /** + * Adapts the Cells to the current height; invalidates the Cells if + * the Direction does not match the height + */ + void AdjustCells(const SwTwips nHeight, const bool bHeight); + + SwRowFrame* GetFollowRow() const { return m_pFollowRow; } + void SetFollowRow(SwRowFrame* pNew) { m_pFollowRow = pNew; } + + // #i29550# + sal_uInt16 GetTopMarginForLowers() const { return mnTopMarginForLowers; } + void SetTopMarginForLowers(sal_uInt16 nNew) { mnTopMarginForLowers = nNew; } + sal_uInt16 GetBottomMarginForLowers() const { return mnBottomMarginForLowers; } + void SetBottomMarginForLowers(sal_uInt16 nNew) { mnBottomMarginForLowers = nNew; } + sal_uInt16 GetBottomLineSize() const { return mnBottomLineSize; } + void SetBottomLineSize(sal_uInt16 nNew) { mnBottomLineSize = nNew; } + // <-- collapsing + + bool IsRepeatedHeadline() const { return m_bIsRepeatedHeadline; } + void SetRepeatedHeadline(bool bNew) { m_bIsRepeatedHeadline = bNew; } + + // --> split table rows + bool IsRowSplitAllowed() const; + bool IsForceRowSplitAllowed() const { return m_bForceRowSplitAllowed; } + void SetForceRowSplitAllowed(bool bNew) { m_bForceRowSplitAllowed = bNew; }; + bool IsFollowFlowRow() const { return m_bIsFollowFlowRow; } + void SetFollowFlowRow(bool bNew) { m_bIsFollowFlowRow = bNew; } + // <-- split table rows + + // #131283# Table row keep feature + bool ShouldRowKeepWithNext(const bool bCheckParents = true) const; + + // #i4032# NEW TABLES + bool IsRowSpanLine() const { return m_bIsRowSpanLine; } + void SetRowSpanLine(bool bNew) { m_bIsRowSpanLine = bNew; } + + // A row may only be split if the minimum height of the row frame + // fits into the vertical space left. + // The minimum height is found as maximum of two values: minimal + // contents of the row (e.g., height of first line of text, or an + // object, or lower table cell), and the minimum height setting. + // As the minimum height setting should not prevent the row to + // flow, (it only should ensure that *total* height is no less), we + // should not consider the setting when the split is performed + // (we should be able to keep on first page as little as required). + // When IsInSplit is true, lcl_CalcMinRowHeight will ignore the + // minimum height setting. It is set in lcl_RecalcSplitLine around + // lcl_RecalcRow and SwRowFrame::Calc that decide if it's possible + // to keep part of row's content on first page, and update table's + // height to fit the rest of space. + bool IsInSplit() const { return m_bIsInSplit; } + void SetInSplit(bool bNew = true) { m_bIsInSplit = bNew; } + void OnFrameSize(const SfxPoolItem&); + + void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/scriptinfo.hxx b/sw/source/core/inc/scriptinfo.hxx new file mode 100644 index 0000000000..21c3c2240c --- /dev/null +++ b/sw/source/core/inc/scriptinfo.hxx @@ -0,0 +1,398 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_SCRIPTINFO_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_SCRIPTINFO_HXX + +#include +#include +#include +#include +#include +#include +#include +#include "TextFrameIndex.hxx" +#include + +class SwTextNode; +class SwTextFrame; +class Point; +class MultiSelection; +enum class SwFontScript; +namespace sw { struct MergedPara; } +namespace sw::mark { class IBookmark; } + +#define SPACING_PRECISION_FACTOR 100 + +// encapsulates information about script changes +class SwScriptInfo +{ +public: + enum CompType { KANA, SPECIAL_LEFT, SPECIAL_RIGHT, NONE, SPECIAL_MIDDLE}; + enum class MarkKind { Start = (1<<0), End = (1<<1), Point = (1<<2) }; + +private: + //! Records a single change in script type. + struct ScriptChangeInfo + { + TextFrameIndex position; //!< Character position at which we change script + sal_uInt8 type; //!< Script type (Latin/Asian/Complex) that we change to. + ScriptChangeInfo(TextFrameIndex pos, sal_uInt8 typ) : position(pos), type(typ) {}; + }; + //TODO - This is sorted, so should probably be a std::set rather than vector. + // But we also use random access (probably unnecessarily). + std::vector m_ScriptChanges; + //! Records a single change in direction. + struct DirectionChangeInfo + { + TextFrameIndex position; //!< Character position at which we change direction. + sal_uInt8 type; //!< Direction that we change to. + DirectionChangeInfo(TextFrameIndex pos, sal_uInt8 typ) : position(pos), type(typ) {}; + }; + std::vector m_DirectionChanges; + std::deque m_Kashida; + /// indexes into m_Kashida + std::unordered_set m_KashidaInvalid; + std::deque m_NoKashidaLine; + std::deque m_NoKashidaLineEnd; + std::vector m_HiddenChg; + std::vector> m_Bookmarks; + //! Records a single change in compression. + struct CompressionChangeInfo + { + TextFrameIndex position; //!< Character position where the change occurs. + TextFrameIndex length; //!< Length of the segment. + CompType type; //!< Type of compression that we change to. + CompressionChangeInfo(TextFrameIndex pos, TextFrameIndex len, CompType typ) : position(pos), length(len), type(typ) {}; + }; + std::vector m_CompressionChanges; +#ifdef DBG_UTIL + CompType DbgCompType(const TextFrameIndex nPos) const; +#endif + + TextFrameIndex m_nInvalidityPos; + sal_uInt8 m_nDefaultDir; + + void UpdateBidiInfo( const OUString& rText ); + bool IsKashidaValid(size_t nKashPos) const; + // returns true if nKashPos is newly marked invalid + bool MarkKashidaInvalid(size_t nKashPos); + void ClearKashidaInvalid(size_t nKashPos); + bool MarkOrClearKashidaInvalid(TextFrameIndex nStt, TextFrameIndex nLen, + bool bMark, sal_Int32 nMarkCount); + bool IsKashidaLine(TextFrameIndex nCharIdx) const; + // examines the range [ nStart, nStart + nEnd ] if there are kanas + // returns start index of kana entry in array, otherwise SAL_MAX_SIZE + size_t HasKana(TextFrameIndex nStart, TextFrameIndex nEnd) const; + +public: + + SwScriptInfo(); + ~SwScriptInfo(); + + // determines script changes + void InitScriptInfo(const SwTextNode& rNode, sw::MergedPara const* pMerged, bool bRTL); + void InitScriptInfo(const SwTextNode& rNode, sw::MergedPara const* pMerged); + + // set/get position from which data is invalid + void SetInvalidityA(const TextFrameIndex nPos) + { + if (nPos < m_nInvalidityPos) + m_nInvalidityPos = nPos; + } + TextFrameIndex GetInvalidityA() const + { + return m_nInvalidityPos; + } + + // get default direction for paragraph + sal_uInt8 GetDefaultDir() const { return m_nDefaultDir; }; + + // array operations, nCnt refers to array position + size_t CountScriptChg() const { return m_ScriptChanges.size(); } + TextFrameIndex GetScriptChg(const size_t nCnt) const + { + assert(nCnt < m_ScriptChanges.size()); + return m_ScriptChanges[nCnt].position; + } + sal_uInt8 GetScriptType( const size_t nCnt ) const + { + assert( nCnt < m_ScriptChanges.size()); + return m_ScriptChanges[nCnt].type; + } + + size_t CountDirChg() const { return m_DirectionChanges.size(); } + TextFrameIndex GetDirChg(const size_t nCnt) const + { + assert(nCnt < m_DirectionChanges.size()); + return m_DirectionChanges[ nCnt ].position; + } + sal_uInt8 GetDirType( const size_t nCnt ) const + { + assert(nCnt < m_DirectionChanges.size()); + return m_DirectionChanges[ nCnt ].type; + } + + size_t CountKashida() const + { + return m_Kashida.size(); + } + + TextFrameIndex GetKashida(const size_t nCnt) const + { + assert(nCnt < m_Kashida.size()); + return m_Kashida[nCnt]; + } + + size_t CountCompChg() const { return m_CompressionChanges.size(); }; + TextFrameIndex GetCompStart(const size_t nCnt) const + { + assert(nCnt < m_CompressionChanges.size()); + return m_CompressionChanges[ nCnt ].position; + } + TextFrameIndex GetCompLen(const size_t nCnt) const + { + assert(nCnt < m_CompressionChanges.size()); + return m_CompressionChanges[ nCnt ].length; + } + CompType GetCompType( const size_t nCnt ) const + { + assert(nCnt < m_CompressionChanges.size()); + return m_CompressionChanges[ nCnt ].type; + } + + size_t CountHiddenChg() const { return m_HiddenChg.size(); }; + TextFrameIndex GetHiddenChg(const size_t nCnt) const + { + assert(nCnt < m_HiddenChg.size()); + return m_HiddenChg[ nCnt ]; + } + TextFrameIndex NextHiddenChg(TextFrameIndex nPos) const; + TextFrameIndex NextBookmark(TextFrameIndex nPos) const; + std::vector> + GetBookmarks(TextFrameIndex const nPos); + static void CalcHiddenRanges(const SwTextNode& rNode, + MultiSelection& rHiddenMulti, + std::vector> * pBookmarks); + static void selectHiddenTextProperty(const SwTextNode& rNode, + MultiSelection &rHiddenMulti, + std::vector> * pBookmarks); + static void selectRedLineDeleted(const SwTextNode& rNode, MultiSelection &rHiddenMulti, bool bSelect=true); + + // "high" level operations, nPos refers to string position + TextFrameIndex NextScriptChg(TextFrameIndex nPos) const; + sal_Int16 ScriptType(const TextFrameIndex nPos) const; + + // Returns the position of the next direction level change. + // If bLevel is set, the position of the next level which is smaller + // than the level at position nPos is returned. This is required to + // obtain the end of a SwBidiPortion + TextFrameIndex NextDirChg(const TextFrameIndex nPos, + const sal_uInt8* pLevel = nullptr) const; + sal_uInt8 DirType(const TextFrameIndex nPos) const; + + // HIDDEN TEXT STUFF START + +/** Hidden text range information - static and non-version + + @descr Determines if a given position is inside a hidden text range. The + static version tries to obtain a valid SwScriptInfo object + via the SwTextNode, otherwise it calculates the values from scratch. + The non-static version uses the internally cached information + for the calculation. + + @param rNode + The text node. + @param nPos + The given position that should be checked. + @param rnStartPos + Return parameter for the start position of the hidden range. + COMPLETE_STRING if nPos is not inside a hidden range. + @param rnEndPos + Return parameter for the end position of the hidden range. + 0 if nPos is not inside a hidden range. + @param rnEndPos + Return parameter that contains all the hidden text ranges. Optional. + @return + returns true if there are any hidden characters in this paragraph. + +*/ + static bool GetBoundsOfHiddenRange( const SwTextNode& rNode, sal_Int32 nPos, + sal_Int32& rnStartPos, sal_Int32& rnEndPos, + std::vector* pList = nullptr ); + bool GetBoundsOfHiddenRange(TextFrameIndex nPos, TextFrameIndex & rnStartPos, + TextFrameIndex & rnEndPos) const; + + static bool IsInHiddenRange( const SwTextNode& rNode, sal_Int32 nPos ); + +/** Hidden text attribute handling + + @descr Takes a string and either deletes the hidden ranges or sets + a given character in place of the hidden characters. + + @param rNode + The text node. + @param rText + The string to modify. + @param cChar + The character that should replace the hidden characters. + @param bDel + If set, the hidden ranges will be deleted from the text node. + */ + static sal_Int32 MaskHiddenRanges( + const SwTextNode& rNode, OUStringBuffer& rText, + const sal_Int32 nStt, const sal_Int32 nEnd, + const sal_Unicode cChar ); + +/** Hidden text attribute handling + + @descr Takes a SwTextNode and deletes the hidden ranges from the node. + + @param rNode + The text node. + */ + static void DeleteHiddenRanges( SwTextNode& rNode ); + + // HIDDEN TEXT STUFF END + + // modifies the kerning array according to a given compress value + tools::Long Compress( KernArray& rKernArray, TextFrameIndex nIdx, TextFrameIndex nLen, + const sal_uInt16 nCompress, const sal_uInt16 nFontHeight, + const bool bCentered, + Point* pPoint = nullptr ) const; + +/** Performs a kashida justification on the kerning array + + @descr Add some extra space for kashida justification to the + positions in the kerning array. + @param pKernArray + The printers kerning array. Optional. + @param nStt + Start referring to the paragraph. + @param nLen + The number of characters to be considered. + @param nSpaceAdd + The value which has to be added to a kashida opportunity. + @return The number of kashida opportunities in the given range +*/ + sal_Int32 KashidaJustify( KernArray* pKernArray, sal_Bool* pKashidaArray, + TextFrameIndex nStt, TextFrameIndex nLen, tools::Long nSpaceAdd = 0) const; + +/** Clears array of kashidas marked as invalid + */ + void ClearKashidaInvalid(TextFrameIndex const nStt, TextFrameIndex const nLen) + { + MarkOrClearKashidaInvalid(nStt, nLen, false, 0); + } + +/** Marks nCnt kashida positions as invalid + pKashidaPositions: array of char indices relative to the paragraph +*/ + void MarkKashidasInvalid(sal_Int32 nCnt, const TextFrameIndex* pKashidaPositions); + +/** Marks nCnt kashida positions as invalid + in the given text range + */ + bool MarkKashidasInvalid(sal_Int32 const nCnt, + TextFrameIndex const nStt, TextFrameIndex const nLen) + { + return MarkOrClearKashidaInvalid(nStt, nLen, true, nCnt); + } + +/** retrieves kashida opportunities for a given text range. + + rKashidaPositions: buffer to receive the char indices of the + kashida opportunities relative to the paragraph +*/ + void GetKashidaPositions(TextFrameIndex nStt, TextFrameIndex nLen, + std::vector& rKashidaPosition); + +/** Use regular blank justification instead of kashdida justification for the given line of text. + nStt Start char index of the line referring to the paragraph. + nLen Number of characters in the line +*/ + void SetNoKashidaLine(TextFrameIndex nStt, TextFrameIndex nLen); + +/** Clear forced blank justification for a given line. + nStt Start char index of the line referring to the paragraph. + nLen Number of characters in the line +*/ + void ClearNoKashidaLine(TextFrameIndex nStt, TextFrameIndex nLen); + +/** Checks if text is Arabic text. + + @descr Checks if text is Arabic text. + @param rText + The text to check + @param nStt + Start index of the text + @return Returns if the language is an Arabic language + */ + static bool IsArabicText(const OUString& rText, TextFrameIndex nStt, TextFrameIndex nLen); + +/** Performs a thai justification on the kerning array + + @descr Add some extra space for thai justification to the + positions in the kerning array. + @param aText + The String + @param pKernArray + The printers kerning array. Optional. + @param nIdx + Start referring to the paragraph. + @param nLen + The number of characters to be considered. + @param nSpaceAdd + The value which has to be added to the cells. + @return The number of extra spaces in the given range +*/ + static TextFrameIndex ThaiJustify( std::u16string_view aText, KernArray* pKernArray, + TextFrameIndex nIdx, + TextFrameIndex nLen, + TextFrameIndex nNumberOfBlanks = TextFrameIndex(0), + tools::Long nSpaceAdd = 0 ); + + static TextFrameIndex CountCJKCharacters(const OUString &rText, + TextFrameIndex nPos, TextFrameIndex nEnd, LanguageType aLang); + + static void CJKJustify( const OUString& rText, KernArray& rKernArray, + TextFrameIndex nStt, + TextFrameIndex nLen, LanguageType aLang, + tools::Long nSpaceAdd, bool bIsSpaceStop ); + + /// return a frame for the node, ScriptInfo is its member... + /// (many clients need both frame and SI, and both have to match) + static SwScriptInfo* GetScriptInfo( const SwTextNode& rNode, + SwTextFrame const** o_pFrame = nullptr, + bool bAllowInvalid = false); + + SwFontScript WhichFont(TextFrameIndex nIdx) const; + static SwFontScript WhichFont(sal_Int32 nIdx, OUString const & rText); +}; + +namespace o3tl +{ + +template<> struct typed_flags : is_typed_flags {}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/sectfrm.hxx b/sw/source/core/inc/sectfrm.hxx new file mode 100644 index 0000000000..c07d78b12b --- /dev/null +++ b/sw/source/core/inc/sectfrm.hxx @@ -0,0 +1,189 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_SECTFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_SECTFRM_HXX + +#include "layfrm.hxx" +#include "flowfrm.hxx" + +#include + +class SwSection; +class SwSectionFormat; +class SwAttrSetChg; +class SwFootnoteContFrame; +class SwLayouter; + +enum class SwFindMode +{ + None = 0, EndNote = 1, LastCnt = 2, MyLast = 4 +}; + +enum class SwSectionFrameInvFlags : sal_uInt8 +{ + NONE = 0x00, + InvalidateSize = 0x01, + SetCompletePaint = 0x10, +}; + +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +} + +class SwSectionFrame final: public SwLayoutFrame, public SwFlowFrame + , public SvtListener // TODO? +{ + SwSection* m_pSection; + bool m_bFootnoteAtEnd; // footnotes at the end of section + bool m_bEndnAtEnd; // endnotes at the end of section + bool m_bContentLock; // content locked + bool m_bOwnFootnoteNum; // special numbering of footnotes + bool m_bFootnoteLock; // ftn, don't leave this section bwd + + void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, SwSectionFrameInvFlags &, + SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr ); + void Cut_( bool bRemove ); + // Is there a FootnoteContainer? + // An empty sectionfrm without FootnoteCont is superfluous + bool IsSuperfluous() const { return !ContainsAny() && !ContainsFootnoteCont(); } + void CalcFootnoteAtEndFlag(); + void CalcEndAtEndFlag(); + const SwSectionFormat* GetEndSectFormat_() const; + bool IsEndnoteAtMyEnd() const; + + virtual void DestroyImpl() override; + virtual ~SwSectionFrame() override; + + virtual void MakeAll(vcl::RenderContext* pRenderContext) override; + virtual bool ShouldBwdMoved( SwLayoutFrame *pNewUpper, bool &rReformat ) override; + virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override; + virtual void Notify(SfxHint const& rHint) override; + virtual void SwClientNotify( const SwModify&, const SfxHint& ) override; + +public: + SwSectionFrame( SwSection &, SwFrame* ); // Content is not created! + SwSectionFrame( SwSectionFrame &, bool bMaster ); // _ONLY_ for creating Master/Follows! + + void Init(); + virtual void CheckDirection( bool bVert ) override; + + virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override; + + virtual void Cut() override; + virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override; + + inline const SwSectionFrame *GetFollow() const; + inline SwSectionFrame *GetFollow(); + SwSectionFrame* FindMaster() const; + + SwContentFrame *FindLastContent( SwFindMode nMode = SwFindMode::None ); + inline const SwContentFrame *FindLastContent() const; + SwSection* GetSection() { return m_pSection; } + const SwSection* GetSection() const { return m_pSection; } + void ColLock() { mbColLocked = true; } + void ColUnlock() { mbColLocked = false; } + + void CalcFootnoteContent(); + void SimpleFormat(); + bool IsDescendantFrom( const SwSectionFormat* pSect ) const; + bool HasToBreak( const SwFrame* pFrame ) const; + void MergeNext( SwSectionFrame* pNxt ); + + /** + * Splits the SectionFrame surrounding the pFrame up in two parts: + * pFrame and the start of the 2nd part + */ + SwSectionFrame* SplitSect( SwFrame* pFrameStartAfter, SwFrame* pFramePutAfter ); + void DelEmpty( bool bRemove ); // Like Cut(), except for that Follow chaining is maintained + SwFootnoteContFrame* ContainsFootnoteCont( const SwFootnoteContFrame* pCont = nullptr ) const; + bool Growable() const; + SwTwips Shrink_( SwTwips, bool bTst ); + SwTwips Grow_ ( SwTwips, bool bTst ); + + /** + * A sectionfrm has to maximize, if he has a follow or a ftncontainer at + * the end of the page. A superfluous follow will be ignored, + * if bCheckFollow is set. + */ + bool ToMaximize( bool bCheckFollow ) const; + bool ToMaximize_() const { + if( !m_pSection ) return false; + return ToMaximize( false ); + } + bool MoveAllowed( const SwFrame* ) const; + bool CalcMinDiff( SwTwips& rMinDiff ) const; + + /** + * Returns the size delta that the section would like to be + * greater if it has undersized TextFrames in it. + * + * The return value is > 0 for undersized Frames, or 0 otherwise. + * + * If necessary the undersized-flag is corrected. + * We need this in the FormatWidthCols to "deflate" columns there. + */ + SwTwips Undersize(); + SwTwips CalcUndersize() const; + + /// Adapt size to surroundings + void CheckClipping( bool bGrow, bool bMaximize ); + + void InvalidateFootnotePos(); + void CollectEndnotes( SwLayouter* pLayouter ); + const SwSectionFormat* GetEndSectFormat() const { + if( IsEndnAtEnd() ) return GetEndSectFormat_(); + return nullptr; + } + + static void MoveContentAndDelete( SwSectionFrame* pDel, bool bSave ); + + bool IsBalancedSection() const; + + virtual void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; + void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override; + + bool IsFootnoteAtEnd() const { return m_bFootnoteAtEnd; } + bool IsEndnAtEnd() const { return m_bEndnAtEnd; } + bool IsAnyNoteAtEnd() const { return m_bFootnoteAtEnd || m_bEndnAtEnd; } + + void SetContentLock( bool bNew ) { m_bContentLock = bNew; } + bool IsContentLocked() const { return m_bContentLock; } + + bool IsOwnFootnoteNum() const { return m_bOwnFootnoteNum; } + + void SetFootnoteLock( bool bNew ) { m_bFootnoteLock = bNew; } + bool IsFootnoteLock() const { return m_bFootnoteLock; } +}; + +inline const SwSectionFrame *SwSectionFrame::GetFollow() const +{ + return static_cast(SwFlowFrame::GetFollow()); +} +inline SwSectionFrame *SwSectionFrame::GetFollow() +{ + return static_cast(SwFlowFrame::GetFollow()); +} +inline const SwContentFrame *SwSectionFrame::FindLastContent() const +{ + return const_cast(this)->FindLastContent(); +} + +#endif // INCLUDED_SW_SOURCE_CORE_INC_SECTFRM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/sortedobjs.hxx b/sw/source/core/inc/sortedobjs.hxx new file mode 100644 index 0000000000..6d524f4928 --- /dev/null +++ b/sw/source/core/inc/sortedobjs.hxx @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_SORTEDOBJS_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_SORTEDOBJS_HXX + +#include +#include + +class SwAnchoredObject; + +/** class for collecting anchored objects + + for #i28701# + Anchored objects can be inserted and deleted. The entries can be directly + accessed via index. + An anchored object is inserted sorted. The sort criteria are: + - anchor type + - order 1: to-page, 2: to-fly, 3: to-paragraph|to-character|as-character + - anchor node + - wrapping style (inclusive layer) + - order 1: wrapping style != css::text::WrapTextMode_THROUGH and not in hell layer, + 2: wrapping style = css::text::WrapTextMode_THROUGH or in hell layer + - wrapping style influence + - order 1: NONE_SUCCESSIVE_POSITIONED, 2: NONE_CONCURRENT_POSITIONED + - again anchor type + - order 1: to-paragraph, 2: to-character, 3: as-character + - anchor node position + - internal anchor order number + If one of the sort criteria attributes of an anchored object changes, + the sorting has to be updated - use method +*/ +class SW_DLLPUBLIC SwSortedObjs +{ + private: + std::vector< SwAnchoredObject* > maSortedObjLst; + + public: + typedef std::vector::const_iterator const_iterator; + SwSortedObjs(); + ~SwSortedObjs(); + + size_t size() const; + + /** direct access to the entries + + @param _nIndex + input parameter - index of entry, valid value range [0..size()-1] + */ + SwAnchoredObject* operator[]( size_t _nIndex ) const; + const_iterator begin() const + { return maSortedObjLst.cbegin(); }; + const_iterator end() const + { return maSortedObjLst.cend(); }; + + bool Insert( SwAnchoredObject& _rAnchoredObj ); + + void Remove( SwAnchoredObject& _rAnchoredObj ); + + bool Contains( const SwAnchoredObject& _rAnchoredObj ) const; + + /** method to update the position of the given anchored object in the + sorted list + + @return boolean, indicating success of the update. + */ + void Update(SwAnchoredObject& _rAnchoredObj); + void UpdateAll(); + + /** Position of object <_rAnchoredObj> in sorted list + + Returns the number of the list position of object <_rAnchoredObj>. + Returns , if object isn't contained in list. + + @return size_t + Number of the list position of object <_rAnchoredObj> + */ + size_t ListPosOf( const SwAnchoredObject& _rAnchoredObj ) const; + + bool is_sorted() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/swblocks.hxx b/sw/source/core/inc/swblocks.hxx new file mode 100644 index 0000000000..7bd877ad65 --- /dev/null +++ b/sw/source/core/inc/swblocks.hxx @@ -0,0 +1,129 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_SWBLOCKS_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_SWBLOCKS_HXX + +#include +#include +#include +#include +#include + +class SwPaM; +class SwDoc; +class SvxMacroTableDtor; + +// Name of a text block: + +class SwBlockName +{ + friend class SwImpBlocks; + sal_uInt16 m_nHashS, m_nHashL; // Hash codes for testing +public: + OUString m_aShort; /// Shortname + OUString m_aLong; /// Longname + OUString m_aPackageName; /// Package name + bool m_bIsOnlyTextFlagInit : 1; /// Is the Flag valid? + bool m_bIsOnlyText : 1; /// Unformatted text + + SwBlockName( const OUString& rShort, const OUString& rLong ); + SwBlockName( const OUString& rShort, const OUString& rLong, OUString aPackageName ); + + /// For sorting in the array + bool operator< ( const SwBlockName& r ) const { return m_aShort < r.m_aShort; } +}; + +class SwBlockNames : public o3tl::sorted_vector, o3tl::less_uniqueptr_to > {}; + +class SwImpBlocks +{ + friend class SwTextBlocks; +protected: + OUString m_aFile; // Physical file name + OUString m_aName; // Logical file name + OUString m_aCurrentText; // Current text + OUString m_aShort, m_aLong; // Short- and longname (PutDoc) + OUString m_sBaseURL; // Base URL - has to be set at the Readers and Writers + SwBlockNames m_aNames; // List of all Blocks + Date m_aDateModified; // For aligning the Actions + tools::Time m_aTimeModified; + rtl::Reference m_xDoc; // Document to be switched + sal_uInt16 m_nCurrentIndex; // Current Index + bool m_bReadOnly : 1; + bool m_bInPutMuchBlocks : 1; // Put several block entries + bool m_bInfoChanged : 1; // Whether any info of TextBlock changed + + explicit SwImpBlocks( const OUString& ); + + enum class FileType { + NoFile, // Not present + None, // No TB file + XML // XML Block List + }; + static FileType GetFileType( const OUString& ); + + virtual void ClearDoc(); // Delete Doc content + std::unique_ptr MakePaM(); // Span PaM over Doc + virtual void AddName( const OUString&, const OUString&, bool bOnlyText = false ); + bool IsFileChanged() const; + void Touch(); + +public: + virtual ~SwImpBlocks(); + + static sal_uInt16 Hash( std::u16string_view ); /// Hashcode for Block names + sal_uInt16 GetCount() const; /// Get count of Text Blocks + sal_uInt16 GetIndex( const OUString& ) const; /// Index for shortnames + sal_uInt16 GetLongIndex( std::u16string_view ) const; /// Index for longnames + OUString GetShortName( sal_uInt16 ) const; /// Return shortname for index + OUString GetLongName( sal_uInt16 ) const; /// Return longname for index + OUString GetPackageName( sal_uInt16 ) const; /// Return packagename for index + + const OUString& GetFileName() const {return m_aFile;} /// Return physical file name + void SetName( const OUString& rName ) /// Logic name + { m_aName = rName; m_bInfoChanged = true; } + const OUString& GetName() const + { return m_aName; } + + const OUString& GetBaseURL() const { return m_sBaseURL;} + void SetBaseURL( const OUString& rURL ) { m_sBaseURL = rURL; } + + virtual ErrCode Delete( sal_uInt16 ) = 0; + virtual ErrCode Rename( sal_uInt16, const OUString& ) = 0; + virtual ErrCode CopyBlock( SwImpBlocks& rImp, OUString& rShort, const OUString& rLong) = 0; + virtual ErrCode GetDoc( sal_uInt16 ) = 0; + virtual ErrCode BeginPutDoc( const OUString&, const OUString& ) = 0; + virtual ErrCode PutDoc() = 0; + virtual ErrCode PutText( const OUString&, const OUString&, const OUString& ) = 0; + virtual ErrCode MakeBlockList() = 0; + + virtual ErrCode OpenFile( bool bReadOnly = true ) = 0; + virtual void CloseFile() = 0; + + virtual bool IsOnlyTextBlock( const OUString& rShort ) const; + + virtual ErrCode GetMacroTable( sal_uInt16 nIdx, SvxMacroTableDtor& rMacroTable ); + virtual ErrCode SetMacroTable( sal_uInt16 nIdx, + const SvxMacroTableDtor& rMacroTable ); + virtual bool PutMuchEntries( bool bOn ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/swcache.hxx b/sw/source/core/inc/swcache.hxx new file mode 100644 index 0000000000..df8ed2a64e --- /dev/null +++ b/sw/source/core/inc/swcache.hxx @@ -0,0 +1,268 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_SWCACHE_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_SWCACHE_HXX + +/** + * Here, we manage pointers in a simple PtrArray to objects. + * These objects are created (using new) in cache access classes; they are + * destroyed by the cache. + * + * One can access these objects by array index or by searching in the array. + * If you access it by index, managing the index is the responsibility of + * the cache user. + * + * The cached objects are derived from the base class SwCacheObj. + * In it, the cache objects are doubly-linked which allows for the use of + * an LRU algorithm. + * + * The LRU algorithm can be changed in the base class, by setting a virtual + * First Pointer. It can be set to the first real one plus an offset. + * By doing so we can protect the start area of the cache and make sure we + * don't mess up the cache during some special operations. + * E.g.: the Idle Handler should not destroy the cache for the visible area. + * + * The cache can be grown and shrunk in size. + * E.g.: The cache for FormatInfo is grown for every new Shell and shrunk + * when destroying them. + */ + +#include +#include + +#include +#include + +class SwCacheObj; + +class SwCache +{ + std::vector> m_aCacheObjects; + std::vector m_aFreePositions; /// Free positions for the Insert if the maximum has not been reached + /// Every time an object is deregistered, its position is added here + SwCacheObj *m_pRealFirst; /// _ALWAYS_ the real first LRU + SwCacheObj *m_pFirst; /// The virtual first, only different to m_pRealFirst when SetLRUOfst has been called + SwCacheObj *m_pLast; + + sal_uInt16 m_nCurMax; // Maximum of accepted objects + + void DeleteObj( SwCacheObj *pObj ); + +#ifdef DBG_UTIL + OString m_aName; + tools::Long m_nAppend; /// number of entries appended + tools::Long m_nInsertFree; /// number of entries inserted on freed position + tools::Long m_nReplace; /// number of LRU replacements + tools::Long m_nGetSuccess; + tools::Long m_nGetFail; + tools::Long m_nToTop; /// number of reordering (LRU) + tools::Long m_nDelete; /// number of explicit deletes + tools::Long m_nGetSeek; /// number of gets without index + tools::Long m_nAverageSeekCnt; /// number of seeks for all gets without index + tools::Long m_nFlushCnt; /// number of flush calls + tools::Long m_nFlushedObjects; + tools::Long m_nIncreaseMax; /// number of cache size increases + tools::Long m_nDecreaseMax; /// number of cache size decreases + + void Check(); +#endif + +public: + +// Only add sal_uInt8!!! +#ifdef DBG_UTIL + SwCache( const sal_uInt16 nInitSize, OString aNm ); +#else + SwCache( const sal_uInt16 nInitSize ); +#endif + /// The dtor will free all objects still in the vector + ~SwCache(); + + void Flush(); + + //bToTop == false -> No LRU resorting! + SwCacheObj *Get( const void *pOwner, const bool bToTop = true ); + SwCacheObj *Get( const void *pOwner, const sal_uInt16 nIndex, + const bool bToTop = true ); + void ToTop( SwCacheObj *pObj ); + + bool Insert(SwCacheObj *pNew, bool isDuplicateOwnerAllowed); + void Delete(const void * pOwner, sal_uInt16 nIndex); + void Delete( const void *pOwner ); + + /// Mark some entries as "do not delete" + /// @param nOfst determines how many are not to be touched + void SetLRUOfst( const sal_uInt16 nOfst ); + void ResetLRUOfst() { m_pFirst = m_pRealFirst; } + + void IncreaseMax( const sal_uInt16 nAdd ); + void DecreaseMax( const sal_uInt16 nSub ); + sal_uInt16 GetCurMax() const { return m_nCurMax; } + SwCacheObj *First() { return m_pRealFirst; } + static inline SwCacheObj *Next( SwCacheObj *pCacheObj); + SwCacheObj* operator[](sal_uInt16 nIndex) { return m_aCacheObjects[nIndex].get(); } + sal_uInt16 size() { return m_aCacheObjects.size(); } +}; + +/// Try to prevent visible SwParaPortions from being deleted. +class SwSaveSetLRUOfst +{ +public: + SwSaveSetLRUOfst(); + ~SwSaveSetLRUOfst(); +}; + +/** + * The Cache object base class + * Users of the Cache must derive a class from the SwCacheObj and store + * their payload there + */ +class SwCacheObj +{ + friend class SwCache; /// Can do everything + + SwCacheObj *m_pNext; /// For the LRU chaining + SwCacheObj *m_pPrev; + + sal_uInt16 m_nCachePos; /// Position in the Cache array + + sal_uInt8 m_nLock; + + SwCacheObj *GetNext() { return m_pNext; } + SwCacheObj *GetPrev() { return m_pPrev; } + void SetNext( SwCacheObj *pNew ) { m_pNext = pNew; } + void SetPrev( SwCacheObj *pNew ) { m_pPrev = pNew; } + + void SetCachePos(const sal_uInt16 nNew) + { + if (m_nCachePos != nNew) + { + m_nCachePos = nNew; + UpdateCachePos(); + } + } + virtual void UpdateCachePos() { } + +protected: + const void *m_pOwner; + +public: + + SwCacheObj( const void *pOwner ); + virtual ~SwCacheObj(); + + const void *GetOwner() const { return m_pOwner; } + inline bool IsOwner( const void *pNew ) const; + + sal_uInt16 GetCachePos() const { return m_nCachePos; } + + bool IsLocked() const { return 0 != m_nLock; } + +#ifdef DBG_UTIL + void Lock(); + void Unlock(); +#else + void Lock() { ++m_nLock; } + void Unlock() { --m_nLock; } +#endif +}; + +/** + * Access class for the Cache + * + * The Cache object is created in the ctor. + * If the Cache does not return one, the member is set to 0 and one is + * created on the Get() and added to the Cache (if possible). + * Cache users must derive a class from SwCacheAccess in order to + * guarantee type safety. The base class should always be called for the + * Get(). A derived Get() should only ever guarantee type safety. + * Cache objects are always locked for the instance's life time. + */ +class SwCacheAccess +{ + SwCache &m_rCache; + + void Get_(bool isDuplicateOwnerAllowed); + +protected: + SwCacheObj *m_pObj; + const void *m_pOwner; /// Can be use in NewObj + + virtual SwCacheObj *NewObj() = 0; + + inline SwCacheObj *Get(bool isDuplicateOwnerAllowed); + + inline SwCacheAccess( SwCache &rCache, const void *pOwner, bool bSeek ); + inline SwCacheAccess( SwCache &rCache, const void* nCacheId, const sal_uInt16 nIndex ); + +public: + virtual ~SwCacheAccess(); +}; + + +inline bool SwCacheObj::IsOwner( const void *pNew ) const +{ + return m_pOwner && m_pOwner == pNew; +} + +inline SwCacheObj *SwCache::Next( SwCacheObj *pCacheObj) +{ + if ( pCacheObj ) + return pCacheObj->GetNext(); + else + return nullptr; +} + +inline SwCacheAccess::SwCacheAccess( SwCache &rC, const void *pOwn, bool bSeek ) : + m_rCache( rC ), + m_pObj( nullptr ), + m_pOwner( pOwn ) +{ + if ( bSeek && m_pOwner ) + { + m_pObj = m_rCache.Get( m_pOwner ); + if (m_pObj) + m_pObj->Lock(); + } +} + +inline SwCacheAccess::SwCacheAccess( SwCache &rC, const void* nCacheId, + const sal_uInt16 nIndex ) : + m_rCache( rC ), + m_pObj( nullptr ), + m_pOwner( nCacheId ) +{ + if ( m_pOwner ) + { + m_pObj = m_rCache.Get( m_pOwner, nIndex ); + if (m_pObj) + m_pObj->Lock(); + } +} + +inline SwCacheObj *SwCacheAccess::Get(bool const isDuplicateOwnerAllowed = true) +{ + if ( !m_pObj ) + Get_(isDuplicateOwnerAllowed); + return m_pObj; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/swfntcch.hxx b/sw/source/core/inc/swfntcch.hxx new file mode 100644 index 0000000000..a895ee8550 --- /dev/null +++ b/sw/source/core/inc/swfntcch.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_SWFNTCCH_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_SWFNTCCH_HXX + +#define NUM_DEFAULT_VALUES 39 + +#include "swcache.hxx" +#include "swfont.hxx" + +class SwViewShell; +class SfxPoolItem; + +class SwFontCache : public SwCache +{ +public: + + SwFontCache() : SwCache(50 +#ifdef DBG_UTIL + , "Global AttributeSet/Font-Cache pSwFontCache"_ostr +#endif + ) {} + +}; + +// AttributeSet/Font-Cache, globale Variable, in FontCache.Cxx angelegt +extern SwFontCache *pSwFontCache; + +class SwFontObj final : public SwCacheObj +{ + friend class SwFontAccess; + +private: + SwFont m_aSwFont; + const SfxPoolItem* m_pDefaultArray[ NUM_DEFAULT_VALUES ]; + +public: + SwFontObj( const void* pOwner, SwViewShell *pSh ); + + virtual ~SwFontObj() override; + + SwFont& GetFont() { return m_aSwFont; } + const SwFont& GetFont() const { return m_aSwFont; } + const SfxPoolItem** GetDefault() { return m_pDefaultArray; } +}; + +class SwFontAccess final : public SwCacheAccess +{ + SwViewShell *m_pShell; + + virtual SwCacheObj *NewObj( ) override; + +public: + SwFontAccess( const void *pOwner, SwViewShell *pSh ); + SwFontObj *Get(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx new file mode 100644 index 0000000000..86f44fb3eb --- /dev/null +++ b/sw/source/core/inc/swfont.hxx @@ -0,0 +1,1010 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_SWFONT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_SWFONT_HXX + +#include +#include +#include +#include +#include +#include +#include +#include "drawfont.hxx" +#include +#include +#include + +class SfxItemSet; +class SwAttrSet; +class SwDoCapitals; // DoCapitals +class SwScriptInfo; // GetTextSize_ +class SwViewShell; +class IDocumentSettingAccess; +enum class SvxShadowItemSide; + +const sal_Unicode CH_BLANK = ' '; // ' ' blank spaces +const sal_Unicode CH_BREAK = 0x0A; +const sal_Unicode CH_TAB = '\t'; // \t +constexpr OUStringChar CH_PAR = u'\u00B6'; // paragraph +const sal_Unicode CH_BULLET = 0xB7; // centered dot +const sal_Unicode CH_FULL_BLANK = 0x3000; +const sal_Unicode CH_NB_SPACE = 0xA0; +const sal_Unicode CH_SIX_PER_EM = 0x2006; // six-per-em space + +Degree10 UnMapDirection( Degree10 nDir, const bool bVertFormat, const bool bVertFormatLRBT ); + +class SwSubFont final : public SvxFont +{ + friend class SwFont; + const void* m_nFontCacheId; // "MagicNumber" within the font cache + Size m_aSize; // foreigners only see this size + sal_uInt16 m_nFontIndex; // index in the font cache + sal_uInt16 m_nOrgHeight; // height including escapement/proportion + sal_uInt16 m_nOrgAscent; // ascent including escapement/proportion + sal_uInt16 m_nProportionalWidth; // proportional width + bool m_bSmallCapsPercentage66; + + sal_uInt16 CalcEscAscent( const sal_uInt16 nOldAscent ) const; + sal_uInt16 CalcEscHeight( const sal_uInt16 nOldHeight, + const sal_uInt16 nOldAscent ) const; + void CalcEsc( SwDrawTextInfo const & rInf, Point& rPos ); + + short CheckKerning_( ); + + bool ChgFnt( SwViewShell const *pSh, OutputDevice& rOut ); + bool IsSymbol( SwViewShell const *pSh ); + sal_uInt16 GetAscent( SwViewShell const *pSh, const OutputDevice& rOut ); + sal_uInt16 GetHeight( SwViewShell const *pSh, const OutputDevice& rOut ); + sal_uInt16 GetHangingBaseline( SwViewShell const *pSh, const OutputDevice& rOut ); + Size GetTextSize_( SwDrawTextInfo& rInf ); + Size GetCapitalSize( SwDrawTextInfo& rInf ); + void DrawText_( SwDrawTextInfo &rInf, const bool bGrey ); + void DrawCapital( SwDrawTextInfo &rInf ); + void DrawStretchCapital( SwDrawTextInfo &rInf ); + void DoOnCapitals( SwDoCapitals &rDo ); + void DrawStretchText_( SwDrawTextInfo &rInf ); + TextFrameIndex GetModelPositionForViewPoint_( SwDrawTextInfo& rInf ); + TextFrameIndex GetCapitalCursorOfst( SwDrawTextInfo& rInf ); + + inline void SetColor( const Color& rColor ); + inline void SetFillColor( const Color& rColor ); + inline void SetCharSet( const rtl_TextEncoding eCharSet ); + inline void SetPitch( const FontPitch ePitch ); + inline void SetAlign( const TextAlign eAlign ); + inline void SetUnderline( const FontLineStyle eUnderline ); + inline void SetOverline( const FontLineStyle eOverline ); + inline void SetStrikeout( const FontStrikeout eStrikeout ); + inline void SetItalic( const FontItalic eItalic ); + inline void SetOutline( const bool bOutline ); + inline void SetVertical( const Degree10 nDir, const bool bVertFormat ); + inline void SetShadow( const bool bShadow ); + inline void SetAutoKern( FontKerning nAutoKern ); + inline void SetWordLineMode( const bool bWordLineMode ); + inline void SetEmphasisMark( const FontEmphasisMark eValue ); + inline void SetRelief( const FontRelief eNew ); + + // methods for sub-/superscript + inline void SetEscapement( const short nNewEsc ); + inline void SetProportion( const sal_uInt8 nNewPropr ); + + inline void SetFamily( const FontFamily eFamily ); + inline void SetName( const OUString& rName ); + inline void SetStyleName( const OUString& rStyleName ); + inline void SetSize( const Size& rSize ); + inline void SetWeight( const FontWeight eWeight ); + inline void SetLanguage( LanguageType eNewLang ); + short CheckKerning() + { return GetFixKerning() >= 0 ? GetFixKerning() : CheckKerning_( ); } + void SetPropWidth( const sal_uInt16 nNew ) + { m_nFontCacheId = nullptr; m_nProportionalWidth = nNew; } +public: + SwSubFont() : m_aSize(0,0) + { m_nFontCacheId = nullptr; m_nFontIndex = m_nOrgHeight = m_nOrgAscent = 0; m_nProportionalWidth =100; m_bSmallCapsPercentage66 = false; } + sal_uInt16 GetPropWidth() const { return m_nProportionalWidth; } +}; + +enum class SwFontScript +{ + Latin, CJK, CTL, LAST = CTL +}; + +// mostly used as a "unknown script" marker +#define SW_SCRIPTS (SwFontScript(int(SwFontScript::LAST)+1)) + +/// To take Asian or other languages into consideration, an SwFont object consists of 3 SwSubFonts +/// (Latin, CJK, and CTL). The m_nActual member indicates the current script, i.e. the currently +/// active subfont. +class SwFont +{ + // CJK == Chinese, Japanese, Korean + // CTL == Complex text layout ( Hebrew, Arabic ) + o3tl::enumarray m_aSub; // Latin-, CJK- and CTL-font + + std::optional + mxBackColor; // background color (i.e. at character styles) + Color m_aHighlightColor; // highlight color + Color m_aUnderColor; // color of the underlining + Color m_aOverColor; // color of the overlining + + // character borders + std::optional m_aTopBorder; + std::optional m_aBottomBorder; + std::optional m_aRightBorder; + std::optional m_aLeftBorder; + + // border distance + sal_uInt16 m_nTopBorderDist; + sal_uInt16 m_nBottomBorderDist; + sal_uInt16 m_nRightBorderDist; + sal_uInt16 m_nLeftBorderDist; + + Color m_aShadowColor; + sal_uInt16 m_nShadowWidth; + SvxShadowLocation m_aShadowLocation; + + sal_uInt8 m_nToxCount; // counts the nesting depth of the Tox + sal_uInt8 m_nRefCount; // counts the nesting depth of the Refs + sal_uInt8 m_nMetaCount; // count META/METAFIELD + sal_uInt8 m_nContentControlCount; // count CONTENTCONTROL + sal_uInt8 m_nInputFieldCount; // count INPUTFIELD + + SwFontScript m_nActual; // actual font (Latin, CJK or CTL) + + // switch for the font-extensions + bool m_bPaintBlank :1; // blanks not with DrawRect + bool m_bFontChg :1; + bool m_bOrgChg :1; // nOrgHeight/Ascent are invalid + bool m_bGreyWave :1; // for the extended TextInput: gray waveline + +public: + SwFont( const SwAttrSet* pSet, const IDocumentSettingAccess* pIDocumentSettingAccess ); + SwFont( const SwFont& rFont ); + + void ChgFnt( SwViewShell const *pSh, OutputDevice& rOut ) + { m_bPaintBlank = m_aSub[m_nActual].ChgFnt( pSh, rOut ); } + + ~SwFont(); + + SwFont& operator=( const SwFont &rFont ); + + SwFontScript GetActual() const { return m_nActual; } + inline void SetActual( SwFontScript nNew ); + const SvxFont& GetActualFont() const { return m_aSub[m_nActual]; } + + // gets a font cache id via SwFntAccess + void AllocFontCacheId( SwViewShell const *pSh, SwFontScript nWhich ); + // set background color + void SetBackColor( std::optional xNewColor ); + const std::optional& GetBackColor() const{ return mxBackColor; } + void SetHighlightColor( const Color& aNewColor ); + const Color& GetHighlightColor() const { return m_aHighlightColor; } + + void CheckFontCacheId( SwViewShell const *pSh, SwFontScript nWhich ) + { if( !m_aSub[ nWhich ].m_nFontCacheId ) AllocFontCacheId( pSh, nWhich ); } + void GetFontCacheId( const void* &rnFontCacheId, sal_uInt16 &rIdx, SwFontScript nWhich ) + { rnFontCacheId = m_aSub[nWhich].m_nFontCacheId; rIdx = m_aSub[nWhich].m_nFontIndex; } + void SetFontCacheId( const void* nNewFontCacheId, const sal_uInt16 nIdx, SwFontScript nWhich ) + { m_aSub[nWhich].m_nFontCacheId = nNewFontCacheId; m_aSub[nWhich].m_nFontIndex = nIdx; } + bool DifferentFontCacheId( const SwFont* pFnt, SwFontScript nWhich ) + { return m_aSub[nWhich].m_nFontCacheId != pFnt->m_aSub[nWhich].m_nFontCacheId || + !m_aSub[nWhich].m_nFontCacheId || !pFnt->m_aSub[nWhich].m_nFontCacheId; } + + const Size &GetSize( SwFontScript nWhich ) const + { return m_aSub[nWhich].m_aSize; } + bool IsFntChg() const { return m_bFontChg; } + void SetFntChg( const bool bNew ) { m_bFontChg = bNew; } + + // the encapsulated SV-Font-methods (set bFntChg to true) + inline void SetColor( const Color& rColor ); + inline void SetFillColor( const Color& rColor ); + inline void SetAlign( const TextAlign eAlign ); + inline void SetUnderline( const FontLineStyle eUnderline ); + void SetUnderColor( const Color &rColor ) { m_aUnderColor = rColor; } + inline void SetOverline( const FontLineStyle eOverline ); + void SetOverColor( const Color &rColor ) { m_aOverColor = rColor; } + inline void SetStrikeout( const FontStrikeout eStrikeout ); + inline void SetOutline( const bool bOutline ); + void SetVertical(Degree10 nDir, const bool bVertLayout = false, + const bool bVertLayoutLRBT = false); + inline void SetShadow( const bool bShadow ); + inline void SetAutoKern( FontKerning nAutoKern ); + inline void SetTransparent( const bool bTrans ); + inline void SetWordLineMode( const bool bWordLineMode ); + inline void SetFixKerning( const short nNewKern ); + inline void SetCaseMap( const SvxCaseMap eNew ); + inline void SetEmphasisMark( const FontEmphasisMark eValue ); + + // methods for sub-/superscript + inline void SetEscapement( const short nNewEsc ); + inline void SetProportion( const sal_uInt8 nNewPropr ); + + inline void SetPropWidth( const sal_uInt16 nNew ); + + inline void SetFamily( const FontFamily eFamily, const SwFontScript nWhich ); + inline void SetName( const OUString& rName, const SwFontScript nWhich ); + inline void SetStyleName( const OUString& rStyleName, const SwFontScript nWhich ); + inline void SetSize( const Size& rSize, const SwFontScript nWhich ); + inline void SetWeight( const FontWeight eWeight, const SwFontScript nWhich ); + inline void SetItalic( const FontItalic eItalic, const SwFontScript nWhich ); + inline void SetLanguage( LanguageType eNewLang, const SwFontScript nWhich ); + inline void SetCharSet( const rtl_TextEncoding eCharSet, const SwFontScript nWhich ); + inline void SetPitch( const FontPitch ePitch, const SwFontScript nWhich ); + inline void SetRelief( const FontRelief eNew ); + + // Get/Set-methods for the current setting + sal_uInt8 &GetTox() { return m_nToxCount; } + bool IsTox() const { return ( 0 != m_nToxCount ); } + sal_uInt8 &GetRef() { return m_nRefCount; } + bool IsRef() const { return ( 0 != m_nRefCount ); } + sal_uInt8 &GetMeta() { return m_nMetaCount; } + bool IsMeta() const { return (0 != m_nMetaCount); } + sal_uInt8& GetContentControl() { return m_nContentControlCount; } + bool IsContentControl() const { return m_nContentControlCount != 0; } + sal_uInt8 &GetInputField() { return m_nInputFieldCount; } + bool IsInputField() const { return (0 != m_nInputFieldCount); } + inline void SetGreyWave( const bool bNew ); + bool IsGreyWave() const { return m_bGreyWave; } + bool IsPaintBlank() const { return m_bPaintBlank; } + + // setting of the base class font for SwTextCharFormat + void SetDiffFnt( const SfxItemSet* pSet, + const IDocumentSettingAccess* pIDocumentSettingAccess ); + + const SvxFont &GetFnt( const SwFontScript nWhich ) const + { return m_aSub[nWhich]; }; + + bool IsSymbol( SwViewShell const *pSh ) + { return m_aSub[m_nActual].IsSymbol( pSh ); } + FontLineStyle GetUnderline() const { return m_aSub[m_nActual].GetUnderline(); } + const Color& GetUnderColor() const { return m_aUnderColor; } + FontLineStyle GetOverline() const { return m_aSub[m_nActual].GetOverline(); } + const Color& GetOverColor() const { return m_aOverColor; } + FontStrikeout GetStrikeout() const { return m_aSub[m_nActual].GetStrikeout(); } + const Color& GetColor() const { return m_aSub[m_nActual].GetColor(); } + bool IsWordLineMode() const { return m_aSub[m_nActual].IsWordLineMode(); } + short GetEscapement() const { return m_aSub[m_nActual].GetEscapement(); } + SvxCaseMap GetCaseMap() const { return m_aSub[m_nActual].GetCaseMap(); } + sal_uInt8 GetPropr() const { return m_aSub[m_nActual].GetPropr(); } + FontItalic GetItalic() const { return m_aSub[m_nActual].GetItalic(); } + LanguageType GetLanguage() const { return m_aSub[m_nActual].GetLanguage(); } + tools::Long GetHeight() const { return m_aSub[m_nActual].GetFontSize().Height(); } + FontWeight GetWeight() const { return m_aSub[m_nActual].GetWeight(); } + FontEmphasisMark GetEmphasisMark() const + { return m_aSub[m_nActual].GetEmphasisMark(); } + Degree10 GetOrientation(const bool bVertLayout = false, + const bool bVertFormatLRBT = false) const; + + const OUString& GetName( const SwFontScript nWhich ) const + { return m_aSub[nWhich].GetFamilyName(); } + LanguageType GetLanguage( const SwFontScript nWhich ) const + { return m_aSub[nWhich].GetLanguage(); } + rtl_TextEncoding GetCharSet( const SwFontScript nWhich ) const + { return m_aSub[nWhich].GetCharSet(); } + tools::Long GetHeight( const SwFontScript nWhich ) const + { return m_aSub[nWhich].GetFontSize().Height(); } + + // makes the logical font be effective in the OutputDevice + void ChgPhysFnt( SwViewShell const *pSh, OutputDevice& rOut ); + + TextFrameIndex GetCapitalBreak( SwViewShell const* pSh, const OutputDevice* pOut, + const SwScriptInfo* pScript, const OUString& rText, + tools::Long nTextWidth, TextFrameIndex nIdx, TextFrameIndex nLen); + + void DoOnCapitals( SwDoCapitals &rDo ) + { m_aSub[m_nActual].DoOnCapitals( rDo ); } + + Size GetTextSize_( SwDrawTextInfo& rInf ) + { rInf.SetFont( this ); return m_aSub[m_nActual].GetTextSize_( rInf ); } + + TextFrameIndex GetTextBreak( SwDrawTextInfo const & rInf, tools::Long nTextWidth ); + + TextFrameIndex GetModelPositionForViewPoint_( SwDrawTextInfo& rInf ) + { return m_aSub[m_nActual].GetModelPositionForViewPoint_( rInf ); } + + void DrawText_( SwDrawTextInfo &rInf ) + { m_aSub[m_nActual].DrawText_( rInf, IsGreyWave() ); } + + void DrawStretchText_( SwDrawTextInfo &rInf ) + { m_aSub[m_nActual].DrawStretchText_( rInf ); } + + short CheckKerning() + { return m_aSub[m_nActual].CheckKerning(); } + + sal_uInt16 GetAscent( SwViewShell const *pSh, const OutputDevice& rOut ) + { return m_aSub[m_nActual].GetAscent( pSh, rOut ); } + sal_uInt16 GetHeight( SwViewShell const *pSh, const OutputDevice& rOut ) + { return m_aSub[m_nActual].GetHeight( pSh, rOut ); } + + sal_uInt16 GetHangingBaseline( SwViewShell const *pSh, const OutputDevice& rOut ) + { return m_nActual == SwFontScript::CTL ? m_aSub[m_nActual].GetHangingBaseline( pSh, rOut ) : 0; } + + void Invalidate() + { m_bFontChg = m_bOrgChg = true; } + + void SetTopBorder( const editeng::SvxBorderLine* pTopBorder ); + void SetBottomBorder( const editeng::SvxBorderLine* pBottomBorder ); + void SetRightBorder( const editeng::SvxBorderLine* pRightBorder ); + void SetLeftBorder( const editeng::SvxBorderLine* pLeftBorder ); + + const std::optional& GetTopBorder() const { return m_aTopBorder; } + const std::optional& GetBottomBorder() const { return m_aBottomBorder; } + const std::optional& GetRightBorder() const { return m_aRightBorder; } + const std::optional& GetLeftBorder() const { return m_aLeftBorder; } + + // Get absolute border correspond to the layout verticality and orientation. + const std::optional& + GetAbsTopBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const; + const std::optional& + GetAbsBottomBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const; + const std::optional& + GetAbsRightBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const; + const std::optional& + GetAbsLeftBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const; + + void SetTopBorderDist( const sal_uInt16 nTopDist ); + void SetBottomBorderDist( const sal_uInt16 nBottomDist ); + void SetRightBorderDist( const sal_uInt16 nRightDist ); + void SetLeftBorderDist( const sal_uInt16 nLeftDist ); + + sal_uInt16 GetTopBorderDist() const { return m_nTopBorderDist; } + sal_uInt16 GetBottomBorderDist() const { return m_nBottomBorderDist; } + sal_uInt16 GetRightBorderDist() const { return m_nRightBorderDist; } + sal_uInt16 GetLeftBorderDist() const { return m_nLeftBorderDist; } + + // Return with the whole space which border holed (border width, spacing and shadow width) + sal_uInt16 GetTopBorderSpace() const; + sal_uInt16 GetBottomBorderSpace() const; + sal_uInt16 GetRightBorderSpace() const; + sal_uInt16 GetLeftBorderSpace() const; + + /// Check whether font has any border on any side + bool HasBorder() const; + + void SetShadowColor( const Color& rColor ); + void SetShadowWidth( const sal_uInt16 nWidth ); + void SetShadowLocation( const SvxShadowLocation aLocation ); + + const Color& GetShadowColor() const { return m_aShadowColor; } + sal_uInt16 GetShadowWidth() const { return m_nShadowWidth; } + SvxShadowLocation GetShadowLocation() const { return m_aShadowLocation; } + + /** + * Get the absolute shadow location dependent from orientation. + * + * @param[in] bVertLayout true, if the container layout is vertical + * false, otherwise + * @param[in] bVertLayoutLRBT true if the container layout is vertical + * (bottom to top, left to right), false otherwise + * @return absolute location + **/ + SvxShadowLocation GetAbsShadowLocation(const bool bVertLayout, + const bool bVertLayoutLRBT) const; + + /** + * Calculate the shadow space on the specified side dependent from + * the orientation and connection with neighbours. + * @see shaditem.hxx for integer constants of sides + * + * @param[in] nShadow specify the side + * @param[in] bVertLayout true, if the container layout is vertical + * false, otherwise + * @param[in] bVertLayoutLRBT true if the container layout is vertical + * (bottom to top, left to right), false otherwise + * @param[in] bSkipLeft relative left shadow space is skipped + * @param[in] bSkipRight relative right shadow space is skipped + * @return the shadow space + **/ + sal_uInt16 CalcShadowSpace( + const SvxShadowItemSide nShadow, const bool bVertLayout, const bool bVertLayoutLRBT, + const bool bSkipLeft, const bool bSkipRight ) const; + + void dumpAsXml( xmlTextWriterPtr writer ) const; +}; + +inline void SwFont::SetColor( const Color& rColor ) +{ + m_bFontChg = true; + m_aSub[SwFontScript::Latin].SetColor( rColor ); + m_aSub[SwFontScript::CJK].SetColor( rColor ); + m_aSub[SwFontScript::CTL].SetColor( rColor ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetColor( const Color& rColor ) +{ + m_nFontCacheId = nullptr; + Font::SetColor( rColor ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetFillColor( const Color& rColor ) +{ + m_nFontCacheId = nullptr; + Font::SetFillColor( rColor ); +} + +inline void SwFont::SetFillColor( const Color& rColor ) +{ + m_bFontChg = true; + m_aSub[SwFontScript::Latin].SetFillColor( rColor ); + m_aSub[SwFontScript::CJK].SetFillColor( rColor ); + m_aSub[SwFontScript::CTL].SetFillColor( rColor ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetFamily( const FontFamily eFamily ) +{ + m_nFontCacheId = nullptr; + Font::SetFamily( eFamily ); +} + +inline void SwFont::SetFamily( const FontFamily eFamily, const SwFontScript nWhich ) +{ + m_bFontChg = true; + m_aSub[nWhich].SetFamily( eFamily ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetName( const OUString& rName ) +{ + m_nFontCacheId = nullptr; + Font::SetFamilyName( rName ); +} + +inline void SwFont::SetName( const OUString& rName, const SwFontScript nWhich ) +{ + m_bFontChg = true; + m_aSub[nWhich].SetName( rName ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetStyleName( const OUString& rStyleName ) +{ + m_nFontCacheId = nullptr; + Font::SetStyleName( rStyleName ); +} + +inline void SwFont::SetStyleName( const OUString& rStyle, const SwFontScript nWhich ) +{ + m_bFontChg = true; + m_aSub[nWhich].SetStyleName( rStyle ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetCharSet( const rtl_TextEncoding eCharSet ) +{ + m_nFontCacheId = nullptr; + Font::SetCharSet( eCharSet ); +} + +inline void SwFont::SetCharSet( const rtl_TextEncoding eCharSet, const SwFontScript nWhich ) +{ + m_bFontChg = true; + m_aSub[nWhich].SetCharSet( eCharSet ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetPitch( const FontPitch ePitch ) +{ + m_nFontCacheId = nullptr; + Font::SetPitch( ePitch ); +} + +// encapsulated SV-Font-method +inline void SwFont::SetPitch( const FontPitch ePitch, const SwFontScript nWhich ) +{ + m_bFontChg = true; + m_aSub[nWhich].SetPitch( ePitch ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetAlign( const TextAlign eAlign ) +{ + m_nFontCacheId = nullptr; + Font::SetAlignment( eAlign ); +} + +inline void SwFont::SetAlign( const TextAlign eAlign ) +{ + m_bFontChg = true; + m_aSub[SwFontScript::Latin].SetAlign( eAlign ); + m_aSub[SwFontScript::CJK].SetAlign( eAlign ); + m_aSub[SwFontScript::CTL].SetAlign( eAlign ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetWeight( const FontWeight eWeight ) +{ + m_nFontCacheId = nullptr; + Font::SetWeight( eWeight ); +} + +inline void SwFont::SetWeight( const FontWeight eWeight, const SwFontScript nWhich ) +{ + m_bFontChg = true; + m_aSub[nWhich].SetWeight( eWeight ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetUnderline( const FontLineStyle eUnderline ) +{ + m_nFontCacheId = nullptr; + Font::SetUnderline( eUnderline ); +} + +inline void SwFont::SetUnderline( const FontLineStyle eUnderline ) +{ + m_bFontChg = true; + m_aSub[SwFontScript::Latin].SetUnderline( eUnderline ); + m_aSub[SwFontScript::CJK].SetUnderline( eUnderline ); + m_aSub[SwFontScript::CTL].SetUnderline( eUnderline ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetOverline( const FontLineStyle eOverline ) +{ + m_nFontCacheId = nullptr; + Font::SetOverline( eOverline ); +} + +inline void SwFont::SetOverline( const FontLineStyle eOverline ) +{ + m_bFontChg = true; + m_aSub[SwFontScript::Latin].SetOverline( eOverline ); + m_aSub[SwFontScript::CJK].SetOverline( eOverline ); + m_aSub[SwFontScript::CTL].SetOverline( eOverline ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetStrikeout( const FontStrikeout eStrikeout ) +{ + m_nFontCacheId = nullptr; + Font::SetStrikeout( eStrikeout ); +} + +inline void SwFont::SetStrikeout( const FontStrikeout eStrikeout ) +{ + m_bFontChg = true; + m_aSub[SwFontScript::Latin].SetStrikeout( eStrikeout ); + m_aSub[SwFontScript::CJK].SetStrikeout( eStrikeout ); + m_aSub[SwFontScript::CTL].SetStrikeout( eStrikeout ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetItalic( const FontItalic eItalic ) +{ + m_nFontCacheId = nullptr; + Font::SetItalic( eItalic ); +} + +inline void SwFont::SetItalic( const FontItalic eItalic, const SwFontScript nWhich ) +{ + m_bFontChg = true; + m_aSub[nWhich].SetItalic( eItalic ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetOutline( const bool bOutline ) +{ + m_nFontCacheId = nullptr; + Font::SetOutline( bOutline ); +} + +inline void SwFont::SetOutline( const bool bOutline ) +{ + m_bFontChg = true; + m_aSub[SwFontScript::Latin].SetOutline( bOutline ); + m_aSub[SwFontScript::CJK].SetOutline( bOutline ); + m_aSub[SwFontScript::CTL].SetOutline( bOutline ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetShadow( const bool bShadow ) +{ + m_nFontCacheId = nullptr; + Font::SetShadow( bShadow ); +} + +inline void SwFont::SetShadow( const bool bShadow ) +{ + m_bFontChg = true; + m_aSub[SwFontScript::Latin].SetShadow( bShadow ); + m_aSub[SwFontScript::CJK].SetShadow( bShadow ); + m_aSub[SwFontScript::CTL].SetShadow( bShadow ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetAutoKern( FontKerning nAutoKern ) +{ + m_nFontCacheId = nullptr; + Font::SetKerning( nAutoKern ); +} + +inline void SwFont::SetAutoKern( FontKerning nAutoKern ) +{ + m_bFontChg = true; + m_aSub[SwFontScript::CJK].SetAutoKern( nAutoKern ); + if( nAutoKern != FontKerning::NONE ) + nAutoKern = FontKerning::FontSpecific; + m_aSub[SwFontScript::Latin].SetAutoKern( nAutoKern ); + m_aSub[SwFontScript::CTL].SetAutoKern( nAutoKern ); +} + +inline void SwFont::SetTransparent( const bool bTrans ) +{ + m_aSub[SwFontScript::Latin].SetTransparent( bTrans ); + m_aSub[SwFontScript::CJK].SetTransparent( bTrans ); + m_aSub[SwFontScript::CTL].SetTransparent( bTrans ); +} + +inline void SwFont::SetFixKerning( const short nNewKern ) +{ + m_aSub[SwFontScript::Latin].SetFixKerning( nNewKern ); + m_aSub[SwFontScript::CJK].SetFixKerning( nNewKern ); + m_aSub[SwFontScript::CTL].SetFixKerning( nNewKern ); +} + +inline void SwFont::SetCaseMap( const SvxCaseMap eNew ) +{ + m_aSub[SwFontScript::Latin].SetCaseMap( eNew ); + m_aSub[SwFontScript::CJK].SetCaseMap( eNew ); + m_aSub[SwFontScript::CTL].SetCaseMap( eNew ); +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetWordLineMode( const bool bWordLineMode ) +{ + m_nFontCacheId = nullptr; + Font::SetWordLineMode( bWordLineMode ); +} + +inline void SwFont::SetWordLineMode( const bool bWordLineMode ) +{ + m_bFontChg = true; + m_aSub[SwFontScript::Latin].SetWordLineMode( bWordLineMode ); + m_aSub[SwFontScript::CJK].SetWordLineMode( bWordLineMode ); + m_aSub[SwFontScript::CTL].SetWordLineMode( bWordLineMode ); +} +// encapsulated SV-Font-method +inline void SwSubFont::SetEmphasisMark( const FontEmphasisMark eValue ) +{ + m_nFontCacheId = nullptr; + Font::SetEmphasisMark( eValue ); +} + +inline void SwFont::SetEmphasisMark( const FontEmphasisMark eValue ) +{ + m_bFontChg = true; + m_aSub[SwFontScript::Latin].SetEmphasisMark( eValue ); + m_aSub[SwFontScript::CJK].SetEmphasisMark( eValue ); + m_aSub[SwFontScript::CTL].SetEmphasisMark( eValue ); +} + +inline void SwFont::SetPropWidth( const sal_uInt16 nNew ) +{ + if( nNew != m_aSub[SwFontScript::Latin].GetPropWidth() ) + { + m_bFontChg = true; + m_aSub[SwFontScript::Latin].SetPropWidth( nNew ); + m_aSub[SwFontScript::CJK].SetPropWidth( nNew ); + m_aSub[SwFontScript::CTL].SetPropWidth( nNew ); + } +} + +// encapsulated SV-Font-method +inline void SwSubFont::SetRelief( const FontRelief eNew ) +{ + m_nFontCacheId = nullptr; + Font::SetRelief( eNew ); +} + +inline void SwFont::SetRelief( const FontRelief eNew ) +{ + if( eNew != m_aSub[SwFontScript::Latin].GetRelief() ) + { + m_bFontChg = true; + m_aSub[SwFontScript::Latin].SetRelief( eNew ); + m_aSub[SwFontScript::CJK].SetRelief( eNew ); + m_aSub[SwFontScript::CTL].SetRelief( eNew ); + } +} + +// overloaded font-method +inline void SwSubFont::SetSize( const Size& rSize ) +{ + m_aSize = rSize; + if ( GetPropr() == 100 ) + Font::SetFontSize( m_aSize ); + else + { + Font::SetFontSize( Size( + m_aSize.Width() * GetPropr() / 100, + m_aSize.Height() * GetPropr() / 100 ) ); + } + m_nFontCacheId = nullptr; +} + +inline void SwFont::SetSize( const Size& rSize, const SwFontScript nWhich ) +{ + if( m_aSub[nWhich].m_aSize != rSize ) + { + m_aSub[nWhich].SetSize( rSize ); + m_bFontChg = true; + m_bOrgChg = true; + } +} + +inline void SwFont::SetActual( SwFontScript nNew ) +{ + if ( m_nActual != nNew ) + { + m_bFontChg = true; + m_bOrgChg = true; + m_nActual = nNew; + } +} + +inline void SwSubFont::SetProportion( const sal_uInt8 nNewPropr ) +{ + m_nFontCacheId = nullptr; + Font::SetFontSize( Size( m_aSize.Width() * nNewPropr / 100, + m_aSize.Height() * nNewPropr / 100 ) ); + SvxFont::SetPropr( nNewPropr ); +} + +inline void SwFont::SetProportion( const sal_uInt8 nNewPropr ) +{ + if( nNewPropr != m_aSub[SwFontScript::Latin].GetPropr() ) + { + m_bFontChg = true; + m_bOrgChg = true; + + m_aSub[SwFontScript::Latin].SetProportion( nNewPropr ); + m_aSub[SwFontScript::CJK].SetProportion( nNewPropr ); + m_aSub[SwFontScript::CTL].SetProportion( nNewPropr ); + } +} + +inline void SwSubFont::SetEscapement( const short nNewEsc ) +{ + m_nFontCacheId = nullptr; + SvxFont::SetEscapement( nNewEsc ); +} + +inline void SwFont::SetEscapement( const short nNewEsc ) +{ + if( nNewEsc != m_aSub[SwFontScript::Latin].GetEscapement() ) + { + // these have to be set, otherwise nOrgHeight and nOrgAscent will not + // be calculated + m_bFontChg = true; + m_bOrgChg = true; + + m_aSub[SwFontScript::Latin].SetEscapement( nNewEsc ); + m_aSub[SwFontScript::CJK].SetEscapement( nNewEsc ); + m_aSub[SwFontScript::CTL].SetEscapement( nNewEsc ); + } +} + +inline void SwSubFont::SetLanguage( LanguageType eNewLang ) +{ + m_nFontCacheId = nullptr; + if( eNewLang == LANGUAGE_SYSTEM ) + eNewLang = GetAppLanguage(); + SvxFont::SetLanguage( eNewLang ); +} + +inline void SwFont::SetLanguage( const LanguageType eNewLang, const SwFontScript nWhich ) +{ + m_aSub[nWhich].SetLanguage( eNewLang ); + if( SwFontScript::CJK == nWhich ) + { + m_aSub[SwFontScript::Latin].SetCJKContextLanguage( eNewLang ); + m_aSub[SwFontScript::CJK].SetCJKContextLanguage( eNewLang ); + m_aSub[SwFontScript::CTL].SetCJKContextLanguage( eNewLang ); + } +} + +inline void SwFont::SetGreyWave( const bool bNew ) +{ + m_bGreyWave = bNew; +} + +inline void SwSubFont::SetVertical( const Degree10 nDir, const bool bVertFormat ) +{ + m_nFontCacheId = nullptr; + Font::SetVertical( bVertFormat ); + Font::SetOrientation( nDir ); +} + +inline void SwFont::SetTopBorderDist( const sal_uInt16 nTopDist ) +{ + m_nTopBorderDist = nTopDist; + m_bFontChg = true; + m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr; +} + +inline void SwFont::SetBottomBorderDist( const sal_uInt16 nBottomDist ) +{ + m_nBottomBorderDist = nBottomDist; + m_bFontChg = true; + m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr; +} + +inline void SwFont::SetRightBorderDist( const sal_uInt16 nRightDist ) +{ + m_nRightBorderDist = nRightDist; + m_bFontChg = true; + m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr; +} + +inline void SwFont::SetLeftBorderDist( const sal_uInt16 nLeftDist ) +{ + m_nLeftBorderDist = nLeftDist; + m_bFontChg = true; + m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr; +} + +inline sal_uInt16 SwFont::GetTopBorderSpace() const +{ + sal_uInt16 nRet = 0; + if( m_aTopBorder ) + { + nRet += m_aTopBorder->GetScaledWidth() + m_nTopBorderDist; + } + if( m_aShadowLocation == SvxShadowLocation::TopLeft || + m_aShadowLocation == SvxShadowLocation::TopRight ) + { + nRet += m_nShadowWidth; + } + return nRet; +} + +inline sal_uInt16 SwFont::GetBottomBorderSpace() const +{ + sal_uInt16 nRet = 0; + if( m_aBottomBorder ) + { + nRet += m_aBottomBorder->GetScaledWidth() + m_nBottomBorderDist; + } + if( m_aShadowLocation == SvxShadowLocation::BottomLeft || + m_aShadowLocation == SvxShadowLocation::BottomRight ) + { + nRet += m_nShadowWidth; + } + return nRet; +} + +inline sal_uInt16 SwFont::GetRightBorderSpace() const +{ + sal_uInt16 nRet = 0; + if( m_aRightBorder ) + { + nRet += m_aRightBorder->GetScaledWidth() + m_nRightBorderDist; + } + if( m_aShadowLocation == SvxShadowLocation::TopRight || + m_aShadowLocation == SvxShadowLocation::BottomRight ) + { + nRet += m_nShadowWidth; + } + return nRet; +} + +inline sal_uInt16 SwFont::GetLeftBorderSpace() const +{ + sal_uInt16 nRet = 0; + if( m_aLeftBorder ) + { + nRet += m_aLeftBorder->GetScaledWidth() + m_nLeftBorderDist; + } + if( m_aShadowLocation == SvxShadowLocation::TopLeft || + m_aShadowLocation == SvxShadowLocation::BottomLeft ) + { + nRet += m_nShadowWidth; + } + return nRet; +} + +inline bool SwFont::HasBorder() const +{ + return m_aTopBorder || m_aBottomBorder || m_aLeftBorder || m_aRightBorder; +} + +inline void SwFont::SetShadowColor( const Color& rColor ) +{ + m_aShadowColor = rColor; + m_bFontChg = true; + m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr; +} + +inline void SwFont::SetShadowWidth( const sal_uInt16 nWidth ) +{ + m_nShadowWidth = nWidth; + m_bFontChg = true; + m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr; +} + +inline void SwFont::SetShadowLocation( const SvxShadowLocation aLocation ) +{ + m_aShadowLocation = aLocation; + m_bFontChg = true; + m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr; +} + +inline void SwFont::SetHighlightColor( const Color& aNewColor ) +{ + m_aHighlightColor = aNewColor; + m_bFontChg = true; + m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr; +} + +// Used for the "continuous underline" feature. +class SwUnderlineFont +{ + Point m_aPos; + TextFrameIndex m_nEnd; + std::unique_ptr m_pFont; + +public: + // sets the font which should paint the common baseline, + // index where continuous underline ends, + // and the starting point of the common baseline + SwUnderlineFont(SwFont& rFnt, TextFrameIndex nEnd, const Point& rPoint); + ~SwUnderlineFont(); + + SwFont& GetFont() + { + OSL_ENSURE( m_pFont, "No underline font" ); + return *m_pFont; + } + const Point& GetPos() const { return m_aPos; } + TextFrameIndex GetEnd() const { return m_nEnd; } + // the x coordinate of the starting point has to be set for each portion + void SetPos( const Point& rPoint ) { m_aPos = rPoint; } +}; + +#ifdef DBG_UTIL + +class SvStatistics +{ +public: + sal_uInt16 nGetTextSize; + sal_uInt16 nDrawText; + sal_uInt16 nGetStretchTextSize; + sal_uInt16 nDrawStretchText; + sal_uInt16 nChangeFont; + + SvStatistics() + { nGetTextSize = nDrawText = nGetStretchTextSize = nDrawStretchText = nChangeFont = 0; } +}; + +// global variable, implemented in swfont.cxx +extern SvStatistics g_SvStat; + +#define SV_STAT(nWhich) ++(g_SvStat.nWhich); + + +#else +#define SV_STAT(nWhich) +#endif /* DBG_UTIL */ + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/swselectionlist.hxx b/sw/source/core/inc/swselectionlist.hxx new file mode 100644 index 0000000000..9eb3903211 --- /dev/null +++ b/sw/source/core/inc/swselectionlist.hxx @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_SWSELECTIONLIST_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_SWSELECTIONLIST_HXX + +#include + +class SwPaM; +class SwFrame; + +/** This class is used as parameter for creation of a block cursor selection + + This class will be created by a block cursor. Its responsibility is + to collect a group of selected text portions which are part of a common + context. + Definition of context: + A page header is a context. + A page footer is a context. + A footnote is a context. + Every fly frame builds a context together with its linked colleagues. + The content of the page bodies builds a context. +*/ + +class SwSelectionList +{ + std::list m_aList; // container for the selected text portions + const SwFrame* m_pContext; // the context of these text portions +public: + /** Ctor to create an empty list for a given context + + @param pInitCxt + The frame (normally a SwTextFrame) where the block cursor selection starts, + it will be used to get the allowed context for the text selections. + */ + explicit SwSelectionList(const SwFrame* pInitCxt); + + /** Start of the container for the selected text portions + */ + std::list::iterator getStart() { return m_aList.begin(); } + + /** End of the container for the selected text portions + */ + std::list::iterator getEnd() { return m_aList.end(); } + + /** Adds a text portion to the selection list + + @param pPam + represents a text portion to select + */ + void insertPaM(SwPaM* pPam) { m_aList.push_front(pPam); } + + /** Reports if the list does not contain any text portion + + @return true, if list is empty + */ + bool isEmpty() const { return m_aList.empty(); } + + /** Checks if the context of the list is equal to the context of the frame + + If the list does not have already a context, the context of the frame + will define the list's context. + If the list has already a context, it will be compared to the context of + the given frame. + + @param pCheck + The frame to check + + @return true, if the context of the frame is equal to the one of the list + */ + bool checkContext(const SwFrame* pCheck); +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_SWSELECTIONLIST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/swthreadjoiner.hxx b/sw/source/core/inc/swthreadjoiner.hxx new file mode 100644 index 0000000000..18e1e11930 --- /dev/null +++ b/sw/source/core/inc/swthreadjoiner.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_SWTHREADJOINER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_SWTHREADJOINER_HXX + +#include + +namespace com::sun::star::uno +{ +template class Reference; +} +namespace com::sun::star::util +{ +class XJobManager; +} + +/** Testing */ +namespace SwThreadJoiner +{ +css::uno::Reference& GetThreadJoiner(); + +void ReleaseThreadJoiner(); +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/swthreadmanager.hxx b/sw/source/core/inc/swthreadmanager.hxx new file mode 100644 index 0000000000..6c478aec85 --- /dev/null +++ b/sw/source/core/inc/swthreadmanager.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_SWTHREADMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_SWTHREADMANAGER_HXX + +#include + +#include + +namespace rtl { template class Reference; } + +class ObservableThread; +class ThreadManager; + +/** class to manage threads in Writer using a instance + + #i73788# + Conforms the singleton pattern +*/ +class SwThreadManager +{ + public: + + static SwThreadManager& GetThreadManager(); + + static bool ExistsThreadManager(); + + // private: don't call! + SwThreadManager(); + // private: don't call! + ~SwThreadManager(); + + oslInterlockedCount AddThread( const rtl::Reference< ObservableThread >& rThread ); + + void RemoveThread( const oslInterlockedCount nThreadID ); + + /** suspend the starting of threads + + Suspending the starting of further threads is sensible during the + destruction of a Writer document. + */ + void SuspendStartingOfThreads(); + + /** continues the starting of threads after it has been suspended + */ + void ResumeStartingOfThreads(); + + bool StartingOfThreadsSuspended(); + + private: + + SwThreadManager(SwThreadManager const&) = delete; + SwThreadManager& operator=(SwThreadManager const&) = delete; + + static bool sbThreadManagerInstantiated; + + std::unique_ptr mpThreadManagerImpl; + +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/tabfrm.hxx b/sw/source/core/inc/tabfrm.hxx new file mode 100644 index 0000000000..08020de734 --- /dev/null +++ b/sw/source/core/inc/tabfrm.hxx @@ -0,0 +1,265 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_TABFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_TABFRM_HXX + +#include + +#include "layfrm.hxx" +#include "flowfrm.hxx" + +class SwTable; +class SwBorderAttrs; +class SwAttrSetChg; + +enum class SwTabFrameInvFlags : sal_uInt8 +{ + NONE = 0x00, + InvalidatePrt = 0x02, + InvalidateIndNextPrt = 0x04, + InvalidatePrevPrt = 0x08, + SetIndNextCompletePaint = 0x10, + InvalidateBrowseWidth = 0x20, + InvalidatePos = 0x40, + InvalidateNextPos = 0x80, +}; + +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +} + +/// SwTabFrame is one table in the document layout, containing rows (which contain cells). +class SW_DLLPUBLIC SwTabFrame final: public SwLayoutFrame, public SwFlowFrame +{ + friend void CalcContent( SwLayoutFrame *pLay, bool bNoColl ); + + // does the special treatment for Get_[Next|Prev]Leaf() + using SwFrame::GetLeaf; + + SwTable * m_pTable; + + bool m_bComplete :1; /// Set entries for Repaint without needing to + /// set the base class' CompletePaint + /// With that we would want to avoid unnecessary + /// table repaints + bool m_bCalcLowers :1; /// For stability of the content in MakeAll + bool m_bLowersFormatted :1; /// Communication between MakeAll and Layact + bool m_bLockBackMove :1; /// The Master took care of the BackMove test + bool m_bWantBackMove :1; /// Table wants to move back but was locked + bool m_bResizeHTMLTable :1; /// Call the Resize of the HTMLTableLayout in the MakeAll + /// This is an optimization, so that we don't have to call + /// it in ContentFrame::Grow; there it might be called for + /// _every_ Cell + + bool m_bONECalcLowers :1; /// Primarily for the StarONE SS + /// The Contents are formatted via Calc() on MakeAll in any + /// case. There are no further invalidations and that path can + /// hardly give any guarantees + + bool m_bHasFollowFlowLine :1; /// Means that the first line in the follow + /// is indented to contain content from a broken + /// cell + bool m_bIsRebuildLastLine :1; /// Means that currently the last line of the + /// TabFrame is rebuilt. In this case we do not + // want any notification to the master table + + bool m_bRestrictTableGrowth :1; // Usually, the table may grow infinitely, + // as the table can be split in SwTabFrame::MakeAll + // In MakeAll, this flag is set to indicate that + // the table may only grow inside its upper. This + // is necessary, in order to let the text flow into + // the FollowFlowLine + + bool m_bRemoveFollowFlowLinePending :1; + + // #i26945# + bool m_bConsiderObjsForMinCellHeight :1; // Usually, the floating screen objects + // are considered during the calculation + // for the minimal cell height. + // For the splitting table rows algorithm + // we need not to consider floating + // screen object for the preparation + // of the re-calculation of the + // last table row. + // #i26945# + bool m_bObjsDoesFit :1; // For splitting table rows algorithm, this boolean + // indicates, if the floating screen objects fits + + bool m_bInRecalcLowerRow : 1; + + /** + * Split() splits the Frame at the specified position: a Follow is + * created and constructed and inserted directly after this. + * Join() gets the Follow's content and destroys it. + */ + bool Split(const SwTwips nCutPos, bool bTryToSplit, bool bTableRowKeep, bool & rIsFootnoteGrowth); + void Join(); + + void UpdateAttr_( + const SfxPoolItem*, + const SfxPoolItem*, SwTabFrameInvFlags &, + SwAttrSetChg *pa = nullptr, + SwAttrSetChg *pb = nullptr ); + void Invalidate(SwTabFrameInvFlags); + void HandleTableHeadlineChange(); + + virtual bool ShouldBwdMoved( SwLayoutFrame *pNewUpper, bool &rReformat ) override; + + virtual void DestroyImpl() override; + virtual ~SwTabFrame() override; + + virtual void MakeAll(vcl::RenderContext* pRenderContext) override; + virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override; + virtual void SwClientNotify(const SwModify&, const SfxHint&) override; + // only changes the Framesize, not the PrtArea size + virtual SwTwips GrowFrame ( SwTwips, bool bTst = false, bool bInfo = false ) override; + virtual const SwTabFrame* DynCastTabFrame() const override { return this; } + +public: + SwTabFrame( SwTable &, SwFrame* ); // calling RegistFlys always after creation _and_pasting! + SwTabFrame( SwTabFrame & ); // _only_ for the creation of follows + + void JoinAndDelFollows(); // for DelFrames of the TableNodes! + + // calls thr RegistFlys of the rows + void RegistFlys(); + + inline const SwTabFrame *GetFollow() const; + inline SwTabFrame *GetFollow(); + SwTabFrame* FindMaster( bool bFirstMaster = false ) const; + + virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&, + SwPrintData const*const pPrintData = nullptr ) const override; + virtual void CheckDirection( bool bVert ) override; + + virtual void Cut() override; + virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override; + + virtual bool Prepare( const PrepareHint ePrep = PrepareHint::Clear, + const void *pVoid = nullptr, bool bNotify = true ) override; + + SwFrame *FindLastContentOrTable(); + inline const SwFrame *FindLastContentOrTable() const; + SwContentFrame *FindLastContent(); + inline const SwContentFrame *FindLastContent() const; + + const SwTable *GetTable() const { return m_pTable; } + SwTable *GetTable() { return m_pTable; } + + bool IsComplete() const { return m_bComplete; } + void SetComplete() { m_bComplete = true; } + void ResetComplete() { m_bComplete = false; } + + bool IsLowersFormatted() const { return m_bLowersFormatted; } + void SetLowersFormatted(bool b) { m_bLowersFormatted = b; } + + void SetCalcLowers() { m_bCalcLowers = true; } // use rarely + void SetResizeHTMLTable() { m_bResizeHTMLTable = true; } // same + void SetONECalcLowers() { m_bONECalcLowers = true; } + + // Start: New stuff for breaking table rows + + bool HasFollowFlowLine() const { return m_bHasFollowFlowLine; } + void SetFollowFlowLine(bool bNew) { m_bHasFollowFlowLine = bNew; } + + bool IsRebuildLastLine() const { return m_bIsRebuildLastLine; } + void SetRebuildLastLine(bool bNew) { m_bIsRebuildLastLine = bNew; } + + bool IsRestrictTableGrowth() const { return m_bRestrictTableGrowth; } + void SetRestrictTableGrowth( bool bNew ) { m_bRestrictTableGrowth = bNew; } + + bool IsRemoveFollowFlowLinePending() const { return m_bRemoveFollowFlowLinePending; } + void SetRemoveFollowFlowLinePending(bool bNew) { m_bRemoveFollowFlowLinePending = bNew; } + + bool IsInRecalcLowerRow() const + { + return m_bInRecalcLowerRow; + } + void SetInRecalcLowerRow( bool bNew ) + { + m_bInRecalcLowerRow = bNew; + } + + // #i26945# + bool IsConsiderObjsForMinCellHeight() const + { + return m_bConsiderObjsForMinCellHeight; + } + void SetConsiderObjsForMinCellHeight(bool const bConsiderObjsForMinCellHeight) + { + m_bConsiderObjsForMinCellHeight = bConsiderObjsForMinCellHeight; + } + + // #i26945# + bool DoesObjsFit() const + { + return m_bObjsDoesFit; + } + void SetDoesObjsFit(bool const bObjsDoesFit) + { + m_bObjsDoesFit = bObjsDoesFit; + } + + bool RemoveFollowFlowLine(); + + // End: New stuff for breaking table rows + + bool CalcFlyOffsets( + SwTwips& rUpper, + tools::Long& rLeftOffset, + tools::Long& rRightOffset, + SwTwips * pSpaceBelowBottom) const; + + SwTwips CalcHeightOfFirstContentLine() const; + + bool IsInHeadline( const SwFrame& rFrame ) const; + SwRowFrame* GetFirstNonHeadlineRow() const; + + bool IsLayoutSplitAllowed() const; + + // #i29550# + bool IsCollapsingBorders() const; + + sal_uInt16 GetBottomLineSize() const; + + void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; +}; + +inline const SwFrame *SwTabFrame::FindLastContentOrTable() const +{ + return const_cast(this)->FindLastContentOrTable(); +} + +inline const SwContentFrame *SwTabFrame::FindLastContent() const +{ + return const_cast(this)->FindLastContent(); +} + +inline const SwTabFrame *SwTabFrame::GetFollow() const +{ + return static_cast(SwFlowFrame::GetFollow()); +} +inline SwTabFrame *SwTabFrame::GetFollow() +{ + return static_cast(SwFlowFrame::GetFollow()); +} + +#endif // INCLUDED_SW_SOURCE_CORE_INC_TABFRM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/tblrwcl.hxx b/sw/source/core/inc/tblrwcl.hxx new file mode 100644 index 0000000000..9cd6fa3eb2 --- /dev/null +++ b/sw/source/core/inc/tblrwcl.hxx @@ -0,0 +1,197 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_TBLRWCL_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_TBLRWCL_HXX + +#include +#include + +#include +#include + +namespace editeng { class SvxBorderLine; } + +class SwDoc; +class SwTableNode; +class SwTableBoxFormat; +class SwHistory; +class SwContentNode; +class SfxPoolItem; +class SwShareBoxFormats; +class SwFormatFrameSize; + +void sw_LineSetHeadCondColl( const SwTableLine* pLine ); + +#ifdef DBG_UTIL +void CheckBoxWidth( const SwTableLine& rLine, SwTwips nSize ); +#endif + +void InsTableBox( SwDoc& rDoc, SwTableNode* pTableNd, + SwTableLine* pLine, SwTableBoxFormat* pBoxFrameFormat, + SwTableBox* pBox, sal_uInt16 nInsPos, sal_uInt16 nCnt = 1 ); + +void DeleteBox_( SwTable& rTable, SwTableBox* pBox, SwUndo* pUndo, + bool bCalcNewSize, const bool bCorrBorder, + SwShareBoxFormats* pShareFormats = nullptr ); + +/** + * Class for SplitTable + * Collects the uppermost or lowermost Lines of a Box from a Line in an array. + * We also store their positions. + * + * @see implementation in ndtbl.cxx + */ +class SwCollectTableLineBoxes +{ + std::vector m_aPositionArr; + std::vector m_Boxes; + SwHistory* m_pHistory; + SplitTable_HeadlineOption m_nMode; + sal_uInt16 m_nWidth; + bool m_bGetFromTop : 1; + bool m_bGetValues : 1; + +public: + SwCollectTableLineBoxes( bool bTop, SplitTable_HeadlineOption nMd = SplitTable_HeadlineOption::NONE, SwHistory* pHist=nullptr ) + : + m_pHistory( pHist ), m_nMode( nMd ), m_nWidth( 0 ), + m_bGetFromTop( bTop ), m_bGetValues( true ) + + {} + + void AddBox( const SwTableBox& rBox ); + const SwTableBox* GetBoxOfPos( const SwTableBox& rBox ); + void AddToUndoHistory( const SwContentNode& rNd ); + + size_t Count() const { return m_Boxes.size(); } + const SwTableBox& GetBox( std::size_t nPos, sal_uInt16* pWidth = nullptr ) const + { + // We need the EndPos of the column here! + if( pWidth ) + *pWidth = (nPos+1 == m_aPositionArr.size()) ? m_nWidth + : m_aPositionArr[ nPos+1 ]; + return *m_Boxes[ nPos ]; + } + + bool IsGetFromTop() const { return m_bGetFromTop; } + bool IsGetValues() const { return m_bGetValues; } + + SplitTable_HeadlineOption GetMode() const { return m_nMode; } + void SetValues( bool bFlag ) { m_bGetValues = false; m_nWidth = 0; + m_bGetFromTop = bFlag; } + bool Resize( sal_uInt16 nOffset, sal_uInt16 nWidth ); +}; + +void sw_Box_CollectBox( const SwTableBox* pBox, SwCollectTableLineBoxes* pSplPara ); +bool sw_Line_CollectBox( const SwTableLine*& rpLine, void* pPara ); + +void sw_BoxSetSplitBoxFormats( SwTableBox* pBox, SwCollectTableLineBoxes* pSplPara ); + +/** + * This structure is needed by Undo to restore row span attributes + * when a table has been split into two tables + */ +struct SwSaveRowSpan +{ + sal_uInt16 mnSplitLine; // the line number where the table has been split + std::vector< tools::Long > mnRowSpans; // the row span attributes in this line + SwSaveRowSpan( SwTableBoxes& rBoxes, sal_uInt16 nSplitLn ); +}; + +struct SwGCLineBorder +{ + const SwTableLines* pLines; + SwShareBoxFormats* pShareFormats; + sal_uInt16 nLinePos; + + SwGCLineBorder( const SwTable& rTable ) + : pLines( &rTable.GetTabLines() ), pShareFormats(nullptr), nLinePos( 0 ) {} + + SwGCLineBorder( const SwTableBox& rBox ) + : pLines( &rBox.GetTabLines() ), pShareFormats(nullptr), nLinePos( 0 ) {} + bool IsLastLine() const { return nLinePos + 1 >= o3tl::narrowing(pLines->size()); } +}; + +class SwGCBorder_BoxBrd +{ + const editeng::SvxBorderLine* m_pBorderLine; + bool m_bAnyBorderFind; +public: + SwGCBorder_BoxBrd() : m_pBorderLine( nullptr ), m_bAnyBorderFind( false ) {} + + void SetBorder( const editeng::SvxBorderLine& rBorderLine ) + { m_pBorderLine = &rBorderLine; m_bAnyBorderFind = false; } + + /** + * Check whether the left Border is the same as the set one + * @returns false if no Border was set + */ + bool CheckLeftBorderOfFormat( const SwFrameFormat& rFormat ); + + bool IsAnyBorderFound() const { return m_bAnyBorderFind; } +}; + +void sw_GC_Line_Border( const SwTableLine* pLine, SwGCLineBorder* pGCPara ); + +class SwShareBoxFormat +{ + const SwFrameFormat* m_pOldFormat; + std::vector m_aNewFormats; + +public: + SwShareBoxFormat( const SwFrameFormat& rFormat ) + : m_pOldFormat( &rFormat ) + {} + + const SwFrameFormat& GetOldFormat() const { return *m_pOldFormat; } + + SwFrameFormat* GetFormat( tools::Long nWidth ) const; + SwFrameFormat* GetFormat( const SfxPoolItem& rItem ) const; + void AddFormat( SwFrameFormat& rFormat ); + /// @returns true, if we can delete + bool RemoveFormat( const SwFrameFormat& rFormat ); +}; + +class SwShareBoxFormats +{ + std::vector m_ShareArr; + + bool Seek_Entry( const SwFrameFormat& rFormat, sal_uInt16* pPos ) const; + + void ChangeFrameFormat( SwTableBox* pBox, SwTableLine* pLn, SwFrameFormat& rFormat ); + +public: + SwShareBoxFormats() {} + ~SwShareBoxFormats(); + + SwFrameFormat* GetFormat( const SwFrameFormat& rFormat, tools::Long nWidth ) const; + SwFrameFormat* GetFormat( const SwFrameFormat& rFormat, const SfxPoolItem& ) const; + + void AddFormat( const SwFrameFormat& rOld, SwFrameFormat& rNew ); + + void SetSize( SwTableBox& rBox, const SwFormatFrameSize& rSz ); + void SetAttr( SwTableBox& rBox, const SfxPoolItem& rItem ); + void SetAttr( SwTableLine& rLine, const SfxPoolItem& rItem ); + + void RemoveFormat( const SwFrameFormat& rFormat ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/textapi.hxx b/sw/source/core/inc/textapi.hxx new file mode 100644 index 0000000000..ec0395cbbd --- /dev/null +++ b/sw/source/core/inc/textapi.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_TEXTAPI_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_TEXTAPI_HXX + +#include +#include +#include + +class SwDoc; + +struct SwTextAPIEditSource_Impl; +class SwTextAPIEditSource final : public SvxEditSource +{ + SwTextAPIEditSource_Impl* m_pImpl; + + void EnsureOutliner(); + virtual std::unique_ptr Clone() const override; + virtual SvxTextForwarder* GetTextForwarder() override; + virtual void UpdateData() override; + explicit SwTextAPIEditSource( const SwTextAPIEditSource& rSource ); + +public: + SwTextAPIEditSource(SwDoc* pDoc); + virtual ~SwTextAPIEditSource() override; + + void Dispose(); + void SetText( OutlinerParaObject const & rText ); + void SetString( const OUString& rText ); + std::optional CreateText(); + OUString GetText() const; +}; + +class SwTextAPIObject final : public SvxUnoText +{ + std::unique_ptr m_pSource; +public: + SwTextAPIObject( std::unique_ptr p); + virtual ~SwTextAPIObject() noexcept override; + void DisposeEditSource() { m_pSource->Dispose(); } + std::optional CreateText() { return m_pSource->CreateText(); } + void SetString( const OUString& rText ) { m_pSource->SetString( rText ); } + void SetText( OutlinerParaObject const & rText ) { m_pSource->SetText( rText ); } + OUString GetText() const { return m_pSource->GetText(); } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/threadlistener.hxx b/sw/source/core/inc/threadlistener.hxx new file mode 100644 index 0000000000..071de465cc --- /dev/null +++ b/sw/source/core/inc/threadlistener.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_THREADLISTENER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_THREADLISTENER_HXX + +#include "ifinishedthreadlistener.hxx" + +class ThreadManager; +class ObservableThread; + +/** helper class to observe threads + + OD 2007-03-30 #i73788# + An instance of this class can be used to observe a thread in order to + be notified, if the thread has finished its work. The notification is + directly forward to its owner - an instance of ThreadManager + Note: + - A thread can only have one or none listener. + - The notification is performed via the ThreadID +*/ +class ThreadListener final : public IFinishedThreadListener +{ + public: + + ThreadListener( ThreadManager& rThreadListenerOwner ); + virtual ~ThreadListener() override; + + void ListenToThread( const oslInterlockedCount nThreadID, + ObservableThread& rThread ); + + virtual void NotifyAboutFinishedThread( const oslInterlockedCount nThreadID ) override; + + private: + + ThreadManager& mrThreadListenerOwner; +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/tocntntanchoredobjectposition.hxx b/sw/source/core/inc/tocntntanchoredobjectposition.hxx new file mode 100644 index 0000000000..54fdecc589 --- /dev/null +++ b/sw/source/core/inc/tocntntanchoredobjectposition.hxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_TOCNTNTANCHOREDOBJECTPOSITION_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_TOCNTNTANCHOREDOBJECTPOSITION_HXX +#include "anchoredobjectposition.hxx" + +class SwFrame; +class SwTextFrame; +class SwLayoutFrame; +class SwRect; + +namespace objectpositioning +{ + class SwToContentAnchoredObjectPosition final : public SwAnchoredObjectPosition + { + private: + // calculated data for object position + const SwLayoutFrame* mpVertPosOrientFrame; + // #i26791# + // determine offset to frame anchor position according to the + // positioning alignments + Point maOffsetToFrameAnchorPos; + + // data for calculation of position + bool mbAnchorToChar; + const SwFrame* mpToCharOrientFrame; + const SwRect* mpToCharRect; + SwTwips mnToCharTopOfLine; + + virtual bool IsAnchoredToChar() const override; + virtual const SwFrame* ToCharOrientFrame() const override; + virtual const SwRect* ToCharRect() const override; + // #i22341# + virtual SwTwips ToCharTopOfLine() const override; + + // method to cast to + // the needed type + SwTextFrame& GetAnchorTextFrame() const; + + /** determine frame for horizontal position + + if the given proposed frame is a content frame, the proposed + frame is returned. + otherwise (given proposed frame is a layout frame), + the lower content frames of the proposed frame are checked + for the first, that the anchor or a follow of the anchor. + If none is found, the proposed frame is returned. + + @param _pProposedFrame + input parameter - proposed frame for horizontal position + + @return constant reference to object, at which the + horizontal position is determined. + */ + const SwFrame& GetHoriVirtualAnchor( const SwLayoutFrame& _pProposedFrame ) const; + + public: + SwToContentAnchoredObjectPosition( SdrObject& _rDrawObj ); + virtual ~SwToContentAnchoredObjectPosition() override; + + /** calculate position of object + */ + virtual void CalcPosition() override; + + /** frame, at which the vertical position is oriented at + */ + const SwLayoutFrame& GetVertPosOrientFrame() const { return *mpVertPosOrientFrame;} + + /// In case overlap is not allowed, re-position the current object. + void CalcOverlap(const SwTextFrame* pAnchorFrameForVertPos, Point& rRelPos, + const SwTwips nTopOfAnch); + }; +} // namespace objectpositioning + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/tolayoutanchoredobjectposition.hxx b/sw/source/core/inc/tolayoutanchoredobjectposition.hxx new file mode 100644 index 0000000000..256e7378d8 --- /dev/null +++ b/sw/source/core/inc/tolayoutanchoredobjectposition.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_TOLAYOUTANCHOREDOBJECTPOSITION_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_TOLAYOUTANCHOREDOBJECTPOSITION_HXX +#include "anchoredobjectposition.hxx" + +namespace objectpositioning +{ + class SwToLayoutAnchoredObjectPosition final : public SwAnchoredObjectPosition + { + private: + // calculated data for object position type TO_LAYOUT + Point maRelPos; + + // #i26791# + // determine offset to frame anchor position according to the + // positioning alignments + Point maOffsetToFrameAnchorPos; + + public: + SwToLayoutAnchoredObjectPosition( SdrObject& _rDrawObj ); + virtual ~SwToLayoutAnchoredObjectPosition() override; + + /** calculate position for object + */ + virtual void CalcPosition() override; + + /** calculated relative position for object + */ + const Point& GetRelPos() const { return maRelPos;} + }; +} // namespace objectpositioning + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/txmsrt.hxx b/sw/source/core/inc/txmsrt.hxx new file mode 100644 index 0000000000..324f88a90f --- /dev/null +++ b/sw/source/core/inc/txmsrt.hxx @@ -0,0 +1,310 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_TXMSRT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_TXMSRT_HXX + +#include +#include +#include +#include + +#include +#include +#include + +class SwContentNode; +class SwTextNode; +class SwTextTOXMark; +class SwContentIndex; +class SwFormatField; +class SwRootFrame; +class IndexEntrySupplierWrapper; + +enum TOXSortType +{ + TOX_SORT_INDEX, + TOX_SORT_CUSTOM, + TOX_SORT_CONTENT, + TOX_SORT_PARA, + TOX_SORT_TABLE, + TOX_SORT_AUTHORITY +}; + +struct SwTOXSource +{ + const SwContentNode* pNd; + sal_Int32 nPos; + bool bMainEntry; + + SwTOXSource( const SwContentNode* pNode, sal_Int32 n, bool bMain ) + : pNd(pNode), nPos(n), bMainEntry(bMain) + { + } +}; + +struct TextAndReading +{ + OUString sText; + OUString sReading; + + TextAndReading() {} + + TextAndReading(OUString aText, OUString aReading) + : sText(std::move(aText)) + , sReading(std::move(aReading)) + {} +}; + +class SwTOXInternational +{ + std::unique_ptr m_pIndexWrapper; + std::optional m_oCharClass; + LanguageType m_eLang; + OUString m_sSortAlgorithm; + SwTOIOptions m_nOptions; + + void Init(); + +public: + SwTOXInternational( LanguageType nLang, SwTOIOptions nOptions, + OUString aSortAlgorithm ); + SwTOXInternational( const SwTOXInternational& ); + ~SwTOXInternational(); + + sal_Int32 Compare( const TextAndReading& rTaR1, + const css::lang::Locale& rLocale1, + const TextAndReading& rTaR2, + const css::lang::Locale& rLocale2 ) const; + + bool IsEqual( const TextAndReading& rTaR1, + const css::lang::Locale& rLocale1, + const TextAndReading& rTaR2, + const css::lang::Locale& rLocale2 ) const + { + return 0 == Compare( rTaR1, rLocale1, rTaR2, rLocale2 ); + } + + bool IsLess( const TextAndReading& rTaR1, + const css::lang::Locale& rLocale1, + const TextAndReading& rTaR2, + const css::lang::Locale& rLocale2 ) const + { + return -1 == Compare( rTaR1, rLocale1, rTaR2, rLocale2 ); + } + + OUString GetIndexKey( const TextAndReading& rTaR, + const css::lang::Locale& rLcl ) const; + + OUString GetFollowingText( bool bMorePages ) const; + + OUString ToUpper( const OUString& rStr, sal_Int32 nPos ) const; + bool IsNumeric( const OUString& rStr ) const; +}; + +/** + * Class for sorting directories + */ +struct SwTOXSortTabBase +{ + bool operator==(const SwTOXSortTabBase&) const = delete; + bool operator<(const SwTOXSortTabBase&) const = delete; + + std::vector aTOXSources; + css::lang::Locale aLocale; + const SwTextNode* pTOXNd; + const SwTextTOXMark* pTextMark; + const SwTOXInternational* pTOXIntl; + SwNodeOffset nPos; + sal_Int32 nCntPos; + sal_uInt16 nType; + static SwTOIOptions nOpt; + + SwTOXSortTabBase( TOXSortType nType, + const SwContentNode* pTOXSrc, + const SwTextTOXMark* pTextMark, + const SwTOXInternational* pIntl, + const css::lang::Locale* pLocale = nullptr ); + virtual ~SwTOXSortTabBase() {} + + sal_uInt16 GetType() const { return nType; } + static SwTOIOptions GetOptions() { return nOpt; } + + virtual void FillText(SwTextNode& rNd, const SwContentIndex& rInsPos, + sal_uInt16 nAuthField, SwRootFrame const* pLayout) const; + virtual sal_uInt16 GetLevel() const = 0; + virtual bool equivalent( const SwTOXSortTabBase& ); + virtual bool sort_lt( const SwTOXSortTabBase& ); + + virtual std::pair GetURL(SwRootFrame const*const pLayout) const; + + virtual bool IsFullPara() const; + + // must be called + inline void InitText(SwRootFrame const*const pLayout); + inline TextAndReading const & GetText() const; + inline const css::lang::Locale& GetLocale() const; + +private: + bool m_bValidText; + TextAndReading m_aSort; + + virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const = 0; +}; + +inline void SwTOXSortTabBase::InitText(SwRootFrame const*const pLayout) +{ + // 'this' is 'SwTOXSortTabBase const*', so the virtual + // mechanism will call the derived class' GetText_Impl + assert(!m_bValidText); + m_aSort = GetText_Impl(pLayout); + m_bValidText = true; +} + +inline TextAndReading const & SwTOXSortTabBase::GetText() const +{ + assert(m_bValidText); + return m_aSort; +} + +inline const css::lang::Locale& SwTOXSortTabBase::GetLocale() const +{ + return aLocale; +} + +/** + * For sorting by text + */ +struct SwTOXIndex final : public SwTOXSortTabBase +{ + SwTOXIndex( const SwTextNode&, const SwTextTOXMark*, SwTOIOptions nOptions, sal_uInt8 nKeyLevel, + const SwTOXInternational& rIntl, + const css::lang::Locale& rLocale ); + + virtual void FillText(SwTextNode& rNd, const SwContentIndex& rInsPos, + sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override; + virtual sal_uInt16 GetLevel() const override; + virtual bool equivalent( const SwTOXSortTabBase& ) override; + virtual bool sort_lt( const SwTOXSortTabBase& ) override; + +private: + virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override; + + sal_uInt8 nKeyLevel; +}; + +struct SwTOXCustom final : public SwTOXSortTabBase +{ + SwTOXCustom( TextAndReading aKey, sal_uInt16 nLevel, + const SwTOXInternational& rIntl, + const css::lang::Locale& rLocale ); + + virtual sal_uInt16 GetLevel() const override; + virtual bool equivalent( const SwTOXSortTabBase& ) override; + virtual bool sort_lt( const SwTOXSortTabBase& ) override; + +private: + virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override; + + TextAndReading m_aKey; + sal_uInt16 nLev; +}; + +/** + * For sorting by position + */ +struct SwTOXContent final : public SwTOXSortTabBase +{ + SwTOXContent( const SwTextNode&, const SwTextTOXMark*, + const SwTOXInternational& rIntl ); + + virtual void FillText(SwTextNode& rNd, const SwContentIndex& rInsPos, + sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override; + virtual sal_uInt16 GetLevel() const override; +private: + virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override; + +}; + +struct SwTOXPara final : public SwTOXSortTabBase +{ + SwTOXPara(SwContentNode&, SwTOXElement, + sal_uInt16 nLevel = FORM_ALPHA_DELIMITER, + OUString sSeqName = OUString()); + + void SetStartIndex(sal_Int32 nSet) { nStartIndex = nSet; } + void SetEndIndex(sal_Int32 nSet) { nEndIndex = nSet; } + + virtual void FillText(SwTextNode& rNd, const SwContentIndex& rInsPos, + sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override; + virtual sal_uInt16 GetLevel() const override; + + virtual std::pair GetURL(SwRootFrame const*const pLayout) const override; + virtual bool IsFullPara() const override; +private: + virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override; + + SwTOXElement eType; + sal_uInt16 m_nLevel; + sal_Int32 nStartIndex; + sal_Int32 nEndIndex; + OUString m_sSequenceName; +}; + +struct SwTOXTable final : public SwTOXSortTabBase +{ + SwTOXTable( const SwContentNode& rNd ); + + void SetLevel(sal_uInt16 nSet){nLevel = nSet;} + + virtual sal_uInt16 GetLevel() const override; + + virtual std::pair GetURL(SwRootFrame const*const pLayout) const override; + +private: + virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override; + + sal_uInt16 nLevel; +}; + +/// Represents one row in the bibliography table. +struct SwTOXAuthority final : public SwTOXSortTabBase +{ +private: + SwFormatField& m_rField; + virtual void FillText(SwTextNode& rNd, const SwContentIndex& rInsPos, + sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override; + virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override; + +public: + SwTOXAuthority( const SwContentNode& rNd, SwFormatField& rField, const SwTOXInternational& rIntl ); + + SwFormatField& GetFieldFormat() {return m_rField;} + + virtual bool equivalent( const SwTOXSortTabBase& ) override; + virtual bool sort_lt( const SwTOXSortTabBase& ) override; + virtual sal_uInt16 GetLevel() const override; + OUString GetText(sal_uInt16 nAuthField, const SwRootFrame* pLayout) const; + + /// Gets the URL of the underlying SwAuthEntry, ignoring its page number. + static OUString GetSourceURL(const OUString& rText); +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_TXMSRT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/txtfly.hxx b/sw/source/core/inc/txtfly.hxx new file mode 100644 index 0000000000..9047e127e7 --- /dev/null +++ b/sw/source/core/inc/txtfly.hxx @@ -0,0 +1,389 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +class OutputDevice; +class SwPageFrame; +class SdrObject; +class SwFormat; +class SwAnchoredObject; +class SwTextFrame; +class SwDrawTextInfo; +class SwContourCache; +class SwBreakPortion; +class SwTextFormatInfo; + +typedef std::vector< SwAnchoredObject* > SwAnchoredObjList; + +/** Contour-cache global variable, initialized/destroyed in txtinit.cxx + and needed in txtfly.cxx by text wrapping. + */ +extern SwContourCache *pContourCache; + +#define POLY_CNT 20 +#define POLY_MIN 5 +#define POLY_MAX 4000 + +void ClrContourCache( const SdrObject *pObj ); + +class SwContourCache +{ + friend void ClrContourCache(); + struct CacheItem + { + const SdrObject *mpSdrObj; + std::unique_ptr mxTextRanger; + }; + std::vector mvItems; + tools::Long mnPointCount; + SwRect ContourRect( const SwFormat* pFormat, const SdrObject* pObj, + const SwTextFrame* pFrame, const SwRect &rLine, const tools::Long nXPos, + const bool bRight ); + +public: + SwContourCache(); + ~SwContourCache(); + const SdrObject* GetObject( sal_uInt16 nPos ) const{ return mvItems[ nPos ].mpSdrObj; } + sal_uInt16 GetCount() const { return mvItems.size(); } + void ClrObject( sal_uInt16 nPos ); + + /** + Computes the rectangle that will cover the object in the given line. + + For _non_ contour-flow objects, this is simply the overlap area of + BoundRect (including spacing), and the line, for contour-flow, + the tools::PolyPolygon of the object gets traversed + */ + static SwRect CalcBoundRect( const SwAnchoredObject* pAnchoredObj, + const SwRect &rLine, + const SwTextFrame* pFrame, + const tools::Long nXPos, + const bool bRight ); +}; + +// MS Word wraps on sides with even less space (value guessed). +#define TEXT_MIN_SMALL 300 + +/** + The purpose of this class is to be the universal interface between + formatting/text output and the possibly overlapping free-flying frames. + During formatting the formatter gets the information from SwTextFly, whether + a certain area is present by the attributes of an overlapping frame. + Such areas are represented by dummy portions. + + The whole text output and touch-up is, again, forwarded to a SwTextFly. + This one decides, whether parts of the text need to be clipped and splits + the areas for e.g. a DrawRect. + + Please note that all free-flying frames are located in a PtrArray, sorted + by TopLeft. + + Internally we always use document-global values. The IN and OUT parameters + are, however, adjusted to the needs of the LineIter most of the time. That + is: they are converted to frame- and window-local coordinates. + If multiple frames with wrap attributes are located on the same line, we get + the following settings for the text flow: + + L/R P L R N + P -P-P- -P-L -P R- -P N + L -L P- -L L -L R- -L N + R R-P- R-L R R- R N + N N P- N L N R- N N + + (P=parallel, L=left, R=right, N=no wrap) + + We can describe the behaviour as follows: + Every frame can push away text, with the restriction that it only has influence + until the next frame. + */ +class SwTextFly +{ + const SwPageFrame * m_pPage; + const SwAnchoredObject * mpCurrAnchoredObj; + const SwTextFrame * m_pCurrFrame; + const SwTextFrame * m_pMaster; + std::unique_ptr mpAnchoredObjList; + + tools::Long m_nMinBottom; + tools::Long m_nNextTop; /// Stores the upper edge of the "next" frame + SwNodeOffset m_nCurrFrameNodeIndex; + + bool m_bOn : 1; + bool m_bTopRule: 1; + bool mbIgnoreCurrentFrame: 1; + bool mbIgnoreContour: 1; + + /** boolean, indicating if objects in page header|footer are considered for + text frames not in page header|footer. + */ + bool mbIgnoreObjsInHeaderFooter: 1; + + /** + This method will be called during the LineIter formatting + \li to compute the position of the next \c FlyPortion + \li remember new overlappings after a change of the line height. + + \param[in] rPortion + Scope: document global. + */ + SwRect GetFrame_( const SwRect &rPortion ) const; + + SwAnchoredObjList& InitAnchoredObjList(); + +public: + SwAnchoredObjList& GetAnchoredObjList() const; +private: + + /** + Look for the first object which overlaps with the rectangle. + Iterates over the anchored object list mpAnchoredObjList. + */ + bool ForEach( const SwRect &rRect, SwRect* pRect, bool bAvoid ) const; + + /** + \li There is less than 2cm space on both sides for the text: + no surround (css::text::WrapTextMode_NONE) + + \li There is more than 2cm space on only one side: + surround on that side (css::text::WrapTextMode_LEFT or css::text::WrapTextMode_RIGHT) + + \li There is more than 2cm space on both sides, the object is + larger than 1.5cm: surround on the wider side + (css::text::WrapTextMode_LEFT or css::text::WrapTextMode_RIGHT) + + \li There is more than 2cm space on both sides and the object + width is less than 1.5cm: both sides surround (css::text::WrapTextMode_PARALLEL) + */ + css::text::WrapTextMode GetSurroundForTextWrap( const SwAnchoredObject* pAnchoredObj ) const; + + /** + The right margin is the right margin or it is determined by the + next object standing on the line. + */ + void CalcRightMargin( SwRect &rFly, + SwAnchoredObjList::size_type nPos, + const SwRect &rLine ) const; + + /** + The left margin is the left margin of the current PrintArea or + it is determined by the last FlyFrame, which stands on the line. + */ + void CalcLeftMargin( SwRect &rFly, + SwAnchoredObjList::size_type nPos, + const SwRect &rLine ) const; + + /** + \return the position in sorted array + */ + SwAnchoredObjList::size_type GetPos( const SwAnchoredObject* pAnchoredObj ) const; + + bool GetTop( const SwAnchoredObject* _pAnchoredObj, + const bool bInFootnote, + const bool bInFooterOrHeader ); + + SwTwips CalcMinBottom() const; + + const SwTextFrame* GetMaster_(); + +public: + + SwTextFly(); + SwTextFly( const SwTextFrame *pFrame ); + SwTextFly( const SwTextFly& rTextFly ); + ~SwTextFly(); + + void CtorInitTextFly( const SwTextFrame *pFrame ); + + void SetTopRule(); + + SwRect GetFrame( const SwRect &rPortion ) const; + bool IsOn() const; + + /** + If there is no flying object frame standing in rRect (usually the current row), + then we are turning ourself off. + + \param rRect is global to the document! + */ + bool Relax( const SwRect &rRect ); + bool Relax(); + + SwTwips GetMinBottom() const; + + /// Gets the maximum of the fly frame bottoms. + SwTwips GetMaxBottom(const SwBreakPortion& rPortion, const SwTextFormatInfo& rInfo) const; + + const SwTextFrame* GetMaster() const; + + // This temporary variable needs to be manipulated in const methods + tools::Long GetNextTop() const; + void SetNextTop( tools::Long nNew ) const; + + /** + Determines the demanded rectangle for an anchored object, + considering its surround for text wrapping. + + \param pAnchoredObj the object for which to get the bounds + \param rLine the bounds of the line to format + + \return the flying object bounds + */ + SwRect AnchoredObjToRect( const SwAnchoredObject* pAnchoredObj, + const SwRect& rRect ) const; + + /** + This method is called by DrawText(). + + Ensures that the overlapping frames (except the transparent frames) won't + be scribbled by setting clip regions so that only the portions that are not + in the area of FlyFrames that are opaque and above the current frame will + be output. + + DrawText() takes over the on optimization! + */ + void DrawTextOpaque( SwDrawTextInfo &rInf ); + + /** + Two subtleties needs to be mentioned: + \li DrawRect() is allowed over the ClipRects + \li FlyToRect() returns bigger values than the frame data + + Ensure that the overlapping frames (except the transparent frames) + won't be scribbled + */ + void DrawFlyRect( OutputDevice* pOut, const SwRect &rRect ); + + /** + Used to switch off the SwTextFly when there is no overlapping object (Relax). + + \param[in] the line area + \return whether the line will be overlapped by a frame + */ + bool IsAnyFrame( const SwRect &rLine ) const; + + /** + Same as IsAnyFrame(const SwRect&), but uses the current frame print + area + */ + bool IsAnyFrame() const; + + /** + true when a frame or DrawObj must be taken in account. The optimizations + like Paint/FormatEmpty for empty sentences or the virtual OutputDevice can + be used only when false is returned. + + \param rRect + The rectangle can be empty, the current frame is then used. The value is + global to the document. + */ + bool IsAnyObj( const SwRect& rRect ) const; + + void SetIgnoreCurrentFrame( bool bNew ); + void SetIgnoreContour( bool bNew ); + + void SetIgnoreObjsInHeaderFooter( const bool bNew ); + + SwRect GetFrameArea() const; +}; + +inline SwAnchoredObjList& SwTextFly::GetAnchoredObjList() const +{ + return mpAnchoredObjList + ? *mpAnchoredObjList + : const_cast(this)->InitAnchoredObjList(); +} + +inline void SwTextFly::SetTopRule() +{ + m_bTopRule = false; +} + +inline bool SwTextFly::IsOn() const +{ + return m_bOn; +} + +inline bool SwTextFly::Relax( const SwRect &rRect ) +{ + if (m_bOn) + { + m_bOn = IsAnyFrame( rRect ); + } + return m_bOn; +} + +inline bool SwTextFly::Relax() +{ + if (m_bOn) + { + m_bOn = IsAnyFrame(); + } + return m_bOn; +} + +inline SwTwips SwTextFly::GetMinBottom() const +{ + return mpAnchoredObjList ? m_nMinBottom : CalcMinBottom(); +} + +inline const SwTextFrame* SwTextFly::GetMaster() const +{ + return m_pMaster ? m_pMaster : const_cast(this)->GetMaster_(); +} + +inline tools::Long SwTextFly::GetNextTop() const +{ + return m_nNextTop; +} + +inline void SwTextFly::SetNextTop( tools::Long nNew ) const +{ + const_cast(this)->m_nNextTop = nNew; +} + +inline SwRect SwTextFly::GetFrame( const SwRect &rRect ) const +{ + return m_bOn ? GetFrame_( rRect ) : SwRect(); +} + +inline void SwTextFly::SetIgnoreCurrentFrame( bool bNew ) +{ + mbIgnoreCurrentFrame = bNew; +} + +inline void SwTextFly::SetIgnoreContour( bool bNew ) +{ + mbIgnoreContour = bNew; +} + +inline void SwTextFly::SetIgnoreObjsInHeaderFooter( const bool bNew ) +{ + mbIgnoreObjsInHeaderFooter = bNew; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx new file mode 100644 index 0000000000..aa2246727f --- /dev/null +++ b/sw/source/core/inc/txtfrm.hxx @@ -0,0 +1,1060 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_TXTFRM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_TXTFRM_HXX + +#include +#include "cntfrm.hxx" +#include "TextFrameIndex.hxx" +#include + +#include +#include + +#include + +namespace com::sun::star::linguistic2 { class XHyphenatedWord; } + +namespace sw::mark { class IMark; } +class SwCharRange; +class SwTextNode; +class SwTextAttrEnd; +class SwTextFormatter; +class SwTextFormatInfo; +class SwParaPortion; +class WidowsAndOrphans; +class SwTextFootnote; +class SwInterHyphInfo; // Hyphenate() +class SwCache; +class SwBorderAttrs; +class SwFrameFormat; +struct SwCursorMoveState; +struct SwFillData; +class SwPortionHandler; +class SwScriptInfo; +enum class ExpandMode; +class SwTextAttr; +class SwWrtShell; +class SwNode; +class SwFlyAtContentFrame; + +#define NON_PRINTING_CHARACTER_COLOR Color(0x26, 0x8b, 0xd2) + +/// a clone of SwInterHyphInfo, but with TextFrameIndex instead of node index +class SwInterHyphInfoTextFrame +{ +private: + /// output: hyphenated word + css::uno::Reference m_xHyphWord; +public: + /// input: requested range to hyphenate + TextFrameIndex m_nStart; + TextFrameIndex m_nEnd; + /// output: found word + TextFrameIndex m_nWordStart; + TextFrameIndex m_nWordLen; + + SwInterHyphInfoTextFrame(SwTextFrame const& rFrame, + SwTextNode const& rNode, SwInterHyphInfo const& rHyphInfo); + void UpdateTextNodeHyphInfo(SwTextFrame const& rFrame, + SwTextNode const& rNode, SwInterHyphInfo & o_rHyphInfo); + + void SetHyphWord(const css::uno::Reference &xHW) + { + m_xHyphWord = xHW; + } +}; + +namespace sw { + +/** + * Describes a part of a single text node, which will be part of a text frame, + * even when redlines are hidden at a layout level. + */ +struct Extent +{ + SwTextNode * /*const logically, but need assignment for std::vector*/ pNode; + sal_Int32 nStart; + sal_Int32 nEnd; + Extent(SwTextNode *const p, sal_Int32 const s, sal_Int32 const e) + : pNode(p), nStart(s), nEnd(e) + { + assert(pNode); + assert(nStart != nEnd); + } +}; + +struct MergedPara; +class InsertText; + +std::pair MapViewToModel(MergedPara const&, TextFrameIndex nIndex); +TextFrameIndex MapModelToView(MergedPara const&, SwTextNode const* pNode, sal_Int32 nIndex); + +// warning: Existing must be used only once; a second use would delete the frame created by the first one... +enum class FrameMode { New, Existing }; +std::unique_ptr CheckParaRedlineMerge(SwTextFrame & rFrame, SwTextNode & rTextNode, FrameMode eMode); +SwTextFrame * MakeTextFrame(SwTextNode & rNode, SwFrame *, sw::FrameMode eMode); + +bool FrameContainsNode(SwContentFrame const& rFrame, SwNodeOffset nNodeIndex); +bool IsParaPropsNode(SwRootFrame const& rLayout, SwTextNode const& rNode); +SwTextNode * GetParaPropsNode(SwRootFrame const& rLayout, SwNode const& rNode); +SwPosition GetParaPropsPos(SwRootFrame const& rLayout, SwPosition const& rPos); +std::pair +GetFirstAndLastNode(SwRootFrame const& rLayout, SwNode const& rPos); + +SwTextNode const& GetAttrMerged(SfxItemSet & rFormatSet, + SwTextNode const& rNode, SwRootFrame const* pLayout); + +void GotoPrevLayoutTextFrame(SwNodeIndex & rIndex, SwRootFrame const* pLayout); +void GotoNextLayoutTextFrame(SwNodeIndex & rIndex, SwRootFrame const* pLayout); + +TextFrameIndex UpdateMergedParaForDelete(MergedPara & rMerged, + bool isRealDelete, + SwTextNode const& rNode, sal_Int32 nIndex, sal_Int32 nLen); + +void MoveMergedFlysAndFootnotes(std::vector const& rFrames, + SwTextNode const& rFirstNode, SwTextNode & rSecondNode, bool); + +void MoveDeletedPrevFrames(const SwTextNode & rDeletedPrev, SwTextNode & rNode); +enum class Recreate { No, ThisNode, Predecessor }; +void CheckResetRedlineMergeFlag(SwTextNode & rNode, Recreate eRecreateMerged); + +void UpdateFramesForAddDeleteRedline(SwDoc & rDoc, SwPaM const& rPam); +void UpdateFramesForRemoveDeleteRedline(SwDoc & rDoc, SwPaM const& rPam); + +void AddRemoveFlysAnchoredToFrameStartingAtNode( + SwTextFrame & rFrame, SwTextNode & rTextNode, + std::set *pSkipped); + +OUString GetExpandTextMerged(SwRootFrame const* pLayout, + SwTextNode const& rNode, bool bWithNumber, + bool bWithSpacesForLevel, ExpandMode i_mode); + +bool IsMarkHidden(SwRootFrame const& rLayout, ::sw::mark::IMark const& rMark); +bool IsMarkHintHidden(SwRootFrame const& rLayout, + SwTextNode const& rNode, SwTextAttrEnd const& rHint); + +void RecreateStartTextFrames(SwTextNode & rNode); + +sw::InsertText MakeInsertText(SwTextNode& rNode, const sal_Int32 nPos, const sal_Int32 nLen); + +/** + * Decides if rTextNode has a numbering which has layout-level values (e.g. Arabic, but not + * none or bullets). + */ +bool HasNumberingWhichNeedsLayoutUpdate(const SwTextNode& rTextNode); + +} // namespace sw + +/// Represents the visualization of a paragraph. Typical upper is an +/// SwBodyFrame. The first text portion of the first line is az SwParaPortion. +class SW_DLLPUBLIC SwTextFrame final : public SwContentFrame +{ + friend class SwTextIter; + friend class SwTestFormat; + friend class WidowsAndOrphans; + friend class TextFrameLockGuard; // May Lock()/Unlock() + friend bool sw_ChangeOffset(SwTextFrame* pFrame, TextFrameIndex nNew); + + /// SwLineLayout cache: the lines are not actually owned by the SwTextFrame + /// but by this SwCache, so they will be deleted in large documents + /// if there are too many of them, but the "valid" flags of the frame + /// will still be set; GetFormatted() is the function that forces + /// recreation of the SwLineLayout by Format() if necessary. + static SwCache *s_pTextCache; + static constexpr tools::Long nMinPrtLine = 0; // This Line must not be underrun when printing + // Hack for table cells stretching multiple pages + + sal_Int32 mnAllLines :24; // Line count for the Paint (including nThisLines) + sal_Int32 mnThisLines :8; // Count of Lines of the Frame + + // The x position for flys anchored at this paragraph. + // These values are calculated in SwTextFrame::CalcBaseOfstForFly() + SwTwips mnFlyAnchorOfst; + // The x position for wrap-through flys anchored at this paragraph. + SwTwips mnFlyAnchorOfstNoWrap; + /// The y position for wrap-through flys anchored at this paragraph. + SwTwips mnFlyAnchorVertOfstNoWrap; + SwTwips mnFootnoteLine; + // OD 2004-03-17 #i11860# - re-factoring of #i11859# + // member for height of last line (value needed for proportional line spacing) + SwTwips mnHeightOfLastLine; + // member for the additional first line offset, which is caused by the list + // label alignment for list level position and space mode LABEL_ALIGNMENT. + // This additional first line offset is used for the text formatting. + // It is NOT used for the determination of printing area. + SwTwips mnAdditionalFirstLineOffset; + + /// redline merge data + std::unique_ptr m_pMergedPara; + + TextFrameIndex mnOffset; // Is the offset in the Content (character count) + + sal_uInt16 mnCacheIndex; // Index into the cache, USHRT_MAX if there's definitely no fitting object in the cache + + // Separates the Master and creates a Follow or adjusts the data in the Follow + void AdjustFollow_( SwTextFormatter &rLine, TextFrameIndex nOffset, + TextFrameIndex nStrEnd, const sal_uInt8 nMode ); + + // Iterates all Lines and sets the line spacing using the attribute + void CalcLineSpace(); + + // Only called in Format + void AdjustFrame( const SwTwips nChgHeight, bool bHasToFit = false ); + + // Evaluates the Preps in Format() + bool CalcPreps(); + void PrepWidows( const sal_uInt16 nNeed, bool bNotify ); + void InvalidateRange_( const SwCharRange &, const tools::Long = 0); + inline void InvalidateRange( const SwCharRange &, const tools::Long = 0); + + // WidowsAndOrphans, AdjustFrame, AdjustFollow + void FormatAdjust( SwTextFormatter &rLine, WidowsAndOrphans &rFrameBreak, + TextFrameIndex nStrLen, const bool bDummy ); + void ChangeOffset( SwTextFrame* pFrame, TextFrameIndex nNew ); + + bool mbLocked : 1; // In the Format? + bool mbWidow : 1; // Is our follow a Widow? + bool mbJustWidow : 1; // Did we just request Widow flag on master? + bool mbEmpty : 1; // Are we an empty paragraph? + bool mbInFootnoteConnect : 1; // Is in Connect at the moment + bool mbFootnote : 1; // Has at least one footnote + bool mbRepaint : 1; // TextFrame: Repaint is ready to be fetched + /// Contains rotated portions. + bool mbHasRotatedPortions : 1; + bool mbFieldFollow : 1; // Start with Field rest of the Master + bool mbHasAnimation : 1; // Contains animated SwGrfNumPortion + bool mbIsSwapped : 1; // during text formatting we swap the + // width and height for vertical formatting + // OD 14.03.2003 #i11760# - flag to control, if follow is formatted in + // method . + // E.g., avoid formatting of follow, if method + // is running. + bool mbFollowFormatAllowed : 1; + + void ResetPreps(); + void Lock() { mbLocked = true; } + void Unlock() { mbLocked = false; } + void SetWidow( const bool bNew ) { mbWidow = bNew; } + void SetJustWidow( const bool bNew ) { mbJustWidow = bNew; } + void SetEmpty( const bool bNew ) { mbEmpty = bNew; } + void SetFieldFollow( const bool bNew ) { mbFieldFollow = bNew; } + + bool IsIdxInside(TextFrameIndex nPos, TextFrameIndex nLen) const; + + // Changes the Frame or not (cf. FlyCnt) + bool GetModelPositionForViewPoint_(SwPosition *pPos, const Point &rPoint, + const bool bChgFrame, SwCursorMoveState* = nullptr ) const; + void FillCursorPos( SwFillData &rFill ) const; + + // Format exactly one Line + bool FormatLine( SwTextFormatter &rLine, const bool bPrev ); + + // In order to safe stack space, we split this method: + // Format_ calls Format_ with parameters + void FormatImpl( vcl::RenderContext* pRenderContext, SwParaPortion *pPara, + ::std::vector & rIntersectingObjs); + void Format_( SwTextFormatter &rLine, SwTextFormatInfo &rInf, + const bool bAdjust = false ); + void FormatOnceMore( SwTextFormatter &rLine, SwTextFormatInfo &rInf ); + + // Formats the Follow and ensures disposing on orphans + bool CalcFollow(TextFrameIndex nTextOfst); + + virtual void MakePos() override; + + // Corrects the position from which we need to format + static TextFrameIndex FindBrk(std::u16string_view aText, TextFrameIndex nStart, + TextFrameIndex nEnd); + + // inline branch + SwTwips GetFootnoteFrameHeight_() const; + + // Outsourced to CalcPreps + bool CalcPrepFootnoteAdjust(); + + // For Footnote and WidOrp: Forced validation + void ValidateFrame(); + void ValidateBodyFrame(); + + bool GetDropRect_( SwRect &rRect ) const; + + void SetPara( SwParaPortion *pNew, bool bDelete = true ); + + bool IsFootnoteNumFrame_() const; + + // Refresh formatting information + bool FormatQuick( bool bForceQuickFormat ); + + // Opt: Format empty paragraphs + bool FormatEmpty(); + SwTwips EmptyHeight() const; + + // Opt: Paint empty paragraphs + bool PaintEmpty( const SwRect &, bool bCheck ) const; + + void ChgThisLines(); // Must always be called if the Line count could have changed + + // required for 'new' relative anchor position + void CalcBaseOfstForFly(); + + /** method to determine height of last line, needed for proportional line spacing + + OD 2004-03-17 #i11860# + OD 2005-05-20 #i47162# - introduce new optional parameter <_bUseFont> + in order to force the usage of the former algorithm to determine the + height of the last line, which uses the font. + + @param _bUseFont + optional input parameter - boolean indicating, if the font has to be + used to determine the height of the last line. default value: false + */ + void CalcHeightOfLastLine( const bool _bUseFont = false ); + + virtual void DestroyImpl() override; + virtual ~SwTextFrame() override; + + void UpdateOutlineContentVisibilityButton(SwWrtShell* pWrtSh) const; + void PaintOutlineContentVisibilityButton() const; + + void PaintParagraphStylesHighlighting() const; + + virtual void SwClientNotify(SwModify const& rModify, SfxHint const& rHint) override; + + /// Like GetDrawObjs(), but limit to fly frames which are allowed to split. + std::vector GetSplitFlyDrawObjs() const; + +public: + + virtual const SvxFormatBreakItem& GetBreakItem() const override; + virtual const SwFormatPageDesc& GetPageDescItem() const override; + + css::uno::Sequence< css::style::TabStop > GetTabStopInfo( SwTwips CurrentPos ) override; + + /** + * This is public, as it needs to be called by some methods in order to save the Prepare + * USE WITH CAUTION! + */ + void Init(); + + /// Is called by DoIdleJob_(), ExecSpellPopup() and UpDown() + SwRect AutoSpell_(SwTextNode &, sal_Int32); + + /// Is called by DoIdleJob_() + SwRect SmartTagScan(SwTextNode &); + + /// Is called by DoIdleJob_() + void CollectAutoCmplWrds(SwTextNode &, sal_Int32); + + /** + * Returns the view rectangle for the rPos model position. The values are relative to the upper + * left position of the page frame. + * Additional information can be obtained by passing an SwCursorMoveState object. + * Returns false if rPos > number of character is string + */ + virtual bool GetCharRect( SwRect& rRect, const SwPosition& rPos, + SwCursorMoveState* pCMS = nullptr, bool bAllowFarAway = true ) const override; + + /// A slimmer version of GetCharRect for autopositioning Frames + bool GetAutoPos( SwRect &, const SwPosition& ) const; + + /** + * Determine top of line for given position in the text frame + * + * OD 11.11.2003 #i22341# + * Assumption: given position exists in the text frame or in a follow of it + * OD 2004-02-02 - adjustment + * Top of first paragraph line is the top of the paragraph. + * OD 2004-03-18 #i11860# - Consider upper space amount considered for + * previous frame and the page grid. + * + * @param _onTopOfLine + * output parameter - top of line, if the given position is found in the + * text frame. + * + * @param _rPos + * input parameter - reference to the position in the text frame + * + * @return boolean indicating, if the top of line for the given position + * has been determined or not. + */ + bool GetTopOfLine( SwTwips& _onTopOfLine, + const SwPosition& _rPos ) const; + + virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const override; + + /** + * In nOffset returns the offset of the char within the set + * text buffer, which is closest to the position provided by + * aPoint within the layout's SSize. + * + * @returns false if the SPoint is outside of the SSize else + * returns true + */ + virtual bool GetModelPositionForViewPoint( SwPosition *, Point&, + SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override; + + /** + * Makes sure that the Frame is not switched (e.g. switched for a + * character-bound Frame) + */ + bool GetKeyCursorOfst(SwPosition *pPos, const Point &rPoint ) const + { return GetModelPositionForViewPoint_( pPos, rPoint, false ); } + + void PaintExtraData( const SwRect & rRect ) const; /// Page number etc. + SwRect GetPaintSwRect(); + virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&, + SwPrintData const*const pPrintData = nullptr ) const override; + + /** + * Layout oriented cursor travelling: + * Left border, right border, previous Line, following Line, + * same horizontal position + */ + virtual bool LeftMargin(SwPaM *) const override; + virtual bool RightMargin(SwPaM *, bool bAPI = false) const override; + + virtual bool UnitUp(SwPaM *, const SwTwips nOffset, + bool bSetInReadOnly ) const override; + virtual bool UnitDown(SwPaM *, const SwTwips nOffset, + bool bSetInReadOnly ) const override; + bool UnitUp_(SwPaM *, const SwTwips nOffset, + bool bSetInReadOnly ) const; + bool UnitDown_(SwPaM *, const SwTwips nOffset, + bool bSetInReadOnly ) const; + + /** + * Prepares the cursor position for a visual cursor move (BiDi). + * The behaviour is different for insert and overwrite cursors + */ + void PrepareVisualMove( TextFrameIndex& nPos, sal_uInt8& nCursorLevel, + bool& bRight, bool bInsertCursor ); + + /// Methods to manage the FollowFrame + void SplitFrame(TextFrameIndex nTextPos); + SwContentFrame *JoinFrame(); + TextFrameIndex GetOffset() const { return mnOffset; } + void SetOffset_(TextFrameIndex nNewOfst); + inline void SetOffset (TextFrameIndex nNewOfst); + void ManipOfst(TextFrameIndex const nNewOfst) { mnOffset = nNewOfst; } + SwTextFrame *GetFrameAtPos ( const SwPosition &rPos); + inline const SwTextFrame *GetFrameAtPos ( const SwPosition &rPos) const; + SwTextFrame& GetFrameAtOfst(TextFrameIndex nOfst); + /// If there's a Follow and we don't contain text ourselves + bool IsEmptyMaster() const + { return GetFollow() && !GetFollow()->GetOffset(); } + + void SetMergedPara(std::unique_ptr p); + sw::MergedPara * GetMergedPara() { return m_pMergedPara.get(); } + sw::MergedPara const* GetMergedPara() const { return m_pMergedPara.get(); } + + /// Returns the text portion we want to edit (for inline see underneath) + const OUString& GetText() const; + SwTextNode const* GetTextNodeForParaProps() const; + SwTextNode const* GetTextNodeForFirstText() const; + SwTextNode * GetTextNodeFirst() + { return const_cast(const_cast(this)->GetTextNodeFirst()); }; + SwTextNode const* GetTextNodeFirst() const; + SwDoc & GetDoc() + { return const_cast(const_cast(this)->GetDoc()); } + SwDoc const& GetDoc() const; + + SwTextFrame(SwTextNode * const, SwFrame*, sw::FrameMode eMode); + + /** + * SwContentFrame: the shortcut for the Frames + * If the void* casts wrongly, it's its own fault! + * The void* must be checked for 0 in any case! + * + * return true if the Portion associated with this SwTextFrame was + * potentially destroyed and replaced by Prepare + */ + virtual bool Prepare( const PrepareHint ePrep = PrepareHint::Clear, + const void *pVoid = nullptr, bool bNotify = true ) override; + + /** + * nMaxHeight is the required height + * bSplit indicates, that the paragraph has to be split + * bTst indicates, that we are currently doing a test formatting + */ + virtual bool WouldFit(SwTwips &nMaxHeight, bool &bSplit, bool bTst, bool bMoveBwd) override; + + /** + * The WouldFit equivalent for temporarily rewired TextFrames + * nMaxHeight returns the required size here too and bSplit + * determines whether the paragraph needs to be split. + * We pass the potential predecessor for the distance calculation + */ + bool TestFormat( const SwFrame* pPrv, SwTwips &nMaxHeight, bool &bSplit ); + + /** + * We format a Line for interactive hyphenation + * @return found + */ + bool Hyphenate(SwInterHyphInfoTextFrame & rInf); + + /// Test grow + inline SwTwips GrowTst( const SwTwips nGrow ); + + SwParaPortion *GetPara(); + inline const SwParaPortion *GetPara() const; + inline bool HasPara() const; + bool HasPara_() const; + + /// map position in potentially merged text frame to SwPosition + std::pair MapViewToModel(TextFrameIndex nIndex) const; + SwPosition MapViewToModelPos(TextFrameIndex nIndex) const; + TextFrameIndex MapModelToView(SwTextNode const* pNode, sal_Int32 nIndex) const; + TextFrameIndex MapModelToViewPos(SwPosition const& rPos) const; + + // If there are any hanging punctuation portions in the margin + // the offset will be returned. + SwTwips HangingMargin() const; + + /// Get the amount of lower margin of this frame we need to consider for fly portion purposes. + SwTwips GetLowerMarginForFlyIntersect() const; + + // Locking + bool IsLocked() const { return mbLocked; } + + bool IsWidow() const { return mbWidow; } + bool IsJustWidow() const { return mbJustWidow; } + bool IsEmpty() const { return mbEmpty; } + bool HasFootnote() const { return mbFootnote; } + bool IsInFootnoteConnect()const { return mbInFootnoteConnect;} + bool IsFieldFollow() const { return mbFieldFollow;} + + inline void SetRepaint() const; + inline void ResetRepaint() const; + bool HasRepaint() const { return mbRepaint; } + void SetHasRotatedPortions(bool bHasRotatedPortions); + bool GetHasRotatedPortions() const { return mbHasRotatedPortions; } + void SetAnimation() const + { const_cast(this)->mbHasAnimation = true; } + bool HasAnimation() const { return mbHasAnimation; } + + bool IsSwapped() const { return mbIsSwapped; } + + /// Does the Frame have a local footnote (in this Frame or Follow)? +#ifdef DBG_UTIL + void CalcFootnoteFlag(TextFrameIndex nStop = TextFrameIndex(COMPLETE_STRING)); //For testing SplitFrame +#else + void CalcFootnoteFlag(); +#endif + + /// Hidden + bool IsHiddenNow() const; // bHidden && pOut == pPrt + void HideHidden(); // Remove appendage if Hidden + void HideFootnotes(TextFrameIndex nStart, TextFrameIndex nEnd); + + /** + * Hides respectively shows objects, which are anchored at paragraph, + * at/as a character of the paragraph, corresponding to the paragraph and + * paragraph portion visibility. + */ + void HideAndShowObjects(); + + /// Footnote + void RemoveFootnote(TextFrameIndex nStart, + TextFrameIndex nLen = TextFrameIndex(COMPLETE_STRING)); + inline SwTwips GetFootnoteFrameHeight() const; + SwTextFrame *FindFootnoteRef( const SwTextFootnote *pFootnote ); + const SwTextFrame *FindFootnoteRef( const SwTextFootnote *pFootnote ) const + { return const_cast(this)->FindFootnoteRef( pFootnote ); } + void ConnectFootnote( SwTextFootnote *pFootnote, const SwTwips nDeadLine ); + + /** + * If we're a Footnote that grows towards its reference ... + * public, because it's needed by SwContentFrame::MakeAll + */ + SwTwips GetFootnoteLine( const SwTextFootnote *pFootnote ) const; + + TextFrameIndex GetDropLen(TextFrameIndex nWishLen) const; + + LanguageType GetLangOfChar(TextFrameIndex nIndex, sal_uInt16 nScript, + bool bNoChar = false) const; + + virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override; + virtual void CheckDirection( bool bVert ) override; + + /// Returns the sum of line height in pLine + SwTwips GetParHeight() const; + + inline SwTextFrame *GetFollow(); + inline const SwTextFrame *GetFollow() const; + + /// Find the page number of ErgoSum and QuoVadis + SwTextFrame *FindQuoVadisFrame(); + + /** + * In case the SwLineLayout was cleared out of the s_pTextCache, recreate it + * + * #i29062# GetFormatted() can trigger a full formatting + * of the paragraph, causing other layout frames to become invalid. This + * has to be avoided during painting. Therefore we need to pass the + * information that we are currently in the paint process. + */ + SwTextFrame* GetFormatted( bool bForceQuickFormat = false ); + + /// Will be moved soon + void SetFootnote( const bool bNew ) { mbFootnote = bNew; } + + /// Respect the Follows + inline bool IsInside(TextFrameIndex nPos) const; + + /// DropCaps and selections + bool GetDropRect( SwRect &rRect ) const + { return HasPara() && GetDropRect_( rRect ); } + + static SwCache *GetTextCache() { return s_pTextCache; } + static void SetTextCache( SwCache *pNew ) { s_pTextCache = pNew; } + + static tools::Long GetMinPrtLine() { return nMinPrtLine; } + + sal_uInt16 GetCacheIdx() const { return mnCacheIndex; } + void SetCacheIdx( const sal_uInt16 nNew ) { mnCacheIndex = nNew; } + + /// Removes the Line information from the Cache but retains the entry itself + void ClearPara(); + /// Removes this frame completely from the Cache + void RemoveFromCache(); + + /// Am I a FootnoteFrame, with a number at the start of the paragraph? + bool IsFootnoteNumFrame() const + { return IsInFootnote() && !GetIndPrev() && IsFootnoteNumFrame_(); } + + /** + * Simulates a formatting as if there were not right margin or Flys or other + * obstacles and returns the width + */ + SwTwips CalcFitToContent(); + + /** + * Simulate format for a list item paragraph, whose list level attributes + * are in LABEL_ALIGNMENT mode, in order to determine additional first + * line offset for the real text formatting due to the value of label + * adjustment attribute of the list level. + */ + void CalcAdditionalFirstLineOffset(); + + SwTwips GetAdditionalFirstLineOffset() const + { + return mnAdditionalFirstLineOffset; + } + + /** + * Returns the additional line spacing for the next paragraph + * @param _bNoPropLineSpacing: control, whether the value of a + * proportional line spacing is returned or not + */ + tools::Long GetLineSpace( const bool _bNoPropLineSpacing = false ) const; + + /// Returns the first line height + sal_uInt16 FirstLineHeight() const; + + /// Rewires FlyInContentFrame, if nEnd > Index >= nStart + void MoveFlyInCnt(SwTextFrame *pNew, TextFrameIndex nStart, TextFrameIndex nEnd); + + /// Calculates the position of FlyInContentFrames + TextFrameIndex CalcFlyPos( SwFrameFormat const * pSearch ); + + /// Determines the start position and step size of the register + bool FillRegister( SwTwips& rRegStart, sal_uInt16& rRegDiff ); + + /// Determines the line count + sal_Int32 GetLineCount(TextFrameIndex nPos); + + /// For displaying the line numbers + sal_Int32 GetAllLines() const { return mnAllLines; } + sal_Int32 GetThisLines() const { return mnThisLines;} + void RecalcAllLines(); + + /// Stops the animations within numberings + void StopAnimation( const OutputDevice *pOut ); + + /// Visit all portions for Accessibility + void VisitPortions( SwPortionHandler& rPH ) const; + + /// Returns the script info stored at the paraportion + const SwScriptInfo* GetScriptInfo() const; + + /// Swaps width and height of the text frame + void SwapWidthAndHeight(); + + /** + * Calculates the coordinates of a rectangle when switching from + * horizontal to vertical layout + */ + void SwitchHorizontalToVertical( SwRect& rRect ) const; + + /** + * Calculates the coordinates of a point when switching from + * horizontal to vertical layout + */ + void SwitchHorizontalToVertical( Point& rPoint ) const; + + /** + * Calculates the limit value when switching from + * horizontal to vertical layout + */ + tools::Long SwitchHorizontalToVertical( tools::Long nLimit ) const; + + /** + * Calculates the coordinates of a rectangle when switching from + * vertical to horizontal layout + */ + void SwitchVerticalToHorizontal( SwRect& rRect ) const; + + /** + * Calculates the coordinates of a point when switching from + * vertical to horizontal layout + */ + void SwitchVerticalToHorizontal( Point& rPoint ) const; + + /** + * Calculates the a limit value when switching from + * vertical to horizontal layout + */ + tools::Long SwitchVerticalToHorizontal( tools::Long nLimit ) const; + + /** + * Calculates the coordinates of a rectangle when switching from + * LTR to RTL layout + */ + void SwitchLTRtoRTL( SwRect& rRect ) const; + + /** + * Calculates the coordinates of a point when switching from + * LTR to RTL layout + */ + void SwitchLTRtoRTL( Point& rPoint ) const; + + /** + * Calculates the coordinates of a rectangle when switching from + * RTL to LTR layout + */ + void SwitchRTLtoLTR( SwRect& rRect ) const { SwitchLTRtoRTL( rRect ); } + + /** + * Calculates the coordinates of a point when switching from + * RTL to LTR layout + */ + void SwitchRTLtoLTR( Point& rPoint ) const { SwitchLTRtoRTL( rPoint ); }; + + bool FollowFormatAllowed() const + { + return mbFollowFormatAllowed; + } + + void AllowFollowFormat() + { + mbFollowFormatAllowed = true; + } + + void ForbidFollowFormat() + { + mbFollowFormatAllowed = false; + } + + SwTwips GetBaseOffsetForFly( bool bIgnoreFlysAnchoredAtThisFrame ) const + { + return ( bIgnoreFlysAnchoredAtThisFrame ? + mnFlyAnchorOfst : + mnFlyAnchorOfstNoWrap ); + } + + SwTwips GetBaseVertOffsetForFly(bool bIgnoreFlysAnchoredAtThisFrame) const; + + SwTwips GetHeightOfLastLine() const + { + return mnHeightOfLastLine; + } + + static void repaintTextFrames( const SwTextNode& rNode ); + + void RegisterToNode(SwTextNode &, bool isForceNodeAsFirst = false); + + bool IsSymbolAt(TextFrameIndex) const; + OUString GetCurWord(SwPosition const&) const; + sal_uInt16 GetScalingOfSelectedText(TextFrameIndex nStt, TextFrameIndex nEnd); + + /// This text frame may have a split fly frames anchored to it. Is any of them a frame that has + /// a follow, i.e. not the last in a master -> follow 1 -> ... -> last follow chain? + SwFlyAtContentFrame* HasNonLastSplitFlyDrawObj() const; + + /// This text frame has a follow and the text frame don't contain text. Additionally one split + /// fly is anchored to the text frame. + bool IsEmptyMasterWithSplitFly() const; + + /// This text frame is not split, doesn't fit the upper, has a single split fly anchored to it + /// with a negative vertical offset. Such frames may need explicit splitting. + bool IsEmptyWithSplitFly() const; + + static SwView* GetView(); + + void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; + void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override; +}; + +//use this to protect a SwTextFrame for a given scope from getting merged with +//its neighbour and thus deleted +class TextFrameLockGuard +{ +private: + SwTextFrame *m_pTextFrame; + bool m_bOldLocked; +public: + //Lock pFrame for the lifetime of the Cut/Paste call, etc. to avoid + //SwTextFrame::AdjustFollow_ removing the pFrame we're trying to Make + TextFrameLockGuard(SwFrame* pFrame) + { + m_pTextFrame = pFrame->IsTextFrame() ? static_cast(pFrame) : nullptr; + if (m_pTextFrame) + { + m_bOldLocked = m_pTextFrame->IsLocked(); + m_pTextFrame->Lock(); + } + else + { + m_bOldLocked = false; + } + } + + ~TextFrameLockGuard() + { + if (m_pTextFrame && !m_bOldLocked) + m_pTextFrame->Unlock(); + } +}; + +inline const SwParaPortion *SwTextFrame::GetPara() const +{ + return const_cast(this)->GetPara(); +} + +inline bool SwTextFrame::HasPara() const +{ + return mnCacheIndex!=USHRT_MAX && HasPara_(); +} + +inline SwTwips SwTextFrame::GrowTst( const SwTwips nGrow ) +{ + return Grow( nGrow, true ); +} + +inline bool SwTextFrame::IsInside(TextFrameIndex const nPos) const +{ + bool bRet = true; + if( nPos < GetOffset() ) + bRet = false; + else + { + const SwTextFrame *pFoll = GetFollow(); + if( pFoll && nPos >= pFoll->GetOffset() ) + bRet = false; + } + return bRet; +} + +inline SwTwips SwTextFrame::GetFootnoteFrameHeight() const +{ + if( !IsFollow() && IsInFootnote() && HasPara() ) + return GetFootnoteFrameHeight_(); + else + return 0; +} + +inline const SwTextFrame *SwTextFrame::GetFollow() const +{ + return static_cast(SwContentFrame::GetFollow()); +} +inline SwTextFrame *SwTextFrame::GetFollow() +{ + return static_cast(SwContentFrame::GetFollow()); +} + +inline const SwTextFrame *SwTextFrame::GetFrameAtPos( const SwPosition &rPos) const +{ + return const_cast(this)->GetFrameAtPos( rPos ); +} + +inline void SwTextFrame::SetOffset(TextFrameIndex const nNewOfst) +{ + if ( mnOffset != nNewOfst ) + SetOffset_( nNewOfst ); +} + +inline void SwTextFrame::SetRepaint() const +{ + const_cast(this)->mbRepaint = true; +} +inline void SwTextFrame::ResetRepaint() const +{ + const_cast(this)->mbRepaint = false; +} + +class TemporarySwap { +protected: + explicit TemporarySwap(SwTextFrame * frame, bool swap): + m_frame(frame), m_undo(false) + { + if (m_frame->IsVertical() && swap) { + m_undo = true; + m_frame->SwapWidthAndHeight(); + } + } + + ~TemporarySwap() { + if (m_undo) { + m_frame->SwapWidthAndHeight(); + } + } + +private: + TemporarySwap(TemporarySwap const &) = delete; + void operator =(TemporarySwap const &) = delete; + + SwTextFrame * m_frame; + bool m_undo; +}; + +class SwSwapIfSwapped: private TemporarySwap { +public: + explicit SwSwapIfSwapped(SwTextFrame* frame): + TemporarySwap(frame, frame->IsSwapped()) {} +}; + +class SwSwapIfNotSwapped: private TemporarySwap { +public: + explicit SwSwapIfNotSwapped(SwTextFrame* frame): + TemporarySwap(frame, !frame->IsSwapped()) {} +}; + +/** + * Helper class which can be used instead of the macros if a function + * has too many returns + */ +class SwFrameSwapper +{ + const SwTextFrame* pFrame; + bool bUndo; +public: + SwFrameSwapper( const SwTextFrame* pFrame, bool bSwapIfNotSwapped ); + ~SwFrameSwapper(); +}; + +class SwLayoutModeModifier +{ + const OutputDevice& m_rOut; + vcl::text::ComplexTextLayoutFlags m_nOldLayoutMode; +public: + SwLayoutModeModifier( const OutputDevice& rOutp ); + ~SwLayoutModeModifier(); + void Modify( bool bChgToRTL ); + void SetAuto(); +}; + +class SwDigitModeModifier +{ + const OutputDevice& rOut; + LanguageType nOldLanguageType; +public: + SwDigitModeModifier( const OutputDevice& rOutp, LanguageType eCurLang ); + ~SwDigitModeModifier(); +}; + +namespace sw { + +/** + * Describes parts of multiple text nodes, which will form a text frame, even + * when redlines are hidden at a layout level. + */ +struct MergedPara +{ + sw::WriterMultiListener listener; + std::vector extents; + /// note: cannot be const currently to avoid UB because SwTextGuess::Guess + /// const_casts it and modifies it (also, Update will modify it) + OUString mergedText; + /// most paragraph properties are taken from the first non-empty node + SwTextNode * pParaPropsNode; + /// except break attributes, those are taken from the first node + SwTextNode *const pFirstNode; + /// mainly for sanity checks + SwTextNode const* pLastNode; + MergedPara(SwTextFrame & rFrame, std::vector&& rExtents, + OUString aText, + SwTextNode *const pProps, SwTextNode *const pFirst, + SwTextNode const*const pLast) + : listener(rFrame), extents(std::move(rExtents)), mergedText(std::move(aText)) + , pParaPropsNode(pProps), pFirstNode(pFirst), pLastNode(pLast) + { + assert(pParaPropsNode); + assert(pFirstNode); + assert(pLastNode); + } +}; + +/// iterate SwTextAttr in potentially merged text frame +class MergedAttrIterBase +{ +protected: + sw::MergedPara const*const m_pMerged; + SwTextNode const*const m_pNode; + size_t m_CurrentExtent; + size_t m_CurrentHint; + MergedAttrIterBase(SwTextFrame const& rFrame); +}; + +class MergedAttrIter + : public MergedAttrIterBase +{ +public: + MergedAttrIter(SwTextFrame const& rFrame) : MergedAttrIterBase(rFrame) {} + SwTextAttr const* NextAttr(SwTextNode const** ppNode = nullptr); +}; + +class MergedAttrIterByEnd +{ +private: + std::vector> m_Hints; + SwTextNode const*const m_pNode; + size_t m_CurrentHint; +public: + MergedAttrIterByEnd(SwTextFrame const& rFrame); + SwTextAttr const* NextAttr(SwTextNode const*& rpNode); + void PrevAttr(); +}; + +class MergedAttrIterReverse + : public MergedAttrIterBase +{ +public: + MergedAttrIterReverse(SwTextFrame const& rFrame); + SwTextAttr const* PrevAttr(SwTextNode const** ppNode = nullptr); +}; + + +const SwTwips WIDOW_MAGIC = (SAL_MAX_INT32 - 1)/2; + +} // namespace sw + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/txttypes.hxx b/sw/source/core/inc/txttypes.hxx new file mode 100644 index 0000000000..6b3124fb8b --- /dev/null +++ b/sw/source/core/inc/txttypes.hxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +/// @see PORGRP_* masks in porlin.hxx for meaning of bits! +enum class PortionType +{ + NONE = 0x0000, + FlyCnt = 0x0001, + + Hole = 0x0080, + TempEnd = 0x0081, + Break = 0x0082, + Kern = 0x0083, + Arrow = 0x0084, + Multi = 0x0085, + HiddenText = 0x0086, + ControlChar = 0x0087, + Bookmark = 0x0088, + + Text = 0x8000, + Lay = 0x8001, + Para = 0x8002, + Hanging = 0x8004, + InputField = 0x8005, + FieldMark = 0x8006, + FieldFormCheckbox = 0x8007, + + Drop = 0x8080, + Tox = 0x8089, + IsoTox = 0x808a, + Ref = 0x808b, + IsoRef = 0x808c, + Meta = 0x808d, + ContentControl = 0x808e, + + Expand = 0xc080, + Blank = 0xc081, + PostIts = 0xc082, + + Hyphen = 0xd080, + HyphenStr = 0xd081, + SoftHyphen = 0xd082, + SoftHyphenStr = 0xd083, + SoftHyphenComp = 0xd084, + + Field = 0xe080, + Hidden = 0xe081, + QuoVadis = 0xe082, + ErgoSum = 0xe083, + Combined = 0xe084, + Footnote = 0xe085, + + FootnoteNum = 0xe880, + Number = 0xe881, + Bullet = 0xe882, + GrfNum = 0xe883, + + Glue = 0x0480, + + Margin = 0x04c0, + + Fix = 0x06c0, + Fly = 0x06c1, + + // Tabulator, not table + Tab = 0x0750, + + TabRight = 0x07d0, + TabCenter = 0x07d1, + TabDecimal = 0x07d2, + + TabLeft = 0x0740, +}; + +namespace sw +{ +const char* PortionTypeToString(PortionType nType); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/undoflystrattr.hxx b/sw/source/core/inc/undoflystrattr.hxx new file mode 100644 index 0000000000..6cb639ac41 --- /dev/null +++ b/sw/source/core/inc/undoflystrattr.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOFLYSTRATTR_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNDOFLYSTRATTR_HXX + +#include +#include + +class SwFlyFrameFormat; + +class SwUndoFlyStrAttr final : public SwUndo +{ + public: + SwUndoFlyStrAttr( SwFlyFrameFormat& rFlyFrameFormat, + const SwUndoId eUndoId, + OUString sOldStr, + OUString sNewStr ); + virtual ~SwUndoFlyStrAttr() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + virtual SwRewriter GetRewriter() const override; + + private: + SwFlyFrameFormat& mrFlyFrameFormat; + const OUString msOldStr; + const OUString msNewStr; +}; + +class SwUndoFlyDecorative final : public SwUndo +{ + public: + SwUndoFlyDecorative(SwFlyFrameFormat& rFlyFrameFormat, + bool isDecorative); + virtual ~SwUndoFlyDecorative() override; + + virtual void UndoImpl( ::sw::UndoRedoContext & ) override; + virtual void RedoImpl( ::sw::UndoRedoContext & ) override; + + virtual SwRewriter GetRewriter() const override; + + private: + SwFlyFrameFormat & m_rFlyFrameFormat; + bool const m_IsDecorative; +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOFLYSTRATTR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unobookmark.hxx b/sw/source/core/inc/unobookmark.hxx new file mode 100644 index 0000000000..d1d800d9a2 --- /dev/null +++ b/sw/source/core/inc/unobookmark.hxx @@ -0,0 +1,240 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + +class SwDoc; +class SwXTextRange; + +typedef ::cppu::ImplInheritanceHelper +< ::sfx2::MetadatableMixin +, css::lang::XServiceInfo +, css::beans::XPropertySet +, css::container::XNamed +, css::text::XTextContent +> SwXBookmark_Base; + +/// UNO API wrapper around an internal sw::mark::IMark. +class SwXBookmark + : public SwXBookmark_Base +{ + +private: + + class Impl; + ::sw::UnoImplPtr m_pImpl; + +protected: + /// @throws css::lang::IllegalArgumentException + /// @throws css::uno::RuntimeException + void attachToRangeEx( + const css::uno::Reference< css::text::XTextRange > & xTextRange, + IDocumentMarkAccess::MarkType eType, + bool isFieldmarkSeparatorAtStart = false); + /// @throws css::lang::IllegalArgumentException + /// @throws css::uno::RuntimeException + virtual void attachToRange( + const css::uno::Reference< css::text::XTextRange > & xTextRange); + + ::sw::mark::IMark* GetBookmark() const; + + IDocumentMarkAccess* GetIDocumentMarkAccess(); + + SwDoc * GetDoc(); + + void registerInMark( SwXBookmark& rXMark, ::sw::mark::IMark* const pMarkBase ); + + virtual ~SwXBookmark() override; + + SwXBookmark(SwDoc *const pDoc); + + /// descriptor + SwXBookmark(); + +public: + + static rtl::Reference + CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark * pBookmark); + + /// @return IMark for this, but only if it lives in pDoc + static ::sw::mark::IMark const* GetBookmarkInDoc(SwDoc const*const pDoc, + const css::uno::Reference & xUT); + + // MetadatableMixin + virtual ::sfx2::Metadatable* GetCoreObject() override; + virtual css::uno::Reference< css::frame::XModel > GetModel() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( + const OUString& rServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() override; + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + virtual void SAL_CALL removeEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( + const OUString& rPropertyName, + const css::uno::Any& rValue) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& rPropertyName) override; + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< + css::beans::XVetoableChangeListener >& xListener) override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName(const OUString& rName) override; + + // XTextContent + virtual void SAL_CALL attach( + const css::uno::Reference< css::text::XTextRange > & xTextRange) override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override; + +}; + +class SwXFieldmarkParameters final + : public ::cppu::WeakImplHelper< css::container::XNameContainer> + , public SvtListener +{ + private: + ::sw::mark::IFieldmark* m_pFieldmark; + /// @throws css::uno::RuntimeException + ::sw::mark::IFieldmark::parameter_map_t* getCoreParameters(); + public: + SwXFieldmarkParameters(::sw::mark::IFieldmark* const pFieldmark) + : m_pFieldmark(pFieldmark) + { + StartListening(pFieldmark->GetNotifier()); + } + + // XNameContainer + virtual void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) override; + virtual void SAL_CALL removeByName( const OUString& Name ) override; + // XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override; + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType( ) override; + virtual sal_Bool SAL_CALL hasElements( ) override; + + virtual void Notify( const SfxHint& rHint ) override; +}; + +typedef cppu::ImplInheritanceHelper< SwXBookmark, + css::text::XFormField, + css::text::XTextField + > SwXFieldmark_Base; + +/// UNO wrapper around an sw::mark::IFieldmark. +class SwXFieldmark final + : public SwXFieldmark_Base +{ + ::sw::mark::ICheckboxFieldmark* getCheckboxFieldmark(); + bool const m_bReplacementObject; + bool m_isFieldmarkSeparatorAtStart = false; + + rtl::Reference + GetCommand(::sw::mark::IFieldmark const& rMark); + rtl::Reference + GetResult(::sw::mark::IFieldmark const& rMark); + + SwXFieldmark(bool isReplacementObject, SwDoc* pDoc); + +public: + static rtl::Reference + CreateXFieldmark(SwDoc & rDoc, ::sw::mark::IMark * pMark, + bool isReplacementObject = false); + + virtual void attachToRange( + const css::uno::Reference & xTextRange) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence SAL_CALL + getSupportedServiceNames() override; + + // XPropertySet + virtual css::uno::Reference SAL_CALL + getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( + const OUString& rPropertyName, + const css::uno::Any& rValue) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& rPropertyName) override; + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( + const css::uno::Reference & xListener) override; + virtual void SAL_CALL removeEventListener( + const css::uno::Reference & xListener) override; + + // XTextContent + virtual void SAL_CALL attach( + const css::uno::Reference & xTextRange) override; + virtual css::uno::Reference SAL_CALL getAnchor() override; + + // XTextField + virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override; + + // XFormField + virtual OUString SAL_CALL getFieldType() override; + virtual void SAL_CALL setFieldType(const OUString& description) override; + virtual css::uno::Reference SAL_CALL getParameters() override; + +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unocontentcontrol.hxx b/sw/source/core/inc/unocontentcontrol.hxx new file mode 100644 index 0000000000..08e32afd7f --- /dev/null +++ b/sw/source/core/inc/unocontentcontrol.hxx @@ -0,0 +1,170 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +class SwPaM; +class SwTextNode; +class SwFormatContentControl; +class SwContentControl; +class SwXText; +class SwXTextPortion; + +typedef std::deque> TextRangeList_t; + +/** + * UNO API wrapper around an SwContentControl, exposed as the com.sun.star.text.ContentControl + * service. + */ +class SwXContentControl final + : public cppu::WeakImplHelper +{ + class Impl; + sw::UnoImplPtr m_pImpl; + +protected: + void AttachImpl(const css::uno::Reference& xTextRange, + sal_uInt16 nWhich); + + ~SwXContentControl() override; + + SwXContentControl(const SwXContentControl&) = delete; + SwXContentControl& operator=(const SwXContentControl&) = delete; + + SwXContentControl(SwDoc* pDoc, SwContentControl* pContentControl, + const css::uno::Reference& xParentText, + std::unique_ptr pPortions); + + SwXContentControl(SwDoc* pDoc); + +public: + static rtl::Reference + CreateXContentControl(SwContentControl& rContentControl, + const css::uno::Reference& xParentText = nullptr, + std::unique_ptr&& pPortions + = std::unique_ptr()); + + static rtl::Reference CreateXContentControl(SwDoc& rDoc); + + /// Initializes params with position of the attribute content (without CH_TXTATR). + bool SetContentRange(SwTextNode*& rpNode, sal_Int32& rStart, sal_Int32& rEnd) const; + const css::uno::Reference& GetParentText() const; + + // XServiceInfo + OUString SAL_CALL getImplementationName() override; + sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override; + css::uno::Sequence SAL_CALL getSupportedServiceNames() override; + + // XComponent + void SAL_CALL dispose() override; + void SAL_CALL + addEventListener(const css::uno::Reference& xListener) override; + void SAL_CALL + removeEventListener(const css::uno::Reference& xListener) override; + + // XElementAccess + css::uno::Type SAL_CALL getElementType() override; + sal_Bool SAL_CALL hasElements() override; + + // XEnumerationAccess + css::uno::Reference SAL_CALL createEnumeration() override; + + // XTextContent + void SAL_CALL attach(const css::uno::Reference& xTextRange) override; + css::uno::Reference SAL_CALL getAnchor() override; + + // XTextRange + css::uno::Reference SAL_CALL getText() override; + css::uno::Reference SAL_CALL getStart() override; + css::uno::Reference SAL_CALL getEnd() override; + OUString SAL_CALL getString() override; + void SAL_CALL setString(const OUString& rString) override; + + // XSimpleText + css::uno::Reference SAL_CALL createTextCursor() override; + css::uno::Reference SAL_CALL createTextCursorByRange( + const css::uno::Reference& xTextPosition) override; + void SAL_CALL insertString(const css::uno::Reference& xRange, + const OUString& aString, sal_Bool bAbsorb) override; + void SAL_CALL insertControlCharacter(const css::uno::Reference& xRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb) override; + + // XText + void SAL_CALL insertTextContent(const css::uno::Reference& xRange, + const css::uno::Reference& xContent, + sal_Bool bAbsorb) override; + void SAL_CALL + removeTextContent(const css::uno::Reference& xContent) override; + + // XPropertySet + css::uno::Reference SAL_CALL getPropertySetInfo() override; + void SAL_CALL setPropertyValue(const OUString& rPropertyName, + const css::uno::Any& rValue) override; + css::uno::Any SAL_CALL getPropertyValue(const OUString& rPropertyName) override; + void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference& xListener) override; + void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference& xListener) override; + void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference& xListener) override; + void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference& xListener) override; +}; + +/// UNO wrapper around SwContentControlManager. +class SwXContentControls final : public cppu::WeakImplHelper, + public SwUnoCollection +{ + ~SwXContentControls() override; + +public: + SwXContentControls(SwDoc* pDoc); + + // XIndexAccess + sal_Int32 SAL_CALL getCount() override; + css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override; + + // XElementAccess + css::uno::Type SAL_CALL getElementType() override; + sal_Bool SAL_CALL hasElements() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unoevent.hxx b/sw/source/core/inc/unoevent.hxx new file mode 100644 index 0000000000..4906f447f6 --- /dev/null +++ b/sw/source/core/inc/unoevent.hxx @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOEVENT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNOEVENT_HXX + +#include + +class SvxMacroItem; +class SwXFrame; +class SwXTextFrame; +class SwXTextGraphicObject; +class SwXTextEmbeddedObject; +class SwFormatINetFormat; +namespace sw +{ +class ICoreFrameStyle; +} + +class SwHyperlinkEventDescriptor final : public SvDetachedEventDescriptor +{ + //XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + + virtual ~SwHyperlinkEventDescriptor() override; + +public: + SwHyperlinkEventDescriptor(); + + void copyMacrosFromINetFormat(const SwFormatINetFormat& aFormat); + void copyMacrosIntoINetFormat(SwFormatINetFormat& aFormat); + + void + copyMacrosFromNameReplace(css::uno::Reference const& xReplace); +}; + +// SwEventDescriptor for +// 1) SwXTextFrame +// 2) SwXGraphicObject +// 3) SwXEmbeddedObject +// All these objects are an SwXFrame, so they can use a common implementation +class SwFrameEventDescriptor final : public SvEventDescriptor +{ + SwXFrame& m_rFrame; + +public: + SwFrameEventDescriptor(SwXTextFrame& rFrameRef); + SwFrameEventDescriptor(SwXTextGraphicObject& rGraphicRef); + SwFrameEventDescriptor(SwXTextEmbeddedObject& rObjectRef); + + virtual ~SwFrameEventDescriptor() override; + + virtual OUString SAL_CALL getImplementationName() override; + +private: + virtual void setMacroItem(const SvxMacroItem& rItem) override; + virtual const SvxMacroItem& getMacroItem() override; + virtual sal_uInt16 getMacroItemWhich() const override; +}; + +class SwFrameStyleEventDescriptor final : public SvEventDescriptor +{ + sw::ICoreFrameStyle& m_rStyle; + +public: + SwFrameStyleEventDescriptor(sw::ICoreFrameStyle& rStyle); + + virtual ~SwFrameStyleEventDescriptor() override; + + virtual OUString SAL_CALL getImplementationName() override; + +private: + virtual void setMacroItem(const SvxMacroItem& rItem) override; + virtual const SvxMacroItem& getMacroItem() override; + virtual sal_uInt16 getMacroItemWhich() const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unofield.hxx b/sw/source/core/inc/unofield.hxx new file mode 100644 index 0000000000..55214020c0 --- /dev/null +++ b/sw/source/core/inc/unofield.hxx @@ -0,0 +1,229 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOFIELD_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNOFIELD_HXX + +#include +#include +#include +#include + +#include + +#include +#include +#include + +class SwDoc; +class SwFormatField; +class SwSetExpField; + +typedef ::cppu::WeakImplHelper +< css::beans::XPropertySet +, css::lang::XServiceInfo +, css::lang::XComponent +> SwXFieldMaster_Base; + +class SwXFieldMaster final + : public SwXFieldMaster_Base +{ + +private: + class Impl; + ::sw::UnoImplPtr m_pImpl; + + virtual ~SwXFieldMaster() override; + + SwXFieldMaster(SwFieldType& rType, SwDoc * pDoc); + + /// descriptor + SwXFieldMaster(SwDoc& rDoc, SwFieldIds nResId); + +public: + + static rtl::Reference + CreateXFieldMaster(SwDoc * pDoc, SwFieldType * pType, + SwFieldIds nResId = SwFieldIds::Unknown); + + static OUString GetProgrammaticName(const SwFieldType& rType, SwDoc& rDoc); + static OUString LocalizeFormula(const SwSetExpField& rField, const OUString& rFormula, bool bQuery); + + SwFieldType* GetFieldType(bool bDontCreate = false) const; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( + const OUString& rServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() override; + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + virtual void SAL_CALL removeEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( + const OUString& rPropertyName, + const css::uno::Any& rValue) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& rPropertyName) override; + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + +}; + +typedef ::cppu::WeakImplHelper +< css::text::XDependentTextField +, css::lang::XServiceInfo +, css::beans::XPropertySet +, css::util::XUpdatable +> SwXTextField_Base; + +/** + * UNO wrapper around an SwFormatField, i.e. a Writer field that the user creates via Insert -> + * Field. + */ +class SwXTextField final + : public SwXTextField_Base +{ + +private: + class Impl; + ::sw::UnoImplPtr m_pImpl; + + virtual ~SwXTextField() override; + + SwXTextField(SwFormatField& rFormat, SwDoc & rDoc); + + /// descriptor + SwXTextField(SwServiceType nServiceId, SwDoc* pDoc); + +public: + SwServiceType GetServiceId() const; + + static void TransmuteLeadToInputField(SwSetExpField & rField); + + /// @return an SwXTextField, either an already existing one or a new one + static rtl::Reference + CreateXTextField(SwDoc * pDoc, SwFormatField const* pFormat, + SwServiceType nServiceId = SwServiceType::Invalid); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( + const OUString& rServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() override; + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + virtual void SAL_CALL removeEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( + const OUString& rPropertyName, + const css::uno::Any& rValue) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& rPropertyName) override; + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + + // XUpdatable + virtual void SAL_CALL update() override; + + // XTextContent + virtual void SAL_CALL attach( + const css::uno::Reference< css::text::XTextRange > & xTextRange) override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override; + + // XTextField + virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override; + + // XDependentTextField + virtual void SAL_CALL attachTextFieldMaster( + const css::uno::Reference< css::beans::XPropertySet > & xFieldMaster) override; + virtual css::uno::Reference< css::beans::XPropertySet> SAL_CALL getTextFieldMaster() override; + +}; + +typedef ::cppu::WeakImplHelper +< css::container::XEnumeration +, css::lang::XServiceInfo +> SwXFieldEnumeration_Base; + +class SwXFieldEnumeration final + : public SwXFieldEnumeration_Base +{ + +private: + class Impl; + ::sw::UnoImplPtr m_pImpl; + + virtual ~SwXFieldEnumeration() override; + +public: + explicit SwXFieldEnumeration(SwDoc & rDoc); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( + const OUString& rServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() override; + + // XEnumeration + virtual sal_Bool SAL_CALL hasMoreElements() override; + virtual css::uno::Any SAL_CALL nextElement() override; + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unoflatpara.hxx b/sw/source/core/inc/unoflatpara.hxx new file mode 100644 index 0000000000..9fd768d277 --- /dev/null +++ b/sw/source/core/inc/unoflatpara.hxx @@ -0,0 +1,138 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOFLATPARA_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNOFLATPARA_HXX + +#include + +#include +#include +#include +#include +#include "unotextmarkup.hxx" +#include + +#include + +namespace com::sun::star::container { class XStringKeyMap; } +namespace com::sun::star::text { class XTextRange; } +class SwTextNode; +class SwDoc; +class ModelToViewHelper; + +typedef ::cppu::ImplInheritanceHelper +< SwXTextMarkup +, css::beans::XPropertySet +, css::text::XFlatParagraph +> SwXFlatParagraph_Base; + +class SwXFlatParagraph final + : public SwXFlatParagraph_Base +{ +public: + SwXFlatParagraph( SwTextNode& rTextNode, OUString aExpandText, const ModelToViewHelper& rConversionMap ); + virtual ~SwXFlatParagraph() override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( + const OUString& rPropertyName, + const css::uno::Any& rValue) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& rPropertyName) override; + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + + // text::XTextMarkup: + virtual css::uno::Reference< css::container::XStringKeyMap > SAL_CALL getMarkupInfoContainer() override; + + virtual void SAL_CALL commitStringMarkup(::sal_Int32 nType, const OUString & aIdentifier, ::sal_Int32 nStart, ::sal_Int32 nLength, + const css::uno::Reference< css::container::XStringKeyMap > & xMarkupInfoContainer) override; + + virtual void SAL_CALL commitTextRangeMarkup(::sal_Int32 nType, const OUString & aIdentifier, const css::uno::Reference< css::text::XTextRange> & xRange, + const css::uno::Reference< css::container::XStringKeyMap > & xMarkupInfoContainer) override; + + // text::XFlatParagraph: + virtual OUString SAL_CALL getText() override; + virtual sal_Bool SAL_CALL isModified() override; + virtual void SAL_CALL setChecked(::sal_Int32 nType, sal_Bool bVal) override; + virtual sal_Bool SAL_CALL isChecked(::sal_Int32 nType) override; + virtual css::lang::Locale SAL_CALL getLanguageOfText(::sal_Int32 nPos, ::sal_Int32 nLen) override; + virtual css::lang::Locale SAL_CALL getPrimaryLanguageOfText(::sal_Int32 nPos, ::sal_Int32 nLen) override; + virtual void SAL_CALL changeText(::sal_Int32 nPos, ::sal_Int32 nLen, const OUString & aNewText, const css::uno::Sequence< css::beans::PropertyValue > & aAttributes) override; + virtual void SAL_CALL changeAttributes(::sal_Int32 nPos, ::sal_Int32 nLen, const css::uno::Sequence< css::beans::PropertyValue > & aAttributes) override; + virtual css::uno::Sequence< ::sal_Int32 > SAL_CALL getLanguagePortions() override; + + using SwXTextMarkup::GetTextNode; + +private: + SwXFlatParagraph( const SwXFlatParagraph & ) = delete; + SwXFlatParagraph & operator = ( const SwXFlatParagraph & ) = delete; + + OUString maExpandText; + OUString maOrigText; +}; + +class SwXFlatParagraphIterator final : + public ::cppu::WeakImplHelper + < + css::text::XFlatParagraphIterator + >, + public SvtListener +{ +public: + SwXFlatParagraphIterator( SwDoc& rDoc, sal_Int32 nType, bool bAutomatic ); + virtual ~SwXFlatParagraphIterator() override; + + // text::XFlatParagraphIterator: + virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getFirstPara() override; + virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getNextPara() override; + virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getLastPara() override; + virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getParaBefore(const css::uno::Reference< css::text::XFlatParagraph > & xPara) override; + virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getParaAfter(const css::uno::Reference< css::text::XFlatParagraph > & xPara) override; + + virtual void Notify( const SfxHint& ) override; + +private: + SwXFlatParagraphIterator( const SwXFlatParagraphIterator & ) = delete; + SwXFlatParagraphIterator & operator =(const SwXFlatParagraphIterator & ) = delete; + + SwDoc* mpDoc; + const sal_Int32 mnType; + const bool mbAutomatic; + + SwNodeOffset mnCurrentNode; // used for non-automatic mode + SwNodeOffset mnEndNode; // used for non-automatic mode +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unofldmid.h b/sw/source/core/inc/unofldmid.h new file mode 100644 index 0000000000..8c1838f456 --- /dev/null +++ b/sw/source/core/inc/unofldmid.h @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOFLDMID_H +#define INCLUDED_SW_SOURCE_CORE_INC_UNOFLDMID_H + +// mapping of the properties on the descriptor +#define FIELD_PROP_PAR1 10 +#define FIELD_PROP_PAR2 11 +#define FIELD_PROP_PAR3 12 +#define FIELD_PROP_FORMAT 13 +#define FIELD_PROP_SUBTYPE 14 +#define FIELD_PROP_BOOL1 15 +#define FIELD_PROP_BOOL2 16 +#define FIELD_PROP_DATE 17 +#define FIELD_PROP_USHORT1 18 +#define FIELD_PROP_USHORT2 19 +#define FIELD_PROP_BYTE1 20 +#define FIELD_PROP_DOUBLE 21 +#define FIELD_PROP_BOOL3 22 +#define FIELD_PROP_PAR4 23 +#define FIELD_PROP_SHORT1 24 +#define FIELD_PROP_DATE_TIME 25 +#define FIELD_PROP_PROP_SEQ 26 +#define FIELD_PROP_LOCALE 27 +#define FIELD_PROP_BOOL4 28 +#define FIELD_PROP_STRINGS 29 +#define FIELD_PROP_PAR5 30 +#define FIELD_PROP_GRABBAG 31 + +#define FIELD_PROP_IS_FIELD_USED 32 +#define FIELD_PROP_IS_FIELD_DISPLAYED 33 + +#define FIELD_PROP_TEXT 34 +#define FIELD_PROP_TITLE 35 +#define FIELD_PROP_PAR6 36 +#define FIELD_PROP_PAR7 37 + +#define FIELD_PROP_USHORT3 38 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unofootnote.hxx b/sw/source/core/inc/unofootnote.hxx new file mode 100644 index 0000000000..23f22bee2c --- /dev/null +++ b/sw/source/core/inc/unofootnote.hxx @@ -0,0 +1,136 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOFOOTNOTE_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNOFOOTNOTE_HXX + +#include +#include +#include +#include + +#include + +#include + +class SwDoc; +class SwFormatFootnote; + +typedef ::cppu::WeakImplHelper +< css::lang::XServiceInfo +, css::beans::XPropertySet +, css::container::XEnumerationAccess +, css::text::XFootnote +> SwXFootnote_Base; + +class SwXFootnote final + : public SwXFootnote_Base + , public SwXText +{ + friend class SwXFootnotes; + + class Impl; + ::sw::UnoImplPtr m_pImpl; + + virtual const SwStartNode *GetStartNode() const override; + + virtual ~SwXFootnote() override; + + SwXFootnote(SwDoc & rDoc, SwFormatFootnote & rFormat); + SwXFootnote(const bool bEndnote); + +public: + + static rtl::Reference + CreateXFootnote(SwDoc & rDoc, SwFormatFootnote * pFootnoteFormat, + bool isEndnote = false); + + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( + const css::uno::Type& rType) override; + virtual void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + virtual void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > + SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( + const OUString& rServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() override; + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + virtual void SAL_CALL removeEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( + const OUString& rPropertyName, + const css::uno::Any& rValue) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& rPropertyName) override; + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XTextContent + virtual void SAL_CALL attach( + const css::uno::Reference< css::text::XTextRange > & xTextRange) override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override; + + // XFootnote + virtual OUString SAL_CALL getLabel() override; + virtual void SAL_CALL setLabel(const OUString& rLabel) override; + + // XSimpleText + virtual rtl::Reference< SwXTextCursor > createXTextCursor() override; + virtual rtl::Reference< SwXTextCursor > createXTextCursorByRange( + const ::css::uno::Reference< ::css::text::XTextRange >& aTextPosition ) override; +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNOFOOTNOTE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unoidx.hxx b/sw/source/core/inc/unoidx.hxx new file mode 100644 index 0000000000..30eca1011a --- /dev/null +++ b/sw/source/core/inc/unoidx.hxx @@ -0,0 +1,214 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOIDX_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNOIDX_HXX + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + +class SwDoc; +class SwTOXBaseSection; +class SwTOXMark; +class SwTOXType; + +typedef ::cppu::ImplInheritanceHelper +< ::sfx2::MetadatableMixin +, css::lang::XServiceInfo +, css::beans::XPropertySet +, css::container::XNamed +, css::util::XRefreshable +, css::text::XDocumentIndex +> SwXDocumentIndex_Base; + +class SwXDocumentIndex final + : public SwXDocumentIndex_Base +{ + +private: + + class StyleAccess_Impl; + class TokenAccess_Impl; + + class Impl; + ::sw::UnoImplPtr m_pImpl; + + virtual ~SwXDocumentIndex() override; + + SwXDocumentIndex(SwTOXBaseSection &, SwDoc &); + + /// descriptor + SwXDocumentIndex(const TOXTypes eToxType, SwDoc& rDoc); + +public: + + static rtl::Reference + CreateXDocumentIndex(SwDoc & rDoc, SwTOXBaseSection * pSection, + TOXTypes eTypes = TOX_INDEX); + + // MetadatableMixin + virtual ::sfx2::Metadatable* GetCoreObject() override; + virtual css::uno::Reference< css::frame::XModel > + GetModel() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( + const OUString& rServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() override; + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + virtual void SAL_CALL removeEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( + const OUString& rPropertyName, + const css::uno::Any& rValue) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& rPropertyName) override; + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName(const OUString& rName) override; + + // XRefreshable + virtual void SAL_CALL refresh() override; + virtual void SAL_CALL addRefreshListener( + const css::uno::Reference< css::util::XRefreshListener>& xListener) override; + virtual void SAL_CALL removeRefreshListener( + const css::uno::Reference< css::util::XRefreshListener>& xListener) override; + + // XTextContent + virtual void SAL_CALL attach( + const css::uno::Reference< css::text::XTextRange > & xTextRange) override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override; + + // XDocumentIndex + virtual OUString SAL_CALL getServiceName() override; + virtual void SAL_CALL update() override; + +}; + +typedef ::cppu::WeakImplHelper +< css::lang::XServiceInfo +, css::beans::XPropertySet +, css::text::XDocumentIndexMark +> SwXDocumentIndexMark_Base; + +class SwXDocumentIndexMark final + : public SwXDocumentIndexMark_Base +{ + +private: + + class Impl; + ::sw::UnoImplPtr m_pImpl; + + virtual ~SwXDocumentIndexMark() override; + + SwXDocumentIndexMark(SwDoc & rDoc, + const SwTOXType & rType, const SwTOXMark & rMark); + + /// descriptor + SwXDocumentIndexMark(const TOXTypes eToxType); + +public: + + static rtl::Reference + CreateXDocumentIndexMark(SwDoc & rDoc, + SwTOXMark * pMark, TOXTypes eType = TOX_INDEX); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( + const OUString& rServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() override; + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + virtual void SAL_CALL removeEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( + const OUString& rPropertyName, + const css::uno::Any& rValue) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& rPropertyName) override; + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference& xListener) override; + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + + // XTextContent + virtual void SAL_CALL attach( + const css::uno::Reference< css::text::XTextRange > & xTextRange) override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override; + + // XDocumentIndexMark + virtual OUString SAL_CALL getMarkEntry() override; + virtual void SAL_CALL setMarkEntry(const OUString& rIndexEntry) override; + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unolinebreak.hxx b/sw/source/core/inc/unolinebreak.hxx new file mode 100644 index 0000000000..700f35e3ff --- /dev/null +++ b/sw/source/core/inc/unolinebreak.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOLINEBREAK_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNOLINEBREAK_HXX + +#include +#include +#include +#include + +#include + +class SwDoc; +class SwFormatLineBreak; + +/// UNO API wrapper around an SwFormatLineBreak, exposed as the com.sun.star.text.LineBreak service. +class SwXLineBreak final + : public cppu::WeakImplHelper +{ + class Impl; + ::sw::UnoImplPtr m_pImpl; + + SwXLineBreak(SwFormatLineBreak& rFormat); + SwXLineBreak(); + + ~SwXLineBreak() override; + +public: + static rtl::Reference CreateXLineBreak(SwFormatLineBreak* pLineBreakFormat); + + // XPropertySet + css::uno::Reference SAL_CALL getPropertySetInfo() override; + void SAL_CALL setPropertyValue(const OUString& rPropertyName, + const css::uno::Any& rValue) override; + css::uno::Any SAL_CALL getPropertyValue(const OUString& rPropertyName) override; + void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference& xListener) override; + void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference& xListener) override; + void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference& xListener) override; + void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference& xListener) override; + + // XServiceInfo + OUString SAL_CALL getImplementationName() override; + sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override; + css::uno::Sequence SAL_CALL getSupportedServiceNames() override; + + // XTextContent + void SAL_CALL attach(const css::uno::Reference& xTextRange) override; + css::uno::Reference SAL_CALL getAnchor() override; + + // XComponent, via XTextContent + void SAL_CALL dispose() override; + void SAL_CALL + addEventListener(const css::uno::Reference& xListener) override; + void SAL_CALL + removeEventListener(const css::uno::Reference& xListener) override; +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNOLINEBREAK_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unometa.hxx b/sw/source/core/inc/unometa.hxx new file mode 100644 index 0000000000..c2e4f4c30f --- /dev/null +++ b/sw/source/core/inc/unometa.hxx @@ -0,0 +1,265 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOMETA_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNOMETA_HXX + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +class SwXTextPortion; +class SwPaM; +class SwTextNode; +class SwXText; +namespace sw { + class Meta; +} + +typedef std::deque< + rtl::Reference > + TextRangeList_t; + + + +typedef ::cppu::ImplInheritanceHelper +< ::sfx2::MetadatableMixin +, css::lang::XServiceInfo +, css::container::XChild +, css::container::XEnumerationAccess +, css::text::XTextContent +, css::text::XText +> SwXMeta_Base; + +class SwXMeta + : public SwXMeta_Base +{ + +public: + + class Impl; + +protected: + + ::sw::UnoImplPtr m_pImpl; + + /// @throws css::lang::IllegalArgumentException + /// @throws css::uno::RuntimeException + void AttachImpl( + const css::uno::Reference< css::text::XTextRange > & xTextRange, + const sal_uInt16 nWhich); + + virtual ~SwXMeta() override; + + SwXMeta(SwXMeta const&) = delete; + SwXMeta& operator=(SwXMeta const&) = delete; + + /// @param pDoc and pMeta != 0, but not & because of ImplInheritanceHelper + SwXMeta(SwDoc *const pDoc, ::sw::Meta *const pMeta, + css::uno::Reference const& xParentText, + std::unique_ptr pPortions); + + SwXMeta(SwDoc *const pDoc); + +public: + + static rtl::Reference + CreateXMeta( + ::sw::Meta & rMeta, + css::uno::Reference xParentText, + std::unique_ptr && pPortions); + + static rtl::Reference + CreateXMeta(SwDoc & rDoc, bool isField); + + /// init params with position of the attribute content (w/out CH_TXTATR) + bool SetContentRange( SwTextNode *& rpNode, sal_Int32 & rStart, sal_Int32 & rEnd) const; + css::uno::Reference< SwXText > const & GetParentText() const; + + /// @throws css::lang::IllegalArgumentException + /// @throws css::uno::RuntimeException + bool CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb); + + // MetadatableMixin + virtual ::sfx2::Metadatable * GetCoreObject() override; + virtual css::uno::Reference< css::frame::XModel > + GetModel() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( + const OUString& rServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() override; + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + virtual void SAL_CALL removeEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + + // XChild + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL + getParent() override; + virtual void SAL_CALL setParent( + css::uno::Reference< css::uno::XInterface> const& xParent) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XTextContent + virtual void SAL_CALL attach( + const css::uno::Reference< css::text::XTextRange > & xTextRange) override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override; + + // XTextRange + virtual css::uno::Reference< css::text::XText > + SAL_CALL getText() override; + virtual css::uno::Reference< + css::text::XTextRange > SAL_CALL getStart() override; + virtual css::uno::Reference< + css::text::XTextRange > SAL_CALL getEnd() override; + virtual OUString SAL_CALL getString() override; + virtual void SAL_CALL setString(const OUString& rString) override; + + // XSimpleText + virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL + createTextCursor() override; + virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL + createTextCursorByRange( + const css::uno::Reference< css::text::XTextRange > & xTextPosition) override; + virtual void SAL_CALL insertString( + const css::uno::Reference< css::text::XTextRange > & xRange, + const OUString& aString, sal_Bool bAbsorb) override; + virtual void SAL_CALL insertControlCharacter( + const css::uno::Reference< css::text::XTextRange > & xRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb) override; + + // XText + virtual void SAL_CALL insertTextContent( + const css::uno::Reference< css::text::XTextRange > & xRange, + const css::uno::Reference< css::text::XTextContent > & xContent, + sal_Bool bAbsorb) override; + virtual void SAL_CALL removeTextContent( + const css::uno::Reference< css::text::XTextContent > & xContent) override; + +}; + +typedef ::cppu::ImplInheritanceHelper +< SwXMeta +, css::beans::XPropertySet +, css::text::XTextField +> SwXMetaField_Base; + +class SwXMetaField final + : public SwXMetaField_Base +{ + +private: + + virtual ~SwXMetaField() override; + + friend rtl::Reference + SwXMeta::CreateXMeta(::sw::Meta &, + css::uno::Reference, + std::unique_ptr && pPortions); + + SwXMetaField(SwDoc *const pDoc, ::sw::Meta *const pMeta, + css::uno::Reference const& xParentText, + std::unique_ptr pPortions); + + friend rtl::Reference + SwXMeta::CreateXMeta(SwDoc &, bool); + + SwXMetaField(SwDoc *const pDoc); + +public: + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( + const OUString& ServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames( ) override; + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + virtual void SAL_CALL removeEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( + const OUString& rPropertyName, + const css::uno::Any& rValue) override; + virtual css::uno::Any SAL_CALL + getPropertyValue(const OUString& rPropertyName) override; + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + + // XTextContent + virtual void SAL_CALL attach( + const css::uno::Reference< css::text::XTextRange > & xTextRange) override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override; + + // XTextField + virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override; + +}; + +/// get prefix/suffix from the RDF repository. @throws RuntimeException +void getPrefixAndSuffix( + const css::uno::Reference< css::frame::XModel>& xModel, + const css::uno::Reference< css::rdf::XMetadatable>& xMetaField, + OUString *const o_pPrefix, OUString *const o_pSuffix, OUString *const o_pShadowColor); + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNOMETA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unoparaframeenum.hxx b/sw/source/core/inc/unoparaframeenum.hxx new file mode 100644 index 0000000000..c44e0f660c --- /dev/null +++ b/sw/source/core/inc/unoparaframeenum.hxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOPARAFRAMEENUM_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNOPARAFRAMEENUM_HXX + +#include + +#include +#include + + +class SwNode; +class SwNodeIndex; +class SwPaM; +class SwFrameFormat; + +namespace com { namespace sun { namespace star { namespace text { class XTextContent; } } } } + +namespace sw +{ + struct FrameClient final : public SwClient + { + FrameClient(sw::BroadcastingModify* pModify) : SwClient(pModify) {}; + }; +} +struct FrameClientSortListEntry +{ + sal_Int32 nIndex; + sal_uInt32 nOrder; + std::unique_ptr pFrameClient; + + FrameClientSortListEntry (sal_Int32 const i_nIndex, + sal_uInt32 const i_nOrder, std::unique_ptr i_pClient) + : nIndex(i_nIndex), nOrder(i_nOrder), pFrameClient(std::move(i_pClient)) { } +}; + +typedef std::deque< FrameClientSortListEntry > + FrameClientSortList_t; + +// #i28701# - adjust 4th parameter +void CollectFrameAtNode( const SwNode& rNd, + FrameClientSortList_t& rFrames, + const bool bAtCharAnchoredObjs ); + +enum ParaFrameMode +{ + PARAFRAME_PORTION_PARAGRAPH, + PARAFRAME_PORTION_CHAR, + PARAFRAME_PORTION_TEXTRANGE, +}; + +struct SwXParaFrameEnumeration + : public SwSimpleEnumeration_Base +{ + static rtl::Reference Create(const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat* const pFormat = nullptr); +}; + +css::uno::Reference FrameClientToXTextContent(sw::FrameClient* pClient); + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNOPARAFRAMEENUM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unoport.hxx b/sw/source/core/inc/unoport.hxx new file mode 100644 index 0000000000..d64936a703 --- /dev/null +++ b/sw/source/core/inc/unoport.hxx @@ -0,0 +1,314 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOPORT_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNOPORT_HXX + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::text { class XTextField; } +namespace com::sun::star::text { class XFootnote; } + +class SwFrameFormat; +class SwRangeRedline; +class SwTextRuby; +class SwXText; +class SwXTextPortion; + +typedef std::deque< + rtl::Reference > + TextRangeList_t; + +enum SwTextPortionType +{ + PORTION_TEXT, + PORTION_FIELD, + PORTION_FRAME, + PORTION_FOOTNOTE, + PORTION_REFMARK_START, + PORTION_REFMARK_END, + PORTION_TOXMARK_START, + PORTION_TOXMARK_END, + PORTION_BOOKMARK_START, + PORTION_BOOKMARK_END, + PORTION_REDLINE_START, + PORTION_REDLINE_END, + PORTION_RUBY_START, + PORTION_RUBY_END, + PORTION_SOFT_PAGEBREAK, + PORTION_META, + PORTION_FIELD_START, + PORTION_FIELD_SEP, + PORTION_FIELD_END, + PORTION_FIELD_START_END, + PORTION_ANNOTATION, + PORTION_ANNOTATION_END, + PORTION_LINEBREAK, + PORTION_CONTENT_CONTROL, + PORTION_LIST_AUTOFMT +}; + +class SwXTextPortion : public cppu::WeakImplHelper +< + css::beans::XTolerantMultiPropertySet, + css::beans::XMultiPropertySet, + css::beans::XPropertySet, + css::text::XTextRange, + css::beans::XPropertyState, + css::container::XContentEnumerationAccess, + css::lang::XServiceInfo +>, + public SvtListener +{ +private: + + const SfxItemPropertySet * m_pPropSet; + const css::uno::Reference< css::text::XText > + m_xParentText; + css::uno::Reference< css::text::XTextContent > + m_xRefMark; + css::uno::Reference< css::text::XTextContent > + m_xTOXMark; + css::uno::Reference< css::text::XTextContent > + m_xBookmark; + css::uno::Reference< css::text::XFootnote > + m_xFootnote; + css::uno::Reference< css::text::XTextField > + m_xTextField; + css::uno::Reference< css::text::XTextContent > + m_xMeta; + css::uno::Reference m_xLineBreak; + css::uno::Reference m_xContentControl; + std::optional< css::uno::Any > m_oRubyText; + std::optional< css::uno::Any > m_oRubyStyle; + std::optional< css::uno::Any > m_oRubyAdjust; + std::optional< css::uno::Any > m_oRubyIsAbove; + std::optional< css::uno::Any > m_oRubyPosition; + sw::UnoCursorPointer m_pUnoCursor; + + SwFrameFormat* m_pFrameFormat; + const SwTextPortionType m_ePortionType; + + bool m_bIsCollapsed; + + /// Expose the paragraph's RES_PARATR_LIST_AUTOFMT, not the char props of the underlying (empty) + /// text. + bool m_bIsListAutoFormat; + + void init(const SwUnoCursor* pPortionCursor); + +protected: + /// @throws css::beans::UnknownPropertyException + /// @throws css::beans::PropertyVetoException + /// @throws css::lang::IllegalArgumentException + /// @throws css::lang::WrappedTargetException + /// @throws css::uno::RuntimeException + void SetPropertyValues_Impl( + const css::uno::Sequence< OUString >& aPropertyNames, + const css::uno::Sequence< css::uno::Any >& aValues ); + /// @throws css::beans::UnknownPropertyException + /// @throws css::lang::WrappedTargetException + /// @throws css::uno::RuntimeException + css::uno::Sequence< css::uno::Any > GetPropertyValues_Impl( + const css::uno::Sequence< OUString >& aPropertyNames ); + + void GetPropertyValue( css::uno::Any &rVal, + const SfxItemPropertyMapEntry& rEntry, SwUnoCursor *pUnoCursor, std::unique_ptr &pSet ); + + /// @throws css::uno::RuntimeException + css::uno::Sequence GetPropertyValuesTolerant_Impl( + const css::uno::Sequence< OUString >& rPropertyNames, bool bDirectValuesOnly ); + + virtual ~SwXTextPortion() override; + + virtual void Notify(const SfxHint& rHint) override; + +public: + SwXTextPortion(const SwUnoCursor* pPortionCursor, css::uno::Reference< css::text::XText > xParent, SwTextPortionType eType ); + SwXTextPortion(const SwUnoCursor* pPortionCursor, css::uno::Reference< css::text::XText > xParent, SwFrameFormat& rFormat ); + + // for Ruby + SwXTextPortion(const SwUnoCursor* pPortionCursor, + SwTextRuby const& rAttr, + css::uno::Reference< css::text::XText > xParent, + bool bIsEnd ); + + //XTextRange + virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override; + virtual OUString SAL_CALL getString() override; + virtual void SAL_CALL setString(const OUString& aString) override; + + //XTolerantMultiPropertySet + virtual css::uno::Sequence< css::beans::SetPropertyTolerantFailed > SAL_CALL setPropertyValuesTolerant( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override; + virtual css::uno::Sequence< css::beans::GetPropertyTolerantResult > SAL_CALL getPropertyValuesTolerant( const css::uno::Sequence< OUString >& aPropertyNames ) override; + virtual css::uno::Sequence< css::beans::GetDirectPropertyTolerantResult > SAL_CALL getDirectPropertyValuesTolerant( const css::uno::Sequence< OUString >& aPropertyNames ) override; + + //XMultiPropertySet + virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override; + virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override; + virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override; + virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override; + + //XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + //XPropertyState + virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override; + virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override; + virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override; + virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override; + + //XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + //XContentEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString& aServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override; + + void SetRefMark( css::uno::Reference< css::text::XTextContent > const & xMark) + { m_xRefMark = xMark; } + + void SetTOXMark( css::uno::Reference< css::text::XTextContent > const & xMark) + { m_xTOXMark = xMark; } + + void SetBookmark( css::uno::Reference< css::text::XTextContent > const & xMark) + { m_xBookmark = xMark; } + + void SetFootnote( css::uno::Reference< css::text::XFootnote > const & xNote) + { m_xFootnote = xNote; } + + void SetTextField( css::uno::Reference< css::text::XTextField> const & xField) + { m_xTextField = xField; } + + void SetMeta( css::uno::Reference< css::text::XTextContent > const & xMeta) + { m_xMeta = xMeta; } + + void SetLineBreak(css::uno::Reference const& xLineBreak) + { + m_xLineBreak = xLineBreak; + } + + void SetContentControl(const css::uno::Reference& xContentControl) + { + m_xContentControl = xContentControl; + } + + void SetCollapsed(bool bSet) { m_bIsCollapsed = bSet;} + + SwTextPortionType GetTextPortionType() const { return m_ePortionType; } + + SwUnoCursor& GetCursor() const + { return *m_pUnoCursor; } +}; + +class SwXTextPortionEnumeration final + : public ::cppu::WeakImplHelper + < css::container::XEnumeration + , css::lang::XServiceInfo + > +{ + TextRangeList_t m_Portions; // contains all portions, filled by ctor + sw::UnoCursorPointer m_pUnoCursor; + + virtual ~SwXTextPortionEnumeration() override; + +public: + /// @param bOnlyTextFields tries to return less data, but may return more than just text fields + SwXTextPortionEnumeration(SwPaM& rParaCursor, + css::uno::Reference< SwXText > const & xParent, + const sal_Int32 nStart, const sal_Int32 nEnd, bool bOnlyTextFields = false ); + + SwXTextPortionEnumeration(SwPaM& rParaCursor, + TextRangeList_t && rPortions ); + + //XEnumeration + virtual sal_Bool SAL_CALL hasMoreElements() override; + virtual css::uno::Any SAL_CALL nextElement() override; + + //XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() override; +}; + +class SwXRedlinePortion final : public SwXTextPortion +{ +private: + SwRangeRedline const& m_rRedline; + + bool Validate(); + + using SwXTextPortion::GetPropertyValue; + + virtual ~SwXRedlinePortion() override; + +public: + SwXRedlinePortion( + SwRangeRedline const& rRedline, + SwUnoCursor const* pPortionCursor, + css::uno::Reference< css::text::XText > const& xParent, + bool const bIsStart); + + /// @throws std::exception + static css::uno::Any GetPropertyValue( + std::u16string_view PropertyName, SwRangeRedline const& rRedline); + /// @throws std::exception + static css::uno::Sequence< css::beans::PropertyValue > CreateRedlineProperties( + SwRangeRedline const& rRedline, bool const bIsStart); + + virtual css::uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() override; + + // XPropertySet + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& rPropertyName) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unorefmark.hxx b/sw/source/core/inc/unorefmark.hxx new file mode 100644 index 0000000000..6d5535973c --- /dev/null +++ b/sw/source/core/inc/unorefmark.hxx @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOREFMARK_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNOREFMARK_HXX + +#include +#include +#include +#include + +#include + +#include + +class SwDoc; +class SwFormatRefMark; + +typedef ::cppu::WeakImplHelper +< css::lang::XServiceInfo +, css::beans::XPropertySet +, css::container::XNamed +, css::text::XTextContent +> SwXReferenceMark_Base; + +class SwXReferenceMark final + : public SwXReferenceMark_Base +{ + +private: + + class Impl; + ::sw::UnoImplPtr m_pImpl; + + virtual ~SwXReferenceMark() override; + + SwXReferenceMark(SwDoc *const pDoc, SwFormatRefMark *const pMark); + +public: + + static rtl::Reference + CreateXReferenceMark(SwDoc & rDoc, SwFormatRefMark * pMarkFormat); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( + const OUString& rServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() override; + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + virtual void SAL_CALL removeEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( + const OUString& rPropertyName, + const css::uno::Any& rValue) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& rPropertyName) override; + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName(const OUString& rName) override; + + // XTextContent + virtual void SAL_CALL attach( + const css::uno::Reference< css::text::XTextRange > & xTextRange) override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override; + +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNOREFMARK_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unosection.hxx b/sw/source/core/inc/unosection.hxx new file mode 100644 index 0000000000..7527a2f110 --- /dev/null +++ b/sw/source/core/inc/unosection.hxx @@ -0,0 +1,155 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOSECTION_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNOSECTION_HXX + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +class SwSectionFormat; + +typedef ::cppu::ImplInheritanceHelper +< ::sfx2::MetadatableMixin +, css::lang::XServiceInfo +, css::beans::XPropertySet +, css::beans::XPropertyState +, css::beans::XMultiPropertySet +, css::container::XNamed +, css::text::XTextSection +> SwXTextSection_Base; + +class SwXTextSection final + : public SwXTextSection_Base +{ + +private: + + class Impl; + ::sw::UnoImplPtr m_pImpl; + + SwXTextSection(SwSectionFormat *const pFormat, const bool bIndexHeader); + + virtual ~SwXTextSection() override; + +public: + + SwSectionFormat* GetFormat() const; + + static rtl::Reference< SwXTextSection > + CreateXTextSection(SwSectionFormat *const pFormat, + const bool bIndexHeader = false); + + // MetadatableMixin + virtual ::sfx2::Metadatable* GetCoreObject() override; + virtual css::uno::Reference< css::frame::XModel > + GetModel() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( + const OUString& rServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() override; + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + virtual void SAL_CALL removeEventListener( + const css::uno::Reference< css::lang::XEventListener > & xListener) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( + const OUString& rPropertyName, + const css::uno::Any& rValue) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& rPropertyName) override; + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override; + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override; + + // XPropertyState + virtual css::beans::PropertyState SAL_CALL + getPropertyState(const OUString& rPropertyName) override; + virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL + getPropertyStates( + const css::uno::Sequence< OUString >& rPropertyNames) override; + virtual void SAL_CALL setPropertyToDefault( + const OUString& rPropertyName) override; + virtual css::uno::Any SAL_CALL getPropertyDefault( + const OUString& rPropertyName) override; + + // XMultiPropertySet + virtual void SAL_CALL setPropertyValues( + const css::uno::Sequence< OUString >& rPropertyNames, + const css::uno::Sequence< css::uno::Any >& rValues) override; + virtual css::uno::Sequence< css::uno::Any > + SAL_CALL getPropertyValues( + const css::uno::Sequence< OUString >& rPropertyNames) override; + virtual void SAL_CALL addPropertiesChangeListener( + const css::uno::Sequence< OUString >& rPropertyNames, + const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener) override; + virtual void SAL_CALL removePropertiesChangeListener( + const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener) override; + virtual void SAL_CALL firePropertiesChangeEvent( + const css::uno::Sequence< OUString >& rPropertyNames, + const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener) override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName(const OUString& rName) override; + + // XTextContent + virtual void SAL_CALL attach( + const css::uno::Reference< css::text::XTextRange > & xTextRange) override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override; + + // XTextSection + virtual css::uno::Reference< css::text::XTextSection > SAL_CALL + getParentSection() override; + virtual css::uno::Sequence< css::uno::Reference< css::text::XTextSection > > SAL_CALL + getChildSections() override; + +}; + +#endif // INCLUDED_SW_SOURCE_CORE_INC_UNOSECTION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unotextmarkup.hxx b/sw/source/core/inc/unotextmarkup.hxx new file mode 100644 index 0000000000..4475bafdac --- /dev/null +++ b/sw/source/core/inc/unotextmarkup.hxx @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOTEXTMARKUP_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_UNOTEXTMARKUP_HXX + +#include + +#include +#include + +#include + +#include + +namespace com::sun::star::container { class XStringKeyMap; } +namespace com::sun::star::text { class XTextRange; } +class SwTextNode; +class ModelToViewHelper; + +/** Implementation of the css::text::XTextMarkup interface + */ +class SwXTextMarkup + : public ::cppu::WeakImplHelper + < css::text::XTextMarkup + , css::text::XMultiTextMarkup + > +{ +public: + SwXTextMarkup(SwTextNode *const rTextNode, + const ModelToViewHelper& rConversionMap); + virtual ~SwXTextMarkup() override; + + // css::text::XTextMarkup: + virtual css::uno::Reference< css::container::XStringKeyMap > SAL_CALL getMarkupInfoContainer() override; + + virtual void SAL_CALL commitStringMarkup(::sal_Int32 nType, const OUString & aIdentifier, ::sal_Int32 nStart, ::sal_Int32 nLength, + const css::uno::Reference< css::container::XStringKeyMap > & xMarkupInfoContainer) override; + + virtual void SAL_CALL commitTextRangeMarkup(::sal_Int32 nType, const OUString & aIdentifier, const css::uno::Reference< css::text::XTextRange> & xRange, + const css::uno::Reference< css::container::XStringKeyMap > & xMarkupInfoContainer) override; + + // css::text::XMultiTextMarkup: + virtual void SAL_CALL commitMultiTextMarkup( const css::uno::Sequence< css::text::TextMarkupDescriptor >& aMarkups ) override; + +private: + SwXTextMarkup( const SwXTextMarkup & ) = delete; + SwXTextMarkup & operator =( const SwXTextMarkup & ) = delete; + + struct Impl; + ::sw::UnoImplPtr m_pImpl; + +protected: + SwTextNode* GetTextNode(); + void ClearTextNode(); + const ModelToViewHelper& GetConversionMap() const; +}; + +/** Implementation of the css::container::XStringKeyMap interface + */ +class SwXStringKeyMap final : + public ::cppu::WeakImplHelper< + css::container::XStringKeyMap> +{ +public: + SwXStringKeyMap(); + + // css::container::XStringKeyMap: + virtual css::uno::Any SAL_CALL getValue(const OUString & aKey) override; + virtual sal_Bool SAL_CALL hasValue(const OUString & aKey) override; + virtual void SAL_CALL insertValue(const OUString & aKey, const css::uno::Any & aValue) override; + virtual ::sal_Int32 SAL_CALL getCount() override; + virtual OUString SAL_CALL getKeyByIndex(::sal_Int32 nIndex) override; + virtual css::uno::Any SAL_CALL getValueByIndex(::sal_Int32 nIndex) override; + +private: + SwXStringKeyMap(SwXStringKeyMap const &) = delete; + void operator =(SwXStringKeyMap const &) = delete; + + virtual ~SwXStringKeyMap() override {} + + std::map< OUString, css::uno::Any > maMap; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/viewimp.hxx b/sw/source/core/inc/viewimp.hxx new file mode 100644 index 0000000000..4b249154c2 --- /dev/null +++ b/sw/source/core/inc/viewimp.hxx @@ -0,0 +1,317 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_VIEWIMP_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_VIEWIMP_HXX + +#include +#include +#include +#include +#include +#include +#include + +class OutputDevice; +class SwViewShell; +class SwFlyFrame; +class SwViewOption; +class SwFrame; +class SwLayAction; +class SwLayIdle; +class SwDrawView; +class SdrPageView; +class SwPageFrame; +class SwAccessibleMap; +class SdrObject; +class Fraction; +class SwPrintData; +class SwPagePreviewLayout; +struct PreviewPage; +class SwTextFrame; +// --> OD #i76669# +namespace sdr::contact { class ViewObjectContactRedirector; } +// <-- + +class SwViewShellImp +{ + friend class SwViewShell; + + friend class SwLayAction; // Lay- and IdleAction register and deregister + friend class SwLayIdle; + + // for paint of page preview + friend class SwPagePreviewLayout; + + SwViewShell *m_pShell; // If someone passes an Imp, but needs a SwViewShell, we + // keep a backlink here + + std::unique_ptr m_pDrawView; // Our DrawView + SdrPageView *m_pSdrPageView; // Exactly one Page for our DrawView + + SwPageFrame *m_pFirstVisiblePage; // Always points to the first visible Page + std::optional m_oPaintRegion; // Collector of Paintrects from the LayAction + + std::vector m_pendingLOKInvalidations; + + SwLayAction *m_pLayAction; // Is set if an Action object exists + // Is registered by the SwLayAction ctor and deregistered by the dtor + SwLayIdle *m_pIdleAct; // The same as SwLayAction for SwLayIdle + + /// note: the map is *uniquely* owned here - the shared_ptr is only + /// used so that SwAccessibleContext can check via weak_ptr that it's alive + std::shared_ptr m_pAccessibleMap; + + bool m_bFirstPageInvalid : 1; // Pointer to the first Page invalid? + bool m_bResetHdlHiddenPaint : 1; // Ditto + bool m_bSmoothUpdate : 1; // For SmoothScroll + bool m_bStopSmooth : 1; + + sal_uInt16 m_nRestoreActions ; // Count for the Action that need to be restored (UNO) + SwRect m_aSmoothRect; + + std::unique_ptr m_pPagePreviewLayout; + + void SetFirstVisPage(OutputDevice const * pRenderContext); // Recalculate the first visible Page + + void StartAction(); // Show handle and hide + void EndAction(); // Called by SwViewShell::ImplXXXAction + void LockPaint(); // Ditto; called by SwViewShell::ImplLockPaint + void UnlockPaint(); + +private: + + SwAccessibleMap *CreateAccessibleMap(); + + /** invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs + + #i27138# + implementation for wrapper method + + + @param _pFromTextFrame + input parameter - paragraph frame, for which the relation CONTENT_FLOWS_FROM + has to be invalidated. + If NULL, no CONTENT_FLOWS_FROM relation has to be invalidated + + @param _pToTextFrame + input parameter - paragraph frame, for which the relation CONTENT_FLOWS_TO + has to be invalidated. + If NULL, no CONTENT_FLOWS_TO relation has to be invalidated + */ + void InvalidateAccessibleParaFlowRelation_( const SwTextFrame* _pFromTextFrame, + const SwTextFrame* _pToTextFrame ); + + /** invalidate text selection for paragraphs + + #i27301# + implementation for wrapper method + + */ + void InvalidateAccessibleParaTextSelection_(); + + /** invalidate attributes for paragraphs and paragraph's characters + + #i88069# + implementation for wrapper method + + */ + void InvalidateAccessibleParaAttrs_( const SwTextFrame& rTextFrame ); + +public: + SwViewShellImp( SwViewShell * ); + ~SwViewShellImp(); + void Init( const SwViewOption * ); /// Only for SwViewShell::Init() + + const SwViewShell *GetShell() const { return m_pShell; } + SwViewShell *GetShell() { return m_pShell; } + + Color GetRetoucheColor() const; + + /// Management of the first visible Page + const SwPageFrame *GetFirstVisPage(OutputDevice const * pRenderContext) const; + SwPageFrame *GetFirstVisPage(OutputDevice const * pRenderContext); + void SetFirstVisPageInvalid() { m_bFirstPageInvalid = true; } + + const SwPageFrame* GetLastVisPage(const OutputDevice* pRenderContext) const; + + bool AddPaintRect( const SwRect &rRect ); + bool HasPaintRegion() { return m_oPaintRegion.has_value(); } + std::optional TakePaintRegion() { auto ret = std::move(m_oPaintRegion); m_oPaintRegion.reset(); return ret; } + const std::optional& GetPaintRegion() { return m_oPaintRegion; } + void DeletePaintRegion() { m_oPaintRegion.reset(); } + + void AddPendingLOKInvalidation( const SwRect& rRect ); + std::vector TakePendingLOKInvalidations(); + + /// New Interface for StarView Drawing + bool HasDrawView() const { return nullptr != m_pDrawView; } + SwDrawView* GetDrawView() { return m_pDrawView.get(); } + const SwDrawView* GetDrawView() const { return m_pDrawView.get(); } + SdrPageView*GetPageView() { return m_pSdrPageView; } + const SdrPageView*GetPageView() const { return m_pSdrPageView; } + void MakeDrawView(); + + /** + * @param _pPageBackgrdColor for setting this color as the background color + * at the outliner of the draw view for painting layers "hell" and "heaven" + * + * @param _bIsPageRightToLeft for the horizontal text direction of the page + * in order to set the default horizontal text direction at the outliner of + * the draw view for painting layers "hell" and "heaven" + */ + void PaintLayer( const SdrLayerID _nLayerID, + SwPrintData const*const pPrintData, + SwPageFrame const& rPageFrame, + const SwRect& _rRect, + const Color* _pPageBackgrdColor, + const bool _bIsPageRightToLeft, + sdr::contact::ViewObjectContactRedirector* pRedirector ); + + /** + * Is passed to the DrawEngine as a Link and decides what is painted + * or not and in what way + */ + + // Interface Drawing + bool IsDragPossible( const Point &rPoint ); + void NotifySizeChg( const Size &rNewSz ); + + /// SS for the Lay-/IdleAction and relatives + bool IsAction() const { return m_pLayAction != nullptr; } + bool IsIdleAction() const { return m_pIdleAct != nullptr; } + SwLayAction &GetLayAction() { return *m_pLayAction; } + const SwLayAction &GetLayAction() const { return *m_pLayAction; } + + /** + * If an Action is running we ask it to check whether it's time + * to enable the WaitCursor + */ + void CheckWaitCursor(); + + /// Asks the LayAction if present + bool IsCalcLayoutProgress() const; + + /** + * @returns true if a LayAction is running + * + * There we also set the Flag for ExpressionFields + */ + bool IsUpdateExpFields(); + + void SetRestoreActions(sal_uInt16 nSet){m_nRestoreActions = nSet;} + sal_uInt16 GetRestoreActions() const{return m_nRestoreActions;} + + void InitPagePreviewLayout(); + + SwPagePreviewLayout* PagePreviewLayout() + { + return m_pPagePreviewLayout.get(); + } + + /// Is this view accessible? + bool IsAccessible() const { return m_pAccessibleMap != nullptr; } + + inline SwAccessibleMap& GetAccessibleMap(); + + /// Update (this) accessible view + void UpdateAccessible(); + + /// Remove a frame from the accessible view + void DisposeAccessible( const SwFrame *pFrame, const SdrObject *pObj, + bool bRecursive, bool bCanSkipInvisible ); + inline void DisposeAccessibleFrame( const SwFrame *pFrame, + bool bRecursive = false ); + inline void DisposeAccessibleObj( const SdrObject *pObj, bool bCanSkipInvisible ); + + /// Move a frame's position in the accessible view + void MoveAccessible( const SwFrame *pFrame, const SdrObject *pObj, + const SwRect& rOldFrame ); + inline void MoveAccessibleFrame( const SwFrame *pFrame, const SwRect& rOldFrame ); + + /// Add a frame in the accessible view + inline void AddAccessibleFrame( const SwFrame *pFrame ); + + inline void AddAccessibleObj( const SdrObject *pObj ); + + /// Invalidate accessible frame's content + void InvalidateAccessibleFrameContent( const SwFrame *pFrame ); + + /// Invalidate accessible frame's cursor position + void InvalidateAccessibleCursorPosition( const SwFrame *pFrame ); + + /// Invalidate editable state for all accessible frames + void InvalidateAccessibleEditableState( bool bAllShells, + const SwFrame *pFrame=nullptr ); + + /// Invalidate frame's relation set (for chained frames) + void InvalidateAccessibleRelationSet( const SwFlyFrame *pMaster, + const SwFlyFrame *pFollow ); + + /// update data for accessible preview + /// change method signature due to new page preview functionality + void UpdateAccessiblePreview( const std::vector>& _rPreviewPages, + const Fraction& _rScale, + const SwPageFrame* _pSelectedPageFrame, + const Size& _rPreviewWinSize ); + + void InvalidateAccessiblePreviewSelection( sal_uInt16 nSelPage ); + + /// Fire all accessible events that have been collected so far + void FireAccessibleEvents(); +}; + +inline SwAccessibleMap& SwViewShellImp::GetAccessibleMap() +{ + if( !m_pAccessibleMap ) + CreateAccessibleMap(); + + return *m_pAccessibleMap; +} + +inline void SwViewShellImp::DisposeAccessibleFrame( const SwFrame *pFrame, + bool bRecursive ) +{ + DisposeAccessible( pFrame, nullptr, bRecursive, true ); +} + +inline void SwViewShellImp::DisposeAccessibleObj( const SdrObject *pObj, bool bCanSkipInvisible ) +{ + DisposeAccessible( nullptr, pObj, false, bCanSkipInvisible ); +} + +inline void SwViewShellImp::MoveAccessibleFrame( const SwFrame *pFrame, + const SwRect& rOldFrame ) +{ + MoveAccessible( pFrame, nullptr, rOldFrame ); +} + +inline void SwViewShellImp::AddAccessibleFrame( const SwFrame *pFrame ) +{ + SwRect aEmptyRect; + MoveAccessible( pFrame, nullptr, aEmptyRect ); +} + +inline void SwViewShellImp::AddAccessibleObj( const SdrObject *pObj ) +{ + SwRect aEmptyRect; + MoveAccessible( nullptr, pObj, aEmptyRect ); +} +#endif // INCLUDED_SW_SOURCE_CORE_INC_VIEWIMP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/visiturl.hxx b/sw/source/core/inc/visiturl.hxx new file mode 100644 index 0000000000..f273f33bb7 --- /dev/null +++ b/sw/source/core/inc/visiturl.hxx @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_VISITURL_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_VISITURL_HXX + +#include + +class SwDoc; + +class SwURLStateChanged final : public SfxListener +{ + SwDoc& m_rDoc; + +public: + SwURLStateChanged(SwDoc& rD); + virtual ~SwURLStateChanged() override; + + virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/vprint.hxx b/sw/source/core/inc/vprint.hxx new file mode 100644 index 0000000000..9d2c7fe372 --- /dev/null +++ b/sw/source/core/inc/vprint.hxx @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include + +class SwRootFrame; +class SwPageFrame; +class SwPrintData; + +SwPageFrame const* sw_getPage(SwRootFrame const& rLayout, sal_Int32 const nPage); + +namespace sw +{ +bool IsShrinkPageForPostIts(SwViewShell const& rShell, SwPrintData const&); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/wrong.hxx b/sw/source/core/inc/wrong.hxx new file mode 100644 index 0000000000..d4bef9d26d --- /dev/null +++ b/sw/source/core/inc/wrong.hxx @@ -0,0 +1,413 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_WRONG_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_WRONG_HXX + +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include "TextFrameIndex.hxx" + +#if defined _MSC_VER +// For MSVC (without /vmg) SwTextNode must consistently be defined for +// WrongListIterator::m_pGetWrongList of pointer-to-SwTextNode-member type to consistently have the +// same size in all translation units that include this file: +#include +#endif + +class SwWrongList; + +enum WrongAreaLineType +{ + WRONGAREA_NONE, + WRONGAREA_WAVE, + WRONGAREA_BOLDWAVE, + WRONGAREA_BOLD, + WRONGAREA_DASHED +}; + +enum WrongListType +{ + WRONGLIST_SPELL, + WRONGLIST_GRAMMAR, + WRONGLIST_SMARTTAG, + WRONGLIST_CHANGETRACKING +}; + +// ST2 +class SwWrongArea +{ +public: + OUString maType; + css::uno::Reference< css::container::XStringKeyMap > mxPropertyBag; + sal_Int32 mnPos; + sal_Int32 mnLen; + SwWrongList* mpSubList; + + Color mColor; + WrongAreaLineType mLineType; + + SwWrongArea( OUString aType, + WrongListType listType, + css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag, + sal_Int32 nPos, + sal_Int32 nLen); + + SwWrongArea( OUString aType, + css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag, + sal_Int32 nPos, + sal_Int32 nLen, + SwWrongList* pSubList); +private: + + static Color getGrammarColor ( css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag) + { + try + { + if (xPropertyBag.is()) + { + css::uno::Any aLineColor = xPropertyBag->getValue("LineColor"); + ::Color lineColor; + + if (aLineColor >>= lineColor) + { + return lineColor; + } + } + } + catch(const css::container::NoSuchElementException&) + { + } + catch(const css::uno::RuntimeException&) + { + } + + return SwViewOption::GetCurrentViewOptions().GetGrammarColor(); + } + + static WrongAreaLineType getGrammarLineType( css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag ) + { + try + { + if (xPropertyBag.is()) + { + css::uno::Any aLineType = xPropertyBag->getValue("LineType"); + ::sal_Int16 lineType = 0; + + if (!(aLineType >>= lineType)) + { + return WRONGAREA_WAVE; + } + if (css::awt::FontUnderline::BOLDWAVE == lineType) + { + return WRONGAREA_BOLDWAVE; + } + if (css::awt::FontUnderline::BOLD == lineType) + { + return WRONGAREA_BOLD; + } + if (css::awt::FontUnderline::DASH == lineType) + { + return WRONGAREA_DASHED; + } + if (css::awt::FontUnderline::SMALLWAVE == lineType) + { + return WRONGAREA_WAVE; //Code draws wave height based on space that fits. + } + } + } + catch(const css::container::NoSuchElementException&) + { + } + catch(const css::uno::RuntimeException&) + { + } + + return WRONGAREA_WAVE; + } + + static Color getSmartColor ( css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag) + { + try + { + if (xPropertyBag.is()) + { + css::uno::Any aLineColor = xPropertyBag->getValue("LineColor"); + ::Color lineColor; + + if (aLineColor >>= lineColor) + { + return lineColor; + } + } + } + catch(const css::container::NoSuchElementException&) + { + } + catch(const css::uno::RuntimeException&) + { + } + + return SwViewOption::GetCurrentViewOptions().GetSmarttagColor(); + } + + static WrongAreaLineType getSmartLineType( css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag ) + { + try + { + if (xPropertyBag.is()) + { + css::uno::Any aLineType = xPropertyBag->getValue("LineType"); + ::sal_Int16 lineType = 0; + + if (!(aLineType >>= lineType)) + { + return WRONGAREA_DASHED; + } + if (css::awt::FontUnderline::WAVE == lineType) + { + return WRONGAREA_WAVE; + } + if (css::awt::FontUnderline::BOLDWAVE == lineType) + { + return WRONGAREA_BOLDWAVE; + } + if (css::awt::FontUnderline::BOLD == lineType) + { + return WRONGAREA_BOLD; + } + if (css::awt::FontUnderline::SMALLWAVE == lineType) + { + return WRONGAREA_WAVE; //Code draws wave height based on space that fits. + } + } + } + catch(const css::container::NoSuchElementException&) + { + } + catch(const css::uno::RuntimeException&) + { + } + + return WRONGAREA_DASHED; + } + + static Color getWrongAreaColor(WrongListType listType, + css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag ) + { + if (WRONGLIST_SPELL == listType) + { + return SwViewOption::GetCurrentViewOptions().GetSpellColor(); + } + else if (WRONGLIST_GRAMMAR == listType) + { + return getGrammarColor(xPropertyBag); + } + else if (WRONGLIST_SMARTTAG == listType) + { + return getSmartColor(xPropertyBag); + } + + return SwViewOption::GetCurrentViewOptions().GetSpellColor(); + } + + static WrongAreaLineType getWrongAreaLineType(WrongListType listType, + css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag ) + { + if (WRONGLIST_SPELL == listType) + { + return WRONGAREA_WAVE; + } + else if (WRONGLIST_GRAMMAR == listType) + { + return getGrammarLineType(xPropertyBag); + } + else if (WRONGLIST_SMARTTAG == listType) + { + return getSmartLineType(xPropertyBag); + } + + return WRONGAREA_WAVE; + } + +}; + +class SAL_DLLPUBLIC_RTTI SwWrongList +{ + std::vector maList; + WrongListType meType; + + sal_Int32 mnBeginInvalid; // Start of the invalid range + sal_Int32 mnEndInvalid; // End of the invalid range + + static void ShiftLeft( sal_Int32 &rPos, sal_Int32 nStart, sal_Int32 nEnd ) + { if( rPos > nStart ) rPos = rPos > nEnd ? rPos - nEnd + nStart : nStart; } + void Invalidate_( sal_Int32 nBegin, sal_Int32 nEnd ); + + void Insert(sal_uInt16 nWhere, std::vector::iterator startPos, std::vector::iterator const & endPos); + void Remove( sal_uInt16 nIdx, sal_uInt16 nLen ); + + SwWrongList& operator= (const SwWrongList &) = delete; + SwWrongList( const SwWrongList& rCpy ) = delete; + +public: + SwWrongList( WrongListType eType ); + + virtual ~SwWrongList(); + virtual SwWrongList* Clone(); + virtual void CopyFrom( const SwWrongList& rCopy ); + + WrongListType GetWrongListType() const { return meType; } + sal_Int32 GetBeginInv() const { return mnBeginInvalid; } + sal_Int32 GetEndInv() const { return mnEndInvalid; } + void SetInvalid( sal_Int32 nBegin, sal_Int32 nEnd ); + void Validate(){ mnBeginInvalid = mnEndInvalid = COMPLETE_STRING; } + void Invalidate( sal_Int32 nBegin, sal_Int32 nEnd ); + bool InvalidateWrong(); + enum class FreshState { FRESH, CURSOR, NOTHING }; + FreshState Fresh( sal_Int32 &rStart, sal_Int32 &rEnd, sal_Int32 nPos, + sal_Int32 nLen, sal_uInt16 nIndex, sal_Int32 nCursorPos ); + sal_uInt16 GetWrongPos( sal_Int32 nValue ) const; + + bool Check( sal_Int32 &rChk, sal_Int32 &rLn ) const; + bool InWrongWord( sal_Int32 &rChk, sal_Int32 &rLn ) const; + sal_Int32 NextWrong( sal_Int32 nChk ) const; + + void Move( sal_Int32 nPos, sal_Int32 nDiff ); + void ClearList(); + + // Divide the list into two part, the wrong words until nSplitPos will be + // removed and transferred to a new SwWrongList. + std::unique_ptr SplitList( sal_Int32 nSplitPos ); + // Join the next SwWrongList, nInsertPos is my own text length, where + // the other wrong list has to be inserted. + void JoinList( SwWrongList* pNext, sal_Int32 nInsertPos ); + + sal_Int32 Len( sal_uInt16 nIdx ) const + { + return nIdx < maList.size() ? maList[nIdx].mnLen : 0; + } + + sal_Int32 Pos( sal_uInt16 nIdx ) const + { + return nIdx < maList.size() ? maList[nIdx].mnPos : 0; + } + + sal_uInt16 Count() const { return o3tl::narrowing(maList.size()); } + + void Insert( const OUString& rType, + css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag, + sal_Int32 nNewPos, sal_Int32 nNewLen, sal_uInt16 nWhere ) + { + std::vector::iterator i = maList.begin(); + if ( nWhere >= maList.size() ) + i = maList.end(); // robust + else + i += nWhere; + + maList.insert(i, SwWrongArea( rType, meType, xPropertyBag, nNewPos, nNewLen) ); + } + + void Insert( const OUString& rType, + css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag, + sal_Int32 nNewPos, sal_Int32 nNewLen ); + + SwWrongList* SubList( sal_uInt16 nIdx ) const + { + return nIdx < maList.size() ? maList[nIdx].mpSubList : nullptr; + } + + void InsertSubList( sal_Int32 nNewPos, sal_Int32 nNewLen, sal_uInt16 nWhere, SwWrongList* pSubList ); + + const SwWrongArea* GetElement( sal_uInt16 nIdx ) const + { + return nIdx < maList.size() ? &maList[nIdx] : nullptr; + } + void RemoveEntry( sal_Int32 nBegin, sal_Int32 nEnd ); + bool LookForEntry( sal_Int32 nBegin, sal_Int32 nEnd ); +}; + +class SwTextNode; +class SwTextFrame; + +namespace sw { + +struct MergedPara; + +class WrongListIteratorBase +{ +protected: + SwWrongList const* (SwTextNode::*const m_pGetWrongList)() const; + sw::MergedPara const*const m_pMergedPara; + size_t m_CurrentExtent; + TextFrameIndex m_CurrentIndex; + SwWrongList const*const m_pWrongList; + +public: + /// for the text frame + WrongListIteratorBase(SwTextFrame const& rFrame, + SwWrongList const* (SwTextNode::*pGetWrongList)() const); + /// for SwTextSlot + WrongListIteratorBase(SwWrongList const& rWrongList); +}; + +class WrongListIterator + : public WrongListIteratorBase +{ +public: + /// for the text frame + WrongListIterator(SwTextFrame const& rFrame, + SwWrongList const* (SwTextNode::*pGetWrongList)() const); + /// for SwTextSlot + WrongListIterator(SwWrongList const& rWrongList); + + bool Check(TextFrameIndex &rStart, TextFrameIndex &rLen); + const SwWrongArea* GetWrongElement(TextFrameIndex nStart); + + bool LooksUseful() { return m_pMergedPara || m_pWrongList; } +}; + +class WrongListIteratorCounter + : public WrongListIteratorBase +{ +public: + WrongListIteratorCounter(SwTextFrame const& rFrame, + SwWrongList const* (SwTextNode::*pGetWrongList)() const); + WrongListIteratorCounter(SwWrongList const& rWrongList); + + sal_uInt16 GetElementCount(); + std::optional> GetElementAt(sal_uInt16 nIndex); +}; + +} // namespace sw + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3