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 : #ifndef _SFX_FCONTNR_HXX
20 : #define _SFX_FCONTNR_HXX
21 :
22 : #include "sal/config.h"
23 : #include "sfx2/dllapi.h"
24 : #include "sal/types.h"
25 : #include <com/sun/star/uno/Sequence.hxx>
26 : #include <com/sun/star/beans/NamedValue.hpp>
27 : #include <com/sun/star/container/XNameAccess.hpp>
28 : #include <svl/poolitem.hxx>
29 : #include <vcl/window.hxx>
30 :
31 : #include <sfx2/docfilt.hxx>
32 : #include <sfx2/sfxdefs.hxx>
33 :
34 : #include <tools/ref.hxx>
35 :
36 : #include <boost/utility.hpp>
37 :
38 : class Window;
39 : class SfxFilter;
40 : class SfxObjectFactory;
41 : class SfxMedium;
42 : class SfxFilterContainer_Impl;
43 : class SfxFrame;
44 :
45 : //#define SFX_FILTER_CONTAINER_FACTORY 1
46 : typedef sal_uInt16 SfxFilterContainerFlags;
47 :
48 : class SfxRefItem : public SfxPoolItem
49 : {
50 : SvRefBaseRef aRef;
51 : public:
52 : virtual SfxPoolItem* Clone( SfxItemPool* = 0 ) const
53 : { return new SfxRefItem( *this ); }
54 : virtual int operator==( const SfxPoolItem& rL) const
55 : { return ((SfxRefItem&)rL).aRef == aRef; }
56 : SfxRefItem( sal_uInt16 nWhichId, const SvRefBaseRef& rValue ) : SfxPoolItem( nWhichId )
57 : { aRef = rValue; }
58 : const SvRefBaseRef& GetValue() const { return aRef; }
59 :
60 : };
61 :
62 : class SfxFrameWindow
63 : {
64 : Window* pWindow;
65 : public:
66 : SfxFrameWindow( Window *pWin )
67 : : pWindow( pWin )
68 : {}
69 :
70 : virtual ~SfxFrameWindow()
71 : { delete pWindow; }
72 : Window* GetWindow() const
73 : { return pWindow; }
74 : void SetWindow( Window *pWin )
75 : { pWindow = pWin; }
76 : };
77 :
78 : typedef sal_uIntPtr (*SfxDetectFilter)( SfxMedium& rMedium, const SfxFilter **, SfxFilterFlags nMust, SfxFilterFlags nDont );
79 :
80 : class SFX2_DLLPUBLIC SfxFilterContainer
81 : {
82 : SfxFilterContainer_Impl *pImpl;
83 :
84 : public:
85 : SfxFilterContainer( const String& rName );
86 : ~SfxFilterContainer();
87 :
88 :
89 : const String GetName() const;
90 :
91 : const SfxFilter* GetAnyFilter( SfxFilterFlags nMust = SFX_FILTER_IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
92 : const SfxFilter* GetFilter4EA( const String& rEA, SfxFilterFlags nMust = SFX_FILTER_IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
93 : const SfxFilter* GetFilter4Extension( const String& rExt, SfxFilterFlags nMust = SFX_FILTER_IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
94 : const SfxFilter* GetFilter4FilterName( const String& rName, SfxFilterFlags nMust = 0, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
95 :
96 : SAL_DLLPRIVATE static void ReadFilters_Impl( sal_Bool bUpdate=sal_False );
97 : SAL_DLLPRIVATE static void ReadSingleFilter_Impl( const OUString& rName,
98 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& xTypeCFG,
99 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& xFilterCFG,
100 : sal_Bool bUpdate );
101 : SAL_DLLPRIVATE static const SfxFilter* GetDefaultFilter_Impl( const String& );
102 : };
103 :
104 : class SfxFilterMatcher_Impl;
105 :
106 : class SFX2_DLLPUBLIC SfxFilterMatcher : private boost::noncopyable
107 : {
108 : friend class SfxFilterMatcherIter;
109 : SfxFilterMatcher_Impl &m_rImpl;
110 : public:
111 : SfxFilterMatcher( const OUString& rFact );
112 : SfxFilterMatcher();
113 : ~SfxFilterMatcher();
114 :
115 : SAL_DLLPRIVATE static sal_Bool IsFilterInstalled_Impl( const SfxFilter* pFilter );
116 : DECL_DLLPRIVATE_STATIC_LINK( SfxFilterMatcher, MaybeFileHdl_Impl, String* );
117 :
118 : sal_uInt32 GuessFilterIgnoringContent( SfxMedium& rMedium, const SfxFilter **, SfxFilterFlags nMust = SFX_FILTER_IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
119 : sal_uInt32 GuessFilter( SfxMedium& rMedium, const SfxFilter **, SfxFilterFlags nMust = SFX_FILTER_IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
120 : sal_uInt32 GuessFilterControlDefaultUI( SfxMedium& rMedium, const SfxFilter **, SfxFilterFlags nMust = SFX_FILTER_IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED, sal_Bool bDefUI = sal_True ) const;
121 : sal_uInt32 DetectFilter( SfxMedium& rMedium, const SfxFilter **, sal_Bool bPlugIn, sal_Bool bAPI = sal_False ) const;
122 :
123 : const SfxFilter* GetFilter4Mime( const OUString& rMime, SfxFilterFlags nMust = SFX_FILTER_IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED) const;
124 : const SfxFilter* GetFilter4ClipBoardId( sal_uInt32 nId, SfxFilterFlags nMust = SFX_FILTER_IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
125 : const SfxFilter* GetFilter4EA( const String& rEA, SfxFilterFlags nMust = SFX_FILTER_IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
126 : const SfxFilter* GetFilter4Extension( const String& rExt, SfxFilterFlags nMust = SFX_FILTER_IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
127 : const SfxFilter* GetFilter4FilterName( const String& rName, SfxFilterFlags nMust = 0, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
128 : const SfxFilter* GetFilter4UIName( const String& rName, SfxFilterFlags nMust = 0, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
129 : const SfxFilter* GetFilterForProps( const com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue >& aSeq, SfxFilterFlags nMust = 0, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
130 : const SfxFilter* GetAnyFilter( SfxFilterFlags nMust=0, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED ) const;
131 : };
132 :
133 : class SfxFilterContainer_Impl;
134 841 : class SFX2_DLLPUBLIC SfxFilterMatcherIter : private boost::noncopyable
135 :
136 : {
137 : SfxFilterFlags nOrMask;
138 : SfxFilterFlags nAndMask;
139 : sal_uInt16 nCurrent;
140 : const SfxFilterMatcher_Impl &m_rMatch;
141 :
142 : SAL_DLLPRIVATE const SfxFilter* Find_Impl();
143 :
144 : public:
145 : SfxFilterMatcherIter( const SfxFilterMatcher& rMatcher, SfxFilterFlags nMask = 0, SfxFilterFlags nNotMask = SFX_FILTER_NOTINSTALLED );
146 : const SfxFilter* First();
147 : const SfxFilter* Next();
148 : };
149 :
150 :
151 : #endif
152 :
153 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|