LibreOffice Module sw (master)  1
srcedtw.hxx
Go to the documentation of this file.
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 <set>
29 
30 namespace com::sun::star::beans { class XMultiPropertySet; }
31 class ScrollBar;
32 class SwSrcView;
33 class SwSrcEditWindow;
34 class TextEngine;
35 class TextView;
36 class DataChangedEvent;
37 
39 {
41 
42 protected:
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;
50 
51 public:
52  TextViewOutWin(vcl::Window* pParent, WinBits nBits) :
53  Window(pParent, nBits), pTextView(nullptr){}
54 
55  void SetTextView( TextView* pView ) {pTextView = pView;}
56 
57 };
58 
59 class SwSrcEditWindow : public vcl::Window, public SfxListener
60 {
61 private:
63  friend class ChangesListener;
64  std::unique_ptr<TextView> m_pTextView;
65  std::unique_ptr<ExtTextEngine> m_pTextEngine;
66 
70 
72 
74  osl::Mutex mutex_;
75  css::uno::Reference< css::beans::XMultiPropertySet >
77 
79  sal_uInt16 m_nStartLine;
80  rtl_TextEncoding m_eSourceEncoding;
83 
85  std::set<sal_uInt16> m_aSyntaxLineTable;
86 
87  void ImpDoHighlight( const OUString& rSource, sal_uInt16 nLineOff );
88 
90  void SetFont();
91 
92  DECL_LINK( SyntaxTimerHdl, Timer *, void );
93 
94  using Window::Invalidate;
95 
96 protected:
97 
98  virtual void Resize() override;
99  virtual void DataChanged( const DataChangedEvent& ) override;
100  virtual void GetFocus() override;
101 // virtual void LoseFocus();
102 
103  void CreateTextEngine();
104  void DoSyntaxHighlight( sal_uInt16 nPara );
105 
106  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
107 
108  DECL_LINK(ScrollHdl, ScrollBar*, void);
109 
110 public:
111  SwSrcEditWindow( vcl::Window* pParent, SwSrcView* pParentView );
112  virtual ~SwSrcEditWindow() override;
113  virtual void dispose() override;
114 
115  void SetScrollBarRanges();
116  void InitScrollBars();
117  void Read(SvStream& rInput) { m_pTextEngine->Read(rInput); }
118  void Write(SvStream& rOutput) { m_pTextEngine->Write(rOutput); }
119 
121  {return m_pTextView.get();}
123  {return m_pTextEngine.get();}
125 
127 
128  virtual void Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE ) override;
129 
131  { m_pTextEngine->SetModified(false); }
132  bool IsModified() const
133  { return m_pTextEngine->IsModified();}
134 
135  void SetReadonly(bool bSet){m_bReadonly = bSet;}
136  bool IsReadonly() const {return m_bReadonly;}
137 
138  void SetStartLine(sal_uInt16 nLine){m_nStartLine = nLine;}
139 
140  virtual void Command( const CommandEvent& rCEvt ) override;
141  void HandleWheelCommand( const CommandEvent& rCEvt );
142 
143  void SetTextEncoding(rtl_TextEncoding eEncoding);
144 };
145 
146 #endif
147 
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
TextEngine * GetTextEngine()
Definition: srcedtw.hxx:122
virtual void Command(const CommandEvent &rCEvt) override
Definition: srcedtw.cxx:762
void InitScrollBars()
Definition: srcedtw.cxx:553
void SetReadonly(bool bSet)
Definition: srcedtw.hxx:135
virtual void KeyInput(const KeyEvent &rKeyEvt) override
Definition: srcedtw.cxx:450
InvalidateFlags
void HandleWheelCommand(const CommandEvent &rCEvt)
Definition: srcedtw.cxx:780
Window(vcl::Window *pParent, WinBits nStyle=0)
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: srcedtw.cxx:394
long Long
SwSrcView * GetSrcView()
Definition: srcedtw.hxx:124
VclPtr< ScrollBar > m_pVScrollbar
Definition: srcedtw.hxx:68
sal_uInt16 m_nStartLine
Definition: srcedtw.hxx:79
rtl::Reference< ChangesListener > m_xListener
Definition: srcedtw.hxx:73
SwSrcView * m_pSrcView
Definition: srcedtw.hxx:71
virtual void DataChanged(const DataChangedEvent &) override
Definition: srcedtw.cxx:302
TextViewOutWin * GetOutWin()
Definition: srcedtw.hxx:126
VclPtr< ScrollBar > m_pHScrollbar
Definition: srcedtw.hxx:68
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: srcedtw.cxx:416
sal_Int64 WinBits
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: srcedtw.cxx:400
TextView * pTextView
Definition: srcedtw.hxx:40
std::unique_ptr< ExtTextEngine > m_pTextEngine
Definition: srcedtw.hxx:65
VclPtr< TextViewOutWin > m_pOutWin
Definition: srcedtw.hxx:67
void SetTextEncoding(rtl_TextEncoding eEncoding)
Definition: srcedtw.cxx:989
void DoSyntaxHighlight(sal_uInt16 nPara)
Definition: srcedtw.cxx:643
bool m_bHighlighting
Definition: srcedtw.hxx:82
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE) override
Definition: srcedtw.cxx:756
bool IsModified() const
Definition: srcedtw.hxx:132
void SetFont()
Definition: srcedtw.cxx:951
TextViewOutWin(vcl::Window *pParent, WinBits nBits)
Definition: srcedtw.hxx:52
DECL_LINK(SyntaxTimerHdl, Timer *, void)
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: srcedtw.cxx:724
osl::Mutex mutex_
Definition: srcedtw.hxx:74
virtual void Resize() override
Definition: srcedtw.cxx:320
void ImpDoHighlight(const OUString &rSource, sal_uInt16 nLineOff)
Definition: srcedtw.cxx:668
Idle m_aSyntaxIdle
Definition: srcedtw.hxx:84
TextView * GetTextView()
Definition: srcedtw.hxx:120
void SetStartLine(sal_uInt16 nLine)
Definition: srcedtw.hxx:138
virtual void DataChanged(const DataChangedEvent &) override
Definition: srcedtw.cxx:373
virtual void Command(const CommandEvent &rCEvt) override
Definition: srcedtw.cxx:423
void SetScrollBarRanges()
Definition: srcedtw.cxx:545
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: srcedtw.cxx:488
css::uno::Reference< css::beans::XMultiPropertySet > m_xNotifier
Definition: srcedtw.hxx:76
void Read(SvStream &rInput)
Definition: srcedtw.hxx:117
rtl_TextEncoding m_eSourceEncoding
Definition: srcedtw.hxx:80
void CreateTextEngine()
Definition: srcedtw.cxx:493
void SetTextView(TextView *pView)
Definition: srcedtw.hxx:55
void Write(SvStream &rOutput)
Definition: srcedtw.hxx:118
std::set< sal_uInt16 > m_aSyntaxLineTable
Definition: srcedtw.hxx:85
void SetFont(const vcl::Font &rNewFont)
virtual ~SwSrcEditWindow() override
Definition: srcedtw.cxx:269
std::unique_ptr< TextView > m_pTextView
Definition: srcedtw.hxx:64
virtual void GetFocus() override
Definition: srcedtw.cxx:786
tools::Long m_nCurTextWidth
Definition: srcedtw.hxx:78
SwSrcEditWindow(vcl::Window *pParent, SwSrcView *pParentView)
Definition: srcedtw.cxx:234
bool IsReadonly() const
Definition: srcedtw.hxx:136
virtual void dispose() override
Definition: srcedtw.cxx:274
void ClearModifyFlag()
Definition: srcedtw.hxx:130
bool m_bReadonly
Definition: srcedtw.hxx:81