merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / misc / singledoccontroller.cxx
blob205025a0e31b9d4a7367cd014b8a36a373f9cba4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: singledoccontroller.cxx,v $
10 * $Revision: 1.30.24.2 $
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_dbaccess.hxx"
34 #include "browserids.hxx"
35 #include "commontypes.hxx"
36 #include "dataview.hxx"
37 #include "dbu_misc.hrc"
38 #include "dbustrings.hrc"
39 #include "moduledbu.hxx"
40 #include "singledoccontroller.hxx"
41 #include <com/sun/star/frame/XUntitledNumbers.hpp>
43 /** === begin UNO includes === **/
44 #include <com/sun/star/beans/PropertyAttribute.hpp>
45 #include <com/sun/star/container/XChild.hpp>
46 #include <com/sun/star/container/XNameAccess.hpp>
47 #include <com/sun/star/sdb/XDocumentDataSource.hpp>
48 #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
49 #include <com/sun/star/sdbc/XDataSource.hpp>
50 #include <com/sun/star/lang/IllegalArgumentException.hpp>
51 #include <com/sun/star/frame/XUntitledNumbers.hpp>
52 /** === end UNO includes === **/
54 #include <comphelper/sequence.hxx>
55 #include <comphelper/types.hxx>
56 #include <connectivity/dbexception.hxx>
57 #include <connectivity/dbtools.hxx>
58 #include <cppuhelper/typeprovider.hxx>
59 #include <rtl/ustrbuf.hxx>
60 #include <toolkit/unohlp.hxx>
61 #include <tools/debug.hxx>
62 #include <tools/diagnose_ex.h>
63 #include <vcl/msgbox.hxx>
65 //........................................................................
66 namespace dbaui
68 //........................................................................
70 /** === begin UNO using === **/
71 using ::com::sun::star::uno::Any;
72 using ::com::sun::star::uno::Reference;
73 using ::com::sun::star::beans::XPropertySet;
74 using ::com::sun::star::util::XNumberFormatter;
75 using ::com::sun::star::lang::XMultiServiceFactory;
76 using ::com::sun::star::uno::RuntimeException;
77 using ::com::sun::star::uno::Sequence;
78 using ::com::sun::star::uno::Type;
79 using ::com::sun::star::sdbc::XConnection;
80 using ::com::sun::star::uno::UNO_QUERY;
81 using ::com::sun::star::container::XChild;
82 using ::com::sun::star::sdbc::XDataSource;
83 using ::com::sun::star::util::XNumberFormatter;
84 using ::com::sun::star::util::XNumberFormatsSupplier;
85 using ::com::sun::star::frame::XFrame;
86 using ::com::sun::star::uno::Exception;
87 using ::com::sun::star::sdbc::SQLException;
88 using ::com::sun::star::lang::EventObject;
89 using ::com::sun::star::beans::PropertyValue;
90 using ::com::sun::star::frame::XModel;
91 using ::com::sun::star::sdb::XOfficeDatabaseDocument;
92 using ::com::sun::star::awt::XWindow;
93 using ::com::sun::star::sdbc::XDatabaseMetaData;
94 using ::com::sun::star::sdb::XDocumentDataSource;
95 using ::com::sun::star::document::XEmbeddedScripts;
96 using ::com::sun::star::lang::IllegalArgumentException;
97 using ::com::sun::star::uno::UNO_SET_THROW;
98 using ::com::sun::star::uno::UNO_QUERY_THROW;
99 using ::com::sun::star::frame::XUntitledNumbers;
100 /** === end UNO using === **/
102 class DataSourceHolder
104 public:
105 DataSourceHolder()
109 DataSourceHolder( const Reference< XDataSource >& _rxDataSource )
111 m_xDataSource = _rxDataSource;
112 Reference< XDocumentDataSource > xDocDS( m_xDataSource, UNO_QUERY );
113 if ( xDocDS.is() )
114 m_xDocument = xDocDS->getDatabaseDocument();
116 m_xDataSourceProps.set( m_xDataSource, UNO_QUERY );
119 const Reference< XDataSource >& getDataSource() const { return m_xDataSource; }
120 const Reference< XPropertySet >& getDataSourceProps() const { return m_xDataSourceProps; }
121 const Reference< XOfficeDatabaseDocument > getDatabaseDocument() const { return m_xDocument; }
123 bool is() const { return m_xDataSource.is(); }
125 void clear()
127 m_xDataSource.clear();
128 m_xDocument.clear();
131 private:
132 Reference< XDataSource > m_xDataSource;
133 Reference< XPropertySet > m_xDataSourceProps;
134 Reference< XOfficeDatabaseDocument > m_xDocument;
137 struct OSingleDocumentControllerImpl
139 private:
140 ::boost::optional< bool > m_aDocScriptSupport;
142 public:
143 OModuleClient m_aModuleClient;
144 ::dbtools::SQLExceptionInfo m_aCurrentError; // contains the current error which can be set through IEnvironment
146 // <properties>
147 SharedConnection m_xConnection;
148 ::dbtools::DatabaseMetaData m_aSdbMetaData;
149 // </properties>
150 ::rtl::OUString m_sDataSourceName; // the data source we're working for
151 DataSourceHolder m_aDataSource;
152 Reference< XModel > m_xDocument;
153 Reference< XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier
154 sal_Int32 m_nDocStartNumber;
155 sal_Bool m_bSuspended; // is true when the controller was already suspended
156 sal_Bool m_bEditable; // is the control readonly or not
157 sal_Bool m_bModified; // is the data modified
158 bool m_bNotAttached;
160 OSingleDocumentControllerImpl()
161 :m_aDocScriptSupport()
162 ,m_nDocStartNumber(0)
163 ,m_bSuspended( sal_False )
164 ,m_bEditable(sal_True)
165 ,m_bModified(sal_False)
166 ,m_bNotAttached(true)
170 bool documentHasScriptSupport() const
172 OSL_PRECOND( !!m_aDocScriptSupport,
173 "OSingleDocumentControllerImpl::documentHasScriptSupport: not completely initialized, yet - don't know!?" );
174 return !!m_aDocScriptSupport && *m_aDocScriptSupport;
177 void setDocumentScriptSupport( const bool _bSupport )
179 OSL_PRECOND( !m_aDocScriptSupport,
180 "OSingleDocumentControllerImpl::setDocumentScriptSupport: already initialized!" );
181 m_aDocScriptSupport = ::boost::optional< bool >( _bSupport );
185 //====================================================================
186 //= OSingleDocumentController
187 //====================================================================
188 //--------------------------------------------------------------------
189 OSingleDocumentController::OSingleDocumentController(const Reference< XMultiServiceFactory >& _rxORB)
190 :OSingleDocumentController_Base( _rxORB )
191 ,m_pImpl(new OSingleDocumentControllerImpl())
195 //--------------------------------------------------------------------
196 OSingleDocumentController::~OSingleDocumentController()
200 //--------------------------------------------------------------------
201 void OSingleDocumentController::impl_initialize()
203 OGenericUnoController::impl_initialize();
205 const ::comphelper::NamedValueCollection& rArguments( getInitParams() );
207 Reference< XConnection > xConnection;
208 xConnection = rArguments.getOrDefault( (::rtl::OUString)PROPERTY_ACTIVE_CONNECTION, xConnection );
210 if ( !xConnection.is() )
211 ::dbtools::isEmbeddedInDatabase( getModel(), xConnection );
213 if ( xConnection.is() )
214 initializeConnection( xConnection );
216 bool bShowError = true;
217 if ( !isConnected() )
219 reconnect( sal_False );
220 bShowError = false;
222 if ( !isConnected() )
224 if ( bShowError )
225 connectionLostMessage();
226 throw IllegalArgumentException();
230 //--------------------------------------------------------------------
231 Any SAL_CALL OSingleDocumentController::queryInterface(const Type& _rType) throw (RuntimeException)
233 if ( _rType.equals( XScriptInvocationContext::static_type() ) )
235 if ( m_pImpl->documentHasScriptSupport() )
236 return makeAny( Reference< XScriptInvocationContext >( this ) );
237 return Any();
240 return OSingleDocumentController_Base::queryInterface( _rType );
243 //--------------------------------------------------------------------
244 Sequence< Type > SAL_CALL OSingleDocumentController::getTypes( ) throw (RuntimeException)
246 Sequence< Type > aTypes( OSingleDocumentController_Base::getTypes() );
247 if ( !m_pImpl->documentHasScriptSupport() )
249 Sequence< Type > aStrippedTypes( aTypes.getLength() - 1 );
250 ::std::remove_copy_if(
251 aTypes.getConstArray(),
252 aTypes.getConstArray() + aTypes.getLength(),
253 aStrippedTypes.getArray(),
254 ::std::bind2nd( ::std::equal_to< Type >(), XScriptInvocationContext::static_type() )
256 aTypes = aStrippedTypes;
258 return aTypes;
261 //--------------------------------------------------------------------
262 void OSingleDocumentController::initializeConnection( const Reference< XConnection >& _rxForeignConn )
264 DBG_ASSERT( !isConnected(), "OSingleDocumentController::initializeConnection: not to be called when already connected!" );
265 // usually this gets called from within initialize of derived classes ...
266 if ( isConnected() )
267 disconnect();
269 m_pImpl->m_xConnection.reset( _rxForeignConn, SharedConnection::NoTakeOwnership );
270 m_pImpl->m_aSdbMetaData.reset( m_pImpl->m_xConnection );
271 startConnectionListening( m_pImpl->m_xConnection );
273 // get the data source the connection belongs to
276 // determine our data source
277 OSL_PRECOND( !m_pImpl->m_aDataSource.is(), "OSingleDocumentController::initializeConnection: already a data source in this phase?" );
279 Reference< XChild > xConnAsChild( m_pImpl->m_xConnection, UNO_QUERY );
280 Reference< XDataSource > xDS;
281 if ( xConnAsChild.is() )
282 xDS = Reference< XDataSource >( xConnAsChild->getParent(), UNO_QUERY );
284 // (take the indirection through XDataSource to ensure we have a correct object ....)
285 m_pImpl->m_aDataSource = xDS;
287 OSL_POSTCOND( m_pImpl->m_aDataSource.is(), "OSingleDocumentController::initializeConnection: unable to obtain the data source object!" );
289 if ( m_pImpl->m_bNotAttached )
291 Reference< XUntitledNumbers > xUntitledProvider( getDatabaseDocument(), UNO_QUERY );
292 m_pImpl->m_nDocStartNumber = 1;
293 if ( xUntitledProvider.is() )
294 m_pImpl->m_nDocStartNumber = xUntitledProvider->leaseNumber( static_cast< XWeak* >( this ) );
297 // determine the availability of script support in our document. Our own XScriptInvocationContext
298 // interface depends on this
299 m_pImpl->setDocumentScriptSupport( Reference< XEmbeddedScripts >( getDatabaseDocument(), UNO_QUERY ).is() );
301 // get a number formatter
302 Reference< XPropertySet > xDataSourceProps( m_pImpl->m_aDataSource.getDataSourceProps(), UNO_SET_THROW );
303 xDataSourceProps->getPropertyValue( PROPERTY_NAME ) >>= m_pImpl->m_sDataSourceName;
304 DBG_ASSERT( m_pImpl->m_sDataSourceName.getLength(), "OSingleDocumentController::initializeConnection: invalid data source name!" );
305 Reference< XNumberFormatsSupplier> xSupplier = ::dbtools::getNumberFormats(m_pImpl->m_xConnection);
306 if(xSupplier.is())
308 m_pImpl->m_xFormatter = Reference< XNumberFormatter >(getORB()
309 ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY);
310 m_pImpl->m_xFormatter->attachNumberFormatsSupplier(xSupplier);
312 OSL_ENSURE(m_pImpl->m_xFormatter.is(),"No NumberFormatter!");
314 catch( const Exception& )
316 DBG_UNHANDLED_EXCEPTION();
320 //--------------------------------------------------------------------
321 void OSingleDocumentController::reconnect( sal_Bool _bUI )
323 OSL_ENSURE(!m_pImpl->m_bSuspended, "Cannot reconnect while suspended!");
325 stopConnectionListening( m_pImpl->m_xConnection );
326 m_pImpl->m_aSdbMetaData.reset( NULL );
327 m_pImpl->m_xConnection.clear();
329 // reconnect
330 sal_Bool bReConnect = sal_True;
331 if ( _bUI )
333 QueryBox aQuery( getView(), ModuleRes(QUERY_CONNECTION_LOST) );
334 bReConnect = ( RET_YES == aQuery.Execute() );
337 // now really reconnect ...
338 if ( bReConnect )
340 m_pImpl->m_xConnection.reset( connect( m_pImpl->m_aDataSource.getDataSource(), NULL ), SharedConnection::TakeOwnership );
341 m_pImpl->m_aSdbMetaData.reset( m_pImpl->m_xConnection );
344 // invalidate all slots
345 InvalidateAll();
348 //--------------------------------------------------------------------
349 void OSingleDocumentController::disconnect()
351 stopConnectionListening(m_pImpl->m_xConnection);
352 m_pImpl->m_aSdbMetaData.reset( NULL );
353 m_pImpl->m_xConnection.clear();
355 InvalidateAll();
358 //--------------------------------------------------------------------
359 void OSingleDocumentController::losingConnection()
361 // our connection was disposed so we need a new one
362 reconnect( sal_True );
365 //--------------------------------------------------------------------
366 void SAL_CALL OSingleDocumentController::disposing()
368 OSingleDocumentController_Base::disposing();
369 m_aUndoManager.Clear();
371 disconnect();
373 attachFrame( Reference < XFrame >() );
375 m_pImpl->m_aDataSource.clear();
378 //--------------------------------------------------------------------
379 sal_Bool OSingleDocumentController::Construct(Window* _pParent)
381 DBG_ASSERT( getView(), "OSingleDocumentController::Construct: have no view!" );
382 if ( getView() )
383 getView()->enableSeparator( );
385 return OSingleDocumentController_Base::Construct( _pParent );
388 //--------------------------------------------------------------------
389 void SAL_CALL OSingleDocumentController::disposing(const EventObject& _rSource) throw( RuntimeException )
391 if ( _rSource.Source == getConnection() )
393 if ( !m_pImpl->m_bSuspended // when already suspended then we don't have to reconnect
394 && !getBroadcastHelper().bInDispose
395 && !getBroadcastHelper().bDisposed
396 && isConnected()
399 losingConnection();
401 else
403 m_pImpl->m_xConnection.reset( m_pImpl->m_xConnection, SharedConnection::NoTakeOwnership );
404 // this prevents the "disposeComponent" call in disconnect
405 disconnect();
408 else
409 OSingleDocumentController_Base::disposing( _rSource );
412 //--------------------------------------------------------------------
413 void OSingleDocumentController::appendError( const ::rtl::OUString& _rErrorMessage, const ::dbtools::StandardSQLState _eSQLState,
414 const sal_Int32 _nErrorCode )
416 m_pImpl->m_aCurrentError.append( ::dbtools::SQLExceptionInfo::SQL_EXCEPTION, _rErrorMessage, getStandardSQLStateAscii( _eSQLState ),
417 _nErrorCode );
419 //--------------------------------------------------------------------
420 void OSingleDocumentController::clearError()
422 m_pImpl->m_aCurrentError = ::dbtools::SQLExceptionInfo();
425 //--------------------------------------------------------------------
426 sal_Bool OSingleDocumentController::hasError() const
428 return m_pImpl->m_aCurrentError.isValid();
431 //--------------------------------------------------------------------
432 const ::dbtools::SQLExceptionInfo& OSingleDocumentController::getError() const
434 return m_pImpl->m_aCurrentError;
437 //--------------------------------------------------------------------
438 void OSingleDocumentController::displayError()
440 showError( m_pImpl->m_aCurrentError );
443 //--------------------------------------------------------------------
444 sal_Bool SAL_CALL OSingleDocumentController::suspend(sal_Bool bSuspend) throw( RuntimeException )
446 m_pImpl->m_bSuspended = bSuspend;
447 if ( !bSuspend && !isConnected() )
448 reconnect(sal_True);
451 return sal_True;
454 // -----------------------------------------------------------------------------
455 sal_Bool SAL_CALL OSingleDocumentController::attachModel( const Reference< XModel > & _rxModel) throw( RuntimeException )
457 if ( !_rxModel.is() )
458 return sal_False;
459 if ( !OSingleDocumentController_Base::attachModel( _rxModel ) )
460 return sal_False;
462 m_pImpl->m_bNotAttached = false;
463 if ( m_pImpl->m_nDocStartNumber == 1 )
464 releaseNumberForComponent();
466 Reference< XUntitledNumbers > xUntitledProvider( _rxModel, UNO_QUERY );
467 m_pImpl->m_nDocStartNumber = 1;
468 if ( xUntitledProvider.is() )
469 m_pImpl->m_nDocStartNumber = xUntitledProvider->leaseNumber( static_cast< XWeak* >( this ) );
471 return sal_True;
474 // -----------------------------------------------------------------------------
475 FeatureState OSingleDocumentController::GetState(sal_uInt16 _nId) const
477 FeatureState aReturn;
478 // (disabled automatically)
479 aReturn.bEnabled = sal_True;
481 switch (_nId)
483 case ID_BROWSER_UNDO:
484 aReturn.bEnabled = m_pImpl->m_bEditable && m_aUndoManager.GetUndoActionCount() != 0;
485 if ( aReturn.bEnabled )
487 String sUndo(ModuleRes(STR_UNDO_COLON));
488 sUndo += String(RTL_CONSTASCII_USTRINGPARAM(" "));
489 sUndo += m_aUndoManager.GetUndoActionComment();
490 aReturn.sTitle = sUndo;
492 break;
493 case ID_BROWSER_REDO:
494 aReturn.bEnabled = m_pImpl->m_bEditable && m_aUndoManager.GetRedoActionCount() != 0;
495 if ( aReturn.bEnabled )
497 String sRedo(ModuleRes(STR_REDO_COLON));
498 sRedo += String(RTL_CONSTASCII_USTRINGPARAM(" "));
499 sRedo += m_aUndoManager.GetRedoActionComment();
500 aReturn.sTitle = sRedo;
502 break;
503 default:
504 aReturn = OSingleDocumentController_Base::GetState(_nId);
506 return aReturn;
508 // -----------------------------------------------------------------------------
509 void OSingleDocumentController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& _rArgs)
511 switch(_nId)
513 case ID_BROWSER_CLOSE:
514 closeTask();
515 return;
516 case ID_BROWSER_UNDO:
517 m_aUndoManager.Undo();
518 InvalidateFeature(ID_BROWSER_REDO);
519 break;
520 case ID_BROWSER_REDO:
521 m_aUndoManager.Redo();
522 InvalidateFeature(ID_BROWSER_UNDO);
523 break;
524 default:
525 OSingleDocumentController_Base::Execute( _nId, _rArgs );
526 break;
528 InvalidateFeature(_nId);
530 // -----------------------------------------------------------------------------
531 SfxUndoManager* OSingleDocumentController::getUndoMgr()
533 return &m_aUndoManager;
535 // -----------------------------------------------------------------------------
536 void OSingleDocumentController::addUndoActionAndInvalidate(SfxUndoAction *_pAction)
538 // add undo action
539 m_aUndoManager.AddUndoAction(_pAction);
540 // when we add an undo action the controller was modified
541 setModified(sal_True);
542 // now inform me that or states changed
543 InvalidateFeature(ID_BROWSER_UNDO);
544 InvalidateFeature(ID_BROWSER_REDO);
546 // -----------------------------------------------------------------------------
547 void OSingleDocumentController::setModified(sal_Bool _bModified)
549 m_pImpl->m_bModified = _bModified;
550 InvalidateFeature(ID_BROWSER_SAVEDOC);
552 if ( isFeatureSupported( ID_BROWSER_SAVEASDOC ) )
553 InvalidateFeature(ID_BROWSER_SAVEASDOC);
556 // -----------------------------------------------------------------------------
557 ::rtl::OUString OSingleDocumentController::getDataSourceName() const
559 ::rtl::OUString sName;
560 Reference< XPropertySet > xDataSourceProps( m_pImpl->m_aDataSource.getDataSourceProps() );
561 if ( xDataSourceProps.is() )
562 xDataSourceProps->getPropertyValue(PROPERTY_NAME) >>= sName;
563 return sName;
565 // -----------------------------------------------------------------------------
566 void OSingleDocumentController::connectionLostMessage() const
568 String aMessage(ModuleRes(RID_STR_CONNECTION_LOST));
569 Reference< XWindow > xWindow = getTopMostContainerWindow();
570 Window* pWin = NULL;
571 if ( xWindow.is() )
572 pWin = VCLUnoHelper::GetWindow(xWindow);
573 if ( !pWin )
574 pWin = getView()->Window::GetParent();
576 InfoBox(pWin, aMessage).Execute();
578 // -----------------------------------------------------------------------------
579 const Reference< XConnection >& OSingleDocumentController::getConnection() const
581 return m_pImpl->m_xConnection;
584 // -----------------------------------------------------------------------------
585 sal_Bool OSingleDocumentController::isReadOnly() const
587 return !m_pImpl->m_bEditable;
590 // -----------------------------------------------------------------------------
591 sal_Bool OSingleDocumentController::isEditable() const
593 return m_pImpl->m_bEditable;
596 // -----------------------------------------------------------------------------
597 sal_Bool OSingleDocumentController::isModified() const
599 return m_pImpl->m_bModified;
602 // -----------------------------------------------------------------------------
603 void OSingleDocumentController::setEditable(sal_Bool _bEditable)
605 m_pImpl->m_bEditable = _bEditable;
608 // -----------------------------------------------------------------------------
609 const ::dbtools::DatabaseMetaData& OSingleDocumentController::getSdbMetaData() const
611 return m_pImpl->m_aSdbMetaData;
614 // -----------------------------------------------------------------------------
615 sal_Bool OSingleDocumentController::isConnected() const
617 return m_pImpl->m_xConnection.is();
620 // -----------------------------------------------------------------------------
621 Reference< XDatabaseMetaData > OSingleDocumentController::getMetaData( ) const
623 Reference< XDatabaseMetaData > xMeta;
626 if ( isConnected() )
627 xMeta.set( m_pImpl->m_xConnection->getMetaData(), UNO_SET_THROW );
629 catch( const Exception& )
631 DBG_UNHANDLED_EXCEPTION();
633 return xMeta;
636 // -----------------------------------------------------------------------------
637 const Reference< XPropertySet >& OSingleDocumentController::getDataSource() const
639 return m_pImpl->m_aDataSource.getDataSourceProps();
642 // -----------------------------------------------------------------------------
643 sal_Bool OSingleDocumentController::haveDataSource() const
645 return m_pImpl->m_aDataSource.is();
648 // -----------------------------------------------------------------------------
649 Reference< XModel > OSingleDocumentController::getDatabaseDocument() const
651 return Reference< XModel >( m_pImpl->m_aDataSource.getDatabaseDocument(), UNO_QUERY );
654 // -----------------------------------------------------------------------------
655 Reference< XNumberFormatter > OSingleDocumentController::getNumberFormatter() const
657 return m_pImpl->m_xFormatter;
660 // -----------------------------------------------------------------------------
661 Reference< XModel > OSingleDocumentController::getPrivateModel() const
663 return getDatabaseDocument();
665 // -----------------------------------------------------------------------------
666 // XTitle
667 ::rtl::OUString SAL_CALL OSingleDocumentController::getTitle()
668 throw (RuntimeException)
670 ::osl::MutexGuard aGuard( getMutex() );
671 if ( m_bExternalTitle )
672 return impl_getTitleHelper_throw()->getTitle ();
674 ::rtl::OUStringBuffer sTitle;
675 Reference< XTitle > xTitle(getPrivateModel(),UNO_QUERY);
676 if ( xTitle.is() )
678 sTitle.append( xTitle->getTitle() );
679 sTitle.appendAscii(" : ");
681 sTitle.append( getPrivateTitle() );
682 // There can be only one view with the same object
683 //const sal_Int32 nCurrentView = getCurrentStartNumber();
684 //if ( nCurrentView > 1 )
686 // sTitle.appendAscii(" : ");
687 // sTitle.append(nCurrentView);
690 return sTitle.makeStringAndClear();
692 // -----------------------------------------------------------------------------
693 sal_Int32 OSingleDocumentController::getCurrentStartNumber() const
695 return m_pImpl->m_nDocStartNumber;
698 // -----------------------------------------------------------------------------
699 Reference< XEmbeddedScripts > SAL_CALL OSingleDocumentController::getScriptContainer() throw (RuntimeException)
701 ::osl::MutexGuard aGuard( getMutex() );
702 if ( !m_pImpl->documentHasScriptSupport() )
703 return NULL;
705 return Reference< XEmbeddedScripts >( getDatabaseDocument(), UNO_QUERY_THROW );
708 //........................................................................
709 } // namespace dbaui
710 //........................................................................