1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sfx2.hxx"
26 
27 #include "sfx2/docstoragemodifylistener.hxx"
28 #include <vos/mutex.hxx>
29 
30 /** === begin UNO includes === **/
31 /** === end UNO includes === **/
32 
33 //........................................................................
34 namespace sfx2
35 {
36 //........................................................................
37 
38     /** === begin UNO using === **/
39     using ::com::sun::star::uno::Reference;
40     using ::com::sun::star::uno::XInterface;
41     using ::com::sun::star::uno::UNO_QUERY;
42     using ::com::sun::star::uno::UNO_QUERY_THROW;
43     using ::com::sun::star::uno::UNO_SET_THROW;
44     using ::com::sun::star::uno::Exception;
45     using ::com::sun::star::uno::RuntimeException;
46     using ::com::sun::star::uno::Any;
47     using ::com::sun::star::uno::makeAny;
48     using ::com::sun::star::lang::EventObject;
49     /** === end UNO using === **/
50 
51     //====================================================================
52     //=
53     //====================================================================
54     //--------------------------------------------------------------------
DocumentStorageModifyListener(IModifiableDocument & _rDocument,::vos::IMutex & _rMutex)55     DocumentStorageModifyListener::DocumentStorageModifyListener( IModifiableDocument& _rDocument, ::vos::IMutex& _rMutex )
56         :m_pDocument( &_rDocument )
57         ,m_rMutex( _rMutex )
58     {
59     }
60 
61     //--------------------------------------------------------------------
~DocumentStorageModifyListener()62     DocumentStorageModifyListener::~DocumentStorageModifyListener()
63     {
64     }
65 
66     //--------------------------------------------------------------------
dispose()67     void DocumentStorageModifyListener::dispose()
68     {
69         ::vos::OGuard aGuard( m_rMutex );
70         m_pDocument = NULL;
71     }
72 
73     //--------------------------------------------------------------------
modified(const EventObject &)74     void SAL_CALL DocumentStorageModifyListener::modified( const EventObject& /*aEvent*/ ) throw (RuntimeException)
75     {
76         ::vos::OGuard aGuard( m_rMutex );
77         // storageIsModified must not contain any locking!
78         if ( m_pDocument )
79             m_pDocument->storageIsModified();
80     }
81 
82     //--------------------------------------------------------------------
disposing(const EventObject &)83     void SAL_CALL DocumentStorageModifyListener::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
84     {
85         // not interested in. In particular, we do *not* dispose ourself when a storage we're
86         // listening at is disposed. The reason here is that this listener instance is *reused*
87         // in case the document is re-based to another storage.
88     }
89 
90 //........................................................................
91 } // namespace sfx2
92 //........................................................................
93