1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_SRCEDTW_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_SRCEDTW_HXX
22 #include <vcl/window.hxx>
23 #include <svl/lstner.hxx>
24 #include <vcl/timer.hxx>
25 #include <vcl/idle.hxx>
27 #include <vcl/xtextedt.hxx>
30 namespace com::sun::star::beans
{ class XMultiPropertySet
; }
33 class SwSrcEditWindow
;
36 class DataChangedEvent
;
38 class TextViewOutWin
: public vcl::Window
43 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& ) override
;
44 virtual void KeyInput( const KeyEvent
& rKeyEvt
) override
;
45 virtual void MouseMove( const MouseEvent
& rMEvt
) override
;
46 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
47 virtual void MouseButtonUp( const MouseEvent
& rMEvt
) override
;
48 virtual void Command( const CommandEvent
& rCEvt
) override
;
49 virtual void DataChanged( const DataChangedEvent
& ) override
;
52 TextViewOutWin(vcl::Window
* pParent
, WinBits nBits
) :
53 Window(pParent
, nBits
), pTextView(nullptr){}
55 void SetTextView( TextView
* pView
) {pTextView
= pView
;}
59 class SwSrcEditWindow
: public vcl::Window
, public SfxListener
62 class ChangesListener
;
63 friend class ChangesListener
;
64 std::unique_ptr
<TextView
> m_pTextView
;
65 std::unique_ptr
<ExtTextEngine
> m_pTextEngine
;
67 VclPtr
<TextViewOutWin
> m_pOutWin
;
68 VclPtr
<ScrollBar
> m_pHScrollbar
,
71 SwSrcView
* m_pSrcView
;
73 rtl::Reference
< ChangesListener
> m_xListener
;
75 css::uno::Reference
< css::beans::XMultiPropertySet
>
78 tools::Long m_nCurTextWidth
;
79 sal_uInt16 m_nStartLine
;
80 rtl_TextEncoding m_eSourceEncoding
;
85 std::set
<sal_uInt16
> m_aSyntaxLineTable
;
87 void ImpDoHighlight( const OUString
& rSource
, sal_uInt16 nLineOff
);
89 using OutputDevice::SetFont
;
92 DECL_LINK( SyntaxTimerHdl
, Timer
*, void );
94 using Window::Invalidate
;
98 virtual void Resize() override
;
99 virtual void DataChanged( const DataChangedEvent
& ) override
;
100 virtual void GetFocus() override
;
101 // virtual void LoseFocus();
103 void CreateTextEngine();
104 void DoSyntaxHighlight( sal_uInt16 nPara
);
106 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
108 DECL_LINK(ScrollHdl
, ScrollBar
*, void);
111 SwSrcEditWindow( vcl::Window
* pParent
, SwSrcView
* pParentView
);
112 virtual ~SwSrcEditWindow() override
;
113 virtual void dispose() override
;
115 void SetScrollBarRanges();
116 void InitScrollBars();
117 void Read(SvStream
& rInput
) { m_pTextEngine
->Read(rInput
); }
118 void Write(SvStream
& rOutput
) { m_pTextEngine
->Write(rOutput
); }
120 TextView
* GetTextView()
121 {return m_pTextView
.get();}
122 TextEngine
* GetTextEngine()
123 {return m_pTextEngine
.get();}
124 SwSrcView
* GetSrcView() {return m_pSrcView
;}
126 TextViewOutWin
* GetOutWin() {return m_pOutWin
;}
128 virtual void Invalidate( InvalidateFlags nFlags
= InvalidateFlags::NONE
) override
;
130 void ClearModifyFlag()
131 { m_pTextEngine
->SetModified(false); }
132 bool IsModified() const
133 { return m_pTextEngine
->IsModified();}
135 void SetReadonly(bool bSet
){m_bReadonly
= bSet
;}
136 bool IsReadonly() const {return m_bReadonly
;}
138 void SetStartLine(sal_uInt16 nLine
){m_nStartLine
= nLine
;}
140 virtual void Command( const CommandEvent
& rCEvt
) override
;
141 void HandleWheelCommand( const CommandEvent
& rCEvt
);
143 void SetTextEncoding(rtl_TextEncoding eEncoding
);
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */