Branch data 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 : :
21 : : #include <osl/mutex.hxx>
22 : : #include <cppuhelper/weak.hxx>
23 : : #include <toolkit/helper/vclunohelper.hxx>
24 : : #include <com/sun/star/awt/XWindow.hpp>
25 : : #include <com/sun/star/awt/XWindowPeer.hpp>
26 : : #include <com/sun/star/frame/XDispatchProvider.hpp>
27 : : #include <com/sun/star/frame/FrameSearchFlag.hpp>
28 : : #include <com/sun/star/util/XURLTransformer.hpp>
29 : : #include "bibconfig.hxx"
30 : :
31 : :
32 : : #include "datman.hxx"
33 : : #include "bibcont.hxx"
34 : :
35 : :
36 : 0 : BibShortCutHandler::~BibShortCutHandler()
37 : : {
38 [ # # ]: 0 : }
39 : :
40 : 0 : sal_Bool BibShortCutHandler::HandleShortCutKey( const KeyEvent& )
41 : : {
42 : 0 : return sal_False;
43 : : }
44 : :
45 : :
46 : 0 : BibWindow::BibWindow( Window* pParent, WinBits nStyle ) : Window( pParent, nStyle ), BibShortCutHandler( this )
47 : : {
48 : 0 : }
49 : :
50 : 0 : BibWindow::~BibWindow()
51 : : {
52 [ # # ]: 0 : }
53 : :
54 : :
55 : 0 : BibSplitWindow::BibSplitWindow( Window* pParent, WinBits nStyle ) : SplitWindow( pParent, nStyle ), BibShortCutHandler( this )
56 : : {
57 : 0 : }
58 : :
59 : 0 : BibSplitWindow::~BibSplitWindow()
60 : : {
61 [ # # ]: 0 : }
62 : :
63 : :
64 : 0 : BibTabPage::BibTabPage( Window* pParent, const ResId& rResId ) : TabPage( pParent, rResId ), BibShortCutHandler( this )
65 : : {
66 : 0 : }
67 : :
68 : 0 : BibTabPage::~BibTabPage()
69 : : {
70 [ # # ]: 0 : }
71 : :
72 : :
73 : : using namespace osl;
74 : : using namespace ::com::sun::star;
75 : : using namespace ::com::sun::star::uno;
76 : : using namespace ::com::sun::star::frame;
77 : : using namespace ::rtl;
78 : :
79 : : #define C2U(cChar) OUString::createFromAscii(cChar)
80 : : #define PROPERTY_FRAME 1
81 : : //split window size is a percent value
82 : : #define WIN_MIN_HEIGHT 10
83 : : #define WIN_STEP_SIZE 5
84 : :
85 : 0 : BibWindowContainer::BibWindowContainer( Window* pParent, BibShortCutHandler* pChildWin, WinBits nStyle ) :
86 : : BibWindow( pParent, nStyle ),
87 : 0 : pChild( pChildWin )
88 : : {
89 [ # # ]: 0 : if(pChild!=NULL)
90 : : {
91 : 0 : Window* pChildWindow = GetChild();
92 [ # # ]: 0 : pChildWindow->SetParent(this);
93 [ # # ]: 0 : pChildWindow->Show();
94 [ # # ]: 0 : pChildWindow->SetPosPixel(Point(0,0));
95 : : }
96 : 0 : }
97 : :
98 : 0 : BibWindowContainer::~BibWindowContainer()
99 : : {
100 [ # # ]: 0 : if( pChild )
101 : : {
102 : 0 : Window* pDel = GetChild();
103 : 0 : pChild = NULL; // prevents GetFocus for child while deleting!
104 [ # # ][ # # ]: 0 : delete pDel;
105 : : }
106 [ # # ]: 0 : }
107 : :
108 : 0 : void BibWindowContainer::Resize()
109 : : {
110 [ # # ]: 0 : if( pChild )
111 [ # # ]: 0 : GetChild()->SetSizePixel( GetOutputSizePixel() );
112 : 0 : }
113 : :
114 : 0 : void BibWindowContainer::GetFocus()
115 : : {
116 [ # # ]: 0 : if( pChild )
117 : 0 : GetChild()->GrabFocus();
118 : 0 : }
119 : :
120 : 0 : sal_Bool BibWindowContainer::HandleShortCutKey( const KeyEvent& rKeyEvent )
121 : : {
122 [ # # ]: 0 : return pChild? pChild->HandleShortCutKey( rKeyEvent ) : sal_False;
123 : : }
124 : :
125 : :
126 : 0 : BibBookContainer::BibBookContainer(Window* pParent,BibDataManager* pDtMn, WinBits nStyle):
127 : : BibSplitWindow(pParent,nStyle),
128 : : pDatMan(pDtMn),
129 : : pTopWin(NULL),
130 : : pBottomWin(NULL),
131 [ # # ]: 0 : bFirstTime(sal_True)
132 : : {
133 [ # # ]: 0 : pBibMod = OpenBibModul();
134 [ # # ]: 0 : aTimer.SetTimeoutHdl(LINK( this, BibBookContainer, SplitHdl));
135 [ # # ]: 0 : aTimer.SetTimeout(400);
136 : 0 : }
137 : :
138 [ # # ]: 0 : BibBookContainer::~BibBookContainer()
139 : : {
140 [ # # ]: 0 : if( xTopFrameRef.is() )
141 [ # # ][ # # ]: 0 : xTopFrameRef->dispose();
142 [ # # ]: 0 : if( xBottomFrameRef.is() )
143 [ # # ][ # # ]: 0 : xBottomFrameRef->dispose();
144 : :
145 [ # # ]: 0 : if( pTopWin )
146 : : {
147 : 0 : Window* pDel = pTopWin;
148 : 0 : pTopWin = NULL; // prevents GetFocus for child while deleting!
149 [ # # ][ # # ]: 0 : delete pDel;
150 : : }
151 : :
152 [ # # ]: 0 : if( pBottomWin )
153 : : {
154 : 0 : Window* pDel = pBottomWin;
155 : 0 : pBottomWin = NULL; // prevents GetFocus for child while deleting!
156 [ # # ][ # # ]: 0 : delete pDel;
157 : : }
158 : :
159 [ # # ]: 0 : CloseBibModul( pBibMod );
160 [ # # ]: 0 : }
161 : :
162 : 0 : void BibBookContainer::Split()
163 : : {
164 : 0 : aTimer.Start();
165 : 0 : }
166 : 0 : IMPL_LINK( BibBookContainer, SplitHdl, Timer*,/*pT*/)
167 : : {
168 : 0 : long nSize= GetItemSize( TOP_WINDOW);
169 : 0 : BibConfig* pConfig = BibModul::GetConfig();
170 : 0 : pConfig->setBeamerSize(nSize);
171 : 0 : nSize = GetItemSize( BOTTOM_WINDOW);
172 : 0 : pConfig->setViewSize(nSize);
173 : 0 : return 0;
174 : : }
175 : :
176 : 0 : void BibBookContainer::createTopFrame( BibShortCutHandler* pWin )
177 : : {
178 [ # # ]: 0 : if ( xTopFrameRef.is() ) xTopFrameRef->dispose();
179 : :
180 [ # # ]: 0 : if(pTopWin)
181 : : {
182 : 0 : RemoveItem(TOP_WINDOW);
183 [ # # ]: 0 : delete pTopWin;
184 : : }
185 [ # # ]: 0 : pTopWin=new BibWindowContainer(this,pWin);
186 : 0 : pTopWin->Show();
187 : 0 : BibConfig* pConfig = BibModul::GetConfig();
188 : 0 : long nSize = pConfig->getBeamerSize();
189 : 0 : InsertItem(TOP_WINDOW, pTopWin, nSize, 1, 0, SWIB_PERCENTSIZE );
190 : :
191 : 0 : }
192 : :
193 : 0 : void BibBookContainer::createBottomFrame( BibShortCutHandler* pWin )
194 : : {
195 [ # # ]: 0 : if ( xBottomFrameRef.is() ) xBottomFrameRef->dispose();
196 : :
197 [ # # ]: 0 : if(pBottomWin)
198 : : {
199 : 0 : RemoveItem(BOTTOM_WINDOW);
200 [ # # ]: 0 : delete pBottomWin;
201 : : }
202 : :
203 [ # # ]: 0 : pBottomWin=new BibWindowContainer(this,pWin);
204 : :
205 : 0 : BibConfig* pConfig = BibModul::GetConfig();
206 : 0 : long nSize = pConfig->getViewSize();
207 : 0 : InsertItem(BOTTOM_WINDOW, pBottomWin, nSize, 1, 0, SWIB_PERCENTSIZE );
208 : :
209 : 0 : }
210 : :
211 : 0 : void BibBookContainer::GetFocus()
212 : : {
213 [ # # ]: 0 : if( pBottomWin )
214 : 0 : pBottomWin->GrabFocus();
215 : 0 : }
216 : :
217 : 0 : long BibBookContainer::PreNotify( NotifyEvent& rNEvt )
218 : : {
219 : 0 : long nHandled = 0;
220 [ # # ]: 0 : if( EVENT_KEYINPUT == rNEvt.GetType() )
221 : : {
222 [ # # ]: 0 : const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
223 : 0 : const KeyCode aKeyCode = pKEvt->GetKeyCode();
224 : 0 : sal_uInt16 nKey = aKeyCode.GetCode();
225 : 0 : const sal_uInt16 nModifier = aKeyCode.GetModifier();
226 : :
227 [ # # ]: 0 : if( KEY_MOD2 == nModifier )
228 : : {
229 [ # # ][ # # ]: 0 : if( KEY_UP == nKey || KEY_DOWN == nKey )
230 : : {
231 [ # # ][ # # ]: 0 : if(pTopWin && pBottomWin)
232 : : {
233 [ # # ]: 0 : sal_uInt16 nFirstWinId = KEY_UP == nKey ? TOP_WINDOW : BOTTOM_WINDOW;
234 [ # # ]: 0 : sal_uInt16 nSecondWinId = KEY_UP == nKey ? BOTTOM_WINDOW : TOP_WINDOW;
235 [ # # ]: 0 : long nHeight = GetItemSize( nFirstWinId );
236 : 0 : nHeight -= WIN_STEP_SIZE;
237 [ # # ]: 0 : if(nHeight < WIN_MIN_HEIGHT)
238 : 0 : nHeight = WIN_MIN_HEIGHT;
239 [ # # ]: 0 : SetItemSize( nFirstWinId, nHeight );
240 [ # # ]: 0 : SetItemSize( nSecondWinId, 100 - nHeight );
241 : : }
242 : 0 : nHandled = 1;
243 : : }
244 [ # # ][ # # ]: 0 : else if( pKEvt->GetCharCode() && HandleShortCutKey( *pKEvt ) )
[ # # ][ # # ]
245 : 0 : nHandled = 1;
246 : : }
247 : : }
248 : :
249 : 0 : return nHandled;
250 : : }
251 : :
252 : 0 : sal_Bool BibBookContainer::HandleShortCutKey( const KeyEvent& rKeyEvent )
253 : : {
254 : 0 : sal_Bool bRet = sal_False;
255 : :
256 [ # # ]: 0 : if( pTopWin )
257 : 0 : bRet = pTopWin->HandleShortCutKey( rKeyEvent );
258 : :
259 [ # # ][ # # ]: 0 : if( !bRet && pBottomWin )
260 : 0 : bRet = pBottomWin->HandleShortCutKey( rKeyEvent );
261 : :
262 : 0 : return bRet;
263 : : }
264 : :
265 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|