LOCRDT fix conditional compilation

Add a config header for this, and split yrs.hxx in two because the
actual libyrs.h is only needed in 2 files.

Change-Id: I30453fda3082f977e328ed56a4a101743ecdd586
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185329
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
This commit is contained in:
Michael Stahl
2025-05-15 09:24:48 +02:00
parent 55f087b48b
commit 55793ae8c8
32 changed files with 177 additions and 140 deletions
-1
View File
@@ -4468,7 +4468,6 @@ $(call gb_LinkTarget_set_include,$(1),\
$$(INCLUDE) \
-I$(WITH_YRS)/tests-ffi/include \
)
$(call gb_LinkTarget_add_defs,$(1),-DYRS)
$(call gb_LinkTarget_add_libs,$(1),$(WITH_YRS)/target/debug/libyrs.a)
endef
+11
View File
@@ -0,0 +1,11 @@
#pragma once
/* Collaboration stuff
*
* Currently only experimental YRS
*/
#define ENABLE_YRS 0
#define ENABLE_YRS_WEAK 0
+5 -1
View File
@@ -2843,7 +2843,10 @@ AC_ARG_WITH(hamcrest,
AC_ARG_WITH(yrs,
AS_HELP_STRING([--with-yrs=<absolute path to yrs build>],
[Specifies the built yrs git repo for very experimental experiments.]),
WITH_YRS=$withval)
WITH_YRS=$withval
if test "x$withval" != "xno"; then
AC_DEFINE(ENABLE_YRS)
fi)
AC_SUBST(WITH_YRS)
AC_ARG_WITH(perl-home,
@@ -16064,6 +16067,7 @@ AC_CONFIG_HEADERS([config_host/config_eot.h])
AC_CONFIG_HEADERS([config_host/config_extensions.h])
AC_CONFIG_HEADERS([config_host/config_cairo_canvas.h])
AC_CONFIG_HEADERS([config_host/config_cairo_rgba.h])
AC_CONFIG_HEADERS([config_host/config_collab.h])
AC_CONFIG_HEADERS([config_host/config_cxxabi.h])
AC_CONFIG_HEADERS([config_host/config_dbus.h])
AC_CONFIG_HEADERS([config_host/config_emscripten.h])
+4 -2
View File
@@ -19,6 +19,8 @@
#pragma once
#include <config_collab.h>
#include "ParagraphPortionList.hxx"
#include "editattr.hxx"
#include "edtspell.hxx"
@@ -46,7 +48,7 @@
enum class TextRotation;
#if defined(YRS)
#if ENABLE_YRS
class ImpEditEngine;
class IYrsTransactionSupplier;
typedef struct TransactionInner YTransaction;
@@ -128,7 +130,7 @@ private:
bool mbModified:1;
bool mbDisableAttributeExpanding:1;
#if defined(YRS)
#if ENABLE_YRS
OString m_CommentId;
IYrsTransactionSupplier * m_pYrsSupplier{nullptr};
public:
+36 -34
View File
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <editdoc.hxx>
#include <editeng/tstpitem.hxx>
#include <editeng/colritem.hxx>
#include <editeng/fontitem.hxx>
@@ -42,7 +44,7 @@
#include <editeng/lrspitem.hxx>
#include <editeng/ulspitem.hxx>
#include <editeng/lspcitem.hxx>
#if defined(YRS)
#if ENABLE_YRS
#include <editeng/frmdiritem.hxx>
#include <editeng/hngpnctitem.hxx>
#include <editeng/forbiddenruleitem.hxx>
@@ -53,7 +55,6 @@
#include <svl/itemiter.hxx>
#endif
#include <editdoc.hxx>
#include <editeng/eerdll.hxx>
#include <eerdll2.hxx>
#include "impedit.hxx"
@@ -724,7 +725,8 @@ void EditSelection::Adjust( const EditDoc& rNodes )
}
}
#if defined(YRS)
#if ENABLE_YRS
#include <editeng/yrstransactionsupplier.hxx>
#include <editeng/yrs.hxx>
namespace {
@@ -2774,7 +2776,7 @@ bool EditDoc::YrsWriteEECursor(YTransaction *const pTxn, Branch const& rArray,
::std::optional<::std::pair<int64_t, int64_t>> const i_oMark)
{
::std::optional<EditPaM> oMark;
#if defined(YRS_WEAK)
#if ENABLE_YRS_WEAK
auto start{i_point.first}; // returned from yweak_read(), need to convert
ContentNode * pNode{nullptr};
for (decltype(Count()) i = 0; i < Count(); ++i)
@@ -3145,7 +3147,7 @@ EditDoc::EditDoc( SfxItemPool* pPool ) :
mbModified(false),
mbDisableAttributeExpanding(false)
{
#if defined(YRS)
#if ENABLE_YRS
SAL_INFO("editeng.yrs", "YRS +EditDoc");
#endif
// Don't create an empty node, Clear() will be called in EditEngine-CTOR
@@ -3153,7 +3155,7 @@ EditDoc::EditDoc( SfxItemPool* pPool ) :
EditDoc::~EditDoc()
{
#if defined(YRS)
#if ENABLE_YRS
SAL_INFO("editeng.yrs", "YRS -EditDoc");
#endif
maContents.clear();
@@ -3164,7 +3166,7 @@ EditDoc::~EditDoc()
void EditDoc::SetVertical(bool const bVertical)
{
mbIsVertical = bVertical;
#if defined(YRS)
#if ENABLE_YRS
YrsSetVertical(m_pYrsSupplier, m_CommentId, mbIsVertical);
#endif
}
@@ -3172,7 +3174,7 @@ void EditDoc::SetVertical(bool const bVertical)
void EditDoc::SetRotation(TextRotation const nRotation)
{
mnRotation = nRotation;
#if defined(YRS)
#if ENABLE_YRS
YrsSetRotation(m_pYrsSupplier, m_CommentId, mnRotation);
#endif
}
@@ -3180,7 +3182,7 @@ void EditDoc::SetRotation(TextRotation const nRotation)
void EditDoc::SetDefTab(sal_uInt16 const nTab)
{
mnDefTab = nTab ? nTab : DEFTAB;
#if defined(YRS)
#if ENABLE_YRS
YrsSetDefTab(m_pYrsSupplier, m_CommentId, mnDefTab);
#endif
}
@@ -3319,7 +3321,7 @@ void EditDoc::Insert(sal_Int32 nPos, std::unique_ptr<ContentNode> pNode)
return;
}
maContents.insert(maContents.begin()+nPos, std::move(pNode));
#if defined(YRS)
#if ENABLE_YRS
YrsAddPara(m_pYrsSupplier, m_CommentId, *this, nPos);
#endif
}
@@ -3331,7 +3333,7 @@ void EditDoc::Remove(sal_Int32 nPos)
SAL_WARN( "editeng", "EditDoc::Remove - out of bounds pos " << nPos);
return;
}
#if defined(YRS)
#if ENABLE_YRS
YrsRemovePara(m_pYrsSupplier, m_CommentId, *this, nPos);
#endif
maContents.erase(maContents.begin() + nPos);
@@ -3345,7 +3347,7 @@ std::unique_ptr<ContentNode> EditDoc::Release(sal_Int32 nPos)
return nullptr;
}
#if defined(YRS)
#if ENABLE_YRS
YrsRemovePara(m_pYrsSupplier, m_CommentId, *this, nPos);
#endif
std::unique_ptr<ContentNode> pNode = std::move(maContents[nPos]);
@@ -3434,7 +3436,7 @@ EditPaM EditDoc::Clear()
{
maContents.clear();
#if defined(YRS)
#if ENABLE_YRS
// Insert will call YrsAddPara()
YrsClear(m_pYrsSupplier, m_CommentId);
#endif
@@ -3482,7 +3484,7 @@ EditPaM EditDoc::RemoveText()
maContents.clear();
#if defined(YRS)
#if ENABLE_YRS
// Insert will call YrsAddPara()
YrsClear(m_pYrsSupplier, m_CommentId);
#endif
@@ -3513,7 +3515,7 @@ EditPaM EditDoc::InsertText( EditPaM aPaM, const OUString& rStr )
SetModified( true );
#if defined(YRS)
#if ENABLE_YRS
YrsInsertText(m_pYrsSupplier, m_CommentId, *this, GetPos(aPaM.GetNode()), aPaM.GetIndex() - rStr.getLength(), rStr);
#endif
@@ -3554,19 +3556,19 @@ EditPaM EditDoc::InsertParaBreak( EditPaM aPaM, bool bKeepEndingAttribs )
// Character attributes may need to be copied or trimmed:
pNode->CopyAndCutAttribs( aPaM.GetNode(), GetItemPool(), bKeepEndingAttribs );
#if defined(YRS)
#if ENABLE_YRS
{
// skip the YrsAddPara in Insert
YrsReplayGuard const g{m_pYrsSupplier};
#endif
Insert(nPos+1, std::unique_ptr<ContentNode>(pNode));
#if defined(YRS)
#if ENABLE_YRS
}
#endif
SetModified(true);
#if defined(YRS)
#if ENABLE_YRS
YrsInsertParaBreak(m_pYrsSupplier, m_CommentId, *this, nPos, aPaM.GetIndex());
#endif
@@ -3589,7 +3591,7 @@ EditPaM EditDoc::InsertFeature( EditPaM aPaM, const SfxPoolItem& rItem )
SetModified( true );
#if defined(YRS)
#if ENABLE_YRS
YrsInsertFeature(m_pYrsSupplier, m_CommentId, *this, GetPos(aPaM.GetNode()), pAttrib);
#endif
@@ -3608,19 +3610,19 @@ EditPaM EditDoc::ConnectParagraphs( ContentNode* pLeft, ContentNode* pRight )
// the one to the right disappears.
sal_Int32 nRight = GetPos( pRight );
#if defined(YRS)
#if ENABLE_YRS
{
// skip the YrsRemovePara in Remove, the node even still has the text...
YrsReplayGuard const g{m_pYrsSupplier};
#endif
Remove( nRight );
#if defined(YRS)
#if ENABLE_YRS
}
#endif
SetModified(true);
#if defined(YRS)
#if ENABLE_YRS
assert(nRight != 0);
YrsConnectPara(m_pYrsSupplier, m_CommentId, *this, nRight - 1, aPaM.GetIndex());
#endif
@@ -3636,7 +3638,7 @@ void EditDoc::RemoveChars( EditPaM aPaM, sal_Int32 nChars )
SetModified( true );
#if defined(YRS)
#if ENABLE_YRS
YrsRemoveChars(m_pYrsSupplier, m_CommentId, *this, GetPos(aPaM.GetNode()), aPaM.GetIndex(), nChars);
#endif
}
@@ -3672,21 +3674,21 @@ void EditDoc::InsertAttribInSelection( ContentNode* pNode, sal_Int32 nStart, sal
// Will become a large Attribute.
pEndingAttrib->GetEnd() = pStartingAttrib->GetEnd();
pNode->GetCharAttribs().Remove(pStartingAttrib);
#if defined(YRS)
#if ENABLE_YRS
YrsInsertAttrib(m_pYrsSupplier, m_CommentId, *this, GetPos(pNode), pEndingAttrib);
#endif
}
else if ( pStartingAttrib && ( *(pStartingAttrib->GetItem()) == rPoolItem ) )
{
pStartingAttrib->GetStart() = nStart;
#if defined(YRS)
#if ENABLE_YRS
YrsInsertAttrib(m_pYrsSupplier, m_CommentId, *this, GetPos(pNode), pStartingAttrib);
#endif
}
else if ( pEndingAttrib && ( *(pEndingAttrib->GetItem()) == rPoolItem ) )
{
pEndingAttrib->GetEnd() = nEnd;
#if defined(YRS)
#if ENABLE_YRS
YrsInsertAttrib(m_pYrsSupplier, m_CommentId, *this, GetPos(pNode), pEndingAttrib);
#endif
}
@@ -3743,7 +3745,7 @@ bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEn
if ( pAttr->GetEnd() > nEnd )
{
bNeedsSorting = true;
#if defined(YRS)
#if ENABLE_YRS
YrsRemoveAttrib(m_pYrsSupplier, m_CommentId, *this, GetPos(pNode), pAttr->Which(), pAttr->GetStart(), nEnd);
#endif
pAttr->GetStart() = nEnd; // then it starts after this
@@ -3764,7 +3766,7 @@ bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEn
bChanged = true;
if ( ( pAttr->GetStart() < nStart ) && !pAttr->IsFeature() )
{
#if defined(YRS)
#if ENABLE_YRS
YrsRemoveAttrib(m_pYrsSupplier, m_CommentId, *this, GetPos(pNode), pAttr->Which(), nStart, pAttr->GetEnd());
#endif
pAttr->GetEnd() = nStart; // then it ends here
@@ -3784,7 +3786,7 @@ bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEn
{
bNeedsSorting = true;
pAttr->GetStart() = nEnd;
#if defined(YRS)
#if ENABLE_YRS
YrsRemoveAttrib(m_pYrsSupplier, m_CommentId, *this, GetPos(pNode), pAttr->Which(), nStart, nEnd);
#endif
rpStarting = pAttr;
@@ -3794,7 +3796,7 @@ bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEn
else if ( pAttr->GetEnd() == nEnd )
{
pAttr->GetEnd() = nStart;
#if defined(YRS)
#if ENABLE_YRS
YrsRemoveAttrib(m_pYrsSupplier, m_CommentId, *this, GetPos(pNode), pAttr->Which(), nStart, nEnd);
#endif
rpEnding = pAttr;
@@ -3807,13 +3809,13 @@ bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEn
sal_Int32 nOldEnd = pAttr->GetEnd();
pAttr->GetEnd() = nStart;
rpEnding = pAttr;
#if defined(YRS)
#if ENABLE_YRS
YrsRemoveAttrib(m_pYrsSupplier, m_CommentId, *this, GetPos(pNode), pAttr->Which(), nStart, nEnd);
{
YrsReplayGuard const g{m_pYrsSupplier};
#endif
InsertAttrib( *pAttr->GetItem(), pNode, nEnd, nOldEnd );
#if defined(YRS)
#if ENABLE_YRS
}
#endif
if ( nWhich )
@@ -3823,7 +3825,7 @@ bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEn
}
if ( bRemoveAttrib )
{
#if defined(YRS)
#if ENABLE_YRS
YrsRemoveAttrib(m_pYrsSupplier, m_CommentId, *this, GetPos(pNode), pAttr->Which(), pAttr->GetStart(), pAttr->GetEnd());
#endif
DBG_ASSERT( ( pAttr != rpStarting ) && ( pAttr != rpEnding ), "Delete and retain the same attribute?" );
@@ -3862,7 +3864,7 @@ void EditDoc::InsertAttrib( const SfxPoolItem& rPoolItem, ContentNode* pNode, sa
SetModified( true );
#if defined(YRS)
#if ENABLE_YRS
YrsInsertAttrib(m_pYrsSupplier, m_CommentId, *this, GetPos(pNode), pAttrib);
#endif
}
+1 -1
View File
@@ -347,7 +347,7 @@ void EditView::GetSelectionRectangles(std::vector<tools::Rectangle>& rLogicRects
return getImpl().GetSelectionRectangles(getImpl().GetEditSelection(), rLogicRects);
}
#if defined(YRS)
#if ENABLE_YRS
void EditView::YrsGetSelectionRectangles(
::std::vector<::std::pair<OUString, ::std::vector<tools::Rectangle>>>& rLogicRects) const
{
+2 -2
View File
@@ -287,7 +287,7 @@ private:
EESelectionMode meSelectionMode;
EditSelection maEditSelection;
EEAnchorMode meAnchorMode;
#if defined(YRS)
#if ENABLE_YRS
public:
/// when SwAnnotationWin::UpdateData() is called, the EE is cleared
/// and recreated, so use ESelection not EditSelection to survive this!
@@ -531,7 +531,7 @@ public:
class ImpEditEngine : public SfxListener, public svl::StyleSheetUser
{
friend class EditEngine;
#if defined(YRS)
#if ENABLE_YRS
friend class EditDoc;
#endif
+4 -4
View File
@@ -3832,7 +3832,7 @@ void ImpEditEngine::UpdateSelections()
{
pView->getImpl().SetEditSelection(aCurSel);
}
#if defined(YRS)
#if ENABLE_YRS
for (auto & it : pView->getImpl().m_PeerCursors)
{
EditSelection sel(CreateSel(it.second.second));
@@ -3847,7 +3847,7 @@ void ImpEditEngine::UpdateSelections()
maDeletedNodes.clear();
}
#if defined(YRS)
#if ENABLE_YRS
static bool UpdatePosDelete(EPaM & rPos, ESelection const& rDeleted)
{
// correct towards start: RemoveParagraph(Count()) can't work otherwise
@@ -3934,7 +3934,7 @@ void ImpEditEngine::UpdateSelectionsDelete(ESelection const& rDeleted)
(void)pView;
(void)deleted;
#endif
#if defined(YRS)
#if ENABLE_YRS
for (auto & it : pView->getImpl().m_PeerCursors)
{
UpdatePosDelete(it.second.second.start, deleted);
@@ -3966,7 +3966,7 @@ void ImpEditEngine::UpdateSelectionsInsert(ESelection const& rInserted)
{
pView->getImpl().SetEditSelection(CreateSel(esel));
}
#if defined(YRS)
#if ENABLE_YRS
for (auto & it : pView->getImpl().m_PeerCursors)
{
UpdatePosInsert(it.second.second.start, rInserted);
+2 -2
View File
@@ -90,7 +90,7 @@ void ImpEditEngine::SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle )
if ( pCurStyle )
EndListening( *pCurStyle );
pNode->SetStyleSheet( pStyle, maStatus.UseCharAttribs() );
#if defined(YRS)
#if ENABLE_YRS
maEditDoc.YrsSetStyle(nPara, pStyle ? pStyle->GetName() : OUString());
#endif
if ( pStyle )
@@ -553,7 +553,7 @@ void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, SetA
{
pNode->GetContentAttribs().GetItems().Put( rItem );
bParaAttribFound = true;
#if defined(YRS)
#if ENABLE_YRS
maEditDoc.YrsSetParaAttr(nNode, rItem);
#endif
}
+3 -2
View File
@@ -36,8 +36,9 @@
#include <com/sun/star/uno/Reference.h>
#include <editeng/editengdllapi.h>
#include <config_collab.h>
#if defined(YRS)
#if ENABLE_YRS
class IYrsTransactionSupplier;
typedef struct TransactionInner YTransaction;
typedef struct YTextEvent YTextEvent;
@@ -412,7 +413,7 @@ public:
void SetNegativeX(bool bSet);
bool IsNegativeX() const;
#if defined(YRS)
#if ENABLE_YRS
void SetYrsCommentId(IYrsTransactionSupplier *, OString const& rId);
void YrsWriteEEState();
void YrsReadEEState(YTransaction *);
-35
View File
@@ -9,7 +9,6 @@
#pragma once
#define YRS_WEAK
extern "C" {
#if defined(__clang__)
#pragma clang diagnostic push
@@ -21,8 +20,6 @@ extern "C" {
#endif
}
#include <rtl/string.hxx>
// check input is valid values to find encoding bugs early
#define yvalidate(cond) \
if (!(cond)) \
@@ -35,36 +32,4 @@ struct YOutputDeleter
void operator()(YOutput* const p) const { youtput_destroy(p); }
};
class IYrsTransactionSupplier
{
public:
enum class Mode
{
Edit,
Replay
};
protected:
Mode m_Mode{ Mode::Edit };
public:
IYrsTransactionSupplier() = default;
virtual ~IYrsTransactionSupplier() = default;
Mode SetMode(Mode const mode)
{
Mode ret = mode;
std::swap(ret, m_Mode);
return ret;
}
virtual YDoc* GetYDoc() = 0;
virtual Branch* GetCommentMap() = 0;
virtual Branch* GetCursorMap() = 0;
virtual YTransaction* GetReadTransaction() = 0;
virtual YTransaction* GetWriteTransaction() = 0;
virtual bool CommitTransaction(bool isForce = false) = 0;
virtual OString GenNewCommentId() = 0;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
@@ -0,0 +1,50 @@
/* -*- 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 <rtl/string.hxx>
typedef struct TransactionInner YTransaction;
typedef struct Branch Branch;
typedef struct YDoc YDoc;
class IYrsTransactionSupplier
{
public:
enum class Mode
{
Edit,
Replay
};
protected:
Mode m_Mode{ Mode::Edit };
public:
IYrsTransactionSupplier() = default;
virtual ~IYrsTransactionSupplier() = default;
Mode SetMode(Mode const mode)
{
Mode ret = mode;
std::swap(ret, m_Mode);
return ret;
}
virtual YDoc* GetYDoc() = 0;
virtual Branch* GetCommentMap() = 0;
virtual Branch* GetCursorMap() = 0;
virtual YTransaction* GetReadTransaction() = 0;
virtual YTransaction* GetWriteTransaction() = 0;
virtual bool CommitTransaction(bool isForce = false) = 0;
virtual OString GenNewCommentId() = 0;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
-4
View File
@@ -44,10 +44,6 @@ $(eval $(call gb_Library_set_include,sfx,\
$(eval $(call gb_Library_add_defs,sfx,-DSFX2_DLLIMPLEMENTATION))
ifneq ($(WITH_YRS),)
$(eval $(call gb_Library_add_defs,sfx,-DYRS))
endif
$(eval $(call gb_Library_use_libraries,sfx,\
basegfx \
comphelper \
+3 -2
View File
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <config_collab.h>
#include <sfx2/app.hxx>
#include <sfx2/bindings.hxx>
@@ -46,7 +47,7 @@
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/util/XCloseable.hpp>
#if defined(YRS)
#if ENABLE_YRS
#include <com/sun/star/io/SequenceInputStream.hpp>
#include <com/sun/star/connection/Connector.hpp>
#endif
@@ -631,7 +632,7 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rA
Reference< XModel2 > xModel = aDescriptor.getOrDefault( u"Model"_ustr, Reference< XModel2 >() );
const bool bExternalModel = xModel.is();
#if defined(YRS)
#if ENABLE_YRS
uno::Reference<connection::XConnection> xConnection;
if (!xModel.is() && aDescriptor.getOrDefault(u"URL"_ustr, OUString()) == "private:factory/swriter" && !getenv("YRSACCEPT"))
{
+1
View File
@@ -74,6 +74,7 @@ $(eval $(call gb_CppunitTest_use_externals,sw_uwriter,\
icuuc \
icu_headers \
libxml2 \
yrs \
))
$(eval $(call gb_CppunitTest_set_include,sw_uwriter,\
+5 -3
View File
@@ -19,9 +19,11 @@
#pragma once
#if defined(YRS)
#include <config_collab.h>
#if ENABLE_YRS
#include <com/sun/star/uno/Any.h>
#include <editeng/yrs.hxx>
#include <editeng/yrstransactionsupplier.hxx>
#include <optional>
struct SwPosition;
class SwPostItField;
@@ -55,7 +57,7 @@ public:
virtual bool IsEnableSetModified() const = 0;
virtual void SetEnableSetModified(bool bEnableSetModified) = 0;
#if defined(YRS)
#if ENABLE_YRS
virtual void YrsInitAcceptor() = 0;
virtual void YrsInitConnector(css::uno::Any const& raConnector) = 0;
virtual IYrsTransactionSupplier::Mode SetYrsMode(IYrsTransactionSupplier::Mode mode) = 0;
+3 -1
View File
@@ -21,6 +21,8 @@
#include <sal/config.h>
#include "swdllapi.h"
#include <config_collab.h>
#include <cstddef>
#include <memory>
#include <vector>
@@ -128,7 +130,7 @@ class SAL_DLLPUBLIC_RTTI SwPostItMgr final : public SfxListener,
SwAnnotationItem* InsertItem( SfxBroadcaster* pItem, bool bCheckExistence, bool bFocus);
void RemoveItem( SfxBroadcaster* pBroadcast );
#if defined(YRS)
#if ENABLE_YRS
public:
#endif
VclPtr<sw::annotation::SwAnnotationWin> GetOrCreateAnnotationWindow(SwAnnotationItem& rItem, bool& rCreated);
+1 -1
View File
@@ -203,7 +203,7 @@ private:
SwShellTableCursor* m_pTableCursor; /**< table Cursor; only in tables when the
selection lays over 2 columns */
#if defined(YRS)
#if ENABLE_YRS
public:
::std::unordered_map<OString, ::std::unique_ptr<VisibleCursorState>> m_PeerCursors;
SwVisibleCursor * FindVisibleCursorForPeer(SwSelPaintRects const& rCursor) const;
+2 -1
View File
@@ -18,6 +18,7 @@
*/
#pragma once
#include <config_collab.h>
#include <config_feature_desktop.h>
#include <vcl/cursor.hxx>
@@ -68,7 +69,7 @@ public:
std::optional<OString> getLOKPayload(int nType, int nViewId) const;
#if defined(YRS)
#if ENABLE_YRS
::std::optional<OUString> m_Author;
#endif
};
+10 -10
View File
@@ -60,7 +60,7 @@
#include <comphelper/flagguard.hxx>
#include <strings.hrc>
#include <IDocumentLayoutAccess.hxx>
#if defined(YRS)
#if ENABLE_YRS
#include <IDocumentState.hxx>
#endif
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
@@ -1781,7 +1781,7 @@ void SwCursorShell::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
bVis = true;
m_pVisibleCursor->Hide();
}
#if defined(YRS)
#if ENABLE_YRS
for (auto const& it : m_PeerCursors)
{
if (it.second->m_pCurrentCursor)
@@ -1819,7 +1819,7 @@ void SwCursorShell::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
if( m_bSVCursorVis && bVis ) // also show SV cursor again
m_pVisibleCursor->Show();
#if defined(YRS)
#if ENABLE_YRS
for (auto const& it : m_PeerCursors)
{
if (it.second->m_pCurrentCursor && it.second->m_bSVCursorVis)
@@ -2186,7 +2186,7 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd, ScrollSizeMo
}
m_pVisibleCursor->Hide(); // always hide visible Cursor
#if defined(YRS)
#if ENABLE_YRS
for (auto const& it : m_PeerCursors)
{
if (it.second->m_pCurrentCursor)
@@ -2273,7 +2273,7 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd, ScrollSizeMo
}
};
MoveIntoContent(m_pCurrentCursor);
#if defined(YRS)
#if ENABLE_YRS
for (auto const& it : m_PeerCursors)
{
if (it.second->m_pCurrentCursor)
@@ -2448,7 +2448,7 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd, ScrollSizeMo
*ppFrame = pFrame;
return true;
};
#if defined(YRS)
#if ENABLE_YRS
for (auto const& it : m_PeerCursors)
{
if (it.second->m_pCurrentCursor)
@@ -2487,7 +2487,7 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd, ScrollSizeMo
pNxt = pNxt->GetNext();
}
}
#if defined(YRS)
#if ENABLE_YRS
for (auto const& it : m_PeerCursors)
{
if (it.second->m_pCurrentCursor)
@@ -2526,7 +2526,7 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd, ScrollSizeMo
if( m_bSVCursorVis )
m_pVisibleCursor->Show(); // show again
#if defined(YRS)
#if ENABLE_YRS
for (auto const& it : m_PeerCursors)
{
if (it.second->m_pCurrentCursor && it.second->m_bSVCursorVis)
@@ -3240,7 +3240,7 @@ SwVisibleCursor* SwCursorShell::GetVisibleCursor() const
return m_pVisibleCursor;
}
#if defined(YRS)
#if ENABLE_YRS
void SwCursorShell::YrsAddCursor(OString const& rId, ::std::optional<SwPosition> const& roPoint,
::std::optional<SwPosition> const& roMark, OUString const& rAuthor)
{
@@ -3633,7 +3633,7 @@ SwCursorShell::~SwCursorShell()
else
ClearTableBoxContent();
#if defined(YRS)
#if ENABLE_YRS
for (auto const& it : m_PeerCursors)
{
delete it.second->m_pVisibleCursor;
+2 -2
View File
@@ -472,7 +472,7 @@ void SwSelPaintRects::Show(std::vector<OString>* pSelectionRectangles)
if (xTargetOverlay.is())
{
::std::optional<Color> oColor;
#if defined(YRS)
#if ENABLE_YRS
if (SwVisibleCursor *const pVisibleCursor{GetShell()->FindVisibleCursorForPeer(*this)})
{
::std::size_t const authorId{SwModule::get()->InsertRedlineAuthor(*pVisibleCursor->m_Author)};
@@ -966,7 +966,7 @@ void SwShellCursor::FillRects()
{
GetShell()->GetLayout()->CalcFrameRects(*this, *this);
}
#if defined(YRS)
#if ENABLE_YRS
if (!HasMark())
{
if (SwVisibleCursor *const pVisibleCursor{GetShell()->FindVisibleCursorForPeer(*this)})
+11 -11
View File
@@ -23,7 +23,7 @@
#include <DocumentLayoutManager.hxx>
#include <acorrect.hxx>
#if defined(YRS)
#if ENABLE_YRS
#include <AnnotationWin.hxx>
#include <wrtsh.hxx>
#include <view.hxx>
@@ -60,7 +60,7 @@
namespace sw
{
#if defined(YRS)
#if ENABLE_YRS
using sw::annotation::SwAnnotationWin;
namespace {
@@ -740,7 +740,7 @@ void YrsReadCursor(ObserveCursorState & rState, OString const& rPeerId,
{
Branch const*const pArray{rCursor.value.y_type};
auto const len{yarray_len(pArray)};
#if defined(YRS_WEAK)
#if ENABLE_YRS_WEAK
if (len == 2
&& yarray_get(pArray, rState.pTxn, 0)->tag == Y_JSON_STR)
#else
@@ -753,7 +753,7 @@ void YrsReadCursor(ObserveCursorState & rState, OString const& rPeerId,
YrsInvalidateEECursors(rState, rPeerId, &commentId);
YrsInvalidateSwCursors(rState, rPeerId, rAuthor, false);
::std::optional<::std::pair<int64_t, int64_t>> oMark;
#if defined(YRS_WEAK)
#if ENABLE_YRS_WEAK
::std::unique_ptr<YOutput, YOutputDeleter> const pWeak{yarray_get(pArray, rState.pTxn, 1)};
yvalidate(pWeak->tag == Y_WEAK_LINK);
Branch * pBranch{nullptr};
@@ -921,7 +921,7 @@ extern "C" void observe_cursors(void *const pState, uint32_t count, YEvent const
YrsReadCursor(rState, peerId, pChange[2].values[0], author, false);
break;
}
#if defined(YRS_WEAK)
#if ENABLE_YRS_WEAK
case Y_WEAK_LINK:
{
// not sure what this is, but yffi doesn't have any API
@@ -1292,7 +1292,7 @@ void DocumentStateManager::YrsNotifyCursorUpdate()
pShell->GetView().GetPostItMgr()->GetActiveSidebarWin()})
{
// TODO StickyIndex cannot be inserted into YDoc ?
#if defined(YRS_WEAK)
#if ENABLE_YRS_WEAK
if (pWin->GetOutlinerView()->GetEditView().YrsWriteEECursor(pTxn, *pEntry->value.y_type, pCurrent.get()))
{
YrsCommitModified();
@@ -1378,7 +1378,7 @@ void DocumentStateManager::YrsNotifyCursorUpdate()
{
if (pCurrent == nullptr || pCurrent->tag != Y_ARRAY
|| yarray_len(pCurrent->value.y_type) != 2
#if defined(YRS_WEAK)
#if ENABLE_YRS_WEAK
|| yarray_get(pCurrent->value.y_type, pTxn, 0)->tag != Y_JSON_INT
#endif
|| yarray_get(pCurrent->value.y_type, pTxn, 0)->value.integer != positions[0].value.integer
@@ -1534,14 +1534,14 @@ DocumentStateManager::DocumentStateManager( SwDoc& i_rSwdoc ) :
mbNewDoc(false),
mbInCallModified(false)
{
#if defined(YRS)
#if ENABLE_YRS
m_pYrsSupplier.reset(new YrsTransactionSupplier);
#endif
}
DocumentStateManager::~DocumentStateManager()
{
#if defined(YRS)
#if ENABLE_YRS
if (m_pYrsReader) // not in e.g. AutoText docs
{
m_pYrsReader->m_xConnection->close();
@@ -1569,13 +1569,13 @@ void DocumentStateManager::SetModified()
if( m_rDoc.GetAutoCorrExceptWord() && !m_rDoc.GetAutoCorrExceptWord()->IsDeleted() )
m_rDoc.DeleteAutoCorrExceptWord();
#if defined(YRS)
#if ENABLE_YRS
SAL_INFO("sw.yrs", "YRS SetModified");
YrsCommitModified();
#endif
}
#if defined(YRS)
#if ENABLE_YRS
void DocumentStateManager::YrsCommitModified()
{
if (m_pYrsSupplier->CommitTransaction())
+2 -2
View File
@@ -122,7 +122,7 @@ void PaMCorrAbs( const SwPaM& rRange,
if( pCursorShell->IsTableMode() )
lcl_PaMCorrAbs( const_cast<SwPaM &>(*pCursorShell->GetTableCrs()), aStart, aEnd, aNewPos );
#if defined(YRS)
#if ENABLE_YRS
for (auto const& it : pCursorShell->m_PeerCursors)
{
if (it.second->m_pCurrentCursor)
@@ -293,7 +293,7 @@ void PaMCorrRel( const SwNode &rOldNode,
if( pCursorShell->IsTableMode() )
lcl_PaMCorrRel1( pCursorShell->GetTableCrs(), pOldNode, aNewPos, nCntIdx );
#if defined(YRS)
#if ENABLE_YRS
for (auto const& it : pCursorShell->m_PeerCursors)
{
for (SwPaM & rPaM : it.second->m_pCurrentCursor->GetRingContainer())
+3 -3
View File
@@ -21,7 +21,7 @@
#include <IDocumentState.hxx>
#if defined(YRS)
#if ENABLE_YRS
#include <rtl/ref.hxx>
#include <com/sun/star/connection/XAcceptor.hpp>
#include <com/sun/star/connection/XConnector.hpp>
@@ -33,7 +33,7 @@ class SwDoc;
namespace sw {
#if defined(YRS)
#if ENABLE_YRS
class YrsThread;
class YrsTransactionSupplier;
#endif
@@ -69,7 +69,7 @@ private:
bool mbNewDoc ; //< TRUE: new Doc.
bool mbInCallModified; //< TRUE: in Set/Reset-Modified link.
#if defined(YRS)
#if ENABLE_YRS
friend class YrsThread;
::rtl::Reference<YrsThread> m_pYrsReader;
css::uno::Reference<css::connection::XAcceptor> m_xAcceptor;
+1 -1
View File
@@ -1209,7 +1209,7 @@ void SwDocShell::LoadingFinished()
// before <FinishedLoading(..)> is called.
const bool bHasDocToStayModified( m_xDoc->getIDocumentState().IsModified() && m_xDoc->getIDocumentLinksAdministration().LinksUpdated() );
#if defined(YRS)
#if ENABLE_YRS
#if 0
// this doesn't even filter as advertised!
auto const args{GetBaseModel()->getArgs2({u"YrsConnect"_ustr})};
+4 -4
View File
@@ -61,7 +61,7 @@
#include <docsh.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
#if defined(YRS)
#if ENABLE_YRS
#include <IDocumentState.hxx>
#endif
#include <SwUndoField.hxx>
@@ -209,7 +209,7 @@ void SwAnnotationWin::SetPostItText()
// get text from SwPostItField and insert into our textview
mpOutliner->SetModifyHdl( Link<LinkParamNone*,void>() );
mpOutliner->EnableUndo( false );
#if defined(YRS)
#if ENABLE_YRS
auto const mode = mrView.GetDocShell()->GetDoc()->getIDocumentState().SetYrsMode(IYrsTransactionSupplier::Mode::Replay);
#endif
if( mpField->GetTextObject() )
@@ -220,7 +220,7 @@ void SwAnnotationWin::SetPostItText()
GetOutlinerView()->SetStyleSheet(SwResId(STR_POOLCOLL_COMMENT));
GetOutlinerView()->InsertText(sNewText);
}
#if defined(YRS)
#if ENABLE_YRS
mrView.GetDocShell()->GetDoc()->getIDocumentState().SetYrsMode(mode);
#endif
@@ -265,7 +265,7 @@ void SwAnnotationWin::SetResolved(bool resolved)
UpdateData();
Invalidate();
collectUIInformation(u"SETRESOLVED"_ustr,get_id());
#if defined(YRS)
#if ENABLE_YRS
mrView.GetDocShell()->GetDoc()->getIDocumentState().YrsNotifySetResolved(
GetOutlinerView()->GetEditView().GetYrsCommentId(),
*static_cast<SwPostItField const*>(mpFormatField->GetField()));
+3 -3
View File
@@ -45,7 +45,7 @@
#include <doc.hxx>
#include <IDocumentSettingAccess.hxx>
#include <IDocumentFieldsAccess.hxx>
#if defined(YRS)
#if ENABLE_YRS
#include <IDocumentState.hxx>
#endif
#include <docstyle.hxx>
@@ -520,7 +520,7 @@ void SwPostItMgr::RemoveItem( SfxBroadcaster* pBroadcast )
[&pBroadcast](const std::unique_ptr<SwAnnotationItem>& pField) { return pField->GetBroadcaster() == pBroadcast; });
if (i != mvPostItFields.end())
{
#if defined(YRS)
#if ENABLE_YRS
mpView->GetDocShell()->GetDoc()->getIDocumentState().YrsRemoveComment(
(*i)->GetAnchorPosition(),
(*i)->mpPostIt->GetOutlinerView()->GetEditView().GetYrsCommentId());
@@ -908,7 +908,7 @@ VclPtr<SwAnnotationWin> SwPostItMgr::GetOrCreateAnnotationWindow(SwAnnotationIte
pPostIt->InitControls();
pPostIt->SetReadonly(mbReadOnly);
rItem.mpPostIt = pPostIt;
#if defined(YRS)
#if ENABLE_YRS
SAL_INFO("sw.yrs", "YRS GetOrCreateAnnotationWindow " << rItem.mpPostIt);
#endif
if (mpAnswer)
+3 -3
View File
@@ -55,7 +55,7 @@
#include <wrtsh.hxx>
#include <AnnotationWin.hxx>
#include <IDocumentDeviceAccess.hxx>
#if defined(YRS)
#if ENABLE_YRS
#include <IDocumentState.hxx>
#include <swmodule.hxx>
#endif
@@ -203,7 +203,7 @@ OUString SidebarTextControl::RequestHelp(tools::Rectangle& rHelpRect)
return OUString();
}
#if defined(YRS)
#if ENABLE_YRS
void SidebarTextControl::EditViewInvalidate(const tools::Rectangle& rRect)
{
SAL_INFO("sw.yrs", "YRS EditViewInvalidate");
@@ -278,7 +278,7 @@ void SidebarTextControl::Paint(vcl::RenderContext& rRenderContext, const tools::
DoPaint(rRenderContext, rRect);
#if defined(YRS)
#if ENABLE_YRS
if (EditView *const pEditView{GetEditView()})
{
rRenderContext.Push(vcl::PushFlags::ALL);
+1 -1
View File
@@ -57,7 +57,7 @@ class SidebarTextControl : public WeldEditView
virtual EditEngine* GetEditEngine() const override;
#if defined(YRS)
#if ENABLE_YRS
virtual void EditViewInvalidate(const tools::Rectangle& rRect) override;
virtual void EditViewSelectionChange() override;
#endif
+2 -2
View File
@@ -75,7 +75,7 @@
#include <txmsrt.hxx>
#include <unotools/useroptions.hxx>
#include <IDocumentContentOperations.hxx>
#if defined(YRS)
#if ENABLE_YRS
#include <IDocumentState.hxx>
#include <txtfld.hxx>
#endif
@@ -1572,7 +1572,7 @@ bool SwFieldMgr::InsertField(
pCurShell->EndAllAction();
#if defined(YRS)
#if ENABLE_YRS
if (isSuccess)
{
// now the SwAnnotationWin are created
+1 -1
View File
@@ -1027,7 +1027,7 @@ SwView::SwView(SfxViewFrame& _rFrame, SfxViewShell* pOldSh)
// Set DocShell
m_xGlueDocShell.reset(new SwViewGlueDocShell(*this, rDocSh));
m_pPostItMgr.reset(new SwPostItMgr(this));
#if defined(YRS)
#if ENABLE_YRS
m_pWrtShell->GetDoc()->getIDocumentState().YrsInitAcceptor();
#endif
+1 -1
View File
@@ -523,7 +523,7 @@ Reference< XInterface > SwXTextDocument::getCurrentSelection()
sal_Bool SwXTextDocument::attachResource(const OUString& aURL, const Sequence< beans::PropertyValue >& aArgs)
{
#if defined(YRS)
#if ENABLE_YRS
// this is for new document
for (auto const& rArg : aArgs)
{