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 ************************************************************************/
31 #include "bibcont.hxx"
32 #include "bibbeam.hxx"
33 #include "general.hxx"
34 #include "bibview.hxx"
36 #include "bibresid.hxx"
38 #include "sections.hrc"
39 #include "bibconfig.hxx"
42 #include <vcl/svapp.hxx>
43 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
44 #include <com/sun/star/form/XLoadable.hpp>
45 #include <vcl/msgbox.hxx>
46 #include <tools/debug.hxx>
48 using namespace ::com::sun::star
;
49 using namespace ::com::sun::star::form
;
50 using namespace ::com::sun::star::beans
;
51 using namespace ::com::sun::star::lang
;
52 using namespace ::com::sun::star::uno
;
54 #define C2U( cChar ) ::rtl::OUString::createFromAscii( cChar )
56 //.........................................................................
59 //.........................................................................
61 // -----------------------------------------------------------------------
62 BibView::BibView( Window
* _pParent
, BibDataManager
* _pManager
, WinBits _nStyle
)
63 :BibWindow( _pParent
, _nStyle
)
64 ,m_pDatMan( _pManager
)
65 ,m_xDatMan( _pManager
)
66 ,m_pGeneralPage( NULL
)
69 connectForm( m_xDatMan
);
72 // -----------------------------------------------------------------------
75 BibGeneralPage
* pGeneralPage
= m_pGeneralPage
;
76 m_pGeneralPage
= NULL
;
78 pGeneralPage
->CommitActiveControl();
79 Reference
< XForm
> xForm
= m_pDatMan
->getForm();
80 Reference
< XPropertySet
> xProps( xForm
, UNO_QUERY
);
81 Reference
< sdbc::XResultSetUpdate
> xResUpd( xProps
, UNO_QUERY
);
82 DBG_ASSERT( xResUpd
.is(), "BibView::~BibView: invalid form!" );
86 Any aModified
= xProps
->getPropertyValue( C2U( "IsModified" ) );
87 sal_Bool bFlag
= sal_False
;
88 if ( ( aModified
>>= bFlag
) && bFlag
)
93 Any aNew
= xProps
->getPropertyValue( C2U( "IsNew" ) );
100 catch( const uno::Exception
& rEx
)
107 if ( isFormConnected() )
110 pGeneralPage
->RemoveListeners();
111 m_xGeneralPage
= NULL
;
114 void BibView::UpdatePages()
117 // this is _strange_: Why not updating the existent general page?
118 // I consider the current behaviour a HACK.
119 // frank.schoenheit@sun.com
120 if ( m_pGeneralPage
)
122 m_pGeneralPage
->Hide();
123 m_pGeneralPage
->RemoveListeners();
127 m_xGeneralPage
= m_pGeneralPage
= new BibGeneralPage( this, m_pDatMan
);
132 // "delayed" GetFocus() because GetFocus() is initially called before GeneralPage is created
133 m_pGeneralPage
->GrabFocus();
135 String
sErrorString( m_pGeneralPage
->GetErrorString() );
136 if ( sErrorString
.Len() )
138 sal_Bool bExecute
= BibModul::GetConfig()->IsShowColumnAssignmentWarning();
139 if(!m_pDatMan
->HasActiveConnection())
141 //no connection is available -> the data base has to be assigned
142 m_pDatMan
->DispatchDBChangeDialog();
143 bExecute
= sal_False
;
147 sErrorString
+= '\n';
148 sErrorString
+= String( BibResId( RID_MAP_QUESTION
) );
149 QueryBox
aQuery( this, WB_YES_NO
, sErrorString
);
150 aQuery
.SetDefaultCheckBoxText();
151 short nResult
= aQuery
.Execute();
152 BibModul::GetConfig()->SetShowColumnAssignmentWarning(
153 !aQuery
.GetCheckBoxState());
154 if( RET_YES
!= nResult
)
156 bExecute
= sal_False
;
161 Application::PostUserEvent( STATIC_LINK( this, BibView
, CallMappingHdl
) );
166 void BibView::_loaded( const EventObject
& _rEvent
)
169 FormControlContainer::_loaded( _rEvent
);
172 void BibView::_reloaded( const EventObject
& _rEvent
)
175 FormControlContainer::_loaded( _rEvent
);
178 IMPL_STATIC_LINK( BibView
, CallMappingHdl
, BibView
*, EMPTYARG
)
180 pThis
->m_pDatMan
->CreateMappingDialog( pThis
);
184 void BibView::Resize()
186 if ( m_pGeneralPage
)
188 ::Size
aSz( GetOutputSizePixel() );
189 m_pGeneralPage
->SetSizePixel( aSz
);
194 Reference
< awt::XControlContainer
> BibView::getControlContainer()
196 Reference
< awt::XControlContainer
> xReturn
;
197 if ( m_pGeneralPage
)
198 xReturn
= m_pGeneralPage
->GetControlContainer();
202 void BibView::GetFocus()
205 m_pGeneralPage
->GrabFocus();
208 sal_Bool
BibView::HandleShortCutKey( const KeyEvent
& rKeyEvent
)
210 return m_pGeneralPage
? m_pGeneralPage
->HandleShortCutKey( rKeyEvent
) : sal_False
;
213 //.........................................................................
215 //.........................................................................
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */