masterfix DEV300: #i10000# build fix
[LibreOffice.git] / extensions / source / bibliography / bibview.cxx
blob76f489f17bf5b31defc0229919e0d043e5315227
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 #ifndef BIB_HRC
32 #include "bib.hrc"
33 #endif
34 #include "bibcont.hxx"
35 #include "bibbeam.hxx"
36 #include "bibmod.hxx"
37 #include "general.hxx"
38 #include "bibview.hxx"
39 #include "datman.hxx"
40 #include "bibresid.hxx"
41 #include "bibmod.hxx"
42 #include "sections.hrc"
43 #include "bibconfig.hxx"
46 #include <vcl/svapp.hxx>
47 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
48 #include <com/sun/star/form/XLoadable.hpp>
49 #include <vcl/msgbox.hxx>
50 #include <tools/debug.hxx>
52 using namespace ::com::sun::star;
53 using namespace ::com::sun::star::form;
54 using namespace ::com::sun::star::beans;
55 using namespace ::com::sun::star::lang;
56 using namespace ::com::sun::star::uno;
58 #define C2U( cChar ) ::rtl::OUString::createFromAscii( cChar )
60 //.........................................................................
61 namespace bib
63 //.........................................................................
65 // -----------------------------------------------------------------------
66 BibView::BibView( Window* _pParent, BibDataManager* _pManager, WinBits _nStyle )
67 :BibWindow( _pParent, _nStyle )
68 ,m_pDatMan( _pManager )
69 ,m_xDatMan( _pManager )
70 ,m_pGeneralPage( NULL )
72 if ( m_xDatMan.is() )
73 connectForm( m_xDatMan );
76 // -----------------------------------------------------------------------
77 BibView::~BibView()
79 BibGeneralPage* pGeneralPage = m_pGeneralPage;
80 m_pGeneralPage = NULL;
82 pGeneralPage->CommitActiveControl();
83 Reference< XForm > xForm = m_pDatMan->getForm();
84 Reference< XPropertySet > xProps( xForm, UNO_QUERY );
85 Reference< sdbc::XResultSetUpdate > xResUpd( xProps, UNO_QUERY );
86 DBG_ASSERT( xResUpd.is(), "BibView::~BibView: invalid form!" );
88 if ( xResUpd.is() )
90 Any aModified = xProps->getPropertyValue( C2U( "IsModified" ) );
91 sal_Bool bFlag = sal_False;
92 if ( ( aModified >>= bFlag ) && bFlag )
95 try
97 Any aNew = xProps->getPropertyValue( C2U( "IsNew" ) );
98 aNew >>= bFlag;
99 if ( bFlag )
100 xResUpd->insertRow();
101 else
102 xResUpd->updateRow();
104 catch( const uno::Exception& rEx)
106 (void) rEx;
111 if ( isFormConnected() )
112 disconnectForm();
114 pGeneralPage->RemoveListeners();
115 m_xGeneralPage = NULL;
118 /* -----------------16.11.99 13:13-------------------
120 --------------------------------------------------*/
121 void BibView::UpdatePages()
123 // TODO:
124 // this is _strange_: Why not updating the existent general page?
125 // I consider the current behaviour a HACK.
126 // frank.schoenheit@sun.com
127 if ( m_pGeneralPage )
129 m_pGeneralPage->Hide();
130 m_pGeneralPage->RemoveListeners();
131 m_xGeneralPage = 0;
134 m_xGeneralPage = m_pGeneralPage = new BibGeneralPage( this, m_pDatMan );
136 Resize();
138 if( HasFocus() )
139 // "delayed" GetFocus() because GetFocus() is initially called before GeneralPage is created
140 m_pGeneralPage->GrabFocus();
142 String sErrorString( m_pGeneralPage->GetErrorString() );
143 if ( sErrorString.Len() )
145 sal_Bool bExecute = BibModul::GetConfig()->IsShowColumnAssignmentWarning();
146 if(!m_pDatMan->HasActiveConnection())
148 //no connection is available -> the data base has to be assigned
149 m_pDatMan->DispatchDBChangeDialog();
150 bExecute = sal_False;
152 else if(bExecute)
154 sErrorString += '\n';
155 sErrorString += String( BibResId( RID_MAP_QUESTION ) );
156 QueryBox aQuery( this, WB_YES_NO, sErrorString );
157 aQuery.SetDefaultCheckBoxText();
158 short nResult = aQuery.Execute();
159 BibModul::GetConfig()->SetShowColumnAssignmentWarning(
160 !aQuery.GetCheckBoxState());
161 if( RET_YES != nResult )
163 bExecute = sal_False;
166 if(bExecute)
168 Application::PostUserEvent( STATIC_LINK( this, BibView, CallMappingHdl ) );
172 //---------------------------------------------------------------------
173 //--- 19.10.01 16:55:49 -----------------------------------------------
175 void BibView::_loaded( const EventObject& _rEvent )
177 UpdatePages();
178 FormControlContainer::_loaded( _rEvent );
181 void BibView::_reloaded( const EventObject& _rEvent )
183 UpdatePages();
184 FormControlContainer::_loaded( _rEvent );
187 /* -----------------------------02.02.00 16:49--------------------------------
189 ---------------------------------------------------------------------------*/
190 IMPL_STATIC_LINK( BibView, CallMappingHdl, BibView*, EMPTYARG )
192 pThis->m_pDatMan->CreateMappingDialog( pThis );
193 return 0;
195 /* -----------------------------13.04.00 16:12--------------------------------
197 ---------------------------------------------------------------------------*/
198 void BibView::Resize()
200 if ( m_pGeneralPage )
202 ::Size aSz( GetOutputSizePixel() );
203 m_pGeneralPage->SetSizePixel( aSz );
205 Window::Resize();
208 //---------------------------------------------------------------------
209 //--- 18.10.01 18:52:45 -----------------------------------------------
211 Reference< awt::XControlContainer > BibView::getControlContainer()
213 Reference< awt::XControlContainer > xReturn;
214 if ( m_pGeneralPage )
215 xReturn = m_pGeneralPage->GetControlContainer();
216 return xReturn;
219 void BibView::GetFocus()
221 if( m_pGeneralPage )
222 m_pGeneralPage->GrabFocus();
225 sal_Bool BibView::HandleShortCutKey( const KeyEvent& rKeyEvent )
227 return m_pGeneralPage? m_pGeneralPage->HandleShortCutKey( rKeyEvent ) : sal_False;
230 //.........................................................................
231 } // namespace bib
232 //.........................................................................