srcedtw.cxx (efeef26f) srcedtw.cxx (7a980842)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 50 unchanged lines hidden (view full) ---

59#include <helpid.h>
60#endif
61#include <deque>
62
63
64
65struct SwTextPortion
66{
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 50 unchanged lines hidden (view full) ---

59#include <helpid.h>
60#endif
61#include <deque>
62
63
64
65struct SwTextPortion
66{
67 sal_uInt16 nLine;
67 sal_uInt32 nLine;
68 sal_uInt16 nStart, nEnd;
69 svtools::ColorConfigEntry eType;
70};
71
72#define MAX_SYNTAX_HIGHLIGHT 20
73#define MAX_HIGHLIGHTTIME 200
74#define SYNTAX_HIGHLIGHT_TIMEOUT 200
75

--- 540 unchanged lines hidden (view full) ---

616
617IMPL_LINK( SwSrcEditWindow, SyntaxTimerHdl, Timer *, pTimer )
618{
619 Time aSyntaxCheckStart;
620 DBG_ASSERT( pTextView, "Noch keine View, aber Syntax-Highlight ?!" );
621 // pTextEngine->SetUpdateMode( sal_False );
622
623 bHighlighting = sal_True;
68 sal_uInt16 nStart, nEnd;
69 svtools::ColorConfigEntry eType;
70};
71
72#define MAX_SYNTAX_HIGHLIGHT 20
73#define MAX_HIGHLIGHTTIME 200
74#define SYNTAX_HIGHLIGHT_TIMEOUT 200
75

--- 540 unchanged lines hidden (view full) ---

616
617IMPL_LINK( SwSrcEditWindow, SyntaxTimerHdl, Timer *, pTimer )
618{
619 Time aSyntaxCheckStart;
620 DBG_ASSERT( pTextView, "Noch keine View, aber Syntax-Highlight ?!" );
621 // pTextEngine->SetUpdateMode( sal_False );
622
623 bHighlighting = sal_True;
624 sal_uInt16 nLine;
624 sal_uInt32 nLine;
625 sal_uInt16 nCount = 0;
626 // zuerst wird der Bereich um dem Cursor bearbeitet
627 TextSelection aSel = pTextView->GetSelection();
625 sal_uInt16 nCount = 0;
626 // zuerst wird der Bereich um dem Cursor bearbeitet
627 TextSelection aSel = pTextView->GetSelection();
628 sal_uInt16 nCur = (sal_uInt16)aSel.GetStart().GetPara();
628 sal_uInt32 nCur = aSel.GetStart().GetPara();
629 if(nCur > 40)
630 nCur -= 40;
631 else
632 nCur = 0;
633 if(aSyntaxLineTable.Count())
634 for(sal_uInt16 i = 0; i < 80 && nCount < 40; i++, nCur++)
635 {
636 void * p = aSyntaxLineTable.Get(nCur);

--- 11 unchanged lines hidden (view full) ---

648 }
649 }
650 }
651
652 // wenn dann noch etwas frei ist, wird von Beginn an weitergearbeitet
653 void* p = aSyntaxLineTable.First();
654 while ( p && nCount < MAX_SYNTAX_HIGHLIGHT)
655 {
629 if(nCur > 40)
630 nCur -= 40;
631 else
632 nCur = 0;
633 if(aSyntaxLineTable.Count())
634 for(sal_uInt16 i = 0; i < 80 && nCount < 40; i++, nCur++)
635 {
636 void * p = aSyntaxLineTable.Get(nCur);

--- 11 unchanged lines hidden (view full) ---

648 }
649 }
650 }
651
652 // wenn dann noch etwas frei ist, wird von Beginn an weitergearbeitet
653 void* p = aSyntaxLineTable.First();
654 while ( p && nCount < MAX_SYNTAX_HIGHLIGHT)
655 {
656 nLine = (sal_uInt16)aSyntaxLineTable.GetCurKey();
656 nLine = (sal_uInt32)aSyntaxLineTable.GetCurKey();
657 DoSyntaxHighlight( nLine );
657 DoSyntaxHighlight( nLine );
658 sal_uInt16 nCurKey = (sal_uInt16)aSyntaxLineTable.GetCurKey();
659 p = aSyntaxLineTable.Next();
658 p = aSyntaxLineTable.Next();
660 aSyntaxLineTable.Remove(nCurKey);
659 aSyntaxLineTable.Remove(nLine);
661 nCount ++;
662 if(Time().GetTime() - aSyntaxCheckStart.GetTime() > MAX_HIGHLIGHTTIME)
663 {
664 pTimer->SetTimeout( 2 * SYNTAX_HIGHLIGHT_TIMEOUT );
665 break;
666 }
667 }
668 // os: #43050# hier wird ein TextView-Problem umpopelt:

--- 18 unchanged lines hidden (view full) ---

687 bHighlighting = sal_False;
688
689 return 0;
690}
691/*-----------------15.01.97 10.01-------------------
692
693--------------------------------------------------*/
694
660 nCount ++;
661 if(Time().GetTime() - aSyntaxCheckStart.GetTime() > MAX_HIGHLIGHTTIME)
662 {
663 pTimer->SetTimeout( 2 * SYNTAX_HIGHLIGHT_TIMEOUT );
664 break;
665 }
666 }
667 // os: #43050# hier wird ein TextView-Problem umpopelt:

--- 18 unchanged lines hidden (view full) ---

686 bHighlighting = sal_False;
687
688 return 0;
689}
690/*-----------------15.01.97 10.01-------------------
691
692--------------------------------------------------*/
693
695void SwSrcEditWindow::DoSyntaxHighlight( sal_uInt16 nPara )
694void SwSrcEditWindow::DoSyntaxHighlight( sal_uInt32 nPara )
696{
697 // Durch das DelayedSyntaxHighlight kann es passieren,
698 // dass die Zeile nicht mehr existiert!
699 if ( nPara < pTextEngine->GetParagraphCount() )
700 {
701 sal_Bool bTempModified = IsModified();
702 pTextEngine->RemoveAttribs( nPara, (sal_Bool)sal_True );
703 String aSource( pTextEngine->GetText( nPara ) );

--- 14 unchanged lines hidden (view full) ---

718 ClearModifyFlag();
719 }
720}
721
722/*-----------------15.01.97 09.49-------------------
723
724--------------------------------------------------*/
725
695{
696 // Durch das DelayedSyntaxHighlight kann es passieren,
697 // dass die Zeile nicht mehr existiert!
698 if ( nPara < pTextEngine->GetParagraphCount() )
699 {
700 sal_Bool bTempModified = IsModified();
701 pTextEngine->RemoveAttribs( nPara, (sal_Bool)sal_True );
702 String aSource( pTextEngine->GetText( nPara ) );

--- 14 unchanged lines hidden (view full) ---

717 ClearModifyFlag();
718 }
719}
720
721/*-----------------15.01.97 09.49-------------------
722
723--------------------------------------------------*/
724
726void SwSrcEditWindow::DoDelayedSyntaxHighlight( sal_uInt16 nPara )
725void SwSrcEditWindow::DoDelayedSyntaxHighlight( sal_uInt32 nPara )
727{
728 if ( !bHighlighting && bDoSyntaxHighlight )
729 {
730 aSyntaxLineTable.Insert( nPara, (void*)(sal_uInt16)1 );
731 aSyntaxIdleTimer.Start();
732 }
733}
734
735/*-----------------15.01.97 11.32-------------------
736
737--------------------------------------------------*/
738
726{
727 if ( !bHighlighting && bDoSyntaxHighlight )
728 {
729 aSyntaxLineTable.Insert( nPara, (void*)(sal_uInt16)1 );
730 aSyntaxIdleTimer.Start();
731 }
732}
733
734/*-----------------15.01.97 11.32-------------------
735
736--------------------------------------------------*/
737
739void SwSrcEditWindow::ImpDoHighlight( const String& rSource, sal_uInt16 nLineOff )
738void SwSrcEditWindow::ImpDoHighlight( const String& rSource, sal_uInt32 nLineOff )
740{
741 SwTextPortions aPortionList;
742 lcl_Highlight(rSource, aPortionList);
743
744 size_t nCount = aPortionList.size();
745 if ( !nCount )
746 return;
747

--- 14 unchanged lines hidden (view full) ---

762 if ( bOptimizeHighlight )
763 {
764 // Es muessen nur die Blanks und Tabs mit attributiert werden.
765 // Wenn zwei gleiche Attribute hintereinander eingestellt werden,
766 // optimiert das die TextEngine.
767 sal_uInt16 nLastEnd = 0;
768
769#ifdef DBG_UTIL
739{
740 SwTextPortions aPortionList;
741 lcl_Highlight(rSource, aPortionList);
742
743 size_t nCount = aPortionList.size();
744 if ( !nCount )
745 return;
746

--- 14 unchanged lines hidden (view full) ---

761 if ( bOptimizeHighlight )
762 {
763 // Es muessen nur die Blanks und Tabs mit attributiert werden.
764 // Wenn zwei gleiche Attribute hintereinander eingestellt werden,
765 // optimiert das die TextEngine.
766 sal_uInt16 nLastEnd = 0;
767
768#ifdef DBG_UTIL
770 sal_uInt16 nLine = aPortionList[0].nLine;
769 sal_uInt32 nLine = aPortionList[0].nLine;
771#endif
772 for ( size_t i = 0; i < nCount; i++ )
773 {
774 SwTextPortion& r = aPortionList[i];
775 DBG_ASSERT( r.nLine == nLine, "doch mehrere Zeilen ?" );
776 if ( r.nStart > r.nEnd ) // Nur bis Bug von MD behoeben
777 continue;
778

--- 15 unchanged lines hidden (view full) ---

794 if ( r.nStart > r.nEnd ) // Nur bis Bug von MD behoeben
795 continue;
796 if(r.eType != svtools::HTMLSGML &&
797 r.eType != svtools::HTMLCOMMENT &&
798 r.eType != svtools::HTMLKEYWORD &&
799 r.eType != svtools::HTMLUNKNOWN)
800 r.eType = svtools::HTMLUNKNOWN;
801 Color aColor((ColorData)SW_MOD()->GetColorConfig().GetColorValue((svtools::ColorConfigEntry)r.eType).nColor);
770#endif
771 for ( size_t i = 0; i < nCount; i++ )
772 {
773 SwTextPortion& r = aPortionList[i];
774 DBG_ASSERT( r.nLine == nLine, "doch mehrere Zeilen ?" );
775 if ( r.nStart > r.nEnd ) // Nur bis Bug von MD behoeben
776 continue;
777

--- 15 unchanged lines hidden (view full) ---

793 if ( r.nStart > r.nEnd ) // Nur bis Bug von MD behoeben
794 continue;
795 if(r.eType != svtools::HTMLSGML &&
796 r.eType != svtools::HTMLCOMMENT &&
797 r.eType != svtools::HTMLKEYWORD &&
798 r.eType != svtools::HTMLUNKNOWN)
799 r.eType = svtools::HTMLUNKNOWN;
800 Color aColor((ColorData)SW_MOD()->GetColorConfig().GetColorValue((svtools::ColorConfigEntry)r.eType).nColor);
802 sal_uInt16 nLine = nLineOff+r.nLine; //
801 sal_uInt32 nLine = nLineOff+r.nLine; //
803 pTextEngine->SetAttrib( TextAttribFontColor( aColor ), nLine, r.nStart, r.nEnd+1, sal_True );
804 }
805}
806
807/*-----------------30.06.97 09:12-------------------
808
809--------------------------------------------------*/
810

--- 12 unchanged lines hidden (view full) ---

823 if ( (long)pTextEngine->GetTextHeight() < pOutWin->GetOutputSizePixel().Height() )
824 pTextView->Scroll( 0, pTextView->GetStartDocPos().Y() );
825 pVScrollbar->SetThumbPos( pTextView->GetStartDocPos().Y() );
826 SetScrollBarRanges();
827 }
828 else if( ( rTextHint.GetId() == TEXT_HINT_PARAINSERTED ) ||
829 ( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED ) )
830 {
802 pTextEngine->SetAttrib( TextAttribFontColor( aColor ), nLine, r.nStart, r.nEnd+1, sal_True );
803 }
804}
805
806/*-----------------30.06.97 09:12-------------------
807
808--------------------------------------------------*/
809

--- 12 unchanged lines hidden (view full) ---

822 if ( (long)pTextEngine->GetTextHeight() < pOutWin->GetOutputSizePixel().Height() )
823 pTextView->Scroll( 0, pTextView->GetStartDocPos().Y() );
824 pVScrollbar->SetThumbPos( pTextView->GetStartDocPos().Y() );
825 SetScrollBarRanges();
826 }
827 else if( ( rTextHint.GetId() == TEXT_HINT_PARAINSERTED ) ||
828 ( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED ) )
829 {
831 DoDelayedSyntaxHighlight( (sal_uInt16)rTextHint.GetValue() );
830 DoDelayedSyntaxHighlight( rTextHint.GetValue() );
832 }
833 }
834}
835
836void SwSrcEditWindow::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, sal_uInt32 )
837{
838 if( pBrdCst == pSourceViewConfig)
839 SetFont();

--- 256 unchanged lines hidden ---
831 }
832 }
833}
834
835void SwSrcEditWindow::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, sal_uInt32 )
836{
837 if( pBrdCst == pSourceViewConfig)
838 SetFont();

--- 256 unchanged lines hidden ---