1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
30 #include <osl/mutex.hxx>
31 #include <cppuhelper/weak.hxx>
32 #include <toolkit/helper/vclunohelper.hxx>
33 #include <com/sun/star/awt/XWindow.hpp>
34 #include <com/sun/star/awt/XWindowPeer.hpp>
35 #include <com/sun/star/frame/XDispatchProvider.hpp>
36 #include <com/sun/star/frame/FrameSearchFlag.hpp>
37 #include <com/sun/star/util/XURLTransformer.hpp>
38 #include "bibconfig.hxx"
42 #include "bibcont.hxx"
45 BibShortCutHandler::~BibShortCutHandler()
49 sal_Bool
BibShortCutHandler::HandleShortCutKey( const KeyEvent
& )
55 BibWindow::BibWindow( Window
* pParent
, WinBits nStyle
) : Window( pParent
, nStyle
), BibShortCutHandler( this )
59 BibWindow::~BibWindow()
64 BibSplitWindow::BibSplitWindow( Window
* pParent
, WinBits nStyle
) : SplitWindow( pParent
, nStyle
), BibShortCutHandler( this )
68 BibSplitWindow::~BibSplitWindow()
73 BibTabPage::BibTabPage( Window
* pParent
, const ResId
& rResId
) : TabPage( pParent
, rResId
), BibShortCutHandler( this )
77 BibTabPage::~BibTabPage()
83 using namespace ::com::sun::star
;
84 using namespace ::com::sun::star::uno
;
85 using namespace ::com::sun::star::frame
;
86 using namespace ::rtl
;
88 #define C2U(cChar) OUString::createFromAscii(cChar)
89 #define PROPERTY_FRAME 1
90 //split window size is a percent value
91 #define WIN_MIN_HEIGHT 10
92 #define WIN_STEP_SIZE 5
94 BibWindowContainer::BibWindowContainer( Window
* pParent
, BibShortCutHandler
* pChildWin
, WinBits nStyle
) :
95 BibWindow( pParent
, nStyle
),
100 Window
* pChildWindow
= GetChild();
101 pChildWindow
->SetParent(this);
102 pChildWindow
->Show();
103 pChildWindow
->SetPosPixel(Point(0,0));
107 BibWindowContainer::~BibWindowContainer()
111 Window
* pDel
= GetChild();
112 pChild
= NULL
; // prevents GetFocus for child while deleting!
117 void BibWindowContainer::Resize()
120 GetChild()->SetSizePixel( GetOutputSizePixel() );
123 void BibWindowContainer::GetFocus()
126 GetChild()->GrabFocus();
129 sal_Bool
BibWindowContainer::HandleShortCutKey( const KeyEvent
& rKeyEvent
)
131 return pChild
? pChild
->HandleShortCutKey( rKeyEvent
) : sal_False
;
135 BibBookContainer::BibBookContainer(Window
* pParent
,BibDataManager
* pDtMn
, WinBits nStyle
):
136 BibSplitWindow(pParent
,nStyle
),
142 pBibMod
= OpenBibModul();
143 aTimer
.SetTimeoutHdl(LINK( this, BibBookContainer
, SplitHdl
));
144 aTimer
.SetTimeout(400);
147 BibBookContainer::~BibBookContainer()
149 if( xTopFrameRef
.is() )
150 xTopFrameRef
->dispose();
151 if( xBottomFrameRef
.is() )
152 xBottomFrameRef
->dispose();
156 Window
* pDel
= pTopWin
;
157 pTopWin
= NULL
; // prevents GetFocus for child while deleting!
163 Window
* pDel
= pBottomWin
;
164 pBottomWin
= NULL
; // prevents GetFocus for child while deleting!
168 CloseBibModul( pBibMod
);
171 void BibBookContainer::Split()
175 IMPL_LINK( BibBookContainer
, SplitHdl
, Timer
*,/*pT*/)
177 long nSize
= GetItemSize( TOP_WINDOW
);
178 BibConfig
* pConfig
= BibModul::GetConfig();
179 pConfig
->setBeamerSize(nSize
);
180 nSize
= GetItemSize( BOTTOM_WINDOW
);
181 pConfig
->setViewSize(nSize
);
185 void BibBookContainer::createTopFrame( BibShortCutHandler
* pWin
)
187 if ( xTopFrameRef
.is() ) xTopFrameRef
->dispose();
191 RemoveItem(TOP_WINDOW
);
194 pTopWin
=new BibWindowContainer(this,pWin
);
196 BibConfig
* pConfig
= BibModul::GetConfig();
197 long nSize
= pConfig
->getBeamerSize();
198 InsertItem(TOP_WINDOW
, pTopWin
, nSize
, 1, 0, SWIB_PERCENTSIZE
);
202 void BibBookContainer::createBottomFrame( BibShortCutHandler
* pWin
)
204 if ( xBottomFrameRef
.is() ) xBottomFrameRef
->dispose();
208 RemoveItem(BOTTOM_WINDOW
);
212 pBottomWin
=new BibWindowContainer(this,pWin
);
214 BibConfig
* pConfig
= BibModul::GetConfig();
215 long nSize
= pConfig
->getViewSize();
216 InsertItem(BOTTOM_WINDOW
, pBottomWin
, nSize
, 1, 0, SWIB_PERCENTSIZE
);
220 void BibBookContainer::GetFocus()
223 pBottomWin
->GrabFocus();
226 long BibBookContainer::PreNotify( NotifyEvent
& rNEvt
)
229 if( EVENT_KEYINPUT
== rNEvt
.GetType() )
231 const KeyEvent
* pKEvt
= rNEvt
.GetKeyEvent();
232 const KeyCode aKeyCode
= pKEvt
->GetKeyCode();
233 sal_uInt16 nKey
= aKeyCode
.GetCode();
234 const sal_uInt16 nModifier
= aKeyCode
.GetModifier();
236 if( KEY_MOD2
== nModifier
)
238 if( KEY_UP
== nKey
|| KEY_DOWN
== nKey
)
240 if(pTopWin
&& pBottomWin
)
242 sal_uInt16 nFirstWinId
= KEY_UP
== nKey
? TOP_WINDOW
: BOTTOM_WINDOW
;
243 sal_uInt16 nSecondWinId
= KEY_UP
== nKey
? BOTTOM_WINDOW
: TOP_WINDOW
;
244 long nHeight
= GetItemSize( nFirstWinId
);
245 nHeight
-= WIN_STEP_SIZE
;
246 if(nHeight
< WIN_MIN_HEIGHT
)
247 nHeight
= WIN_MIN_HEIGHT
;
248 SetItemSize( nFirstWinId
, nHeight
);
249 SetItemSize( nSecondWinId
, 100 - nHeight
);
253 else if( pKEvt
->GetCharCode() && HandleShortCutKey( *pKEvt
) )
261 sal_Bool
BibBookContainer::HandleShortCutKey( const KeyEvent
& rKeyEvent
)
263 sal_Bool bRet
= sal_False
;
266 bRet
= pTopWin
->HandleShortCutKey( rKeyEvent
);
268 if( !bRet
&& pBottomWin
)
269 bRet
= pBottomWin
->HandleShortCutKey( rKeyEvent
);
274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */