/src/libreoffice/sd/source/ui/annotations/annotationwindow.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <vcl/weld/Builder.hxx> |
23 | | #include <vcl/weld/weld.hxx> |
24 | | #include <tools/long.hxx> |
25 | | #include <svx/weldeditview.hxx> |
26 | | #include <svx/annotation/Annotation.hxx> |
27 | | |
28 | | |
29 | | class OutlinerView; |
30 | | class Outliner; |
31 | | class SvxLanguageItem; |
32 | | class SdDrawDocument; |
33 | | |
34 | | namespace sdr::annotation { class TextApiObject; } |
35 | | |
36 | | namespace sd |
37 | | { |
38 | | |
39 | | class DrawDocShell; |
40 | | class AnnotationWindow; |
41 | | |
42 | | class AnnotationTextWindow : public WeldEditView |
43 | | { |
44 | | private: |
45 | | AnnotationWindow& mrContents; |
46 | | |
47 | | public: |
48 | | AnnotationTextWindow(AnnotationWindow& rContents); |
49 | | |
50 | | virtual EditView* GetEditView() const override; |
51 | | |
52 | | virtual EditEngine* GetEditEngine() const override; |
53 | | |
54 | | virtual void EditViewScrollStateChange() override; |
55 | | |
56 | | void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; |
57 | | |
58 | | virtual void Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) override; |
59 | | virtual bool KeyInput(const KeyEvent& rKeyEvt) override; |
60 | | virtual bool Command(const CommandEvent& rCEvt) override; |
61 | | }; |
62 | | |
63 | | class AnnotationWindow final |
64 | | { |
65 | | private: |
66 | | std::unique_ptr<weld::Builder> mxBuilder; |
67 | | std::unique_ptr<weld::Popover> mxPopover; |
68 | | std::unique_ptr<weld::Widget> mxContainer; |
69 | | |
70 | | DrawDocShell* mpDocShell; |
71 | | SdDrawDocument* mpDoc; |
72 | | |
73 | | bool mbReadonly; |
74 | | bool mbProtected; |
75 | | |
76 | | rtl::Reference<sdr::annotation::Annotation> mxAnnotation; |
77 | | |
78 | | public: |
79 | | Color maColor; |
80 | | Color maColorDark; |
81 | | Color maColorLight; |
82 | | |
83 | | private: |
84 | | vcl::Font maLabelFont; |
85 | | |
86 | | std::unique_ptr<OutlinerView> mpOutlinerView; |
87 | | std::unique_ptr<::Outliner> mpOutliner; |
88 | | |
89 | | std::unique_ptr<weld::ScrolledWindow> mxVScrollbar; |
90 | | std::unique_ptr<WeldEditView> mxTextControl; |
91 | | std::unique_ptr<weld::CustomWeld> mxTextControlWin; |
92 | | std::unique_ptr<weld::Label> mxMeta; |
93 | | std::unique_ptr<weld::MenuButton> mxMenuButton; |
94 | | |
95 | | DECL_LINK(ScrollHdl, weld::ScrolledWindow&, void); |
96 | | DECL_LINK(MenuItemSelectedHdl, const OUString&, void); |
97 | | |
98 | | void FillMenuButton(); |
99 | | void InitControls(); |
100 | | |
101 | | void SetMapMode(const MapMode& rNewMapMode); |
102 | | void setAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation); |
103 | | |
104 | 0 | static sal_Int32 GetPrefScrollbarWidth() { return 16; } |
105 | | public: |
106 | | AnnotationWindow(weld::Window* pParent, const ::tools::Rectangle& rRect, DrawDocShell* pDocShell, |
107 | | const rtl::Reference<sdr::annotation::Annotation>& xAnnotation); |
108 | | ~AnnotationWindow(); |
109 | | |
110 | 0 | void connect_closed(const Link<weld::Popover&, void>& rLink) { mxPopover->connect_closed(rLink); } |
111 | | |
112 | | void DoResize(); |
113 | | void ResizeIfNecessary(::tools::Long aOldHeight, ::tools::Long aNewHeight); |
114 | | void SetScrollbar(); |
115 | | void StartEdit(); |
116 | | |
117 | 0 | const rtl::Reference<sdr::annotation::Annotation>& getAnnotation() const { return mxAnnotation; } |
118 | | |
119 | | void SaveToDocument(); |
120 | | |
121 | | ::tools::Long GetPostItTextHeight(); |
122 | | |
123 | 0 | DrawDocShell* DocShell() { return mpDocShell; } |
124 | | |
125 | | void SetLanguage(const SvxLanguageItem &aNewItem); |
126 | | |
127 | | void Rescale(); |
128 | | |
129 | | void ToggleInsMode(); |
130 | | |
131 | 0 | bool IsProtected() const { return mbProtected; } |
132 | | |
133 | 0 | OutlinerView* GetOutlinerView() { return mpOutlinerView.get();} |
134 | 0 | ::Outliner* GetOutliner() { return mpOutliner.get();} |
135 | | |
136 | | void SetColor(); |
137 | | }; |
138 | | |
139 | | sdr::annotation::TextApiObject* getTextApiObject( const css::uno::Reference< css::office::XAnnotation >& xAnnotation ); |
140 | | |
141 | | |
142 | | } // namespace sd |
143 | | |
144 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |