summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2023-08-08 11:32:53 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-08-08 17:02:12 +0200
commitf238f5bf1ba51b03dcbbdc6195c9c9bd590777dd (patch)
tree36f9b96fa7ebf09fbf94f8291b25909ea4f0051b /sw
parentdc915b2b9ed3fe9a2b97f15aca47ee39ab4db3bf (diff)
when notes are not shown don't do expensive comment size calculation...
and positioning, etc. Change-Id: Ice2f1a506bc6ae6d463e51e3d98e075a88c93cc0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155450 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/AnnotationWin.hxx2
-rw-r--r--sw/source/uibase/docvw/AnnotationWin2.cxx172
-rw-r--r--sw/source/uibase/docvw/PostItMgr.cxx91
3 files changed, 141 insertions, 124 deletions
diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index f7ac7b301d46..2a3bf339f581 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -90,8 +90,8 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public InterimItemWindow
tools::Long nY,
tools::Long nWidth,
tools::Long nHeight,
- const SwRect& aAnchorRect,
const tools::Long PageBorder);
+ void SetAnchorRect(const SwRect& aAnchorRect);
void SetPosAndSize();
void TranslateTopPosition(const tools::Long aAmount);
void CheckMetaText();
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx
index 8c7a26bc1b10..5e8f7a86886e 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -254,13 +254,17 @@ void SwAnnotationWin::DrawForPage(OutputDevice* pDev, const Point& rPt)
}
void SwAnnotationWin::SetPosSizePixelRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight,
- const SwRect& aAnchorRect, const tools::Long aPageBorder)
+ const tools::Long aPageBorder)
{
mPosSize = tools::Rectangle(Point(nX,nY),Size(nWidth,nHeight));
+ mPageBorder = aPageBorder;
+}
+
+void SwAnnotationWin::SetAnchorRect(const SwRect& aAnchorRect)
+{
if (!mAnchorRect.IsEmpty() && mAnchorRect != aAnchorRect)
mbAnchorRectChanged = true;
mAnchorRect = aAnchorRect;
- mPageBorder = aPageBorder;
}
void SwAnnotationWin::SetSize( const Size& rNewSize )
@@ -542,105 +546,106 @@ void SwAnnotationWin::Rescale()
void SwAnnotationWin::SetPosAndSize()
{
- bool bChange = false;
-
- if (GetSizePixel() != mPosSize.GetSize())
+ const bool bShowNotes = mrMgr.ShowNotes();
+ if (bShowNotes)
{
- bChange = true;
- SetSizePixel(mPosSize.GetSize());
+ bool bChange = false;
- DoResize();
- }
+ if (GetSizePixel() != mPosSize.GetSize())
+ {
+ bChange = true;
+ SetSizePixel(mPosSize.GetSize());
- if (GetPosPixel().X() != mPosSize.Left() || (std::abs(GetPosPixel().Y() - mPosSize.Top()) > 5) )
- {
- bChange = true;
- SetPosPixel(mPosSize.TopLeft());
+ DoResize();
+ }
- Point aLineStart;
- Point aLineEnd ;
- switch ( meSidebarPosition )
+ if (GetPosPixel().X() != mPosSize.Left() || (std::abs(GetPosPixel().Y() - mPosSize.Top()) > 5) )
{
- case sw::sidebarwindows::SidebarPosition::LEFT:
+ bChange = true;
+ SetPosPixel(mPosSize.TopLeft());
+
+ Point aLineStart;
+ Point aLineEnd ;
+ switch ( meSidebarPosition )
{
- aLineStart = EditWin().PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
- aLineEnd = EditWin().PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
+ case sw::sidebarwindows::SidebarPosition::LEFT:
+ {
+ aLineStart = EditWin().PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
+ aLineEnd = EditWin().PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
+ }
+ break;
+ case sw::sidebarwindows::SidebarPosition::RIGHT:
+ {
+ aLineStart = EditWin().PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
+ aLineEnd = EditWin().PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
+ }
+ break;
+ default:
+ OSL_FAIL( "<SwAnnotationWin::SetPosAndSize()> - unexpected position of sidebar" );
+ break;
}
- break;
- case sw::sidebarwindows::SidebarPosition::RIGHT:
+
+ // LOK has map mode disabled, and we still want to perform pixel ->
+ // twips conversion for the size of the line above the note.
+ if (comphelper::LibreOfficeKit::isActive() && !EditWin().IsMapModeEnabled())
{
- aLineStart = EditWin().PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
- aLineEnd = EditWin().PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
+ EditWin().EnableMapMode();
+ Size aSize(aLineEnd.getX() - aLineStart.getX(), aLineEnd.getY() - aLineStart.getY());
+ aSize = EditWin().PixelToLogic(aSize);
+ aLineEnd = aLineStart;
+ aLineEnd.Move(aSize.getWidth(), aSize.getHeight());
+ EditWin().EnableMapMode(false);
}
- break;
- default:
- OSL_FAIL( "<SwAnnotationWin::SetPosAndSize()> - unexpected position of sidebar" );
- break;
- }
-
- // LOK has map mode disabled, and we still want to perform pixel ->
- // twips conversion for the size of the line above the note.
- if (comphelper::LibreOfficeKit::isActive() && !EditWin().IsMapModeEnabled())
- {
- EditWin().EnableMapMode();
- Size aSize(aLineEnd.getX() - aLineStart.getX(), aLineEnd.getY() - aLineStart.getY());
- aSize = EditWin().PixelToLogic(aSize);
- aLineEnd = aLineStart;
- aLineEnd.Move(aSize.getWidth(), aSize.getHeight());
- EditWin().EnableMapMode(false);
- }
- if (mpAnchor)
- {
- mpAnchor->SetAllPosition( basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom() - 5* 15),
- basegfx::B2DPoint( mAnchorRect.Left()-5*15 , mAnchorRect.Bottom()+5*15),
- basegfx::B2DPoint( mAnchorRect.Left()+5*15 , mAnchorRect.Bottom()+5*15),
- basegfx::B2DPoint( mAnchorRect.Left(), mAnchorRect.Bottom()+2*15),
- basegfx::B2DPoint( mPageBorder ,mAnchorRect.Bottom()+2*15),
- basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()),
- basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()));
- }
- else
- {
- mpAnchor = AnchorOverlayObject::CreateAnchorOverlayObject( mrView,
- mAnchorRect,
- mPageBorder,
- aLineStart,
- aLineEnd,
- mColorAnchor );
- if ( mpAnchor )
+ if (mpAnchor)
{
- mpAnchor->setVisible(true);
- mpAnchor->SetAnchorState(AnchorState::Tri);
- if (HasChildPathFocus())
+ mpAnchor->SetAllPosition( basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom() - 5* 15),
+ basegfx::B2DPoint( mAnchorRect.Left()-5*15 , mAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( mAnchorRect.Left()+5*15 , mAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( mAnchorRect.Left(), mAnchorRect.Bottom()+2*15),
+ basegfx::B2DPoint( mPageBorder ,mAnchorRect.Bottom()+2*15),
+ basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()),
+ basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()));
+ }
+ else
+ {
+ mpAnchor = AnchorOverlayObject::CreateAnchorOverlayObject( mrView,
+ mAnchorRect,
+ mPageBorder,
+ aLineStart,
+ aLineEnd,
+ mColorAnchor );
+ if ( mpAnchor )
{
- mpAnchor->setLineSolid(true);
+ mpAnchor->setVisible(true);
+ mpAnchor->SetAnchorState(AnchorState::Tri);
+ if (HasChildPathFocus())
+ {
+ mpAnchor->setLineSolid(true);
+ }
}
}
}
- }
- else
- {
- if ( mpAnchor &&
- ( mpAnchor->getBasePosition() != basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom()-5*15) ) )
+ else
{
- mpAnchor->SetTriPosition( basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom() - 5* 15),
- basegfx::B2DPoint( mAnchorRect.Left()-5*15 , mAnchorRect.Bottom()+5*15),
- basegfx::B2DPoint( mAnchorRect.Left()+5*15 , mAnchorRect.Bottom()+5*15),
- basegfx::B2DPoint( mAnchorRect.Left(), mAnchorRect.Bottom()+2*15),
- basegfx::B2DPoint( mPageBorder , mAnchorRect.Bottom()+2*15));
+ if ( mpAnchor &&
+ ( mpAnchor->getBasePosition() != basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom()-5*15) ) )
+ {
+ mpAnchor->SetTriPosition( basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom() - 5* 15),
+ basegfx::B2DPoint( mAnchorRect.Left()-5*15 , mAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( mAnchorRect.Left()+5*15 , mAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( mAnchorRect.Left(), mAnchorRect.Bottom()+2*15),
+ basegfx::B2DPoint( mPageBorder , mAnchorRect.Bottom()+2*15));
+ }
}
- }
- if (mpShadow && bChange)
- {
- Point aStart = EditWin().PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()));
- Point aEnd = EditWin().PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height()));
- mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y()));
- }
+ if (mpShadow && bChange)
+ {
+ Point aStart = EditWin().PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()));
+ Point aEnd = EditWin().PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height()));
+ mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y()));
+ }
- if (mrMgr.ShowNotes())
- {
if (IsFollow() && !HasChildPathFocus())
{
// #i111964#
@@ -665,7 +670,6 @@ void SwAnnotationWin::SetPosAndSize()
}
}
-
// text range overlay
maAnnotationTextRanges.clear();
if ( mrSidebarItem.maLayoutInfo.mnStartNodeIdx != SwNodeOffset(0)
@@ -725,7 +729,7 @@ void SwAnnotationWin::SetPosAndSize()
}
}
- if (mrMgr.ShowNotes() && !maAnnotationTextRanges.empty())
+ if (bShowNotes && !maAnnotationTextRanges.empty())
{
if ( mpTextRangeOverlay != nullptr )
{
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 254aef92d8d3..e85b191a60fb 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -695,7 +695,11 @@ void SwPostItMgr::PreparePageContainer()
void SwPostItMgr::LayoutPostIts()
{
- bool bEnableMapMode = comphelper::LibreOfficeKit::isActive() && !mpEditWin->IsMapModeEnabled();
+ const bool bLoKitActive = comphelper::LibreOfficeKit::isActive();
+ const bool bTiledAnnotations = comphelper::LibreOfficeKit::isTiledAnnotations();
+ const bool bShowNotes = ShowNotes();
+
+ const bool bEnableMapMode = bLoKitActive && !mpEditWin->IsMapModeEnabled();
if (bEnableMapMode)
mpEditWin->EnableMapMode();
@@ -715,38 +719,13 @@ void SwPostItMgr::LayoutPostIts()
{
std::vector<SwAnnotationWin*> aVisiblePostItList;
tools::ULong lNeededHeight = 0;
- tools::Long mlPageBorder = 0;
- tools::Long mlPageEnd = 0;
for (auto const& pItem : pPage->mvSidebarItems)
{
VclPtr<SwAnnotationWin> pPostIt = pItem->mpPostIt;
- if (pPage->eSidebarPosition == sw::sidebarwindows::SidebarPosition::LEFT )
- {
- // x value for notes positioning
- mlPageBorder = mpEditWin->LogicToPixel( Point( pPage->mPageRect.Left(), 0)).X() - GetSidebarWidth(true);// - GetSidebarBorderWidth(true);
- //bending point
- mlPageEnd =
- mpWrtShell->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE)
- ? pItem->maLayoutInfo.mPagePrtArea.Left()
- : pPage->mPageRect.Left() + 350;
- }
- else if (pPage->eSidebarPosition == sw::sidebarwindows::SidebarPosition::RIGHT )
- {
- // x value for notes positioning
- mlPageBorder = mpEditWin->LogicToPixel( Point(pPage->mPageRect.Right(), 0)).X() + GetSidebarBorderWidth(true);
- //bending point
- mlPageEnd =
- mpWrtShell->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE)
- ? pItem->maLayoutInfo.mPagePrtArea.Right() :
- pPage->mPageRect.Right() - 350;
- }
-
if (pItem->mbShow)
{
- tools::Long Y = mpEditWin->LogicToPixel( Point(0,pItem->maLayoutInfo.mPosition.Bottom())).Y();
- tools::Long aPostItHeight = 0;
if (!pPostIt)
{
pPostIt = pItem->GetSidebarWindow( mpView->GetEditWin(),
@@ -767,16 +746,49 @@ void SwPostItMgr::LayoutPostIts()
GetColorAnchor(pItem->maLayoutInfo.mRedlineAuthor));
pPostIt->SetSidebarPosition(pPage->eSidebarPosition);
pPostIt->SetFollow(static_cast<bool>(pPostIt->CalcParent()));
- aPostItHeight = ( pPostIt->GetPostItTextHeight() < pPostIt->GetMinimumSizeWithoutMeta()
- ? pPostIt->GetMinimumSizeWithoutMeta()
- : pPostIt->GetPostItTextHeight() )
- + pPostIt->GetMetaHeight();
- pPostIt->SetPosSizePixelRect( mlPageBorder ,
- Y - GetInitialAnchorDistance(),
- GetSidebarWidth(true),
- aPostItHeight,
- pItem->maLayoutInfo.mPosition,
- mlPageEnd );
+
+ tools::Long aPostItHeight = 0;
+ if (bShowNotes)
+ {
+ tools::Long mlPageBorder = 0;
+ tools::Long mlPageEnd = 0;
+
+ if (pPage->eSidebarPosition == sw::sidebarwindows::SidebarPosition::LEFT )
+ {
+ // x value for notes positioning
+ mlPageBorder = mpEditWin->LogicToPixel( Point( pPage->mPageRect.Left(), 0)).X() - GetSidebarWidth(true);// - GetSidebarBorderWidth(true);
+ //bending point
+ mlPageEnd =
+ mpWrtShell->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE)
+ ? pItem->maLayoutInfo.mPagePrtArea.Left()
+ : pPage->mPageRect.Left() + 350;
+ }
+ else if (pPage->eSidebarPosition == sw::sidebarwindows::SidebarPosition::RIGHT )
+ {
+ // x value for notes positioning
+ mlPageBorder = mpEditWin->LogicToPixel( Point(pPage->mPageRect.Right(), 0)).X() + GetSidebarBorderWidth(true);
+ //bending point
+ mlPageEnd =
+ mpWrtShell->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE)
+ ? pItem->maLayoutInfo.mPagePrtArea.Right() :
+ pPage->mPageRect.Right() - 350;
+ }
+
+ tools::Long Y = mpEditWin->LogicToPixel( Point(0,pItem->maLayoutInfo.mPosition.Bottom())).Y();
+
+ aPostItHeight = ( pPostIt->GetPostItTextHeight() < pPostIt->GetMinimumSizeWithoutMeta()
+ ? pPostIt->GetMinimumSizeWithoutMeta()
+ : pPostIt->GetPostItTextHeight() )
+ + pPostIt->GetMetaHeight();
+ pPostIt->SetPosSizePixelRect( mlPageBorder ,
+ Y - GetInitialAnchorDistance(),
+ GetSidebarWidth(true),
+ aPostItHeight,
+ mlPageEnd );
+ }
+
+ pPostIt->SetAnchorRect(pItem->maLayoutInfo.mPosition);
+
pPostIt->ChangeSidebarItem( *pItem );
if (pItem->mbFocus)
@@ -787,7 +799,8 @@ void SwPostItMgr::LayoutPostIts()
}
// only the visible postits are used for the final layout
aVisiblePostItList.push_back(pPostIt);
- lNeededHeight += pPostIt->IsFollow() ? aPostItHeight : aPostItHeight+GetSpaceBetween();
+ if (bShowNotes)
+ lNeededHeight += pPostIt->IsFollow() ? aPostItHeight : aPostItHeight+GetSpaceBetween();
}
else // we don't want to see it
{
@@ -878,7 +891,7 @@ void SwPostItMgr::LayoutPostIts()
for (auto const& visiblePostIt : aVisiblePostItList)
{
- if (comphelper::LibreOfficeKit::isActive() && !comphelper::LibreOfficeKit::isTiledAnnotations())
+ if (bLoKitActive && !bTiledAnnotations)
{
if (visiblePostIt->GetSidebarItem().mbPendingLayout)
lcl_CommentNotification(mpView, CommentNotificationType::Add, &visiblePostIt->GetSidebarItem(), 0);
@@ -901,7 +914,7 @@ void SwPostItMgr::LayoutPostIts()
}
}
- if (!ShowNotes())
+ if (!bShowNotes)
{ // we do not want to see the notes anymore -> Options-Writer-View-Notes
IDocumentRedlineAccess const& rIDRA(mpWrtShell->getIDocumentRedlineAccess());
bool bRepair = false;