[Libreoffice-commits] .: Branch 'libreoffice-3-6' - sw/inc sw/source

2012-12-03 Thread Libreoffice Gerrit user
 sw/inc/shellres.hxx   |2 +-
 sw/source/ui/utlui/initui.cxx |8 
 2 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit a0926265dbfc617603cfa1fb8a4a22a5663183fe
Author: Caolán McNamara caol...@redhat.com
Date:   Sat Dec 1 12:18:53 2012 +

Resolves: fdo#56549 crash in format-autocorrect-apply and edit changes

regression from cad9afa15f53d547733fa55f1353772f6d696611

Change-Id: I1aa36bf86969a5a90456817d360d59125948e519
(cherry picked from commit 32c26ffb1f7585318a11f684a9886b58cea5b307)
Reviewed-on: https://gerrit.libreoffice.org/1218
Reviewed-by: Miklos Vajna vmik...@suse.cz
Tested-by: Miklos Vajna vmik...@suse.cz

diff --git a/sw/inc/shellres.hxx b/sw/inc/shellres.hxx
index 688fe08..7a7a543 100644
--- a/sw/inc/shellres.hxx
+++ b/sw/inc/shellres.hxx
@@ -95,7 +95,7 @@ struct SW_DLLPUBLIC ShellResource : public Resource
 
 private:
 void _GetAutoFmtNameLst() const;
-std::vectorString *pAutoFmtNameLst;
+mutable std::vectorString *pAutoFmtNameLst;
 String  sPageDescFirstName;
 String  sPageDescFollowName;
 String  sPageDescName;
diff --git a/sw/source/ui/utlui/initui.cxx b/sw/source/ui/utlui/initui.cxx
index 1a3e6d4..0b2dac9 100644
--- a/sw/source/ui/utlui/initui.cxx
+++ b/sw/source/ui/utlui/initui.cxx
@@ -238,10 +238,10 @@ struct ImpAutoFmtNameListLoader : public Resource
 
 void ShellResource::_GetAutoFmtNameLst() const
 {
-std::vectorString* pLst(pAutoFmtNameLst);
-pLst = new std::vectorString;
-pLst-reserve(STR_AUTOFMTREDL_END);
-ImpAutoFmtNameListLoader aTmp( *pLst );
+assert(!pAutoFmtNameLst);
+pAutoFmtNameLst = new std::vectorString;
+pAutoFmtNameLst-reserve(STR_AUTOFMTREDL_END);
+ImpAutoFmtNameListLoader aTmp(*pAutoFmtNameLst);
 }
 
 ImpAutoFmtNameListLoader::ImpAutoFmtNameListLoader( std::vectorString rLst )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: Branch 'libreoffice-3-6' - sw/inc sw/source

2012-09-26 Thread Libreoffice Gerrit user
 sw/inc/printdata.hxx  |2 +-
 sw/inc/unotxdoc.hxx   |5 +++--
 sw/source/core/view/printdata.cxx |5 +
 sw/source/ui/uno/unotxdoc.cxx |   26 ++
 4 files changed, 27 insertions(+), 11 deletions(-)

New commits:
commit 47014647eced4864e149b923b7eb024418e71782
Author: Michael Stahl mst...@redhat.com
Date:   Wed Sep 26 12:43:29 2012 +0200

rhbz#827695: sw: prevent crashes after incomplete print:

If the last page is not printed for whatever reason, then
SwXTextDocument's destructor will delete a SwViewOptionAdjust_Impl,
which accesses the document's ViewShell, which has already been
deleted at that point.  Add a horrible kludge to not crash for now.

Change-Id: I67fe37970d60782030b84f2ba1e66ef3f9c6
(cherry picked from commit d53e12c7a9c2d0a3b487303673c1fafd09f6593c)
Reviewed-on: https://gerrit.libreoffice.org/699
Reviewed-by: Noel Power noel.po...@suse.com
Tested-by: Noel Power noel.po...@suse.com

diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx
index 02d56b8..a64ece9 100644
--- a/sw/inc/printdata.hxx
+++ b/sw/inc/printdata.hxx
@@ -42,7 +42,6 @@
 
 class SwDoc;
 class SwDocShell;
-class ViewShell;
 class _SetGetExpFlds;
 class SwViewOption;
 class OutputDevice;
@@ -278,6 +277,7 @@ public:
 void ViewOptionAdjustStart( ViewShell rSh, const SwViewOption 
rViewOptions);
 void ViewOptionAdjust( SwPrintData const* const pPrtOptions );
 void ViewOptionAdjustStop();
+void ViewOptionAdjustCrashPreventionKludge();
 
 bool HasSwPrtOptions() const{ return m_pPrtOptions != 0; }
 SwPrintData const*  GetSwPrtOptions() const { return m_pPrtOptions.get(); }
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 9d94f18..63004fb 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -586,7 +586,7 @@ public:
   ---*/
 class SwViewOptionAdjust_Impl
 {
-ViewShell m_rShell;
+ViewShell * m_pShell;
 SwViewOptionm_aOldViewOptions;
 
 public:
@@ -594,7 +594,8 @@ public:
 ~SwViewOptionAdjust_Impl();
 void AdjustViewOptions( SwPrintData const* const pPrtOptions );
 bool checkShell( const ViewShell rCompare ) const
-{ return rCompare == m_rShell; }
+{ return rCompare == m_pShell; }
+void DontTouchThatViewShellItSmellsFunny() { m_pShell = 0; }
 };
 
 
diff --git a/sw/source/core/view/printdata.cxx 
b/sw/source/core/view/printdata.cxx
index 4e6d37f..9988855 100644
--- a/sw/source/core/view/printdata.cxx
+++ b/sw/source/core/view/printdata.cxx
@@ -131,6 +131,11 @@ void SwRenderData::ViewOptionAdjustStop()
 m_pViewOptionAdjust.reset();
 }
 
+void SwRenderData::ViewOptionAdjustCrashPreventionKludge()
+{
+m_pViewOptionAdjust-DontTouchThatViewShellItSmellsFunny();
+}
+
 
 void SwRenderData::MakeSwPrtOptions(
 SwDocShell const*const pDocShell,
diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx
index 43c1672..69e524d 100644
--- a/sw/source/ui/uno/unotxdoc.cxx
+++ b/sw/source/ui/uno/unotxdoc.cxx
@@ -404,6 +404,13 @@ SwXTextDocument::~SwXTextDocument()
 xNumFmtAgg = 0;
 }
 delete m_pPrintUIOptions;
+if (m_pRenderData  m_pRenderData-IsViewOptionAdjust())
+{   // rhbz#827695: this can happen if the last page is not printed
+// the ViewShell has been deleted already by SwView::~SwView
+// FIXME: replace this awful implementation of XRenderable with
+// something less insane that has its own view
+m_pRenderData-ViewOptionAdjustCrashPreventionKludge();
+}
 delete m_pRenderData;
 }
 
@@ -3856,14 +3863,17 @@ void SwXDocumentPropertyHelper::onChange()
 
 SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl(
 ViewShell rSh, const SwViewOption rViewOptions)
-: m_rShell( rSh )
+: m_pShell(rSh)
 , m_aOldViewOptions( rViewOptions )
 {
 }
 
 SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl()
 {
-m_rShell.ApplyViewOptions( m_aOldViewOptions );
+if (m_pShell)
+{
+m_pShell-ApplyViewOptions( m_aOldViewOptions );
+}
 }
 
 void
@@ -3871,14 +3881,14 @@ SwViewOptionAdjust_Impl::AdjustViewOptions(SwPrintData 
const*const pPrtOptions)
 {
 // to avoid unnecessary reformatting the view options related to the 
content
 // below should only change if necessary, that is if respective content is 
present
-const bool bContainsHiddenChars = 
m_rShell.GetDoc()-ContainsHiddenChars();
-const SwFieldType* pFldType = m_rShell.GetDoc()-GetSysFldType( 
RES_HIDDENTXTFLD );
+const bool bContainsHiddenChars = 
m_pShell-GetDoc()-ContainsHiddenChars();
+const SwFieldType* pFldType = m_pShell-GetDoc()-GetSysFldType( 
RES_HIDDENTXTFLD );
 const bool bContainsHiddenFields= pFldType  
pFldType-GetDepends();
-pFldType = m_rShell.GetDoc()-GetSysFldType( RES_HIDDENPARAFLD );
+pFldType = m_pShell-GetDoc()-GetSysFldType( 

[Libreoffice-commits] .: Branch 'libreoffice-3-6' - sw/inc sw/source

2012-09-19 Thread Libreoffice Gerrit user
 sw/inc/swtable.hxx   |1 +
 sw/source/core/table/swtable.cxx |   14 +++---
 sw/source/core/undo/untbl.cxx|5 +
 3 files changed, 17 insertions(+), 3 deletions(-)

New commits:
commit d60ea419c57812f611125b0ca51bf897ea7e214b
Author: Michael Stahl m...@openoffice.org
Date:   Tue Sep 18 14:19:50 2012 +0200

rhbz#852128: sw: avoid table undo crash:

SwUndoTblNdsChg::UndoImpl: to prevent access of deleted table box start
node, disconnect the SwTableBox from the start node before removing the
table box nodes.
This problem was probably introduced with CWS swnewtable
db4de0817df6906db2743239d45f9f0834ab1e91, which changed the order of the
removal operations for unknown reasons.

(cherry picked from commit cf842d7c7f9559bfdbb3924cd05a3a50d1dff5e3)

Conflicts:
sw/source/core/table/swtable.cxx

Change-Id: Ic59823a84082cc6ff453b2b512cbb8253886ecf3
Reviewed-on: https://gerrit.libreoffice.org/640
Reviewed-by: Miklos Vajna vmik...@suse.cz
Tested-by: Miklos Vajna vmik...@suse.cz

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 29c779a..a352588 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -422,6 +422,7 @@ public:
 SwFrmFmt* ClaimFrmFmt();
 void ChgFrmFmt( SwTableBoxFmt *pNewFmt );
 
+void RemoveFromTable();
 const SwStartNode *GetSttNd() const { return pSttNd; }
 sal_uLong GetSttIdx() const;
 
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 3a57a75..69e755b 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1747,10 +1747,9 @@ SwTableBox::SwTableBox( SwTableBoxFmt* pFmt, const 
SwStartNode rSttNd, SwTableL
 rSrtArr.Insert( p );// eintragen
 }
 
-SwTableBox::~SwTableBox()
+void SwTableBox::RemoveFromTable()
 {
-// Inhaltstragende Box ?
-if( !GetFrmFmt()-GetDoc()-IsInDtor()  pSttNd )
+if (pSttNd) // box containing contents?
 {
 // an der Table austragen
 const SwTableNode* pTblNd = pSttNd-FindTableNode();
@@ -1759,6 +1758,15 @@ SwTableBox::~SwTableBox()
 GetTabSortBoxes();
 SwTableBox *p = this;   // error: this
 rSrtArr.Remove( p );// austragen
+pSttNd = 0; // clear it so this is only run once
+}
+}
+
+SwTableBox::~SwTableBox()
+{
+if (!GetFrmFmt()-GetDoc()-IsInDtor())
+{
+RemoveFromTable();
 }
 
 // ist die TabelleBox der letzte Client im FrameFormat, kann dieses
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 11dbb4b..e3a6af5 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1755,7 +1755,11 @@ void SwUndoTblNdsChg::UndoImpl(::sw::UndoRedoContext  
rContext)
 rDoc.GetNodes()._MoveNodes( aRg, rDoc.GetNodes(), aInsPos, 
sal_False );
 }
 else
+{   // first disconnect box from node, otherwise ~SwTableBox would
+// access pBox-pSttNd, deleted by DeleteSection
+pBox-RemoveFromTable();
 rDoc.DeleteSection( rDoc.GetNodes()[ nIdx ] );
+}
 aDelBoxes.insert( aDelBoxes.end(), pBox );
 }
 }
@@ -1771,6 +1775,7 @@ void SwUndoTblNdsChg::UndoImpl(::sw::UndoRedoContext  
rContext)
 // TL_CHART2: notify chart about box to be removed
 if (pPCD)
 pPCD-DeleteBox( pTblNd-GetTable(), *pBox );
+pBox-RemoveFromTable(); // ~SwTableBox would access pBox-pSttNd
 aDelBoxes.insert( aDelBoxes.end(), pBox );
 rDoc.DeleteSection( rDoc.GetNodes()[ nIdx ] );
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: Branch 'libreoffice-3-6' - sw/inc sw/source

2012-07-11 Thread Michael Stahl
 sw/inc/fldbas.hxx|2 +-
 sw/source/core/fields/expfld.cxx |2 +-
 sw/source/core/fields/fldbas.cxx |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 13aac1fe6c7b1c04adfe14b678b50b59e231489b
Author: Cédric Bosdonnat cedric.bosdon...@free.fr
Date:   Tue Jul 10 13:44:33 2012 +0200

fdo#51793: FormatNumber can handle sal_uInt32 values after all...

Change-Id: I9d50bce0278a4aa65873aa816eb991473f556cee
(cherry picked from commit 32c7ba61a9ce620c1c9544ac469ccfd143e60bb9)

Signed-off-by: Michael Stahl mst...@redhat.com

diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index 404dcfc..93c7495 100644
--- a/sw/inc/fldbas.hxx
+++ b/sw/inc/fldbas.hxx
@@ -230,7 +230,7 @@ extern sal_uInt16 aTypeTab[];
 // General tools.
 String  GetResult(double nVal, sal_uInt32 nNumFmt, sal_uInt16 nLang = 
LANGUAGE_SYSTEM);
 voidSetErrorStr(const String rStr);
-String  FormatNumber(sal_uInt16 nNum, sal_uInt32 nFormat);
+String  FormatNumber(sal_uInt32 nNum, sal_uInt32 nFormat);
 
 // Instances of SwFields and those derived from it occur 0 to n times.
 // For each class there is one instance of the associated type class.
diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx
index 9afe607..7ea20a4 100644
--- a/sw/source/core/fields/expfld.cxx
+++ b/sw/source/core/fields/expfld.cxx
@@ -881,7 +881,7 @@ void SwSetExpField::SetValue( const double rAny )
 SwValueField::SetValue(rAny);
 
 if( IsSequenceFld() )
-sExpand = FormatNumber( (sal_uInt16)GetValue(), GetFormat() );
+sExpand = FormatNumber( (sal_uInt32)GetValue(), GetFormat() );
 else
 sExpand = ((SwValueFieldType*)GetTyp())-ExpandValue( rAny,
 GetFormat(), GetLanguage());
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index 3ca892e..2a693ea 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -434,7 +434,7 @@ SwField * SwField::CopyField() const
 Beschreibung: Numerierung expandieren
  */
 
-String FormatNumber(sal_uInt16 nNum, sal_uInt32 nFormat)
+String FormatNumber(sal_uInt32 nNum, sal_uInt32 nFormat)
 {
 if(SVX_NUM_PAGEDESC == nFormat)
 return  String::CreateFromInt32( nNum );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: Branch 'libreoffice-3-6' - sw/inc sw/source

2012-06-21 Thread Ivan Timofeev
 sw/inc/EnhancedPDFExportHelper.hxx  |9 +++
 sw/source/core/text/EnhancedPDFExportHelper.cxx |   57 
 2 files changed, 37 insertions(+), 29 deletions(-)

New commits:
commit 9b6cab988b4dd7be88573aab99010aaac657f78f
Author: Ivan Timofeev timofeev@gmail.com
Date:   Wed Jun 20 22:15:46 2012 +0400

fdo#34093: fix error in calculation of page number of SwRect

StringRangeEnumerator (i.e. user's input) contains page numbers in a 
different
page range (it excludes empty pages). So:
- first map page numbers to a common range, then compare
- user's input can't contain empty pages, remove this check

Change-Id: I4fce5215272fc90f39c9e05d3f3604734a8aebe3
(cherry picked from commit db053e48d2ca17e1256eb12500f075488483603b)

diff --git a/sw/inc/EnhancedPDFExportHelper.hxx 
b/sw/inc/EnhancedPDFExportHelper.hxx
index 2020d13..a5a5210 100644
--- a/sw/inc/EnhancedPDFExportHelper.hxx
+++ b/sw/inc/EnhancedPDFExportHelper.hxx
@@ -216,7 +216,14 @@ class SwEnhancedPDFExportHelper
 OutputDevice mrOut;
 
 StringRangeEnumerator* mpRangeEnum;
-std::vectorbool maIsPageEmpty;
+/** The problem is that numbers in StringRangeEnumerator aren't accordant
+ * to real page numbers if mbSkipEmptyPages is true, because in this case
+ * empty pages are excluded from a page range and numbers in
+ * StringRangeEnumerator are shifted.
+ *
+ * maPageNumberMap[real_page_number] is either a corresponding page number
+ * in a page range without empty pages, or -1 if this page is empty. */
+std::vector sal_Int32  maPageNumberMap;
 
 bool mbSkipEmptyPages;
 bool mbEditEngineOnly;
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index ff70ebc..1427b76 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -1523,12 +1523,17 @@ SwEnhancedPDFExportHelper::SwEnhancedPDFExportHelper( 
SwEditShell rSh,
 
 if ( mbSkipEmptyPages )
 {
-maIsPageEmpty.resize( mrSh.GetPageCount() );
+maPageNumberMap.resize( mrSh.GetPageCount() );
 const SwPageFrm* pCurrPage =
 static_castconst SwPageFrm*( mrSh.GetLayout()-Lower() );
-for ( size_t i = 0, n = maIsPageEmpty.size(); i  n  pCurrPage; ++i )
+sal_Int32 nPageNumber = 0;
+for ( size_t i = 0, n = maPageNumberMap.size(); i  n  pCurrPage; 
++i )
 {
-maIsPageEmpty[i] = pCurrPage-IsEmptyPage();
+if ( pCurrPage-IsEmptyPage() )
+maPageNumberMap[i] = -1;
+else
+maPageNumberMap[i] = nPageNumber++;
+
 pCurrPage = static_castconst SwPageFrm*( pCurrPage-GetNext() );
 }
 }
@@ -2150,7 +2155,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
 sal_Int32 SwEnhancedPDFExportHelper::CalcOutputPageNum( const SwRect rRect ) 
const
 {
 // Document page number.
-const sal_Int32 nPageNumOfRect = mrSh.GetPageNumAndSetOffsetForPDF( mrOut, 
rRect );
+sal_Int32 nPageNumOfRect = mrSh.GetPageNumAndSetOffsetForPDF( mrOut, rRect 
);
 if ( nPageNumOfRect  0 )
 return -1;
 
@@ -2158,6 +2163,10 @@ sal_Int32 SwEnhancedPDFExportHelper::CalcOutputPageNum( 
const SwRect rRect ) co
 sal_Int32 nRet = -1;
 if ( mpRangeEnum )
 {
+if ( mbSkipEmptyPages )
+// Map the page number to the range without empty pages.
+nPageNumOfRect = maPageNumberMap[ nPageNumOfRect ];
+
 if ( mpRangeEnum-hasValue( nPageNumOfRect ) )
 {
 sal_Int32 nOutputPageNum = 0;
@@ -2165,18 +2174,12 @@ sal_Int32 SwEnhancedPDFExportHelper::CalcOutputPageNum( 
const SwRect rRect ) co
 StringRangeEnumerator::Iterator aEnd  = mpRangeEnum-end();
 for ( ; aIter != aEnd; ++aIter )
 {
-bool bSkipThisPage = mbSkipEmptyPages 
-static_castsize_t( *aIter )  maIsPageEmpty.size() 
-maIsPageEmpty[*aIter];
-if ( !bSkipThisPage )
+if ( *aIter == nPageNumOfRect )
 {
-if ( *aIter == nPageNumOfRect )
-{
-nRet = nOutputPageNum;
-break;
-}
-++nOutputPageNum;
+nRet = nOutputPageNum;
+break;
 }
+++nOutputPageNum;
 }
 }
 }
@@ -2185,9 +2188,9 @@ sal_Int32 SwEnhancedPDFExportHelper::CalcOutputPageNum( 
const SwRect rRect ) co
 if ( mbSkipEmptyPages )
 {
 sal_Int32 nOutputPageNum = 0;
-for ( size_t i = 0; i  maIsPageEmpty.size(); ++i )
+for ( size_t i = 0; i  maPageNumberMap.size(); ++i )
 {
-if ( !maIsPageEmpty[i] )
+if ( maPageNumberMap[i] = 0 ) // is not