Update ooo320-m1
[ooovba.git] / applied_patches / 0580-odf-converter-ignore-writerfilter.diff
blob5c07000ae555a7aca794d190746e5985dbe88c54
1 diff --git filter/source/config/cache/filtercache.cxx filter/source/config/cache/filtercache.cxx
2 index 395b321..7eb1ee1 100644
3 --- filter/source/config/cache/filtercache.cxx
4 +++ filter/source/config/cache/filtercache.cxx
5 @@ -65,7 +65,15 @@
6 #include <tools/urlobj.hxx>
7 #include <tools/wldcrd.hxx>
9 +#include <com/sun/star/deployment/thePackageManagerFactory.hpp>
11 #include <comphelper/configurationhelper.hxx>
12 +#include <ucbhelper/commandenvironment.hxx>
13 +#include <rtl/bootstrap.hxx>
15 +#include <osl/file.hxx>
17 +using namespace com::sun::star;
19 //_______________________________________________
20 // namespace
21 @@ -1544,6 +1552,90 @@ void FilterCache::impl_load(EFillState eRequiredState)
22 // <- SAFE
25 +static bool isOdfConverterInstalled()
27 + static bool bTested = false;
28 + static bool bInstalled = false;
30 + if ( bTested )
31 + return bInstalled;
33 + bTested = true;
35 + // the easy path - check for the OdfConverter binary
36 + rtl::OUString aPath;
38 + rtl::Bootstrap::get( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BRAND_BASE_DIR" ) ), aPath );
39 + aPath += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/program/OdfConverter" ) );
41 + osl::DirectoryItem aDirItem;
42 + if ( osl::DirectoryItem::get( aPath, aDirItem ) == osl::FileBase::E_None )
43 + {
44 + bInstalled = true;
45 + return bInstalled;
46 + }
48 + // check the installed extensions
49 + uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> xMS(::comphelper::getProcessServiceFactory(), uno::UNO_QUERY);
50 + uno::Reference< beans::XPropertySet > xProps(xMS, uno::UNO_QUERY);
51 + uno::Reference< uno::XComponentContext > xContext(xProps->getPropertyValue(rtl::OUString::createFromAscii("DefaultContext")), uno::UNO_QUERY);
53 + uno::Reference< deployment::XPackageManager > xUserContext(
54 + deployment::thePackageManagerFactory::get (xContext)->getPackageManager( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("user") ) ) );
55 + uno::Reference< ::com::sun::star::deployment::XPackageManager > xSharedContext(
56 + deployment::thePackageManagerFactory::get (xContext)->getPackageManager( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("shared") ) ) );
58 + uno::Reference< ::com::sun::star::task::XInteractionHandler > xInteractionHandler = uno::Reference< task::XInteractionHandler > (
59 + xMS->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uui.InteractionHandler") ) ), uno::UNO_QUERY );
60 + ::ucbhelper::CommandEnvironment* pCommandEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, uno::Reference< ucb::XProgressHandler >() );
62 + uno::Reference< ucb::XCommandEnvironment > xCmdEnv( static_cast< ::com::sun::star::ucb::XCommandEnvironment* >( pCommandEnv ), uno::UNO_QUERY );
64 + const uno::Sequence< uno::Reference< deployment::XPackage > > userPackages(
65 + xUserContext->getDeployedPackages( NULL, xCmdEnv ) );
66 + const uno::Sequence< uno::Reference< deployment::XPackage > > sharedPackages(
67 + xSharedContext->getDeployedPackages( NULL, xCmdEnv ) );
69 + const uno::Sequence< uno::Reference< deployment::XPackage > > pkgsArray[2] = {
70 + userPackages,
71 + sharedPackages
72 + };
74 + for ( int i = 0; i < 2; i++ ) {
75 + const uno::Sequence< uno::Reference< deployment::XPackage > > pkgs = pkgsArray[i];
77 + for ( int j = 0; j < pkgs.getLength(); j++ ) {
78 + rtl::OUString fname = pkgs[j]->getName();
79 + if ( fname.matchIgnoreAsciiCase( rtl::OUString::createFromAscii( "odf-converter-" ) ) ) {
80 + printf( "Found match for odf-converter!\n");
81 + fflush( stdout );
82 + bInstalled = true;
83 + return bInstalled;
84 + }
85 + }
86 + }
88 + return false;
91 +static bool terribleHackToPreferOdfConverter( const rtl::OUString& rName )
93 + if ( !isOdfConverterInstalled() )
94 + return false;
96 + if ( rName.equalsAscii( "Calc MS Excel 2007 XML" ) ||
97 + rName.equalsAscii( "MS Excel 2007 XML" ) ||
98 + rName.equalsAscii( "MS PowerPoint 2007 XML" ) ||
99 + rName.equalsAscii( "Impress MS PowerPoint 2007 XML" ) ||
100 + rName.equalsAscii( "writer_MS_Word_2007" ) ||
101 + rName.equalsAscii( "MS Word 2007 XML" ) )
103 + return true;
106 + return false;
109 /*-----------------------------------------------
110 22.09.2003 14:27
111 -----------------------------------------------*/
112 @@ -1611,6 +1703,9 @@ void FilterCache::impl_loadSet(const css::uno::Reference< css::container::XNameA
113 sal_Int32 c = lItems.getLength();
114 for (sal_Int32 i=0; i<c; ++i)
116 + if ( terribleHackToPreferOdfConverter( pItems[i] ) )
117 + continue;
119 CacheItemList::iterator pItem = pCache->find(pItems[i]);
120 switch(eOption)
122 diff --git filter/source/config/cache/makefile.mk filter/source/config/cache/makefile.mk
123 index 50ef0c7..eed2b91 100644
124 --- filter/source/config/cache/makefile.mk
125 +++ filter/source/config/cache/makefile.mk
126 @@ -64,6 +64,7 @@ SLOFILES= \
127 SHL1OBJS= $(SLOFILES)
129 SHL1STDLIBS= \
130 + $(UCBHELPERLIB) \
131 $(COMPHELPERLIB) \
132 $(CPPUHELPERLIB) \
133 $(CPPULIB) \