1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include "bibcont.hxx"
23 #include "bibbeam.hxx"
24 #include "general.hxx"
25 #include "bibview.hxx"
27 #include "bibresid.hxx"
29 #include "sections.hrc"
30 #include "bibconfig.hxx"
33 #include <vcl/svapp.hxx>
34 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
35 #include <com/sun/star/form/XLoadable.hpp>
36 #include <vcl/msgbox.hxx>
37 #include <tools/debug.hxx>
39 using namespace ::com::sun::star
;
40 using namespace ::com::sun::star::form
;
41 using namespace ::com::sun::star::beans
;
42 using namespace ::com::sun::star::lang
;
43 using namespace ::com::sun::star::uno
;
45 //.........................................................................
48 //.........................................................................
50 // -----------------------------------------------------------------------
51 BibView::BibView( Window
* _pParent
, BibDataManager
* _pManager
, WinBits _nStyle
)
52 :BibWindow( _pParent
, _nStyle
)
53 ,m_pDatMan( _pManager
)
54 ,m_xDatMan( _pManager
)
55 ,m_pGeneralPage( NULL
)
58 connectForm( m_xDatMan
);
61 // -----------------------------------------------------------------------
64 BibGeneralPage
* pGeneralPage
= m_pGeneralPage
;
65 m_pGeneralPage
= NULL
;
67 pGeneralPage
->CommitActiveControl();
68 Reference
< XForm
> xForm
= m_pDatMan
->getForm();
69 Reference
< XPropertySet
> xProps( xForm
, UNO_QUERY
);
70 Reference
< sdbc::XResultSetUpdate
> xResUpd( xProps
, UNO_QUERY
);
71 DBG_ASSERT( xResUpd
.is(), "BibView::~BibView: invalid form!" );
75 Any aModified
= xProps
->getPropertyValue( "IsModified" );
76 sal_Bool bFlag
= sal_False
;
77 if ( ( aModified
>>= bFlag
) && bFlag
)
82 Any aNew
= xProps
->getPropertyValue( "IsNew" );
89 catch( const uno::Exception
& rEx
)
96 if ( isFormConnected() )
99 pGeneralPage
->RemoveListeners();
100 m_xGeneralPage
= NULL
;
103 void BibView::UpdatePages()
106 // this is _strange_: Why not updating the existent general page?
107 // I consider the current behaviour a HACK.
108 // frank.schoenheit@sun.com
109 if ( m_pGeneralPage
)
111 m_pGeneralPage
->Hide();
112 m_pGeneralPage
->RemoveListeners();
116 m_xGeneralPage
= m_pGeneralPage
= new BibGeneralPage( this, m_pDatMan
);
121 // "delayed" GetFocus() because GetFocus() is initially called before GeneralPage is created
122 m_pGeneralPage
->GrabFocus();
124 String
sErrorString( m_pGeneralPage
->GetErrorString() );
125 if ( sErrorString
.Len() )
127 sal_Bool bExecute
= BibModul::GetConfig()->IsShowColumnAssignmentWarning();
128 if(!m_pDatMan
->HasActiveConnection())
130 //no connection is available -> the data base has to be assigned
131 m_pDatMan
->DispatchDBChangeDialog();
132 bExecute
= sal_False
;
136 sErrorString
+= '\n';
137 sErrorString
+= String( BibResId( RID_MAP_QUESTION
) );
138 QueryBox
aQuery( this, WB_YES_NO
, sErrorString
);
139 aQuery
.SetDefaultCheckBoxText();
140 short nResult
= aQuery
.Execute();
141 BibModul::GetConfig()->SetShowColumnAssignmentWarning(
142 !aQuery
.GetCheckBoxState());
143 if( RET_YES
!= nResult
)
145 bExecute
= sal_False
;
150 Application::PostUserEvent( STATIC_LINK( this, BibView
, CallMappingHdl
) );
155 void BibView::_loaded( const EventObject
& _rEvent
)
158 FormControlContainer::_loaded( _rEvent
);
161 void BibView::_reloaded( const EventObject
& _rEvent
)
164 FormControlContainer::_loaded( _rEvent
);
167 IMPL_STATIC_LINK( BibView
, CallMappingHdl
, BibView
*, EMPTYARG
)
169 pThis
->m_pDatMan
->CreateMappingDialog( pThis
);
173 void BibView::Resize()
175 if ( m_pGeneralPage
)
177 ::Size
aSz( GetOutputSizePixel() );
178 m_pGeneralPage
->SetSizePixel( aSz
);
183 Reference
< awt::XControlContainer
> BibView::getControlContainer()
185 Reference
< awt::XControlContainer
> xReturn
;
186 if ( m_pGeneralPage
)
187 xReturn
= m_pGeneralPage
->GetControlContainer();
191 void BibView::GetFocus()
194 m_pGeneralPage
->GrabFocus();
197 sal_Bool
BibView::HandleShortCutKey( const KeyEvent
& rKeyEvent
)
199 return m_pGeneralPage
? m_pGeneralPage
->HandleShortCutKey( rKeyEvent
) : sal_False
;
202 //.........................................................................
204 //.........................................................................
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */