summaryrefslogtreecommitdiff
path: root/sw/source/filter/xml
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/filter/xml')
-rw-r--r--sw/source/filter/xml/swxml.cxx16
-rw-r--r--sw/source/filter/xml/xmlexpit.cxx12
-rw-r--r--sw/source/filter/xml/xmliteme.cxx8
-rw-r--r--sw/source/filter/xml/xmltbli.cxx101
-rw-r--r--sw/source/filter/xml/xmltexte.cxx63
-rw-r--r--sw/source/filter/xml/xmltexte.hxx9
6 files changed, 131 insertions, 78 deletions
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index eb3508b20d22..271cdeabfedf 100644
--- a/sw/source/filter/xml/swxml.cxx
+++ b/sw/source/filter/xml/swxml.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: swxml.cxx,v $
*
- * $Revision: 1.49 $
+ * $Revision: 1.50 $
*
- * last change: $Author: tl $ $Date: 2002-11-20 14:33:04 $
+ * last change: $Author: hr $ $Date: 2003-03-27 15:42:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -100,6 +100,9 @@
#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_
#include <com/sun/star/io/XActiveDataSource.hpp>
#endif
+#ifndef _COM_SUN_STAR_PACKAGES_ZIP_ZIPIOEXCEPTION_HPP_
+#include <com/sun/star/packages/zip/ZipIOException.hpp>
+#endif
#include <svtools/svstdarr.hxx>
#ifndef _SFXDOCFILE_HXX //autogen wg. SfxMedium
@@ -346,6 +349,15 @@ sal_Int32 ReadThroughComponent(
#endif
return ERR_SWG_READ_ERROR;
}
+ catch( packages::zip::ZipIOException& r )
+ {
+#ifdef DEBUG
+ ByteString aError( "Zip exception catched while importing:\n" );
+ aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR( aError.GetBuffer() );
+#endif
+ return ERRCODE_IO_BROKENPACKAGE;
+ }
catch( io::IOException& r )
{
#ifdef DEBUG
diff --git a/sw/source/filter/xml/xmlexpit.cxx b/sw/source/filter/xml/xmlexpit.cxx
index 863377ff9a86..b7f25f9497ee 100644
--- a/sw/source/filter/xml/xmlexpit.cxx
+++ b/sw/source/filter/xml/xmlexpit.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlexpit.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: dvo $ $Date: 2002-06-19 13:07:54 $
+ * last change: $Author: hr $ $Date: 2003-03-27 15:42:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -243,8 +243,6 @@ void SvXMLExportItemMapper::exportXML( SvXMLAttributeList& rAttrList,
sal_uInt16 nFlags,
const SfxItemSet *pSet ) const
{
- OUString sCDATA( GetXMLToken(XML_CDATA) );
-
if( 0 != (rEntry.nMemberId & MID_FLAG_SPECIAL_ITEM_EXPORT) )
{
if( rItem.ISA( SvXMLAttrContainerItem ) )
@@ -281,7 +279,7 @@ void SvXMLExportItemMapper::exportXML( SvXMLAttributeList& rAttrList,
sName.append( GetXMLToken(XML_XMLNS) );
sName.append( sal_Unicode(':') );
sName.append( sPrefix );
- rAttrList.AddAttribute( sName.makeStringAndClear(), sCDATA,
+ rAttrList.AddAttribute( sName.makeStringAndClear(),
sNamespace );
}
@@ -290,7 +288,7 @@ void SvXMLExportItemMapper::exportXML( SvXMLAttributeList& rAttrList,
}
sName.append( pUnknown->GetAttrLName( i ) );
- rAttrList.AddAttribute( sName.makeStringAndClear(), sCDATA,
+ rAttrList.AddAttribute( sName.makeStringAndClear(),
pUnknown->GetAttrValue(i) );
}
@@ -311,7 +309,7 @@ void SvXMLExportItemMapper::exportXML( SvXMLAttributeList& rAttrList,
OUString sName(
rNamespaceMap.GetQNameByKey( rEntry.nNameSpace,
GetXMLToken(rEntry.eLocalName)));
- rAttrList.AddAttribute( sName, sCDATA, aValue );
+ rAttrList.AddAttribute( sName, aValue );
}
}
}
diff --git a/sw/source/filter/xml/xmliteme.cxx b/sw/source/filter/xml/xmliteme.cxx
index f3853a9c3a6d..cf806225419e 100644
--- a/sw/source/filter/xml/xmliteme.cxx
+++ b/sw/source/filter/xml/xmliteme.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmliteme.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: dvo $ $Date: 2001-10-26 12:02:47 $
+ * last change: $Author: hr $ $Date: 2003-03-27 15:42:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -146,7 +146,6 @@ extern SvXMLItemMapEntry aXMLTableCellItemMap[];
class SwXMLTableItemMapper_Impl: public SvXMLExportItemMapper
{
- const OUString sCDATA;
SwXMLBrushItemExport aBrushItemExport;
protected:
@@ -188,7 +187,6 @@ SwXMLTableItemMapper_Impl::SwXMLTableItemMapper_Impl(
SvXMLItemMapEntriesRef rMapEntries,
SwXMLExport& rExp ) :
SvXMLExportItemMapper( rMapEntries ),
- sCDATA( GetXMLToken( XML_CDATA ) ),
aBrushItemExport( rExp ),
nAbsWidth( USHRT_MAX )
{
@@ -206,7 +204,7 @@ void SwXMLTableItemMapper_Impl::AddAttribute( sal_uInt16 nPrefix,
{
OUString sName( rNamespaceMap.GetQNameByKey( nPrefix,
GetXMLToken(eLName) ) );
- rAttrList.AddAttribute( sName, sCDATA, rValue );
+ rAttrList.AddAttribute( sName, rValue );
}
void SwXMLTableItemMapper_Impl::handleSpecialItem(
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index 50df41ee5d32..51a98522f711 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmltbli.cxx,v $
*
- * $Revision: 1.40 $
+ * $Revision: 1.41 $
*
- * last change: $Author: hbrinkm $ $Date: 2002-12-04 16:24:56 $
+ * last change: $Author: hr $ $Date: 2003-03-27 15:42:26 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -170,6 +170,10 @@
#include <vos/mutex.hxx>
#endif
+#ifndef _NDTXT_HXX
+#include "ndtxt.hxx"
+#endif
+
using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -1738,7 +1742,8 @@ void SwXMLTableContext::InsertRepRows( sal_uInt32 nCount )
{
const SwXMLTableCell_Impl *pSrcCell =
GetCell( nCurRow-1, nCurCol );
- InsertCell( pSrcCell->GetStyleName(), 1U, pSrcCell->GetColSpan(),
+ InsertCell( pSrcCell->GetStyleName(), 1U,
+ pSrcCell->GetColSpan(),
InsertTableSection(), 0, pSrcCell->IsProtected(),
&pSrcCell->GetFormula(),
pSrcCell->HasValue(), pSrcCell->GetValue() );
@@ -2067,19 +2072,76 @@ SwTableBox *SwXMLTableContext::MakeTableBox(
if( pCell->GetStartNode() )
{
- const OUString& rFormula = pCell->GetFormula();
- if (rFormula.getLength() > 0)
+
+ // #104801# try to rescue broken documents with a certain pattern
+ // if: 1) the cell has a default number format (number 0)
+ // 2) the call has no formula
+ // 3) the value is 0.0
+ // 4) the text doesn't look anything like 0.0
+ // [read: length > 10, or length smaller 10 and no 0 in it]
+ // then make it a text cell!
+ bool bSuppressNumericContent = false;
+ if( pCell->HasValue() && (pCell->GetValue() == 0.0) &&
+ (pCell->GetFormula().getLength() == 0) &&
+ (sStyleName.getLength() != 0) )
{
- // formula cell: insert formula if valid
- SwTblBoxFormula aFormulaItem( rFormula );
- pBoxFmt->SetAttr( aFormulaItem );
+ // default num format?
+ const SfxPoolItem* pItem = NULL;
+ if( pBoxFmt->GetItemState( RES_BOXATR_FORMAT, FALSE, &pItem )
+ == SFX_ITEM_SET )
+ {
+ const SwTblBoxNumFormat* pNumFormat =
+ static_cast<const SwTblBoxNumFormat*>( pItem );
+ if( ( pNumFormat != NULL ) && ( pNumFormat->GetValue() == 0 ) )
+ {
+ // only one text node?
+ SwNodeIndex aNodeIndex( *(pCell->GetStartNode()), 1 );
+ if( ( aNodeIndex.GetNode().EndOfSectionIndex() -
+ aNodeIndex.GetNode().StartOfSectionIndex() ) == 2 )
+ {
+ SwTxtNode* pTxtNode= aNodeIndex.GetNode().GetTxtNode();
+ if( pTxtNode != NULL )
+ {
+ // check text: does it look like some form of 0.0?
+ const String& rText = pTxtNode->GetTxt();
+ if( ( rText.Len() > 10 ) ||
+ ( rText.Search( '0' ) == STRING_NOTFOUND ) )
+ {
+ bSuppressNumericContent = true;
+ }
+ }
+ }
+ else
+ bSuppressNumericContent = true; // several nodes
+ }
+ }
}
- // always insert value, even if default
- if( pCell->HasValue() )
+ if( bSuppressNumericContent )
{
- SwTblBoxValue aValueItem( pCell->GetValue() );
- pBoxFmt->SetAttr( aValueItem );
+ // suppress numeric content? Then reset number format!
+ pBoxFmt->ResetAttr( RES_BOXATR_FORMULA );
+ pBoxFmt->ResetAttr( RES_BOXATR_FORMAT );
+ pBoxFmt->ResetAttr( RES_BOXATR_VALUE );
+ }
+ else
+ {
+ // the normal case: set formula and value (if available)
+
+ const OUString& rFormula = pCell->GetFormula();
+ if (rFormula.getLength() > 0)
+ {
+ // formula cell: insert formula if valid
+ SwTblBoxFormula aFormulaItem( rFormula );
+ pBoxFmt->SetAttr( aFormulaItem );
+ }
+
+ // always insert value, even if default
+ if( pCell->HasValue() )
+ {
+ SwTblBoxValue aValueItem( pCell->GetValue() );
+ pBoxFmt->SetAttr( aValueItem );
+ }
}
// update cell content depend on the default language
@@ -2759,11 +2821,16 @@ const SwStartNode *SwXMLTableContext::InsertTableSection(
if( !pPrevSttNd )
{
pBox1->pSttNd = pStNd;
- SwTable& rTable = pTableNode->GetTable();
- SwFrmFmt *pTblFmt = rTable.GetFrmFmt();
- Reference < XCell > xCell( SwXCell::CreateXCell( pTblFmt, pBox1, 0, &rTable ) );
- Reference < XText > xText( xCell, UNO_QUERY );
- Reference < XTextCursor > xTextCursor = xText->createTextCursor();
+ SwCntntNode *pCNd = pDoc->GetNodes()[ pStNd->GetIndex() + 1 ]
+ ->GetCntntNode();
+ SwPosition aPos( *pCNd );
+ aPos.nContent.Assign( pCNd, 0U );
+
+ Reference < XTextRange > xTextRange =
+ SwXTextRange::CreateTextRangeFromPosition( pDoc, aPos, 0 );
+ Reference < XText > xText = xTextRange->getText();
+ Reference < XTextCursor > xTextCursor =
+ xText->createTextCursorByRange( xTextRange );
GetImport().GetTextImport()->SetCursor( xTextCursor );
}
}
diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx
index edea7b16d1f2..426c5abf43c5 100644
--- a/sw/source/filter/xml/xmltexte.cxx
+++ b/sw/source/filter/xml/xmltexte.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmltexte.cxx,v $
*
- * $Revision: 1.26 $
+ * $Revision: 1.27 $
*
- * last change: $Author: mib $ $Date: 2001-11-26 11:37:14 $
+ * last change: $Author: hr $ $Date: 2003-03-27 15:42:26 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -288,26 +288,6 @@ SwXMLTextParagraphExport::~SwXMLTextParagraphExport()
{
}
-void SwXMLTextParagraphExport::getTextEmbeddedObjectProperties(
- const Reference < XPropertySet >& rPropSet,
- OUString& rURL,
- sal_Bool& rExtern ) const
-{
- SwOLENode *pOLENd = GetNoTxtNode( rPropSet )->GetOLENode();
- SwOLEObj& rOLEObj = pOLENd->GetOLEObj();
-
- rURL = sEmbeddedObjectProtocol;
- rURL += rOLEObj.GetName();
- SvInfoObject *pInfo =
- pOLENd->GetDoc()->GetPersist()->Find( rOLEObj.GetName() );
- DBG_ASSERT( pInfo, "no info object for OLE object found" );
- if( pInfo )
- {
- SvGlobalName aClassName( pInfo->GetClassName() );
- rExtern = aOutplaceClassId == aClassName;
- }
-}
-
void SwXMLTextParagraphExport::setTextEmbeddedGraphicURL(
const Reference < XPropertySet >& rPropSet,
OUString& rURL) const
@@ -360,29 +340,32 @@ void lcl_addOutplaceProperties(
if( pEmbed )
{
const Rectangle& rVisArea = pEmbed->GetVisArea();
- Any aAny;
+ if( !rVisArea.IsEmpty() )
+ {
+ Any aAny;
- aAny <<= (sal_Int32)rVisArea.Left();
- *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_LEFT ), aAny );
- pStates++;
+ aAny <<= (sal_Int32)rVisArea.Left();
+ *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_LEFT ), aAny );
+ pStates++;
- aAny <<= (sal_Int32)rVisArea.Top();
- *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_TOP ), aAny );
- pStates++;
+ aAny <<= (sal_Int32)rVisArea.Top();
+ *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_TOP ), aAny );
+ pStates++;
- aAny <<= (sal_Int32)rVisArea.GetWidth();
- *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_WIDTH ), aAny );
- pStates++;
+ aAny <<= (sal_Int32)rVisArea.GetWidth();
+ *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_WIDTH ), aAny );
+ pStates++;
- aAny <<= (sal_Int32)rVisArea.GetHeight();
- *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_HEIGHT ), aAny );
- pStates++;
+ aAny <<= (sal_Int32)rVisArea.GetHeight();
+ *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_HEIGHT ), aAny );
+ pStates++;
- aAny <<= (sal_Int32)pEmbed->GetViewAspect();
- *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_DRAW_ASPECT ), aAny );
- pStates++;
+ aAny <<= (sal_Int32)pEmbed->GetViewAspect();
+ *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_DRAW_ASPECT ), aAny );
+ pStates++;
- // TODO: aspect
+ // TODO: aspect
+ }
}
}
@@ -551,7 +534,7 @@ void SwXMLTextParagraphExport::_exportTextEmbedded(
if( (rExport.getExportFlags() & EXPORT_EMBEDDED) == 0 )
{
OUString sURL( sEmbeddedObjectProtocol );
- sURL += rOLEObj.GetName();
+ sURL += pInfo->GetStorageName();
sURL = GetExport().AddEmbeddedObject( sURL );
lcl_addURL( rExport, sURL, sal_False );
}
diff --git a/sw/source/filter/xml/xmltexte.hxx b/sw/source/filter/xml/xmltexte.hxx
index a71cf928efc6..0673a237d9cf 100644
--- a/sw/source/filter/xml/xmltexte.hxx
+++ b/sw/source/filter/xml/xmltexte.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmltexte.hxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: mib $ $Date: 2001-03-21 10:19:54 $
+ * last change: $Author: hr $ $Date: 2003-03-27 15:42:27 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -115,11 +115,6 @@ public:
SvXMLAutoStylePoolP& rAutoStylePool );
~SwXMLTextParagraphExport();
- virtual void getTextEmbeddedObjectProperties(
- const ::com::sun::star::uno::Reference <
- ::com::sun::star::beans::XPropertySet >& rPropSet,
- ::rtl::OUString& rStreamName,
- sal_Bool& rExtern ) const;
virtual void setTextEmbeddedGraphicURL(
const ::com::sun::star::uno::Reference <
::com::sun::star::beans::XPropertySet >& rPropSet,