1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
31 #include <osl/mutex.hxx>
32 #include <tools/urlobj.hxx>
33 #include <cppuhelper/weak.hxx>
34 #include <unotools/processfactory.hxx>
35 #include <toolkit/helper/vclunohelper.hxx>
36 #include <com/sun/star/awt/XWindow.hpp>
37 #include <com/sun/star/awt/XWindowPeer.hpp>
38 #include <com/sun/star/frame/XDispatchProvider.hpp>
39 #include <com/sun/star/frame/FrameSearchFlag.hpp>
40 #include <com/sun/star/util/XURLTransformer.hpp>
41 #include "bibconfig.hxx"
45 #include "bibcont.hxx"
48 BibShortCutHandler::~BibShortCutHandler()
52 sal_Bool
BibShortCutHandler::HandleShortCutKey( const KeyEvent
& )
58 BibWindow::BibWindow( Window
* pParent
, WinBits nStyle
) : Window( pParent
, nStyle
), BibShortCutHandler( this )
62 BibWindow::~BibWindow()
67 BibSplitWindow::BibSplitWindow( Window
* pParent
, WinBits nStyle
) : SplitWindow( pParent
, nStyle
), BibShortCutHandler( this )
71 BibSplitWindow::~BibSplitWindow()
76 BibTabPage::BibTabPage( Window
* pParent
, const ResId
& rResId
) : TabPage( pParent
, rResId
), BibShortCutHandler( this )
80 BibTabPage::~BibTabPage()
86 using namespace ::com::sun::star
;
87 using namespace ::com::sun::star::uno
;
88 using namespace ::com::sun::star::frame
;
89 using namespace ::rtl
;
91 #define C2U(cChar) OUString::createFromAscii(cChar)
92 #define PROPERTY_FRAME 1
93 //split window size is a percent value
94 #define WIN_MIN_HEIGHT 10
95 #define WIN_STEP_SIZE 5
97 BibWindowContainer::BibWindowContainer( Window
* pParent
, BibShortCutHandler
* pChildWin
, WinBits nStyle
) :
98 BibWindow( pParent
, nStyle
),
103 Window
* pChildWindow
= GetChild();
104 pChildWindow
->SetParent(this);
105 pChildWindow
->Show();
106 pChildWindow
->SetPosPixel(Point(0,0));
110 BibWindowContainer::~BibWindowContainer()
114 Window
* pDel
= GetChild();
115 pChild
= NULL
; // prevents GetFocus for child while deleting!
120 void BibWindowContainer::Resize()
123 GetChild()->SetSizePixel( GetOutputSizePixel() );
126 void BibWindowContainer::GetFocus()
129 GetChild()->GrabFocus();
132 sal_Bool
BibWindowContainer::HandleShortCutKey( const KeyEvent
& rKeyEvent
)
134 return pChild
? pChild
->HandleShortCutKey( rKeyEvent
) : sal_False
;
138 BibBookContainer::BibBookContainer(Window
* pParent
,BibDataManager
* pDtMn
, WinBits nStyle
):
139 BibSplitWindow(pParent
,nStyle
),
145 pBibMod
= OpenBibModul();
146 aTimer
.SetTimeoutHdl(LINK( this, BibBookContainer
, SplitHdl
));
147 aTimer
.SetTimeout(400);
150 BibBookContainer::~BibBookContainer()
152 if( xTopFrameRef
.is() )
153 xTopFrameRef
->dispose();
154 if( xBottomFrameRef
.is() )
155 xBottomFrameRef
->dispose();
159 Window
* pDel
= pTopWin
;
160 pTopWin
= NULL
; // prevents GetFocus for child while deleting!
166 Window
* pDel
= pBottomWin
;
167 pBottomWin
= NULL
; // prevents GetFocus for child while deleting!
171 CloseBibModul( pBibMod
);
174 void BibBookContainer::Split()
178 IMPL_LINK( BibBookContainer
, SplitHdl
, Timer
*,/*pT*/)
180 long nSize
= GetItemSize( TOP_WINDOW
);
181 BibConfig
* pConfig
= BibModul::GetConfig();
182 pConfig
->setBeamerSize(nSize
);
183 nSize
= GetItemSize( BOTTOM_WINDOW
);
184 pConfig
->setViewSize(nSize
);
188 void BibBookContainer::createTopFrame( BibShortCutHandler
* pWin
)
190 if ( xTopFrameRef
.is() ) xTopFrameRef
->dispose();
194 RemoveItem(TOP_WINDOW
);
197 pTopWin
=new BibWindowContainer(this,pWin
);
199 BibConfig
* pConfig
= BibModul::GetConfig();
200 long nSize
= pConfig
->getBeamerSize();
201 InsertItem(TOP_WINDOW
, pTopWin
, nSize
, 1, 0, SWIB_PERCENTSIZE
);
205 void BibBookContainer::createBottomFrame( BibShortCutHandler
* pWin
)
207 if ( xBottomFrameRef
.is() ) xBottomFrameRef
->dispose();
211 RemoveItem(BOTTOM_WINDOW
);
215 pBottomWin
=new BibWindowContainer(this,pWin
);
217 BibConfig
* pConfig
= BibModul::GetConfig();
218 long nSize
= pConfig
->getViewSize();
219 InsertItem(BOTTOM_WINDOW
, pBottomWin
, nSize
, 1, 0, SWIB_PERCENTSIZE
);
223 void BibBookContainer::GetFocus()
226 pBottomWin
->GrabFocus();
229 long BibBookContainer::PreNotify( NotifyEvent
& rNEvt
)
232 if( EVENT_KEYINPUT
== rNEvt
.GetType() )
234 const KeyEvent
* pKEvt
= rNEvt
.GetKeyEvent();
235 const KeyCode aKeyCode
= pKEvt
->GetKeyCode();
236 USHORT nKey
= aKeyCode
.GetCode();
237 const USHORT nModifier
= aKeyCode
.GetModifier();
239 if( KEY_MOD2
== nModifier
)
241 if( KEY_UP
== nKey
|| KEY_DOWN
== nKey
)
243 if(pTopWin
&& pBottomWin
)
245 USHORT nFirstWinId
= KEY_UP
== nKey
? TOP_WINDOW
: BOTTOM_WINDOW
;
246 USHORT nSecondWinId
= KEY_UP
== nKey
? BOTTOM_WINDOW
: TOP_WINDOW
;
247 long nHeight
= GetItemSize( nFirstWinId
);
248 nHeight
-= WIN_STEP_SIZE
;
249 if(nHeight
< WIN_MIN_HEIGHT
)
250 nHeight
= WIN_MIN_HEIGHT
;
251 SetItemSize( nFirstWinId
, nHeight
);
252 SetItemSize( nSecondWinId
, 100 - nHeight
);
256 else if( pKEvt
->GetCharCode() && HandleShortCutKey( *pKEvt
) )
264 sal_Bool
BibBookContainer::HandleShortCutKey( const KeyEvent
& rKeyEvent
)
266 sal_Bool bRet
= sal_False
;
269 bRet
= pTopWin
->HandleShortCutKey( rKeyEvent
);
271 if( !bRet
&& pBottomWin
)
272 bRet
= pBottomWin
->HandleShortCutKey( rKeyEvent
);