/* -*- 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/. */ #include #include #include "AnnotationPopup.hxx" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "annotationmanagerimpl.hxx" #include "annotationwindow.hxx" #include #include #include #include #include #include using namespace ::com::sun::star; namespace sd { AnnotationPopup::AnnotationPopup(rtl::Reference const& xAnnotation) : sdr::annotation::IAnnotationPopup(xAnnotation) { } AnnotationPopup::~AnnotationPopup() {} IMPL_LINK_NOARG(AnnotationPopup, PopupModeEndHdl, weld::Popover&, void) { closePopup(); } void AnnotationPopup::closePopup() { if (mpAnnotationWindow) { mpAnnotationWindow->SaveToDocument(); mpAnnotationWindow.reset(); } } void AnnotationPopup::openPopup() { if (!mxAnnotation.is()) return; sd::DrawDocShell* pDocShell = dynamic_cast(SfxObjectShell::Current()); sd::ViewShell* pViewShell = pDocShell ? pDocShell->GetViewShell() : nullptr; if (!pViewShell) return; if (!mpAnnotationWindow) { vcl::Window* pWindow = pViewShell->GetActiveWindow(); if (pWindow) { auto aRealPosition2D = mxAnnotation->getPosition(); Point aPosition(::tools::Long(aRealPosition2D.X * 100.0), ::tools::Long(aRealPosition2D.Y * 100.0)); Point aPositionPixel = pWindow->LogicToPixel(aPosition); aPositionPixel.AdjustX(4); aPositionPixel.AdjustY(1); auto aRealSize2D = mxAnnotation->getSize(); Size aSize(::tools::Long(aRealSize2D.Width * 100.0), ::tools::Long(aRealSize2D.Height * 100.0)); Size aSizePixel = pWindow->LogicToPixel(aSize); ::tools::Rectangle aRectangle(aPositionPixel, aSizePixel); weld::Window* pParent = weld::GetPopupParent(*pWindow, aRectangle); mpAnnotationWindow.reset( new AnnotationWindow(pParent, aRectangle, pDocShell, mxAnnotation)); mpAnnotationWindow->connect_closed(LINK(this, AnnotationPopup, PopupModeEndHdl)); } } if (mpAnnotationWindow) mpAnnotationWindow->StartEdit(); } } // end of namespace sd /* vim:set shiftwidth=4 softtabstop=4 expandtab: */