/* -*- 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 .
*/
void SwAnnotationWin::PaintTile(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
{ bool bMenuButtonVisible = mxMenuButton->get_visible(); // No point in showing this button till click on it are not handled. if (bMenuButtonVisible)
mxMenuButton->hide();
// draw left over space if (Application::GetSettings().GetStyleSettings().GetHighContrastMode())
rRenderContext.SetFillColor(COL_BLACK); else
rRenderContext.SetFillColor(mColorDark);
rRenderContext.SetLineColor();
rRenderContext.DrawRect(rRect);
// drawinglayer sets the map mode to pixels, not needed here.
rRenderContext.Pop(); // Work in document-global twips.
rRenderContext.Pop(); if (mpAnchor)
pProcessor->process(mpAnchor->getOverlayObjectPrimitive2DSequence()); if (mpTextRangeOverlay)
pProcessor->process(mpTextRangeOverlay->getOverlayObjectPrimitive2DSequence());
void SwAnnotationWin::DrawForPage(OutputDevice* pDev, const Point& rPt)
{ // tdf#143511 unclip SysObj so get_extents_relative_to of children // of the SysObj can provide meaningful results
UnclipVisibleSysObj();
if (mxMetadataAuthor->get_visible())
{ int x, y, width, height;
mxMetadataAuthor->get_extents_relative_to(*m_xContainer, x, y, width, height);
Point aPos(rPt + PixelToLogic(Point(x, y)));
Size aSize(PixelToLogic(Size(width, height)));
if (mxMetadataDate->get_visible())
{ int x, y, width, height;
mxMetadataDate->get_extents_relative_to(*m_xContainer, x, y, width, height);
Point aPos(rPt + PixelToLogic(Point(x, y)));
Size aSize(PixelToLogic(Size(width, height)));
if (mxMetadataResolved->get_visible())
{ int x, y, width, height;
mxMetadataResolved->get_extents_relative_to(*m_xContainer, x, y, width, height);
Point aPos(rPt + PixelToLogic(Point(x, y)));
Size aSize(PixelToLogic(Size(width, height)));
if (mpAnchor)
pProcessor->process(mpAnchor->getOverlayObjectPrimitive2DSequence()); if (mpTextRangeOverlay)
pProcessor->process(mpTextRangeOverlay->getOverlayObjectPrimitive2DSequence());
pProcessor.reset();
if (mxVScrollbar->get_vpolicy() != VclPolicyType::NEVER)
{ // if there is a scrollbar shown, draw "..." to indicate the comment isn't // completely shown int x, y, width, height;
mxMenuButton->get_extents_relative_to(*m_xContainer, x, y, width, height);
Point aPos(rPt + PixelToLogic(Point(x, y)));
pDev->DrawText(aPos, u"..."_ustr);
}
pDev->Pop();
if (pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportTaggedPDF())
{
pPDFExtOutDevData->EndStructureElement();
}
}
// we should leave this setting alone, but for this we need a better layout algo // with variable meta size height
mxMetadataAuthor->set_font(maLabelFont);
// we should leave this setting alone, but for this we need a better layout algo // with variable meta size height
mxMetadataDate->set_font(maLabelFont);
// we should leave this setting alone, but for this we need a better layout algo // with variable meta size height
mxMetadataResolved->set_font(maLabelFont);
mxMetadataResolved->set_label(SwResId(STR_ACCESS_ANNOTATION_RESOLVED_NAME));
// actual window which holds the user text
mxSidebarTextControl.reset(new SidebarTextControl(*this, mrView, mrMgr));
mxSidebarTextControlWin.reset(new weld::CustomWeld(*m_xBuilder, u"editview"_ustr, *mxSidebarTextControl));
mxSidebarTextControl->SetPointer(PointerStyle::Text);
void SwAnnotationWin::UpdateColors()
{
std::size_t aIndex = SwModule::get()->InsertRedlineAuthor(GetAuthor());
SetColor( SwPostItMgr::GetColorDark(aIndex),
SwPostItMgr::GetColorLight(aIndex),
SwPostItMgr::GetColorAnchor(aIndex)); // draw comments either black or white depending on the document background // TODO: make editeng depend on the actual note background
mpOutlinerView->SetBackgroundColor(svtools::ColorConfig().GetColorValue(svtools::DOCCOLOR).nColor);
}
void SwAnnotationWin::SetMenuButtonColors()
{ if (!mxMenuButton) return;
void SwAnnotationWin::Rescale()
{ // On Android, this method leads to invoke ImpEditEngine::UpdateViews // which hides the text cursor. Moreover it causes sudden document scroll // when modifying a commented text. Not clear the root cause, // anyway skipping this method fixes the problem, and there should be // no side effect, since the client has disabled annotations rendering. if (comphelper::LibreOfficeKit::isActive() && !comphelper::LibreOfficeKit::isTiledAnnotations()) return;
if (mxMetadataAuthor)
mxMetadataAuthor->set_font(aFont); if (mxMetadataDate)
mxMetadataDate->set_font(aFont); if (mxMetadataResolved)
mxMetadataResolved->set_font(aFont);
SetMenuButtonColors(); if (mxVScrollbar)
mxVScrollbar->set_scroll_thickness(GetPrefScrollbarWidth());
}
if (bChange)
{
Point aLineStart;
Point aLineEnd ; switch ( meSidebarPosition )
{ 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( " - 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);
}
// For annotation text range rectangles to be calculated correctly, // we need the map mode disabled bool bDisableMapMode = comphelper::LibreOfficeKit::isActive() && EditWin().IsMapModeEnabled(); if (bDisableMapMode)
EditWin().EnableMapMode(false);
if (mpSidebarItem->maLayoutInfo.mPositionFromCommentAnchor)
pTmpCursorForAnnotationTextRange->FillRects();
if (aTextHeight > aHeight)
{ constint nThickness = mxVScrollbar->get_scroll_thickness(); if (nThickness)
{ // we need vertical scrollbars and have to reduce the width
aWidth -= nThickness;
mpOutliner->SetPaperSize(PixelToLogic(Size(aWidth, aHeight)));
}
mxVScrollbar->set_vpolicy(VclPolicyType::ALWAYS);
} else
{
mxVScrollbar->set_vpolicy(VclPolicyType::NEVER);
}
tools::Rectangle aOutputArea = PixelToLogic(tools::Rectangle(0, 0, aWidth, aHeight)); if (mxVScrollbar->get_vpolicy() == VclPolicyType::NEVER)
{ // if we do not have a scrollbar anymore, we want to see the complete text
mpOutlinerView->SetVisArea(aOutputArea);
}
mpOutlinerView->SetOutputArea(aOutputArea);
mpOutlinerView->ShowCursor(true, true);
// Don't leave an empty area at the bottom if we can move the text down.
tools::Long nMaxVisAreaTop = mpOutliner->GetTextHeight() - aOutputArea.GetHeight(); if (mpOutlinerView->GetVisArea().Top() > nMaxVisAreaTop)
{
GetOutlinerView()->Scroll(0, mpOutlinerView->GetVisArea().Top() - nMaxVisAreaTop);
}
int nUpper = mpOutliner->GetTextHeight(); int nCurrentDocPos = mpOutlinerView->GetVisArea().Top(); int nStepIncrement = mpOutliner->GetTextHeight() / 10; int nPageIncrement = PixelToLogic(Size(0,aHeight)).Height() * 8 / 10; int nPageSize = PixelToLogic(Size(0,aHeight)).Height();
/* limit the page size to below nUpper because gtk's gtk_scrolled_window_start_deceleration has effectively...
void SwAnnotationWin::SetSizePixel( const Size& rNewSize )
{ if (comphelper::LibreOfficeKit::isActive()) return;
InterimItemWindow::SetSizePixel(rNewSize);
if (mpShadow)
{
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()));
}
}
// prevent autoscroll to the old cursor location // when cursor out of visible area
GetOutlinerView()->ShowCursor(false);
if (SwWrtShell* pWrtShell = mrView.GetWrtShellPtr())
mpOutlinerView->GetEditView().SetInsertMode(pWrtShell->IsInsMode());
if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
GetOutlinerView()->SetBackgroundColor(mColorDark);
//tdf#119130 only have the active postit as a dialog control in which pressing //ctrl+tab cycles between text and button so we don't waste time searching //thousands of SwAnnotationWins
SetStyle(GetStyle() | WB_DIALOGCONTROL);
void SwAnnotationWin::DeactivatePostIt()
{ //tdf#119130 only have the active postit as a dialog control in which pressing //ctrl+tab cycles between text and button so we don't waste time searching //thousands of SwAnnotationWins
SetStyle(GetStyle() & ~WB_DIALOGCONTROL);
SetViewState(ViewState::NORMAL); // Make sure this view doesn't emit LOK callbacks during the update, as the // sidebar window's SidebarTextControl doesn't have a valid twip offset // (map mode origin) during that operation. bool bTiledPainting = comphelper::LibreOfficeKit::isTiledPainting();
comphelper::LibreOfficeKit::setTiledPainting(true); // write the visible text back into the SwField
UpdateData();
comphelper::LibreOfficeKit::setTiledPainting(bTiledPainting);
if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
GetOutlinerView()->SetBackgroundColor(COL_TRANSPARENT);
switch (nSlot)
{ case FN_POSTIT: case FN_REPLY:
{ constbool bReply = nSlot == FN_REPLY; // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note // will be created if (!mrMgr.IsAnswer() && mpOutliner->GetEditEngine().HasText())
{
OutlinerParaObject aPara(GetOutlinerView()->GetEditView().CreateTextObject());
mrMgr.RegisterAnswer(aPara);
} if (mrMgr.HasActiveSidebarWin())
mrMgr.SetActiveSidebarWin(nullptr);
SwitchToFieldPos();
// In this case, force generating the associated window // synchronously so we can bundle its use of the registered // "Answer" into the same undo group that the synchronous // FN_POSTIT was put in
mrMgr.GetOrCreateAnnotationWindowForLatestPostItField();
SwRewriter aRewriter;
aRewriter.AddRule(UndoArg1, pPostItField->GetDescription());
pShell->GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, &aRewriter);
} break;
} case FN_DELETE_COMMENT: //Delete(); // do not kill the parent of our open popup menu
mnDeleteEventId = Application::PostUserEvent( LINK( this, SwAnnotationWin, DeleteHdl), nullptr, true ); break; case FN_DELETE_COMMENT_THREAD:
DeleteThread(); break; case FN_RESOLVE_NOTE:
ToggleResolved();
DoResize();
Invalidate();
mrMgr.LayoutPostIts(); break; case FN_RESOLVE_NOTE_THREAD:
GetTopReplyNote()->SetResolved(!IsThreadResolved());
mrMgr.UpdateResolvedStatus(GetTopReplyNote());
DoResize();
Invalidate();
mrMgr.LayoutPostIts(); break; case FN_FORMAT_ALL_NOTES: case FN_DELETE_ALL_NOTES: case FN_HIDE_ALL_NOTES: // not possible as slot as this would require that "this" is the active postit
mrView.GetViewFrame().GetBindings().Execute( nSlot, nullptr, SfxCallMode::ASYNCHRON ); break; case FN_DELETE_NOTE_AUTHOR: case FN_HIDE_NOTE_AUTHOR:
{ // not possible as slot as this would require that "this" is the active postit
SfxStringItem aItem( nSlot, GetAuthor() ); const SfxPoolItem* aItems[2];
aItems[0] = &aItem;
aItems[1] = nullptr;
mrView.GetViewFrame().GetBindings().Execute( nSlot, aItems, SfxCallMode::ASYNCHRON );
} break; case FN_PROMOTE_COMMENT:
SetAsRoot();
DoResize();
Invalidate();
mrMgr.LayoutPostIts(); break; default:
mrView.GetViewFrame().GetBindings().Execute( nSlot ); break;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.