Files
libreoffice/xmloff/source/style/breakhdl.cxx

197 lines
5.3 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-09-18 16:07:07 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 16:07:07 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 16:07:07 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 16:07:07 +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-09-18 16:07:07 +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-09-18 16:07:07 +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-09-18 16:07:07 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_xmloff.hxx"
2000-09-18 16:07:07 +00:00
#include <breakhdl.hxx>
#include <xmloff/xmltoken.hxx>
#include <xmloff/xmluconv.hxx>
2000-09-18 16:07:07 +00:00
#include <rtl/ustrbuf.hxx>
#include <com/sun/star/style/BreakType.hpp>
#include <com/sun/star/uno/Any.hxx>
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
2000-09-18 16:07:07 +00:00
using namespace ::com::sun::star;
using namespace ::xmloff::token;
2000-09-18 16:07:07 +00:00
SvXMLEnumMapEntry pXML_BreakTypes[] =
2000-09-18 16:07:07 +00:00
{
{ XML_AUTO, 0 },
{ XML_COLUMN, 1 },
{ XML_PAGE, 2 },
{ XML_EVEN_PAGE, 2 },
{ XML_ODD_PAGE, 2 },
{ XML_TOKEN_INVALID, 0}
2000-09-18 16:07:07 +00:00
};
///////////////////////////////////////////////////////////////////////////////
//
// class XMLFmtBreakBeforePropHdl
//
XMLFmtBreakBeforePropHdl::~XMLFmtBreakBeforePropHdl()
{
// Nothing to do
}
sal_Bool XMLFmtBreakBeforePropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
2000-09-18 16:07:07 +00:00
{
sal_uInt16 nEnum;
sal_Bool bRet = SvXMLUnitConverter::convertEnum( nEnum, rStrImpValue, pXML_BreakTypes );
if( bRet )
2000-09-18 16:07:07 +00:00
{
style::BreakType eBreak;
switch ( nEnum )
{
case 0:
eBreak = style::BreakType_NONE;
break;
case 1:
eBreak = style::BreakType_COLUMN_BEFORE;
break;
default:
eBreak = style::BreakType_PAGE_BEFORE;
break;
}
2000-09-18 16:07:07 +00:00
rValue <<= eBreak;
}
return bRet;
}
sal_Bool XMLFmtBreakBeforePropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
2000-09-18 16:07:07 +00:00
{
style::BreakType eBreak;
if( !( rValue >>= eBreak ) )
{
sal_Int32 nValue = 0;
2000-09-18 16:07:07 +00:00
if( !( rValue >>= nValue ) )
return sal_False;
eBreak = (style::BreakType) nValue;
}
sal_uInt16 nEnum = 0;
switch( eBreak )
{
case style::BreakType_COLUMN_BEFORE:
nEnum = 1;
break;
case style::BreakType_PAGE_BEFORE:
nEnum = 2;
break;
case style::BreakType_NONE:
nEnum = 0;
break;
default:
return sal_False;
}
OUStringBuffer aOut;
/* sal_Bool bOk = */ SvXMLUnitConverter::convertEnum( aOut, nEnum, pXML_BreakTypes );
2000-09-18 16:07:07 +00:00
rStrExpValue = aOut.makeStringAndClear();
return sal_True;
2000-09-18 16:07:07 +00:00
}
///////////////////////////////////////////////////////////////////////////////
//
// class XMLFmtBreakBeforePropHdl
//
XMLFmtBreakAfterPropHdl::~XMLFmtBreakAfterPropHdl()
{
// Nothing to do
}
sal_Bool XMLFmtBreakAfterPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
2000-09-18 16:07:07 +00:00
{
sal_uInt16 nEnum;
sal_Bool bRet = SvXMLUnitConverter::convertEnum( nEnum, rStrImpValue, pXML_BreakTypes );
if( bRet )
2000-09-18 16:07:07 +00:00
{
style::BreakType eBreak;
switch ( nEnum )
{
case 0:
eBreak = style::BreakType_NONE;
break;
case 1:
eBreak = style::BreakType_COLUMN_AFTER;
break;
default:
eBreak = style::BreakType_PAGE_AFTER;
break;
}
2000-09-18 16:07:07 +00:00
rValue <<= eBreak;
}
return bRet;
}
sal_Bool XMLFmtBreakAfterPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
2000-09-18 16:07:07 +00:00
{
style::BreakType eBreak;
if( !( rValue >>= eBreak ) )
{
sal_Int32 nValue = 0;
2000-09-18 16:07:07 +00:00
if( !( rValue >>= nValue ) )
return sal_False;
eBreak = (style::BreakType) nValue;
}
sal_uInt16 nEnum = 0;
switch( eBreak )
{
case style::BreakType_COLUMN_AFTER:
nEnum = 1;
break;
case style::BreakType_PAGE_AFTER:
nEnum = 2;
break;
case style::BreakType_NONE:
nEnum = 0;
break;
default:
return sal_False;
}
OUStringBuffer aOut;
/* sal_Bool bOk = */ SvXMLUnitConverter::convertEnum( aOut, nEnum, pXML_BreakTypes );
2000-09-18 16:07:07 +00:00
rStrExpValue = aOut.makeStringAndClear();
return sal_True;
2000-09-18 16:07:07 +00:00
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */