summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
authorKatarina Machalkova <kmachalkova@suse.cz>2010-10-19 17:04:12 +0200
committerKatarina Machalkova <kmachalkova@suse.cz>2010-10-19 17:04:12 +0200
commit4f54b69d72817bc642b0804458f3f03de264b7c7 (patch)
treee154966f1b3045e8cf752a6809566461ae944ae3 /oox/source
parentfbcee910cdb406c3c12068b4e68de642006d3cb6 (diff)
Merged oox-smartart-import.diff from ooo-build
Diffstat (limited to 'oox/source')
-rw-r--r--oox/source/core/facreg.cxx6
-rw-r--r--oox/source/core/filterbase.cxx9
-rw-r--r--oox/source/core/xmlfilterbase.cxx165
-rw-r--r--oox/source/drawingml/chart/chartspaceconverter.cxx5
-rw-r--r--oox/source/drawingml/chart/converterbase.cxx4
-rw-r--r--oox/source/drawingml/chart/datasourceconverter.cxx13
-rw-r--r--oox/source/drawingml/clrscheme.cxx2
-rw-r--r--oox/source/drawingml/color.cxx1
-rw-r--r--oox/source/drawingml/customshapegeometry.cxx6
-rw-r--r--oox/source/drawingml/diagram/datamodelcontext.cxx232
-rw-r--r--oox/source/drawingml/diagram/diagram.cxx496
-rw-r--r--oox/source/drawingml/diagram/diagramdefinitioncontext.cxx13
-rw-r--r--oox/source/drawingml/diagram/diagramdefinitioncontext.hxx2
-rw-r--r--oox/source/drawingml/diagram/diagramfragmenthandler.cxx183
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx689
-rw-r--r--oox/source/drawingml/diagram/layoutnodecontext.cxx146
-rw-r--r--oox/source/drawingml/diagram/layoutnodecontext.hxx3
-rw-r--r--oox/source/drawingml/diagram/makefile.mk1
-rw-r--r--oox/source/drawingml/drawingmltypes.cxx4
-rw-r--r--oox/source/drawingml/fillproperties.cxx3
-rw-r--r--oox/source/drawingml/graphicshapecontext.cxx58
-rw-r--r--oox/source/drawingml/lineproperties.cxx5
-rw-r--r--oox/source/drawingml/makefile.mk1
-rw-r--r--oox/source/drawingml/shape.cxx43
-rw-r--r--oox/source/drawingml/shapepropertiescontext.cxx6
-rw-r--r--oox/source/drawingml/textparagraph.cxx9
-rw-r--r--oox/source/drawingml/textparagraphproperties.cxx1
-rw-r--r--oox/source/helper/storagebase.cxx20
-rw-r--r--oox/source/ppt/makefile.mk2
-rw-r--r--oox/source/ppt/pptimport.cxx4
-rw-r--r--oox/source/ppt/presentationfragmenthandler.cxx13
-rw-r--r--oox/source/ppt/slidepersist.cxx11
-rw-r--r--oox/source/shape/ShapeFilterBase.cxx4
-rw-r--r--oox/source/shape/ShapeFilterBase.hxx2
-rw-r--r--oox/source/xls/excelfilter.cxx2
-rw-r--r--oox/source/xls/workbookhelper.cxx4
36 files changed, 1780 insertions, 388 deletions
diff --git a/oox/source/core/facreg.cxx b/oox/source/core/facreg.cxx
index 590cdd876e93..95c041bca5ce 100644
--- a/oox/source/core/facreg.cxx
+++ b/oox/source/core/facreg.cxx
@@ -58,6 +58,8 @@ extern uno::Reference< uno::XInterface > SAL_CALL className##_createInstance(
namespace oox {
namespace core { SERVICE( FilterDetect ); }
namespace ppt { SERVICE( PowerPointImport ); }
+ namespace ppt { SERVICE( QuickDiagrammingImport ); }
+ namespace ppt { SERVICE( QuickDiagrammingLayout ); }
namespace xls { SERVICE( BiffDetector ); }
namespace xls { SERVICE( ExcelFilter ); }
namespace xls { SERVICE( ExcelBiffFilter ); }
@@ -101,6 +103,8 @@ OOX_DLLPUBLIC sal_Bool SAL_CALL component_writeInfo( void * , void * pRegistryKe
WRITEINFO( ::oox::core::FilterDetect );
WRITEINFO( ::oox::ppt::PowerPointImport );
+ WRITEINFO( ::oox::ppt::QuickDiagrammingImport );
+ WRITEINFO( ::oox::ppt::QuickDiagrammingLayout );
WRITEINFO( ::oox::xls::BiffDetector );
WRITEINFO( ::oox::xls::ExcelFilter );
WRITEINFO( ::oox::xls::ExcelBiffFilter );
@@ -149,6 +153,8 @@ OOX_DLLPUBLIC void * SAL_CALL component_getFactory( const sal_Char * pImplName,
SINGLEFACTORY( ::oox::core::FilterDetect )
else SINGLEFACTORY( oox::ppt::PowerPointImport )
+ else SINGLEFACTORY( oox::ppt::QuickDiagrammingImport )
+ else SINGLEFACTORY( oox::ppt::QuickDiagrammingLayout )
else SINGLEFACTORY( ::oox::xls::BiffDetector )
else SINGLEFACTORY( ::oox::xls::ExcelFilter )
else SINGLEFACTORY( ::oox::xls::ExcelBiffFilter )
diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx
index 502f17faa0fc..8cadd60d8ca0 100644
--- a/oox/source/core/filterbase.cxx
+++ b/oox/source/core/filterbase.cxx
@@ -32,6 +32,7 @@
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/task/XStatusIndicator.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
#include <osl/mutex.hxx>
#include <rtl/instance.hxx>
#include <rtl/uri.hxx>
@@ -63,6 +64,7 @@ using ::com::sun::star::io::XInputStream;
using ::com::sun::star::io::XOutputStream;
using ::com::sun::star::io::XStream;
using ::com::sun::star::task::XStatusIndicator;
+using ::com::sun::star::drawing::XShape;
using ::com::sun::star::task::XInteractionHandler;
using ::com::sun::star::graphic::XGraphic;
using ::com::sun::star::container::XNameAccess;
@@ -163,6 +165,7 @@ struct FilterBaseImpl
Reference< XStream > mxOutStream;
Reference< XStatusIndicator > mxStatusIndicator;
Reference< XInteractionHandler > mxInteractionHandler;
+ Reference< XShape > mxParentShape;
explicit FilterBaseImpl( const Reference< XMultiServiceFactory >& rxGlobalFactory );
@@ -274,6 +277,11 @@ const Reference< XFrame >& FilterBase::getTargetFrame() const
return mxImpl->mxTargetFrame;
}
+const Reference< XShape >& FilterBase::getParentShape() const
+{
+ return mxImpl->mxParentShape;
+}
+
const Reference< XStatusIndicator >& FilterBase::getStatusIndicator() const
{
return mxImpl->mxStatusIndicator;
@@ -568,6 +576,7 @@ void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDesc
mxImpl->mxTargetFrame = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_FRAME(), Reference< XFrame >() );
mxImpl->mxStatusIndicator = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_STATUSINDICATOR(), Reference< XStatusIndicator >() );
mxImpl->mxInteractionHandler = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_INTERACTIONHANDLER(), Reference< XInteractionHandler >() );
+ mxImpl->mxParentShape = mxImpl->maMediaDesc.getUnpackedValueOrDefault( CREATE_OUSTRING( "ParentShape" ), mxImpl->mxParentShape );
// Check for ISO OOXML
OUString sFilterName = mxImpl->maMediaDesc.getUnpackedValueOrDefault( CREATE_OUSTRING( "FilterName" ), OUString() );
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 37e26f415ca4..673acfe6b543 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -32,10 +32,14 @@
#include <rtl/strbuf.hxx>
#include <rtl/ustrbuf.hxx>
+#include <rtl/instance.hxx>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/embed/XRelationshipAccess.hpp>
+#include <com/sun/star/xml/dom/XDocument.hpp>
+#include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
#include <com/sun/star/xml/sax/InputSource.hpp>
#include <com/sun/star/xml/sax/XFastParser.hpp>
+#include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
#include <com/sun/star/document/XDocumentProperties.hpp>
#include <comphelper/mediadescriptor.hxx>
#include <sax/fshelper.hxx>
@@ -55,6 +59,7 @@ using ::rtl::OStringBuffer;
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
using ::com::sun::star::beans::StringPair;
+using ::com::sun::star::beans::Pair;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Exception;
@@ -75,11 +80,14 @@ using ::com::sun::star::xml::sax::XFastTokenHandler;
using ::com::sun::star::xml::sax::XFastDocumentHandler;
using ::com::sun::star::xml::sax::InputSource;
using ::com::sun::star::xml::sax::SAXException;
+using ::com::sun::star::xml::dom::XDocument;
+using ::com::sun::star::xml::dom::XDocumentBuilder;
using ::com::sun::star::document::XDocumentProperties;
using ::com::sun::star::util::DateTime;
using ::comphelper::MediaDescriptor;
using ::sax_fastparser::FastSerializerHelper;
using ::sax_fastparser::FSHelperPtr;
+using namespace ::com::sun::star;
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
@@ -119,6 +127,8 @@ struct XmlFilterBaseImpl
typedef RefMap< OUString, Relations > RelationsMap;
Reference< XFastParser > mxFastParser;
+ Reference< XFastTokenHandler >
+ mxTokenHandler;
OUString maBinSuffix;
OUString maVmlSuffix;
RelationsMap maRelationsMap;
@@ -152,6 +162,66 @@ static Reference< XComponentContext > lcl_getComponentContext(Reference< XMultiS
// ============================================================================
+namespace
+{
+ struct NamespaceIds: public rtl::StaticWithInit<
+ Sequence< Pair< OUString, sal_Int32 > >,
+ NamespaceIds>
+ {
+ Sequence< Pair< OUString, sal_Int32 > > operator()()
+ {
+ static const char* const namespaceURIs[] = {
+ "http://www.w3.org/XML/1998/namespace",
+ "http://schemas.openxmlformats.org/package/2006/relationships",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
+ "http://schemas.openxmlformats.org/drawingml/2006/main",
+ "http://schemas.openxmlformats.org/drawingml/2006/diagram",
+ "http://schemas.openxmlformats.org/drawingml/2006/chart",
+ "http://schemas.openxmlformats.org/drawingml/2006/chartDrawing",
+ "urn:schemas-microsoft-com:vml",
+ "urn:schemas-microsoft-com:office:office",
+ "urn:schemas-microsoft-com:office:word",
+ "urn:schemas-microsoft-com:office:excel",
+ "urn:schemas-microsoft-com:office:powerpoint",
+ "http://schemas.microsoft.com/office/2006/activeX",
+ "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
+ "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",
+ "http://schemas.microsoft.com/office/excel/2006/main",
+ "http://schemas.openxmlformats.org/presentationml/2006/main"
+ };
+
+ static const sal_Int32 namespaceIds[] = {
+ NMSP_XML,
+ NMSP_PACKAGE_RELATIONSHIPS,
+ NMSP_RELATIONSHIPS,
+ NMSP_DRAWINGML,
+ NMSP_DIAGRAM,
+ NMSP_CHART,
+ NMSP_CDR,
+ NMSP_VML,
+ NMSP_OFFICE,
+ NMSP_VML_DOC,
+ NMSP_VML_XLS,
+ NMSP_VML_PPT,
+ NMSP_AX,
+ NMSP_XLS,
+ NMSP_XDR,
+ NMSP_XM,
+ NMSP_PPT
+ };
+
+ Sequence< Pair< OUString, sal_Int32 > > aRet(STATIC_ARRAY_SIZE(namespaceIds));
+ for( sal_Int32 i=0; i<aRet.getLength(); ++i )
+ aRet[i] = beans::make_Pair(
+ ::rtl::OUString::createFromAscii(namespaceURIs[i]),
+ namespaceIds[i]);
+ return aRet;
+ }
+ };
+}
+
+// ============================================================================
+
XmlFilterBase::XmlFilterBase( const Reference< XMultiServiceFactory >& rxGlobalFactory ) :
FilterBase( rxGlobalFactory ),
mxImpl( new XmlFilterBaseImpl ),
@@ -160,32 +230,18 @@ XmlFilterBase::XmlFilterBase( const Reference< XMultiServiceFactory >& rxGlobalF
{
try
{
+ // create the fast tokenhandler
+ mxImpl->mxTokenHandler.set( new FastTokenHandler );
+
// create the fast parser
mxImpl->mxFastParser.set( rxGlobalFactory->createInstance( CREATE_OUSTRING( "com.sun.star.xml.sax.FastParser" ) ), UNO_QUERY_THROW );
- mxImpl->mxFastParser->setTokenHandler( new FastTokenHandler );
+ mxImpl->mxFastParser->setTokenHandler( mxImpl->mxTokenHandler );
// register XML namespaces
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://www.w3.org/XML/1998/namespace" ), NMSP_XML );
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/package/2006/relationships" ), NMSP_PACKAGE_RELATIONSHIPS );
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/officeDocument/2006/relationships" ), NMSP_RELATIONSHIPS );
-
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/main" ), NMSP_DRAWINGML );
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/diagram" ), NMSP_DIAGRAM );
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/chart" ), NMSP_CHART );
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/chartDrawing" ), NMSP_CDR );
-
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:vml" ), NMSP_VML );
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:office" ), NMSP_OFFICE );
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:word" ), NMSP_VML_DOC );
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:excel" ), NMSP_VML_XLS );
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:powerpoint" ), NMSP_VML_PPT );
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.microsoft.com/office/2006/activeX" ), NMSP_AX );
-
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/spreadsheetml/2006/main"), NMSP_XLS );
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" ), NMSP_XDR );
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.microsoft.com/office/excel/2006/main" ), NMSP_XM );
-
- mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/presentationml/2006/main"), NMSP_PPT );
+ const Sequence< Pair< OUString, sal_Int32 > > ids=
+ NamespaceIds::get();
+ for( sal_Int32 i=0; i<ids.getLength(); ++i )
+ mxImpl->mxFastParser->registerNamespace( ids[i].First, ids[i].Second );
}
catch( Exception& )
{
@@ -298,6 +354,66 @@ bool XmlFilterBase::importFragment( const ::rtl::Reference< FragmentHandler >& r
return false;
}
+Reference<XDocument> XmlFilterBase::importFragment( const ::rtl::OUString& aFragmentPath )
+{
+ Reference<XDocument> xRet;
+
+ // path to fragment stream valid?
+ OSL_ENSURE( aFragmentPath.getLength() > 0, "XmlFilterBase::importFragment - empty fragment path" );
+ if( aFragmentPath.getLength() == 0 )
+ return xRet;
+
+ // try to open the fragment stream (this may fail - do not assert)
+ Reference< XInputStream > xInStrm = openInputStream( aFragmentPath );
+ if( !xInStrm.is() )
+ return xRet;
+
+ // binary streams (fragment extension is '.bin') currently not supported
+ sal_Int32 nBinSuffixPos = aFragmentPath.getLength() - mxImpl->maBinSuffix.getLength();
+ if( (nBinSuffixPos >= 0) && aFragmentPath.match( mxImpl->maBinSuffix, nBinSuffixPos ) )
+ return xRet;
+
+ // try to import XML stream
+ try
+ {
+ // create the dom parser
+ Reference<XDocumentBuilder> xDomBuilder(
+ getGlobalFactory()->createInstance(
+ CREATE_OUSTRING( "com.sun.star.xml.dom.DocumentBuilder" ) ),
+ UNO_QUERY_THROW );
+
+ // create DOM from fragment
+ xRet = xDomBuilder->parse(xInStrm);
+ }
+ catch( Exception& )
+ {
+ }
+
+ return xRet;
+}
+
+bool XmlFilterBase::importFragment( const ::rtl::Reference< FragmentHandler >& rxHandler,
+ const Reference< xml::sax::XFastSAXSerializable >& rxSerializer )
+{
+ Reference< XFastDocumentHandler > xDocHandler( rxHandler.get() );
+ if( !xDocHandler.is() )
+ return false;
+
+ // try to import XML stream
+ try
+ {
+ rxSerializer->fastSerialize( xDocHandler,
+ mxImpl->mxTokenHandler,
+ uno::Sequence< beans::StringPair >(),
+ NamespaceIds::get() );
+ return true;
+ }
+ catch( Exception& )
+ {}
+
+ return false;
+}
+
RelationsRef XmlFilterBase::importRelations( const OUString& rFragmentPath )
{
// try to find cached relations
@@ -565,6 +681,11 @@ XmlFilterBase& XmlFilterBase::exportDocumentProperties( Reference< XDocumentProp
return *this;
}
+::oox::drawingml::chart::ChartConverter* XmlFilterBase::getChartConverter()
+{
+ return 0;
+}
+
// protected ------------------------------------------------------------------
Reference< XInputStream > XmlFilterBase::implGetInputStream( MediaDescriptor& rMediaDesc ) const
diff --git a/oox/source/drawingml/chart/chartspaceconverter.cxx b/oox/source/drawingml/chart/chartspaceconverter.cxx
index 33b823f676ae..94c92388b8d7 100644
--- a/oox/source/drawingml/chart/chartspaceconverter.cxx
+++ b/oox/source/drawingml/chart/chartspaceconverter.cxx
@@ -71,9 +71,12 @@ ChartSpaceConverter::~ChartSpaceConverter()
void ChartSpaceConverter::convertFromModel( const Reference< XShapes >& rxExternalPage, const Point& rChartPos )
{
+ if( !getChartConverter() )
+ return;
+
/* create data provider (virtual function in the ChartConverter class,
derived converters may create an external data provider) */
- getChartConverter().createDataProvider( getChartDocument() );
+ getChartConverter()->createDataProvider( getChartDocument() );
// attach number formatter of container document to data receiver
try
diff --git a/oox/source/drawingml/chart/converterbase.cxx b/oox/source/drawingml/chart/converterbase.cxx
index 52bd978cd3b8..7fce093822fe 100644
--- a/oox/source/drawingml/chart/converterbase.cxx
+++ b/oox/source/drawingml/chart/converterbase.cxx
@@ -262,9 +262,9 @@ XmlFilterBase& ConverterRoot::getFilter() const
return mxData->mrFilter;
}
-ChartConverter& ConverterRoot::getChartConverter() const
+ChartConverter* ConverterRoot::getChartConverter() const
{
- return mxData->mrConverter;
+ return &mxData->mrConverter;
}
Reference< XChartDocument > ConverterRoot::getChartDocument() const
diff --git a/oox/source/drawingml/chart/datasourceconverter.cxx b/oox/source/drawingml/chart/datasourceconverter.cxx
index 4c76b27b982e..1671c6caceb2 100644
--- a/oox/source/drawingml/chart/datasourceconverter.cxx
+++ b/oox/source/drawingml/chart/datasourceconverter.cxx
@@ -54,12 +54,15 @@ DataSequenceConverter::~DataSequenceConverter()
Reference< XDataSequence > DataSequenceConverter::createDataSequence( const OUString& rRole )
{
// create data sequence from data source model (virtual call at chart converter)
- Reference< XDataSequence > xDataSeq = getChartConverter().createDataSequence( getChartDocument()->getDataProvider(), mrModel );
-
- // set sequence role
- PropertySet aSeqProp( xDataSeq );
- aSeqProp.setProperty( PROP_Role, rRole );
+ Reference< XDataSequence > xDataSeq;
+ if( getChartConverter() )
+ {
+ xDataSeq = getChartConverter()->createDataSequence( getChartDocument()->getDataProvider(), mrModel );
+ // set sequen ce role
+ PropertySet aSeqProp( xDataSeq );
+ aSeqProp.setProperty( PROP_Role, rRole );
+ }
return xDataSeq;
}
diff --git a/oox/source/drawingml/clrscheme.cxx b/oox/source/drawingml/clrscheme.cxx
index b7e558266372..4aea4fe6e2ba 100644
--- a/oox/source/drawingml/clrscheme.cxx
+++ b/oox/source/drawingml/clrscheme.cxx
@@ -26,6 +26,7 @@
*
************************************************************************/
+#include <osl/diagnose.h>
#include "oox/drawingml/clrscheme.hxx"
#include "tokens.hxx"
@@ -62,6 +63,7 @@ ClrScheme::~ClrScheme()
sal_Bool ClrScheme::getColor( sal_Int32 nSchemeClrToken, sal_Int32& rColor ) const
{
+ OSL_ASSERT((nSchemeClrToken & sal_Int32(0xFFFF0000))==0);
switch( nSchemeClrToken )
{
case XML_bg1 : nSchemeClrToken = XML_lt1; break;
diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx
index 70f4d54e99ca..566b83daa467 100644
--- a/oox/source/drawingml/color.cxx
+++ b/oox/source/drawingml/color.cxx
@@ -382,6 +382,7 @@ sal_Int32 Color::getColor( const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr
{
for( TransformVec::const_iterator aIt = maTransforms.begin(), aEnd = maTransforms.end(); aIt != aEnd; ++aIt )
{
+ OSL_ASSERT((aIt->mnToken & sal_Int32(0xFFFF0000))==0);
switch( aIt->mnToken )
{
case XML_red: toCrgb(); lclSetValue( mnC1, aIt->mnValue ); break;
diff --git a/oox/source/drawingml/customshapegeometry.cxx b/oox/source/drawingml/customshapegeometry.cxx
index d1e86de16e9b..dacb7f17b298 100644
--- a/oox/source/drawingml/customshapegeometry.cxx
+++ b/oox/source/drawingml/customshapegeometry.cxx
@@ -1172,8 +1172,9 @@ Path2DListContext::Path2DListContext( ContextHandler& rParent, CustomShapeProper
// ---------------------------------------------------------------------
-OUString GetShapeType( sal_Int32 nType )
+OUString GetShapePresetType( sal_Int32 nType )
{
+ OSL_ASSERT((nType & sal_Int32(0xFFFF0000))==0);
OUString sType;
switch( nType )
{
@@ -1801,6 +1802,7 @@ OUString GetShapeType( sal_Int32 nType )
static OUString GetTextShapeType( sal_Int32 nType )
{
+ OSL_ASSERT((nType & sal_Int32(0xFFFF0000))==0);
OUString sType;
switch( nType )
{
@@ -2031,7 +2033,7 @@ PresetShapeGeometryContext::PresetShapeGeometryContext( ContextHandler& rParent,
OUString sShapeType;
sal_Int32 nShapeType = xAttribs->getOptionalValueToken( XML_prst, FastToken::DONTKNOW );
if ( nShapeType != FastToken::DONTKNOW )
- sShapeType = GetShapeType( nShapeType );
+ sShapeType = GetShapePresetType( nShapeType );
OSL_ENSURE( sShapeType.getLength(), "oox::drawingml::CustomShapeCustomGeometryContext::CustomShapeCustomGeometryContext(), unknown shape type" );
mrCustomShapeProperties.setShapePresetType( sShapeType );
}
diff --git a/oox/source/drawingml/diagram/datamodelcontext.cxx b/oox/source/drawingml/diagram/datamodelcontext.cxx
index d7c88b69af89..26da02281c8a 100644
--- a/oox/source/drawingml/diagram/datamodelcontext.cxx
+++ b/oox/source/drawingml/diagram/datamodelcontext.cxx
@@ -26,7 +26,7 @@
*
************************************************************************/
-#include "oox/drawingml/diagram/datamodelcontext.hxx"
+#include "datamodelcontext.hxx"
#include "oox/helper/attributelist.hxx"
#include "oox/core/namespaces.hxx"
#include "oox/drawingml/fillpropertiesgroupcontext.hxx"
@@ -42,40 +42,46 @@ namespace oox { namespace drawingml {
-// CL_Cxn
-class CxnContext
+// CT_CxnList
+class CxnListContext
: public ContextHandler
{
public:
- CxnContext( ContextHandler& rParent,
- const Reference< XFastAttributeList >& xAttribs,
- const dgm::ConnectionPtr & pConnection )
+ CxnListContext( ContextHandler& rParent,
+ dgm::Connections & aConnections )
: ContextHandler( rParent )
- , mpConnection( pConnection )
+ , mrConnections( aConnections )
{
- sal_Int32 nType = xAttribs->getOptionalValueToken( XML_type, XML_parOf );
- pConnection->mnType = nType;
- pConnection->msModelId = xAttribs->getOptionalValue( XML_modelId );
- pConnection->msSourceId = xAttribs->getOptionalValue( XML_srcId );
- pConnection->msDestId = xAttribs->getOptionalValue( XML_destId );
- pConnection->msPresId = xAttribs->getOptionalValue( XML_presId );
- pConnection->msSibTransId = xAttribs->getOptionalValue( XML_sibTransId );
- AttributeList attribs( xAttribs );
- pConnection->mnSourceOrder = attribs.getInteger( XML_srcOrd, 0 );
- pConnection->mnDestOrder = attribs.getInteger( XML_destOrd, 0 );
}
-
virtual Reference< XFastContextHandler > SAL_CALL
createFastChildContext( sal_Int32 aElementToken,
- const Reference< XFastAttributeList >& /*xAttribs*/ )
+ const Reference< XFastAttributeList >& xAttribs )
throw (SAXException, RuntimeException)
{
Reference< XFastContextHandler > xRet;
switch( aElementToken )
{
- case NMSP_DIAGRAM|XML_extLst:
+ case NMSP_DIAGRAM|XML_cxn:
+ {
+ mrConnections.push_back( dgm::Connection() );
+ dgm::Connection& rConnection=mrConnections.back();
+
+ const sal_Int32 nType = xAttribs->getOptionalValueToken( XML_type, XML_parOf );
+ rConnection.mnType = nType;
+ rConnection.msModelId = xAttribs->getOptionalValue( XML_modelId );
+ rConnection.msSourceId = xAttribs->getOptionalValue( XML_srcId );
+ rConnection.msDestId = xAttribs->getOptionalValue( XML_destId );
+ rConnection.msPresId = xAttribs->getOptionalValue( XML_presId );
+ rConnection.msSibTransId = xAttribs->getOptionalValue( XML_sibTransId );
+ rConnection.msParTransId = xAttribs->getOptionalValue( XML_parTransId );
+ const AttributeList attribs( xAttribs );
+ rConnection.mnSourceOrder = attribs.getInteger( XML_srcOrd, 0 );
+ rConnection.mnDestOrder = attribs.getInteger( XML_destOrd, 0 );
+
+ // skip CT_extLst
return xRet;
+ }
default:
break;
}
@@ -83,37 +89,136 @@ public:
xRet.set( this );
return xRet;
}
+
private:
- dgm::ConnectionPtr mpConnection;
+ dgm::Connections& mrConnections;
};
-// CT_CxnList
-class CxnListContext
+// CT_presLayoutVars
+class PresLayoutVarsContext
: public ContextHandler
{
public:
- CxnListContext( ContextHandler& rParent, dgm::Connections & aConnections )
- : ContextHandler( rParent )
- , maConnections( aConnections )
+ PresLayoutVarsContext( ContextHandler& rParent,
+ dgm::Point & rPoint ) :
+ ContextHandler( rParent ),
+ mrPoint( rPoint )
+ {
+ }
+ virtual Reference< XFastContextHandler > SAL_CALL
+ createFastChildContext( sal_Int32 aElementToken,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
{
+ Reference< XFastContextHandler > xRet;
+ AttributeList aAttribs( xAttribs );
+
+ switch( aElementToken )
+ {
+ // TODO
+ case NMSP_DIAGRAM|XML_animLvl:
+ case NMSP_DIAGRAM|XML_animOne:
+ break;
+ case NMSP_DIAGRAM|XML_bulletEnabled:
+ mrPoint.mbBulletEnabled = aAttribs.getBool( XML_val, false );
+ break;
+ case NMSP_DIAGRAM|XML_chMax:
+ mrPoint.mnMaxChildren = aAttribs.getInteger( XML_val, -1 );
+ break;
+ case NMSP_DIAGRAM|XML_chPref:
+ mrPoint.mnPreferredChildren = aAttribs.getInteger( XML_val, -1 );
+ break;
+ case NMSP_DIAGRAM|XML_dir:
+ mrPoint.mnDirection = aAttribs.getToken( XML_val, XML_norm );
+ break;
+ case NMSP_DIAGRAM|XML_hierBranch:
+ mrPoint.mnHierarchyBranch = aAttribs.getToken( XML_val, XML_std );
+ break;
+ case NMSP_DIAGRAM|XML_orgChart:
+ mrPoint.mbOrgChartEnabled = aAttribs.getBool( XML_val, false );
+ break;
+ case NMSP_DIAGRAM|XML_resizeHandles:
+ mrPoint.mnResizeHandles = aAttribs.getToken( XML_val, XML_rel );
+ break;
+ default:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
}
+
+private:
+ dgm::Point& mrPoint;
+};
+
+
+// CT_prSet
+class PropertiesContext
+ : public ContextHandler
+{
+public:
+ PropertiesContext( ContextHandler& rParent,
+ dgm::Point & rPoint,
+ const Reference< XFastAttributeList >& xAttribs ) :
+ ContextHandler( rParent ),
+ mrPoint( rPoint )
+ {
+ OUString aEmptyStr;
+ AttributeList aAttribs( xAttribs );
+
+ mrPoint.msColorTransformCategoryId = aAttribs.getString( XML_csCatId, aEmptyStr );
+ mrPoint.msColorTransformTypeId = aAttribs.getString( XML_csTypeId, aEmptyStr );
+ mrPoint.msLayoutCategoryId = aAttribs.getString( XML_loCatId, aEmptyStr );
+ mrPoint.msLayoutTypeId = aAttribs.getString( XML_loTypeId, aEmptyStr );
+ mrPoint.msPlaceholderText = aAttribs.getString( XML_phldrT, aEmptyStr );
+ mrPoint.msPresentationAssociationId = aAttribs.getString( XML_presAssocID, aEmptyStr );
+ mrPoint.msPresentationLayoutName = aAttribs.getString( XML_presName, aEmptyStr );
+ mrPoint.msPresentationLayoutStyleLabel = aAttribs.getString( XML_presStyleLbl, aEmptyStr );
+ mrPoint.msQuickStyleCategoryId = aAttribs.getString( XML_qsCatId, aEmptyStr );
+ mrPoint.msQuickStyleTypeId = aAttribs.getString( XML_qsTypeId, aEmptyStr );
+
+ mrPoint.mnCustomAngle = aAttribs.getInteger( XML_custAng, -1 );
+ mrPoint.mnPercentageNeighbourWidth = aAttribs.getInteger( XML_custLinFactNeighborX, -1 );
+ mrPoint.mnPercentageNeighbourHeight = aAttribs.getInteger( XML_custLinFactNeighborY, -1 );
+ mrPoint.mnPercentageOwnWidth = aAttribs.getInteger( XML_custLinFactX, -1 );
+ mrPoint.mnPercentageOwnHeight = aAttribs.getInteger( XML_custLinFactY, -1 );
+ mrPoint.mnIncludeAngleScale = aAttribs.getInteger( XML_custRadScaleInc, -1 );
+ mrPoint.mnRadiusScale = aAttribs.getInteger( XML_custRadScaleRad, -1 );
+ mrPoint.mnWidthScale = aAttribs.getInteger( XML_custScaleX, -1 );
+ mrPoint.mnHeightScale = aAttribs.getInteger( XML_custScaleY, -1 );
+ mrPoint.mnWidthOverride = aAttribs.getInteger( XML_custSzX, -1 );
+ mrPoint.mnHeightOverride = aAttribs.getInteger( XML_custSzY, -1 );
+ mrPoint.mnLayoutStyleCount = aAttribs.getInteger( XML_presStyleCnt, -1 );
+ mrPoint.mnLayoutStyleIndex = aAttribs.getInteger( XML_presStyleIdx, -1 );
+
+ mrPoint.mbCoherent3DOffset = aAttribs.getBool( XML_coherent3DOff, false );
+ mrPoint.mbCustomHorizontalFlip = aAttribs.getBool( XML_custFlipHor, false );
+ mrPoint.mbCustomVerticalFlip = aAttribs.getBool( XML_custFlipVert, false );
+ mrPoint.mbCustomText = aAttribs.getBool( XML_custT, false );
+ mrPoint.mbIsPlaceholder = aAttribs.getBool( XML_phldr, false );
+ }
virtual Reference< XFastContextHandler > SAL_CALL
createFastChildContext( sal_Int32 aElementToken,
- const Reference< XFastAttributeList >& xAttribs )
+ const Reference< XFastAttributeList >& )
throw (SAXException, RuntimeException)
{
Reference< XFastContextHandler > xRet;
switch( aElementToken )
{
- case NMSP_DIAGRAM|XML_cxn:
+ case NMSP_DIAGRAM|XML_presLayoutVars:
{
- dgm::ConnectionPtr pConnection( new dgm::Connection() );
- maConnections.push_back( pConnection );
- xRet.set( new CxnContext( *this, xAttribs, pConnection ) );
+ xRet.set( new PresLayoutVarsContext( *this, mrPoint ) );
break;
}
+ case NMSP_DIAGRAM|XML_style:
+ {
+ // TODO
+ // skip CT_shapeStyle
+ return xRet;
+ }
default:
break;
}
@@ -123,11 +228,10 @@ public:
}
private:
- dgm::Connections & maConnections;
+ dgm::Point& mrPoint;
};
-
// CL_Pt
class PtContext
: public ContextHandler
@@ -135,27 +239,25 @@ class PtContext
public:
PtContext( ContextHandler& rParent,
const Reference< XFastAttributeList >& xAttribs,
- const dgm::PointPtr & pPoint)
- : ContextHandler( rParent )
- , mpPoint( pPoint )
- {
- mpPoint->setModelId( xAttribs->getOptionalValue( XML_modelId ) );
- //
- // the default type is XML_node
- sal_Int32 nType = xAttribs->getOptionalValueToken( XML_type, XML_node );
- mpPoint->setType( nType );
-
- // ignore the cxnId unless it is this type. See 5.15.3.1.3 in Primer
- if( ( nType == XML_parTrans ) || ( nType == XML_sibTrans ) )
- {
- mpPoint->setCnxId( xAttribs->getOptionalValue( XML_cxnId ) );
- }
- }
+ dgm::Point & rPoint):
+ ContextHandler( rParent ),
+ mrPoint( rPoint )
+ {
+ mrPoint.msModelId = xAttribs->getOptionalValue( XML_modelId );
+
+ // the default type is XML_node
+ const sal_Int32 nType = xAttribs->getOptionalValueToken( XML_type, XML_node );
+ mrPoint.mnType = nType;
+
+ // ignore the cxnId unless it is this type. See 5.15.3.1.3 in Primer
+ if( ( nType == XML_parTrans ) || ( nType == XML_sibTrans ) )
+ mrPoint.msCnxId = xAttribs->getOptionalValue( XML_cxnId );
+ }
virtual Reference< XFastContextHandler > SAL_CALL
createFastChildContext( sal_Int32 aElementToken,
- const Reference< XFastAttributeList >& /*xAttribs*/ )
+ const Reference< XFastAttributeList >& xAttribs )
throw (SAXException, RuntimeException)
{
Reference< XFastContextHandler > xRet;
@@ -165,18 +267,22 @@ public:
case NMSP_DIAGRAM|XML_extLst:
return xRet;
case NMSP_DIAGRAM|XML_prSet:
- // TODO
- // CT_ElemPropSet
+ OSL_TRACE( "diagram property set for point");
+ xRet = new PropertiesContext( *this, mrPoint, xAttribs );
break;
case NMSP_DIAGRAM|XML_spPr:
OSL_TRACE( "shape props for point");
- xRet = new ShapePropertiesContext( *this, *mpPoint->getShape() );
+ if( !mrPoint.mpShape )
+ mrPoint.mpShape.reset( new Shape() );
+ xRet = new ShapePropertiesContext( *this, *(mrPoint.mpShape) );
break;
case NMSP_DIAGRAM|XML_t:
{
OSL_TRACE( "shape text body for point");
TextBodyPtr xTextBody( new TextBody );
- mpPoint->getShape()->setTextBody( xTextBody );
+ if( !mrPoint.mpShape )
+ mrPoint.mpShape.reset( new Shape() );
+ mrPoint.mpShape->setTextBody( xTextBody );
xRet = new TextBodyContext( *this, *xTextBody );
break;
}
@@ -189,7 +295,7 @@ public:
}
private:
- dgm::PointPtr mpPoint;
+ dgm::Point& mrPoint;
};
@@ -199,11 +305,10 @@ class PtListContext
: public ContextHandler
{
public:
- PtListContext( ContextHandler& rParent, dgm::Points & aPoints)
- : ContextHandler( rParent )
- , maPoints( aPoints )
- {
- }
+ PtListContext( ContextHandler& rParent, dgm::Points& rPoints) :
+ ContextHandler( rParent ),
+ mrPoints( rPoints )
+ {}
virtual Reference< XFastContextHandler > SAL_CALL
createFastChildContext( sal_Int32 aElementToken,
const Reference< XFastAttributeList >& xAttribs )
@@ -216,9 +321,8 @@ public:
case NMSP_DIAGRAM|XML_pt:
{
// CT_Pt
- dgm::PointPtr pPoint( new dgm::Point() );
- maPoints.push_back( pPoint );
- xRet.set( new PtContext( *this, xAttribs, pPoint ) );
+ mrPoints.push_back( dgm::Point() );
+ xRet.set( new PtContext( *this, xAttribs, mrPoints.back() ) );
break;
}
default:
@@ -230,7 +334,7 @@ public:
}
private:
- dgm::Points & maPoints;
+ dgm::Points& mrPoints;
};
// CT_BackgroundFormatting
diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx
index 2e507d87752b..8a78ddc8d020 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -32,10 +32,22 @@
#include <com/sun/star/awt/Point.hpp>
#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/xml/dom/XDocument.hpp>
+#include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
+#include <rtl/ustrbuf.hxx>
+#include "oox/drawingml/textbody.hxx"
+#include "oox/drawingml/textparagraph.hxx"
+#include "oox/drawingml/textrun.hxx"
#include "oox/drawingml/diagram/diagram.hxx"
#include "oox/drawingml/fillproperties.hxx"
#include "oox/core/namespaces.hxx"
#include "tokens.hxx"
+#include "diagram.hxx"
+#include "diagramlayoutatoms.hxx"
+#include "diagramfragmenthandler.hxx"
+
+#include <iostream>
+#include <fstream>
using rtl::OUString;
using namespace ::com::sun::star;
@@ -47,58 +59,26 @@ namespace dgm {
void Connection::dump()
{
- OSL_TRACE("dgm: cnx modelId %s, srcId %s, dstId %s",
+ OSL_TRACE("dgm: cnx modelId %s, srcId %s, dstId %s, parTransId %s, presId %s, sibTransId %s, srcOrd %d, dstOrd %d",
OUSTRING_TO_CSTR( msModelId ),
OUSTRING_TO_CSTR( msSourceId ),
- OUSTRING_TO_CSTR( msDestId ) );
-}
-
-Point::Point()
- : mpShape( new Shape( "com.sun.star.drawing.GraphicObjectShape" ) )
- , mnType( 0 )
-{
+ OUSTRING_TO_CSTR( msDestId ),
+ OUSTRING_TO_CSTR( msParTransId ),
+ OUSTRING_TO_CSTR( msPresId ),
+ OUSTRING_TO_CSTR( msSibTransId ),
+ mnSourceOrder,
+ mnDestOrder );
}
void Point::dump()
{
- OSL_TRACE( "dgm: pt cnxId %s, modelId %s",
+ OSL_TRACE( "dgm: pt text %x, cnxId %s, modelId %s, type %d",
+ mpShape.get(),
OUSTRING_TO_CSTR( msCnxId ),
- OUSTRING_TO_CSTR( msModelId ) );
-}
-
-void Point::setModelId( const ::rtl::OUString & sModelId )
-{
- msModelId = sModelId;
- mpShape->setName( msModelId );
-}
-
-
-bool PointsTree::addChild( const PointsTreePtr & pChild )
-{
- bool added = false;
-
- OSL_ENSURE( pChild->mpParent.expired(), "can't add, has already a parent" );
- OSL_ENSURE( mpNode, "has no node" );
- if( mpNode && pChild->mpParent.expired() )
- {
- pChild->mpParent = shared_from_this();
- maChildrens.push_back( pChild );
- added = true;
- }
-
- return added;
+ OUSTRING_TO_CSTR( msModelId ),
+ mnType );
}
-PointsTreePtr PointsTree::getParent() const
-{
- if( !mpParent.expired() )
- {
- return mpParent.lock() ;
- }
- return PointsTreePtr();
-}
-
-
} // dgm namespace
DiagramData::DiagramData()
@@ -116,18 +96,10 @@ void DiagramData::dump()
boost::bind( &dgm::Point::dump, _1 ) );
}
-static void setPosition( const dgm::PointPtr & pPoint, const awt::Point & pt )
-{
- ShapePtr pShape = pPoint->getShape();
- awt::Size sz;
- sz.Width = 50;
- sz.Height = 50;
- pShape->setPosition( pt );
- pShape->setSize( sz );
-}
-
-void DiagramLayout::layout( const dgm::PointsTreePtr & pTree, const awt::Point & pt )
+void DiagramLayout::layout( const dgm::Points & /*pTree*/, const awt::Point & /*pt*/ )
{
+ // TODO
+#if 0
setPosition( pTree->getPoint(), pt );
awt::Point nextPt = pt;
nextPt.Y += 50;
@@ -137,6 +109,7 @@ void DiagramLayout::layout( const dgm::PointsTreePtr & pTree, const awt::Point &
layout( *iter, nextPt );
nextPt.X += 50;
}
+#endif
}
void Diagram::setData( const DiagramDataPtr & pData)
@@ -150,19 +123,244 @@ void Diagram::setLayout( const DiagramLayoutPtr & pLayout)
mpLayout = pLayout;
}
-void Diagram::setQStyles( const DiagramQStylesPtr & pStyles)
+#if OSL_DEBUG_LEVEL > 1
+rtl::OString normalizeDotName( const rtl::OUString& rStr )
{
- mpQStyles = pStyles;
-}
+ rtl::OUStringBuffer aBuf;
+ aBuf.append((sal_Unicode)'N');
+ const sal_Int32 nLen(rStr.getLength());
+ sal_Int32 nCurrIndex(0);
+ while( nCurrIndex < nLen )
+ {
+ const sal_Int32 aChar=rStr.iterateCodePoints(&nCurrIndex);
+ if( aChar != '-' && aChar != '{' && aChar != '}' )
+ aBuf.append((sal_Unicode)aChar);
+ }
-void Diagram::setColors( const DiagramColorsPtr & pColors)
+ return rtl::OUStringToOString(aBuf.makeStringAndClear(),
+ RTL_TEXTENCODING_UTF8);
+}
+#endif
+
+static sal_Int32 calcDepth( const rtl::OUString& rNodeName,
+ const dgm::Connections& rCnx )
{
- mpColors = pColors;
+ // find length of longest path in 'isChild' graph, ending with rNodeName
+ dgm::Connections::const_iterator aCurrCxn( rCnx.begin() );
+ const dgm::Connections::const_iterator aEndCxn( rCnx.end() );
+ while( aCurrCxn != aEndCxn )
+ {
+ if( aCurrCxn->msParTransId.getLength() &&
+ aCurrCxn->msSibTransId.getLength() &&
+ aCurrCxn->msSourceId.getLength() &&
+ aCurrCxn->msDestId.getLength() &&
+ aCurrCxn->mnType != XML_presOf &&
+ aCurrCxn->mnType != XML_presParOf &&
+ rNodeName == aCurrCxn->msDestId )
+ {
+ return calcDepth(aCurrCxn->msSourceId,
+ rCnx) + 1;
+ }
+ ++aCurrCxn;
+ }
+
+ return 0;
}
+
void Diagram::build( )
{
+ // build name-object maps
+ // ======================
+
+#if OSL_DEBUG_LEVEL > 1
+ std::ofstream output("/tmp/tree.dot");
+
+ output << "digraph datatree {" << std::endl;
+#endif
+
+ dgm::Points::iterator aCurrPoint( getData()->getPoints( ).begin() );
+ const dgm::Points::iterator aEndPoint( getData()->getPoints( ).end() );
+ while( aCurrPoint != aEndPoint )
+ {
+#if OSL_DEBUG_LEVEL > 1
+ output << "\t"
+ << normalizeDotName(aCurrPoint->msModelId).getStr()
+ << "[";
+
+ if( aCurrPoint->msPresentationLayoutName.getLength() )
+ output << "label=\""
+ << rtl::OUStringToOString(
+ aCurrPoint->msPresentationLayoutName,
+ RTL_TEXTENCODING_UTF8).getStr() << "\", ";
+ else
+ output << "label=\""
+ << rtl::OUStringToOString(
+ aCurrPoint->msModelId,
+ RTL_TEXTENCODING_UTF8).getStr() << "\", ";
+
+ switch( aCurrPoint->mnType )
+ {
+ case XML_doc: output << "style=filled, color=red"; break;
+ case XML_asst: output << "style=filled, color=green"; break;
+ default:
+ case XML_node: output << "style=filled, color=blue"; break;
+ case XML_pres: output << "style=filled, color=yellow"; break;
+ case XML_parTrans: output << "color=grey"; break;
+ case XML_sibTrans: output << " "; break;
+ }
+
+ output << "];" << std::endl;
+
+ // does currpoint have any text set?
+ if( aCurrPoint->mpShape &&
+ aCurrPoint->mpShape->getTextBody() &&
+ !aCurrPoint->mpShape->getTextBody()->getParagraphs().empty() &&
+ !aCurrPoint->mpShape->getTextBody()->getParagraphs().front()->getRuns().empty() )
+ {
+ static sal_Int32 nCount=0;
+
+ output << "\t"
+ << "textNode" << nCount
+ << " ["
+ << "label=\""
+ << rtl::OUStringToOString(
+ aCurrPoint->mpShape->getTextBody()->getParagraphs().front()->getRuns().front()->getText(),
+ RTL_TEXTENCODING_UTF8).getStr()
+ << "\"" << "];" << std::endl;
+ output << "\t"
+ << normalizeDotName(aCurrPoint->msModelId).getStr()
+ << " -> "
+ << "textNode" << nCount++
+ << ";" << std::endl;
+ }
+
+
+#if 0
+ // msPresentationAssociationId does not appear to be
+ // valid/used, the relation this imposed for several examples
+ // was ~broken
+ if( aCurrPoint->msPresentationAssociationId.getLength() )
+ output << "\t"
+ << normalizeDotName(aCurrPoint->msModelId).getStr()
+ << " -> "
+ << normalizeDotName(aCurrPoint->msPresentationAssociationId).getStr()
+ << " [style=dotted, color=red, "
+ << "label=\"presAssocID\"];" << std::endl;
+#endif
+
+#endif
+
+ const bool bInserted1=getData()->getPointNameMap().insert(
+ std::make_pair(aCurrPoint->msModelId,&(*aCurrPoint))).second;
+ (void)bInserted1;
+
+ OSL_ENSURE(bInserted1,"Diagram::build(): non-unique point model id");
+
+ if( aCurrPoint->msPresentationLayoutName.getLength() )
+ {
+ DiagramData::PointsNameMap::value_type::second_type& rVec=
+ getData()->getPointsPresNameMap()[aCurrPoint->msPresentationLayoutName];
+ rVec.push_back(&(*aCurrPoint));
+ }
+ ++aCurrPoint;
+ }
+
+ dgm::Connections::const_iterator aCurrCxn( getData()->getConnections( ).begin() );
+ const dgm::Connections::const_iterator aEndCxn( getData()->getConnections( ).end() );
+ while( aCurrCxn != aEndCxn )
+ {
+#if OSL_DEBUG_LEVEL > 1
+ if( aCurrCxn->msParTransId.getLength() ||
+ aCurrCxn->msSibTransId.getLength() )
+ {
+ if( aCurrCxn->msSourceId.getLength() ||
+ aCurrCxn->msDestId.getLength() )
+ {
+ output << "\t"
+ << normalizeDotName(aCurrCxn->msSourceId).getStr()
+ << " -> "
+ << normalizeDotName(aCurrCxn->msParTransId).getStr()
+ << " -> "
+ << normalizeDotName(aCurrCxn->msSibTransId).getStr()
+ << " -> "
+ << normalizeDotName(aCurrCxn->msDestId).getStr()
+ << " [style=dotted,"
+ << ((aCurrCxn->mnType == XML_presOf) ? " color=red, " : ((aCurrCxn->mnType == XML_presParOf) ? " color=green, " : " "))
+ << "label=\""
+ << rtl::OUStringToOString(aCurrCxn->msModelId,
+ RTL_TEXTENCODING_UTF8 ).getStr()
+ << "\"];" << std::endl;
+ }
+ else
+ {
+ output << "\t"
+ << normalizeDotName(aCurrCxn->msParTransId).getStr()
+ << " -> "
+ << normalizeDotName(aCurrCxn->msSibTransId).getStr()
+ << " ["
+ << ((aCurrCxn->mnType == XML_presOf) ? " color=red, " : ((aCurrCxn->mnType == XML_presParOf) ? " color=green, " : " "))
+ << "label=\""
+ << rtl::OUStringToOString(aCurrCxn->msModelId,
+ RTL_TEXTENCODING_UTF8 ).getStr()
+ << "\"];" << std::endl;
+ }
+ }
+ else if( aCurrCxn->msSourceId.getLength() ||
+ aCurrCxn->msDestId.getLength() )
+ output << "\t"
+ << normalizeDotName(aCurrCxn->msSourceId).getStr()
+ << " -> "
+ << normalizeDotName(aCurrCxn->msDestId).getStr()
+ << " [label=\""
+ << rtl::OUStringToOString(aCurrCxn->msModelId,
+ RTL_TEXTENCODING_UTF8 ).getStr()
+ << ((aCurrCxn->mnType == XML_presOf) ? "\", color=red]" : ((aCurrCxn->mnType == XML_presParOf) ? "\", color=green]" : "\"]"))
+ << ";" << std::endl;
+#endif
+
+ const bool bInserted1=getData()->getConnectionNameMap().insert(
+ std::make_pair(aCurrCxn->msModelId,&(*aCurrCxn))).second;
+ (void)bInserted1;
+
+ OSL_ENSURE(bInserted1,"Diagram::build(): non-unique connection model id");
+
+ if( aCurrCxn->mnType == XML_presOf )
+ {
+ DiagramData::StringMap::value_type::second_type& rVec=getData()->getPresOfNameMap()[aCurrCxn->msDestId];
+ rVec.push_back(
+ std::make_pair(
+ aCurrCxn->msSourceId,sal_Int32(0)));
+ }
+
+ ++aCurrCxn;
+ }
+
+ // assign outline levels
+ DiagramData::StringMap::iterator aPresOfIter=getData()->getPresOfNameMap().begin();
+ const DiagramData::StringMap::iterator aPresOfEnd=getData()->getPresOfNameMap().end();
+ while( aPresOfIter != aPresOfEnd )
+ {
+ DiagramData::StringMap::value_type::second_type::iterator aPresOfNodeIterCalcLevel=aPresOfIter->second.begin();
+ const DiagramData::StringMap::value_type::second_type::iterator aPresOfNodeEnd=aPresOfIter->second.end();
+ while(aPresOfNodeIterCalcLevel != aPresOfNodeEnd)
+ {
+ const sal_Int32 nDepth=calcDepth(aPresOfNodeIterCalcLevel->first,
+ getData()->getConnections());
+ aPresOfNodeIterCalcLevel->second = nDepth != 0 ? nDepth : -1;
+ ++aPresOfNodeIterCalcLevel;
+ }
+
+ ++aPresOfIter;
+ }
+
+#if OSL_DEBUG_LEVEL > 1
+ output << "}" << std::endl;
+#endif
+
+ // TODO
+#if 0
OSL_TRACE( "building diagram" );
typedef std::map< OUString, dgm::PointPtr > PointsMap;
PointsMap aPointsMap;
@@ -238,30 +436,33 @@ void Diagram::build( )
}
// check bounds
OSL_ENSURE( aRoots.size() == 1, "more than one root" );
- // #i92239# roots may be empty
- if( !aRoots.empty() )
+ mpRoot = aRoots.begin()->second;
+ OSL_TRACE( "root is %s", OUSTRING_TO_CSTR( mpRoot->getPoint()->getModelId() ) );
+ for( PointsTreeMap::iterator iter = aTreeMap.begin();
+ iter != aTreeMap.end(); iter++ )
{
- mpRoot = aRoots.begin()->second;
- OSL_TRACE( "root is %s", OUSTRING_TO_CSTR( mpRoot->getPoint()->getModelId() ) );
- for( PointsTreeMap::iterator iter = aTreeMap.begin();
- iter != aTreeMap.end(); iter++ )
+ if(! iter->second->getParent() )
{
- if(! iter->second->getParent() )
- {
- OSL_TRACE("node without parent %s", OUSTRING_TO_CSTR( iter->first ) );
- }
+ OSL_TRACE("node without parent %s", OUSTRING_TO_CSTR( iter->first ) );
}
}
+#endif
}
void Diagram::addTo( const ShapePtr & pParentShape )
{
+ // collect data, init maps
+ build( );
+
+ // create Shape hierarchy
+ ShapeCreationVisitor aCreationVisitor(pParentShape, *this);
+ mpLayout->getNode()->accept(aCreationVisitor);
+
+#if 0
dgm::Points & aPoints( mpData->getPoints( ) );
dgm::Points::iterator aPointsIter;
- build( );
- if( mpRoot.get() )
- mpLayout->layout( mpRoot, awt::Point( 0, 0 ) );
+ mpLayout->layout( mpRoot, awt::Point( 0, 0 ) );
for( aPointsIter = aPoints.begin(); aPointsIter != aPoints.end(); ++aPointsIter )
{
@@ -284,6 +485,7 @@ void Diagram::addTo( const ShapePtr & pParentShape )
{
OSL_TRACE( "Dgm: shape name %s", OUSTRING_TO_CSTR( (*iter)->getName() ) );
}
+#endif
}
OUString Diagram::getLayoutId() const
@@ -296,6 +498,156 @@ OUString Diagram::getLayoutId() const
return sLayoutId;
}
+uno::Reference<xml::dom::XDocument> loadFragment(
+ core::XmlFilterBase& rFilter,
+ const rtl::Reference< core::FragmentHandler >& rxHandler )
+{
+ // load diagramming fragments into DOM representation, that later
+ // gets serialized back to SAX events and parsed
+ return rFilter.importFragment( rxHandler->getFragmentPath() );
+}
+
+void importFragment( core::XmlFilterBase& rFilter,
+ const uno::Reference<xml::dom::XDocument>& rXDom,
+ const char* /*pPropName*/,
+ const ShapePtr& /*pShape*/,
+ const rtl::Reference< core::FragmentHandler >& rxHandler )
+{
+ uno::Reference<xml::sax::XFastSAXSerializable> xSerializer(
+ rXDom, uno::UNO_QUERY_THROW);
+
+ // now serialize DOM tree into internal data structures
+ rFilter.importFragment( rxHandler, xSerializer );
+
+ // not yet
+#if 0
+ // tack XDocument onto shape
+ pShape->getShapeProperties().setProperty(
+ OUString::createFromAscii(pPropName),
+ rXDom);
+#endif
+}
+
+void loadDiagram( const ShapePtr& pShape,
+ core::XmlFilterBase& rFilter,
+ const ::rtl::OUString& rDataModelPath,
+ const ::rtl::OUString& rLayoutPath,
+ const ::rtl::OUString& rQStylePath,
+ const ::rtl::OUString& rColorStylePath )
+{
+ DiagramPtr pDiagram( new Diagram() );
+
+ DiagramDataPtr pData( new DiagramData() );
+ pDiagram->setData( pData );
+
+ DiagramLayoutPtr pLayout( new DiagramLayout() );
+ pDiagram->setLayout( pLayout );
+
+ // data
+ if( rDataModelPath.getLength() > 0 )
+ {
+ rtl::Reference< core::FragmentHandler > xRef(
+ new DiagramDataFragmentHandler( rFilter, rDataModelPath, pData ));
+
+ importFragment(rFilter,
+ loadFragment(rFilter,xRef),
+ "DiagramData",
+ pShape,
+ xRef);
+ }
+
+ // layout
+ if( rLayoutPath.getLength() > 0 )
+ {
+ rtl::Reference< core::FragmentHandler > xRef(
+ new DiagramLayoutFragmentHandler( rFilter, rLayoutPath, pLayout ));
+ importFragment(rFilter,
+ loadFragment(rFilter,xRef),
+ "DiagramLayout",
+ pShape,
+ xRef);
+ }
+
+ // style
+ if( rQStylePath.getLength() > 0 )
+ {
+ rtl::Reference< core::FragmentHandler > xRef(
+ new DiagramQStylesFragmentHandler( rFilter, rQStylePath, pDiagram->getStyles() ));
+ importFragment(rFilter,
+ loadFragment(rFilter,xRef),
+ "DiagramQStyle",
+ pShape,
+ xRef);
+ }
+
+ // colors
+ if( rColorStylePath.getLength() > 0 )
+ {
+ rtl::Reference< core::FragmentHandler > xRef(
+ new ColorFragmentHandler( rFilter, rColorStylePath, pDiagram->getColors() ));
+ importFragment(rFilter,
+ loadFragment(rFilter,xRef),
+ "DiagramColorStyle",
+ pShape,
+ xRef);
+ }
+
+ // diagram loaded. now lump together & attach to shape
+ pDiagram->addTo(pShape);
+}
+
+void loadDiagram( const ShapePtr& pShape,
+ core::XmlFilterBase& rFilter,
+ const uno::Reference<xml::dom::XDocument>& rXDataModelDom,
+ const uno::Reference<xml::dom::XDocument>& rXLayoutDom,
+ const uno::Reference<xml::dom::XDocument>& rXQStyleDom,
+ const uno::Reference<xml::dom::XDocument>& rXColorStyleDom )
+{
+ DiagramPtr pDiagram( new Diagram() );
+
+ DiagramDataPtr pData( new DiagramData() );
+ pDiagram->setData( pData );
+
+ DiagramLayoutPtr pLayout( new DiagramLayout() );
+ pDiagram->setLayout( pLayout );
+
+ OUString aEmpty;
+
+ // data
+ if( rXDataModelDom.is() )
+ importFragment(rFilter,
+ rXDataModelDom,
+ "DiagramData",
+ pShape,
+ new DiagramDataFragmentHandler( rFilter, aEmpty, pData ));
+
+ // layout
+ if( rXLayoutDom.is() )
+ importFragment(rFilter,
+ rXLayoutDom,
+ "DiagramLayout",
+ pShape,
+ new DiagramLayoutFragmentHandler( rFilter, aEmpty, pLayout ));
+
+ // style
+ if( rXQStyleDom.is() )
+ importFragment(rFilter,
+ rXQStyleDom,
+ "DiagramQStyle",
+ pShape,
+ new DiagramQStylesFragmentHandler( rFilter, aEmpty, pDiagram->getStyles() ));
+
+ // colors
+ if( rXColorStyleDom.is() )
+ importFragment(rFilter,
+ rXColorStyleDom,
+ "DiagramColorStyle",
+ pShape,
+ new ColorFragmentHandler( rFilter, aEmpty, pDiagram->getColors() ));
+
+ // diagram loaded. now lump together & attach to shape
+ pDiagram->addTo(pShape);
+}
} }
diff --git a/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx b/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
index d14535df509b..65e6c7531018 100644
--- a/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
+++ b/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
@@ -28,9 +28,8 @@
#include "diagramdefinitioncontext.hxx"
#include "oox/core/namespaces.hxx"
-#include "oox/helper/helper.hxx"
#include "layoutnodecontext.hxx"
-#include "oox/drawingml/diagram/datamodelcontext.hxx"
+#include "datamodelcontext.hxx"
#include "tokens.hxx"
using namespace ::oox::core;
@@ -88,9 +87,15 @@ DiagramDefinitionContext::createFastChildContext( ::sal_Int32 aElement,
mpLayout->setDesc( xAttribs->getOptionalValue( XML_val ) );
break;
case NMSP_DIAGRAM|XML_layoutNode:
- mpLayout->getNode().reset( new LayoutNode() );
- xRet.set( new LayoutNodeContext( *this, xAttribs, mpLayout->getNode() ) );
+ {
+ LayoutNodePtr pNode( new LayoutNode() );
+ mpLayout->getNode() = pNode;
+ pNode->setChildOrder( xAttribs->getOptionalValueToken( XML_chOrder, XML_b ) );
+ pNode->setMoveWith( xAttribs->getOptionalValue( XML_moveWith ) );
+ pNode->setStyleLabel( xAttribs->getOptionalValue( XML_styleLbl ) );
+ xRet.set( new LayoutNodeContext( *this, xAttribs, pNode ) );
break;
+ }
case NMSP_DIAGRAM|XML_clrData:
// TODO, does not matter for the UI. skip.
return xRet;
diff --git a/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx b/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx
index 99407aed80d3..d5f5db6f3197 100644
--- a/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx
+++ b/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx
@@ -29,7 +29,7 @@
#define OOX_DRAWINGML_DIAGRAMDEFINITIONCONTEXT_HXX
#include "oox/core/contexthandler.hxx"
-#include "oox/drawingml/diagram/diagram.hxx"
+#include "diagram.hxx"
namespace oox { namespace drawingml {
diff --git a/oox/source/drawingml/diagram/diagramfragmenthandler.cxx b/oox/source/drawingml/diagram/diagramfragmenthandler.cxx
index a739a0095a5f..17091ae2f6ed 100644
--- a/oox/source/drawingml/diagram/diagramfragmenthandler.cxx
+++ b/oox/source/drawingml/diagram/diagramfragmenthandler.cxx
@@ -28,11 +28,11 @@
#include <osl/diagnose.h>
-#include "oox/drawingml/diagram/diagramfragmenthandler.hxx"
-#include "oox/drawingml/diagram/datamodelcontext.hxx"
#include "oox/core/namespaces.hxx"
+#include "oox/drawingml/colorchoicecontext.hxx"
#include "diagramdefinitioncontext.hxx"
-#include "tokens.hxx"
+#include "diagramfragmenthandler.hxx"
+#include "datamodelcontext.hxx"
using namespace ::oox::core;
using namespace ::com::sun::star::xml::sax;
@@ -132,95 +132,144 @@ DiagramLayoutFragmentHandler::createFastChildContext( ::sal_Int32 aElement,
///////////////////////
DiagramQStylesFragmentHandler::DiagramQStylesFragmentHandler( XmlFilterBase& rFilter,
- const OUString& rFragmentPath,
- const DiagramQStylesPtr pDataPtr )
- throw( )
- : FragmentHandler( rFilter, rFragmentPath )
- , mpDataPtr( pDataPtr )
+ const OUString& rFragmentPath,
+ DiagramQStyleMap& rStylesMap ) :
+ FragmentHandler2( rFilter, rFragmentPath ),
+ maStyleName(),
+ maStyleEntry(),
+ mrStylesMap( rStylesMap )
+{}
+
+::oox::core::ContextHandlerRef DiagramQStylesFragmentHandler::createStyleMatrixContext(
+ sal_Int32 nElement,
+ const AttributeList& rAttribs,
+ ShapeStyleRef& o_rStyle )
{
+ o_rStyle.mnThemedIdx = (nElement == (NMSP_DRAWINGML|XML_fontRef)) ?
+ rAttribs.getToken( XML_idx, XML_none ) : rAttribs.getInteger( XML_idx, 0 );
+ return new ColorContext( *this, o_rStyle.maPhClr );
}
-DiagramQStylesFragmentHandler::~DiagramQStylesFragmentHandler( ) throw ()
-{
-
-}
-
-void SAL_CALL DiagramQStylesFragmentHandler::endDocument()
- throw (SAXException, RuntimeException)
+::oox::core::ContextHandlerRef DiagramQStylesFragmentHandler::onCreateContext( sal_Int32 nElement,
+ const AttributeList& rAttribs )
{
+ // state-table like way of navigating the color fragment. we
+ // currently ignore everything except styleLbl in the colorsDef
+ // element
+ switch( getCurrentElement() )
+ {
+ case XML_ROOT_CONTEXT:
+ return nElement == (NMSP_DIAGRAM|XML_styleDef) ? this : NULL;
+ case NMSP_DIAGRAM|XML_styleDef:
+ return nElement == (NMSP_DIAGRAM|XML_styleLbl) ? this : NULL;
+ case NMSP_DIAGRAM|XML_styleLbl:
+ return nElement == (NMSP_DIAGRAM|XML_style) ? this : NULL;
+ case NMSP_DIAGRAM|XML_style:
+ {
+ switch( nElement )
+ {
+ case NMSP_DRAWINGML|XML_lnRef : // CT_StyleMatrixReference
+ return createStyleMatrixContext(nElement,rAttribs,
+ maStyleEntry.maLineStyle);
+ case NMSP_DRAWINGML|XML_fillRef : // CT_StyleMatrixReference
+ return createStyleMatrixContext(nElement,rAttribs,
+ maStyleEntry.maFillStyle);
+ case NMSP_DRAWINGML|XML_effectRef : // CT_StyleMatrixReference
+ return createStyleMatrixContext(nElement,rAttribs,
+ maStyleEntry.maEffectStyle);
+ case NMSP_DRAWINGML|XML_fontRef : // CT_FontRe ference
+ return createStyleMatrixContext(nElement,rAttribs,
+ maStyleEntry.maTextStyle);
+ }
+ return 0;
+ }
+ }
+ return 0;
}
-
-Reference< XFastContextHandler > SAL_CALL
-DiagramQStylesFragmentHandler::createFastChildContext( ::sal_Int32 aElement,
- const Reference< XFastAttributeList >& )
- throw ( SAXException, RuntimeException)
+void DiagramQStylesFragmentHandler::onStartElement( const AttributeList& rAttribs )
{
- Reference< XFastContextHandler > xRet;
-
- switch( aElement )
+ if( getCurrentElement() == (NMSP_DIAGRAM|XML_styleLbl) )
{
- case NMSP_DIAGRAM|XML_styleDef:
- // TODO
- break;
- default:
- break;
+ maStyleName = rAttribs.getString( XML_name, OUString() );
+ maStyleEntry = mrStylesMap[maStyleName];
}
-
- if( !xRet.is() )
- xRet = getFastContextHandler();
-
- return xRet;
}
-/////////////////////
-
-DiagramColorsFragmentHandler::DiagramColorsFragmentHandler( XmlFilterBase& rFilter,
- const OUString& rFragmentPath,
- const DiagramColorsPtr pDataPtr )
- throw( )
- : FragmentHandler( rFilter, rFragmentPath )
- , mpDataPtr( pDataPtr )
+void DiagramQStylesFragmentHandler::onEndElement( const ::rtl::OUString& )
{
+ if( getCurrentElement() == (NMSP_DIAGRAM|XML_styleLbl) )
+ mrStylesMap[maStyleName] = maStyleEntry;
}
-DiagramColorsFragmentHandler::~DiagramColorsFragmentHandler( ) throw ()
-{
-
-}
+///////////////////////
-void SAL_CALL DiagramColorsFragmentHandler::endDocument()
- throw (SAXException, RuntimeException)
+ColorFragmentHandler::ColorFragmentHandler( ::oox::core::XmlFilterBase& rFilter,
+ const ::rtl::OUString& rFragmentPath,
+ DiagramColorMap& rColorsMap ) :
+ FragmentHandler2(rFilter,rFragmentPath),
+ maColorName(),
+ maColorEntry(),
+ mrColorsMap(rColorsMap)
+{}
+
+::oox::core::ContextHandlerRef ColorFragmentHandler::onCreateContext( sal_Int32 nElement,
+ const AttributeList& /*rAttribs*/ )
{
+ // state-table like way of navigating the color fragment. we
+ // currently ignore everything except styleLbl in the colorsDef
+ // element
+ switch( getCurrentElement() )
+ {
+ case XML_ROOT_CONTEXT:
+ return nElement == (NMSP_DIAGRAM|XML_colorsDef) ? this : NULL;;
+ case NMSP_DIAGRAM|XML_colorsDef:
+ return nElement == (NMSP_DIAGRAM|XML_styleLbl) ? this : NULL;;
+ case NMSP_DIAGRAM|XML_styleLbl:
+ return ((nElement == (NMSP_DIAGRAM|XML_fillClrLst)) ||
+ (nElement == (NMSP_DIAGRAM|XML_linClrLst)) ||
+ (nElement == (NMSP_DIAGRAM|XML_effectClrLst)) ||
+ (nElement == (NMSP_DIAGRAM|XML_txLinClrLst)) ||
+ (nElement == (NMSP_DIAGRAM|XML_txFillClrLst)) ||
+ (nElement == (NMSP_DIAGRAM|XML_txEffectClrLst))) ? this : NULL;;
+
+ // the actual colors - defer to color fragment handlers.
+
+ // TODO(F1): well, actually, there might be *several* color
+ // definitions in it, after all it's called list. but
+ // apparently colorChoiceContext doesn't handle that anyway...
+ case NMSP_DIAGRAM|XML_fillClrLst:
+ return new ColorContext( *this, maColorEntry.maFillColor );
+ case NMSP_DIAGRAM|XML_linClrLst:
+ return new ColorContext( *this, maColorEntry.maLineColor );
+ case NMSP_DIAGRAM|XML_effectClrLst:
+ return new ColorContext( *this, maColorEntry.maEffectColor );
+ case NMSP_DIAGRAM|XML_txFillClrLst:
+ return new ColorContext( *this, maColorEntry.maTextFillColor );
+ case NMSP_DIAGRAM|XML_txLinClrLst:
+ return new ColorContext( *this, maColorEntry.maTextLineColor );
+ case NMSP_DIAGRAM|XML_txEffectClrLst:
+ return new ColorContext( *this, maColorEntry.maTextEffectColor );
+ }
+ return 0;
}
-
-Reference< XFastContextHandler > SAL_CALL
-DiagramColorsFragmentHandler::createFastChildContext( ::sal_Int32 aElement,
- const Reference< XFastAttributeList >& )
- throw ( SAXException, RuntimeException)
+void ColorFragmentHandler::onStartElement( const AttributeList& rAttribs )
{
- Reference< XFastContextHandler > xRet;
-
- switch( aElement )
+ if( getCurrentElement() == (NMSP_DIAGRAM|XML_styleLbl) )
{
- case NMSP_DIAGRAM|XML_colorsDef:
- // TODO
- break;
- default:
- break;
+ maColorName = rAttribs.getString( XML_name, OUString() );
+ maColorEntry = mrColorsMap[maColorName];
}
-
- if( !xRet.is() )
- xRet = getFastContextHandler();
-
- return xRet;
}
-
-
+void ColorFragmentHandler::onEndElement( const ::rtl::OUString& )
+{
+ if( getCurrentElement() == (NMSP_DIAGRAM|XML_styleLbl) )
+ mrColorsMap[maColorName] = maColorEntry;
+}
} }
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index dd213fda6c36..a0c2d6eb1245 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -26,14 +26,24 @@
*
************************************************************************/
-#include "oox/drawingml/diagram/diagramlayoutatoms.hxx"
+#include "diagramlayoutatoms.hxx"
#include <functional>
#include <boost/bind.hpp>
+#include <basegfx/numeric/ftools.hxx>
+
#include "oox/helper/attributelist.hxx"
+#include "oox/drawingml/fillproperties.hxx"
+#include "oox/drawingml/lineproperties.hxx"
+#include "oox/drawingml/textbody.hxx"
+#include "oox/drawingml/textparagraph.hxx"
+#include "oox/drawingml/textrun.hxx"
+#include "oox/drawingml/customshapeproperties.hxx"
+#include "diagramlayoutatoms.hxx"
#include "layoutnodecontext.hxx"
+using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::xml::sax;
using namespace ::oox::core;
@@ -43,7 +53,7 @@ namespace oox { namespace drawingml {
IteratorAttr::IteratorAttr( )
: mnAxis( 0 )
- , mnCnt( 0 )
+ , mnCnt( -1 )
, mbHideLastTrans( false )
, mnPtType( 0 )
, mnSt( 0 )
@@ -55,7 +65,7 @@ void IteratorAttr::loadFromXAttr( const Reference< XFastAttributeList >& xAttr )
{
AttributeList attr( xAttr );
mnAxis = xAttr->getOptionalValueToken( XML_axis, 0 );
- mnCnt = attr.getInteger( XML_cnt, 0 );
+ mnCnt = attr.getInteger( XML_cnt, -1 );
mbHideLastTrans = attr.getBool( XML_hideLastTrans, false );
mnPtType = xAttr->getOptionalValueToken( XML_ptType, 0 );
mnSt = attr.getInteger( XML_st, 0 );
@@ -88,56 +98,675 @@ void LayoutAtom::dump(int level)
OSL_TRACE( "level = %d - %s of type %s", level,
OUSTRING_TO_CSTR( msName ),
typeid(*this).name() );
- std::for_each( mpChildNodes.begin(), mpChildNodes.end(),
- boost::bind( &LayoutAtom::dump, _1, level + 1 ) );
+ const std::vector<LayoutAtomPtr>& pChildren=getChildren();
+ std::for_each( pChildren.begin(), pChildren.end(),
+ boost::bind( &LayoutAtom::dump, _1, level + 1 ) );
+}
+
+
+ForEachAtom::ForEachAtom(const Reference< XFastAttributeList >& xAttributes)
+{
+ maIter.loadFromXAttr(xAttributes);
+}
+
+void ForEachAtom::accept( LayoutAtomVisitor& rVisitor )
+{
+ rVisitor.visit(*this);
+}
+
+void ChooseAtom::accept( LayoutAtomVisitor& rVisitor )
+{
+ rVisitor.visit(*this);
+}
+
+ConditionAtom::ConditionAtom(const Reference< XFastAttributeList >& xAttributes) :
+ mbElse( false )
+{
+ maIter.loadFromXAttr( xAttributes );
+ maCond.loadFromXAttr( xAttributes );
+}
+
+const std::vector<LayoutAtomPtr>& ConditionAtom::getChildren() const
+{
+ bool bDecisionVar=true;
+ // HACK
+ if( maCond.mnFunc==XML_var && maCond.mnArg==XML_dir &&
+ maCond.mnOp==XML_equ && !maCond.msVal.equalsAscii("norm") )
+ bDecisionVar=false;
+
+ if( bDecisionVar )
+ return mpChildNodes;
+ else
+ return mpElseChildNodes;
+}
+
+void ConditionAtom::accept( LayoutAtomVisitor& rVisitor )
+{
+ rVisitor.visit(*this);
+}
+
+void ConditionAtom::addChild( const LayoutAtomPtr & pNode )
+{
+ if( mbElse )
+ mpElseChildNodes.push_back( pNode );
+ else
+ mpChildNodes.push_back( pNode );
+}
+
+void ConstraintAtom::accept( LayoutAtomVisitor& rVisitor )
+{
+ rVisitor.visit(*this);
+}
+
+void AlgAtom::accept( LayoutAtomVisitor& rVisitor )
+{
+ rVisitor.visit(*this);
}
+void AlgAtom::layoutShape( const ShapePtr& rShape,
+ const Diagram& /*rDgm*/,
+ const rtl::OUString& rName ) const
+{
+ switch(mnType)
+ {
+ case XML_composite:
+ {
+ if( rShape->getChildren().empty() )
+ {
+ rShape->setSize(awt::Size(50,50));
+ break;
+ }
+
+ // just put stuff below each other
+ const sal_Int32 nIncX=0;
+ const sal_Int32 nIncY=1;
+
+ std::vector<ShapePtr>::const_iterator aCurrShape=rShape->getChildren().begin();
+ const std::vector<ShapePtr>::const_iterator aLastShape=rShape->getChildren().end();
+
+ // find biggest shape
+ awt::Size aMaxSize;
+ while( aCurrShape != aLastShape )
+ {
+ const awt::Size& sz=(*aCurrShape)->getSize();
+
+ aMaxSize.Width = std::max(
+ aMaxSize.Width,
+ sz.Width);
+ aMaxSize.Height = std::max(
+ aMaxSize.Height,
+ sz.Height);
+
+ ++aCurrShape;
+ }
+
+ aCurrShape=rShape->getChildren().begin();
+ const awt::Point aStartPos=(*aCurrShape)->getPosition();
+ awt::Point aCurrPos=aStartPos;
+ awt::Size aTotalSize;
+ aTotalSize.Width = aMaxSize.Width;
+ while( aCurrShape != aLastShape )
+ {
+ const awt::Size& sz=(*aCurrShape)->getSize();
+ (*aCurrShape)->setPosition(aCurrPos);
+ (*aCurrShape)->setSize(
+ awt::Size(aMaxSize.Width,
+ sz.Height));
+
+ aTotalSize.Height = std::max(
+ aTotalSize.Height,
+ aCurrPos.Y + sz.Height);
+
+ aCurrPos.X += nIncX*sz.Width;
+ aCurrPos.Y += nIncY*sz.Height;
+
+ ++aCurrShape;
+ }
+
+ rShape->setSize(aTotalSize);
+ break;
+ }
+
+ case XML_conn:
+ break;
+
+ case XML_cycle:
+ {
+ if( rShape->getChildren().empty() )
+ {
+ rShape->setSize(awt::Size(50,50));
+ break;
+ }
+
+ const sal_Int32 nStartAngle=maMap.count(XML_stAng) ? maMap.find(XML_stAng)->second : 0;
+ const sal_Int32 nSpanAngle=maMap.count(XML_spanAng) ? maMap.find(XML_spanAng)->second : 360;
+
+ std::vector<ShapePtr>::const_iterator aCurrShape=rShape->getChildren().begin();
+ const std::vector<ShapePtr>::const_iterator aLastShape=rShape->getChildren().end();
+ const sal_Int32 nShapes=aLastShape-aCurrShape;
+
+ // find biggest shape
+ awt::Size aMaxSize;
+ while( aCurrShape != aLastShape )
+ {
+ const awt::Size& sz=(*aCurrShape)->getSize();
+
+ aMaxSize.Width = std::max(
+ aMaxSize.Width,
+ sz.Width);
+ aMaxSize.Height = std::max(
+ aMaxSize.Height,
+ sz.Height);
+
+ ++aCurrShape;
+ }
+
+ // layout shapes
+ const sal_Int32 nMaxDim=std::max(aMaxSize.Width,aMaxSize.Height);
+ awt::Size aTotalSize;
+ aCurrShape=rShape->getChildren().begin();
+ for( sal_Int32 i=0; i<nShapes; ++i, ++aCurrShape )
+ {
+ const awt::Size& sz=(*aCurrShape)->getSize();
+
+ const double r=nShapes*nMaxDim/F_2PI * 360.0/nSpanAngle;
+ const awt::Point aCurrPos(
+ r + r*sin( (double(i)*nSpanAngle/nShapes + nStartAngle)*F_PI180 ),
+ r - r*cos( (double(i)*nSpanAngle/nShapes + nStartAngle)*F_PI180 ) );
+ (*aCurrShape)->setPosition(aCurrPos);
+
+ aTotalSize.Width = std::max(
+ aTotalSize.Width,
+ aCurrPos.X + sz.Width);
+ aTotalSize.Height = std::max(
+ aTotalSize.Height,
+ aCurrPos.Y + sz.Height);
+ }
+
+ rShape->setSize(aTotalSize);
+ break;
+ }
+
+ case XML_hierChild:
+ case XML_hierRoot:
+ break;
+
+ case XML_lin:
+ {
+ if( rShape->getChildren().empty() )
+ {
+ rShape->setSize(awt::Size(50,50));
+ break;
+ }
+
+ const sal_Int32 nDir=maMap.count(XML_linDir) ? maMap.find(XML_linDir)->second : XML_fromL;
+ const sal_Int32 nIncX=nDir==XML_fromL ? 1 : (nDir==XML_fromR ? -1 : 0);
+ const sal_Int32 nIncY=nDir==XML_fromT ? 1 : (nDir==XML_fromB ? -1 : 0);
+
+ std::vector<ShapePtr>::const_iterator aCurrShape=rShape->getChildren().begin();
+ const std::vector<ShapePtr>::const_iterator aLastShape=rShape->getChildren().end();
+ const awt::Point aStartPos=(*aCurrShape)->getPosition();
+ awt::Point aCurrPos=aStartPos;
+ awt::Size aTotalSize;
+ while( aCurrShape != aLastShape )
+ {
+ const awt::Size& sz=(*aCurrShape)->getSize();
+ (*aCurrShape)->setPosition(aCurrPos);
+
+ aTotalSize.Width = std::max(
+ aTotalSize.Width,
+ aCurrPos.X + sz.Width);
+ aTotalSize.Height = std::max(
+ aTotalSize.Height,
+ aCurrPos.Y + sz.Height);
+
+ // HACK: the spacing is arbitrary
+ aCurrPos.X += nIncX*(sz.Width+5);
+ aCurrPos.Y += nIncY*(sz.Height+5);
+
+ ++aCurrShape;
+ }
+
+ rShape->setSize(aTotalSize);
+ break;
+ }
+
+ case XML_pyra:
+ case XML_snake:
+ break;
+
+ case XML_sp:
+ // HACK. Handled one level higher. Or rather, planned to
+ break;
-void ForEachAtom::processAtom()
+ case XML_tx:
+ {
+ TextBodyPtr pTextBody=rShape->getTextBody();
+ if( !pTextBody ||
+ pTextBody->getParagraphs().empty() ||
+ pTextBody->getParagraphs().front()->getRuns().empty() )
+ {
+ rShape->setSize(awt::Size(5,5));
+ break;
+ }
+
+ // HACK - count chars & paragraphs to come up with *some*
+ // notion of necessary size
+ const sal_Int32 nHackyFontHeight=50;
+ const sal_Int32 nHackyFontWidth=20;
+ awt::Size aTotalSize;
+ for( sal_uInt32 nPara=0; nPara<pTextBody->getParagraphs().size(); ++nPara )
+ {
+ aTotalSize.Height += nHackyFontHeight;
+
+ sal_Int32 nLocalWidth=0;
+ for( sal_uInt32 nRun=0; nRun<pTextBody->getParagraphs().at(nPara)->getRuns().size(); ++nRun )
+ nLocalWidth +=
+ pTextBody->getParagraphs().at(nPara)->getRuns().at(nRun)->getText().getLength()
+ * nHackyFontWidth;
+
+ aTotalSize.Width = std::max(
+ aTotalSize.Width,
+ nLocalWidth);
+ }
+
+ rShape->setSize(aTotalSize);
+ }
+
+ default:
+ break;
+ }
+
+ OSL_TRACE("Layouting shape %s: (%d,%d,%d,%d)",
+ OUSTRING_TO_CSTR( rName ),
+ rShape->getPosition().X,
+ rShape->getPosition().Y,
+ rShape->getSize().Width,
+ rShape->getSize().Height);
+}
+
+void LayoutNode::accept( LayoutAtomVisitor& rVisitor )
{
- // TODO there is likely some conditions
- std::for_each( mpChildNodes.begin(), mpChildNodes.end(),
- boost::bind( &LayoutAtom::processAtom, _1 ) );
+ rVisitor.visit(*this);
}
-/** call ConditionAtom::test() if pAtom is one
- * if it is not a ConditionAtom, then return false.
- */
-static bool _test_atom( const LayoutAtomPtr & pAtom)
+bool LayoutNode::setupShape( const ShapePtr& rShape, const Diagram& rDgm, sal_uInt32 nIdx ) const
{
- try {
- bool bResult = false;
- const ConditionAtomPtr pCond = boost::dynamic_pointer_cast< ConditionAtom >(pAtom);
- if( pCond )
+ // find the data node to grab text from
+ DiagramData::PointsNameMap::const_iterator aDataNode=rDgm.getData()->getPointsPresNameMap().find(msName);
+ if( aDataNode->second.size() > nIdx &&
+ aDataNode != rDgm.getData()->getPointsPresNameMap().end() )
+ {
+ OSL_TRACE( "Filling content from %d th layout node named \"%s\", modelId \"%s\"",
+ nIdx,
+ OUSTRING_TO_CSTR( msName ),
+ OUSTRING_TO_CSTR( aDataNode->second.at(nIdx)->msModelId ) );
+
+ // got the presentation node - now, need the actual data node:
+ const DiagramData::StringMap::const_iterator aNodeName=rDgm.getData()->getPresOfNameMap().find(
+ aDataNode->second.at(nIdx)->msModelId);
+ if( aNodeName != rDgm.getData()->getPresOfNameMap().end() )
+ {
+ DiagramData::StringMap::value_type::second_type::const_iterator aVecIter=aNodeName->second.begin();
+ const DiagramData::StringMap::value_type::second_type::const_iterator aVecEnd=aNodeName->second.end();
+ while( aVecIter != aVecEnd )
+ {
+ DiagramData::PointNameMap::const_iterator aDataNode2=rDgm.getData()->getPointNameMap().find(aVecIter->first);
+ if( aVecIter->second == 0 )
+ {
+ // grab shape attr from topmost element(s)
+ rShape->getShapeProperties() = aDataNode2->second->mpShape->getShapeProperties();
+ rShape->getLineProperties() = aDataNode2->second->mpShape->getLineProperties();
+ rShape->getFillProperties() = aDataNode2->second->mpShape->getFillProperties();
+ rShape->getCustomShapeProperties() = aDataNode2->second->mpShape->getCustomShapeProperties();
+ rShape->setMasterTextListStyle( aDataNode2->second->mpShape->getMasterTextListStyle() );
+
+ OSL_TRACE( "Custom shape with preset type %s added for layout node named \"%s\"",
+ OUSTRING_TO_CSTR(
+ rShape->getCustomShapeProperties()->getShapePresetType()),
+ OUSTRING_TO_CSTR( msName ) );
+ }
+
+ // append text with right outline level
+ if( aDataNode2->second->mpShape->getTextBody() &&
+ !aDataNode2->second->mpShape->getTextBody()->getParagraphs().empty() &&
+ !aDataNode2->second->mpShape->getTextBody()->getParagraphs().front()->getRuns().empty() )
+ {
+ TextBodyPtr pTextBody=rShape->getTextBody();
+ if( !pTextBody )
+ {
+ pTextBody.reset( new TextBody() );
+
+ // also copy text attrs
+ pTextBody->getTextListStyle() =
+ aDataNode2->second->mpShape->getTextBody()->getTextListStyle();
+ pTextBody->getTextProperties() =
+ aDataNode2->second->mpShape->getTextBody()->getTextProperties();
+
+ rShape->setTextBody(pTextBody);
+ }
+
+ TextParagraph& rPara=pTextBody->addParagraph();
+ if( aVecIter->second != -1 )
+ rPara.getProperties().setLevel(aVecIter->second);
+
+ rPara.addRun(
+ aDataNode2->second->mpShape->getTextBody()->getParagraphs().front()->getRuns().front());
+ rPara.getProperties().apply(
+ aDataNode2->second->mpShape->getTextBody()->getParagraphs().front()->getProperties());
+ }
+
+ ++aVecIter;
+ }
+ }
+ else
+ {
+ OSL_TRACE("ShapeCreationVisitor::visit: no data node name found while processing shape type %s for layout node named \"%s\"",
+ OUSTRING_TO_CSTR(
+ rShape->getCustomShapeProperties()->getShapePresetType()),
+ OUSTRING_TO_CSTR( msName ) );
+ }
+
+ // TODO(Q1): apply styling & coloring - taking
+ // layout node's styleLbl for both style & color
+ // now, but docs are a bit unclear on this
+ if( msStyleLabel.getLength() )
{
- bResult = pCond->test();
+ OSL_TRACE("setting style with label %s",
+ OUSTRING_TO_CSTR( msStyleLabel ) );
+
+ const DiagramQStyleMap::const_iterator aStyle=rDgm.getStyles().find(msStyleLabel);
+ if( aStyle != rDgm.getStyles().end() )
+ {
+ rShape->getShapeStyleRefs()[XML_fillRef] = aStyle->second.maFillStyle;
+ OSL_TRACE("added fill style with id %d", aStyle->second.maFillStyle.mnThemedIdx);
+ rShape->getShapeStyleRefs()[XML_lnRef] = aStyle->second.maLineStyle;
+ OSL_TRACE("added line style with id %d", aStyle->second.maLineStyle.mnThemedIdx);
+ rShape->getShapeStyleRefs()[XML_effectRef] = aStyle->second.maEffectStyle;
+ OSL_TRACE("added effect style with id %d", aStyle->second.maEffectStyle.mnThemedIdx);
+ rShape->getShapeStyleRefs()[XML_fontRef] = aStyle->second.maTextStyle;
+ OSL_TRACE("added fontref style with id %d", aStyle->second.maTextStyle.mnThemedIdx);
+ Color aColor=aStyle->second.maTextStyle.maPhClr;
+ OSL_TRACE("added fontref color with alpha %d", aColor.getTransparence() );
+ }
+
+ const DiagramColorMap::const_iterator aColor=rDgm.getColors().find(msStyleLabel);
+ if( aColor != rDgm.getColors().end() )
+ {
+ const DiagramColor& rColor=aColor->second;
+ if( rColor.maFillColor.isUsed() )
+ rShape->getShapeStyleRefs()[XML_fillRef].maPhClr = rColor.maFillColor;
+ if( rColor.maLineColor.isUsed() )
+ rShape->getShapeStyleRefs()[XML_lnRef].maPhClr = rColor.maLineColor;
+ if( rColor.maEffectColor.isUsed() )
+ rShape->getShapeStyleRefs()[XML_effectRef].maPhClr = rColor.maEffectColor;
+ if( rColor.maTextFillColor.isUsed() )
+ rShape->getShapeStyleRefs()[XML_fontRef].maPhClr = rColor.maTextFillColor;
+ }
}
- return bResult;
+
+ // even if no data node found, successful anyway. it's
+ // contained at the layoutnode
+ return true;
}
- catch(...)
+ else
{
+ OSL_TRACE("ShapeCreationVisitor::visit: no text found while processing shape type %s for layout node named \"%s\"",
+ OUSTRING_TO_CSTR(
+ rShape->getCustomShapeProperties()->getShapePresetType()),
+ OUSTRING_TO_CSTR( msName ) );
}
+
return false;
}
-void ChooseAtom::processAtom()
+///////////////////////////////////////////////////////////////////////
+//
+// Visitation
+//
+
+class ShapeLayoutingVisitor : public LayoutAtomVisitor
+{
+ ShapePtr mpParentShape;
+ const Diagram& mrDgm;
+ rtl::OUString maName;
+
+ virtual void visit(ConstraintAtom& rAtom);
+ virtual void visit(AlgAtom& rAtom);
+ virtual void visit(ForEachAtom& rAtom);
+ virtual void visit(ConditionAtom& rAtom);
+ virtual void visit(ChooseAtom& rAtom);
+ virtual void visit(LayoutNode& rAtom);
+
+public:
+ ShapeLayoutingVisitor(const ShapePtr& rParentShape,
+ const Diagram& rDgm,
+ const rtl::OUString& rName) :
+ mpParentShape(rParentShape),
+ mrDgm(rDgm),
+ maName(rName)
+ {}
+
+ void defaultVisit(LayoutAtom& rAtom);
+};
+
+class ShallowPresNameVisitor : public LayoutAtomVisitor
+{
+ const Diagram& mrDgm;
+ size_t mnCnt;
+
+ void defaultVisit(LayoutAtom& rAtom);
+ virtual void visit(ConstraintAtom& rAtom);
+ virtual void visit(AlgAtom& rAtom);
+ virtual void visit(ForEachAtom& rAtom);
+ virtual void visit(ConditionAtom& rAtom);
+ virtual void visit(ChooseAtom& rAtom);
+ virtual void visit(LayoutNode& rAtom);
+
+public:
+ ShallowPresNameVisitor(const Diagram& rDgm) :
+ mrDgm(rDgm),
+ mnCnt(0)
+ {}
+
+ size_t getCount() const
+ { return mnCnt; }
+};
+
+void ShapeCreationVisitor::defaultVisit(LayoutAtom& rAtom)
+{
+ const std::vector<LayoutAtomPtr>& pChildren=rAtom.getChildren();
+ std::for_each( pChildren.begin(), pChildren.end(),
+ boost::bind( &LayoutAtom::accept,
+ _1,
+ boost::ref(*this)) );
+}
+
+void ShapeCreationVisitor::visit(ConstraintAtom& /*rAtom*/)
+{
+ // TODO: eval the constraints
+}
+
+void ShapeCreationVisitor::visit(AlgAtom& rAtom)
{
- std::vector< LayoutAtomPtr >::iterator
- iter = std::find_if( mpChildNodes.begin(), mpChildNodes.end(),
- boost::bind( &_test_atom, _1 ) );
- if( iter != mpChildNodes.end() )
+ defaultVisit(rAtom);
+}
+
+void ShapeCreationVisitor::visit(ForEachAtom& rAtom)
+{
+ const std::vector<LayoutAtomPtr>& pChildren=rAtom.getChildren();
+
+ sal_Int32 nChildren=1;
+ if( rAtom.iterator().mnPtType == XML_node )
+ {
+ // cound child data nodes - check all child Atoms for "name"
+ // attribute that is contained in diagram's
+ // getPointsPresNameMap()
+ ShallowPresNameVisitor aVisitor(mrDgm);
+ std::for_each( pChildren.begin(), pChildren.end(),
+ boost::bind( &LayoutAtom::accept,
+ _1,
+ boost::ref(aVisitor)) );
+ nChildren = aVisitor.getCount();
+ }
+
+ const sal_Int32 nCnt = std::min(
+ nChildren,
+ rAtom.iterator().mnCnt==-1 ? nChildren : rAtom.iterator().mnCnt);
+
+ const sal_Int32 nOldIdx=mnCurrIdx;
+ const sal_Int32 nStep=rAtom.iterator().mnStep;
+ for( mnCurrIdx=0; mnCurrIdx<nCnt && nStep>0; mnCurrIdx+=nStep )
{
- // TODO do something
- (*iter)->processAtom();
+ // TODO there is likely some conditions
+ std::for_each( pChildren.begin(), pChildren.end(),
+ boost::bind( &LayoutAtom::accept,
+ _1,
+ boost::ref(*this)) );
}
+
+ // and restore idx
+ mnCurrIdx = nOldIdx;
}
-bool ConditionAtom::test()
+void ShapeCreationVisitor::visit(ConditionAtom& rAtom)
{
- // TODO
- return false;
+ defaultVisit(rAtom);
+}
+
+void ShapeCreationVisitor::visit(ChooseAtom& rAtom)
+{
+ defaultVisit(rAtom);
+}
+
+void ShapeCreationVisitor::visit(LayoutNode& rAtom)
+{
+ ShapePtr pCurrParent(mpParentShape);
+ ShapePtr pCurrShape(rAtom.getShape());
+ if( pCurrShape )
+ {
+ OSL_TRACE("ShapeCreationVisitor::visit: processing shape type %s",
+ OUSTRING_TO_CSTR(
+ pCurrShape->getCustomShapeProperties()->getShapePresetType()) );
+
+ // TODO(F3): cloned shape shares all properties by reference,
+ // don't change them!
+ ShapePtr pClonedShape(
+ new Shape( pCurrShape ));
+
+ if( rAtom.setupShape(pClonedShape, mrDgm, mnCurrIdx) )
+ {
+ pCurrParent->addChild(pClonedShape);
+ pCurrParent = pClonedShape;
+ }
+ }
+ else
+ {
+ OSL_TRACE("ShapeCreationVisitor::visit: no shape set while processing layoutnode named %s",
+ OUSTRING_TO_CSTR( rAtom.getName() ) );
+ }
+
+ // set new parent for children
+ ShapePtr pPreviousParent(mpParentShape);
+ mpParentShape=pCurrParent;
+
+ // process children
+ defaultVisit(rAtom);
+
+ // restore parent
+ mpParentShape=pPreviousParent;
+
+ // layout shapes - now all child shapes are created
+ ShapeLayoutingVisitor aLayoutingVisitor(pCurrParent,
+ mrDgm,
+ rAtom.getName());
+ aLayoutingVisitor.defaultVisit(rAtom);
+}
+
+void ShapeLayoutingVisitor::defaultVisit(LayoutAtom& rAtom)
+{
+ // visit all children, one of them need to be the layout algoritm
+ const std::vector<LayoutAtomPtr>& pChildren=rAtom.getChildren();
+ std::for_each( pChildren.begin(), pChildren.end(),
+ boost::bind( &LayoutAtom::accept,
+ _1,
+ boost::ref(*this)) );
+}
+
+void ShapeLayoutingVisitor::visit(ConstraintAtom& /*rAtom*/)
+{
+ // stop processing
+}
+
+void ShapeLayoutingVisitor::visit(AlgAtom& rAtom)
+{
+ rAtom.layoutShape(mpParentShape,mrDgm,maName);
+}
+
+void ShapeLayoutingVisitor::visit(ForEachAtom& /*rAtom*/)
+{
+ // stop processing
+}
+
+void ShapeLayoutingVisitor::visit(ConditionAtom& rAtom)
+{
+ defaultVisit(rAtom);
+}
+
+void ShapeLayoutingVisitor::visit(ChooseAtom& rAtom)
+{
+ defaultVisit(rAtom);
}
+void ShapeLayoutingVisitor::visit(LayoutNode& /*rAtom*/)
+{
+ // stop processing - only traverse Condition/Choose atoms
+}
+
+void ShallowPresNameVisitor::defaultVisit(LayoutAtom& rAtom)
+{
+ // visit all children, at least one of them needs to have proper
+ // name set
+ const std::vector<LayoutAtomPtr>& pChildren=rAtom.getChildren();
+ std::for_each( pChildren.begin(), pChildren.end(),
+ boost::bind( &LayoutAtom::accept,
+ _1,
+ boost::ref(*this)) );
+}
+
+void ShallowPresNameVisitor::visit(ConstraintAtom& /*rAtom*/)
+{
+ // stop processing
+}
+
+void ShallowPresNameVisitor::visit(AlgAtom& /*rAtom*/)
+{
+ // stop processing
+}
+
+void ShallowPresNameVisitor::visit(ForEachAtom& rAtom)
+{
+ defaultVisit(rAtom);
+}
+
+void ShallowPresNameVisitor::visit(ConditionAtom& rAtom)
+{
+ defaultVisit(rAtom);
+}
+
+void ShallowPresNameVisitor::visit(ChooseAtom& rAtom)
+{
+ defaultVisit(rAtom);
+}
+
+void ShallowPresNameVisitor::visit(LayoutNode& rAtom)
+{
+ DiagramData::PointsNameMap::const_iterator aDataNode=
+ mrDgm.getData()->getPointsPresNameMap().find(rAtom.getName());
+ if( aDataNode != mrDgm.getData()->getPointsPresNameMap().end() )
+ mnCnt = std::max(mnCnt,
+ aDataNode->second.size());
+}
} }
diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx b/oox/source/drawingml/diagram/layoutnodecontext.cxx
index 61213b5afa4c..ad7e4ae3a289 100644
--- a/oox/source/drawingml/diagram/layoutnodecontext.cxx
+++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx
@@ -32,7 +32,9 @@
#include "oox/core/namespaces.hxx"
#include "oox/drawingml/diagram/diagram.hxx"
#include "oox/drawingml/shapecontext.hxx"
+#include "oox/drawingml/customshapeproperties.hxx"
#include "diagramdefinitioncontext.hxx"
+#include "constraintlistcontext.hxx"
using namespace ::oox::core;
using namespace ::com::sun::star::uno;
@@ -47,15 +49,9 @@ class IfContext
public:
IfContext( ContextHandler& rParent,
const Reference< XFastAttributeList >& xAttribs,
- const LayoutAtomPtr & pNode )
- : LayoutNodeContext( rParent, xAttribs, pNode )
- {
- ConditionAtomPtr pAtom( boost::dynamic_pointer_cast< ConditionAtom >(pNode) );
- OSL_ENSURE( pAtom, "Must pass a ConditionAtom" );
-
- pAtom->iterator().loadFromXAttr( xAttribs );
- pAtom->cond().loadFromXAttr( xAttribs );
- }
+ const ConditionAtomPtr& pAtom )
+ : LayoutNodeContext( rParent, xAttribs, pAtom )
+ {}
};
@@ -64,21 +60,47 @@ class AlgorithmContext
: public ContextHandler
{
public:
- AlgorithmContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, const LayoutAtomPtr & pNode )
+ AlgorithmContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, const AlgAtomPtr & pNode )
: ContextHandler( rParent )
, mnRevision( 0 )
- , mnType( 0 )
, mpNode( pNode )
{
AttributeList aAttribs( xAttribs );
mnRevision = aAttribs.getInteger( XML_rev, 0 );
- mnType = xAttribs->getOptionalValueToken( XML_type, 0 );
+ pNode->setType(xAttribs->getOptionalValueToken(XML_type, 0));
+ }
+
+ virtual Reference< XFastContextHandler > SAL_CALL
+ createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+
+ switch( getToken(aElement) )
+ {
+ case XML_param:
+ {
+ AttributeList aAttribs( xAttribs );
+ const sal_Int32 nValTok=aAttribs.getToken( XML_val, 0 );
+ mpNode->addParam(
+ aAttribs.getToken( XML_type, 0 ),
+ nValTok>0 ? nValTok : aAttribs.getInteger( XML_val, 0 ) );
+ break;
+ }
+ default:
+ break;
+ }
+
+ if( !xRet.is() )
+ xRet.set(this);
+
+ return xRet;
}
private:
- sal_Int32 mnRevision;
- sal_Int32 mnType;
- LayoutAtomPtr mpNode;
+ sal_Int32 mnRevision;
+ AlgAtomPtr mpNode;
};
@@ -88,7 +110,6 @@ class ChooseContext
public:
ChooseContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, const LayoutAtomPtr & pNode )
: ContextHandler( rParent )
- , mbHasElse( false )
, mpNode( pNode )
{
msName = xAttribs->getOptionalValue( XML_name );
@@ -101,24 +122,23 @@ public:
{
Reference< XFastContextHandler > xRet;
- switch( aElement )
+ switch( getToken(aElement) )
{
case XML_if:
{
// CT_When
- LayoutAtomPtr pAtom( new ConditionAtom( false ) );
- mpNode->addChild( pAtom );
- xRet.set( new IfContext( *this, xAttribs, pAtom ) );
+ mpConditionNode.reset( new ConditionAtom(xAttribs) );
+ mpNode->addChild( mpConditionNode );
+ xRet.set( new IfContext( *this, xAttribs, mpConditionNode ) );
break;
}
case XML_else:
// CT_Otherwise
- if( !mbHasElse )
+ if( mpConditionNode )
{
- LayoutAtomPtr pAtom( new ConditionAtom( true ) );
- mpNode->addChild( pAtom );
- xRet.set( new IfContext( *this, xAttribs, pAtom ) );
- mbHasElse = true;
+ mpConditionNode->readElseBranch();
+ xRet.set( new IfContext( *this, xAttribs, mpConditionNode ) );
+ mpConditionNode.reset();
}
else
{
@@ -135,9 +155,9 @@ public:
return xRet;
}
private:
- bool mbHasElse;
OUString msName;
LayoutAtomPtr mpNode;
+ ConditionAtomPtr mpConditionNode;
};
@@ -147,13 +167,10 @@ class ForEachContext
: public LayoutNodeContext
{
public:
- ForEachContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, const LayoutAtomPtr & pNode )
- : LayoutNodeContext( rParent, xAttribs, pNode )
+ ForEachContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, const ForEachAtomPtr& pAtom )
+ : LayoutNodeContext( rParent, xAttribs, pAtom )
{
- ForEachAtomPtr pAtom( boost::dynamic_pointer_cast< ForEachAtom >(pNode) );
- OSL_ENSURE( pAtom, "Must pass a ForEachAtom" );
xAttribs->getOptionalValue( XML_ref );
-
pAtom->iterator().loadFromXAttr( xAttribs );
}
};
@@ -197,17 +214,12 @@ private:
// CT_LayoutNode
LayoutNodeContext::LayoutNodeContext( ContextHandler& rParent,
const Reference< XFastAttributeList >& xAttribs,
- const LayoutAtomPtr &pNode )
+ const LayoutAtomPtr& pAtom )
: ContextHandler( rParent )
- , mpNode( pNode )
+ , mpNode( pAtom )
{
- OSL_ENSURE( pNode, "Node must NOT be NULL" );
+ OSL_ENSURE( pAtom, "Node must NOT be NULL" );
mpNode->setName( xAttribs->getOptionalValue( XML_name ) );
- // TODO shall we even bother?
- // b or t
-// sal_Int32 nChOrder = xAttributes->getOptionalValueToken( XML_chOrder, XML_b );
-// OUString sMoveWith = xAttributes->getOptionalValue( XML_moveWith );
-// OUString sStyleLbl = xAttributes->getOptionalValue( XML_styleLbl );
}
@@ -228,33 +240,33 @@ void SAL_CALL LayoutNodeContext::endFastElement( ::sal_Int32 )
sal_Int32 LayoutNodeContext::tagToVarIdx( sal_Int32 aTag )
{
sal_Int32 nIdx = -1;
- switch( aTag )
+ switch( aTag & ~NMSP_DIAGRAM )
{
- case NMSP_DIAGRAM|XML_animLvl:
+ case XML_animLvl:
nIdx = LayoutNode::VAR_animLvl;
break;
- case NMSP_DIAGRAM|XML_animOne:
+ case XML_animOne:
nIdx = LayoutNode::VAR_animOne;
break;
- case NMSP_DIAGRAM|XML_bulletEnabled:
+ case XML_bulletEnabled:
nIdx = LayoutNode::VAR_bulletEnabled;
break;
- case NMSP_DIAGRAM|XML_chMax:
+ case XML_chMax:
nIdx = LayoutNode::VAR_chMax;
break;
- case NMSP_DIAGRAM|XML_chPref:
+ case XML_chPref:
nIdx = LayoutNode::VAR_chPref;
break;
- case NMSP_DIAGRAM|XML_dir:
+ case XML_dir:
nIdx = LayoutNode::VAR_dir;
break;
- case NMSP_DIAGRAM|XML_hierBranch:
+ case XML_hierBranch:
nIdx = LayoutNode::VAR_hierBranch;
break;
- case NMSP_DIAGRAM|XML_orgChart:
+ case XML_orgChart:
nIdx = LayoutNode::VAR_orgChart;
break;
- case NMSP_DIAGRAM|XML_resizeHandles:
+ case XML_resizeHandles:
nIdx = LayoutNode::VAR_resizeHandles;
break;
default:
@@ -277,13 +289,39 @@ LayoutNodeContext::createFastChildContext( ::sal_Int32 aElement,
{
LayoutNodePtr pNode( new LayoutNode() );
mpNode->addChild( pNode );
+ pNode->setChildOrder( xAttribs->getOptionalValueToken( XML_chOrder, XML_b ) );
+ pNode->setMoveWith( xAttribs->getOptionalValue( XML_moveWith ) );
+ pNode->setStyleLabel( xAttribs->getOptionalValue( XML_styleLbl ) );
xRet.set( new LayoutNodeContext( *this, xAttribs, pNode ) );
break;
}
case NMSP_DIAGRAM|XML_shape:
{
- ShapePtr pShape( new Shape() );
- xRet.set( new ShapeContext( *this, ShapePtr(), pShape ) );
+ LayoutNodePtr pNode( boost::dynamic_pointer_cast< LayoutNode >( mpNode ) );
+ if( pNode )
+ {
+ ShapePtr pShape;
+
+ if( xAttribs->hasAttribute( XML_type ) )
+ {
+ pShape.reset( new Shape("com.sun.star.drawing.CustomShape") );
+ const sal_Int32 nType(xAttribs->getOptionalValueToken( XML_type, XML_obj ));
+ pShape->setSubType( nType );
+ pShape->getCustomShapeProperties()->setShapePresetType(
+ GetShapePresetType( nType ) );
+ }
+ else
+ {
+ pShape.reset( new Shape("com.sun.star.drawing.GroupShape") );
+ }
+
+ pNode->setShape( pShape );
+ xRet.set( new ShapeContext( *this, ShapePtr(), pShape ) );
+ }
+ else
+ {
+ OSL_TRACE( "OOX: encountered a shape in a non layoutNode context" );
+ }
break;
}
case NMSP_DIAGRAM|XML_extLst:
@@ -291,7 +329,7 @@ LayoutNodeContext::createFastChildContext( ::sal_Int32 aElement,
case NMSP_DIAGRAM|XML_alg:
{
// CT_Algorithm
- LayoutAtomPtr pAtom( new AlgAtom );
+ AlgAtomPtr pAtom( new AlgAtom );
mpNode->addChild( pAtom );
xRet.set( new AlgorithmContext( *this, xAttribs, pAtom ) );
break;
@@ -307,14 +345,14 @@ LayoutNodeContext::createFastChildContext( ::sal_Int32 aElement,
case NMSP_DIAGRAM|XML_forEach:
{
// CT_ForEach
- LayoutAtomPtr pAtom( new ForEachAtom );
+ ForEachAtomPtr pAtom( new ForEachAtom(xAttribs) );
mpNode->addChild( pAtom );
xRet.set( new ForEachContext( *this, xAttribs, pAtom ) );
break;
}
case NMSP_DIAGRAM|XML_constrLst:
// CT_Constraints
- // TODO
+ xRet.set( new ConstraintListContext( *this, xAttribs, mpNode ) );
break;
case NMSP_DIAGRAM|XML_presOf:
{
diff --git a/oox/source/drawingml/diagram/layoutnodecontext.hxx b/oox/source/drawingml/diagram/layoutnodecontext.hxx
index 19cb19aa602d..c9c0c6e1d7e2 100644
--- a/oox/source/drawingml/diagram/layoutnodecontext.hxx
+++ b/oox/source/drawingml/diagram/layoutnodecontext.hxx
@@ -29,7 +29,8 @@
#define OOX_DRAWINGML_LAYOUTNODECONTEXT_HXX
#include "oox/core/contexthandler.hxx"
-#include "oox/drawingml/diagram/diagram.hxx"
+#include "diagramlayoutatoms.hxx"
+#include "diagram.hxx"
namespace oox { namespace drawingml {
diff --git a/oox/source/drawingml/diagram/makefile.mk b/oox/source/drawingml/diagram/makefile.mk
index 9d526ed3d3fb..1d438c21fbae 100644
--- a/oox/source/drawingml/diagram/makefile.mk
+++ b/oox/source/drawingml/diagram/makefile.mk
@@ -41,6 +41,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Files --------------------------------------------------------
SLOFILES = \
+ $(SLO)$/constraintlistcontext.obj \
$(SLO)$/diagram.obj \
$(SLO)$/diagramfragmenthandler.obj \
$(SLO)$/diagramdefinitioncontext.obj \
diff --git a/oox/source/drawingml/drawingmltypes.cxx b/oox/source/drawingml/drawingmltypes.cxx
index 2b0eeae3273f..3e2582ffcdf4 100644
--- a/oox/source/drawingml/drawingmltypes.cxx
+++ b/oox/source/drawingml/drawingmltypes.cxx
@@ -160,6 +160,7 @@ float GetFontHeight( sal_Int32 nHeight )
sal_Int16 GetFontUnderline( sal_Int32 nToken )
{
+ OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
switch( nToken )
{
case XML_none: return FontUnderline::NONE;
@@ -186,6 +187,7 @@ sal_Int16 GetFontUnderline( sal_Int32 nToken )
sal_Int16 GetFontStrikeout( sal_Int32 nToken )
{
+ OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
switch( nToken )
{
case XML_dblStrike: return FontStrikeout::DOUBLE;
@@ -208,6 +210,7 @@ sal_Int16 GetCaseMap( sal_Int32 nToken )
/** converts a paragraph align to a ParaAdjust */
sal_Int16 GetParaAdjust( sal_Int32 nAlign )
{
+ OSL_ASSERT((nAlign & sal_Int32(0xFFFF0000))==0);
sal_Int16 nEnum;
switch( nAlign )
{
@@ -236,6 +239,7 @@ sal_Int16 GetParaAdjust( sal_Int32 nAlign )
TabAlign GetTabAlign( sal_Int32 aToken )
{
+ OSL_ASSERT((aToken & sal_Int32(0xFFFF0000))==0);
TabAlign nEnum;
switch( aToken )
{
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index e7351424d924..dd1bf960166f 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -79,6 +79,7 @@ static const sal_Int32 spnDefaultFillIds[ FillId_END ] =
BitmapMode lclGetBitmapMode( sal_Int32 nToken )
{
+ OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
switch( nToken )
{
case XML_tile: return BitmapMode_REPEAT;
@@ -89,6 +90,7 @@ BitmapMode lclGetBitmapMode( sal_Int32 nToken )
RectanglePoint lclGetRectanglePoint( sal_Int32 nToken )
{
+ OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
switch( nToken )
{
case XML_tl: return RectanglePoint_LEFT_TOP;
@@ -223,6 +225,7 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rM
if( moFillType.has() )
{
FillStyle eFillStyle = FillStyle_NONE;
+ OSL_ASSERT((moFillType.get() & sal_Int32(0xFFFF0000))==0);
switch( moFillType.get() )
{
case XML_noFill:
diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx
index 1631920c6452..45ef18e57741 100644
--- a/oox/source/drawingml/graphicshapecontext.cxx
+++ b/oox/source/drawingml/graphicshapecontext.cxx
@@ -32,7 +32,7 @@
#include "oox/drawingml/fillpropertiesgroupcontext.hxx"
#include "oox/drawingml/customshapeproperties.hxx"
-#include "oox/drawingml/diagram/diagramfragmenthandler.hxx"
+#include "oox/drawingml/diagram/diagram.hxx"
#include "oox/drawingml/table/tablecontext.hxx"
#include "oox/core/namespaces.hxx"
#include "oox/core/xmlfilterbase.hxx"
@@ -94,7 +94,7 @@ Reference< XFastContextHandler > GraphicShapeContext::createFastChildContext( sa
(mpShapePtr->getCustomShapeProperties());
sal_uInt32 nType = aElementToken & (~ NMSP_MASK);
- OUString sType(GetShapeType(nType));
+ OUString sType(GetShapePresetType(nType));
if (sType.getLength() > 0)
pCstmShpProps->setShapePresetType(sType);
@@ -119,6 +119,7 @@ Reference< XFastContextHandler > GraphicalObjectFrameContext::createFastChildCon
{
Reference< XFastContextHandler > xRet;
+ OSL_ASSERT(((aElementToken &(~NMSP_MASK)) & sal_Int32(0xFFFF0000))==0);
switch( aElementToken &(~NMSP_MASK) )
{
// CT_ShapeProperties
@@ -277,48 +278,6 @@ DiagramGraphicDataContext::~DiagramGraphicDataContext()
{
}
-DiagramPtr DiagramGraphicDataContext::loadDiagram()
-{
- DiagramPtr pDiagram( new Diagram() );
- XmlFilterBase& rFilter = getFilter();
-
- // data
- OUString sDmPath = getFragmentPathFromRelId( msDm );
- if( sDmPath.getLength() > 0 )
- {
- DiagramDataPtr pData( new DiagramData() );
- pDiagram->setData( pData );
- rFilter.importFragment( new DiagramDataFragmentHandler( rFilter, sDmPath, pData ) );
- }
- // layout
- OUString sLoPath = getFragmentPathFromRelId( msLo );
- if( sLoPath.getLength() > 0 )
- {
- DiagramLayoutPtr pLayout( new DiagramLayout() );
- pDiagram->setLayout( pLayout );
- rFilter.importFragment( new DiagramLayoutFragmentHandler( rFilter, sLoPath, pLayout ) );
- }
- // style
- OUString sQsPath = getFragmentPathFromRelId( msQs );
- if( sQsPath.getLength() > 0 )
- {
- DiagramQStylesPtr pStyles( new DiagramQStyles() );
- pDiagram->setQStyles( pStyles );
- rFilter.importFragment( new DiagramQStylesFragmentHandler( rFilter, sQsPath, pStyles ) );
- }
- // colors
- OUString sCsPath = getFragmentPathFromRelId( msCs );
- if( sCsPath.getLength() > 0 )
- {
- DiagramColorsPtr pColors( new DiagramColors() );
- pDiagram->setColors( pColors );
- rFilter.importFragment( new DiagramColorsFragmentHandler( rFilter, sCsPath, pColors ) ) ;
- }
-
- return pDiagram;
-}
-
-
Reference< XFastContextHandler > DiagramGraphicDataContext::createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs )
throw (SAXException, RuntimeException)
{
@@ -332,8 +291,12 @@ Reference< XFastContextHandler > DiagramGraphicDataContext::createFastChildConte
msLo = xAttribs->getOptionalValue( NMSP_RELATIONSHIPS|XML_lo );
msQs = xAttribs->getOptionalValue( NMSP_RELATIONSHIPS|XML_qs );
msCs = xAttribs->getOptionalValue( NMSP_RELATIONSHIPS|XML_cs );
- DiagramPtr pDiagram = loadDiagram();
- pDiagram->addTo( mpShapePtr );
+ loadDiagram(mpShapePtr,
+ getFilter(),
+ getFragmentPathFromRelId( msDm ),
+ getFragmentPathFromRelId( msLo ),
+ getFragmentPathFromRelId( msQs ),
+ getFragmentPathFromRelId( msCs ));
OSL_TRACE("diagram added shape %s of type %s", OUSTRING_TO_CSTR( mpShapePtr->getName() ),
OUSTRING_TO_CSTR( mpShapePtr->getServiceName() ) );
break;
@@ -392,7 +355,8 @@ void CreateChartCallback::onXShapeCreated( const Reference< drawing::XShape >& r
Reference< drawing::XShapes > xExternalPage;
if( !mbEmbedShapes )
xExternalPage = rxShapes;
- mrFilter.getChartConverter().convertFromModel( mrFilter, aModel, xChartDoc, xExternalPage, rxShape->getPosition(), rxShape->getSize() );
+ if( mrFilter.getChartConverter() )
+ mrFilter.getChartConverter()->convertFromModel( mrFilter, aModel, xChartDoc, xExternalPage, rxShape->getPosition(), rxShape->getSize() );
}
catch( Exception& )
{
diff --git a/oox/source/drawingml/lineproperties.cxx b/oox/source/drawingml/lineproperties.cxx
index 7bc60f026665..17266e4efe3f 100644
--- a/oox/source/drawingml/lineproperties.cxx
+++ b/oox/source/drawingml/lineproperties.cxx
@@ -160,6 +160,7 @@ void lclConvertCustomDash( LineDash& orLineDash, const LineProperties::DashStopV
DashStyle lclGetDashStyle( sal_Int32 nToken )
{
+ OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
switch( nToken )
{
case XML_rnd: return DashStyle_ROUNDRELATIVE;
@@ -171,6 +172,7 @@ DashStyle lclGetDashStyle( sal_Int32 nToken )
LineJoint lclGetLineJoint( sal_Int32 nToken )
{
+ OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
switch( nToken )
{
case XML_round: return LineJoint_ROUND;
@@ -186,6 +188,7 @@ const sal_Int32 OOX_ARROWSIZE_LARGE = 2;
sal_Int32 lclGetArrowSize( sal_Int32 nToken )
{
+ OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
switch( nToken )
{
case XML_sm: return OOX_ARROWSIZE_SMALL;
@@ -207,6 +210,7 @@ void lclPushMarkerProperties( PropertyMap& rPropMap, const LineArrowProperties&
OUStringBuffer aBuffer;
sal_Int32 nArrowType = rArrowProps.moArrowType.get( XML_none );
+ OSL_ASSERT((nArrowType & sal_Int32(0xFFFF0000))==0);
switch( nArrowType )
{
case XML_triangle:
@@ -263,6 +267,7 @@ void lclPushMarkerProperties( PropertyMap& rPropMap, const LineArrowProperties&
#define OOX_ARROW_POINT( x, y ) Point( static_cast< sal_Int32 >( fArrowWidth * x ), static_cast< sal_Int32 >( fArrowLength * y ) )
::std::vector< Point > aPoints;
+ OSL_ASSERT((rArrowProps.moArrowType.get() & sal_Int32(0xFFFF0000))==0);
switch( rArrowProps.moArrowType.get() )
{
case XML_triangle:
diff --git a/oox/source/drawingml/makefile.mk b/oox/source/drawingml/makefile.mk
index e2d4ea6b8f3d..5079b02c1da1 100644
--- a/oox/source/drawingml/makefile.mk
+++ b/oox/source/drawingml/makefile.mk
@@ -59,6 +59,7 @@ SLOFILES = \
$(SLO)$/linepropertiescontext.obj\
$(SLO)$/objectdefaultcontext.obj\
$(SLO)$/shape.obj\
+ $(SLO)$/shape3dproperties.obj\
$(SLO)$/shapecontext.obj\
$(SLO)$/shapegroupcontext.obj\
$(SLO)$/shapepropertiescontext.obj\
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 8cdd2d6541e3..8483e730a2c0 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -42,8 +42,10 @@
#include <tools/solar.h> // for the F_PI180 define
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/beans/XMultiPropertySet.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/xml/AttributeData.hpp>
#include <com/sun/star/drawing/HomogenMatrix3.hpp>
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include <com/sun/star/text/XText.hpp>
@@ -106,6 +108,34 @@ Shape::Shape( const sal_Char* pServiceName )
msServiceName = OUString::createFromAscii( pServiceName );
setDefaults();
}
+
+Shape::Shape( const ShapePtr& pSourceShape )
+: maChildren()
+, mbIsChild( pSourceShape->mbIsChild )
+, mpTextBody(pSourceShape->mpTextBody)
+, mpLinePropertiesPtr( pSourceShape->mpLinePropertiesPtr )
+, mpFillPropertiesPtr( pSourceShape->mpFillPropertiesPtr )
+, mpGraphicPropertiesPtr( pSourceShape->mpGraphicPropertiesPtr )
+, mpCustomShapePropertiesPtr( pSourceShape->mpCustomShapePropertiesPtr )
+, mpTablePropertiesPtr( pSourceShape->mpTablePropertiesPtr )
+, mp3DPropertiesPtr( pSourceShape->mp3DPropertiesPtr )
+, maShapeProperties( pSourceShape->maShapeProperties )
+, mpMasterTextListStyle( pSourceShape->mpMasterTextListStyle )
+, mxShape()
+, msServiceName( pSourceShape->msServiceName )
+, msName( pSourceShape->msName )
+, msId( pSourceShape->msId )
+, mnSubType( pSourceShape->mnSubType )
+, mnSubTypeIndex( pSourceShape->mnSubTypeIndex )
+, maShapeStyleRefs( pSourceShape->maShapeStyleRefs )
+, maSize( pSourceShape->maSize )
+, maPosition( pSourceShape->maPosition )
+, mxCreateCallback( pSourceShape->mxCreateCallback )
+, mnRotation( pSourceShape->mnRotation )
+, mbFlipH( pSourceShape->mbFlipH )
+, mbFlipV( pSourceShape->mbFlipV )
+{}
+
Shape::~Shape()
{
}
@@ -195,6 +225,19 @@ void Shape::applyShapeReference( const Shape& rReferencedShape )
mbHidden = rReferencedShape.mbHidden;
}
+void Shape::addChildren( const ::oox::core::XmlFilterBase& rFilterBase,
+ const Theme* pTheme,
+ const Reference< XShapes >& rxShapes,
+ const awt::Rectangle* pShapeRect,
+ ShapeIdMap* pShapeMap )
+{
+ addChildren(rFilterBase, *this, pTheme, rxShapes,
+ pShapeRect ?
+ *pShapeRect :
+ awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ),
+ pShapeMap);
+}
+
// for group shapes, the following method is also adding each child
void Shape::addChildren(
const ::oox::core::XmlFilterBase& rFilterBase,
diff --git a/oox/source/drawingml/shapepropertiescontext.cxx b/oox/source/drawingml/shapepropertiescontext.cxx
index 470433af0556..4fa8acb8451b 100644
--- a/oox/source/drawingml/shapepropertiescontext.cxx
+++ b/oox/source/drawingml/shapepropertiescontext.cxx
@@ -35,6 +35,7 @@
#include <com/sun/star/container/XNamed.hpp>
#include "oox/core/namespaces.hxx"
+#include "oox/drawingml/scene3dcontext.hxx"
#include "oox/drawingml/linepropertiescontext.hxx"
#include "oox/drawingml/fillpropertiesgroupcontext.hxx"
#include "oox/drawingml/transform2dcontext.hxx"
@@ -106,8 +107,11 @@ Reference< XFastContextHandler > ShapePropertiesContext::createFastChildContext(
case NMSP_DRAWINGML|XML_effectDag: // CT_EffectContainer
break;
- // todo
case NMSP_DRAWINGML|XML_scene3d: // CT_Scene3D
+// xRet.set( new Scene3DContext( *this, xAttribs, *(mrShape.get3DShapeProperties()) ) );
+ break;
+
+ // todo
case NMSP_DRAWINGML|XML_sp3d: // CT_Shape3D
break;
}
diff --git a/oox/source/drawingml/textparagraph.cxx b/oox/source/drawingml/textparagraph.cxx
index feda8f2ac00d..d31e911e4996 100644
--- a/oox/source/drawingml/textparagraph.cxx
+++ b/oox/source/drawingml/textparagraph.cxx
@@ -63,6 +63,9 @@ void TextParagraph::insertAt(
Reference< XTextRange > xStart( xAt, UNO_QUERY );
sal_Int16 nLevel = maProperties.getLevel();
+
+ OSL_TRACE("TextParagraph::insertAt() - level %d", nLevel);
+
const TextParagraphPropertiesVector& rListStyle = rTextListStyle.getListStyle();
if ( nLevel >= static_cast< sal_Int16 >( rListStyle.size() ) )
nLevel = 0;
@@ -114,6 +117,12 @@ void TextParagraph::insertAt(
const OUString sNumberingLevel( CREATE_OUSTRING( "NumberingLevel" ) );
xProps->setPropertyValue( sNumberingLevel, Any( static_cast< sal_Int16 >( -1 ) ) );
}
+ else if ( nLevel > 1 )
+ {
+ // Even more UGLY HACK
+ const OUString sNumberingLevel( CREATE_OUSTRING( "NumberingLevel" ) );
+ xProps->setPropertyValue( sNumberingLevel, Any( static_cast< sal_Int16 >( nLevel-1 ) ) );
+ }
// FIXME this is causing a lot of dispruption (ie does not work). I wonder what to do -- Hub
// Reference< XTextRange > xEnd( xAt, UNO_QUERY );
diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx
index 68aad1f3cf26..f818a5defca6 100644
--- a/oox/source/drawingml/textparagraphproperties.cxx
+++ b/oox/source/drawingml/textparagraphproperties.cxx
@@ -114,6 +114,7 @@ void BulletList::setSuffixMinusRight()
void BulletList::setType( sal_Int32 nType )
{
+ OSL_ASSERT((nType & sal_Int32(0xFFFF0000))==0);
// OSL_TRACE( "OOX: set list numbering type %d", nType);
switch( nType )
{
diff --git a/oox/source/helper/storagebase.cxx b/oox/source/helper/storagebase.cxx
index 3abd50f81628..6aeb49f79649 100644
--- a/oox/source/helper/storagebase.cxx
+++ b/oox/source/helper/storagebase.cxx
@@ -50,17 +50,25 @@ namespace oox {
namespace {
-void lclSplitFirstElement( OUString& orElement, OUString& orRemainder, const OUString& rFullName )
+void lclSplitFirstElement( OUString& orElement, OUString& orRemainder, OUString aFullName )
{
- sal_Int32 nSlashPos = rFullName.indexOf( '/' );
- if( (0 <= nSlashPos) && (nSlashPos < rFullName.getLength()) )
+ sal_Int32 nSlashPos = aFullName.indexOf( '/' );
+
+ // strip leading slashes
+ while( nSlashPos == 0 )
+ {
+ aFullName = aFullName.copy(1);
+ nSlashPos = aFullName.indexOf( '/' );
+ }
+
+ if( (0 <= nSlashPos) && (nSlashPos < aFullName.getLength()) )
{
- orElement = rFullName.copy( 0, nSlashPos );
- orRemainder = rFullName.copy( nSlashPos + 1 );
+ orElement = aFullName.copy( 0, nSlashPos );
+ orRemainder = aFullName.copy( nSlashPos + 1 );
}
else
{
- orElement = rFullName;
+ orElement = aFullName;
}
}
diff --git a/oox/source/ppt/makefile.mk b/oox/source/ppt/makefile.mk
index 7ee7e0c46d68..46cfd4ffd917 100644
--- a/oox/source/ppt/makefile.mk
+++ b/oox/source/ppt/makefile.mk
@@ -50,6 +50,8 @@ SLOFILES = \
$(SLO)$/commontimenodecontext.obj \
$(SLO)$/conditioncontext.obj \
$(SLO)$/customshowlistcontext.obj \
+ $(SLO)$/dgmimport.obj\
+ $(SLO)$/dgmlayout.obj\
$(SLO)$/headerfootercontext.obj \
$(SLO)$/layoutfragmenthandler.obj\
$(SLO)$/pptfilterhelpers.obj\
diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx
index a48977ae1f31..440704ffe84a 100644
--- a/oox/source/ppt/pptimport.cxx
+++ b/oox/source/ppt/pptimport.cxx
@@ -173,9 +173,9 @@ const oox::drawingml::table::TableStyleListPtr PowerPointImport::getTableStyles(
return mpTableStyleList;;
}
-::oox::drawingml::chart::ChartConverter& PowerPointImport::getChartConverter()
+::oox::drawingml::chart::ChartConverter* PowerPointImport::getChartConverter()
{
- return *mxChartConv;
+ return mxChartConv.get();
}
namespace {
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx
index 989577424125..1f3c93e7d4eb 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -33,6 +33,8 @@
#include <com/sun/star/drawing/XDrawPages.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#include <com/sun/star/drawing/XMasterPageTarget.hpp>
+#include <com/sun/star/xml/dom/XDocument.hpp>
+#include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/style/XStyle.hpp>
#include <com/sun/star/presentation/XPresentationPage.hpp>
@@ -231,8 +233,17 @@ void PresentationFragmentHandler::endDocument() throw (SAXException, RuntimeExce
{
oox::drawingml::ThemePtr pThemePtr( new oox::drawingml::Theme() );
pMasterPersistPtr->setTheme( pThemePtr );
- rFilter.importFragment( new ThemeFragmentHandler( rFilter, aThemeFragmentPath, *pThemePtr ) );
+ Reference<xml::dom::XDocument> xDoc=
+ rFilter.importFragment(aThemeFragmentPath);
+
+ rFilter.importFragment(
+ new ThemeFragmentHandler(
+ rFilter, aThemeFragmentPath, *pThemePtr ),
+ Reference<xml::sax::XFastSAXSerializable>(
+ xDoc,
+ UNO_QUERY_THROW));
rThemes[ aThemeFragmentPath ] = pThemePtr;
+ pThemePtr->setFragment(xDoc);
}
else
{
diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index c4ab81e51a0b..12c899c99c0a 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -166,6 +166,17 @@ void SlidePersist::createXShapes( const XmlFilterBase& rFilterBase )
pNode->setNode( rFilterBase, xNode, pSlidePtr );
}
}
+
+ // not yet
+#if 0
+ if( getTheme() )
+ {
+ uno::Reference< beans::XPropertySet > xPagePropSet( mxPage, uno::UNO_QUERY_THROW );
+ xPagePropSet->setPropertyValue(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PPTTheme" )),
+ uno::makeAny(getTheme()->getFragment()));
+ }
+#endif
}
void SlidePersist::createBackground( const XmlFilterBase& rFilterBase )
diff --git a/oox/source/shape/ShapeFilterBase.cxx b/oox/source/shape/ShapeFilterBase.cxx
index b390669a18ba..0f46b3fb5de8 100644
--- a/oox/source/shape/ShapeFilterBase.cxx
+++ b/oox/source/shape/ShapeFilterBase.cxx
@@ -61,9 +61,9 @@ const ::oox::drawingml::table::TableStyleListPtr ShapeFilterBase::getTableStyles
return ::oox::drawingml::table::TableStyleListPtr();
}
-::oox::drawingml::chart::ChartConverter& ShapeFilterBase::getChartConverter()
+::oox::drawingml::chart::ChartConverter* ShapeFilterBase::getChartConverter()
{
- return *mxChartConv;
+ return mxChartConv.get();
}
::rtl::OUString ShapeFilterBase::implGetImplementationName() const
diff --git a/oox/source/shape/ShapeFilterBase.hxx b/oox/source/shape/ShapeFilterBase.hxx
index 09cbc75e01aa..945ecf739979 100644
--- a/oox/source/shape/ShapeFilterBase.hxx
+++ b/oox/source/shape/ShapeFilterBase.hxx
@@ -58,7 +58,7 @@ public:
/** Has to be implemented by each filter to return TableStyles. */
virtual const ::oox::drawingml::table::TableStyleListPtr getTableStyles();
- virtual ::oox::drawingml::chart::ChartConverter& getChartConverter();
+ virtual ::oox::drawingml::chart::ChartConverter* getChartConverter();
virtual rtl::OUString implGetImplementationName() const;
diff --git a/oox/source/xls/excelfilter.cxx b/oox/source/xls/excelfilter.cxx
index 1093b5cc7bfe..276459334c01 100644
--- a/oox/source/xls/excelfilter.cxx
+++ b/oox/source/xls/excelfilter.cxx
@@ -152,7 +152,7 @@ const TableStyleListPtr ExcelFilter::getTableStyles()
return TableStyleListPtr();
}
-::oox::drawingml::chart::ChartConverter& ExcelFilter::getChartConverter()
+::oox::drawingml::chart::ChartConverter* ExcelFilter::getChartConverter()
{
return WorkbookHelper( getWorkbookData() ).getChartConverter();
}
diff --git a/oox/source/xls/workbookhelper.cxx b/oox/source/xls/workbookhelper.cxx
index f8a49c435244..0a99a653977d 100644
--- a/oox/source/xls/workbookhelper.cxx
+++ b/oox/source/xls/workbookhelper.cxx
@@ -203,7 +203,7 @@ public:
/** Returns the converter for string to cell address/range conversion. */
inline AddressConverter& getAddressConverter() const { return *mxAddrConverter; }
/** Returns the chart object converter. */
- inline ExcelChartConverter& getChartConverter() const { return *mxChartConverter; }
+ inline ExcelChartConverter* getChartConverter() const { return mxChartConverter.get(); }
/** Returns the page/print settings converter. */
inline PageSettingsConverter& getPageSettingsConverter() const { return *mxPageSettConverter; }
@@ -894,7 +894,7 @@ AddressConverter& WorkbookHelper::getAddressConverter() const
return mrBookData.getAddressConverter();
}
-ExcelChartConverter& WorkbookHelper::getChartConverter() const
+ExcelChartConverter* WorkbookHelper::getChartConverter() const
{
return mrBookData.getChartConverter();
}