1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: typecfg.cxx,v $
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_framework.hxx"
34 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
37 #include <classes/servicemanager.hxx>
38 #include <classes/filtercache.hxx>
39 #include <macros/generic.hxx>
40 #include <macros/debug.hxx>
43 //_________________________________________________________________________________________________________________
45 //_________________________________________________________________________________________________________________
46 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
47 #include <com/sun/star/container/XNameContainer.hpp>
48 #include <com/sun/star/beans/PropertyValue.hpp>
50 //_________________________________________________________________________________________________________________
52 //_________________________________________________________________________________________________________________
53 #include <comphelper/processfactory.hxx>
54 #include <vos/process.hxx>
55 #include <rtl/ustring.hxx>
56 #include <rtl/ustrbuf.hxx>
58 #include <vcl/event.hxx>
59 #include <vcl/svapp.hxx>
60 #include <vcl/wrkwin.hxx>
61 #include <vcl/msgbox.hxx>
64 //_________________________________________________________________________________________________________________
66 //_________________________________________________________________________________________________________________
68 #define RDBFILE DECLARE_ASCII("typecfg.rdb" )
69 #define ARGUMENT_GENERATE_CFGVIEW DECLARE_ASCII("-cfgview" )
70 #define ARGUMENT_CHECK_FILTERREGISTRATION DECLARE_ASCII("-registerfilter" )
71 #define ARGUMENT_GENERATE_TYPEDETECTION_XCD DECLARE_ASCII("-generatexcd" )
73 //_________________________________________________________________________________________________________________
75 //_________________________________________________________________________________________________________________
77 using namespace ::std
;
78 using namespace ::vos
;
79 using namespace ::rtl
;
80 using namespace ::framework
;
81 using namespace ::comphelper
;
82 using namespace ::com::sun::star::uno
;
83 using namespace ::com::sun::star::lang
;
84 using namespace ::com::sun::star::container
;
85 using namespace ::com::sun::star::beans
;
87 //_________________________________________________________________________________________________________________
89 //_________________________________________________________________________________________________________________
91 //_________________________________________________________________________________________________________________
93 //_________________________________________________________________________________________________________________
98 E_CHECK_FILTERREGISTRATION
,
99 E_GENERATE_TYPEDETECTION_XCD
102 /*-***************************************************************************************************************/
103 class TypeApplication
: public Application
105 //*************************************************************************************************************
110 //*************************************************************************************************************
113 void impl_parseCommandLine ();
114 void impl_generateCFGView ();
115 void impl_checkFilterRegistration ();
116 void impl_generateTypeDetectionXCD ();
118 //*************************************************************************************************************
122 Reference
< XMultiServiceFactory
> m_xServiceManager
;
124 FilterCache
* m_pCache
;
126 }; // class FilterApplication
128 //_________________________________________________________________________________________________________________
130 //_________________________________________________________________________________________________________________
132 TypeApplication gApplication
;
134 //*****************************************************************************************************************
135 void TypeApplication::Main()
137 // Init global servicemanager and set it.
138 ServiceManager aManager
;
139 m_xServiceManager
= aManager
.getSharedUNOServiceManager( RDBFILE
);
140 setProcessServiceFactory( m_xServiceManager
);
142 m_pCache
= new FilterCache
;
144 impl_parseCommandLine();
148 case E_GENERATE_CFGVIEW
: impl_generateCFGView();
150 case E_CHECK_FILTERREGISTRATION
: impl_checkFilterRegistration();
152 case E_GENERATE_TYPEDETECTION_XCD
: impl_generateTypeDetectionXCD();
160 //*****************************************************************************************************************
161 void TypeApplication::impl_parseCommandLine()
165 sal_Int32 nArgument
= 0 ;
166 sal_Int32 nCount
= aInfo
.getCommandArgCount();
168 while( nArgument
<nCount
)
170 aInfo
.getCommandArg( nArgument
, sArgument
);
172 if( sArgument
== ARGUMENT_GENERATE_CFGVIEW
)
174 m_eMode
= E_GENERATE_CFGVIEW
;
178 if( sArgument
== ARGUMENT_CHECK_FILTERREGISTRATION
)
180 m_eMode
= E_CHECK_FILTERREGISTRATION
;
184 if( sArgument
== ARGUMENT_GENERATE_TYPEDETECTION_XCD
)
186 m_eMode
= E_GENERATE_TYPEDETECTION_XCD
;
194 //*****************************************************************************************************************
195 void TypeApplication::impl_generateCFGView()
197 #ifdef ENABLE_FILTERCACHEDEBUG
198 // Cache use ref count!
200 aCache
.impldbg_generateHTMLView();
201 #endif //ENABLE_FILTERCACHEDEBUG
204 //*****************************************************************************************************************
205 void TypeApplication::impl_checkFilterRegistration()
207 Reference
< XNameContainer
> xFilterContainer( m_xServiceManager
->createInstance( SERVICENAME_FILTERFACTORY
), UNO_QUERY
);
208 LOG_ASSERT2( xFilterContainer
.is()==sal_False
, "TypeApplication::impl_checkFilterRegistration()", "Couldn't create filter factory!" )
209 if( xFilterContainer
.is() == sal_True
)
211 Sequence
< PropertyValue
> lProperties( 8 );
213 lProperties
[0].Name
= DECLARE_ASCII("Type") ;
214 lProperties
[0].Value
<<= DECLARE_ASCII("MeinType") ;
216 lProperties
[1].Name
= DECLARE_ASCII("UIName") ;
217 lProperties
[1].Value
<<= DECLARE_ASCII("MeinUIName") ;
219 lProperties
[2].Name
= DECLARE_ASCII("UINames") ;
220 lProperties
[2].Value
<<= Sequence
< PropertyValue
>() ;
222 lProperties
[3].Name
= DECLARE_ASCII("DocumentService") ;
223 lProperties
[3].Value
<<= DECLARE_ASCII("MeinDocService") ;
225 lProperties
[4].Name
= DECLARE_ASCII("FilterService") ;
226 lProperties
[4].Value
<<= DECLARE_ASCII("MeinFilterService") ;
228 lProperties
[5].Name
= DECLARE_ASCII("Flags") ;
229 lProperties
[5].Value
<<= (sal_Int32
)256 ;
231 lProperties
[6].Name
= DECLARE_ASCII("UserData") ;
232 lProperties
[6].Value
<<= Sequence
< OUString
>() ;
234 lProperties
[7].Name
= DECLARE_ASCII("FileFormatVersion") ;
235 lProperties
[7].Value
<<= (sal_Int32
)0 ;
237 lProperties
[8].Name
= DECLARE_ASCII("TemplateName") ;
238 lProperties
[8].Value
<<= DECLARE_ASCII("MeinTemplate") ;
242 //*****************************************************************************************************************
243 void TypeApplication::impl_generateTypeDetectionXCD()
245 #ifdef ENABLE_GENERATEFILTERCACHE
246 // Cache use ref count!
248 sal_Bool bWriteable
= sal_True
;
249 sal_Unicode cSeparator
= ',' ;
250 aCache
.impldbg_generateXCD( "org.openoffice.Office.TypeDetection.xcd", bWriteable
, cSeparator
);
251 #endif //ENABLE_GENERATEFILTERCACHE