2000-12-11 18:14:26 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 14:13:37 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-12-11 18:14:26 +00:00
|
|
|
*
|
2005-09-09 14:13:37 +00:00
|
|
|
* $RCSfile: XMLLineNumberingExport.cxx,v $
|
2000-12-11 18:14:26 +00:00
|
|
|
*
|
2006-11-21 16:38:10 +00:00
|
|
|
* $Revision: 1.11 $
|
2000-12-11 18:14:26 +00:00
|
|
|
*
|
2006-11-21 16:38:10 +00:00
|
|
|
* last change: $Author: vg $ $Date: 2006-11-21 17:38:10 $
|
2000-12-11 18:14:26 +00:00
|
|
|
*
|
2005-09-09 14:13:37 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2000-12-11 18:14:26 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 14:13:37 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2000-12-11 18:14:26 +00:00
|
|
|
*
|
2005-09-09 14:13:37 +00:00
|
|
|
* 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.
|
2000-12-11 18:14:26 +00:00
|
|
|
*
|
2005-09-09 14:13:37 +00:00
|
|
|
* 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.
|
2000-12-11 18:14:26 +00:00
|
|
|
*
|
2005-09-09 14:13:37 +00:00
|
|
|
* 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
|
2000-12-11 18:14:26 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 10:09:24 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_xmloff.hxx"
|
|
|
|
|
2000-12-11 18:14:26 +00:00
|
|
|
#ifndef _XMLOFF_XMLLINENUMBERINGEXPORT_HXX_
|
|
|
|
#include "XMLLineNumberingExport.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
|
|
|
|
#include "com/sun/star/beans/XPropertySet.hpp"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_TEXT_XLINENUMBERINGPROPERTIES_HPP_
|
|
|
|
#include "com/sun/star/text/XLineNumberingProperties.hpp"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_STYLE_LINENUMBERPOSITION_HPP_
|
|
|
|
#include <com/sun/star/style/LineNumberPosition.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLEXP_HXX
|
|
|
|
#include "xmlexp.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLUCONV_HXX
|
|
|
|
#include "xmluconv.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLNMSPE_HXX
|
|
|
|
#include "xmlnmspe.hxx"
|
|
|
|
#endif
|
|
|
|
|
2001-06-29 20:07:26 +00:00
|
|
|
#ifndef _XMLOFF_XMLTOKEN_HXX
|
|
|
|
#include "xmltoken.hxx"
|
2000-12-11 18:14:26 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLNUME_HXX
|
|
|
|
#include "xmlnume.hxx"
|
|
|
|
#endif
|
|
|
|
|
2001-06-29 20:07:26 +00:00
|
|
|
|
2000-12-11 18:14:26 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star;
|
2001-06-15 09:37:08 +00:00
|
|
|
using namespace ::xmloff::token;
|
2000-12-11 18:14:26 +00:00
|
|
|
|
|
|
|
using ::rtl::OUString;
|
|
|
|
using ::rtl::OUStringBuffer;
|
|
|
|
using ::com::sun::star::beans::XPropertySet;
|
|
|
|
using ::com::sun::star::text::XLineNumberingProperties;
|
|
|
|
|
2001-06-29 20:07:26 +00:00
|
|
|
|
2006-06-19 17:42:41 +00:00
|
|
|
XMLLineNumberingExport::XMLLineNumberingExport(SvXMLExport& rExp)
|
|
|
|
: sCharStyleName(RTL_CONSTASCII_USTRINGPARAM("CharStyleName"))
|
|
|
|
, sCountEmptyLines(RTL_CONSTASCII_USTRINGPARAM("CountEmptyLines"))
|
|
|
|
, sCountLinesInFrames(RTL_CONSTASCII_USTRINGPARAM("CountLinesInFrames"))
|
|
|
|
, sDistance(RTL_CONSTASCII_USTRINGPARAM("Distance"))
|
|
|
|
, sInterval(RTL_CONSTASCII_USTRINGPARAM("Interval"))
|
|
|
|
, sSeparatorText(RTL_CONSTASCII_USTRINGPARAM("SeparatorText"))
|
|
|
|
, sNumberPosition(RTL_CONSTASCII_USTRINGPARAM("NumberPosition"))
|
|
|
|
, sNumberingType(RTL_CONSTASCII_USTRINGPARAM("NumberingType"))
|
|
|
|
, sIsOn(RTL_CONSTASCII_USTRINGPARAM("IsOn"))
|
|
|
|
, sRestartAtEachPage(RTL_CONSTASCII_USTRINGPARAM("RestartAtEachPage"))
|
|
|
|
, sSeparatorInterval(RTL_CONSTASCII_USTRINGPARAM("SeparatorInterval"))
|
|
|
|
, rExport(rExp)
|
2000-12-11 18:14:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SvXMLEnumMapEntry __READONLY_DATA aLineNumberPositionMap[] =
|
|
|
|
{
|
2001-06-15 09:37:08 +00:00
|
|
|
{ XML_LEFT, style::LineNumberPosition::LEFT },
|
|
|
|
{ XML_RIGHT, style::LineNumberPosition::RIGHT },
|
|
|
|
{ XML_INSIDE, style::LineNumberPosition::INSIDE },
|
|
|
|
{ XML_OUTSIDE, style::LineNumberPosition::OUTSIDE },
|
|
|
|
{ XML_TOKEN_INVALID, 0 }
|
2000-12-11 18:14:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void XMLLineNumberingExport::Export()
|
|
|
|
{
|
|
|
|
// export element if we have line numbering info
|
|
|
|
Reference<XLineNumberingProperties> xSupplier(rExport.GetModel(),
|
|
|
|
UNO_QUERY);
|
|
|
|
if (xSupplier.is())
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xLineNumbering =
|
|
|
|
xSupplier->getLineNumberingProperties();
|
|
|
|
|
|
|
|
if (xLineNumbering.is())
|
|
|
|
{
|
|
|
|
Any aAny;
|
|
|
|
|
|
|
|
// char style
|
|
|
|
aAny = xLineNumbering->getPropertyValue(sCharStyleName);
|
|
|
|
OUString sTmp;
|
|
|
|
aAny >>= sTmp;
|
|
|
|
if (sTmp.getLength() > 0)
|
|
|
|
{
|
2004-07-13 07:34:20 +00:00
|
|
|
rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME,
|
|
|
|
rExport.EncodeStyleName( sTmp ));
|
2000-12-11 18:14:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// enable
|
|
|
|
aAny = xLineNumbering->getPropertyValue(sIsOn);
|
|
|
|
if (! *(sal_Bool*)aAny.getValue())
|
|
|
|
{
|
2001-06-29 20:07:26 +00:00
|
|
|
rExport.AddAttribute(XML_NAMESPACE_TEXT,
|
|
|
|
XML_NUMBER_LINES, XML_FALSE);
|
2000-12-11 18:14:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// count empty lines
|
|
|
|
aAny = xLineNumbering->getPropertyValue(sCountEmptyLines);
|
|
|
|
if (! *(sal_Bool*)aAny.getValue())
|
|
|
|
{
|
2001-06-29 20:07:26 +00:00
|
|
|
rExport.AddAttribute(XML_NAMESPACE_TEXT,
|
|
|
|
XML_COUNT_EMPTY_LINES, XML_FALSE);
|
2000-12-11 18:14:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// count in frames
|
|
|
|
aAny = xLineNumbering->getPropertyValue(sCountLinesInFrames);
|
|
|
|
if (*(sal_Bool*)aAny.getValue())
|
|
|
|
{
|
2001-06-29 20:07:26 +00:00
|
|
|
rExport.AddAttribute(XML_NAMESPACE_TEXT,
|
2004-07-13 07:34:20 +00:00
|
|
|
XML_COUNT_IN_TEXT_BOXES, XML_TRUE);
|
2000-12-11 18:14:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// restart numbering
|
|
|
|
aAny = xLineNumbering->getPropertyValue(sRestartAtEachPage);
|
|
|
|
if (*(sal_Bool*)aAny.getValue())
|
|
|
|
{
|
2001-06-29 20:07:26 +00:00
|
|
|
rExport.AddAttribute(XML_NAMESPACE_TEXT,
|
|
|
|
XML_RESTART_ON_PAGE, XML_TRUE);
|
2000-12-11 18:14:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Distance
|
|
|
|
aAny = xLineNumbering->getPropertyValue(sDistance);
|
2006-11-21 16:38:10 +00:00
|
|
|
sal_Int32 nLength = 0;
|
2000-12-11 18:14:26 +00:00
|
|
|
aAny >>= nLength;
|
|
|
|
if (nLength != 0)
|
|
|
|
{
|
|
|
|
OUStringBuffer sBuf;
|
|
|
|
rExport.GetMM100UnitConverter().convertMeasure(sBuf, nLength);
|
2001-06-29 20:07:26 +00:00
|
|
|
rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_OFFSET,
|
2000-12-11 18:14:26 +00:00
|
|
|
sBuf.makeStringAndClear());
|
|
|
|
}
|
|
|
|
|
|
|
|
// NumeringType
|
2001-03-19 08:41:43 +00:00
|
|
|
OUStringBuffer sNumPosBuf;
|
2000-12-11 18:14:26 +00:00
|
|
|
aAny = xLineNumbering->getPropertyValue(sNumberingType);
|
2006-07-19 15:39:37 +00:00
|
|
|
sal_Int16 nFormat = 0;
|
2000-12-11 18:14:26 +00:00
|
|
|
aAny >>= nFormat;
|
2001-03-19 08:41:43 +00:00
|
|
|
rExport.GetMM100UnitConverter().convertNumFormat( sNumPosBuf, nFormat );
|
2001-06-29 20:07:26 +00:00
|
|
|
rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT,
|
2001-03-19 08:41:43 +00:00
|
|
|
sNumPosBuf.makeStringAndClear());
|
|
|
|
rExport.GetMM100UnitConverter().convertNumLetterSync( sNumPosBuf, nFormat );
|
|
|
|
if( sNumPosBuf.getLength() )
|
2000-12-11 18:14:26 +00:00
|
|
|
{
|
2001-03-19 08:41:43 +00:00
|
|
|
rExport.AddAttribute(XML_NAMESPACE_STYLE,
|
2001-06-29 20:07:26 +00:00
|
|
|
XML_NUM_LETTER_SYNC,
|
2001-03-19 08:41:43 +00:00
|
|
|
sNumPosBuf.makeStringAndClear() );
|
2000-12-11 18:14:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// number position
|
|
|
|
aAny = xLineNumbering->getPropertyValue(sNumberPosition);
|
2006-07-19 15:39:37 +00:00
|
|
|
sal_Int16 nPosition = 0;
|
2000-12-11 18:14:26 +00:00
|
|
|
aAny >>= nPosition;
|
|
|
|
if (SvXMLUnitConverter::convertEnum(sNumPosBuf, nPosition,
|
|
|
|
aLineNumberPositionMap))
|
|
|
|
{
|
2001-06-29 20:07:26 +00:00
|
|
|
rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NUMBER_POSITION,
|
2000-12-11 18:14:26 +00:00
|
|
|
sNumPosBuf.makeStringAndClear());
|
|
|
|
}
|
|
|
|
|
|
|
|
// sInterval
|
|
|
|
aAny = xLineNumbering->getPropertyValue(sInterval);
|
2006-07-19 15:39:37 +00:00
|
|
|
sal_Int16 nLineInterval = 0;
|
2000-12-11 18:14:26 +00:00
|
|
|
aAny >>= nLineInterval;
|
|
|
|
OUStringBuffer sBuf;
|
|
|
|
SvXMLUnitConverter::convertNumber(sBuf,
|
|
|
|
(sal_Int32)nLineInterval);
|
2001-06-29 20:07:26 +00:00
|
|
|
rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_INCREMENT,
|
2000-12-11 18:14:26 +00:00
|
|
|
sBuf.makeStringAndClear());
|
|
|
|
|
|
|
|
SvXMLElementExport aConfigElem(rExport, XML_NAMESPACE_TEXT,
|
2001-06-29 20:07:26 +00:00
|
|
|
XML_LINENUMBERING_CONFIGURATION,
|
2000-12-11 18:14:26 +00:00
|
|
|
sal_True, sal_True);
|
|
|
|
|
|
|
|
// line separator
|
|
|
|
aAny = xLineNumbering->getPropertyValue(sSeparatorText);
|
|
|
|
OUString sSeparator;
|
|
|
|
aAny >>= sSeparator;
|
|
|
|
if (sSeparator.getLength() > 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
// SeparatorInterval
|
|
|
|
aAny = xLineNumbering->getPropertyValue(sSeparatorInterval);
|
2006-07-19 15:39:37 +00:00
|
|
|
sal_Int16 nLineDistance = 0;
|
2000-12-11 18:14:26 +00:00
|
|
|
aAny >>= nLineDistance;
|
|
|
|
SvXMLUnitConverter::convertNumber(sBuf,
|
|
|
|
(sal_Int32)nLineDistance);
|
2001-06-29 20:07:26 +00:00
|
|
|
rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_INCREMENT,
|
2000-12-11 18:14:26 +00:00
|
|
|
sBuf.makeStringAndClear());
|
|
|
|
|
|
|
|
SvXMLElementExport aSeparatorElem(rExport, XML_NAMESPACE_TEXT,
|
2001-06-29 20:07:26 +00:00
|
|
|
XML_LINENUMBERING_SEPARATOR,
|
2000-12-11 18:14:26 +00:00
|
|
|
sal_True, sal_False);
|
2001-09-24 12:40:55 +00:00
|
|
|
rExport.Characters(sSeparator);
|
2000-12-11 18:14:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// else: no configuration: don't save -> default
|
|
|
|
}
|
|
|
|
// can't even get supplier: don't save -> default
|
|
|
|
}
|