diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/attr/swatrset.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/undo/unins.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unochart.cxx | 464 | ||||
-rw-r--r-- | sw/source/core/unocore/unodraw.cxx | 37 | ||||
-rw-r--r-- | sw/source/core/unocore/unoport.cxx | 263 | ||||
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/unocore/unotext.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 84 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8gr.cxx | 14 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 73 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par2.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par3.cxx | 51 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8scan.cxx | 28 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewtab.cxx | 25 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 25 | ||||
-rw-r--r-- | sw/source/uibase/utlui/uitool.cxx | 11 |
18 files changed, 508 insertions, 596 deletions
diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx index ae0ff382b9e7..865907a172a9 100644 --- a/sw/source/core/attr/swatrset.cxx +++ b/sw/source/core/attr/swatrset.cxx @@ -377,8 +377,7 @@ void SwAttrSet::CopyToModify( SwModify& rMod ) const RES_PAGEDESC, false, &pItem ) && nullptr != ( pPgDesc = static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc()) ) { - if( !tmpSet ) - tmpSet.reset( new SfxItemSet( *this )); + tmpSet.reset(new SfxItemSet(*this)); SwPageDesc* pDstPgDesc = pDstDoc->FindPageDesc(pPgDesc->GetName()); if( !pDstPgDesc ) diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx index 4b7fef996f36..1103e507d8c4 100644 --- a/sw/source/core/undo/unins.cxx +++ b/sw/source/core/undo/unins.cxx @@ -843,7 +843,7 @@ void SwUndoReRead::SaveGraphicData( const SwGrfNode& rGrfNd ) { maNm = OUString(); maFltr = OUString(); - rGrfNd.GetFileFilterNms( maNm ? &*maNm : nullptr, maFltr ? &*maFltr : nullptr ); + rGrfNd.GetFileFilterNms(&*maNm, &*maFltr); pGrf.reset(); } else diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index 87584578da2c..0b2064cfa53b 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -652,274 +652,264 @@ uno::Reference< chart2::data::XDataSource > SwChartDataProvider::Impl_createData if (!pTableFormat || !pUnoCursor) throw lang::IllegalArgumentException(); - if(pTableFormat) + SwTable* pTable = SwTable::FindTable(pTableFormat); + if (pTable->IsTableComplex()) + return xRes; // we can't handle this thus returning an empty references + + // get a character map in the size of the table to mark + // all the ranges to use in + sal_Int32 nRows = pTable->GetTabLines().size(); + sal_Int32 nCols = pTable->GetTabLines().front()->GetTabBoxes().size(); + std::vector<std::vector<sal_Char>> aMap(nRows); + for (sal_Int32 i = 0; i < nRows; ++i) + aMap[i].resize(nCols); + + // iterate over subranges and mark used cells in above map + //!! by proceeding this way we automatically get rid of + //!! multiple listed or overlapping cell ranges which should + //!! just be ignored silently + sal_Int32 nSubRanges = aSubRanges.getLength(); + for (sal_Int32 i = 0; i < nSubRanges; ++i) { - SwTable* pTable = SwTable::FindTable( pTableFormat ); - if(pTable->IsTableComplex()) - return xRes; // we can't handle this thus returning an empty references - else + OUString aTableName, aStartCell, aEndCell; + bool bOk2 = GetTableAndCellsFromRangeRep( + pSubRanges[i], aTableName, aStartCell, aEndCell ); + OSL_ENSURE(bOk2, "failed to get table and start/end cells"); + + sal_Int32 nStartRow, nStartCol, nEndRow, nEndCol; + SwXTextTable::GetCellPosition(aStartCell, nStartCol, nStartRow); + SwXTextTable::GetCellPosition(aEndCell, nEndCol, nEndRow); + OSL_ENSURE( nStartRow <= nEndRow && nStartCol <= nEndCol, + "cell range not normalized"); + + // test if the ranges span more than the available cells + if( nStartRow < 0 || nEndRow >= nRows || + nStartCol < 0 || nEndCol >= nCols ) { - // get a character map in the size of the table to mark - // all the ranges to use in - sal_Int32 nRows = pTable->GetTabLines().size(); - sal_Int32 nCols = pTable->GetTabLines().front()->GetTabBoxes().size(); - std::vector< std::vector< sal_Char > > aMap( nRows ); - for (sal_Int32 i = 0; i < nRows; ++i) - aMap[i].resize( nCols ); - - // iterate over subranges and mark used cells in above map - //!! by proceeding this way we automatically get rid of - //!! multiple listed or overlapping cell ranges which should - //!! just be ignored silently - sal_Int32 nSubRanges = aSubRanges.getLength(); - for (sal_Int32 i = 0; i < nSubRanges; ++i) - { - OUString aTableName, aStartCell, aEndCell; - bool bOk2 = GetTableAndCellsFromRangeRep( - pSubRanges[i], aTableName, aStartCell, aEndCell ); - OSL_ENSURE( bOk2, "failed to get table and start/end cells" ); - - sal_Int32 nStartRow, nStartCol, nEndRow, nEndCol; - SwXTextTable::GetCellPosition( aStartCell, nStartCol, nStartRow ); - SwXTextTable::GetCellPosition( aEndCell, nEndCol, nEndRow ); - OSL_ENSURE( nStartRow <= nEndRow && nStartCol <= nEndCol, - "cell range not normalized"); - - // test if the ranges span more than the available cells - if( nStartRow < 0 || nEndRow >= nRows || - nStartCol < 0 || nEndCol >= nCols ) - { - throw lang::IllegalArgumentException(); - } - for (sal_Int32 k1 = nStartRow; k1 <= nEndRow; ++k1) - { - for (sal_Int32 k2 = nStartCol; k2 <= nEndCol; ++k2) - aMap[k1][k2] = 'x'; - } - } + throw lang::IllegalArgumentException(); + } + for (sal_Int32 k1 = nStartRow; k1 <= nEndRow; ++k1) + { + for (sal_Int32 k2 = nStartCol; k2 <= nEndCol; ++k2) + aMap[k1][k2] = 'x'; + } + } + + // find label and data sequences to use - // find label and data sequences to use + sal_Int32 oi; // outer index (slower changing index) + sal_Int32 ii; // inner index (faster changing index) + sal_Int32 oiEnd = bDtaSrcIsColumns ? nCols : nRows; + sal_Int32 iiEnd = bDtaSrcIsColumns ? nRows : nCols; + std::vector<sal_Int32> aLabelIdx(oiEnd); + std::vector<sal_Int32> aDataStartIdx(oiEnd); + std::vector<sal_Int32> aDataLen(oiEnd); + for (oi = 0; oi < oiEnd; ++oi) + { + aLabelIdx[oi] = -1; + aDataStartIdx[oi] = -1; + aDataLen[oi] = 0; + } + + for (oi = 0; oi < oiEnd; ++oi) + { + ii = 0; + while (ii < iiEnd) + { + sal_Char &rChar = bDtaSrcIsColumns ? aMap[ii][oi] : aMap[oi][ii]; - sal_Int32 oi; // outer index (slower changing index) - sal_Int32 ii; // inner index (faster changing index) - sal_Int32 oiEnd = bDtaSrcIsColumns ? nCols : nRows; - sal_Int32 iiEnd = bDtaSrcIsColumns ? nRows : nCols; - std::vector< sal_Int32 > aLabelIdx( oiEnd ); - std::vector< sal_Int32 > aDataStartIdx( oiEnd ); - std::vector< sal_Int32 > aDataLen( oiEnd ); - for (oi = 0; oi < oiEnd; ++oi) + // label should be used but is not yet found? + if (rChar == 'x' && bFirstIsLabel && aLabelIdx[oi] == -1) { - aLabelIdx[oi] = -1; - aDataStartIdx[oi] = -1; - aDataLen[oi] = 0; + aLabelIdx[oi] = ii; + rChar = 'L'; // setting a different char for labels here + // makes the test for the data sequence below + // easier } - for (oi = 0; oi < oiEnd; ++oi) + // find data sequence + if (rChar == 'x' && aDataStartIdx[oi] == -1) { - ii = 0; - while (ii < iiEnd) - { - sal_Char &rChar = bDtaSrcIsColumns ? aMap[ii][oi] : aMap[oi][ii]; - - // label should be used but is not yet found? - if (rChar == 'x' && bFirstIsLabel && aLabelIdx[oi] == -1) - { - aLabelIdx[oi] = ii; - rChar = 'L'; // setting a different char for labels here - // makes the test for the data sequence below - // easier - } - - // find data sequence - if (rChar == 'x' && aDataStartIdx[oi] == -1) - { - aDataStartIdx[oi] = ii; + aDataStartIdx[oi] = ii; - // get length of data sequence - sal_Int32 nL = 0; - sal_Char c; - while (ii< iiEnd && 'x' == (c = bDtaSrcIsColumns ? aMap[ii][oi] : aMap[oi][ii])) - { - ++nL; ++ii; - } - aDataLen[oi] = nL; - - // check that there is no other separate sequence of data - // to be found because that is not supported - while (ii < iiEnd) - { - if ('x' == (c = bDtaSrcIsColumns ? aMap[ii][oi] : aMap[oi][ii])) - throw lang::IllegalArgumentException(); - ++ii; - } - } - else - ++ii; + // get length of data sequence + sal_Int32 nL = 0; + sal_Char c; + while (ii< iiEnd && 'x' == (c = bDtaSrcIsColumns ? aMap[ii][oi] : aMap[oi][ii])) + { + ++nL; ++ii; } - } + aDataLen[oi] = nL; - // make some other consistency checks while calculating - // the number of XLabeledDataSequence to build: - // - labels should always be used or not at all - // - the data sequences should have equal non-zero length - sal_Int32 nNumLDS = 0; - if (oiEnd > 0) - { - sal_Int32 nFirstSeqLen = 0; - sal_Int32 nFirstSeqLabelIdx = -1; - bool bFirstFound = false; - for (oi = 0; oi < oiEnd; ++oi) + // check that there is no other separate sequence of data + // to be found because that is not supported + while (ii < iiEnd) { - // row/col used at all? - if (aDataStartIdx[oi] != -1 && - (!bFirstIsLabel || aLabelIdx[oi] != -1)) - { - ++nNumLDS; - if (!bFirstFound) - { - nFirstSeqLen = aDataLen[oi]; - nFirstSeqLabelIdx = aLabelIdx[oi]; - bFirstFound = true; - } - else - { - if (nFirstSeqLen != aDataLen[oi] || - nFirstSeqLabelIdx != aLabelIdx[oi]) - throw lang::IllegalArgumentException(); - } - } + if ('x' == (c = bDtaSrcIsColumns ? aMap[ii][oi] : aMap[oi][ii])) + throw lang::IllegalArgumentException(); + ++ii; } } - if (nNumLDS == 0) - throw lang::IllegalArgumentException(); + else + ++ii; + } + } - // now we should have all necessary data to build a proper DataSource - // thus if we came this far there should be no further problem - if (bTestOnly) - return xRes; // have createDataSourcePossible return true - - // create data source from found label and data sequences - uno::Sequence< uno::Reference< chart2::data::XDataSequence > > aLabelSeqs( nNumLDS ); - uno::Reference< chart2::data::XDataSequence > *pLabelSeqs = aLabelSeqs.getArray(); - uno::Sequence< uno::Reference< chart2::data::XDataSequence > > aDataSeqs( nNumLDS ); - uno::Reference< chart2::data::XDataSequence > *pDataSeqs = aDataSeqs.getArray(); - sal_Int32 nSeqsIdx = 0; - for (oi = 0; oi < oiEnd; ++oi) + // make some other consistency checks while calculating + // the number of XLabeledDataSequence to build: + // - labels should always be used or not at all + // - the data sequences should have equal non-zero length + sal_Int32 nNumLDS = 0; + if (oiEnd > 0) + { + sal_Int32 nFirstSeqLen = 0; + sal_Int32 nFirstSeqLabelIdx = -1; + bool bFirstFound = false; + for (oi = 0; oi < oiEnd; ++oi) + { + // row/col used at all? + if (aDataStartIdx[oi] != -1 && + (!bFirstIsLabel || aLabelIdx[oi] != -1)) { - // row/col not used? (see if-statement above where nNumLDS was counted) - if (!(aDataStartIdx[oi] != -1 && - (!bFirstIsLabel || aLabelIdx[oi] != -1))) - continue; - - // get cell ranges for label and data - - SwRangeDescriptor aLabelDesc; - SwRangeDescriptor aDataDesc; - if (bDtaSrcIsColumns) // use columns + ++nNumLDS; + if (!bFirstFound) { - aLabelDesc.nTop = aLabelIdx[oi]; - aLabelDesc.nLeft = oi; - aLabelDesc.nBottom = aLabelDesc.nTop; - aLabelDesc.nRight = oi; - - aDataDesc.nTop = aDataStartIdx[oi]; - aDataDesc.nLeft = oi; - aDataDesc.nBottom = aDataDesc.nTop + aDataLen[oi] - 1; - aDataDesc.nRight = oi; + nFirstSeqLen = aDataLen[oi]; + nFirstSeqLabelIdx = aLabelIdx[oi]; + bFirstFound = true; } - else // use rows + else { - aLabelDesc.nTop = oi; - aLabelDesc.nLeft = aLabelIdx[oi]; - aLabelDesc.nBottom = oi; - aLabelDesc.nRight = aLabelDesc.nLeft; - - aDataDesc.nTop = oi; - aDataDesc.nLeft = aDataStartIdx[oi]; - aDataDesc.nBottom = oi; - aDataDesc.nRight = aDataDesc.nLeft + aDataLen[oi] - 1; + if (nFirstSeqLen != aDataLen[oi] || + nFirstSeqLabelIdx != aLabelIdx[oi]) + throw lang::IllegalArgumentException(); } - const OUString aBaseName = pTableFormat->GetName() + "."; + } + } + } + if (nNumLDS == 0) + throw lang::IllegalArgumentException(); - OUString aLabelRange; - if (aLabelIdx[oi] != -1) - { - aLabelRange = aBaseName - + sw_GetCellName( aLabelDesc.nLeft, aLabelDesc.nTop ) - + ":" + sw_GetCellName( aLabelDesc.nRight, aLabelDesc.nBottom ); - } + // now we should have all necessary data to build a proper DataSource + // thus if we came this far there should be no further problem + if (bTestOnly) + return xRes; // have createDataSourcePossible return true + + // create data source from found label and data sequences + uno::Sequence<uno::Reference<chart2::data::XDataSequence>> aLabelSeqs(nNumLDS); + uno::Reference<chart2::data::XDataSequence>* pLabelSeqs = aLabelSeqs.getArray(); + uno::Sequence<uno::Reference<chart2::data::XDataSequence>> aDataSeqs(nNumLDS); + uno::Reference<chart2::data::XDataSequence>* pDataSeqs = aDataSeqs.getArray(); + sal_Int32 nSeqsIdx = 0; + for (oi = 0; oi < oiEnd; ++oi) + { + // row/col not used? (see if-statement above where nNumLDS was counted) + if (!(aDataStartIdx[oi] != -1 && + (!bFirstIsLabel || aLabelIdx[oi] != -1))) + continue; - OUString aDataRange; - if (aDataStartIdx[oi] != -1) - { - aDataRange = aBaseName - + sw_GetCellName( aDataDesc.nLeft, aDataDesc.nTop ) - + ":" + sw_GetCellName( aDataDesc.nRight, aDataDesc.nBottom ); - } + // get cell ranges for label and data - // get cursors spanning the cell ranges for label and data - std::shared_ptr<SwUnoCursor> pLabelUnoCursor; - std::shared_ptr<SwUnoCursor> pDataUnoCursor; - GetFormatAndCreateCursorFromRangeRep( pDoc, aLabelRange, &pTableFormat, pLabelUnoCursor); - GetFormatAndCreateCursorFromRangeRep( pDoc, aDataRange, &pTableFormat, pDataUnoCursor); - - // create XDataSequence's from cursors - if (pLabelUnoCursor) - pLabelSeqs[ nSeqsIdx ] = new SwChartDataSequence( *this, *pTableFormat, pLabelUnoCursor ); - OSL_ENSURE( pDataUnoCursor, "pointer to data sequence missing" ); - if (pDataUnoCursor) - pDataSeqs [ nSeqsIdx ] = new SwChartDataSequence( *this, *pTableFormat, pDataUnoCursor ); - if (pLabelUnoCursor || pDataUnoCursor) - ++nSeqsIdx; - } - OSL_ENSURE( nSeqsIdx == nNumLDS, "mismatch between sequence size and num,ber of entries" ); + SwRangeDescriptor aLabelDesc; + SwRangeDescriptor aDataDesc; + if (bDtaSrcIsColumns) // use columns + { + aLabelDesc.nTop = aLabelIdx[oi]; + aLabelDesc.nLeft = oi; + aLabelDesc.nBottom = aLabelDesc.nTop; + aLabelDesc.nRight = oi; + + aDataDesc.nTop = aDataStartIdx[oi]; + aDataDesc.nLeft = oi; + aDataDesc.nBottom = aDataDesc.nTop + aDataLen[oi] - 1; + aDataDesc.nRight = oi; + } + else // use rows + { + aLabelDesc.nTop = oi; + aLabelDesc.nLeft = aLabelIdx[oi]; + aLabelDesc.nBottom = oi; + aLabelDesc.nRight = aLabelDesc.nLeft; + + aDataDesc.nTop = oi; + aDataDesc.nLeft = aDataStartIdx[oi]; + aDataDesc.nBottom = oi; + aDataDesc.nRight = aDataDesc.nLeft + aDataLen[oi] - 1; + } + const OUString aBaseName = pTableFormat->GetName() + "."; - // build data source from data and label sequences - uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLDS( nNumLDS ); - uno::Reference< chart2::data::XLabeledDataSequence > *pLDS = aLDS.getArray(); - for (sal_Int32 i = 0; i < nNumLDS; ++i) - { - SwChartLabeledDataSequence *pLabeledDtaSeq = new SwChartLabeledDataSequence; - pLabeledDtaSeq->setLabel( pLabelSeqs[i] ); - pLabeledDtaSeq->setValues( pDataSeqs[i] ); - pLDS[i] = pLabeledDtaSeq; - } + OUString aLabelRange; + if (aLabelIdx[oi] != -1) + { + aLabelRange = aBaseName + + sw_GetCellName( aLabelDesc.nLeft, aLabelDesc.nTop ) + + ":" + sw_GetCellName( aLabelDesc.nRight, aLabelDesc.nBottom ); + } - // apply 'SequenceMapping' if it was provided - sal_Int32 nSequenceMappingLen = aSequenceMapping.getLength(); - if (nSequenceMappingLen) - { - sal_Int32 *pSequenceMapping = aSequenceMapping.getArray(); - uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aOld_LDS( aLDS ); - uno::Reference< chart2::data::XLabeledDataSequence > *pOld_LDS = aOld_LDS.getArray(); + OUString aDataRange = aBaseName + + sw_GetCellName( aDataDesc.nLeft, aDataDesc.nTop ) + + ":" + sw_GetCellName( aDataDesc.nRight, aDataDesc.nBottom ); - sal_Int32 nNewCnt = 0; - for (sal_Int32 i = 0; i < nSequenceMappingLen; ++i) - { - // check that index to be used is valid - // and has not yet been used - sal_Int32 nIdx = pSequenceMapping[i]; - if (0 <= nIdx && nIdx < nNumLDS && pOld_LDS[nIdx].is()) - { - pLDS[nNewCnt++] = pOld_LDS[nIdx]; + // get cursors spanning the cell ranges for label and data + std::shared_ptr<SwUnoCursor> pLabelUnoCursor; + std::shared_ptr<SwUnoCursor> pDataUnoCursor; + GetFormatAndCreateCursorFromRangeRep(pDoc, aLabelRange, &pTableFormat, pLabelUnoCursor); + GetFormatAndCreateCursorFromRangeRep(pDoc, aDataRange, &pTableFormat, pDataUnoCursor); - // mark index as being used already (avoids duplicate entries) - pOld_LDS[nIdx].clear(); - } - } - // add not yet used 'old' sequences to new one - for (sal_Int32 i = 0; i < nNumLDS; ++i) - { - if (pOld_LDS[i].is()) - pLDS[nNewCnt++] = pOld_LDS[i]; - } - OSL_ENSURE( nNewCnt == nNumLDS, "unexpected size of resulting sequence" ); - } + // create XDataSequence's from cursors + if (pLabelUnoCursor) + pLabelSeqs[nSeqsIdx] = new SwChartDataSequence(*this, *pTableFormat, pLabelUnoCursor); + OSL_ENSURE(pDataUnoCursor, "pointer to data sequence missing"); + if (pDataUnoCursor) + pDataSeqs[nSeqsIdx] = new SwChartDataSequence(*this, *pTableFormat, pDataUnoCursor); + if (pLabelUnoCursor || pDataUnoCursor) + ++nSeqsIdx; + } + OSL_ENSURE(nSeqsIdx == nNumLDS, "mismatch between sequence size and num,ber of entries"); - xRes = new SwChartDataSource( aLDS ); + // build data source from data and label sequences + uno::Sequence<uno::Reference<chart2::data::XLabeledDataSequence>> aLDS(nNumLDS); + uno::Reference<chart2::data::XLabeledDataSequence>* pLDS = aLDS.getArray(); + for (sal_Int32 i = 0; i < nNumLDS; ++i) + { + SwChartLabeledDataSequence* pLabeledDtaSeq = new SwChartLabeledDataSequence; + pLabeledDtaSeq->setLabel(pLabelSeqs[i]); + pLabeledDtaSeq->setValues(pDataSeqs[i]); + pLDS[i] = pLabeledDtaSeq; + } + + // apply 'SequenceMapping' if it was provided + sal_Int32 nSequenceMappingLen = aSequenceMapping.getLength(); + if (nSequenceMappingLen) + { + sal_Int32 *pSequenceMapping = aSequenceMapping.getArray(); + uno::Sequence<uno::Reference<chart2::data::XLabeledDataSequence>> aOld_LDS(aLDS); + uno::Reference<chart2::data::XLabeledDataSequence>* pOld_LDS = aOld_LDS.getArray(); + + sal_Int32 nNewCnt = 0; + for (sal_Int32 i = 0; i < nSequenceMappingLen; ++i) + { + // check that index to be used is valid + // and has not yet been used + sal_Int32 nIdx = pSequenceMapping[i]; + if (0 <= nIdx && nIdx < nNumLDS && pOld_LDS[nIdx].is()) + { + pLDS[nNewCnt++] = pOld_LDS[nIdx]; + + // mark index as being used already (avoids duplicate entries) + pOld_LDS[nIdx].clear(); + } + } + // add not yet used 'old' sequences to new one + for (sal_Int32 i = 0; i < nNumLDS; ++i) + { + if (pOld_LDS[i].is()) + pLDS[nNewCnt++] = pOld_LDS[i]; } + OSL_ENSURE(nNewCnt == nNumLDS, "unexpected size of resulting sequence"); } + xRes = new SwChartDataSource(aLDS); return xRes; } diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index fa903d7bf703..e2d61dc8abe1 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -760,37 +760,32 @@ uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference< const SdrMarkList& rMarkList = pPage->PreGroup(xShapes); if ( rMarkList.GetMarkCount() > 1 ) { - bool bFlyInCnt = false; - for ( size_t i = 0; !bFlyInCnt && i < rMarkList.GetMarkCount(); ++i ) + for (size_t i = 0; i < rMarkList.GetMarkCount(); ++i) { const SdrObject *pObj = rMarkList.GetMark( i )->GetMarkedSdrObj(); if (RndStdIds::FLY_AS_CHAR == ::FindFrameFormat(const_cast<SdrObject*>( pObj))->GetAnchor().GetAnchorId()) { - bFlyInCnt = true; + throw uno::RuntimeException(); // FlyInCnt! } } - if( bFlyInCnt ) - throw uno::RuntimeException(); - if( !bFlyInCnt ) - { - UnoActionContext aContext(pDoc); - pDoc->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr ); - SwDrawContact* pContact = pDoc->GroupSelection( *pPage->GetDrawView() ); - pDoc->ChgAnchor( - pPage->GetDrawView()->GetMarkedObjectList(), - RndStdIds::FLY_AT_PARA, - true, false ); + UnoActionContext aContext(pDoc); + pDoc->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr ); - pPage->GetDrawView()->UnmarkAll(); - if(pContact) - { - uno::Reference< uno::XInterface > xInt = SwFmDrawPage::GetInterface( pContact->GetMaster() ); - xRet.set(xInt, uno::UNO_QUERY); - } - pDoc->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr ); + SwDrawContact* pContact = pDoc->GroupSelection( *pPage->GetDrawView() ); + pDoc->ChgAnchor( + pPage->GetDrawView()->GetMarkedObjectList(), + RndStdIds::FLY_AT_PARA, + true, false ); + + pPage->GetDrawView()->UnmarkAll(); + if(pContact) + { + uno::Reference< uno::XInterface > xInt = SwFmDrawPage::GetInterface( pContact->GetMaster() ); + xRet.set(xInt, uno::UNO_QUERY); } + pDoc->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr ); } pPage->RemovePageView(); } diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index 6275e317caf9..86f9ead27693 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -222,155 +222,152 @@ void SwXTextPortion::GetPropertyValue( OSL_ENSURE( pUnoCursor, "UNO cursor missing" ); if (!pUnoCursor) return; - if(pUnoCursor) + switch(rEntry.nWID) { - switch(rEntry.nWID) + case FN_UNO_TEXT_PORTION_TYPE: { - case FN_UNO_TEXT_PORTION_TYPE: + const char* pRet; + switch (m_ePortionType) + { + case PORTION_TEXT: pRet = "Text";break; + case PORTION_FIELD: pRet = "TextField";break; + case PORTION_FRAME: pRet = "Frame";break; + case PORTION_FOOTNOTE: pRet = "Footnote";break; + case PORTION_REFMARK_START: + case PORTION_REFMARK_END: pRet = UNO_NAME_REFERENCE_MARK;break; + case PORTION_TOXMARK_START: + case PORTION_TOXMARK_END: pRet = UNO_NAME_DOCUMENT_INDEX_MARK;break; + case PORTION_BOOKMARK_START : + case PORTION_BOOKMARK_END : pRet = UNO_NAME_BOOKMARK;break; + case PORTION_REDLINE_START: + case PORTION_REDLINE_END: pRet = "Redline";break; + case PORTION_RUBY_START: + case PORTION_RUBY_END: pRet = "Ruby";break; + case PORTION_SOFT_PAGEBREAK:pRet = "SoftPageBreak";break; + case PORTION_META: pRet = UNO_NAME_META; break; + case PORTION_FIELD_START:pRet = "TextFieldStart";break; + case PORTION_FIELD_END:pRet = "TextFieldEnd";break; + case PORTION_FIELD_START_END:pRet = "TextFieldStartEnd";break; + case PORTION_ANNOTATION: + pRet = "Annotation"; + break; + case PORTION_ANNOTATION_END: + pRet = "AnnotationEnd"; + break; + default: + pRet = nullptr; + } + + OUString sRet; + if( pRet ) + sRet = OUString::createFromAscii( pRet ); + rVal <<= sRet; + } + break; + case FN_UNO_CONTROL_CHARACTER: // obsolete! + break; + case FN_UNO_DOCUMENT_INDEX_MARK: + rVal <<= m_xTOXMark; + break; + case FN_UNO_REFERENCE_MARK: + rVal <<= m_xRefMark; + break; + case FN_UNO_BOOKMARK: + rVal <<= m_xBookmark; + break; + case FN_UNO_FOOTNOTE: + rVal <<= m_xFootnote; + break; + case FN_UNO_TEXT_FIELD: + rVal <<= m_xTextField; + break; + case FN_UNO_META: + rVal <<= m_xMeta; + break; + case FN_UNO_IS_COLLAPSED: + { + switch (m_ePortionType) { - const char* pRet; - switch (m_ePortionType) - { - case PORTION_TEXT: pRet = "Text";break; - case PORTION_FIELD: pRet = "TextField";break; - case PORTION_FRAME: pRet = "Frame";break; - case PORTION_FOOTNOTE: pRet = "Footnote";break; case PORTION_REFMARK_START: - case PORTION_REFMARK_END: pRet = UNO_NAME_REFERENCE_MARK;break; - case PORTION_TOXMARK_START: - case PORTION_TOXMARK_END: pRet = UNO_NAME_DOCUMENT_INDEX_MARK;break; case PORTION_BOOKMARK_START : - case PORTION_BOOKMARK_END : pRet = UNO_NAME_BOOKMARK;break; - case PORTION_REDLINE_START: - case PORTION_REDLINE_END: pRet = "Redline";break; + case PORTION_TOXMARK_START: + case PORTION_REFMARK_END: + case PORTION_TOXMARK_END: + case PORTION_BOOKMARK_END : + case PORTION_REDLINE_START : + case PORTION_REDLINE_END : case PORTION_RUBY_START: - case PORTION_RUBY_END: pRet = "Ruby";break; - case PORTION_SOFT_PAGEBREAK:pRet = "SoftPageBreak";break; - case PORTION_META: pRet = UNO_NAME_META; break; - case PORTION_FIELD_START:pRet = "TextFieldStart";break; - case PORTION_FIELD_END:pRet = "TextFieldEnd";break; - case PORTION_FIELD_START_END:pRet = "TextFieldStartEnd";break; - case PORTION_ANNOTATION: - pRet = "Annotation"; - break; - case PORTION_ANNOTATION_END: - pRet = "AnnotationEnd"; - break; + case PORTION_RUBY_END: + case PORTION_FIELD_START: + case PORTION_FIELD_END: + rVal <<= m_bIsCollapsed; + break; default: - pRet = nullptr; - } - - OUString sRet; - if( pRet ) - sRet = OUString::createFromAscii( pRet ); - rVal <<= sRet; + break; } - break; - case FN_UNO_CONTROL_CHARACTER: // obsolete! - break; - case FN_UNO_DOCUMENT_INDEX_MARK: - rVal <<= m_xTOXMark; - break; - case FN_UNO_REFERENCE_MARK: - rVal <<= m_xRefMark; - break; - case FN_UNO_BOOKMARK: - rVal <<= m_xBookmark; - break; - case FN_UNO_FOOTNOTE: - rVal <<= m_xFootnote; - break; - case FN_UNO_TEXT_FIELD: - rVal <<= m_xTextField; - break; - case FN_UNO_META: - rVal <<= m_xMeta; - break; - case FN_UNO_IS_COLLAPSED: + } + break; + case FN_UNO_IS_START: + { + bool bStart = true, bPut = true; + switch (m_ePortionType) { - switch (m_ePortionType) - { - case PORTION_REFMARK_START: - case PORTION_BOOKMARK_START : - case PORTION_TOXMARK_START: - case PORTION_REFMARK_END: - case PORTION_TOXMARK_END: - case PORTION_BOOKMARK_END : - case PORTION_REDLINE_START : - case PORTION_REDLINE_END : - case PORTION_RUBY_START: - case PORTION_RUBY_END: - case PORTION_FIELD_START: - case PORTION_FIELD_END: - rVal <<= m_bIsCollapsed; - break; - default: - break; - } + case PORTION_REFMARK_START: + case PORTION_BOOKMARK_START: + case PORTION_TOXMARK_START: + case PORTION_REDLINE_START: + case PORTION_RUBY_START: + case PORTION_FIELD_START: + break; + + case PORTION_REFMARK_END: + case PORTION_TOXMARK_END: + case PORTION_BOOKMARK_END: + case PORTION_REDLINE_END: + case PORTION_RUBY_END: + case PORTION_FIELD_END: + bStart = false; + break; + default: + bPut = false; } - break; - case FN_UNO_IS_START: + if(bPut) + rVal <<= bStart; + } + break; + case RES_TXTATR_CJK_RUBY: + { + const uno::Any* pToSet = nullptr; + switch(rEntry.nMemberId) { - bool bStart = true, bPut = true; - switch (m_ePortionType) - { - case PORTION_REFMARK_START: - case PORTION_BOOKMARK_START: - case PORTION_TOXMARK_START: - case PORTION_REDLINE_START: - case PORTION_RUBY_START: - case PORTION_FIELD_START: - break; - - case PORTION_REFMARK_END: - case PORTION_TOXMARK_END: - case PORTION_BOOKMARK_END: - case PORTION_REDLINE_END: - case PORTION_RUBY_END: - case PORTION_FIELD_END: - bStart = false; - break; - default: - bPut = false; - } - if(bPut) - rVal <<= bStart; + case MID_RUBY_TEXT : pToSet = m_pRubyText.get(); break; + case MID_RUBY_ADJUST : pToSet = m_pRubyAdjust.get(); break; + case MID_RUBY_CHARSTYLE:pToSet = m_pRubyStyle.get(); break; + case MID_RUBY_ABOVE : pToSet = m_pRubyIsAbove.get();break; + case MID_RUBY_POSITION: pToSet = m_pRubyPosition.get();break; } - break; - case RES_TXTATR_CJK_RUBY: + if(pToSet) + rVal = *pToSet; + } + break; + default: + beans::PropertyState eTemp; + bool bDone = SwUnoCursorHelper::getCursorPropertyValue( + rEntry, *pUnoCursor, &rVal, eTemp ); + if(!bDone) { - const uno::Any* pToSet = nullptr; - switch(rEntry.nMemberId) + if(!pSet) { - case MID_RUBY_TEXT : pToSet = m_pRubyText.get(); break; - case MID_RUBY_ADJUST : pToSet = m_pRubyAdjust.get(); break; - case MID_RUBY_CHARSTYLE:pToSet = m_pRubyStyle.get(); break; - case MID_RUBY_ABOVE : pToSet = m_pRubyIsAbove.get();break; - case MID_RUBY_POSITION: pToSet = m_pRubyPosition.get();break; + pSet = o3tl::make_unique<SfxItemSet>( + pUnoCursor->GetDoc()->GetAttrPool(), + svl::Items< + RES_CHRATR_BEGIN, RES_FRMATR_END - 1, + RES_UNKNOWNATR_CONTAINER, + RES_UNKNOWNATR_CONTAINER>{}); + SwUnoCursorHelper::GetCursorAttr(*pUnoCursor, *pSet); } - if(pToSet) - rVal = *pToSet; + m_pPropSet->getPropertyValue(rEntry, *pSet, rVal); } - break; - default: - beans::PropertyState eTemp; - bool bDone = SwUnoCursorHelper::getCursorPropertyValue( - rEntry, *pUnoCursor, &rVal, eTemp ); - if(!bDone) - { - if(!pSet) - { - pSet = o3tl::make_unique<SfxItemSet>( - pUnoCursor->GetDoc()->GetAttrPool(), - svl::Items< - RES_CHRATR_BEGIN, RES_FRMATR_END - 1, - RES_UNKNOWNATR_CONTAINER, - RES_UNKNOWNATR_CONTAINER>{}); - SwUnoCursorHelper::GetCursorAttr(*pUnoCursor, *pSet); - } - m_pPropSet->getPropertyValue(rEntry, *pSet, rVal); - } - } } } diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 55500a7eab90..1fc47bd59ce7 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -723,9 +723,9 @@ sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Cell>(const SwDoc& rDoc, OUString* { const sal_Int32 nAutoFormat = nIndex / rTableTemplateMap.size(); const sal_Int32 nBoxFormat = rTableTemplateMap[nIndex % rTableTemplateMap.size()]; - const SwTableAutoFormat* pTableFormat = &rAutoFormats[nAutoFormat]; - if (pTableFormat) - *pString = pTableFormat->GetName() + pTableFormat->GetTableTemplateCellSubName(pTableFormat->GetBoxFormat(nBoxFormat)); + const SwTableAutoFormat& rTableFormat = rAutoFormats[nAutoFormat]; + *pString = rTableFormat.GetName() + + rTableFormat.GetTableTemplateCellSubName(rTableFormat.GetBoxFormat(nBoxFormat)); } else *pString = rDoc.GetCellStyles()[nIndex-nUsedCellStylesCount].GetName(); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index e27630e16445..0657f7bc361d 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -2462,8 +2462,7 @@ class SwXHeadFootText::Impl : m_pHeadFootFormat(&rHeadFootFormat) , m_bIsHeader(bIsHeader) { - if(m_pHeadFootFormat) - StartListening(m_pHeadFootFormat->GetNotifier()); + StartListening(m_pHeadFootFormat->GetNotifier()); } SwFrameFormat* GetHeadFootFormat() const { diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 2b59e5ec84e2..1fd3f828696a 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -1460,13 +1460,7 @@ const SwRedlineData* SwWW8AttrIter::GetRunLevelRedline( sal_Int32 nPos ) if( pCurRedline ) { const SwPosition* pEnd = pCurRedline->End(); - if( pEnd->nNode == rNd && - pEnd->nContent.GetIndex() <= nPos ) - { - pCurRedline = nullptr; - ++nCurRedlinePos; - } - else + if (!(pEnd->nNode == rNd && pEnd->nContent.GetIndex() <= nPos)) { switch( pCurRedline->GetType() ) { @@ -1479,57 +1473,55 @@ const SwRedlineData* SwWW8AttrIter::GetRunLevelRedline( sal_Int32 nPos ) default: break; } - pCurRedline = nullptr; - ++nCurRedlinePos; } + pCurRedline = nullptr; + ++nCurRedlinePos; } - if( !pCurRedline ) + assert(!pCurRedline); + // search next Redline + for( ; nCurRedlinePos < m_rExport.m_pDoc->getIDocumentRedlineAccess().GetRedlineTable().size(); + ++nCurRedlinePos ) { - // search next Redline - for( ; nCurRedlinePos < m_rExport.m_pDoc->getIDocumentRedlineAccess().GetRedlineTable().size(); - ++nCurRedlinePos ) - { - const SwRangeRedline* pRedl = m_rExport.m_pDoc->getIDocumentRedlineAccess().GetRedlineTable()[ nCurRedlinePos ]; + const SwRangeRedline* pRedl = m_rExport.m_pDoc->getIDocumentRedlineAccess().GetRedlineTable()[ nCurRedlinePos ]; - const SwPosition* pStt = pRedl->Start(); - const SwPosition* pEnd = pStt == pRedl->GetPoint() - ? pRedl->GetMark() - : pRedl->GetPoint(); + const SwPosition* pStt = pRedl->Start(); + const SwPosition* pEnd = pStt == pRedl->GetPoint() + ? pRedl->GetMark() + : pRedl->GetPoint(); - if( pStt->nNode == rNd ) + if( pStt->nNode == rNd ) + { + if( pStt->nContent.GetIndex() >= nPos ) { - if( pStt->nContent.GetIndex() >= nPos ) + if( pStt->nContent.GetIndex() == nPos ) { - if( pStt->nContent.GetIndex() == nPos ) - { - switch( pRedl->GetType() ) - { - case nsRedlineType_t::REDLINE_INSERT: - case nsRedlineType_t::REDLINE_DELETE: - case nsRedlineType_t::REDLINE_FORMAT: - // write data of this redline - pCurRedline = pRedl; - return &( pCurRedline->GetRedlineData() ); - break; - default: - break; - } - } - break; + switch( pRedl->GetType() ) + { + case nsRedlineType_t::REDLINE_INSERT: + case nsRedlineType_t::REDLINE_DELETE: + case nsRedlineType_t::REDLINE_FORMAT: + // write data of this redline + pCurRedline = pRedl; + return &( pCurRedline->GetRedlineData() ); + break; + default: + break; + } } - } - else - { break; } + } + else + { + break; + } - if( pEnd->nNode == rNd && - pEnd->nContent.GetIndex() < nPos ) - { - pCurRedline = pRedl; - break; - } + if( pEnd->nNode == rNd && + pEnd->nContent.GetIndex() < nPos ) + { + pCurRedline = pRedl; + break; } } return nullptr; diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 09740c9eb718..e674c23e6041 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -1057,12 +1057,6 @@ sal_uInt16 MSWordSections::NumberOfColumns( const SwDoc &rDoc, const WW8_SepInfo if ( !pPd ) pPd = &rDoc.GetPageDesc( 0 ); - if ( !pPd ) - { - OSL_ENSURE( pPd, "totally impossible" ); - return 1; - } - const SfxItemSet &rSet = pPd->GetMaster().GetAttrSet(); SfxItemSet aSet( *rSet.GetPool(), svl::Items<RES_COL, RES_COL>{} ); aSet.SetParent( &rSet ); diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx index 251588a83837..c5c2b0316a3a 100644 --- a/sw/source/filter/ww8/wrtww8gr.cxx +++ b/sw/source/filter/ww8/wrtww8gr.cxx @@ -390,17 +390,9 @@ void WW8Export::OutGrf(const ww8::Frame &rFrame) ? rFrame.GetContent()->GetGrfNode() : nullptr; if ( pGrfNd && pGrfNd->IsLinkedFile() ) { - OUString sStr( FieldString(ww::eINCLUDEPICTURE) ); - sStr += " \""; - { - if ( pGrfNd ) - { - OUString aFileURL; - pGrfNd->GetFileFilterNms( &aFileURL, nullptr ); - sStr += aFileURL; - } - } - sStr += "\" \\d"; + OUString sStr; + pGrfNd->GetFileFilterNms(&sStr, nullptr); + sStr = FieldString(ww::eINCLUDEPICTURE) + " \"" + sStr + "\" \\d"; OutputField( nullptr, ww::eINCLUDEPICTURE, sStr, FieldFlags::Start | FieldFlags::CmdStart | FieldFlags::CmdEnd ); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 317a4efc9bcf..9fba22da4f5e 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -4709,8 +4709,8 @@ void AttributeOutputBase::ParaLineSpacing( const SvxLineSpacingItem& rSpacing ) void WW8AttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust ) { // sprmPJc - sal_uInt8 nAdj = 255; - sal_uInt8 nAdjBiDi = 255; + sal_uInt8 nAdj; + sal_uInt8 nAdjBiDi; switch ( rAdjust.GetAdjust() ) { case SvxAdjust::Left: @@ -4732,46 +4732,43 @@ void WW8AttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust ) return; // not a supported Attribute } - if ( 255 != nAdj ) // supported Attribute? - { - m_rWW8Export.InsUInt16( NS_sprm::sprmPJc80 ); - m_rWW8Export.pO->push_back( nAdj ); + m_rWW8Export.InsUInt16(NS_sprm::sprmPJc80); + m_rWW8Export.pO->push_back(nAdj); - /* - Sadly for left to right paragraphs both these values are the same, - for right to left paragraphs the bidi one is the reverse of the - normal one. - */ - m_rWW8Export.InsUInt16( NS_sprm::sprmPJc ); //bidi version ? - bool bBiDiSwap = false; - if ( m_rWW8Export.m_pOutFormatNode ) + /* + Sadly for left to right paragraphs both these values are the same, + for right to left paragraphs the bidi one is the reverse of the + normal one. + */ + m_rWW8Export.InsUInt16(NS_sprm::sprmPJc); //bidi version ? + bool bBiDiSwap = false; + if (m_rWW8Export.m_pOutFormatNode) + { + SvxFrameDirection nDirection = SvxFrameDirection::Horizontal_LR_TB; + if (dynamic_cast<const SwTextNode*>(m_rWW8Export.m_pOutFormatNode) != nullptr) { - SvxFrameDirection nDirection = SvxFrameDirection::Horizontal_LR_TB; - if ( dynamic_cast< const SwTextNode *>( m_rWW8Export.m_pOutFormatNode ) != nullptr ) - { - SwPosition aPos(*static_cast<const SwContentNode*>(m_rWW8Export.m_pOutFormatNode)); - nDirection = m_rWW8Export.m_pDoc->GetTextDirection(aPos); - } - else if ( dynamic_cast< const SwTextFormatColl *>( m_rWW8Export.m_pOutFormatNode ) != nullptr ) - { - const SwTextFormatColl* pC = - static_cast<const SwTextFormatColl*>(m_rWW8Export.m_pOutFormatNode); - const SvxFrameDirectionItem &rItem = - ItemGet<SvxFrameDirectionItem>(*pC, RES_FRAMEDIR); - nDirection = rItem.GetValue(); - } - if ( ( nDirection == SvxFrameDirection::Horizontal_RL_TB ) || - ( nDirection == SvxFrameDirection::Environment && AllSettings::GetLayoutRTL() ) ) - { - bBiDiSwap = true; - } + SwPosition aPos(*static_cast<const SwContentNode*>(m_rWW8Export.m_pOutFormatNode)); + nDirection = m_rWW8Export.m_pDoc->GetTextDirection(aPos); + } + else if (dynamic_cast<const SwTextFormatColl*>(m_rWW8Export.m_pOutFormatNode) != nullptr) + { + const SwTextFormatColl* pC = + static_cast<const SwTextFormatColl*>(m_rWW8Export.m_pOutFormatNode); + const SvxFrameDirectionItem &rItem = + ItemGet<SvxFrameDirectionItem>(*pC, RES_FRAMEDIR); + nDirection = rItem.GetValue(); + } + if ( ( nDirection == SvxFrameDirection::Horizontal_RL_TB ) || + ( nDirection == SvxFrameDirection::Environment && AllSettings::GetLayoutRTL() ) ) + { + bBiDiSwap = true; } - - if ( bBiDiSwap ) - m_rWW8Export.pO->push_back( nAdjBiDi ); - else - m_rWW8Export.pO->push_back( nAdj ); } + + if (bBiDiSwap) + m_rWW8Export.pO->push_back(nAdjBiDi); + else + m_rWW8Export.pO->push_back(nAdj); } void WW8AttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDirection ) diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 20be4b7357ec..2bb992ac8d95 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -3201,8 +3201,8 @@ void WW8TabDesc::AdjustNewBand() m_pTabLine->GetFrameFormat()->SetFormatAttr(SwFormatRowSplit(!bSetCantSplit)); // if table is only a single row, and row is set as don't split, set the same value for the whole table. - if( bSetCantSplit && m_pTabLines->size() == 1 ) - m_pTable->GetFrameFormat()->SetFormatAttr(SwFormatLayoutSplit( !bSetCantSplit )); + if (bSetCantSplit && m_pTabLines->size() == 1) + m_pTable->GetFrameFormat()->SetFormatAttr(SwFormatLayoutSplit(false)); short i; // SW-Index short j; // WW-Index diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index 34bca3e5ac85..53d5016661ef 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -870,14 +870,12 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet lcl_CopyGreaterEight(sPrefix, sNumString, 0, nFirstNoIndex); //Next number appears at - if (nUpperLevel) - { - sal_uInt8 nOneBasedNextNoIndex = aOfsNumsXCH[nUpperLevel-1]; - const sal_Int32 nNextNoIndex = - nOneBasedNextNoIndex > 0 ? nOneBasedNextNoIndex : SAL_MAX_INT32; - if (sNumString.getLength() > nNextNoIndex) - lcl_CopyGreaterEight(sPostfix, sNumString, nNextNoIndex); - } + assert(nUpperLevel > 0); + sal_uInt8 nOneBasedNextNoIndex = aOfsNumsXCH[nUpperLevel-1]; + const sal_Int32 nNextNoIndex = + nOneBasedNextNoIndex > 0 ? nOneBasedNextNoIndex : SAL_MAX_INT32; + if (sNumString.getLength() > nNextNoIndex) + lcl_CopyGreaterEight(sPostfix, sNumString, nNextNoIndex); /* We use lcl_CopyGreaterEight because once if we have removed unused @@ -2014,9 +2012,9 @@ void SwWW8ImplReader::Read_LFOPosition(sal_uInt16, const sal_uInt8* pData, m_nLFOPosition = USHRT_MAX; } - else + else // nData in (0..0x7FFF] { - m_nLFOPosition = static_cast<sal_uInt16>(nData)-1; + m_nLFOPosition = static_cast<sal_uInt16>(nData)-1; // m_nLFOPosition in [0..0x7FFF) /* If we are a ww8+ style with ww7- style lists then there is a bizarre broken word bug where when the list is removed from a para @@ -2028,28 +2026,25 @@ void SwWW8ImplReader::Read_LFOPosition(sal_uInt16, const sal_uInt8* pData, m_vColl[m_nCurrentColl].m_bHasBrokenWW6List = true; // here the stream data is 1-based, we subtract ONE - if (USHRT_MAX > m_nLFOPosition) + if (m_nLFOPosition != 2047-1) //Normal ww8+ list behaviour { - if (m_nLFOPosition != 2047-1) //Normal ww8+ list behaviour + if (WW8ListManager::nMaxLevel == m_nListLevel) + m_nListLevel = 0; + if (WW8ListManager::nMaxLevel > m_nListLevel) { - if (WW8ListManager::nMaxLevel == m_nListLevel) - m_nListLevel = 0; - if (WW8ListManager::nMaxLevel > m_nListLevel) - { - RegisterNumFormat(m_nLFOPosition, m_nListLevel); - m_nLFOPosition = USHRT_MAX; - m_nListLevel = WW8ListManager::nMaxLevel; - } - } - else if (m_xPlcxMan && m_xPlcxMan->HasParaSprm(NS_sprm::LN_PAnld).pSprm) - { - /* - #i8114# Horrific backwards compatible ww7- lists in ww8+ - docs - */ - Read_ANLevelNo(13 /*equiv ww7- sprm no*/, &m_nListLevel, 1); + RegisterNumFormat(m_nLFOPosition, m_nListLevel); + m_nLFOPosition = USHRT_MAX; + m_nListLevel = WW8ListManager::nMaxLevel; } } + else if (m_xPlcxMan && m_xPlcxMan->HasParaSprm(NS_sprm::LN_PAnld).pSprm) + { + /* + #i8114# Horrific backwards compatible ww7- lists in ww8+ + docs + */ + Read_ANLevelNo(13 /*equiv ww7- sprm no*/, &m_nListLevel, 1); + } } } } diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index b422202e14e3..671bbb944786 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -673,9 +673,6 @@ SwSectionFormat *wwSectionManager::InsertSection( if (!pPage) pPage = &mrReader.m_rDoc.GetPageDesc(0); - if (!pPage) - return nullptr; - SwSectionFormat *pFormat = rSection.mpSection->GetFormat(); OSL_ENSURE(pFormat, "impossible"); if (!pFormat) @@ -4261,7 +4258,7 @@ void SwWW8ImplReader::Read_LineSpace( sal_uInt16, const sal_uInt8* pData, short { long n = nSpace * 10 / 24; // WW: 240 = 100%, SW: 100 = 100% - if( n>SAL_MAX_UINT16 ) n = SAL_MAX_UINT16; + // here n is in [0..13653] aLSpc.SetPropLineSpace( static_cast<sal_uInt16>(n) ); const SvxFontHeightItem* pH = static_cast<const SvxFontHeightItem*>( GetFormatAttr( RES_CHRATR_FONTSIZE )); diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 5354cbbb1c56..643601e144e3 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -2174,10 +2174,10 @@ bool WW8PLCFspecial::SeekPos(long nP) } // Search from beginning? - if( (1 > nIdx) || (nP < pPLCF_PosArray[ nIdx-1 ]) ) + if ((nIdx < 1) || (nP < pPLCF_PosArray[nIdx - 1])) nIdx = 1; - long nI = nIdx ? nIdx : 1; + long nI = nIdx; long nEnd = nIMax; for(int n = (1==nIdx ? 1 : 2); n; --n ) @@ -2447,10 +2447,10 @@ bool WW8PLCF::SeekPos(WW8_CP nPos) } // Search from beginning? - if( (1 > nIdx) || (nP < pPLCF_PosArray[ nIdx-1 ]) ) + if ((nIdx < 1) || (nP < pPLCF_PosArray[nIdx - 1])) nIdx = 1; - sal_Int32 nI = nIdx ? nIdx : 1; + sal_Int32 nI = nIdx; sal_Int32 nEnd = nIMax; for(int n = (1==nIdx ? 1 : 2); n; --n ) @@ -2542,10 +2542,10 @@ bool WW8PLCFpcd_Iter::SeekPos(long nPos) return false; // not found: nPos less than smallest entry } // Search from beginning? - if( (1 > nIdx) || (nP < rPLCF.pPLCF_PosArray[ nIdx-1 ]) ) + if ((nIdx < 1) || (nP < rPLCF.pPLCF_PosArray[nIdx - 1])) nIdx = 1; - long nI = nIdx ? nIdx : 1; + long nI = nIdx; long nEnd = rPLCF.nIMax; for(int n = (1==nIdx ? 1 : 2); n; --n ) @@ -2654,13 +2654,7 @@ WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(const WW8Fib& rFib, SvStream* pSt, } unsigned int nOfs = maRawData[nRawDataOffset] * 2; - - //clip to available data, corrupt fkp - if (nOfs >= 511) - { - mnIMax = mnIdx; - break; - } + // nOfs in [0..0xff*2=510] Entry aEntry(Get_Long(pStart)); @@ -2894,10 +2888,10 @@ bool WW8PLCFx_Fc_FKP::WW8Fkp::SeekPos(WW8_FC nFc) } // Search from beginning? - if ((1 > mnIdx) || (nFc < maEntries[mnIdx-1].mnFC)) + if ((mnIdx < 1) || (nFc < maEntries[mnIdx - 1].mnFC)) mnIdx = 1; - sal_uInt8 nI = mnIdx ? mnIdx : 1; + sal_uInt8 nI = mnIdx; sal_uInt8 nEnd = mnIMax; for(sal_uInt8 n = (1==mnIdx ? 1 : 2); n; --n ) @@ -8314,9 +8308,7 @@ sal_uInt16 wwSprmParser::GetSprmId(const sal_uInt8* pSp) const if (ww::IsSevenMinus(meVersion)) { - nId = *pSp; - if (0x0100 < nId) - nId = 0; + nId = *pSp; // [0..0xff] } else { diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx index 5fa4446755b4..2a42029afd2c 100644 --- a/sw/source/uibase/uiview/viewtab.cxx +++ b/sw/source/uibase/uiview/viewtab.cxx @@ -1329,18 +1329,9 @@ void SwView::StateTabWin(SfxItemSet& rSet) aLongLR.SetRight(rPageRect.Right() - aRect.Right()); } } - if( nWhich == SID_ATTR_LONG_LRSPACE ) - rSet.Put( aLongLR ); - else - { - SvxLRSpaceItem aLR( aLongLR.GetLeft(), - aLongLR.GetRight(), - 0, 0, - nWhich); - rSet.Put(aLR); - } - break; + rSet.Put( aLongLR ); } + break; // provide left and right margins of current page style case SID_ATTR_PAGE_LRSPACE: @@ -1387,17 +1378,9 @@ void SwView::StateTabWin(SfxItemSet& rSet) aLongUL.SetUpper(rPagePrtRect.Top()); aLongUL.SetLower(nPageHeight - rPagePrtRect.Bottom()); } - if( nWhich == SID_ATTR_LONG_ULSPACE ) - rSet.Put( aLongUL ); - else - { - SvxULSpaceItem aULTmp(static_cast<sal_uInt16>(aLongUL.GetUpper()), - static_cast<sal_uInt16>(aLongUL.GetLower()), - nWhich); - rSet.Put(aULTmp); - } - break; + rSet.Put( aLongUL ); } + break; // provide top and bottom margins of current page style case SID_ATTR_PAGE_ULSPACE: diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 9324c70999af..4cb1bd3ec1e3 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3007,18 +3007,13 @@ void SAL_CALL SwXTextDocument::render( { // the view shell should be SwView for documents PDF export // or SwPagePreview for PDF export of the page preview - //!! (check for SwView first as in GuessViewShell) !! - OSL_ENSURE( pView, "!! view missing !!" ); SwViewShell* pVwSh = nullptr; - if (pView) - { - // TODO/mba: we really need a generic way to get the SwViewShell! - SwView* pSwView = dynamic_cast<SwView*>( pView ); - if ( pSwView ) - pVwSh = pSwView->GetWrtShellPtr(); - else - pVwSh = static_cast<SwPagePreview*>(pView)->GetViewShell(); - } + // TODO/mba: we really need a generic way to get the SwViewShell! + const SwView* pSwView = dynamic_cast<const SwView*>(pView); + if (pSwView) + pVwSh = pSwView->GetWrtShellPtr(); + else + pVwSh = static_cast<SwPagePreview*>(pView)->GetViewShell(); // get output device to use VclPtr< OutputDevice > pOut = lcl_GetOutputDevice( *m_pPrintUIOptions ); @@ -3029,8 +3024,8 @@ void SAL_CALL SwXTextDocument::render( const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage" ); bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); - OSL_ENSURE(( dynamic_cast< const SwView *>( pView ) != nullptr && m_pRenderData->IsViewOptionAdjust()) - || (dynamic_cast< const SwView *>( pView ) == nullptr && !m_pRenderData->IsViewOptionAdjust()), + OSL_ENSURE((pSwView && m_pRenderData->IsViewOptionAdjust()) + || (!pSwView && !m_pRenderData->IsViewOptionAdjust()), "SwView / SwViewOptionAdjust_Impl availability mismatch" ); // since printing now also use the API for PDF export this option @@ -3043,9 +3038,7 @@ void SAL_CALL SwXTextDocument::render( // During this process, additional information required for tagging // the pdf file are collected, which are evaulated during painting. - SwWrtShell* pWrtShell = dynamic_cast< const SwView *>( pView ) != nullptr ? - static_cast<SwView*>(pView)->GetWrtShellPtr() : - nullptr; + SwWrtShell* pWrtShell = pSwView ? pSwView->GetWrtShellPtr() : nullptr; SwPrintData const& rSwPrtOptions = *m_pRenderData->GetSwPrtOptions(); diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx index 154d9d7f9553..aa679eb392e9 100644 --- a/sw/source/uibase/utlui/uitool.cxx +++ b/sw/source/uibase/utlui/uitool.cxx @@ -230,7 +230,7 @@ static UseOnPage lcl_convertUseFromSvx(SvxPageUsage nUse) void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) { SwFrameFormat& rMaster = rPageDesc.GetMaster(); - int nFirstShare = -1; + bool bFirstShare = false; // Transfer all general frame attributes rMaster.SetFormatAttr(rSet); @@ -278,12 +278,9 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) ::FillHdFt(pHeaderFormat, rHeaderSet); rPageDesc.ChgHeaderShare(rHeaderSet.Get(SID_ATTR_PAGE_SHARED).GetValue()); - if (nFirstShare < 0) - { - rPageDesc.ChgFirstShare(static_cast<const SfxBoolItem&>( + rPageDesc.ChgFirstShare(static_cast<const SfxBoolItem&>( rHeaderSet.Get(SID_ATTR_PAGE_SHARED_FIRST)).GetValue()); - nFirstShare = rPageDesc.IsFirstShared() ? 1 : 0; - } + bFirstShare = true; } else { @@ -317,7 +314,7 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) ::FillHdFt(pFooterFormat, rFooterSet); rPageDesc.ChgFooterShare(rFooterSet.Get(SID_ATTR_PAGE_SHARED).GetValue()); - if (nFirstShare < 0) + if (!bFirstShare) { rPageDesc.ChgFirstShare(static_cast<const SfxBoolItem&>( rFooterSet.Get(SID_ATTR_PAGE_SHARED_FIRST)).GetValue()); |