summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-04-19 22:36:41 +0900
committerTomaž Vajngerl <quikee@gmail.com>2024-05-14 12:43:10 +0200
commit2791964914ba19b636ce49a60508bcab7af675cd (patch)
tree49acd5388689aa72fa7110fc67cd485bab95f21d /include
parent7dd7cb6f6c6812fc9ef56de3114d07c68e02f2b2 (diff)
annot: move TextAPI to svx and adapt the code
TextApiObject is derived from SvxUnoText and holds and handles the text in the annotation. This functionality is changed to get rid of sd module specifics and moved to svx module. This now allows to move the most improtant parts of the Annotation object to svx. Change-Id: I34e238616e7fac973e75e79bb60a8d093c493258 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166497 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/svx/annotation/Annotation.hxx18
-rw-r--r--include/svx/annotation/TextAPI.hxx56
2 files changed, 70 insertions, 4 deletions
diff --git a/include/svx/annotation/Annotation.hxx b/include/svx/annotation/Annotation.hxx
index 5ec5e2ec3c34..be378d6a61de 100644
--- a/include/svx/annotation/Annotation.hxx
+++ b/include/svx/annotation/Annotation.hxx
@@ -20,6 +20,7 @@
#include <comphelper/compbase.hxx>
#include <cppuhelper/propertysetmixin.hxx>
#include <svx/annotation/Annotation.hxx>
+#include <svx/annotation/TextAPI.hxx>
class SdrUndoAction;
class SfxViewShell;
@@ -70,6 +71,7 @@ protected:
OUString m_Author;
OUString m_Initials;
css::util::DateTime m_DateTime;
+ rtl::Reference<sdr::annotation::TextApiObject> m_TextRange;
bool m_bIsFreeText = false;
@@ -84,11 +86,11 @@ public:
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const& type) override;
virtual void SAL_CALL acquire() noexcept override
{
- ::comphelper::WeakComponentImplHelper<css::office::XAnnotation>::acquire();
+ comphelper::WeakComponentImplHelper<css::office::XAnnotation>::acquire();
}
virtual void SAL_CALL release() noexcept override
{
- ::comphelper::WeakComponentImplHelper<css::office::XAnnotation>::release();
+ comphelper::WeakComponentImplHelper<css::office::XAnnotation>::release();
}
css::geometry::RealPoint2D GetPosition() const { return m_Position; }
@@ -106,8 +108,16 @@ public:
css::util::DateTime GetDateTime() const { return m_DateTime; }
void SetDateTime(const css::util::DateTime& rValue) { m_DateTime = rValue; }
- virtual OUString GetText() = 0;
- virtual void SetText(OUString const& rText) = 0;
+ virtual css::uno::Reference<css::text::XText> SAL_CALL getTextRange() override;
+
+ // override WeakComponentImplHelperBase::disposing()
+ // This function is called upon disposing the component,
+ // if your component needs special work when it becomes
+ // disposed, do it here.
+ virtual void disposing(std::unique_lock<std::mutex>& rGuard) override;
+
+ OUString GetText();
+ void SetText(OUString const& rText);
SdrModel* GetModel() const;
SdrPage const* getPage() const { return mpPage; }
diff --git a/include/svx/annotation/TextAPI.hxx b/include/svx/annotation/TextAPI.hxx
new file mode 100644
index 000000000000..c227b4a803c5
--- /dev/null
+++ b/include/svx/annotation/TextAPI.hxx
@@ -0,0 +1,56 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <editeng/unotext.hxx>
+#include <rtl/ref.hxx>
+#include <editeng/outliner.hxx>
+#include <svx/svxdllapi.h>
+
+class SdrModel;
+
+namespace sdr::annotation
+{
+class TextAPIEditSource;
+
+class SVXCORE_DLLPUBLIC TextApiObject final : public SvxUnoText
+{
+public:
+ static rtl::Reference<TextApiObject> create(SdrModel* pModel);
+
+ virtual ~TextApiObject() noexcept override;
+
+ /// @throws css::uno::RuntimeException
+ void dispose();
+
+ std::optional<OutlinerParaObject> CreateText();
+ void SetText(OutlinerParaObject const& rText);
+ OUString GetText() const;
+
+ static TextApiObject* getImplementation(const css::uno::Reference<css::text::XText>&);
+
+private:
+ std::unique_ptr<TextAPIEditSource> mpSource;
+ TextApiObject(std::unique_ptr<TextAPIEditSource> pEditSource);
+};
+
+} // namespace sdr::annotation
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */