21 #include <osl/diagnose.h>
109 rtl_math_ConversionStatus eStatus;
113 if( rtl_math_ConversionStatus_Ok != eStatus || nEnd == 0 )
141 nCmp = n1 < n2 ? -1 : n1 == n2 ? 0 : 1;
185 : nOrg(rPos.GetIndex()), aPos(rPos)
196 const OUString& rStr = pTextNd->
GetText();
200 sal_Int32 nStart = 0;
203 while( nStart != -1 &&
i < nDCount)
205 nStart = rStr.indexOf( nDeli, nStart );
215 sal_Int32 nEnd = rStr.indexOf( nDeli, nStart+1 );
217 return rStr.copy( nStart );
218 return rStr.copy( nStart, nEnd-nStart );
239 OUStringBuffer aRetStr;
243 OSL_ENSURE(pMyBox,
"No atomic Box");
257 return aRetStr.makeStringAndClear();
297 if (pAPos && (RndStdIds::FLY_AT_PARA == pAnchor->
GetAnchorId()) &&
305 nEnd = pEnd->nNode.GetIndex();
306 while( nStart <= nEnd )
308 if( !
GetNodes()[ nStart++ ]->IsTextNode() )
318 SwPaM* pRedlPam =
nullptr;
325 pRedlPam =
new SwPaM( pStart->
nNode, pEnd->nNode, -1, 1 );
376 std::multiset<SwSortTextElement> aSortSet;
377 while( aStart <= pEnd->nNode )
388 if( bUndo && !pRedlUndo )
397 for (
const auto& rElem : aSortSet)
410 pUndoSort->
Insert(rElem.nOrg, nBeg + n);
474 OSL_ENSURE( !rBoxes.
empty(),
"no valid Box list" );
481 FndBox_ aFndBox(
nullptr,
nullptr );
483 FndPara aPara( rBoxes, &aFndBox );
493 FndLines_t::size_type nStart = 0;
499 while( nStart < rLines.size() )
507 if( pTableNd->GetTable().IsHeadline( *pLine ) )
513 if( nStart == rLines.size() )
529 pTableNd->GetTable().SetHTMLTableLayout(std::shared_ptr<SwHTMLTableLayout>());
536 pTableNd->DelFrames();
542 pUndoSort =
new SwUndoSort( rBoxes[0]->GetSttIdx(),
555 std::multiset<SwSortBoxElement> aSortList;
558 for( sal_uInt16
i = static_cast<sal_uInt16>(nStart);
i < nCount; ++
i)
566 for (
const auto& rElem : aSortList)
570 MoveRow(
this, aFlatBox, rElem.nRow, i+nStart, aMovedList, pUndoSort);
574 MoveCol(
this, aFlatBox, rElem.nRow, i+nStart, aMovedList, pUndoSort);
582 const sal_uLong nIdx = pTableNd->GetIndex();
586 UpdateCharts( pTableNd->GetTable().GetFrameFormat()->GetName() );
600 for( sal_uInt16
i=0;
i < rBox.
GetCols(); ++
i )
613 MoveCell(pDoc, pS, pT, bMoved, pUD);
627 pTFormat =
const_cast<SwTableBox*
>(pT)->ClaimFrameFormat();
657 MoveCell(pDoc, pS, pT, bMoved, pUD);
671 pTFormat =
const_cast<SwTableBox*
>(pT)->ClaimFrameFormat();
688 OSL_ENSURE(pSource && pTar,
"Source or target missing");
703 if( pNd->StartOfSectionNode() == pSource->
GetSttNd() )
712 sal_uLong nCount = pNd->EndOfSectionIndex() - pNd->StartOfSectionIndex();
714 bool bDelFirst =
false;
717 OSL_ENSURE( pNd->GetContentNode(),
"No ContentNode");
718 bDelFirst = !pNd->GetContentNode()->Len() && bMovedBefore;
723 SwNodeRange aRgTar( aTar.GetNode(), 0, *pNd->EndOfSectionNode() );
753 m_pArr = std::make_unique<FndBox_ const *[]>(nCount);
767 FndBoxes_t::size_type nBoxes {0};
769 for (FndLines_t::size_type
i=0;
i < rLines.size(); ++
i)
775 if(
i && nBoxes != rBoxes.size())
778 nBoxes = rBoxes.size();
789 FndLines_t::size_type nLines {0};
791 for (FndBoxes_t::size_type
i = 0;
i < rBoxes.size(); ++
i)
793 FndBox_ const*
const pBox = rBoxes[
i].get();
797 if(
i && nLines != rLines.size() )
800 nLines = rLines.size();
816 for (
const auto & pLine : rLines)
821 for (
const auto &rpB : rBoxes)
823 nCount += rpB->GetLines().empty() ? 1 :
GetColCount(*rpB);
839 sal_uInt16 nLines = 0;
840 for (
const auto & pLine : rLines)
844 for (
const auto &rpB : rBoxes)
846 if (!rpB->GetLines().empty())
852 nLines = nLines + nLn;
860 bool bModRow =
false;
864 sal_uInt16 nOldRow =
m_nRow;
865 for (
const auto & pLine : rLines)
869 sal_uInt16 nOldCol =
m_nCol;
870 for( FndBoxes_t::size_type j = 0; j < rBoxes.size(); ++j )
873 const FndBox_ *
const pBox = rBoxes[j].get();
887 auto pSet = std::make_unique<SfxItemSet>(
906 FillFlat( *pBox, ( j+1 == rBoxes.size() ) );
921 sal_uInt16 nOff = n_Row *
m_nCols + n_Col;
924 OSL_ENSURE(n_Col <
m_nCols && n_Row <
m_nRows && pTmp,
"invalid array access");
937 std::vector<const SwTableBox*>::const_iterator it = std::find(
mBoxes.begin(),
mBoxes.end(), pTableBox);
SwSortTextElement(const SwNodeIndex &rPos)
SortingElement for Text.
const SwEndNode * EndOfSectionNode() const
const FndLines_t & GetLines() const
virtual sal_Int32 Len() const
static double StrToDouble(const OUString &rStr)
const Value & back() const
Marks a position in the document model.
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
SwSortDirection eDirection
void loadCollatorAlgorithm(const OUString &rAlgorithm, const css::lang::Locale &rLocale, sal_Int32 nOption)
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
const OUString & GetText() const
sal_uLong GetSttIdx() const
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(150)
virtual AppendResult AppendRedline(SwRangeRedline *pNewRedl, bool bCallDelete)=0
Append a new redline.
void MoveCell(SwDoc *pDoc, const SwTableBox *pSource, const SwTableBox *pTar, bool bMovedBefore, SwUndoSort *pUD)
Move a single Cell.
virtual void SetModified()=0
Must be called manually at changes of format.
const SwPosition * GetMark() const
virtual OUString GetKey(sal_uInt16 nKey) const =0
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
std::vector< std::unique_ptr< SwSortKey > > aKeys
SwTableLine is one table row in the document model.
IDocumentUndoRedo & GetIDocumentUndoRedo()
IDocumentContentOperations const & getIDocumentContentOperations() const
void Copy_(const SwNodeRange &rRg, const SwNodeIndex &rInsPos, bool bNewFrames=true) const
double stringToDouble(const OUString &rString, bool bUseGroupSep, rtl_math_ConversionStatus *pStatus, sal_Int32 *pParseEnd) const
const SwFrameFormats * GetSpzFrameFormats() const
FlatFndBox(SwDoc *pDocPtr, const FndBox_ &rBox)
Generate two-dimensional array of FndBoxes.
void UpdateCharts(std::u16string_view rName) const
void ForEach_FndLineCopyCol(SwTableLines &rLines, FndPara *pFndPara)
This creates a structure mirroring the SwTable structure that contains all rows and non-leaf boxes (a...
static SwSortOptions * pOptions
static LanguageType nLang
sal_uInt16 GetRowCount(const FndBox_ &rBox)
Maximum count of Rows (Lines)
void SetValues(const SwPaM &rPam)
SwContentNode * GetContentNode(bool bPoint=true) const
sal_uInt16 GetPos(const SwTableBox *pTableBox) const
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
void Delete(const SwNodeIndex &rPos, sal_uLong nNodes=1)
delete nodes
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
static LocaleDataWrapper * pLclData
virtual OUString GetKey(sal_uInt16 nKey) const override
const SwTextFormatColl * GetDfltTextFormatColl() const
sal_uLong GetIndex() const
virtual void UpdateTableFields(SfxPoolItem *pHt)=0
virtual void DoUndo(bool const bDoUndo)=0
Enable/Disable Undo.
const FndBoxes_t & GetBoxes() const
void push_back(const SwTableBox *&rpTableBox)
void Insert(const OUString &rOrgPos, const OUString &rNewPos)
virtual bool DoesUndo() const =0
Is Undo enabled?
void FillFlat(const FndBox_ &, bool bLastBox=false)
Create a linear array of atomic FndBoxes.
std::vector< const SwTableBox * > mBoxes
bool CheckBoxSymmetry(const FndLine_ &rLn)
Check Box for symmetry (All Boxes of a Line need to have same number of Lines)
const FndBox_ * GetBox(sal_uInt16 nCol, sal_uInt16 nRow) const
Access a specific Cell.
bool SortText(const SwPaM &, const SwSortOptions &)
Sort Text in the Document.
PaM is Point and Mark: a selection of the document model.
virtual void AppendUndo(std::unique_ptr< SwUndo > pUndo)=0
Add new Undo action.
void SetSaveRange(const SwPaM &rRange)
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
void SectionDown(SwNodeRange *pRange, SwStartNodeType=SwNormalStartNode)
create a start/end section pair
static css::lang::Locale * pLocale
const SwPosition * GetPoint() const
SwIndex & Assign(SwIndexReg *, sal_Int32)
virtual double GetValue(sal_uInt16 nKey) const
virtual OUString GetKey(sal_uInt16 nKey) const override
Get Key for a cell.
virtual double GetValue(sal_uInt16 nKey) const override
static bool IsShowOriginal(const RedlineFlags eM)
virtual bool DeleteRedline(const SwPaM &rPam, bool bSaveInUndo, RedlineType nDelType)=0
SwContentNode * GetContentNode()
std::unique_ptr< FndBox_ const *[]> m_pArr
sal_uInt16 GetCols() const
void MoveRow(SwDoc *pDoc, const FlatFndBox &rBox, sal_uInt16 nS, sal_uInt16 nT, SwMovedBoxes &rMovedList, SwUndoSort *pUD)
Move a row.
static void Init(SwDoc *, const SwSortOptions &rOpt, FlatFndBox const *=nullptr)
Construct a SortElement for the Sort.
IDocumentState const & getIDocumentState() const
#define LANGUAGE_DONTKNOW
static CollatorWrapper * pSortCollator
Marks a node in the document model.
SwFrameFormat * GetFrameFormat()
virtual bool MoveNodeRange(SwNodeRange &, SwNodeIndex &, SwMoveFlags)=0
bool operator<(const SwSortElement &) const
const SwPosition * Start() const
virtual bool IsIgnoreRedline() const =0
void RestoreUpperFrames(SwNodes &rNds, sal_uLong nStt, sal_uLong nEnd)
SwTextNode is a paragraph in the document model.
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
constexpr TypedWhichId< SwTableBoxFormula > RES_BOXATR_FORMULA(149)
std::vector< std::unique_ptr< FndBox_ > > FndBoxes_t
const SwStartNode * GetSttNd() const
sal_uInt16 GetColCount(const FndBox_ &rBox)
Maximum count of Columns (Boxes)
bool CheckLineSymmetry(const FndBox_ &rBox)
All Lines of a Box need to have same number of Boxes.
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
const SwTableBox * GetBox() const
const SfxItemSet * GetItemSet(sal_uInt16 nCol, sal_uInt16 nRow) const
LanguageType GetAppLanguage()
void MoveCol(SwDoc *pDoc, const FlatFndBox &rBox, sal_uInt16 nS, sal_uInt16 nT, SwMovedBoxes &rMovedList, SwUndoSort *pUD)
Move a column.
const SwPosition * End() const
std::vector< std::unique_ptr< SfxItemSet > > m_ppItemSets
static const FlatFndBox * pBox
SwTableBox is one table cell in the document model.
Reference< XComponentContext > getProcessComponentContext()
std::vector< std::unique_ptr< FndLine_ > > FndLines_t
sal_uInt32 GetValue() const
bool SortTable(const SwSelBoxes &rBoxes, const SwSortOptions &)
Sort Table in the Document.
virtual const SwRedlineTable & GetRedlineTable() const =0
sal_uInt16 GetRows() const
SwContentNode * GoNext(SwNodeIndex *) const
#define SW_COLLATOR_IGNORES
int keycompare(const SwSortElement &rCmp, sal_uInt16 nKey) const
const SwAttrPool & GetAttrPool() const
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
bool anyOf(strong_int v) const
static OUString * pLastAlgorithm
SwSortBoxElement(sal_uInt16 nRC)
SortingElement for Tables.
SwTextNode * MakeTextNode(const SwNodeIndex &rWhere, SwTextFormatColl *pColl, bool bNewFrames=true)
Implementations of "Make...Node" are in the given .cxx-files.
SwNodeIndex & Assign(SwNodes const &rNds, sal_uLong)
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
Base class of the Writer document model elements.