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 #ifndef SUBCOMPONENTRECOVERY_HXX
25 #define SUBCOMPONENTRECOVERY_HXX
26 
27 #include "subcomponents.hxx"
28 
29 /** === begin UNO includes === **/
30 #include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
31 #include <com/sun/star/embed/XStorage.hpp>
32 /** === end UNO includes === **/
33 
34 #include <comphelper/componentcontext.hxx>
35 
36 //........................................................................
37 namespace dbaccess
38 {
39 //........................................................................
40 
41 	//====================================================================
42 	//= SubComponentRecovery
43 	//====================================================================
44     class DBACCESS_DLLPRIVATE SubComponentRecovery
45     {
46     public:
SubComponentRecovery(const::comphelper::ComponentContext & i_rContext,const::com::sun::star::uno::Reference<::com::sun::star::sdb::application::XDatabaseDocumentUI> & i_rController,const::com::sun::star::uno::Reference<::com::sun::star::lang::XComponent> & i_rComponent)47         SubComponentRecovery( const ::comphelper::ComponentContext& i_rContext, const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& i_rController,
48                 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& i_rComponent )
49             :m_rContext( i_rContext )
50             ,m_xDocumentUI( i_rController, ::com::sun::star::uno::UNO_SET_THROW )
51             ,m_xComponent( i_rComponent )
52             ,m_eType( UNKNOWN )
53             ,m_aCompDesc()
54         {
55             impl_identifyComponent_throw();
56         }
57 
SubComponentRecovery(const::comphelper::ComponentContext & i_rContext,const::com::sun::star::uno::Reference<::com::sun::star::sdb::application::XDatabaseDocumentUI> & i_rController,const SubComponentType i_eType)58         SubComponentRecovery( const ::comphelper::ComponentContext& i_rContext, const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& i_rController,
59                 const SubComponentType i_eType )
60             :m_rContext( i_rContext )
61             ,m_xDocumentUI( i_rController, ::com::sun::star::uno::UNO_SET_THROW )
62             ,m_xComponent()
63             ,m_eType( i_eType )
64             ,m_aCompDesc()
65         {
66         }
67 
68         // only to be used after being constructed with a component
69         void    saveToRecoveryStorage(
70                     const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rRecoveryStorage,
71                     MapCompTypeToCompDescs& io_mapCompDescs
72                 );
73 
74         // only to be used after being constructed with a type
75         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
76                 recoverFromStorage(
77                     const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rRecoveryStorage,
78                     const ::rtl::OUString& i_rComponentName,
79                     const bool i_bForEditing
80                 );
81 
82         static const ::rtl::OUString getComponentsStorageName( const SubComponentType i_eType );
83 
84     private:
85         void    impl_saveSubDocument_throw(
86                     const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rObjectStorage
87                 );
88 
89         void    impl_saveQueryDesign_throw(
90                     const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rObjectStorage
91                 );
92 
93         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
94                 impl_recoverSubDocument_throw(
95                     const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rRecoveryStorage,
96                     const ::rtl::OUString& i_rComponentName,
97                     const bool i_bForEditing
98                 );
99 
100         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
101                 impl_recoverQueryDesign_throw(
102                     const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rRecoveryStorage,
103                     const ::rtl::OUString& i_rComponentName,
104                     const bool i_bForEditing
105                 );
106 
107         void    impl_identifyComponent_throw();
108 
109     private:
110         const ::comphelper::ComponentContext&   m_rContext;
111         ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >
112                                                 m_xDocumentUI;
113         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
114                                                 m_xComponent;
115         SubComponentType                        m_eType;
116         SubComponentDescriptor                  m_aCompDesc;
117     };
118 
119 
120 //........................................................................
121 } // namespace dbaccess
122 //........................................................................
123 
124 #endif // SUBCOMPONENTRECOVERY_HXX
125