2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 22:24:36 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 22:24:36 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 22:24:36 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 22:24:36 +00:00
|
|
|
* $RCSfile: XMLTextNumRuleInfo.cxx,v $
|
|
|
|
* $Revision: 1.13 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 22:24:36 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 22:24:36 +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
|
|
|
*
|
2008-04-10 22:24:36 +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
|
|
|
*
|
2008-04-10 22:24:36 +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
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 10:15:23 +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 <tools/debug.hxx>
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
|
|
|
#include <com/sun/star/container/XIndexReplace.hpp>
|
|
|
|
#include <com/sun/star/style/NumberingType.hpp>
|
2000-10-23 10:28:11 +00:00
|
|
|
#include <com/sun/star/container/XNamed.hpp>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "XMLTextNumRuleInfo.hxx"
|
|
|
|
|
2008-03-12 10:05:35 +00:00
|
|
|
using ::rtl::OUString;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::style;
|
|
|
|
|
|
|
|
XMLTextNumRuleInfo::XMLTextNumRuleInfo() :
|
|
|
|
sNumberingRules(RTL_CONSTASCII_USTRINGPARAM("NumberingRules")),
|
|
|
|
sNumberingLevel(RTL_CONSTASCII_USTRINGPARAM("NumberingLevel")),
|
|
|
|
sNumberingStartValue(RTL_CONSTASCII_USTRINGPARAM("NumberingStartValue")),
|
2000-10-23 10:28:11 +00:00
|
|
|
sParaIsNumberingRestart(RTL_CONSTASCII_USTRINGPARAM("ParaIsNumberingRestart")),
|
2000-09-18 16:07:07 +00:00
|
|
|
sNumberingType(RTL_CONSTASCII_USTRINGPARAM("NumberingType")),
|
|
|
|
sIsNumbering(RTL_CONSTASCII_USTRINGPARAM("IsNumbering")),
|
2004-11-26 12:05:38 +00:00
|
|
|
sNumberingIsNumber(RTL_CONSTASCII_USTRINGPARAM("NumberingIsNumber")),
|
|
|
|
sNumberingIsOutline(RTL_CONSTASCII_USTRINGPARAM("NumberingIsOutline"))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
2006-10-13 11:16:22 +00:00
|
|
|
// --> OD 2006-09-27 #i69627#
|
2000-09-18 16:07:07 +00:00
|
|
|
void XMLTextNumRuleInfo::Set(
|
|
|
|
const ::com::sun::star::uno::Reference <
|
2006-10-13 11:16:22 +00:00
|
|
|
::com::sun::star::text::XTextContent > & xTextContent,
|
|
|
|
const sal_Bool bOutlineStyleAsNormalListStyle )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Reset();
|
2006-10-13 11:16:22 +00:00
|
|
|
// --> OD 2006-09-27 #i69627#
|
|
|
|
mbOutlineStyleAsNormalListStyle = bOutlineStyleAsNormalListStyle;
|
|
|
|
// <--
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
Reference< XPropertySet > xPropSet( xTextContent, UNO_QUERY );
|
|
|
|
Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
|
|
|
|
|
|
|
|
Any aAny;
|
|
|
|
|
2001-11-16 13:47:50 +00:00
|
|
|
// check if this paragraph supports a numbering
|
|
|
|
if( !xPropSetInfo->hasPropertyByName( sNumberingLevel ) )
|
|
|
|
return;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if( xPropSetInfo->hasPropertyByName( sNumberingRules ) )
|
|
|
|
{
|
|
|
|
aAny = xPropSet->getPropertyValue( sNumberingRules );
|
2000-10-23 10:28:11 +00:00
|
|
|
aAny >>= xNumRules;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2006-10-13 11:16:22 +00:00
|
|
|
// --> OD 2006-09-27 #i69627#
|
|
|
|
bool bSuppressListStyle( false );
|
2004-11-26 12:05:38 +00:00
|
|
|
{
|
2006-10-13 11:16:22 +00:00
|
|
|
if ( !mbOutlineStyleAsNormalListStyle )
|
|
|
|
{
|
|
|
|
BOOL bIsOutline = FALSE;
|
|
|
|
Reference<XPropertySet> xNumRulesProps(xNumRules, UNO_QUERY);
|
|
|
|
if (xNumRulesProps.is() &&
|
|
|
|
xNumRulesProps->getPropertySetInfo()->
|
|
|
|
hasPropertyByName( sNumberingIsOutline ) )
|
|
|
|
{
|
|
|
|
aAny = xNumRulesProps->getPropertyValue( sNumberingIsOutline );
|
|
|
|
bIsOutline = *(sal_Bool*)aAny.getValue();
|
|
|
|
bSuppressListStyle = bIsOutline ? true : false;
|
|
|
|
}
|
|
|
|
}
|
2004-11-26 12:05:38 +00:00
|
|
|
}
|
|
|
|
|
2006-10-13 11:16:22 +00:00
|
|
|
if( xNumRules.is() && !bSuppressListStyle )
|
|
|
|
// <--
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-10-23 10:28:11 +00:00
|
|
|
Reference < XNamed > xNamed( xNumRules, UNO_QUERY );
|
|
|
|
if( xNamed.is() )
|
2000-10-31 08:00:40 +00:00
|
|
|
{
|
|
|
|
bIsNamed = sal_True;
|
2000-10-23 10:28:11 +00:00
|
|
|
sName = xNamed->getName();
|
2000-10-31 08:00:40 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
aAny = xPropSet->getPropertyValue( sNumberingLevel );
|
|
|
|
aAny >>= nLevel;
|
|
|
|
|
|
|
|
bIsNumbered = sal_True;
|
|
|
|
if( xPropSetInfo->hasPropertyByName( sNumberingIsNumber ) )
|
|
|
|
{
|
|
|
|
aAny = xPropSet->getPropertyValue( sNumberingIsNumber );
|
2004-07-13 07:38:24 +00:00
|
|
|
OSL_ENSURE( aAny.hasValue(),
|
|
|
|
"numbered paragraph without number info" );
|
|
|
|
if( !aAny.hasValue() )
|
|
|
|
bIsNumbered = sal_False;
|
|
|
|
else
|
|
|
|
bIsNumbered = *(sal_Bool *)aAny.getValue();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( bIsNumbered )
|
|
|
|
{
|
2000-10-23 10:28:11 +00:00
|
|
|
if( xPropSetInfo->hasPropertyByName( sParaIsNumberingRestart ) )
|
|
|
|
{
|
|
|
|
aAny = xPropSet->getPropertyValue( sParaIsNumberingRestart );
|
|
|
|
bIsRestart = *(sal_Bool *)aAny.getValue();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
if( xPropSetInfo->hasPropertyByName( sNumberingStartValue ) )
|
|
|
|
{
|
|
|
|
aAny = xPropSet->getPropertyValue( sNumberingStartValue );
|
|
|
|
aAny >>= nStartValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-18 07:52:32 +00:00
|
|
|
OSL_ENSURE( nLevel < xNumRules->getCount(), "wrong num rule level" );
|
|
|
|
if( nLevel >= xNumRules->getCount() )
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
return;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-10-23 10:28:11 +00:00
|
|
|
aAny = xNumRules->getByIndex( nLevel );
|
2000-09-18 16:07:07 +00:00
|
|
|
Sequence<PropertyValue> aProps;
|
|
|
|
aAny >>= aProps;
|
|
|
|
const PropertyValue* pPropArray = aProps.getConstArray();
|
|
|
|
sal_Int32 nCount = aProps.getLength();
|
|
|
|
for( sal_Int32 i=0; i<nCount; i++ )
|
|
|
|
{
|
|
|
|
const beans::PropertyValue& rProp = pPropArray[i];
|
|
|
|
|
|
|
|
if( rProp.Name == sNumberingType )
|
|
|
|
{
|
2006-07-19 15:39:54 +00:00
|
|
|
sal_Int16 nType = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
rProp.Value >>= nType;
|
|
|
|
if( NumberingType::CHAR_SPECIAL != nType &&
|
|
|
|
NumberingType::BITMAP != nType )
|
|
|
|
{
|
|
|
|
bIsOrdered = sal_True;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nLevel++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|