Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #include "scriptdocument.hxx"
21 : : #include "basobj.hxx"
22 : : #include "basidesh.hrc"
23 : : #include "iderid.hxx"
24 : : #include "dlgeddef.hxx"
25 : : #include "doceventnotifier.hxx"
26 : : #include "documentenumeration.hxx"
27 : :
28 : : #include <com/sun/star/uri/XUriReferenceFactory.hpp>
29 : : #include <com/sun/star/util/XMacroExpander.hpp>
30 : : #include <com/sun/star/document/MacroExecMode.hpp>
31 : : #include <com/sun/star/frame/XStorable.hpp>
32 : : #include <com/sun/star/frame/FrameSearchFlag.hpp>
33 : : #include <com/sun/star/frame/XDesktop.hpp>
34 : : #include <com/sun/star/frame/XModel2.hpp>
35 : : #include <com/sun/star/awt/XWindow2.hpp>
36 : : #include <com/sun/star/document/XEmbeddedScripts.hpp>
37 : : #include <com/sun/star/script/vba/XVBACompatibility.hpp>
38 : : #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
39 : :
40 : : #include <sfx2/objsh.hxx>
41 : : #include <sfx2/app.hxx>
42 : : #include <sfx2/viewfrm.hxx>
43 : : #include <sfx2/bindings.hxx>
44 : : #include <sfx2/docfile.hxx>
45 : :
46 : : #include <vcl/svapp.hxx>
47 : :
48 : : #include <basic/basicmanagerrepository.hxx>
49 : :
50 : : #include <xmlscript/xmldlg_imexp.hxx>
51 : :
52 : : #include <unotools/syslocale.hxx>
53 : :
54 : : #include <unotools/collatorwrapper.hxx>
55 : :
56 : : #include <tools/diagnose_ex.h>
57 : :
58 : : #include <comphelper/processfactory.hxx>
59 : : #include <comphelper/documentinfo.hxx>
60 : : #include <comphelper/componentcontext.hxx>
61 : :
62 : : #include <osl/mutex.hxx>
63 : :
64 : : #include <cppuhelper/implbase1.hxx>
65 : :
66 : : #include <rtl/uri.hxx>
67 : : #include <rtl/bootstrap.hxx>
68 : :
69 : : #include <osl/process.h>
70 : : #include <osl/file.hxx>
71 : :
72 : : #include <set>
73 : :
74 : : namespace basctl
75 : : {
76 : : using ::com::sun::star::uno::Sequence;
77 : : using ::com::sun::star::uno::Reference;
78 : : using ::com::sun::star::frame::XModel;
79 : : using ::com::sun::star::beans::XPropertySet;
80 : : using ::com::sun::star::script::XLibraryContainer;
81 : : using ::com::sun::star::uno::UNO_QUERY_THROW;
82 : : using ::com::sun::star::uno::UNO_SET_THROW;
83 : : using ::com::sun::star::beans::XPropertySetInfo;
84 : : using ::com::sun::star::uno::Exception;
85 : : using ::com::sun::star::container::XNameContainer;
86 : : using ::com::sun::star::container::NoSuchElementException;
87 : : using ::com::sun::star::uno::UNO_QUERY;
88 : : using ::com::sun::star::task::XStatusIndicator;
89 : : using ::com::sun::star::uno::makeAny;
90 : : using ::com::sun::star::script::XLibraryContainer2;
91 : : using ::com::sun::star::lang::XMultiServiceFactory;
92 : : using ::com::sun::star::uri::XUriReferenceFactory;
93 : : using ::com::sun::star::uri::XUriReference;
94 : : using ::com::sun::star::uno::XComponentContext;
95 : : using ::com::sun::star::util::XMacroExpander;
96 : : using ::com::sun::star::io::XInputStreamProvider;
97 : : using ::com::sun::star::uno::Any;
98 : : using ::com::sun::star::io::XInputStream;
99 : : using ::com::sun::star::frame::XStorable;
100 : : using ::com::sun::star::util::XModifiable;
101 : : using ::com::sun::star::frame::XController;
102 : : using ::com::sun::star::frame::XFrame;
103 : : using ::com::sun::star::util::URL;
104 : : using ::com::sun::star::frame::XDispatchProvider;
105 : : using ::com::sun::star::frame::XDispatch;
106 : : using ::com::sun::star::beans::PropertyValue;
107 : : using ::com::sun::star::frame::XDesktop;
108 : : using ::com::sun::star::container::XEnumerationAccess;
109 : : using ::com::sun::star::container::XEnumeration;
110 : : using ::com::sun::star::frame::XModel2;
111 : : using ::com::sun::star::awt::XWindow2;
112 : : using ::com::sun::star::document::XEventListener;
113 : : using ::com::sun::star::lang::EventObject;
114 : : using ::com::sun::star::uno::RuntimeException;
115 : : using ::com::sun::star::document::XEventBroadcaster;
116 : : using ::com::sun::star::document::XEmbeddedScripts;
117 : : using ::com::sun::star::script::ModuleInfo;
118 : : using ::com::sun::star::script::vba::XVBACompatibility;
119 : : using ::com::sun::star::script::vba::XVBAModuleInfo;
120 : : /** === end UNO using === **/
121 : : namespace MacroExecMode = ::com::sun::star::document::MacroExecMode;
122 : : namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag;
123 : :
124 : : //====================================================================
125 : : //= helper
126 : : //====================================================================
127 : : namespace
128 : : {
129 : 0 : static bool StringCompareLessThan( const String& lhs, const String& rhs )
130 : : {
131 : 0 : return ( lhs.CompareIgnoreCaseToAscii( rhs ) == COMPARE_LESS );
132 : : }
133 : :
134 : : class FilterDocuments : public docs::IDocumentDescriptorFilter
135 : : {
136 : : public:
137 : 0 : FilterDocuments( bool _bFilterInvisible ) : m_bFilterInvisible( _bFilterInvisible ) { }
138 : :
139 : 0 : virtual ~FilterDocuments() {}
140 : :
141 : : virtual bool includeDocument( const docs::DocumentDescriptor& _rDocument ) const;
142 : :
143 : : private:
144 : : bool impl_isDocumentVisible_nothrow( const docs::DocumentDescriptor& _rDocument ) const;
145 : :
146 : : private:
147 : : bool m_bFilterInvisible;
148 : : };
149 : :
150 : 0 : bool FilterDocuments::impl_isDocumentVisible_nothrow( const docs::DocumentDescriptor& _rDocument ) const
151 : : {
152 : : try
153 : : {
154 : 0 : for ( docs::Controllers::const_iterator controller = _rDocument.aControllers.begin();
155 : 0 : controller != _rDocument.aControllers.end();
156 : : ++controller
157 : : )
158 : : {
159 : 0 : Reference< XFrame > xFrame( (*controller)->getFrame(), UNO_SET_THROW );
160 : 0 : Reference< XWindow2 > xContainer( xFrame->getContainerWindow(), UNO_QUERY_THROW );
161 : 0 : if ( xContainer->isVisible() )
162 : 0 : return true;
163 : 0 : }
164 : : }
165 : 0 : catch( const Exception& )
166 : : {
167 : : DBG_UNHANDLED_EXCEPTION();
168 : : }
169 : 0 : return false;
170 : : }
171 : :
172 : 0 : bool FilterDocuments::includeDocument( const docs::DocumentDescriptor& _rDocument ) const
173 : : {
174 : 0 : Reference< XEmbeddedScripts > xScripts( _rDocument.xModel, UNO_QUERY );
175 : 0 : if ( !xScripts.is() )
176 : 0 : return false;
177 : 0 : if ( !m_bFilterInvisible || impl_isDocumentVisible_nothrow( _rDocument ) )
178 : 0 : return true;
179 : 0 : return false;
180 : : }
181 : :
182 : 0 : void lcl_getAllModels_throw( docs::Documents& _out_rModels, bool _bVisibleOnly )
183 : : {
184 : 0 : _out_rModels.clear();
185 : :
186 : 0 : ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
187 : 0 : FilterDocuments aFilter( _bVisibleOnly );
188 : 0 : docs::DocumentEnumeration aEnum( aContext, &aFilter );
189 : :
190 : 0 : aEnum.getDocuments( _out_rModels );
191 : 0 : }
192 : : }
193 : :
194 : : class ScriptDocument_Impl : public DocumentEventListener
195 : : {
196 : : private:
197 : : bool m_bIsApplication;
198 : : bool m_bValid;
199 : : bool m_bDocumentClosed;
200 : : Reference< XModel > m_xDocument;
201 : : Reference< XModifiable > m_xDocModify;
202 : : Reference< XEmbeddedScripts > m_xScriptAccess;
203 : : ::std::auto_ptr< DocumentEventNotifier >
204 : : m_pDocListener;
205 : :
206 : : public:
207 : : ScriptDocument_Impl( );
208 : : ScriptDocument_Impl( const Reference< XModel >& _rxDocument );
209 : : ~ScriptDocument_Impl();
210 : :
211 : : /** determines whether the instance refers to a valid "document" with script and
212 : : dialog libraries
213 : : */
214 : 0 : inline bool isValid() const { return m_bValid; }
215 : : /** determines whether the instance refers to a non-closed document
216 : : */
217 : 0 : inline bool isAlive() const { return m_bValid ? ( m_bIsApplication ? true : !m_bDocumentClosed ) : false; }
218 : : /// determines whether the "document" refers to the application in real
219 : 0 : inline bool isApplication() const { return m_bValid && m_bIsApplication; }
220 : : /// determines whether the document refers to a real document (instead of the application)
221 : 0 : inline bool isDocument() const { return m_bValid && !m_bIsApplication; }
222 : :
223 : : /** invalidates the instance
224 : : */
225 : : void invalidate();
226 : :
227 : : const Reference< XModel >&
228 : 0 : getDocumentRef() const { return m_xDocument; }
229 : :
230 : : /// returns a library container belonging to the document
231 : : Reference< XLibraryContainer >
232 : : getLibraryContainer( LibraryContainerType _eType ) const;
233 : :
234 : : /// determines whether a given library is part of the shared installation
235 : : bool isLibraryShared( const ::rtl::OUString& _rLibName, LibraryContainerType _eType );
236 : :
237 : : /** returns the current frame of the document
238 : :
239 : : To be called for documents only, not for the application.
240 : :
241 : : If <FALSE/> is returned, an assertion will be raised in non-product builds.
242 : : */
243 : : bool getCurrentFrame( Reference< XFrame >& _out_rxFrame ) const;
244 : :
245 : : // versions with the same signature/semantics as in ScriptDocument itself
246 : : bool isReadOnly() const;
247 : : bool isInVBAMode() const;
248 : : BasicManager*
249 : : getBasicManager() const;
250 : : Reference< XModel >
251 : : getDocument() const;
252 : : void setDocumentModified() const;
253 : : bool isDocumentModified() const;
254 : : bool saveDocument( const Reference< XStatusIndicator >& _rxStatusIndicator ) const;
255 : :
256 : : ::rtl::OUString
257 : : getTitle() const;
258 : : ::rtl::OUString
259 : : getURL() const;
260 : :
261 : : bool allowMacros() const;
262 : :
263 : : Reference< XNameContainer >
264 : : getLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, bool _bLoadLibrary ) const
265 : : SAL_THROW((NoSuchElementException));
266 : : bool hasLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const;
267 : : Reference< XNameContainer >
268 : : getOrCreateLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const;
269 : :
270 : : void loadLibraryIfExists( LibraryContainerType _eType, const ::rtl::OUString& _rLibrary );
271 : :
272 : : bool removeModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModuleName );
273 : : bool hasModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName ) const;
274 : : bool getModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rObjectName, Any& _out_rModuleOrDialog );
275 : : bool renameModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rOldName, const ::rtl::OUString& _rNewName, const Reference< XNameContainer >& _rxExistingDialogModel );
276 : : bool createModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, bool _bCreateMain, ::rtl::OUString& _out_rNewModuleCode ) const;
277 : : bool insertModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rObjectName, const ::rtl::OUString& _rModName, const Any& _rElement ) const;
278 : : bool updateModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, const ::rtl::OUString& _rModuleCode ) const;
279 : : bool createDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName, Reference< XInputStreamProvider >& _out_rDialogProvider ) const;
280 : :
281 : : protected:
282 : : // DocumentEventListener
283 : : virtual void onDocumentCreated( const ScriptDocument& _rDocument );
284 : : virtual void onDocumentOpened( const ScriptDocument& _rDocument );
285 : : virtual void onDocumentSave( const ScriptDocument& _rDocument );
286 : : virtual void onDocumentSaveDone( const ScriptDocument& _rDocument );
287 : : virtual void onDocumentSaveAs( const ScriptDocument& _rDocument );
288 : : virtual void onDocumentSaveAsDone( const ScriptDocument& _rDocument );
289 : : virtual void onDocumentClosed( const ScriptDocument& _rDocument );
290 : : virtual void onDocumentTitleChanged( const ScriptDocument& _rDocument );
291 : : virtual void onDocumentModeChanged( const ScriptDocument& _rDocument );
292 : :
293 : : private:
294 : : bool impl_initDocument_nothrow( const Reference< XModel >& _rxModel );
295 : : };
296 : :
297 : : //====================================================================
298 : : //= ScriptDocument_Impl - implementation
299 : : //====================================================================
300 : 0 : ScriptDocument_Impl::ScriptDocument_Impl()
301 : : :m_bIsApplication( true )
302 : : ,m_bValid( true )
303 : 0 : ,m_bDocumentClosed( false )
304 : : {
305 : 0 : }
306 : :
307 : 0 : ScriptDocument_Impl::ScriptDocument_Impl( const Reference< XModel >& _rxDocument )
308 : : :m_bIsApplication( false )
309 : : ,m_bValid( false )
310 : 0 : ,m_bDocumentClosed( false )
311 : : {
312 : 0 : if ( _rxDocument.is() )
313 : : {
314 : 0 : if ( impl_initDocument_nothrow( _rxDocument ) )
315 : : {
316 : : }
317 : : }
318 : 0 : }
319 : :
320 : 0 : ScriptDocument_Impl::~ScriptDocument_Impl()
321 : : {
322 : 0 : invalidate();
323 : 0 : }
324 : :
325 : 0 : void ScriptDocument_Impl::invalidate()
326 : : {
327 : 0 : m_bIsApplication = false;
328 : 0 : m_bValid = false;
329 : 0 : m_bDocumentClosed = false;
330 : :
331 : 0 : m_xDocument.clear();
332 : 0 : m_xDocModify.clear();
333 : 0 : m_xScriptAccess.clear();
334 : :
335 : 0 : if ( m_pDocListener.get() )
336 : 0 : m_pDocListener->dispose();
337 : 0 : }
338 : :
339 : 0 : bool ScriptDocument_Impl::impl_initDocument_nothrow( const Reference< XModel >& _rxModel )
340 : : {
341 : : try
342 : : {
343 : 0 : m_xDocument.set ( _rxModel, UNO_SET_THROW );
344 : 0 : m_xDocModify.set ( _rxModel, UNO_QUERY_THROW );
345 : 0 : m_xScriptAccess.set ( _rxModel, UNO_QUERY );
346 : :
347 : 0 : m_bValid = m_xScriptAccess.is();
348 : :
349 : 0 : if ( m_bValid )
350 : 0 : m_pDocListener.reset( new DocumentEventNotifier( *this, _rxModel ) );
351 : : }
352 : 0 : catch( const Exception& )
353 : : {
354 : : DBG_UNHANDLED_EXCEPTION();
355 : 0 : m_bValid = false;
356 : : }
357 : :
358 : 0 : if ( !m_bValid )
359 : : {
360 : 0 : invalidate();
361 : : }
362 : :
363 : 0 : return m_bValid;
364 : : }
365 : :
366 : 0 : Reference< XLibraryContainer > ScriptDocument_Impl::getLibraryContainer( LibraryContainerType _eType ) const
367 : : {
368 : : OSL_ENSURE( isValid(), "ScriptDocument_Impl::getLibraryContainer: invalid!" );
369 : :
370 : 0 : Reference< XLibraryContainer > xContainer;
371 : 0 : if ( !isValid() )
372 : 0 : return xContainer;
373 : :
374 : : try
375 : : {
376 : 0 : if ( isApplication() )
377 : 0 : xContainer.set( _eType == E_SCRIPTS ? SFX_APP()->GetBasicContainer() : SFX_APP()->GetDialogContainer(), UNO_QUERY_THROW );
378 : : else
379 : : {
380 : : xContainer.set(
381 : 0 : _eType == E_SCRIPTS ? m_xScriptAccess->getBasicLibraries() : m_xScriptAccess->getDialogLibraries(),
382 : 0 : UNO_QUERY_THROW );
383 : : }
384 : : }
385 : 0 : catch( const Exception& )
386 : : {
387 : : DBG_UNHANDLED_EXCEPTION();
388 : : }
389 : 0 : return xContainer;
390 : : }
391 : :
392 : 0 : bool ScriptDocument_Impl::isReadOnly() const
393 : : {
394 : : OSL_ENSURE( isValid(), "ScriptDocument_Impl::isReadOnly: invalid state!" );
395 : : OSL_ENSURE( !isApplication(), "ScriptDocument_Impl::isReadOnly: not allowed to be called for the application!" );
396 : :
397 : 0 : bool bIsReadOnly = true;
398 : 0 : if ( isValid() && !isApplication() )
399 : : {
400 : : try
401 : : {
402 : : // note that XStorable is required by the OfficeDocument service
403 : 0 : Reference< XStorable > xDocStorable( m_xDocument, UNO_QUERY_THROW );
404 : 0 : bIsReadOnly = xDocStorable->isReadonly();
405 : : }
406 : 0 : catch( const Exception& )
407 : : {
408 : : DBG_UNHANDLED_EXCEPTION();
409 : : }
410 : : }
411 : 0 : return bIsReadOnly;
412 : : }
413 : :
414 : 0 : bool ScriptDocument_Impl::isInVBAMode() const
415 : : {
416 : 0 : bool bResult = false;
417 : 0 : if ( !isApplication() )
418 : : {
419 : 0 : Reference< XVBACompatibility > xVBACompat( getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
420 : 0 : if ( xVBACompat.is() )
421 : 0 : bResult = xVBACompat->getVBACompatibilityMode();
422 : : }
423 : 0 : return bResult;
424 : : }
425 : :
426 : :
427 : 0 : BasicManager* ScriptDocument_Impl::getBasicManager() const
428 : : {
429 : : OSL_ENSURE( isValid(), "ScriptDocument_Impl::getBasicManager: invalid state!" );
430 : 0 : if ( !isValid() )
431 : 0 : return NULL;
432 : :
433 : 0 : if ( isApplication() )
434 : 0 : return SFX_APP()->GetBasicManager();
435 : :
436 : 0 : return ::basic::BasicManagerRepository::getDocumentBasicManager( m_xDocument );
437 : : }
438 : :
439 : :
440 : 0 : Reference< XModel > ScriptDocument_Impl::getDocument() const
441 : : {
442 : : OSL_ENSURE( isValid(), "ScriptDocument_Impl::getDocument: invalid state!" );
443 : : OSL_ENSURE( isDocument(), "ScriptDocument_Impl::getDocument: for documents only!" );
444 : 0 : if ( !isValid() || !isDocument() )
445 : 0 : return NULL;
446 : :
447 : 0 : return m_xDocument;
448 : : }
449 : :
450 : :
451 : 0 : Reference< XNameContainer > ScriptDocument_Impl::getLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, bool _bLoadLibrary ) const
452 : : SAL_THROW((NoSuchElementException))
453 : : {
454 : : OSL_ENSURE( isValid(), "ScriptDocument_Impl::getLibrary: invalid state!" );
455 : :
456 : 0 : Reference< XNameContainer > xContainer;
457 : : try
458 : : {
459 : 0 : Reference< XLibraryContainer > xLibContainer = getLibraryContainer( _eType );
460 : 0 : if ( isValid() )
461 : : {
462 : 0 : if ( xLibContainer.is() )
463 : 0 : xContainer.set( xLibContainer->getByName( _rLibName ), UNO_QUERY_THROW );
464 : : }
465 : :
466 : 0 : if ( !xContainer.is() )
467 : 0 : throw NoSuchElementException();
468 : :
469 : : // load library
470 : 0 : if ( _bLoadLibrary && !xLibContainer->isLibraryLoaded( _rLibName ) )
471 : 0 : xLibContainer->loadLibrary( _rLibName );
472 : : }
473 : 0 : catch( const NoSuchElementException& )
474 : : {
475 : 0 : throw; // allowed to leave
476 : : }
477 : 0 : catch( const Exception& )
478 : : {
479 : : DBG_UNHANDLED_EXCEPTION();
480 : : }
481 : :
482 : 0 : return xContainer;
483 : : }
484 : :
485 : :
486 : 0 : bool ScriptDocument_Impl::hasLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const
487 : : {
488 : 0 : bool bHas = false;
489 : : try
490 : : {
491 : 0 : Reference< XLibraryContainer > xLibContainer = getLibraryContainer( _eType );
492 : 0 : bHas = xLibContainer.is() && xLibContainer->hasByName( _rLibName );
493 : : }
494 : 0 : catch( const Exception& )
495 : : {
496 : : DBG_UNHANDLED_EXCEPTION();
497 : : }
498 : 0 : return bHas;
499 : : }
500 : :
501 : :
502 : 0 : Reference< XNameContainer > ScriptDocument_Impl::getOrCreateLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const
503 : : {
504 : 0 : Reference< XNameContainer > xLibrary;
505 : : try
506 : : {
507 : 0 : Reference< XLibraryContainer > xLibContainer( getLibraryContainer( _eType ), UNO_QUERY_THROW );
508 : 0 : if ( xLibContainer->hasByName( _rLibName ) )
509 : 0 : xLibrary.set( xLibContainer->getByName( _rLibName ), UNO_QUERY_THROW );
510 : : else
511 : 0 : xLibrary.set( xLibContainer->createLibrary( _rLibName ), UNO_QUERY_THROW );
512 : :
513 : 0 : if ( !xLibContainer->isLibraryLoaded( _rLibName ) )
514 : 0 : xLibContainer->loadLibrary( _rLibName );
515 : : }
516 : 0 : catch( const Exception& )
517 : : {
518 : : DBG_UNHANDLED_EXCEPTION();
519 : : }
520 : 0 : return xLibrary;
521 : : }
522 : :
523 : :
524 : 0 : void ScriptDocument_Impl::loadLibraryIfExists( LibraryContainerType _eType, const ::rtl::OUString& _rLibrary )
525 : : {
526 : : try
527 : : {
528 : 0 : Reference< XLibraryContainer > xLibContainer( getLibraryContainer( _eType ) );
529 : 0 : if ( xLibContainer.is() && xLibContainer->hasByName( _rLibrary ) && !xLibContainer->isLibraryLoaded( _rLibrary ) )
530 : 0 : xLibContainer->loadLibrary( _rLibrary );
531 : : }
532 : 0 : catch( const Exception& )
533 : : {
534 : : DBG_UNHANDLED_EXCEPTION();
535 : : }
536 : 0 : }
537 : :
538 : :
539 : 0 : bool ScriptDocument_Impl::removeModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModuleName )
540 : : {
541 : : OSL_ENSURE( isValid(), "ScriptDocument_Impl::removeModuleOrDialog: invalid!" );
542 : 0 : if ( isValid() )
543 : : {
544 : : try
545 : : {
546 : 0 : Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, true ) );
547 : 0 : if ( xLib.is() )
548 : : {
549 : 0 : xLib->removeByName( _rModuleName );
550 : 0 : return true;
551 : 0 : }
552 : : }
553 : 0 : catch( const Exception& )
554 : : {
555 : : DBG_UNHANDLED_EXCEPTION();
556 : : }
557 : : }
558 : 0 : return false;
559 : : }
560 : :
561 : :
562 : 0 : bool ScriptDocument_Impl::hasModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName ) const
563 : : {
564 : : OSL_ENSURE( isValid(), "ScriptDocument_Impl::hasModuleOrDialog: invalid!" );
565 : 0 : if ( !isValid() )
566 : 0 : return false;
567 : :
568 : : try
569 : : {
570 : 0 : Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, true ) );
571 : 0 : if ( xLib.is() )
572 : 0 : return xLib->hasByName( _rModName );
573 : : }
574 : 0 : catch( const Exception& )
575 : : {
576 : : DBG_UNHANDLED_EXCEPTION();
577 : : }
578 : 0 : return false;
579 : : }
580 : :
581 : :
582 : 0 : bool ScriptDocument_Impl::getModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rObjectName, Any& _out_rModuleOrDialog )
583 : : {
584 : : OSL_ENSURE( isValid(), "ScriptDocument_Impl::getModuleOrDialog: invalid!" );
585 : 0 : if ( !isValid() )
586 : 0 : return false;
587 : :
588 : 0 : _out_rModuleOrDialog.clear();
589 : : try
590 : : {
591 : 0 : Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, true ), UNO_QUERY_THROW );
592 : 0 : if ( xLib->hasByName( _rObjectName ) )
593 : : {
594 : 0 : _out_rModuleOrDialog = xLib->getByName( _rObjectName );
595 : 0 : return true;
596 : 0 : }
597 : : }
598 : 0 : catch( const Exception& )
599 : : {
600 : : DBG_UNHANDLED_EXCEPTION();
601 : : }
602 : 0 : return false;
603 : : }
604 : :
605 : :
606 : 0 : bool ScriptDocument_Impl::renameModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName,
607 : : const ::rtl::OUString& _rOldName, const ::rtl::OUString& _rNewName, const Reference< XNameContainer >& _rxExistingDialogModel )
608 : : {
609 : : OSL_ENSURE( isValid(), "ScriptDocument_Impl::renameModuleOrDialog: invalid!" );
610 : 0 : if ( !isValid() )
611 : 0 : return false;
612 : :
613 : : try
614 : : {
615 : 0 : Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, true ), UNO_QUERY_THROW );
616 : :
617 : : // get element
618 : 0 : Any aElement( xLib->getByName( _rOldName ) );
619 : :
620 : : // remove element from container
621 : 0 : xLib->removeByName( _rOldName );
622 : :
623 : : // if it's a dialog, import and export, to reflect the new name
624 : 0 : if ( _eType == E_DIALOGS )
625 : : {
626 : : // create dialog model
627 : 0 : ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
628 : 0 : Reference< XNameContainer > xDialogModel;
629 : 0 : if ( _rxExistingDialogModel.is() )
630 : 0 : xDialogModel = _rxExistingDialogModel;
631 : : else
632 : 0 : if ( !aContext.createComponent( "com.sun.star.awt.UnoControlDialogModel", xDialogModel ) )
633 : 0 : return false;
634 : :
635 : : // import dialog model
636 : 0 : Reference< XInputStreamProvider > xISP( aElement, UNO_QUERY_THROW );
637 : 0 : if ( !_rxExistingDialogModel.is() )
638 : : {
639 : 0 : Reference< XInputStream > xInput( xISP->createInputStream(), UNO_QUERY_THROW );
640 : 0 : ::xmlscript::importDialogModel( xInput, xDialogModel, aContext.getUNOContext(), isDocument() ? getDocument() : Reference< XModel >() );
641 : : }
642 : :
643 : : // set new name as property
644 : 0 : Reference< XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY_THROW );
645 : 0 : xDlgPSet->setPropertyValue( DLGED_PROP_NAME, makeAny( _rNewName ) );
646 : :
647 : : // export dialog model
648 : 0 : xISP = ::xmlscript::exportDialogModel( xDialogModel, aContext.getUNOContext(), isDocument() ? getDocument() : Reference< XModel >() );
649 : 0 : aElement <<= xISP;
650 : : }
651 : :
652 : : // insert element by new name in container
653 : 0 : if ( _eType == E_SCRIPTS )
654 : : {
655 : 0 : Reference< XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY );
656 : 0 : if ( xVBAModuleInfo->hasModuleInfo( _rOldName ) )
657 : : {
658 : 0 : ModuleInfo sModuleInfo = xVBAModuleInfo->getModuleInfo( _rOldName );
659 : 0 : xVBAModuleInfo->removeModuleInfo( _rOldName );
660 : 0 : xVBAModuleInfo->insertModuleInfo( _rNewName, sModuleInfo );
661 : 0 : }
662 : : }
663 : 0 : xLib->insertByName( _rNewName, aElement );
664 : 0 : return true;
665 : : }
666 : 0 : catch( const Exception& )
667 : : {
668 : : DBG_UNHANDLED_EXCEPTION();
669 : : }
670 : 0 : return false;
671 : : }
672 : :
673 : :
674 : 0 : bool ScriptDocument_Impl::createModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, bool _bCreateMain, ::rtl::OUString& _out_rNewModuleCode ) const
675 : : {
676 : 0 : _out_rNewModuleCode = ::rtl::OUString();
677 : : try
678 : : {
679 : 0 : Reference< XNameContainer > xLib( getLibrary( E_SCRIPTS, _rLibName, true ) );
680 : 0 : if ( !xLib.is() || xLib->hasByName( _rModName ) )
681 : 0 : return false;
682 : :
683 : : // create new module
684 : 0 : _out_rNewModuleCode = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "REM ***** BASIC *****\n\n" ) );
685 : 0 : if ( _bCreateMain )
686 : 0 : _out_rNewModuleCode += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Sub Main\n\nEnd Sub\n" ) );
687 : :
688 : : // insert module into library
689 : 0 : xLib->insertByName( _rModName, makeAny( _out_rNewModuleCode ) );
690 : : }
691 : 0 : catch( const Exception& )
692 : : {
693 : : DBG_UNHANDLED_EXCEPTION();
694 : 0 : return false;
695 : : }
696 : :
697 : 0 : return true;
698 : : }
699 : :
700 : :
701 : 0 : bool ScriptDocument_Impl::insertModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rObjectName, const Any& _rElement ) const
702 : : {
703 : : try
704 : : {
705 : 0 : Reference< XNameContainer > xLib( getOrCreateLibrary( _eType, _rLibName ), UNO_QUERY_THROW );
706 : 0 : if ( xLib->hasByName( _rObjectName ) )
707 : 0 : return false;
708 : :
709 : 0 : xLib->insertByName( _rObjectName, _rElement );
710 : 0 : return true;
711 : : }
712 : 0 : catch( const Exception& )
713 : : {
714 : : DBG_UNHANDLED_EXCEPTION();
715 : : }
716 : 0 : return false;
717 : : }
718 : :
719 : :
720 : 0 : bool ScriptDocument_Impl::updateModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, const ::rtl::OUString& _rModuleCode ) const
721 : : {
722 : : try
723 : : {
724 : 0 : Reference< XNameContainer > xLib( getOrCreateLibrary( E_SCRIPTS, _rLibName ), UNO_QUERY_THROW );
725 : 0 : if ( !xLib->hasByName( _rModName ) )
726 : 0 : return false;
727 : 0 : xLib->replaceByName( _rModName, makeAny( _rModuleCode ) );
728 : 0 : return true;
729 : : }
730 : 0 : catch( const Exception& )
731 : : {
732 : : DBG_UNHANDLED_EXCEPTION();
733 : : }
734 : 0 : return false;
735 : : }
736 : :
737 : :
738 : 0 : bool ScriptDocument_Impl::createDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName, Reference< XInputStreamProvider >& _out_rDialogProvider ) const
739 : : {
740 : : try
741 : : {
742 : 0 : Reference< XNameContainer > xLib( getLibrary( E_DIALOGS, _rLibName, true ), UNO_QUERY_THROW );
743 : :
744 : : // create dialog
745 : 0 : _out_rDialogProvider.clear();
746 : 0 : if ( xLib->hasByName( _rDialogName ) )
747 : 0 : return false;
748 : :
749 : : // create new dialog model
750 : 0 : ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
751 : 0 : Reference< XNameContainer > xDialogModel;
752 : 0 : if ( !aContext.createComponent( "com.sun.star.awt.UnoControlDialogModel", xDialogModel ) )
753 : 0 : return false;
754 : :
755 : : // set name property
756 : 0 : Reference< XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY_THROW );
757 : 0 : xDlgPSet->setPropertyValue( DLGED_PROP_NAME, makeAny( _rDialogName ) );
758 : :
759 : : // export dialog model
760 : 0 : _out_rDialogProvider = ::xmlscript::exportDialogModel( xDialogModel, aContext.getUNOContext(), isDocument() ? getDocument() : Reference< XModel >() );
761 : :
762 : : // insert dialog into library
763 : 0 : xLib->insertByName( _rDialogName, makeAny( _out_rDialogProvider ) );
764 : : }
765 : 0 : catch( const Exception& )
766 : : {
767 : : DBG_UNHANDLED_EXCEPTION();
768 : : }
769 : :
770 : 0 : return _out_rDialogProvider.is();
771 : : }
772 : :
773 : :
774 : 0 : void ScriptDocument_Impl::setDocumentModified() const
775 : : {
776 : : OSL_ENSURE( isValid() && isDocument(), "ScriptDocument_Impl::setDocumentModified: only to be called for real documents!" );
777 : 0 : if ( isValid() && isDocument() )
778 : : {
779 : : try
780 : : {
781 : 0 : m_xDocModify->setModified( true );
782 : : }
783 : 0 : catch( const Exception& )
784 : : {
785 : : DBG_UNHANDLED_EXCEPTION();
786 : : }
787 : : }
788 : 0 : }
789 : :
790 : :
791 : 0 : bool ScriptDocument_Impl::isDocumentModified() const
792 : : {
793 : : OSL_ENSURE( isValid() && isDocument(), "ScriptDocument_Impl::isDocumentModified: only to be called for real documents!" );
794 : 0 : bool bIsModified = false;
795 : 0 : if ( isValid() && isDocument() )
796 : : {
797 : : try
798 : : {
799 : 0 : bIsModified = m_xDocModify->isModified();
800 : : }
801 : 0 : catch( const Exception& )
802 : : {
803 : : DBG_UNHANDLED_EXCEPTION();
804 : : }
805 : : }
806 : 0 : return bIsModified;
807 : : }
808 : :
809 : :
810 : 0 : bool ScriptDocument_Impl::saveDocument( const Reference< XStatusIndicator >& _rxStatusIndicator ) const
811 : : {
812 : 0 : Reference< XFrame > xFrame;
813 : 0 : if ( !getCurrentFrame( xFrame ) )
814 : 0 : return false;
815 : :
816 : 0 : Sequence< PropertyValue > aArgs;
817 : 0 : if ( _rxStatusIndicator.is() )
818 : : {
819 : 0 : aArgs.realloc(1);
820 : 0 : aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StatusIndicator" ) );
821 : 0 : aArgs[0].Value <<= _rxStatusIndicator;
822 : : }
823 : :
824 : : try
825 : : {
826 : 0 : URL aURL;
827 : 0 : aURL.Complete = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Save" ) );
828 : 0 : aURL.Main = aURL.Complete;
829 : 0 : aURL.Protocol = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:" ) );
830 : 0 : aURL.Path = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Save" ) );
831 : :
832 : 0 : Reference< XDispatchProvider > xDispProv( xFrame, UNO_QUERY_THROW );
833 : : Reference< XDispatch > xDispatch(
834 : 0 : xDispProv->queryDispatch( aURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_self" ) ), FrameSearchFlag::AUTO ),
835 : 0 : UNO_SET_THROW );
836 : :
837 : 0 : xDispatch->dispatch( aURL, aArgs );
838 : : }
839 : 0 : catch( const Exception& )
840 : : {
841 : : DBG_UNHANDLED_EXCEPTION();
842 : 0 : return false;
843 : : }
844 : :
845 : 0 : return true;
846 : : }
847 : :
848 : :
849 : 0 : ::rtl::OUString ScriptDocument_Impl::getTitle() const
850 : : {
851 : : OSL_PRECOND( isValid() && isDocument(), "ScriptDocument_Impl::getTitle: for documents only!" );
852 : :
853 : 0 : ::rtl::OUString sTitle;
854 : 0 : if ( isValid() && isDocument() )
855 : : {
856 : 0 : sTitle = ::comphelper::DocumentInfo::getDocumentTitle( m_xDocument );
857 : : }
858 : 0 : return sTitle;
859 : : }
860 : :
861 : :
862 : 0 : ::rtl::OUString ScriptDocument_Impl::getURL() const
863 : : {
864 : : OSL_PRECOND( isValid() && isDocument(), "ScriptDocument_Impl::getURL: for documents only!" );
865 : :
866 : 0 : ::rtl::OUString sURL;
867 : 0 : if ( isValid() && isDocument() )
868 : : {
869 : : try
870 : : {
871 : 0 : sURL = m_xDocument->getURL();
872 : : }
873 : 0 : catch( const Exception& )
874 : : {
875 : : DBG_UNHANDLED_EXCEPTION();
876 : : }
877 : : }
878 : 0 : return sURL;
879 : : }
880 : :
881 : :
882 : 0 : bool ScriptDocument_Impl::allowMacros() const
883 : : {
884 : : OSL_ENSURE( isValid() && isDocument(), "ScriptDocument_Impl::allowMacros: for documents only!" );
885 : 0 : bool bAllow = false;
886 : 0 : if ( isValid() && isDocument() )
887 : : {
888 : : try
889 : : {
890 : 0 : bAllow = m_xScriptAccess->getAllowMacroExecution();
891 : : }
892 : 0 : catch( const Exception& )
893 : : {
894 : : DBG_UNHANDLED_EXCEPTION();
895 : : }
896 : : }
897 : 0 : return bAllow;
898 : : }
899 : :
900 : :
901 : 0 : bool ScriptDocument_Impl::getCurrentFrame( Reference< XFrame >& _out_rxFrame ) const
902 : : {
903 : 0 : _out_rxFrame.clear();
904 : : OSL_PRECOND( isValid() && isDocument(), "ScriptDocument_Impl::getCurrentFrame: documents only!" );
905 : 0 : if ( !isValid() || !isDocument() )
906 : 0 : return false;
907 : :
908 : : try
909 : : {
910 : 0 : Reference< XModel > xDocument( m_xDocument, UNO_SET_THROW );
911 : 0 : Reference< XController > xController( xDocument->getCurrentController(), UNO_SET_THROW );
912 : 0 : _out_rxFrame.set( xController->getFrame(), UNO_SET_THROW );
913 : : }
914 : 0 : catch( const Exception& )
915 : : {
916 : : DBG_UNHANDLED_EXCEPTION();
917 : : }
918 : :
919 : 0 : return _out_rxFrame.is();
920 : : }
921 : :
922 : :
923 : 0 : bool ScriptDocument_Impl::isLibraryShared( const ::rtl::OUString& _rLibName, LibraryContainerType _eType )
924 : : {
925 : 0 : bool bIsShared = false;
926 : : try
927 : : {
928 : 0 : Reference< XLibraryContainer2 > xLibContainer( getLibraryContainer( _eType ), UNO_QUERY_THROW );
929 : :
930 : 0 : if ( !xLibContainer->hasByName( _rLibName ) || !xLibContainer->isLibraryLink( _rLibName ) )
931 : 0 : return false;
932 : 0 : ::rtl::OUString aFileURL;
933 : 0 : Reference< XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
934 : 0 : Reference< XUriReferenceFactory > xUriFac;
935 : 0 : if ( xMSF.is() )
936 : : {
937 : : xUriFac.set(
938 : 0 : xMSF->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.uri.UriReferenceFactory" ) ) ),
939 : 0 : UNO_QUERY_THROW );
940 : : }
941 : :
942 : 0 : ::rtl::OUString aLinkURL( xLibContainer->getLibraryLinkURL( _rLibName ) );
943 : 0 : Reference< XUriReference > xUriRef( xUriFac->parse( aLinkURL ), UNO_QUERY_THROW );
944 : :
945 : 0 : ::rtl::OUString aScheme = xUriRef->getScheme();
946 : 0 : if ( aScheme.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("file")) )
947 : : {
948 : 0 : aFileURL = aLinkURL;
949 : : }
950 : 0 : else if ( aScheme.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.pkg")) )
951 : : {
952 : 0 : ::rtl::OUString aAuthority = xUriRef->getAuthority();
953 : 0 : if ( aAuthority.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.expand:" ) ) )
954 : : {
955 : 0 : ::rtl::OUString aDecodedURL( aAuthority.copy( sizeof ( "vnd.sun.star.expand:" ) - 1 ) );
956 : 0 : aDecodedURL = ::rtl::Uri::decode( aDecodedURL, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
957 : 0 : Reference< XComponentContext > xContext;
958 : 0 : Reference< XPropertySet > xProps( xMSF, UNO_QUERY_THROW );
959 : 0 : xContext.set( xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" )) ), UNO_QUERY_THROW );
960 : : Reference< XMacroExpander > xMacroExpander(
961 : 0 : xContext->getValueByName(
962 : 0 : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.util.theMacroExpander" )) ),
963 : 0 : UNO_QUERY_THROW );
964 : 0 : aFileURL = xMacroExpander->expandMacros( aDecodedURL );
965 : 0 : }
966 : : }
967 : :
968 : 0 : if ( !aFileURL.isEmpty() )
969 : : {
970 : 0 : ::osl::DirectoryItem aFileItem;
971 : 0 : ::osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileURL );
972 : 0 : OSL_VERIFY( ::osl::DirectoryItem::get( aFileURL, aFileItem ) == ::osl::FileBase::E_None );
973 : 0 : OSL_VERIFY( aFileItem.getFileStatus( aFileStatus ) == ::osl::FileBase::E_None );
974 : 0 : ::rtl::OUString aCanonicalFileURL( aFileStatus.getFileURL() );
975 : :
976 : 0 : ::rtl::OUString aSearchURL1( RTL_CONSTASCII_USTRINGPARAM( "share/basic" ) );
977 : 0 : ::rtl::OUString aSearchURL2( RTL_CONSTASCII_USTRINGPARAM( "share/uno_packages" ) );
978 : 0 : ::rtl::OUString aSearchURL3( RTL_CONSTASCII_USTRINGPARAM( "share/extensions" ) );
979 : 0 : if( aCanonicalFileURL.indexOf( aSearchURL1 ) >= 0 ||
980 : 0 : aCanonicalFileURL.indexOf( aSearchURL2 ) >= 0 ||
981 : 0 : aCanonicalFileURL.indexOf( aSearchURL3 ) >= 0 )
982 : 0 : bIsShared = true;
983 : 0 : }
984 : : }
985 : 0 : catch( const Exception& )
986 : : {
987 : : DBG_UNHANDLED_EXCEPTION();
988 : : }
989 : :
990 : 0 : return bIsShared;
991 : : }
992 : :
993 : :
994 : 0 : void ScriptDocument_Impl::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
995 : : {
996 : : // not interested in
997 : 0 : }
998 : :
999 : 0 : void ScriptDocument_Impl::onDocumentOpened( const ScriptDocument& /*_rDocument*/ )
1000 : : {
1001 : : // not interested in
1002 : 0 : }
1003 : :
1004 : 0 : void ScriptDocument_Impl::onDocumentSave( const ScriptDocument& /*_rDocument*/ )
1005 : : {
1006 : : // not interested in
1007 : 0 : }
1008 : :
1009 : 0 : void ScriptDocument_Impl::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ )
1010 : : {
1011 : : // not interested in
1012 : 0 : }
1013 : :
1014 : 0 : void ScriptDocument_Impl::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ )
1015 : : {
1016 : : // not interested in
1017 : 0 : }
1018 : :
1019 : 0 : void ScriptDocument_Impl::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*/ )
1020 : : {
1021 : : // not interested in
1022 : 0 : }
1023 : :
1024 : 0 : void ScriptDocument_Impl::onDocumentClosed( const ScriptDocument& _rDocument )
1025 : : {
1026 : : DBG_TESTSOLARMUTEX();
1027 : : OSL_PRECOND( isValid(), "ScriptDocument_Impl::onDocumentClosed: should not be listening if I'm not valid!" );
1028 : :
1029 : 0 : bool bMyDocument = m_xDocument == _rDocument.getDocument();
1030 : : OSL_PRECOND( bMyDocument, "ScriptDocument_Impl::onDocumentClosed: didn't want to know *this*!" );
1031 : 0 : if ( bMyDocument )
1032 : : {
1033 : 0 : m_bDocumentClosed = true;
1034 : : }
1035 : 0 : }
1036 : :
1037 : :
1038 : 0 : void ScriptDocument_Impl::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ )
1039 : : {
1040 : : // not interested in
1041 : 0 : }
1042 : :
1043 : 0 : void ScriptDocument_Impl::onDocumentModeChanged( const ScriptDocument& /*_rDocument*/ )
1044 : : {
1045 : : // not interested in
1046 : 0 : }
1047 : :
1048 : : //====================================================================
1049 : : //= ScriptDocument
1050 : : //====================================================================
1051 : 0 : ScriptDocument::ScriptDocument()
1052 : 0 : :m_pImpl( new ScriptDocument_Impl() )
1053 : : {
1054 : 0 : }
1055 : :
1056 : :
1057 : 0 : ScriptDocument::ScriptDocument( ScriptDocument::SpecialDocument _eType )
1058 : 0 : :m_pImpl( new ScriptDocument_Impl( Reference< XModel >() ) )
1059 : : {
1060 : : OSL_ENSURE( _eType == NoDocument, "ScriptDocument::ScriptDocument: unknown SpecialDocument type!" );
1061 : : (void)_eType;
1062 : 0 : }
1063 : :
1064 : :
1065 : 0 : ScriptDocument::ScriptDocument( const Reference< XModel >& _rxDocument )
1066 : 0 : :m_pImpl( new ScriptDocument_Impl( _rxDocument ) )
1067 : : {
1068 : : OSL_ENSURE( _rxDocument.is(), "ScriptDocument::ScriptDocument: document must not be NULL!" );
1069 : : // a NULL document results in an uninitialized instance, and for this
1070 : : // purpose, there is a dedicated constructor
1071 : 0 : }
1072 : :
1073 : :
1074 : 0 : ScriptDocument::ScriptDocument( const ScriptDocument& _rSource )
1075 : 0 : :m_pImpl( _rSource.m_pImpl )
1076 : : {
1077 : 0 : }
1078 : :
1079 : :
1080 : 0 : ScriptDocument::~ScriptDocument()
1081 : : {
1082 : 0 : }
1083 : :
1084 : :
1085 : 0 : const ScriptDocument& ScriptDocument::getApplicationScriptDocument()
1086 : : {
1087 : 0 : static ScriptDocument s_aApplicationScripts;
1088 : 0 : return s_aApplicationScripts;
1089 : : }
1090 : :
1091 : :
1092 : 0 : ScriptDocument ScriptDocument::getDocumentForBasicManager( const BasicManager* _pManager )
1093 : : {
1094 : 0 : if ( _pManager == SFX_APP()->GetBasicManager() )
1095 : 0 : return getApplicationScriptDocument();
1096 : :
1097 : 0 : docs::Documents aDocuments;
1098 : 0 : lcl_getAllModels_throw( aDocuments, false );
1099 : :
1100 : 0 : for ( docs::Documents::const_iterator doc = aDocuments.begin();
1101 : 0 : doc != aDocuments.end();
1102 : : ++doc
1103 : : )
1104 : : {
1105 : 0 : const BasicManager* pDocBasicManager = ::basic::BasicManagerRepository::getDocumentBasicManager( doc->xModel );
1106 : 0 : if ( ( pDocBasicManager != SFX_APP()->GetBasicManager() )
1107 : : && ( pDocBasicManager == _pManager )
1108 : : )
1109 : : {
1110 : 0 : return ScriptDocument( doc->xModel );
1111 : : }
1112 : : }
1113 : :
1114 : : OSL_FAIL( "ScriptDocument::getDocumentForBasicManager: did not find a document for this manager!" );
1115 : 0 : return ScriptDocument( NoDocument );
1116 : : }
1117 : :
1118 : :
1119 : 0 : ScriptDocument ScriptDocument::getDocumentWithURLOrCaption( const ::rtl::OUString& _rUrlOrCaption )
1120 : : {
1121 : 0 : ScriptDocument aDocument( getApplicationScriptDocument() );
1122 : 0 : if ( _rUrlOrCaption.isEmpty() )
1123 : : return aDocument;
1124 : :
1125 : 0 : docs::Documents aDocuments;
1126 : 0 : lcl_getAllModels_throw( aDocuments, false );
1127 : :
1128 : 0 : for ( docs::Documents::const_iterator doc = aDocuments.begin();
1129 : 0 : doc != aDocuments.end();
1130 : : ++doc
1131 : : )
1132 : : {
1133 : 0 : const ScriptDocument aCheck = ScriptDocument( doc->xModel );
1134 : 0 : if ( _rUrlOrCaption == aCheck.getTitle()
1135 : 0 : || _rUrlOrCaption == aCheck.getURL()
1136 : : )
1137 : : {
1138 : 0 : aDocument = aCheck;
1139 : : break;
1140 : : }
1141 : 0 : }
1142 : :
1143 : 0 : return aDocument;
1144 : : }
1145 : :
1146 : :
1147 : : namespace
1148 : : {
1149 : 0 : struct DocumentTitleLess : public ::std::binary_function< ScriptDocument, ScriptDocument, bool >
1150 : : {
1151 : 0 : DocumentTitleLess( const CollatorWrapper& _rCollator )
1152 : 0 : :m_aCollator( _rCollator )
1153 : : {
1154 : 0 : }
1155 : :
1156 : 0 : bool operator()( const ScriptDocument& _lhs, const ScriptDocument& _rhs ) const
1157 : : {
1158 : 0 : return m_aCollator.compareString( _lhs.getTitle(), _rhs.getTitle() ) < 0;
1159 : : }
1160 : : private:
1161 : : const CollatorWrapper m_aCollator;
1162 : : };
1163 : : }
1164 : :
1165 : :
1166 : 0 : ScriptDocuments ScriptDocument::getAllScriptDocuments( ScriptDocument::ScriptDocumentList _eListType )
1167 : : {
1168 : 0 : ScriptDocuments aScriptDocs;
1169 : :
1170 : : // include application?
1171 : 0 : if ( _eListType == AllWithApplication )
1172 : 0 : aScriptDocs.push_back( getApplicationScriptDocument() );
1173 : :
1174 : : // obtain documents
1175 : : try
1176 : : {
1177 : 0 : docs::Documents aDocuments;
1178 : 0 : lcl_getAllModels_throw( aDocuments, true /* exclude invisible */ );
1179 : :
1180 : 0 : for ( docs::Documents::const_iterator doc = aDocuments.begin();
1181 : 0 : doc != aDocuments.end();
1182 : : ++doc
1183 : : )
1184 : : {
1185 : : // exclude documents without script/library containers
1186 : 0 : ScriptDocument aDoc( doc->xModel );
1187 : 0 : if ( !aDoc.isValid() )
1188 : 0 : continue;
1189 : :
1190 : 0 : aScriptDocs.push_back( aDoc );
1191 : 0 : }
1192 : : }
1193 : 0 : catch( const Exception& )
1194 : : {
1195 : : DBG_UNHANDLED_EXCEPTION();
1196 : : }
1197 : :
1198 : : // sort document list by doc title?
1199 : 0 : if ( _eListType == DocumentsSorted )
1200 : : {
1201 : 0 : CollatorWrapper aCollator( ::comphelper::getProcessServiceFactory() );
1202 : 0 : aCollator.loadDefaultCollator( SvtSysLocale().GetLocaleData().getLocale(), 0 );
1203 : 0 : ::std::sort( aScriptDocs.begin(), aScriptDocs.end(), DocumentTitleLess( aCollator ) );
1204 : : }
1205 : :
1206 : 0 : return aScriptDocs;
1207 : : }
1208 : :
1209 : :
1210 : 0 : bool ScriptDocument::operator==( const ScriptDocument& _rhs ) const
1211 : : {
1212 : 0 : return m_pImpl->getDocumentRef() == _rhs.m_pImpl->getDocumentRef();
1213 : : }
1214 : :
1215 : :
1216 : 0 : sal_Int32 ScriptDocument::hashCode() const
1217 : : {
1218 : 0 : return sal::static_int_cast<sal_Int32>(reinterpret_cast< sal_IntPtr >( m_pImpl->getDocumentRef().get() ));
1219 : : }
1220 : :
1221 : :
1222 : 0 : bool ScriptDocument::isValid() const
1223 : : {
1224 : 0 : return m_pImpl->isValid();
1225 : : }
1226 : :
1227 : :
1228 : 0 : bool ScriptDocument::isAlive() const
1229 : : {
1230 : 0 : return m_pImpl->isAlive();
1231 : : }
1232 : :
1233 : :
1234 : 0 : Reference< XLibraryContainer > ScriptDocument::getLibraryContainer( LibraryContainerType _eType ) const
1235 : : {
1236 : 0 : return m_pImpl->getLibraryContainer( _eType );
1237 : : }
1238 : :
1239 : :
1240 : 0 : Reference< XNameContainer > ScriptDocument::getLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, bool _bLoadLibrary ) const
1241 : : SAL_THROW((NoSuchElementException))
1242 : : {
1243 : 0 : return m_pImpl->getLibrary( _eType, _rLibName, _bLoadLibrary );
1244 : : }
1245 : :
1246 : :
1247 : 0 : bool ScriptDocument::hasLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const
1248 : : {
1249 : 0 : return m_pImpl->hasLibrary( _eType, _rLibName );
1250 : : }
1251 : :
1252 : :
1253 : 0 : Reference< XNameContainer > ScriptDocument::getOrCreateLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const
1254 : : {
1255 : 0 : return m_pImpl->getOrCreateLibrary( _eType, _rLibName );
1256 : : }
1257 : :
1258 : :
1259 : 0 : void ScriptDocument::loadLibraryIfExists( LibraryContainerType _eType, const ::rtl::OUString& _rLibrary )
1260 : : {
1261 : 0 : m_pImpl->loadLibraryIfExists( _eType, _rLibrary );
1262 : 0 : }
1263 : :
1264 : :
1265 : 0 : Sequence< ::rtl::OUString > ScriptDocument::getObjectNames( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const
1266 : : {
1267 : 0 : Sequence< ::rtl::OUString > aModuleNames;
1268 : :
1269 : : try
1270 : : {
1271 : 0 : if ( hasLibrary( _eType, _rLibName ) )
1272 : : {
1273 : 0 : Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, false ) );
1274 : 0 : if ( xLib.is() )
1275 : 0 : aModuleNames = xLib->getElementNames();
1276 : : }
1277 : : }
1278 : 0 : catch( const Exception& )
1279 : : {
1280 : : DBG_UNHANDLED_EXCEPTION();
1281 : : }
1282 : :
1283 : : // sort
1284 : 0 : ::std::sort( aModuleNames.getArray() , aModuleNames.getArray() + aModuleNames.getLength() , StringCompareLessThan );
1285 : :
1286 : 0 : return aModuleNames;
1287 : : }
1288 : :
1289 : :
1290 : 0 : ::rtl::OUString ScriptDocument::createObjectName( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const
1291 : : {
1292 : 0 : ::rtl::OUString aObjectName;
1293 : :
1294 : : ::rtl::OUString aBaseName = _eType == E_SCRIPTS
1295 : : ? ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Module" ) )
1296 : 0 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Dialog" ) );
1297 : :
1298 : 0 : Sequence< ::rtl::OUString > aUsedNames( getObjectNames( _eType, _rLibName ) );
1299 : 0 : ::std::set< ::rtl::OUString > aUsedNamesCheck;
1300 : 0 : ::std::copy( aUsedNames.getConstArray(), aUsedNames.getConstArray() + aUsedNames.getLength(),
1301 : 0 : ::std::insert_iterator< ::std::set< ::rtl::OUString > >( aUsedNamesCheck, aUsedNamesCheck.begin() ) );
1302 : :
1303 : 0 : bool bValid = false;
1304 : 0 : sal_Int32 i = 1;
1305 : 0 : while ( !bValid )
1306 : : {
1307 : 0 : aObjectName = aBaseName;
1308 : 0 : aObjectName += ::rtl::OUString::valueOf( i );
1309 : :
1310 : 0 : if ( aUsedNamesCheck.find( aObjectName ) == aUsedNamesCheck.end() )
1311 : 0 : bValid = true;
1312 : :
1313 : 0 : ++i;
1314 : : }
1315 : :
1316 : 0 : return aObjectName;
1317 : : }
1318 : :
1319 : :
1320 : 0 : Sequence< ::rtl::OUString > ScriptDocument::getLibraryNames() const
1321 : : {
1322 : 0 : return BasicIDE::GetMergedLibraryNames( getLibraryContainer( E_SCRIPTS ), getLibraryContainer( E_DIALOGS ) );
1323 : : }
1324 : :
1325 : :
1326 : 0 : bool ScriptDocument::isReadOnly() const
1327 : : {
1328 : 0 : return m_pImpl->isReadOnly();
1329 : : }
1330 : :
1331 : :
1332 : 0 : bool ScriptDocument::isApplication() const
1333 : : {
1334 : 0 : return m_pImpl->isApplication();
1335 : : }
1336 : :
1337 : 0 : bool ScriptDocument::isInVBAMode() const
1338 : : {
1339 : 0 : return m_pImpl->isInVBAMode();
1340 : : }
1341 : :
1342 : :
1343 : 0 : BasicManager* ScriptDocument::getBasicManager() const
1344 : : {
1345 : 0 : return m_pImpl->getBasicManager();
1346 : : }
1347 : :
1348 : :
1349 : 0 : Reference< XModel > ScriptDocument::getDocument() const
1350 : : {
1351 : 0 : return m_pImpl->getDocument();
1352 : : }
1353 : :
1354 : :
1355 : 0 : Reference< XModel > ScriptDocument::getDocumentOrNull() const
1356 : : {
1357 : 0 : if ( isDocument() )
1358 : 0 : return m_pImpl->getDocument();
1359 : 0 : return NULL;
1360 : : }
1361 : :
1362 : :
1363 : 0 : bool ScriptDocument::removeModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModuleName ) const
1364 : : {
1365 : 0 : return m_pImpl->removeModuleOrDialog( E_SCRIPTS, _rLibName, _rModuleName );
1366 : : }
1367 : :
1368 : :
1369 : 0 : bool ScriptDocument::hasModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModuleName ) const
1370 : : {
1371 : 0 : return m_pImpl->hasModuleOrDialog( E_SCRIPTS, _rLibName, _rModuleName );
1372 : : }
1373 : :
1374 : :
1375 : 0 : bool ScriptDocument::getModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, ::rtl::OUString& _out_rModuleSource ) const
1376 : : {
1377 : 0 : Any aCode;
1378 : 0 : if ( !m_pImpl->getModuleOrDialog( E_SCRIPTS, _rLibName, _rModName, aCode ) )
1379 : 0 : return false;
1380 : 0 : OSL_VERIFY( aCode >>= _out_rModuleSource );
1381 : 0 : return true;
1382 : : }
1383 : :
1384 : :
1385 : 0 : bool ScriptDocument::renameModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rOldName, const ::rtl::OUString& _rNewName ) const
1386 : : {
1387 : 0 : return m_pImpl->renameModuleOrDialog( E_SCRIPTS, _rLibName, _rOldName, _rNewName, NULL );
1388 : : }
1389 : :
1390 : :
1391 : 0 : bool ScriptDocument::createModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, bool _bCreateMain, ::rtl::OUString& _out_rNewModuleCode ) const
1392 : : {
1393 : 0 : if ( !m_pImpl->createModule( _rLibName, _rModName, _bCreateMain, _out_rNewModuleCode ) )
1394 : 0 : return false;
1395 : :
1396 : : // doc shell modified
1397 : 0 : BasicIDE::MarkDocumentModified( *const_cast< ScriptDocument* >( this ) ); // here?
1398 : 0 : return true;
1399 : : }
1400 : :
1401 : :
1402 : 0 : bool ScriptDocument::insertModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, const ::rtl::OUString& _rModuleCode ) const
1403 : : {
1404 : 0 : return m_pImpl->insertModuleOrDialog( E_SCRIPTS, _rLibName, _rModName, makeAny( _rModuleCode ) );
1405 : : }
1406 : :
1407 : :
1408 : 0 : bool ScriptDocument::updateModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, const ::rtl::OUString& _rModuleCode ) const
1409 : : {
1410 : 0 : return m_pImpl->updateModule( _rLibName, _rModName, _rModuleCode );
1411 : : }
1412 : :
1413 : :
1414 : 0 : bool ScriptDocument::removeDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName ) const
1415 : : {
1416 : 0 : return m_pImpl->removeModuleOrDialog( E_DIALOGS, _rLibName, _rDialogName );
1417 : : }
1418 : :
1419 : :
1420 : 0 : bool ScriptDocument::hasDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName ) const
1421 : : {
1422 : 0 : return m_pImpl->hasModuleOrDialog( E_DIALOGS, _rLibName, _rDialogName );
1423 : : }
1424 : :
1425 : :
1426 : 0 : bool ScriptDocument::getDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName, Reference< XInputStreamProvider >& _out_rDialogProvider ) const
1427 : : {
1428 : 0 : Any aCode;
1429 : 0 : if ( !m_pImpl->getModuleOrDialog( E_DIALOGS, _rLibName, _rDialogName, aCode ) )
1430 : 0 : return false;
1431 : 0 : OSL_VERIFY( aCode >>= _out_rDialogProvider );
1432 : 0 : return _out_rDialogProvider.is();
1433 : : }
1434 : :
1435 : :
1436 : 0 : bool ScriptDocument::renameDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rOldName, const ::rtl::OUString& _rNewName, const Reference< XNameContainer >& _rxExistingDialogModel ) const
1437 : : {
1438 : 0 : return m_pImpl->renameModuleOrDialog( E_DIALOGS, _rLibName, _rOldName, _rNewName, _rxExistingDialogModel );
1439 : : }
1440 : :
1441 : :
1442 : 0 : bool ScriptDocument::createDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName, Reference< XInputStreamProvider >& _out_rDialogProvider ) const
1443 : : {
1444 : 0 : if ( !m_pImpl->createDialog( _rLibName, _rDialogName, _out_rDialogProvider ) )
1445 : 0 : return false;
1446 : :
1447 : 0 : BasicIDE::MarkDocumentModified( *const_cast< ScriptDocument* >( this ) ); // here?
1448 : 0 : return true;
1449 : : }
1450 : :
1451 : :
1452 : 0 : bool ScriptDocument::insertDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName, const Reference< XInputStreamProvider >& _rxDialogProvider ) const
1453 : : {
1454 : 0 : return m_pImpl->insertModuleOrDialog( E_DIALOGS, _rLibName, _rDialogName, makeAny( _rxDialogProvider ) );
1455 : : }
1456 : :
1457 : :
1458 : 0 : void ScriptDocument::setDocumentModified() const
1459 : : {
1460 : 0 : m_pImpl->setDocumentModified();
1461 : 0 : }
1462 : :
1463 : :
1464 : 0 : bool ScriptDocument::isDocumentModified() const
1465 : : {
1466 : 0 : return m_pImpl->isDocumentModified();
1467 : : }
1468 : :
1469 : :
1470 : 0 : bool ScriptDocument::saveDocument( const Reference< XStatusIndicator >& _rxStatusIndicator ) const
1471 : : {
1472 : 0 : return m_pImpl->saveDocument( _rxStatusIndicator );
1473 : : }
1474 : :
1475 : :
1476 : 0 : LibraryLocation ScriptDocument::getLibraryLocation( const ::rtl::OUString& _rLibName ) const
1477 : : {
1478 : 0 : LibraryLocation eLocation = LIBRARY_LOCATION_UNKNOWN;
1479 : 0 : if ( !_rLibName.isEmpty() )
1480 : : {
1481 : 0 : if ( isDocument() )
1482 : : {
1483 : 0 : eLocation = LIBRARY_LOCATION_DOCUMENT;
1484 : : }
1485 : : else
1486 : : {
1487 : 0 : if ( ( hasLibrary( E_SCRIPTS, _rLibName ) && !m_pImpl->isLibraryShared( _rLibName, E_SCRIPTS ) )
1488 : 0 : || ( hasLibrary( E_DIALOGS, _rLibName ) && !m_pImpl->isLibraryShared( _rLibName, E_DIALOGS ) )
1489 : : )
1490 : : {
1491 : 0 : eLocation = LIBRARY_LOCATION_USER;
1492 : : }
1493 : : else
1494 : : {
1495 : 0 : eLocation = LIBRARY_LOCATION_SHARE;
1496 : : }
1497 : : }
1498 : : }
1499 : :
1500 : 0 : return eLocation;
1501 : : }
1502 : :
1503 : :
1504 : 0 : ::rtl::OUString ScriptDocument::getTitle( LibraryLocation _eLocation, LibraryType _eType ) const
1505 : : {
1506 : 0 : ::rtl::OUString aTitle;
1507 : :
1508 : 0 : switch ( _eLocation )
1509 : : {
1510 : : case LIBRARY_LOCATION_USER:
1511 : : {
1512 : 0 : switch ( _eType )
1513 : : {
1514 : 0 : case LIBRARY_TYPE_MODULE: aTitle = IDE_RESSTR(RID_STR_USERMACROS); break;
1515 : 0 : case LIBRARY_TYPE_DIALOG: aTitle = IDE_RESSTR(RID_STR_USERDIALOGS); break;
1516 : 0 : case LIBRARY_TYPE_ALL: aTitle = IDE_RESSTR(RID_STR_USERMACROSDIALOGS); break;
1517 : : default:
1518 : 0 : break;
1519 : : }
1520 : 0 : break;
1521 : : case LIBRARY_LOCATION_SHARE:
1522 : : {
1523 : 0 : switch ( _eType )
1524 : : {
1525 : 0 : case LIBRARY_TYPE_MODULE: aTitle = IDE_RESSTR(RID_STR_SHAREMACROS); break;
1526 : 0 : case LIBRARY_TYPE_DIALOG: aTitle = IDE_RESSTR(RID_STR_SHAREDIALOGS); break;
1527 : 0 : case LIBRARY_TYPE_ALL: aTitle = IDE_RESSTR(RID_STR_SHAREMACROSDIALOGS); break;
1528 : : default:
1529 : 0 : break;
1530 : : }
1531 : : }
1532 : 0 : break;
1533 : : case LIBRARY_LOCATION_DOCUMENT:
1534 : 0 : aTitle = getTitle();
1535 : 0 : break;
1536 : : default:
1537 : 0 : break;
1538 : : }
1539 : : }
1540 : :
1541 : 0 : return aTitle;
1542 : : }
1543 : :
1544 : :
1545 : 0 : ::rtl::OUString ScriptDocument::getTitle() const
1546 : : {
1547 : 0 : return m_pImpl->getTitle();
1548 : : }
1549 : :
1550 : :
1551 : 0 : ::rtl::OUString ScriptDocument::getURL() const
1552 : : {
1553 : 0 : return m_pImpl->getURL();
1554 : : }
1555 : :
1556 : :
1557 : 0 : bool ScriptDocument::isActive() const
1558 : : {
1559 : 0 : bool bIsActive( false );
1560 : : try
1561 : : {
1562 : 0 : Reference< XFrame > xFrame;
1563 : 0 : if ( m_pImpl->getCurrentFrame( xFrame ) )
1564 : 0 : bIsActive = xFrame->isActive();
1565 : : }
1566 : 0 : catch( const Exception& )
1567 : : {
1568 : : DBG_UNHANDLED_EXCEPTION();
1569 : : }
1570 : 0 : return bIsActive;
1571 : : }
1572 : :
1573 : :
1574 : 0 : bool ScriptDocument::allowMacros() const
1575 : : {
1576 : 0 : return m_pImpl->allowMacros();
1577 : : }
1578 : :
1579 : : }
1580 : :
1581 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|