2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-12 17:21:24 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-12-11 18:14:26 +00:00
|
|
|
|
|
|
|
#include "XMLLineNumberingExport.hxx"
|
2013-11-11 22:30:35 -06:00
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#include <com/sun/star/text/XLineNumberingProperties.hpp>
|
2000-12-11 18:14:26 +00:00
|
|
|
#include <com/sun/star/style/LineNumberPosition.hpp>
|
2016-06-02 15:06:06 +02:00
|
|
|
#include <o3tl/any.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>
|
2007-06-27 15:02:43 +00:00
|
|
|
#include <xmloff/xmlexp.hxx>
|
|
|
|
#include <xmloff/xmluconv.hxx>
|
2013-11-11 22:30:35 -06:00
|
|
|
#include <xmloff/xmlnmspe.hxx>
|
2007-06-27 15:02:43 +00:00
|
|
|
#include <xmloff/xmltoken.hxx>
|
|
|
|
#include <xmloff/xmlnume.hxx>
|
2000-12-11 18:14:26 +00:00
|
|
|
|
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 ::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)
|
2016-12-01 10:51:35 +02:00
|
|
|
: rExport(rExp)
|
2000-12-11 18:14:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-03-09 09:04:15 +02:00
|
|
|
SvXMLEnumMapEntry<sal_uInt16> const aLineNumberPositionMap[] =
|
2000-12-11 18:14:26 +00:00
|
|
|
{
|
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
|
2016-12-01 10:51:35 +02:00
|
|
|
aAny = xLineNumbering->getPropertyValue("CharStyleName");
|
2000-12-11 18:14:26 +00:00
|
|
|
OUString sTmp;
|
|
|
|
aAny >>= sTmp;
|
2012-01-26 17:05:51 -02:00
|
|
|
if (!sTmp.isEmpty())
|
2000-12-11 18:14:26 +00:00
|
|
|
{
|
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
|
2016-12-01 10:51:35 +02:00
|
|
|
aAny = xLineNumbering->getPropertyValue("IsOn");
|
2016-06-10 15:52:05 +02:00
|
|
|
if (! *o3tl::doAccess<bool>(aAny))
|
2000-12-11 18:14:26 +00:00
|
|
|
{
|
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
|
2016-12-01 10:51:35 +02:00
|
|
|
aAny = xLineNumbering->getPropertyValue("CountEmptyLines");
|
2016-06-10 15:52:05 +02:00
|
|
|
if (! *o3tl::doAccess<bool>(aAny))
|
2000-12-11 18:14:26 +00:00
|
|
|
{
|
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
|
2016-12-01 10:51:35 +02:00
|
|
|
aAny = xLineNumbering->getPropertyValue("CountLinesInFrames");
|
2016-06-10 15:52:05 +02:00
|
|
|
if (*o3tl::doAccess<bool>(aAny))
|
2000-12-11 18:14:26 +00:00
|
|
|
{
|
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
|
2016-12-01 10:51:35 +02:00
|
|
|
aAny = xLineNumbering->getPropertyValue("RestartAtEachPage");
|
2016-06-10 15:52:05 +02:00
|
|
|
if (*o3tl::doAccess<bool>(aAny))
|
2000-12-11 18:14:26 +00:00
|
|
|
{
|
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
|
2016-12-01 10:51:35 +02:00
|
|
|
aAny = xLineNumbering->getPropertyValue("Distance");
|
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;
|
2011-10-11 14:19:09 +02:00
|
|
|
rExport.GetMM100UnitConverter().convertMeasureToXML(
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2018-01-17 21:59:25 +01:00
|
|
|
// NumberingType
|
2001-03-19 08:41:43 +00:00
|
|
|
OUStringBuffer sNumPosBuf;
|
2016-12-01 10:51:35 +02:00
|
|
|
aAny = xLineNumbering->getPropertyValue("NumberingType");
|
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());
|
2015-04-02 14:07:31 +02:00
|
|
|
SvXMLUnitConverter::convertNumLetterSync( sNumPosBuf, nFormat );
|
2013-06-18 19:53:19 +02:00
|
|
|
if( !sNumPosBuf.isEmpty() )
|
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
|
2016-12-01 10:51:35 +02:00
|
|
|
aAny = xLineNumbering->getPropertyValue("NumberPosition");
|
2017-03-09 09:04:15 +02:00
|
|
|
sal_uInt16 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
|
2016-12-01 10:51:35 +02:00
|
|
|
aAny = xLineNumbering->getPropertyValue("Interval");
|
2006-07-19 15:39:37 +00:00
|
|
|
sal_Int16 nLineInterval = 0;
|
2000-12-11 18:14:26 +00:00
|
|
|
aAny >>= nLineInterval;
|
2001-06-29 20:07:26 +00:00
|
|
|
rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_INCREMENT,
|
2017-02-01 09:26:27 +02:00
|
|
|
OUString::number(nLineInterval));
|
2000-12-11 18:14:26 +00:00
|
|
|
|
|
|
|
SvXMLElementExport aConfigElem(rExport, XML_NAMESPACE_TEXT,
|
2001-06-29 20:07:26 +00:00
|
|
|
XML_LINENUMBERING_CONFIGURATION,
|
2014-03-28 16:28:51 +02:00
|
|
|
true, true);
|
2000-12-11 18:14:26 +00:00
|
|
|
|
|
|
|
// line separator
|
2016-12-01 10:51:35 +02:00
|
|
|
aAny = xLineNumbering->getPropertyValue("SeparatorText");
|
2000-12-11 18:14:26 +00:00
|
|
|
OUString sSeparator;
|
|
|
|
aAny >>= sSeparator;
|
2012-01-26 17:05:51 -02:00
|
|
|
if (!sSeparator.isEmpty())
|
2000-12-11 18:14:26 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
// SeparatorInterval
|
2016-12-01 10:51:35 +02:00
|
|
|
aAny = xLineNumbering->getPropertyValue("SeparatorInterval");
|
2006-07-19 15:39:37 +00:00
|
|
|
sal_Int16 nLineDistance = 0;
|
2000-12-11 18:14:26 +00:00
|
|
|
aAny >>= nLineDistance;
|
2001-06-29 20:07:26 +00:00
|
|
|
rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_INCREMENT,
|
2017-02-01 09:26:27 +02:00
|
|
|
OUString::number(nLineDistance));
|
2000-12-11 18:14:26 +00:00
|
|
|
|
|
|
|
SvXMLElementExport aSeparatorElem(rExport, XML_NAMESPACE_TEXT,
|
2001-06-29 20:07:26 +00:00
|
|
|
XML_LINENUMBERING_SEPARATOR,
|
2014-03-28 16:28:51 +02:00
|
|
|
true, 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
|
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|