From ad468a24d60160c9b3e2b184cb2daa1e2f137a08 Mon Sep 17 00:00:00 2001 From: Oliver-Rainer Wittmann Date: Fri, 26 Feb 2010 15:43:56 +0100 Subject: sw33bf03: #i100611#,#i107834# - method - remove adjustment to determined screen due to an arbitrary text string rendering and apply cmc's patch to preserve "faked" font properties (weight and italic) --- sw/source/core/txtnode/fntcache.cxx | 179 +----------------------------------- 1 file changed, 5 insertions(+), 174 deletions(-) (limited to 'sw/source') diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 7aec6d4e9884..3a2c7ddc3f0e 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -447,8 +447,6 @@ USHORT SwFntObj::GetFontLeading( const ViewShell *pSh, const OutputDevice& rOut void SwFntObj::CreateScrFont( const ViewShell& rSh, const OutputDevice& rOut ) { -static sal_Char __READONLY_DATA sStandardString[] = "Dies ist der Teststring"; - if ( pScrFont ) return; @@ -484,6 +482,11 @@ static sal_Char __READONLY_DATA sStandardString[] = "Dies ist der Teststring"; pScrFont = pPrtFont; FontMetric aMet = pPrt->GetFontMetric( ); + //Don't loose "faked" properties of the logical font that don't truly + //exist in the physical font metrics which vcl which fake up for us + aMet.SetWeight(pScrFont->GetWeight()); + aMet.SetItalic(pScrFont->GetItalic()); + bSymbol = RTL_TEXTENCODING_SYMBOL == aMet.GetCharSet(); if ( USHRT_MAX == nGuessedLeading ) @@ -492,178 +495,6 @@ static sal_Char __READONLY_DATA sStandardString[] = "Dies ist der Teststring"; if ( USHRT_MAX == nExtLeading ) nExtLeading = static_cast(aMet.GetExtLeading()); -#if OSL_DEBUG_LEVEL > 1 - const XubString aDbgTxt1( pPrtFont->GetName() ); - const XubString aDbgTxt2( aMet.GetName() ); -#endif - - if ( aMet.IsDeviceFont( ) ) - { - if ( (RTL_TEXTENCODING_DONTKNOW == pPrtFont->GetCharSet() || - FAMILY_DONTKNOW == pPrtFont->GetFamily() || - PITCH_DONTKNOW == pPrtFont->GetPitch() ) && - (RTL_TEXTENCODING_DONTKNOW == aMet.GetCharSet() || - FAMILY_DONTKNOW == aMet.GetFamily() || - PITCH_DONTKNOW == aMet.GetPitch() ) ) - { - // Das folgende ist teuer, aber selten: ein unbekannter Font - // kann vom Drucker nicht vernuenftig zugeordnet werden. Dann - // nehmen wir eben das Mapping des Bildschirms in Anspruch und - // setzen den Familyname, Charset und Pitch wie dort. Dieser - // Font wird nun nochmals auf dem Drucker eingestellt. - Font aFnt1 = pOut->GetFontMetric(); - Font aFnt2( *pPrtFont ); - - if (RTL_TEXTENCODING_DONTKNOW == pPrtFont->GetCharSet()) - aFnt2.SetCharSet( aFnt1.GetCharSet() ); - if (FAMILY_DONTKNOW == pPrtFont->GetFamily()) - aFnt2.SetFamily( aFnt1.GetFamily() ); - if (PITCH_DONTKNOW == pPrtFont->GetPitch()) - aFnt2.SetPitch( aFnt1.GetPitch() ); - - pPrt->SetFont( aFnt2 ); - aMet = pPrt->GetFontMetric( ); - } - - const XubString aStandardStr( sStandardString, - RTL_TEXTENCODING_MS_1252 ); - - // This is the reference width - const long nOWidth = pPrt->GetTextWidth( aStandardStr ); - - // Let's have a look what's the difference to the width - // calculated for the output device using the font set at the - // reference device - long nSWidth = nOWidth - pOut->GetTextWidth( aStandardStr ); - nScrHeight = (USHORT) pOut->GetTextHeight(); - - // Um Aerger mit dem Generic Printer aus dem Wege zu gehen. - if( aMet.GetSize().Height() ) - { - BOOL bScrSymbol = FALSE; - CharSet ePrtChSet = aMet.GetCharSet(); - // NoSymbol bedeutet, dass der Drucker sich fuer einen - // Nicht-Symbol-Font entschieden hat. - BOOL bNoSymbol = ( RTL_TEXTENCODING_DONTKNOW != ePrtChSet && - RTL_TEXTENCODING_SYMBOL != ePrtChSet ); - if ( bNoSymbol ) - bScrSymbol = RTL_TEXTENCODING_SYMBOL == - pOut->GetFontMetric().GetCharSet(); - Size aTmp( aMet.GetSize() ); - - if( aTmp.Width() && !pPrtFont->GetSize().Width() ) - { - aTmp.Width() = 0; - aMet.SetSize( aTmp ); - } - - // Now we set the metrics used at the reference device at the - // output device - pOut->SetFont( aMet ); - - if( bNoSymbol && ( bScrSymbol != ( RTL_TEXTENCODING_SYMBOL == - pOut->GetFontMetric().GetCharSet() ) ) ) - { - // Hier landen wir, wenn der Drucker keinen Symbolfont waehlt, - // aber genau einer der beiden Screenfonts ein Symbolfont ist. - // Wir nehmen dann eben den anderen. - if ( bScrSymbol ) - pScrFont = new Font( aMet ); // mit Abgleich - else - pOut->SetFont( *pPrtFont ); // ohne Abgleich - } - else - { - // Let's have a look what's the difference to the width - // calculated for the output device using the metrics set at - // the reference device - long nPWidth = nOWidth - pOut->GetTextWidth( aStandardStr ); - - // We prefer smaller fonts - BYTE nNeg = 0; - if ( nSWidth<0 ) { nSWidth *= -2; nNeg = 1; } - if ( nPWidth<0 ) { nPWidth *= -2; nNeg |= 2; } - - // nSWidth = Difference between string width on reference device - // and string width on output device with user font set. - // nPWidth = Difference between string width on reference device - // and string width on output device with metric obtained - // from reference device. - // We prefer to take the font with the smaller deviation, - // exception: keep the original font unless the deviation - // is really bad (at least 3%) - // Since the test string is neither localized nor has a high resemblance - // of the "real text for this font" a higher deviation is reasonable - - if ( (nSWidth <= nPWidth) - || (nSWidth * 32 <= nOWidth ) ) - { - // No adjustment, we take the same font for the output - // device like for the reference device - pOut->SetFont( *pPrtFont ); - pScrFont = pPrtFont; - nPWidth = nSWidth; - nNeg &= 1; - } - else - { - // The metrics give a better result. So we build - // a new font for the output device based on the - // metrics used at the reference device - pScrFont = new Font( aMet ); // mit Abgleich - nSWidth = nPWidth; - nNeg &= 2; - } - - // - // now pScrFont is set to the better font and this should - // be set at the output device - // - - // we still have to check if the choosed font is not to wide - if( nNeg && nOWidth ) - { - nPWidth *= 100; - nPWidth /= nOWidth; - - // if the screen font is too wide, we try to reduce - // the font height and get a smaller one - if( nPWidth > 25 ) - { - if( nPWidth > 80 ) - nPWidth = 80; - nPWidth = 100 - nPWidth/4; - Size aTmpSize = pScrFont->GetSize(); - aTmpSize.Height() *= nPWidth; - aTmpSize.Height() /= 100; - if( aTmpSize.Width() ) - { - aTmpSize.Width() *= nPWidth; - aTmpSize.Width() /= 100; - } - Font *pNew = new Font( *pScrFont ); - pNew->SetSize( aTmpSize ); - pOut->SetFont( *pNew ); - nPWidth = nOWidth - - pOut->GetTextWidth( aStandardStr ); - if( nPWidth < 0 ) { nPWidth *= -2; } - if( nPWidth < nSWidth ) - { - if( pScrFont != pPrtFont ) - delete pScrFont; - pScrFont = pNew; - } - else - { - delete pNew; - pOut->SetFont( *pScrFont ); - } - } - } - } - } - } - // reset the original reference device font pPrt->SetFont( aOldPrtFnt ); } -- cgit v1.2.3 From 775be31b8148eed368b440c49613cfb1917a027e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 15 Mar 2010 17:00:24 +0100 Subject: sw33bf03: #i110144#: sw: ascii export: add space after list label --- sw/source/filter/ascii/ascatr.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'sw/source') diff --git a/sw/source/filter/ascii/ascatr.cxx b/sw/source/filter/ascii/ascatr.cxx index 02408f971140..abb842acb3f4 100644 --- a/sw/source/filter/ascii/ascatr.cxx +++ b/sw/source/filter/ascii/ascatr.cxx @@ -172,7 +172,14 @@ static Writer& OutASC_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) SwASC_AttrIter aAttrIter( (SwASCWriter&)rWrt, rNd, nStrPos ); if( !nStrPos && rWrt.bExportPargraphNumbering ) - rWrt.Strm().WriteUnicodeOrByteText( rNd.GetNumString() ); + { + String numString( rNd.GetNumString() ); + if (numString.Len()) + { + numString.Append(' '); + rWrt.Strm().WriteUnicodeOrByteText(numString); + } + } String aStr( rNd.GetTxt() ); if( rWrt.bASCII_ParaAsBlanc ) -- cgit v1.2.3 From a4f0aa4ea560aefd0eba9dd59ad63d7d91087864 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 16 Mar 2010 17:07:56 +0100 Subject: sw33bf03: #i110140#: sw: ~SwTxtFld: unregister at field format --- sw/source/core/txtnode/atrfld.cxx | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sw/source') diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 68c779f9914b..9ac53456e7ef 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -268,6 +268,11 @@ SwTxtFld::SwTxtFld( SwFmtFld& rAttr, xub_StrLen nStartPos ) SwTxtFld::~SwTxtFld( ) { + SwFmtFld & rFmtFld( static_cast(GetAttr()) ); + if (this == rFmtFld.pTxtAttr) + { + rFmtFld.pTxtAttr = 0; // #i110140# invalidate! + } } /************************************************************************* -- cgit v1.2.3 From b9ba6b35bf4a2a3ef5f85e4cca6ac6e8818161f1 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 16 Mar 2010 17:15:38 +0100 Subject: sw33bf03: #i110140#: SwFldFmt::Modify: apply patch by cmc --- sw/source/core/txtnode/atrfld.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sw/source') diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 9ac53456e7ef..13695778c6a8 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -160,14 +160,16 @@ void SwFmtFld::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) if( !pTxtAttr ) return; + // don't do anything, especially not expand! + if( pNew && pNew->Which() == RES_OBJECTDYING ) + return; + SwTxtNode* pTxtNd = (SwTxtNode*)&pTxtAttr->GetTxtNode(); ASSERT( pTxtNd, "wo ist denn mein Node?" ); if( pNew ) { switch( pNew->Which() ) { - case RES_OBJECTDYING: - return; // don't do anything, especially not expand! case RES_TXTATR_FLDCHG: // "Farbe hat sich geaendert !" // this, this fuer "nur Painten" @@ -192,6 +194,8 @@ void SwFmtFld::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) case RES_FMT_CHG: pTxtNd->Modify( pOld, pNew ); return; + default: + break; } } -- cgit v1.2.3 From 3421215984f3c0a5fcbadc070524f93dc6b89923 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 17 Mar 2010 13:44:55 +0100 Subject: sw33bf03: #i109921#: sw: unnecessary null checks: apply patch by cmc --- sw/source/core/frmedt/feshview.cxx | 5 +---- sw/source/ui/uno/unotxvw.cxx | 27 ++++++++++++--------------- 2 files changed, 13 insertions(+), 19 deletions(-) (limited to 'sw/source') diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index af2e8d1c7677..d435bfb194d9 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -238,10 +238,7 @@ BOOL SwFEShell::SelectObj( const Point& rPt, BYTE nFlag, SdrObject *pObj ) if( bForget ) { pDView->UnmarkAll(); - if ( pTmpObj ) - pDView->MarkObj( pTmpObj, Imp()->GetPageView(), bAddSelect, bEnterGroup ); - else - pDView->MarkObj( rPt, MINMOVE ); + pDView->MarkObj( pTmpObj, Imp()->GetPageView(), bAddSelect, bEnterGroup ); break; } } diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 73c89873819b..556f6bd26997 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -908,12 +908,12 @@ void SAL_CALL SwXTextView::setRubyList( -----------------------------------------------------------------------*/ SfxObjectShellRef SwXTextView::BuildTmpSelectionDoc( SfxObjectShellRef& /*rRef*/ ) { - SwWrtShell* pOldSh = &m_pView->GetWrtShell(); - SfxPrinter *pPrt = pOldSh->getIDocumentDeviceAccess()->getPrinter( false ); + SwWrtShell& rOldSh = m_pView->GetWrtShell(); + SfxPrinter *pPrt = rOldSh.getIDocumentDeviceAccess()->getPrinter( false ); SwDocShell* pDocSh; SfxObjectShellRef xDocSh( pDocSh = new SwDocShell( /*pPrtDoc, */SFX_CREATE_MODE_STANDARD ) ); xDocSh->DoInitNew( 0 ); - pOldSh->FillPrtDoc(pDocSh->GetDoc(), pPrt); + rOldSh.FillPrtDoc(pDocSh->GetDoc(), pPrt); SfxViewFrame* pDocFrame = SfxViewFrame::CreateViewFrame( *xDocSh, 0, TRUE ); SwView* pDocView = (SwView*) pDocFrame->GetViewShell(); pDocView->AttrChangedNotify( &pDocView->GetWrtShell() );//Damit SelectShell gerufen wird. @@ -922,22 +922,19 @@ SfxObjectShellRef SwXTextView::BuildTmpSelectionDoc( SfxObjectShellRef& /*rRef*/ IDocumentDeviceAccess* pIDDA = pSh->getIDocumentDeviceAccess(); SfxPrinter* pTempPrinter = pIDDA->getPrinter( true ); - if( pOldSh ) - { - const SwPageDesc& rCurPageDesc = pOldSh->GetPageDesc(pOldSh->GetCurPageDesc()); - - IDocumentDeviceAccess* pIDDA_old = pOldSh->getIDocumentDeviceAccess(); + const SwPageDesc& rCurPageDesc = rOldSh.GetPageDesc(rOldSh.GetCurPageDesc()); - if( pIDDA_old->getPrinter( false ) ) - { - pIDDA->setJobsetup( *pIDDA_old->getJobsetup() ); - //#69563# if it isn't the same printer then the pointer has been invalidated! - pTempPrinter = pIDDA->getPrinter( true ); - } + IDocumentDeviceAccess* pIDDA_old = rOldSh.getIDocumentDeviceAccess(); - pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue()); + if( pIDDA_old->getPrinter( false ) ) + { + pIDDA->setJobsetup( *pIDDA_old->getJobsetup() ); + //#69563# if it isn't the same printer then the pointer has been invalidated! + pTempPrinter = pIDDA->getPrinter( true ); } + pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue()); + return xDocSh; } -- cgit v1.2.3 From 5d58845170113179d5bc9e60d2411196b8d30240 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 26 Mar 2010 19:38:34 +0100 Subject: sw33bf03: #i110408#: SwXFlatParagraph: apply patch by dtardon --- sw/inc/unoflatpara.hxx | 12 ++++++++++-- sw/source/core/unocore/unoflatpara.cxx | 30 +++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 7 deletions(-) (limited to 'sw/source') diff --git a/sw/inc/unoflatpara.hxx b/sw/inc/unoflatpara.hxx index e092a6d28c82..70af89580ec5 100644 --- a/sw/inc/unoflatpara.hxx +++ b/sw/inc/unoflatpara.hxx @@ -32,6 +32,7 @@ #define _UNOFLATPARA_HXX #include +#include #include #include #include @@ -54,9 +55,10 @@ class SwDoc; ******************************************************************************/ class SwXFlatParagraph: - public ::cppu::WeakImplHelper1 + public ::cppu::WeakImplHelper2 < - css::text::XFlatParagraph + css::text::XFlatParagraph, + css::lang::XUnoTunnel >, public SwXTextMarkup { @@ -88,6 +90,12 @@ public: const SwTxtNode* getTxtNode() const; + static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 >& rId) + throw (css::uno::RuntimeException); + private: SwXFlatParagraph( const SwXFlatParagraph & ); // not defined SwXFlatParagraph & operator = ( const SwXFlatParagraph & ); // not defined diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index d68fc43a3abc..e857a3b21af7 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -33,6 +33,7 @@ #include +#include #include #include @@ -268,6 +269,24 @@ css::uno::Sequence< ::sal_Int32 > SAL_CALL SwXFlatParagraph::getLanguagePortions return css::uno::Sequence< ::sal_Int32>(); } + +const uno::Sequence< sal_Int8 >& +SwXFlatParagraph::getUnoTunnelId() +{ + static uno::Sequence aSeq(CreateUnoTunnelId()); + return aSeq; +} + + +sal_Int64 SAL_CALL +SwXFlatParagraph::getSomething( + const uno::Sequence< sal_Int8 >& rId) + throw (uno::RuntimeException) +{ + return sw::UnoTunnelImpl(rId, this); +} + + /****************************************************************************** * SwXFlatParagraphIterator ******************************************************************************/ @@ -429,8 +448,9 @@ uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getParaAfter(co if (!mpDoc) return xRet; - text::XFlatParagraph* pFP = xPara.get(); - SwXFlatParagraph* pFlatParagraph = static_cast(pFP); + const uno::Reference xFPTunnel(xPara, uno::UNO_QUERY); + OSL_ASSERT(xFPTunnel.is()); + SwXFlatParagraph* const pFlatParagraph(sw::UnoTunnelGetImplementation(xFPTunnel)); if ( !pFlatParagraph ) return xRet; @@ -475,8 +495,9 @@ uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getParaBefore(c if (!mpDoc) return xRet; - text::XFlatParagraph* pFP = xPara.get(); - SwXFlatParagraph* pFlatParagraph = static_cast(pFP); + const uno::Reference xFPTunnel(xPara, uno::UNO_QUERY); + OSL_ASSERT(xFPTunnel.is()); + SwXFlatParagraph* const pFlatParagraph(sw::UnoTunnelGetImplementation(xFPTunnel)); if ( !pFlatParagraph ) return xRet; @@ -511,4 +532,3 @@ uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getParaBefore(c return xRet; } - -- cgit v1.2.3 From 7e1bf0010d130597d5658a117737e7d9747dee91 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 30 Mar 2010 12:51:35 +0200 Subject: sw33bf03: #i110454#: fix ASSERT from WW8Export::ExportDocument_Impl() --- sw/inc/shellio.hxx | 7 ++++--- sw/source/filter/rtf/rtfatr.cxx | 4 ++-- sw/source/filter/writer/writer.cxx | 16 +++++++++------- sw/source/filter/ww8/wrtww8.cxx | 8 ++++---- 4 files changed, 19 insertions(+), 16 deletions(-) (limited to 'sw/source') diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx index 45d413ced105..9208659d9f66 100644 --- a/sw/inc/shellio.hxx +++ b/sw/inc/shellio.hxx @@ -439,13 +439,14 @@ class SW_DLLPUBLIC Writer : public SvRefBase SwAsciiOptions aAscOpts; String sBaseURL; + SvStream * m_pStream; + void _AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont ); void _AddFontItems( SfxItemPool& rPool, USHORT nWhichId ); protected: Writer_Impl* pImpl; - SvStream* pStrm; SwPaM* pOrigPam; // der letze zu bearbeitende Pam const String* pOrigFileName; @@ -537,9 +538,9 @@ public: inline SvStream& OutLong( long nVal ) { return OutLong( Strm(), nVal ); } inline SvStream& OutULong( ULONG nVal ) { return OutULong( Strm(), nVal ); } - void SetStrm( SvStream& rStrm ) { pStrm = &rStrm; } + void SetStream(SvStream *const pStream) { m_pStream = pStream; } #ifndef DBG_UTIL - SvStream& Strm() { return *pStrm; } + SvStream& Strm() { return *m_pStream; } #else SvStream& Strm(); #endif diff --git a/sw/source/filter/rtf/rtfatr.cxx b/sw/source/filter/rtf/rtfatr.cxx index ecbcfbfe7c7f..b5e2f7b316ea 100644 --- a/sw/source/filter/rtf/rtfatr.cxx +++ b/sw/source/filter/rtf/rtfatr.cxx @@ -513,12 +513,12 @@ void OutRTF_SwFlyFrmFmt( SwRTFWriter& rRTFWrt ) // ueberhaupt eigene Attribute gibt ! SvMemoryStream aTmpStrm; SvStream* pSaveStrm = &rRTFWrt.Strm(); - rRTFWrt.SetStrm( aTmpStrm ); + rRTFWrt.SetStream( &aTmpStrm ); rRTFWrt.bRTFFlySyntax = false; OutRTF_SwFmt( rRTFWrt, *rRTFWrt.pFlyFmt ); - rRTFWrt.SetStrm( *pSaveStrm ); // Stream-Pointer wieder zurueck + rRTFWrt.SetStream( pSaveStrm ); // Stream-Pointer wieder zurueck if ( aTmpStrm.GetEndOfData() ) // gibt es SWG spezifische Attribute? { diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx index 2ed742255173..66ad4f87b699 100644 --- a/sw/source/filter/writer/writer.cxx +++ b/sw/source/filter/writer/writer.cxx @@ -145,7 +145,9 @@ void Writer_Impl::InsertBkmk(const ::sw::mark::IMark& rBkmk) */ Writer::Writer() - : pImpl(0), pStrm(0), pOrigPam(0), pOrigFileName(0), pDoc(0), pCurPam(0) + : pImpl(0) + , m_pStream(0) + , pOrigPam(0), pOrigFileName(0), pDoc(0), pCurPam(0) { bWriteAll = bShowProgress = bUCS2_WithStartChar = true; bASCII_NoLastLineEnd = bASCII_ParaAsBlanc = bASCII_ParaAsCR = @@ -181,7 +183,7 @@ void Writer::ResetWriter() pCurPam = 0; pOrigFileName = 0; pDoc = 0; - pStrm = 0; + m_pStream = 0; bShowProgress = bUCS2_WithStartChar = TRUE; bASCII_NoLastLineEnd = bASCII_ParaAsBlanc = bASCII_ParaAsCR = @@ -253,8 +255,8 @@ SwPaM* Writer::NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx, #ifdef DBG_UTIL SvStream& Writer::Strm() { - ASSERT( pStrm, "Oh-oh. Dies ist ein Storage-Writer. Gleich knallts!" ); - return *pStrm; + ASSERT( m_pStream, "Oh-oh. Writer with no Stream!" ); + return *m_pStream; } #endif @@ -318,7 +320,7 @@ ULONG Writer::Write( SwPaM& rPaM, SvStream& rStrm, const String* pFName ) return nResult; } - pStrm = &rStrm; + m_pStream = &rStrm; pDoc = rPaM.GetDoc(); pOrigFileName = pFName; pImpl = new Writer_Impl( *pDoc ); @@ -590,7 +592,7 @@ ULONG StgWriter::WriteStream() ULONG StgWriter::Write( SwPaM& rPaM, SvStorage& rStg, const String* pFName ) { - pStrm = 0; + SetStream(0); pStg = &rStg; pDoc = rPaM.GetDoc(); pOrigFileName = pFName; @@ -611,7 +613,7 @@ ULONG StgWriter::Write( SwPaM& rPaM, SvStorage& rStg, const String* pFName ) ULONG StgWriter::Write( SwPaM& rPaM, const uno::Reference < embed::XStorage >& rStg, const String* pFName, SfxMedium* pMedium ) { - pStrm = 0; + SetStream(0); pStg = 0; xStg = rStg; pDoc = rPaM.GetDoc(); diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 9eb8fec9de7c..709fa282e6cb 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -2982,7 +2982,6 @@ void WW8Export::ExportDocument_Impl() pFib = new WW8Fib( bWrtWW8 ? 8 : 6 ); - SvStream* pOldStrm = &(Strm()); // JP 19.05.99: wozu das ??? SvStorageStreamRef xWwStrm( GetWriter().GetStorage().OpenSotStream( aMainStg ) ); SvStorageStreamRef xTableStrm( xWwStrm ), xDataStrm( xWwStrm ); xWwStrm->SetBufferSize( 32768 ); @@ -3002,7 +3001,7 @@ void WW8Export::ExportDocument_Impl() xDataStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); } - GetWriter().SetStrm( *xWwStrm ); + GetWriter().SetStream( & *xWwStrm ); pTableStrm = &xTableStrm; pDataStrm = &xDataStrm; @@ -3024,7 +3023,8 @@ void WW8Export::ExportDocument_Impl() { bEncrypt =true; - GetWriter().SetStrm( *aTempMain.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE ) ); + GetWriter().SetStream( + aTempMain.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE ) ); pTableStrm = aTempTable.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE ); @@ -3176,7 +3176,7 @@ void WW8Export::ExportDocument_Impl() delete pPiece; delete pDop; delete pFib; - GetWriter().SetStrm( *pOldStrm ); + GetWriter().SetStream( 0 ); xWwStrm->SetBufferSize( 0 ); -- cgit v1.2.3 From 386916453e828dc02912ccaa44fb262217a1f362 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 30 Mar 2010 12:52:28 +0200 Subject: sw33bf03: #i110455#: fix inverted ASSERT in MSWordStyles::WriteProperties() --- sw/source/filter/ww8/wrtw8sty.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sw/source') diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 8e6b0c77b878..7051639a4b3a 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -438,7 +438,8 @@ void MSWordStyles::WriteProperties( const SwFmt* pFmt, bool bParProp, USHORT nPo m_rExport.OutputFormat( *pFmt, bParProp, !bParProp ); - ASSERT( m_rExport.pCurrentStyle != pFmt, "current style was changed" ); // reset current style... + ASSERT( m_rExport.pCurrentStyle == pFmt, "current style was changed" ); + // reset current style... m_rExport.pCurrentStyle = NULL; if ( bInsDefCharSiz ) // nicht abgeleitet v. anderem Style -- cgit v1.2.3 From 876116a06642ed8a7be922995ec9ea45cb0ee3fb Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 19 Apr 2010 17:23:07 +0200 Subject: sw33bf03: #i110241#: revert change from writerfilter32bugfixes01 this will break import of certain "format" redlines. --- sw/source/core/doc/docredln.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sw/source') diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index dddf027647c1..3fb23299d4c3 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -1112,8 +1112,7 @@ bool SwDoc::AppendRedline( SwRedline* pNewRedl, bool bCallDelete ) case POS_EQUAL: case POS_INSIDE: - // TODO Check if there is any side effect - //delete pNewRedl, pNewRedl = 0; + delete pNewRedl, pNewRedl = 0; break; case POS_OUTSIDE: -- cgit v1.2.3 From 40f2ebaa07d820660f5d14531eb22818287d7e93 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 19 Apr 2010 17:25:53 +0200 Subject: sw33bf03: #i104585#: copy outline numbering rule to clipboard --- sw/source/core/docnode/ndcopy.cxx | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sw/source') diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index 088fe5b50424..315a51f85b88 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -922,6 +922,12 @@ bool SwDoc::CopyImpl( SwPaM& rPam, SwPosition& rPos, bool bCopyBookmarks = true; BOOL bStartIsTxtNode = 0 != pSttTxtNd; + // #i104585# copy outline num rule to clipboard (for ASCII filter) + if (pDoc->IsClipBoard() && GetOutlineNumRule()) + { + pDoc->SetOutlineNumRule(*GetOutlineNumRule()); + } + // --> OD 2009-08-25 #i86492# // Correct the search for a previous list: // First search for non-outline numbering list. Then search for non-outline -- cgit v1.2.3 From 64cb69b7093f7629513293d25240a1794ae8f7f3 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 19 Apr 2010 17:27:33 +0200 Subject: sw33bf03: #i110586#: use proper which range for autoformat item set --- sw/source/core/txtnode/thints.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sw/source') diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 0e8c7163abc1..730e61c96c85 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -776,7 +776,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, // For each attribute in the automatic style check if it // is also set the the new character style: - SfxItemSet aNewSet( *pOldStyle->GetPool(), RES_CHRATR_BEGIN, RES_CHRATR_END ); + SfxItemSet aNewSet( *pOldStyle->GetPool(), + aCharAutoFmtSetRange); SfxItemIter aItemIter( *pOldStyle ); const SfxPoolItem* pItem = aItemIter.GetCurItem(); while( TRUE ) -- cgit v1.2.3 From 1bd25912372dad5ad1371d363838b35b0775861d Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 19 Apr 2010 17:28:53 +0200 Subject: sw33bf03: #i110655#: SwRect::Justify(): fix regression from #i106401# --- sw/source/core/bastyp/swrect.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sw/source') diff --git a/sw/source/core/bastyp/swrect.cxx b/sw/source/core/bastyp/swrect.cxx index e156c71aa5fb..554dad2ebfa2 100644 --- a/sw/source/core/bastyp/swrect.cxx +++ b/sw/source/core/bastyp/swrect.cxx @@ -245,7 +245,7 @@ void SwRect::Justify() } if ( m_Size.getWidth() < 0 ) { - m_Point.Y() += m_Size.getWidth() + 1; + m_Point.X() += m_Size.getWidth() + 1; m_Size.setWidth(-m_Size.getWidth()); } } -- cgit v1.2.3 From caa1ed58b354fa289d4801d716b63c64f3bc495e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 26 Apr 2010 18:22:31 +0200 Subject: sw33bf03: #i108345#: SwpHintsArray::Check(): check for overlapping AUTOFMT --- sw/source/core/txtnode/ndhints.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'sw/source') diff --git a/sw/source/core/txtnode/ndhints.cxx b/sw/source/core/txtnode/ndhints.cxx index ef165b010aea..ee05b1fe2180 100644 --- a/sw/source/core/txtnode/ndhints.cxx +++ b/sw/source/core/txtnode/ndhints.cxx @@ -372,7 +372,7 @@ bool SwpHintsArray::Check() const CHECK_ERR( !isCHRATR(nWhich), "HintsCheck: Character attribute in end array" ); - // 8) portion check + // 8) style portion check #if OSL_DEBUG_LEVEL > 1 const SwTxtAttr* pHtThis = m_HintStarts[i]; const SwTxtAttr* pHtLast = i > 0 ? m_HintStarts[i-1] : 0; @@ -380,11 +380,19 @@ bool SwpHintsArray::Check() const ( RES_TXTATR_CHARFMT != pHtLast->Which() && RES_TXTATR_AUTOFMT != pHtLast->Which() ) || ( RES_TXTATR_CHARFMT != pHtThis->Which() && RES_TXTATR_AUTOFMT != pHtThis->Which() ) || ( *pHtThis->GetStart() >= *pHtLast->GetEnd() ) || - ( *pHtThis->GetStart() == *pHtLast->GetStart() && *pHtThis->GetEnd() == *pHtLast->GetEnd() ) || - ( *pHtThis->GetStart() == *pHtThis->GetEnd() ), + ( ( ( (*pHtThis->GetStart() == *pHtLast->GetStart()) + && (*pHtThis->GetEnd() == *pHtLast->GetEnd()) + ) // same range + || (*pHtThis->GetStart() == *pHtThis->GetEnd()) + ) + && ( (pHtThis->Which() != RES_TXTATR_AUTOFMT) + || (pHtLast->Which() != RES_TXTATR_AUTOFMT) + ) // never two AUTOFMT on same range + ), "HintsCheck: Portion inconsistency. " "This can be temporarily ok during undo operations" ); + // 9) nesting portion check if (pHtThis->IsNesting()) { for ( USHORT j = 0; j < Count(); ++j ) @@ -402,7 +410,7 @@ bool SwpHintsArray::Check() const } } - // 9) dummy char check (unfortunately cannot check SwTxtNode::m_Text) + // 10) dummy char check (unfortunately cannot check SwTxtNode::m_Text) if (pHtThis->HasDummyChar()) { for ( USHORT j = 0; j < i; ++j ) -- cgit v1.2.3 From 7ff8a504cfd11fc28e9e7b8ecd54509e16b19727 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 26 Apr 2010 18:25:01 +0200 Subject: sw33bf03: #i108345# SwTxtNode::FmtToTxtAttr(): apply patch by dtardon: create automatic char. styles correctly --- sw/inc/ndtxt.hxx | 2 + sw/source/core/txtnode/thints.cxx | 301 +++++++++++++++++++++++++++++--------- 2 files changed, 235 insertions(+), 68 deletions(-) (limited to 'sw/source') diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 04f1fad3e660..513695313bc6 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -202,6 +202,8 @@ class SW_DLLPUBLIC SwTxtNode: public SwCntntNode, public ::sfx2::Metadatable inline void TryDeleteSwpHints(); + SW_DLLPRIVATE void impl_FmtToTxtAttr(const SfxItemSet& i_rAttrSet); + public: bool IsWordCountDirty() const; bool IsWrongDirty() const; diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 730e61c96c85..16b74a8a54e4 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -2063,25 +2063,202 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, return rSet.Count() ? TRUE : FALSE; } -int lcl_IsNewAttrInSet( const SwpHints& rHints, const SfxPoolItem& rItem, - const xub_StrLen nEnd ) + +namespace +{ + +typedef std::pair AttrSpan_t; +typedef std::multimap AttrSpanMap_t; + + +struct IsAutoStyle { - int bIns = TRUE; - for( USHORT i = 0; i < rHints.Count(); ++i ) + bool + operator()(const AttrSpanMap_t::value_type& i_rAttrSpan) + const { - const SwTxtAttr *pOther = rHints[ i ]; - if( *pOther->GetStart() ) - break; + return i_rAttrSpan.second && i_rAttrSpan.second->Which() == RES_TXTATR_AUTOFMT; + } +}; + + +/** Removes from io_rAttrSet all items that are set by style on the + given span. + */ +struct RemovePresentAttrs +{ + RemovePresentAttrs(SfxItemSet& io_rAttrSet) + : m_rAttrSet(io_rAttrSet) + { + } + + void + operator()(const AttrSpanMap_t::value_type& i_rAttrSpan) + const + { + if (!i_rAttrSpan.second) + { + return; + } - if( pOther->GetEnd() && - *pOther->GetEnd() == nEnd && - ( pOther->IsCharFmtAttr() || pOther->Which() == rItem.Which() ) ) + const SwTxtAttr* const pAutoStyle(i_rAttrSpan.second); + SfxItemIter aIter(m_rAttrSet); + const SfxPoolItem* pItem(aIter.GetCurItem()); + while (true) + { + const USHORT nWhich(pItem->Which()); + if (CharFmt::IsItemIncluded(nWhich, pAutoStyle)) + { + m_rAttrSet.ClearItem(nWhich); + } + + if (aIter.IsAtEnd()) + { + break; + } + pItem = aIter.NextItem(); + } + } + +private: + SfxItemSet& m_rAttrSet; +}; + + +/** Collects all style-covered spans from i_rHints to o_rSpanMap. In + addition inserts dummy spans with pointer to format equal to 0 for + all gaps (i.e. spans not covered by any style). This simplifies + creation of autostyles for all needed spans, but it means all code + that tries to access the pointer has to check if it's non-null! + */ +void +lcl_CollectHintSpans(const SwpHints& i_rHints, const USHORT nLength, + AttrSpanMap_t& o_rSpanMap) +{ + USHORT nLastEnd(0); + + for (USHORT i(0); i != i_rHints.Count(); ++i) + { + const SwTxtAttr* const pHint(i_rHints[i]); + const USHORT nWhich(pHint->Which()); + if (nWhich == RES_TXTATR_CHARFMT || nWhich == RES_TXTATR_AUTOFMT) + { + const AttrSpan_t aSpan(*pHint->GetStart(), *pHint->GetEnd()); + o_rSpanMap.insert(AttrSpanMap_t::value_type(aSpan, pHint)); + + if (aSpan.first != nLastEnd) + { + // insert dummy span covering the gap + o_rSpanMap.insert(AttrSpanMap_t::value_type( + AttrSpan_t(nLastEnd, aSpan.first), 0)); + } + + nLastEnd = aSpan.second; + } + } + + // no hints at the end (special case: no hints at all in i_rHints) + if (nLastEnd != nLength && nLength != 0) + { + o_rSpanMap.insert( + AttrSpanMap_t::value_type(AttrSpan_t(nLastEnd, nLength), 0)); + } +} + + +void +lcl_FillWhichIds(const SfxItemSet& i_rAttrSet, std::vector& o_rClearIds) +{ + o_rClearIds.reserve(i_rAttrSet.Count()); + SfxItemIter aIter(i_rAttrSet); + const SfxPoolItem* pItem(aIter.GetCurItem()); + while (true) + { + o_rClearIds.push_back(pItem->Which()); + + if (aIter.IsAtEnd()) { - bIns = FALSE; break; } + pItem = aIter.NextItem(); + } +} + +struct SfxItemSetClearer +{ + SfxItemSet & m_rItemSet; + SfxItemSetClearer(SfxItemSet & rItemSet) : m_rItemSet(rItemSet) { } + void operator()(USHORT const nWhich) { m_rItemSet.ClearItem(nWhich); } +}; + +} + + +/** Does the hard work of SwTxtNode::FmtToTxtAttr: the real conversion + of items to automatic styles. + */ +void +SwTxtNode::impl_FmtToTxtAttr(const SfxItemSet& i_rAttrSet) +{ + typedef AttrSpanMap_t::iterator AttrSpanMap_iterator_t; + AttrSpanMap_t aAttrSpanMap; + + if (i_rAttrSet.Count() == 0) + { + return; + } + + // 1. Identify all spans in hints' array + + lcl_CollectHintSpans(*m_pSwpHints, m_Text.Len(), aAttrSpanMap); + + // 2. Go through all spans and insert new attrs + + AttrSpanMap_iterator_t aCurRange(aAttrSpanMap.begin()); + const AttrSpanMap_iterator_t aEnd(aAttrSpanMap.end()); + while (aCurRange != aEnd) + { + typedef std::pair + AttrSpanMapRange_t; + AttrSpanMapRange_t aRange(aAttrSpanMap.equal_range(aCurRange->first)); + + // 2a. Collect attributes to insert + + SfxItemSet aCurSet(i_rAttrSet); + std::for_each(aRange.first, aRange.second, RemovePresentAttrs(aCurSet)); + + // 2b. Insert automatic style containing the collected attributes + + if (aCurSet.Count() != 0) + { + AttrSpanMap_iterator_t aAutoStyleIt( + std::find_if(aRange.first, aRange.second, IsAutoStyle())); + if (aAutoStyleIt != aRange.second) + { + // there already is an automatic style on that span: + // create new one and remove the original one + SwTxtAttr* const pAutoStyle(const_cast(aAutoStyleIt->second)); + const boost::shared_ptr pOldStyle( + static_cast( + pAutoStyle->GetAttr()).GetStyleHandle()); + aCurSet.Put(*pOldStyle); + + // remove the old hint + m_pSwpHints->Delete(pAutoStyle); + DestroyAttr(pAutoStyle); + } + m_pSwpHints->Insert( + MakeTxtAttr(*GetDoc(), aCurSet, + aCurRange->first.first, aCurRange->first.second)); + } + + aCurRange = aRange.second; } - return bIns; + + // 3. Clear items from the node + std::vector aClearedIds; + lcl_FillWhichIds(i_rAttrSet, aClearedIds); + ClearItemsFromAttrSet(aClearedIds); } void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) @@ -2094,91 +2271,79 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) if( pNd == this ) { - if( aThisSet.Count() ) - { - SfxItemIter aIter( aThisSet ); - const SfxPoolItem* pItem = aIter.GetCurItem(); - std::vector aClearWhichIds; - - while ( true ) - { - if (lcl_IsNewAttrInSet( *m_pSwpHints, *pItem, GetTxt().Len() )) - { - m_pSwpHints->SwpHintsArray::Insert( - MakeTxtAttr( *GetDoc(), - const_cast(*pItem), - 0, GetTxt().Len() ) ); - aClearWhichIds.push_back( pItem->Which() ); - } - - if( aIter.IsAtEnd() ) - break; - pItem = aIter.NextItem(); - } - - ClearItemsFromAttrSet( aClearWhichIds ); - } + impl_FmtToTxtAttr(aThisSet); } else { + // There are five possible combinations of items from this and + // pNd (pNd is the 'main' node): + // + // case pNd this action + // ---------------------------------------------------- + // 1 - - do nothing + // 2 - a convert item to attr of this + // 3 a - convert item to attr of pNd + // 4 a a clear item in this + // 5 a b convert item to attr of this + SfxItemSet aNdSet( pNd->GetDoc()->GetAttrPool(), aCharFmtSetRange ); if( pNd->HasSwAttrSet() && pNd->GetpSwAttrSet()->Count() ) aNdSet.Put( *pNd->GetpSwAttrSet() ); pNd->GetOrCreateSwpHints(); + std::vector aProcessedIds; + if( aThisSet.Count() ) { SfxItemIter aIter( aThisSet ); - const SfxPoolItem* pItem = aIter.GetCurItem(), *pNdItem; + const SfxPoolItem* pItem = aIter.GetCurItem(), *pNdItem = 0; + SfxItemSet aConvertSet( GetDoc()->GetAttrPool(), aCharFmtSetRange ); std::vector aClearWhichIds; - while( TRUE ) + while( true ) { - if( ( SFX_ITEM_SET != aNdSet.GetItemState( pItem->Which(), FALSE, - &pNdItem ) || *pItem != *pNdItem ) && - lcl_IsNewAttrInSet( *m_pSwpHints, *pItem, GetTxt().Len() ) ) + if( SFX_ITEM_SET == aNdSet.GetItemState( pItem->Which(), FALSE, &pNdItem ) ) { - m_pSwpHints->SwpHintsArray::Insert( MakeTxtAttr( *GetDoc(), - const_cast(*pItem), - 0, GetTxt().Len() ) ); - aClearWhichIds.push_back( pItem->Which() ); + if (*pItem == *pNdItem) // 4 + { + aClearWhichIds.push_back( pItem->Which() ); + } + else // 5 + { + aConvertSet.Put(*pItem); + } + aProcessedIds.push_back(pItem->Which()); + } + else // 2 + { + aConvertSet.Put(*pItem); } - aNdSet.ClearItem( pItem->Which() ); if( aIter.IsAtEnd() ) break; pItem = aIter.NextItem(); } + + // 4/ clear items of this that are set with the same value on pNd ClearItemsFromAttrSet( aClearWhichIds ); + + // 2, 5/ convert all other items to attrs + impl_FmtToTxtAttr(aConvertSet); } - if( aNdSet.Count() ) { - SfxItemIter aIter( aNdSet ); - const SfxPoolItem* pItem = aIter.GetCurItem(); - std::vector aClearWhichIds; + std::for_each(aProcessedIds.begin(), aProcessedIds.end(), + SfxItemSetClearer(aNdSet)); - while ( true ) - { - if ( lcl_IsNewAttrInSet( *pNd->m_pSwpHints, *pItem, - pNd->GetTxt().Len() ) ) - { - pNd->m_pSwpHints->SwpHintsArray::Insert( - MakeTxtAttr( *pNd->GetDoc(), - const_cast(*pItem), - 0, pNd->GetTxt().Len() ) ); - } - aClearWhichIds.push_back( pItem->Which() ); + // 3/ convert items to attrs + pNd->impl_FmtToTxtAttr(aNdSet); - if( aIter.IsAtEnd() ) - break; - pItem = aIter.NextItem(); + if( aNdSet.Count() ) + { + SwFmtChg aTmp1( pNd->GetFmtColl() ); + pNd->SwModify::Modify( &aTmp1, &aTmp1 ); } - - pNd->ClearItemsFromAttrSet( aClearWhichIds ); - SwFmtChg aTmp1( pNd->GetFmtColl() ); - pNd->SwModify::Modify( &aTmp1, &aTmp1 ); } } -- cgit v1.2.3 From 29e00d08352b602be0425b9c14385ec38a835b6d Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 28 Apr 2010 10:55:22 +0200 Subject: sw33bf03: #i110454#: fix warning by moving member to Impl struct --- sw/inc/shellio.hxx | 8 +------- sw/source/filter/writer/writer.cxx | 17 +++++++++-------- 2 files changed, 10 insertions(+), 15 deletions(-) (limited to 'sw/source') diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx index 931e6d117ead..28dcdf26a352 100644 --- a/sw/inc/shellio.hxx +++ b/sw/inc/shellio.hxx @@ -436,8 +436,6 @@ class SW_DLLPUBLIC Writer : public SvRefBase SwAsciiOptions aAscOpts; String sBaseURL; - SvStream * m_pStream; - void _AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont ); void _AddFontItems( SfxItemPool& rPool, USHORT nWhichId ); @@ -535,12 +533,8 @@ public: inline SvStream& OutLong( long nVal ) { return OutLong( Strm(), nVal ); } inline SvStream& OutULong( ULONG nVal ) { return OutULong( Strm(), nVal ); } - void SetStream(SvStream *const pStream) { m_pStream = pStream; } -#ifndef DBG_UTIL - SvStream& Strm() { return *m_pStream; } -#else + void SetStream(SvStream *const pStream); SvStream& Strm(); -#endif void SetOrganizerMode( BOOL bSet ) { bOrganizerMode = bSet; } }; diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx index bcd61fda6af0..bde2e253d947 100644 --- a/sw/source/filter/writer/writer.cxx +++ b/sw/source/filter/writer/writer.cxx @@ -58,6 +58,8 @@ DECLARE_TABLE( SwBookmarkNodeTable, SvPtrarr* ) struct Writer_Impl { + SvStream * m_pStream; + SvStringsSortDtor *pSrcArr, *pDestArr; SvPtrarr* pFontRemoveLst, *pBkmkArr; SwBookmarkNodeTable* pBkmkNodePos; @@ -70,7 +72,8 @@ struct Writer_Impl }; Writer_Impl::Writer_Impl( const SwDoc& /*rDoc*/ ) - : pSrcArr( 0 ), pDestArr( 0 ), pFontRemoveLst( 0 ), pBkmkNodePos( 0 ) + : m_pStream(0) + , pSrcArr( 0 ), pDestArr( 0 ), pFontRemoveLst( 0 ), pBkmkNodePos( 0 ) { } @@ -142,7 +145,6 @@ void Writer_Impl::InsertBkmk(const ::sw::mark::IMark& rBkmk) Writer::Writer() : pImpl(0) - , m_pStream(0) , pOrigPam(0), pOrigFileName(0), pDoc(0), pCurPam(0) { bWriteAll = bShowProgress = bUCS2_WithStartChar = true; @@ -179,7 +181,6 @@ void Writer::ResetWriter() pCurPam = 0; pOrigFileName = 0; pDoc = 0; - m_pStream = 0; bShowProgress = bUCS2_WithStartChar = TRUE; bASCII_NoLastLineEnd = bASCII_ParaAsBlanc = bASCII_ParaAsCR = @@ -248,13 +249,13 @@ SwPaM* Writer::NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx, ///////////////////////////////////////////////////////////////////////////// // Stream-spezifisches -#ifdef DBG_UTIL SvStream& Writer::Strm() { - ASSERT( m_pStream, "Oh-oh. Writer with no Stream!" ); - return *m_pStream; + ASSERT( pImpl->m_pStream, "Oh-oh. Writer with no Stream!" ); + return *pImpl->m_pStream; } -#endif + +void Writer::SetStream(SvStream *const pStream) { pImpl->m_pStream = pStream; } SvStream& Writer::OutHex( SvStream& rStrm, ULONG nHex, BYTE nLen ) @@ -316,10 +317,10 @@ ULONG Writer::Write( SwPaM& rPaM, SvStream& rStrm, const String* pFName ) return nResult; } - m_pStream = &rStrm; pDoc = rPaM.GetDoc(); pOrigFileName = pFName; pImpl = new Writer_Impl( *pDoc ); + pImpl->m_pStream = &rStrm; // PaM kopieren, damit er veraendert werden kann pCurPam = new SwPaM( *rPaM.End(), *rPaM.Start() ); -- cgit v1.2.3 From 94e9b98a8341459bcdb7781a4f711cb5458c89ee Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 28 Apr 2010 17:13:01 +0200 Subject: sw33bf03: #i110454#: try to fix harebrained lifecycle of Writer_Impl --- sw/inc/shellio.hxx | 9 ++++-- sw/source/filter/writer/writer.cxx | 64 ++++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 37 deletions(-) (limited to 'sw/source') diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx index 28dcdf26a352..b92cc26ca38e 100644 --- a/sw/inc/shellio.hxx +++ b/sw/inc/shellio.hxx @@ -24,8 +24,10 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _SHELLIO_HXX -#define _SHELLIO_HXX +#ifndef SW_SHELLIO_HXX +#define SW_SHELLIO_HXX + +#include #include #include @@ -439,8 +441,9 @@ class SW_DLLPUBLIC Writer : public SvRefBase void _AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont ); void _AddFontItems( SfxItemPool& rPool, USHORT nWhichId ); + ::std::auto_ptr m_pImpl; + protected: - Writer_Impl* pImpl; SwPaM* pOrigPam; // der letze zu bearbeitende Pam const String* pOrigFileName; diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx index bde2e253d947..d70b6d6c754e 100644 --- a/sw/source/filter/writer/writer.cxx +++ b/sw/source/filter/writer/writer.cxx @@ -64,14 +64,14 @@ struct Writer_Impl SvPtrarr* pFontRemoveLst, *pBkmkArr; SwBookmarkNodeTable* pBkmkNodePos; - Writer_Impl( const SwDoc& rDoc ); + Writer_Impl(); ~Writer_Impl(); void RemoveFontList( SwDoc& rDoc ); void InsertBkmk( const ::sw::mark::IMark& rBkmk ); }; -Writer_Impl::Writer_Impl( const SwDoc& /*rDoc*/ ) +Writer_Impl::Writer_Impl() : m_pStream(0) , pSrcArr( 0 ), pDestArr( 0 ), pFontRemoveLst( 0 ), pBkmkNodePos( 0 ) { @@ -144,7 +144,7 @@ void Writer_Impl::InsertBkmk(const ::sw::mark::IMark& rBkmk) */ Writer::Writer() - : pImpl(0) + : m_pImpl(new Writer_Impl) , pOrigPam(0), pOrigFileName(0), pDoc(0), pCurPam(0) { bWriteAll = bShowProgress = bUCS2_WithStartChar = true; @@ -168,9 +168,11 @@ const IDocumentStylePoolAccess* Writer::getIDocumentStylePoolAccess() const { re void Writer::ResetWriter() { - if( pImpl && pImpl->pFontRemoveLst ) - pImpl->RemoveFontList( *pDoc ); - delete pImpl, pImpl = 0; + if (m_pImpl->pFontRemoveLst) + { + m_pImpl->RemoveFontList( *pDoc ); + } + m_pImpl.reset(new Writer_Impl); if( pCurPam ) { @@ -251,11 +253,12 @@ SwPaM* Writer::NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx, // Stream-spezifisches SvStream& Writer::Strm() { - ASSERT( pImpl->m_pStream, "Oh-oh. Writer with no Stream!" ); - return *pImpl->m_pStream; + ASSERT( m_pImpl->m_pStream, "Oh-oh. Writer with no Stream!" ); + return *m_pImpl->m_pStream; } -void Writer::SetStream(SvStream *const pStream) { pImpl->m_pStream = pStream; } +void Writer::SetStream(SvStream *const pStream) +{ m_pImpl->m_pStream = pStream; } SvStream& Writer::OutHex( SvStream& rStrm, ULONG nHex, BYTE nLen ) @@ -319,8 +322,7 @@ ULONG Writer::Write( SwPaM& rPaM, SvStream& rStrm, const String* pFName ) pDoc = rPaM.GetDoc(); pOrigFileName = pFName; - pImpl = new Writer_Impl( *pDoc ); - pImpl->m_pStream = &rStrm; + m_pImpl->m_pStream = &rStrm; // PaM kopieren, damit er veraendert werden kann pCurPam = new SwPaM( *rPaM.End(), *rPaM.Start() ); @@ -371,20 +373,20 @@ BOOL Writer::CopyLocalFileToINet( String& rFileNm ) INET_PROT_NEWS >= aTargetUrl.GetProtocol() ) ) return bRet; - if( pImpl->pSrcArr ) + if (m_pImpl->pSrcArr) { // wurde die Datei schon verschoben USHORT nPos; - if( pImpl->pSrcArr->Seek_Entry( &rFileNm, &nPos )) + if (m_pImpl->pSrcArr->Seek_Entry( &rFileNm, &nPos )) { - rFileNm = *(*pImpl->pDestArr)[ nPos ]; + rFileNm = *(*m_pImpl->pDestArr)[ nPos ]; return TRUE; } } else { - pImpl->pSrcArr = new SvStringsSortDtor( 4, 4 ); - pImpl->pDestArr = new SvStringsSortDtor( 4, 4 ); + m_pImpl->pSrcArr = new SvStringsSortDtor( 4, 4 ); + m_pImpl->pDestArr = new SvStringsSortDtor( 4, 4 ); } String *pSrc = new String( rFileNm ); @@ -403,8 +405,8 @@ BOOL Writer::CopyLocalFileToINet( String& rFileNm ) if( bRet ) { - pImpl->pSrcArr->Insert( pSrc ); - pImpl->pDestArr->Insert( pDest ); + m_pImpl->pSrcArr->Insert( pSrc ); + m_pImpl->pDestArr->Insert( pDest ); rFileNm = *pDest; } else @@ -418,9 +420,6 @@ BOOL Writer::CopyLocalFileToINet( String& rFileNm ) void Writer::PutNumFmtFontsInAttrPool() { - if( !pImpl ) - pImpl = new Writer_Impl( *pDoc ); - // dann gibt es noch in den NumRules ein paar Fonts // Diese in den Pool putten. Haben sie danach einen RefCount > 1 // kann es wieder entfernt werden - ist schon im Pool @@ -460,9 +459,6 @@ void Writer::PutNumFmtFontsInAttrPool() void Writer::PutEditEngFontsInAttrPool( BOOL bIncl_CJK_CTL ) { - if( !pImpl ) - pImpl = new Writer_Impl( *pDoc ); - SfxItemPool& rPool = pDoc->GetAttrPool(); if( rPool.GetSecondaryPool() ) { @@ -477,9 +473,6 @@ void Writer::PutEditEngFontsInAttrPool( BOOL bIncl_CJK_CTL ) void Writer::PutCJKandCTLFontsInAttrPool() { - if( !pImpl ) - pImpl = new Writer_Impl( *pDoc ); - SfxItemPool& rPool = pDoc->GetAttrPool(); _AddFontItems( rPool, RES_CHRATR_CJK_FONT ); _AddFontItems( rPool, RES_CHRATR_CTL_FONT ); @@ -516,11 +509,13 @@ void Writer::_AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont ) rPool.Remove( *pItem ); else { - if( !pImpl->pFontRemoveLst ) - pImpl->pFontRemoveLst = new SvPtrarr( 0, 10 ); + if (!m_pImpl->pFontRemoveLst) + { + m_pImpl->pFontRemoveLst = new SvPtrarr( 0, 10 ); + } void* p = (void*)pItem; - pImpl->pFontRemoveLst->Insert( p, pImpl->pFontRemoveLst->Count() ); + m_pImpl->pFontRemoveLst->Insert( p, m_pImpl->pFontRemoveLst->Count() ); } } @@ -532,7 +527,9 @@ void Writer::CreateBookmarkTbl() for(IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->getBookmarksBegin(); ppBkmk != pMarkAccess->getBookmarksEnd(); ++ppBkmk) - pImpl->InsertBkmk(**ppBkmk); + { + m_pImpl->InsertBkmk(**ppBkmk); + } } @@ -543,7 +540,8 @@ USHORT Writer::GetBookmarks(const SwCntntNode& rNd, xub_StrLen nStt, ASSERT( !rArr.Count(), "es sind noch Eintraege vorhanden" ); ULONG nNd = rNd.GetIndex(); - SvPtrarr* pArr = pImpl->pBkmkNodePos ? pImpl->pBkmkNodePos->Get( nNd ) : 0; + SvPtrarr* pArr = (m_pImpl->pBkmkNodePos) ? + m_pImpl->pBkmkNodePos->Get( nNd ) : 0; if( pArr ) { // there exist some bookmarks, search now all which is in the range @@ -593,7 +591,6 @@ ULONG StgWriter::Write( SwPaM& rPaM, SvStorage& rStg, const String* pFName ) pStg = &rStg; pDoc = rPaM.GetDoc(); pOrigFileName = pFName; - pImpl = new Writer_Impl( *pDoc ); // PaM kopieren, damit er veraendert werden kann pCurPam = new SwPaM( *rPaM.End(), *rPaM.Start() ); @@ -615,7 +612,6 @@ ULONG StgWriter::Write( SwPaM& rPaM, const uno::Reference < embed::XStorage >& r xStg = rStg; pDoc = rPaM.GetDoc(); pOrigFileName = pFName; - pImpl = new Writer_Impl( *pDoc ); // PaM kopieren, damit er veraendert werden kann pCurPam = new SwPaM( *rPaM.End(), *rPaM.Start() ); -- cgit v1.2.3