Line data Source code
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 : #ifndef INCLUDED_SD_SOURCE_UI_ANNOTATIONS_ANNOTATIONWINDOW_HXX
21 : #define INCLUDED_SD_SOURCE_UI_ANNOTATIONS_ANNOTATIONWINDOW_HXX
22 :
23 : #include <com/sun/star/office/XAnnotation.hpp>
24 :
25 : #include <vcl/ctrl.hxx>
26 : #include <vcl/lineinfo.hxx>
27 : #include <vcl/floatwin.hxx>
28 :
29 : #include <basegfx/polygon/b2dpolygon.hxx>
30 :
31 : #include <svx/sdr/overlay/overlayobject.hxx>
32 : #include <editeng/editstat.hxx>
33 :
34 : class OutlinerView;
35 : class Outliner;
36 : class ScrollBar;
37 : class MultiLineEdit;
38 : class SvxLanguageItem;
39 : class SdDrawDocument;
40 :
41 : namespace sd {
42 :
43 : class AnnotationManagerImpl;
44 : class AnnotationWindow;
45 : class DrawDocShell;
46 : class TextApiObject;
47 : class View;
48 :
49 : class AnnotationTextWindow : public Control
50 : {
51 : private:
52 : OutlinerView* mpOutlinerView;
53 : VclPtr<AnnotationWindow> mpAnnotationWindow;
54 :
55 : protected:
56 : virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect) SAL_OVERRIDE;
57 : virtual void KeyInput( const KeyEvent& rKeyEvt ) SAL_OVERRIDE;
58 : virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
59 : virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
60 : virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
61 : virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
62 : virtual void LoseFocus() SAL_OVERRIDE;
63 :
64 : public:
65 : AnnotationTextWindow( AnnotationWindow* pParent, WinBits nBits );
66 : virtual ~AnnotationTextWindow();
67 : virtual void dispose() SAL_OVERRIDE;
68 :
69 0 : void SetOutlinerView( OutlinerView* pOutlinerView ) { mpOutlinerView = pOutlinerView; }
70 :
71 : virtual OUString GetSurroundingText() const SAL_OVERRIDE;
72 : virtual Selection GetSurroundingTextSelection() const SAL_OVERRIDE;
73 :
74 : virtual void GetFocus() SAL_OVERRIDE;
75 : };
76 :
77 : class AnnotationWindow : public FloatingWindow
78 : {
79 : private:
80 : AnnotationManagerImpl& mrManager;
81 : DrawDocShell* mpDocShell;
82 : View* mpView;
83 : SdDrawDocument* mpDoc;
84 :
85 : OutlinerView* mpOutlinerView;
86 : Outliner* mpOutliner;
87 : VclPtr<ScrollBar> mpVScrollbar;
88 : ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > mxAnnotation;
89 : bool mbReadonly;
90 : bool mbProtected;
91 : bool mbMouseOverButton;
92 : VclPtr<AnnotationTextWindow> mpTextWindow;
93 : VclPtr<MultiLineEdit> mpMeta;
94 : Rectangle maRectMetaButton;
95 : basegfx::B2DPolygon maPopupTriangle;
96 :
97 : protected:
98 : void SetSizePixel( const Size& rNewSize ) SAL_OVERRIDE;
99 :
100 : DECL_LINK(ScrollHdl, ScrollBar*);
101 :
102 : public:
103 : AnnotationWindow( AnnotationManagerImpl& rManager, DrawDocShell* pDocShell, vcl::Window* pParent );
104 : virtual ~AnnotationWindow();
105 : virtual void dispose() SAL_OVERRIDE;
106 :
107 : void StartEdit();
108 :
109 : SvxLanguageItem GetLanguage();
110 :
111 : void setAnnotation( const ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation, bool bGrabFocus = false );
112 : const ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& getAnnotation() const { return mxAnnotation; }
113 :
114 : void ExecuteSlot( sal_uInt16 nSID );
115 :
116 : ScrollBar* Scrollbar() { return mpVScrollbar;}
117 :
118 0 : DrawDocShell* DocShell() { return mpDocShell; }
119 0 : OutlinerView* getView() { return mpOutlinerView; }
120 0 : sd::View* DocView() { return mpView; }
121 0 : Outliner* Engine() { return mpOutliner; }
122 0 : SdDrawDocument* Doc() { return mpDoc; }
123 :
124 : long GetPostItTextHeight();
125 :
126 : void InitControls();
127 : void HidePostIt();
128 : void DoResize();
129 : void ResizeIfNecessary(long aOldHeight, long aNewHeight);
130 : void SetScrollbar();
131 :
132 : void Rescale();
133 :
134 : bool IsReadOnly() { return mbReadonly;}
135 :
136 0 : bool IsProtected() { return mbProtected; }
137 :
138 : void SetLanguage(const SvxLanguageItem &aNewItem);
139 :
140 0 : static sal_Int32 GetScrollbarWidth() { return 16; }
141 :
142 : void ToggleInsMode();
143 :
144 : DECL_LINK( OnlineSpellCallback, SpellCallbackInfo*);
145 :
146 : virtual void Deactivate() SAL_OVERRIDE;
147 : virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect) SAL_OVERRIDE;
148 : virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
149 : virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
150 : virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
151 : virtual void GetFocus() SAL_OVERRIDE;
152 :
153 : void SetColor();
154 :
155 : Color maColor;
156 : Color maColorDark;
157 : Color maColorLight;
158 : };
159 :
160 : TextApiObject* getTextApiObject( const css::uno::Reference< css::office::XAnnotation >& xAnnotation );
161 :
162 :
163 : } // namespace sd
164 :
165 : #endif
166 :
167 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|