summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-04-19 15:34:06 +0900
committerMiklos Vajna <vmiklos@collabora.com>2024-06-11 09:39:49 +0200
commit037196e6355115ea79a10cb6020e6fcaa6958082 (patch)
treea27a63a2a1fbc0bea0ffdf829e6870372e075b1c /svx/source
parent3693180fd7ce9520faa07f71e71ddaa4fa4e27b0 (diff)
annot: moved more of Annotation and dependencies into svx
Moved the holder of annotations from SdPage to SvxPage, so that the vector holding the annotations and accessors are on SvxPage and adapted the code. This also changes the type od most parameters on most methods from sd::Annotation to sdr::annotation::Annotation and adapted the code. Moved AnnotationEnumeration into svx, as it was needed in svx already. Change-Id: Iab17aa881443f58adfb9158959db00ed24076279 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166494 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit a0a581ead18f030f59d203539706de0230746cae) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168555 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/annotation/Annotation.cxx21
-rw-r--r--svx/source/annotation/AnnotationEnumeration.cxx80
-rw-r--r--svx/source/svdraw/svdpage.cxx1
3 files changed, 102 insertions, 0 deletions
diff --git a/svx/source/annotation/Annotation.cxx b/svx/source/annotation/Annotation.cxx
index afa8d0f525dd..7654d047f4a1 100644
--- a/svx/source/annotation/Annotation.cxx
+++ b/svx/source/annotation/Annotation.cxx
@@ -8,6 +8,7 @@
*/
#include <svx/annotation/Annotation.hxx>
+#include <svx/svdpage.hxx>
#include <tools/json_writer.hxx>
#include <sfx2/viewsh.hxx>
#include <unotools/datetime.hxx>
@@ -136,8 +137,28 @@ void AnnotationData::set(Annotation& rAnnotation)
rAnnotation.SetText(m_Text);
}
+Annotation::Annotation(const css::uno::Reference<css::uno::XComponentContext>& rxContext,
+ SdrPage* pPage)
+ : cppu::WeakComponentImplHelper<office::XAnnotation>(m_aMutex)
+ , cppu::PropertySetMixin<office::XAnnotation>(rxContext, IMPLEMENTS_PROPERTY_SET,
+ uno::Sequence<OUString>())
+ , mpPage(pPage)
+ , m_nId(nextID())
+{
+}
+
sal_uInt32 Annotation::m_nLastId = 1;
+SdrModel* Annotation::GetModel() const
+{
+ return mpPage != nullptr ? &mpPage->getSdrModelFromSdrPage() : nullptr;
+}
+
+uno::Any Annotation::queryInterface(uno::Type const& type)
+{
+ return ::cppu::WeakComponentImplHelper<office::XAnnotation>::queryInterface(type);
+}
+
std::unique_ptr<SdrUndoAction> Annotation::createUndoAnnotation()
{
return std::make_unique<UndoAnnotation>(*this);
diff --git a/svx/source/annotation/AnnotationEnumeration.cxx b/svx/source/annotation/AnnotationEnumeration.cxx
new file mode 100644
index 000000000000..443a04f8c217
--- /dev/null
+++ b/svx/source/annotation/AnnotationEnumeration.cxx
@@ -0,0 +1,80 @@
+/* -*- 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 .
+ */
+
+#include <sal/config.h>
+
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <com/sun/star/office/XAnnotationEnumeration.hpp>
+
+#include <svx/annotation/Annotation.hxx>
+#include <svx/annotation/AnnotationEnumeration.hxx>
+
+using namespace css;
+
+namespace sdr::annotation
+{
+namespace
+{
+class AnnotationEnumeration : public ::cppu::WeakImplHelper<css::office::XAnnotationEnumeration>
+{
+public:
+ explicit AnnotationEnumeration(AnnotationVector&& rAnnotations);
+ AnnotationEnumeration(const AnnotationEnumeration&) = delete;
+ AnnotationEnumeration& operator=(const AnnotationEnumeration&) = delete;
+
+ // css::office::XAnnotationEnumeration:
+ virtual sal_Bool SAL_CALL hasMoreElements() override;
+ virtual css::uno::Reference<css::office::XAnnotation> SAL_CALL nextElement() override;
+
+private:
+ // destructor is private and will be called indirectly by the release call virtual ~AnnotationEnumeration() {}
+
+ AnnotationVector maAnnotations;
+ AnnotationVector::iterator maIter;
+};
+
+} // end anonymous ns
+
+uno::Reference<office::XAnnotationEnumeration>
+createAnnotationEnumeration(AnnotationVector&& rAnnotations)
+{
+ return new AnnotationEnumeration(std::move(rAnnotations));
+}
+
+AnnotationEnumeration::AnnotationEnumeration(AnnotationVector&& rAnnotations)
+ : maAnnotations(std::move(rAnnotations))
+{
+ maIter = maAnnotations.begin();
+}
+
+// css::office::XAnnotationEnumeration:
+sal_Bool SAL_CALL AnnotationEnumeration::hasMoreElements() { return maIter != maAnnotations.end(); }
+
+css::uno::Reference<css::office::XAnnotation> SAL_CALL AnnotationEnumeration::nextElement()
+{
+ if (maIter == maAnnotations.end())
+ throw css::container::NoSuchElementException();
+
+ return (*maIter++);
+}
+
+} // end sdr::annotation
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index 49a3025759b5..c6e570fdaf6c 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -51,6 +51,7 @@
#include <sdr/contact/viewcontactofsdrpage.hxx>
#include <svx/sdr/contact/viewobjectcontact.hxx>
#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/annotation/Annotation.hxx>
#include <algorithm>
#include <clonelist.hxx>
#include <svl/hint.hxx>