diff options
author | Douglas Mencken <dougmencken@gmail.com> | 2016-03-28 23:12:07 -0400 |
---|---|---|
committer | Douglas Mencken <dougmencken@gmail.com> | 2017-01-12 06:35:54 -0500 |
commit | 63a241a4ce0dfbc592e419b2b7f689a56ee54ad7 (patch) | |
tree | a9dd3c48cc4884c44e36a8eef3ef462341d70cef | |
parent | 7477af65e249e1b4f049f7d1f0c7878961b755e3 (diff) |
fix that Writer can't save a document in "alien" formats
plus refactor some debug messages
Change-Id: Ief962ea1b978bba5d36d194232962dc0364ef512
26 files changed, 601 insertions, 328 deletions
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index 501dd71f4880..58378c94d3c9 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -477,7 +477,7 @@ bool SvxLRSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const default: bRet = false; // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have? - OSL_FAIL("unknown MemberId"); + SAL_WARN( "editeng.items", "unknown MemberId ( " << OUString::number( nMemberId ) << " )" ); } return bRet; } @@ -550,7 +550,7 @@ bool SvxLRSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) break; default: - OSL_FAIL("unknown MemberId"); + SAL_WARN( "editeng.items", "unknown MemberId ( " << OUString::number( nMemberId ) << " )" ); return false; } return true; @@ -743,7 +743,7 @@ SfxPoolItem* SvxLRSpaceItem::Create( SvStream& rStrm, sal_uInt16 nVersion ) cons if ( nVersion >= LRSPACE_AUTOFIRST_VERSION ) { - rStrm.ReadUInt16( left ).ReadUInt16( prpleft ).ReadUInt16( right ).ReadUInt16( prpright ).ReadInt16( firstline ). ReadUInt16( prpfirstline ).ReadUInt16( txtleft ).ReadSChar( autofirst ); + rStrm.ReadUInt16( left ).ReadUInt16( prpleft ).ReadUInt16( right ).ReadUInt16( prpright ).ReadInt16( firstline ). ReadUInt16( prpfirstline ).ReadUInt16( txtleft ).ReadSChar( autofirst ); sal_uInt64 const nPos = rStrm.Tell(); sal_uInt32 nMarker; @@ -759,11 +759,11 @@ SfxPoolItem* SvxLRSpaceItem::Create( SvStream& rStrm, sal_uInt16 nVersion ) cons } else if ( nVersion == LRSPACE_TXTLEFT_VERSION ) { - rStrm.ReadUInt16( left ).ReadUInt16( prpleft ).ReadUInt16( right ).ReadUInt16( prpright ).ReadInt16( firstline ). ReadUInt16( prpfirstline ).ReadUInt16( txtleft ); + rStrm.ReadUInt16( left ).ReadUInt16( prpleft ).ReadUInt16( right ).ReadUInt16( prpright ).ReadInt16( firstline ). ReadUInt16( prpfirstline ).ReadUInt16( txtleft ); } else if ( nVersion == LRSPACE_16_VERSION ) { - rStrm.ReadUInt16( left ).ReadUInt16( prpleft ).ReadUInt16( right ).ReadUInt16( prpright ).ReadInt16( firstline ). ReadUInt16( prpfirstline ); + rStrm.ReadUInt16( left ).ReadUInt16( prpleft ).ReadUInt16( right ).ReadUInt16( prpright ).ReadInt16( firstline ). ReadUInt16( prpfirstline ); } else { @@ -944,7 +944,7 @@ bool SvxULSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) break; default: - OSL_FAIL("unknown MemberId"); + SAL_WARN( "editeng.items", "unknown MemberId ( " << OUString::number( nMemberId ) << " )" ); return false; } return true; @@ -3494,7 +3494,7 @@ bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const break; case MID_GRAPHIC: - SAL_WARN( "editeng.items", "not implemented" ); + SAL_WARN( "editeng.items", "MID_GRAPHIC is not implemented" ); break; case MID_GRAPHIC_TRANSPARENT: @@ -3598,7 +3598,7 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) rVal >>= sLink; if( sLink.startsWith( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) ) { - OSL_FAIL( "package urls aren't implemented" ); + SAL_WARN( "editeng.items", "package urls aren't implemented" ); } else if( sLink.startsWith( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) { diff --git a/oox/source/docprop/docprophandler.cxx b/oox/source/docprop/docprophandler.cxx index d7a1e31c1ea8..7f2901eeab6c 100644 --- a/oox/source/docprop/docprophandler.cxx +++ b/oox/source/docprop/docprophandler.cxx @@ -296,7 +296,7 @@ void SAL_CALL OOXMLDocPropHandler::startFastElement( ::sal_Int32 nElement, const } else { - OSL_FAIL( "Unexpected file format!" ); + OSL_FAIL( "Unexpected file format" ); } } else if ( m_nState && m_nInBlock == 1 ) // that tag should contain the property name @@ -489,7 +489,7 @@ void SAL_CALL OOXMLDocPropHandler::characters( const OUString& aChars ) break; default: - OSL_FAIL( "Unexpected core property!" ); + OSL_FAIL( "Unexpected core property" ); } } else if ( m_nState == EXTPR_TOKEN( Properties ) ) @@ -603,7 +603,7 @@ void SAL_CALL OOXMLDocPropHandler::characters( const OUString& aChars ) break; default: - OSL_FAIL( "Unexpected extended property!" ); + OSL_FAIL( "Unexpected extended property" ); } } else if ( m_nState == CUSTPR_TOKEN( Properties ) ) @@ -659,7 +659,7 @@ void SAL_CALL OOXMLDocPropHandler::characters( const OUString& aChars ) } else { - OSL_FAIL( "Unexpected tag in custom property!" ); + OSL_FAIL( "Unexpected tag in custom property" ); } } } @@ -675,7 +675,7 @@ void SAL_CALL OOXMLDocPropHandler::characters( const OUString& aChars ) catch( uno::Exception& e ) { throw xml::sax::SAXException( - OUString("Error while setting document property!"), + OUString( "Error while setting document property" ), uno::Reference< uno::XInterface >(), uno::makeAny( e ) ); } diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index 620fe68949ad..4bc80fc3a278 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -131,7 +131,11 @@ namespace sax_fastparser { void FastSaxSerializer::endDocument() { - assert(mbMarkStackEmpty && maMarkStack.empty()); + if( !mbMarkStackEmpty ) + SAL_WARN( "sax", "endDocument(): mbMarkStackEmpty is false" ); + if( !maMarkStack.empty() ) + SAL_WARN( "sax", "endDocument(): maMarkStack is not empty" ); + maCachedOutputStream.flush(); } diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 76ff7a30ec32..4878ef6d966d 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -1869,12 +1869,12 @@ void SfxMedium::Transfer_Impl() // makes sense only in case logic name is set if ( osl::FileBase::getFileURLFromSystemPath( pImpl->m_aName, aNameURL ) != osl::FileBase::E_None ) - SAL_WARN( "sfx.doc", "The medium name is not convertible!" ); + SAL_WARN( "sfx.doc", "The medium name is not convertible" ); } if ( !aNameURL.isEmpty() && ( !pImpl->m_eError || (pImpl->m_eError & ERRCODE_WARNING_MASK) ) ) { - SAL_INFO( "sfx.doc", "SfxMedium::Transfer_Impl, copying to target" ); + SAL_WARN( "sfx.doc", "copying to target" ); Reference < css::ucb::XCommandEnvironment > xEnv; Reference< XOutputStream > rOutStream; @@ -1972,7 +1972,7 @@ void SfxMedium::Transfer_Impl() if ( aFile.open( osl_File_OpenFlag_Write ) == osl::FileBase::E_None ) { aFile.sync(); - SAL_INFO( "sfx.doc", "fsync'd saved file '" << aDestURL << "'" ); + SAL_WARN( "sfx.doc", "fsync'd saved file '" << aDestURL << "'" ); aFile.close(); } } @@ -2947,6 +2947,7 @@ void SfxMedium::CompleteReOpen() pImpl->bUseInteractionHandler = bUseInteractionHandler; } + SfxMedium::SfxMedium(const OUString &rName, StreamMode nOpenMode, std::shared_ptr<const SfxFilter> pFilter, SfxItemSet *pInSet) : pImpl(new SfxMedium_Impl) { @@ -2955,8 +2956,11 @@ SfxMedium::SfxMedium(const OUString &rName, StreamMode nOpenMode, std::shared_pt pImpl->m_aLogicName = rName; pImpl->m_nStorOpenMode = nOpenMode; Init_Impl(); + + SAL_WARN( "sfx.doc", "created SfxMedium \"" << rName << "\"" ); } + SfxMedium::SfxMedium(const OUString &rName, const OUString &rReferer, StreamMode nOpenMode, std::shared_ptr<const SfxFilter> pFilter, SfxItemSet *pInSet) : pImpl(new SfxMedium_Impl) { @@ -2969,8 +2973,11 @@ SfxMedium::SfxMedium(const OUString &rName, const OUString &rReferer, StreamMode pImpl->m_aLogicName = rName; pImpl->m_nStorOpenMode = nOpenMode; Init_Impl(); + + SAL_WARN( "sfx.doc", "created SfxMedium \"" << rName << "\" with referer \"" << rReferer << "\"" ); } + SfxMedium::SfxMedium( const uno::Sequence<beans::PropertyValue>& aArgs ) : pImpl(new SfxMedium_Impl) { @@ -3021,7 +3028,7 @@ SfxMedium::SfxMedium( const uno::Sequence<beans::PropertyValue>& aArgs ) : } else { - SAL_WARN( "sfx.doc", "Can not create a new temporary file for crash recovery!\n" ); + SAL_WARN( "sfx.doc", "can't create a new temporary file for crash recovery" ); } } } @@ -3036,6 +3043,8 @@ SfxMedium::SfxMedium( const uno::Sequence<beans::PropertyValue>& aArgs ) : pImpl->m_nStorOpenMode = pImpl->m_bOriginallyLoadedReadOnly ? SFX_STREAM_READONLY : SFX_STREAM_READWRITE; Init_Impl(); + + SAL_WARN( "sfx.doc", "created SfxMedium from property values, file name item \"" << pFileNameItem->GetValue() << "\"" ); } @@ -3044,7 +3053,7 @@ SfxMedium::SfxMedium( const uno::Reference < embed::XStorage >& rStor, const OUS { OUString aType = SfxFilter::GetTypeFromStorage(rStor); pImpl->m_pFilter = SfxGetpApp()->GetFilterMatcher().GetFilter4EA( aType ); - DBG_ASSERT( pImpl->m_pFilter, "No Filter for storage found!" ); + DBG_ASSERT( pImpl->m_pFilter, "no filter for storage found" ); Init_Impl(); pImpl->xStorage = rStor; @@ -3054,6 +3063,8 @@ SfxMedium::SfxMedium( const uno::Reference < embed::XStorage >& rStor, const OUS GetItemSet()->Put( SfxStringItem( SID_DOC_BASEURL, rBaseURL ) ); if ( p ) GetItemSet()->Put( *p ); + + SAL_WARN( "sfx.doc", "created SfxMedium from XStorage: base URL \"" << rBaseURL << "\"" ); } @@ -3061,7 +3072,7 @@ SfxMedium::SfxMedium( const uno::Reference < embed::XStorage >& rStor, const OUS pImpl(new SfxMedium_Impl) { pImpl->m_pFilter = SfxGetpApp()->GetFilterMatcher().GetFilter4EA( rTypeName ); - DBG_ASSERT( pImpl->m_pFilter, "No Filter for storage found!" ); + DBG_ASSERT( pImpl->m_pFilter, "no filter for storage found" ); Init_Impl(); pImpl->xStorage = rStor; @@ -3071,6 +3082,8 @@ SfxMedium::SfxMedium( const uno::Reference < embed::XStorage >& rStor, const OUS GetItemSet()->Put( SfxStringItem( SID_DOC_BASEURL, rBaseURL ) ); if ( p ) GetItemSet()->Put( *p ); + + SAL_WARN( "sfx.doc", "created SfxMedium from XStorage: base URL \"" << rBaseURL << "\", type name \"" << rTypeName << "\"" ); } @@ -3087,12 +3100,12 @@ SfxMedium::~SfxMedium() if ( osl::FileBase::getFileURLFromSystemPath( pImpl->m_aName, aTemp ) != osl::FileBase::E_None ) { - SAL_WARN( "sfx.doc", "Physical name not convertible!"); + SAL_WARN( "sfx.doc", "physical name not convertible"); } if ( !::utl::UCBContentHelper::Kill( aTemp ) ) { - SAL_WARN( "sfx.doc", "Couldn't remove temporary file!"); + SAL_WARN( "sfx.doc", "couldn't remove temporary file"); } } } @@ -3173,9 +3186,7 @@ SvKeyValueIterator* SfxMedium::GetHeaderAttributes_Impl() pImpl->xAttributes->Append( SvKeyValue( OUString("content-type"), aContentType ) ); } - catch ( const css::uno::Exception& ) - { - } + catch ( const css::uno::Exception& ) { } } } @@ -3220,9 +3231,7 @@ uno::Sequence < util::RevisionTag > SfxMedium::GetVersionList( const uno::Refere { return xReader->load( xStorage ); } - catch ( const uno::Exception& ) - { - } + catch ( const uno::Exception& ) { } return uno::Sequence < util::RevisionTag >(); } diff --git a/sfx2/source/doc/docinf.cxx b/sfx2/source/doc/docinf.cxx index 27d986f3e83a..a918e6db88de 100644 --- a/sfx2/source/doc/docinf.cxx +++ b/sfx2/source/doc/docinf.cxx @@ -268,34 +268,51 @@ bool SaveOlePropertySet( "_PID_HLINKS" ); } - uno::Reference<beans::XPropertySet> xUserDefinedProps( - i_xDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW); - DBG_ASSERT(xUserDefinedProps.is(), "UserDefinedProperties is null"); - uno::Reference<beans::XPropertySetInfo> xPropInfo = - xUserDefinedProps->getPropertySetInfo(); - DBG_ASSERT(xPropInfo.is(), "UserDefinedProperties Info is null"); - uno::Sequence<beans::Property> props = xPropInfo->getProperties(); - for (sal_Int32 i = 0; i < props.getLength(); ++i) + try { - try + uno::Reference<beans::XPropertySet> xUserDefinedProps( + i_xDocProps->getUserDefinedProperties(), uno::UNO_QUERY ); + if ( xUserDefinedProps.is() ) { - // skip transient properties - if (~props[i].Attributes & beans::PropertyAttribute::TRANSIENT) + uno::Reference<beans::XPropertySetInfo> xPropInfo = + xUserDefinedProps->getPropertySetInfo(); + if ( xPropInfo.is() ) { - const OUString name = props[i].Name; - const sal_Int32 nPropId = rCustomSect.GetFreePropertyId(); - if (rCustomSect.SetAnyValue( nPropId, - xUserDefinedProps->getPropertyValue(name))) { - rCustomSect.SetPropertyName( nPropId, name ); + uno::Sequence<beans::Property> props = xPropInfo->getProperties(); + for ( sal_Int32 i = 0; i < props.getLength(); ++i ) + { + try + { + // skip transient properties + if ( ~props[i].Attributes & beans::PropertyAttribute::TRANSIENT ) + { + const OUString name = props[i].Name; + const sal_Int32 nPropId = rCustomSect.GetFreePropertyId(); + if (rCustomSect.SetAnyValue( nPropId, + xUserDefinedProps->getPropertyValue(name))) + { + rCustomSect.SetPropertyName( nPropId, name ); + } + } + } + catch ( ... ) + { + // may happen with concurrent modification + SAL_WARN( "sfx", "caught exception" ); + } } } + else + { + SAL_WARN( "sfx", "PropertySetInfo for UserDefinedProperties is nil" ); + } } - catch (const uno::Exception &) + else { - // may happen with concurrent modification... - SAL_INFO("sfx", "SavePropertySet: exception"); + SAL_WARN( "sfx", "UserDefinedProperties is nil" ); } } + catch ( ... ) { } // save the property set ErrCode nDocError = aDocSet.SavePropertySet(i_pStorage, diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 4077a2ab60f9..940eb1e297a3 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -1755,31 +1755,51 @@ void SfxStoringHelper::SetDocInfoState( try { uno::Reference< beans::XPropertySet > const xSet( - xDocPropsToFill->getUserDefinedProperties(), uno::UNO_QUERY); - uno::Reference< beans::XPropertyContainer > xContainer( xSet, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySetInfo > xSetInfo = xSet->getPropertySetInfo(); - uno::Sequence< beans::Property > lProps = xSetInfo->getProperties(); - const beans::Property* pProps = lProps.getConstArray(); - sal_Int32 c = lProps.getLength(); - sal_Int32 i = 0; - for (i=0; i<c; ++i) + xDocPropsToFill->getUserDefinedProperties(), uno::UNO_QUERY ); + if ( xSet.is() ) { - uno::Any aValue = xPropSet->getPropertyValue( pProps[i].Name ); - if ( pProps[i].Attributes & css::beans::PropertyAttribute::REMOVABLE ) + uno::Reference< beans::XPropertyContainer > xContainer( xSet, uno::UNO_QUERY ); + if ( xContainer.is() ) { - try + uno::Reference< beans::XPropertySetInfo > xSetInfo = xSet->getPropertySetInfo(); + if ( xSetInfo.is() ) { - // QUESTION: DefaultValue?! - xContainer->addProperty( pProps[i].Name, pProps[i].Attributes, aValue ); + uno::Sequence< beans::Property > lProps = xSetInfo->getProperties(); + const beans::Property* pProps = lProps.getConstArray(); + sal_Int32 c = lProps.getLength(); + for ( sal_Int32 i = 0; i < c; ++i ) + { + uno::Any aValue = xPropSet->getPropertyValue( pProps[i].Name ); + if ( pProps[i].Attributes & css::beans::PropertyAttribute::REMOVABLE ) + { + try + { + // QUESTION: DefaultValue? + xContainer->addProperty( pProps[i].Name, pProps[i].Attributes, aValue ); + } + catch (beans::PropertyExistException const&) { } + try + { + // it is possible that the propertysets from XML and binary files differ; shouldn't break then + xSet->setPropertyValue( pProps[i].Name, aValue ); + } + catch ( const uno::Exception& ) { } + } + } } - catch (beans::PropertyExistException const&) {} - try + else { - // it is possible that the propertysets from XML and binary files differ; we shouldn't break then - xSet->setPropertyValue( pProps[i].Name, aValue ); + SAL_WARN( "sfx.doc", "PropertySetInfo is nil" ); } - catch ( const uno::Exception& ) {} } + else + { + SAL_WARN( "sfx.doc", "PropertyContainer is nil" ); + } + } + else + { + SAL_WARN( "sfx.doc", "PropertySet is nil" ); } // sigh... have to set these manually I'm afraid... wonder why @@ -1802,9 +1822,9 @@ void SfxStoringHelper::SetDocInfoState( xDocPropsToFill->setEditingDuration(i_xOldDocProps->getEditingDuration()); // other attributes e.g. DocumentStatistics are not editable from dialog } - catch (const uno::Exception& e) + catch ( const uno::Exception& e ) { - SAL_INFO("sfx.doc", "SetDocInfoState: caught exception: " << e.Message); + SAL_WARN( "sfx.doc", "SetDocInfoState: caught exception: " << e.Message ); } // set the modified flag back if required diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index d2adf250c33c..72642a7a4ca3 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -1081,11 +1081,11 @@ bool SfxObjectShell::SaveTo_Impl */ { - SAL_INFO( "sfx.doc", "saving \"" << rMedium.GetName() << "\"" ); + SAL_WARN( "sfx.doc", "saving \"" << rMedium.GetName() << "\"" ); UpdateDocInfoForSave(); - AddLog( OSL_LOG_PREFIX "Begin" ); + SAL_WARN( "sfx.doc", "[ Begin ]" ); ModifyBlocker_Impl aMod(this); @@ -1124,7 +1124,7 @@ bool SfxObjectShell::SaveTo_Impl || pImpl->nScriptingSignatureState == SignatureState::NOTVALIDATED || pImpl->nScriptingSignatureState == SignatureState::INVALID ) ) { - AddLog( OSL_LOG_PREFIX "MacroSignaturePreserving" ); + SAL_WARN( "sfx.doc", "[ MacroSignaturePreserving ]" ); // the checking of the library modified state iterates over the libraries, should be done only when required // currently the check is commented out since it is broken, we have to check the signature every time we save @@ -1170,7 +1170,7 @@ bool SfxObjectShell::SaveTo_Impl && ::utl::UCBContentHelper::EqualURLs( pMedium->GetName(), rMedium.GetName() ) ) { bStoreToSameLocation = true; - AddLog( OSL_LOG_PREFIX "Save" ); + SAL_WARN( "sfx.doc", "[ Save ]" ); if ( pMedium->DocNeedsFileDateCheck() ) rMedium.CheckFileDate( pMedium->GetInitFileDate( false ) ); @@ -1186,7 +1186,7 @@ bool SfxObjectShell::SaveTo_Impl const bool bDoBackup = SvtSaveOptions().IsBackup(); if ( bDoBackup ) { - AddLog( OSL_LOG_PREFIX "DoBackup" ); + SAL_WARN( "sfx.doc", "[ DoBackup ]" ); rMedium.DoBackup_Impl(); if ( rMedium.GetError() ) { @@ -1214,7 +1214,7 @@ bool SfxObjectShell::SaveTo_Impl // if the last step is failed the stream should stay to be transacted and should be committed on any flush // so we can forget the stream in any way and the next storage commit will flush it - AddLog( OSL_LOG_PREFIX "Save: Own to Own" ); + SAL_WARN( "sfx.doc", "[ Save: Own to Own ]" ); bNeedsDisconnectionOnFail = DisconnectStorage_Impl( *pMedium, rMedium ); @@ -1237,7 +1237,7 @@ bool SfxObjectShell::SaveTo_Impl // just disconnect the stream from the source format // so that the target medium can use it - AddLog( OSL_LOG_PREFIX "Save: Alien to Alien" ); + SAL_WARN( "sfx.doc", "[ Save: Alien to Alien ]" ); pMedium->CloseAndRelease(); rMedium.CloseAndRelease(); @@ -1250,7 +1250,7 @@ bool SfxObjectShell::SaveTo_Impl // format is an own one so just disconnect the source // medium - AddLog( OSL_LOG_PREFIX "Save: Alien to Own" ); + SAL_WARN( "sfx.doc", "[ Save: Alien to Own ]" ); pMedium->CloseAndRelease(); rMedium.CloseAndRelease(); @@ -1262,7 +1262,7 @@ bool SfxObjectShell::SaveTo_Impl // an alien format, just connect the source to temporary // storage - AddLog( OSL_LOG_PREFIX "Save: Own to Alien" ); + SAL_WARN( "sfx.doc", "[ Save: Own to Alien ]" ); bNeedsDisconnectionOnFail = DisconnectStorage_Impl( *pMedium, rMedium ); @@ -1284,7 +1284,7 @@ bool SfxObjectShell::SaveTo_Impl // but for now the framework has to be ready for it // TODO/LATER: let the medium be prepared for alien formats as well - AddLog( OSL_LOG_PREFIX "SaveAs/Export" ); + SAL_WARN( "sfx.doc", "[ SaveAs/Export ]" ); rMedium.CloseAndRelease(); if ( bStorageBasedTarget ) @@ -1300,7 +1300,7 @@ bool SfxObjectShell::SaveTo_Impl return false; } - AddLog( OSL_LOG_PREFIX "Locking" ); + SAL_WARN( "sfx.doc", "[ Locking ]" ); rMedium.LockOrigFileOnDemand( false, false ); @@ -1353,14 +1353,14 @@ bool SfxObjectShell::SaveTo_Impl // TODO/LATER: get rid of bOk if (bOwnTarget && pFilter && !(pFilter->GetFilterFlags() & SfxFilterFlags::STARONEFILTER)) { - AddLog( OSL_LOG_PREFIX "Storing in own format." ); + SAL_WARN( "sfx.doc", "[ Storing in own format ]" ); uno::Reference< embed::XStorage > xMedStorage = rMedium.GetStorage(); if ( !xMedStorage.is() ) { // no saving without storage, unlock UI and return Lock_Impl( this, false ); pImpl->bForbidReload = bOldStat; - AddLog( OSL_LOG_PREFIX "Storing failed, still no error set." ); + SAL_WARN( "sfx.doc", "[ Storing failed, still no error set ]" ); return false; } @@ -1390,22 +1390,19 @@ bool SfxObjectShell::SaveTo_Impl if ( bOk ) { bOk = false; - // currently the case that the storage is the same should be impossible if ( xMedStorage == GetStorage() ) { - OSL_ENSURE( !pVersionItem, "This scenario is impossible currently!\n" ); - AddLog( OSL_LOG_PREFIX "Should be impossible." ); - // usual save procedure - bOk = Save(); + OSL_ENSURE( !pVersionItem, "storage is the same, currently this scenario is impossible" ); + bOk = Save(); // usual save } else { // save to target - AddLog( OSL_LOG_PREFIX "Save as own format." ); + SAL_WARN( "sfx.doc", "[ Save as own format ]" ); bOk = SaveAsOwnFormat( rMedium ); if ( bOk && pVersionItem ) { - AddLog( OSL_LOG_PREFIX "pVersionItem != NULL" ); + SAL_WARN( "sfx.doc", "pVersionItem is not nil" ); aTmpVersionURL = CreateTempCopyOfStorage_Impl( xMedStorage ); bOk = !aTmpVersionURL.isEmpty(); } @@ -1418,13 +1415,13 @@ bool SfxObjectShell::SaveTo_Impl { // store the thumbnail representation image // the thumbnail is not stored in case of encrypted document - AddLog( OSL_LOG_PREFIX "Thumbnail creation." ); + SAL_WARN( "sfx.doc", "[ Thumbnail creation ]" ); if ( !GenerateAndStoreThumbnail( bPasswdProvided, pFilter->IsOwnTemplateFormat(), xMedStorage ) ) { // TODO: error handling - SAL_WARN( "sfx.doc", "Couldn't store thumbnail representation!" ); + SAL_WARN( "sfx.doc", "couldn't store thumbnail representation" ); } } @@ -1432,7 +1429,7 @@ bool SfxObjectShell::SaveTo_Impl { if ( pImpl->bIsSaving || pImpl->bPreserveVersions ) { - AddLog( OSL_LOG_PREFIX "Preserve versions." ); + SAL_WARN( "sfx.doc", "[ Preserve versions ]" ); try { Sequence < util::RevisionTag > aVersions = rMedium.GetVersionList(); @@ -1462,8 +1459,7 @@ bool SfxObjectShell::SaveTo_Impl } catch( uno::Exception& ) { - AddLog( OSL_LOG_PREFIX "Preserve versions has failed." ); - SAL_WARN( "sfx.doc", "Couldn't copy versions!" ); + SAL_WARN( "sfx.doc", "Preserve versions has failed, couldn't copy versions" ); bOk = false; // TODO/LATER: a specific error could be set } @@ -1513,12 +1509,27 @@ bool SfxObjectShell::SaveTo_Impl } else { - AddLog( OSL_LOG_PREFIX "Storing in alien format." ); // it's a "SaveAs" in an alien format + SAL_WARN( "sfx.doc", "[ Storing in alien format ]" ); + if ( rMedium.GetFilter() && ( rMedium.GetFilter()->GetFilterFlags() & SfxFilterFlags::STARONEFILTER ) ) - bOk = ExportTo( rMedium ); + { + SAL_WARN( "sfx.doc", "[ Going ExportTo ]" ); + try + { + bOk = ExportTo( rMedium ); + } catch ( ... ) { } + SAL_WARN( "sfx.doc", "[ " << ( bOk ? "ExportTo okay" : "ExportTo problem" ) << " ]" ); + } else - bOk = ConvertTo( rMedium ); + { + SAL_WARN( "sfx.doc", "[ Going ConvertTo ]" ); + try + { + bOk = ConvertTo( rMedium ); + } catch ( ... ) { } + SAL_WARN( "sfx.doc", "[ " << ( bOk ? "ConvertTo okay" : "ConvertTo problem" ) << " ]" ); + } // after saving the document, the temporary object storage must be updated // if the old object storage was not a temporary one, it will be updated also, because it will be used @@ -1544,7 +1555,7 @@ bool SfxObjectShell::SaveTo_Impl uno::Reference< security::XDocumentDigitalSignatures > xDDSigns; if ( bOk && bTryToPreserveScriptSignature ) { - AddLog( OSL_LOG_PREFIX "Copying scripting signature." ); + SAL_WARN( "sfx.doc", "[ Copying scripting signature ]" ); // if the scripting code was not changed and it is signed the signature should be preserved // unfortunately at this point we have only information whether the basic code has changed or not @@ -1614,9 +1625,8 @@ bool SfxObjectShell::SaveTo_Impl } else { - // it should not happen, the copies signature is invalid! - // throw the changes away - SAL_WARN( "sfx.doc", "An invalid signature was copied!" ); + // it should not happen, the signature is invalid + SAL_WARN( "sfx.doc", "an invalid signature was copied" ); } } } @@ -1628,7 +1638,7 @@ bool SfxObjectShell::SaveTo_Impl rMedium.CloseZipStorage_Impl(); } - AddLog( OSL_LOG_PREFIX "Medium commit." ); + SAL_WARN( "sfx.doc", "[ Commit medium ]" ); OUString sName( rMedium.GetName( ) ); bOk = rMedium.Commit(); @@ -1639,7 +1649,7 @@ bool SfxObjectShell::SaveTo_Impl if ( bOk ) { - AddLog( OSL_LOG_PREFIX "Storing is successful." ); + SAL_WARN( "sfx.doc", "[ Storing is successful ]" ); // if the target medium is an alien format and the "old" medium was an own format and the "old" medium // has a name, the object storage must be exchanged, because now we need a new temporary storage @@ -1660,7 +1670,7 @@ bool SfxObjectShell::SaveTo_Impl // copy storage of old medium to new temporary storage and take this over if( !ConnectTmpStorage_Impl( pMedium->GetStorage(), pMedium ) ) { - AddLog( OSL_LOG_PREFIX "Process after storing has failed." ); + SAL_WARN( "sfx.doc", "process after storing has failed" ); bOk = false; } } @@ -1668,7 +1678,7 @@ bool SfxObjectShell::SaveTo_Impl } else { - AddLog( OSL_LOG_PREFIX "Storing has failed." ); + SAL_WARN( "sfx.doc", "[ Storing has failed ]" ); // in case the document storage was connected to backup temporarely it must be disconnected now if ( bNeedsDisconnectionOnFail ) @@ -2295,6 +2305,8 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium, bool SfxObjectShell::ExportTo( SfxMedium& rMedium ) { OUString aFilterName( rMedium.GetFilter()->GetFilterName() ); + SAL_WARN( "sfx.doc", "@ ExportTo: filter name is \"" << aFilterName << "\"" ); + uno::Reference< document::XExporter > xExporter; { @@ -2312,9 +2324,10 @@ bool SfxObjectShell::ExportTo( SfxMedium& rMedium ) for ( sal_Int32 nFilterProp = 0; nFilterProp<nFilterProps; nFilterProp++ ) { const beans::PropertyValue& rFilterProp = aProps[nFilterProp]; - if (rFilterProp.Name == "FilterService") + if ( rFilterProp.Name == "FilterService" ) { rFilterProp.Value >>= aFilterImplName; + SAL_WARN( "sfx.doc", "@ ExportTo: filter implementation name is \"" << aFilterImplName << "\"" ); break; } } @@ -2325,8 +2338,8 @@ bool SfxObjectShell::ExportTo( SfxMedium& rMedium ) { xExporter.set( xFilterFact->createInstanceWithArguments( aFilterName, uno::Sequence < uno::Any >() ), uno::UNO_QUERY ); } - catch(const uno::Exception&) - { + catch( ... ) { + SAL_WARN( "sfx.doc", "exception in xExporter.set()" ); xExporter.clear(); } } diff --git a/sw/inc/dbgoutsw.hxx b/sw/inc/dbgoutsw.hxx index e70d032ff803..57f7a0cb0ff0 100644 --- a/sw/inc/dbgoutsw.hxx +++ b/sw/inc/dbgoutsw.hxx @@ -19,8 +19,6 @@ #ifndef INCLUDED_SW_INC_DBGOUTSW_HXX #define INCLUDED_SW_INC_DBGOUTSW_HXX -#ifdef DBG_UTIL - #include <rtl/ustring.hxx> #include <tox.hxx> #include <cstdio> @@ -108,7 +106,7 @@ const char * dbg_out(const std::unordered_map<tKey, tMember, fHashFunction> & rM } SW_DLLPUBLIC const char * dbg_out(const SwFormToken & rToken); SW_DLLPUBLIC const char * dbg_out(const SwFormTokens & rTokens); -#endif // DBG_UTIL + #endif // INCLUDED_SW_INC_DBGOUTSW_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx index 18a795a141c4..d67da5e2e5f1 100644 --- a/sw/source/core/attr/calbck.cxx +++ b/sw/source/core/attr/calbck.cxx @@ -167,7 +167,11 @@ void SwModify::Add( SwClient* pDepend ) { for(auto& rIter : sw::ClientIteratorBase::our_pClientIters->GetRingContainer()) { - SAL_WARN_IF(&rIter.m_rRoot == m_pWriterListeners, "sw.core", "a " << typeid(*pDepend).name() << " client added as listener to a " << typeid(*this).name() << " during client iteration."); + SAL_WARN_IF ( + &rIter.m_rRoot == m_pWriterListeners, + "sw.core", + "a " << typeid(*pDepend).name() << " client added as listener to a " << typeid(*this).name() << " during client iteration" + ); } } #endif diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx index 218fd6a95fce..18dbee21c696 100644 --- a/sw/source/core/bastyp/index.cxx +++ b/sw/source/core/bastyp/index.cxx @@ -223,7 +223,8 @@ SwIndexReg::SwIndexReg() SwIndexReg::~SwIndexReg() { - assert(!m_pFirst && !m_pLast && "There are still indices registered"); + if ( ( m_pFirst != nullptr ) || ( m_pLast != nullptr ) ) + SAL_WARN( "sw.core", "There are still indices registered" ); } void SwIndexReg::Update( diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx index f86ee1c116ae..b1c471a179d7 100644 --- a/sw/source/core/doc/dbgoutsw.cxx +++ b/sw/source/core/doc/dbgoutsw.cxx @@ -17,8 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifdef DBG_UTIL - #include <rtl/ustring.hxx> #include <svl/poolitem.hxx> #include <svl/itemiter.hxx> @@ -995,6 +993,4 @@ const char * dbg_out(const SwNodeRange & rRange) return dbg_out(lcl_dbg_out(rRange)); } -#endif // DEBUG - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/rdfhelper.cxx b/sw/source/core/doc/rdfhelper.cxx index a139dfc0ba57..19176578f54b 100644 --- a/sw/source/core/doc/rdfhelper.cxx +++ b/sw/source/core/doc/rdfhelper.cxx @@ -25,30 +25,52 @@ using namespace com::sun::star; std::map<OUString, OUString> SwRDFHelper::getTextNodeStatements(const OUString& rType, const SwTextNode& rNode) { + SAL_WARN( "sw.doc", "at SwRDFHelper::getTextNodeStatements" ); + std::map<OUString, OUString> aRet; - // We only read the node, but CreateXParagraph() needs a non-cost one. + // We only read the node, but CreateXParagraph() needs a non-cost one auto& rTextNode = const_cast<SwTextNode&>(rNode); + css::uno::Reference< css::frame::XModel > xModel = rTextNode.GetDoc()->GetDocShell()->GetBaseModel(); + if ( ! xModel.is() ) + { + SAL_WARN( "sw.doc", "can't get base XModel" ); + return aRet; + } + + try { + uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess( xModel, uno::UNO_QUERY_THROW ); + uno::Reference<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext()); uno::Reference<rdf::XURI> xType = rdf::URI::create(xComponentContext, rType); - uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(rTextNode.GetDoc()->GetDocShell()->GetBaseModel(), uno::UNO_QUERY); - uno::Sequence< uno::Reference<rdf::XURI> > aGraphNames = xDocumentMetadataAccess->getMetadataGraphsWithType(xType); - if (!aGraphNames.hasElements()) - return aRet; - uno::Reference<rdf::XResource> xTextNode(SwXParagraph::CreateXParagraph(*rTextNode.GetDoc(), &rTextNode), uno::UNO_QUERY); - for (const uno::Reference<rdf::XURI>& xGraphName : aGraphNames) + if ( xDocumentMetadataAccess.is() && xType.is() ) { - uno::Reference<rdf::XNamedGraph> xGraph = xDocumentMetadataAccess->getRDFRepository()->getGraph(xGraphName); - uno::Reference<container::XEnumeration> xStatements = xGraph->getStatements(xTextNode, uno::Reference<rdf::XURI>(), uno::Reference<rdf::XURI>()); - while (xStatements->hasMoreElements()) + uno::Sequence< uno::Reference< rdf::XURI >> aGraphNames = xDocumentMetadataAccess->getMetadataGraphsWithType(xType); + if ( !aGraphNames.hasElements() ) + return aRet; + + uno::Reference<rdf::XResource> xTextNode(SwXParagraph::CreateXParagraph(*rTextNode.GetDoc(), &rTextNode), uno::UNO_QUERY); + if ( xTextNode.is() ) { - rdf::Statement aStatement = xStatements->nextElement().get<rdf::Statement>(); - aRet[aStatement.Predicate->getStringValue()] = aStatement.Object->getStringValue(); - } + for ( const uno::Reference<rdf::XURI>& xGraphName : aGraphNames ) + { + uno::Reference<rdf::XNamedGraph> xGraph = xDocumentMetadataAccess->getRDFRepository()->getGraph(xGraphName); + uno::Reference<container::XEnumeration> xStatements = xGraph->getStatements(xTextNode, uno::Reference<rdf::XURI>(), uno::Reference<rdf::XURI>()); + while ( xStatements->hasMoreElements() ) + { + rdf::Statement aStatement = xStatements->nextElement().get< rdf::Statement >(); + aRet[aStatement.Predicate->getStringValue()] = aStatement.Object->getStringValue(); + } + } + } else + SAL_WARN( "sw.doc", "No xTextNode" ); } + } + catch ( ... ) { SAL_WARN( "sw.doc", "caught exception" ); } + SAL_WARN( "sw.doc", "leaving SwRDFHelper::getTextNodeStatements" ); return aRet; } diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx index dd4fc972072d..fcabaad6a29f 100644 --- a/sw/source/core/view/vnew.cxx +++ b/sw/source/core/view/vnew.cxx @@ -340,14 +340,14 @@ SwViewShell::~SwViewShell() delete mpOpt; - // resize format cache. + // resize format cache if ( SwTextFrame::GetTextCache()->GetCurMax() > 250 ) SwTextFrame::GetTextCache()->DecreaseMax( 100 ); // Remove from PaintQueue if necessary SwPaintQueue::Remove( this ); - OSL_ENSURE( !mnStartAction, "EndAction() pending." ); + OSL_ENSURE( !mnStartAction, "EndAction() pending" ); } if ( mpDoc ) diff --git a/sw/source/filter/ww8/WW8TableInfo.cxx b/sw/source/filter/ww8/WW8TableInfo.cxx index cc1be4c35f68..ca1bac476ec3 100644 --- a/sw/source/filter/ww8/WW8TableInfo.cxx +++ b/sw/source/filter/ww8/WW8TableInfo.cxx @@ -342,10 +342,8 @@ RowSpansPtr WW8TableNodeInfoInner::getRowSpansOfRow() pResult = pCellGrid->getRowSpansOfRow(this); return pResult; - } - +} -#ifdef DBG_UTIL std::string WW8TableNodeInfoInner::toString() const { static char buffer[256]; @@ -367,7 +365,6 @@ std::string WW8TableNodeInfoInner::toString() const return std::string(buffer); } -#endif WW8TableNodeInfo::WW8TableNodeInfo(WW8TableInfo * pParent, const SwNode * pNode) @@ -383,7 +380,6 @@ WW8TableNodeInfo::~WW8TableNodeInfo() { } -#ifdef DBG_UTIL std::string WW8TableNodeInfo::toString() const { static char buffer[1024]; @@ -408,7 +404,6 @@ std::string WW8TableNodeInfo::toString() const return sResult; } -#endif void WW8TableNodeInfo::setDepth(sal_uInt32 nDepth) { @@ -427,9 +422,7 @@ void WW8TableNodeInfo::setEndOfLine(bool bEndOfLine) WW8TableNodeInfoInner::Pointer_t pInner = getInnerForDepth(mnDepth); pInner->setEndOfLine(bEndOfLine); -#ifdef DBG_UTIL - SAL_INFO( "sw.ww8", "<endOfLine depth=\"" << mnDepth << "\">" << toString() << "</endOfLine>" ); -#endif + SAL_WARN( "sw.ww8", "<endOfLine depth=\"" << mnDepth << "\">" << toString() << "</endOfLine>" ); } void WW8TableNodeInfo::setEndOfCell(bool bEndOfCell) @@ -437,9 +430,7 @@ void WW8TableNodeInfo::setEndOfCell(bool bEndOfCell) WW8TableNodeInfoInner::Pointer_t pInner = getInnerForDepth(mnDepth); pInner->setEndOfCell(bEndOfCell); -#ifdef DBG_UTIL - SAL_INFO( "sw.ww8", "<endOfCell depth=\"" << mnDepth << "\">" << toString() << "</endOfCell>" ); -#endif + SAL_WARN( "sw.ww8", "<endOfCell depth=\"" << mnDepth << "\">" << toString() << "</endOfCell>" ); } void WW8TableNodeInfo::setFirstInTable(bool bFirstInTable) @@ -448,9 +439,7 @@ void WW8TableNodeInfo::setFirstInTable(bool bFirstInTable) pInner->setFirstInTable(bFirstInTable); -#ifdef DBG_UTIL - SAL_INFO( "sw.ww8", "<firstInTable depth=\"" << mnDepth << "\">" << toString() << "</firstInTable>" ); -#endif + SAL_WARN( "sw.ww8", "<firstInTable depth=\"" << mnDepth << "\">" << toString() << "</firstInTable>" ); } void WW8TableNodeInfo::setVertMerge(bool bVertMerge) @@ -459,9 +448,7 @@ void WW8TableNodeInfo::setVertMerge(bool bVertMerge) pInner->setVertMerge(bVertMerge); -#ifdef DBG_UTIL - SAL_INFO( "sw.ww8", "<vertMerge depth=\"" << mnDepth << "\">" << toString() << "</vertMerge>" ); -#endif + SAL_WARN( "sw.ww8", "<vertMerge depth=\"" << mnDepth << "\">" << toString() << "</vertMerge>" ); } void WW8TableNodeInfo::setTableBox(const SwTableBox * pTableBox) @@ -478,9 +465,7 @@ void WW8TableNodeInfo::setNext(WW8TableNodeInfo * pNext) { mpNext = pNext; -#ifdef DBG_UTIL - SAL_INFO( "sw.ww8", "<setnext><from>" << toString() << "</from><to>" << pNext->toString() << "</to></setnext>" ); -#endif + SAL_WARN( "sw.ww8", "<setnext><from>" << toString() << "</from><to>" << pNext->toString() << "</to></setnext>" ); } void WW8TableNodeInfo::setNextNode(const SwNode * pNode) @@ -578,8 +563,8 @@ WW8TableInfo::processSwTableByLayout(const SwTable * pTable, RowEndInners_t &rLa { SwRect aRect = aTableCellInfo.getRect(); - SAL_INFO( "sw.ww8", "<CellFrame>" ); - SAL_INFO( "sw.ww8", "<rect top=\"" << aRect.Top() << "\" bottom=\"" << aRect.Bottom() + SAL_WARN( "sw.ww8", "<CellFrame>" ); + SAL_WARN( "sw.ww8", "<rect top=\"" << aRect.Top() << "\" bottom=\"" << aRect.Bottom() << "\" left=\"" << aRect.Left() << "\" right=\"" << aRect.Right() << "\"/>" ); const SwTableBox * pTableBox = aTableCellInfo.getTableBox(); const SwStartNode * pSttNd = pTableBox->GetSttNd(); @@ -609,7 +594,7 @@ WW8TableInfo::processSwTableByLayout(const SwTable * pTable, RowEndInners_t &rLa while (!bDone); } - SAL_INFO( "sw.ww8", "</CellFrame>" ); + SAL_WARN( "sw.ww8", "</CellFrame>" ); } return reorderByLayout(pTable, rLastRowEnds); @@ -617,7 +602,7 @@ WW8TableInfo::processSwTableByLayout(const SwTable * pTable, RowEndInners_t &rLa void WW8TableInfo::processSwTable(const SwTable * pTable) { - SAL_INFO( "sw.ww8", "<processSwTable>" ); + SAL_WARN( "sw.ww8", "<processSwTable>" ); WW8TableNodeInfo * pPrev = nullptr; RowEndInners_t aLastRowEnds; @@ -625,9 +610,8 @@ void WW8TableInfo::processSwTable(const SwTable * pTable) if (pTable->IsTableComplex() && pTable->HasLayout()) { pPrev = processSwTableByLayout(pTable, aLastRowEnds); -#ifdef DBG_UTIL - SAL_INFO( "sw.ww8", getCellGridForTable(pTable)->toString()); -#endif + + SAL_WARN( "sw.ww8", getCellGridForTable(pTable)->toString()); } else { @@ -654,7 +638,7 @@ void WW8TableInfo::processSwTable(const SwTable * pTable) a.second->setFinalEndOfLine(true); } } - SAL_INFO( "sw.ww8", "</processSwTable>" ); + SAL_WARN( "sw.ww8", "</processSwTable>" ); } WW8TableNodeInfo * @@ -665,7 +649,7 @@ WW8TableInfo::processTableLine(const SwTable * pTable, WW8TableNodeInfo * pPrev, RowEndInners_t &rLastRowEnds) { - SAL_INFO( "sw.ww8", "<processTableLine row=\"" << nRow << "\" depth=\"" << nDepth << "\">" ); + SAL_WARN( "sw.ww8", "<processTableLine row=\"" << nRow << "\" depth=\"" << nDepth << "\">" ); const SwTableBoxes & rBoxes = pTableLine->GetTabBoxes(); @@ -678,7 +662,7 @@ WW8TableInfo::processTableLine(const SwTable * pTable, pPrev = processTableBox(pTable, pBox, nRow, static_cast<sal_uInt32>(n), nDepth, n == rBoxes.size() - 1, pPrev, rLastRowEnds); } - SAL_INFO( "sw.ww8", "</processTableLine>" ); + SAL_WARN( "sw.ww8", "</processTableLine>" ); return pPrev; } @@ -691,7 +675,7 @@ WW8TableInfo::processTableBoxLines(const SwTableBox * pBox, sal_uInt32 nCell, sal_uInt32 nDepth) { - SAL_INFO( "sw.ww8", "<processTableBoxLines depth=\"" << nDepth << "\" row=\"" << nRow + SAL_WARN( "sw.ww8", "<processTableBoxLines depth=\"" << nDepth << "\" row=\"" << nRow << "\" cell=\"" << nCell << "\">" ); const SwTableLines & rLines = pBox->GetTabLines(); @@ -729,7 +713,7 @@ WW8TableInfo::processTableBoxLines(const SwTableBox * pBox, } } - SAL_INFO( "sw.ww8", "</processTableBoxLines>" ); + SAL_WARN( "sw.ww8", "</processTableBoxLines>" ); return pNodeInfo; } @@ -754,7 +738,7 @@ WW8TableInfo::processTableBox(const SwTable * pTable, WW8TableNodeInfo * pPrev, RowEndInners_t &rLastRowEnds) { - SAL_INFO( "sw.ww8", "<processTableBox row=\"" << nRow << "\" cell=\"" << nCell + SAL_WARN( "sw.ww8", "<processTableBox row=\"" << nRow << "\" cell=\"" << nCell << "\" depth=\"" << nDepth << "\">" ); WW8TableNodeInfo::Pointer_t pNodeInfo; @@ -837,7 +821,7 @@ WW8TableInfo::processTableBox(const SwTable * pTable, } } - SAL_INFO( "sw.ww8", "</processTableBox>" ); + SAL_WARN( "sw.ww8", "</processTableBox>" ); return pPrev; } @@ -886,9 +870,8 @@ WW8TableNodeInfo::Pointer_t WW8TableInfo::insertTableNodeInfo pNodeInfo->setRect(*pRect); } -#ifdef DBG_UTIL - SAL_INFO( "sw.ww8", pNodeInfo->toString()); -#endif + SAL_WARN( "sw.ww8", pNodeInfo->toString()); + return pNodeInfo; } @@ -1005,7 +988,6 @@ bool CellInfo::operator < (const CellInfo & aCellInfo) const return aRet; } -#ifdef DBG_UTIL std::string CellInfo::toString() const { static char sBuffer[256]; @@ -1024,15 +1006,12 @@ std::string CellInfo::toString() const return sBuffer; } -#endif WW8TableNodeInfo * WW8TableInfo::reorderByLayout(const SwTable * pTable, RowEndInners_t &rLastRowEnds) { WW8TableCellGrid::Pointer_t pCellGrid = getCellGridForTable(pTable); -#ifdef DBG_UTIL - SAL_INFO( "sw.ww8", pCellGrid->toString()); -#endif + SAL_WARN( "sw.ww8", pCellGrid->toString()); pCellGrid->addShadowCells(); return pCellGrid->connectCells(rLastRowEnds); @@ -1102,16 +1081,15 @@ void WW8TableCellGrid::insert(const SwRect & rRect, void WW8TableCellGrid::addShadowCells() { - SAL_INFO( "sw.ww8", "<addShadowCells>" ); + SAL_WARN( "sw.ww8", "<addShadowCells>" ); RowTops_t::const_iterator aTopsIt = getRowTopsBegin(); while (aTopsIt != getRowTopsEnd()) { -#ifdef DBG_UTIL - long nTop = *aTopsIt; - (void) nTop; -#endif + ///long nTop = *aTopsIt; + ///(void) nTop; + CellInfoMultiSet::const_iterator aCellIt = getCellsBegin(*aTopsIt); CellInfoMultiSet::const_iterator aCellEndIt = getCellsEnd(*aTopsIt); @@ -1175,7 +1153,8 @@ void WW8TableCellGrid::addShadowCells() ++aTopsIt; } - SAL_INFO( "sw.ww8", "</addShadowCells>" ); + + SAL_WARN( "sw.ww8", "</addShadowCells>" ); } WW8TableNodeInfo * WW8TableCellGrid::connectCells(RowEndInners_t &rLastRowEnds) @@ -1286,7 +1265,6 @@ WW8TableNodeInfo * WW8TableCellGrid::connectCells(RowEndInners_t &rLastRowEnds) return pLastNodeInfo; } -#ifdef DBG_UTIL std::string WW8TableCellGrid::toString() { std::string sResult = "<WW8TableCellGrid>"; @@ -1366,7 +1344,6 @@ std::string WW8TableCellGrid::toString() return sResult; } -#endif TableBoxVectorPtr WW8TableCellGrid::getTableBoxesOfRow (WW8TableNodeInfoInner * pNodeInfoInner) @@ -1428,9 +1405,7 @@ void WW8TableCellGridRow::insert(const CellInfo & rCellInfo) { m_pCellInfos->insert(rCellInfo); -#ifdef DBG_UTIL - SAL_INFO( "sw.ww8", "<gridRowInsert>" << rCellInfo.toString() << "</gridRowInsert>" ); -#endif + SAL_WARN( "sw.ww8", "<gridRowInsert>" << rCellInfo.toString() << "</gridRowInsert>" ); } CellInfoMultiSet::const_iterator WW8TableCellGridRow::begin() const diff --git a/sw/source/filter/ww8/WW8TableInfo.hxx b/sw/source/filter/ww8/WW8TableInfo.hxx index f5db223db764..2a1f787e7607 100644 --- a/sw/source/filter/ww8/WW8TableInfo.hxx +++ b/sw/source/filter/ww8/WW8TableInfo.hxx @@ -107,9 +107,9 @@ public: GridColsPtr getGridColsOfRow(AttributeOutputBase & rBase, bool calculateColumnsFromAllRows = false); RowSpansPtr getRowSpansOfRow(); -#ifdef DBG_UTIL +//#ifdef DBG_UTIL std::string toString() const; -#endif +//#endif }; class CellInfo @@ -151,9 +151,9 @@ public: m_nFormatFrameWidth = nFormatFrameWidth; } -#ifdef DBG_UTIL +//#ifdef DBG_UTIL std::string toString() const; -#endif +//#endif }; typedef std::multiset<CellInfo> CellInfoMultiSet; @@ -211,9 +211,9 @@ public: sal_uInt32 getCell() const; sal_uInt32 getRow() const; -#ifdef DBG_UTIL +//#ifdef DBG_UTIL std::string toString() const; -#endif +//#endif bool operator < (const WW8TableNodeInfo & rInfo) const; }; @@ -280,9 +280,9 @@ public: void addShadowCells(); WW8TableNodeInfo *connectCells(RowEndInners_t &rLastRowEnds); -#ifdef DBG_UTIL +//#ifdef DBG_UTIL std::string toString(); -#endif +//#endif TableBoxVectorPtr getTableBoxesOfRow(WW8TableNodeInfoInner * pNodeInfo); WidthsPtr getWidthsOfRow(WW8TableNodeInfoInner * pNodeInfo); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 8ac45b248cf4..4322f861ec19 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -248,6 +248,8 @@ static bool lcl_isOnelinerSdt(const OUString& rName) void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo ) { + SAL_WARN( "sw.ww8", "<StartParagraph>" ); + if ( m_nColBreakStatus == COLBRK_POSTPONE ) m_nColBreakStatus = COLBRK_WRITE; @@ -336,6 +338,8 @@ void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pText m_bParagraphOpened = true; m_bIsFirstParagraph = false; + + SAL_WARN( "sw.ww8", "</StartParagraph>" ); } static void lcl_deleteAndResetTheLists( rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrTokenChildren, rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrDataBindingAttrs, OUString& rSdtPrAlias) @@ -350,6 +354,7 @@ static void lcl_deleteAndResetTheLists( rtl::Reference<sax_fastparser::FastAttri void DocxAttributeOutput::PopulateFrameProperties(const SwFrameFormat* pFrameFormat, const Size& rSize) { + SAL_WARN( "sw.ww8", "<PopulateFrameProperties>" ); sax_fastparser::FastAttributeList* attrList = FastSerializerHelper::createAttrList(); @@ -416,6 +421,8 @@ void DocxAttributeOutput::PopulateFrameProperties(const SwFrameFormat* pFrameFor sax_fastparser::XFastAttributeListRef xAttrList(attrList); m_pSerializer->singleElementNS( XML_w, XML_framePr, xAttrList ); + + SAL_WARN( "sw.ww8", "</PopulateFrameProperties>" ); } bool DocxAttributeOutput::TextBoxIsFramePr(const SwFrameFormat& rFrameFormat) @@ -831,6 +838,8 @@ void DocxAttributeOutput::SectionBreaks(const SwNode& rNode) void DocxAttributeOutput::StartParagraphProperties() { + SAL_WARN( "sw.ww8", "<StartParagraphProperties>" ); + m_pSerializer->mark(Tag_StartParagraphProperties); m_pSerializer->startElementNS( XML_w, XML_pPr, FSEND ); @@ -843,6 +852,8 @@ void DocxAttributeOutput::StartParagraphProperties() } InitCollectedParagraphProperties(); + + SAL_WARN( "sw.ww8", "</StartParagraphProperties>" ); } void DocxAttributeOutput::InitCollectedParagraphProperties() @@ -902,6 +913,8 @@ void DocxAttributeOutput::InitCollectedParagraphProperties() void DocxAttributeOutput::WriteCollectedParagraphProperties() { + SAL_INFO( "sw.ww8", "<WriteCollectedParagraphProperties>" ); + if ( m_rExport.SdrExporter().getFlyAttrList().is() ) { XFastAttributeListRef xAttrList( m_rExport.SdrExporter().getFlyAttrList().get() ); @@ -925,6 +938,8 @@ void DocxAttributeOutput::WriteCollectedParagraphProperties() m_pSerializer->singleElementNS( XML_w, XML_shd, xAttrList ); } + + SAL_INFO( "sw.ww8", "</WriteCollectedParagraphProperties>" ); } namespace @@ -965,6 +980,8 @@ void lcl_writeParagraphMarkerProperties(DocxAttributeOutput& rAttributeOutput, c void DocxAttributeOutput::EndParagraphProperties(const SfxItemSet& rParagraphMarkerProperties, const SwRedlineData* pRedlineData, const SwRedlineData* pRedlineParagraphMarkerDeleted, const SwRedlineData* pRedlineParagraphMarkerInserted) { + SAL_WARN( "sw.ww8", "<EndParagraphProperties>" ); + // Call the 'Redline' function. This will add redline (change-tracking) information that regards to paragraph properties. // This includes changes like 'Bold', 'Underline', 'Strikethrough' etc. @@ -1017,7 +1034,7 @@ void DocxAttributeOutput::EndParagraphProperties(const SfxItemSet& rParagraphMar EndRedline( pRedlineParagraphMarkerInserted ); } - // mergeTopMarks() after paragraph mark properties child elements. + // mergeTopMarks() after paragraph mark properties child elements m_pSerializer->mergeTopMarks(Tag_InitCollectedRunProperties); m_pSerializer->endElementNS( XML_w, XML_rPr ); @@ -1033,10 +1050,10 @@ void DocxAttributeOutput::EndParagraphProperties(const SfxItemSet& rParagraphMar m_pSerializer->endElementNS( XML_w, XML_pPr ); - // RDF metadata for this text node. + // RDF metadata for this text node SwTextNode* pTextNode = m_rExport.m_pCurPam->GetNode().GetTextNode(); std::map<OUString, OUString> aStatements = SwRDFHelper::getTextNodeStatements("urn:bails", *pTextNode); - if (!aStatements.empty()) + if ( !aStatements.empty() ) { m_pSerializer->startElementNS(XML_w, XML_smartTag, FSNS(XML_w, XML_uri), "http://www.w3.org/1999/02/22-rdf-syntax-ns#", @@ -1051,6 +1068,8 @@ void DocxAttributeOutput::EndParagraphProperties(const SfxItemSet& rParagraphMar m_pSerializer->endElementNS(XML_w, XML_smartTagPr); m_pSerializer->endElementNS(XML_w, XML_smartTag); } + else + SAL_WARN( "sw.ww8", "RDF metadata is empty" ); if ( m_nColBreakStatus == COLBRK_WRITE ) { @@ -1075,6 +1094,8 @@ void DocxAttributeOutput::EndParagraphProperties(const SfxItemSet& rParagraphMar // merge the properties _before_ the run (strictly speaking, just // after the start of the paragraph) m_pSerializer->mergeTopMarks(Tag_StartParagraphProperties, sax_fastparser::MergeMarks::PREPEND); + + SAL_WARN( "sw.ww8", "</EndParagraphProperties>" ); } void DocxAttributeOutput::SetStateOfFlyFrame( FlyProcessingState nStateOfFlyFrame ) @@ -1737,6 +1758,8 @@ void DocxAttributeOutput::StartRunProperties() void DocxAttributeOutput::InitCollectedRunProperties() { + SAL_INFO( "sw.ww8", "<InitCollectedRunProperties>" ); + m_pFontsAttrList = nullptr; m_pEastAsianLayoutAttrList = nullptr; m_pCharLangAttrList = nullptr; @@ -1806,6 +1829,8 @@ void DocxAttributeOutput::InitCollectedRunProperties() aSeqOrder[i] = aOrder[i]; m_pSerializer->mark(Tag_InitCollectedRunProperties, aSeqOrder); + + SAL_INFO( "sw.ww8", "</InitCollectedRunProperties>" ); } namespace @@ -1973,6 +1998,8 @@ void lclProcessRecursiveGrabBag(sal_Int32 aElementId, const css::uno::Sequence<c void DocxAttributeOutput::WriteCollectedRunProperties() { + SAL_INFO( "sw.ww8", "<WriteCollectedRunProperties>" ); + // Write all differed properties if ( m_pFontsAttrList.is() ) { @@ -2017,6 +2044,8 @@ void DocxAttributeOutput::WriteCollectedRunProperties() } m_aTextEffectsGrabBag.clear(); } + + SAL_INFO( "sw.ww8", "</WriteCollectedRunProperties>" ); } void DocxAttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData ) @@ -2596,9 +2625,11 @@ void DocxAttributeOutput::FormatDrop( const SwTextNode& /*rNode*/, const SwForma void DocxAttributeOutput::ParagraphStyle( sal_uInt16 nStyle ) { + SAL_WARN( "sw.ww8", "<ParagraphStyle>" ); OString aStyleId(m_rExport.m_pStyles->GetStyleId(nStyle)); m_pSerializer->singleElementNS( XML_w, XML_pStyle, FSNS( XML_w, XML_val ), aStyleId.getStr(), FSEND ); + SAL_WARN( "sw.ww8", "</ParagraphStyle>" ); } static void impl_borderLine( FSHelperPtr const & pSerializer, sal_Int32 elementToken, const SvxBorderLine* pBorderLine, sal_uInt16 nDist, diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 4616cde329d3..42b5bce15ee5 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -88,17 +88,29 @@ using sw::mark::IMark; AttributeOutputBase& DocxExport::AttrOutput() const { - return *m_pAttrOutput; + if ( m_pAttrOutput ) + return *m_pAttrOutput; + else + SAL_WARN( "sw.ww8", "m_pAttrOutput is nil" ); + throw css::uno::RuntimeException( "m_pAttrOutput is nil" ); } DocxAttributeOutput& DocxExport::DocxAttrOutput() const { - return *m_pAttrOutput; + if ( m_pAttrOutput ) + return *m_pAttrOutput; + else + SAL_WARN( "sw.ww8", "m_pAttrOutput is nil" ); + throw css::uno::RuntimeException( "m_pAttrOutput is nil" ); } MSWordSections& DocxExport::Sections() const { - return *m_pSections; + if ( m_pSections ) + return *m_pSections; + else + SAL_WARN( "sw.ww8", "m_pSections is nil" ); + throw css::uno::RuntimeException( "m_pSections is nil" ); } bool DocxExport::CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ) @@ -402,7 +414,7 @@ OString DocxExport::WriteOLEObject(SwOLEObj& rObject, OUString & io_rProgID) } catch (uno::Exception const& e) { - SAL_WARN("sw.ww8", "DocxExport::WriteOLEObject: exception: " << e.Message); + SAL_WARN("sw.ww8", "WriteOLEObject: exception: " << e.Message); return OString(); } @@ -430,6 +442,8 @@ void DocxExport::OutputDML(uno::Reference<drawing::XShape>& xShape) void DocxExport::ExportDocument_Impl() { + SAL_WARN( "sw.ww8", "ExportDocument_Impl()" ); + // Set the 'Track Revisions' flag in the settings structure m_aSettings.trackRevisions = bool( RedlineFlags::On & m_nOrigRedlineFlags ); @@ -568,6 +582,8 @@ void DocxExport::PrepareNewPageDesc( const SfxItemSet* pSet, void DocxExport::InitStyles() { + SAL_WARN( "sw.ww8", "InitStyles()" ); + m_pStyles = new MSWordStyles( *this, /*bListStyles =*/ true ); // setup word/styles.xml and the relations + content type @@ -587,10 +603,14 @@ void DocxExport::InitStyles() // switch the serializer back m_pAttrOutput->SetSerializer( m_pDocumentFS ); + + SAL_WARN( "sw.ww8", "done InitStyles()" ); } void DocxExport::WriteFootnotesEndnotes() { + SAL_WARN( "sw.ww8", "WriteFootnotesEndnotes()" ); + if ( m_pAttrOutput->HasFootnotes() ) { // setup word/styles.xml and the relations + content type @@ -642,6 +662,8 @@ void DocxExport::WriteFootnotesEndnotes() void DocxExport::WritePostitFields() { + SAL_WARN( "sw.ww8", "WritePostitFields()" ); + if ( m_pAttrOutput->HasPostitFields() ) { m_pFilter->addRelation( m_pDocumentFS->getOutputStream(), @@ -662,6 +684,8 @@ void DocxExport::WritePostitFields() void DocxExport::WriteNumbering() { + SAL_WARN( "sw.ww8", "WriteNumbering()" ); + if ( !m_pUsedNumTable ) return; // no numbering is used @@ -698,6 +722,8 @@ void DocxExport::WriteNumbering() void DocxExport::WriteHeaderFooter( const SwFormat& rFormat, bool bHeader, const char* pType ) { + SAL_WARN( "sw.ww8", "WriteHeaderFooter()" ); + // setup the xml stream OUString aRelId; ::sax_fastparser::FSHelperPtr pFS; @@ -776,6 +802,8 @@ void DocxExport::WriteHeaderFooter( const SwFormat& rFormat, bool bHeader, const void DocxExport::WriteFonts() { + SAL_WARN( "sw.ww8", "WriteFonts()" ); + m_pFilter->addRelation( m_pDocumentFS->getOutputStream(), "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable", "fontTable.xml" ); @@ -818,6 +846,8 @@ void DocxExport::WriteProperties( ) void DocxExport::WriteSettings() { + SAL_WARN( "sw.ww8", "WriteSettings()" ); + SwViewShell *pViewShell(m_pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()); if( !pViewShell && !m_aSettings.hasData() && !m_pAttrOutput->HasFootnotes() && !m_pAttrOutput->HasEndnotes()) return; @@ -978,6 +1008,8 @@ void DocxExport::WriteSettings() void DocxExport::WriteTheme() { + SAL_WARN( "sw.ww8", "WriteTheme()" ); + uno::Reference< beans::XPropertySet > xPropSet( m_pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW ); uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); @@ -1016,6 +1048,8 @@ void DocxExport::WriteTheme() void DocxExport::WriteGlossary() { + SAL_WARN( "sw.ww8", "WriteGlossary()" ); + uno::Reference< beans::XPropertySet > xPropSet( m_pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW ); uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); @@ -1087,6 +1121,8 @@ void DocxExport::WriteGlossary() void DocxExport::WriteCustomXml() { + SAL_WARN( "sw.ww8", "WriteCustomXml()" ); + uno::Reference< beans::XPropertySet > xPropSet( m_pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW ); uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); @@ -1158,6 +1194,8 @@ void DocxExport::WriteCustomXml() void DocxExport::WriteActiveX() { + SAL_WARN( "sw.ww8", "WriteActiveX()" ); + uno::Reference< beans::XPropertySet > xPropSet( m_pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW ); uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); @@ -1252,6 +1290,8 @@ void DocxExport::WriteActiveX() void DocxExport::WriteEmbeddings() { + SAL_WARN( "sw.ww8", "WriteEmbeddings()" ); + uno::Reference< beans::XPropertySet > xPropSet( m_pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW ); uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); @@ -1330,6 +1370,8 @@ bool DocxExport::isMirroredMargin() void DocxExport::WriteMainText() { + SAL_WARN( "sw.ww8", "WriteMainText()" ); + // setup the namespaces m_pDocumentFS->startElementNS( XML_w, XML_document, MainXmlNamespaces()); @@ -1366,6 +1408,8 @@ void DocxExport::WriteMainText() // finish body and document m_pDocumentFS->endElementNS( XML_w, XML_body ); m_pDocumentFS->endElementNS( XML_w, XML_document ); + + SAL_WARN( "sw.ww8", "done WriteMainText()" ); } XFastAttributeListRef DocxExport::MainXmlNamespaces() @@ -1482,6 +1526,8 @@ DocxExport::DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCur // the related drawing export m_pSdrExport = new DocxSdrExport( *this, m_pDocumentFS, m_pDrawingML ); + + SAL_WARN( "sw.ww8", "created DocxExport" ); } DocxExport::~DocxExport() diff --git a/sw/source/filter/ww8/docxexportfilter.cxx b/sw/source/filter/ww8/docxexportfilter.cxx index cf4acf222c63..17bf8f151b27 100644 --- a/sw/source/filter/ww8/docxexportfilter.cxx +++ b/sw/source/filter/ww8/docxexportfilter.cxx @@ -39,25 +39,32 @@ DocxExportFilter::DocxExportFilter( const uno::Reference< uno::XComponentContext bool DocxExportFilter::exportDocument() { + SAL_WARN( "sw.ww8", "DocxExportFilter::exportDocument()" ); + // get SwDoc* uno::Reference< uno::XInterface > xIfc( getModel(), uno::UNO_QUERY ); SwXTextDocument *pTextDoc = dynamic_cast< SwXTextDocument * >( xIfc.get() ); if ( !pTextDoc ) + { + SAL_WARN( "sw.ww8", "can't get SwXTextDocument" ); return false; + } SwDoc *pDoc = pTextDoc->GetDocShell()->GetDoc(); if ( !pDoc ) + { + SAL_WARN( "sw.ww8", "can't get SwDoc" ); return false; + } // update layout (if present), for SwWriteTable SwViewShell* pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); - if (pViewShell != nullptr) + if ( pViewShell ) pViewShell->CalcLayout(); // get SwPaM* - // FIXME so far we get SwPaM for the entire document; probably we should - // be able to output just the selection as well - though no idea how to - // get the correct SwPaM* then... + // FIXME so far we get SwPaM for the entire document; probably it's possible + // to output just the selection as well, though no idea how to get the correct SwPaM* then SwPaM aPam( pDoc->GetNodes().GetEndOfContent() ); aPam.SetMark(); aPam.Move( fnMoveBackward, GoInDoc ); @@ -66,10 +73,15 @@ bool DocxExportFilter::exportDocument() // export the document // (in a separate block so that it's destructed before the commit) + try { DocxExport aExport( this, pDoc, pCurPam, &aPam ); aExport.ExportDocument( true ); // FIXME support exporting selection only } + catch ( ... ) { + SAL_WARN( "sw.ww8", "exception during export" ); + return false; + } commitStorage(); diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index f12d5c7a3dfc..0c6fe5a4a325 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -655,6 +655,7 @@ FlyProcessingState SwWW8AttrIter::OutFlys(sal_Int32 nSwPos) } ++maFlyIter; } + return ( m_rExport.AttrOutput().IsFlyProcessingPostponed() ? FLY_POSTPONED : FLY_PROCESSED ) ; } @@ -1405,6 +1406,7 @@ const SwRedlineData* SwWW8AttrIter::GetParagraphLevelRedline( ) } } } + return nullptr; } @@ -2033,7 +2035,8 @@ void MSWordExportBase::GetSortedBookmarks( const SwTextNode& rNode, sal_Int32 nA void MSWordExportBase::OutputTextNode( const SwTextNode& rNode ) { - SAL_INFO( "sw.ww8", "<OutWW8_SwTextNode>" ); + SAL_WARN( "sw.ww8", "<OutputTextNode>" ); + SAL_WARN( "sw.ww8", "\"" << rNode.GetText() << "\"" ); ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo( m_pTableInfo->getTableNodeInfo( &rNode ) ); @@ -2132,8 +2135,9 @@ void MSWordExportBase::OutputTextNode( const SwTextNode& rNode ) if ( aAttrIter.RequiresImplicitBookmark() ) { OUString sBkmkName = "_toc" + OUString::number( rNode.GetIndex() ); - // Add a bookmark converted to a Word name. + // Add a bookmark converted to a Word name AppendBookmark( BookmarkToWord( sBkmkName ) ); + SAL_WARN( "sw.ww8", "appended bookmark" ); } const OUString& aStr( rNode.GetText() ); @@ -2145,12 +2149,14 @@ void MSWordExportBase::OutputTextNode( const SwTextNode& rNode ) OUString aStringForImage("\001"); ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner; - if ( pTextNodeInfo.get() != nullptr ) + if ( pTextNodeInfo.get() ) { pTextNodeInfoInner = pTextNodeInfo->getFirstInner(); } do { + SAL_WARN( "sw.ww8", OUString::number( nAktPos ) << " = nAktPos" ); + const SwRedlineData* pRedlineData = aAttrIter.GetRunLevelRedline( nAktPos ); FlyProcessingState nStateOfFlyFrame = FLY_PROCESSED; bool bPostponeWritingText = false ; @@ -2471,11 +2477,9 @@ void MSWordExportBase::OutputTextNode( const SwTextNode& rNode ) if ( m_pParentFrame && IsInTable() ) // Fly-Attrs OutputFormat( m_pParentFrame->GetFrameFormat(), false, false, true ); - if ( pTextNodeInfo.get() != nullptr ) + if ( pTextNodeInfo.get() ) { -#ifdef DBG_UTIL - SAL_INFO( "sw.ww8", pTextNodeInfo->toString()); -#endif + SAL_WARN( "sw.ww8", "TextNodeInfo \"" << pTextNodeInfo->toString() << "\"" ); AttrOutput().TableInfoCell( pTextNodeInfoInner ); if (pTextNodeInfoInner->isFirstInTable()) @@ -2483,13 +2487,15 @@ void MSWordExportBase::OutputTextNode( const SwTextNode& rNode ) const SwTable * pTable = pTextNodeInfoInner->getTable(); const SwTableFormat* pTabFormat = pTable->GetFrameFormat(); - if (pTabFormat != nullptr) + if ( pTabFormat ) { if (pTabFormat->GetBreak().GetBreak() == SvxBreak::PageBefore) AttrOutput().PageBreakBefore(true); } } } + else + SAL_WARN( "sw.ww8", "no TextNodeInfo" ); if ( !bFlyInTable ) { @@ -2804,9 +2810,9 @@ void MSWordExportBase::OutputTextNode( const SwTextNode& rNode ) // then properties on character 8 are for the paragraph marker if( (endPos) && (startPos == *endPos ) && (*endPos == rNode.GetText().getLength()) ) { - SAL_INFO( "sw.ww8", startPos << "startPos == endPos" << *endPos); + SAL_WARN( "sw.ww8", startPos << " startPos == endPos " << *endPos ); sal_uInt16 nWhich = pHt->GetAttr().Which(); - SAL_INFO( "sw.ww8", "nWhich" << nWhich); + SAL_WARN( "sw.ww8", "nWhich = " << nWhich ); if (nWhich == RES_TXTATR_AUTOFMT || nWhich == RES_TXTATR_CHARFMT) aParagraphMarkerProperties.Put(pHt->GetAttr()); if (nWhich != RES_TXTATR_CHARFMT) @@ -2825,7 +2831,7 @@ void MSWordExportBase::OutputTextNode( const SwTextNode& rNode ) AttrOutput().EndParagraph( pTextNodeInfoInner ); - SAL_INFO( "sw.ww8", "</OutWW8_SwTextNode>" ); + SAL_INFO( "sw.ww8", "</OutputTextNode>" ); } // Tables @@ -3096,21 +3102,29 @@ void WW8AttributeOutput::Redline( const SwRedlineData* pRedline ) void MSWordExportBase::OutputContentNode( const SwContentNode& rNode ) { + SAL_WARN( "sw.ww8", "<OutputContentNode>" ); switch ( rNode.GetNodeType() ) { case SwNodeType::Text: - OutputTextNode( *rNode.GetTextNode() ); + SAL_WARN( "sw.ww8", "it's TextNode" ); + { + const SwTextNode* rTextNode = rNode.GetTextNode(); + OutputTextNode( *rTextNode ); + } break; case SwNodeType::Grf: + SAL_WARN( "sw.ww8", "it's GrfNode" ); OutputGrfNode( *rNode.GetGrfNode() ); break; case SwNodeType::Ole: + SAL_WARN( "sw.ww8", "it's OLENode" ); OutputOLENode( *rNode.GetOLENode() ); break; default: - SAL_WARN("sw.ww8", "Unhandled node, type == " << (int)rNode.GetNodeType() ); + SAL_WARN( "sw.ww8", "unhandled node of type " << ( int )rNode.GetNodeType() ); break; } + SAL_WARN( "sw.ww8", "</OutputContentNode>" ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 0b139cf3ac2d..ca0566848ce2 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -521,13 +521,18 @@ void MSWordStyles::WriteProperties( const SwFormat* pFormat, bool bParProp, sal_ { m_rExport.AttrOutput().StartStyleProperties( bParProp, nPos ); - OSL_ENSURE( m_rExport.m_pCurrentStyle == nullptr, "Current style not NULL" ); // set current style before calling out + if ( m_rExport.m_pCurrentStyle ) + { + // set current style before calling out + SAL_WARN( "sw.ww8", "current style is not nil" ); + } + m_rExport.m_pCurrentStyle = pFormat; m_rExport.OutputFormat( *pFormat, bParProp, !bParProp ); OSL_ENSURE( m_rExport.m_pCurrentStyle == pFormat, "current style was changed" ); - // reset current style... + // reset current style m_rExport.m_pCurrentStyle = nullptr; if ( bInsDefCharSiz ) // not derived from other Style @@ -635,53 +640,70 @@ void MSWordStyles::OutputStyle( SwFormat* pFormat, sal_uInt16 nPos ) void WW8AttributeOutput::StartStyles() { + SAL_WARN( "sw.ww8", "<StartStyles>" ); + WW8Fib& rFib = *m_rWW8Export.pFib; sal_uLong nCurPos = m_rWW8Export.pTableStrm->Tell(); if ( nCurPos & 1 ) // Start auf gerader { - m_rWW8Export.pTableStrm->WriteChar( (char)0 ); // Address + m_rWW8Export.pTableStrm->WriteChar( 0 ); // Address ++nCurPos; } rFib.m_fcStshfOrig = rFib.m_fcStshf = nCurPos; m_nStyleCountPos = nCurPos + 2; // Anzahl wird nachgetragen - static sal_uInt8 aStShi[] = { - 0x12, 0x00, - 0x0F, 0x00, 0x0A, 0x00, 0x01, 0x00, 0x5B, 0x00, - 0x0F, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + // STSHI structure stores style sheet information + static sal_uInt8 aStShi_Blob[] = { + 0x12, 0x00, /* ushort cbStshi Size of the following STSHI structure */ + 0x0F, 0x00, /* ushort cstd Count of styles in stylesheet */ + 0x0A, 0x00, /* ushort cbSTDBaseInFile Length of STD Base as stored in a file */ + 0x01, 0x00, /* ushort fStdStylenamesWritten : 1 // Are built-in stylenames stored? */ + /* ushort spareFlags : 15 */ + 0x5B, 0x00, /* ushort stiMaxWhenSaved Max sti known when this file was written */ + 0x0F, 0x00, /* ushort istdMaxFixedWhenSaved How many fixed-index istds are there? */ + 0x02, 0x00, /* ushort nVerBuiltInNamesWhenSaved Current version of built-in stylenames */ + 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }; - m_rWW8Export.pTableStrm->WriteBytes(&aStShi, sizeof(aStShi)); + m_rWW8Export.pTableStrm->WriteBytes( &aStShi_Blob, sizeof( aStShi_Blob ) ); + + SAL_WARN( "sw.ww8", "</StartStyles>" ); } void WW8AttributeOutput::EndStyles( sal_uInt16 nNumberOfStyles ) { + SAL_WARN( "sw.ww8", "<EndStyles>" ); + WW8Fib& rFib = *m_rWW8Export.pFib; rFib.m_lcbStshfOrig = rFib.m_lcbStshf = m_rWW8Export.pTableStrm->Tell() - rFib.m_fcStshf; SwWW8Writer::WriteShort( *m_rWW8Export.pTableStrm, m_nStyleCountPos, nNumberOfStyles ); + + SAL_WARN( "sw.ww8", "</EndStyles>" ); } void MSWordStyles::OutputStylesTable() { + SAL_WARN( "sw.ww8", "<OutputStylesTable>" ); + m_rExport.m_bStyDef = true; m_rExport.AttrOutput().StartStyles(); - sal_uInt16 n; // HACK // Ms Office seems to have an internal limitation of 4091 styles // and refuses to load .docx with more, even though the spec seems to allow that; // so simply if there are more styles, don't export those // Implementing check for all exports DOCX, DOC, RTF sal_uInt16 nLimit = MSWORD_MAX_STYLES_LIMIT; - m_nUsedSlots = (nLimit > m_nUsedSlots)? m_nUsedSlots : nLimit; + m_nUsedSlots = ( nLimit > m_nUsedSlots ) ? m_nUsedSlots : nLimit; - for ( n = 0; n < m_nUsedSlots; n++ ) + for ( sal_uInt16 n = 0; n < m_nUsedSlots; n++ ) { - if (m_aNumRules.find(n) != m_aNumRules.end()) - OutputStyle(m_aNumRules[n], n); + if ( m_aNumRules.find(n) != m_aNumRules.end() ) + OutputStyle( m_aNumRules[n], n ); else OutputStyle( m_pFormatA[n], n ); } @@ -689,6 +711,8 @@ void MSWordStyles::OutputStylesTable() m_rExport.AttrOutput().EndStyles( m_nUsedSlots ); m_rExport.m_bStyDef = false; + + SAL_WARN( "sw.ww8", "</OutputStylesTable>" ); } const SwNumRule* MSWordStyles::GetSwNumRule(sal_uInt16 nId) const diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 10ebf2d12921..7389ee32fd29 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -498,13 +498,18 @@ static void WriteDop( WW8Export& rWrt ) uno::Reference<document::XDocumentProperties> xDocProps; uno::Reference<beans::XPropertySet> xProps; if (pDocShell) { - uno::Reference<lang::XComponent> xModelComp(pDocShell->GetModel(), - uno::UNO_QUERY); - xProps.set(xModelComp, uno::UNO_QUERY); - uno::Reference<document::XDocumentPropertiesSupplier> xDPS( - xModelComp, uno::UNO_QUERY_THROW); - xDocProps = xDPS->getDocumentProperties(); - OSL_ENSURE(xDocProps.is(), "DocumentProperties is null"); + uno::Reference<lang::XComponent> xModelComp( pDocShell->GetModel(), uno::UNO_QUERY ); + if ( xModelComp.is() ) + { + xProps.set( xModelComp, uno::UNO_QUERY ); + + uno::Reference<document::XDocumentPropertiesSupplier> xDPS( xModelComp, uno::UNO_QUERY ); + if ( xDPS.is() ) + xDocProps = xDPS->getDocumentProperties(); + } + + if ( ! xDocProps.is() ) + SAL_WARN( "sw.ww8", "DocumentProperties is null" ); rDop.lKeyProtDoc = pDocShell->GetModifyPasswordHash(); } @@ -771,16 +776,15 @@ void WW8Export::ExportDopTypography(WW8DopTypography &rTypo) rTypo.iJustification = m_pDoc->getIDocumentSettingAccess().getCharacterCompressionType(); } -// It can only be found something with this method, if it is used within +// It can only be found something with this method if it is used within // WW8_SwAttrIter::OutAttr() and WW8Export::OutputItemSet() const SfxPoolItem* MSWordExportBase::HasItem( sal_uInt16 nWhich ) const { - const SfxPoolItem* pItem=nullptr; + const SfxPoolItem* pItem = nullptr; if (m_pISet) { - // if write a EditEngine text, then the WhichIds are greater as - // ourer own Ids. So the Id have to translate from our into the - // EditEngine Range + // if write a EditEngine text, then WhichIds are bigger than own Ids + // So translate from own into the EditEngine range nWhich = sw::hack::GetSetWhichFromSwDocWhich(*m_pISet, *m_pDoc, nWhich); if (nWhich && SfxItemState::SET != m_pISet->GetItemState(nWhich, true, &pItem)) pItem = nullptr; @@ -789,16 +793,26 @@ const SfxPoolItem* MSWordExportBase::HasItem( sal_uInt16 nWhich ) const pItem = m_pChpIter->HasTextItem( nWhich ); else { - OSL_ENSURE( false, "Where is my ItemSet / pChpIter ?" ); - pItem = nullptr; + ///print_stacktrace( ); + /* SAL_WARN( "sw.ww8", "HasItem" + << "( " << OUString::number( nWhich ) << " ): " + << "Where is my ItemSet / AttrIter ?" ); */ } + return pItem; } const SfxPoolItem& MSWordExportBase::GetItem(sal_uInt16 nWhich) const { - assert((m_pISet || m_pChpIter) && "Where is my ItemSet / pChpIter ?"); - if (m_pISet) + ///SAL_WARN( "sw.ww8", "GetItem" << "( " << OUString::number( nWhich ) << " )" ); + if ( !m_pISet && !m_pChpIter ) + { + SAL_WARN( "sw.ww8", "GetItem" + << "( " << OUString::number( nWhich ) << " ): " + << "Where is my item set / attribute iterator ?" ); + throw css::uno::RuntimeException( "m_pISet & m_pChpIter are both nil" ); + } + if ( m_pISet ) { // if write a EditEngine text, then the WhichIds are greater as // ourer own Ids. So the Id have to translate from our into the @@ -807,6 +821,8 @@ const SfxPoolItem& MSWordExportBase::GetItem(sal_uInt16 nWhich) const OSL_ENSURE(nWhich != 0, "All broken, Impossible"); return m_pISet->Get(nWhich); } + + ///SAL_WARN( "sw.ww8", "done GetItem" << "( " << OUString::number( nWhich ) << " )" ); return m_pChpIter->GetItem( nWhich ); } @@ -1846,7 +1862,7 @@ void WW8Export::OutSwString(const OUString& rStr, sal_Int32 nStt, sal_Int32 const nLen) { - SAL_INFO( "sw.ww8.level2", "<OutSwString>" ); + SAL_WARN( "sw.ww8", "<OutSwString>" ); if( nLen ) { @@ -1854,25 +1870,23 @@ void WW8Export::OutSwString(const OUString& rStr, sal_Int32 nStt, { OUString sOut( rStr.copy( nStt, nLen ) ); - SAL_INFO( "sw.ww8.level2", sOut ); - + SAL_WARN( "sw.ww8", sOut ); SwWW8Writer::WriteString16(Strm(), sOut, false); } else { - SAL_INFO( "sw.ww8.level2", rStr ); - + SAL_WARN( "sw.ww8", rStr ); SwWW8Writer::WriteString16(Strm(), rStr, false); } } - SAL_INFO( "sw.ww8.level2", "</OutSwString>" ); + SAL_WARN( "sw.ww8", "</OutSwString>" ); } void WW8Export::WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) { - if (pTableTextNodeInfoInner.get() != nullptr && pTableTextNodeInfoInner->getDepth() == 1 && pTableTextNodeInfoInner->isEndOfCell()) - WriteChar('\007'); + if ( pTableTextNodeInfoInner.get() && pTableTextNodeInfoInner->getDepth() == 1 && pTableTextNodeInfoInner->isEndOfCell() ) + WriteChar( '\007' ); else WriteChar( '\015' ); @@ -2374,7 +2388,7 @@ void WW8AttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t else WW8Export::Out_SwFormatTableBox( *m_rWW8Export.pO, nullptr); // 8/16 Byte - SAL_INFO( "sw.ww8.level2", "<tclength>" << ( m_rWW8Export.pO->size() - npOCount ) << "</tclength>" ); + SAL_WARN( "sw.ww8", "<tclength>" << ( m_rWW8Export.pO->size() - npOCount ) << "</tclength>" ); } } @@ -2444,7 +2458,6 @@ void AttributeOutputBase::GetTablePageSize( ww8::WW8TableNodeInfoInner * pTableT const SvxLRSpaceItem &rLR = pFormat->GetLRSpace(); nPageSize -= (rLR.GetLeft() + rLR.GetRight()); } - } if ( nWidthPercent ) @@ -2603,11 +2616,13 @@ private: SwPaM *m_pCurPam; sal_uLong m_nStart, m_nEnd; public: - TrackContentToExport(SwPaM *pCurPam, sal_uLong nCurStart, sal_uLong nCurEnd) + TrackContentToExport( SwPaM *pCurPam, sal_uLong nCurStart, sal_uLong nCurEnd ) : m_pCurPam(pCurPam) , m_nStart(nCurStart) , m_nEnd(nCurEnd) { + SAL_WARN( "sw.ww8", "created TrackContentToExport ( nCurStart = " << OUString::number( nCurStart ) + << ", nCurEnd = " << OUString::number( nCurEnd ) << " )" ); } bool contentRemainsToExport(ww8::WW8TableInfo *pTableInfo) @@ -2641,17 +2656,23 @@ public: void MSWordExportBase::WriteText() { - TrackContentToExport aContentTracking(m_pCurPam, m_nCurStart, m_nCurEnd); + SAL_WARN( "sw.ww8", "<WriteText>" ); + + TrackContentToExport aContentTracking( m_pCurPam, m_nCurStart, m_nCurEnd ); while (aContentTracking.contentRemainsToExport(m_pTableInfo.get())) { SwNode& rNd = m_pCurPam->GetNode(); if ( rNd.IsTextNode() ) + { + SAL_WARN( "sw.ww8", "got text node" ); SectionBreaksAndFrames( *rNd.GetTextNode() ); + } // output the various types of nodes if ( rNd.IsContentNode() ) { + SAL_WARN( "sw.ww8", "got content node" ); SwContentNode* pCNd = static_cast<SwContentNode*>(&rNd); const SwPageDesc* pTemp = rNd.FindPageDesc(); @@ -2663,10 +2684,14 @@ void MSWordExportBase::WriteText() } else if ( rNd.IsTableNode() ) { + SAL_WARN( "sw.ww8", "got table node" ); m_pTableInfo->processSwTable( &rNd.GetTableNode()->GetTable() ); } else if ( rNd.IsSectionNode() && TXT_MAINTEXT == m_nTextTyp ) + { + SAL_WARN( "sw.ww8", "got section node" ); OutputSectionNode( *rNd.GetSectionNode() ); + } else if ( TXT_MAINTEXT == m_nTextTyp && rNd.IsEndNode() && rNd.StartOfSectionNode()->IsSectionNode() ) { @@ -2677,11 +2702,15 @@ void MSWordExportBase::WriteText() SwNodeIndex aIdx( rNd, 1 ); if ( aIdx.GetNode().IsEndNode() && aIdx.GetNode().StartOfSectionNode()->IsSectionNode() ) - ; + { + SAL_WARN( "sw.ww8", "aIdx.GetNode().IsEndNode() && aIdx.GetNode().StartOfSectionNode()->IsSectionNode()" ); + } else if ( aIdx.GetNode().IsSectionNode() ) - ; + { + SAL_WARN( "sw.ww8", "aIdx.GetNode().IsSectionNode()" ); + } else if ( !IsInTable() - && (rSect.GetType() != TOX_CONTENT_SECTION && rSect.GetType() != TOX_HEADER_SECTION )) //No sections in table + && ( rSect.GetType() != TOX_CONTENT_SECTION && rSect.GetType() != TOX_HEADER_SECTION ) ) //No sections in table { //#120140# Do not need to insert a page/section break after a section end. Check this case first bool bNeedExportBreakHere = true; @@ -2738,10 +2767,12 @@ void MSWordExportBase::WriteText() } else if ( rNd.IsStartNode() ) { + SAL_WARN( "sw.ww8", "got start node" ); OutputStartNode( *rNd.GetStartNode() ); } else if ( rNd.IsEndNode() ) { + SAL_WARN( "sw.ww8", "got end node" ); OutputEndNode( *rNd.GetEndNode() ); } @@ -2751,9 +2782,9 @@ void MSWordExportBase::WriteText() const SwNode * pCurrentNode = &m_pCurPam->GetPoint()->nNode.GetNode(); const SwNode * pNextNode = m_pTableInfo->getNextNode(pCurrentNode); - if (pCurrentNode == pNextNode) + if ( pCurrentNode == pNextNode ) { - SAL_WARN("sw.ww8", "loop in TableInfo"); + SAL_WARN( "sw.ww8", "loop in TableInfo" ); pNextNode = nullptr; } @@ -2763,15 +2794,16 @@ void MSWordExportBase::WriteText() ++m_pCurPam->GetPoint()->nNode; sal_uLong nPos = m_pCurPam->GetPoint()->nNode.GetIndex(); + SAL_WARN( "sw.ww8", OUString::number( nPos ) << " = nPos" ); ::SetProgressState( nPos, m_pCurPam->GetDoc()->GetDocShell() ); } - SAL_INFO( "sw.ww8.level2", "</WriteText>" ); + SAL_WARN( "sw.ww8", "</WriteText>" ); } void WW8Export::WriteMainText() { - SAL_INFO( "sw.ww8.level2", "<WriteMainText>" ); + SAL_WARN( "sw.ww8", "<WriteMainText>" ); pFib->m_fcMin = Strm().Tell(); @@ -2794,22 +2826,22 @@ void WW8Export::WriteMainText() if( pLastNd ) m_nLastFormatId = GetId( static_cast<SwTextFormatColl&>(pLastNd->GetAnyFormatColl()) ); - SAL_INFO( "sw.ww8.level2", "</WriteMainText>" ); + SAL_WARN( "sw.ww8", "</WriteMainText>" ); } bool MSWordExportBase::IsInTable() const { bool bResult = false; - if (m_pCurPam != nullptr) + if ( m_pCurPam ) { SwNode& rNode = m_pCurPam->GetNode(); - if (m_pTableInfo.get() != nullptr) + if ( m_pTableInfo.get() ) { ww8::WW8TableNodeInfo::Pointer_t pTableNodeInfo = m_pTableInfo->getTableNodeInfo(&rNode); - if (pTableNodeInfo.get() != nullptr && pTableNodeInfo->getDepth() > 0) + if ( pTableNodeInfo.get() && pTableNodeInfo->getDepth() > 0) { bResult = true; } @@ -3160,7 +3192,7 @@ bool SwWW8Writer::InitStd97CodecUpdateMedium( ::msfilter::MSCodec_Std97& rCodec const SfxUnoAnyItem* pEncryptionDataItem = SfxItemSet::GetItem<SfxUnoAnyItem>(mpMedium->GetItemSet(), SID_ENCRYPTIONDATA, false); if ( pEncryptionDataItem && ( pEncryptionDataItem->GetValue() >>= aEncryptionData ) && !rCodec.InitCodec( aEncryptionData ) ) { - OSL_ENSURE( false, "Unexpected EncryptionData!" ); + SAL_WARN( "sw.ww8", "unexpected EncryptionData" ); aEncryptionData.realloc( 0 ); } @@ -3384,6 +3416,8 @@ void WW8Export::ExportDocument_Impl() void WW8Export::PrepareStorage() { + SAL_WARN( "sw.ww8", "<PrepareStorage>" ); + static const sal_uInt8 pData[] = { 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00, @@ -3415,36 +3449,41 @@ void WW8Export::PrepareStorage() xStor->WriteBytes(pData, sizeof(pData)); SwDocShell* pDocShell = m_pDoc->GetDocShell (); - OSL_ENSURE(pDocShell, "no SwDocShell"); - - if (pDocShell) { + if ( pDocShell ) { uno::Reference<document::XDocumentPropertiesSupplier> xDPS( - pDocShell->GetModel(), uno::UNO_QUERY_THROW); - uno::Reference<document::XDocumentProperties> xDocProps( - xDPS->getDocumentProperties()); - OSL_ENSURE(xDocProps.is(), "DocumentProperties is null"); + pDocShell->GetModel(), uno::UNO_QUERY ); + if ( ! xDPS.is() ) + { + SAL_WARN( "sw.ww8", "no DocumentPropertiesSupplier" ); + return; + } - if (xDocProps.is()) + uno::Reference<document::XDocumentProperties> xDocProps( xDPS->getDocumentProperties() ); + if ( xDocProps.is() ) { if ( SvtFilterOptions::Get().IsEnableWordPreview() ) { - std::shared_ptr<GDIMetaFile> xMetaFile = - pDocShell->GetPreviewMetaFile(); - uno::Sequence<sal_Int8> metaFile( - sfx2::convertMetaFile(xMetaFile.get())); - sfx2::SaveOlePropertySet(xDocProps, &GetWriter().GetStorage(), &metaFile); + std::shared_ptr<GDIMetaFile> xMetaFile = pDocShell->GetPreviewMetaFile(); + uno::Sequence<sal_Int8> metaFile( sfx2::convertMetaFile( xMetaFile.get() ) ); + sfx2::SaveOlePropertySet( xDocProps, &GetWriter().GetStorage(), &metaFile ); } else sfx2::SaveOlePropertySet( xDocProps, &GetWriter().GetStorage() ); } + else + SAL_WARN( "sw.ww8", "DocumentProperties is null" ); } + else + SAL_WARN( "sw.ww8", "no SwDocShell" ); + + SAL_WARN( "sw.ww8", "</PrepareStorage>" ); } sal_uLong SwWW8Writer::WriteStorage() { // #i34818# - update layout (if present), for SwWriteTable SwViewShell* pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); - if( pViewShell != nullptr ) + if( pViewShell ) pViewShell->CalcLayout(); long nMaxNode = pDoc->GetNodes().Count(); @@ -3879,7 +3918,7 @@ void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) pDataStrm->WriteUInt32( slen ); int len = sizeof( aFieldData ); - OSL_ENSURE( len == 0x44-sizeof(sal_uInt32), "SwWW8Writer::WriteFormData(..) - wrong aFieldData length" ); + OSL_ENSURE( len == 0x44 - sizeof(sal_uInt32), "wrong aFieldData length" ); pDataStrm->WriteBytes( aFieldData, len ); pDataStrm->WriteUInt32( aFieldHeader.version ).WriteUInt16( aFieldHeader.bits ).WriteUInt16( aFieldHeader.cch ).WriteUInt16( aFieldHeader.hps ); @@ -3917,9 +3956,7 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer SVBT16 nStyle; ShortToSVBT16( m_rWW8Export.m_nStyleBeforeFly, nStyle ); -#ifdef DBG_UTIL - SAL_INFO( "sw.ww8", "<OutWW8_TableNodeInfoInner>" << pNodeInfoInner->toString()); -#endif + SAL_WARN( "sw.ww8", "<TableNodeInfoInner>" ); m_rWW8Export.pO->clear(); @@ -3947,7 +3984,7 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer if (pNodeInfoInner->isEndOfCell()) { - SAL_INFO( "sw.ww8", "<endOfCell/>" ); + SAL_WARN( "sw.ww8", "<endOfCell/>" ); m_rWW8Export.WriteCR(pNodeInfoInner); @@ -3981,7 +4018,7 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer if (pNodeInfoInner->isEndOfLine()) { - SAL_INFO( "sw.ww8", "<endOfLine/>" ); + SAL_WARN( "sw.ww8", "<endOfLine/>" ); TableRowEnd(pNodeInfoInner->getDepth()); @@ -3992,20 +4029,18 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer m_rWW8Export.pO->clear(); } - SAL_INFO( "sw.ww8", "</OutWW8_TableNodeInfoInner>" ); + + SAL_WARN( "sw.ww8", "</TableNodeInfoInner>" ); } void MSWordExportBase::OutputStartNode( const SwStartNode & rNode) { + SAL_WARN( "sw.ww8", "<OutputStartNode>" ); /// << dbg_out(&rNode) ); - ww8::WW8TableNodeInfo::Pointer_t pNodeInfo = - m_pTableInfo->getTableNodeInfo( &rNode ); + ww8::WW8TableNodeInfo::Pointer_t pNodeInfo = m_pTableInfo->getTableNodeInfo( &rNode ); - if (pNodeInfo.get() != nullptr) + if ( pNodeInfo.get() ) { -#ifdef DBG_UTIL - SAL_INFO( "sw.ww8", pNodeInfo->toString()); -#endif const ww8::WW8TableNodeInfo::Inners_t aInners = pNodeInfo->getInners(); ww8::WW8TableNodeInfo::Inners_t::const_reverse_iterator aIt(aInners.rbegin()); ww8::WW8TableNodeInfo::Inners_t::const_reverse_iterator aEnd(aInners.rend()); @@ -4017,18 +4052,19 @@ void MSWordExportBase::OutputStartNode( const SwStartNode & rNode) ++aIt; } } - SAL_INFO( "sw.ww8", "</OutWW8_SwStartNode>" ); + /// else + /// SAL_WARN( "sw.ww8", "can't get TableNodeInfo" ); + + SAL_WARN( "sw.ww8", "</OutputStartNode>" ); } void MSWordExportBase::OutputEndNode( const SwEndNode &rNode ) { -#ifdef DBG_UTIL - SAL_INFO( "sw.ww8", "<OutWW8_SwEndNode>" << dbg_out(&rNode)); -#endif + SAL_WARN( "sw.ww8", "<OutputEndNode>" ); /// << dbg_out(&rNode) ); ww8::WW8TableNodeInfo::Pointer_t pNodeInfo = m_pTableInfo->getTableNodeInfo( &rNode ); - if (pNodeInfo.get() != nullptr) + if ( pNodeInfo.get() ) { #ifdef DBG_UTIL SAL_INFO( "sw.ww8", pNodeInfo->toString()); @@ -4043,12 +4079,15 @@ void MSWordExportBase::OutputEndNode( const SwEndNode &rNode ) ++aIt; } } - SAL_INFO( "sw.ww8", "</OutWW8_SwEndNode>" ); + /// else + /// SAL_WARN( "sw.ww8", "can't get TableNodeInfo" ); + + SAL_WARN( "sw.ww8", "</OutputEndNode>" ); } const NfKeywordTable & MSWordExportBase::GetNfKeywordTable() { - if (m_pKeyMap.get() == nullptr) + if ( ! m_pKeyMap.get() ) { m_pKeyMap.reset(new NfKeywordTable); NfKeywordTable & rKeywordTable = *m_pKeyMap; diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 1a833a9af899..c4af12e79bcb 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -391,6 +391,8 @@ bool MSWordExportBase::SetAktPageDescFromNode(const SwNode &rNd) // und damit im falschen landen wuerden. void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd, bool isCellOpen, bool isTextNodeEmpty) { + SAL_WARN( "sw.ww8", "<OutputSectionBreaks>" ); + if ( m_bStyDef || m_bOutKF || m_bInWriteEscher || m_bOutPageDescs ) return; @@ -475,7 +477,6 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode if ( !bRemoveHardBreakInsideTable ) { - OSL_ENSURE(m_pAktPageDesc, "should not be possible"); /* If because of this pagebreak the page desc following the page break is the follow style of the current page desc then output a @@ -495,7 +496,9 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode } if( isTextNodeEmpty ) bNewPageDesc = false; - } + } else + SAL_WARN( "sw.ww8", "m_pAktPageDesc is nil"); + if ( !bNewPageDesc ) AttrOutput().OutputItem( *pItem ); } @@ -542,6 +545,8 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode } m_bBreakBefore = false; m_bPrevTextNodeIsEmpty = isTextNodeEmpty ; + + SAL_WARN( "sw.ww8", "</OutputSectionBreaks>" ); } // #i76300# @@ -608,7 +613,7 @@ void WW8Export::PrepareNewPageDesc( const SfxItemSet*pSet, const SwSectionFormat* pFormat = GetSectionFormat( rNd ); const sal_uLong nLnNm = GetSectionLineNo( pSet, rNd ); - OSL_ENSURE( pNewPgDescFormat || pNewPgDesc, "Neither page desc format nor page desc provided." ); + OSL_ENSURE( pNewPgDescFormat || pNewPgDesc, "Neither page desc format nor page desc provided" ); if ( pNewPgDescFormat ) { @@ -710,6 +715,8 @@ bool WW8Export::DisallowInheritingOutlineNumbering(const SwFormat &rFormat) void MSWordExportBase::OutputFormat( const SwFormat& rFormat, bool bPapFormat, bool bChpFormat, bool bFlyFormat ) { + SAL_INFO( "sw.ww8", "<OutputFormat>" ); + bool bCallOutSet = true; const SwModify* pOldMod = m_pOutFormatNode; m_pOutFormatNode = &rFormat; @@ -834,7 +841,7 @@ void MSWordExportBase::OutputFormat( const SwFormat& rFormat, bool bPapFormat, b case RES_FRMFMT: break; default: - OSL_ENSURE( false, "Which format is exported here?" ); + SAL_WARN( "sw.ww8", "Which format is exported here?" ); break; } @@ -842,6 +849,8 @@ void MSWordExportBase::OutputFormat( const SwFormat& rFormat, bool bPapFormat, b OutputItemSet( rFormat.GetAttrSet(), bPapFormat, bChpFormat, i18n::ScriptType::LATIN, m_bExportModeRTF); m_pOutFormatNode = pOldMod; + + SAL_INFO( "sw.ww8", "</OutputFormat>" ); } bool MSWordExportBase::HasRefToObject( sal_uInt16 nTyp, const OUString* pName, sal_uInt16 nSeqNo ) @@ -935,6 +944,8 @@ void WW8AttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript ) void WW8AttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) { + SAL_WARN( "sw.ww8", "<EndParagraph>" ); + m_rWW8Export.m_pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell() - (mbOnTOXEnding?2:0), m_rWW8Export.pO->size(), m_rWW8Export.pO->data() ); mbOnTOXEnding = false; m_rWW8Export.pO->clear(); @@ -953,6 +964,8 @@ void WW8AttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTe m_rWW8Export.pO->clear(); } } + + SAL_WARN( "sw.ww8", "</EndParagraph>" ); } void WW8AttributeOutput::StartRunProperties() @@ -1026,11 +1039,15 @@ void WW8AttributeOutput::OutputFKP(bool bForce) void WW8AttributeOutput::ParagraphStyle( sal_uInt16 nStyle ) { - OSL_ENSURE( m_rWW8Export.pO->empty(), " pO ist am ZeilenEnde nicht leer" ); + SAL_WARN( "sw.ww8", "<ParagraphStyle>" ); + + OSL_ENSURE( m_rWW8Export.pO->empty(), " pO is not empty" ); SVBT16 nSty; ShortToSVBT16( nStyle, nSty ); m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), nSty, nSty+2 ); // Style # + + SAL_WARN( "sw.ww8", "</ParagraphStyle>" ); } void WW8AttributeOutput::OutputWW8Attribute( sal_uInt8 nId, bool bVal ) @@ -1668,6 +1685,8 @@ WW8_WrPlcField* WW8Export::CurrentFieldPlc() const void WW8Export::OutputField( const SwField* pField, ww::eField eFieldType, const OUString& rFieldCmd, FieldFlags nMode ) { + SAL_WARN( "sw.ww8", "<OutputField>" ); + OUString sFieldCmd(rFieldCmd); switch (eFieldType) { @@ -1801,6 +1820,8 @@ void WW8Export::OutputField( const SwField* pField, ww::eField eFieldType, pFieldP->Append( Fc2Cp( Strm().Tell() ), aField15 ); InsertSpecialChar( *this, 0x15, nullptr, bIncludeEmptyPicLocation ); } + + SAL_WARN( "sw.ww8", "</OutputField>" ); } void WW8Export::StartCommentOutput(const OUString& rName) @@ -5162,6 +5183,7 @@ const SwRedlineData* AttributeOutputBase::GetParagraphMarkerRedline( const SwTex } } } + return nullptr; } diff --git a/sw/source/uibase/app/docshini.cxx b/sw/source/uibase/app/docshini.cxx index 42c276d3e4a0..ddd2038a333f 100644 --- a/sw/source/uibase/app/docshini.cxx +++ b/sw/source/uibase/app/docshini.cxx @@ -553,11 +553,8 @@ bool SwDocShell::Load( SfxMedium& rMedium ) if( pReader ) { // set Doc's DocInfo at DocShell-Medium - SAL_INFO( "sw.ui", "before ReadDocInfo" ); SwReader aRdr( rMedium, aEmptyOUStr, m_pDoc ); - SAL_INFO( "sw.ui", "before Read" ); nErr = aRdr.Read( *pReader ); - SAL_INFO( "sw.ui", "after Read" ); // If a XML document is loaded, the global doc/web doc // flags have to be set, because they aren't loaded // by this formats. @@ -576,13 +573,13 @@ bool SwDocShell::Load( SfxMedium& rMedium ) break; default: - OSL_ENSURE( false, "Load: new CreateMode?" ); + SAL_WARN( "sw.ui", "Load: new CreateMode?" ); } UpdateFontList(); InitDrawModelAndDocShell(this, m_pDoc ? m_pDoc->getIDocumentDrawModelAccess().GetDrawModel() : nullptr); - SAL_WARN( "sw.ui", "error on load: " << nErr ); + SAL_WARN( "sw.ui", "error on load: 0x" << OUString::number(static_cast< sal_uInt32 >( nErr ), 16) ); bRet = !IsError( nErr ); if (bRet && !m_pDoc->IsInLoadAsynchron() && diff --git a/vcl/osx/salmenu.cxx b/vcl/osx/salmenu.cxx index 0697f6afd92b..a7b90a0997f0 100644 --- a/vcl/osx/salmenu.cxx +++ b/vcl/osx/salmenu.cxx @@ -677,7 +677,7 @@ void AquaSalMenu::SetAccelerator( unsigned /*nPos*/, SalMenuItem* pSalMenuItem, sal_uInt16 nModifier; sal_Unicode nCommandKey = 0; - sal_uInt16 nKeyCode=rKeyCode.GetCode(); + sal_uInt16 nKeyCode = rKeyCode.GetCode(); if( nKeyCode ) { if ((nKeyCode>=KEY_A) && (nKeyCode<=KEY_Z)) // letter A..Z @@ -751,7 +751,7 @@ void AquaSalMenu::SetAccelerator( unsigned /*nPos*/, SalMenuItem* pSalMenuItem, else // not even a code ? nonsense -> ignore return; - SAL_WARN_IF( !nCommandKey, "vcl", "unmapped accelerator key" ); + SAL_WARN_IF( !nCommandKey, "vcl.osx", "unmapped accelerator for key code 0x" << OUString::number(nKeyCode, 16) ); nModifier=rKeyCode.GetModifier(); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 3278f9237538..c71ec57bd759 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -571,10 +571,11 @@ void DomainMapper_Impl::PopProperties(ContextType eId) PropertyMapPtr DomainMapper_Impl::GetTopContextOfType(ContextType eId) { PropertyMapPtr pRet; - SAL_WARN_IF( m_aPropertyStacks[eId].empty(), "writerfilter.dmapper", - "no context of type " << static_cast<int>(eId) << " available"); - if(!m_aPropertyStacks[eId].empty()) - pRet = m_aPropertyStacks[eId].top(); + if ( ! m_aPropertyStacks[ eId ].empty() ) + pRet = m_aPropertyStacks[ eId ].top(); + else + SAL_WARN( "writerfilter.dmapper", "no context of type " << static_cast< int >( eId ) << " is here" ); + return pRet; } diff --git a/writerfilter/source/filter/WriterFilter.cxx b/writerfilter/source/filter/WriterFilter.cxx index e247000158f3..dfce2b8e1d42 100644 --- a/writerfilter/source/filter/WriterFilter.cxx +++ b/writerfilter/source/filter/WriterFilter.cxx @@ -124,8 +124,10 @@ private: sal_Bool WriterFilter::filter(const uno::Sequence< beans::PropertyValue >& aDescriptor) throw (uno::RuntimeException, std::exception) { - if (m_xSrcDoc.is()) + if ( m_xSrcDoc.is() ) { + SAL_WARN( "writerfilter", "WriterFilter::filter() SourceDocument" ); + uno::Reference< lang::XMultiServiceFactory > xMSF(m_xContext->getServiceManager(), uno::UNO_QUERY_THROW); uno::Reference< uno::XInterface > xIfc; try @@ -141,15 +143,40 @@ sal_Bool WriterFilter::filter(const uno::Sequence< beans::PropertyValue >& aDesc uno::Any a(cppu::getCaughtException()); throw lang::WrappedTargetRuntimeException("wrapped " + a.getValueTypeName() + ": " + e.Message, uno::Reference<uno::XInterface>(), a); } - uno::Reference< document::XExporter > xExprtr(xIfc, uno::UNO_QUERY_THROW); - uno::Reference< document::XFilter > xFltr(xIfc, uno::UNO_QUERY_THROW); - if (!xExprtr.is() || !xFltr.is()) + + uno::Reference< document::XExporter > xExporter( xIfc, uno::UNO_QUERY ); + uno::Reference< document::XFilter > xFilter( xIfc, uno::UNO_QUERY ); + +#if OSL_DEBUG_LEVEL > 0 + OUString msg = "XExporter is "; + if ( xExporter.is() ) + msg += "okay"; + else + msg += "nil"; + msg += ", "; + msg += "XFilter is "; + if ( xFilter.is() ) + msg += "okay"; + else + msg += "nil"; + SAL_WARN( "writerfilter", msg ); +#endif + + if ( !xExporter.is() || !xFilter.is() ) return false; - xExprtr->setSourceDocument(m_xSrcDoc); - return xFltr->filter(aDescriptor); + + xExporter->setSourceDocument( m_xSrcDoc ); + sal_Bool bRet = sal_False; + try { + bRet = xFilter->filter( aDescriptor ); + } catch ( ... ) { } + SAL_WARN( "writerfilter", "xFilter->filter() result is " << ( bRet ? "true" : "false" ) ); + return bRet; } - else if (m_xDstDoc.is()) + else if ( m_xDstDoc.is() ) { + SAL_WARN( "writerfilter", "WriterFilter::filter() DstDoc" ); + utl::MediaDescriptor aMediaDesc(aDescriptor); bool bRepairStorage = aMediaDesc.getUnpackedValueOrDefault("RepairPackage", false); bool bSkipImages = aMediaDesc.getUnpackedValueOrDefault("FilterOptions", OUString("")) == "SkipImages"; @@ -310,9 +337,10 @@ void WriterFilter::initialize(const uno::Sequence< uno::Any >& /*rArguments*/) t { } -OUString WriterFilter::getImplementationName() throw (uno::RuntimeException, std::exception) +OUString WriterFilter::getImplementationName() + throw ( uno::RuntimeException, std::exception ) { - return OUString("com.sun.star.comp.Writer.WriterFilter"); + return OUString( "com.sun.star.comp.Writer.WriterFilter" ); } |