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:20 +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:20 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-10-16 12:01:58 +00:00
|
|
|
*
|
2008-04-10 22:18:20 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-10-16 12:01:58 +00:00
|
|
|
*
|
2008-04-10 22:18:20 +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:20 +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:20 +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 "XMLSectionSourceDDEImportContext.hxx"
|
|
|
|
#include "XMLSectionImportContext.hxx"
|
|
|
|
#include <com/sun/star/text/SectionFileLink.hpp>
|
2007-06-27 15:05:59 +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:05:59 +00:00
|
|
|
#include <xmloff/xmltoken.hxx>
|
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
|
|
|
#include <sax/tools/converter.hxx>
|
2000-10-16 12:01:58 +00:00
|
|
|
#include <com/sun/star/uno/Reference.h>
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
2001-02-16 15:20:41 +00:00
|
|
|
#include <com/sun/star/beans/XMultiPropertySet.hpp>
|
|
|
|
#include <tools/debug.hxx>
|
2000-10-16 12:01:58 +00:00
|
|
|
|
|
|
|
using ::rtl::OUString;
|
|
|
|
using ::com::sun::star::beans::XPropertySet;
|
2001-02-16 15:20:41 +00:00
|
|
|
using ::com::sun::star::beans::XMultiPropertySet;
|
2000-10-16 12:01:58 +00:00
|
|
|
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
|
|
|
|
|
|
|
const sal_Char sAPI_DDECommandFile[] = "DDECommandFile";
|
|
|
|
const sal_Char sAPI_DDECommandType[] = "DDECommandType";
|
|
|
|
const sal_Char sAPI_DDECommandElement[] = "DDECommandElement";
|
2000-11-20 18:56:50 +00:00
|
|
|
const sal_Char sAPI_IsAutomaticUpdate[] = "IsAutomaticUpdate";
|
|
|
|
|
2000-10-16 12:01:58 +00:00
|
|
|
|
|
|
|
TYPEINIT1(XMLSectionSourceDDEImportContext, SvXMLImportContext);
|
|
|
|
|
|
|
|
XMLSectionSourceDDEImportContext::XMLSectionSourceDDEImportContext(
|
|
|
|
SvXMLImport& rImport,
|
|
|
|
sal_uInt16 nPrfx,
|
|
|
|
const OUString& rLocalName,
|
|
|
|
Reference<XPropertySet> & rSectPropSet) :
|
|
|
|
SvXMLImportContext(rImport, nPrfx, rLocalName),
|
|
|
|
rSectionPropertySet(rSectPropSet),
|
|
|
|
sDdeCommandFile(RTL_CONSTASCII_USTRINGPARAM(sAPI_DDECommandFile)),
|
|
|
|
sDdeCommandType(RTL_CONSTASCII_USTRINGPARAM(sAPI_DDECommandType)),
|
2000-11-20 18:56:50 +00:00
|
|
|
sDdeCommandElement(RTL_CONSTASCII_USTRINGPARAM(sAPI_DDECommandElement)),
|
|
|
|
sIsAutomaticUpdate(RTL_CONSTASCII_USTRINGPARAM(sAPI_IsAutomaticUpdate))
|
2000-10-16 12:01:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
XMLSectionSourceDDEImportContext::~XMLSectionSourceDDEImportContext()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
enum XMLSectionSourceDDEToken
|
|
|
|
{
|
|
|
|
XML_TOK_SECTION_DDE_APPLICATION,
|
|
|
|
XML_TOK_SECTION_DDE_TOPIC,
|
2000-11-20 18:56:50 +00:00
|
|
|
XML_TOK_SECTION_DDE_ITEM,
|
|
|
|
XML_TOK_SECTION_IS_AUTOMATIC_UPDATE
|
2000-10-16 12:01:58 +00:00
|
|
|
};
|
|
|
|
|
2010-12-06 10:36:18 +00:00
|
|
|
static SvXMLTokenMapEntry aSectionSourceDDETokenMap[] =
|
2000-10-16 12:01:58 +00:00
|
|
|
{
|
2001-06-15 16:16:59 +00:00
|
|
|
{ XML_NAMESPACE_OFFICE, XML_DDE_APPLICATION,
|
2000-11-20 18:56:50 +00:00
|
|
|
XML_TOK_SECTION_DDE_APPLICATION },
|
2001-06-15 16:16:59 +00:00
|
|
|
{ XML_NAMESPACE_OFFICE, XML_DDE_TOPIC, XML_TOK_SECTION_DDE_TOPIC },
|
|
|
|
{ XML_NAMESPACE_OFFICE, XML_DDE_ITEM, XML_TOK_SECTION_DDE_ITEM },
|
|
|
|
{ XML_NAMESPACE_OFFICE, XML_AUTOMATIC_UPDATE,
|
2000-11-20 18:56:50 +00:00
|
|
|
XML_TOK_SECTION_IS_AUTOMATIC_UPDATE },
|
2000-10-16 12:01:58 +00:00
|
|
|
XML_TOKEN_MAP_END
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void XMLSectionSourceDDEImportContext::StartElement(
|
|
|
|
const Reference<XAttributeList> & xAttrList)
|
|
|
|
{
|
|
|
|
SvXMLTokenMap aTokenMap(aSectionSourceDDETokenMap);
|
|
|
|
OUString sApplication;
|
|
|
|
OUString sTopic;
|
|
|
|
OUString sItem;
|
2000-11-20 18:56:50 +00:00
|
|
|
sal_Bool bAutomaticUpdate = sal_False;
|
2000-10-16 12:01:58 +00:00
|
|
|
|
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_DDE_APPLICATION:
|
|
|
|
sApplication = xAttrList->getValueByIndex(nAttr);
|
|
|
|
break;
|
|
|
|
case XML_TOK_SECTION_DDE_TOPIC:
|
|
|
|
sTopic = xAttrList->getValueByIndex(nAttr);
|
|
|
|
break;
|
|
|
|
case XML_TOK_SECTION_DDE_ITEM:
|
|
|
|
sItem = xAttrList->getValueByIndex(nAttr);
|
|
|
|
break;
|
2000-11-20 18:56:50 +00:00
|
|
|
case XML_TOK_SECTION_IS_AUTOMATIC_UPDATE:
|
|
|
|
{
|
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
|
|
|
bool bTmp(false);
|
|
|
|
if (::sax::Converter::convertBool(
|
2000-11-20 18:56:50 +00:00
|
|
|
bTmp, xAttrList->getValueByIndex(nAttr)))
|
|
|
|
{
|
|
|
|
bAutomaticUpdate = bTmp;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2000-10-16 12:01:58 +00:00
|
|
|
default:
|
|
|
|
; // ignore
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DDE not supported on all platforms; query property first
|
|
|
|
if (rSectionPropertySet->getPropertySetInfo()->
|
|
|
|
hasPropertyByName(sDdeCommandFile))
|
|
|
|
{
|
2001-02-16 15:20:41 +00:00
|
|
|
// use multi property set to force single update of connection #83654#
|
|
|
|
Sequence<OUString> aNames(4);
|
|
|
|
Sequence<Any> aValues(4);
|
|
|
|
|
|
|
|
aValues[0] <<= sApplication;
|
|
|
|
aNames[0] = sDdeCommandFile;
|
2000-10-16 12:01:58 +00:00
|
|
|
|
2001-02-16 15:20:41 +00:00
|
|
|
aValues[1] <<= sTopic;
|
|
|
|
aNames[1] = sDdeCommandType;
|
2000-10-16 12:01:58 +00:00
|
|
|
|
2001-02-16 15:20:41 +00:00
|
|
|
aValues[2] <<= sItem;
|
|
|
|
aNames[2] = sDdeCommandElement;
|
2000-10-16 12:01:58 +00:00
|
|
|
|
2001-02-16 15:20:41 +00:00
|
|
|
aValues[3].setValue(&bAutomaticUpdate, ::getBooleanCppuType());
|
|
|
|
aNames[3] = sIsAutomaticUpdate;
|
2000-11-20 18:56:50 +00:00
|
|
|
|
2001-02-16 15:20:41 +00:00
|
|
|
Reference<XMultiPropertySet> rMultiPropSet(rSectionPropertySet,
|
|
|
|
UNO_QUERY);
|
|
|
|
DBG_ASSERT(rMultiPropSet.is(), "we'd really like a XMultiPropertySet");
|
|
|
|
if (rMultiPropSet.is())
|
|
|
|
rMultiPropSet->setPropertyValues(aNames, aValues);
|
|
|
|
// else: ignore
|
2000-10-16 12:01:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void XMLSectionSourceDDEImportContext::EndElement()
|
|
|
|
{
|
|
|
|
// nothing to be done!
|
|
|
|
}
|
|
|
|
|
|
|
|
SvXMLImportContext* XMLSectionSourceDDEImportContext::CreateChildContext(
|
|
|
|
sal_uInt16 nPrefix,
|
|
|
|
const OUString& rLocalName,
|
2006-06-19 17:44:30 +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: */
|