summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authormatteocam <matteo.campanelli@gmail.com>2015-09-06 11:14:02 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2015-09-20 13:05:14 +0200
commit0c0dedb9e4a24f09a46e077ddd0bc36de7b5c575 (patch)
tree1246d03c3efb778687fcd6e89d16364180df8713 /editeng
parente705b13b9b8d63f6aba22ca2d4f39b76cf9b45b1 (diff)
chained editeng: Add primitive creation methods for chaining
Change-Id: I061009a6830c3590e30900b14b2d006f68d237c1
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editeng.cxx28
-rw-r--r--editeng/source/editeng/impedit.hxx24
-rw-r--r--editeng/source/editeng/impedit3.cxx107
-rw-r--r--editeng/source/editeng/impedit4.cxx9
-rw-r--r--editeng/source/outliner/outlin2.cxx4
-rw-r--r--editeng/source/outliner/outliner.cxx169
6 files changed, 340 insertions, 1 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index d4c0ba53b4a1..39bf7c67bb17 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -1485,6 +1485,12 @@ EditTextObject* EditEngine::CreateTextObject( const ESelection& rESelection )
return pImpEditEngine->CreateTextObject( aSel );
}
+EditTextObject* EditEngine::GetEmptyTextObject() const
+{
+ return pImpEditEngine->GetEmptyTextObject();
+}
+
+
void EditEngine::SetText( const EditTextObject& rTextObject )
{
pImpEditEngine->EnterBlockNotifications();
@@ -1523,6 +1529,11 @@ void EditEngine::SetImportHdl( const Link<ImportInfo&,void>& rLink )
pImpEditEngine->aImportHdl = rLink;
}
+void EditEngine::SetChainingEventHdl( const Link<>& rLink )
+{
+ pImpEditEngine->SetChainingEventHdl( rLink );
+}
+
Link<ImportInfo&,void> EditEngine::GetImportHdl() const
{
return pImpEditEngine->aImportHdl;
@@ -2739,6 +2750,23 @@ EditPaM EditEngine::InsertLineBreak(const EditSelection& rEditSelection)
return pImpEditEngine->InsertLineBreak(rEditSelection);
}
+sal_Int32 EditEngine::GetOverflowingParaNum() const {
+ return pImpEditEngine->GetOverflowingParaNum();
+}
+
+sal_Int32 EditEngine::GetOverflowingLineNum() const {
+ return pImpEditEngine->GetOverflowingLineNum();
+}
+
+void EditEngine::ClearOverflowingParaNum() {
+ pImpEditEngine->ClearOverflowingParaNum();
+}
+
+bool EditEngine::IsPageOverflow() {
+ pImpEditEngine->CheckPageOverflow();
+ return pImpEditEngine->IsPageOverflow();
+}
+
EFieldInfo::EFieldInfo()
{
pFieldItem = NULL;
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 64d58a120272..3931f6185048 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -476,6 +476,11 @@ private:
Timer aOnlineSpellTimer;
+ // For Chaining
+ sal_Int32 mnOverflowingPara = -1;
+ sal_Int32 mnOverflowingLine = -1;
+ bool mbNeedsChainingHandling = false;
+
// If it is detected at one point that the StatusHdl has to be called, but
// this should not happen immediately (critical section):
Timer aStatusTimer;
@@ -490,6 +495,8 @@ private:
Link<EditView*,void> maBeginDropHdl;
Link<EditView*,void> maEndDropHdl;
+ Link<> aChainingHdlLink;
+
rtl::Reference<SvxForbiddenCharactersTable> xForbiddenCharsTable;
bool bKernAsianPunctuation:1;
@@ -524,6 +531,8 @@ private:
EditUndoSetAttribs* CreateAttribUndo( EditSelection aSel, const SfxItemSet& rSet );
+ EditTextObject* GetEmptyTextObject();
+
EditPaM GetPaM( Point aDocPos, bool bSmart = true );
EditPaM GetPaM( ParaPortion* pPortion, Point aPos, bool bSmart = true );
long GetXPos(const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nIndex, bool bPreferPortionStart = false) const;
@@ -539,6 +548,8 @@ private:
EditSelection InsertTextObject( const EditTextObject&, EditPaM aPaM );
EditSelection InsertText( css::uno::Reference< css::datatransfer::XTransferable >& rxDataObj, const OUString& rBaseURL, const EditPaM& rPaM, bool bUseSpecial );
+ void CheckPageOverflow();
+
EditPaM Clear();
EditPaM RemoveText();
bool CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY );
@@ -674,6 +685,9 @@ private:
css::uno::Reference < css::i18n::XBreakIterator > ImplGetBreakIterator() const;
css::uno::Reference < css::i18n::XExtendedInputSequenceChecker > ImplGetInputSequenceChecker() const;
+ void ImplUpdateOverflowingParaNum( sal_uInt32 );
+ void ImplUpdateOverflowingLineNum( sal_uInt32, sal_uInt32, sal_uInt32 );
+
SpellInfo * CreateSpellInfo( bool bMultipleDocs );
ImpEditEngine(); // disabled
@@ -706,6 +720,8 @@ public:
void SetVertical( bool bVertical );
bool IsVertical() const { return GetEditDoc().IsVertical(); }
+ bool IsPageOverflow( ) const;
+
void SetFixedCellHeight( bool bUseFixedCellHeight );
bool IsFixedCellHeight() const { return GetEditDoc().IsFixedCellHeight(); }
@@ -821,6 +837,7 @@ public:
void SetModifyHdl( const Link<LinkParamNone*,void>& rLink ) { aModifyHdl = rLink; }
Link<LinkParamNone*,void> GetModifyHdl() const { return aModifyHdl; }
+ void SetChainingEventHdl( const Link<>& rLink ) { aChainingHdlLink = rLink; }
bool IsInSelectionMode() { return bInSelection; }
@@ -854,6 +871,7 @@ public:
inline ESelection CreateESel( const EditSelection& rSel );
inline EditSelection CreateSel( const ESelection& rSel );
+ void CallChainingEventHdl();
void SetStyleSheetPool( SfxStyleSheetPool* pSPool );
SfxStyleSheetPool* GetStyleSheetPool() const { return pStylePool; }
@@ -982,13 +1000,17 @@ public:
EditSelection TransliterateText( const EditSelection& rSelection, sal_Int32 nTransliterationMode );
short ReplaceTextOnly( ContentNode* pNode, sal_Int32 nCurrentStart, sal_Int32 nLen, const OUString& rText, const css::uno::Sequence< sal_Int32 >& rOffsets );
-
void SetAsianCompressionMode( sal_uInt16 n );
sal_uInt16 GetAsianCompressionMode() const { return nAsianCompressionMode; }
void SetKernAsianPunctuation( bool b );
bool IsKernAsianPunctuation() const { return bKernAsianPunctuation; }
+ sal_Int32 GetOverflowingParaNum() const { return mnOverflowingPara; }
+ sal_Int32 GetOverflowingLineNum() const { return mnOverflowingLine; }
+ void ClearOverflowingParaNum() { mnOverflowingPara = -1; }
+
+
void SetAddExtLeading( bool b );
bool IsAddExtLeading() const { return bAddExtLeading; }
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 1b2c779a5221..2298ecc3925e 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -343,6 +343,12 @@ void ImpEditEngine::CheckIdleFormatter()
FormatDoc();
}
+bool ImpEditEngine::IsPageOverflow( ) const
+{
+ return mbNeedsChainingHandling;
+}
+
+
void ImpEditEngine::FormatFullDoc()
{
for ( sal_Int32 nPortion = 0; nPortion < GetParaPortions().Count(); nPortion++ )
@@ -556,6 +562,42 @@ void ImpEditEngine::CheckAutoPageSize()
}
}
+void ImpEditEngine::CheckPageOverflow()
+{
+ // FIXME(matteocam)
+ /* fprintf( stderr, IsPageOverflow(aPaperSize, aPrevPaperSize)
+ ? "YES Overflow!\n" : "NO Overflow!\n" ); */
+ // setting overflow status
+
+ fprintf(stderr, "[CONTROL_STATUS] AutoPageSize is %s", ( aStatus.GetControlWord() & EEControlBits::AUTOPAGESIZE ) ? "ON\n" : "OFF\n" );
+
+ sal_uInt32 nBoxHeight = GetMaxAutoPaperSize().Height();
+ fprintf(stderr, "[OVERFLOW-CHECK] Current MaxAutoPaperHeight is %d\n", nBoxHeight);
+
+ sal_uInt32 nTxtHeight = CalcTextHeight(NULL);
+ fprintf(stderr, "[OVERFLOW-CHECK] Current Text Height is %d\n", nTxtHeight);
+
+ sal_uInt32 nParaCount = GetParaPortions().Count();
+ sal_uInt32 nFirstLineCount = GetLineCount(0);
+ bool bOnlyOneEmptyPara = (nParaCount == 1) &&
+ (nFirstLineCount == 1) &&
+ (GetLineLen(0,0) == 0);
+
+ if (nTxtHeight > nBoxHeight && !bOnlyOneEmptyPara)
+ {
+ // which paragraph is the first to cause higher size of the box?
+ ImplUpdateOverflowingParaNum( nBoxHeight); // XXX: currently only for horizontal text
+ //aStatus.SetPageOverflow(true);
+ mbNeedsChainingHandling = true;
+ } else
+ {
+ // No overflow if withing box boundaries
+ //aStatus.SetPageOverflow(false);
+ mbNeedsChainingHandling = false;
+ }
+
+}
+
static sal_Int32 ImplCalculateFontIndependentLineSpacing( const sal_Int32 nFontHeight )
{
return ( nFontHeight * 12 ) / 10; // + 20%
@@ -4029,6 +4071,17 @@ void ImpEditEngine::CallStatusHdl()
}
}
+void ImpEditEngine::CallChainingEventHdl()
+{
+ // XXX: We don't use this method any more at the moment.
+ // only if it's the right ImpEditEngine (with right info on changes in text)
+ if ( aChainingHdlLink.IsSet() /* && aStatus.GetStatusWord() */)
+ {
+ aChainingHdlLink.Call( &mbNeedsChainingHandling );
+
+ }
+}
+
ContentNode* ImpEditEngine::GetPrevVisNode( ContentNode* pCurNode )
{
const ParaPortion* pPortion = FindParaPortion( pCurNode );
@@ -4573,4 +4626,58 @@ void ImpEditEngine::ImplExpandCompressedPortions( EditLine* pLine, ParaPortion*
}
}
+void ImpEditEngine::ImplUpdateOverflowingParaNum(sal_uInt32 nPaperHeight)
+{
+ sal_uInt32 nY = 0;
+ sal_uInt32 nPH;
+
+ for ( sal_Int32 nPara = 0; nPara < GetParaPortions().Count(); nPara++ ) {
+ ParaPortion* pPara = GetParaPortions()[nPara];
+ nPH = pPara->GetHeight();
+ nY += nPH;
+ if ( nY > nPaperHeight /*nCurTextHeight*/ ) // found first paragraph overflowing
+ {
+ mnOverflowingPara = nPara;
+ fprintf(stderr, "[CHAINING] Setting first overflowing #Para#: %d\n", nPara);
+ ImplUpdateOverflowingLineNum( nPaperHeight, nPara, nY-nPH);
+ return;
+ }
+ }
+}
+
+void ImpEditEngine::ImplUpdateOverflowingLineNum(sal_uInt32 nPaperHeight,
+ sal_uInt32 nOverflowingPara,
+ sal_uInt32 nHeightBeforeOverflowingPara)
+{
+ sal_uInt32 nY = nHeightBeforeOverflowingPara;
+ sal_uInt32 nLH;
+
+ ParaPortion *pPara = GetParaPortions()[nOverflowingPara];
+
+ // Like UpdateOverflowingParaNum but for each line in the first
+ // overflowing paragraph.
+ for ( sal_Int32 nLine = 0; nLine < pPara->GetLines().Count(); nLine++ ) {
+ // XXX: We must use a reference here because the copy constructor resets the height
+ EditLine &aLine = pPara->GetLines()[nLine];
+ nLH = aLine.GetHeight();
+ nY += nLH;
+
+ // Debugging output
+ if (nLine == 0) {
+ fprintf(stderr, "[CHAINING] First line has height %d\n", nLH);
+ }
+
+ if ( nY > nPaperHeight ) // found first line overflowing
+ {
+ mnOverflowingLine = nLine;
+ fprintf(stderr, "[CHAINING] Setting first overflowing -Line- to: %d\n", nLine);
+ return;
+ }
+ }
+
+ assert(0); // You should never get here
+
+}
+
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 6589ec6deb23..4dee2f6e13a7 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1000,6 +1000,15 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput,
}
}
+EditTextObject* ImpEditEngine::GetEmptyTextObject()
+{
+ EditSelection aEmptySel;
+ aEmptySel.Min() = aEditDoc.GetStartPaM();
+ aEmptySel.Max() = aEditDoc.GetStartPaM();
+
+ return CreateTextObject( aEmptySel );
+}
+
EditTextObject* ImpEditEngine::CreateTextObject()
{
EditSelection aCompleteSelection;
diff --git a/editeng/source/outliner/outlin2.cxx b/editeng/source/outliner/outlin2.cxx
index 365e346f11e0..087c0c347cf3 100644
--- a/editeng/source/outliner/outlin2.cxx
+++ b/editeng/source/outliner/outlin2.cxx
@@ -126,7 +126,11 @@ void Outliner::SetNotifyHdl( const Link<EENotify&,void>& rLink )
pEditEngine->SetNotifyHdl( LINK( this, Outliner, EditEngineNotifyHdl ) );
else
pEditEngine->SetNotifyHdl( Link<EENotify&,void>() );
+}
+void Outliner::SetChainingEventHdl( const Link<>& rLink )
+{
+ pEditEngine->SetChainingEventHdl( rLink );
}
void Outliner::SetStatusEventHdl( const Link<EditStatus&, void>& rLink )
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 912fa49b413f..f0c982fa520f 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -37,6 +37,7 @@
#include <editeng/eeitem.hxx>
#include <editeng/editstat.hxx>
#include <editeng/scripttypeitem.hxx>
+#include <editeng/overflowingtxt.hxx>
#include <editeng/editobj.hxx>
#include <svl/itemset.hxx>
#include <svl/whiter.hxx>
@@ -413,6 +414,12 @@ OutlinerParaObject* Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32
return pPObj;
}
+void Outliner::SetToEmptyText()
+{
+ OutlinerParaObject *pEmptyTxt = GetEmptyParaObject();
+ SetText(*pEmptyTxt);
+}
+
void Outliner::SetText( const OUString& rText, Paragraph* pPara )
{
DBG_ASSERT(pPara,"SetText:No Para");
@@ -2052,4 +2059,166 @@ bool Outliner::HasParaFlag( const Paragraph* pPara, ParaFlag nFlag )
return pPara && pPara->HasFlag( nFlag );
}
+
+bool Outliner::IsPageOverflow()
+{
+ return pEditEngine->IsPageOverflow();
+}
+
+NonOverflowingText *Outliner::GetNonOverflowingText() const
+{
+ /* XXX:
+ * nCount should be the number of paragraphs of the non overflowing text
+ * nStart should be the starting paragraph of the non overflowing text (XXX: Always 0?)
+ */
+
+ if ( GetParagraphCount() < 1 )
+ return NULL;
+
+ // last non-overflowing paragraph is before the first overflowing one
+ sal_Int32 nCount = pEditEngine->GetOverflowingParaNum();
+ sal_Int32 nOverflowLine = pEditEngine->GetOverflowingLineNum(); // XXX: Unused for now
+
+ // Defensive check: oveflowing para index beyond actual # of paragraphs?
+ if ( nCount > GetParagraphCount()-1) {
+ fprintf(stderr,
+ "[Overflowing] Ops, trying to retrieve para %d when max index is %d\n",
+ nCount,
+ GetParagraphCount()-1);
+ return NULL;
+ }
+
+ if (nCount < 0)
+ {
+ fprintf(stderr,
+ "[Overflowing] No Overflowing text but GetNonOverflowinText called?!\n");
+ return NULL;
+ }
+
+ // NOTE: We want the selection of the overflowing text from here
+ // At the same time we may want to consider the beginning of such text
+ // in a more fine grained way (i.e. as GetNonOverflowingText did)
+
+/*
+ sal_Int32 nHeadPara = pEditEngine->GetOverflowingParaNum();
+ sal_uInt32 nParaCount = GetParagraphCount();
+
+ sal_uInt32 nLen = 0;
+ for ( sal_Int32 nLine = 0;
+ nLine < pEditEngine->GetOverflowingLineNum();
+ nLine++) {
+ nLen += GetLineLen(nHeadPara, nLine);
+ }
+
+ sal_uInt32 nOverflowingPara = pEditEngine->GetOverflowingParaNum();
+ ESelection aOverflowingTextSel;
+ sal_Int32 nLastPara = nParaCount-1;
+ sal_Int32 nLastParaLen = GetText(GetParagraph(nLastPara)).getLength();
+ aOverflowingTextSel = ESelection(nOverflowingPara, nLen,
+ nLastPara, nLastParaLen);
+ bool bLastParaInterrupted =
+ pEditEngine->GetOverflowingLineNum() > 0;
+
+ return new NonOverflowingText(aOverflowingTextSel, bLastParaInterrupted);
+ **/
+
+
+ // Only overflowing text, i.e. 1st line of 1st paragraph overflowing
+ bool bItAllOverflew = nCount == 0 && nOverflowLine == 0;
+ if ( bItAllOverflew )
+ {
+ ESelection aEmptySel(0,0,0,0);
+ //EditTextObject *pTObj = pEditEngine->CreateTextObject(aEmptySel);
+ bool bLastParaInterrupted = true; // Last Para was interrupted since everything overflew
+ return new NonOverflowingText(aEmptySel, bLastParaInterrupted);
+ } else { // Get the lines that of the overflowing para fit in the box
+
+ sal_Int32 nOverflowingPara = nCount;
+ sal_uInt32 nLen = 0;
+
+ for ( sal_Int32 nLine = 0;
+ nLine < pEditEngine->GetOverflowingLineNum();
+ nLine++)
+ {
+ nLen += GetLineLen(nOverflowingPara, nLine);
+ }
+
+ //sal_Int32 nStartPara = 0;
+ //sal_Int32 nStartPos = 0;
+ ESelection aOverflowingTextSelection;
+
+ const sal_Int32 nEndPara = GetParagraphCount()-1;
+ const sal_Int32 nEndPos = pEditEngine->GetTextLen(nEndPara);
+
+ if (nLen == 0) {
+ // XXX: What happens inside this case might be dependent on the joining paragraps or not-thingy
+ // Overflowing paragraph is empty or first line overflowing: it's not "Non-Overflowing" text then
+ sal_Int32 nParaLen = GetText(GetParagraph(nOverflowingPara-1)).getLength();
+ aOverflowingTextSelection =
+ ESelection(nOverflowingPara-1, nParaLen, nEndPara, nEndPos);
+ } else {
+ // We take until we have to from the overflowing paragraph
+ aOverflowingTextSelection =
+ ESelection(nOverflowingPara, nLen, nEndPara, nEndPos);
+ }
+ //EditTextObject *pTObj = pEditEngine->CreateTextObject(aNonOverflowingTextSelection);
+
+ //sal_Int32 nLastLine = GetLineCount(nOverflowingPara)-1;
+ bool bLastParaInterrupted =
+ pEditEngine->GetOverflowingLineNum() > 0;
+
+ return new NonOverflowingText(aOverflowingTextSelection, bLastParaInterrupted);
+ }
+}
+
+OutlinerParaObject *Outliner::GetEmptyParaObject() const
+{
+ EditTextObject *pEmptyText = pEditEngine->GetEmptyTextObject();
+ OutlinerParaObject* pPObj = new OutlinerParaObject( *pEmptyText );
+ pPObj->SetOutlinerMode(GetMode());
+
+ delete pEmptyText;
+ return pPObj;
+}
+
+OverflowingText *Outliner::GetOverflowingText() const
+{
+ if ( pEditEngine->GetOverflowingParaNum() < 0)
+ return NULL;
+
+
+ // Defensive check: oveflowing para index beyond actual # of paragraphs?
+ if ( pEditEngine->GetOverflowingParaNum() > GetParagraphCount()-1) {
+ fprintf(stderr,
+ "[Overflowing] Ops, trying to retrieve para %d when max index is %d\n",
+ pEditEngine->GetOverflowingParaNum(),
+ GetParagraphCount()-1);
+ return NULL;
+ }
+
+ sal_Int32 nHeadPara = pEditEngine->GetOverflowingParaNum();
+ sal_uInt32 nParaCount = GetParagraphCount();
+
+ sal_uInt32 nLen = 0;
+ for ( sal_Int32 nLine = 0;
+ nLine < pEditEngine->GetOverflowingLineNum();
+ nLine++) {
+ nLen += GetLineLen(nHeadPara, nLine);
+ }
+
+ sal_uInt32 nOverflowingPara = pEditEngine->GetOverflowingParaNum();
+ ESelection aOverflowingTextSel;
+ sal_Int32 nLastPara = nParaCount-1;
+ sal_Int32 nLastParaLen = GetText(GetParagraph(nLastPara)).getLength();
+ aOverflowingTextSel = ESelection(nOverflowingPara, nLen,
+ nLastPara, nLastParaLen);
+ return new OverflowingText(pEditEngine->CreateTransferable(aOverflowingTextSel));
+
+}
+
+void Outliner::ClearOverflowingParaNum()
+{
+ pEditEngine->ClearOverflowingParaNum();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */