sc/source/filter/inc/addressconverter.hxx | 45 +++++++++++++++++++++++++++-- sc/source/filter/oox/addressconverter.cxx | 10 +++++- sc/source/filter/oox/condformatbuffer.cxx | 2 - sc/source/filter/oox/defnamesbuffer.cxx | 5 +-- sc/source/filter/oox/sheetdatabuffer.cxx | 10 +++--- sc/source/filter/oox/worksheethelper.cxx | 2 - sc/source/filter/oox/worksheetsettings.cxx | 2 - sw/inc/IDocumentContentOperations.hxx | 32 ++++++++++++++++++-- sw/source/core/doc/docnew.cxx | 20 +++++++++--- 9 files changed, 104 insertions(+), 24 deletions(-)
New commits: commit ddffb797904c5ae1a5ab3bc66eeb9bfc168a0148 Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Mon Jun 23 09:16:18 2014 +0200 Replace the whole content for copied documents If the document is initialized in CreateCopy, it already contains the initial empty paragraph. So we have to delete the content from initial document, as we're going to replace the whole content with the pasted document. Change-Id: Ie6a64dcb070f7d611dfde97f2c1a721834b4167b Reviewed-on: https://gerrit.libreoffice.org/10963 Reviewed-by: Björn Michaelsen <bjoern.michael...@canonical.com> Tested-by: Björn Michaelsen <bjoern.michael...@canonical.com> diff --git a/sw/inc/IDocumentContentOperations.hxx b/sw/inc/IDocumentContentOperations.hxx index 5227528..8f64f1c 100644 --- a/sw/inc/IDocumentContentOperations.hxx +++ b/sw/inc/IDocumentContentOperations.hxx @@ -65,10 +65,36 @@ public: }; public: - /** Copying of a range within or to another document. - The position can also be within the range! + /** Copy a selected content range to a position + + The position can be in the same or in an another document. It can also + be within the range! + + \warning The range has to include at least two nodes or has to be a + SwDoc::IsColumnSelection! + + Normally this functions should work only with content nodes. But there + is a special case used by SwDoc::Paste, which starts the SwPaM at the + content start node. This position doesn't contain any content: + + @code + SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 1 ); + @endcode + + This is important, because it prevents merging of the first node of + the range into the node pointed to by \p rPos. + As a result this keeps all properties of the first real content node, + which is the 2nd, including the Flys and the page description. In this + case the first (fake) node is silently dropped and all other nodes are + just copied. + + @param rPam + The source node range to copy + + @param rPos + The target copy destination */ - virtual bool CopyRange(SwPaM&, SwPosition&, const bool bCopyAll ) const = 0; + virtual bool CopyRange(SwPaM& rPam, SwPosition& rPos, const bool bCopyAll ) const = 0; /** Delete section containing the node. */ diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index c18fe20..1a7e76e 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -915,6 +915,12 @@ SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const // copy content pRet->Paste( *this ); + if ( bCallInitNew ) { + // delete leading page / initial content from target document + SwNodeIndex aDeleteIdx( pRet->GetNodes().GetEndOfExtras(), 2 ); + pRet->GetNodes().Delete( aDeleteIdx, 1 ); + } + // remove the temporary shell if it is there as it was done before pRet->SetTmpDocShell( (SfxObjectShell*)NULL ); @@ -926,12 +932,14 @@ SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const // copy document content - code from SwFEShell::Paste( SwDoc* ) void SwDoc::Paste( const SwDoc& rSource ) { - // this has to be empty const sal_uInt16 nStartPageNumber = GetPhyPageNum(); - // until the end of the NodesArray - SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 2 ); - SwPaM aCpyPam( aSourceIdx ); //DocStart - SwNodeIndex aTargetIdx( GetNodes().GetEndOfExtras(), 2 ); - SwPaM aInsertPam( aTargetIdx ); //replaces PCURCRSR from SwFEShell::Paste() + // GetEndOfExtras + 1 = StartOfContent == no content node! + // this ensures, that we have at least two nodes in the SwPaM. + // @see IDocumentContentOperations::CopyRange + SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 1 ); + SwPaM aCpyPam( aSourceIdx ); + + SwNodeIndex aTargetIdx( GetNodes().GetEndOfContent() ); + SwPaM aInsertPam( aTargetIdx ); aCpyPam.SetMark(); aCpyPam.Move( fnMoveForward, fnGoDoc ); commit a685de59fce89ab77e1e03b0044621c3f43a00c3 Author: Takeshi Abe <t...@fixedpoint.jp> Date: Tue Sep 9 15:20:31 2014 +0900 fdo#75757: remove inheritance to std::vector from ApiCellRangeList. Change-Id: I29913e0e437c112640b08187f8bea6b1f0f1c17c Reviewed-on: https://gerrit.libreoffice.org/11349 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/source/filter/inc/addressconverter.hxx b/sc/source/filter/inc/addressconverter.hxx index 5afec56..69d031a 100644 --- a/sc/source/filter/inc/addressconverter.hxx +++ b/sc/source/filter/inc/addressconverter.hxx @@ -32,14 +32,55 @@ class BiffInputStream; /** A vector of com.sun.star.table.CellRangeAddress elements and additional functionality. */ -class ApiCellRangeList : public ::std::vector< ::com::sun::star::table::CellRangeAddress > +class ApiCellRangeList { public: - inline explicit ApiCellRangeList() {} + inline explicit ApiCellRangeList() : mvAddresses() {} + + size_t size() const { return mvAddresses.size(); } + + bool empty() const { return mvAddresses.empty(); } + + const ::com::sun::star::table::CellRangeAddress& front() const + { return mvAddresses.front(); } + + ::com::sun::star::table::CellRangeAddress& operator[]( size_t i ) + { return mvAddresses[ i ]; } + + ::std::vector< ::com::sun::star::table::CellRangeAddress >::const_iterator begin() const + { return mvAddresses.begin(); } + ::std::vector< ::com::sun::star::table::CellRangeAddress >::iterator begin() + { return mvAddresses.begin(); } + + ::std::vector< ::com::sun::star::table::CellRangeAddress >::const_iterator end() const + { return mvAddresses.end(); } + + ::std::vector< ::com::sun::star::table::CellRangeAddress >::reverse_iterator rbegin() + { return mvAddresses.rbegin(); } + + ::std::vector< ::com::sun::star::table::CellRangeAddress >::reverse_iterator rend() + { return mvAddresses.rend(); } + + void clear() { mvAddresses.clear(); } + + void erase( ::std::vector< ::com::sun::star::table::CellRangeAddress >::iterator it ) + { mvAddresses.erase( it ); } + + void pop_back() { mvAddresses.pop_back(); } + + void push_back( const ::com::sun::star::table::CellRangeAddress& rAddress ) + { mvAddresses.push_back( rAddress ); } /** Returns the base address of this range list (top-left cell of first range). */ ::com::sun::star::table::CellAddress getBaseAddress() const; + + /** Converts to a sequence. */ + com::sun::star::uno::Sequence< ::com::sun::star::table::CellRangeAddress > + toSequence() const; + +private: + ::std::vector< ::com::sun::star::table::CellRangeAddress > mvAddresses; }; /** A 2D cell address struct for binary filters. */ diff --git a/sc/source/filter/oox/addressconverter.cxx b/sc/source/filter/oox/addressconverter.cxx index 22e1632..75d5d33 100644 --- a/sc/source/filter/oox/addressconverter.cxx +++ b/sc/source/filter/oox/addressconverter.cxx @@ -26,6 +26,7 @@ #include <rtl/strbuf.hxx> #include <rtl/ustrbuf.hxx> #include <oox/core/filterbase.hxx> +#include <oox/helper/containerhelper.hxx> #include "biffinputstream.hxx" namespace oox { @@ -69,9 +70,14 @@ const sal_Int16 BIFF8_MAXTAB = BIFF5_MAXTAB; CellAddress ApiCellRangeList::getBaseAddress() const { - if( empty() ) + if( mvAddresses.empty() ) return CellAddress(); - return CellAddress( front().Sheet, front().StartColumn, front().StartRow ); + return CellAddress( mvAddresses.front().Sheet, mvAddresses.front().StartColumn, mvAddresses.front().StartRow ); +} + +com::sun::star::uno::Sequence< CellRangeAddress > ApiCellRangeList::toSequence() const +{ + return ContainerHelper::vectorToSequence( mvAddresses ); } void BinAddress::read( SequenceInputStream& rStrm ) diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx index 5cd7360..dd8aac4 100644 --- a/sc/source/filter/oox/condformatbuffer.cxx +++ b/sc/source/filter/oox/condformatbuffer.cxx @@ -987,7 +987,7 @@ void CondFormat::finalizeImport() sal_Int32 nIndex = getScDocument().AddCondFormat(mpFormat, nTab); ScRangeList aList; - for( ApiCellRangeList::const_iterator itr = maModel.maRanges.begin(); itr != maModel.maRanges.end(); ++itr) + for( ::std::vector< CellRangeAddress >::const_iterator itr = maModel.maRanges.begin(); itr != maModel.maRanges.end(); ++itr) { ScRange aRange; ScUnoConversion::FillScRange(aRange, *itr); diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx index 73addbe..53f0d56 100644 --- a/sc/source/filter/oox/defnamesbuffer.cxx +++ b/sc/source/filter/oox/defnamesbuffer.cxx @@ -28,7 +28,6 @@ #include <com/sun/star/sheet/XPrintAreas.hpp> #include <rtl/ustrbuf.hxx> #include <oox/helper/attributelist.hxx> -#include <oox/helper/containerhelper.hxx> #include <oox/helper/propertyset.hxx> #include "addressconverter.hxx" #include "biffinputstream.hxx" @@ -406,7 +405,7 @@ void DefinedName::convertFormula() ApiCellRangeList aPrintRanges; getFormulaParser().extractCellRangeList( aPrintRanges, aFTokenSeq, false, mnCalcSheet ); if( xPrintAreas.is() && !aPrintRanges.empty() ) - xPrintAreas->setPrintAreas( ContainerHelper::vectorToSequence( aPrintRanges ) ); + xPrintAreas->setPrintAreas( aPrintRanges.toSequence() ); } break; case BIFF_DEFNAME_PRINTTITLES: @@ -419,7 +418,7 @@ void DefinedName::convertFormula() bool bHasRowTitles = false; bool bHasColTitles = false; const CellAddress& rMaxPos = getAddressConverter().getMaxAddress(); - for( ApiCellRangeList::const_iterator aIt = aTitleRanges.begin(), aEnd = aTitleRanges.end(); (aIt != aEnd) && (!bHasRowTitles || !bHasColTitles); ++aIt ) + for( ::std::vector< CellRangeAddress >::const_iterator aIt = aTitleRanges.begin(), aEnd = aTitleRanges.end(); (aIt != aEnd) && (!bHasRowTitles || !bHasColTitles); ++aIt ) { bool bFullRow = (aIt->StartColumn == 0) && (aIt->EndColumn >= rMaxPos.Column); bool bFullCol = (aIt->StartRow == 0) && (aIt->EndRow >= rMaxPos.Row); diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx index 446b9f8..a9fa35d 100644 --- a/sc/source/filter/oox/sheetdatabuffer.cxx +++ b/sc/source/filter/oox/sheetdatabuffer.cxx @@ -342,7 +342,7 @@ void addIfNotInMyMap( StylesBuffer& rStyles, std::map< std::pair< sal_Int32, sal { // add ranges from the rangelist to the existing rangelist for the // matching style ( should we check if they overlap ? ) - for ( ApiCellRangeList::const_iterator iter = rRangeList.begin(), iter_end = rRangeList.end(); iter != iter_end; ++iter ) + for ( ::std::vector< CellRangeAddress >::const_iterator iter = rRangeList.begin(), iter_end = rRangeList.end(); iter != iter_end; ++iter ) it->second.push_back( *iter ); return; } @@ -437,7 +437,7 @@ void SheetDataBuffer::finalizeImport() for ( std::map< std::pair< sal_Int32, sal_Int32 >, ApiCellRangeList >::iterator it = rangeStyleListMap.begin(), it_end = rangeStyleListMap.end(); it != it_end; ++it ) { const ApiCellRangeList& rRanges( it->second ); - for ( ApiCellRangeList::const_iterator it_range = rRanges.begin(), it_rangeend = rRanges.end(); it_range!=it_rangeend; ++it_range ) + for ( ::std::vector< CellRangeAddress >::const_iterator it_range = rRanges.begin(), it_rangeend = rRanges.end(); it_range!=it_rangeend; ++it_range ) addColXfStyle( it->first.first, it->first.second, *it_range ); } @@ -652,8 +652,8 @@ void SheetDataBuffer::setCellFormat( const CellModel& rModel, sal_Int32 nNumFmtI { if( (rModel.mnXfId >= 0) || (nNumFmtId >= 0) ) { - ApiCellRangeList::reverse_iterator aIt = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rbegin(); - ApiCellRangeList::reverse_iterator aItEnd = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rend(); + ::std::vector< CellRangeAddress >::reverse_iterator aIt = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rbegin(); + ::std::vector< CellRangeAddress >::reverse_iterator aItEnd = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rend(); /* The xlsx sheet data contains row wise information. * It is sufficient to check if the row range size is one */ @@ -674,7 +674,7 @@ void SheetDataBuffer::setCellFormat( const CellModel& rModel, sal_Int32 nNumFmtI aIt = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rbegin(); aItEnd = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rend(); - ApiCellRangeList::reverse_iterator aItM = aIt+1; + ::std::vector< CellRangeAddress >::reverse_iterator aItM = aIt+1; while( aItM != aItEnd ) { if( aIt->Sheet == aItM->Sheet ) diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx index 4417bbe..ddc4ba5 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -500,7 +500,7 @@ Reference< XSheetCellRanges > WorksheetGlobals::getCellRangeList( const ApiCellR { xRanges.set( getBaseFilter().getModelFactory()->createInstance( maSheetCellRanges ), UNO_QUERY_THROW ); Reference< XSheetCellRangeContainer > xRangeCont( xRanges, UNO_QUERY_THROW ); - xRangeCont->addRangeAddresses( ContainerHelper::vectorToSequence( rRanges ), sal_False ); + xRangeCont->addRangeAddresses( rRanges.toSequence(), sal_False ); } catch( Exception& ) { diff --git a/sc/source/filter/oox/worksheetsettings.cxx b/sc/source/filter/oox/worksheetsettings.cxx index b92958d..09483b4 100644 --- a/sc/source/filter/oox/worksheetsettings.cxx +++ b/sc/source/filter/oox/worksheetsettings.cxx @@ -160,7 +160,7 @@ void WorksheetSettings::importProtectedRange( const AttributeList& rAttribs ) if (!aRangeList.empty()) { ScRangeList* pRangeList = aProt.maRangeList = new ScRangeList; - for (ApiCellRangeList::const_iterator itr( aRangeList.begin()), end( aRangeList.end()); itr != end; ++itr) + for (::std::vector< ::com::sun::star::table::CellRangeAddress >::const_iterator itr( aRangeList.begin()), end( aRangeList.end()); itr != end; ++itr) { ScRange aRange; ScUnoConversion::FillScRange( aRange, *itr);
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits