Kaydet (Commit) e220dde9 authored tarafından Christian Lippka's avatar Christian Lippka

#92487# add style:list-style for graphic shape styles

üst 877d9bf1
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: XMLShapeStyleContext.cxx,v $ * $RCSfile: XMLShapeStyleContext.cxx,v $
* *
* $Revision: 1.7 $ * $Revision: 1.8 $
* *
* last change: $Author: thb $ $Date: 2001-07-24 17:06:07 $ * last change: $Author: cl $ $Date: 2002-01-11 12:18:09 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -68,6 +68,10 @@ ...@@ -68,6 +68,10 @@
#include "XMLShapePropertySetContext.hxx" #include "XMLShapePropertySetContext.hxx"
#endif #endif
#ifndef _XMLOFF_CONTEXTID_HXX_
#include "contextid.hxx"
#endif
#ifndef _COM_SUN_STAR_DRAWING_XCONTROLSHAPE_HPP_ #ifndef _COM_SUN_STAR_DRAWING_XCONTROLSHAPE_HPP_
#include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/drawing/XControlShape.hpp>
#endif #endif
...@@ -88,6 +92,10 @@ ...@@ -88,6 +92,10 @@
#include "xmltoken.hxx" #include "xmltoken.hxx"
#endif #endif
#ifndef _XMLOFF_XMLERROR_HXX
#include "xmlerror.hxx"
#endif
#include "sdpropls.hxx" #include "sdpropls.hxx"
using namespace ::rtl; using namespace ::rtl;
...@@ -107,7 +115,8 @@ XMLShapeStyleContext::XMLShapeStyleContext( ...@@ -107,7 +115,8 @@ XMLShapeStyleContext::XMLShapeStyleContext(
const uno::Reference< xml::sax::XAttributeList >& xAttrList, const uno::Reference< xml::sax::XAttributeList >& xAttrList,
SvXMLStylesContext& rStyles, SvXMLStylesContext& rStyles,
sal_uInt16 nFamily) sal_uInt16 nFamily)
: XMLPropStyleContext(rImport, nPrfx, rLName, xAttrList, rStyles, nFamily ) : XMLPropStyleContext(rImport, nPrfx, rLName, xAttrList, rStyles, nFamily ),
m_bIsNumRuleAlreadyConverted( sal_False )
{ {
} }
...@@ -121,6 +130,10 @@ void XMLShapeStyleContext::SetAttribute( sal_uInt16 nPrefixKey, const ::rtl::OUS ...@@ -121,6 +130,10 @@ void XMLShapeStyleContext::SetAttribute( sal_uInt16 nPrefixKey, const ::rtl::OUS
{ {
m_sControlDataStyleName = rValue; m_sControlDataStyleName = rValue;
} }
else if( (XML_NAMESPACE_STYLE == nPrefixKey) && IsXMLToken( rLocalName, ::xmloff::token::XML_LIST_STYLE_NAME ) )
{
m_sListStyleName = rValue;
}
else else
{ {
XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue ); XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
...@@ -155,9 +168,68 @@ SvXMLImportContext *XMLShapeStyleContext::CreateChildContext( ...@@ -155,9 +168,68 @@ SvXMLImportContext *XMLShapeStyleContext::CreateChildContext(
void XMLShapeStyleContext::FillPropertySet( const Reference< beans::XPropertySet > & rPropSet ) void XMLShapeStyleContext::FillPropertySet( const Reference< beans::XPropertySet > & rPropSet )
{ {
if( !m_bIsNumRuleAlreadyConverted )
{
m_bIsNumRuleAlreadyConverted = sal_True;
// for compatibility to beta files, search for CTF_SD_NUMBERINGRULES_NAME to
// import numbering rules from the style:properties element
const UniReference< XMLPropertySetMapper >&rMapper = GetStyles()->GetImportPropertyMapper( GetFamily() )->getPropertySetMapper();
::std::vector< XMLPropertyState > &rProperties = GetProperties();
::std::vector< XMLPropertyState >::iterator end( rProperties.end() );
::std::vector< XMLPropertyState >::iterator property;
// first, look for the old format, where we had a text:list-style-name
// attribute in the style:properties element
for( property = rProperties.begin(); property != end; property++ )
{
// find properties with context
if( rMapper->GetEntryContextId( property->mnIndex ) == CTF_SD_NUMBERINGRULES_NAME )
break;
}
// if we did not find an old list-style-name in the properties, and we need one
// because we got a style:list-style attribute in the style-style element
// we generate one
if( (property == end) && ( 0 != m_sListStyleName.getLength() ) )
{
sal_Int32 nIndex = rMapper->FindEntryIndex( CTF_SD_NUMBERINGRULES_NAME );
DBG_ASSERT( -1 != nIndex, "can't find numbering rules property entry, can't set numbering rule!" );
XMLPropertyState aNewState( nIndex );
rProperties.push_back( aNewState );
end = rProperties.end();
property = end - 1;
}
// so, if we have an old or a new list style name, we set its value to
// a numbering rule
if( property != end )
{
if( 0 == m_sListStyleName.getLength() )
{
property->maValue >>= m_sListStyleName;
}
const SvxXMLListStyleContext *pListStyle = GetImport().GetTextImport()->FindAutoListStyle( m_sListStyleName );
DBG_ASSERT( pListStyle, "list-style not found for shape style" );
if( pListStyle )
{
uno::Reference< container::XIndexReplace > xNumRule( pListStyle->CreateNumRule( GetImport().GetModel() ) );
pListStyle->FillUnoNumRule(xNumRule, NULL /* const SvI18NMap * ??? */ );
property->maValue <<= xNumRule;
}
else
{
property->mnIndex = -1;
}
}
}
XMLPropStyleContext::FillPropertySet(rPropSet); XMLPropStyleContext::FillPropertySet(rPropSet);
#ifndef SVX_LIGHT
if (m_sControlDataStyleName.getLength()) if (m_sControlDataStyleName.getLength())
{ // we had a data-style-name attribute { // we had a data-style-name attribute
...@@ -174,40 +246,9 @@ void XMLShapeStyleContext::FillPropertySet( const Reference< beans::XPropertySet ...@@ -174,40 +246,9 @@ void XMLShapeStyleContext::FillPropertySet( const Reference< beans::XPropertySet
} }
} }
} }
#endif // #ifndef SVX_LIGHT
} }
void XMLShapeStyleContext::Finish( sal_Bool bOverwrite ) void XMLShapeStyleContext::Finish( sal_Bool bOverwrite )
{ {
const UniReference< XMLPropertySetMapper >&rMapper = GetStyles()->GetImportPropertyMapper( GetFamily() )->getPropertySetMapper();
::std::vector< XMLPropertyState > &rProperties = GetProperties();
std::vector< XMLPropertyState >::iterator end( rProperties.end() );
for( std::vector< XMLPropertyState >::iterator property = rProperties.begin();
property != end;
property++ )
{
// find properties with context
// to prevent writing this property set mnIndex member to -1
if( rMapper->GetEntryContextId( property->mnIndex ) == CTF_NUMBERINGRULES_NAME )
{
OUString sName;
if( property->maValue >>= sName )
{
uno::Reference< container::XIndexReplace > xNumRule;
const SvxXMLListStyleContext *pListStyle = GetImport().GetTextImport()->FindAutoListStyle( sName );
DBG_ASSERT( pListStyle, "list-style not found for shape style" );
if( pListStyle )
{
xNumRule = pListStyle->CreateNumRule( GetImport().GetModel() );
pListStyle->FillUnoNumRule(xNumRule, NULL /* const SvI18NMap * ??? */ );
}
property->maValue <<= xNumRule;
}
break;
}
}
} }
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: sdpropls.cxx,v $ * $RCSfile: sdpropls.cxx,v $
* *
* $Revision: 1.56 $ * $Revision: 1.57 $
* *
* last change: $Author: cl $ $Date: 2001-11-19 14:44:39 $ * last change: $Author: cl $ $Date: 2002-01-11 12:18:09 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -284,7 +284,7 @@ const XMLPropertyMapEntry aXMLSDProperties[] = ...@@ -284,7 +284,7 @@ const XMLPropertyMapEntry aXMLSDProperties[] =
MAP( "TextRightDistance", XML_NAMESPACE_FO, XML_PADDING_RIGHT, XML_TYPE_MEASURE|MID_FLAG_MULTI_PROPERTY, 0 ), // exists in SW, too MAP( "TextRightDistance", XML_NAMESPACE_FO, XML_PADDING_RIGHT, XML_TYPE_MEASURE|MID_FLAG_MULTI_PROPERTY, 0 ), // exists in SW, too
MAP( "TextWritingMode", XML_NAMESPACE_DRAW, XML_WRITING_MODE, XML_SD_TYPE_WRITINGMODE, CTF_WRITINGMODE ), MAP( "TextWritingMode", XML_NAMESPACE_DRAW, XML_WRITING_MODE, XML_SD_TYPE_WRITINGMODE, CTF_WRITINGMODE ),
MAP( "NumberingRules", XML_NAMESPACE_TEXT, XML_LIST_STYLE, XML_SD_TYPE_NUMBULLET|MID_FLAG_ELEMENT_ITEM, CTF_NUMBERINGRULES ), MAP( "NumberingRules", XML_NAMESPACE_TEXT, XML_LIST_STYLE, XML_SD_TYPE_NUMBULLET|MID_FLAG_ELEMENT_ITEM, CTF_NUMBERINGRULES ),
MAP( "NumberingRules", XML_NAMESPACE_TEXT, XML_LIST_STYLE_NAME, XML_TYPE_STRING, CTF_NUMBERINGRULES_NAME ), MAP( "NumberingRules", XML_NAMESPACE_TEXT, XML_LIST_STYLE_NAME, XML_TYPE_STRING, CTF_SD_NUMBERINGRULES_NAME ),
// shadow attributes // shadow attributes
MAP( "Shadow", XML_NAMESPACE_DRAW, XML_SHADOW, XML_SD_TYPE_SHADOW, 0 ), MAP( "Shadow", XML_NAMESPACE_DRAW, XML_SHADOW, XML_SD_TYPE_SHADOW, 0 ),
...@@ -1079,7 +1079,7 @@ XMLShapeExportPropertyMapper::XMLShapeExportPropertyMapper( const UniReference< ...@@ -1079,7 +1079,7 @@ XMLShapeExportPropertyMapper::XMLShapeExportPropertyMapper( const UniReference<
msCDATA( GetXMLToken(XML_CDATA)), msCDATA( GetXMLToken(XML_CDATA)),
msTrue( GetXMLToken(XML_TRUE)), msTrue( GetXMLToken(XML_TRUE)),
msFalse( GetXMLToken(XML_FALSE)), msFalse( GetXMLToken(XML_FALSE)),
mbIsInAutoStyles( sal_False ) mbIsInAutoStyles( sal_True )
{ {
} }
...@@ -1138,21 +1138,14 @@ void XMLShapeExportPropertyMapper::ContextFilter( ...@@ -1138,21 +1138,14 @@ void XMLShapeExportPropertyMapper::ContextFilter(
property->mnIndex = -1; property->mnIndex = -1;
} }
break; break;
case CTF_NUMBERINGRULES_NAME: case CTF_SD_NUMBERINGRULES_NAME:
{ {
if( mbIsInAutoStyles ) // this property is not exported in the style:properties element
{ // because its an XIndexAccess and not a string.
uno::Reference< container::XIndexReplace > xNumRule; // This will be handled in SvXMLAutoStylePoolP::exportStyleAttributes
if( property->maValue >>= xNumRule ) // This is suboptimal
{ if( !mbIsInAutoStyles )
const OUString sName = ((XMLTextListAutoStylePool*)&mrExport.GetTextParagraphExport()->GetListAutoStylePool())->Add( xNumRule );
property->maValue <<= sName;
}
}
else
{
property->mnIndex = -1; property->mnIndex = -1;
}
} }
break; break;
case CTF_WRITINGMODE: case CTF_WRITINGMODE:
...@@ -1528,3 +1521,4 @@ void XMLPageExportPropertyMapper::handleElementItem( ...@@ -1528,3 +1521,4 @@ void XMLPageExportPropertyMapper::handleElementItem(
} }
#endif // #ifndef SVX_LIGHT #endif // #ifndef SVX_LIGHT
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: sdpropls.hxx,v $ * $RCSfile: sdpropls.hxx,v $
* *
* $Revision: 1.25 $ * $Revision: 1.26 $
* *
* last change: $Author: dvo $ $Date: 2001-10-25 20:57:02 $ * last change: $Author: cl $ $Date: 2002-01-11 12:18:09 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -173,7 +173,7 @@ extern const XMLPropertyMapEntry aXMLSDPresPageProps[]; ...@@ -173,7 +173,7 @@ extern const XMLPropertyMapEntry aXMLSDPresPageProps[];
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#define CTF_NUMBERINGRULES 1000 #define CTF_NUMBERINGRULES 1000
#define CTF_NUMBERINGRULES_NAME 1001 //#define CTF_NUMBERINGRULES_NAME 1001
#define CTF_WRITINGMODE 1002 #define CTF_WRITINGMODE 1002
#define CTF_REPEAT_OFFSET_X 1003 #define CTF_REPEAT_OFFSET_X 1003
#define CTF_REPEAT_OFFSET_Y 1004 #define CTF_REPEAT_OFFSET_Y 1004
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: shapeexport.cxx,v $ * $RCSfile: shapeexport.cxx,v $
* *
* $Revision: 1.47 $ * $Revision: 1.48 $
* *
* last change: $Author: cl $ $Date: 2001-11-30 14:12:36 $ * last change: $Author: cl $ $Date: 2002-01-11 12:18:09 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -839,7 +839,6 @@ SvXMLExportPropertyMapper* XMLShapeExport::CreateShapePropMapper( ...@@ -839,7 +839,6 @@ SvXMLExportPropertyMapper* XMLShapeExport::CreateShapePropMapper(
new XMLShapeExportPropertyMapper( xMapper, new XMLShapeExportPropertyMapper( xMapper,
(XMLTextListAutoStylePool*)&rExport.GetTextParagraphExport()->GetListAutoStylePool(), (XMLTextListAutoStylePool*)&rExport.GetTextParagraphExport()->GetListAutoStylePool(),
rExport ); rExport );
((XMLShapeExportPropertyMapper*)pResult)->SetAutoStyles( sal_True );
// chain text attributes // chain text attributes
return pResult; return pResult;
} }
...@@ -1036,6 +1035,7 @@ void XMLShapeExport::ExportGraphicDefaults() ...@@ -1036,6 +1035,7 @@ void XMLShapeExport::ExportGraphicDefaults()
// construct PropertySetMapper // construct PropertySetMapper
UniReference< SvXMLExportPropertyMapper > xPropertySetMapper( CreateShapePropMapper( rExport ) ); UniReference< SvXMLExportPropertyMapper > xPropertySetMapper( CreateShapePropMapper( rExport ) );
((XMLShapeExportPropertyMapper*)xPropertySetMapper.get())->SetAutoStyles( sal_False );
// chain text attributes // chain text attributes
xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(rExport)); xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(rExport));
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: xmlaustp.cxx,v $ * $RCSfile: xmlaustp.cxx,v $
* *
* $Revision: 1.14 $ * $Revision: 1.15 $
* *
* last change: $Author: dvo $ $Date: 2001-10-25 20:57:03 $ * last change: $Author: cl $ $Date: 2002-01-11 12:14:05 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -60,6 +60,10 @@ ...@@ -60,6 +60,10 @@
************************************************************************/ ************************************************************************/
#ifndef _COM_SUN_STAR_CONTAINER_XINDEXREPLACE_HPP_
#include <com/sun/star/container/XIndexReplace.hpp>
#endif
#ifndef _TOOLS_DEBUG_HXX #ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx> #include <tools/debug.hxx>
#endif #endif
...@@ -82,6 +86,10 @@ ...@@ -82,6 +86,10 @@
#include "xmlexp.hxx" #include "xmlexp.hxx"
#endif #endif
#ifndef _XMLOFF_XMLTEXTLISTAUTOSTYLEPOOL_HXX
#include "XMLTextListAutoStylePool.hxx"
#endif
#ifndef _XMLOFF_PAGEMASTERSTYLEMAP_HXX #ifndef _XMLOFF_PAGEMASTERSTYLEMAP_HXX
#include "PageMasterStyleMap.hxx" #include "PageMasterStyleMap.hxx"
#endif #endif
...@@ -112,14 +120,14 @@ void SvXMLAutoStylePoolP::exportStyleAttributes( ...@@ -112,14 +120,14 @@ void SvXMLAutoStylePoolP::exportStyleAttributes(
#endif #endif
) const ) const
{ {
if (XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily) if( (XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily) || (XML_STYLE_FAMILY_SD_PRESENTATION_ID == nFamily) )
{ // it's a graphics style { // it's a graphics style
UniReference< XMLPropertySetMapper > aPropertyMapper = rPropExp.getPropertySetMapper(); UniReference< XMLPropertySetMapper > aPropertyMapper = rPropExp.getPropertySetMapper();
DBG_ASSERT(aPropertyMapper.is(), "SvXMLAutoStylePoolP::exportStyleAttributes: invalid property set mapper!"); DBG_ASSERT(aPropertyMapper.is(), "SvXMLAutoStylePoolP::exportStyleAttributes: invalid property set mapper!");
#ifdef DBG_UTIL
sal_Bool bFoundControlShapeDataStyle = sal_False; sal_Bool bFoundControlShapeDataStyle = sal_False;
#endif sal_Bool bFoundNumberingRulesName = sal_False;
for ( vector< XMLPropertyState >::const_iterator pProp = rProperties.begin(); for ( vector< XMLPropertyState >::const_iterator pProp = rProperties.begin();
pProp != rProperties.end(); pProp != rProperties.end();
++pProp ++pProp
...@@ -127,36 +135,54 @@ void SvXMLAutoStylePoolP::exportStyleAttributes( ...@@ -127,36 +135,54 @@ void SvXMLAutoStylePoolP::exportStyleAttributes(
{ {
if (pProp->mnIndex > -1) if (pProp->mnIndex > -1)
{ // it's a valid property { // it's a valid property
if (CTF_SD_CONTROL_SHAPE_DATA_STYLE == aPropertyMapper->GetEntryContextId(pProp->mnIndex)) switch( aPropertyMapper->GetEntryContextId(pProp->mnIndex) )
{ // it's the control shape data style property {
case CTF_SD_CONTROL_SHAPE_DATA_STYLE:
{ // it's the control shape data style property
if (bFoundControlShapeDataStyle)
{
DBG_ERROR("SvXMLAutoStylePoolP::exportStyleAttributes: found two properties with the ControlShapeDataStyle context id!");
// already added the attribute for the first occurence
break;
}
// obtain the data style name
::rtl::OUString sControlDataStyleName;
pProp->maValue >>= sControlDataStyleName;
DBG_ASSERT(sControlDataStyleName.getLength(), "SvXMLAutoStylePoolP::exportStyleAttributes: invalid property value for the data style name!");
// add the attribute
GetExport().AddAttribute(
aPropertyMapper->GetEntryNameSpace(pProp->mnIndex),
aPropertyMapper->GetEntryXMLName(pProp->mnIndex),
sControlDataStyleName );
#ifdef DBG_UTIL // check if there is another property with the special context id we're handling here
if (bFoundControlShapeDataStyle) bFoundControlShapeDataStyle = sal_True;
break;
}
case CTF_SD_NUMBERINGRULES_NAME:
{ {
DBG_ERROR("SvXMLAutoStylePoolP::exportStyleAttributes: found two properties with the ControlShapeDataStyle context id!"); if (bFoundNumberingRulesName)
// already added the attribute for the first occurence {
DBG_ERROR("SvXMLAutoStylePoolP::exportStyleAttributes: found two properties with the numbering rules name context id!");
// already added the attribute for the first occurence
break;
}
uno::Reference< container::XIndexReplace > xNumRule;
pProp->maValue >>= xNumRule;
if( xNumRule.is() && (xNumRule->getCount() > 0 ) )
{
const OUString sName(((XMLTextListAutoStylePool*)&GetExport().GetTextParagraphExport()->GetListAutoStylePool())->Add( xNumRule ));
GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_LIST_STYLE_NAME, sName );
}
bFoundNumberingRulesName = sal_True;
break; break;
} }
#endif
// obtain the data style name
::rtl::OUString sControlDataStyleName;
pProp->maValue >>= sControlDataStyleName;
DBG_ASSERT(sControlDataStyleName.getLength(), "SvXMLAutoStylePoolP::exportStyleAttributes: invalid property value for the data style name!");
// add the attribute
GetExport().AddAttribute(
aPropertyMapper->GetEntryNameSpace(pProp->mnIndex),
aPropertyMapper->GetEntryXMLName(pProp->mnIndex),
sControlDataStyleName );
#ifdef DBG_UTIL
// in a non-pro version, check if there is another property with the special context id we're handling here
bFoundControlShapeDataStyle = sal_True;
continue;
#else
// in a pro version, just leave the loop
break;
#endif
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment