2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-11-02 14:51:18 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 22:05:06 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-11-02 14:51:18 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-11-02 14:51:18 +00:00
|
|
|
*
|
2008-04-10 22:05:06 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-11-02 14:51:18 +00:00
|
|
|
*
|
2008-04-10 22:05:06 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-11-02 14:51:18 +00:00
|
|
|
*
|
2008-04-10 22:05:06 +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-11-02 14:51:18 +00:00
|
|
|
*
|
2008-04-10 22:05:06 +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-11-02 14:51:18 +00:00
|
|
|
*
|
2008-04-10 22:05:06 +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-11-02 14:51:18 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 10:08:03 +00:00
|
|
|
|
2000-11-02 14:51:18 +00:00
|
|
|
|
|
|
|
#include "XMLIndexSimpleEntryContext.hxx"
|
|
|
|
#include "XMLIndexTemplateContext.hxx"
|
2007-06-27 14:58:27 +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 14:58:27 +00:00
|
|
|
#include <xmloff/xmltoken.hxx>
|
|
|
|
#include <xmloff/xmluconv.hxx>
|
2000-11-02 14:51:18 +00:00
|
|
|
|
|
|
|
using ::rtl::OUString;
|
|
|
|
using ::com::sun::star::beans::PropertyValue;
|
|
|
|
using ::com::sun::star::beans::PropertyValues;
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
|
|
using ::com::sun::star::uno::Sequence;
|
|
|
|
using ::com::sun::star::uno::Any;
|
|
|
|
using ::com::sun::star::xml::sax::XAttributeList;
|
2001-06-29 20:07:26 +00:00
|
|
|
using ::xmloff::token::IsXMLToken;
|
|
|
|
using ::xmloff::token::XML_STYLE_NAME;
|
2000-11-02 14:51:18 +00:00
|
|
|
|
|
|
|
const sal_Char sAPI_TokenType[] = "TokenType";
|
|
|
|
const sal_Char sAPI_CharacterStyleName[] = "CharacterStyleName";
|
|
|
|
|
|
|
|
TYPEINIT1( XMLIndexSimpleEntryContext, SvXMLImportContext);
|
|
|
|
|
|
|
|
XMLIndexSimpleEntryContext::XMLIndexSimpleEntryContext(
|
|
|
|
SvXMLImport& rImport,
|
|
|
|
const OUString& rEntry,
|
|
|
|
XMLIndexTemplateContext& rTemplate,
|
|
|
|
sal_uInt16 nPrfx,
|
2006-06-19 17:40:35 +00:00
|
|
|
const OUString& rLocalName )
|
|
|
|
: SvXMLImportContext(rImport, nPrfx, rLocalName)
|
|
|
|
, rEntryType(rEntry)
|
|
|
|
, bCharStyleNameOK(sal_False)
|
|
|
|
, rTemplateContext(rTemplate)
|
|
|
|
, nValues(1)
|
2000-11-02 14:51:18 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
XMLIndexSimpleEntryContext::~XMLIndexSimpleEntryContext()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void XMLIndexSimpleEntryContext::StartElement(
|
|
|
|
const Reference<XAttributeList> & xAttrList)
|
|
|
|
{
|
|
|
|
// we know only one attribute: style-name
|
2001-01-02 13:41:38 +00:00
|
|
|
sal_Int16 nLength = xAttrList->getLength();
|
|
|
|
for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
|
2000-11-02 14:51:18 +00:00
|
|
|
{
|
|
|
|
OUString sLocalName;
|
|
|
|
sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
|
|
|
|
GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
|
|
|
|
&sLocalName );
|
|
|
|
if ( (XML_NAMESPACE_TEXT == nPrefix) &&
|
2001-06-29 20:07:26 +00:00
|
|
|
IsXMLToken(sLocalName, XML_STYLE_NAME) )
|
2000-11-02 14:51:18 +00:00
|
|
|
{
|
|
|
|
sCharStyleName = xAttrList->getValueByIndex(nAttr);
|
2006-11-01 14:07:12 +00:00
|
|
|
OUString sDisplayStyleName = GetImport().GetStyleDisplayName(
|
2007-01-23 07:28:32 +00:00
|
|
|
XML_STYLE_FAMILY_TEXT_TEXT, sCharStyleName );
|
2006-11-01 14:07:12 +00:00
|
|
|
// #142494#: Check if style exists
|
|
|
|
const Reference < ::com::sun::star::container::XNameContainer > & rStyles =
|
2007-01-23 07:28:32 +00:00
|
|
|
GetImport().GetTextImport()->GetTextStyles();
|
2006-11-01 14:07:12 +00:00
|
|
|
if( rStyles.is() && rStyles->hasByName( sDisplayStyleName ) )
|
|
|
|
bCharStyleNameOK = sal_True;
|
|
|
|
else
|
|
|
|
bCharStyleNameOK = sal_False;
|
2000-11-02 14:51:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we have a style name, set it!
|
|
|
|
if (bCharStyleNameOK)
|
|
|
|
{
|
|
|
|
nValues++;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void XMLIndexSimpleEntryContext::EndElement()
|
|
|
|
{
|
|
|
|
Sequence<PropertyValue> aValues(nValues);
|
|
|
|
|
|
|
|
FillPropertyValues(aValues);
|
|
|
|
rTemplateContext.addTemplateEntry(aValues);
|
|
|
|
}
|
|
|
|
|
|
|
|
void XMLIndexSimpleEntryContext::FillPropertyValues(
|
|
|
|
::com::sun::star::uno::Sequence<
|
|
|
|
::com::sun::star::beans::PropertyValue> & rValues)
|
|
|
|
{
|
|
|
|
// due to the limited number of subclasses, we fill the values
|
|
|
|
// directly into the slots. Subclasses will have to know they can
|
|
|
|
// only use slot so-and-so.
|
|
|
|
|
|
|
|
Any aAny;
|
|
|
|
|
|
|
|
// token type
|
|
|
|
rValues[0].Name = rTemplateContext.sTokenType;
|
|
|
|
aAny <<= rEntryType;
|
|
|
|
rValues[0].Value = aAny;
|
|
|
|
|
|
|
|
// char style
|
|
|
|
if (bCharStyleNameOK)
|
|
|
|
{
|
|
|
|
rValues[1].Name = rTemplateContext.sCharacterStyleName;
|
2004-07-13 07:32:39 +00:00
|
|
|
aAny <<= GetImport().GetStyleDisplayName(
|
|
|
|
XML_STYLE_FAMILY_TEXT_TEXT,
|
|
|
|
sCharStyleName );
|
2000-11-02 14:51:18 +00:00
|
|
|
rValues[1].Value = aAny;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|