Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _SRCEDTW_HXX
29 : : #define _SRCEDTW_HXX
30 : :
31 : : #include <vcl/window.hxx>
32 : : #include <svl/lstner.hxx>
33 : : #include <vcl/timer.hxx>
34 : :
35 : : #include <vcl/xtextedt.hxx>
36 : : #include <set>
37 : :
38 : : namespace com { namespace sun { namespace star { namespace beans {
39 : : class XMultiPropertySet;
40 : : } } } }
41 : :
42 : : class ScrollBar;
43 : : class SwSrcView;
44 : : class SwSrcEditWindow;
45 : : class TextEngine;
46 : : class ExtTextView;
47 : : class DataChangedEvent;
48 : :
49 [ # # ]: 0 : class TextViewOutWin : public Window
50 : : {
51 : : ExtTextView* pTextView;
52 : :
53 : : protected:
54 : : virtual void Paint( const Rectangle& );
55 : : virtual void KeyInput( const KeyEvent& rKeyEvt );
56 : : virtual void MouseMove( const MouseEvent& rMEvt );
57 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
58 : : virtual void MouseButtonUp( const MouseEvent& rMEvt );
59 : : virtual void Command( const CommandEvent& rCEvt );
60 : : virtual void DataChanged( const DataChangedEvent& );
61 : :
62 : : public:
63 : 0 : TextViewOutWin(Window* pParent, WinBits nBits) :
64 : 0 : Window(pParent, nBits), pTextView(0){}
65 : :
66 : 0 : void SetTextView( ExtTextView* pView ) {pTextView = pView;}
67 : :
68 : : };
69 : :
70 : : //------------------------------------------------------------
71 : : typedef std::set<sal_uInt16> SyntaxLineSet;
72 : :
73 : : class SwSrcEditWindow : public Window, public SfxListener
74 : : {
75 : : private:
76 : : class ChangesListener;
77 : : friend class ChangesListener;
78 : : ExtTextView* pTextView;
79 : : ExtTextEngine* pTextEngine;
80 : :
81 : : TextViewOutWin* pOutWin;
82 : : ScrollBar *pHScrollbar,
83 : : *pVScrollbar;
84 : :
85 : : SwSrcView* pSrcView;
86 : :
87 : : rtl::Reference< ChangesListener > listener_;
88 : : osl::Mutex mutex_;
89 : : com::sun::star::uno::Reference< com::sun::star::beans::XMultiPropertySet >
90 : : notifier_;
91 : :
92 : : long nCurTextWidth;
93 : : sal_uInt16 nStartLine;
94 : : rtl_TextEncoding eSourceEncoding;
95 : : sal_Bool bReadonly;
96 : : sal_Bool bDoSyntaxHighlight;
97 : : sal_Bool bHighlighting;
98 : :
99 : : Timer aSyntaxIdleTimer;
100 : : SyntaxLineSet aSyntaxLineTable;
101 : :
102 : : void ImpDoHighlight( const String& rSource, sal_uInt16 nLineOff );
103 : :
104 : : using OutputDevice::SetFont;
105 : : void SetFont();
106 : :
107 : : DECL_LINK( SyntaxTimerHdl, Timer * );
108 : : DECL_LINK( TimeoutHdl, Timer * );
109 : :
110 : : using Window::Notify;
111 : : using Window::Invalidate;
112 : :
113 : : protected:
114 : :
115 : : virtual void Resize();
116 : : virtual void DataChanged( const DataChangedEvent& );
117 : : virtual void GetFocus();
118 : : // virtual void LoseFocus();
119 : :
120 : : void CreateTextEngine();
121 : : void DoSyntaxHighlight( sal_uInt16 nPara );
122 : :
123 : : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
124 : :
125 : : DECL_LINK(ScrollHdl, ScrollBar*);
126 : :
127 : : public:
128 : : SwSrcEditWindow( Window* pParent, SwSrcView* pParentView );
129 : : ~SwSrcEditWindow();
130 : :
131 : : void SetScrollBarRanges();
132 : : void InitScrollBars();
133 : 0 : sal_uLong Read( SvStream& rInput)
134 : 0 : {return pTextEngine->Read(rInput);}
135 : 0 : sal_uLong Write( SvStream& rOutput)
136 : 0 : {return pTextEngine->Write(rOutput);}
137 : :
138 : 0 : ExtTextView* GetTextView()
139 : 0 : {return pTextView;}
140 : 0 : TextEngine* GetTextEngine()
141 : 0 : {return pTextEngine;}
142 : 0 : SwSrcView* GetSrcView() {return pSrcView;}
143 : :
144 : 0 : TextViewOutWin* GetOutWin() {return pOutWin;}
145 : :
146 : : virtual void Invalidate( sal_uInt16 nFlags = 0 );
147 : :
148 : 0 : void ClearModifyFlag()
149 : 0 : { pTextEngine->SetModified(sal_False); }
150 : 0 : sal_Bool IsModified() const
151 : 0 : { return pTextEngine->IsModified();}
152 : : void CreateScrollbars();
153 : :
154 : 0 : void SetReadonly(sal_Bool bSet){bReadonly = bSet;}
155 : 0 : sal_Bool IsReadonly(){return bReadonly;}
156 : :
157 : : void DoDelayedSyntaxHighlight( sal_uInt16 nPara );
158 : :
159 : 0 : void SetStartLine(sal_uInt16 nLine){nStartLine = nLine;}
160 : :
161 : : virtual void Command( const CommandEvent& rCEvt );
162 : : void HandleWheelCommand( const CommandEvent& rCEvt );
163 : :
164 : : void SetTextEncoding(rtl_TextEncoding eEncoding);
165 : : };
166 : :
167 : : #endif
168 : :
169 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|