2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-10-16 12:01:58 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 22:18:46 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-10-16 12:01:58 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-10-16 12:01:58 +00:00
|
|
|
*
|
2008-04-10 22:18:46 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-10-16 12:01:58 +00:00
|
|
|
*
|
2008-04-10 22:18:46 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-10-16 12:01:58 +00:00
|
|
|
*
|
2008-04-10 22:18:46 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-10-16 12:01:58 +00:00
|
|
|
*
|
2008-04-10 22:18:46 +00:00
|
|
|
* OpenOffice.org 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 version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-10-16 12:01:58 +00:00
|
|
|
*
|
2008-04-10 22:18:46 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-10-16 12:01:58 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include "XMLSectionSourceImportContext.hxx"
|
|
|
|
#include "XMLSectionImportContext.hxx"
|
|
|
|
#include <com/sun/star/text/SectionFileLink.hpp>
|
2007-06-27 15:06:29 +00:00
|
|
|
#include <xmloff/xmlictxt.hxx>
|
|
|
|
#include <xmloff/xmlimp.hxx>
|
|
|
|
#include <xmloff/txtimp.hxx>
|
|
|
|
#include <xmloff/nmspmap.hxx>
|
2010-04-16 23:04:00 +02:00
|
|
|
#include "xmloff/xmlnmspe.hxx"
|
2007-06-27 15:06:29 +00:00
|
|
|
#include <xmloff/xmltoken.hxx>
|
2000-10-16 12:01:58 +00:00
|
|
|
#include <com/sun/star/uno/Reference.h>
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
using ::rtl::OUString;
|
|
|
|
using ::com::sun::star::beans::XPropertySet;
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
|
|
using ::com::sun::star::xml::sax::XAttributeList;
|
|
|
|
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::text;
|
2001-06-15 16:16:59 +00:00
|
|
|
using namespace ::xmloff::token;
|
2000-10-16 12:01:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
TYPEINIT1(XMLSectionSourceImportContext, SvXMLImportContext);
|
|
|
|
|
|
|
|
XMLSectionSourceImportContext::XMLSectionSourceImportContext(
|
|
|
|
SvXMLImport& rImport,
|
|
|
|
sal_uInt16 nPrfx,
|
|
|
|
const OUString& rLocalName,
|
|
|
|
Reference<XPropertySet> & rSectPropSet) :
|
|
|
|
SvXMLImportContext(rImport, nPrfx, rLocalName),
|
|
|
|
rSectionPropertySet(rSectPropSet)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
XMLSectionSourceImportContext::~XMLSectionSourceImportContext()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
enum XMLSectionSourceToken
|
|
|
|
{
|
|
|
|
XML_TOK_SECTION_XLINK_HREF,
|
|
|
|
XML_TOK_SECTION_TEXT_FILTER_NAME,
|
|
|
|
XML_TOK_SECTION_TEXT_SECTION_NAME
|
|
|
|
};
|
|
|
|
|
2010-12-06 10:36:18 +00:00
|
|
|
static SvXMLTokenMapEntry aSectionSourceTokenMap[] =
|
2000-10-16 12:01:58 +00:00
|
|
|
{
|
2001-06-15 16:16:59 +00:00
|
|
|
{ XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_SECTION_XLINK_HREF },
|
|
|
|
{ XML_NAMESPACE_TEXT, XML_FILTER_NAME, XML_TOK_SECTION_TEXT_FILTER_NAME },
|
|
|
|
{ XML_NAMESPACE_TEXT, XML_SECTION_NAME,
|
2000-10-16 12:01:58 +00:00
|
|
|
XML_TOK_SECTION_TEXT_SECTION_NAME },
|
|
|
|
XML_TOKEN_MAP_END
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void XMLSectionSourceImportContext::StartElement(
|
|
|
|
const Reference<XAttributeList> & xAttrList)
|
|
|
|
{
|
|
|
|
SvXMLTokenMap aTokenMap(aSectionSourceTokenMap);
|
|
|
|
OUString sURL;
|
|
|
|
OUString sFilterName;
|
|
|
|
OUString sSectionName;
|
|
|
|
|
2001-01-02 13:41:38 +00:00
|
|
|
sal_Int16 nLength = xAttrList->getLength();
|
|
|
|
for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
|
2000-10-16 12:01:58 +00:00
|
|
|
{
|
|
|
|
OUString sLocalName;
|
|
|
|
sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
|
|
|
|
GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
|
|
|
|
&sLocalName );
|
|
|
|
|
|
|
|
switch (aTokenMap.Get(nPrefix, sLocalName))
|
|
|
|
{
|
|
|
|
case XML_TOK_SECTION_XLINK_HREF:
|
|
|
|
sURL = xAttrList->getValueByIndex(nAttr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XML_TOK_SECTION_TEXT_FILTER_NAME:
|
|
|
|
sFilterName = xAttrList->getValueByIndex(nAttr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XML_TOK_SECTION_TEXT_SECTION_NAME:
|
|
|
|
sSectionName = xAttrList->getValueByIndex(nAttr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
; // ignore
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// we only need them once
|
|
|
|
const OUString sFileLink(RTL_CONSTASCII_USTRINGPARAM("FileLink"));
|
|
|
|
const OUString sLinkRegion(RTL_CONSTASCII_USTRINGPARAM("LinkRegion"));
|
|
|
|
|
|
|
|
Any aAny;
|
2012-01-26 17:05:51 -02:00
|
|
|
if (!sURL.isEmpty() || !sFilterName.isEmpty())
|
2000-10-16 12:01:58 +00:00
|
|
|
{
|
|
|
|
SectionFileLink aFileLink;
|
2001-06-27 06:38:11 +00:00
|
|
|
aFileLink.FileURL = GetImport().GetAbsoluteReference( sURL );
|
2000-10-16 12:01:58 +00:00
|
|
|
aFileLink.FilterName = sFilterName;
|
|
|
|
|
|
|
|
aAny <<= aFileLink;
|
|
|
|
rSectionPropertySet->setPropertyValue(sFileLink, aAny);
|
|
|
|
}
|
|
|
|
|
2012-01-26 17:05:51 -02:00
|
|
|
if (!sSectionName.isEmpty())
|
2000-10-16 12:01:58 +00:00
|
|
|
{
|
|
|
|
aAny <<= sSectionName;
|
|
|
|
rSectionPropertySet->setPropertyValue(sLinkRegion, aAny);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void XMLSectionSourceImportContext::EndElement()
|
|
|
|
{
|
|
|
|
// this space intentionally left blank.
|
|
|
|
}
|
|
|
|
|
|
|
|
SvXMLImportContext* XMLSectionSourceImportContext::CreateChildContext(
|
|
|
|
sal_uInt16 nPrefix,
|
|
|
|
const OUString& rLocalName,
|
2006-06-19 17:44:42 +00:00
|
|
|
const Reference<XAttributeList> & )
|
2000-10-16 12:01:58 +00:00
|
|
|
{
|
|
|
|
// ignore -> default context
|
|
|
|
return new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
|
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|