merge the formfield patch from ooo-build
[ooovba.git] / sw / source / filter / xml / xmlimp.hxx
blob1e3c761fa2fd3b4d6a879f5cdcefaf795ff64dc3
1 /************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlimp.hxx,v $
10 * $Revision: 1.35 $
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 #ifndef _XMLIMP_HXX
32 #define _XMLIMP_HXX
34 #include <sot/storage.hxx>
35 #include <xmloff/xmlictxt.hxx>
36 #include "xmlitmap.hxx"
37 #include <xmloff/xmlimp.hxx>
39 class SwDoc;
40 class SwPaM;
41 class SvXMLUnitConverter;
42 class SvXMLTokenMap;
43 class SvXMLImportItemMapper;
44 class SfxItemSet;
45 class SwNodeIndex;
46 class XMLTextImportHelper;
47 class SvXMLGraphicHelper;
48 class SvXMLEmbeddedObjectHelper;
50 // define, how many steps ( = paragraphs ) the progress bar should advance
51 // for styles, autostyles and settings + meta
52 #define PROGRESS_BAR_STEP 20
54 namespace SwImport {
55 SwDoc* GetDocFromXMLImport( SvXMLImport& );
58 class SwXMLImport: public SvXMLImport
60 SwNodeIndex *pSttNdIdx;
62 SvXMLUnitConverter *pTwipUnitConv;
63 SvXMLImportItemMapper *pTableItemMapper;// paragraph item import
64 SvXMLTokenMap *pDocElemTokenMap;
65 SvXMLTokenMap *pTableElemTokenMap;
66 SvXMLTokenMap *pTableCellAttrTokenMap;
67 SvXMLGraphicHelper *pGraphicResolver;
68 SvXMLEmbeddedObjectHelper *pEmbeddedResolver;
70 SvXMLItemMapEntriesRef xTableItemMap;
71 SvXMLItemMapEntriesRef xTableColItemMap;
72 SvXMLItemMapEntriesRef xTableRowItemMap;
73 SvXMLItemMapEntriesRef xTableCellItemMap;
74 SvStorageRef xPackage;
75 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
76 xLateInitSettings;
78 sal_uInt16 nStyleFamilyMask;// Mask of styles to load
79 sal_Bool bLoadDoc : 1; // Load doc or styles only
80 sal_Bool bInsert : 1; // Insert mode. If styles are
81 // loaded only sal_False means that
82 // existing styles will be
83 // overwritten.
84 sal_Bool bBlock : 1; // Load text block
85 sal_Bool bAutoStylesValid : 1;
86 sal_Bool bShowProgress : 1;
87 sal_Bool bOrganizerMode : 1;
88 sal_Bool bInititedXForms : 1;
89 sal_Bool bPreserveRedlineMode;
91 void _InitItemImport();
92 void _FinitItemImport();
93 void UpdateTxtCollConditions( SwDoc *pDoc );
95 void setTextInsertMode(
96 const ::com::sun::star::uno::Reference<
97 ::com::sun::star::text::XTextRange > & rInsertPos );
98 void setStyleInsertMode( sal_uInt16 nFamilies,
99 sal_Bool bOverwrite );
100 void setBlockMode();
101 void setOrganizerMode();
104 protected:
106 // This method is called after the namespace map has been updated, but
107 // before a context for the current element has been pushed.
108 virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
109 const ::rtl::OUString& rLocalName,
110 const ::com::sun::star::uno::Reference<
111 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
113 virtual XMLTextImportHelper* CreateTextImport();
115 virtual XMLShapeImportHelper* CreateShapeImport();
117 public:
119 // #110680#
120 SwXMLImport(
121 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
122 sal_uInt16 nImportFlags = IMPORT_ALL);
124 #ifdef XML_CORE_API
125 // #110680#
126 SwXMLImport(
127 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
128 SwDoc& rDoc,
129 const SwPaM& rPaM,
130 sal_Bool bLoadDoc,
131 sal_Bool bInsertMode,
132 sal_uInt16 nStyleFamMask,
133 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & rModel,
134 const ::com::sun::star::uno::Reference< ::com::sun::star::document::XGraphicObjectResolver > &,
135 SvStorage *pPkg );
136 #endif
138 ~SwXMLImport() throw();
140 // ::com::sun::star::xml::sax::XDocumentHandler
141 virtual void SAL_CALL startDocument(void)
142 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
143 virtual void SAL_CALL endDocument(void)
144 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
146 // XUnoTunnel
147 static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
148 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
150 // XInitialization
151 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
153 // XServiceInfo (override parent method)
154 ::rtl::OUString SAL_CALL getImplementationName()
155 throw( ::com::sun::star::uno::RuntimeException );
157 void InsertStyles( sal_Bool bAuto );
158 void FinishStyles();
160 // namespace office
162 // NB: in contrast to other CreateFooContexts, this particular one handles
163 // the root element (i.e. office:document-meta)
164 SvXMLImportContext *CreateMetaContext( const ::rtl::OUString& rLocalName );
165 SvXMLImportContext *CreateScriptContext( const ::rtl::OUString& rLocalName );
166 SvXMLImportContext *CreateStylesContext(
167 const ::rtl::OUString& rLocalName,
168 const ::com::sun::star::uno::Reference<
169 ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
170 sal_Bool bAuto );
171 SvXMLImportContext *CreateMasterStylesContext(
172 const ::rtl::OUString& rLocalName,
173 const ::com::sun::star::uno::Reference<
174 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
175 SvXMLImportContext *CreateFontDeclsContext(
176 const ::rtl::OUString& rLocalName,
177 const ::com::sun::star::uno::Reference<
178 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
179 SvXMLImportContext *CreateBodyContentContext( const ::rtl::OUString& rLocalName );
180 sal_uInt16 GetStyleFamilyMask() const { return nStyleFamilyMask; }
181 sal_Bool IsInsertMode() const { return bInsert; }
182 sal_Bool IsStylesOnlyMode() const { return !bLoadDoc; }
183 sal_Bool IsBlockMode() const { return bBlock; }
184 sal_Bool IsOrganizerMode() const { return bOrganizerMode; }
186 inline const SvXMLUnitConverter& GetTwipUnitConverter() const;
187 inline const SvXMLImportItemMapper& GetTableItemMapper() const;
188 SvXMLImportContext *CreateTableItemImportContext( sal_uInt16 nPrefix,
189 const ::rtl::OUString& rLocalName,
190 const ::com::sun::star::uno::Reference<
191 ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
192 sal_uInt16 nSubFamily, SfxItemSet& rItemSet );
194 const SvXMLTokenMap& GetDocElemTokenMap();
195 const SvXMLTokenMap& GetTableElemTokenMap();
196 const SvXMLTokenMap& GetTableCellAttrTokenMap();
198 sal_Bool FindAutomaticStyle( sal_uInt16 nFamily,
199 const ::rtl::OUString& rName,
200 const SfxItemSet **ppItemSet=0,
201 ::rtl::OUString *pParent=0 ) const;
203 virtual void SetStatistics(
204 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue> & i_rStats);
205 virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
206 virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps);
207 virtual void SetDocumentSpecificSettings(const ::rtl::OUString& _rSettingsGroupName,
208 const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& _rSettings);
210 SvStorage *GetPackage() { return &xPackage; }
212 void SetProgressValue( sal_Int32 nValue );
214 // initialize XForms
215 virtual void initXForms();
218 inline const SvXMLUnitConverter& SwXMLImport::GetTwipUnitConverter() const
220 return *pTwipUnitConv;
223 inline const SvXMLImportItemMapper& SwXMLImport::GetTableItemMapper() const
225 return *pTableItemMapper;
228 inline void SwXMLImport::SetProgressValue( sal_Int32 nValue )
230 if ( bShowProgress )
231 GetProgressBarHelper()->SetValue(nValue);
234 #endif // _XMLIMP_HXX