summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2006-12-01 14:27:17 +0000
committerRüdiger Timm <rt@openoffice.org>2006-12-01 14:27:17 +0000
commit7040dd6447cb8a0aec4b7026a5551b7636184cda (patch)
tree986f6ca36e8c76e9728ec9ac1991a86d675b892b /xmloff
parent355684e3ebddb7314e5f0b2ffeeec2dfe54fb181 (diff)
INTEGRATION: CWS swautomatic01 (1.13.120); FILE MERGED
2006/10/10 16:24:16 fme 1.13.120.9: RESYNC: (1.14-1.15); FILE MERGED 2006/08/31 07:45:24 ama 1.13.120.8: #i65476#: Automatic styles, use display name as parent name 2006/08/21 13:12:46 ama 1.13.120.7: #i65476#: Optimization for automatic paragraphs/numbering 2006/08/18 09:07:53 ama 1.13.120.6: #i65476#: Automatic styles 2006/08/16 10:04:24 ama 1.13.120.5: #i65476#: Automatic styles (paragraph) 2006/08/11 15:40:55 fme 1.13.120.4: #i65476# Automatic styles - resync 2006/08/10 15:39:51 fme 1.13.120.3: RESYNC: (1.13-1.14); FILE MERGED 2006/06/26 13:51:14 ama 1.13.120.2: #i65476#: Automatic Styles 2006/06/15 09:37:05 ama 1.13.120.1: #i65476#: Automatic Styles
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/style/prstylei.cxx216
1 files changed, 135 insertions, 81 deletions
diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx
index 9b0649879892..f5f89cfd0f55 100644
--- a/xmloff/source/style/prstylei.cxx
+++ b/xmloff/source/style/prstylei.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: prstylei.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: obo $ $Date: 2006-09-17 10:56:37 $
+ * last change: $Author: rt $ $Date: 2006-12-01 15:27:17 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -55,6 +55,7 @@
#ifndef _COM_SUN_STAR_STYLE_XSTYLE_HPP_
#include <com/sun/star/style/XStyle.hpp>
#endif
+#include <com/sun/star/style/XAutoStyleFamily.hpp>
#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
#include <com/sun/star/container/XNameContainer.hpp>
#endif
@@ -221,104 +222,157 @@ typedef ::std::set < OUString, ::comphelper::UStringLess > PropertyNameSet;
void XMLPropStyleContext::CreateAndInsert( sal_Bool bOverwrite )
{
- const OUString& rName = GetDisplayName();
- if( 0 == rName.getLength() || IsDefaultStyle() )
- return;
+ if( ((SvXMLStylesContext *)&mxStyles)->IsAutomaticStyle()
+ && ( GetFamily() == XML_STYLE_FAMILY_TEXT_TEXT || GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH ) )
+ {
+ Reference < XAutoStyleFamily > xAutoFamily =
+ ((SvXMLStylesContext *)&mxStyles)->GetAutoStyles( GetFamily() );
+ if( !xAutoFamily.is() )
+ return;
+ UniReference < SvXMLImportPropertyMapper > xImpPrMap =
+ ((SvXMLStylesContext *)&mxStyles)->GetImportPropertyMapper( GetFamily() );
+ DBG_ASSERT( xImpPrMap.is(), "There is no import prop mapper" );
+ if( xImpPrMap.is() )
+ {
+ Sequence< PropertyValue > aValues;
+ xImpPrMap->FillPropertySequence( maProperties, aValues );
- Reference < XNameContainer > xFamilies =
- ((SvXMLStylesContext *)&mxStyles)->GetStylesContainer( GetFamily() );
- if( !xFamilies.is() )
- return;
+ sal_Int32 nLen = aValues.getLength();
+ if( nLen )
+ {
+ if( GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH )
+ {
+ aValues.realloc( nLen + 2 );
+ PropertyValue *pProps = aValues.getArray() + nLen;
+ pProps->Name = rtl::OUString::createFromAscii("ParaStyleName");
+ OUString sParent( GetParentName() );
+ if( sParent.getLength() )
+ sParent = GetImport().GetStyleDisplayName( GetFamily(), sParent );
+ pProps->Value <<= sParent;
+ ++pProps;
+ pProps->Name = rtl::OUString::createFromAscii("ParaConditionalStyleName");
+ pProps->Value <<= sParent;
+ }
- sal_Bool bNew = sal_False;
- if( xFamilies->hasByName( rName ) )
- {
- Any aAny = xFamilies->getByName( rName );
- aAny >>= mxStyle;
+ Reference < XAutoStyle > xAutoStyle = xAutoFamily->insertStyle( aValues );
+ if( xAutoStyle.is() )
+ {
+ Sequence< OUString > aPropNames(1);
+ aPropNames[0] = GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH ?
+ rtl::OUString::createFromAscii("ParaAutoStyleName") :
+ rtl::OUString::createFromAscii("CharAutoStyleName");
+ Sequence< Any > aAny = xAutoStyle->getPropertyValues( aPropNames );
+ if( aAny.hasElements() )
+ {
+ OUString aName;
+ aAny[0] >>= aName;
+ SetAutoName( aName );
+ }
+ }
+ }
+ }
}
else
{
- mxStyle = Create();
- if( !mxStyle.is() )
+ const OUString& rName = GetDisplayName();
+ if( 0 == rName.getLength() || IsDefaultStyle() )
return;
- Any aAny;
- aAny <<= mxStyle;
- xFamilies->insertByName( rName, aAny );
- bNew = sal_True;
- }
+ Reference < XNameContainer > xFamilies =
+ ((SvXMLStylesContext *)&mxStyles)->GetStylesContainer( GetFamily() );
+ if( !xFamilies.is() )
+ return;
- Reference < XPropertySet > xPropSet( mxStyle, UNO_QUERY );
- Reference< XPropertySetInfo > xPropSetInfo =
- xPropSet->getPropertySetInfo();
- if( !bNew && xPropSetInfo->hasPropertyByName( msIsPhysical ) )
- {
- Any aAny = xPropSet->getPropertyValue( msIsPhysical );
- bNew = !*(sal_Bool *)aAny.getValue();
- }
- SetNew( bNew );
- if( rName != GetName() )
- GetImport().AddStyleDisplayName( GetFamily(), GetName(), rName );
+ sal_Bool bNew = sal_False;
+ if( xFamilies->hasByName( rName ) )
+ {
+ Any aAny = xFamilies->getByName( rName );
+ aAny >>= mxStyle;
+ }
+ else
+ {
+ mxStyle = Create();
+ if( !mxStyle.is() )
+ return;
+
+ Any aAny;
+ aAny <<= mxStyle;
+ xFamilies->insertByName( rName, aAny );
+ bNew = sal_True;
+ }
- if( bOverwrite || bNew )
- {
- Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
+ Reference < XPropertySet > xPropSet( mxStyle, UNO_QUERY );
+ Reference< XPropertySetInfo > xPropSetInfo =
+ xPropSet->getPropertySetInfo();
+ if( !bNew && xPropSetInfo->hasPropertyByName( msIsPhysical ) )
+ {
+ Any aAny = xPropSet->getPropertyValue( msIsPhysical );
+ bNew = !*(sal_Bool *)aAny.getValue();
+ }
+ SetNew( bNew );
+ if( rName != GetName() )
+ GetImport().AddStyleDisplayName( GetFamily(), GetName(), rName );
- UniReference < XMLPropertySetMapper > xPrMap;
- UniReference < SvXMLImportPropertyMapper > xImpPrMap =
- ((SvXMLStylesContext *)&mxStyles)->GetImportPropertyMapper(
- GetFamily() );
- DBG_ASSERT( xImpPrMap.is(), "There is the import prop mapper" );
- if( xImpPrMap.is() )
- xPrMap = xImpPrMap->getPropertySetMapper();
- if( xPrMap.is() )
+ if( bOverwrite || bNew )
{
- Reference < XMultiPropertyStates > xMultiStates( xPropSet,
- UNO_QUERY );
- if( xMultiStates.is() )
- {
- xMultiStates->setAllPropertiesToDefault();
- }
- else
+ Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
+
+ UniReference < XMLPropertySetMapper > xPrMap;
+ UniReference < SvXMLImportPropertyMapper > xImpPrMap =
+ ((SvXMLStylesContext *)&mxStyles)->GetImportPropertyMapper(
+ GetFamily() );
+ DBG_ASSERT( xImpPrMap.is(), "There is the import prop mapper" );
+ if( xImpPrMap.is() )
+ xPrMap = xImpPrMap->getPropertySetMapper();
+ if( xPrMap.is() )
{
- PropertyNameSet aNameSet;
- sal_Int32 nCount = xPrMap->GetEntryCount();
- sal_Int32 i;
- for( i = 0; i < nCount; i++ )
+ Reference < XMultiPropertyStates > xMultiStates( xPropSet,
+ UNO_QUERY );
+ if( xMultiStates.is() )
{
- const OUString& rPrName = xPrMap->GetEntryAPIName( i );
- if( xPropSetInfo->hasPropertyByName( rPrName ) )
- aNameSet.insert( rPrName );
+ xMultiStates->setAllPropertiesToDefault();
}
-
- nCount = aNameSet.size();
- Sequence < OUString > aNames( nCount );
- OUString *pNames = aNames.getArray();
- PropertyNameSet::iterator aIter = aNameSet.begin();
- while( aIter != aNameSet.end() )
- *pNames++ = *aIter++;
-
- Sequence < PropertyState > aStates(
- xPropState->getPropertyStates( aNames ) );
- const PropertyState *pStates = aStates.getConstArray();
- pNames = aNames.getArray();
-
- for( i = 0; i < nCount; i++ )
+ else
{
- if( PropertyState_DIRECT_VALUE == *pStates++ )
- xPropState->setPropertyToDefault( pNames[i] );
+ PropertyNameSet aNameSet;
+ sal_Int32 nCount = xPrMap->GetEntryCount();
+ sal_Int32 i;
+ for( i = 0; i < nCount; i++ )
+ {
+ const OUString& rPrName = xPrMap->GetEntryAPIName( i );
+ if( xPropSetInfo->hasPropertyByName( rPrName ) )
+ aNameSet.insert( rPrName );
+ }
+
+ nCount = aNameSet.size();
+ Sequence < OUString > aNames( nCount );
+ OUString *pNames = aNames.getArray();
+ PropertyNameSet::iterator aIter = aNameSet.begin();
+ while( aIter != aNameSet.end() )
+ *pNames++ = *aIter++;
+
+ Sequence < PropertyState > aStates(
+ xPropState->getPropertyStates( aNames ) );
+ const PropertyState *pStates = aStates.getConstArray();
+ pNames = aNames.getArray();
+
+ for( i = 0; i < nCount; i++ )
+ {
+ if( PropertyState_DIRECT_VALUE == *pStates++ )
+ xPropState->setPropertyToDefault( pNames[i] );
+ }
}
}
- }
- if (mxStyle.is())
- mxStyle->setParentStyle(OUString());
+ if (mxStyle.is())
+ mxStyle->setParentStyle(OUString());
- FillPropertySet( xPropSet );
- }
- else
- {
- SetValid( sal_False );
+ FillPropertySet( xPropSet );
+ }
+ else
+ {
+ SetValid( sal_False );
+ }
}
}