1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bibview.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
37 #include "bibcont.hxx"
38 #include "bibbeam.hxx"
40 #include "general.hxx"
41 #include "bibview.hxx"
43 #include "bibresid.hxx"
45 #include "sections.hrc"
46 #include "bibconfig.hxx"
49 #include <vcl/svapp.hxx>
50 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
51 #include <com/sun/star/form/XLoadable.hpp>
52 #include <vcl/msgbox.hxx>
53 #include <tools/debug.hxx>
55 using namespace ::com::sun::star
;
56 using namespace ::com::sun::star::form
;
57 using namespace ::com::sun::star::beans
;
58 using namespace ::com::sun::star::lang
;
59 using namespace ::com::sun::star::uno
;
61 #define C2U( cChar ) ::rtl::OUString::createFromAscii( cChar )
63 //.........................................................................
66 //.........................................................................
68 // -----------------------------------------------------------------------
69 BibView::BibView( Window
* _pParent
, BibDataManager
* _pManager
, WinBits _nStyle
)
70 :BibWindow( _pParent
, _nStyle
)
71 ,m_pDatMan( _pManager
)
72 ,m_xDatMan( _pManager
)
73 ,m_pGeneralPage( NULL
)
76 connectForm( m_xDatMan
);
79 // -----------------------------------------------------------------------
82 BibGeneralPage
* pGeneralPage
= m_pGeneralPage
;
83 m_pGeneralPage
= NULL
;
85 pGeneralPage
->CommitActiveControl();
86 Reference
< XForm
> xForm
= m_pDatMan
->getForm();
87 Reference
< XPropertySet
> xProps( xForm
, UNO_QUERY
);
88 Reference
< sdbc::XResultSetUpdate
> xResUpd( xProps
, UNO_QUERY
);
89 DBG_ASSERT( xResUpd
.is(), "BibView::~BibView: invalid form!" );
93 Any aModified
= xProps
->getPropertyValue( C2U( "IsModified" ) );
94 sal_Bool bFlag
= sal_False
;
95 if ( ( aModified
>>= bFlag
) && bFlag
)
100 Any aNew
= xProps
->getPropertyValue( C2U( "IsNew" ) );
103 xResUpd
->insertRow();
105 xResUpd
->updateRow();
107 catch( const uno::Exception
& rEx
)
114 if ( isFormConnected() )
117 pGeneralPage
->RemoveListeners();
118 m_xGeneralPage
= NULL
;
121 /* -----------------16.11.99 13:13-------------------
123 --------------------------------------------------*/
124 void BibView::UpdatePages()
127 // this is _strange_: Why not updating the existent general page?
128 // I consider the current behaviour a HACK.
129 // frank.schoenheit@sun.com
130 if ( m_pGeneralPage
)
132 m_pGeneralPage
->Hide();
133 m_pGeneralPage
->RemoveListeners();
137 m_xGeneralPage
= m_pGeneralPage
= new BibGeneralPage( this, m_pDatMan
);
142 // "delayed" GetFocus() because GetFocus() is initially called before GeneralPage is created
143 m_pGeneralPage
->GrabFocus();
145 String
sErrorString( m_pGeneralPage
->GetErrorString() );
146 if ( sErrorString
.Len() )
148 sal_Bool bExecute
= BibModul::GetConfig()->IsShowColumnAssignmentWarning();
149 if(!m_pDatMan
->HasActiveConnection())
151 //no connection is available -> the data base has to be assigned
152 m_pDatMan
->DispatchDBChangeDialog();
153 bExecute
= sal_False
;
157 sErrorString
+= '\n';
158 sErrorString
+= String( BibResId( RID_MAP_QUESTION
) );
159 QueryBox
aQuery( this, WB_YES_NO
, sErrorString
);
160 aQuery
.SetDefaultCheckBoxText();
161 short nResult
= aQuery
.Execute();
162 BibModul::GetConfig()->SetShowColumnAssignmentWarning(
163 !aQuery
.GetCheckBoxState());
164 if( RET_YES
!= nResult
)
166 bExecute
= sal_False
;
171 Application::PostUserEvent( STATIC_LINK( this, BibView
, CallMappingHdl
) );
175 //---------------------------------------------------------------------
176 //--- 19.10.01 16:55:49 -----------------------------------------------
178 void BibView::_loaded( const EventObject
& _rEvent
)
181 FormControlContainer::_loaded( _rEvent
);
184 void BibView::_reloaded( const EventObject
& _rEvent
)
187 FormControlContainer::_loaded( _rEvent
);
190 /* -----------------------------02.02.00 16:49--------------------------------
192 ---------------------------------------------------------------------------*/
193 IMPL_STATIC_LINK( BibView
, CallMappingHdl
, BibView
*, EMPTYARG
)
195 pThis
->m_pDatMan
->CreateMappingDialog( pThis
);
198 /* -----------------------------13.04.00 16:12--------------------------------
200 ---------------------------------------------------------------------------*/
201 void BibView::Resize()
203 if ( m_pGeneralPage
)
205 ::Size
aSz( GetOutputSizePixel() );
206 m_pGeneralPage
->SetSizePixel( aSz
);
211 //---------------------------------------------------------------------
212 //--- 18.10.01 18:52:45 -----------------------------------------------
214 Reference
< awt::XControlContainer
> BibView::getControlContainer()
216 Reference
< awt::XControlContainer
> xReturn
;
217 if ( m_pGeneralPage
)
218 xReturn
= m_pGeneralPage
->GetControlContainer();
222 void BibView::GetFocus()
225 m_pGeneralPage
->GrabFocus();
228 BOOL
BibView::HandleShortCutKey( const KeyEvent
& rKeyEvent
)
230 return m_pGeneralPage
? m_pGeneralPage
->HandleShortCutKey( rKeyEvent
) : FALSE
;
233 //.........................................................................
235 //.........................................................................