summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmloff/source/draw/shapeimport.cxx255
-rw-r--r--xmloff/source/draw/ximpshap.cxx47
-rw-r--r--xmloff/source/draw/ximpshap.hxx5
3 files changed, 167 insertions, 140 deletions
diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx
index bc3df8826564..c975bc5ef2b4 100644
--- a/xmloff/source/draw/shapeimport.cxx
+++ b/xmloff/source/draw/shapeimport.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: shapeimport.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: cl $ $Date: 2000-10-10 10:59:39 $
+ * last change: $Author: cl $ $Date: 2000-11-06 12:08:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -445,145 +445,152 @@ SvXMLImportContext* XMLShapeImportHelper::CreateGroupChildContext(
{
SvXMLImportContext *pContext = 0L;
- if(rShapes.is())
+ const SvXMLTokenMap& rTokenMap = GetGroupShapeElemTokenMap();
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ sal_Bool bIsPlaceholder(FALSE);
+ OUString aPresentationObjectClass;
+
+ for(sal_Int16 a(0); a < nAttrCount; a++)
{
- const SvXMLTokenMap& rTokenMap = GetGroupShapeElemTokenMap();
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- sal_Bool bIsPlaceholder(FALSE);
- OUString aPresentationObjectClass;
+ const OUString& rAttrName = xAttrList->getNameByIndex(a);
+ OUString aLocalName;
+ sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
- for(sal_Int16 a(0); a < nAttrCount; a++)
+ if(XML_NAMESPACE_PRESENTATION == nPrefix)
{
- const OUString& rAttrName = xAttrList->getNameByIndex(a);
- OUString aLocalName;
- sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
-
- if(XML_NAMESPACE_PRESENTATION == nPrefix)
+ if(aLocalName.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_placeholder))))
{
- if(aLocalName.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_placeholder))))
- {
- bIsPlaceholder = TRUE;
- }
- else if(aLocalName.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_class))))
- {
- aPresentationObjectClass = xAttrList->getValueByIndex(a);
- }
+ bIsPlaceholder = TRUE;
+ }
+ else if(aLocalName.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_class))))
+ {
+ aPresentationObjectClass = xAttrList->getValueByIndex(a);
}
}
+ }
- switch(rTokenMap.Get(nPrefix, rLocalName))
+ switch(rTokenMap.Get(nPrefix, rLocalName))
+ {
+ case XML_TOK_GROUP_GROUP:
{
- case XML_TOK_GROUP_GROUP:
+ // draw:g inside group context (RECURSIVE)
+ // create new group shape and add it to rShapes, use it
+ // as base for the new group import
+ uno::Reference< lang::XMultiServiceFactory > xServiceFact(mxModel, uno::UNO_QUERY);
+ if(xServiceFact.is())
{
- // draw:g inside group context (RECURSIVE)
- // create new group shape and add it to rShapes, use it
- // as base for the new group import
- uno::Reference< lang::XMultiServiceFactory > xServiceFact(mxModel, uno::UNO_QUERY);
- if(xServiceFact.is())
+ uno::Reference< drawing::XShape > xShape(
+ xServiceFact->createInstance(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GroupShape"))),
+ uno::UNO_QUERY);
+ if(xShape.is())
{
- uno::Reference< drawing::XShape > xShape(
- xServiceFact->createInstance(
- OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GroupShape"))),
- uno::UNO_QUERY);
- if(xShape.is())
- {
- rShapes->add( xShape );
+ addShape( xShape, xAttrList, rShapes );
- uno::Reference< drawing::XShapes > xNewShapes(xShape, uno::UNO_QUERY);
- if(xNewShapes.is())
- {
- pContext = new SdXMLGroupShapeContext( rImport, nPrefix, rLocalName, xNewShapes);
- }
+ uno::Reference< drawing::XShapes > xNewShapes(xShape, uno::UNO_QUERY);
+ if(xNewShapes.is())
+ {
+ pContext = new SdXMLGroupShapeContext( rImport, nPrefix, rLocalName, xNewShapes);
}
}
- break;
- }
- case XML_TOK_GROUP_RECT:
- {
- // draw:rect inside group context
- pContext = new SdXMLRectShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
- break;
- }
- case XML_TOK_GROUP_LINE:
- {
- // draw:line inside group context
- pContext = new SdXMLLineShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
- break;
- }
- case XML_TOK_GROUP_CIRCLE:
- case XML_TOK_GROUP_ELLIPSE:
- {
- // draw:circle or draw:ellipse inside group context
- pContext = new SdXMLEllipseShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
- break;
- }
- case XML_TOK_GROUP_POLYGON:
- case XML_TOK_GROUP_POLYLINE:
- {
- // draw:polygon or draw:polyline inside group context
- pContext = new SdXMLPolygonShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes,
- rTokenMap.Get(nPrefix, rLocalName) == XML_TOK_GROUP_POLYGON ? TRUE : FALSE );
- break;
- }
- case XML_TOK_GROUP_PATH:
- {
- // draw:path inside group context
- pContext = new SdXMLPathShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes);
- break;
- }
- case XML_TOK_GROUP_TEXT_BOX:
- {
- // text:text-box inside group context
- pContext = new SdXMLTextBoxShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
- break;
- }
- case XML_TOK_GROUP_CONTROL:
- {
- // draw:control inside group context
- pContext = new SdXMLControlShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
- break;
- }
- case XML_TOK_GROUP_CONNECTOR:
- {
- // draw:connector inside group context
- pContext = new SdXMLConnectorShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
- break;
- }
- case XML_TOK_GROUP_MEASURE:
- {
- // draw:measure inside group context
- pContext = new SdXMLMeasureShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
- break;
- }
- case XML_TOK_GROUP_PAGE:
- {
- // draw:page inside group context
- pContext = new SdXMLPageShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
- break;
- }
- case XML_TOK_GROUP_CAPTION:
- {
- // draw:caption inside group context
- pContext = new SdXMLCaptionShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
- break;
- }
- case XML_TOK_GROUP_CHART:
- {
- // chart:chart inside group context
- pContext = new SdXMLChartShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
- break;
}
- case XML_TOK_GROUP_IMAGE:
- {
- // office:image inside group context
- pContext = new SdXMLGraphicObjectShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
- break;
- }
-
- // add other shapes here...
+ break;
+ }
+ case XML_TOK_GROUP_RECT:
+ {
+ // draw:rect inside group context
+ pContext = new SdXMLRectShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
+ break;
+ }
+ case XML_TOK_GROUP_LINE:
+ {
+ // draw:line inside group context
+ pContext = new SdXMLLineShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
+ break;
+ }
+ case XML_TOK_GROUP_CIRCLE:
+ case XML_TOK_GROUP_ELLIPSE:
+ {
+ // draw:circle or draw:ellipse inside group context
+ pContext = new SdXMLEllipseShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
+ break;
}
+ case XML_TOK_GROUP_POLYGON:
+ case XML_TOK_GROUP_POLYLINE:
+ {
+ // draw:polygon or draw:polyline inside group context
+ pContext = new SdXMLPolygonShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes,
+ rTokenMap.Get(nPrefix, rLocalName) == XML_TOK_GROUP_POLYGON ? TRUE : FALSE );
+ break;
+ }
+ case XML_TOK_GROUP_PATH:
+ {
+ // draw:path inside group context
+ pContext = new SdXMLPathShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes);
+ break;
+ }
+ case XML_TOK_GROUP_TEXT_BOX:
+ {
+ // text:text-box inside group context
+ pContext = new SdXMLTextBoxShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
+ break;
+ }
+ case XML_TOK_GROUP_CONTROL:
+ {
+ // draw:control inside group context
+ pContext = new SdXMLControlShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
+ break;
+ }
+ case XML_TOK_GROUP_CONNECTOR:
+ {
+ // draw:connector inside group context
+ pContext = new SdXMLConnectorShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
+ break;
+ }
+ case XML_TOK_GROUP_MEASURE:
+ {
+ // draw:measure inside group context
+ pContext = new SdXMLMeasureShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
+ break;
+ }
+ case XML_TOK_GROUP_PAGE:
+ {
+ // draw:page inside group context
+ pContext = new SdXMLPageShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
+ break;
+ }
+ case XML_TOK_GROUP_CAPTION:
+ {
+ // draw:caption inside group context
+ pContext = new SdXMLCaptionShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
+ break;
+ }
+ case XML_TOK_GROUP_CHART:
+ {
+ // chart:chart inside group context
+ pContext = new SdXMLChartShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
+ break;
+ }
+ case XML_TOK_GROUP_IMAGE:
+ {
+ // office:image inside group context
+ pContext = new SdXMLGraphicObjectShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
+ break;
+ }
+
+ // add other shapes here...
}
return pContext;
}
+
+void XMLShapeImportHelper::addShape( uno::Reference< drawing::XShape >& rShape, const uno::Reference< xml::sax::XAttributeList >& xAttrList, uno::Reference< drawing::XShapes >& rShapes)
+ throw()
+{
+ if( rShape.is() && rShapes.is() )
+ {
+ // add new shape to parent
+ rShapes->add( rShape );
+ }
+}
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 3a98218c969a..1389a2bdaecc 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ximpshap.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: cl $ $Date: 2000-11-02 10:56:21 $
+ * last change: $Author: cl $ $Date: 2000-11-06 12:08:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -128,7 +128,8 @@ SdXMLShapeContext::SdXMLShapeContext(
mnRotate( 0L ),
mnStyleFamily(XML_STYLE_FAMILY_SD_GRAPHICS_ID),
mbIsPlaceholder(FALSE),
- mbIsUserTransformed(FALSE)
+ mbIsUserTransformed(FALSE),
+ mxAttrList(xAttrList)
{
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
for(sal_Int16 i=0; i < nAttrCount; i++)
@@ -189,7 +190,16 @@ SdXMLShapeContext::SdXMLShapeContext(
SdXMLShapeContext::~SdXMLShapeContext()
{
if(mxCursor.is())
+ {
+ // delete addition newline
+ const OUString aEmpty;
+ mxCursor->gotoEnd( sal_False );
+ mxCursor->goLeft( 1, sal_True );
+ mxCursor->setString( aEmpty );
+
+ // reset cursor
GetImport().GetTextImport()->ResetCursor();
+ }
if(mxOldCursor.is())
GetImport().GetTextImport()->SetCursor( mxOldCursor );
@@ -211,6 +221,11 @@ SvXMLImportContext *SdXMLShapeContext::CreateChildContext( USHORT nPrefix,
mxCursor = xText->createTextCursor();
if( mxCursor.is() )
{
+/*
+ const OUString aEmpty;
+ mxCursor->gotoEnd( sal_True );
+ mxCursor->setString( aEmpty );
+*/
GetImport().GetTextImport()->SetCursor( mxCursor );
}
}
@@ -254,13 +269,12 @@ void SdXMLShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeL
void SdXMLShapeContext::AddShape(uno::Reference< drawing::XShape >& xShape)
{
- if(xShape.is() && mxShapes.is())
+ if(xShape.is())
{
// set shape local
mxShape = xShape;
- // add new shape to parent
- mxShapes->add( xShape );
+ GetImport().GetShapeImport()->addShape( xShape, mxAttrList, mxShapes );
}
}
@@ -992,16 +1006,21 @@ void SdXMLTextBoxShapeContext::StartElement(const uno::Reference< xml::sax::XAtt
{
// Add, set Style and properties from base shape
AddShape(xShape);
- SetStyle();
- SdXMLShapeContext::StartElement(xAttrList);
- if(bIsPresShape && mbIsPlaceholder)
+ if(bIsPresShape && !mbIsPlaceholder)
{
- // Do something special if this is a placeholder (?)
-
+ uno::Reference< beans::XPropertySet > xProps(xShape, uno::UNO_QUERY);
+ if(xProps.is())
+ {
+ uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
+ if( xPropsInfo.is() && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
+ xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) );
+ }
+ }
+ SetStyle();
- }
+ SdXMLShapeContext::StartElement(xAttrList);
if(!bIsPresShape || mbIsUserTransformed)
{
@@ -1375,7 +1394,7 @@ SdXMLGraphicObjectShapeContext::SdXMLGraphicObjectShapeContext(
uno::Reference< drawing::XShape > xShape( xServiceFact->createInstance( aType ), uno::UNO_QUERY);
if(xShape.is())
{
- rShapes->add( xShape );
+ AddShape( xShape );
if( !mbIsPlaceholder )
{
@@ -1478,7 +1497,7 @@ SdXMLChartShapeContext::SdXMLChartShapeContext(
uno::Reference< drawing::XShape > xShape( xServiceFact->createInstance( aType ), uno::UNO_QUERY);
if(xShape.is())
{
- rShapes->add( xShape );
+ AddShape( xShape );
if( !mbIsPlaceholder )
{
diff --git a/xmloff/source/draw/ximpshap.hxx b/xmloff/source/draw/ximpshap.hxx
index 69493753cba7..7af98b3bdb9b 100644
--- a/xmloff/source/draw/ximpshap.hxx
+++ b/xmloff/source/draw/ximpshap.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ximpshap.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: cl $ $Date: 2000-11-02 10:56:21 $
+ * last change: $Author: cl $ $Date: 2000-11-06 12:08:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -97,6 +97,7 @@ protected:
com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxShape;
com::sun::star::uno::Reference< com::sun::star::text::XTextCursor > mxCursor;
com::sun::star::uno::Reference< com::sun::star::text::XTextCursor > mxOldCursor;
+ com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList> mxAttrList;
rtl::OUString maDrawStyleName;
rtl::OUString maPresentationClass;
sal_Int32 mnRotate;