summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMichael Brauer <mib@openoffice.org>2001-07-04 12:36:04 +0000
committerMichael Brauer <mib@openoffice.org>2001-07-04 12:36:04 +0000
commit3539b10f1d4be8e686219333850f4ded8d781f1d (patch)
tree2f07a497a9d9db8007ed224d2a0df4353d4b2148 /xmloff
parent52048ceee3e5de4b3955dd84c0dbc40d106613d3 (diff)
Move SvXMLAttrContainerItem to SVX, moved writer only code to sw
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/unoatrcn.hxx12
-rw-r--r--xmloff/source/core/unoatrcn.cxx8
-rw-r--r--xmloff/source/core/xmlcnitm.cxx302
3 files changed, 74 insertions, 248 deletions
diff --git a/xmloff/inc/unoatrcn.hxx b/xmloff/inc/unoatrcn.hxx
index 888ef2c30128..cbba0dd29b19 100644
--- a/xmloff/inc/unoatrcn.hxx
+++ b/xmloff/inc/unoatrcn.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unoatrcn.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 17:07:01 $
+ * last change: $Author: mib $ $Date: 2001-07-04 13:33:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -78,7 +78,7 @@
extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SvUnoAttributeContainer_CreateInstance();
-class SvXMLAttrContainerItem_Impl;
+class SvXMLAttrContainerData;
class SvUnoAttributeContainer : public ::cppu::WeakAggImplHelper3<
::com::sun::star::lang::XServiceInfo,
@@ -86,15 +86,15 @@ class SvUnoAttributeContainer : public ::cppu::WeakAggImplHelper3<
::com::sun::star::container::XNameContainer >
{
private:
- SvXMLAttrContainerItem_Impl* mpContainer;
+ SvXMLAttrContainerData* mpContainer;
sal_uInt16 getIndexByName(const ::rtl::OUString& aName ) const;
public:
- SvUnoAttributeContainer( SvXMLAttrContainerItem_Impl* pContainer = NULL );
+ SvUnoAttributeContainer( SvXMLAttrContainerData* pContainer = NULL );
virtual ~SvUnoAttributeContainer();
- SvXMLAttrContainerItem_Impl* GetContainerImpl() const { return mpContainer; }
+ SvXMLAttrContainerData* GetContainerImpl() const { return mpContainer; }
static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
static SvUnoAttributeContainer* getImplementation( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInt ) throw();
diff --git a/xmloff/source/core/unoatrcn.cxx b/xmloff/source/core/unoatrcn.cxx
index 8b4be7eb0081..d5ba88c32a8d 100644
--- a/xmloff/source/core/unoatrcn.cxx
+++ b/xmloff/source/core/unoatrcn.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unoatrcn.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-19 00:31:44 $
+ * last change: $Author: mib $ $Date: 2001-07-04 13:36:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -97,11 +97,11 @@ uno::Reference< uno::XInterface > SvUnoAttributeContainer_CreateInstance()
return *(new SvUnoAttributeContainer);
}
-SvUnoAttributeContainer::SvUnoAttributeContainer( SvXMLAttrContainerItem_Impl* pContainer)
+SvUnoAttributeContainer::SvUnoAttributeContainer( SvXMLAttrContainerData* pContainer)
: mpContainer( pContainer )
{
if( mpContainer == NULL )
- mpContainer = new SvXMLAttrContainerItem_Impl;
+ mpContainer = new SvXMLAttrContainerData;
}
SvUnoAttributeContainer::~SvUnoAttributeContainer()
diff --git a/xmloff/source/core/xmlcnitm.cxx b/xmloff/source/core/xmlcnitm.cxx
index e8503bdd6612..cd110274109a 100644
--- a/xmloff/source/core/xmlcnitm.cxx
+++ b/xmloff/source/core/xmlcnitm.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlcnitm.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: er $ $Date: 2001-05-13 03:31:37 $
+ * last change: $Author: mib $ $Date: 2001-07-04 13:36:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,6 +59,9 @@
*
************************************************************************/
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
#ifndef _COM_SUN_STAR_XML_ATTRIBUTEDATA_HPP_
#include <com/sun/star/xml/AttributeData.hpp>
#endif
@@ -66,7 +69,6 @@
#include <com/sun/star/lang/XUnoTunnel.hpp>
#endif
-#include "xmlcnitm.hxx"
#include "xmlcnimp.hxx"
#include "unoatrcn.hxx"
@@ -76,34 +78,46 @@ using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::xml;
-SV_IMPL_PTRARR( OUStringsDtor2_Impl, OUStringPtr )
+typedef ::rtl::OUString *OUStringPtr;
+SV_DECL_PTRARR_DEL( SvXMLAttrContainerData_Impl, OUStringPtr, 5, 5 )
+SV_IMPL_PTRARR( SvXMLAttrContainerData_Impl, OUStringPtr )
-SvXMLAttrContainerItem_Impl::SvXMLAttrContainerItem_Impl(
- const SvXMLAttrContainerItem_Impl& rImpl ) :
- aNamespaceMap( rImpl.aNamespaceMap )
+SvXMLAttrContainerData::SvXMLAttrContainerData(
+ const SvXMLAttrContainerData& rImpl ) :
+ aNamespaceMap( rImpl.aNamespaceMap ),
+ pLNames( new SvXMLAttrContainerData_Impl ),
+ pValues( new SvXMLAttrContainerData_Impl )
{
- USHORT nCount = rImpl.aLNames.Count();
+ USHORT nCount = rImpl.pLNames->Count();
for( USHORT i=0; i<nCount; i++ )
{
aPrefixPoss.Insert( rImpl.aPrefixPoss[i], i );
- aLNames.Insert( new OUString( *rImpl.aLNames[i] ), i );
- aValues.Insert( new OUString( *rImpl.aValues[i] ), i );
+ pLNames->Insert( new OUString( *(*rImpl.pLNames)[i] ), i );
+ pValues->Insert( new OUString( *(*rImpl.pValues)[i] ), i );
}
}
-SvXMLAttrContainerItem_Impl::SvXMLAttrContainerItem_Impl()
+SvXMLAttrContainerData::SvXMLAttrContainerData() :
+ pLNames( new SvXMLAttrContainerData_Impl ),
+ pValues( new SvXMLAttrContainerData_Impl )
{
}
-int SvXMLAttrContainerItem_Impl::operator ==(
- const SvXMLAttrContainerItem_Impl& rCmp ) const
+SvXMLAttrContainerData::~SvXMLAttrContainerData()
{
- BOOL bRet = aLNames.Count() == rCmp.aLNames.Count() &&
+ delete pLNames;
+ delete pValues;
+}
+
+int SvXMLAttrContainerData::operator ==(
+ const SvXMLAttrContainerData& rCmp ) const
+{
+ BOOL bRet = pLNames->Count() == rCmp.pLNames->Count() &&
aNamespaceMap == rCmp.aNamespaceMap;
if( bRet )
{
- USHORT nCount = aLNames.Count();
+ USHORT nCount = pLNames->Count();
USHORT i;
for( i=0; bRet && i < nCount; i++ )
bRet = aPrefixPoss[i] == rCmp.aPrefixPoss[i];
@@ -111,38 +125,38 @@ int SvXMLAttrContainerItem_Impl::operator ==(
if( bRet )
{
for( i=0; bRet && i < nCount; i++ )
- bRet = *aLNames[i] == *rCmp.aLNames[i] &&
- *aValues[i] == *rCmp.aValues[i];
+ bRet = *(*pLNames)[i] == *(*rCmp.pLNames)[i] &&
+ *(*pValues)[i] == *(*rCmp.pValues)[i];
}
}
return (int)bRet;
}
-BOOL SvXMLAttrContainerItem_Impl::AddAttr( const OUString& rLName,
+BOOL SvXMLAttrContainerData::AddAttr( const OUString& rLName,
const OUString& rValue )
{
aPrefixPoss.Insert( USHRT_MAX, aPrefixPoss.Count() );
- aLNames.Insert( new OUString(rLName), aLNames.Count() );
- aValues.Insert( new OUString(rValue), aValues.Count() );
+ pLNames->Insert( new OUString(rLName), pLNames->Count() );
+ pValues->Insert( new OUString(rValue), pValues->Count() );
return TRUE;
}
-BOOL SvXMLAttrContainerItem_Impl::AddAttr( const OUString& rPrefix,
+BOOL SvXMLAttrContainerData::AddAttr( const OUString& rPrefix,
const OUString& rNamespace,
const OUString& rLName,
const OUString& rValue )
{
USHORT nPos = aNamespaceMap.Add( rPrefix, rNamespace );
aPrefixPoss.Insert( nPos, aPrefixPoss.Count() );
- aLNames.Insert( new OUString(rLName), aLNames.Count() );
- aValues.Insert( new OUString(rValue), aValues.Count() );
+ pLNames->Insert( new OUString(rLName), pLNames->Count() );
+ pValues->Insert( new OUString(rValue), pValues->Count() );
return TRUE;
}
-BOOL SvXMLAttrContainerItem_Impl::AddAttr( const OUString& rPrefix,
+BOOL SvXMLAttrContainerData::AddAttr( const OUString& rPrefix,
const OUString& rLName,
const OUString& rValue )
{
@@ -151,26 +165,26 @@ BOOL SvXMLAttrContainerItem_Impl::AddAttr( const OUString& rPrefix,
return FALSE;
aPrefixPoss.Insert( nPos, aPrefixPoss.Count() );
- aLNames.Insert( new OUString(rLName), aLNames.Count() );
- aValues.Insert( new OUString(rValue), aValues.Count() );
+ pLNames->Insert( new OUString(rLName), pLNames->Count() );
+ pValues->Insert( new OUString(rValue), pValues->Count() );
return TRUE;
}
-BOOL SvXMLAttrContainerItem_Impl::SetAt( USHORT i,
+BOOL SvXMLAttrContainerData::SetAt( USHORT i,
const rtl::OUString& rLName, const rtl::OUString& rValue )
{
if( i >= GetAttrCount() )
return FALSE;
- *aLNames[i] = rLName;
- *aValues[i] = rValue;
+ *(*pLNames)[i] = rLName;
+ *(*pValues)[i] = rValue;
aPrefixPoss[i] = USHRT_MAX;
return TRUE;
}
-BOOL SvXMLAttrContainerItem_Impl::SetAt( USHORT i,
+BOOL SvXMLAttrContainerData::SetAt( USHORT i,
const rtl::OUString& rPrefix, const rtl::OUString& rNamespace,
const rtl::OUString& rLName, const rtl::OUString& rValue )
{
@@ -181,14 +195,14 @@ BOOL SvXMLAttrContainerItem_Impl::SetAt( USHORT i,
if( USHRT_MAX == nPos )
return FALSE;
- *aLNames[i] = rLName;
- *aValues[i] = rValue;
+ *(*pLNames)[i] = rLName;
+ *(*pValues)[i] = rValue;
aPrefixPoss[i] = nPos;
return TRUE;
}
-BOOL SvXMLAttrContainerItem_Impl::SetAt( USHORT i,
+BOOL SvXMLAttrContainerData::SetAt( USHORT i,
const rtl::OUString& rPrefix,
const rtl::OUString& rLName,
const rtl::OUString& rValue )
@@ -200,21 +214,21 @@ BOOL SvXMLAttrContainerItem_Impl::SetAt( USHORT i,
if( USHRT_MAX == nPos )
return FALSE;
- *aLNames[i] = rLName;
- *aValues[i] = rValue;
+ *(*pLNames)[i] = rLName;
+ *(*pValues)[i] = rValue;
aPrefixPoss[i] = nPos;
return TRUE;
}
-void SvXMLAttrContainerItem_Impl::Remove( USHORT i )
+void SvXMLAttrContainerData::Remove( USHORT i )
{
if( i < GetAttrCount() )
{
- delete aLNames[i];
- aLNames.Remove( i );
- delete aValues[i];
- aValues.Remove( i );
+ delete (*pLNames)[i];
+ pLNames->Remove( i );
+ delete (*pValues)[i];
+ pValues->Remove( i );
aPrefixPoss.Remove( i );
}
else
@@ -223,210 +237,22 @@ void SvXMLAttrContainerItem_Impl::Remove( USHORT i )
}
}
-// ------------------------------------------------------------------------
-
-TYPEINIT1(SvXMLAttrContainerItem, SfxPoolItem);
-
-SvXMLAttrContainerItem::SvXMLAttrContainerItem( USHORT nWhich ) :
- SfxPoolItem( nWhich )
-{
- pImpl = new SvXMLAttrContainerItem_Impl;
-}
-
-SvXMLAttrContainerItem::SvXMLAttrContainerItem(
- const SvXMLAttrContainerItem& rItem ) :
- SfxPoolItem( rItem )
-{
- pImpl = new SvXMLAttrContainerItem_Impl( *rItem.pImpl );
-}
-
-SvXMLAttrContainerItem::~SvXMLAttrContainerItem()
-{
- delete pImpl;
-}
-
-int SvXMLAttrContainerItem::operator==( const SfxPoolItem& rItem ) const
+sal_uInt16 SvXMLAttrContainerData::GetAttrCount() const
{
- DBG_ASSERT( rItem.ISA(SvXMLAttrContainerItem),
- "SvXMLAttrContainerItem::operator ==(): Bad type");
- return *pImpl == *((const SvXMLAttrContainerItem&)rItem).pImpl;
+ return pLNames->Count();
}
-int SvXMLAttrContainerItem::Compare( const SfxPoolItem &rWith ) const
+const ::rtl::OUString& SvXMLAttrContainerData::GetAttrLName(sal_uInt16 i) const
{
- DBG_ASSERT( !this, "not yet implemented" );
-
- return 0;
+ OSL_ENSURE( i >= 0 && i < pLNames->Count(),
+ "SvXMLAttrContainerData::GetLName: illegal index" );
+ return *(*pLNames)[i];
}
-SfxItemPresentation SvXMLAttrContainerItem::GetPresentation(
- SfxItemPresentation ePresentation,
- SfxMapUnit eCoreMetric,
- SfxMapUnit ePresentationMetric,
- XubString &rText,
- const IntlWrapper *pIntlWrapper ) const
+const ::rtl::OUString& SvXMLAttrContainerData::GetAttrValue(sal_uInt16 i) const
{
- return SFX_ITEM_PRESENTATION_NONE;
+ OSL_ENSURE( i >= 0 && i < pValues->Count(),
+ "SvXMLAttrContainerData::GetValue: illegal index" );
+ return *(*pValues)[i];
}
-USHORT SvXMLAttrContainerItem::GetVersion( USHORT nFileFormatVersion ) const
-{
- // This item should never be stored
- return USHRT_MAX;
-}
-
-BOOL SvXMLAttrContainerItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
-{
- Reference<XNameContainer> xContainer =
- new SvUnoAttributeContainer( new SvXMLAttrContainerItem_Impl( *pImpl ) );
-
- rVal.setValue( &xContainer, ::getCppuType((Reference<XNameContainer>*)0) );
- return TRUE;
-}
-BOOL SvXMLAttrContainerItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId )
-{
- Reference<XInterface> xRef;
- SvUnoAttributeContainer* pContainer = NULL;
-
- if( rVal.getValue() != NULL && rVal.getValueType().getTypeClass() == TypeClass_INTERFACE )
- {
- xRef = *(Reference<XInterface>*)rVal.getValue();
- Reference<XUnoTunnel> xTunnel(xRef, UNO_QUERY);
- pContainer = (SvUnoAttributeContainer*)xTunnel->getSomething(SvUnoAttributeContainer::getUnoTunnelId());
- }
-
- if( pContainer )
- {
- delete pImpl;
- pImpl = new SvXMLAttrContainerItem_Impl( * pContainer->GetContainerImpl() );
- }
- else
- {
- SvXMLAttrContainerItem_Impl* pNewImpl = new SvXMLAttrContainerItem_Impl;
-
- try
- {
- Reference<XNameContainer> xContainer( xRef, UNO_QUERY );
- if( !xContainer.is() )
- return FALSE;
-
- const Sequence< OUString > aNameSequence( xContainer->getElementNames() );
- const OUString* pNames = aNameSequence.getConstArray();
- const INT32 nCount = aNameSequence.getLength();
- Any aAny;
- AttributeData* pData;
-
- for( INT32 nAttr = 0; nAttr < nCount; nAttr++ )
- {
- const OUString aName( *pNames++ );
-
- aAny = xContainer->getByName( aName );
- if( aAny.getValue() == NULL || aAny.getValueType() != ::getCppuType((AttributeData*)0) )
- return FALSE;
-
- pData = (AttributeData*)aAny.getValue();
- USHORT pos = aName.indexOf( sal_Unicode(':') );
- if( pos != -1 )
- {
- const OUString aPrefix( aName.copy( 0, pos ));
- const OUString aLName( aName.copy( pos+1 ));
-
- if( pData->Namespace.getLength() == 0 )
- {
- if( !pNewImpl->AddAttr( aPrefix, aLName, pData->Value ) )
- break;
- }
- else
- {
- if( !pNewImpl->AddAttr( aPrefix, pData->Namespace, aLName, pData->Value ) )
- break;
- }
- }
- else
- {
- if( !pNewImpl->AddAttr( aName, pData->Value ) )
- break;
- }
- }
-
- if( nAttr == nCount )
- {
- delete pImpl;
- pImpl = pNewImpl;
- return FALSE;
- }
- else
- {
- delete pNewImpl;
- }
- }
- catch(...)
- {
- delete pNewImpl;
- return FALSE;
- }
- }
- return TRUE;
-}
-
-
-BOOL SvXMLAttrContainerItem::AddAttr( const OUString& rLName,
- const OUString& rValue )
-{
- return pImpl->AddAttr( rLName, rValue );
-}
-
-BOOL SvXMLAttrContainerItem::AddAttr( const OUString& rPrefix,
- const OUString& rNamespace, const OUString& rLName,
- const OUString& rValue )
-{
- return pImpl->AddAttr( rPrefix, rNamespace, rLName, rValue );
-}
-
-USHORT SvXMLAttrContainerItem::GetAttrCount() const
-{
- return (USHORT)pImpl->GetAttrCount();
-}
-
-OUString SvXMLAttrContainerItem::GetAttrNamespace( USHORT i ) const
-{
- return pImpl->GetAttrNamespace( i );
-}
-
-OUString SvXMLAttrContainerItem::GetAttrPrefix( USHORT i ) const
-{
- return pImpl->GetAttrPrefix( i );
-}
-
-const OUString& SvXMLAttrContainerItem::GetAttrLName( USHORT i ) const
-{
- return pImpl->GetAttrLName( i );
-}
-
-const OUString& SvXMLAttrContainerItem::GetAttrValue( USHORT i ) const
-{
- return pImpl->GetAttrValue( i );
-}
-
-
-USHORT SvXMLAttrContainerItem::GetFirstNamespaceIndex() const
-{
- return pImpl->GetFirstNamespaceIndex();
-}
-
-USHORT SvXMLAttrContainerItem::GetNextNamespaceIndex( USHORT nIdx ) const
-{
- return pImpl->GetNextNamespaceIndex( nIdx );
-}
-
-const OUString& SvXMLAttrContainerItem::GetNamespace( USHORT i ) const
-{
- return pImpl->GetNamespace( i );
-}
-
-const OUString& SvXMLAttrContainerItem::GetPrefix( USHORT i ) const
-{
- return pImpl->GetPrefix( i );
-}
-
-