Files
libreoffice/xmloff/source/text/XMLTextNumRuleInfo.cxx

236 lines
8.1 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by: Armin Le Grand. #118558# Correcting OLE attributes of LO3.4 at load time by loading as OOo3.3, details see task. http://svn.apache.org/viewvc?view=revision&revision=1195906 #118485# - Styles for OLEs are not saved. http://svn.apache.org/viewvc?view=revision&revision=1182166 #118898# Adapted ImpGraphic::ImplGetBitmap to correctly convert metafiles http://svn.apache.org/viewvc?view=revision&revision=1293316 #119337# Solves the wrong get/setPropertyValue calls in SvxShapeText (and thus in SvxOle2Shape) http://svn.apache.org/viewvc?view=revision&revision=1344156 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i117717#: remove wrong assertion http://svn.apache.org/viewvc?view=revision&revision=1172349 Patch contributed by Herbert Duerr goodbye Registration and License dialogs, don't let the door hit you http://svn.apache.org/viewvc?view=revision&revision=1172613 help gcc 4.6.0 on 32bit ubuntu 11.10" http://svn.apache.org/viewvc?view=revision&revision=1245357 Do not add targets for junit tests when junit is disabled. Patch contributed by Andre Fischer http://svn.apache.org/viewvc?view=revision&revision=1241508 Revert "sb140: #i117082# avoid unncessary static class data members commit 21d97438e2944861e26e4984195f959a0cce1e41. remove obsolete FreeBSD visibility special case. retain consolidated BSD bridge code, remove OS/2 pieces.
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-09-18 16:07:07 +00:00
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"
#include <xmloff/XMLTextListAutoStylePool.hxx>
2000-09-18 16:07:07 +00:00
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::style;
// Complete refactoring of the class and enhancement of the class for lists.
XMLTextNumRuleInfo::XMLTextNumRuleInfo()
: msNumberingRules("NumberingRules")
, msNumberingLevel("NumberingLevel")
, msNumberingStartValue("NumberingStartValue")
, msParaIsNumberingRestart("ParaIsNumberingRestart")
, msNumberingIsNumber("NumberingIsNumber")
, msNumberingIsOutline("NumberingIsOutline")
, msPropNameListId("ListId")
, msPropNameStartWith("StartWith")
, msContinueingPreviousSubTree("ContinueingPreviousSubTree")
, msListLabelStringProp("ListLabelString")
, mxNumRules()
, msNumRulesName()
, msListId()
, mnListStartValue( -1 )
, mnListLevel( 0 )
, mbIsNumbered( false )
, mbIsRestart( false )
, mnListLevelStartValue( -1 )
, mbOutlineStyleAsNormalListStyle( false )
2000-09-18 16:07:07 +00:00
{
Reset();
}
// Written OpenDocument file format doesn't fit to the created text document (#i69627#)
2000-09-18 16:07:07 +00:00
void XMLTextNumRuleInfo::Set(
const ::com::sun::star::uno::Reference <
::com::sun::star::text::XTextContent > & xTextContent,
const bool bOutlineStyleAsNormalListStyle,
const XMLTextListAutoStylePool& rListAutoPool,
const bool bExportTextNumberElement )
2000-09-18 16:07:07 +00:00
{
Reset();
// Written OpenDocument file format doesn't fit to the created text document (#i69627#)
mbOutlineStyleAsNormalListStyle = bOutlineStyleAsNormalListStyle;
2000-09-18 16:07:07 +00:00
Reference< XPropertySet > xPropSet( xTextContent, UNO_QUERY );
Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
2000-09-18 16:07:07 +00:00
// check if this paragraph supports a numbering
if( !xPropSetInfo->hasPropertyByName( msNumberingLevel ) )
return;
2000-09-18 16:07:07 +00:00
if( xPropSet->getPropertyValue( msNumberingLevel ) >>= mnListLevel )
{
if( xPropSetInfo->hasPropertyByName( msNumberingRules ) )
{
xPropSet->getPropertyValue( msNumberingRules ) >>= mxNumRules;
}
}
else
2000-09-18 16:07:07 +00:00
{
// in applications using the outliner we always have a numbering rule,
// so a void property no numbering
mnListLevel = 0;
2000-09-18 16:07:07 +00:00
}
// Assertion saving writer document (#i97312#)
CWS-TOOLING: integrate CWS outlinelevel 2008-12-19 10:32:51 +0100 od r265718 : #i70748# method <SwWW8Writer::StartTOX(..)> - correction for custom to outline style assigned paragraph styles 2008-12-19 09:24:41 +0100 od r265715 : #i70748# method <HandleModifyAtTxtNode(..)> - retrieve former applied list style before potential reset of empty list style due to set outline level 2008-12-17 15:33:57 +0100 hde r265608 : #i97013# 2008-12-17 14:43:42 +0100 od r265603 : #i70748# adjust fix i44177 - adjustment of to outline style assigned paragraph styles only for OOo-Templates. 2008-12-17 12:59:42 +0100 od r265598 : #i70748# method <XMLTextImportHelper::SetStyleAndAttrs(..)> - special handling of OOo 2.x document regarding outline numbering of headings. 2008-12-17 12:45:53 +0100 od r265597 : #i70748# method <HandleModifyAtTxtNode(..)> - correct determination of new and former applied list style 2008-12-17 10:18:41 +0100 od r265581 : #i97312# method <XMLTextNumRuleInfo::Set(..)> - check, if numbering rules instance contains any numbering rule. 2008-12-16 14:34:22 +0100 hde r265542 : #i97013 2008-12-16 14:20:24 +0100 od r265541 : #i70748# adjust documentation of "Which"-ID numbers 2008-12-16 14:19:49 +0100 od r265539 : #i70748# Adjust Attribute-Function-Mapping table due to new attribute 2008-12-16 14:06:24 +0100 od r265538 : #i70748# - Correct handling of to outline style assigned paragraph styles on reset of all paragraph style attributes - WW8 import: Consider refactoring of paragraph style's outline level attribute - NO_NUMBERING define no longer exsits. 2008-12-16 10:37:19 +0100 od r265530 : #i70478# Correction on moving outline paragraph up respectively down in its outline level: - Check also outline paragraph, which are not an outline via a to outline style assigned paragraph style, if action is applicable. 2008-12-16 09:10:13 +0100 hde r265523 : #i97277 2008-12-16 09:09:30 +0100 hde r265522 : #i97277 2008-12-16 09:07:40 +0100 hde r265521 : Added control and purged obsolete id's 2008-12-10 13:09:36 +0100 od r265174 : #i70748# correction of previous fix due to warning-free code 2008-12-10 13:03:30 +0100 od r265172 : #i70748# method <XMLTextImportHelper::SetStyleAndAttrs(..)> - Due to performance issues avoid retrieving outline level value from paragraph's paragraph style for each paragraph. Instead retrieve current outline level value from paragraph, which is the inherited value from its paragraph style, and only when it is needed. 2008-12-09 16:50:36 +0100 ufi r265117 : help 2008-12-09 16:49:50 +0100 ufi r265116 : help 2008-12-09 15:45:05 +0100 od r265107 : #i70748# method <XMLTextImportHelper::SetStyleAndAttrs(..)> - some minor rework and check access to paragraph styles 2008-12-09 15:42:04 +0100 od r265106 : #i70748# adjust name of local variable to avoid hiding of class variable 2008-12-09 15:40:51 +0100 od r265105 : #i70748# correct initialization order 2008-12-09 15:35:07 +0100 od r265101 : #i70748# remove duplicate entry in certain property map 2008-12-09 15:33:39 +0100 od r265100 : #i70748# add end of file token 2008-12-07 15:11:54 +0100 zhaojianwei r264952 : conflicts left not to be resolved when cws rebase 2008-12-04 14:52:21 +0100 zhaojianwei r264846 : CWS-TOOLING: rebase CWS outlinelevel to trunk@264325 (milestone: DEV300:m36) 2008-11-28 03:42:09 +0100 zhaojianwei r264525 : #i70748#: migrate CWS outlinelevel to SVN 2008-11-28 03:41:39 +0100 zhaojianwei r264524 : #i70748#: migrate CWS outlinelevel to SVN 2008-11-28 03:41:11 +0100 zhaojianwei r264523 : #i70748#: migrate CWS outlinelevel to SVN
2009-01-07 11:57:24 +00:00
if ( mxNumRules.is() && mxNumRules->getCount() < 1 )
{
DBG_ASSERT( false,
"<XMLTextNumRuleInfo::Set(..)> - numbering rules instance does not contain any numbering rule" );
Reset();
return;
}
if ( mnListLevel < 0 )
{
DBG_ASSERT( false,
"<XMLTextNumRuleInfo::Set(..)> - unexpected numbering level" );
Reset();
return;
}
// Written OpenDocument file format doesn't fit to the created text document (#i69627#)
bool bSuppressListStyle( false );
if ( mxNumRules.is() )
{
if ( !mbOutlineStyleAsNormalListStyle )
{
bool bIsOutline = false;
Reference<XPropertySet> xNumRulesProps(mxNumRules, UNO_QUERY);
if ( xNumRulesProps.is() &&
xNumRulesProps->getPropertySetInfo()->
hasPropertyByName( msNumberingIsOutline ) )
{
xNumRulesProps->getPropertyValue( msNumberingIsOutline ) >>= bIsOutline;
bSuppressListStyle = bIsOutline;
}
}
}
if( mxNumRules.is() && !bSuppressListStyle )
2000-09-18 16:07:07 +00:00
{
// First try to find the numbering rules in the list auto style pool.
// If not found, the numbering rules instance has to be named.
msNumRulesName = rListAutoPool.Find( mxNumRules );
if ( msNumRulesName.isEmpty() )
{
Reference < XNamed > xNamed( mxNumRules, UNO_QUERY );
DBG_ASSERT( xNamed.is(),
"<XMLTextNumRuleInfo::Set(..)> - numbering rules instance have to be named. Serious defect -> please inform OD." );
if( xNamed.is() )
{
msNumRulesName = xNamed->getName();
}
}
DBG_ASSERT( !msNumRulesName.isEmpty(),
"<XMLTextNumRuleInfo::Set(..)> - no name found for numbering rules instance. Serious defect -> please inform OD." );
if( xPropSetInfo->hasPropertyByName( msPropNameListId ) )
{
xPropSet->getPropertyValue( msPropNameListId ) >>= msListId;
}
2000-09-18 16:07:07 +00:00
mbContinueingPreviousSubTree = false;
if( xPropSetInfo->hasPropertyByName( msContinueingPreviousSubTree ) )
{
xPropSet->getPropertyValue( msContinueingPreviousSubTree ) >>= mbContinueingPreviousSubTree;
}
mbIsNumbered = true;
if( xPropSetInfo->hasPropertyByName( msNumberingIsNumber ) )
2000-09-18 16:07:07 +00:00
{
if( !(xPropSet->getPropertyValue( msNumberingIsNumber ) >>= mbIsNumbered ) )
{
OSL_FAIL( "numbered paragraph without number info" );
mbIsNumbered = false;
}
2000-09-18 16:07:07 +00:00
}
if( mbIsNumbered )
2000-09-18 16:07:07 +00:00
{
if( xPropSetInfo->hasPropertyByName( msParaIsNumberingRestart ) )
2000-10-23 10:28:11 +00:00
{
xPropSet->getPropertyValue( msParaIsNumberingRestart ) >>= mbIsRestart;
2000-10-23 10:28:11 +00:00
}
if( xPropSetInfo->hasPropertyByName( msNumberingStartValue ) )
2000-09-18 16:07:07 +00:00
{
xPropSet->getPropertyValue( msNumberingStartValue ) >>= mnListStartValue;
2000-09-18 16:07:07 +00:00
}
}
OSL_ENSURE( mnListLevel < mxNumRules->getCount(), "wrong num rule level" );
if( mnListLevel >= mxNumRules->getCount() )
2001-04-18 07:52:32 +00:00
{
Reset();
return;
}
2000-09-18 16:07:07 +00:00
Sequence<PropertyValue> aProps;
mxNumRules->getByIndex( mnListLevel ) >>= aProps;
2000-09-18 16:07:07 +00:00
const PropertyValue* pPropArray = aProps.getConstArray();
sal_Int32 nCount = aProps.getLength();
for( sal_Int32 i=0; i<nCount; i++ )
{
const PropertyValue& rProp = pPropArray[i];
if ( rProp.Name == msPropNameStartWith )
2000-09-18 16:07:07 +00:00
{
rProp.Value >>= mnListLevelStartValue;
break;
2000-09-18 16:07:07 +00:00
}
}
msListLabelString = OUString();
if ( bExportTextNumberElement &&
xPropSetInfo->hasPropertyByName( msListLabelStringProp ) )
{
xPropSet->getPropertyValue( msListLabelStringProp ) >>= msListLabelString;
}
// paragraph's list level range is [0..9] representing list levels [1..10]
++mnListLevel;
2000-09-18 16:07:07 +00:00
}
else
{
mnListLevel = 0;
}
2000-09-18 16:07:07 +00:00
}
bool XMLTextNumRuleInfo::BelongsToSameList( const XMLTextNumRuleInfo& rCmp ) const
{
bool bRet( true );
// Currently only the text documents support <ListId>.
if ( !rCmp.msListId.isEmpty() || !msListId.isEmpty() )
{
bRet = rCmp.msListId == msListId;
}
else
{
bRet = HasSameNumRules( rCmp );
}
return bRet;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */