/src/libreoffice/sw/source/uibase/inc/srcedtw.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 | | #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_SRCEDTW_HXX |
20 | | #define INCLUDED_SW_SOURCE_UIBASE_INC_SRCEDTW_HXX |
21 | | |
22 | | #include <vcl/window.hxx> |
23 | | #include <svl/lstner.hxx> |
24 | | #include <vcl/timer.hxx> |
25 | | #include <vcl/idle.hxx> |
26 | | |
27 | | #include <vcl/xtextedt.hxx> |
28 | | #include <mutex> |
29 | | #include <set> |
30 | | |
31 | | namespace com::sun::star::beans { class XMultiPropertySet; } |
32 | | namespace weld { class Scrollbar; } |
33 | | class ScrollAdaptor; |
34 | | class SwSrcView; |
35 | | class TextEngine; |
36 | | class TextView; |
37 | | |
38 | | class TextViewOutWin final : public vcl::Window |
39 | | { |
40 | | TextView* m_pTextView; |
41 | | |
42 | | virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override; |
43 | | virtual void KeyInput( const KeyEvent& rKeyEvt ) override; |
44 | | virtual void MouseMove( const MouseEvent& rMEvt ) override; |
45 | | virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; |
46 | | virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; |
47 | | virtual void Command( const CommandEvent& rCEvt ) override; |
48 | | virtual void DataChanged( const DataChangedEvent& ) override; |
49 | | |
50 | | public: |
51 | | TextViewOutWin(vcl::Window* pParent, WinBits nBits) : |
52 | 0 | Window(pParent, nBits), m_pTextView(nullptr){} |
53 | | |
54 | 0 | void SetTextView( TextView* pView ) {m_pTextView = pView;} |
55 | | |
56 | | }; |
57 | | |
58 | | class SwSrcEditWindow final : public vcl::Window, public SfxListener |
59 | | { |
60 | | private: |
61 | | class ChangesListener; |
62 | | friend class ChangesListener; |
63 | | std::unique_ptr<TextView> m_pTextView; |
64 | | std::unique_ptr<ExtTextEngine> m_pTextEngine; |
65 | | |
66 | | VclPtr<TextViewOutWin> m_pOutWin; |
67 | | VclPtr<ScrollAdaptor> m_pHScrollbar, |
68 | | m_pVScrollbar; |
69 | | |
70 | | SwSrcView* m_pSrcView; |
71 | | |
72 | | rtl::Reference< ChangesListener > m_xListener; |
73 | | std::mutex mutex_; |
74 | | css::uno::Reference< css::beans::XMultiPropertySet > |
75 | | m_xNotifier; |
76 | | |
77 | | tools::Long m_nCurTextWidth; |
78 | | sal_uInt16 m_nStartLine; |
79 | | rtl_TextEncoding m_eSourceEncoding; |
80 | | bool m_bReadonly; |
81 | | bool m_bHighlighting; |
82 | | |
83 | | Idle m_aSyntaxIdle; |
84 | | std::set<sal_uInt16> m_aSyntaxLineTable; |
85 | | |
86 | | void ImpDoHighlight( std::u16string_view aSource, sal_uInt16 nLineOff ); |
87 | | |
88 | | void SetFont(); |
89 | | |
90 | | DECL_LINK( SyntaxTimerHdl, Timer *, void ); |
91 | | |
92 | | virtual void Resize() override; |
93 | | virtual void DataChanged( const DataChangedEvent& ) override; |
94 | | virtual void GetFocus() override; |
95 | | |
96 | | void CreateTextEngine(); |
97 | | void DoSyntaxHighlight( sal_uInt16 nPara ); |
98 | | |
99 | | virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; |
100 | | |
101 | | DECL_LINK(HorzScrollHdl, weld::Scrollbar&, void); |
102 | | DECL_LINK(VertScrollHdl, weld::Scrollbar&, void); |
103 | | |
104 | | public: |
105 | | SwSrcEditWindow( vcl::Window* pParent, SwSrcView* pParentView ); |
106 | | virtual ~SwSrcEditWindow() override; |
107 | | virtual void dispose() override; |
108 | | |
109 | | void SetScrollBarRanges(); |
110 | | void InitScrollBars(); |
111 | 0 | void Read(SvStream& rInput) { m_pTextEngine->Read(rInput); } |
112 | 0 | void Write(SvStream& rOutput) { m_pTextEngine->Write(rOutput); } |
113 | | |
114 | | TextView* GetTextView() |
115 | 0 | {return m_pTextView.get();} |
116 | | TextEngine* GetTextEngine() |
117 | 0 | {return m_pTextEngine.get();} |
118 | 0 | SwSrcView* GetSrcView() {return m_pSrcView;} |
119 | | |
120 | 0 | TextViewOutWin* GetOutWin() {return m_pOutWin;} |
121 | | |
122 | | virtual void ImplInvalidate( const vcl::Region* pRegion, InvalidateFlags nFlags ) override; |
123 | | |
124 | | void ClearModifyFlag() |
125 | 0 | { m_pTextEngine->SetModified(false); } |
126 | | bool IsModified() const |
127 | 0 | { return m_pTextEngine->IsModified();} |
128 | | |
129 | 0 | void SetReadonly(bool bSet){m_bReadonly = bSet;} |
130 | 0 | bool IsReadonly() const {return m_bReadonly;} |
131 | | |
132 | 0 | void SetStartLine(sal_uInt16 nLine){m_nStartLine = nLine;} |
133 | | |
134 | | virtual void Command( const CommandEvent& rCEvt ) override; |
135 | | void HandleWheelCommand( const CommandEvent& rCEvt ); |
136 | | |
137 | | void SetTextEncoding(rtl_TextEncoding eEncoding); |
138 | | }; |
139 | | |
140 | | #endif |
141 | | |
142 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |