summaryrefslogtreecommitdiff
path: root/sw/source/filter/xml
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/filter/xml')
-rw-r--r--sw/source/filter/xml/makefile.mk144
-rw-r--r--sw/source/filter/xml/swxml.cxx314
-rw-r--r--sw/source/filter/xml/wrtxml.cxx238
-rw-r--r--sw/source/filter/xml/wrtxml.hxx89
-rw-r--r--sw/source/filter/xml/xmlbrsh.cxx318
-rw-r--r--sw/source/filter/xml/xmlbrshe.hxx122
-rw-r--r--sw/source/filter/xml/xmlbrshi.hxx113
-rw-r--r--sw/source/filter/xml/xmlexp.cxx550
-rw-r--r--sw/source/filter/xml/xmlexp.hxx254
-rw-r--r--sw/source/filter/xml/xmlfmt.cxx1814
-rw-r--r--sw/source/filter/xml/xmlfmte.cxx1144
-rw-r--r--sw/source/filter/xml/xmlimp.cxx570
-rw-r--r--sw/source/filter/xml/xmlimp.hxx283
-rw-r--r--sw/source/filter/xml/xmliteme.cxx490
-rw-r--r--sw/source/filter/xml/xmlitemi.cxx638
-rw-r--r--sw/source/filter/xml/xmlitemm.cxx548
-rw-r--r--sw/source/filter/xml/xmlmeta.cxx227
-rw-r--r--sw/source/filter/xml/xmltble.cxx1085
-rw-r--r--sw/source/filter/xml/xmltbli.cxx2229
-rw-r--r--sw/source/filter/xml/xmltbli.hxx211
-rw-r--r--sw/source/filter/xml/xmltext.cxx1647
-rw-r--r--sw/source/filter/xml/xmltexte.hxx100
-rw-r--r--sw/source/filter/xml/xmltexti.hxx125
23 files changed, 13253 insertions, 0 deletions
diff --git a/sw/source/filter/xml/makefile.mk b/sw/source/filter/xml/makefile.mk
new file mode 100644
index 000000000000..1534f01d5af9
--- /dev/null
+++ b/sw/source/filter/xml/makefile.mk
@@ -0,0 +1,144 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sw
+TARGET=xml
+
+PROJECTPCH=filt_pch
+PROJECTPCHSOURCE=..\filt_1st\filt_pch
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/inc$/swpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/inc$/sw.mk
+
+.IF "$(mydebug)" != ""
+CDEFS=$(CDEFS) -Dmydebug
+.ENDIF
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = \
+ swxml.cxx \
+ xmlimp.cxx \
+ wrtxml.cxx \
+ xmlexp.cxx \
+ xmlectxt.cxx \
+ xmltext.cxx \
+ xmltbli.cxx \
+ xmltble.cxx \
+ xmlfmt.cxx \
+ xmlfmte.cxx \
+ xmlmeta.cxx \
+ xmlnum.cxx \
+ xmlitemm.cxx \
+ xmlitemi.cxx \
+ xmliteme.cxx \
+ swxmlat.cxx \
+ hintlist.cxx \
+ xmlbrsh.cxx
+
+SLOFILES = \
+ $(SLO)$/swxml.obj \
+ $(SLO)$/xmlimp.obj \
+ $(SLO)$/wrtxml.obj \
+ $(SLO)$/xmlexp.obj \
+ $(SLO)$/xmlectxt.obj \
+ $(SLO)$/xmltext.obj \
+ $(SLO)$/xmltbli.obj \
+ $(SLO)$/xmltble.obj \
+ $(SLO)$/xmlfmt.obj \
+ $(SLO)$/xmlfmte.obj \
+ $(SLO)$/xmlmeta.obj \
+ $(SLO)$/xmlnum.obj \
+ $(SLO)$/xmlitemm.obj \
+ $(SLO)$/xmlitemi.obj \
+ $(SLO)$/xmliteme.obj \
+ $(SLO)$/swxmlat.obj \
+ $(SLO)$/hintlist.obj \
+ $(SLO)$/xmlbrsh.obj
+
+EXCEPTIONSFILES= \
+ $(SLO)$/swxml.obj \
+ $(SLO)$/xmlimp.obj \
+ $(SLO)$/wrtxml.obj \
+ $(SLO)$/xmlexp.obj \
+ $(SLO)$/xmlectxt.obj \
+ $(SLO)$/xmltext.obj \
+ $(SLO)$/xmltbli.obj \
+ $(SLO)$/xmltble.obj \
+ $(SLO)$/xmlfmt.obj \
+ $(SLO)$/xmlfmte.obj \
+ $(SLO)$/xmlmeta.obj \
+ $(SLO)$/xmlnum.obj \
+ $(SLO)$/xmlitemi.obj \
+ $(SLO)$/xmliteme.obj \
+ $(SLO)$/swxmlat.obj \
+ $(SLO)$/xmlbrsh.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
new file mode 100644
index 000000000000..d5f514b3ed32
--- /dev/null
+++ b/sw/source/filter/xml/swxml.cxx
@@ -0,0 +1,314 @@
+/*************************************************************************
+ *
+ * $RCSfile: swxml.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef _RSCSFX_HXX
+#include <rsc/rscsfx.hxx>
+#endif
+
+#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_
+#include <unotools/processfactory.hxx>
+#endif
+#ifndef _COM_SUN_STAR_XML_SAX_INPUTSOURCE_HPP_
+#include <com/sun/star/xml/sax/InputSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_SAX_XPARSER_HPP_
+#include <com/sun/star/xml/sax/XParser.hpp>
+#endif
+
+#ifndef _SFXDOCFILE_HXX //autogen wg. SfxMedium
+#include <sfx2/docfile.hxx>
+#endif
+
+#ifndef _SWSWERROR_H
+#include <swerror.h>
+#endif
+#ifndef _ERRHDL_HXX //autogen wg. ASSERT
+#include <errhdl.hxx>
+#endif
+#ifndef _FLTINI_HXX //autogen wg. XMLReader
+#include <fltini.hxx>
+#endif
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#ifndef _DOCSH_HXX //autogen wg. SwDoc
+#include <docsh.hxx>
+#endif
+
+#ifndef _XMLIMP_HXX
+#include "xmlimp.hxx"
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::rtl;
+
+XMLReader::XMLReader()
+{
+}
+
+sal_uInt32 XMLReader::Read( SwDoc &rDoc, SwPaM &rPaM, const String & rName )
+{
+ Reference< lang::XMultiServiceFactory > xServiceFactory =
+ utl::getProcessServiceFactory();
+ ASSERT( xServiceFactory.is(),
+ "XMLReader::Read: got no service manager" );
+ if( !xServiceFactory.is() )
+ return ERR_SWG_READ_ERROR;
+
+ // Get model
+ SwDocShell *pDocSh = rDoc.GetDocShell();
+ ASSERT( pDocSh, "XMLReader::Read: got no doc shell" );
+ if( !pDocSh )
+ return ERR_SWG_READ_ERROR;
+
+ Reference< frame::XModel > xModel = pDocSh->GetModel();
+ ASSERT( xModel.is(),
+ "XMLReader::Read: got no model" );
+ if( !xModel.is() )
+ return ERR_SWG_READ_ERROR;
+
+ // Get data source ...
+ Reference< io::XActiveDataSource > xSource;
+ if( pMedium /* && pMedium->GetLoadEnvironment_Impl() */ )
+ {
+ // if there is a medium and if this medium has a load environment,
+ // we get an active data source from the medium.
+ xSource = pMedium->GetDataSource();
+ ASSERT( xSource.is(), "XMLReader:: got no data source from medium" );
+ }
+ if( !xSource.is() )
+ {
+ // If we didn't get a data source from a medium, we have to create
+ // one.
+ Reference< XInterface > xFactory = xServiceFactory->createInstance(
+ OUString::createFromAscii("com.sun.star.frame.DataSourceFactory") );
+ if( xFactory.is() )
+ {
+ Reference< lang::XMultiServiceFactory > xMFactory( xFactory,
+ UNO_QUERY );
+ if( xMFactory.is() )
+ {
+ OUString sURL( rName );
+ Sequence< Any > aArgs(1);
+ Any* pArgs = aArgs.getArray();
+ *pArgs <<= sURL;
+
+ Reference< XInterface > xSrc =
+ xMFactory->createInstanceWithArguments( sURL, aArgs );
+ if( xSrc.is() )
+ {
+ Reference< io::XActiveDataSource > xTmp( xSrc, UNO_QUERY );
+ xSource = xTmp;
+ }
+ }
+ }
+ }
+
+ // get data source
+ ASSERT( xSource.is(), "XMLReader::Read: data source missing" );
+ if( !xSource.is() )
+ return ERR_SWG_READ_ERROR;
+
+ // get parser
+ Reference< XInterface > xXMLParser = xServiceFactory->createInstance(
+ OUString::createFromAscii("com.sun.star.xml.sax.Parser") );
+ ASSERT( xXMLParser.is(),
+ "XMLReader::Read: com.sun.star.xml.sax.Parser service missing" );
+ if( !xXMLParser.is() )
+ return ERR_SWG_READ_ERROR;
+
+ // get a pipe for connecting the data source to the parser
+ Reference< XInterface > xPipe = xServiceFactory->createInstance(
+ OUString::createFromAscii("com.sun.star.io.Pipe") );
+ ASSERT( xPipe.is(),
+ "XMLReader::Read: com.sun.star.io.Pipe service missing" );
+ if( !xPipe.is() )
+ return ERR_SWG_READ_ERROR;
+
+ sal_uInt16 nStyleFamilyMask = SFX_STYLE_FAMILY_ALL;
+ sal_Bool bLoadDoc;
+ sal_Bool bInsert;
+ if( aOpt.IsFmtsOnly() )
+ {
+ bLoadDoc = sal_False;
+ bInsert = aOpt.IsMerge();
+ nStyleFamilyMask = 0U;
+ if( aOpt.IsFrmFmts() )
+ nStyleFamilyMask |= SFX_STYLE_FAMILY_FRAME;
+ if( aOpt.IsPageDescs() )
+ nStyleFamilyMask |= SFX_STYLE_FAMILY_PAGE;
+ if( aOpt.IsTxtFmts() )
+ nStyleFamilyMask |= (SFX_STYLE_FAMILY_CHAR|SFX_STYLE_FAMILY_PARA);
+ if( aOpt.IsNumRules() )
+ nStyleFamilyMask |= SFX_STYLE_FAMILY_PSEUDO;
+ }
+ else
+ {
+ bLoadDoc = sal_True;
+ bInsert = bInsertMode;
+ nStyleFamilyMask = SFX_STYLE_FAMILY_ALL;
+ }
+ aOpt.ResetAllFmtsOnly();
+
+ // get filter
+ Reference< xml::sax::XDocumentHandler > xFilter =
+ new SwXMLImport( rDoc, rPaM, bLoadDoc, bInsert, nStyleFamilyMask,
+ xModel );
+
+ // connect pipe's output stream to the data source
+ Reference< io::XOutputStream > xPipeOutput( xPipe, UNO_QUERY );
+ xSource->setOutputStream( xPipeOutput );
+
+ // connect pipe's input stream to the parser
+ xml::sax::InputSource aParserInput;
+ Reference< io::XInputStream > xPipeInput( xPipe, UNO_QUERY );
+ aParserInput.aInputStream = xPipeInput;
+ aParserInput.sSystemId = rName;
+
+ // connect parser and filter
+ Reference< xml::sax::XParser > xParser( xXMLParser, UNO_QUERY );
+ xParser->setDocumentHandler( xFilter );
+
+ rDoc.AddLink(); // prevent deletion
+ sal_uInt32 nRet = 0;
+
+ // parse
+ Reference< io::XActiveDataControl > xSourceControl( xSource, UNO_QUERY );
+ xSourceControl->start();
+ try
+ {
+ xParser->parseStream( aParserInput );
+ }
+ catch( xml::sax::SAXParseException& )
+ {
+ nRet = ERR_SWG_READ_ERROR;
+ }
+ catch( xml::sax::SAXException&)
+ {
+ nRet = ERR_SWG_READ_ERROR;
+ }
+ catch( io::IOException& )
+ {
+ nRet = ERR_SWG_READ_ERROR;
+ }
+
+ rDoc.RemoveLink();
+
+ return nRet;
+}
+
+
+/*************************************************************************
+
+ $Log: not supported by cvs2svn $
+ Revision 1.13 2000/09/18 16:05:04 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.12 2000/07/07 13:58:36 mib
+ text styles using StarOffice API
+
+ Revision 1.11 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.10 2000/03/21 15:10:56 os
+ UNOIII
+
+ Revision 1.9 2000/03/13 14:33:43 mib
+ UNO3
+
+ Revision 1.8 2000/02/11 14:40:44 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.7 1999/11/26 11:15:20 mib
+ loading of styles only and insert mode
+
+ Revision 1.6 1999/11/19 16:40:21 os
+ modules renamed
+
+ Revision 1.5 1999/11/19 15:27:05 mib
+ Opt: using OUString constructor instead of StringToOUString
+
+ Revision 1.4 1999/09/23 11:53:47 mib
+ i18n, token maps and hard paragraph attributes
+
+ Revision 1.3 1999/08/19 14:51:30 HR
+ #65293#: fixed exception macro usage
+
+
+ Rev 1.2 19 Aug 1999 16:51:30 HR
+ #65293#: fixed exception macro usage
+
+ Rev 1.1 17 Aug 1999 16:31:26 MIB
+ import
+
+ Rev 1.0 12 Aug 1999 12:28:08 MIB
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx
new file mode 100644
index 000000000000..feb0e8237350
--- /dev/null
+++ b/sw/source/filter/xml/wrtxml.cxx
@@ -0,0 +1,238 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtxml.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_
+#include <unotools/processfactory.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _SFXDOCFILE_HXX //autogen wg. SfxMedium
+#include <sfx2/docfile.hxx>
+#endif
+#ifndef _PAM_HXX //autogen wg. SwPaM
+#include <pam.hxx>
+#endif
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#ifndef _DOCSH_HXX //autogen wg. SwDoc
+#include <docsh.hxx>
+#endif
+
+#ifndef _ERRHDL_HXX //autogen wg. ASSERT
+#include <errhdl.hxx>
+#endif
+#ifndef _SWSWERROR_H
+#include <swerror.h>
+#endif
+#ifndef _WRTXML_HXX
+#include <wrtxml.hxx>
+#endif
+#ifndef _XMLEXP_HXX
+#include <xmlexp.hxx>
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+SwXMLWriter::SwXMLWriter()
+{
+}
+
+
+__EXPORT SwXMLWriter::~SwXMLWriter()
+{
+}
+
+sal_uInt32 SwXMLWriter::WriteStream()
+{
+ ASSERT( !this, "SwXMLWriter::WriteStream: use Write!" );
+
+ return ERR_SWG_WRITE_ERROR;
+}
+
+sal_uInt32 SwXMLWriter::Write( SwPaM& rPaM, SfxMedium& rMed,
+ const String* pFileName )
+{
+ Reference< lang::XMultiServiceFactory > xServiceFactory =
+ utl::getProcessServiceFactory();
+ ASSERT( xServiceFactory.is(),
+ "SwXMLWriter::Write: got no service manager" );
+ if( !xServiceFactory.is() )
+ return ERR_SWG_WRITE_ERROR;
+
+ Reference< XInterface > xWriter = xServiceFactory->createInstance(
+ OUString::createFromAscii("com.sun.star.xml.sax.Writer") );
+ ASSERT( xWriter.is(),
+ "SwXMLWriter::Write: com.sun.star.xml.sax.Writer service missing" );
+ if(!xWriter.is())
+ return ERR_SWG_WRITE_ERROR;
+
+ Reference< frame::XModel > xModel = rPaM.GetDoc()->GetDocShell()->GetModel();
+ ASSERT( xModel.is(),
+ "XMLWriter::Write: got no model" );
+ if( !xModel.is() )
+ return ERR_SWG_WRITE_ERROR;
+
+ Reference< io::XOutputStream > xOut = rMed.GetDataSink();
+ Reference< io::XActiveDataSource > xSrc( xWriter, UNO_QUERY );
+ xSrc->setOutputStream( xOut );
+
+ Reference< xml::sax::XDocumentHandler > xHandler( xWriter, UNO_QUERY );
+
+ SwXMLExport *pExp = new SwXMLExport( xModel, rPaM, *pFileName, xHandler,
+ bWriteAll, bWriteOnlyFirstTable,
+ bShowProgress );
+
+ sal_uInt32 nRet = pExp->exportDoc( sXML_text );
+
+ delete pExp;
+
+ ResetWriter();
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+void GetXMLWriter( const String&, WriterRef& xRet )
+{
+ xRet = new SwXMLWriter;
+}
+
+// -----------------------------------------------------------------------
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/wrtxml.cxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.17 2000/09/18 16:05:04 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.16 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.15 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.14 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.13 2000/03/21 15:10:56 os
+ UNOIII
+
+ Revision 1.12 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.11 2000/03/03 16:07:54 pl
+ #73771# workaround for c50 intel compiler
+
+ Revision 1.10 2000/02/11 14:40:52 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.9 1999/11/26 11:09:47 mib
+ progress, export-flags
+
+ Revision 1.8 1999/11/19 16:40:21 os
+ modules renamed
+
+ Revision 1.7 1999/10/26 13:34:30 mib
+ removed 'using namespace' from header files
+
+ Revision 1.6 1999/10/25 10:41:48 mib
+ Using new OUString ASCII methods
+
+ Revision 1.5 1999/10/15 14:48:25 hr
+ export() -> exportDoc()
+
+ Revision 1.4 1999/10/15 12:36:39 mib
+ added document class attribute
+
+ Revision 1.3 1999/10/08 11:47:06 mib
+ moved some file to SVTOOLS/SVX
+
+ Revision 1.2 1999/09/22 11:56:36 mib
+ string -> wstring
+
+ Revision 1.1 1999/08/12 10:28:26 MIB
+ Initial revision.
+
+
+ Rev 1.0 12 Aug 1999 12:28:26 MIB
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/wrtxml.hxx b/sw/source/filter/xml/wrtxml.hxx
new file mode 100644
index 000000000000..bdc91f054444
--- /dev/null
+++ b/sw/source/filter/xml/wrtxml.hxx
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtxml.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _WRTXML_HXX
+#define _WRTXML_HXX
+
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+
+class SwDoc;
+class SwPaM;
+class SfxMedium;
+
+class SwXMLWriter : public Writer
+{
+protected:
+ virtual sal_uInt32 WriteStream();
+
+public:
+
+ SwXMLWriter();
+ virtual ~SwXMLWriter();
+
+ virtual sal_uInt32 Write( SwPaM& rPam, SfxMedium& rMed,
+ const String* pFileName );
+};
+
+
+#endif // _WRTXML_HXX
+
diff --git a/sw/source/filter/xml/xmlbrsh.cxx b/sw/source/filter/xml/xmlbrsh.cxx
new file mode 100644
index 000000000000..e500fc83ae4e
--- /dev/null
+++ b/sw/source/filter/xml/xmlbrsh.cxx
@@ -0,0 +1,318 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlbrsh.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#include "hintids.hxx"
+#include <tools/debug.hxx>
+
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/xmlkywd.hxx>
+#include <xmloff/xmlimp.hxx>
+#include <xmloff/xmltkmap.hxx>
+
+#ifndef _SVX_UNOMID_HXX
+#include <svx/unomid.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX
+#include <svx/brshitem.hxx>
+#endif
+
+#include "xmlbrshi.hxx"
+#include "xmlbrshe.hxx"
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+enum SvXMLTokenMapAttrs
+{
+ XML_TOK_BGIMG_HREF,
+ XML_TOK_BGIMG_TYPE,
+ XML_TOK_BGIMG_ACTUATE,
+ XML_TOK_BGIMG_SHOW,
+ XML_TOK_BGIMG_POSITION,
+ XML_TOK_BGIMG_REPEAT,
+ XML_TOK_BGIMG_FILTER,
+ XML_TOK_NGIMG_END=XML_TOK_UNKNOWN
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aBGImgAttributesAttrTokenMap[] =
+{
+ { XML_NAMESPACE_XLINK, sXML_href, XML_TOK_BGIMG_HREF },
+ { XML_NAMESPACE_XLINK, sXML_type, XML_TOK_BGIMG_TYPE },
+ { XML_NAMESPACE_XLINK, sXML_actuate, XML_TOK_BGIMG_ACTUATE },
+ { XML_NAMESPACE_XLINK, sXML_show, XML_TOK_BGIMG_SHOW },
+ { XML_NAMESPACE_STYLE, sXML_position, XML_TOK_BGIMG_POSITION },
+ { XML_NAMESPACE_STYLE, sXML_repeat, XML_TOK_BGIMG_REPEAT },
+ { XML_NAMESPACE_STYLE, sXML_filter_name,XML_TOK_BGIMG_FILTER },
+ XML_TOKEN_MAP_END
+};
+
+TYPEINIT1( SwXMLBrushItemImportContext, SvXMLImportContext );
+
+void SwXMLBrushItemImportContext::ProcessAttrs(
+ const Reference< xml::sax::XAttributeList >& xAttrList,
+ const SvXMLUnitConverter& rUnitConv )
+{
+ SvXMLTokenMap aTokenMap( aBGImgAttributesAttrTokenMap );
+
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ const OUString& rValue = xAttrList->getValueByIndex( i );
+
+ switch( aTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_BGIMG_HREF:
+ pItem->importXML( rValue, MID_GRAPHIC_LINK, rUnitConv );
+ break;
+ case XML_TOK_BGIMG_TYPE:
+ case XML_TOK_BGIMG_ACTUATE:
+ case XML_TOK_BGIMG_SHOW:
+ break;
+ case XML_TOK_BGIMG_POSITION:
+ pItem->importXML( rValue, MID_GRAPHIC_POSITION, rUnitConv );
+ break;
+ case XML_TOK_BGIMG_REPEAT:
+ pItem->importXML( rValue, MID_GRAPHIC_REPEAT, rUnitConv );
+ break;
+ case XML_TOK_BGIMG_FILTER:
+ pItem->importXML( rValue, MID_GRAPHIC_FILTER, rUnitConv );
+ break;
+ }
+ }
+
+ if( !(pItem->GetGraphicLink() || pItem->GetGraphic() ) )
+ pItem->SetGraphicPos( GPOS_NONE );
+ else if( GPOS_NONE == pItem->GetGraphicPos() )
+ pItem->SetGraphicPos( GPOS_TILED );
+}
+
+SwXMLBrushItemImportContext::SwXMLBrushItemImportContext(
+ SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList >& xAttrList,
+ const SvXMLUnitConverter& rUnitConv,
+ const SvxBrushItem& rItem ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ pItem( new SvxBrushItem( rItem ) )
+{
+ // delete any grephic that is existing
+ pItem->SetGraphicPos( GPOS_NONE );
+
+ ProcessAttrs( xAttrList, rUnitConv );
+}
+
+SwXMLBrushItemImportContext::SwXMLBrushItemImportContext(
+ SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ const SvXMLUnitConverter& rUnitConv,
+ sal_uInt16 nWhich ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ pItem( new SvxBrushItem( nWhich ) )
+{
+ ProcessAttrs( xAttrList, rUnitConv );
+}
+
+SwXMLBrushItemImportContext::~SwXMLBrushItemImportContext()
+{
+ delete pItem;
+}
+
+OUString SwXMLBrushItemExport::GetQNameByKey(
+ sal_uInt16 nKey,
+ const OUString& rLocalName ) const
+{
+ if( pNamespaceMap )
+ return pNamespaceMap->GetQNameByKey( nKey, rLocalName );
+ else
+ return rLocalName;
+}
+
+void SwXMLBrushItemExport::ClearAttrList()
+{
+ pAttrList->Clear();
+}
+
+#ifndef PRODUCT
+void SwXMLBrushItemExport::CheckAttrList()
+{
+ DBG_ASSERT( !pAttrList->getLength(),
+ "SvxXMLBrsuhItemExport::CheckAttrList: list is not empty" );
+}
+#endif
+
+void SwXMLBrushItemExport::AddAttribute( sal_uInt16 nPrefixKey,
+ const sal_Char *pName,
+ const OUString& rValue )
+{
+ OUString sName( OUString::createFromAscii( pName ) );
+
+ pAttrList->AddAttribute( GetQNameByKey( nPrefixKey, sName ),
+ sCDATA, rValue );
+}
+
+SwXMLBrushItemExport::SwXMLBrushItemExport(
+ const Reference< xml::sax::XDocumentHandler >& rHandler,
+ const SvXMLUnitConverter& rUnitConverter ) :
+ sCDATA( OUString::createFromAscii( sXML_CDATA ) ),
+ pNamespaceMap( 0 ),
+ rUnitConv( rUnitConverter ),
+ pAttrList( new SvXMLAttributeList )
+{
+ xHandler = rHandler;
+ xAttrList = pAttrList;
+}
+
+SwXMLBrushItemExport::~SwXMLBrushItemExport()
+{
+}
+
+void SwXMLBrushItemExport::exportXML( const SvxBrushItem& rItem,
+ const SvXMLNamespaceMap& rNamespaceMap )
+{
+ pNamespaceMap = &rNamespaceMap;
+
+ CheckAttrList();
+
+ OUString sValue;
+ if( rItem.exportXML( sValue, MID_GRAPHIC_LINK, rUnitConv ) )
+ {
+ AddAttribute( XML_NAMESPACE_XLINK, sXML_href, sValue );
+ AddAttribute( XML_NAMESPACE_XLINK, sXML_type,
+ OUString::createFromAscii(sXML_simple) );
+// AddAttribute( XML_NAMESPACE_XLINK, sXML_show, ACP2WS(sXML_embed) );
+ AddAttribute( XML_NAMESPACE_XLINK, sXML_actuate,
+ OUString::createFromAscii(sXML_onLoad) );
+
+ if( rItem.exportXML( sValue, MID_GRAPHIC_POSITION, rUnitConv ) )
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_position, sValue );
+
+ if( rItem.exportXML( sValue, MID_GRAPHIC_REPEAT, rUnitConv ) )
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_repeat, sValue );
+
+ if( rItem.exportXML( sValue, MID_GRAPHIC_FILTER, rUnitConv ) )
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_filter_name, sValue );
+ }
+
+ OUString sElem( GetQNameByKey( XML_NAMESPACE_STYLE,
+ OUString::createFromAscii(sXML_background_image) ) );
+ xHandler->startElement( sElem, xAttrList );
+ ClearAttrList();
+ xHandler->endElement( sElem );
+
+ pNamespaceMap = 0;
+}
+
+/*************************************************************************
+
+ Source Code Control ::com::sun::star::chaos::System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlbrsh.cxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+ Source Code Control ::com::sun::star::chaos::System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.2 2000/09/18 16:05:05 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.1 2000/08/02 14:52:38 mib
+ text export continued
+
+ Revision 1.2 2000/06/26 08:29:55 mib
+ no SVX dependency any longer
+
+ Revision 1.1 2000/06/08 09:14:25 aw
+ new export classes from svx
+
+ Revision 1.5 2000/05/02 10:04:19 mib
+ unicode
+
+ Revision 1.4 2000/03/13 14:38:56 cl
+ uno3
+
+ Revision 1.3 2000/02/10 20:09:32 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.2 2000/01/06 14:59:19 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+ Revision 1.1 1999/12/13 08:11:18 mib
+ #70271#: XML brush item import/export
+
+ Revision 1.1 1999/12/04 16:47:25 cl
+ #70271# added support for exporting tab-stop elements in xml
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlbrshe.hxx b/sw/source/filter/xml/xmlbrshe.hxx
new file mode 100644
index 000000000000..813991daf3c0
--- /dev/null
+++ b/sw/source/filter/xml/xmlbrshe.hxx
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlbrshe.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _XMLBRSHE_HXX
+#define _XMLBRSHE_HXX
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _XMLOFF_ATTRLIST_HXX
+#include <xmloff/attrlist.hxx>
+#endif
+
+
+class SvXMLNamespaceMap;
+class SvXMLUnitConverter;
+class SvxBrushItem;
+
+class SwXMLBrushItemExport
+{
+ const ::rtl::OUString sCDATA;
+
+ // the handler
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XDocumentHandler > xHandler;
+
+ // a common attribute list and an interface of it
+ SvXMLAttributeList *pAttrList;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > xAttrList;
+
+ const SvXMLNamespaceMap *pNamespaceMap; // the namepspace map
+ const SvXMLUnitConverter& rUnitConv;
+
+protected:
+
+ // Check if common attribute list is empty.
+#ifdef PRODUCT
+ void CheckAttrList() {}
+#else
+ void CheckAttrList();
+#endif
+ void ClearAttrList();
+ void AddAttribute( sal_uInt16 nPrefixKey, const sal_Char *pName,
+ const ::rtl::OUString& rValue );
+ ::rtl::OUString GetQNameByKey( sal_uInt16 nKey,
+ const ::rtl::OUString& rLocalName ) const;
+public:
+
+ SwXMLBrushItemExport(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
+ const SvXMLUnitConverter& rUnitConverter );
+ ~SwXMLBrushItemExport();
+
+ // core API
+ void exportXML( const SvxBrushItem& rItem,
+ const SvXMLNamespaceMap& rNamespMap );
+};
+
+
+#endif // _XMLBRSHE_HXX
+
diff --git a/sw/source/filter/xml/xmlbrshi.hxx b/sw/source/filter/xml/xmlbrshi.hxx
new file mode 100644
index 000000000000..13c7a62f4376
--- /dev/null
+++ b/sw/source/filter/xml/xmlbrshi.hxx
@@ -0,0 +1,113 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlbrshi.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _XMLBRSHI_HXX
+#define _XMLBRSHI_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include "xmlictxt.hxx"
+#endif
+
+class SvXMLImport;
+class SvXMLUnitConverter;
+class SvxBrushItem;
+
+namespace rtl { class OUString; }
+
+class SwXMLBrushItemImportContext : public SvXMLImportContext
+{
+private:
+ SvxBrushItem *pItem;
+
+ void ProcessAttrs(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ const SvXMLUnitConverter& rUnitConv );
+
+public:
+ TYPEINFO();
+
+ SwXMLBrushItemImportContext(
+ SvXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ const SvXMLUnitConverter& rUnitConv,
+ const SvxBrushItem& rItem );
+
+ SwXMLBrushItemImportContext(
+ SvXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ const SvXMLUnitConverter& rUnitConv,
+ sal_uInt16 nWhich );
+
+ virtual ~SwXMLBrushItemImportContext();
+
+ const SvxBrushItem& GetItem() const { return *pItem; }
+};
+
+
+#endif // _XMLBRSHI_HXX
+
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
new file mode 100644
index 000000000000..e09dfdfb7074
--- /dev/null
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -0,0 +1,550 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlexp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef _NODE_HXX //autogen wg. SwTableNode
+#include <node.hxx>
+#endif
+#ifndef _NDTXT_HXX //autogen wg. SwTxtNode
+#include <ndtxt.hxx>
+#endif
+#ifndef _PAM_HXX //autogen wg. SwPaM
+#include <pam.hxx>
+#endif
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx> // ...Percent()
+#endif
+#ifndef _STATSTR_HRC
+#include <statstr.hrc> // ResId fuer Statusleiste
+#endif
+#ifndef _SHL_HXX //autogen wg. SHL_WRITER
+#include <tools/shl.hxx>
+#endif
+#ifndef _SWMODULE_HXX //autogen wg. SW_MOD
+#include <swmodule.hxx>
+#endif
+
+#ifndef _SWDOCSH_HXX
+#include <docsh.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXTDOCUMENT_HPP_
+#include <com/sun/star/text/XTextDocument.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_
+#include <com/sun/star/text/XText.hpp>
+#endif
+
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLCNITM_HXX
+#include <xmloff/xmlcnitm.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLASTPL_HXX
+#include <xmloff/xmlastpl.hxx>
+#endif
+
+#ifndef _XMLOFF_TXTFLDE_HXX
+#include <xmloff/txtflde.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNUMFE_HXX
+#include <xmloff/xmlnumfe.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#endif
+
+#ifndef _XMLOFF_TXTPARAE_HXX
+#include <xmloff/txtparae.hxx>
+#endif
+#ifndef _XMLOFF_XMLASTPLP_HXX
+#include <xmloff/xmlaustp.hxx>
+#endif
+#ifndef _XMLOFF_TXTPRMAP_HXX
+#include <xmloff/txtprmap.hxx>
+#endif
+#ifndef _XMLOFF_FAMILIES_HXX_
+#include <xmloff/families.hxx>
+#endif
+
+#ifndef _XMLNUME_HXX
+#include <xmlnume.hxx>
+#endif
+#ifndef _XMLFMTE_HXX
+#include <xmlfmte.hxx>
+#endif
+#ifndef _XMLTEXTE_HXX
+#include <xmltexte.hxx>
+#endif
+#ifndef _XMLEXP_HXX
+#include <xmlexp.hxx>
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::text;
+
+#ifdef XML_CORE_API
+void SwXMLExport::SetCurPaM( SwPaM& rPaM, sal_Bool bWhole, sal_Bool bTabOnly )
+{
+ if( !pCurPaM )
+ {
+ pCurPaM = new SwPaM( *rPaM.End(), *rPaM.Start() );
+ }
+ else
+ {
+ *pCurPaM->GetPoint() = *rPaM.Start();
+ *pCurPaM->GetMark() = *rPaM.End();
+ }
+
+ // Set PaM to table/section start node if whole doc should be exported
+ if( bWhole )
+ {
+ SwTableNode *pTblNd = pCurPaM->GetNode()->FindTableNode();
+ if( pTblNd )
+ {
+ pCurPaM->GetPoint()->nNode = *pTblNd;
+
+ if( bTabOnly )
+ pCurPaM->GetMark()->nNode = *pTblNd->EndOfSectionNode();
+ }
+
+ SwSectionNode * pSectNd = pCurPaM->GetNode()->FindSectionNode();
+ while( pSectNd )
+ {
+ pCurPaM->GetPoint()->nNode = *pSectNd;
+
+ // SwSectionNode::FindSectionNode() returns the section node itself
+ pSectNd = pSectNd->FindStartNode()->FindSectionNode();
+ }
+ }
+}
+#endif
+
+SwXMLExport::SwXMLExport( const Reference< XModel >& rModel, SwPaM& rPaM,
+ const OUString& rFileName,
+ const Reference< xml::sax::XDocumentHandler > & rHandler,
+ sal_Bool bExpWholeDoc, sal_Bool bExpFirstTableOnly,
+ sal_Bool bShowProg ) :
+ SvXMLExport( rFileName, rHandler, rModel,
+ SW_MOD()->GetMetric( rPaM.GetDoc()->IsHTMLMode() ) ),
+ pDoc( rPaM.GetDoc() ),
+#ifdef XML_CORE_API
+ pCurPaM( 0 ),
+ pOrigPaM( &rPaM ),
+ pParaItemMapper( 0 ),
+#endif
+ pTableItemMapper( 0 ),
+#ifdef XML_CORE_API
+ pItemSetAutoStylePool( new SwXMLAutoStylePool ),
+ pListElements( 0 ),
+ pExportedLists( 0 ),
+#endif
+ pTableLines( 0 ),
+ bExportWholeDoc( bExpWholeDoc ),
+ bExportFirstTableOnly( bExpFirstTableOnly ),
+ bShowProgress( bShowProg )
+#ifdef XML_CORE_API
+ , pTextFieldExport( 0 ),
+ pNumberFormatExport( 0 )
+#endif
+{
+// _GetNamespaceMap().AddAtIndex( XML_NAMESPACE_TEXT, sXML_np_text,
+// sXML_n_text, XML_NAMESPACE_TEXT );
+// _GetNamespaceMap().AddAtIndex( XML_NAMESPACE_TABLE, sXML_np_table,
+// sXML_n_table, XML_NAMESPACE_TABLE );
+
+ const SfxPoolItem* pItem;
+ const SfxItemPool& rPool = pDoc->GetAttrPool();
+ sal_uInt16 nItems = rPool.GetItemCount( RES_UNKNOWNATR_CONTAINER );
+ sal_Bool bExtended = sal_False;
+ for( sal_uInt16 i = 0; i < nItems; ++i )
+ {
+ if( 0 != (pItem = rPool.GetItem( RES_UNKNOWNATR_CONTAINER, i ) ) )
+ {
+ const SvXMLAttrContainerItem *pUnknown =
+ (const SvXMLAttrContainerItem *)pItem;
+ if( (pUnknown->GetAttrCount() > 0) )
+ {
+ sal_uInt16 nIdx = pUnknown->GetFirstNamespaceIndex();
+ while( USHRT_MAX != nIdx )
+ {
+ const OUString& rPrefix = pUnknown->GetPrefix( nIdx );
+ if( USHRT_MAX ==
+ GetNamespaceMap().GetIndexByPrefix( rPrefix ) )
+ {
+ // Add namespace declaration for unknown attributes if
+ // there aren't existing ones for the prefix used by the
+ // attibutes
+ _GetNamespaceMap().Add( rPrefix,
+ pUnknown->GetNamespace( nIdx ),
+ XML_NAMESPACE_UNKNOWN );
+ }
+ nIdx = pUnknown->GetNextNamespaceIndex( nIdx );
+ }
+
+ bExtended = sal_True;
+ }
+ }
+ }
+
+ SetExtended( bExtended );
+
+#ifdef XML_CORE_API
+ SetCurPaM( rPaM, bExportWholeDoc, bExportFirstTableOnly );
+#endif
+
+ _InitItemExport();
+
+ if( bShowProgress )
+ ::StartProgress( STR_STATSTR_W4WWRITE, 0, pDoc->GetNodes().Count(),
+ pDoc->GetDocShell() );
+
+#ifdef XML_CORE_API
+ Reference< util::XNumberFormatsSupplier > xNumFmtSupp(
+ pDoc->GetDocShell()->GetBaseModel(), UNO_QUERY);
+ pNumberFormatExport = new SvXMLNumFmtExport( rHandler, xNumFmtSupp );
+
+ pTextFieldExport = new XMLTextFieldExport( *this );
+#endif
+
+ SfxObjectShell* pObjSh = pDoc->GetDocShell();
+ if( pObjSh )
+ pObjSh->UpdateDocInfoForSave(); // update information
+}
+
+#ifndef XML_CORE_API
+XMLTextParagraphExport* SwXMLExport::CreateTextParagraphExport()
+{
+ return new SwXMLTextParagraphExport( *this, *GetAutoStylePool().get() );
+}
+#endif
+
+__EXPORT SwXMLExport::~SwXMLExport()
+{
+#ifdef XML_CORE_API
+ delete pItemSetAutoStylePool;
+#endif
+
+#ifdef XML_CORE_API
+ delete pTextFieldExport;
+ delete pNumberFormatExport;
+#endif
+
+ if( bShowProgress )
+ ::EndProgress( pDoc->GetDocShell() );
+
+#ifdef XML_CORE_API
+ if( pCurPaM )
+ {
+ while( pCurPaM->GetNext() != pCurPaM )
+ delete pCurPaM->GetNext();
+ delete pCurPaM;
+ }
+#endif
+ _FinitItemExport();
+#ifdef XML_CORE_API
+ _FinitNumRuleExport();
+#endif
+ ASSERT( !pTableLines, "there are table columns infos left" );
+}
+
+
+void SwXMLExport::_ExportContent()
+{
+#ifdef XML_CORE_API
+ // export field declarations
+// pTextFieldExport->ExportFieldDeclarations();
+
+ // export all PaMs
+ SwPaM *pPaM = pOrigPaM;
+ sal_Bool bContinue = sal_True;
+ do
+ {
+ // export PaM content
+ ExportCurPaM( bExportWholeDoc );
+
+ bContinue = pPaM->GetNext() != pOrigPaM;
+
+ if( bContinue )
+ {
+ pPaM = (SwPaM *)pPaM->GetNext();
+ SetCurPaM( *pPaM, bExportWholeDoc, bExportFirstTableOnly );
+ }
+
+ } while( bContinue );
+#else
+ GetTextParagraphExport()->exportTextDeclarations();
+ Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
+ Reference < XText > xText = xTextDoc->getText();
+
+ GetTextParagraphExport()->exportFramesBoundToPage();
+ GetTextParagraphExport()->exportText( xText );
+#endif
+}
+
+#ifdef XML_CORE_API
+void SwXMLExport::ExportCurPaM( sal_Bool bExportWholePaM )
+{
+ sal_Bool bFirstNode = sal_True;
+ sal_Bool bExportWholeNode = bExportWholePaM;
+
+ SwXMLNumRuleInfo aPrevNumInfo;
+ SwXMLNumRuleInfo aNextNumInfo;
+
+ while( pCurPaM->GetPoint()->nNode.GetIndex() <
+ pCurPaM->GetMark()->nNode.GetIndex() ||
+ ( pCurPaM->GetPoint()->nNode.GetIndex() ==
+ pCurPaM->GetMark()->nNode.GetIndex() &&
+ pCurPaM->GetPoint()->nContent.GetIndex() <=
+ pCurPaM->GetMark()->nContent.GetIndex() ) )
+ {
+ SwNode *pNd = pCurPaM->GetNode();
+
+ aNextNumInfo.Set( *pNd );
+ ExportListChange( aPrevNumInfo, aNextNumInfo );
+
+ ASSERT( !(pNd->IsGrfNode() || pNd->IsOLENode()),
+ "SwXMLExport::exportCurPaM: grf or OLE node unexpected" );
+ if( pNd->IsTxtNode() )
+ {
+ SwTxtNode* pTxtNd = pNd->GetTxtNode();
+
+ if( !bFirstNode )
+ pCurPaM->GetPoint()->nContent.Assign( pTxtNd, 0 );
+
+ ExportTxtNode( *pTxtNd, 0, STRING_LEN, bExportWholeNode );
+ }
+ else if( pNd->IsTableNode() )
+ {
+ ExportTable( *pNd->GetTableNode() );
+ }
+ else if( pNd->IsSectionNode() )
+ {
+ ExportSection( *pNd->GetSectionNode() );
+ }
+ else if( pNd == &pDoc->GetNodes().GetEndOfContent() )
+ break;
+
+ pCurPaM->GetPoint()->nNode++; // next node
+
+ sal_uInt32 nPos = pCurPaM->GetPoint()->nNode.GetIndex();
+ if( bShowProgress )
+ ::SetProgressState( nPos, pDoc->GetDocShell() );
+
+ // if not everything should be exported, the WriteAll flag must be
+ // set for all but the first and last node anyway.
+ bExportWholeNode = bExportWholePaM ||
+ nPos != pCurPaM->GetMark()->nNode.GetIndex();
+ bFirstNode = sal_False;
+
+ aPrevNumInfo = aNextNumInfo;
+ }
+ aNextNumInfo.Reset();
+ ExportListChange( aPrevNumInfo, aNextNumInfo );
+}
+#endif
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlexp.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.35 2000/09/18 16:05:05 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.34 2000/09/18 11:58:02 mib
+ text frames/graphics import and export continued
+
+ Revision 1.33 2000/08/15 11:55:56 kz
+ #65293# del. 2. Parameter
+
+ Revision 1.32 2000/08/10 10:22:15 mib
+ #74404#: Adeptions to new XSL/XLink working draft
+
+ Revision 1.31 2000/08/02 14:52:39 mib
+ text export continued
+
+ Revision 1.30 2000/07/31 09:42:35 mib
+ text export continued
+
+ Revision 1.29 2000/07/27 08:06:33 mib
+ text import continued
+
+ Revision 1.28 2000/07/26 05:11:20 mib
+ text import/export continued
+
+ Revision 1.27 2000/07/24 12:01:21 dvo
+ - field declarations now exported at content beginning
+
+ Revision 1.26 2000/07/24 10:19:02 dvo
+ - textfield export for XML_CORE_API
+
+ Revision 1.25 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.24 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.23 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.22 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.21 2000/02/11 14:40:57 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.20 2000/02/07 10:03:28 mib
+ #70271#: tables
+
+ Revision 1.19 2000/01/20 10:03:15 mib
+ #70271#: Lists reworked
+
+ Revision 1.18 2000/01/12 15:00:22 mib
+ #70271#: lists
+
+ Revision 1.17 2000/01/06 15:08:27 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+ Revision 1.16 1999/12/06 14:49:49 mib
+ #70271#: office:version attribute
+
+ Revision 1.15 1999/12/06 11:41:33 mib
+ #70258#: Container item for unkown attributes
+
+ Revision 1.14 1999/11/26 11:08:59 mib
+ progress, export-flags
+
+ Revision 1.13 1999/11/22 15:52:34 os
+ headers added
+
+ Revision 1.12 1999/11/17 20:07:53 nn
+ document language
+
+ Revision 1.11 1999/11/12 14:50:28 mib
+ meta import and export reactivated
+
+ Revision 1.10 1999/11/10 15:08:09 mib
+ Import now uses XMLItemMapper
+
+ Revision 1.9 1999/11/09 15:40:29 mib
+ Using XMLItemMapper for export
+
+ Revision 1.8 1999/11/05 19:43:18 nn
+ _ExportMeta
+
+ Revision 1.7 1999/10/26 13:34:30 mib
+ removed 'using namespace' from header files
+
+ Revision 1.6 1999/10/08 11:47:09 mib
+ moved some file to SVTOOLS/SVX
+
+ Revision 1.5 1999/09/22 11:56:47 mib
+ string -> wstring
+
+ Revision 1.4 1999/08/17 14:28:22 MIB
+ namespace map methods renamed consistently
+
+
+ Rev 1.3 17 Aug 1999 16:28:22 MIB
+ namespace map methods renamed consistently
+
+ Rev 1.2 13 Aug 1999 16:21:14 MIB
+ new base class XMLExport, styles and sections
+
+ Rev 1.1 12 Aug 1999 18:05:20 MIB
+ Export ofSvxFontItem, SvxFontHeightItem and SvxLRSpaceItem
+
+ Rev 1.0 12 Aug 1999 12:28:54 MIB
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlexp.hxx b/sw/source/filter/xml/xmlexp.hxx
new file mode 100644
index 000000000000..9926723753c3
--- /dev/null
+++ b/sw/source/filter/xml/xmlexp.hxx
@@ -0,0 +1,254 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlexp.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _XMLEXP_HXX
+#define _XMLEXP_HXX
+
+#ifndef _XMLOFF_XMLEXP_HXX
+#include <xmloff/xmlexp.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLITMAP_HXX
+#include <xmloff/xmlitmap.hxx>
+#endif
+#ifndef _UNIVERSALL_REFERENCE_HXX
+#include <xmloff/uniref.hxx>
+#endif
+
+class SwDoc;
+class SwPaM;
+class SwTxtNode;
+class SwSectionNode;
+class SwFmt;
+class SwFrmFmt;
+class SvXMLUnitConverter;
+class SvXMLExportItemMapper;
+class SwXMLAutoStylePool;
+class SvXMLAutoStylePool;
+class SvXMLAutoStylePoolP;
+class SwNodeNum;
+class SfxPoolItem;
+class SfxItemSet;
+class SwXMLNumRuleInfo;
+class OUStrings_Impl;
+class OUStringsSort_Impl;
+class SwTableLine;
+class SwTableLines;
+class SwTableBox;
+class SwXMLTableColumn_Impl;
+class SwXMLTableLines_Impl;
+class SwXMLTableLinesCache_Impl;
+class SwXMLTableColumnsSortByWidth_Impl;
+class SwXMLTableFrmFmtsSort_Impl;
+class SwTableNode;
+#ifdef XML_CORE_API
+class SvXMLNumFmtExport;
+class XMLTextFieldExport;
+#endif
+class XMLPropertySetMapper;
+class SwXMLTextParagraphExport;
+
+class SwXMLExport : public SvXMLExport
+{
+ friend class SwXMLExpContext;
+
+ SwDoc *pDoc; // the current doc
+#ifdef XML_CORE_API
+ SwPaM *pCurPaM; // the current PaM
+ SwPaM *pOrigPaM; // the original PaM
+#endif
+
+ SvXMLUnitConverter *pTwipUnitConv;
+
+#ifdef XML_CORE_API
+ SvXMLExportItemMapper *pParaItemMapper;
+#endif
+ SvXMLExportItemMapper *pTableItemMapper;
+#ifdef XML_CORE_API
+ SwXMLAutoStylePool *pItemSetAutoStylePool;
+ OUStrings_Impl *pListElements;
+ OUStringsSort_Impl *pExportedLists;
+#endif
+ SwXMLTableLinesCache_Impl *pTableLines;
+#ifdef XML_CORE_API
+ SvXMLNumFmtExport *pNumberFormatExport;
+ XMLTextFieldExport *pTextFieldExport;
+#endif
+
+ SvXMLItemMapEntriesRef xTableItemMap;
+ SvXMLItemMapEntriesRef xTableRowItemMap;
+ SvXMLItemMapEntriesRef xTableCellItemMap;
+ UniReference < XMLPropertySetMapper > xParaPropMapper;
+
+ sal_Bool bExportWholeDoc : 1;// export whole document?
+ sal_Bool bExportFirstTableOnly : 1;
+ sal_Bool bShowProgress : 1;
+
+ void _InitItemExport();
+ void _FinitItemExport();
+#ifdef XML_CORE_API
+ void _FinitNumRuleExport();
+
+ void AddTextAutoStyle( const SfxPoolItem& rItem );
+ void AddParaAutoStyle( const ::rtl::OUString& rParent,
+ const SfxItemSet& rItemSet );
+ ::rtl::OUString FindTextAutoStyle( const SfxPoolItem& rItem );
+ ::rtl::OUString FindParaAutoStyle( const ::rtl::OUString& rParent,
+ const SfxItemSet& rItemSet );
+
+ void ExportCurPaMAutoStyles( sal_Bool bExportWholePaM=sal_True );
+ void ExportTxtNodeAutoStyles( const SwTxtNode& rTxtNd, xub_StrLen nStart,
+ xub_StrLen nEnd, sal_Bool bExportWholeNode );
+ void ExportSectionAutoStyles( const SwSectionNode& rSectNd );
+#endif
+ void ExportTableLinesAutoStyles( const SwTableLines& rLines,
+ sal_uInt32 nAbsWidth,
+ sal_uInt32 nBaseWidth,
+ const ::rtl::OUString& rNamePrefix,
+ SwXMLTableColumnsSortByWidth_Impl& rExpCols,
+ SwXMLTableFrmFmtsSort_Impl& rExpRows,
+ SwXMLTableFrmFmtsSort_Impl& rExpCells,
+ sal_Bool bTop=sal_False );
+
+#ifdef XML_CORE_API
+ void ExportCurPaM( sal_Bool bExportWholePaM=sal_True );
+ void ExportTxtNode( const SwTxtNode& rTxtNd, xub_StrLen nStart,
+ xub_StrLen nEnd, sal_Bool bExportWholeNode );
+ void ExportSection( const SwSectionNode& rSectNd );
+#endif
+
+ void ExportFmt( const SwFmt& rFmt, const sal_Char *pFamily = 0 );
+ void ExportTableFmt( const SwFrmFmt& rFmt, sal_uInt32 nAbsWidth );
+#ifdef XML_CORE_API
+ void ExportNumRules( sal_Bool bAuto, sal_Bool bUsed );
+ void ExportNodeNum( const SwNodeNum& rNdNum );
+ void ExportListChange( const SwXMLNumRuleInfo& rPrvInfo,
+ const SwXMLNumRuleInfo& rNextInfo );
+#endif
+
+ void ExportTableColumnStyle( const SwXMLTableColumn_Impl& rCol );
+ void ExportTableBox( const SwTableBox& rBox, sal_uInt16 nColSpan );
+ void ExportTableLine( const SwTableLine& rLine,
+ const SwXMLTableLines_Impl& rLines );
+ void ExportTableLines( const SwTableLines& rLines,
+ sal_Bool bHeadline=sal_False );
+
+// virtual void _ExportMeta();
+ virtual void _ExportStyles( sal_Bool bUsed );
+ virtual void _ExportAutoStyles();
+ virtual void _ExportMasterStyles();
+ virtual void _ExportContent();
+
+#ifdef XML_CORE_API
+ void SetCurPaM( SwPaM& rPaM, sal_Bool bWhole, sal_Bool bTabOnly );
+#endif
+
+protected:
+
+#ifndef XML_CORE_API
+ virtual XMLTextParagraphExport* CreateTextParagraphExport();
+ virtual SvXMLAutoStylePoolP* CreateAutoStylePool();
+#endif
+
+public:
+
+ SwXMLExport( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > & rModel,
+ SwPaM& rPaM, const ::rtl::OUString& rFileName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
+ sal_Bool bExpWholeDoc, sal_Bool bExpFirstTableOnly,
+ sal_Bool bShowProgr );
+ virtual ~SwXMLExport();
+
+ inline const SvXMLUnitConverter& GetTwipUnitConverter() const;
+
+ void ExportTableAutoStyles( const SwTableNode& rTblNd );
+ void ExportTable( const SwTableNode& rTblNd );
+
+#ifdef XML_CORE_API
+ SvXMLExportItemMapper& GetParaItemMapper() { return *pParaItemMapper; }
+#endif
+ SvXMLExportItemMapper& GetTableItemMapper() { return *pTableItemMapper; }
+ const UniReference < XMLPropertySetMapper >& GetParaPropMapper()
+ {
+ return xParaPropMapper;
+ }
+#ifdef XML_CORE_API
+ SwXMLAutoStylePool& GetItemSetAutoStylePool() { return *pItemSetAutoStylePool; }
+#endif
+
+#ifdef XML_CORE_API
+ SvXMLNumFmtExport& GetNumberFormatExport() { return *pNumberFormatExport; }
+ XMLTextFieldExport& GetTextFieldExport() { return *pTextFieldExport; }
+#endif
+
+ SwDoc& GetDoc() { return *pDoc; }
+};
+
+inline const SvXMLUnitConverter& SwXMLExport::GetTwipUnitConverter() const
+{
+ return *pTwipUnitConv;
+}
+
+
+#endif // _XMLEXP_HXX
+
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
new file mode 100644
index 000000000000..2a8d964c4d72
--- /dev/null
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -0,0 +1,1814 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlfmt.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+
+#ifndef _SVSTDARR_STRINGSSORT_DECL
+#define _SVSTDARR_STRINGSSORT
+#include <svtools/svstdarr.hxx>
+#endif
+
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+
+#ifndef _FORMAT_HXX //autogen wg. SwFmt
+#include <format.hxx>
+#endif
+#ifndef _FMTCOL_HXX //autogen wg. SwTxtFmtColl
+#include <fmtcol.hxx>
+#endif
+#ifndef _HINTS_HXX //autogen wg. SwFmtChg
+#include <hints.hxx>
+#endif
+
+#ifndef _POOLFMT_HXX //autogen wg. RES_POOL_CHRFMT_TYPE
+#include <poolfmt.hxx>
+#endif
+#ifndef _CHARFMT_HXX //autogen wg. SwCharFmt
+#include <charfmt.hxx>
+#endif
+#ifndef _FRMFMT_HXX //autogen wg. SwFrmFmt
+#include <frmfmt.hxx>
+#endif
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#include "docary.hxx"
+#ifndef _UNOSTYLE_HXX
+#include "unostyle.hxx"
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_I18NMAP_HXX
+#include <xmloff/i18nmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLTKMAP_HXX
+#include <xmloff/xmltkmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLITEM_HXX
+#include <xmloff/xmlitem.hxx>
+#endif
+#ifndef _XMLOFF_XMLSTYLE_HXX
+#include <xmloff/xmlstyle.hxx>
+#endif
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+#ifndef _XMLOFF_TXTSTYLI_HXX
+#include <xmloff/txtstyli.hxx>
+#endif
+#ifndef _XMLOFF_TXTIMP_HXX
+#include <xmloff/txtimp.hxx>
+#endif
+#ifndef _XMLOFF_FAMILIES_HXX
+#include <xmloff/families.hxx>
+#endif
+
+#ifndef _NUMRULE_HXX
+#include <numrule.hxx>
+#endif
+#ifndef _XMLIMP_HXX
+#include "xmlimp.hxx"
+#endif
+#ifndef _XMLNUM_HXX
+#include "xmlnum.hxx"
+#endif
+#ifndef _XMLTBLI_HXX
+#include "xmltbli.hxx"
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::style;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::rtl;
+
+class SwXMLConditionParser_Impl
+{
+ OUString sInput;
+
+ sal_uInt32 nCondition;
+ sal_uInt32 nSubCondition;
+
+ sal_Int32 nPos;
+ sal_Int32 nLength;
+
+ inline sal_Bool SkipWS();
+ inline sal_Bool MatchChar( sal_Unicode c );
+ inline sal_Bool MatchName( OUString& rName );
+ inline sal_Bool MatchNumber( sal_uInt32& rNumber );
+
+public:
+
+ SwXMLConditionParser_Impl( const OUString& rInp );
+
+ sal_Bool IsValid() const { return 0 != nCondition; }
+
+ sal_uInt32 GetCondition() const { return nCondition; }
+ sal_uInt32 GetSubCondition() const { return nSubCondition; }
+};
+
+inline sal_Bool SwXMLConditionParser_Impl::SkipWS()
+{
+ while( nPos < nLength && ' ' == sInput[nPos] )
+ nPos++;
+ return sal_True;
+}
+
+inline sal_Bool SwXMLConditionParser_Impl::MatchChar( sal_Unicode c )
+{
+ sal_Bool bRet = sal_False;
+ if( nPos < nLength && c == sInput[nPos] )
+ {
+ nPos++;
+ bRet = sal_True;
+ }
+ return bRet;
+}
+
+inline sal_Bool SwXMLConditionParser_Impl::MatchName( OUString& rName )
+{
+ OUStringBuffer sBuffer( nLength );
+ while( nPos < nLength &&
+ ( ('a' <= sInput[nPos] && sInput[nPos] <= 'z') ||
+ '-' == sInput[nPos] ) )
+ {
+ sBuffer.append( sInput[nPos] );
+ nPos++;
+ }
+ rName = sBuffer.makeStringAndClear();
+ return rName.getLength() > 0;
+}
+
+inline sal_Bool SwXMLConditionParser_Impl::MatchNumber( sal_uInt32& rNumber )
+{
+ OUStringBuffer sBuffer( nLength );
+ while( nPos < nLength && '0' <= sInput[nPos] && sInput[nPos] <= '9' )
+ {
+ sBuffer.append( sInput[nPos] );
+ nPos++;
+ }
+
+ OUString sNum( sBuffer.makeStringAndClear() );
+ if( sNum.getLength() )
+ rNumber = sNum.toInt32();
+ return sNum.getLength() > 0;
+}
+
+SwXMLConditionParser_Impl::SwXMLConditionParser_Impl( const OUString& rInp ) :
+ sInput( rInp ),
+ nPos( 0 ),
+ nLength( rInp.getLength() ),
+ nCondition( 0 ),
+ nSubCondition( 0 )
+{
+ OUString sFunc;
+ sal_Bool bHasSub = sal_False;
+ sal_uInt32 nSub = 0;
+ sal_Bool bOK = SkipWS() && MatchName( sFunc ) && SkipWS() &&
+ MatchChar( '(' ) && SkipWS() && MatchChar( ')' ) && SkipWS();
+ if( bOK && MatchChar( '=' ) )
+ {
+ bOK = SkipWS() && MatchNumber( nSub ) && SkipWS();
+ bHasSub = sal_True;
+ }
+
+ bOK &= nPos == nLength;
+
+ if( bOK )
+ {
+ switch( sFunc[0] )
+ {
+ case 'e':
+ if( sFunc.compareToAscii( sXML_endnote ) == 0 && !bHasSub )
+ nCondition = PARA_IN_ENDNOTE;
+ break;
+
+ case 'f':
+ if( sFunc.compareToAscii( sXML_footer ) == 0 && !bHasSub )
+ nCondition = PARA_IN_FOOTER;
+ else if( sFunc.compareToAscii( sXML_table_header ) == 0 &&
+ !bHasSub )
+ nCondition = PARA_IN_FOOTENOTE;
+ break;
+
+ case 'h':
+ if( sFunc.compareToAscii( sXML_header ) == 0 && !bHasSub )
+ nCondition = PARA_IN_HEADER;
+ break;
+
+ case 'l':
+ if( sFunc.compareToAscii( sXML_list_level ) == 0 &&
+ nSub >=1 && nSub < MAXLEVEL )
+ {
+ nCondition = PARA_IN_LIST;
+ nSubCondition = nSub-1;
+ }
+ break;
+
+ case 'o':
+ if( sFunc.compareToAscii( sXML_outline_level ) == 0 &&
+ nSub >=1 && nSub < MAXLEVEL )
+ {
+ nCondition = PARA_IN_OUTLINE;
+ nSubCondition = nSub-1;
+ }
+ break;
+
+ case 's':
+ if( sFunc.compareToAscii( sXML_section ) == 0 && !bHasSub )
+ {
+ nCondition = PARA_IN_SECTION;
+ }
+ break;
+
+ case 't':
+ if( sFunc.compareToAscii( sXML_table ) == 0 && !bHasSub )
+ {
+ nCondition = PARA_IN_TABLEBODY;
+ }
+ else if( sFunc.compareToAscii( sXML_table_header ) == 0 &&
+ !bHasSub )
+ {
+ nCondition = PARA_IN_TABLEHEAD;
+ }
+ else if( sFunc.compareToAscii( sXML_text_box ) == 0 && !bHasSub )
+ {
+ nCondition = PARA_IN_FRAME;
+ }
+ break;
+ }
+ }
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLConditionContext_Impl : public SvXMLImportContext
+{
+ sal_uInt32 nCondition;
+ sal_uInt32 nSubCondition;
+
+ OUString sApplyStyle;
+
+ void ParseCondition( const OUString& rCond );
+
+public:
+
+ SwXMLConditionContext_Impl(
+ SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+ virtual ~SwXMLConditionContext_Impl();
+
+ sal_Bool IsValid() const { return 0 != nCondition; }
+
+ sal_uInt32 GetCondition() const { return nCondition; }
+ sal_uInt32 GetSubCondition() const { return nSubCondition; }
+ const OUString& GetApplyStyle() const { return sApplyStyle; }
+};
+
+SwXMLConditionContext_Impl::SwXMLConditionContext_Impl(
+ SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ nCondition( 0 ),
+ nSubCondition( 0 )
+{
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ const OUString& rValue = xAttrList->getValueByIndex( i );
+
+ // TODO: use a map here
+ if( XML_NAMESPACE_STYLE == nPrefix )
+ {
+ if( aLocalName.compareToAscii( sXML_condition ) == 0 )
+ {
+ SwXMLConditionParser_Impl aCondParser( rValue );
+ if( aCondParser.IsValid() )
+ {
+ nCondition = aCondParser.GetCondition();
+ nSubCondition = aCondParser.GetSubCondition();
+ }
+ }
+ else if( aLocalName.compareToAscii( sXML_apply_style_name ) == 0 )
+ {
+ sApplyStyle = rValue;
+ }
+ }
+ }
+}
+
+SwXMLConditionContext_Impl::~SwXMLConditionContext_Impl()
+{
+}
+
+// ---------------------------------------------------------------------
+
+typedef SwXMLConditionContext_Impl *SwXMLConditionContextPtr;
+SV_DECL_PTRARR( SwXMLConditions_Impl, SwXMLConditionContextPtr, 5, 2 );
+
+#ifndef XML_CORE_API
+
+class SwXMLTextStyleContext_Impl : public XMLTextStyleContext
+{
+ SwXMLConditions_Impl *pConditions;
+
+protected:
+
+ virtual Reference < XStyle > Create();
+
+public:
+
+ TYPEINFO();
+
+ SwXMLTextStyleContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ sal_uInt16 nFamily,
+ SvXMLStylesContext& rStyles );
+ virtual ~SwXMLTextStyleContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+
+ virtual void Finish( sal_Bool bOverwrite );
+};
+
+TYPEINIT1( SwXMLTextStyleContext_Impl, XMLTextStyleContext );
+
+Reference < XStyle > SwXMLTextStyleContext_Impl::Create()
+{
+ Reference < XStyle > xNewStyle;
+
+ if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() )
+ {
+ Reference< XMultiServiceFactory > xFactory( GetImport().GetModel(),
+ UNO_QUERY );
+ if( xFactory.is() )
+ {
+ OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.style.ConditionalParagraphStyle" ) );
+ Reference < XInterface > xIfc =
+ xFactory->createInstance( sServiceName );
+ if( xIfc.is() )
+ xNewStyle = Reference < XStyle >( xIfc, UNO_QUERY );
+ }
+ }
+ else
+ {
+ xNewStyle = XMLTextStyleContext::Create();
+ }
+
+ return xNewStyle;
+}
+
+SwXMLTextStyleContext_Impl::SwXMLTextStyleContext_Impl( SwXMLImport& rImport,
+ sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ sal_uInt16 nFamily,
+ SvXMLStylesContext& rStyles ) :
+ XMLTextStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles ),
+ pConditions( 0 )
+{
+ SetFamily( nFamily );
+}
+
+SwXMLTextStyleContext_Impl::~SwXMLTextStyleContext_Impl()
+{
+ if( pConditions )
+ {
+ while( pConditions->Count() )
+ {
+ SwXMLConditionContext_Impl *pCond = pConditions->GetObject(0);
+ pConditions->Remove( 0UL );
+ pCond->ReleaseRef();
+ }
+ delete pConditions;
+ }
+}
+
+SvXMLImportContext *SwXMLTextStyleContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ if( XML_NAMESPACE_STYLE == nPrefix &&
+ rLocalName.compareToAscii( sXML_map ) == 0 )
+ {
+ SwXMLConditionContext_Impl *pCond =
+ new SwXMLConditionContext_Impl( GetImport(), nPrefix,
+ rLocalName, xAttrList );
+ if( pCond->IsValid() )
+ {
+ if( !pConditions )
+ pConditions = new SwXMLConditions_Impl;
+ pConditions->Insert( pCond, pConditions->Count() );
+ pCond->AddRef();
+ }
+ pContext = pCond;
+ }
+
+ if( !pContext )
+ pContext = XMLTextStyleContext::CreateChildContext( nPrefix, rLocalName,
+ xAttrList );
+
+ return pContext;
+}
+
+void SwXMLTextStyleContext_Impl::Finish( sal_Bool bOverwrite )
+{
+ XMLTextStyleContext::Finish( bOverwrite );
+
+ if( !pConditions || XML_STYLE_FAMILY_TEXT_PARAGRAPH != GetFamily() )
+ return;
+
+ Reference < XStyle > xStyle = GetStyle();
+ if( !xStyle.is() )
+ return;
+
+ const SwXStyle* pStyle = 0;
+ Reference<XUnoTunnel> xStyleTunnel( xStyle, UNO_QUERY);
+ if( xStyleTunnel.is() )
+ {
+ pStyle = (SwXStyle*)xStyleTunnel->getSomething(
+ SwXStyle::getUnoTunnelId() );
+ }
+ if( !pStyle )
+ return;
+
+ SwDoc& rDoc = ((SwXMLImport&)GetImport()).GetDoc();
+
+ const OUString& rName =
+ SwXStyleFamilies::GetUIName( GetName(), SFX_STYLE_FAMILY_PARA );
+ SwTxtFmtColl *pColl = rDoc.FindTxtFmtCollByName( rName );
+ ASSERT( pColl, "Text collection not found" );
+ if( !pColl || RES_CONDTXTFMTCOLL != pColl->Which() )
+ return;
+
+ sal_uInt16 nCount = pConditions->Count();
+ for( sal_uInt16 i = 0; i < nCount; i++ )
+ {
+ const SwXMLConditionContext_Impl *pCond = (*pConditions)[i];
+ const OUString& rName =
+ SwXStyleFamilies::GetUIName( pCond->GetApplyStyle(),
+ SFX_STYLE_FAMILY_PARA );
+ SwTxtFmtColl* pCondColl = rDoc.FindTxtFmtCollByName( rName );
+ ASSERT( pCondColl,
+ "SwXMLItemSetStyleContext_Impl::ConnectConditions: cond coll missing" );
+ if( pCondColl )
+ {
+ SwCollCondition aCond( pCondColl, pCond->GetCondition(),
+ pCond->GetSubCondition() );
+ ((SwConditionTxtFmtColl*)pColl)->InsertCondition( aCond );
+ }
+ }
+}
+#endif
+
+// ---------------------------------------------------------------------
+
+class SwXMLItemSetStyleContext_Impl : public SvXMLStyleContext
+{
+#ifdef XML_CORE_API
+ OUString sListStyleName;
+ SwFmt *pFmt;
+#endif
+ SfxItemSet *pItemSet;
+
+#ifdef XML_CORE_API
+ SwXMLConditions_Impl *pConditions;
+
+ sal_uInt16 nPoolId; // PoolId
+ sal_Bool bAutoUpdate;
+#endif
+
+ SvXMLImportContext *CreateItemSetContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList);
+
+protected:
+
+#ifdef XML_CORE_API
+ virtual void SetAttribute( sal_uInt16 nPrefixKey,
+ const OUString& rLocalName,
+ const OUString& rValue );
+#endif
+
+ const SwXMLImport& GetSwImport() const
+ { return (const SwXMLImport&)GetImport(); }
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+
+public:
+
+ TYPEINFO();
+
+ SwXMLItemSetStyleContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList
+#ifndef XML_CORE_API
+ ,sal_uInt16 nFamily
+#endif
+ );
+ virtual ~SwXMLItemSetStyleContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+
+#ifdef XML_CORE_API
+ sal_uInt16 GetPoolId() const { return nPoolId; }
+ sal_Bool IsAutoUpdate() const { return bAutoUpdate; }
+#endif
+
+ // The item set may be empty!
+ SfxItemSet *GetItemSet() { return pItemSet; }
+ const SfxItemSet *GetItemSet() const { return pItemSet; }
+
+#ifdef XML_CORE_API
+ SwFmt *GetFmt() { return pFmt; }
+ void SetFmt( SwFmt *p ) { pFmt = p; }
+
+ SwTxtFmtColl* GetColl();
+
+ sal_Bool HasConditions() const { return 0 != pConditions &&
+ pConditions->Count() > 0; }
+ const OUString& GetListStyle() const { return sListStyleName; }
+
+ void ConnectParent();
+ void ConnectFollow();
+ void ConnectConditions();
+ void ConnectListStyle();
+ void ConnectAutoListStyle();
+#endif
+};
+
+#ifdef XML_CORE_API
+void SwXMLItemSetStyleContext_Impl::SetAttribute( sal_uInt16 nPrefixKey,
+ const OUString& rLocalName,
+ const OUString& rValue )
+{
+ // TODO: use a map here
+ if( XML_NAMESPACE_STYLE == nPrefixKey )
+ {
+ if( rLocalName.compareToAscii( sXML_family ) == 0 )
+ {
+ SfxStyleFamily eFamily = SFX_STYLE_FAMILY_ALL;
+ sal_uInt16 nSubFamily = 0U;
+ if( rValue.compareToAscii( sXML_paragraph ) == 0 )
+ {
+ eFamily = SFX_STYLE_FAMILY_PARA;
+ }
+ else if( rValue.compareToAscii( sXML_text ) == 0 )
+ {
+ eFamily = SFX_STYLE_FAMILY_CHAR;
+ }
+ else if( 0 == rValue.compareToAscii( sXML_table, 5L ) )
+ {
+ eFamily = SFX_STYLE_FAMILY_FRAME;
+ if( 5L == rValue.getLength() )
+ nSubFamily = SW_STYLE_SUBFAMILY_TABLE;
+ else if( rValue.compareToAscii( sXML_table_column ) == 0 )
+ nSubFamily = SW_STYLE_SUBFAMILY_TABLE_COL;
+ else if( rValue.compareToAscii( sXML_table_row ) == 0 )
+ nSubFamily = SW_STYLE_SUBFAMILY_TABLE_LINE;
+ else if( rValue.compareToAscii( sXML_table_cell ) == 0 )
+ nSubFamily = SW_STYLE_SUBFAMILY_TABLE_BOX;
+ else
+ eFamily = SFX_STYLE_FAMILY_ALL;
+ }
+
+ if( SFX_STYLE_FAMILY_ALL != eFamily )
+ {
+ SetFamily( eFamily );
+ SetSubFamily( nSubFamily );
+ }
+ }
+ else if( rLocalName.compareToAscii( sXML_pool_id ) == 0 )
+ {
+ sal_Int32 nTmp = rValue.toInt32();
+ nPoolId =
+ (nTmp < 0L) ? 0U : ( (nTmp > USHRT_MAX) ? USHRT_MAX
+ : (sal_uInt16)nTmp );
+ }
+ else if( rLocalName.compareToAscii( sXML_auto_update ) == 0 )
+ {
+ if( rValue.compareToAscii( sXML_true ) == 0 )
+ bAutoUpdate = sal_True;
+ }
+ else if( rLocalName.compareToAscii( sXML_list_style_name ) == 0 )
+ {
+ sListStyleName = rValue;
+ }
+ else
+ {
+ SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+ }
+ }
+ else
+ {
+ SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+ }
+}
+#endif
+
+SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateItemSetContext(
+ sal_uInt16 nPrefix, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ ASSERT( !pItemSet,
+ "SwXMLItemSetStyleContext_Impl::CreateItemSetContext: item set exists" );
+
+ SvXMLImportContext *pContext = 0;
+ SfxItemPool& rItemPool = GetSwImport().GetDoc().GetAttrPool();
+
+#ifdef XML_CORE_API
+ switch( GetFamily() )
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ pItemSet = new SfxItemSet( rItemPool, aTxtFmtCollSetRange );
+ pContext = GetSwImport().CreateParaItemImportContext(
+ nPrefix, rLName, xAttrList, *pItemSet );
+ break;
+
+ case SFX_STYLE_FAMILY_CHAR:
+ pItemSet = new SfxItemSet( rItemPool, aCharFmtSetRange );
+ pContext = GetSwImport().CreateParaItemImportContext(
+ nPrefix, rLName, xAttrList, *pItemSet );
+ break;
+
+ case SFX_STYLE_FAMILY_FRAME:
+ {
+ switch( GetSubFamily() )
+ {
+ case SW_STYLE_SUBFAMILY_TABLE:
+ pItemSet = new SfxItemSet( rItemPool, aTableSetRange );
+ break;
+ case SW_STYLE_SUBFAMILY_TABLE_COL:
+ pItemSet = new SfxItemSet( rItemPool, RES_FRM_SIZE,
+ RES_FRM_SIZE, 0 );
+ break;
+ case SW_STYLE_SUBFAMILY_TABLE_LINE:
+ pItemSet = new SfxItemSet( rItemPool, aTableLineSetRange );
+ break;
+ case SW_STYLE_SUBFAMILY_TABLE_BOX:
+ pItemSet = new SfxItemSet( rItemPool, aTableBoxSetRange );
+ break;
+ }
+ if( pItemSet )
+ pContext = GetSwImport().CreateTableItemImportContext(
+ nPrefix, rLName, xAttrList, GetSubFamily(),
+ *pItemSet );
+ ASSERT( pItemSet,
+ "SwXMLItemSetStyleContext_Impl::CreateItemSetContext: frames are unsopprted");
+ }
+ break;
+
+ default:
+ ASSERT( !this,
+ "SwXMLItemSetStyleContext_Impl::CreateItemSetContext: unknown family" );
+ break;
+ }
+#else
+ switch( GetFamily() )
+ {
+ case XML_STYLE_FAMILY_TABLE_TABLE:
+ pItemSet = new SfxItemSet( rItemPool, aTableSetRange );
+ break;
+ case XML_STYLE_FAMILY_TABLE_COLUMN:
+ pItemSet = new SfxItemSet( rItemPool, RES_FRM_SIZE, RES_FRM_SIZE, 0 );
+ break;
+ case XML_STYLE_FAMILY_TABLE_ROW:
+ pItemSet = new SfxItemSet( rItemPool, aTableLineSetRange );
+ break;
+ case XML_STYLE_FAMILY_TABLE_CELL:
+ pItemSet = new SfxItemSet( rItemPool, aTableBoxSetRange );
+ break;
+ default:
+ ASSERT( !this,
+ "SwXMLItemSetStyleContext_Impl::CreateItemSetContext: unknown family" );
+ break;
+ }
+ if( pItemSet )
+ pContext = GetSwImport().CreateTableItemImportContext(
+ nPrefix, rLName, xAttrList, GetFamily(),
+ *pItemSet );
+#endif
+
+ if( !pContext )
+ {
+ delete pItemSet;
+ pItemSet = 0;
+ }
+
+ return pContext;
+}
+
+TYPEINIT1( SwXMLItemSetStyleContext_Impl, SvXMLStyleContext );
+
+SwXMLItemSetStyleContext_Impl::SwXMLItemSetStyleContext_Impl( SwXMLImport& rImport,
+ sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList
+#ifndef XML_CORE_API
+ ,sal_uInt16 nFamily
+#endif
+ ) :
+ SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList ),
+#ifdef XML_CORE_API
+ nPoolId( USHRT_MAX ),
+ bAutoUpdate( sal_False ),
+ pFmt( 0 ),
+ pConditions( 0 ),
+#endif
+ pItemSet( 0 )
+{
+#ifndef XML_CORE_API
+ SetFamily( nFamily );
+#endif
+}
+
+SwXMLItemSetStyleContext_Impl::~SwXMLItemSetStyleContext_Impl()
+{
+ delete pItemSet;
+#ifdef XML_CORE_API
+ if( pConditions )
+ {
+ while( pConditions->Count() )
+ {
+ SwXMLConditionContext_Impl *pCond = pConditions->GetObject(0);
+ pConditions->Remove( 0UL );
+ pCond->ReleaseRef();
+ }
+ delete pConditions;
+ }
+#endif
+}
+
+SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ if( XML_NAMESPACE_STYLE == nPrefix )
+ {
+ if( rLocalName.compareToAscii( sXML_properties ) == 0 )
+ {
+ pContext = CreateItemSetContext( nPrefix, rLocalName, xAttrList );
+ }
+#ifdef XML_CORE_API
+ else if( rLocalName.compareToAscii( sXML_map ) == 0 )
+ {
+ SwXMLConditionContext_Impl *pCond =
+ new SwXMLConditionContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList );
+ if( pCond->IsValid() )
+ {
+ if( !pConditions )
+ pConditions = new SwXMLConditions_Impl;
+ pConditions->Insert( pCond, pConditions->Count() );
+ pCond->AddRef();
+ }
+ pContext = pCond;
+ }
+#endif
+ }
+
+ if( !pContext )
+ pContext = SvXMLStyleContext::CreateChildContext( nPrefix, rLocalName,
+ xAttrList );
+
+ return pContext;
+}
+
+#ifdef XML_CORE_API
+SwTxtFmtColl* SwXMLItemSetStyleContext_Impl::GetColl()
+{
+ return (GetFamily() & SFX_STYLE_FAMILY_PARA) != 0
+ ? (SwTxtFmtColl*) pFmt
+ : NULL;
+}
+
+void SwXMLItemSetStyleContext_Impl::ConnectParent()
+{
+ if( !pFmt )
+ return;
+
+ SwDoc *pDoc = pFmt->GetDoc();
+ String aName( GetSwImport().GetI18NMap().Get( GetFamily(), GetParent() ) );
+
+// String aName( SwXStyleFamilies::GetUIName( GetParent(),
+// (SfxStyleFamily)GetFamily() ) );
+ SwFmt* pParent;
+ switch( GetFamily() )
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ if( aName.Len() )
+ pParent = pDoc->FindTxtFmtCollByName( aName );
+ else
+ pParent = (*pDoc->GetTxtFmtColls())[ 0 ];
+ break;
+
+ case SFX_STYLE_FAMILY_FRAME:
+ if( aName.Len() )
+ pParent = pDoc->FindFrmFmtByName( aName );
+ else
+ pParent = (*pDoc->GetFrmFmts())[ 0 ];
+ break;
+
+ case SFX_STYLE_FAMILY_CHAR:
+ if( aName.Len() )
+ pParent = pDoc->FindCharFmtByName( aName );
+ else
+ pParent = (*pDoc->GetCharFmts())[ 0 ];
+ break;
+ }
+
+ if( pParent )
+ pFmt->SetDerivedFrom( pParent );
+}
+
+void SwXMLItemSetStyleContext_Impl::ConnectFollow()
+{
+ if( !pFmt || GetFamily() != SFX_STYLE_FAMILY_PARA )
+ return;
+
+ SwDoc *pDoc = pFmt->GetDoc();
+ String aName( GetSwImport().GetI18NMap().Get( GetFamily(), GetFollow() ) );
+// String aName( SwXStyleFamilies::GetUIName( GetFollow(), (SfxStyleFamily)GetFamily() ) );
+
+ SwTxtFmtColl* pFollow;
+ if( aName.Len() )
+ pFollow = pDoc->FindTxtFmtCollByName( aName );
+ else
+ pFollow = GetColl();
+ if( pFollow )
+ GetColl()->SetNextTxtFmtColl( *pFollow );
+}
+
+void SwXMLItemSetStyleContext_Impl::ConnectConditions()
+{
+ if( !pFmt || GetFamily() != SFX_STYLE_FAMILY_PARA || !pConditions ||
+ RES_CONDTXTFMTCOLL != pFmt->Which() )
+ return;
+
+ SwDoc *pDoc = pFmt->GetDoc();
+ SvI18NMap& rI18NMap = ((SwXMLImport&)GetImport()).GetI18NMap();
+
+ sal_uInt16 nCount = pConditions->Count();
+ for( sal_uInt16 i = 0; i < nCount; i++ )
+ {
+ const SwXMLConditionContext_Impl *pCond = (*pConditions)[i];
+ OUString sName( rI18NMap.Get( SFX_STYLE_FAMILY_PARA,
+ pCond->GetApplyStyle() ) );
+// OUString sName( SwXStyleFamilies::GetUIName(
+// pCond->GetApplyStyle(), SFX_STYLE_FAMILY_PARA ) );
+ SwTxtFmtColl* pCondColl = pDoc->FindTxtFmtCollByName( sName );
+ ASSERT( pCondColl,
+ "SwXMLItemSetStyleContext_Impl::ConnectConditions: cond coll missing" );
+ if( pCondColl )
+ {
+ SwCollCondition aCond( pCondColl, pCond->GetCondition(),
+ pCond->GetSubCondition() );
+ ((SwConditionTxtFmtColl*)pFmt)->InsertCondition( aCond );
+ }
+ }
+}
+
+void SwXMLItemSetStyleContext_Impl::ConnectListStyle()
+{
+ if( !pFmt || GetFamily() != SFX_STYLE_FAMILY_PARA ||
+ !GetListStyle().getLength() )
+ return;
+
+ SwDoc *pDoc = pFmt->GetDoc();
+ String aName( GetSwImport().GetI18NMap().Get( SFX_STYLE_FAMILY_PSEUDO,
+ GetListStyle() ) );
+// String aName( SwXStyleFamilies::GetUIName(
+// GetListStyle(), SFX_STYLE_FAMILY_PSEUDO ) );
+ // Styles must not reference automatic num rules
+ SwNumRule *pNumRule = pDoc->FindNumRulePtr( aName );
+ if( pNumRule && !pNumRule->IsAutoRule() )
+ GetColl()->SetAttr( SwNumRuleItem(aName) );
+}
+
+void SwXMLItemSetStyleContext_Impl::ConnectAutoListStyle()
+{
+ if( GetFamily() != SFX_STYLE_FAMILY_PARA || !GetListStyle().getLength() )
+ return;
+
+ SwDoc& rDoc = GetSwImport().GetDoc();
+ String aName( GetSwImport().GetI18NMap().Get( SFX_STYLE_FAMILY_PSEUDO,
+ GetListStyle() ) );
+// String aName( SwXStyleFamilies::GetUIName(
+// GetListStyle(), SFX_STYLE_FAMILY_PSEUDO ) );
+ if( rDoc.FindNumRulePtr( aName ) )
+ {
+ if( !pItemSet )
+ {
+ SfxItemPool& rItemPool = rDoc.GetAttrPool();
+ pItemSet = new SfxItemSet( rItemPool, aTxtFmtCollSetRange );
+ }
+ pItemSet->Put( SwNumRuleItem(aName) );
+ }
+}
+#endif
+
+// ---------------------------------------------------------------------
+
+#ifdef XML_CORE_API
+enum SwXMLStyleStylesElemTokens
+{
+ SW_XML_TOK_STYLE_STYLE,
+ SW_XML_TOK_TEXT_LIST_STYLE,
+ SW_XML_TOK_TEXT_OUTLINE,
+ SW_XML_TOK_STYLE_STYLES_ELEM_END=XML_TOK_UNKNOWN
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aStyleStylesElemTokenMap[] =
+{
+ { XML_NAMESPACE_STYLE, sXML_style, SW_XML_TOK_STYLE_STYLE },
+ { XML_NAMESPACE_TEXT, sXML_list_style, SW_XML_TOK_TEXT_LIST_STYLE},
+ { XML_NAMESPACE_TEXT, sXML_outline_style, SW_XML_TOK_TEXT_OUTLINE },
+ XML_TOKEN_MAP_END
+};
+
+const SvXMLTokenMap& SwXMLImport::GetStyleStylesElemTokenMap()
+{
+ if( !pStyleStylesElemTokenMap )
+ pStyleStylesElemTokenMap =
+ new SvXMLTokenMap( aStyleStylesElemTokenMap );
+
+ return *pStyleStylesElemTokenMap;
+}
+#endif
+
+// ---------------------------------------------------------------------
+//
+class SwXMLStylesContext_Impl : public SvXMLStylesContext
+{
+ SwXMLItemSetStyleContext_Impl *GetSwStyle( sal_uInt16 i ) const;
+#ifdef XML_CORE_API
+ SwXMLListStyleContext *GetSwListStyle( sal_uInt16 i ) const;
+
+ SwFmt *FindFmtByName( const String& rName,
+ sal_uInt16 eFamily ) const;
+ SwXMLItemSetStyleContext_Impl *FindByPoolId( sal_uInt16 nPoolId ) const;
+#endif
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+ const SwXMLImport& GetSwImport() const
+ { return (const SwXMLImport&)GetImport(); }
+
+protected:
+
+#ifdef XML_CORE_API
+ // Create a style context.
+ virtual SvXMLStyleContext *CreateStyleChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+#else
+ virtual SvXMLStyleContext *CreateStyleStyleChildContext( sal_uInt16 nFamily,
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+ // HACK
+ virtual UniReference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
+ sal_uInt16 nFamily ) const;
+
+ virtual ::com::sun::star::uno::Reference <
+ ::com::sun::star::container::XNameContainer >
+ GetStylesContainer( sal_uInt16 nFamily ) const;
+ virtual ::rtl::OUString GetServiceName( sal_uInt16 nFamily ) const;
+ // HACK
+#endif
+
+public:
+
+ TYPEINFO();
+
+ SwXMLStylesContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName ,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+ virtual ~SwXMLStylesContext_Impl();
+
+ virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const;
+#ifdef XML_CORE_API
+ void CopyStylesToDoc();
+ void CopyAutoStylesToDoc();
+#endif
+};
+
+TYPEINIT1( SwXMLStylesContext_Impl, SvXMLStylesContext );
+
+inline SwXMLItemSetStyleContext_Impl *SwXMLStylesContext_Impl::GetSwStyle(
+ sal_uInt16 i ) const
+{
+ return PTR_CAST( SwXMLItemSetStyleContext_Impl, GetStyle( i ) );
+}
+
+#ifdef XML_CORE_API
+inline SwXMLListStyleContext *SwXMLStylesContext_Impl::GetSwListStyle(
+ sal_uInt16 i ) const
+{
+ return PTR_CAST( SwXMLListStyleContext, GetStyle( i ) );
+}
+
+sal_Bool lcl_xmlfmt_isValidPoolId( sal_uInt16 nPoolId, sal_uInt16 eFamily )
+{
+ sal_Bool bValid = sal_False;
+
+ // check if pool id is valid
+ if( eFamily & SFX_STYLE_FAMILY_CHAR )
+ {
+ bValid = (RES_POOLCHR_NORMAL_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCHR_NORMAL_END) ||
+ (RES_POOLCHR_HTML_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCHR_HTML_END);
+ }
+ else if( eFamily & SFX_STYLE_FAMILY_FRAME )
+ {
+ bValid = RES_POOLFRM_BEGIN <= nPoolId && nPoolId < RES_POOLFRM_END;
+ }
+ else if( eFamily & SFX_STYLE_FAMILY_PARA )
+ {
+ bValid = (RES_POOLCOLL_TEXT_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCOLL_TEXT_END) ||
+ (RES_POOLCOLL_LISTS_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCOLL_LISTS_END) ||
+ (RES_POOLCOLL_EXTRA_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCOLL_EXTRA_END) ||
+ (RES_POOLCOLL_REGISTER_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCOLL_REGISTER_END) ||
+ (RES_POOLCOLL_DOC_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCOLL_DOC_END) ||
+ (RES_POOLCOLL_HTML_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCOLL_HTML_END);
+ }
+
+ return bValid;
+}
+
+SwFmt *SwXMLStylesContext_Impl::FindFmtByName( const String& rName,
+ sal_uInt16 eFamily ) const
+{
+ const SwDoc& rDoc = GetSwImport().GetDoc();
+ SwFmt *pFmt = 0;
+ switch( eFamily )
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ pFmt = rDoc.FindTxtFmtCollByName( rName );
+ break;
+ case SFX_STYLE_FAMILY_FRAME:
+ pFmt = rDoc.FindFrmFmtByName( rName );
+ break;
+ case SFX_STYLE_FAMILY_CHAR:
+ pFmt = rDoc.FindCharFmtByName( rName );
+ break;
+ }
+
+ return pFmt;
+}
+
+SwXMLItemSetStyleContext_Impl *SwXMLStylesContext_Impl::FindByPoolId(
+ sal_uInt16 nPoolId ) const
+{
+ SwXMLItemSetStyleContext_Impl *pStyle = 0;
+ sal_uInt16 nCount = GetStyleCount();
+ for( sal_uInt16 i=0; i < nCount && !pStyle; i++ )
+ {
+ SwXMLItemSetStyleContext_Impl *pTmp = GetSwStyle( i );
+ if( pTmp && pTmp->GetPoolId() == nPoolId )
+ pStyle = pTmp;
+ }
+
+ return pStyle;
+}
+
+SvXMLStyleContext *SwXMLStylesContext_Impl::CreateStyleChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLStyleContext *pStyle = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetStyleStylesElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case SW_XML_TOK_STYLE_STYLE:
+ pStyle = new SwXMLItemSetStyleContext_Impl( GetSwImport(), nPrefix, rLocalName,
+ xAttrList);
+ break;
+ case SW_XML_TOK_TEXT_LIST_STYLE:
+ pStyle = new SwXMLListStyleContext( GetSwImport(), nPrefix,
+ rLocalName, xAttrList );
+ break;
+ case SW_XML_TOK_TEXT_OUTLINE:
+ pStyle = new SwXMLListStyleContext( GetSwImport(), nPrefix,
+ rLocalName, xAttrList, sal_True );
+ break;
+ default:
+ pStyle = SvXMLStylesContext::CreateStyleChildContext( nPrefix,
+ rLocalName,
+ xAttrList );
+ break;
+ }
+
+ return pStyle;
+}
+#else
+SvXMLStyleContext *SwXMLStylesContext_Impl::CreateStyleStyleChildContext(
+ sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLStyleContext *pStyle = 0;
+
+ switch( nFamily )
+ {
+ case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
+ pStyle = new SwXMLTextStyleContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList, nFamily, *this );
+ break;
+ case XML_STYLE_FAMILY_TABLE_TABLE:
+ case XML_STYLE_FAMILY_TABLE_COLUMN:
+ case XML_STYLE_FAMILY_TABLE_ROW:
+ case XML_STYLE_FAMILY_TABLE_CELL:
+ pStyle = new SwXMLItemSetStyleContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList, nFamily );
+ break;
+ case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
+ // HACK until CL is back again
+ pStyle = new XMLTextStyleContext( GetImport(), nPrefix,
+ rLocalName, xAttrList, *this );
+ break;
+ default:
+ pStyle = SvXMLStylesContext::CreateStyleStyleChildContext( nFamily,
+ nPrefix,
+ rLocalName,
+ xAttrList );
+ break;
+ }
+
+ return pStyle;
+}
+#endif
+
+SwXMLStylesContext_Impl::SwXMLStylesContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList ) :
+ SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList )
+{
+}
+
+SwXMLStylesContext_Impl::~SwXMLStylesContext_Impl()
+{
+}
+
+#ifndef XML_CORE_API
+sal_Bool SwXMLStylesContext_Impl::InsertStyleFamily( sal_uInt16 nFamily ) const
+{
+ const SwXMLImport& rSwImport = GetSwImport();
+ sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask();
+
+ sal_Bool bIns = sal_True;
+ switch( nFamily )
+ {
+ case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
+ bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PARA) != 0;
+ break;
+ case XML_STYLE_FAMILY_TEXT_TEXT:
+ bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_CHAR) != 0;
+ break;
+ case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
+ bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_FRAME) != 0;
+ break;
+ case XML_STYLE_FAMILY_TEXT_LIST:
+ bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PSEUDO) != 0;
+ break;
+ case XML_STYLE_FAMILY_TEXT_OUTLINE:
+ bIns = !(rSwImport.IsInsertMode() || rSwImport.IsStylesOnlyMode());
+ break;
+ default:
+ bIns = SvXMLStylesContext::InsertStyleFamily( nFamily );
+ break;
+ }
+
+ return bIns;
+}
+
+UniReference < SvXMLImportPropertyMapper > SwXMLStylesContext_Impl::GetImportPropertyMapper(
+ sal_uInt16 nFamily ) const
+{
+ UniReference < SvXMLImportPropertyMapper > xMapper;
+ if( XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily )
+ xMapper = ((SvXMLImport *)&GetImport())->GetTextImport()
+ ->GetFrameImportPropertySetMapper();
+ else
+ xMapper = SvXMLStylesContext::GetImportPropertyMapper( nFamily );
+
+ return xMapper;
+}
+
+Reference < XNameContainer > SwXMLStylesContext_Impl::GetStylesContainer(
+ sal_uInt16 nFamily ) const
+{
+ Reference < XNameContainer > xStyles;
+ if( XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily )
+ xStyles = ((SvXMLImport *)&GetImport())->GetTextImport()->GetFrameStyles();
+ else
+ xStyles = SvXMLStylesContext::GetStylesContainer( nFamily );
+
+ return xStyles;
+}
+
+OUString SwXMLStylesContext_Impl::GetServiceName( sal_uInt16 nFamily ) const
+{
+ String sServiceName;
+ if( XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily )
+ sServiceName = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.FrameStyle") );
+ else
+ sServiceName = SvXMLStylesContext::GetServiceName( nFamily );
+
+ return sServiceName;
+}
+#endif
+
+#ifdef XML_CORE_API
+void SwXMLStylesContext_Impl::CopyStylesToDoc()
+{
+ SwXMLImport& rSwImport = GetSwImport();
+ SwDoc& rDoc = rSwImport.GetDoc();
+ SvI18NMap& rI18NMap = rSwImport.GetI18NMap();
+ sal_Bool bInsertMode = rSwImport.IsInsertMode();
+ sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask();
+
+ // The following families are of interest for pass 1
+ sal_uInt16 nFamilies = nStyleFamilyMask &
+ ( SFX_STYLE_FAMILY_FRAME|SFX_STYLE_FAMILY_PARA|
+ SFX_STYLE_FAMILY_CHAR );
+
+ // pass 1: create text, paragraph and frame styles
+ sal_uInt16 nCount = GetStyleCount();
+ for( sal_uInt16 i=0; i<nCount; i++ )
+ {
+ SwXMLItemSetStyleContext_Impl *pStyle = GetSwStyle( i );
+ if( !pStyle )
+ {
+ continue;
+ }
+
+ sal_uInt16 eFamily = pStyle->GetFamily();
+ if( !(nFamilies & eFamily) )
+ {
+ pStyle->SetValid( sal_False );
+ continue;
+ }
+
+ const OUString& rName = pStyle->GetName();
+ if( 0 == rName.getLength() )
+ {
+ pStyle->SetValid( sal_False );
+ continue;
+ }
+ OUString sName =
+ SwXStyleFamilies::GetUIName( rName, (SfxStyleFamily)eFamily );
+
+// sal_uInt16 nPoolId = pStyle->GetPoolId();
+
+ sal_Bool bNewFmt = sal_False;
+ SwFmt *pFmt = FindFmtByName( sName, eFamily );
+ if( !pFmt )
+ {
+ // it is a new format
+ SwGetPoolIdFromName eNameType;
+ if( eFamily & SFX_STYLE_FAMILY_CHAR )
+ eNameType = GET_POOLID_CHRFMT;
+ else if( eFamily & SFX_STYLE_FAMILY_FRAME )
+ eNameType = GET_POOLID_FRMFMT;
+ else
+ eNameType = GET_POOLID_TXTCOLL;
+
+ sal_uInt16 nPoolId = rDoc.GetPoolId( sName, eNameType );
+ bNewFmt = sal_True;
+// sal_Bool bIsUserDefined = (nPoolId & USER_FMT) != 0;
+ sal_Bool bIsUserDefined = nPoolId == USHRT_MAX;
+#if 0
+ if( !bIsUserDefined )
+ {
+ bIsUserDefined = !lcl_xmlfmt_isValidPoolId( nPoolId, eFamily );
+ if( bIsUserDefined )
+ {
+ // If the pool id is invalid create a user style
+ nPoolId |= (USHRT_MAX &
+ ~(COLL_GET_RANGE_BITS + POOLGRP_NOCOLLID));
+ }
+ }
+ else
+ {
+ // The style is not a pool style, but maybe there is
+ // a pool style with this name now?
+ SwGetPoolIdFromName eNameType;
+ if( eFamily & SFX_STYLE_FAMILY_CHAR )
+ eNameType = GET_POOLID_CHRFMT;
+ else if( eFamily & SFX_STYLE_FAMILY_FRAME )
+ eNameType = GET_POOLID_FRMFMT;
+ else
+ eNameType = GET_POOLID_TXTCOLL;
+ sal_uInt16 nId = rDoc.GetPoolId( rName, eNameType );
+ if( nId != USHRT_MAX )
+ {
+ if( FindByPoolId( nId ) )
+ {
+ // There is a style with the new pool id, too.
+ // This means, that the user style will be ignored.
+ continue;
+ }
+ else
+ {
+ bIsUserDefined = sal_False;
+ nPoolId = nId;
+ }
+ }
+ }
+#endif
+
+ if( bIsUserDefined )
+ {
+ if( eFamily & SFX_STYLE_FAMILY_CHAR )
+ {
+ pFmt = rDoc.MakeCharFmt( rName, NULL );
+ pFmt->SetAuto( sal_False );
+ }
+ else if( eFamily & SFX_STYLE_FAMILY_FRAME )
+ {
+ pFmt = rDoc.MakeFrmFmt( rName, NULL );
+ pFmt->SetAuto( sal_False );
+ }
+ else if( pStyle->HasConditions() )
+ {
+ SwTxtFmtColl* pDer = (*rDoc.GetTxtFmtColls())[ 0 ];
+ pFmt = rDoc.MakeCondTxtFmtColl( rName, pDer );
+ }
+ else
+ {
+ SwTxtFmtColl* pDer = (*rDoc.GetTxtFmtColls())[ 0 ];
+ pFmt = rDoc.MakeTxtFmtColl( rName, pDer );
+ }
+
+// pFmt->SetPoolFmtId( nPoolId );
+// if( pStyle->GetHelpFile().getLength() )
+// pFmt->SetPoolHlpFileId
+// ( (sal_Int8) rDoc.SetDocPattern(
+// pStyle->GetHelpFile() ) );
+// pFmt->SetPoolHelpId( (sal_uInt16)pStyle->GetHelpId() );
+ }
+ else
+ {
+ if( eFamily & SFX_STYLE_FAMILY_CHAR )
+ {
+ sal_uInt16 nStyleCnt = rDoc.GetCharFmts()->Count();
+ pFmt = rDoc.GetCharFmtFromPool( nPoolId );
+ bNewFmt = nStyleCnt != rDoc.GetCharFmts()->Count();
+ }
+ else if( eFamily & SFX_STYLE_FAMILY_FRAME )
+ {
+ sal_uInt16 nStyleCnt = rDoc.GetFrmFmts()->Count();
+ pFmt = rDoc.GetFrmFmtFromPool( nPoolId );
+ bNewFmt = nStyleCnt != rDoc.GetFrmFmts()->Count();
+ }
+ else
+ {
+ sal_uInt16 nStyleCnt = rDoc.GetTxtFmtColls()->Count();
+ pFmt = rDoc.GetTxtCollFromPool( nPoolId );
+ bNewFmt = nStyleCnt != rDoc.GetTxtFmtColls()->Count();
+ }
+
+ // If the name of the pool style has been changed, add
+ // a i18n map entry.
+ if( String(rName) != pFmt->GetName() )
+ rI18NMap.Add( eFamily, pStyle->GetName(), pFmt->GetName() );
+ }
+ }
+#if 0
+ else if( (nPoolId & USER_FMT) != 0 )
+ {
+ // If a pool style has been renamed it may have the same
+ // name a a user style. If this is the case, the user style
+ // will be ignored.
+ sal_uInt16 nId = pFmt->GetPoolFmtId();
+ SwXMLItemSetStyleContext_Impl *pTmp;
+ if( nId != nPoolId && (nId & USER_FMT) == 0 &&
+ (pTmp = FindByPoolId( nPoolId )) != 0 &&
+ pTmp->GetFmt() == pFmt )
+ {
+ pStyle->SetValid( sal_False );
+ continue;
+ }
+ }
+#endif
+
+ pStyle->SetFmt( pFmt );
+
+ if( !bInsertMode || bNewFmt )
+ {
+ if( pStyle->GetItemSet() )
+ {
+ pFmt->ResetAllAttr(); // delete default attributes
+
+ ((SwAttrSet&) pFmt->GetAttrSet()).Put( *pStyle->GetItemSet() );
+ }
+ SwTxtFmtColl* pColl = pStyle->GetColl();
+ if( pColl )
+ {
+ ((SwAttrSet&) pColl->GetAttrSet()).SetModifyAtAttr( pColl );
+ }
+ pFmt->SetAutoUpdateFmt( pStyle->IsAutoUpdate() );
+ }
+ else
+ {
+ pStyle->SetValid( sal_False );
+ }
+ }
+
+ // pass 2: connect parent/next styles and create list styles
+ for( i=0; i<nCount; i++ )
+ {
+ SwXMLItemSetStyleContext_Impl *pStyle = GetSwStyle( i );
+ if( !pStyle )
+ {
+ if( (nStyleFamilyMask & SFX_STYLE_FAMILY_PSEUDO) != 0 )
+ {
+ SwXMLListStyleContext *pListStyle = GetSwListStyle( i );
+ if( pListStyle )
+ pListStyle->InsertNumRule( sal_False );
+ }
+ continue;
+ }
+ else if( !pStyle->IsValid() )
+ continue;
+
+ sal_uInt16 eFamily = pStyle->GetFamily();
+ if( (nFamilies & eFamily) != 0 )
+ {
+ pStyle->ConnectParent();
+ pStyle->ConnectFollow();
+
+ // The format has been changed
+ SwFmtChg aHint( pStyle->GetFmt() );
+ pStyle->GetFmt()->Modify( &aHint, &aHint );
+ }
+ }
+
+ // pass 3: connect conditions and list styles
+ for( i=0; i<nCount; i++ )
+ {
+ SwXMLItemSetStyleContext_Impl *pStyle = GetSwStyle( i );
+ if( pStyle && pStyle->IsValid() &&
+ (nFamilies & pStyle->GetFamily()) != 0 )
+ {
+ pStyle->ConnectListStyle();
+ if( pStyle->HasConditions() )
+ pStyle->ConnectConditions();
+ }
+ }
+}
+
+void SwXMLStylesContext_Impl::CopyAutoStylesToDoc()
+{
+ // pass 1: create list styles
+ sal_uInt16 nCount = GetStyleCount();
+ if( (GetSwImport().GetStyleFamilyMask() & SFX_STYLE_FAMILY_PSEUDO) != 0 )
+ {
+ for( sal_uInt16 i=0; i<nCount; i++ )
+ {
+ SwXMLListStyleContext *pListStyle = GetSwListStyle( i );
+ if( pListStyle && !pListStyle->IsOutline() )
+ pListStyle->InsertNumRule( sal_True );
+ }
+ }
+
+ // pass 3: connect list styles
+ if( (GetSwImport().GetStyleFamilyMask() & SFX_STYLE_FAMILY_PARA) != 0 )
+ {
+ for( sal_uInt16 i=0; i<nCount; i++ )
+ {
+ SwXMLItemSetStyleContext_Impl *pStyle = GetSwStyle( i );
+ if( pStyle && SFX_STYLE_FAMILY_PARA == pStyle->GetFamily() )
+ {
+ pStyle->ConnectAutoListStyle();
+ }
+ }
+ }
+}
+#endif
+
+// ---------------------------------------------------------------------
+
+SvXMLImportContext *SwXMLImport::CreateStylesContext(
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ sal_Bool bAuto )
+{
+ SvXMLImportContext *pContext =
+ new SwXMLStylesContext_Impl( *this, XML_NAMESPACE_OFFICE, rLocalName,
+ xAttrList );
+ if( bAuto )
+ xAutoStyles = pContext;
+ else
+ xStyles = pContext;
+
+ return pContext;
+}
+
+void SwXMLImport::InsertStyles()
+{
+ sal_Bool bStylesValid = xStyles.Is();
+ bAutoStylesValid = xAutoStyles.Is();
+
+ if( bStylesValid )
+#ifdef XML_CORE_API
+ ((SwXMLStylesContext_Impl *)&xStyles)->CopyStylesToDoc();
+#else
+ ((SwXMLStylesContext_Impl *)&xStyles)->CopyStylesToDoc(
+ !IsInsertMode() );
+#endif
+ xStyles = 0;
+
+ if( bAutoStylesValid )
+#ifdef XML_CORE_API
+ ((SwXMLStylesContext_Impl *)&xAutoStyles)->CopyAutoStylesToDoc();
+#else
+ GetTextImport()->SetAutoStyles( (SwXMLStylesContext_Impl *)&xAutoStyles );
+#endif
+ else
+ xAutoStyles = 0;
+}
+
+sal_Bool SwXMLImport::FindAutomaticStyle(
+#ifdef XML_CORE_API
+ SfxStyleFamily eFamily,
+ sal_uInt16 nSubFamily,
+#else
+ sal_uInt16 nFamily,
+#endif
+ const OUString& rName,
+ const SfxItemSet **ppItemSet,
+ OUString *pParent ) const
+{
+ const SwXMLItemSetStyleContext_Impl *pStyle = 0;
+ if( bAutoStylesValid && xAutoStyles.Is() )
+ {
+#ifdef XML_CORE_API
+ pStyle = PTR_CAST( SwXMLItemSetStyleContext_Impl,
+ ((SwXMLStylesContext_Impl *)&xAutoStyles)->
+ FindStyleChildContext( eFamily, nSubFamily, rName,
+ sal_True ) );
+#else
+ pStyle = PTR_CAST( SwXMLItemSetStyleContext_Impl,
+ ((SwXMLStylesContext_Impl *)&xAutoStyles)->
+ FindStyleChildContext( nFamily, rName,
+ sal_True ) );
+#endif
+ if( pStyle )
+ {
+ if( ppItemSet )
+ (*ppItemSet) = pStyle->GetItemSet();
+ if( pParent )
+ *pParent = pStyle->GetParent();
+ }
+ }
+
+ return pStyle != 0;
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlfmt.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.42 2000/09/18 16:05:05 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.41 2000/09/18 11:58:02 mib
+ text frames/graphics import and export continued
+
+ Revision 1.40 2000/08/31 14:26:32 mib
+ conditional styles
+
+ Revision 1.39 2000/08/24 11:16:41 mib
+ text import continued
+
+ Revision 1.38 2000/08/10 10:22:15 mib
+ #74404#: Adeptions to new XSL/XLink working draft
+
+ Revision 1.37 2000/07/27 08:06:34 mib
+ text import continued
+
+ Revision 1.36 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.35 2000/07/07 13:58:36 mib
+ text styles using StarOffice API
+
+ Revision 1.34 2000/06/26 08:31:15 mib
+ removed SfxStyleFamily
+
+ Revision 1.33 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.32 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.31 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.30 2000/03/06 10:46:10 mib
+ #72585#: toInt32
+
+ Revision 1.29 2000/02/18 09:20:12 mib
+ #70271#: initialization of pContext was missing
+
+ Revision 1.28 2000/02/17 14:40:30 mib
+ #70271#: XML table import
+
+ Revision 1.26 2000/01/27 08:59:02 mib
+ #70271#: outline numbering
+
+ Revision 1.25 2000/01/20 10:03:15 mib
+ #70271#: Lists reworked
+
+ Revision 1.24 2000/01/06 15:08:27 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+ Revision 1.23 1999/12/13 08:28:25 mib
+ #70271#: Support for element items added
+
+ Revision 1.22 1999/12/06 11:41:33 mib
+ #70258#: Container item for unkown attributes
+
+ Revision 1.21 1999/11/26 11:13:57 mib
+ loading of styles only and insert mode
+
+ Revision 1.20 1999/11/22 15:52:34 os
+ headers added
+
+ Revision 1.19 1999/11/17 20:08:49 nn
+ document language
+
+ Revision 1.18 1999/11/12 14:50:28 mib
+ meta import and export reactivated
+
+ Revision 1.17 1999/11/12 11:43:03 mib
+ using item mapper, part iii
+
+ Revision 1.16 1999/11/10 15:08:09 mib
+ Import now uses XMLItemMapper
+
+ Revision 1.15 1999/11/09 15:40:08 mib
+ Using XMLItemMapper for export
+
+ Revision 1.14 1999/11/05 19:44:11 nn
+ handle office:meta
+
+ Revision 1.13 1999/11/01 11:38:50 mib
+ List style import
+
+ Revision 1.12 1999/10/25 10:41:48 mib
+ Using new OUString ASCII methods
+
+ Revision 1.11 1999/10/22 09:49:16 mib
+ List style export
+
+ Revision 1.10 1999/10/15 12:37:05 mib
+ integrated SvXMLStyle into SvXMLStyleContext
+
+ Revision 1.9 1999/10/08 11:47:45 mib
+ moved some file to SVTOOLS/SVX
+
+ Revision 1.8 1999/10/01 13:02:51 mib
+ no comparisons between OUString and char* any longer
+
+ Revision 1.7 1999/09/28 10:47:58 mib
+ char fmts again
+
+ Revision 1.6 1999/09/28 08:31:15 mib
+ char fmts, hints
+
+ Revision 1.5 1999/09/23 11:53:58 mib
+ i18n, token maps and hard paragraph attributes
+
+ Revision 1.4 1999/09/22 11:56:57 mib
+ string -> wstring
+
+ Revision 1.3 1999/08/19 12:57:42 MIB
+ attribute import added
+
+
+ Rev 1.2 19 Aug 1999 14:57:42 MIB
+ attribute import added
+
+ Rev 1.1 18 Aug 1999 17:03:36 MIB
+ Style import
+
+ Rev 1.0 13 Aug 1999 16:18:10 MIB
+ Initial revision.
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlfmte.cxx b/sw/source/filter/xml/xmlfmte.cxx
new file mode 100644
index 000000000000..ebac28eab0ff
--- /dev/null
+++ b/sw/source/filter/xml/xmlfmte.cxx
@@ -0,0 +1,1144 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlfmte.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef _HINTS_HXX //autogen wg. SwFmtChg
+#include <hints.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXTDOCUMENT_HPP_
+#include <com/sun/star/text/XTextDocument.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_
+#include <com/sun/star/text/XText.hpp>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#ifndef _SVSTDARR_STRINGSSORT_DECL
+#define _SVSTDARR_STRINGSSORT
+#include <svtools/svstdarr.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+
+#ifndef _XMLOFF_ATTRLIST_HXX
+#include <xmloff/attrlist.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLASTPL_HXX
+#include <xmloff/xmlastpl.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLITMPR_HXX
+#include <xmloff/xmlexpit.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+
+#ifndef _XMLOFF_TXTSTYLE_HXX
+#include <xmloff/txtstyle.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLPROPERTYSETMAPPER_HXX
+#include <xmloff/xmlprmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLPROPMAPPINGTYPES_HXX
+#include <xmloff/maptype.hxx>
+#endif
+#ifndef _XMLOFF_XMLTYPES_HXX
+#include <xmloff/xmltypes.hxx>
+#endif
+#ifndef _XMLOFF_TXTPARAE_HXX
+#include <xmloff/txtparae.hxx>
+#endif
+#ifndef _XMLOFF_TXTPRMAP_HXX
+#include <xmloff/txtprmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLEXPPR_HXX
+#include <xmloff/xmlexppr.hxx>
+#endif
+#ifndef _XMLOFF_XMLASTPLP_HXX
+#include <xmloff/xmlaustp.hxx>
+#endif
+#ifndef _XMLOFF_FAMILIES_HXX_
+#include <xmloff/families.hxx>
+#endif
+
+#ifndef _FORMAT_HXX //autogen wg. SwFmt
+#include <format.hxx>
+#endif
+#ifndef _FMTCOL_HXX //autogen wg. SwTxtFmtColl
+#include <fmtcol.hxx>
+#endif
+#ifndef _CHARFMT_HXX //autogen wg. SwCharFmt
+#include <charfmt.hxx>
+#endif
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#include "docary.hxx"
+#ifndef _NDTXT_HXX //autogen wg. SwTxtNode
+#include <ndtxt.hxx>
+#endif
+#ifndef _SECTION_HXX //autogen wg. SwSection
+#include <section.hxx>
+#endif
+#ifndef _PAM_HXX //autogen wg. SwPaM
+#include <pam.hxx>
+#endif
+#ifndef _TXATBASE_HXX
+#include <txatbase.hxx>
+#endif
+#ifndef _XMLEXP_HXX
+#include "xmlexp.hxx"
+#endif
+#ifndef _XMLECTXT_HXX
+#include "xmlectxt.hxx"
+#endif
+#ifndef _XMLFMTE_HXX
+#include "xmlfmte.hxx"
+#endif
+#ifndef _XMLTEXTE_HXX
+#include "xmltexte.hxx"
+#endif
+
+#ifndef _SWDOCSH_HXX
+#include "docsh.hxx"
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef _XMLOFF_XMLUCONV_HXX
+#include <xmloff/xmluconv.hxx>
+#endif
+#ifndef XML_CORE_API
+#ifndef _XMLOFF_XMLTEXTLISTAUTOSTYLEPOOL_HXX
+#include <xmloff/XMLTextListAutoStylePool.hxx>
+#endif
+#endif
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXTFIELD_HPP_
+#include <com/sun/star/text/XTextField.hpp>
+#endif
+
+#ifndef _UNOFIELD_HXX
+#include <unofield.hxx>
+#endif
+
+#ifndef _XMLOFF_TXTFLDE_HXX
+#include <xmloff/txtflde.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNUMFE_HXX
+#include <xmloff/xmlnumfe.hxx>
+#endif
+
+#ifndef _UNOSTYLE_HXX
+#include "unostyle.hxx"
+#endif
+
+
+using namespace rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::com::sun::star::style;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::text;
+
+void SwXMLExport::ExportFmt( const SwFmt& rFmt, const char *pFamily )
+{
+ // <style:style ...>
+ CheckAttrList();
+
+ // style:family="..."
+ const sal_Char *pStr = pFamily;
+#ifdef XML_CORE_API
+ SfxStyleFamily eFamily = SFX_STYLE_FAMILY_ALL;
+ switch( rFmt.Which() )
+ {
+ case RES_CHRFMT:
+ if( !pStr )
+ pStr = sXML_text;
+ eFamily = SFX_STYLE_FAMILY_CHAR;
+ break;
+ case RES_FRMFMT:
+ if( !pStr )
+ pStr = sXML_frame;
+ eFamily = SFX_STYLE_FAMILY_FRAME;
+ break;
+ case RES_TXTFMTCOLL:
+ case RES_CONDTXTFMTCOLL:
+ if( !pStr )
+ pStr = sXML_paragraph;
+ eFamily = SFX_STYLE_FAMILY_PARA;
+ break;
+ case RES_FLYFRMFMT:
+ case RES_GRFFMTCOLL:
+ DBG_ASSERT( pStr, "SwXMLExport::ExportFmt: which id unexpected" );
+ break;
+ default:
+ DBG_ASSERT( pStr, "SwXMLExport::ExportFmt: which id unknown" );
+ break;
+ }
+ // style:name="..."
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_name,
+ SwXStyleFamilies::GetProgrammaticName( rFmt.GetName(), eFamily ) );
+#else
+ DBG_ASSERT( RES_FRMFMT==rFmt.Which(), "frame format expected" );
+ if( RES_FRMFMT != rFmt.Which() )
+ return;
+ DBG_ASSERT( pStr, "family must be specified" );
+ // style:name="..."
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_name, rFmt.GetName() );
+#endif
+
+ if( pStr )
+ AddAttributeASCII( XML_NAMESPACE_STYLE, sXML_family, pStr );
+
+#ifdef XML_CORE_API
+ // register name to prevent it from beeing reused as an automtic
+ // style name
+ if( SFX_STYLE_FAMILY_ALL != eFamily )
+ pItemSetAutoStylePool->RegisterName( eFamily, rFmt.GetName() );
+#endif
+
+ // style:parent-style-name="..." (if its not the default only)
+ const SwFmt* pParent = rFmt.DerivedFrom();
+ // Parent-Namen nur uebernehmen, wenn kein Default
+ if( pParent && !pParent->IsDefault() )
+ {
+#ifdef XML_CORE_API
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_parent_style_name,
+ SwXStyleFamilies::GetProgrammaticName( pParent->GetName(),
+ eFamily ) );
+#else
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_parent_style_name,
+ pParent->GetName() );
+#endif
+ }
+
+#ifdef XML_CORE_API
+ // style:next-style-name="..."
+ // (if its not the default and not the same style only)
+ if( RES_TXTFMTCOLL == rFmt.Which() || RES_CONDTXTFMTCOLL == rFmt.Which() )
+ {
+ const SwTxtFmtColl& rFollow =
+ ((const SwTxtFmtColl&)rFmt).GetNextTxtFmtColl();
+ if( !rFollow.IsDefault() && &rFollow != &rFmt )
+ {
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_next_style_name,
+ SwXStyleFamilies::GetProgrammaticName( rFollow.GetName(),
+ eFamily ) );
+ }
+ }
+
+#if 0
+ // style:pool-id="..."
+ if( USHRT_MAX != rFmt.GetPoolFmtId() )
+ {
+ OUStringBuffer sTmp( 5L );
+ sTmp.append( (sal_Int32)rFmt.GetPoolFmtId() );
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_pool_id,
+ sTmp.makeStringAndClear() );
+ }
+
+ // style:help-file-name="..." and style:help-id="..."
+ if( UCHAR_MAX != rFmt.GetPoolHlpFileId() )
+ {
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_help_file_name,
+ *pDoc->GetDocPattern( rFmt.GetPoolHlpFileId() ) );
+ OUStringBuffer sTmp( 5L );
+ sTmp.append( (sal_Int32)rFmt.GetPoolHelpId() );
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_help_id,
+ sTmp.makeStringAndClear() );
+ }
+#endif
+
+ // style:auto-update="..."
+ if( rFmt.IsAutoUpdateFmt() )
+ {
+ AddAttributeASCII( XML_NAMESPACE_STYLE, sXML_auto_update, sXML_true );
+ }
+
+ // text:list-style-name
+ if( RES_TXTFMTCOLL == rFmt.Which() || RES_CONDTXTFMTCOLL == rFmt.Which() )
+ {
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rFmt.GetAttrSet().GetItemState( RES_PARATR_NUMRULE,
+ sal_False, &pItem ) )
+ {
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_list_style_name,
+ SwXStyleFamilies::GetProgrammaticName(
+ ((const SwNumRuleItem *)pItem)->GetValue(),
+ SFX_STYLE_FAMILY_PSEUDO ) );
+ }
+ }
+#else
+ ASSERT( USHRT_MAX == rFmt.GetPoolFmtId(), "pool ids arent'supported" );
+ ASSERT( UCHAR_MAX == rFmt.GetPoolHlpFileId(), "help ids aren't supported" );
+#endif
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE, sXML_style,
+ sal_True, sal_True );
+
+#ifdef XML_CORE_API
+ switch( rFmt.Which() )
+ {
+ case RES_TXTFMTCOLL:
+ case RES_CONDTXTFMTCOLL:
+ case RES_CHRFMT:
+ GetParaItemMapper().exportXML( GetDocHandler(),
+ rFmt.GetAttrSet(),
+ GetTwipUnitConverter(),
+ GetNamespaceMap(),
+ XML_EXPORT_FLAG_IGN_WS );
+ break;
+ case RES_FRMFMT:
+ {
+#endif
+ SvXMLItemMapEntriesRef xItemMap;
+ if( sXML_table == pStr )
+ xItemMap = xTableItemMap;
+ else if( sXML_table_row == pStr )
+ xItemMap = xTableRowItemMap;
+ else if( sXML_table_cell == pStr )
+ xItemMap = xTableCellItemMap;
+
+ if( xItemMap.Is() )
+ {
+ SvXMLExportItemMapper& rItemMapper = GetTableItemMapper();
+ rItemMapper.setMapEntries( xItemMap );
+
+ GetTableItemMapper().exportXML( GetDocHandler(),
+ rFmt.GetAttrSet(),
+ GetTwipUnitConverter(),
+ GetNamespaceMap(),
+ XML_EXPORT_FLAG_IGN_WS );
+ }
+#ifdef XML_CORE_API
+ }
+ break;
+ default:
+ DBG_ASSERT( !this,
+ "SwXMLExport::ExportFmt: attribute export missing" );
+ break;
+ }
+
+ if( RES_CONDTXTFMTCOLL == rFmt.Which() )
+ {
+ const SwFmtCollConditions& rConditions =
+ ((SwConditionTxtFmtColl&)rFmt). GetCondColls();
+ for( sal_uInt16 i=0; i < rConditions.Count(); i++ )
+ {
+ const SwCollCondition& rCond = *rConditions[i];
+
+ const sal_Char *pFunc = 0;
+ OUStringBuffer sBuffer( 20 );
+ switch( rCond.GetCondition() )
+ {
+ case PARA_IN_LIST:
+ pFunc = sXML_list_level;
+ sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
+ break;
+ case PARA_IN_OUTLINE:
+ pFunc = sXML_outline_level;
+ sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
+ break;
+ case PARA_IN_FRAME:
+ pFunc = sXML_text_box;
+ break;
+ case PARA_IN_TABLEHEAD:
+ pFunc = sXML_table_header;
+ break;
+ case PARA_IN_TABLEBODY:
+ pFunc = sXML_table;
+ break;
+ case PARA_IN_SECTION:
+ pFunc = sXML_section;
+ break;
+ case PARA_IN_FOOTENOTE:
+ pFunc = sXML_footnote;
+ break;
+ case PARA_IN_FOOTER:
+ pFunc = sXML_footer;
+ break;
+ case PARA_IN_HEADER:
+ pFunc = sXML_header;
+ break;
+ case PARA_IN_ENDNOTE:
+ pFunc = sXML_endnote;
+ break;
+ }
+ OUString sVal( sBuffer.makeStringAndClear() );
+
+ DBG_ASSERT( pFunc, "SwXMLExport::ExportFmt: unknon condition" );
+ if( pFunc )
+ {
+ sBuffer.appendAscii( pFunc );
+ sBuffer.append( (sal_Unicode)'(' );
+ sBuffer.append( (sal_Unicode)')' );
+ if( sVal.getLength() )
+ {
+ sBuffer.append( (sal_Unicode)'=' );
+ sBuffer.append( sVal );
+ }
+
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_condition,
+ sBuffer.makeStringAndClear() );
+ const String& rName =
+ SwXStyleFamilies::GetProgrammaticName(
+ rCond.GetTxtFmtColl()->GetName(),
+ SFX_STYLE_FAMILY_PARA );
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_apply_style_name,
+ rName );
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE,
+ sXML_map, sal_True, sal_True );
+ }
+ }
+ }
+#endif
+ }
+}
+
+#ifndef XML_CORE_API
+
+SwXMLTextParagraphExport::SwXMLTextParagraphExport(
+ SwXMLExport& rExp,
+ SvXMLAutoStylePoolP& rAutoStylePool ) :
+ XMLTextParagraphExport( rExp, rAutoStylePool ),
+ sTextTable( RTL_CONSTASCII_USTRINGPARAM( "TextTable" ) )
+{
+}
+
+SwXMLTextParagraphExport::~SwXMLTextParagraphExport()
+{
+}
+
+void SwXMLTextParagraphExport::exportStyleContent(
+ const Reference< XStyle > & rStyle )
+{
+
+ const SwXStyle* pStyle = 0;
+ Reference<XUnoTunnel> xStyleTunnel( rStyle, UNO_QUERY);
+ if( xStyleTunnel.is() )
+ {
+ pStyle = (SwXStyle*)xStyleTunnel->getSomething(
+ SwXStyle::getUnoTunnelId() );
+ }
+ if( pStyle && SFX_STYLE_FAMILY_PARA == pStyle->GetFamily() )
+ {
+ const SwDoc& rDoc = ((SwXMLExport&)GetExport()).GetDoc();
+ const SwTxtFmtColl *pColl =
+ rDoc.FindTxtFmtCollByName( SwXStyleFamilies::GetUIName( pStyle->GetStyleName(), SFX_STYLE_FAMILY_PARA ) );
+ ASSERT( pColl, "There is the text collection?" );
+ if( pColl && RES_CONDTXTFMTCOLL == pColl->Which() )
+ {
+ const SwFmtCollConditions& rConditions =
+ ((const SwConditionTxtFmtColl *)pColl)->GetCondColls();
+ for( sal_uInt16 i=0; i < rConditions.Count(); i++ )
+ {
+ const SwCollCondition& rCond = *rConditions[i];
+
+ const sal_Char *pFunc = 0;
+ OUStringBuffer sBuffer( 20 );
+ switch( rCond.GetCondition() )
+ {
+ case PARA_IN_LIST:
+ pFunc = sXML_list_level;
+ sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
+ break;
+ case PARA_IN_OUTLINE:
+ pFunc = sXML_outline_level;
+ sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
+ break;
+ case PARA_IN_FRAME:
+ pFunc = sXML_text_box;
+ break;
+ case PARA_IN_TABLEHEAD:
+ pFunc = sXML_table_header;
+ break;
+ case PARA_IN_TABLEBODY:
+ pFunc = sXML_table;
+ break;
+ case PARA_IN_SECTION:
+ pFunc = sXML_section;
+ break;
+ case PARA_IN_FOOTENOTE:
+ pFunc = sXML_footnote;
+ break;
+ case PARA_IN_FOOTER:
+ pFunc = sXML_footer;
+ break;
+ case PARA_IN_HEADER:
+ pFunc = sXML_header;
+ break;
+ case PARA_IN_ENDNOTE:
+ pFunc = sXML_endnote;
+ break;
+ }
+ OUString sVal( sBuffer.makeStringAndClear() );
+
+ DBG_ASSERT( pFunc, "SwXMLExport::ExportFmt: unknon condition" );
+ if( pFunc )
+ {
+ sBuffer.appendAscii( pFunc );
+ sBuffer.append( (sal_Unicode)'(' );
+ sBuffer.append( (sal_Unicode)')' );
+ if( sVal.getLength() )
+ {
+ sBuffer.append( (sal_Unicode)'=' );
+ sBuffer.append( sVal );
+ }
+
+ GetExport().AddAttribute( XML_NAMESPACE_STYLE,
+ sXML_condition,
+ sBuffer.makeStringAndClear() );
+ const String& rName =
+ SwXStyleFamilies::GetProgrammaticName(
+ rCond.GetTxtFmtColl()->GetName(),
+ SFX_STYLE_FAMILY_PARA );
+ GetExport().AddAttribute( XML_NAMESPACE_STYLE,
+ sXML_apply_style_name, rName );
+ SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
+ sXML_map, sal_True, sal_True );
+ }
+ }
+ }
+ }
+}
+
+#endif
+
+void SwXMLExport::_ExportStyles( sal_Bool bUsed )
+{
+#ifdef XML_CORE_API
+ // text collections
+ SvStringsSort *pCollNames = bUsed ? new SvStringsSort : 0;
+ sal_uInt16 nCount = pDoc->GetTxtFmtColls()->Count();
+ sal_uInt16 i;
+ for( i=0; i<nCount; i++ )
+ {
+ const SwTxtFmtColl *pColl = (*pDoc->GetTxtFmtColls())[i];
+ if( ( !bUsed || pDoc->IsUsed( *pColl ) ) && !pColl->IsDefault() )
+ {
+ ExportFmt( *pColl );
+ if( pCollNames )
+ pCollNames->Insert( (String *)&pColl->GetName() );
+ }
+ }
+ if( bUsed )
+ {
+ // Even if some next styles have not been used, they have to be
+ // exported.
+ for( i = 0; i < nCount; i++ )
+ {
+ const SwTxtFmtColl* pColl = (*pDoc->GetTxtFmtColls())[ i ];
+ if( pColl != &pColl->GetNextTxtFmtColl() &&
+ !pCollNames->Seek_Entry(
+ (String *)&pColl->GetNextTxtFmtColl().GetName() ) )
+ {
+ ExportFmt( pColl->GetNextTxtFmtColl() );
+ pCollNames->Insert(
+ (String *)&pColl->GetNextTxtFmtColl().GetName() );
+ }
+ }
+ delete pCollNames;
+ }
+
+ // char fmts
+ nCount = pDoc->GetCharFmts()->Count();
+ for( i=0; i<nCount; i++ )
+ {
+ const SwCharFmt *pFmt = (*pDoc->GetCharFmts())[i];
+ if( ( !bUsed || pDoc->IsUsed( *pFmt ) ) && !pFmt->IsDefault() )
+ ExportFmt( *pFmt );
+ }
+
+ // num rules
+ ExportNumRules( sal_False, bUsed );
+#else
+ GetTextParagraphExport()->exportTextStyles( bUsed );
+#endif
+}
+
+// ---------------------------------------------------------------------
+
+#ifdef XML_CORE_API
+void SwXMLExport::AddTextAutoStyle( const SfxPoolItem& rItem )
+{
+ SfxItemSet aItemSet( pDoc->GetAttrPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END - 1, 0 );
+ aItemSet.Put( rItem );
+ pItemSetAutoStylePool->Add( SFX_STYLE_FAMILY_CHAR, aItemSet );
+}
+
+void SwXMLExport::AddParaAutoStyle( const OUString& rParent,
+ const SfxItemSet& rItemSet )
+{
+ pItemSetAutoStylePool->Add( SFX_STYLE_FAMILY_PARA,
+ SwXStyleFamilies::GetProgrammaticName(rParent, SFX_STYLE_FAMILY_PARA ),
+ rItemSet );
+}
+
+OUString SwXMLExport::FindTextAutoStyle( const SfxPoolItem& rItem )
+{
+ SfxItemSet aItemSet( pDoc->GetAttrPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END - 1, 0 );
+ aItemSet.Put( rItem );
+ return pItemSetAutoStylePool->Find( SFX_STYLE_FAMILY_CHAR, aItemSet );
+}
+
+OUString SwXMLExport::FindParaAutoStyle( const OUString& rParent,
+ const SfxItemSet& rItemSet )
+{
+ return pItemSetAutoStylePool->Find(
+ SFX_STYLE_FAMILY_PARA,
+ SwXStyleFamilies::GetProgrammaticName(rParent, SFX_STYLE_FAMILY_PARA ),
+ rItemSet );
+}
+
+void SwXMLExport::ExportTxtNodeAutoStyles( const SwTxtNode& rTxtNd,
+ xub_StrLen nStart, xub_StrLen nEnd,
+ sal_Bool bExportWholeNode )
+{
+ const SfxItemSet *pItemSet = rTxtNd.GetpSwAttrSet();
+ if( pItemSet )
+ {
+ const SwFmtColl& rColl = rTxtNd.GetAnyFmtColl();
+ OUString sParent( rColl.GetName() );
+ AddParaAutoStyle( sParent, *pItemSet );
+
+ if( rTxtNd.GetCondFmtColl() &&
+ &rColl != rTxtNd.GetFmtColl() )
+ {
+ const SwFmtColl *pColl = rTxtNd.GetFmtColl();
+ sParent = pColl->GetName();
+ AddParaAutoStyle( sParent, *pItemSet );
+ }
+ }
+
+ xub_StrLen nPos = pCurPaM->GetPoint()->nContent.GetIndex();
+ xub_StrLen nEndPos = rTxtNd.GetTxt().Len();
+ if( pCurPaM->GetPoint()->nNode == pCurPaM->GetMark()->nNode )
+ nEndPos = pCurPaM->GetMark()->nContent.GetIndex();
+
+ const SwpHints *pHints = rTxtNd.GetpSwpHints();
+ sal_uInt16 nHintCount = pHints ? pHints->Count() : 0;
+ sal_uInt16 nHintPos = 0;
+ const SwTxtAttr * pTxtAttr = 0;
+
+ if( nHintCount && nPos > *( pTxtAttr = (*pHints)[0] )->GetStart() )
+ {
+ do
+ {
+ nHintPos++;
+ sal_uInt16 nWhich = pTxtAttr->Which();
+ if( pTxtAttr->GetEnd() &&
+ ( (nWhich >= RES_CHRATR_BEGIN && nWhich < RES_CHRATR_END) ||
+ (nWhich >= RES_UNKNOWNATR_BEGIN &&
+ nWhich < RES_UNKNOWNATR_END) ) )
+ {
+ xub_StrLen nHtEnd = *pTxtAttr->GetEnd(),
+ nHtStt = *pTxtAttr->GetStart();
+ if( (bExportWholeNode || nHtEnd > nPos) &&
+ nHtEnd != nHtStt )
+ {
+ AddTextAutoStyle( pTxtAttr->GetAttr() );
+ }
+ }
+
+ }
+ while( nHintPos < nHintCount &&
+ nPos > *( pTxtAttr = (*pHints)[nHintPos ] )->GetStart() );
+ }
+
+ for( ; nPos < nEndPos; nPos++ )
+ {
+ if( nHintPos < nHintCount && *pTxtAttr->GetStart() == nPos
+ && nPos != nEndPos )
+ {
+ do
+ {
+ sal_uInt16 nWhich = pTxtAttr->Which();
+ if( pTxtAttr->GetEnd() && *pTxtAttr->GetEnd() != nPos &&
+ ( (nWhich >= RES_CHRATR_BEGIN && nWhich < RES_CHRATR_END) ||
+ (nWhich >= RES_UNKNOWNATR_BEGIN &&
+ nWhich < RES_UNKNOWNATR_END) ) )
+ {
+ AddTextAutoStyle( pTxtAttr->GetAttr() );
+ } else if( nWhich == RES_TXTATR_FIELD ) {
+ // text field found: export AutoStyle
+#ifdef XML_CORE_API
+// Reference < text::XTextField > xFld = new SwXTextField(
+// ((const SwFmtFld&)pTxtAttr->GetAttr()), &GetDoc() );
+//
+// GetTextFieldExport().ExportFieldAutoStyle( xFld );
+#endif
+ }
+ }
+ while( ++nHintPos < nHintCount &&
+ nPos == *( pTxtAttr = (*pHints)[nHintPos] )->GetStart() );
+ }
+ }
+}
+
+void SwXMLExport::ExportSectionAutoStyles( const SwSectionNode& rSectNd )
+{
+ SwNode *pStartNd = pDoc->GetNodes()[rSectNd.GetIndex() + 1];
+ SwNode *pEndNd = pDoc->GetNodes()[rSectNd.EndOfSectionIndex() - 1];
+
+ {
+ SwXMLExpContext aContext( *this, *pStartNd, *pEndNd, 0, STRING_LEN );
+ ExportCurPaMAutoStyles();
+ }
+
+ pCurPaM->GetPoint()->nNode = *rSectNd.EndOfSectionNode();
+}
+
+void SwXMLExport::ExportCurPaMAutoStyles( sal_Bool bExportWholePaM )
+{
+ sal_Bool bFirstNode = sal_True;
+ sal_Bool bExportWholeNode = bExportWholePaM;
+
+ while( pCurPaM->GetPoint()->nNode.GetIndex() <
+ pCurPaM->GetMark()->nNode.GetIndex() ||
+ ( pCurPaM->GetPoint()->nNode.GetIndex() ==
+ pCurPaM->GetMark()->nNode.GetIndex() &&
+ pCurPaM->GetPoint()->nContent.GetIndex() <=
+ pCurPaM->GetMark()->nContent.GetIndex() ) )
+ {
+ SwNode *pNd = pCurPaM->GetNode();
+
+ ASSERT( !(pNd->IsGrfNode() || pNd->IsOLENode()),
+ "SwXMLExport::exportCurPaM: grf or OLE node unexpected" );
+ if( pNd->IsTxtNode() )
+ {
+ SwTxtNode* pTxtNd = pNd->GetTxtNode();
+
+ if( !bFirstNode )
+ pCurPaM->GetPoint()->nContent.Assign( pTxtNd, 0 );
+
+ ExportTxtNodeAutoStyles( *pTxtNd, 0, STRING_LEN, bExportWholeNode );
+ }
+ else if( pNd->IsTableNode() )
+ {
+ ExportTableAutoStyles( *pNd->GetTableNode() );
+ }
+ else if( pNd->IsSectionNode() )
+ {
+ ExportSectionAutoStyles( *pNd->GetSectionNode() );
+ }
+ else if( pNd == &pDoc->GetNodes().GetEndOfContent() )
+ break;
+
+ pCurPaM->GetPoint()->nNode++; // next node
+
+ // if not everything should be exported, the WriteAll flag must be
+ // set for all but the first and last node anyway.
+ bExportWholeNode = bExportWholePaM ||
+ pCurPaM->GetPoint()->nNode.GetIndex() !=
+ pCurPaM->GetMark()->nNode.GetIndex();
+ bFirstNode = sal_False;
+ }
+}
+#endif
+
+void SwXMLExport::_ExportAutoStyles()
+{
+#ifdef XML_CORE_API
+ // export all PaMs
+ SwPaM *pPaM = pOrigPaM;
+ sal_Bool bContinue = sal_True;
+ do
+ {
+ // export PaM content
+ ExportCurPaMAutoStyles( bExportWholeDoc );
+
+ bContinue = pPaM->GetNext() != pOrigPaM;
+
+ // the current PaM must be at the start if this loop finishes
+ pPaM = (SwPaM *)pPaM->GetNext();
+ SetCurPaM( *pPaM, bExportWholeDoc, bExportFirstTableOnly );
+
+ } while( bContinue );
+
+ // text collections
+ ((SvXMLAutoStylePool *)pItemSetAutoStylePool)->exportXML( SFX_STYLE_FAMILY_PARA,
+ GetParaItemMapper(),
+ GetDocHandler(),
+ GetTwipUnitConverter(),
+ GetNamespaceMap() );
+
+ // char fmts
+ ((SvXMLAutoStylePool *)pItemSetAutoStylePool)->exportXML( SFX_STYLE_FAMILY_CHAR,
+ GetParaItemMapper(),
+ GetDocHandler(),
+ GetTwipUnitConverter(),
+ GetNamespaceMap() );
+
+ // num rules
+ ExportNumRules( sal_True, sal_False );
+
+ // text field styles
+// GetNumberFormatExport().Export( GetNamespaceMap() );
+
+#else
+ Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
+ Reference < XText > xText = xTextDoc->getText();
+
+ GetTextParagraphExport()->collectFrameBoundToPageAutoStyles();
+ GetTextParagraphExport()->collectTextAutoStyles( xText );
+ GetTextParagraphExport()->exportTextAutoStyles();
+ exportAutoDataStyles();
+
+#endif
+
+}
+
+void SwXMLExport::_ExportMasterStyles()
+{
+}
+
+// ---------------------------------------------------------------------
+
+#ifdef XML_CORE_API
+void SwXMLAutoStylePool::exportXML( SvXMLAttributeList& rAttrList,
+ SfxStyleFamily eFamily, const SfxItemSet& rItemSet,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap ) const
+{
+ if( SFX_STYLE_FAMILY_PARA == eFamily )
+ {
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_PARATR_NUMRULE, sal_False,
+ &pItem ) )
+ {
+ OUString sName( rNamespaceMap.GetQNameByKey( XML_NAMESPACE_STYLE,
+ OUString::createFromAscii(sXML_list_style_name) ) );
+ rAttrList.AddAttribute( sName,
+ OUString::createFromAscii( sXML_CDATA ),
+ ((const SwNumRuleItem *)pItem)->GetValue() );
+ }
+ }
+}
+
+SwXMLAutoStylePool::~SwXMLAutoStylePool()
+{
+}
+#else
+
+class SwXMLAutoStylePoolP : public SvXMLAutoStylePoolP
+{
+ SvXMLExport& rExport;
+ const OUString sListStyleName;
+ const OUString sCDATA;
+
+protected:
+
+ virtual void exportStyleAttributes(
+ SvXMLAttributeList& rAttrList,
+ sal_Int32 nFamily,
+ const ::std::vector< XMLPropertyState >& rProperties,
+ const SvXMLExportPropertyMapper& rPropExp,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap) const;
+public:
+
+ SwXMLAutoStylePoolP( SvXMLExport& rExport );
+ virtual ~SwXMLAutoStylePoolP();
+};
+
+void SwXMLAutoStylePoolP::exportStyleAttributes(
+ SvXMLAttributeList& rAttrList,
+ sal_Int32 nFamily,
+ const ::std::vector< XMLPropertyState >& rProperties,
+ const SvXMLExportPropertyMapper& rPropExp,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap) const
+{
+ if( XML_STYLE_FAMILY_TEXT_PARAGRAPH == nFamily )
+ {
+ for( ::std::vector< XMLPropertyState >::const_iterator
+ aProperty = rProperties.begin();
+ aProperty != rProperties.end();
+ aProperty++ )
+ {
+ switch( rPropExp.getPropertySetMapper()->
+ GetEntryContextId( aProperty->mnIndex ) )
+ {
+ case CTF_NUMBERINGSTYLENAME:
+ {
+ OUString sStyleName;
+ aProperty->maValue >>= sStyleName;
+ if( sStyleName.getLength() )
+ {
+ OUString sTmp = rExport.GetTextParagraphExport()->GetListAutoStylePool().Find( sStyleName );
+ if( sTmp.getLength() )
+ sStyleName = sTmp;
+ OUString sName( rNamespaceMap.GetQNameByKey(
+ XML_NAMESPACE_STYLE, sListStyleName ) );
+ rAttrList.AddAttribute( sName, sCDATA, sStyleName );
+ }
+ }
+ break;
+ }
+ }
+ }
+}
+
+SwXMLAutoStylePoolP::SwXMLAutoStylePoolP(SvXMLExport& rExp ) :
+ SvXMLAutoStylePoolP(),
+ rExport( rExp ),
+ sListStyleName( RTL_CONSTASCII_USTRINGPARAM( sXML_list_style_name) ),
+ sCDATA( RTL_CONSTASCII_USTRINGPARAM( sXML_CDATA) )
+{
+}
+
+
+SwXMLAutoStylePoolP::~SwXMLAutoStylePoolP()
+{
+}
+
+SvXMLAutoStylePoolP* SwXMLExport::CreateAutoStylePool()
+{
+ return new SwXMLAutoStylePoolP( *this );
+}
+#endif
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlfmte.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.23 2000/09/18 16:05:06 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.22 2000/09/18 11:58:02 mib
+ text frames/graphics import and export continued
+
+ Revision 1.21 2000/09/07 05:29:00 mib
+ #78555#: Search paragraph styles by programmatic name instead of UI name
+
+ Revision 1.20 2000/08/24 11:16:41 mib
+ text import continued
+
+ Revision 1.19 2000/08/21 11:02:50 dvo
+ - fixed data style export (for textfields)
+
+ Revision 1.18 2000/08/10 10:22:16 mib
+ #74404#: Adeptions to new XSL/XLink working draft
+
+ Revision 1.17 2000/08/02 14:52:39 mib
+ text export continued
+
+ Revision 1.16 2000/07/31 09:42:35 mib
+ text export continued
+
+ Revision 1.15 2000/07/27 08:06:34 mib
+ text import continued
+
+ Revision 1.14 2000/07/26 05:11:20 mib
+ text import/export continued
+
+ Revision 1.13 2000/07/24 10:19:02 dvo
+ - textfield export for XML_CORE_API
+
+ Revision 1.12 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.11 2000/07/10 06:58:49 mib
+ text styles
+
+ Revision 1.10 2000/07/07 13:58:36 mib
+ text styles using StarOffice API
+
+ Revision 1.9 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.8 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.7 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.6 2000/03/06 10:46:11 mib
+ #72585#: toInt32
+
+ Revision 1.5 2000/02/11 14:41:57 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.4 2000/02/07 10:03:28 mib
+ #70271#: tables
+
+ Revision 1.3 2000/01/20 10:03:16 mib
+ #70271#: Lists reworked
+
+ Revision 1.2 2000/01/12 15:00:23 mib
+ #70271#: lists
+
+ Revision 1.1 2000/01/06 15:03:40 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+ Revision 1.23 1999/12/13 08:28:25 mib
+ #70271#: Support for element items added
+
+ Revision 1.22 1999/12/06 11:41:33 mib
+ #70258#: Container item for unkown attributes
+
+ Revision 1.21 1999/11/26 11:13:57 mib
+ loading of styles only and insert mode
+
+ Revision 1.20 1999/11/22 15:52:34 os
+ headers added
+
+ Revision 1.19 1999/11/17 20:08:49 nn
+ document language
+
+ Revision 1.18 1999/11/12 14:50:28 mib
+ meta import and export reactivated
+
+ Revision 1.17 1999/11/12 11:43:03 mib
+ using item mapper, part iii
+
+ Revision 1.16 1999/11/10 15:08:09 mib
+ Import now uses XMLItemMapper
+
+ Revision 1.15 1999/11/09 15:40:08 mib
+ Using XMLItemMapper for export
+
+ Revision 1.14 1999/11/05 19:44:11 nn
+ handle office:meta
+
+ Revision 1.13 1999/11/01 11:38:50 mib
+ List style import
+
+ Revision 1.12 1999/10/25 10:41:48 mib
+ Using new OUString ASCII methods
+
+ Revision 1.11 1999/10/22 09:49:16 mib
+ List style export
+
+ Revision 1.10 1999/10/15 12:37:05 mib
+ integrated SvXMLStyle into SvXMLStyleContext
+
+ Revision 1.9 1999/10/08 11:47:45 mib
+ moved some file to SVTOOLS/SVX
+
+ Revision 1.8 1999/10/01 13:02:51 mib
+ no comparisons between OUString and char* any longer
+
+ Revision 1.7 1999/09/28 10:47:58 mib
+ char fmts again
+
+ Revision 1.6 1999/09/28 08:31:15 mib
+ char fmts, hints
+
+ Revision 1.5 1999/09/23 11:53:58 mib
+ i18n, token maps and hard paragraph attributes
+
+ Revision 1.4 1999/09/22 11:56:57 mib
+ string -> wstring
+
+ Revision 1.3 1999/08/19 12:57:42 MIB
+ attribute import added
+
+
+ Rev 1.2 19 Aug 1999 14:57:42 MIB
+ attribute import added
+
+ Rev 1.1 18 Aug 1999 17:03:36 MIB
+ Style import
+
+ Rev 1.0 13 Aug 1999 16:18:10 MIB
+ Initial revision.
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
new file mode 100644
index 000000000000..41743bc096b2
--- /dev/null
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -0,0 +1,570 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlimp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef _PAM_HXX //autogen wg. SwPaM
+#include <pam.hxx>
+#endif
+
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+
+#ifndef _XMLOFF_I18NMAP_HXX
+#include <xmloff/i18nmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLTKMAP_HXX
+#include <xmloff/xmltkmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+#ifndef _XMLOFF_TXTIMP_HXX
+#include <xmloff/txtimp.hxx>
+#endif
+
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXTRANGE_HPP_
+#include <com/sun/star/text/XTextRange.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_
+#include <com/sun/star/text/XText.hpp>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _UNOOBJ_HXX
+#include <unoobj.hxx>
+#endif
+#ifndef _POOLFMT_HXX
+#include <poolfmt.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _XMLIMP_HXX
+#include "xmlimp.hxx"
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::text;
+
+sal_Char __READONLY_DATA sXML_np__text[] = "text";
+sal_Char __READONLY_DATA sXML_np__table[] = "table";
+
+//----------------------------------------------------------------------------
+
+enum SwXMLDocTokens
+{
+ XML_TOK_DOC_STYLES,
+ XML_TOK_DOC_AUTOSTYLES,
+ XML_TOK_DOC_MASTERSTYLES,
+ XML_TOK_DOC_META,
+ XML_TOK_DOC_BODY,
+ XML_TOK_OFFICE_END=XML_TOK_UNKNOWN
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aDocTokenMap[] =
+{
+ { XML_NAMESPACE_OFFICE, sXML_styles, XML_TOK_DOC_STYLES },
+ { XML_NAMESPACE_OFFICE, sXML_automatic_styles, XML_TOK_DOC_AUTOSTYLES },
+ { XML_NAMESPACE_OFFICE, sXML_master_styles, XML_TOK_DOC_MASTERSTYLES },
+ { XML_NAMESPACE_OFFICE, sXML_meta, XML_TOK_DOC_META },
+ { XML_NAMESPACE_OFFICE, sXML_body, XML_TOK_DOC_BODY },
+ XML_TOKEN_MAP_END
+};
+
+class SwXMLDocContext_Impl : public SvXMLImportContext
+{
+ const SwXMLImport& GetSwImport() const
+ { return (const SwXMLImport&)GetImport(); }
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+
+public:
+
+ SwXMLDocContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+ virtual ~SwXMLDocContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+};
+
+SwXMLDocContext_Impl::SwXMLDocContext_Impl( SwXMLImport& rImport,
+ sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList ) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+}
+
+SwXMLDocContext_Impl::~SwXMLDocContext_Impl()
+{
+}
+
+SvXMLImportContext *SwXMLDocContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetDocElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_DOC_STYLES:
+ pContext = GetSwImport().CreateStylesContext( rLocalName, xAttrList,
+ sal_False );
+ break;
+ case XML_TOK_DOC_AUTOSTYLES:
+ pContext = GetSwImport().CreateStylesContext( rLocalName, xAttrList,
+ sal_True );
+ break;
+// case XML_TOK_DOC_USESTYLES:
+// pContext = GetSwImport().CreateUseStylesContext( rLocalName,
+// xAttrList );
+// break;
+ case XML_TOK_DOC_MASTERSTYLES:
+// pContext = GetSwImport().CreateMasterStylesContext( rLocalName,
+// xAttrList );
+ break;
+ case XML_TOK_DOC_META:
+ pContext = GetSwImport().CreateMetaContext( rLocalName );
+ break;
+ case XML_TOK_DOC_BODY:
+ pContext = GetSwImport().CreateBodyContext( rLocalName );
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+
+ return pContext;
+}
+
+//----------------------------------------------------------------------------
+
+const SvXMLTokenMap& SwXMLImport::GetDocElemTokenMap()
+{
+ if( !pDocElemTokenMap )
+ pDocElemTokenMap = new SvXMLTokenMap( aDocTokenMap );
+
+ return *pDocElemTokenMap;
+}
+
+SvXMLImportContext *SwXMLImport::CreateContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ if( XML_NAMESPACE_OFFICE==nPrefix &&
+ rLocalName.compareToAscii( sXML_document ) == 0 )
+ pContext = new SwXMLDocContext_Impl( *this, nPrefix, rLocalName,
+ xAttrList );
+ else
+ pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
+
+ return pContext;
+}
+
+SwXMLImport::SwXMLImport(
+ SwDoc& rDoc, const SwPaM& rPaM,
+ sal_Bool bLDoc, sal_Bool bInsertMode, sal_uInt16 nStyleFamMask,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > & rModel ) :
+ SvXMLImport( rModel ),
+ bLoadDoc( bLDoc ),
+ bInsert( bInsertMode ),
+ nStyleFamilyMask( nStyleFamMask ),
+ pDoc( &rDoc ),
+ pPaM( new SwPaM( *rPaM.GetPoint() ) ),
+#ifdef XML_CORE_API
+ pI18NMap( new SvI18NMap ),
+ pUnusedNumRules( 0 ),
+#endif
+ pDocElemTokenMap( 0 ),
+#ifdef XML_CORE_API
+ pBodyElemTokenMap( 0 ),
+ pStyleStylesElemTokenMap( 0 ),
+ pTextPElemTokenMap( 0 ),
+ pTextPAttrTokenMap( 0 ),
+ pTextListBlockAttrTokenMap( 0 ),
+ pTextListBlockElemTokenMap( 0 ),
+#endif
+ pTableElemTokenMap( 0 ),
+#ifdef XML_CORE_API
+ pParaItemMapper( 0 ),
+#endif
+ pTableItemMapper( 0 ),
+ pSttNdIdx( 0 ),
+ bAutoStylesValid( sal_False )
+{
+// GetNamespaceMap().AddAtIndex( XML_NAMESPACE_TEXT, sXML_np__text,
+// sXML_n_text, XML_NAMESPACE_TEXT );
+// GetNamespaceMap().AddAtIndex( XML_NAMESPACE_TABLE, sXML_np__table,
+// sXML_n_table, XML_NAMESPACE_TABLE );
+
+ _InitItemImport();
+
+ if( !IsStylesOnlyMode() )
+ {
+ pSttNdIdx = new SwNodeIndex( pDoc->GetNodes() );
+ if( IsInsertMode() )
+ {
+ const SwPosition* pPos = pPaM->GetPoint();
+
+ // Split once and remember the node that has been splitted.
+ pDoc->SplitNode( *pPos );
+ *pSttNdIdx = pPos->nNode.GetIndex()-1;
+
+ // Split again.
+ pDoc->SplitNode( *pPos );
+
+ // Insert all content into the new node
+ pPaM->Move( fnMoveBackward );
+ pDoc->SetTxtFmtColl( *pPaM,
+ pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD) );
+ }
+ }
+ Reference < XTextRange > xTextRange =
+ CreateTextRangeFromPosition( pDoc, *rPaM.GetPoint(), 0 );
+ Reference < XText > xText = xTextRange->getText();
+ Reference < XTextCursor > xTextCursor =
+ xText->createTextCursorByRange( xTextRange );
+ GetTextImport()->SetCursor( xTextCursor );
+}
+
+SwXMLImport::~SwXMLImport()
+{
+ GetTextImport()->ResetCursor();
+
+ if( !IsStylesOnlyMode() )
+ {
+ if( IsInsertMode() && pSttNdIdx->GetIndex() )
+ {
+ // If we are in insert mode, join the splitted node that is in front
+ // of the new content with the first new node.
+ SwTxtNode* pTxtNode = pSttNdIdx->GetNode().GetTxtNode();
+ SwNodeIndex aNxtIdx( *pSttNdIdx );
+ if( pTxtNode && pTxtNode->CanJoinNext( &aNxtIdx ))
+ {
+ xub_StrLen nStt = pTxtNode->GetTxt().Len();
+
+ // If the PaM points to the first new node, move the PaM to the
+ // end of the previous node.
+ if( pPaM->GetPoint()->nNode == aNxtIdx )
+ {
+ pPaM->GetPoint()->nNode = *pSttNdIdx;
+ pPaM->GetPoint()->nContent.Assign( pTxtNode, nStt );
+ }
+
+#ifndef PRODUCT
+ // !!! This should be impossible !!!!
+ ASSERT( pSttNdIdx->GetIndex()+1 !=
+ pPaM->GetBound( sal_True ).nNode.GetIndex(),
+ "PaM.Bound1 point to new node " );
+ ASSERT( pSttNdIdx->GetIndex()+1 !=
+ pPaM->GetBound( sal_False ).nNode.GetIndex(),
+ "PaM.Bound2 points to new node" );
+
+ if( pSttNdIdx->GetIndex()+1 ==
+ pPaM->GetBound( sal_True ).nNode.GetIndex() )
+ {
+ sal_uInt16 nCntPos =
+ pPaM->GetBound( sal_True ).nContent.GetIndex();
+ pPaM->GetBound( sal_True ).nContent.Assign( pTxtNode,
+ pTxtNode->GetTxt().Len() + nCntPos );
+ }
+ if( pSttNdIdx->GetIndex()+1 ==
+ pPaM->GetBound( sal_False ).nNode.GetIndex() )
+ {
+ sal_uInt16 nCntPos =
+ pPaM->GetBound( sal_False ).nContent.GetIndex();
+ pPaM->GetBound( sal_False ).nContent.Assign( pTxtNode,
+ pTxtNode->GetTxt().Len() + nCntPos );
+ }
+#endif
+ // If the first new node isn't empty, convert the node's text
+ // attributes into hints. Otherwise, set the new node's paragraph
+ // style at the previous (empty) node.
+ SwTxtNode* pDelNd = aNxtIdx.GetNode().GetTxtNode();
+ if( pTxtNode->GetTxt().Len() )
+ pDelNd->FmtToTxtAttr( pTxtNode );
+ else
+ pTxtNode->ChgFmtColl( pDelNd->GetTxtColl() );
+ pTxtNode->JoinNext();
+ }
+ }
+
+ SwPosition* pPos = pPaM->GetPoint();
+ if( !pPos->nContent.GetIndex() )
+ {
+ SwTxtNode* pCurrNd;
+ sal_uInt32 nNodeIdx = pPos->nNode.GetIndex();
+
+ if( !IsInsertMode() )
+ {
+ if( pDoc->GetNodes()[nNodeIdx -1]->IsCntntNode() )
+ {
+ SwCntntNode* pCNd = pPaM->GetCntntNode();
+ if( pCNd && pCNd->StartOfSectionIndex()+2 <
+ pCNd->EndOfSectionIndex() )
+ {
+ pPaM->GetBound(sal_True).nContent.Assign( 0, 0 );
+ pPaM->GetBound(sal_False).nContent.Assign( 0, 0 );
+ pDoc->GetNodes().Delete( pPaM->GetPoint()->nNode );
+ }
+ }
+ }
+ else if( 0 != (pCurrNd = pDoc->GetNodes()[nNodeIdx]->GetTxtNode()) )
+ {
+ if( pCurrNd->CanJoinNext( &pPos->nNode ))
+ {
+ SwTxtNode* pNextNd = pPos->nNode.GetNode().GetTxtNode();
+ pPos->nContent.Assign( pNextNd, 0 );
+ pPaM->SetMark(); pPaM->DeleteMark();
+ pNextNd->JoinPrev();
+ }
+ else if( !pCurrNd->GetTxt().Len() )
+ {
+ pPos->nContent.Assign( 0, 0 );
+ pPaM->SetMark(); pPaM->DeleteMark();
+ pDoc->GetNodes().Delete( pPos->nNode, 1 );
+ pPaM->Move( fnMoveBackward );
+ }
+ }
+ }
+ else if( IsInsertMode() )
+ {
+ pPaM->Move( fnMoveForward, fnGoNode );
+ SwTxtNode* pTxtNode = pPos->nNode.GetNode().GetTxtNode();
+ SwNodeIndex aPrvIdx( pPos->nNode );
+ if( pTxtNode && pTxtNode->CanJoinPrev( &aPrvIdx ) &&
+ *pSttNdIdx <= aPrvIdx )
+ {
+ // In fact, we should do an JoinNext here, but the Cursor and
+ // many other stuff is registered to the current node. That for
+ // the node should remain and we do an JoinPrev here.
+
+ // Convert paragraph attributes into hints and set paragraph
+ // style at the next node.
+ SwTxtNode* pPrev = aPrvIdx.GetNode().GetTxtNode();
+ pTxtNode->ChgFmtColl( pPrev->GetTxtColl() );
+ pTxtNode->FmtToTxtAttr( pPrev );
+ pTxtNode->SwCntntNode::ResetAllAttr();
+
+ if( pPrev->GetpSwAttrSet() )
+ pTxtNode->SwCntntNode::SetAttr( *pPrev->GetpSwAttrSet() );
+
+ if( &pPaM->GetBound(sal_True).nNode.GetNode() == pPrev )
+ pPaM->GetBound(sal_True).nContent.Assign( pTxtNode, 0 );
+ if( &pPaM->GetBound(sal_False).nNode.GetNode() == pPrev )
+ pPaM->GetBound(sal_False).nContent.Assign( pTxtNode, 0 );
+
+ pTxtNode->JoinPrev();
+ }
+ }
+ }
+
+#ifdef XML_CORE_API
+ RemoveUnusedNumRules();
+#endif
+
+ delete pSttNdIdx;
+ delete pPaM;
+ delete pDocElemTokenMap;
+#ifdef XML_CORE_API
+ delete pI18NMap;
+ delete pBodyElemTokenMap;
+ delete pTextPElemTokenMap;
+ delete pTextPAttrTokenMap;
+ delete pStyleStylesElemTokenMap;
+ delete pTextListBlockAttrTokenMap;
+ delete pTextListBlockElemTokenMap;
+#endif
+ delete pTableElemTokenMap;
+ _FinitItemImport();
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlimp.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.30 2000/09/18 16:05:06 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.29 2000/08/29 07:33:47 mib
+ text import continued
+
+ Revision 1.28 2000/08/24 11:16:41 mib
+ text import continued
+
+ Revision 1.27 2000/08/10 10:22:16 mib
+ #74404#: Adeptions to new XSL/XLink working draft
+
+ Revision 1.26 2000/07/31 09:42:35 mib
+ text export continued
+
+ Revision 1.25 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.24 2000/07/07 13:58:36 mib
+ text styles using StarOffice API
+
+ Revision 1.23 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.22 2000/05/15 16:53:17 jp
+ Changes for Unicode
+
+ Revision 1.21 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.20 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.19 2000/02/17 14:40:30 mib
+ #70271#: XML table import
+
+ Revision 1.17 2000/01/27 08:59:02 mib
+ #70271#: outline numbering
+
+ Revision 1.16 2000/01/20 10:03:16 mib
+ #70271#: Lists reworked
+
+ Revision 1.15 2000/01/06 15:08:27 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+ Revision 1.14 1999/11/26 11:12:51 mib
+ loading of styles only and insert mode
+
+ Revision 1.13 1999/11/22 15:53:39 mib
+ split/join nodes correctly
+
+ Revision 1.12 1999/11/12 11:43:03 mib
+ using item mapper, part iii
+
+ Revision 1.11 1999/11/10 15:08:09 mib
+ Import now uses XMLItemMapper
+
+ Revision 1.10 1999/11/01 11:38:50 mib
+ List style import
+
+ Revision 1.9 1999/10/15 12:39:11 mib
+ moved styles element from style to office namespace
+
+ Revision 1.8 1999/10/08 11:47:49 mib
+ moved some file to SVTOOLS/SVX
+
+ Revision 1.7 1999/10/05 14:31:14 hr
+ #65293#: removed redundant const
+
+ Revision 1.6 1999/09/28 10:46:58 mib
+ memory leak
+
+ Revision 1.5 1999/09/23 11:54:16 mib
+ i18n, token maps and hard paragraph attributes
+
+ Revision 1.4 1999/09/22 11:57:14 mib
+ string -> wstring
+
+ Revision 1.3 1999/08/19 12:57:42 MIB
+ attribute import added
+
+
+ Rev 1.2 19 Aug 1999 14:57:42 MIB
+ attribute import added
+
+ Rev 1.1 18 Aug 1999 17:05:20 MIB
+ Style import
+
+ Rev 1.0 17 Aug 1999 16:32:52 MIB
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlimp.hxx b/sw/source/filter/xml/xmlimp.hxx
new file mode 100644
index 000000000000..5bb684245bf7
--- /dev/null
+++ b/sw/source/filter/xml/xmlimp.hxx
@@ -0,0 +1,283 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlimp.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _XMLIMP_HXX
+#define _XMLIMP_HXX
+
+#ifndef _RSCSFX_HXX
+#include <rsc/rscsfx.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLITMAP_HXX
+#include <xmloff/xmlitmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLIMP_HXX
+#include <xmloff/xmlimp.hxx>
+#endif
+
+class SwDoc;
+class SwPaM;
+class SvXMLUnitConverter;
+class SvI18NMap;
+class SvXMLTokenMap;
+class SvXMLImportItemMapper;
+class SvXMLStyleContext;
+class SwXMLListBlockContext;
+class SwXMLListItemContext;
+class SfxItemSet;
+class SwNodeIndex;
+class SwNumRule;
+class SwNumRulesSort_Impl;
+class XMLTextImportHelper;
+
+class SwXMLImport: public SvXMLImport
+{
+ SwDoc *pDoc;
+ SwPaM *pPaM; // SwPosition ??
+ SwNodeIndex *pSttNdIdx;
+
+ SvXMLUnitConverter *pTwipUnitConv;
+#ifdef XML_CORE_API
+ SvXMLImportItemMapper *pParaItemMapper;// paragraph item import
+#endif
+ SvXMLImportItemMapper *pTableItemMapper;// paragraph item import
+#ifdef XML_CORE_API
+ SvI18NMap *pI18NMap; // name mapping for I18N
+ SwNumRulesSort_Impl *pUnusedNumRules;
+#endif
+ SvXMLTokenMap *pDocElemTokenMap;
+#ifdef XML_CORE_API
+ SvXMLTokenMap *pBodyElemTokenMap;
+ SvXMLTokenMap *pTextPElemTokenMap;
+ SvXMLTokenMap *pTextPAttrTokenMap;
+ SvXMLTokenMap *pStyleStylesElemTokenMap;
+ SvXMLTokenMap *pTextListBlockAttrTokenMap;
+ SvXMLTokenMap *pTextListBlockElemTokenMap;
+#endif
+ SvXMLTokenMap *pTableElemTokenMap;
+
+ SvXMLItemMapEntriesRef xTableItemMap;
+ SvXMLItemMapEntriesRef xTableColItemMap;
+ SvXMLItemMapEntriesRef xTableRowItemMap;
+ SvXMLItemMapEntriesRef xTableCellItemMap;
+
+ SvXMLImportContextRef xStyles;
+ SvXMLImportContextRef xAutoStyles;
+#ifdef XML_CORE_API
+ SvXMLImportContextRef xListBlock;
+ SvXMLImportContextRef xListItem;
+#endif
+
+ sal_uInt16 nStyleFamilyMask;// Mask of styles to load
+ sal_Bool bLoadDoc : 1; // Load doc or styles only
+ sal_Bool bInsert : 1; // Insert mode. If styles are
+ // loaded only sal_False means that
+ // existing styles will be
+ // overwritten.
+ sal_Bool bAutoStylesValid : 1;
+
+
+ void _InitItemImport();
+ void _FinitItemImport();
+#ifdef XML_CORE_API
+ void RemoveUnusedNumRules();
+#endif
+
+ void InsertStyles();
+
+protected:
+
+ // This method is called after the namespace map has been updated, but
+ // before a context for the current element has been pushed.
+ virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+
+ virtual XMLTextImportHelper* CreateTextImport();
+
+public:
+
+ SwXMLImport( SwDoc& rDoc, const SwPaM& rPaM, sal_Bool bLoadDoc,
+ sal_Bool bInsertMode, sal_uInt16 nStyleFamMask,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > & rModel );
+
+ ~SwXMLImport();
+
+ // namespace office
+ SvXMLImportContext *CreateMetaContext( const ::rtl::OUString& rLocalName );
+ SvXMLImportContext *CreateStylesContext(
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ sal_Bool bAuto );
+ SvXMLImportContext *CreateBodyContext( const ::rtl::OUString& rLocalName );
+
+
+#ifdef XML_CORE_API
+ SwPaM& GetPaM() { return *pPaM; }
+#endif
+ SwDoc& GetDoc() { return *pDoc; }
+ const SwDoc& GetDoc() const { return *pDoc; }
+
+ sal_uInt16 GetStyleFamilyMask() const { return nStyleFamilyMask; }
+ sal_Bool IsInsertMode() const { return bInsert; }
+ sal_Bool IsStylesOnlyMode() const { return !bLoadDoc; }
+
+#ifdef XML_CORE_API
+ SvI18NMap& GetI18NMap() { return *pI18NMap; }
+#endif
+
+ inline const SvXMLUnitConverter& GetTwipUnitConverter() const;
+#ifdef XML_CORE_API
+ inline const SvXMLImportItemMapper& GetParaItemMapper() const;
+#endif
+ inline const SvXMLImportItemMapper& GetTableItemMapper() const;
+#ifdef XML_CORE_API
+ SvXMLImportContext *CreateParaItemImportContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ SfxItemSet& rItemSet );
+#endif
+ SvXMLImportContext *CreateTableItemImportContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ sal_uInt16 nSubFamily, SfxItemSet& rItemSet );
+
+ const SvXMLTokenMap& GetDocElemTokenMap();
+#ifdef XML_CORE_API
+ const SvXMLTokenMap& GetBodyElemTokenMap();
+ const SvXMLTokenMap& GetTextPElemTokenMap();
+ const SvXMLTokenMap& GetTextPAttrTokenMap();
+ const SvXMLTokenMap& GetStyleStylesElemTokenMap();
+ const SvXMLTokenMap& GetTextListBlockAttrTokenMap();
+ const SvXMLTokenMap& GetTextListBlockElemTokenMap();
+#endif
+ const SvXMLTokenMap& GetTableElemTokenMap();
+
+#ifdef XML_CORE_API
+ inline sal_Bool FindAutomaticStyle( SfxStyleFamily eFamily,
+ const ::rtl::OUString& rName,
+ const SfxItemSet **ppItemSet=0,
+ ::rtl::OUString *pParent=0 ) const;
+ sal_Bool FindAutomaticStyle( SfxStyleFamily eFamily,
+ sal_uInt16 nSubStyle,
+ const ::rtl::OUString& rName,
+ const SfxItemSet **ppItemSet=0,
+ ::rtl::OUString *pParent=0 ) const;
+#else
+ sal_Bool FindAutomaticStyle( sal_uInt16 nFamily,
+ const ::rtl::OUString& rName,
+ const SfxItemSet **ppItemSet=0,
+ ::rtl::OUString *pParent=0 ) const;
+#endif
+
+#ifdef XML_CORE_API
+ SwXMLListBlockContext *GetListBlock();
+ sal_Bool IsInList() const { return xListBlock.Is(); }
+ void SetListBlock( SwXMLListBlockContext *pListBlock );
+
+ SwXMLListItemContext *GetListItem();
+ sal_Bool HasListItem() const { return xListItem.Is(); }
+ void SetListItem( SwXMLListItemContext *pListItem );
+
+ void AddUnused( const SwNumRule& rNumRule );
+ void SetUsed( const SwNumRule& rNumRule );
+#endif
+};
+
+inline const SvXMLUnitConverter& SwXMLImport::GetTwipUnitConverter() const
+{
+ return *pTwipUnitConv;
+}
+
+#ifdef XML_CORE_API
+inline const SvXMLImportItemMapper& SwXMLImport::GetParaItemMapper() const
+{
+ return *pParaItemMapper;
+}
+#endif
+
+inline const SvXMLImportItemMapper& SwXMLImport::GetTableItemMapper() const
+{
+ return *pTableItemMapper;
+}
+
+#ifdef XML_CORE_API
+inline sal_Bool SwXMLImport::FindAutomaticStyle( SfxStyleFamily eFamily,
+ const ::rtl::OUString& rName,
+ const SfxItemSet **ppItemSet,
+ ::rtl::OUString *pParent ) const
+{
+ return FindAutomaticStyle( eFamily, 0U, rName, ppItemSet, pParent );
+}
+#endif
+
+
+#endif // _XMLIMP_HXX
diff --git a/sw/source/filter/xml/xmliteme.cxx b/sw/source/filter/xml/xmliteme.cxx
new file mode 100644
index 000000000000..e952d9fbd075
--- /dev/null
+++ b/sw/source/filter/xml/xmliteme.cxx
@@ -0,0 +1,490 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmliteme.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#include <hintids.hxx>
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#ifndef _SHL_HXX //autogen wg. SHL_WRITER
+#include <tools/shl.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLUCONV_HXX
+#include <xmloff/xmluconv.hxx>
+#endif
+#ifndef _XMLOFF_XMLITMPR_HXX
+#include <xmloff/xmlexpit.hxx>
+#endif
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLTABE_HXX
+#include <xmloff/xmltabe.hxx>
+#endif
+#ifndef _XMLBRSHE_HXX
+#include "xmlbrshe.hxx"
+#endif
+
+#ifndef _SVX_TSPTITEM_HXX
+#include <svx/tstpitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_UNOMID_HXX
+#include <svx/unomid.hxx>
+#endif
+
+#ifndef _VCL_FLDUNIT_HXX
+#include <vcl/fldunit.hxx>
+#endif
+
+#ifndef _SWMODULE_HXX //autogen wg. SW_MOD
+#include <swmodule.hxx>
+#endif
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#ifndef _FMTORNT_HXX
+#include "fmtornt.hxx"
+#endif
+#ifndef _UNOMID_H
+#include <unomid.h>
+#endif
+#ifndef _FRMFMT_HXX
+#include "frmfmt.hxx"
+#endif
+#ifndef _FMTFSIZE_HXX
+#include "fmtfsize.hxx"
+#endif
+#ifndef _SWRECT_HXX
+#include "swrect.hxx"
+#endif
+
+#ifndef _XMLDROPE_HXX
+#include "xmldrope.hxx"
+#endif
+#ifndef _XMLEXP_HXX
+#include "xmlexp.hxx"
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+#ifdef XML_CORE_API
+extern SvXMLItemMapEntry aXMLParaItemMap[];
+#endif
+extern SvXMLItemMapEntry aXMLTableItemMap[];
+extern SvXMLItemMapEntry aXMLTableRowItemMap[];
+extern SvXMLItemMapEntry aXMLTableCellItemMap[];
+
+#ifdef XML_CORE_API
+class SwXMLTextItemMapper_Impl: public SvXMLExportItemMapper
+{
+protected:
+ SvXMLUnitConverter& mrUnitConverter;
+ const Reference< xml::sax::XDocumentHandler > & mrHandler;
+ SvxXMLTabStopExport maTabStopExport;
+
+public:
+
+ SwXMLTextItemMapper_Impl(
+ SvXMLItemMapEntriesRef rMapEntries,
+ SvXMLUnitConverter& rUnitConverter,
+ const Reference< xml::sax::XDocumentHandler > & rHandler );
+
+ virtual ~SwXMLTextItemMapper_Impl();
+
+ virtual void handleElementItem(
+ const Reference< xml::sax::XDocumentHandler > & rHandler,
+ const SvXMLItemMapEntry& rEntry,
+ const SfxPoolItem& rItem,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ const SfxItemSet& rSet,
+ sal_uInt16 nFlags ) const;
+};
+
+SwXMLTextItemMapper_Impl::SwXMLTextItemMapper_Impl(
+ SvXMLItemMapEntriesRef rMapEntries,
+ SvXMLUnitConverter& rUnitConverter,
+ const Reference< xml::sax::XDocumentHandler > & rHandler ) :
+ SvXMLExportItemMapper( rMapEntries ),
+ mrUnitConverter(rUnitConverter),
+ mrHandler( rHandler ),
+ maTabStopExport( rHandler, rUnitConverter )
+{
+}
+
+SwXMLTextItemMapper_Impl::~SwXMLTextItemMapper_Impl()
+{
+}
+
+/** this method is called for every item that has the
+ MID_FLAG_ELEMENT_EXPORT flag set */
+void SwXMLTextItemMapper_Impl::handleElementItem(
+ const Reference< xml::sax::XDocumentHandler > & rHandler,
+ const SvXMLItemMapEntry& rEntry,
+ const SfxPoolItem& rItem,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ const SfxItemSet&,
+ sal_uInt16 ) const
+{
+ switch( rEntry.nWhichId )
+ {
+ case RES_PARATR_TABSTOP:
+ {
+ SvxXMLTabStopExport aTabStopExport( rHandler, rUnitConverter );
+
+ Any aAny;
+ rItem.QueryValue( aAny, 0 );
+ aTabStopExport.Export( aAny, rNamespaceMap );
+ }
+ break;
+ case RES_PARATR_DROP:
+ {
+ SwXMLFmtDropExport aFmtDropExport( rHandler, rUnitConverter );
+ aFmtDropExport.exportXML( (const SwFmtDrop&)rItem, rNamespaceMap );
+ }
+ break;
+ case RES_BACKGROUND:
+ {
+ SwXMLBrushItemExport aBrushItemExport( rHandler, rUnitConverter );
+ aBrushItemExport.exportXML( (const SvxBrushItem&)rItem,
+ rNamespaceMap );
+ }
+ break;
+ }
+}
+#endif
+
+// ----------------------------------------------------------------------------
+
+class SwXMLTableItemMapper_Impl: public SvXMLExportItemMapper
+{
+ const OUString sCDATA;
+
+protected:
+ SvXMLUnitConverter& mrUnitConverter;
+ const Reference< xml::sax::XDocumentHandler > & mrHandler;
+
+ sal_uInt32 nAbsWidth;
+
+ void AddAttribute( sal_uInt16 nPrefix, const sal_Char *pLName,
+ const OUString& rValue,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ SvXMLAttributeList& rAttrList ) const;
+
+public:
+
+ SwXMLTableItemMapper_Impl(
+ SvXMLItemMapEntriesRef rMapEntries,
+ SvXMLUnitConverter& rUnitConverter,
+ const Reference< xml::sax::XDocumentHandler > & rHandler );
+
+ virtual ~SwXMLTableItemMapper_Impl();
+
+ virtual void handleSpecialItem( SvXMLAttributeList& rAttrList,
+ const SvXMLItemMapEntry& rEntry,
+ const SfxPoolItem& rItem,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ const SfxItemSet *pSet = NULL ) const;
+
+ virtual void handleElementItem(
+ const Reference< xml::sax::XDocumentHandler > & rHandler,
+ const SvXMLItemMapEntry& rEntry,
+ const SfxPoolItem& rItem,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ const SfxItemSet& rSet,
+ sal_uInt16 nFlags ) const;
+
+ inline void SetAbsWidth( sal_uInt32 nAbs );
+};
+
+SwXMLTableItemMapper_Impl::SwXMLTableItemMapper_Impl(
+ SvXMLItemMapEntriesRef rMapEntries,
+ SvXMLUnitConverter& rUnitConverter,
+ const Reference< xml::sax::XDocumentHandler > & rHandler ) :
+ SvXMLExportItemMapper( rMapEntries ),
+ sCDATA( OUString::createFromAscii( sXML_CDATA ) ),
+ mrUnitConverter(rUnitConverter),
+ mrHandler( rHandler ),
+ nAbsWidth( USHRT_MAX )
+{
+}
+
+SwXMLTableItemMapper_Impl::~SwXMLTableItemMapper_Impl()
+{
+}
+
+void SwXMLTableItemMapper_Impl::AddAttribute( sal_uInt16 nPrefix,
+ const sal_Char *pLName,
+ const OUString& rValue,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ SvXMLAttributeList& rAttrList ) const
+{
+ OUString sLName( OUString::createFromAscii(pLName) );
+ OUString sName( rNamespaceMap.GetQNameByKey( nPrefix, sLName ) );
+ rAttrList.AddAttribute( sName, sCDATA, rValue );
+}
+
+void SwXMLTableItemMapper_Impl::handleSpecialItem(
+ SvXMLAttributeList& rAttrList,
+ const SvXMLItemMapEntry& rEntry,
+ const SfxPoolItem& rItem,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ const SfxItemSet *pSet ) const
+{
+ switch( rEntry.nWhichId )
+ {
+ case RES_LR_SPACE:
+ {
+ const SfxPoolItem *pItem;
+ if( pSet &&
+ SFX_ITEM_SET == pSet->GetItemState( RES_HORI_ORIENT, sal_True,
+ &pItem ) )
+ {
+ SwHoriOrient eHoriOrient =
+ ((const SwFmtHoriOrient *)pItem)->GetHoriOrient();
+ sal_Bool bExport = sal_False;
+ sal_uInt32 nMemberId = rEntry.nMemberId & MID_FLAG_MASK;
+ switch( nMemberId )
+ {
+ case MID_L_MARGIN:
+ bExport = HORI_NONE == eHoriOrient ||
+ HORI_LEFT_AND_WIDTH == eHoriOrient;
+ break;
+ case MID_R_MARGIN:
+ bExport = HORI_NONE == eHoriOrient;
+ break;
+ }
+ OUString sValue;
+ if( bExport && rItem.exportXML( sValue, nMemberId,
+ rUnitConverter ) )
+ {
+ AddAttribute( rEntry.nNameSpace, rEntry.pLocalName, sValue,
+ rNamespaceMap, rAttrList );
+ }
+ }
+ }
+ break;
+
+ case RES_FRM_SIZE:
+ {
+ sal_uInt32 nMemberId = rEntry.nMemberId & MID_FLAG_MASK;
+ switch( nMemberId )
+ {
+ case MID_FRMSIZE_WIDTH:
+ if( nAbsWidth )
+ {
+ OUStringBuffer sBuffer;
+ rUnitConverter.convertMeasure( sBuffer, nAbsWidth );
+ AddAttribute( rEntry.nNameSpace, rEntry.pLocalName,
+ sBuffer.makeStringAndClear(),
+ rNamespaceMap, rAttrList );
+ }
+ break;
+ case MID_FRMSIZE_REL_WIDTH:
+ {
+ OUString sValue;
+ if( rItem.exportXML( sValue, nMemberId, rUnitConverter ) )
+ {
+ AddAttribute( rEntry.nNameSpace, rEntry.pLocalName,
+ sValue, rNamespaceMap, rAttrList );
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+}
+
+/** this method is called for every item that has the
+ MID_FLAG_ELEMENT_EXPORT flag set */
+void SwXMLTableItemMapper_Impl::handleElementItem(
+ const Reference< xml::sax::XDocumentHandler > & rHandler,
+ const SvXMLItemMapEntry& rEntry,
+ const SfxPoolItem& rItem,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ const SfxItemSet&,
+ sal_uInt16 ) const
+{
+ switch( rEntry.nWhichId )
+ {
+ case RES_BACKGROUND:
+ {
+ SwXMLBrushItemExport aBrushItemExport( rHandler, rUnitConverter );
+ aBrushItemExport.exportXML( (const SvxBrushItem&)rItem,
+ rNamespaceMap );
+ }
+ break;
+ }
+}
+
+inline void SwXMLTableItemMapper_Impl::SetAbsWidth( sal_uInt32 nAbs )
+{
+ nAbsWidth = nAbs;
+}
+
+// ----------------------------------------------------------------------------
+
+void SwXMLExport::_InitItemExport()
+{
+ pTwipUnitConv = new SvXMLUnitConverter( MAP_TWIP,
+ GetMM100UnitConverter().getXMLMeasureUnit() );
+
+#ifdef XML_CORE_API
+ SvXMLItemMapEntriesRef xParaItemMap =
+ new SvXMLItemMapEntries( aXMLParaItemMap );
+
+ pParaItemMapper = new SwXMLTextItemMapper_Impl( xParaItemMap,
+ *pTwipUnitConv,
+ GetDocHandler() );
+#endif
+
+ xTableItemMap = new SvXMLItemMapEntries( aXMLTableItemMap );
+ xTableRowItemMap = new SvXMLItemMapEntries( aXMLTableRowItemMap );
+ xTableCellItemMap = new SvXMLItemMapEntries( aXMLTableCellItemMap );
+
+ pTableItemMapper = new SwXMLTableItemMapper_Impl( xTableItemMap,
+ *pTwipUnitConv,
+ GetDocHandler() );
+}
+
+void SwXMLExport::_FinitItemExport()
+{
+#ifdef XML_CORE_API
+ delete pParaItemMapper;
+#endif
+ delete pTableItemMapper;
+ delete pTwipUnitConv;
+}
+
+void SwXMLExport::ExportTableFmt( const SwFrmFmt& rFmt, sal_uInt32 nAbsWidth )
+{
+ ((SwXMLTableItemMapper_Impl *)pTableItemMapper)
+ ->SetAbsWidth( nAbsWidth );
+ ExportFmt( rFmt, sXML_table );
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmliteme.cxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.10 2000/09/18 16:05:07 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.9 2000/08/02 14:52:39 mib
+ text export continued
+
+ Revision 1.8 2000/07/31 09:42:35 mib
+ text export continued
+
+ Revision 1.7 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.6 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.5 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.4 2000/02/11 14:41:45 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.3 2000/02/07 10:03:28 mib
+ #70271#: tables
+
+ Revision 1.2 2000/01/20 14:03:58 mib
+ #70271#: deletion of unit converter
+
+ Revision 1.1 1999/12/14 07:32:49 mib
+ #70271#: XML import/export of drop cap/register/language item, splitted swxmlat
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlitemi.cxx b/sw/source/filter/xml/xmlitemi.cxx
new file mode 100644
index 000000000000..4fae5b362f1f
--- /dev/null
+++ b/sw/source/filter/xml/xmlitemi.cxx
@@ -0,0 +1,638 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlitemi.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#include <hintids.hxx>
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _RSCSFX_HXX
+#include <rsc/rscsfx.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLITMAP_HXX
+#include <xmloff/xmlitmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLIMPIT_HXX
+#include <xmloff/xmlimpit.hxx>
+#endif
+#ifndef _XMLOFF_XMLITEM_HXX
+#include <xmloff/xmlitem.hxx>
+#endif
+#ifndef _XMLOFF_I18NMAP_HXX
+#include <xmloff/i18nmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLUCONV_HXX
+#include <xmloff/xmluconv.hxx>
+#endif
+#ifndef _XMLOFF_FAMILIES_HXX
+#include <xmloff/families.hxx>
+#endif
+
+#ifndef _SVX_UNOMID_HXX
+#include <svx/unomid.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_TSPTITEM_HXX
+#include <svx/tstpitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_LANGITEM_HXX
+#include <svx/langitem.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLTABI_HXX
+//#include <xmloff/xmltabi.hxx>
+#endif
+
+#ifndef _XMLBRSHI_HXX
+#include "xmlbrshi.hxx"
+#endif
+
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#ifndef _UNOMID_H
+#include <unomid.h>
+#endif
+
+#ifndef _XMDROPI_HXX
+#include "xmldropi.hxx"
+#endif
+#ifdef XML_CORE_API
+#ifndef _XMLTBLI_HXX
+#include "xmltbli.hxx"
+#endif
+#endif
+#ifndef _XMLIMP_HXX
+#include "xmlimp.hxx"
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+#ifdef XML_CORE_API
+extern SvXMLItemMapEntry aXMLParaItemMap[];
+#endif
+extern SvXMLItemMapEntry aXMLTableItemMap[];
+extern SvXMLItemMapEntry aXMLTableColItemMap[];
+extern SvXMLItemMapEntry aXMLTableRowItemMap[];
+extern SvXMLItemMapEntry aXMLTableCellItemMap[];
+
+#ifdef XML_CORE_API
+class SwXMLImportTextItemMapper_Impl: public SvXMLImportItemMapper
+{
+ SvI18NMap& rI18NMap;
+ SwDoc& rDoc;
+
+public:
+
+ SwXMLImportTextItemMapper_Impl( SvXMLItemMapEntriesRef rMapEntries,
+ SwDoc& rD, SvI18NMap& rI18NMap );
+ virtual ~SwXMLImportTextItemMapper_Impl();
+
+ virtual sal_Bool handleSpecialItem( const SvXMLItemMapEntry& rEntry,
+ SfxPoolItem& rItem,
+ SfxItemSet& rSet,
+ const OUString& rValue,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap ) const;
+
+ virtual void finished( SfxItemSet& rSet ) const;
+};
+
+SwXMLImportTextItemMapper_Impl::SwXMLImportTextItemMapper_Impl(
+ SvXMLItemMapEntriesRef rMapEntries,
+ SwDoc& rD, SvI18NMap& rI18NM ) :
+ SvXMLImportItemMapper( rMapEntries, RES_UNKNOWNATR_CONTAINER),
+ rDoc( rD ),
+ rI18NMap( rI18NM )
+{
+}
+
+SwXMLImportTextItemMapper_Impl::~SwXMLImportTextItemMapper_Impl()
+{
+}
+
+sal_Bool SwXMLImportTextItemMapper_Impl::handleSpecialItem(
+ const SvXMLItemMapEntry& rEntry,
+ SfxPoolItem& rItem,
+ SfxItemSet& rItemSet,
+ const OUString& rValue,
+ const SvXMLUnitConverter& rUnitConv,
+ const SvXMLNamespaceMap& ) const
+{
+ sal_Bool bRet = sal_False;
+ switch( rItem.Which() )
+ {
+ case RES_TXTATR_CHARFMT:
+ DBG_ASSERT( !this,
+ "SwXMLImportTextItemMapper_Impl::handleSpecialItem: char fmt unexpected" );
+ break;
+
+ case RES_PARATR_NUMRULE:
+ if( rValue.getLength() )
+ {
+ OUString sName( rI18NMap.Get( SFX_STYLE_FAMILY_PSEUDO, rValue ) );
+ ((SwNumRuleItem&)rItem).SetValue( sName );
+ bRet = sal_True;
+ }
+ break;
+
+ case RES_CHRATR_LANGUAGE:
+ // If the item is not contained in the item set, its the default
+ // value. To set language and contry individually, we have to clear
+ // its value.
+ if( SFX_ITEM_SET != rItemSet.GetItemState( RES_CHRATR_LANGUAGE,
+ sal_False ) )
+ {
+ ((SvxLanguageItem &)rItem).SetLanguage( LANGUAGE_NONE );
+ }
+ bRet = rItem.importXML( rValue, rEntry.nMemberId, rUnitConv );
+ break;
+ }
+
+ return bRet;
+}
+
+void SwXMLImportTextItemMapper_Impl::finished( SfxItemSet& rSet ) const
+{
+ const SfxPoolItem *pItem;
+
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_FONT, sal_False,
+ &pItem ) )
+ {
+ const SvxFontItem *pFont = (const SvxFontItem *)pItem;
+ // delete font items that have no family name
+ if( 0 == pFont->GetFamilyName().Len() )
+ rSet.ClearItem( RES_CHRATR_FONT );
+ else if( RTL_TEXTENCODING_DONTKNOW == pFont->GetCharSet() )
+ {
+ SvxFontItem aFont( *pFont );
+ aFont.GetCharSet() = gsl_getSystemTextEncoding();
+ rSet.Put( aFont );
+ }
+ }
+
+ // ensure that box item have a distance to a border.
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_BOX, sal_False, &pItem ) )
+ {
+ const SvxBoxItem *pBox = (const SvxBoxItem *)pItem;
+ sal_uInt16 aLines[4] = { BOX_LINE_TOP, BOX_LINE_BOTTOM,
+ BOX_LINE_LEFT, BOX_LINE_RIGHT };
+ sal_uInt16 i;
+ for( i=0; i<4; i++ )
+ {
+ if( pBox->GetLine( aLines[i] ) &&
+ pBox->GetDistance( aLines[i] ) < MIN_BORDER_DIST )
+ break;
+ }
+ if( i < 4 )
+ {
+ SvxBoxItem aBox( *pBox );
+ for( /*i=0*/; i<4; i++ ) // i points to the mod. line
+ {
+ if( aBox.GetLine( aLines[i] ) &&
+ aBox.GetDistance( aLines[i] ) < MIN_BORDER_DIST )
+ aBox.SetDistance( MIN_BORDER_DIST, aLines[i] );
+ }
+ rSet.Put( aBox );
+ }
+ }
+}
+#endif
+
+// ---------------------------------------------------------------------
+
+class SwXMLImportTableItemMapper_Impl: public SvXMLImportItemMapper
+{
+
+public:
+
+ SwXMLImportTableItemMapper_Impl( SvXMLItemMapEntriesRef rMapEntries );
+ virtual ~SwXMLImportTableItemMapper_Impl();
+
+ virtual sal_Bool handleSpecialItem( const SvXMLItemMapEntry& rEntry,
+ SfxPoolItem& rItem,
+ SfxItemSet& rSet,
+ const OUString& rValue,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap ) const;
+ virtual void finished( SfxItemSet& rSet ) const;
+};
+
+SwXMLImportTableItemMapper_Impl::SwXMLImportTableItemMapper_Impl(
+ SvXMLItemMapEntriesRef rMapEntries ) :
+ SvXMLImportItemMapper( rMapEntries, RES_UNKNOWNATR_CONTAINER)
+{
+}
+
+SwXMLImportTableItemMapper_Impl::~SwXMLImportTableItemMapper_Impl()
+{
+}
+
+sal_Bool SwXMLImportTableItemMapper_Impl::handleSpecialItem(
+ const SvXMLItemMapEntry& rEntry,
+ SfxPoolItem& rItem,
+ SfxItemSet& rItemSet,
+ const OUString& rValue,
+ const SvXMLUnitConverter& rUnitConv,
+ const SvXMLNamespaceMap& ) const
+{
+ sal_Bool bRet = sal_False;
+ sal_uInt16 nMemberId = rEntry.nMemberId & MID_FLAG_MASK;
+ switch( rItem.Which() )
+ {
+ case RES_FRM_SIZE:
+ switch( nMemberId )
+ {
+ case MID_FRMSIZE_COL_WIDTH:
+ // If the item is existing already, a relative value has been set
+ // already that must be preserved.
+ if( SFX_ITEM_SET != rItemSet.GetItemState( RES_FRM_SIZE,
+ sal_False ) )
+ bRet = rItem.importXML( rValue, nMemberId, rUnitConv );
+ break;
+ }
+ }
+
+ return bRet;
+}
+
+void SwXMLImportTableItemMapper_Impl::finished( SfxItemSet& rSet ) const
+{
+#if 0
+ const SfxPoolItem *pItem;
+
+ // ensure that box item have a distance to a border.
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_BOX, sal_False, &pItem ) )
+ {
+ const SvxBoxItem *pBox = (const SvxBoxItem *)pItem;
+ sal_uInt16 aLines[4] = { BOX_LINE_TOP, BOX_LINE_BOTTOM,
+ BOX_LINE_LEFT, BOX_LINE_RIGHT };
+ sal_uInt16 i;
+ for( i=0; i<4; i++ )
+ {
+ if( pBox->GetLine( aLines[i] ) &&
+ pBox->GetDistance( aLines[i] ) < MIN_BORDER_DIST )
+ break;
+ }
+ if( i < 4 )
+ {
+ SvxBoxItem aBox( *pBox );
+ for( /*i=0*/; i<4; i++ ) // i points to the mod. line
+ {
+ if( aBox.GetLine( aLines[i] ) &&
+ aBox.GetDistance( aLines[i] ) < MIN_BORDER_DIST )
+ aBox.SetDistance( MIN_BORDER_DIST, aLines[i] );
+ }
+ rSet.Put( aBox );
+ }
+ }
+#endif
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLItemSetContext_Impl : public SvXMLItemSetContext
+{
+ SvXMLImportContextRef xBackground;
+#ifdef XML_CORE_API
+ SvXMLImportContextRef xTabStop;
+ SvXMLImportContextRef xDropCap;
+#endif
+
+public:
+ SwXMLItemSetContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SfxItemSet& rItemSet,
+ const SvXMLImportItemMapper& rIMapper,
+ const SvXMLUnitConverter& rUnitConv );
+ virtual ~SwXMLItemSetContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SfxItemSet& rItemSet,
+ const SvXMLItemMapEntry& rEntry,
+ const SvXMLUnitConverter& rUnitConv );
+};
+
+SwXMLItemSetContext_Impl::SwXMLItemSetContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SfxItemSet& rItemSet,
+ const SvXMLImportItemMapper& rIMapper,
+ const SvXMLUnitConverter& rUnitConv ) :
+ SvXMLItemSetContext( rImport, nPrfx, rLName, xAttrList,
+ rItemSet, rIMapper, rUnitConv )
+{
+}
+
+SwXMLItemSetContext_Impl::~SwXMLItemSetContext_Impl()
+{
+#ifdef XML_CORE_API
+ if( xTabStop.Is() )
+ {
+ Any aAny;
+ ((SvxXMLTabStopImportContext*)&xTabStop)->fillTabStops( aAny );
+ SvxTabStopItem aTabStop( RES_PARATR_TABSTOP );
+ ((SfxPoolItem *)&aTabStop)->PutValue( aAny, 0 );
+ rItemSet.Put( aTabStop );
+ }
+ if( xDropCap.Is() )
+ {
+ const SwFmtDrop& rItem =
+ ((SwXMLFmtDropImportContext*)&xDropCap)->GetItem();
+ rItemSet.Put( rItem );
+ }
+#endif
+ if( xBackground.Is() )
+ {
+ const SvxBrushItem& rItem =
+ ((SwXMLBrushItemImportContext*)&xBackground)->GetItem();
+ rItemSet.Put( rItem );
+ }
+}
+
+SvXMLImportContext *SwXMLItemSetContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SfxItemSet& rItemSet,
+ const SvXMLItemMapEntry& rEntry,
+ const SvXMLUnitConverter& rUnitConv )
+{
+ SvXMLImportContext *pContext = 0;
+
+ switch( rEntry.nWhichId )
+ {
+#ifdef XML_CORE_API
+ case RES_PARATR_TABSTOP:
+ pContext = new SvxXMLTabStopImportContext( GetImport(), nPrefix,
+ rLocalName, rUnitConv );
+ xTabStop = pContext;
+ break;
+
+ case RES_PARATR_DROP:
+ pContext = new SwXMLFmtDropImportContext( (SwXMLImport&)GetImport(),
+ nPrefix, rLocalName,
+ xAttrList, rUnitConv,
+ RES_PARATR_DROP );
+ xDropCap = pContext;
+ break;
+#endif
+
+ case RES_BACKGROUND:
+ {
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND,
+ sal_False, &pItem ) )
+ {
+ pContext = new SwXMLBrushItemImportContext(
+ GetImport(), nPrefix, rLocalName, xAttrList,
+ rUnitConv, *(const SvxBrushItem *)pItem );
+ }
+ else
+ {
+ pContext = new SwXMLBrushItemImportContext(
+ GetImport(), nPrefix, rLocalName, xAttrList,
+ rUnitConv, RES_BACKGROUND );
+ }
+ xBackground = pContext;
+ }
+ break;
+ }
+
+ if( !pContext )
+ pContext = SvXMLItemSetContext::CreateChildContext( nPrefix, rLocalName,
+ xAttrList, rItemSet,
+ rEntry, rUnitConv );
+
+ return pContext;
+}
+
+// ---------------------------------------------------------------------
+
+void SwXMLImport::_InitItemImport()
+{
+ pTwipUnitConv = new SvXMLUnitConverter( MAP_TWIP, MAP_TWIP );
+
+#ifdef XML_CORE_API
+ SvXMLItemMapEntriesRef xParaItemMapEntries =
+ new SvXMLItemMapEntries( aXMLParaItemMap );
+
+ pParaItemMapper = new SwXMLImportTextItemMapper_Impl( xParaItemMapEntries,
+ GetDoc(), GetI18NMap() );
+#endif
+
+ xTableItemMap = new SvXMLItemMapEntries( aXMLTableItemMap );
+ xTableColItemMap = new SvXMLItemMapEntries( aXMLTableColItemMap );
+ xTableRowItemMap = new SvXMLItemMapEntries( aXMLTableRowItemMap );
+ xTableCellItemMap = new SvXMLItemMapEntries( aXMLTableCellItemMap );
+
+ pTableItemMapper = new SwXMLImportTableItemMapper_Impl( xTableItemMap );
+}
+
+void SwXMLImport::_FinitItemImport()
+{
+#ifdef XML_CORE_API
+ delete pParaItemMapper;
+#endif
+ delete pTableItemMapper;
+ delete pTwipUnitConv;
+}
+
+#ifdef XML_CORE_API
+SvXMLImportContext *SwXMLImport::CreateParaItemImportContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SfxItemSet& rItemSet )
+{
+ return new SwXMLItemSetContext_Impl( *this, nPrefix, rLocalName,
+ xAttrList, rItemSet,
+ GetParaItemMapper(),
+ GetTwipUnitConverter() );
+}
+#endif
+
+SvXMLImportContext *SwXMLImport::CreateTableItemImportContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+#ifdef XML_CORE_API
+ sal_uInt16 nSubFamily,
+#else
+ sal_uInt16 nFamily,
+#endif
+ SfxItemSet& rItemSet )
+{
+ SvXMLItemMapEntriesRef xItemMap;
+
+#ifdef XML_CORE_API
+ switch( nSubFamily )
+#else
+ switch( nFamily )
+#endif
+ {
+#ifdef XML_CORE_API
+ case SW_STYLE_SUBFAMILY_TABLE:
+#else
+ case XML_STYLE_FAMILY_TABLE_TABLE:
+#endif
+ xItemMap = xTableItemMap;
+ break;
+#ifdef XML_CORE_API
+ case SW_STYLE_SUBFAMILY_TABLE_COL:
+#else
+ case XML_STYLE_FAMILY_TABLE_COLUMN:
+#endif
+ xItemMap = xTableColItemMap;
+ break;
+#ifdef XML_CORE_API
+ case SW_STYLE_SUBFAMILY_TABLE_LINE:
+#else
+ case XML_STYLE_FAMILY_TABLE_ROW:
+#endif
+ xItemMap = xTableRowItemMap;
+ break;
+#ifdef XML_CORE_API
+ case SW_STYLE_SUBFAMILY_TABLE_BOX:
+#else
+ case XML_STYLE_FAMILY_TABLE_CELL:
+#endif
+ xItemMap = xTableCellItemMap;
+ break;
+ }
+
+ pTableItemMapper->setMapEntries( xItemMap );
+
+ return new SwXMLItemSetContext_Impl( *this, nPrefix, rLocalName,
+ xAttrList, rItemSet,
+ GetTableItemMapper(),
+ GetTwipUnitConverter() );
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlitemi.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.11 2000/09/18 16:05:07 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.10 2000/08/24 11:16:41 mib
+ text import continued
+
+ Revision 1.9 2000/08/02 14:52:39 mib
+ text export continued
+
+ Revision 1.8 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.7 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.6 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.5 2000/02/17 14:40:30 mib
+ #70271#: XML table import
+
+ Revision 1.3 2000/01/20 14:03:57 mib
+ #70271#: deletion of unit converter
+
+ Revision 1.2 2000/01/06 15:08:28 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+ Revision 1.1 1999/12/14 07:32:58 mib
+ #70271#: XML import/export of drop cap/register/language item, splitted swxmlat
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlitemm.cxx b/sw/source/filter/xml/xmlitemm.cxx
new file mode 100644
index 000000000000..a8f210f815d4
--- /dev/null
+++ b/sw/source/filter/xml/xmlitemm.cxx
@@ -0,0 +1,548 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlitemm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#include <hintids.hxx>
+
+#ifndef _SVX_UNOMID_HXX
+#include <svx/unomid.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_XMLITMAP_HXX
+#include <xmloff/xmlitmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _UNOMID_H
+#include <unomid.h>
+#endif
+
+#define M_E( p, l, w, m ) \
+ { XML_NAMESPACE_##p, sXML_##l, w, m }
+#define M_E_SI( p, l, w, m ) \
+ { XML_NAMESPACE_##p, sXML_##l, w, MID_FLAG_SPECIAL_ITEM_IMPORT|m }
+#define M_E_SE( p, l, w, m ) \
+ { XML_NAMESPACE_##p, sXML_##l, w, MID_FLAG_SPECIAL_ITEM_EXPORT|m }
+
+#ifdef XML_CORE_API
+SvXMLItemMapEntry aXMLParaItemMap[] =
+{
+ // RES_CHRATR_CASEMAP
+ M_E( FO, font_variant, RES_CHRATR_CASEMAP, MID_CASEMAP_VARIANT ),
+ M_E( FO, text_transform, RES_CHRATR_CASEMAP, MID_CASEMAP_TRANS ),
+ // RES_CHRATR_COLOR
+ M_E( FO, color, RES_CHRATR_COLOR, 0 ),
+ // RES_CHRATR_CONTOUR
+ M_E( STYLE, text_outline, RES_CHRATR_CONTOUR, 0 ),
+ // RES_CHRATR_CROSSEDOUT
+ M_E( STYLE, text_crossing_out, RES_CHRATR_CROSSEDOUT, 0 ),
+ // RES_CHRATR_ESCAPEMENT
+ M_E( STYLE, text_position, RES_CHRATR_ESCAPEMENT, 0 ),
+ // RES_CHRATR_FONT
+ M_E( FO, font_family, RES_CHRATR_FONT, MID_FONT_FAMILY_NAME ),
+ M_E( STYLE, font_style_name, RES_CHRATR_FONT, MID_FONT_STYLE_NAME ),
+ M_E( STYLE, font_family_generic,RES_CHRATR_FONT, MID_FONT_FAMILY ),
+ M_E( STYLE, font_pitch, RES_CHRATR_FONT, MID_FONT_PITCH ),
+ M_E( STYLE, font_charset, RES_CHRATR_FONT, MID_FONT_CHAR_SET ),
+ // RES_CHRATR_FONTSIZE
+ M_E( FO, font_size, RES_CHRATR_FONTSIZE, 0 ),
+ // RES_CHRATR_KERNING
+ M_E( FO, letter_spacing, RES_CHRATR_KERNING, 0 ),
+ // RES_CHRATR_LANGUAGE
+ M_E_SI( FO, language, RES_CHRATR_LANGUAGE, MID_LANGUAGE ),
+ M_E_SI( FO, country, RES_CHRATR_LANGUAGE, MID_COUNTRY ),
+ // RES_CHRATR_POSTURE
+ M_E( FO, font_style, RES_CHRATR_POSTURE, 0 ),
+ // RES_CHRATR_PROPORTIONALFONTSIZE
+ // TODO: not used?
+ // RES_CHRATR_SHADOWED
+ M_E( FO, text_shadow, RES_CHRATR_SHADOWED, 0 ),
+ // RES_CHRATR_UNDERLINE
+ M_E( STYLE, text_underline, RES_CHRATR_UNDERLINE, 0 ),
+ // RES_CHRATR_WEIGHT
+ M_E( FO, font_weight, RES_CHRATR_WEIGHT, 0 ),
+ // RES_CHRATR_WORDLINEMODE
+ M_E( FO, score_spaces, RES_CHRATR_WORDLINEMODE, 0 ),
+ // RES_CHRATR_AUTOKERN
+ M_E( STYLE, letter_kerning, RES_CHRATR_AUTOKERN, 0 ),
+ // RES_CHRATR_BLINK
+ M_E( STYLE, text_blinking, RES_CHRATR_BLINK, 0 ),
+ // RES_CHRATR_NOHYPHEN
+ // TODO: not used?
+ // RES_CHRATR_NOLINEBREAK
+ // TODO: not used?
+ // RES_CHRATR_BACKGROUND
+ M_E( FO, text_background_color, RES_CHRATR_BACKGROUND, MID_BACK_COLOR ),
+ // RES_TXTATR_INETFMT
+ // TODO
+ // RES_TXTATR_REFMARK
+ // TODO
+ // RES_TXTATR_TOXMARK
+ // TODO
+ // RES_TXTATR_CHARFMT
+ M_E_SI( TEXT, style_name, RES_TXTATR_CHARFMT, 0 ),
+ // RES_TXTATR_FIELD
+ // TODO
+ // RES_TXTATR_FLYCNT
+ // TODO
+ // RES_TXTATR_FTN
+ // TODO
+ // RES_TXTATR_SOFTHYPH
+ // TODO
+ // RES_TXTATR_HARDBLANK
+ // TODO
+
+ // RES_PARATR_LINESPACING
+ M_E( FO, line_height, RES_PARATR_LINESPACING, MID_LS_FIXED ),
+ M_E( STYLE, line_height_at_least, RES_PARATR_LINESPACING, MID_LS_MINIMUM ),
+ M_E( STYLE, line_spacing, RES_PARATR_LINESPACING, MID_LS_DISTANCE ),
+ // RES_PARATR_ADJUST
+ M_E( FO, text_align, RES_PARATR_ADJUST, MID_PARA_ADJUST ),
+ M_E( FO, text_align_last, RES_PARATR_ADJUST, MID_LAST_LINE_ADJUST ),
+ M_E( STYLE, justify_single_word,RES_PARATR_ADJUST, MID_EXPAND_SINGLE ),
+ // RES_PARATR_SPLIT
+ M_E( STYLE, break_inside, RES_PARATR_SPLIT, 0 ),
+ // RES_PARATR_ORPHANS
+ M_E( FO, orphans, RES_PARATR_ORPHANS, 0 ),
+ // RES_PARATR_WIDOWS
+ M_E( FO, widows, RES_PARATR_WIDOWS, 0 ),
+ // RES_PARATR_TABSTOP
+ M_E( STYLE, tabstop_tab_stops, RES_PARATR_TABSTOP, MID_FLAG_ELEMENT_ITEM ),
+ // RES_PARATR_HYPHENZONE
+ M_E( FO, hyphenate, RES_PARATR_HYPHENZONE,
+ MID_IS_HYPHEN ),
+ M_E( FO, hyphenation_remain_char_count, RES_PARATR_HYPHENZONE,
+ MID_HYPHEN_MIN_LEAD ),
+ M_E( FO, hyphenation_push_char_count, RES_PARATR_HYPHENZONE,
+ MID_HYPHEN_MIN_TRAIL ),
+ M_E( FO, hyphenation_ladder_count, RES_PARATR_HYPHENZONE,
+ MID_HYPHEN_MAX_HYPHENS ),
+ // RES_PARATR_DROP
+ M_E( STYLE, drop_cap, RES_PARATR_DROP, MID_FLAG_ELEMENT_ITEM ),
+ // RES_PARATR_REGISTER
+ M_E( STYLE, register_true, RES_PARATR_REGISTER, 0 ),
+ // RES_PARATR_NUMRULE
+ // not required
+
+ // RES_FILL_ORDER
+ // not required
+ // RES_FRM_SIZE
+ // not required
+ // RES_PAPER_BIN
+ // not required
+ // RES_LR_SPACE
+ M_E( FO, margin_left, RES_LR_SPACE, MID_L_MARGIN ),
+ M_E( FO, margin_right, RES_LR_SPACE, MID_R_MARGIN ),
+ M_E( FO, text_indent, RES_LR_SPACE, MID_FIRST_LINE_INDENT ),
+ M_E( STYLE, auto_text_indent, RES_LR_SPACE, MID_FIRST_AUTO ),
+ // RES_UL_SPACE
+ M_E( FO, margin_top, RES_UL_SPACE, MID_UP_MARGIN ),
+ M_E( FO, margin_bottom, RES_UL_SPACE, MID_LO_MARGIN ),
+ // RES_PAGEDESC
+ // TODO
+ // RES_BREAK
+ M_E( FO, break_before, RES_BREAK, MID_BREAK_BEFORE ),
+ M_E( FO, break_after, RES_BREAK, MID_BREAK_AFTER ),
+ // RES_CNTNT
+ // not required
+ // RES_HEADER
+ // not required
+ // RES_FOOTER
+ // not required
+ // RES_PRINT
+ // not required
+ // RES_OPAQUE
+ // not required
+ // RES_PROTECT
+ // not required
+ // RES_SURROUND
+ // not required
+ // RES_VERT_ORIENT
+ // not required
+ // RES_HORI_ORIENT
+ // not required
+ // RES_ANCHOR
+ // not required
+ // RES_BACKGROUND
+ M_E( FO, background_color, RES_BACKGROUND, MID_BACK_COLOR ),
+ M_E( STYLE, background_image, RES_BACKGROUND, MID_FLAG_ELEMENT_ITEM ),
+ // RES_BOX
+ M_E( STYLE, border_line_width, RES_BOX, ALL_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_left, RES_BOX, LEFT_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_right, RES_BOX, RIGHT_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_top, RES_BOX, TOP_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_bottom, RES_BOX, BOTTOM_BORDER_LINE_WIDTH ),
+ M_E( FO, padding, RES_BOX, ALL_BORDER_PADDING ),
+ M_E( FO, padding_left, RES_BOX, LEFT_BORDER_PADDING ),
+ M_E( FO, padding_right, RES_BOX, RIGHT_BORDER_PADDING ),
+ M_E( FO, padding_top, RES_BOX, TOP_BORDER_PADDING ),
+ M_E( FO, padding_bottom, RES_BOX, BOTTOM_BORDER_PADDING ),
+ M_E( FO, border, RES_BOX, ALL_BORDER ),
+ M_E( FO, border_left, RES_BOX, LEFT_BORDER ),
+ M_E( FO, border_right, RES_BOX, RIGHT_BORDER ),
+ M_E( FO, border_top, RES_BOX, TOP_BORDER ),
+ M_E( FO, border_bottom, RES_BOX, BOTTOM_BORDER ),
+ // RES_SHADOW
+ M_E( STYLE, shadow, RES_SHADOW, 0 ),
+ // RES_FRMMACRO
+ // not required
+ // RES_COL
+ // not required
+ // RES_KEEP
+ M_E( FO, keep_with_next, RES_KEEP, 0 ),
+ // RES_URL
+ // not required
+ // RES_EDIT_IN_READONLY
+ // not required
+ // RES_LAYOUT_SPLIT
+ // not required
+ // RES_CHAIN
+ // not required
+ // RES_LINENUMBER
+ // TODO
+ // RES_FTN_AT_TXTEND
+ // not required
+ // RES_END_AT_TXTEND
+ // not required
+ // RES_UNKNOWNATR_CONTAINER
+ M_E_SE( TEXT, xmlns, RES_UNKNOWNATR_CONTAINER, 0 ),
+ {0,0,0,0 }
+};
+#endif
+
+SvXMLItemMapEntry aXMLTableItemMap[] =
+{
+ // RES_FILL_ORDER
+ // not required
+ // RES_FRM_SIZE
+ M_E_SE( STYLE, width, RES_FRM_SIZE, MID_FRMSIZE_WIDTH ),
+ M_E_SE( STYLE, rel_width, RES_FRM_SIZE, MID_FRMSIZE_REL_WIDTH ),
+ // RES_PAPER_BIN
+ // not required
+ // TODO: RES_LR_SPACE
+ M_E_SE( FO, margin_left, RES_LR_SPACE, MID_L_MARGIN ),
+ M_E_SE( FO, margin_right, RES_LR_SPACE, MID_R_MARGIN ),
+ // RES_UL_SPACE
+ M_E( FO, margin_top, RES_UL_SPACE, MID_UP_MARGIN ),
+ M_E( FO, margin_bottom, RES_UL_SPACE, MID_LO_MARGIN ),
+ // RES_PAGEDESC
+ // TODO
+ // RES_BREAK
+ M_E( FO, break_before, RES_BREAK, MID_BREAK_BEFORE ),
+ M_E( FO, break_after, RES_BREAK, MID_BREAK_AFTER ),
+ // RES_CNTNT
+ // not required
+ // RES_HEADER
+ // not required
+ // RES_FOOTER
+ // not required
+ // RES_PRINT
+ // not required
+ // RES_OPAQUE
+ // not required
+ // RES_PROTECT
+ // not required
+ // RES_SURROUND
+ // not required
+ // RES_VERT_ORIENT
+ // not required
+ // RES_HORI_ORIENT
+ M_E( TABLE, align, RES_HORI_ORIENT, 0 ),
+ // RES_ANCHOR
+ // not required
+ // RES_BACKGROUND
+ M_E( FO, background_color, RES_BACKGROUND, MID_BACK_COLOR ),
+ M_E( STYLE, background_image, RES_BACKGROUND, MID_FLAG_ELEMENT_ITEM ),
+ // RES_BOX
+ // not required
+ // RES_SHADOW
+ M_E( STYLE, shadow, RES_SHADOW, 0 ),
+ // RES_FRMMACRO
+ // not required
+ // RES_COL
+ // not required
+ // RES_KEEP
+ M_E( FO, keep_with_next, RES_KEEP, 0 ),
+ // RES_URL
+ // not required
+ // RES_EDIT_IN_READONLY
+ // not required
+ // RES_LAYOUT_SPLIT
+ M_E( STYLE, may_break_between_rows, RES_LAYOUT_SPLIT, 0 ),
+ // RES_CHAIN
+ // not required
+ // RES_LINENUMBER
+ // not required
+ // RES_FTN_AT_TXTEND
+ // not required
+ // RES_END_AT_TXTEND
+ // not required
+ // RES_UNKNOWNATR_CONTAINER
+ M_E_SE( TEXT, xmlns, RES_UNKNOWNATR_CONTAINER, 0 ),
+ {0,0,0,0 }
+};
+
+SvXMLItemMapEntry aXMLTableColItemMap[] =
+{
+ M_E_SI( STYLE, column_width, RES_FRM_SIZE, MID_FRMSIZE_COL_WIDTH ),
+ M_E( STYLE, rel_column_width, RES_FRM_SIZE, MID_FRMSIZE_REL_COL_WIDTH ),
+ {0,0,0,0 }
+};
+
+SvXMLItemMapEntry aXMLTableRowItemMap[] =
+{
+ // RES_FILL_ORDER
+ // not required
+ // RES_FRM_SIZE
+ M_E( STYLE, row_height, RES_FRM_SIZE, MID_FRMSIZE_FIX_HEIGHT ),
+ M_E( STYLE, min_row_height, RES_FRM_SIZE, MID_FRMSIZE_MIN_HEIGHT ),
+ // RES_PAPER_BIN
+ // not required
+ // RES_LR_SPACE
+ // not required
+ // RES_UL_SPACE
+ // not required
+ // RES_PAGEDESC
+ // not required
+ // RES_BREAK
+ // not required
+ // RES_CNTNT
+ // not required
+ // RES_HEADER
+ // not required
+ // RES_FOOTER
+ // not required
+ // RES_PRINT
+ // not required
+ // RES_OPAQUE
+ // not required
+ // RES_PROTECT
+ // not required
+ // RES_SURROUND
+ // not required
+ // RES_VERT_ORIENT
+ // not required
+ // RES_HORI_ORIENT
+ // not required
+ // RES_ANCHOR
+ // not required
+ // RES_BACKGROUND
+ M_E( FO, background_color, RES_BACKGROUND, MID_BACK_COLOR ),
+ M_E( STYLE, background_image, RES_BACKGROUND, MID_FLAG_ELEMENT_ITEM ),
+ // RES_BOX
+ // not required
+ // RES_ANCHOR
+ // not required
+ // RES_SHADOW
+ // not required
+ // RES_FRMMACRO
+ // not required
+ // RES_COL
+ // not required
+ // RES_KEEP
+ // not required
+ // RES_URL
+ // not required
+ // RES_EDIT_IN_READONLY
+ // not required
+ // RES_LAYOUT_SPLIT
+ // not required
+ // RES_CHAIN
+ // not required
+ // RES_LINENUMBER
+ // not required
+ // RES_FTN_AT_TXTEND
+ // not required
+ // RES_END_AT_TXTEND
+ // not required
+ // RES_UNKNOWNATR_CONTAINER
+ M_E_SE( TEXT, xmlns, RES_UNKNOWNATR_CONTAINER, 0 ),
+ {0,0,0,0 }
+};
+
+SvXMLItemMapEntry aXMLTableCellItemMap[] =
+{
+ // RES_FILL_ORDER
+ // not required
+ // RES_FRM_SIZE
+ // not required
+ // RES_PAPER_BIN
+ // not required
+ // RES_LR_SPACE
+ // not required
+ // RES_UL_SPACE
+ // not required
+ // RES_PAGEDESC
+ // not required
+ // RES_BREAK
+ // not required
+ // RES_CNTNT
+ // not required
+ // RES_HEADER
+ // not required
+ // RES_FOOTER
+ // not required
+ // RES_PRINT
+ // not required
+ // RES_OPAQUE
+ // not required
+ // RES_PROTECT
+ // not required
+ // RES_SURROUND
+ // not required
+ // RES_VERT_ORIENT
+ M_E( TABLE, vertical_align, RES_VERT_ORIENT, 0 ),
+ // RES_HORI_ORIENT
+ // not required
+ // RES_ANCHOR
+ // not required
+ // RES_BACKGROUND
+ M_E( FO, background_color, RES_BACKGROUND, MID_BACK_COLOR ),
+ M_E( STYLE, background_image, RES_BACKGROUND, MID_FLAG_ELEMENT_ITEM ),
+ // RES_BOX
+ M_E( STYLE, border_line_width, RES_BOX, ALL_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_left, RES_BOX, LEFT_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_right, RES_BOX, RIGHT_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_top, RES_BOX, TOP_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_bottom, RES_BOX, BOTTOM_BORDER_LINE_WIDTH ),
+ M_E( FO, padding, RES_BOX, ALL_BORDER_PADDING ),
+ M_E( FO, padding_left, RES_BOX, LEFT_BORDER_PADDING ),
+ M_E( FO, padding_right, RES_BOX, RIGHT_BORDER_PADDING ),
+ M_E( FO, padding_top, RES_BOX, TOP_BORDER_PADDING ),
+ M_E( FO, padding_bottom, RES_BOX, BOTTOM_BORDER_PADDING ),
+ M_E( FO, border, RES_BOX, ALL_BORDER ),
+ M_E( FO, border_left, RES_BOX, LEFT_BORDER ),
+ M_E( FO, border_right, RES_BOX, RIGHT_BORDER ),
+ M_E( FO, border_top, RES_BOX, TOP_BORDER ),
+ M_E( FO, border_bottom, RES_BOX, BOTTOM_BORDER ),
+ // RES_SHADOW
+ // not required
+ // RES_FRMMACRO
+ // not required
+ // RES_COL
+ // not required
+ // RES_KEEP
+ // not required
+ // RES_URL
+ // not required
+ // RES_EDIT_IN_READONLY
+ // not required
+ // RES_LAYOUT_SPLIT
+ // not required
+ // RES_CHAIN
+ // not required
+ // RES_LINENUMBER
+ // not required
+ // RES_FTN_AT_TXTEND
+ // not required
+ // RES_END_AT_TXTEND
+ // not required
+ // RES_UNKNOWNATR_CONTAINER
+ M_E_SE( TEXT, xmlns, RES_UNKNOWNATR_CONTAINER, 0 ),
+ {0,0,0,0 }
+};
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlitemm.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.8 2000/09/18 16:05:07 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.7 2000/08/24 11:16:41 mib
+ text import continued
+
+ Revision 1.6 2000/08/10 10:22:16 mib
+ #74404#: Adeptions to new XSL/XLink working draft
+
+ Revision 1.5 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.4 2000/02/17 14:40:30 mib
+ #70271#: XML table import
+
+ Revision 1.3 2000/02/07 10:03:28 mib
+ #70271#: tables
+
+ Revision 1.2 2000/01/12 15:00:23 mib
+ #70271#: lists
+
+ Revision 1.1 1999/12/14 07:33:08 mib
+ #70271#: XML import/export of drop cap/register/language item, splitted swxmlat
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlmeta.cxx b/sw/source/filter/xml/xmlmeta.cxx
new file mode 100644
index 000000000000..9ea50332e4f9
--- /dev/null
+++ b/sw/source/filter/xml/xmlmeta.cxx
@@ -0,0 +1,227 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlmeta.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#include <hintids.hxx>
+
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XDOCUMENTINFOSUPPLIER_HPP_
+#include <com/sun/star/document/XDocumentInfoSupplier.hpp>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLMETAI_HXX
+#include <xmloff/xmlmetai.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLMETAE_HXX
+#include <xmloff/xmlmetae.hxx>
+#endif
+
+#ifndef _SVX_LANGITEM_HXX
+#include <svx/langitem.hxx>
+#endif
+
+#ifndef _SWDOCSH_HXX
+#include "docsh.hxx"
+#endif
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+
+#ifndef _XMLIMP_HXX
+#include "xmlimp.hxx"
+#endif
+#ifndef _XMLEXP_HXX
+#include "xmlexp.hxx"
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+// ---------------------------------------------------------------------
+
+#if 0
+class SwXMLMetaContext_Impl : public SfxXMLMetaContext
+{
+public:
+ SwXMLMetaContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< document::XDocumentInfo > & rInfo ) :
+ SfxXMLMetaContext( rImport, nPrfx, rLName, rInfo )
+ {}
+
+ virtual void SetDocLanguage( LanguageType eLang );
+};
+
+void SwXMLMetaContext_Impl::SetDocLanguage( LanguageType eLang )
+{
+ SwDoc& rDoc = ((SwXMLImport&)GetImport()).GetDoc();
+
+ rDoc.SetDefault( SvxLanguageItem( eLang, RES_CHRATR_LANGUAGE ) );
+}
+#endif
+
+// ---------------------------------------------------------------------
+
+SvXMLImportContext *SwXMLImport::CreateMetaContext(
+ const OUString& rLocalName )
+{
+ SvXMLImportContext *pContext = 0;
+
+ if( !(IsStylesOnlyMode() || IsInsertMode()) )
+ {
+ pContext = new SfxXMLMetaContext( *this,
+ XML_NAMESPACE_OFFICE, rLocalName,
+ GetModel() );
+#if 0
+ SfxObjectShell* pObjSh = pDoc->GetDocShell();
+ if( pObjSh )
+ {
+ Reference< frame::XModel > xModel = pObjSh->GetBaseModel();
+ Reference< document::XDocumentInfoSupplier > xSupp( xModel,
+ UNO_QUERY );
+ if( xSupp.is() )
+ pContext = new SwXMLMetaContext_Impl( *this,
+ XML_NAMESPACE_OFFICE, rLocalName,
+ xSupp->getDocumentInfo() );
+ }
+#endif
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( *this, XML_NAMESPACE_OFFICE,
+ rLocalName );
+
+ return pContext;
+}
+
+// ---------------------------------------------------------------------
+
+#if 0
+void SwXMLExport::_ExportMeta()
+{
+ SfxObjectShell* pObjSh = pDoc->GetDocShell();
+ if( pObjSh )
+ {
+ pObjSh->UpdateDocInfoForSave(); // update information
+
+ LanguageType eDocLang = ((const SvxLanguageItem&)
+ pDoc->GetDefault(RES_CHRATR_LANGUAGE)).GetLanguage();
+
+ Reference< frame::XModel > xModel = pObjSh->GetBaseModel();
+ Reference< document::XDocumentInfoSupplier > xSupp( xModel,
+ UNO_QUERY );
+ if( xSupp.is() )
+ {
+ SfxXMLMetaExport aMeta( GetDocHandler(), xSupp->getDocumentInfo(),
+ eDocLang );
+ aMeta.Export( GetNamespaceMap() );
+ }
+ }
+}
+#endif
+
+
+/*************************************************************************
+
+ Source Code Control chaos::System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlmeta.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control chaos::System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.7 2000/09/18 16:05:07 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.6 2000/08/02 14:52:39 mib
+ text export continued
+
+ Revision 1.5 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.4 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.3 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.2 2000/02/11 14:42:04 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.1 2000/01/06 15:03:49 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
new file mode 100644
index 000000000000..7f33e1b6ad98
--- /dev/null
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -0,0 +1,1085 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmltble.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#include <hintids.hxx>
+
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXTTABLE_HPP_
+#include <com/sun/star/text/XTextTable.hpp>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLUCONV_HXX
+#include <xmloff/xmluconv.hxx>
+#endif
+
+#ifndef _CNTRSRT_HXX
+#include <svtools/cntnrsrt.hxx>
+#endif
+
+#ifndef _SVX_BRSHITEM_HXX
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX
+#include <svx/boxitem.hxx>
+#endif
+
+#ifndef _SWTABLE_HXX
+#include "swtable.hxx"
+#endif
+#ifndef _DOC_HXX
+#include "doc.hxx"
+#endif
+#ifndef _PAM_HXX
+#include "pam.hxx"
+#endif
+#ifndef _FRMFMT_HXX
+#include "frmfmt.hxx"
+#endif
+#ifndef _WRTSWTBL_HXX
+#include "wrtswtbl.hxx"
+#endif
+#ifndef _FMTFSIZE_HXX
+#include "fmtfsize.hxx"
+#endif
+#ifndef _FMTORNT_HXX
+#include "fmtornt.hxx"
+#endif
+
+#ifndef _UNOOBJ_HXX
+#include "unoobj.hxx"
+#endif
+#ifndef _UNOTBL_HXX
+#include "unotbl.hxx"
+#endif
+
+#ifndef _XMLTEXTE_HXX
+#include "xmltexte.hxx"
+#endif
+#ifndef _XMLEXP_HXX
+#include "xmlexp.hxx"
+#endif
+#ifndef _XMLECTXT_HXX
+#include "xmlectxt.hxx"
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+
+#ifndef XML_CORE_API
+Reference < XText > lcl_xml_CreateTableBoxText(
+ const SwStartNode& rBoxSttNd )
+{
+ SwPaM aPaM( *rBoxSttNd.EndOfSectionNode() );
+ aPaM.Move( fnMoveBackward, fnGoNode );
+ aPaM.SetMark();
+ aPaM.GetPoint()->nNode.Assign( rBoxSttNd );
+ aPaM.Move( fnMoveForward, fnGoNode );
+
+ Reference < XTextRange > xTextRange =
+ CreateTextRangeFromPosition( aPaM.GetDoc(), *aPaM.GetPoint(),
+ aPaM.GetMark() );
+ return xTextRange->getText();
+}
+#endif
+
+class SwXMLTableColumn_Impl : public SwWriteTableCol
+{
+ OUString sStyleName;
+ sal_uInt32 nRelWidth;
+
+public:
+
+
+ SwXMLTableColumn_Impl( sal_uInt16 nPosition ) :
+ SwWriteTableCol( nPosition ),
+ nRelWidth( 0UL )
+ {};
+
+ void SetStyleName( const OUString& rName ) { sStyleName = rName; }
+ const OUString& GetStyleName() const { return sStyleName; }
+
+ void SetRelWidth( sal_uInt32 nSet ) { nRelWidth = nSet; }
+ sal_uInt32 GetRelWidth() const { return nRelWidth; }
+};
+
+sal_Int32 SwXMLTableColumnCmpWidth_Impl( const SwXMLTableColumn_Impl& r1,
+ const SwXMLTableColumn_Impl& r2 )
+{
+ sal_Int32 n = (sal_Int32)r1.GetWidthOpt() - (sal_Int32)r2.GetWidthOpt();
+ if( !n )
+ n = (sal_Int32)r1.GetRelWidth() - (sal_Int32)r2.GetRelWidth();
+ return n;
+}
+
+// ---------------------------------------------------------------------
+
+typedef SwXMLTableColumn_Impl *SwXMLTableColumnPtr;
+SV_DECL_PTRARR_SORT_DEL( SwXMLTableColumns_Impl, SwXMLTableColumnPtr, 5, 5 )
+SV_IMPL_OP_PTRARR_SORT( SwXMLTableColumns_Impl, SwXMLTableColumnPtr )
+
+DECLARE_CONTAINER_SORT( SwXMLTableColumnsSortByWidth_Impl,
+ SwXMLTableColumn_Impl )
+IMPL_CONTAINER_SORT( SwXMLTableColumnsSortByWidth_Impl, SwXMLTableColumn_Impl,
+ SwXMLTableColumnCmpWidth_Impl )
+
+class SwXMLTableLines_Impl
+{
+ SwXMLTableColumns_Impl aCols;
+ const SwTableLines *pLines;
+ sal_uInt32 nWidth;
+
+public:
+
+ SwXMLTableLines_Impl( const SwTableLines& rLines );
+
+ ~SwXMLTableLines_Impl() {}
+
+ sal_uInt32 GetWidth() const { return nWidth; }
+ const SwTableLines *GetLines() const { return pLines; }
+
+ const SwXMLTableColumns_Impl& GetColumns() const { return aCols; }
+};
+
+SwXMLTableLines_Impl::SwXMLTableLines_Impl( const SwTableLines& rLines ) :
+ pLines( &rLines ),
+ nWidth( 0UL )
+{
+#ifndef PRODUCT
+ sal_uInt16 nEndCPos = 0U;
+#endif
+ sal_uInt16 nLines = rLines.Count();
+ sal_uInt16 nLine;
+ for( nLine=0U; nLine<nLines; nLine++ )
+ {
+ const SwTableLine *pLine = rLines[nLine];
+ const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
+ sal_uInt16 nBoxes = rBoxes.Count();
+
+ sal_uInt16 nCPos = 0U;
+ for( sal_uInt16 nBox=0U; nBox<nBoxes; nBox++ )
+ {
+ const SwTableBox *pBox = rBoxes[nBox];
+
+ sal_uInt16 nOldCPos = nCPos;
+
+ if( nBox < nBoxes-1U || nWidth==0UL )
+ {
+ nCPos += (sal_uInt16)SwWriteTable::GetBoxWidth( pBox );
+ SwXMLTableColumn_Impl *pCol =
+ new SwXMLTableColumn_Impl( nCPos );
+
+ if( !aCols.Insert( pCol ) )
+ delete pCol;
+
+ if( nBox==nBoxes-1U )
+ {
+ ASSERT( nLine==0U && nWidth==0UL,
+ "parent width will be lost" );
+ nWidth = nCPos;
+ }
+ }
+ else
+ {
+#ifndef PRODUCT
+ sal_uInt16 nCheckPos =
+ nCPos + (sal_uInt16)SwWriteTable::GetBoxWidth( pBox );
+ if( !nEndCPos )
+ {
+ nEndCPos = nCheckPos;
+ }
+ else
+ {
+ /*
+ ASSERT( SwXMLTableColumn_impl(nCheckPos) ==
+ SwXMLTableColumn_Impl(nEndCPos),
+ "rows have different total widths" );
+ */
+ }
+#endif
+ nCPos = nWidth;
+#ifndef PRODUCT
+ SwXMLTableColumn_Impl aCol( nWidth );
+ ASSERT( aCols.Seek_Entry(&aCol), "couldn't find last column" );
+ ASSERT( SwXMLTableColumn_Impl(nCheckPos) ==
+ SwXMLTableColumn_Impl(nCPos),
+ "rows have different total widths" );
+#endif
+ }
+ }
+ }
+}
+
+typedef SwXMLTableLines_Impl *SwXMLTableLinesPtr;
+DECLARE_LIST( SwXMLTableLinesCache_Impl, SwXMLTableLinesPtr )
+
+// ---------------------------------------------------------------------
+
+typedef SwFrmFmt *SwFrmFmtPtr;
+DECLARE_LIST( SwXMLFrmFmts_Impl, SwFrmFmtPtr )
+
+class SwXMLTableFrmFmtsSort_Impl : public SwXMLFrmFmts_Impl
+{
+public:
+ SwXMLTableFrmFmtsSort_Impl ( sal_uInt16 nInit, sal_uInt16 nGrow ) :
+ SwXMLFrmFmts_Impl( nInit, nGrow )
+ {}
+
+ sal_Bool AddRow( SwFrmFmt& rFrmFmt, const OUString& rNamePrefix, sal_uInt32 nLine );
+ sal_Bool AddCell( SwFrmFmt& rFrmFmt, const OUString& rNamePrefix,
+ sal_uInt32 nCol, sal_uInt32 nRow, sal_Bool bTop );
+};
+
+sal_Bool SwXMLTableFrmFmtsSort_Impl::AddRow( SwFrmFmt& rFrmFmt,
+ const OUString& rNamePrefix,
+ sal_uInt32 nLine )
+{
+ const SwFmtFrmSize *pFrmSize = 0;
+ const SvxBrushItem *pBrush = 0;
+
+ const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_FRM_SIZE, sal_False, &pItem ) )
+ pFrmSize = (const SwFmtFrmSize *)pItem;
+
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, sal_False, &pItem ) )
+ pBrush = (const SvxBrushItem *)pItem;
+
+ // empty styles have not to be exported
+ if( !pFrmSize && !pBrush )
+ return sal_False;
+
+ // order is: -/brush, size/-, size/brush
+ sal_uInt32 nCount = Count();
+ sal_Bool bInsert = sal_True;
+ sal_uInt32 i;
+ for( i=0; i<nCount; i++ )
+ {
+ const SwFmtFrmSize *pTestFrmSize = 0;
+ const SvxBrushItem *pTestBrush = 0;
+ const SwFrmFmt *pTestFmt = GetObject(i);
+ const SfxItemSet& rTestSet = pTestFmt->GetAttrSet();
+ if( SFX_ITEM_SET == rTestSet.GetItemState( RES_FRM_SIZE, sal_False,
+ &pItem ) )
+ {
+ if( !pFrmSize )
+ break;
+
+ pTestFrmSize = (const SwFmtFrmSize *)pItem;
+ }
+ else
+ {
+ if( pFrmSize )
+ continue;
+ }
+
+ if( SFX_ITEM_SET == rTestSet.GetItemState( RES_BACKGROUND, sal_False,
+ &pItem ) )
+ {
+ if( !pBrush )
+ break;
+
+ pTestBrush = (const SvxBrushItem *)pItem;
+ }
+ else
+ {
+ if( pBrush )
+ continue;
+ }
+
+ if( pFrmSize &&
+ ( pFrmSize->GetSizeType() != pTestFrmSize->GetSizeType() ||
+ pFrmSize->GetHeight() != pTestFrmSize->GetHeight() ) )
+ continue;
+
+ if( pBrush && !pBrush->equalsXML( *pTestBrush ) )
+ continue;
+
+ // found!
+ const String& rFmtName = pTestFmt->GetName();
+ rFrmFmt.SetName( rFmtName );
+ bInsert = sal_False;
+ break;
+ }
+
+ if( bInsert )
+ {
+ OUStringBuffer sBuffer( rNamePrefix.getLength() + 4UL );
+ sBuffer.append( rNamePrefix );
+ sBuffer.append( (sal_Unicode)'.' );
+ sBuffer.append( (sal_Int32)(nLine+1UL) );
+
+ rFrmFmt.SetName( sBuffer.makeStringAndClear() );
+ Insert( &rFrmFmt, i );
+ }
+
+ return bInsert;
+}
+
+void lcl_GetTblBoxColStr( sal_uInt16 nCol, String& rNm );
+void lcl_xmltble_appendBoxPrefix( OUStringBuffer& rBuffer,
+ const OUString& rNamePrefix,
+ sal_uInt16 nCol, sal_uInt16 nRow, sal_Bool bTop )
+{
+ rBuffer.append( rNamePrefix );
+ rBuffer.append( (sal_Unicode)'.' );
+ if( bTop )
+ {
+ String sTmp;
+ lcl_GetTblBoxColStr( nCol, sTmp );
+ rBuffer.append( sTmp );
+ }
+ else
+ {
+ rBuffer.append( (sal_Int32)(nCol + 1));
+ rBuffer.append( (sal_Unicode)'.' );
+ }
+ rBuffer.append( (sal_Int32)(nRow + 1));
+}
+
+sal_Bool SwXMLTableFrmFmtsSort_Impl::AddCell( SwFrmFmt& rFrmFmt,
+ const OUString& rNamePrefix,
+ sal_uInt32 nCol, sal_uInt32 nRow, sal_Bool bTop )
+{
+ const SwFmtVertOrient *pVertOrient = 0;
+ const SvxBrushItem *pBrush = 0;
+ const SvxBoxItem *pBox = 0;
+
+ const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_VERT_ORIENT, sal_False,
+ &pItem ) )
+ pVertOrient = (const SwFmtVertOrient *)pItem;
+
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, sal_False, &pItem ) )
+ pBrush = (const SvxBrushItem *)pItem;
+
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BOX, sal_False, &pItem ) )
+ pBox = (const SvxBoxItem *)pItem;
+
+ // empty styles have not to be exported
+ if( !pVertOrient && !pBrush && !pBox )
+ return sal_False;
+
+ // order is: -/-/box, -/brush/-, -/brush/box,
+ // vert/-/-, vert/-/box, vert/brush/-, vert/brush/box
+ sal_uInt32 nCount = Count();
+ sal_Bool bInsert = sal_True;
+ sal_uInt32 i;
+ for( i=0; i<nCount; i++ )
+ {
+ const SwFmtVertOrient *pTestVertOrient = 0;
+ const SvxBrushItem *pTestBrush = 0;
+ const SvxBoxItem *pTestBox = 0;
+ const SwFrmFmt *pTestFmt = GetObject(i);
+ const SfxItemSet& rTestSet = pTestFmt->GetAttrSet();
+ if( SFX_ITEM_SET == rTestSet.GetItemState( RES_VERT_ORIENT, sal_False,
+ &pItem ) )
+ {
+ if( !pVertOrient )
+ break;
+
+ pTestVertOrient = (const SwFmtVertOrient *)pItem;
+ }
+ else
+ {
+ if( pVertOrient )
+ continue;
+ }
+
+ if( SFX_ITEM_SET == rTestSet.GetItemState( RES_BACKGROUND, sal_False,
+ &pItem ) )
+ {
+ if( !pBrush )
+ break;
+
+ pTestBrush = (const SvxBrushItem *)pItem;
+ }
+ else
+ {
+ if( pBrush )
+ continue;
+ }
+
+ if( SFX_ITEM_SET == rTestSet.GetItemState( RES_BOX, sal_False, &pItem ) )
+ {
+ if( !pBox )
+ break;
+
+ pTestBox = (const SvxBoxItem *)pItem;
+ }
+ else
+ {
+ if( pBox )
+ continue;
+ }
+
+ if( pVertOrient &&
+ pVertOrient->GetVertOrient() != pTestVertOrient->GetVertOrient() )
+ continue;
+
+ if( pBrush && !pBrush->equalsXML( *pTestBrush ) )
+ continue;
+
+ if( pBox && !pBox->equalsXML( *pTestBox ) )
+ continue;
+
+ // found!
+ const String& rFmtName = pTestFmt->GetName();
+ rFrmFmt.SetName( rFmtName );
+ bInsert = sal_False;
+ break;
+ }
+
+ if( bInsert )
+ {
+ OUStringBuffer sBuffer( rNamePrefix.getLength() + 8UL );
+ lcl_xmltble_appendBoxPrefix( sBuffer, rNamePrefix, nCol, nRow, bTop );
+ rFrmFmt.SetName( sBuffer.makeStringAndClear() );
+ Insert( &rFrmFmt, i );
+ }
+
+ return bInsert;
+}
+// ---------------------------------------------------------------------
+
+
+void SwXMLExport::ExportTableColumnStyle( const SwXMLTableColumn_Impl& rCol )
+{
+ // <style:style ...>
+ CheckAttrList();
+
+ // style:name="..."
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_name, rCol.GetStyleName() );
+
+ // style:family="table-column"
+ AddAttributeASCII( XML_NAMESPACE_STYLE, sXML_family, sXML_table_column );
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE, sXML_style, sal_True,
+ sal_True );
+ OUStringBuffer sValue;
+ if( rCol.GetWidthOpt() )
+ {
+ GetTwipUnitConverter().convertMeasure( sValue, rCol.GetWidthOpt() );
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_column_width,
+ sValue.makeStringAndClear() );
+ }
+ if( rCol.GetRelWidth() )
+ {
+ sValue.append( (sal_Int32)rCol.GetRelWidth() );
+ sValue.append( (sal_Unicode)'*' );
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_rel_column_width,
+ sValue.makeStringAndClear() );
+ }
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE,
+ sXML_properties, sal_True, sal_True );
+ }
+ }
+}
+
+void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
+ sal_uInt32 nAbsWidth, sal_uInt32 nBaseWidth,
+ const OUString& rNamePrefix,
+ SwXMLTableColumnsSortByWidth_Impl& rExpCols,
+ SwXMLTableFrmFmtsSort_Impl& rExpRows,
+ SwXMLTableFrmFmtsSort_Impl& rExpCells,
+ sal_Bool bTop )
+{
+ // pass 1: calculate columns
+ SwXMLTableLines_Impl *pLines =
+ new SwXMLTableLines_Impl( rLines );
+ if( !pTableLines )
+ pTableLines = new SwXMLTableLinesCache_Impl( 5, 5 );
+ pTableLines->Insert( pLines, pTableLines->Count() );
+
+ OUStringBuffer sBuffer( rNamePrefix.getLength() + 8L );
+
+ // pass 2: export column styles
+ {
+ const SwXMLTableColumns_Impl& rCols = pLines->GetColumns();
+ sal_uInt16 nCPos = 0U;
+ sal_uInt16 nColumns = rCols.Count();
+ for( sal_uInt16 nColumn=0U; nColumn<nColumns; nColumn++ )
+ {
+ SwXMLTableColumn_Impl *pColumn = rCols[nColumn];
+
+ sal_uInt16 nOldCPos = nCPos;
+ nCPos = pColumn->GetPos();
+
+ sal_uInt32 nWidth = nCPos - nOldCPos;
+
+ // If a base width is given, the table has either an automatic
+ // or margin alignment, or an percentage width. In either case,
+ // relative widths should be exported.
+ if( nBaseWidth )
+ {
+ pColumn->SetRelWidth( nWidth );
+ }
+
+ // If an absolute width is given, the table either has a fixed
+ // width, or the current width is known from the layout. In the
+ // later case, a base width is set in addition and must be used
+ // to "absoultize" the relative column width.
+ if( nAbsWidth )
+ {
+ sal_uInt32 nColAbsWidth = nWidth;
+ if( nBaseWidth )
+ {
+ nColAbsWidth *= nAbsWidth;
+ nColAbsWidth += (nBaseWidth/2UL);
+ nColAbsWidth /= nBaseWidth;
+ }
+ pColumn->SetWidthOpt( nColAbsWidth, sal_False );
+ }
+
+ sal_uInt32 nExpPos = 0;
+ if( rExpCols.Seek_Entry( pColumn, &nExpPos ) )
+ {
+ pColumn->SetStyleName(
+ rExpCols.GetObject(nExpPos)->GetStyleName() );
+ }
+ else
+ {
+ sBuffer.append( rNamePrefix );
+ sBuffer.append( (sal_Unicode)'.' );
+ if( bTop )
+ {
+ String sTmp;
+ lcl_GetTblBoxColStr( nColumn, sTmp );
+ sBuffer.append( sTmp );
+ }
+ else
+ {
+ sBuffer.append( (sal_Int32)(nColumn + 1U) );
+ }
+
+ pColumn->SetStyleName( sBuffer.makeStringAndClear() );
+ ExportTableColumnStyle( *pColumn );
+ rExpCols.Insert( pColumn );
+ }
+ }
+ }
+
+ // pass 3: export line/rows
+ sal_uInt16 nLines = rLines.Count();
+ for( sal_uInt16 nLine=0U; nLine<nLines; nLine++ )
+ {
+ SwTableLine *pLine = rLines[nLine];
+
+ SwFrmFmt *pFrmFmt = pLine->GetFrmFmt();
+ if( rExpRows.AddRow( *pFrmFmt, rNamePrefix, nLine ) )
+ ExportFmt( *pFrmFmt, sXML_table_row );
+
+ const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
+ sal_uInt16 nBoxes = rBoxes.Count();
+
+ sal_uInt16 nCPos = 0U;
+ sal_uInt16 nCol = 0U;
+ for( sal_uInt16 nBox=0U; nBox<nBoxes; nBox++ )
+ {
+ const SwTableBox *pBox = rBoxes[nBox];
+
+ sal_uInt16 nOldCPos = nCPos;
+ if( nBox < nBoxes-1U )
+ nCPos += (sal_uInt16)SwWriteTable::GetBoxWidth( pBox );
+ else
+ nCPos = pLines->GetWidth();
+
+
+ // Und ihren Index
+ sal_uInt16 nOldCol = nCol;
+ SwXMLTableColumn_Impl aCol( nCPos );
+ sal_Bool bFound = pLines->GetColumns().Seek_Entry( &aCol, &nCol );
+ ASSERT( bFound, "couldn't find column" );
+
+ const SwStartNode *pBoxSttNd = pBox->GetSttNd();
+ if( pBoxSttNd )
+ {
+#ifdef XML_CORE_API
+ SwNode *pStartNd = pDoc->GetNodes()[pBoxSttNd->GetIndex()+1];
+ SwNode *pEndNd =
+ pDoc->GetNodes()[pBoxSttNd->EndOfSectionIndex()-1];
+ SwXMLExpContext aContext( *this, *pStartNd, *pEndNd,
+ 0, STRING_LEN );
+#endif
+
+ SwFrmFmt *pFrmFmt = pBox->GetFrmFmt();
+ if( rExpCells.AddCell( *pFrmFmt, rNamePrefix, nOldCol, nLine,
+ bTop) )
+ ExportFmt( *pFrmFmt, sXML_table_cell );
+
+#ifdef XML_CORE_API
+ ExportCurPaMAutoStyles();
+#else
+ GetTextParagraphExport()->collectTextAutoStyles(
+ lcl_xml_CreateTableBoxText( *pBoxSttNd ) );
+#endif
+ }
+ else
+ {
+ lcl_xmltble_appendBoxPrefix( sBuffer, rNamePrefix, nOldCol,
+ nLine, bTop );
+
+ ExportTableLinesAutoStyles( pBox->GetTabLines(),
+ nAbsWidth, nBaseWidth,
+ sBuffer.makeStringAndClear(),
+ rExpCols, rExpRows, rExpCells );
+ }
+
+ nCol++;
+ }
+ }
+}
+
+void SwXMLExport::ExportTableAutoStyles( const SwTableNode& rTblNd )
+{
+ const SwTable& rTbl = rTblNd.GetTable();
+ const SwFrmFmt *pTblFmt = rTbl.GetFrmFmt();
+
+ if( pTblFmt )
+ {
+ SwHoriOrient eTabHoriOri = pTblFmt->GetHoriOrient().GetHoriOrient();
+ const SwFmtFrmSize& rFrmSize = pTblFmt->GetFrmSize();
+
+ sal_uInt32 nAbsWidth = rFrmSize.GetSize().Width();
+ sal_uInt32 nBaseWidth = 0UL;
+ sal_Int8 nPrcWidth = rFrmSize.GetWidthPercent();
+
+ sal_Bool bFixAbsWidth = nPrcWidth != 0 || HORI_NONE == eTabHoriOri
+ || HORI_FULL == eTabHoriOri;
+ if( bFixAbsWidth )
+ {
+ nBaseWidth = nAbsWidth;
+ nAbsWidth = pTblFmt->FindLayoutRect(sal_True).Width();
+ if( !nAbsWidth )
+ {
+ // TODO???
+ }
+ }
+ ExportTableFmt( *pTblFmt, nAbsWidth );
+
+ OUString sName( pTblFmt->GetName() );
+ SwXMLTableColumnsSortByWidth_Impl aExpCols( 10, 10 );
+ SwXMLTableFrmFmtsSort_Impl aExpRows( 10, 10 );
+ SwXMLTableFrmFmtsSort_Impl aExpCells( 10, 10 );
+ ExportTableLinesAutoStyles( rTbl.GetTabLines(), nAbsWidth, nBaseWidth,
+ sName, aExpCols, aExpRows, aExpCells,
+ sal_True );
+ }
+
+#ifdef XML_CORE_API
+ pCurPaM->GetPoint()->nNode = *rTblNd.EndOfSectionNode();
+#endif
+}
+
+// ---------------------------------------------------------------------
+
+void SwXMLExport::ExportTableBox( const SwTableBox& rBox, sal_uInt16 nColSpan )
+{
+ const SwStartNode *pBoxSttNd = rBox.GetSttNd();
+ if( pBoxSttNd )
+ {
+ const SwFrmFmt *pFrmFmt = rBox.GetFrmFmt();
+ if( pFrmFmt )
+ {
+ const String& rName = pFrmFmt->GetName();
+ if( rName.Len() )
+ {
+ AddAttribute( XML_NAMESPACE_TABLE, sXML_style_name, rName );
+ }
+ }
+ }
+
+ if( nColSpan != 1 )
+ {
+ OUStringBuffer sTmp;
+ sTmp.append( (sal_Int32)nColSpan );
+ AddAttribute( XML_NAMESPACE_TABLE, sXML_number_columns_spanned,
+ sTmp.makeStringAndClear() );
+ }
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
+ sXML_table_cell, sal_True, sal_True );
+ if( pBoxSttNd )
+ {
+#ifdef XML_CORE_API
+ SwNode *pStartNd = pDoc->GetNodes()[pBoxSttNd->GetIndex()+1];
+ SwNode *pEndNd = pDoc->GetNodes()[pBoxSttNd->EndOfSectionIndex()-1];
+ SwXMLExpContext aContext( *this, *pStartNd, *pEndNd,
+ 0, STRING_LEN );
+ ExportCurPaM();
+#else
+ GetTextParagraphExport()->exportText(
+ lcl_xml_CreateTableBoxText( *pBoxSttNd ) );
+#endif
+ }
+ else
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
+ sXML_sub_table, sal_True, sal_True );
+ ExportTableLines( rBox.GetTabLines() );
+ }
+ }
+}
+
+void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
+ const SwXMLTableLines_Impl& rLines )
+{
+ const SwFrmFmt *pFrmFmt = rLine.GetFrmFmt();
+ if( pFrmFmt )
+ {
+ const String& rName = pFrmFmt->GetName();
+ if( rName.Len() )
+ {
+ AddAttribute( XML_NAMESPACE_TABLE, sXML_style_name, rName );
+ }
+ }
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
+ sXML_table_row, sal_True, sal_True );
+ const SwTableBoxes& rBoxes = rLine.GetTabBoxes();
+ sal_uInt16 nBoxes = rBoxes.Count();
+
+ sal_uInt16 nCPos = 0U;
+ sal_uInt16 nCol = 0U;
+ for( sal_uInt16 nBox=0U; nBox<nBoxes; nBox++ )
+ {
+ const SwTableBox *pBox = rBoxes[nBox];
+
+ sal_uInt16 nOldCPos = nCPos;
+ if( nBox < nBoxes-1U )
+ nCPos += (sal_uInt16)SwWriteTable::GetBoxWidth( pBox );
+ else
+ nCPos = rLines.GetWidth();
+
+ // Und ihren Index
+ sal_uInt16 nOldCol = nCol;
+ SwXMLTableColumn_Impl aCol( nCPos );
+ sal_Bool bFound = rLines.GetColumns().Seek_Entry( &aCol, &nCol );
+ ASSERT( bFound, "couldn't find column" );
+
+ sal_uInt16 nColSpan = nCol - nOldCol + 1U;
+ ExportTableBox( *pBox, nColSpan );
+ for( sal_uInt16 i=nOldCol; i<nCol; i++ )
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
+ sXML_covered_table_cell, sal_True,
+ sal_False );
+ }
+
+ nCol++;
+ }
+ }
+}
+
+void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
+ sal_Bool bHeadline )
+{
+ ASSERT( pTableLines && pTableLines->Count(),
+ "SwXMLExport::ExportTableLines: table columns infos missing" );
+ if( !pTableLines || 0 == pTableLines->Count() )
+ return;
+
+ SwXMLTableLines_Impl *pLines = 0;
+ sal_uInt16 nInfoPos;
+ for( nInfoPos=0; nInfoPos < pTableLines->Count(); nInfoPos++ )
+ {
+ if( pTableLines->GetObject( nInfoPos )->GetLines() == &rLines )
+ {
+ pLines = pTableLines->GetObject( nInfoPos );
+ break;
+ }
+ }
+ ASSERT( pLines,
+ "SwXMLExport::ExportTableLines: table columns info missing" );
+ ASSERT( 0==nInfoPos,
+ "SwXMLExport::ExportTableLines: table columns infos are unsorted" );
+ if( !pLines )
+ return;
+
+ // pass 2: export columns
+ const SwXMLTableColumns_Impl& rCols = pLines->GetColumns();
+ sal_uInt16 nColumn = 0U;
+ sal_uInt16 nColumns = rCols.Count();
+ sal_uInt16 nColRep = 1U;
+ SwXMLTableColumn_Impl *pColumn = (nColumns > 0) ? rCols[0U] : 0;
+ while( pColumn )
+ {
+ nColumn++;
+ SwXMLTableColumn_Impl *pNextColumn =
+ (nColumn < nColumns) ? rCols[nColumn] : 0;
+ if( pNextColumn &&
+ pNextColumn->GetStyleName() == pColumn->GetStyleName() )
+ {
+ nColRep++;
+ }
+ else
+ {
+ AddAttribute( XML_NAMESPACE_TABLE, sXML_style_name,
+ pColumn->GetStyleName() );
+
+ if( nColRep > 1U )
+ {
+ OUStringBuffer sTmp(4);
+ sTmp.append( (sal_Int32)nColRep );
+ AddAttribute( XML_NAMESPACE_TABLE, sXML_number_columns_repeated,
+ sTmp.makeStringAndClear() );
+ }
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
+ sXML_table_column, sal_True, sal_True );
+ }
+
+ nColRep = 1U;
+ }
+ pColumn = pNextColumn;
+ }
+
+ // pass 3: export line/rows
+ sal_uInt16 nLines = rLines.Count();
+ for( sal_uInt16 nLine=0U; nLine<nLines; nLine++ )
+ {
+ const SwTableLine *pLine = rLines[nLine];
+ if( bHeadline && 0U==nLine )
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
+ sXML_table_header_rows, sal_True, sal_True );
+ ExportTableLine( *pLine, *pLines );
+ }
+ else
+ {
+ ExportTableLine( *pLine, *pLines );
+ }
+ }
+
+ pTableLines->Remove( nInfoPos );
+ if( 0 == pTableLines->Count() )
+ {
+ delete pTableLines ;
+ pTableLines = 0;
+ }
+ delete pLines;
+}
+
+sal_Bool lcl_xmltble_ClearName_Line( const SwTableLine*& rpLine, void* );
+
+sal_Bool lcl_xmltble_ClearName_Box( const SwTableBox*& rpBox, void* )
+{
+ if( !rpBox->GetSttNd() )
+ {
+ ((SwTableBox *)rpBox)->GetTabLines().ForEach(
+ &lcl_xmltble_ClearName_Line, 0 );
+ }
+ else
+ {
+ SwFrmFmt *pFrmFmt = ((SwTableBox *)rpBox)->GetFrmFmt();
+ if( pFrmFmt && pFrmFmt->GetName().Len() )
+ pFrmFmt->SetName( aEmptyStr );
+ }
+
+ return sal_True;
+}
+
+sal_Bool lcl_xmltble_ClearName_Line( const SwTableLine*& rpLine, void* )
+{
+ ((SwTableLine *)rpLine)->GetTabBoxes().ForEach(
+ &lcl_xmltble_ClearName_Box, 0 );
+
+ return sal_True;
+}
+
+void SwXMLExport::ExportTable( const SwTableNode& rTblNd )
+{
+ const SwTable& rTbl = rTblNd.GetTable();
+ const SwFrmFmt *pTblFmt = rTbl.GetFrmFmt();
+ if( pTblFmt && pTblFmt->GetName().Len() )
+ {
+ AddAttribute( XML_NAMESPACE_TABLE, sXML_name, pTblFmt->GetName() );
+ AddAttribute( XML_NAMESPACE_TABLE, sXML_style_name,
+ pTblFmt->GetName() );
+ }
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, sXML_table,
+ sal_True, sal_True );
+ ExportTableLines( rTbl.GetTabLines(), rTbl.IsHeadlineRepeat() );
+
+ ((SwTable &)rTbl).GetTabLines().ForEach( &lcl_xmltble_ClearName_Line,
+ 0 );
+ }
+
+#ifdef XML_CORE_API
+ pCurPaM->GetPoint()->nNode = *rTblNd.EndOfSectionNode();
+#endif
+}
+
+#ifndef XML_CORE_API
+void SwXMLTextParagraphExport::exportTable(
+ const Reference < XTextContent > & rTextContent,
+ sal_Bool bAutoStyles )
+{
+// Reference < XPropertySet > xPropSet( rTextContent, UNO_QUERY );
+// Any aAny = xPropSet->getPropertyValue( sTextTable );
+
+ Reference < XTextTable > xTxtTbl( rTextContent, UNO_QUERY );
+// aAny >>= xTxtTbl;
+ DBG_ASSERT( xTxtTbl.is(), "text table missing" );
+ if( xTxtTbl.is() )
+ {
+ const SwXTextTable *pXTable = 0;
+ Reference<XUnoTunnel> xTableTunnel( rTextContent, UNO_QUERY);
+ if( xTableTunnel.is() )
+ {
+ pXTable = (SwXTextTable*)xTableTunnel->getSomething(
+ SwXTextTable::getUnoTunnelId() );
+ ASSERT( pXTable, "SwXTextTable missing" );
+ }
+ if( pXTable )
+ {
+ SwFrmFmt *pFmt = pXTable->GetFrmFmt();
+ ASSERT( pFmt, "table format missing" );
+ const SwTable *pTbl = SwTable::FindTable( pFmt );
+ ASSERT( pTbl, "table missing" );
+ const SwTableNode *pTblNd = pTbl->GetTableNode();
+ ASSERT( pTblNd, "table node missing" );
+ if( bAutoStyles )
+ {
+ ((SwXMLExport&)GetExport()).ExportTableAutoStyles( *pTblNd );
+ }
+ else
+ {
+ ((SwXMLExport&)GetExport()).ExportTable( *pTblNd );
+ }
+ }
+ }
+}
+#endif
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmltble.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.11 2000/09/18 16:05:07 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.10 2000/09/05 09:51:10 mib
+ #78063#: table lines cache is sorted now
+
+ Revision 1.9 2000/07/31 09:42:35 mib
+ text export continued
+
+ Revision 1.8 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.7 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.6 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.5 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.4 2000/02/11 17:08:37 kz
+ #65293# cast Syntax
+
+ Revision 1.3 2000/02/11 14:42:15 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.2 2000/02/08 06:47:09 mib
+ #70271#: remove temporary table cell format names
+
+ Revision 1.1 2000/02/07 10:02:55 mib
+ #70271#: table export
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
new file mode 100644
index 000000000000..a9205eef3ef8
--- /dev/null
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -0,0 +1,2229 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmltbli.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#include "hintids.hxx"
+
+#include <limits.h>
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TEXT_XTEXTTABLE_HPP_
+#include <com/sun/star/text/XTextTable.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_TABLE_XCELLRANGE_HPP_
+#include <com/sun/star/table/XCellRange.hpp>
+#endif
+
+#ifndef _SFXITEMSET_HXX
+#include <svtools/itemset.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLTKMAP_HXX
+#include <xmloff/xmltkmap.hxx>
+#endif
+
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+
+#ifndef _XMLOFF_FAMILIES_HXX
+#include <xmloff/families.hxx>
+#endif
+
+#ifndef _POOLFMT_HXX
+#include "poolfmt.hxx"
+#endif
+#ifndef _FMTFSIZE_HXX
+#include "fmtfsize.hxx"
+#endif
+#ifndef _FMTORNT_HXX
+#include "fmtornt.hxx"
+#endif
+#ifndef _FMTFORDR_HXX
+#include "fmtfordr.hxx"
+#endif
+#ifndef _DOC_HXX
+#include "doc.hxx"
+#endif
+#ifndef _SWTABLE_HXX
+#include "swtable.hxx"
+#endif
+#ifndef _SWTBLFMT_HXX
+#include "swtblfmt.hxx"
+#endif
+#ifndef _PAM_HXX
+#include "pam.hxx"
+#endif
+#ifndef _UNOTBL_HXX
+#include "unotbl.hxx"
+#endif
+#ifndef _UNOCRSR_HXX
+#include "unocrsr.hxx"
+#endif
+
+#ifndef _XMLTEXTI_HXX
+#include "xmltexti.hxx"
+#endif
+#ifndef _XMLNUM_HXX
+#include "xmlnum.hxx"
+#endif
+#ifndef _XMLIMP_HXX
+#include "xmlimp.hxx"
+#endif
+#ifndef _XMLTBLI_HXX
+#include "xmltbli.hxx"
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::xml::sax;
+
+enum SwXMLTableElemTokens
+{
+ XML_TOK_TABLE_HEADER_COLS,
+ XML_TOK_TABLE_COLS,
+ XML_TOK_TABLE_COL,
+ XML_TOK_TABLE_HEADER_ROWS,
+ XML_TOK_TABLE_ROWS,
+ XML_TOK_TABLE_ROW,
+ XML_TOK_TABLE_ELEM_END=XML_TOK_UNKNOWN
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aTableElemTokenMap[] =
+{
+ { XML_NAMESPACE_TABLE, sXML_table_header_columns,
+ XML_TOK_TABLE_HEADER_COLS },
+ { XML_NAMESPACE_TABLE, sXML_table_columns, XML_TOK_TABLE_COLS },
+ { XML_NAMESPACE_TABLE, sXML_table_column, XML_TOK_TABLE_COL },
+ { XML_NAMESPACE_TABLE, sXML_table_header_rows,
+ XML_TOK_TABLE_HEADER_ROWS },
+ { XML_NAMESPACE_TABLE, sXML_table_rows, XML_TOK_TABLE_ROWS },
+ { XML_NAMESPACE_TABLE, sXML_table_row, XML_TOK_TABLE_ROW },
+ XML_TOKEN_MAP_END
+};
+
+const SvXMLTokenMap& SwXMLImport::GetTableElemTokenMap()
+{
+ if( !pTableElemTokenMap )
+ pTableElemTokenMap = new SvXMLTokenMap( aTableElemTokenMap );
+
+ return *pTableElemTokenMap;
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLTableCell_Impl
+{
+ OUString aStyleName;
+
+ SvXMLImportContextRef xSubTable;
+
+ const SwStartNode *pStartNode;
+ sal_uInt32 nRowSpan;
+ sal_uInt32 nColSpan;
+
+ sal_Bool bProtected : 1;
+
+public:
+
+ SwXMLTableCell_Impl( sal_uInt32 nRSpan=1UL, sal_uInt32 nCSpan=1UL ) :
+ nRowSpan( nRSpan ),
+ nColSpan( nCSpan ),
+ pStartNode( 0 ),
+ bProtected( sal_False )
+ {}
+
+ inline void Set( const OUString& rStyleName,
+ sal_uInt32 nRSpan, sal_uInt32 nCSpan,
+ const SwStartNode *pStNd, SwXMLTableContext *pTable );
+
+ sal_Bool IsUsed() const { return pStartNode!=0 ||
+ xSubTable.Is() || bProtected;}
+
+ sal_uInt32 GetRowSpan() const { return nRowSpan; }
+ void SetRowSpan( sal_uInt32 nSet ) { nRowSpan = nSet; }
+ sal_uInt32 GetColSpan() const { return nColSpan; }
+ const OUString& GetStyleName() const { return aStyleName; }
+
+ const SwStartNode *GetStartNode() const { return pStartNode; }
+ inline void SetStartNode( const SwStartNode *pSttNd );
+
+ inline SwXMLTableContext *GetSubTable() const;
+
+ inline void Dispose();
+};
+
+inline void SwXMLTableCell_Impl::Set( const OUString& rStyleName,
+ sal_uInt32 nRSpan, sal_uInt32 nCSpan,
+ const SwStartNode *pStNd,
+ SwXMLTableContext *pTable )
+{
+ aStyleName = rStyleName;
+ nRowSpan = nRSpan;
+ nColSpan = nCSpan;
+ pStartNode = pStNd;
+ xSubTable = pTable;
+}
+
+inline void SwXMLTableCell_Impl::SetStartNode( const SwStartNode *pSttNd )
+{
+ pStartNode = pSttNd;
+ xSubTable = 0;
+}
+
+inline SwXMLTableContext *SwXMLTableCell_Impl::GetSubTable() const
+{
+ return (SwXMLTableContext *)&xSubTable;
+}
+
+inline void SwXMLTableCell_Impl::Dispose()
+{
+ if( xSubTable.Is() )
+ xSubTable = 0;
+}
+
+// ---------------------------------------------------------------------
+
+typedef SwXMLTableCell_Impl* SwXMLTableCellPtr;
+SV_DECL_PTRARR_DEL(SwXMLTableCells_Impl,SwXMLTableCellPtr,5,5)
+SV_IMPL_PTRARR(SwXMLTableCells_Impl,SwXMLTableCellPtr)
+
+class SwXMLTableRow_Impl
+{
+ OUString aStyleName;
+
+ SwXMLTableCells_Impl aCells;
+
+ sal_Bool bSplitable;
+
+public:
+
+ SwXMLTableRow_Impl( const OUString& rStyleName, sal_uInt32 nCells );
+ ~SwXMLTableRow_Impl() {}
+
+ inline SwXMLTableCell_Impl *GetCell( sal_uInt32 nCol ) const;
+
+ inline void Set( const OUString& rStyleName );
+
+ void Expand( sal_uInt32 nCells, sal_Bool bOneCell );
+
+ void SetSplitable( sal_Bool bSet ) { bSplitable = bSet; }
+ sal_Bool IsSplitable() const { return bSplitable; }
+
+
+ const OUString& GetStyleName() const { return aStyleName; }
+
+ void Dispose();
+};
+
+SwXMLTableRow_Impl::SwXMLTableRow_Impl( const OUString& rStyleName,
+ sal_uInt32 nCells ) :
+ aStyleName( rStyleName ),
+ bSplitable( sal_False )
+{
+ ASSERT( nCells <= USHRT_MAX,
+ "SwXMLTableRow_Impl::SwXMLTableRow_Impl: too many cells" );
+ if( nCells > USHRT_MAX )
+ nCells = USHRT_MAX;
+
+ for( sal_uInt16 i=0U; i<nCells; i++ )
+ {
+ aCells.Insert( new SwXMLTableCell_Impl, aCells.Count() );
+ }
+}
+
+inline SwXMLTableCell_Impl *SwXMLTableRow_Impl::GetCell( sal_uInt32 nCol ) const
+{
+ ASSERT( nCol < USHRT_MAX,
+ "SwXMLTableRow_Impl::GetCell: column number is to big" );
+ return aCells[(sal_uInt16)nCol];
+}
+
+void SwXMLTableRow_Impl::Expand( sal_uInt32 nCells, sal_Bool bOneCell )
+{
+ ASSERT( nCells <= USHRT_MAX,
+ "SwXMLTableRow_Impl::Expand: too many cells" );
+ if( nCells > USHRT_MAX )
+ nCells = USHRT_MAX;
+
+ sal_uInt32 nColSpan = nCells - aCells.Count();
+ for( sal_uInt16 i=aCells.Count(); i<nCells; i++ )
+ {
+ aCells.Insert( new SwXMLTableCell_Impl( 1UL,
+ bOneCell ? nColSpan : 1UL ),
+ aCells.Count() );
+ nColSpan--;
+ }
+
+ ASSERT( nCells<=aCells.Count(),
+ "SwXMLTableRow_Impl::Expand: wrong number of cells" );
+}
+
+inline void SwXMLTableRow_Impl::Set( const OUString& rStyleName )
+{
+ aStyleName = rStyleName;
+}
+
+void SwXMLTableRow_Impl::Dispose()
+{
+ for( sal_uInt16 i=0; i < aCells.Count(); i++ )
+ aCells[i]->Dispose();
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLTableCellContext_Impl : public SvXMLImportContext
+{
+ OUString aStyleName;
+
+ SvXMLImportContextRef xMyTable;
+
+ sal_uInt32 nRowSpan;
+ sal_uInt32 nColSpan;
+
+ sal_Bool bHasContent;
+
+ SwXMLTableContext *GetTable() { return (SwXMLTableContext *)&xMyTable; }
+
+ sal_Bool HasContent() const { return bHasContent; }
+ inline void InsertContentIfNotThere();
+ inline void InsertContent( SwXMLTableContext *pTable );
+
+public:
+
+ SwXMLTableCellContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable );
+
+ virtual ~SwXMLTableCellContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+ virtual void EndElement();
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+
+SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ xMyTable( pTable ),
+ nRowSpan( 1UL ),
+ nColSpan( 1UL ),
+ bHasContent( sal_False )
+{
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ const OUString& rValue = xAttrList->getValueByIndex( i );
+ if( XML_NAMESPACE_TABLE == nPrefix )
+ {
+ if( aLocalName.compareToAscii( sXML_style_name ) == 0 )
+ aStyleName = rValue;
+ else if( aLocalName.compareToAscii(
+ sXML_number_columns_spanned ) == 0 )
+ {
+ nColSpan = (sal_uInt32)rValue.toInt32();
+ if( nColSpan < 1UL )
+ nColSpan = 1UL;
+ }
+ else if( aLocalName.compareToAscii(
+ sXML_number_rows_spanned ) == 0 )
+ {
+ nRowSpan = (sal_uInt32)rValue.toInt32();
+ if( nRowSpan < 1UL )
+ nRowSpan = 1UL;
+ }
+ }
+ }
+}
+
+SwXMLTableCellContext_Impl::~SwXMLTableCellContext_Impl()
+{
+}
+
+inline void SwXMLTableCellContext_Impl::InsertContentIfNotThere()
+{
+ if( !bHasContent )
+ {
+ GetTable()->InsertCell( aStyleName, nRowSpan, nColSpan,
+ GetTable()->InsertTableSection() );
+ bHasContent = sal_True;
+ }
+}
+
+inline void SwXMLTableCellContext_Impl::InsertContent(
+ SwXMLTableContext *pTable )
+{
+ GetTable()->InsertCell( aStyleName, nRowSpan, nColSpan, 0, pTable );
+ bHasContent = sal_True;
+}
+
+SvXMLImportContext *SwXMLTableCellContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+#ifdef XML_CORE_API
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetBodyElemTokenMap();
+ sal_Bool bOrdered = sal_False;
+ sal_Bool bHeading = sal_False;
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_SW_H:
+ bHeading = sal_True;
+ case XML_TOK_SW_P:
+ InsertContentIfNotThere();
+ pContext = new SwXMLParaContext( GetSwImport(),nPrefix, rLocalName,
+ xAttrList, bHeading );
+ break;
+ case XML_TOK_SW_ORDERED_LIST:
+ bOrdered = sal_True;
+ case XML_TOK_SW_UNORDERED_LIST:
+ InsertContentIfNotThere();
+ pContext = new SwXMLListBlockContext( GetSwImport(),nPrefix, rLocalName,
+ xAttrList, bOrdered );
+ break;
+
+ case XML_TOK_TABLE_SUBTABLE:
+ if( !HasContent() )
+ {
+ SwXMLTableContext *pTblContext =
+ new SwXMLTableContext( GetSwImport(), nPrefix, rLocalName,
+ xAttrList, GetTable() );
+ pContext = pTblContext;
+ InsertContent( pTblContext );
+ }
+ break;
+ }
+#else
+ if( XML_NAMESPACE_TABLE == nPrefix &&
+ 0 == rLocalName.compareToAscii( sXML_sub_table ) )
+ {
+ if( !HasContent() )
+ {
+ SwXMLTableContext *pTblContext =
+ new SwXMLTableContext( GetSwImport(), nPrefix, rLocalName,
+ xAttrList, GetTable() );
+ pContext = pTblContext;
+ InsertContent( pTblContext );
+ }
+ }
+ else
+ {
+ InsertContentIfNotThere();
+ pContext = GetImport().GetTextImport()->CreateTextChildContext(
+ GetImport(), nPrefix, rLocalName, xAttrList,
+ XML_TEXT_TYPE_CELL );
+ }
+#endif
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+void SwXMLTableCellContext_Impl::EndElement()
+{
+ if( bHasContent )
+ {
+#ifdef XML_CORE_API
+ SwPaM& rPaM = GetSwImport().GetPaM();
+ SwCntntNode* pCNd = rPaM.GetCntntNode();
+ if( pCNd && pCNd->StartOfSectionIndex() + 2UL <
+ pCNd->EndOfSectionIndex() )
+ {
+ rPaM.GetPoint()->nContent.Assign( 0, 0U );
+ rPaM.SetMark();
+ rPaM.DeleteMark();
+ GetSwImport().GetDoc().GetNodes().Delete( rPaM.GetPoint()->nNode );
+ rPaM.Move( fnMoveBackward, fnGoNode );
+ }
+#else
+ if( GetImport().GetTextImport()->GetCursor()->goLeft( 1, sal_True ) )
+ {
+ OUString sEmpty;
+ GetImport().GetTextImport()->GetText()->insertString(
+ GetImport().GetTextImport()->GetCursorAsRange(), sEmpty,
+ sal_True );
+ }
+#endif
+ }
+ else
+ {
+ InsertContentIfNotThere();
+ }
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLTableColContext_Impl : public SvXMLImportContext
+{
+ SvXMLImportContextRef xMyTable;
+
+ SwXMLTableContext *GetTable() { return (SwXMLTableContext *)&xMyTable; }
+
+public:
+
+ SwXMLTableColContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable );
+
+ virtual ~SwXMLTableColContext_Impl();
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+
+SwXMLTableColContext_Impl::SwXMLTableColContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ xMyTable( pTable )
+{
+ sal_uInt32 nColRep = 1UL;
+ OUString aStyleName;
+
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ const OUString& rValue = xAttrList->getValueByIndex( i );
+ if( XML_NAMESPACE_TABLE == nPrefix )
+ {
+ if( aLocalName.compareToAscii( sXML_style_name ) == 0 )
+ aStyleName = rValue;
+ else if( aLocalName.compareToAscii(
+ sXML_number_columns_repeated ) == 0 )
+ nColRep = (sal_uInt32)rValue.toInt32();
+ }
+ }
+
+ sal_Int32 nWidth = MINLAY;
+ sal_Bool bRelWidth = sal_True;
+ if( aStyleName.getLength() )
+ {
+ const SfxPoolItem *pItem;
+ const SfxItemSet *pAutoItemSet = 0;
+ if( GetSwImport().FindAutomaticStyle(
+#ifdef XML_CORE_API
+ SFX_STYLE_FAMILY_FRAME, SW_STYLE_SUBFAMILY_TABLE_COL,
+#else
+ XML_STYLE_FAMILY_TABLE_COLUMN,
+#endif
+ aStyleName, &pAutoItemSet ) &&
+ pAutoItemSet &&
+ SFX_ITEM_SET == pAutoItemSet->GetItemState( RES_FRM_SIZE, sal_False,
+ &pItem ) )
+ {
+ const SwFmtFrmSize *pSize = ((const SwFmtFrmSize *)pItem);
+ nWidth = pSize->GetWidth();
+ bRelWidth = ATT_VAR_SIZE == pSize->GetSizeType();
+ }
+ }
+
+ if( nWidth )
+ {
+ while( nColRep-- && GetTable()->IsInsertColPossible() )
+ GetTable()->InsertColumn( nWidth, bRelWidth );
+ }
+}
+
+SwXMLTableColContext_Impl::~SwXMLTableColContext_Impl()
+{
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLTableColsContext_Impl : public SvXMLImportContext
+{
+ SvXMLImportContextRef xMyTable;
+ sal_Bool bHeader;
+
+ SwXMLTableContext *GetTable() { return (SwXMLTableContext *)&xMyTable; }
+
+public:
+
+ SwXMLTableColsContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable,
+ sal_Bool bHead );
+
+ virtual ~SwXMLTableColsContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+
+SwXMLTableColsContext_Impl::SwXMLTableColsContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable, sal_Bool bHead ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ xMyTable( pTable ),
+ bHeader( bHead )
+{
+}
+
+SwXMLTableColsContext_Impl::~SwXMLTableColsContext_Impl()
+{
+}
+
+SvXMLImportContext *SwXMLTableColsContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ if( XML_NAMESPACE_TABLE == nPrefix &&
+ rLocalName.compareToAscii( sXML_table_column ) == 0 &&
+ GetTable()->IsInsertColPossible() )
+ pContext = new SwXMLTableColContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ GetTable() );
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLTableRowContext_Impl : public SvXMLImportContext
+{
+ SvXMLImportContextRef xMyTable;
+
+ SwXMLTableContext *GetTable() { return (SwXMLTableContext *)&xMyTable; }
+
+public:
+
+ SwXMLTableRowContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable, sal_Bool bInHead=sal_False );
+
+ virtual ~SwXMLTableRowContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+
+ virtual void EndElement();
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+
+SwXMLTableRowContext_Impl::SwXMLTableRowContext_Impl( SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable,
+ sal_Bool bInHead ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ xMyTable( pTable )
+{
+ OUString aStyleName;
+
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ const OUString& rValue = xAttrList->getValueByIndex( i );
+ if( XML_NAMESPACE_TABLE == nPrefix &&
+ aLocalName.compareToAscii( sXML_style_name ) == 0 )
+ {
+ aStyleName = rValue;
+ }
+ }
+ GetTable()->InsertRow( aStyleName, bInHead );
+}
+
+void SwXMLTableRowContext_Impl::EndElement()
+{
+ GetTable()->FinishRow();
+}
+
+SwXMLTableRowContext_Impl::~SwXMLTableRowContext_Impl()
+{
+}
+
+SvXMLImportContext *SwXMLTableRowContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ if( XML_NAMESPACE_TABLE == nPrefix )
+ {
+ if( rLocalName.compareToAscii( sXML_table_cell ) == 0 )
+ {
+ if( GetTable()->IsInsertCellPossible() )
+ pContext = new SwXMLTableCellContext_Impl( GetSwImport(),
+ nPrefix,
+ rLocalName,
+ xAttrList,
+ GetTable() );
+ }
+ else if( rLocalName.compareToAscii( sXML_covered_table_cell ) == 0 )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix,
+ rLocalName );
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLTableRowsContext_Impl : public SvXMLImportContext
+{
+ SvXMLImportContextRef xMyTable;
+
+ sal_Bool bHeader;
+
+ SwXMLTableContext *GetTable() { return (SwXMLTableContext *)&xMyTable; }
+
+public:
+
+ SwXMLTableRowsContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable,
+ sal_Bool bHead );
+
+ virtual ~SwXMLTableRowsContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+
+SwXMLTableRowsContext_Impl::SwXMLTableRowsContext_Impl( SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable,
+ sal_Bool bHead ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ xMyTable( pTable ),
+ bHeader( bHead )
+{
+}
+
+SwXMLTableRowsContext_Impl::~SwXMLTableRowsContext_Impl()
+{
+}
+
+SvXMLImportContext *SwXMLTableRowsContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ if( XML_NAMESPACE_TABLE == nPrefix &&
+ rLocalName.compareToAscii( sXML_table_row ) == 0 &&
+ GetTable()->IsInsertRowPossible() )
+ pContext = new SwXMLTableRowContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ GetTable(),
+ bHeader );
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+// ---------------------------------------------------------------------
+
+typedef SwXMLTableRow_Impl* SwXMLTableRowPtr;
+SV_DECL_PTRARR_DEL(SwXMLTableRows_Impl,SwXMLTableRowPtr,5,5)
+SV_IMPL_PTRARR(SwXMLTableRows_Impl,SwXMLTableRowPtr)
+
+SwXMLTableCell_Impl *SwXMLTableContext::GetCell( sal_uInt32 nRow,
+ sal_uInt32 nCol ) const
+{
+ return (*pRows)[nRow]->GetCell( nCol );
+}
+
+SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ pRows( new SwXMLTableRows_Impl ),
+ pTableNode( 0 ),
+ pBox1( 0 ),
+ pSttNd1( 0 ),
+ pBoxFmt( 0 ),
+ pLineFmt( 0 ),
+ nCurRow( 0UL ),
+ nCurCol( 0UL ),
+ nWidth( 0UL ),
+ bFirstSection( sal_True ),
+ bRelWidth( sal_True ),
+ bHasHeading( sal_False )
+{
+ OUString aName;
+
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ const OUString& rValue = xAttrList->getValueByIndex( i );
+ if( XML_NAMESPACE_TABLE == nPrefix )
+ {
+ if( aLocalName.compareToAscii( sXML_style_name ) == 0 )
+ aStyleName = rValue;
+ else if( aLocalName.compareToAscii( sXML_name ) == 0 )
+ aName = rValue;
+ }
+ }
+
+ SwXMLImport& rSwImport = GetSwImport();
+ SwDoc& rDoc = rSwImport.GetDoc();
+
+ String sTblName;
+ if( aName.getLength() )
+ {
+ const SwTableFmt *pTblFmt = rDoc.FindTblFmtByName( aName );
+ if( !pTblFmt )
+ sTblName = aName;
+ }
+ if( !sTblName.Len() )
+ sTblName = rDoc.GetUniqueTblName();
+
+#ifdef XML_CORE_API
+ const SwTable* pSwTable = rDoc.InsertTable( *rSwImport.GetPaM().GetPoint(),
+ 1U, 1U, HORI_LEFT );
+ pTableNode = pSwTable->GetTableNode();
+
+ SwFrmFmt *pTblFrmFmt = pSwTable->GetFrmFmt();
+ pTblFrmFmt->SetName( sTblName );
+
+ rSwImport.GetPaM().Move( fnMoveBackward );
+#else
+ Reference< XTextTable > xTable;
+
+ const SwXTextTable *pXTable = 0;
+ Reference<XMultiServiceFactory> xFactory( GetImport().GetModel(),
+ UNO_QUERY );
+ ASSERT( xFactory.is(), "factory missing" );
+ if( xFactory.is() )
+ {
+ OUString sService(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextTable" ) );
+ Reference<XInterface> xIfc = xFactory->createInstance( sService );
+ ASSERT( xIfc.is(), "Couldn't create a table" );
+
+ if( xIfc.is() )
+ xTable = Reference< XTextTable > ( xIfc, UNO_QUERY );
+ }
+
+ if( xTable.is() )
+ {
+ xTable->initialize( 1, 1 );
+
+ Reference< XTextContent > xTxtCnt( xTable, UNO_QUERY );
+ GetImport().GetTextImport()->InsertTextContent( xTxtCnt );
+
+ Reference<XUnoTunnel> xTableTunnel( xTable, UNO_QUERY);
+ if( xTableTunnel.is() )
+ {
+ pXTable = (SwXTextTable*)xTableTunnel->getSomething(
+ SwXTextTable::getUnoTunnelId() );
+ ASSERT( pXTable, "SwXTextTable missing" );
+ }
+
+ Reference < XCellRange > xCellRange( xTable, UNO_QUERY );
+ Reference < XCell > xCell = xCellRange->getCellByPosition( 0, 0 );
+ Reference < XText> xText( xCell, UNO_QUERY );
+ xOldCursor = GetImport().GetTextImport()->GetCursor();
+ GetImport().GetTextImport()->SetCursor( xText->createTextCursor() );
+
+ }
+ if( pXTable )
+ {
+ SwFrmFmt *pTblFrmFmt = pXTable->GetFrmFmt();
+ ASSERT( pTblFrmFmt, "table format missing" );
+ SwTable *pTbl = SwTable::FindTable( pTblFrmFmt );
+ ASSERT( pTbl, "table missing" );
+ pTableNode = pTbl->GetTableNode();
+ ASSERT( pTableNode, "table node missing" );
+
+ pTblFrmFmt->SetName( sTblName );
+
+ SwTableLine *pLine1 = pTableNode->GetTable().GetTabLines()[0U];
+ pBox1 = pLine1->GetTabBoxes()[0U];
+ pSttNd1 = pBox1->GetSttNd();
+ }
+#endif
+}
+
+SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ xParentTable( pTable ),
+ pRows( new SwXMLTableRows_Impl ),
+ pTableNode( pTable->pTableNode ),
+ pBox1( 0 ),
+ pSttNd1( 0 ),
+ pBoxFmt( 0 ),
+ pLineFmt( 0 ),
+ nCurRow( 0UL ),
+ nCurCol( 0UL ),
+ nWidth( 0UL ),
+ bFirstSection( sal_False ),
+ bRelWidth( sal_True ),
+ bHasHeading( sal_False )
+{
+}
+
+SwXMLTableContext::~SwXMLTableContext()
+{
+}
+
+SvXMLImportContext *SwXMLTableContext::CreateChildContext( sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetTableElemTokenMap();
+ sal_Bool bHeader = sal_False;
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_TABLE_HEADER_COLS:
+ bHeader = sal_True;
+ case XML_TOK_TABLE_COLS:
+ pContext = new SwXMLTableColsContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ this, bHeader );
+ break;
+ case XML_TOK_TABLE_COL:
+ if( IsInsertColPossible() )
+ pContext = new SwXMLTableColContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ this );
+ break;
+ case XML_TOK_TABLE_HEADER_ROWS:
+ bHeader = sal_True;
+ case XML_TOK_TABLE_ROWS:
+ pContext = new SwXMLTableRowsContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ this, bHeader );
+ break;
+ case XML_TOK_TABLE_ROW:
+ if( IsInsertRowPossible() )
+ pContext = new SwXMLTableRowContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ this );
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+void SwXMLTableContext::InsertColumn( sal_Int32 nWidth, sal_Bool bRelWidth )
+{
+ ASSERT( nCurCol < USHRT_MAX,
+ "SwXMLTableContext::InsertColumn: no space left" );
+ if( nCurCol >= USHRT_MAX )
+ return;
+
+ if( nWidth < MINLAY )
+ nWidth = MINLAY;
+ else if( nWidth > USHRT_MAX )
+ nWidth = USHRT_MAX;
+ aColumnWidths.Insert( (sal_uInt16)nWidth, aColumnWidths.Count() );
+ aColumnRelWidths.Insert( bRelWidth, aColumnRelWidths.Count() );
+}
+
+sal_Int32 SwXMLTableContext::GetColumnWidth( sal_uInt32 nCol,
+ sal_uInt32 nColSpan ) const
+{
+ sal_uInt32 nLast = nCol+nColSpan;
+ if( nLast > aColumnWidths.Count() )
+ nLast = aColumnWidths.Count();
+
+ sal_Int32 nWidth = 0L;
+ for( sal_uInt16 i=nCol; i < nLast; i++ )
+ nWidth += aColumnWidths[i];
+
+ return nWidth;
+}
+
+void SwXMLTableContext::InsertCell( const OUString& rStyleName,
+ sal_uInt32 nRowSpan, sal_uInt32 nColSpan,
+ const SwStartNode *pStartNode,
+ SwXMLTableContext *pTable )
+{
+ ASSERT( nCurCol < GetColumnCount(),
+ "SwXMLTableContext::InsertCell: row is full" );
+ ASSERT( nCurRow < USHRT_MAX,
+ "SwXMLTableContext::InsertCell: table is full" );
+ if( nCurCol >= USHRT_MAX || nCurRow > USHRT_MAX )
+ return;
+
+ ASSERT( nRowSpan >=1UL, "SwXMLTableContext::InsertCell: row span is 0" );
+ if( 0UL == nRowSpan )
+ nRowSpan = 1UL;
+ ASSERT( nColSpan >=1UL, "SwXMLTableContext::InsertCell: col span is 0" );
+ if( 0UL == nColSpan )
+ nColSpan = 1UL;
+
+ sal_uInt32 i, j;
+
+ // Until it is possible to add columns here, fix the column span.
+ sal_uInt32 nColsReq = nCurCol + nColSpan;
+ if( nColsReq > GetColumnCount() )
+ {
+ nColSpan = GetColumnCount() - nCurCol;
+ nColsReq = GetColumnCount();
+ }
+
+ // Check whether there are cells from a previous line already that reach
+ // into the current row.
+ if( nCurRow > 0UL && nColSpan > 1UL )
+ {
+ SwXMLTableRow_Impl *pCurRow = (*pRows)[(sal_uInt16)nCurRow];
+ sal_uInt32 nLastCol = GetColumnCount() < nColsReq ? GetColumnCount()
+ : nColsReq;
+ for( i=nCurCol+1UL; i<nLastCol; i++ )
+ {
+ if( pCurRow->GetCell(i)->IsUsed() )
+ {
+ // If this cell is used, the column span is truncated
+ nColSpan = i - nCurCol;
+ nColsReq = i;
+ break;
+ }
+ }
+ }
+
+ sal_uInt32 nRowsReq = nCurRow + nRowSpan;
+ if( nRowsReq > USHRT_MAX )
+ {
+ nRowSpan = USHRT_MAX - nCurRow;
+ nRowsReq = USHRT_MAX;
+ }
+
+ // Add columns: TODO: This should never happen, since we require
+ // column definitions!
+ for( i=GetColumnCount(); i<nColsReq; i++ )
+ {
+ aColumnWidths.Insert( MINLAY, aColumnWidths.Count() );
+ aColumnRelWidths.Insert( sal_True, aColumnRelWidths.Count() );
+ }
+ for( i=0; i<pRows->Count(); i++ )
+ (*pRows)[(sal_uInt16)i]->Expand( nColsReq, i<nCurRow );
+
+ // Add rows
+ if( pRows->Count() < nRowsReq )
+ {
+ OUString aStyleName;
+ for( i=pRows->Count(); i<nRowsReq; i++ )
+ pRows->Insert( new SwXMLTableRow_Impl(aStyleName,GetColumnCount()),
+ pRows->Count() );
+ }
+
+ // Fill the cells
+ for( i=nColSpan; i>0UL; i-- )
+ for( j=nRowSpan; j>0UL; j-- )
+ GetCell( nRowsReq-j, nColsReq-i )
+ ->Set( rStyleName, j, i, pStartNode, pTable );
+
+ // Set current col to the next (free) column
+ nCurCol = nColsReq;
+ while( nCurCol<GetColumnCount() && GetCell(nCurRow,nCurCol)->IsUsed() )
+ nCurCol++;
+}
+
+void SwXMLTableContext::InsertRow( const OUString& rStyleName,
+ sal_Bool bInHead )
+{
+ ASSERT( nCurRow < USHRT_MAX,
+ "SwXMLTableContext::InsertRow: no space left" );
+ if( nCurRow >= USHRT_MAX )
+ return;
+
+ if( nCurRow < pRows->Count() )
+ {
+ // The current row has already been inserted because of a row span
+ // of a previous row.
+ (*pRows)[nCurRow]->Set( rStyleName );
+ }
+ else
+ {
+ // add a new row
+ pRows->Insert( new SwXMLTableRow_Impl( rStyleName, GetColumnCount()),
+ pRows->Count() );
+ }
+
+ // We start at the first column ...
+ nCurCol=0UL;
+
+ // ... but this cell may be occupied already.
+ while( nCurCol<GetColumnCount() && GetCell(nCurRow,nCurCol)->IsUsed() )
+ nCurCol++;
+
+ if( 0UL == nCurRow )
+ bHasHeading = bInHead;
+}
+
+void SwXMLTableContext::FinishRow()
+{
+ // Insert an empty cell at the end of the line if the row is not complete
+ if( nCurCol < GetColumnCount() )
+ {
+ OUString aStyleName;
+ InsertCell( aStyleName, 1U, GetColumnCount() - nCurCol,
+ InsertTableSection() );
+ }
+
+ // Move to the next row.
+ nCurRow++;
+}
+
+const SwStartNode *SwXMLTableContext::GetPrevStartNode( sal_uInt32 nRow,
+ sal_uInt32 nCol ) const
+{
+ const SwXMLTableCell_Impl *pPrevCell = 0;
+ if( GetColumnCount() == nCol )
+ {
+ // The last cell is the right one here.
+ pPrevCell = GetCell( pRows->Count()-1U, GetColumnCount()-1UL );
+ }
+ else if( 0UL == nRow )
+ {
+ // There are no vertically merged cells within the first row, so the
+ // previous cell is the right one always.
+ if( nCol > 0UL )
+ pPrevCell = GetCell( nRow, nCol-1UL );
+ }
+ else
+ {
+ // If there is a previous cell in the current row that is not spanned
+ // from the previous row, its the right one.
+ const SwXMLTableRow_Impl *pPrevRow = (*pRows)[(sal_uInt16)nRow-1U];
+ sal_uInt32 i = nCol;
+ while( !pPrevCell && i > 0UL )
+ {
+ i--;
+ if( 1UL == pPrevRow->GetCell( i )->GetRowSpan() )
+ pPrevCell = GetCell( nRow, i );
+ }
+
+ // Otherwise, the last cell from the previous row is the right one.
+ if( !pPrevCell )
+ pPrevCell = pPrevRow->GetCell( GetColumnCount()-1UL );
+ }
+
+ const SwStartNode *pSttNd;
+ if( pPrevCell )
+ {
+ if( pPrevCell->GetStartNode() )
+ pSttNd = pPrevCell->GetStartNode();
+ else
+ pSttNd = pPrevCell->GetSubTable()->GetLastStartNode();
+ }
+
+ return pSttNd;
+}
+
+void SwXMLTableContext::FixRowSpan( sal_uInt32 nRow, sal_uInt32 nCol,
+ sal_uInt32 nColSpan )
+{
+ sal_uInt32 nLastCol = nCol + nColSpan;
+ for( sal_uInt16 i = nCol; i < nLastCol; i++ )
+ {
+ sal_uInt32 j = nRow;
+ sal_uInt32 nRowSpan = 1UL;
+ SwXMLTableCell_Impl *pCell = GetCell( j, i );
+ while( pCell && pCell->GetRowSpan() > 1UL )
+ {
+ pCell->SetRowSpan( nRowSpan++ );
+ pCell = j > 0UL ? GetCell( --j, i ) : 0;
+ }
+ }
+}
+
+void SwXMLTableContext::ReplaceWithEmptyCell( sal_uInt32 nRow, sal_uInt32 nCol )
+{
+ const SwStartNode *pPrevSttNd = GetPrevStartNode( nRow, nCol );
+ const SwStartNode *pSttNd = InsertTableSection( pPrevSttNd );
+
+ const SwXMLTableCell_Impl *pCell = GetCell( nRow, nCol );
+ sal_uInt32 nLastRow = nRow + pCell->GetRowSpan();
+ sal_uInt32 nLastCol = nCol + pCell->GetColSpan();
+
+ for( sal_uInt32 i=nRow; i<nLastRow; i++ )
+ {
+ SwXMLTableRow_Impl *pRow = (*pRows)[i];
+ for( sal_uInt32 j=nCol; j<nLastCol; j++ )
+ pRow->GetCell( j )->SetStartNode( pSttNd );
+ }
+}
+
+SwTableBox *SwXMLTableContext::NewTableBox( const SwStartNode *pStNd,
+ SwTableLine *pUpper )
+{
+ SwTableBox *pBox;
+
+ if( pBox1 &&
+ pBox1->GetSttNd() == pStNd )
+ {
+ // wenn der StartNode dem StartNode der initial angelegten Box
+ // entspricht nehmen wir diese Box
+ pBox = pBox1;
+ pBox->SetUpper( pUpper );
+ pBox1 = 0;
+ }
+ else
+ pBox = new SwTableBox( pBoxFmt, *pStNd, pUpper );
+
+ return pBox;
+}
+
+SwTableBox *SwXMLTableContext::MakeTableBox( SwTableLine *pUpper,
+ sal_uInt32 nTopRow,
+ sal_uInt32 nLeftCol,
+ sal_uInt32 nBottomRow,
+ sal_uInt32 nRightCol )
+{
+ SwTableBox *pBox = new SwTableBox( pBoxFmt, 0, pUpper );
+
+ // TODO: Share formats!
+ SwFrmFmt *pFrmFmt = pBox->ClaimFrmFmt();
+ SwFmtFillOrder aFillOrder( pFrmFmt->GetFillOrder() );
+ pFrmFmt->ResetAllAttr();
+ pFrmFmt->SetAttr( aFillOrder );
+
+ SwTableLines& rLines = pBox->GetTabLines();
+ sal_Bool bSplitted = sal_False;
+
+ while( !bSplitted )
+ {
+ sal_uInt32 nStartRow = nTopRow;
+ for( sal_uInt32 i=nTopRow; i<nBottomRow; i++ )
+ {
+ // Could the table be splitted behind the current row?
+ sal_Bool bSplit = sal_True;
+ SwXMLTableRow_Impl *pRow = (*pRows)[(sal_uInt16)i];
+ for( sal_uInt32 j=nLeftCol; j<nRightCol; j++ )
+ {
+ bSplit = ( 1UL == pRow->GetCell(j)->GetRowSpan() );
+ if( !bSplit )
+ break;
+ }
+ if( bSplit && (nStartRow>nTopRow || i+1UL<nBottomRow) )
+ {
+ SwTableLine *pLine =
+ MakeTableLine( pBox, nStartRow, nLeftCol, i+1UL,
+ nRightCol );
+
+ rLines.C40_INSERT( SwTableLine, pLine, rLines.Count() );
+
+ nStartRow = i+1UL;
+ bSplitted = sal_True;
+ }
+ }
+ if( !bSplitted )
+ {
+ // No splitting was possible. That for, we have to force it.
+ // Ruthless!
+
+ nStartRow = nTopRow;
+ while( nStartRow < nBottomRow )
+ {
+ sal_uInt32 nMaxRowSpan = 0UL;
+ SwXMLTableRow_Impl *pStartRow = (*pRows)[(sal_uInt16)nStartRow];
+ SwXMLTableCell_Impl *pCell;
+ for( i=nLeftCol; i<nRightCol; i++ )
+ if( ( pCell=pStartRow->GetCell(i),
+ pCell->GetRowSpan() > nMaxRowSpan ) )
+ nMaxRowSpan = pCell->GetRowSpan();
+
+ nStartRow += nMaxRowSpan;
+ if( nStartRow<nBottomRow )
+ {
+ SwXMLTableRow_Impl *pPrevRow =
+ (*pRows)[(sal_uInt16)nStartRow-1U];
+ i = nLeftCol;
+ while( i < nRightCol )
+ {
+ if( pPrevRow->GetCell(i)->GetRowSpan() > 1UL )
+ {
+ const SwXMLTableCell_Impl *pCell =
+ GetCell( nStartRow, i );
+ sal_uInt32 nColSpan = pCell->GetColSpan();
+ FixRowSpan( nStartRow-1UL, i, nColSpan );
+ ReplaceWithEmptyCell( nStartRow, i );
+ i += nColSpan;
+ }
+ else
+ {
+ i++;
+ }
+ }
+ }
+ }
+ // und jetzt nochmal von vorne ...
+ }
+ }
+
+ return pBox;
+}
+
+SwTableBox *SwXMLTableContext::MakeTableBox(
+ SwTableLine *pUpper, const SwXMLTableCell_Impl *pCell,
+ sal_uInt32 nTopRow, sal_uInt32 nLeftCol, sal_uInt32 nBottomRow,
+ sal_uInt32 nRightCol )
+{
+ SwTableBox *pBox;
+ sal_uInt32 nColSpan = nRightCol - nLeftCol;
+ sal_uInt32 nRowSpan = nBottomRow - nTopRow;
+ sal_Int32 nColWidth = GetColumnWidth( nLeftCol, nColSpan );
+
+ if( pCell->GetStartNode() )
+ {
+ pBox = NewTableBox( pCell->GetStartNode(), pUpper );
+ }
+ else
+ {
+ // und die ist eine Tabelle: dann bauen wir eine neue
+ // Box und fuegen die Zeilen der Tabelle in die Zeilen
+ // der Box ein
+ pBox = new SwTableBox( pBoxFmt, 0, pUpper );
+ pCell->GetSubTable()->MakeTable( pBox, nColWidth );
+ }
+
+ // TODO: Share formats!
+ SwFrmFmt *pFrmFmt = pBox->ClaimFrmFmt();
+ SwFmtFillOrder aFillOrder( pFrmFmt->GetFillOrder() );
+ pFrmFmt->ResetAllAttr();
+ pFrmFmt->SetAttr( aFillOrder );
+
+ const SfxItemSet *pAutoItemSet = 0;
+ const OUString& rStyleName = pCell->GetStyleName();
+ if( pCell->GetStartNode() && rStyleName &&
+ GetSwImport().FindAutomaticStyle(
+#ifdef XML_CORE_API
+ SFX_STYLE_FAMILY_FRAME, SW_STYLE_SUBFAMILY_TABLE_BOX,
+#else
+ XML_STYLE_FAMILY_TABLE_CELL,
+#endif
+ pCell->GetStyleName(),
+ &pAutoItemSet ) )
+ {
+ if( pAutoItemSet )
+ pFrmFmt->SetAttr( *pAutoItemSet );
+ }
+
+ pFrmFmt->SetAttr( SwFmtFrmSize( ATT_VAR_SIZE, nColWidth ) );
+
+ return pBox;
+}
+
+SwTableLine *SwXMLTableContext::MakeTableLine( SwTableBox *pUpper,
+ sal_uInt32 nTopRow,
+ sal_uInt32 nLeftCol,
+ sal_uInt32 nBottomRow,
+ sal_uInt32 nRightCol )
+{
+ SwTableLine *pLine;
+ if( !pUpper && 0UL==nTopRow )
+ {
+ pLine = pTableNode->GetTable().GetTabLines()[0U];
+ }
+ else
+ {
+ pLine = new SwTableLine( pLineFmt, 0, pUpper );
+ }
+
+ // TODO: Share formats!
+ SwFrmFmt *pFrmFmt = pLine->ClaimFrmFmt();
+ SwFmtFillOrder aFillOrder( pFrmFmt->GetFillOrder() );
+ pFrmFmt->ResetAllAttr();
+ pFrmFmt->SetAttr( aFillOrder );
+
+ const SfxItemSet *pAutoItemSet = 0;
+ const OUString& rStyleName = (*pRows)[nTopRow]->GetStyleName();
+ if( 1UL == (nBottomRow - nTopRow) &&
+ rStyleName.getLength() &&
+ GetSwImport().FindAutomaticStyle(
+#ifdef XML_CORE_API
+ SFX_STYLE_FAMILY_FRAME, SW_STYLE_SUBFAMILY_TABLE_LINE,
+#else
+ XML_STYLE_FAMILY_TABLE_ROW,
+#endif
+ rStyleName, &pAutoItemSet ) )
+ {
+ if( pAutoItemSet )
+ pFrmFmt->SetAttr( *pAutoItemSet );
+ }
+
+ SwTableBoxes& rBoxes = pLine->GetTabBoxes();
+
+ sal_uInt32 nStartCol = nLeftCol;
+ while( nStartCol < nRightCol )
+ {
+ for( sal_uInt32 nRow=nTopRow; nRow<nBottomRow; nRow++ )
+ (*pRows)[(sal_uInt16)nRow]->SetSplitable( sal_True );
+
+ sal_uInt32 nCol = nStartCol;
+ sal_uInt32 nSplitCol = nRightCol;
+ sal_Bool bSplitted = sal_False;
+ while( !bSplitted )
+ {
+ ASSERT( nCol < nRightCol, "Zu weit gelaufen" );
+
+ // Kann hinter der aktuellen HTML-Tabellen-Spalte gesplittet
+ // werden? Wenn ja, koennte der enstehende Bereich auch noch
+ // in Zeilen zerlegt werden, wenn man die naechste Spalte
+ // hinzunimmt?
+ sal_Bool bSplit = sal_True;
+ sal_Bool bHoriSplitMayContinue = sal_False;
+ sal_Bool bHoriSplitPossible = sal_False;
+ for( sal_uInt32 nRow=nTopRow; nRow<nBottomRow; nRow++ )
+ {
+ SwXMLTableCell_Impl *pCell = GetCell(nRow,nCol);
+ // Could the table fragment be splitted horizontally behind
+ // the current line?
+ sal_Bool bHoriSplit = (*pRows)[(sal_uInt16)nRow]->IsSplitable() &&
+ nRow+1UL < nBottomRow &&
+ 1UL == pCell->GetRowSpan();
+ (*pRows)[(sal_uInt16)nRow]->SetSplitable( bHoriSplit );
+
+ // Could the table fragment be splitted vertically behind the
+ // current column (uptp the current line?
+ bSplit &= ( 1UL == pCell->GetColSpan() );
+ if( bSplit )
+ {
+ bHoriSplitPossible |= bHoriSplit;
+
+ // Could the current table fragment be splitted
+ // horizontally behind the next collumn, too?
+ bHoriSplit &= (nCol+1UL < nRightCol &&
+ 1UL == GetCell(nRow,nCol+1UL)->GetRowSpan());
+ bHoriSplitMayContinue |= bHoriSplit;
+ }
+ }
+
+#ifndef PRODUCT
+ if( nCol == nRightCol-1UL )
+ {
+ ASSERT( bSplit, "Split-Flag falsch" );
+ ASSERT( !bHoriSplitMayContinue,
+ "HoriSplitMayContinue-Flag falsch" );
+ SwXMLTableCell_Impl *pCell = GetCell( nTopRow, nStartCol );
+ ASSERT( pCell->GetRowSpan() != (nBottomRow-nTopRow) ||
+ !bHoriSplitPossible, "HoriSplitPossible-Flag falsch" );
+ }
+#endif
+ ASSERT( !bHoriSplitMayContinue || bHoriSplitPossible,
+ "bHoriSplitMayContinue, aber nicht bHoriSplitPossible" );
+
+ if( bSplit )
+ {
+ SwTableBox* pBox = 0;
+ SwXMLTableCell_Impl *pCell = GetCell( nTopRow, nStartCol );
+ if( pCell->GetRowSpan() == (nBottomRow-nTopRow) &&
+ pCell->GetColSpan() == (nCol+1UL-nStartCol) )
+ {
+ // The remaining box neither contains lines nor rows (i.e.
+ // is a content box
+ nSplitCol = nCol + 1UL;
+
+#if 0
+ // eventuell ist die Zelle noch leer
+ if( !pCell->GetContents() )
+ {
+ ASSERT( 1UL==pCell->GetRowSpan(),
+ "leere Box ist nicht 1 Zeile hoch" );
+ const SwStartNode* pPrevStNd =
+ GetPrevBoxStartNode( nTopRow, nStartCol );
+ HTMLTableCnts *pCnts = new HTMLTableCnts(
+ pParser->InsertTableSection(pPrevStNd) );
+ SwHTMLTableLayoutCnts *pCntsLayoutInfo =
+ pCnts->CreateLayoutInfo();
+
+ pCell->SetContents( pCnts );
+ pLayoutInfo->GetCell( nTopRow, nStartCol )
+ ->SetContents( pCntsLayoutInfo );
+
+ // ggf. COLSPAN beachten
+ for( sal_uInt16 j=nStartCol+1; j<nSplitCol; j++ )
+ {
+ GetCell(nTopRow,j)->SetContents( pCnts );
+ pLayoutInfo->GetCell( nTopRow, j )
+ ->SetContents( pCntsLayoutInfo );
+ }
+ }
+#endif
+ pBox = MakeTableBox( pLine, pCell,
+ nTopRow, nStartCol,
+ nBottomRow, nSplitCol );
+ bSplitted = sal_True;
+ }
+ else if( bHoriSplitPossible && bHoriSplitMayContinue )
+ {
+ // The table fragment could be splitted behind the current
+ // column, and the remaining fragment could be divided
+ // into lines. Anyway, it could be that this applies to
+ // the next column, too. That for, we check the next
+ // column but rememeber the current one as a good place to
+ // split.
+ nSplitCol = nCol + 1UL;
+ }
+ else
+ {
+ // If the table resulting table fragment could be divided
+ // into lines if spllitting behind the current column, but
+ // this doesn't apply for thr next column, we split begind
+ // the current column. This applies for the last column,
+ // too.
+ // If the resulting box cannot be splitted into rows,
+ // the split at the last split position we remembered.
+ if( bHoriSplitPossible || nSplitCol > nCol+1 )
+ {
+ ASSERT( !bHoriSplitMayContinue,
+ "bHoriSplitMayContinue==sal_True" );
+ ASSERT( bHoriSplitPossible || nSplitCol == nRightCol,
+ "bHoriSplitPossible-Flag sollte gesetzt sein" );
+
+ nSplitCol = nCol + 1UL;
+ }
+
+ pBox = MakeTableBox( pLine, nTopRow, nStartCol,
+ nBottomRow, nSplitCol );
+ bSplitted = sal_True;
+ }
+ if( pBox )
+ rBoxes.C40_INSERT( SwTableBox, pBox, rBoxes.Count() );
+ }
+ nCol++;
+ }
+ nStartCol = nSplitCol;
+ }
+
+ return pLine;
+}
+
+void SwXMLTableContext::_MakeTable( SwTableBox *pBox )
+{
+ // fix column widths
+ sal_uInt32 i;
+ sal_uInt32 nCols = GetColumnCount();
+
+ // If there are empty rows (because of some row span of previous rows)
+ // the have to be deleted. The previous rows have to be truncated.
+
+ if( pRows->Count() > nCurRow )
+ {
+ SwXMLTableRow_Impl *pPrevRow = (*pRows)[(sal_uInt16)nCurRow-1U];
+ SwXMLTableCell_Impl *pCell;
+ for( i=0UL; i<nCols; i++ )
+ {
+ if( ( pCell=pPrevRow->GetCell(i), pCell->GetRowSpan() > 1UL ) )
+ {
+ FixRowSpan( nCurRow-1UL, i, 1UL );
+ }
+ }
+ for( i=(sal_uInt32)pRows->Count()-1UL; i>=nCurRow; i-- )
+ pRows->DeleteAndDestroy( i );
+ }
+
+ // Make sure there is at least one column.
+ if( 0UL == nCols )
+ {
+ InsertColumn( USHRT_MAX, sal_True );
+ nCols = 1UL;
+ }
+ if( 0UL == pRows->Count() )
+ {
+ OUString aStyleName;
+ InsertCell( aStyleName, 1U, nCols, InsertTableSection() );
+ }
+
+ // TODO: Do we have to keep both values, the realtive and the absolute
+ // width?
+ sal_Int32 nAbsWidth = 0L;
+ sal_Int32 nMinAbsColWidth = 0L;
+ sal_Int32 nRelWidth = 0L;
+ sal_Int32 nMinRelColWidth = 0L;
+ sal_uInt32 nRelCols = 0UL;
+ for( i=0U; i < nCols; i++ )
+ {
+ sal_Int32 nColWidth = aColumnWidths[i];
+ if( aColumnRelWidths[i] )
+ {
+ nRelWidth += nColWidth;
+ if( 0L == nMinRelColWidth || nColWidth < nMinRelColWidth )
+ nMinRelColWidth = nColWidth;
+ nRelCols++;
+ }
+ else
+ {
+ nAbsWidth += nColWidth;
+ if( 0L == nMinAbsColWidth || nColWidth < nMinAbsColWidth )
+ nMinAbsColWidth = nColWidth;
+ }
+ }
+ sal_uInt32 nAbsCols = nCols - nRelCols;
+
+ if( bRelWidth )
+ {
+ // If there a columns that have an absolute width, we have to
+ // calculate a relative one for them.
+ if( nAbsCols > 0UL )
+ {
+ // All column that have absolute widths get relative widths;
+ // these widths relate to each over like the original absolute
+ // widths. The smallest column gets a width that hat the same
+ // value as the smallest column that has an relative width
+ // already.
+ if( 0L == nMinRelColWidth )
+ nMinRelColWidth = MINLAY;
+
+ for( i=0UL; nAbsCols > 0UL && i < nCols; i++ )
+ {
+ if( !aColumnRelWidths[(sal_uInt16)i] )
+ {
+ sal_Int32 nRelCol = (aColumnWidths[i] * nMinRelColWidth) /
+ nMinAbsColWidth;
+ aColumnWidths.Replace( (sal_uInt16)nRelCol, (sal_uInt16)i );
+ nRelWidth += nRelCol;
+ nAbsCols--;
+ }
+ }
+ }
+
+ if( !nWidth )
+ {
+ // If no width has been specified by now, we may use any value
+ nWidth = nRelWidth > USHRT_MAX ? USHRT_MAX : nRelWidth;
+ }
+ if( nRelWidth != nWidth )
+ {
+ double n = (double)nWidth / (double)nRelWidth;
+ nRelWidth = 0L;
+ for( i=0U; i < nCols-1UL; i++ )
+ {
+ sal_Int32 nW = (sal_Int32)(aColumnWidths[i] * n);
+ aColumnWidths.Replace( (sal_uInt16)nW, i );
+ nRelWidth += nW;
+ }
+ aColumnWidths.Replace( (sal_uInt16)(nWidth-nRelWidth),
+ (sal_uInt16)nCols-1UL );
+ }
+ }
+ else
+ {
+ // If there are columns that have relative widths, we have to
+ // calculate a absolute widths for them.
+ if( nRelCols > 0UL )
+ {
+ // The absolute space that is available for all columns with a
+ // relative width.
+ sal_Int32 nAbsForRelWidth =
+ nWidth > nAbsWidth ? nWidth - nAbsWidth : 0L;
+
+ // The relative width that has to be distributed in addition to
+ // equally widthed columns.
+ sal_Int32 nExtraRel = nRelWidth - (nRelCols * nMinRelColWidth);
+
+ // The absolute space that may be distributed in addition to
+ // minumum widthed columns.
+ sal_Int32 nMinAbs = nRelCols * MINLAY;
+ sal_Int32 nExtraAbs =
+ nAbsForRelWidth > nMinAbs ? nAbsForRelWidth - nMinAbs : 0L;
+
+ sal_Bool bMin = sal_False; // Do all columns get the mininum width?
+ sal_Bool bMinExtra = sal_False; // Do all columns get the minimum width plus
+ // some extra space?
+
+ if( nAbsForRelWidth <= nMinAbs )
+ {
+ // If there is not enough space left for all columns to
+ // get the minimum width, they get the minimum width, anyway.
+ nAbsForRelWidth = nMinAbs;
+ bMin = sal_True;
+ }
+ else if( nAbsForRelWidth <= (nRelWidth * MINLAY) /
+ nMinRelColWidth )
+ {
+ // If there is enougth space for all columns to get the
+ // minimum width, but not to get a width that takes the
+ // relative width into account, each column gets the minimum
+ // width plus some extra space that is based on the additional
+ // space that is available.
+ bMinExtra = sal_True;
+ }
+ // Otherwise, if there is enouth space for every column, every
+ // column gets this space.
+
+ for( i=0UL; nRelCols > 0UL && i < nCols; i++ )
+ {
+ if( aColumnRelWidths[(sal_uInt16)i] )
+ {
+ sal_Int32 nAbsCol;
+ if( 1UL == nRelCols )
+ {
+ // The last column that has a relative width gets
+ // all absolute space that is left.
+ nAbsCol = nAbsForRelWidth;
+ }
+ else
+ {
+ if( bMin )
+ {
+ nAbsCol = MINLAY;
+ }
+ else if( bMinExtra )
+ {
+ sal_Int32 nExtraRelCol =
+ aColumnWidths[i] - nMinRelColWidth;
+ nAbsCol = MINLAY + (nExtraRelCol * nExtraAbs) /
+ nExtraRel;
+ }
+ else
+ {
+ nAbsCol = (aColumnWidths[i] * nAbsForRelWidth) /
+ nRelWidth;
+ }
+ }
+ aColumnWidths.Replace( (sal_uInt16)nAbsCol, (sal_uInt16)i );
+ nAbsForRelWidth -= nAbsCol;
+ nAbsWidth += nAbsCol;
+ nRelCols--;
+ }
+ }
+ }
+
+ if( nAbsWidth < nWidth )
+ {
+ // If the table's width is larger than the absolute column widths,
+ // every column get some extra width.
+ sal_Int32 nExtraAbs = nWidth - nAbsWidth;
+ sal_Int32 nAbsLastCol =
+ aColumnWidths[(sal_uInt16)nCols-1U] + nExtraAbs;
+ for( i=0UL; i < nCols-1UL; i++ )
+ {
+ sal_Int32 nAbsCol = aColumnWidths[i];
+ sal_Int32 nExtraAbsCol = (nAbsCol * nExtraAbs) /
+ nAbsWidth;
+ nAbsCol += nExtraAbsCol;
+ aColumnWidths.Replace( (sal_uInt16)nAbsCol, i );
+ nAbsLastCol -= nExtraAbsCol;
+ }
+ aColumnWidths.Replace( (sal_uInt16)nAbsLastCol, (sal_uInt16)nCols-1U );
+ }
+ else if( nAbsWidth > nWidth )
+ {
+ // If the table's width is smaller than the absolute column
+ // widths, every column gets the minimum width plus some extra
+ // width.
+ sal_Int32 nExtraAbs = nWidth - (nCols * MINLAY);
+ sal_Int32 nAbsLastCol = MINLAY + nExtraAbs;
+ for( i=0UL; i < nCols-1UL; i++ )
+ {
+ sal_Int32 nAbsCol = aColumnWidths[i];
+ sal_Int32 nExtraAbsCol = (nAbsCol * nExtraAbs) /
+ nAbsWidth;
+ nAbsCol = MINLAY + nExtraAbsCol;
+ aColumnWidths.Replace( (sal_uInt16)nAbsCol, i );
+ nAbsLastCol -= nExtraAbsCol;
+ }
+ aColumnWidths.Replace( (sal_uInt16)nAbsLastCol, (sal_uInt16)nCols-1U );
+ }
+ }
+
+ SwTableLines& rLines =
+ pBox ? pBox->GetTabLines()
+ : pTableNode->GetTable().GetTabLines();
+
+ sal_uInt32 nStartRow = 0UL;
+ sal_uInt32 nRows = pRows->Count();
+ for( i=0UL; i<nRows; i++ )
+ {
+ // Could we split the table behind the current line?
+ sal_Bool bSplit = sal_True;
+ SwXMLTableRow_Impl *pRow = (*pRows)[(sal_uInt16)i];
+ for( sal_uInt32 j=0UL; j<nCols; j++ )
+ {
+ bSplit = ( 1UL == pRow->GetCell(j)->GetRowSpan() );
+ if( !bSplit )
+ break;
+ }
+
+ if( bSplit )
+ {
+ SwTableLine *pLine =
+ MakeTableLine( pBox, nStartRow, 0UL, i+1UL, nCols );
+ if( pBox || nStartRow>0UL )
+ rLines.C40_INSERT( SwTableLine, pLine, rLines.Count() );
+ nStartRow = i+1UL;
+ }
+ }
+}
+
+void SwXMLTableContext::MakeTable()
+{
+ SwXMLImport& rSwImport = GetSwImport();
+
+ SwFrmFmt *pFrmFmt = pTableNode->GetTable().GetFrmFmt();
+
+ SwHoriOrient eHoriOrient = HORI_FULL;
+ sal_Bool bSetHoriOrient = sal_False;
+
+ sal_uInt16 nPrcWidth = 0U;
+ sal_Bool bCalcWidth = sal_False;
+ sal_Bool bSetWidth = sal_False;
+
+ pTableNode->GetTable().SetHeadlineRepeat( bHasHeading );
+
+ const SfxItemSet *pAutoItemSet = 0;
+ if( aStyleName.getLength() &&
+ rSwImport.FindAutomaticStyle(
+#ifdef XML_CORE_API
+ SFX_STYLE_FAMILY_FRAME, SW_STYLE_SUBFAMILY_TABLE,
+#else
+ XML_STYLE_FAMILY_TABLE_TABLE,
+#endif
+ aStyleName, &pAutoItemSet ) &&
+ pAutoItemSet )
+ {
+ const SfxPoolItem *pItem;
+ const SvxLRSpaceItem *pLRSpace = 0;
+ if( SFX_ITEM_SET == pAutoItemSet->GetItemState( RES_LR_SPACE, sal_False,
+ &pItem ) )
+ pLRSpace = (const SvxLRSpaceItem *)pItem;
+
+ if( SFX_ITEM_SET == pAutoItemSet->GetItemState( RES_HORI_ORIENT, sal_False,
+ &pItem ) )
+ {
+ eHoriOrient = ((const SwFmtHoriOrient *)pItem)->GetHoriOrient();
+ switch( eHoriOrient )
+ {
+ case HORI_FULL:
+ if( pLRSpace )
+ {
+ eHoriOrient = HORI_NONE;
+ bSetHoriOrient = sal_True;
+ }
+ break;
+ case HORI_LEFT:
+ if( pLRSpace )
+ {
+ eHoriOrient = HORI_LEFT_AND_WIDTH;
+ bSetHoriOrient = sal_True;
+ }
+ break;
+ }
+ }
+ else
+ {
+ bSetHoriOrient = sal_True;
+ }
+
+ if( SFX_ITEM_SET == pAutoItemSet->GetItemState( RES_FRM_SIZE, sal_False,
+ &pItem ) )
+ {
+ const SwFmtFrmSize *pSize = (const SwFmtFrmSize *)pItem;
+ switch( eHoriOrient )
+ {
+ case HORI_FULL:
+ nWidth = USHRT_MAX;
+ break;
+ case HORI_NONE:
+ // The width will be set in _MakeTable
+ break;
+ default:
+ if( pSize->GetWidthPercent() )
+ {
+ // The width will be set in _MakeTable
+ nPrcWidth = pSize->GetWidthPercent();
+ }
+ else
+ {
+ nWidth = pSize->GetWidth();
+ if( nWidth < GetColumnCount() * MINLAY )
+ {
+ nWidth = GetColumnCount() * MINLAY;
+ }
+ else if( nWidth > USHRT_MAX )
+ {
+ nWidth = USHRT_MAX;
+ }
+ bRelWidth = sal_False;
+ }
+ break;
+ }
+ }
+ else
+ {
+ eHoriOrient = HORI_FULL;
+ bSetHoriOrient = sal_True;
+ nWidth = USHRT_MAX;
+ }
+
+ pFrmFmt->SetAttr( *pAutoItemSet );
+ }
+ else
+ {
+ bSetHoriOrient = sal_True;
+ nWidth = USHRT_MAX;
+ }
+
+ SwTableLine *pLine1 = pTableNode->GetTable().GetTabLines()[0U];
+#ifdef XML_CORE_API
+ pBox1 = pLine1->GetTabBoxes()[0U];
+#else
+ DBG_ASSERT( pBox1 == pLine1->GetTabBoxes()[0U],
+ "Why is box 1 change?" );
+ pBox1->pSttNd = pSttNd1;
+#endif
+ pLine1->GetTabBoxes().Remove(0U);
+
+ pLineFmt = (SwTableLineFmt*)pLine1->GetFrmFmt();
+ pBoxFmt = (SwTableBoxFmt*)pBox1->GetFrmFmt();
+
+ _MakeTable();
+
+ if( bSetHoriOrient )
+ pFrmFmt->SetAttr( SwFmtHoriOrient( 0, eHoriOrient ) );
+
+ // This must be bahind the call to _MakeTable, because nWidth might be
+ // changed there.
+ pFrmFmt->LockModify();
+ SwFmtFrmSize aSize( ATT_VAR_SIZE, nWidth );
+ aSize.SetWidthPercent( (sal_Int8)nPrcWidth );
+ pFrmFmt->SetAttr( aSize );
+ pFrmFmt->UnlockModify();
+
+
+ for( sal_uInt16 i=0; i<pRows->Count(); i++ )
+ (*pRows)[i]->Dispose();
+
+ if( rSwImport.GetDoc().GetRootFrm() )
+ {
+ pTableNode->DelFrms();
+ SwNodeIndex aIdx( *pTableNode->EndOfSectionNode(), 1 );
+ pTableNode->MakeFrms( &aIdx );
+ }
+}
+
+void SwXMLTableContext::MakeTable( SwTableBox *pBox, sal_Int32 nW )
+{
+ pLineFmt = GetParentTable()->pLineFmt;
+ pBoxFmt = GetParentTable()->pBoxFmt;
+ nWidth = nW;
+ bRelWidth = GetParentTable()->bRelWidth;
+
+ _MakeTable( pBox );
+}
+
+const SwStartNode *SwXMLTableContext::InsertTableSection(
+ const SwStartNode *pPrevSttNd )
+{
+ const SwStartNode *pStNd;
+#ifdef XML_CORE_API
+ SwPaM& rPaM = GetSwImport().GetPaM();
+ if( bFirstSection )
+ {
+ // The PaM already is in the first section
+ pStNd = rPaM.GetNode()->FindTableBoxStartNode();
+ bFirstSection = sal_False;
+ }
+ else
+ {
+ SwDoc& rDoc = GetSwImport().GetDoc();
+ const SwEndNode *pEndNd = pPrevSttNd ? pPrevSttNd->EndOfSectionNode()
+ : pTableNode->EndOfSectionNode();
+ sal_uInt32 nOffset = pPrevSttNd ? 1UL : 0UL;
+ SwNodeIndex aIdx( *pEndNd, nOffset );
+ SwTxtFmtColl *pColl = rDoc.GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
+ pStNd = rDoc.GetNodes().MakeTextSection( aIdx, SwTableBoxStartNode,
+ pColl );
+ if( !pPrevSttNd )
+ {
+ rPaM.GetPoint()->nNode.Assign( *pStNd, 1UL );
+ rPaM.GetPoint()->nContent.Assign( rPaM.GetCntntNode(), 0U );
+ }
+ }
+#else
+ Reference<XUnoTunnel> xCrsrTunnel( GetImport().GetTextImport()->GetCursor(),
+ UNO_QUERY);
+ ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" );
+ SwXTextCursor *pTxtCrsr =
+ (SwXTextCursor*)xCrsrTunnel->getSomething(
+ SwXTextCursor::getUnoTunnelId() );
+ ASSERT( pTxtCrsr, "SwXTextCursor missing" );
+
+ if( bFirstSection )
+ {
+ // The Cursor already is in the first section
+ pStNd = pTxtCrsr->GetCrsr()->GetNode()->FindTableBoxStartNode();
+ bFirstSection = sal_False;
+ }
+ else
+ {
+ SwDoc& rDoc = GetSwImport().GetDoc();
+ const SwEndNode *pEndNd = pPrevSttNd ? pPrevSttNd->EndOfSectionNode()
+ : pTableNode->EndOfSectionNode();
+ sal_uInt32 nOffset = pPrevSttNd ? 1UL : 0UL;
+ SwNodeIndex aIdx( *pEndNd, nOffset );
+ SwTxtFmtColl *pColl = rDoc.GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
+ pStNd = rDoc.GetNodes().MakeTextSection( aIdx, SwTableBoxStartNode,
+ pColl );
+ if( !pPrevSttNd )
+ {
+ pBox1->pSttNd = pStNd;
+ SwCntntNode *pCNd = rDoc.GetNodes()[ pStNd->GetIndex() + 1 ]
+ ->GetCntntNode();
+ SwPosition aPos( *pCNd );
+ aPos.nContent.Assign( pCNd, 0U );
+
+ Reference < XTextRange > xTextRange =
+ CreateTextRangeFromPosition( &rDoc, aPos, 0 );
+ Reference < XText > xText = xTextRange->getText();
+ Reference < XTextCursor > xTextCursor =
+ xText->createTextCursorByRange( xTextRange );
+ GetImport().GetTextImport()->SetCursor( xTextCursor );
+ }
+ }
+
+#endif
+
+ return pStNd;
+}
+
+void SwXMLTableContext::EndElement()
+{
+ if( !xParentTable.Is() )
+ {
+ MakeTable();
+#ifdef XML_CORE_API
+ GetSwImport().GetPaM().Move( fnMoveForward );
+#else
+ GetImport().GetTextImport()->SetCursor( xOldCursor );
+#endif
+ }
+}
+
+#ifndef XML_CORE_API
+class SwXMLTextImportHelper : public XMLTextImportHelper
+{
+protected:
+ virtual SvXMLImportContext *CreateTableChildContext(
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< XAttributeList > & xAttrList );
+
+public:
+ SwXMLTextImportHelper(
+ const Reference < XModel>& rModel,
+ sal_Bool bInsertM, sal_Bool bStylesOnlyM );
+ ~SwXMLTextImportHelper();
+};
+
+SwXMLTextImportHelper::SwXMLTextImportHelper(
+ const Reference < XModel>& rModel,
+ sal_Bool bInsertM, sal_Bool bStylesOnlyM ) :
+ XMLTextImportHelper( rModel, bInsertM, bStylesOnlyM )
+{
+}
+
+SwXMLTextImportHelper::~SwXMLTextImportHelper()
+{
+}
+
+SvXMLImportContext *SwXMLTextImportHelper::CreateTableChildContext(
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ return new SwXMLTableContext(
+ (SwXMLImport&)rImport, nPrefix, rLocalName, xAttrList );
+}
+
+XMLTextImportHelper* SwXMLImport::CreateTextImport()
+{
+ return new SwXMLTextImportHelper( GetModel(), IsInsertMode(),
+ IsStylesOnlyMode() );
+}
+
+#endif
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmltbli.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.11 2000/09/18 16:05:07 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.10 2000/09/18 11:58:02 mib
+ text frames/graphics import and export continued
+
+ Revision 1.9 2000/08/24 11:16:42 mib
+ text import continued
+
+ Revision 1.8 2000/08/10 10:22:16 mib
+ #74404#: Adeptions to new XSL/XLink working draft
+
+ Revision 1.7 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.6 2000/06/08 09:45:55 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.5 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.4 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.3 2000/03/10 11:15:04 mib
+ #72721#: Made table import much more robust, rowspan
+
+ Revision 1.2 2000/02/17 15:17:57 mib
+ #70271#: headline repeat
+
+ Revision 1.1 2000/02/17 14:40:01 mib
+ #70271#: XML table import
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmltbli.hxx b/sw/source/filter/xml/xmltbli.hxx
new file mode 100644
index 000000000000..fae90ba3cac8
--- /dev/null
+++ b/sw/source/filter/xml/xmltbli.hxx
@@ -0,0 +1,211 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmltbli.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _XMLTBLI_HXX
+#define _XMLTBLI_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+
+#if !defined(_SVSTDARR_USHORTS_DECL) || !defined(_SVSTDARR_BOOLS_DECL)
+#define _SVSTDARR_USHORTS
+#define _SVSTDARR_BOOLS
+#include <svtools/svstdarr.hxx>
+#endif
+
+class SwXMLImport;
+class SwTableNode;
+class SwTableBox;
+class SwTableLine;
+class SwStartNode;
+class SwTableBoxFmt;
+class SwTableLineFmt;
+class SwXMLTableCell_Impl;
+class SwXMLTableRows_Impl;
+
+
+#ifdef XML_CORE_API
+enum SwXMLStyleSubFamily
+{
+ SW_STYLE_SUBFAMILY_TABLE = 0x0001,
+ SW_STYLE_SUBFAMILY_TABLE_LINE = 0x0002,
+ SW_STYLE_SUBFAMILY_TABLE_BOX = 0x0004,
+ SW_STYLE_SUBFAMILY_TABLE_COL = 0x0008
+};
+#endif
+
+
+class SwXMLTableContext : public SvXMLImportContext
+{
+ ::rtl::OUString aStyleName;
+
+ SvUShorts aColumnWidths;
+ SvBools aColumnRelWidths;
+
+#ifndef XML_CORE_API
+ ::com::sun::star::uno::Reference <
+ ::com::sun::star::text::XTextCursor > xOldCursor;
+#endif
+ SwXMLTableRows_Impl *pRows;
+
+ SwTableNode *pTableNode;
+ SwTableBox *pBox1;
+ const SwStartNode *pSttNd1;
+
+ SwTableBoxFmt *pBoxFmt;
+ SwTableLineFmt *pLineFmt;
+
+ SvXMLImportContextRef xParentTable; // if table ia a sub table
+
+ sal_Bool bFirstSection : 1;
+ sal_Bool bRelWidth : 1;
+ sal_Bool bHasHeading : 1;
+
+ sal_uInt32 nCurRow;
+ sal_uInt32 nCurCol;
+ sal_Int32 nWidth;
+
+ SwTableBox *NewTableBox( const SwStartNode *pStNd,
+ SwTableLine *pUpper );
+ SwTableBox *MakeTableBox( SwTableLine *pUpper,
+ const SwXMLTableCell_Impl *pStartNode,
+ sal_uInt32 nTopRow, sal_uInt32 nLeftCol,
+ sal_uInt32 nBottomRow, sal_uInt32 nRightCol );
+ SwTableBox *MakeTableBox( SwTableLine *pUpper,
+ sal_uInt32 nTopRow, sal_uInt32 nLeftCol,
+ sal_uInt32 nBottomRow, sal_uInt32 nRightCol );
+ SwTableLine *MakeTableLine( SwTableBox *pUpper,
+ sal_uInt32 nTopRow, sal_uInt32 nLeftCol,
+ sal_uInt32 nBottomRow, sal_uInt32 nRightCol );
+
+ void _MakeTable( SwTableBox *pBox=0 );
+ void MakeTable( SwTableBox *pBox, sal_Int32 nWidth );
+ void MakeTable();
+
+ inline SwXMLTableContext *GetParentTable() const;
+
+ const SwStartNode *GetPrevStartNode( sal_uInt32 nRow,
+ sal_uInt32 nCol ) const;
+ inline const SwStartNode *GetLastStartNode() const;
+ void FixRowSpan( sal_uInt32 nRow, sal_uInt32 nCol, sal_uInt32 nColSpan );
+ void ReplaceWithEmptyCell( sal_uInt32 nRow, sal_uInt32 nCol );
+
+public:
+
+ SwXMLTableContext( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+ SwXMLTableContext( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable );
+
+ virtual ~SwXMLTableContext();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+
+ void InsertColumn( sal_Int32 nWidth, sal_Bool bRelWidth );
+ sal_Int32 GetColumnWidth( sal_uInt32 nCol, sal_uInt32 nColSpan=1UL ) const;
+ inline sal_uInt32 GetColumnCount() const;
+
+ sal_Bool IsInsertCellPossible() const { return nCurCol < GetColumnCount(); }
+ sal_Bool IsInsertColPossible() const { return nCurCol < USHRT_MAX; }
+ sal_Bool IsInsertRowPossible() const { return nCurRow < USHRT_MAX; }
+
+
+ void InsertCell( const ::rtl::OUString& rStyleName,
+ sal_uInt32 nRowSpan=1U, sal_uInt32 nColSpan=1U,
+ const SwStartNode *pStNd=0,
+ SwXMLTableContext *pTable=0 );
+ void InsertRow( const ::rtl::OUString& rStyleName,
+ sal_Bool bInHead );
+ void FinishRow();
+ SwXMLTableCell_Impl *GetCell( sal_uInt32 nRow, sal_uInt32 nCol ) const;
+ const SwStartNode *InsertTableSection( const SwStartNode *pPrevSttNd=0 );
+
+ virtual void EndElement();
+};
+
+inline SwXMLTableContext *SwXMLTableContext::GetParentTable() const
+{
+ return (SwXMLTableContext *)&xParentTable;
+}
+
+inline sal_uInt32 SwXMLTableContext::GetColumnCount() const
+{
+ return aColumnWidths.Count();
+}
+
+inline const SwStartNode *SwXMLTableContext::GetLastStartNode() const
+{
+ return GetPrevStartNode( 0UL, GetColumnCount() );
+}
+
+
+#endif
diff --git a/sw/source/filter/xml/xmltext.cxx b/sw/source/filter/xml/xmltext.cxx
new file mode 100644
index 000000000000..ff2578915dab
--- /dev/null
+++ b/sw/source/filter/xml/xmltext.cxx
@@ -0,0 +1,1647 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmltext.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#include "hintids.hxx"
+
+#ifndef _RTL_STRBUF_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#ifndef _RSCSFX_HXX
+#include <rsc/rscsfx.hxx>
+#endif
+
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+
+#ifndef _XMLOFF_I18NMAP_HXX
+#include <xmloff/i18nmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLITEM_HXX
+#include <xmloff/xmlitem.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLIMPIT_HXX
+#include <xmloff/xmlimpit.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLITMPR_HXX
+#include <xmloff/xmlexpit.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLASTPL_HXX
+#include <xmloff/xmlastpl.hxx>
+#endif
+#ifndef _XMLOFF_TXTIMP_HXX
+#include <xmloff/txtimp.hxx>
+#endif
+
+#ifndef _XMLOFF_TXTFLDE_HXX
+#include <xmloff/txtflde.hxx>
+#endif
+
+#ifndef _XMLOFF_TXTVFLDI_HXX
+//#include <xmloff/txtvfldi.hxx>
+#endif
+
+#ifndef _UNOFIELD_HXX
+#include <unofield.hxx>
+#endif
+
+#ifndef _SVX_FONTITEM_HXX //autogen wg. SvxFontItem
+#include <svx/fontitem.hxx>
+#endif
+
+#ifndef _NDTXT_HXX //autogen wg. SwTxtNode
+#include <ndtxt.hxx>
+#endif
+#ifndef _SECTION_HXX //autogen wg. SwSection
+#include <section.hxx>
+#endif
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#ifndef _PAM_HXX //autogen wg. SwPaM
+#include <pam.hxx>
+#endif
+#ifndef _TXATBASE_HXX
+#include <txatbase.hxx>
+#endif
+#ifndef _CHARATR_HXX
+#include <charatr.hxx>
+#endif
+#ifndef _CHARFMT_HXX
+#include <charfmt.hxx>
+#endif
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+#ifndef _FLDBAS_HXX
+#include <fldbas.hxx>
+#endif
+#ifndef _FMTFLD_HXX
+#include <fmtfld.hxx>
+#endif
+#ifndef _FCHRFMT_HXX
+#include <fchrfmt.hxx>
+#endif
+#ifndef _UNOSTYLE_HXX
+#include "unostyle.hxx"
+#endif
+
+#ifndef _XMLECTXT_HXX
+#include "xmlectxt.hxx"
+#endif
+#ifndef _HINTLIST_HXX
+#include "hintlist.hxx"
+#endif
+#ifndef _XMLIMP_HXX
+#include "xmlimp.hxx"
+#endif
+#ifndef _XMLEXP_HXX
+#include "xmlexp.hxx"
+#endif
+#ifndef _XMLNUM_HXX
+#include "xmlnum.hxx"
+#endif
+#ifndef _XMLTBLI_HXX
+#include "xmltbli.hxx"
+#endif
+#ifndef _XMLFMTE_HXX
+#include "xmlfmte.hxx"
+#endif
+#ifndef _XMLTEXTI_HXX
+#include "xmltexti.hxx"
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::text;
+
+#ifdef XML_CORE_API
+enum SwXMLTextPElemTokens
+{
+ XML_TOK_SW_SPAN,
+ XML_TOK_SW_TAB_STOP,
+ XML_TOK_SW_LINE_BREAK,
+ XML_TOK_SW_S,
+ XML_TOK_SW_P_ELEM_END=XML_TOK_UNKNOWN
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aTextPElemTokenMap[] =
+{
+ { XML_NAMESPACE_TEXT, sXML_span, XML_TOK_SW_SPAN },
+ { XML_NAMESPACE_TEXT, sXML_tab_stop, XML_TOK_SW_TAB_STOP },
+ { XML_NAMESPACE_TEXT, sXML_line_break, XML_TOK_SW_LINE_BREAK },
+ { XML_NAMESPACE_TEXT, sXML_s, XML_TOK_SW_S },
+ XML_TOKEN_MAP_END
+};
+
+const SvXMLTokenMap& SwXMLImport::GetTextPElemTokenMap()
+{
+ if( !pTextPElemTokenMap )
+ pTextPElemTokenMap = new SvXMLTokenMap( aTextPElemTokenMap );
+
+ return *pTextPElemTokenMap;
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLHint_Impl
+{
+ SfxItemSet aItemSet;
+ xub_StrLen nStart;
+ xub_StrLen nEnd;
+
+public:
+
+ SwXMLHint_Impl( SfxItemPool& rPool, xub_StrLen nPos ) :
+ aItemSet( rPool, RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
+ RES_TXTATR_BEGIN, RES_TXTATR_END - 1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END - 1, 0 ),
+ nStart( nPos ),
+ nEnd( nPos )
+ {}
+
+ SfxItemSet& GetItemSet() { return aItemSet; }
+ xub_StrLen GetStart() const { return nStart; }
+ xub_StrLen GetEnd() const { return nEnd; }
+ void SetEnd( xub_StrLen nPos ) { nEnd = nPos; }
+};
+
+typedef SwXMLHint_Impl *SwXMLHint_ImplPtr;
+SV_DECL_PTRARR_DEL( SwXMLHints_Impl, SwXMLHint_ImplPtr, 5, 5 )
+SV_IMPL_PTRARR( SwXMLHints_Impl, SwXMLHint_ImplPtr )
+
+// ---------------------------------------------------------------------
+
+class SwXMLImpCharContext_Impl : public SvXMLImportContext
+{
+public:
+
+ SwXMLImpCharContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ sal_Unicode c,
+ sal_Bool bCount );
+
+ virtual ~SwXMLImpCharContext_Impl();
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+
+SwXMLImpCharContext_Impl::SwXMLImpCharContext_Impl(
+ SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ sal_Unicode c,
+ sal_Bool bCount ) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+ sal_uInt16 nCount = 1;
+
+ if( bCount )
+ {
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ if( XML_NAMESPACE_TEXT == nPrefix &&
+ aLocalName.compareToAscii( sXML_c ) == 0 )
+ {
+ sal_Int32 nTmp = xAttrList->getValueByIndex(i).toInt32();
+ if( nTmp > 0L )
+ {
+ if( nTmp > USHRT_MAX )
+ nCount = USHRT_MAX;
+ else
+ nCount = (sal_uInt16)nTmp;
+ }
+ }
+ }
+ }
+
+ if( 1U == nCount )
+ {
+ GetSwImport().GetDoc().Insert( GetSwImport().GetPaM(), c );
+ }
+ else
+ {
+ OUStringBuffer sBuff( nCount );
+ while( nCount-- )
+ sBuff.append( c );
+
+ GetSwImport().GetDoc().Insert( GetSwImport().GetPaM(),
+ sBuff.makeStringAndClear() );
+ }
+}
+
+SwXMLImpCharContext_Impl::~SwXMLImpCharContext_Impl()
+{
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLImpSpanContext_Impl : public SvXMLImportContext
+{
+ SwXMLHints_Impl& rHints;
+ SwXMLHint_Impl *pHint;
+
+ sal_Bool& rIgnoreLeadingSpace;
+
+public:
+
+ SwXMLImpSpanContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLHints_Impl& rHnts,
+ sal_Bool& rIgnLeadSpace );
+
+ virtual ~SwXMLImpSpanContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+
+ virtual void Characters( const OUString& rChars );
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+
+SwXMLImpSpanContext_Impl::SwXMLImpSpanContext_Impl(
+ SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLHints_Impl& rHnts,
+ sal_Bool& rIgnLeadSpace ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ rHints( rHnts ),
+ rIgnoreLeadingSpace( rIgnLeadSpace ),
+ pHint( 0 )
+{
+ OUString aStyleName;
+
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ if( XML_NAMESPACE_TEXT == nPrefix &&
+ aLocalName.compareToAscii( sXML_style_name ) == 0 )
+ aStyleName = xAttrList->getValueByIndex( i );
+ }
+
+ if( aStyleName.getLength() )
+ {
+ SwDoc& rDoc = GetSwImport().GetDoc();
+
+ // try to find a matching automatic style
+ const SfxItemSet *pAutoItemSet = 0;
+ OUString sParentStyle;
+ if( GetSwImport().FindAutomaticStyle( SFX_STYLE_FAMILY_CHAR,
+ aStyleName, &pAutoItemSet,
+ &sParentStyle ) )
+ {
+ aStyleName = sParentStyle;
+ }
+
+ // if an automatic style has not been found or has been found and
+ // has a parent style, try to find this one.
+ SwCharFmt *pCharFmt = 0;
+ if( aStyleName.getLength() )
+ {
+ const SvI18NMap& rI18NMap = GetSwImport().GetI18NMap();
+ String sName( rI18NMap.Get( SFX_STYLE_FAMILY_CHAR,
+ aStyleName) );
+ pCharFmt = rDoc.FindCharFmtByName( sName );
+ }
+
+ if( pAutoItemSet || pCharFmt )
+ {
+ xub_StrLen nPos =
+ GetSwImport().GetPaM().GetPoint()->nContent.GetIndex();
+ pHint = new SwXMLHint_Impl( rDoc.GetAttrPool(), nPos );
+ rHints.Insert( pHint, rHints.Count() );
+ if( pAutoItemSet )
+ pHint->GetItemSet().Put( *pAutoItemSet );
+ if( pCharFmt )
+ {
+ SwFmtCharFmt aCharFmt( pCharFmt );
+ pHint->GetItemSet().Put( aCharFmt );
+ }
+ }
+ }
+}
+
+SwXMLImpSpanContext_Impl::~SwXMLImpSpanContext_Impl()
+{
+ if( pHint )
+ {
+ xub_StrLen nPos =
+ GetSwImport().GetPaM().GetPoint()->nContent.GetIndex();
+ pHint->SetEnd( nPos );
+ }
+}
+
+SvXMLImportContext *SwXMLImpSpanContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetTextPElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_SW_SPAN:
+ pContext = new SwXMLImpSpanContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ rHints,
+ rIgnoreLeadingSpace );
+ break;
+
+ case XML_TOK_SW_TAB_STOP:
+ pContext = new SwXMLImpCharContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ 0x0009, sal_False );
+ rIgnoreLeadingSpace = sal_False;
+ break;
+
+ case XML_TOK_SW_LINE_BREAK:
+ pContext = new SwXMLImpCharContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ 0x000A, sal_False );
+ rIgnoreLeadingSpace = sal_False;
+ break;
+
+ case XML_TOK_SW_S:
+ pContext = new SwXMLImpCharContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ 0x0020, sal_True );
+ break;
+
+ default:
+ // ignore unknown content
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+ break;
+ }
+
+ return pContext;
+}
+
+void SwXMLImpSpanContext_Impl::Characters( const OUString& rChars )
+{
+ sal_Int32 nLen = rChars.getLength();
+ OUStringBuffer sChars( nLen );
+
+ for( sal_Int32 i=0; i < nLen; i++ )
+ {
+ sal_Unicode c = rChars[i];
+ switch( c )
+ {
+ case 0x20:
+ case 0x09:
+ case 0x0a:
+ case 0x0d:
+ if( !rIgnoreLeadingSpace )
+ sChars.append( (sal_Unicode)0x20 );
+ rIgnoreLeadingSpace = sal_True;
+ break;
+ default:
+ rIgnoreLeadingSpace = sal_False;
+ sChars.append( c );
+ break;
+ }
+ }
+
+ GetSwImport().GetDoc().Insert( GetSwImport().GetPaM(),
+ sChars.makeStringAndClear() );
+}
+
+// ---------------------------------------------------------------------
+
+enum SwXMLTextPAttrTokens
+{
+ XML_TOK_SW_P_STYLE_NAME,
+ XML_TOK_SW_P_COND_STYLE_NAME,
+ XML_TOK_SW_P_LEVEL,
+ XML_TOK_SW_P_END=XML_TOK_UNKNOWN
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aTextPAttrTokenMap[] =
+{
+ { XML_NAMESPACE_TEXT, sXML_style_name, XML_TOK_SW_P_STYLE_NAME },
+ { XML_NAMESPACE_TEXT, sXML_cond_style_name,
+ XML_TOK_SW_P_COND_STYLE_NAME },
+ { XML_NAMESPACE_TEXT, sXML_level, XML_TOK_SW_P_LEVEL },
+ XML_TOKEN_MAP_END
+};
+
+SwXMLParaContext::SwXMLParaContext(
+ SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ sal_Bool bHead ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ pItemSet( 0 ),
+ pHints( 0 ),
+ bIgnoreLeadingSpace( sal_True ),
+ bHeading( bHead )
+{
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetTextPAttrTokenMap();
+
+ OUString aStyleName, aCondStyleName;
+ sal_uInt8 nOutlineLevel = NO_NUMBERING;
+
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+ const OUString& rValue = xAttrList->getValueByIndex( i );
+
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ switch( rTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_SW_P_STYLE_NAME:
+ aStyleName = rValue;
+ break;
+ case XML_TOK_SW_P_COND_STYLE_NAME:
+ aCondStyleName = rValue;
+ break;
+ case XML_TOK_SW_P_LEVEL:
+ {
+ sal_Int32 nTmp = rValue.toInt32() - 1L;
+ if( nTmp >= 0L )
+ {
+ if( nTmp > MAXLEVEL )
+ nTmp = MAXLEVEL;
+ nOutlineLevel = (sal_uInt8)nTmp;
+ }
+ }
+
+ }
+ }
+
+ if( aCondStyleName.getLength() )
+ {
+ OUString sTmp( aStyleName );
+ aStyleName = aCondStyleName;
+ aCondStyleName = sTmp;
+ }
+
+ if( aStyleName.getLength() )
+ {
+ const SfxItemSet *pAutoItemSet = 0;
+ OUString sParentStyle;
+ if( GetSwImport().FindAutomaticStyle( SFX_STYLE_FAMILY_PARA,
+ aStyleName, &pAutoItemSet,
+ &sParentStyle ) )
+ {
+ aStyleName = sParentStyle;
+ }
+
+ if( pAutoItemSet )
+ {
+ if( !pItemSet )
+ pItemSet = new SfxItemSet( GetSwImport().GetDoc().GetAttrPool(),
+ aTxtNodeSetRange );
+ pItemSet->Put( *pAutoItemSet );
+ }
+
+ if( aStyleName.getLength() )
+ {
+ const SvI18NMap& rI18NMap = GetSwImport().GetI18NMap();
+ String sName( rI18NMap.Get( SFX_STYLE_FAMILY_PARA, aStyleName ) );
+ SwDoc& rDoc = GetSwImport().GetDoc();
+ SwTxtFmtColl *pColl = rDoc.FindTxtFmtCollByName( sName );
+ if( pColl )
+ {
+ sal_uInt8 nCollOutlineLevel = pColl->GetOutlineLevel();
+ if( bHeading && !( GetSwImport().IsInsertMode() ||
+ GetSwImport().IsStylesOnlyMode() ) &&
+ NO_NUMBERING != nOutlineLevel &&
+ ( NO_NUMBERING == nCollOutlineLevel ||
+ GetRealLevel(nCollOutlineLevel) != nOutlineLevel ) )
+ {
+ sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->Count();
+ for( sal_uInt16 i=0; i<nArrLen; i++ )
+ {
+ SwTxtFmtColl* pCur = (*rDoc.GetTxtFmtColls())[i];
+ sal_uInt8 nCurLevel = pCur->GetOutlineLevel();
+ if( nCurLevel != NO_NUMBERING &&
+ GetRealLevel(nCurLevel) == nOutlineLevel )
+ {
+ if( pColl != pCur )
+ pCur->SetOutlineLevel( NO_NUMBERING );
+ break;
+ }
+ }
+ pColl->SetOutlineLevel( nOutlineLevel );
+ }
+ rDoc.SetTxtFmtColl( GetSwImport().GetPaM(), pColl );
+ }
+ }
+ }
+}
+
+SwXMLParaContext::~SwXMLParaContext()
+{
+#ifndef PRODUCT
+ SwCntntNode *pTTTNd = GetSwImport().GetPaM().GetNode()->GetCntntNode();
+#endif
+
+ // Start a new node.
+ SwDoc& rDoc = GetSwImport().GetDoc();
+ rDoc.AppendTxtNode( *GetSwImport().GetPaM().GetPoint() );
+
+ // Create a "attribute" PaM and move it to the previous node.
+ SwPaM aPaM( GetSwImport().GetPaM() );
+ aPaM.Move( fnMoveBackward, fnGoCntnt );
+ aPaM.SetMark();
+ SwCntntNode *pCNd = aPaM.GetNode()->GetCntntNode();
+ ASSERT( pCNd,
+ "SwXMLParaContext::~SwXMLParaContext: no content node" );
+#ifndef PRODUCT
+ ASSERT( pTTTNd == pCNd,
+ "SwXMLParaContext::~SwXMLParaContext: wrong content node" );
+ ASSERT( (const SwIndexReg*)pTTTNd == aPaM.GetPoint()->nContent.GetIdxReg(),
+ "SwXMLParaContext::~SwXMLParaContext: wrong content node" );
+#endif
+
+ aPaM.GetPoint()->nContent.Assign( pCNd, 0 );
+
+ // Set paragraph attributes.
+ if( pItemSet )
+ rDoc.Insert( aPaM, *pItemSet );
+ delete pItemSet;
+
+ // Set numbering rules
+ SwTxtNode *pTxtNd = pCNd->GetTxtNode();
+ const SwNumRule *pNumRule = pTxtNd->GetNumRule();
+ if( GetSwImport().IsInList() )
+ {
+ SwXMLListBlockContext *pListBlock = GetSwImport().GetListBlock();
+ String sStyleName( GetSwImport().GetI18NMap().Get(
+ SFX_STYLE_FAMILY_PSEUDO,pListBlock->GetStyleName()) );
+ if( !pNumRule ||
+ ( !pListBlock->HasGeneratedStyle() &&
+ pNumRule->GetName() != sStyleName ) )
+ {
+ rDoc.Insert( aPaM, SwNumRuleItem( sStyleName ) );
+ pNumRule = pTxtNd->GetNumRule();
+ }
+
+ ASSERT( pNumRule, "SwXMLParaContext::~SwXMLParaContext: no num rule" );
+ GetSwImport().SetUsed( *pNumRule );
+
+ SwXMLListItemContext *pListItem = GetSwImport().GetListItem();
+
+ sal_uInt8 nLevel = pListBlock->GetLevel() > MAXLEVEL
+ ? MAXLEVEL
+ : (sal_uInt8)pListBlock->GetLevel();
+ if( !pListItem )
+ nLevel |= NO_NUMLEVEL;
+
+ SwNodeNum aNodeNum( nLevel );
+ if( pListBlock->IsRestartNumbering() )
+ {
+ aNodeNum.SetStart();
+ pListBlock->ResetRestartNumbering();
+ }
+ if( pListItem && pListItem->HasStartValue() )
+ {
+ aNodeNum.SetSetValue( pListItem->GetStartValue() );
+ }
+
+ pTxtNd->UpdateNum( aNodeNum );
+
+ GetSwImport().SetListItem( 0 );
+ }
+ else
+ {
+ // If the paragraph is not in a list but its style, remove it from
+ // the list.
+ if( pNumRule )
+ rDoc.Insert( aPaM, SwNumRuleItem() );
+ }
+
+ if( pHints && pHints->Count() )
+ {
+ for( sal_uInt16 i=0; i<pHints->Count(); i++ )
+ {
+ SwXMLHint_Impl *pHint = (*pHints)[i];
+ xub_StrLen nStt = pHint->GetStart();
+ xub_StrLen nEnd = pHint->GetEnd();
+ if( nStt != nEnd )
+ {
+ aPaM.GetPoint()->nContent.Assign( pCNd, nEnd );
+ aPaM.SetMark();
+ aPaM.GetPoint()->nContent.Assign( pCNd, nStt );
+ rDoc.Insert( aPaM, pHint->GetItemSet() );
+ }
+ }
+ }
+ delete pHints;
+}
+
+SvXMLImportContext *SwXMLParaContext::CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetTextPElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_SW_SPAN:
+ if( !pHints )
+ pHints = new SwXMLHints_Impl;
+ pContext = new SwXMLImpSpanContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ *pHints, bIgnoreLeadingSpace );
+ break;
+
+ case XML_TOK_SW_TAB_STOP:
+ pContext = new SwXMLImpCharContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ 0x0009, sal_False );
+ bIgnoreLeadingSpace = sal_False;
+ break;
+
+ case XML_TOK_SW_LINE_BREAK:
+ pContext = new SwXMLImpCharContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ 0x000A, sal_False );
+ bIgnoreLeadingSpace = sal_False;
+ break;
+
+ case XML_TOK_SW_S:
+ pContext = new SwXMLImpCharContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ 0x0020, sal_True );
+ break;
+
+ default:
+ // ignore unknown content
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+ break;
+ }
+
+ return pContext;
+}
+
+void SwXMLParaContext::Characters( const OUString& rChars )
+{
+ sal_Int32 nLen = rChars.getLength();
+ OUStringBuffer sChars( nLen );
+
+ for( sal_Int32 i=0; i < nLen; i++ )
+ {
+ sal_Unicode c = rChars[ i ];
+ switch( c )
+ {
+ case 0x20:
+ case 0x09:
+ case 0x0a:
+ case 0x0d:
+ if( !bIgnoreLeadingSpace )
+ sChars.append( (sal_Unicode)0x20 );
+ bIgnoreLeadingSpace = sal_True;
+ break;
+ default:
+ bIgnoreLeadingSpace = sal_False;
+ sChars.append( c );
+ break;
+ }
+ }
+
+ GetSwImport().GetDoc().Insert( GetSwImport().GetPaM(),
+ sChars.makeStringAndClear() );
+}
+
+const SvXMLTokenMap& SwXMLImport::GetTextPAttrTokenMap()
+{
+ if( !pTextPAttrTokenMap )
+ pTextPAttrTokenMap = new SvXMLTokenMap( aTextPAttrTokenMap );
+
+ return *pTextPAttrTokenMap;
+}
+#endif
+
+// ---------------------------------------------------------------------
+
+#ifdef XML_CORE_API
+static __FAR_DATA SvXMLTokenMapEntry aBodyElemTokenMap[] =
+{
+ { XML_NAMESPACE_TEXT, sXML_p, XML_TOK_SW_P },
+ { XML_NAMESPACE_TEXT, sXML_h, XML_TOK_SW_H },
+ { XML_NAMESPACE_TEXT, sXML_ordered_list, XML_TOK_SW_ORDERED_LIST },
+ { XML_NAMESPACE_TEXT, sXML_unordered_list, XML_TOK_SW_UNORDERED_LIST },
+ { XML_NAMESPACE_TABLE,sXML_table, XML_TOK_TABLE_TABLE },
+ { XML_NAMESPACE_TABLE,sXML_sub_table, XML_TOK_TABLE_SUBTABLE },
+ XML_TOKEN_MAP_END
+};
+#endif
+
+class SwXMLBodyContext_Impl : public SvXMLImportContext
+{
+#ifdef XML_CORE_API
+ const SwXMLImport& GetSwImport() const
+ { return (const SwXMLImport&)GetImport(); }
+#endif
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+
+public:
+
+ SwXMLBodyContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName );
+ virtual ~SwXMLBodyContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+};
+
+SwXMLBodyContext_Impl::SwXMLBodyContext_Impl( SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName ) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+}
+
+SwXMLBodyContext_Impl::~SwXMLBodyContext_Impl()
+{
+}
+
+SvXMLImportContext *SwXMLBodyContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+#ifndef XML_CORE_API
+ pContext = GetSwImport().GetTextImport()->CreateTextChildContext(
+ GetImport(), nPrefix, rLocalName, xAttrList,
+ XML_TEXT_TYPE_BODY );
+#else
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetBodyElemTokenMap();
+ sal_Bool bOrdered = sal_False;
+ sal_Bool bHeading = sal_False;
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_SW_H:
+ bHeading = sal_True;
+ case XML_TOK_SW_P:
+ pContext = new SwXMLParaContext( GetSwImport(),nPrefix, rLocalName,
+ xAttrList, bHeading );
+ break;
+ case XML_TOK_SW_ORDERED_LIST:
+ bOrdered = sal_True;
+ case XML_TOK_SW_UNORDERED_LIST:
+ pContext = new SwXMLListBlockContext( GetSwImport(),nPrefix, rLocalName,
+ xAttrList, bOrdered );
+ break;
+ case XML_TOK_TABLE_TABLE:
+ if( !GetSwImport().GetPaM().GetNode()->FindTableNode() )
+ pContext = new SwXMLTableContext( GetSwImport(),nPrefix, rLocalName,
+ xAttrList );
+ break;
+ }
+#endif
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+#ifdef XML_CORE_API
+const SvXMLTokenMap& SwXMLImport::GetBodyElemTokenMap()
+{
+ if( !pBodyElemTokenMap )
+ pBodyElemTokenMap = new SvXMLTokenMap( aBodyElemTokenMap );
+
+ return *pBodyElemTokenMap;
+}
+#endif
+
+SvXMLImportContext *SwXMLImport::CreateBodyContext(
+ const OUString& rLocalName )
+{
+ // styles nun einfuegen!
+ InsertStyles();
+
+ SvXMLImportContext *pContext = 0;
+
+ if( !IsStylesOnlyMode() )
+ pContext = new SwXMLBodyContext_Impl( *this, XML_NAMESPACE_OFFICE,
+ rLocalName );
+ else
+ pContext = new SvXMLImportContext( *this, XML_NAMESPACE_OFFICE,
+ rLocalName );
+
+ return pContext;
+}
+
+// ---------------------------------------------------------------------
+
+#ifdef XML_CORE_API
+class SwXMLHintEndPosList : public SwHintEndPosList
+{
+ OUString sQSpan;
+ SwXMLExport& rExport;
+
+public:
+
+ SwXMLHintEndPosList( SwXMLExport& rExp );
+ ~SwXMLHintEndPosList();
+
+ void Insert( const SfxPoolItem& rItem, xub_StrLen nStart, xub_StrLen nEnd );
+
+ sal_Bool HasStartingOrEndingHints( xub_StrLen nPos );
+
+ sal_Bool ExportStartingHints( xub_StrLen nPos );
+ sal_Bool ExportEndingHints( xub_StrLen nPos );
+};
+
+SwXMLHintEndPosList::SwXMLHintEndPosList( SwXMLExport& rExp ) :
+ rExport( rExp )
+{
+ OUString sLName( OUString::createFromAscii( sXML_span ) );
+ sQSpan = rExp.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TEXT, sLName );
+}
+
+SwXMLHintEndPosList::~SwXMLHintEndPosList()
+{
+}
+
+void SwXMLHintEndPosList::Insert( const SfxPoolItem& rItem,
+ xub_StrLen nStart, xub_StrLen nEnd )
+{
+ // empty hints will be ignored
+ if( nStart != nEnd )
+ {
+ InsertHint( rItem, nStart, nEnd );
+ }
+}
+
+sal_Bool SwXMLHintEndPosList::ExportStartingHints( xub_StrLen nPos )
+{
+ sal_Bool bRet = sal_False;
+
+ // Hints in the start list are sorted ascending.
+
+ sal_uInt16 nCount = GetStartingCount();
+ for( sal_uInt16 i=0; i< nCount; i++ )
+ {
+ SwHintSttEndPos *pPos = GetStartingHint( i );
+ xub_StrLen nStart = pPos->GetStart();
+ if( nStart > nPos )
+ {
+ // This and all following hint will be started later
+ break;
+ }
+ else if( nStart == nPos )
+ {
+ // export hint's start
+// if( bIWSOutside )
+// rExport.GetDocHandler()->ignorableWhitespace( rExport.sWS );
+ const SfxPoolItem& rItem = pPos->GetItem();
+ if( (rItem.Which() >= RES_CHRATR_BEGIN &&
+ rItem.Which() < RES_CHRATR_END) ||
+ (rItem.Which() >= RES_UNKNOWNATR_BEGIN &&
+ rItem.Which() < RES_UNKNOWNATR_END) )
+ {
+ SfxItemSet aItemSet( rExport.GetDoc().GetAttrPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END - 1,
+ 0 );
+ aItemSet.Put( rItem );
+ OUString sName( rExport.GetItemSetAutoStylePool().Find(
+ SFX_STYLE_FAMILY_CHAR, aItemSet ) );
+ ASSERT( sName.getLength(), "no automatic style found" );
+ if( sName.getLength() )
+ rExport.AddAttribute( XML_NAMESPACE_TEXT, sXML_style_name,
+ sName );
+ }
+ else
+ {
+ rExport.GetParaItemMapper().exportXML(
+ rExport.GetAttrList(), rItem,
+ rExport.GetTwipUnitConverter(),
+ rExport.GetNamespaceMap() );
+ }
+
+ rExport.GetDocHandler()->startElement( sQSpan,
+ rExport.GetXAttrList() );
+ rExport.ClearAttrList();
+
+ bRet = sal_True;
+ }
+ }
+
+ return bRet;
+}
+
+sal_Bool SwXMLHintEndPosList::ExportEndingHints( xub_StrLen nPos )
+{
+ sal_Bool bRet = sal_False;
+
+ // Hints in the end list are sorted ascending
+ sal_uInt16 i=0;
+ while( i < GetEndingCount() )
+ {
+ SwHintSttEndPos *pPos = GetEndingHint( i );
+ xub_StrLen nEnd = pPos->GetEnd();
+
+ if( STRING_LEN==nPos || nEnd == nPos )
+ {
+// if( bIgnWS )
+// rExport.GetDocHandler()->ignorableWhitespace( rExport.sWS );
+ rExport.GetDocHandler()->endElement( sQSpan );
+ _RemoveHint( i );
+
+ bRet = sal_True;
+ }
+ else if( nEnd > nPos )
+ {
+ // This and all hints that are following will be closed later
+ break;
+ }
+ else
+ {
+ // This hint should have been exported already!
+ ASSERT( nEnd >= nPos,
+ "SwXMLHintEndPosLst::OutEndAttrs: hint overseen" );
+ i++;
+ }
+ }
+
+ return bRet;
+}
+
+sal_Bool SwXMLHintEndPosList::HasStartingOrEndingHints( xub_StrLen nPos )
+{
+ sal_Bool bRet = sal_False;
+
+ // Hints in the start list are sorted ascending.
+
+ sal_uInt16 nCount = GetStartingCount();
+ for( sal_uInt16 i=0; i< nCount; i++ )
+ {
+ SwHintSttEndPos *pPos = GetStartingHint( i );
+ xub_StrLen nStart = pPos->GetStart();
+ if( nStart == nPos )
+ {
+ bRet = sal_True;
+ break;
+ }
+ else if( nStart > nPos )
+ {
+ // This and all following hint will be started later
+ break;
+ }
+ }
+
+ if( !bRet )
+ {
+ nCount = GetEndingCount();
+ for( i=0; i < nCount; i++ )
+ {
+ SwHintSttEndPos *pPos = GetEndingHint( i );
+ xub_StrLen nEnd = pPos->GetEnd();
+
+ if( nEnd == nPos )
+ {
+ bRet = sal_True;
+ break;
+ }
+ else if( nEnd > nPos )
+ {
+ // This and all hints that are following will be closed later
+ break;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+void SwXMLExport::ExportTxtNode( const SwTxtNode& rTxtNd, xub_StrLen nStart,
+ xub_StrLen nEnd, sal_Bool bExportWholeNode )
+{
+ // <text:p ...>
+ CheckAttrList();
+
+ const SfxItemSet *pItemSet = rTxtNd.GetpSwAttrSet();
+
+ // text:style-name="..."
+ // If the text collection is a conditional style, the current style
+ // is written as style-name rather than the master style.
+ const SwFmtColl& rColl = rTxtNd.GetAnyFmtColl();
+ OUString sStyleName( rColl.GetName() );
+ if( pItemSet )
+ sStyleName = FindParaAutoStyle( sStyleName, *pItemSet );
+ else
+ sStyleName = SwXStyleFamilies::GetProgrammaticName( sStyleName,
+ SFX_STYLE_FAMILY_PARA );
+ ASSERT( sStyleName.getLength(), "auto para style not found" );
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_style_name, sStyleName );
+
+ sal_uInt8 nOutlineLevel = ((const SwTxtFmtColl&)rColl).GetOutlineLevel();
+
+ // text:cond-style-name="..."
+ if( rTxtNd.GetCondFmtColl() )
+ {
+ // master style
+ const SwFmtColl *pColl = rTxtNd.GetFmtColl();
+ OUString sCondStyleName;
+ if( &rColl == pColl )
+ {
+ sCondStyleName = sStyleName;
+ }
+ else
+ {
+ sCondStyleName = pColl->GetName();
+ if( pItemSet )
+ sCondStyleName = FindParaAutoStyle( sCondStyleName, *pItemSet );
+ else
+ sCondStyleName = SwXStyleFamilies::GetProgrammaticName(
+ sCondStyleName,
+ SFX_STYLE_FAMILY_PARA );
+ ASSERT( sCondStyleName.getLength(), "auto para style not found" );
+ nOutlineLevel = ((const SwTxtFmtColl *)pColl)->GetOutlineLevel();
+ }
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_cond_style_name,
+ sCondStyleName );
+ }
+
+ if( NO_NUMBERING != nOutlineLevel )
+ {
+ OUStringBuffer sTmp;
+ sTmp.append( GetRealLevel(nOutlineLevel)+1L );
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_level,
+ sTmp.makeStringAndClear() );
+ }
+
+ {
+ const sal_Char *pElem =
+ NO_NUMBERING == nOutlineLevel ? sXML_p : sXML_h;
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT, pElem, sal_True,
+ sal_False );
+ xub_StrLen nOffset = 0;
+
+ const String& rText = rTxtNd.GetTxt();
+ xub_StrLen nPos = pCurPaM->GetPoint()->nContent.GetIndex();
+ xub_StrLen nEndPos = rText.Len();
+ if( pCurPaM->GetPoint()->nNode == pCurPaM->GetMark()->nNode )
+ nEndPos = pCurPaM->GetMark()->nContent.GetIndex();
+
+ const SwpHints *pHints = rTxtNd.GetpSwpHints();
+ sal_uInt16 nHintCount = pHints ? pHints->Count() : 0;
+ sal_uInt16 nHintPos = 0;
+ SwXMLHintEndPosList aHintLst( *this );
+
+ // export all hints before the current text position
+ const SwTxtAttr * pTxtAttr = 0;
+ if( nHintCount && nPos > *( pTxtAttr = (*pHints)[0] )->GetStart() )
+ {
+ do
+ {
+ nHintPos++;
+
+ if( pTxtAttr->GetEnd() )
+ {
+ DBG_ASSERT( RES_TXTATR_FIELD == pTxtAttr->Which(),
+ "ignore fields" );
+ xub_StrLen nHtEnd = *pTxtAttr->GetEnd(),
+ nHtStt = *pTxtAttr->GetStart();
+ if( (!bExportWholeNode && nHtEnd <= nPos) ||
+ nHtEnd == nHtStt )
+ continue;
+
+ // add hint to hint list
+ if( bExportWholeNode )
+ {
+ aHintLst.Insert( pTxtAttr->GetAttr(), nHtStt + nOffset,
+ nHtEnd + nOffset );
+ }
+ else
+ {
+ xub_StrLen nTmpStt = nHtStt < nPos ? nPos : nHtStt;
+ xub_StrLen nTmpEnd = nHtEnd < nEndPos ? nHtEnd : nEndPos;
+ aHintLst.Insert( pTxtAttr->GetAttr(), nTmpStt + nOffset,
+ nTmpEnd + nOffset );
+ }
+ }
+
+ }
+ while( nHintPos < nHintCount &&
+ nPos > *( pTxtAttr = (*pHints)[nHintPos ] )->GetStart() );
+ }
+
+ xub_StrLen nExpStartPos = nPos;
+ sal_Bool bCurrCharIsSpace = sal_False;
+ xub_StrLen nSpaceChars = 0;
+ for( ; nPos < nEndPos; nPos++ )
+ {
+ sal_Bool bExpCharAsText = sal_True;
+ const SwTxtAttr * pTxtAttrWOEnd = 0;
+ if( nHintPos < nHintCount && *pTxtAttr->GetStart() == nPos
+ && nPos != nEndPos )
+ {
+ do
+ {
+ if( pTxtAttr->GetEnd() )
+ {
+ if( *pTxtAttr->GetEnd() != nPos )
+ {
+ // insert hint into the hint list if its not
+ // empty
+ aHintLst.Insert( pTxtAttr->GetAttr(),
+ nPos + nOffset,
+ *pTxtAttr->GetEnd() + nOffset );
+ }
+ }
+ else
+ {
+ // hints without end must be exported after all
+ // other hints that start at this position
+ ASSERT( !pTxtAttrWOEnd,
+ "SwXMLExport::ExportTxtNode: There is a hint already" );
+ pTxtAttrWOEnd = pTxtAttr;
+ bExpCharAsText = sal_False; // ignore 0xff
+ }
+ }
+ while( ++nHintPos < nHintCount &&
+ nPos == *( pTxtAttr = (*pHints)[nHintPos] )->GetStart() );
+ }
+
+ // Some characters require some extra work ...
+ sal_Bool bExpCharAsElement = sal_False;
+ sal_Bool bPrevCharIsSpace = bCurrCharIsSpace;
+ bCurrCharIsSpace = sal_False;
+ if( bExpCharAsText )
+ {
+ switch( rText.GetChar(nPos) )
+ {
+ case 0x0009: // Tab
+ case 0x000A: // LF
+ // These characters are exported as text.
+ bExpCharAsElement = sal_True;
+ bExpCharAsText = sal_False;
+ break;
+ case 0x0020: // Blank
+ if( bPrevCharIsSpace )
+ {
+ // If the previous character is a space character,
+ // too, export a special space element.
+ bExpCharAsText = sal_False;
+ }
+ bCurrCharIsSpace = sal_True;
+ break;
+ }
+ }
+
+ // If the current character is not exported as text or if there
+ // are hints starting or ending before the current position,
+ // the text that has not been exported by now has to be exported
+ // now.
+ if( nPos > nExpStartPos &&
+ ( !bExpCharAsText ||
+ aHintLst.HasStartingOrEndingHints( nPos+nOffset ) ) )
+ {
+ ASSERT( 0==nSpaceChars,
+ "SwXMLExport::ExportTxtNode: pending spaces" );
+ String sExp( rText.Copy( nExpStartPos,
+ nPos - nExpStartPos ) );
+ GetDocHandler()->characters( sExp );
+ nExpStartPos = nPos;
+ }
+
+ // If there are spaces left that have not been exported and the
+ // current chracter is either not a space or there are some
+ // hints starting or ending, the pending spaces have to be
+ // exported now.
+ if( nSpaceChars > 0 &&
+ ( !bCurrCharIsSpace ||
+ aHintLst.HasStartingOrEndingHints( nPos+nOffset ) ) )
+ {
+ ASSERT( nExpStartPos == nPos,
+ "SwXMLExport::ExportTxtNode: pending characters" );
+
+ if( nSpaceChars > 1 )
+ {
+ OUStringBuffer sTmp;
+ sTmp.append( (sal_Int32)nSpaceChars );
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_c,
+ sTmp.makeStringAndClear() );
+ }
+
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT,
+ sXML_s, sal_False, sal_False );
+
+ nSpaceChars = 0;
+ }
+
+ // Before the text or tag of the current element, ending and
+ // starting hints have to be exported.
+ aHintLst.ExportEndingHints( nPos + nOffset );
+ aHintLst.ExportStartingHints( nPos + nOffset );
+
+ // If the current character has to be exported as a special
+ // element, the elemnt will be exported now.
+ if( bExpCharAsElement )
+ {
+ switch( rText.GetChar(nPos) )
+ {
+ case 0x0009: // Tab
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT,
+ sXML_tab_stop, sal_False,
+ sal_False );
+ }
+ break;
+ case 0x000A: // LF
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT,
+ sXML_line_break, sal_False,
+ sal_False );
+ }
+ break;
+ }
+ }
+ if( pTxtAttrWOEnd )
+ {
+ // TODO: This is a hack as long as if there is no field
+ // export.
+ if( RES_TXTATR_FIELD == pTxtAttrWOEnd->Which() )
+ {
+ const SwField *pFld =
+ ((const SwFmtFld&)pTxtAttrWOEnd->GetAttr()).GetFld();
+ if( pFld )
+ {
+ GetDocHandler()->characters( pFld->Expand() );
+ }
+#ifdef XML_CORE_API
+// Reference < XTextField > xFld = new SwXTextField(
+// ((const SwFmtFld&)pTxtAttrWOEnd->GetAttr()),
+// &GetDoc() );
+//
+// GetTextFieldExport().ExportField( xFld );
+#endif
+ }
+ }
+
+ // If the current character is a space, and the previous one
+ // is a space, too, the number of pending spaces is incremented
+ // only.
+ if( bCurrCharIsSpace && bPrevCharIsSpace )
+ nSpaceChars++;
+
+ // If the currect character is not exported as text, the start
+ // position for text is the position behind the current position.
+ if( !bExpCharAsText )
+ {
+ ASSERT( nExpStartPos == nPos, "wrong export start pos" );
+ nExpStartPos = nPos+1;
+ }
+ }
+
+ // If there is some text left, it has to be exported now.
+ if( nExpStartPos < nEndPos )
+ {
+ ASSERT( 0==nSpaceChars,
+ "SwXMLExport::ExportTxtNode: pending spaces " );
+ String sExp( rText.Copy( nExpStartPos, nEndPos - nExpStartPos ) );
+ GetDocHandler()->characters( sExp );
+ }
+
+ // If there are some spaces left, they have to be exported now.
+ if( nSpaceChars > 0 )
+ {
+ if( nSpaceChars > 1 )
+ {
+ OUStringBuffer sTmp;
+ sTmp.append( (sal_Int32)nSpaceChars );
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_c,
+ sTmp.makeStringAndClear() );
+ }
+
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT, sXML_s,
+ sal_False, sal_False );
+ }
+
+ // The same applies to all hints that are currently open.
+ aHintLst.ExportEndingHints( STRING_LEN );
+ }
+}
+
+void SwXMLExport::ExportSection( const SwSectionNode& rSectNd )
+{
+#if 0
+ const SwSection& rSection = rSectNd.GetSection();
+ const SwSectionFmt *pSectFmt = rSection.GetFmt();
+ ASSERT( pSectFmt, "SwXMLExport::ExportSection: section without a format?" );
+
+ // <text:section-desc ...>
+ CheckAttrList();
+
+ // text:name="..."
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_name, S2WS(rSection.GetName()) );
+
+ // text:hidden="..."
+ if( rSection.IsHidden() )
+ {
+ AddAttributeASCII( XML_NAMESPACE_TEXT, sXML_hidden, sXML_true );
+
+ // text:condition="..."
+ if( rSection.IsCondHidden() )
+ {
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_condition,
+ S2WS(rSection.GetCondition()) );
+ }
+ }
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT, sXML_section_desc,
+ sal_True, sal_True );
+// TODO
+// pSectionItemExport->Export( pSectFmt->GetAttrSet(), XML_ITEM_IGN_WS );
+ }
+
+ // <text:section ...>
+ CheckAttrList();
+
+ // text:name="..."
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_section_name,
+ S2WS(rSection.GetName()) );
+#endif
+
+ SwNode *pStartNd = pDoc->GetNodes()[rSectNd.GetIndex() + 1];
+ SwNode *pEndNd = pDoc->GetNodes()[rSectNd.EndOfSectionIndex() - 1];
+
+ {
+#if 0
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT, sXML_section,
+ sal_True, sal_True );
+#endif
+ SwXMLExpContext aContext( *this, *pStartNd, *pEndNd, 0, STRING_LEN );
+ ExportCurPaM();
+ }
+
+ pCurPaM->GetPoint()->nNode = *rSectNd.EndOfSectionNode();
+}
+#endif
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmltext.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.48 2000/09/18 16:05:08 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.47 2000/09/18 11:58:03 mib
+ text frames/graphics import and export continued
+
+ Revision 1.46 2000/08/24 11:16:42 mib
+ text import continued
+
+ Revision 1.45 2000/08/10 10:22:16 mib
+ #74404#: Adeptions to new XSL/XLink working draft
+
+ Revision 1.44 2000/08/04 11:39:54 dvo
+ - field declarations import removed from CORE API import
+
+ Revision 1.43 2000/08/03 18:03:58 dvo
+ - variable field declarations import added
+
+ Revision 1.42 2000/07/31 09:42:35 mib
+ text export continued
+
+ Revision 1.41 2000/07/24 10:19:02 dvo
+ - textfield export for XML_CORE_API
+
+ Revision 1.40 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.39 2000/07/11 11:17:59 dvo
+ text field export added
+
+ Revision 1.38 2000/06/08 09:45:55 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.37 2000/05/24 12:08:11 mib
+ unicode bug fix
+
+ Revision 1.36 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.35 2000/03/13 14:33:45 mib
+ UNO3
+
+ Revision 1.34 2000/03/06 10:46:11 mib
+ #72585#: toInt32
+
+ Revision 1.33 2000/02/21 12:51:07 mib
+ #70271#: Export of section element removed
+
+ Revision 1.32 2000/02/17 14:40:30 mib
+ #70271#: XML table import
+
+ Revision 1.30 2000/01/27 08:59:02 mib
+ #70271#: outline numbering
+
+ Revision 1.29 2000/01/20 10:03:16 mib
+ #70271#: Lists reworked
+
+ Revision 1.28 2000/01/12 15:00:23 mib
+ #70271#: lists
+
+ Revision 1.27 2000/01/06 15:08:28 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+ Revision 1.26 1999/12/14 09:47:51 mib
+ #70271#: Export field content as text
+
+ Revision 1.25 1999/12/13 08:29:07 mib
+ #70271#: Support for element items added, background and brush item
+
+ Revision 1.24 1999/12/08 10:44:21 cl
+ #70271# added first support for importing tab-stops
+
+ Revision 1.23 1999/12/06 11:41:33 mib
+ #70258#: Container item for unkown attributes
+
+ Revision 1.22 1999/11/26 11:11:49 mib
+ export-flags, loading of styles only
+
+ Revision 1.21 1999/11/19 15:27:59 mib
+ Opt: using C++ arrays instead of string buffers
+
+ Revision 1.20 1999/11/12 11:43:03 mib
+ using item mapper, part iii
+
+ Revision 1.19 1999/11/10 15:08:09 mib
+ Import now uses XMLItemMapper
+
+ Revision 1.18 1999/11/09 15:40:08 mib
+ Using XMLItemMapper for export
+
+ Revision 1.17 1999/11/03 11:13:50 mib
+ list style import continued
+
+ Revision 1.16 1999/11/01 11:38:50 mib
+ List style import
+
+ Revision 1.15 1999/10/26 13:33:50 mib
+ list styles continued
+
+ Revision 1.14 1999/10/25 10:41:48 mib
+ Using new OUString ASCII methods
+
+ Revision 1.13 1999/10/15 12:38:01 mib
+ XML_TOK_SW_LINE_FEED -> XML_TOK_SW_LINE_BREAK
+
+ Revision 1.12 1999/10/08 11:47:56 mib
+ moved some file to SVTOOLS/SVX
+
+ Revision 1.11 1999/10/06 06:48:06 mib
+ WS stripping
+
+ Revision 1.10 1999/10/01 14:12:02 mib
+ tab, line break and space
+
+ Revision 1.9 1999/09/28 10:47:05 mib
+ memory leak
+
+ Revision 1.8 1999/09/28 08:31:47 mib
+ char fmts, hints
+
+ Revision 1.7 1999/09/23 11:54:28 mib
+ i18n, token maps and hard paragraph attributes
+
+ Revision 1.6 1999/09/22 11:57:46 mib
+ string -> wstring
+
+ Revision 1.5 1999/08/18 15:03:38 MIB
+ Style import
+
+
+ Rev 1.4 18 Aug 1999 17:03:38 MIB
+ Style import
+
+ Rev 1.3 17 Aug 1999 16:29:24 MIB
+ import of text nodes started
+
+ Rev 1.2 13 Aug 1999 16:19:42 MIB
+ styles and sections
+
+ Rev 1.1 12 Aug 1999 18:06:22 MIB
+ Export ofSvxFontItem, SvxFontHeightItem and SvxLRSpaceItem
+
+ Rev 1.0 12 Aug 1999 12:29:28 MIB
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmltexte.hxx b/sw/source/filter/xml/xmltexte.hxx
new file mode 100644
index 000000000000..0c22b3eaaa70
--- /dev/null
+++ b/sw/source/filter/xml/xmltexte.hxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmltexte.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _XMLTEXTE_HXX
+#define _XMLTEXTE_HXX
+
+#ifndef XML_CORE_API
+
+#ifndef _XMLOFF_TEXTPARAE_HXX_
+#include <xmloff/txtparae.hxx>
+#endif
+
+class SwXMLExport;
+class SvXMLAutoStylePoolP;
+
+namespace com { namespace sun { namespace star { namespace style {
+ class XStyle; } } } }
+
+class SwXMLTextParagraphExport : public XMLTextParagraphExport
+{
+ const ::rtl::OUString sTextTable;
+
+protected:
+ virtual void exportStyleContent(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::style::XStyle > & rStyle );
+
+ virtual void exportTable(
+ const ::com::sun::star::uno::Reference <
+ ::com::sun::star::text::XTextContent > & rTextContent,
+ sal_Bool bAutoStyles );
+
+public:
+ SwXMLTextParagraphExport(
+ SwXMLExport& rExp,
+ SvXMLAutoStylePoolP& rAutoStylePool );
+ ~SwXMLTextParagraphExport();
+};
+#endif
+
+
+#endif // _XMLTEXTE_HXX
diff --git a/sw/source/filter/xml/xmltexti.hxx b/sw/source/filter/xml/xmltexti.hxx
new file mode 100644
index 000000000000..f11faf0e4a77
--- /dev/null
+++ b/sw/source/filter/xml/xmltexti.hxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmltexti.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _XMLTEXTI_HXX
+#define _XMLTEXTI_HXX
+
+#ifndef _RTL_USTRING_HXX
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLTKMAP_HXX
+#include <xmloff/xmltkmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+
+#ifdef XML_CORE_API
+class SfxItemSet;
+class SwXMLHints_Impl;
+class SwXMLImport;
+namespace com { namespace sun { namespace star { namespace xml {
+ namespace sax { class XAttributeList; } } } } }
+
+
+enum SwXMLBodyElemTokens
+{
+ XML_TOK_SW_P,
+ XML_TOK_SW_H,
+ XML_TOK_SW_ORDERED_LIST,
+ XML_TOK_SW_UNORDERED_LIST,
+ XML_TOK_TABLE_TABLE,
+ XML_TOK_TABLE_SUBTABLE,
+ XML_TOK_SW_ELEM_END=XML_TOK_UNKNOWN
+};
+
+class SwXMLParaContext : public SvXMLImportContext
+{
+ SfxItemSet *pItemSet;
+ SwXMLHints_Impl *pHints;
+ sal_Bool bIgnoreLeadingSpace;
+ sal_Bool bHeading;
+
+public:
+
+ SwXMLParaContext( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ sal_Bool bHeading );
+
+ virtual ~SwXMLParaContext();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+
+ virtual void Characters( const ::rtl::OUString& rChars );
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+#endif
+
+
+#endif // _XMLTEXTI_HXX