wpcubed.com Forum Index wpcubed.com
WPCubed GmbH Support Forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Different header and footer depending on text on page:

 
Post new topic   Reply to topic    wpcubed.com Forum Index -> FAQ WPTools 3+4
View previous topic :: View next topic  
Author Message
wpsupport
Site Admin


Joined: 24 Oct 2003
Posts: 5658

PostPosted: Tue Nov 11, 2003 3:57 pm    Post subject: Different header and footer depending on text on page: Reply with quote

Create different header and footer as 'named' text:
Code:
  // Generate simplyfied header and footer
  WPRichText1.HeaderFooter.Get(wpIsHeader, wpraNamed, 'ONE').RtfText.AsString :=
    'Dies ist der Header ONE';
  WPRichText1.HeaderFooter.Get(wpIsHeader, wpraNamed, 'TWO').RtfText.AsString :=
    'Dies ist der Header TWO';
  WPRichText1.HeaderFooter.Get(wpIsHeader, wpraNamed, 'THREE').RtfText.AsString :=
    'Dies ist der Header THREE';
  WPRichText1.HeaderFooter.Get(wpIsFooter, wpraNamed, 'ONE').RtfText.AsString :=
    'Dies ist der Footer ONE';
  WPRichText1.HeaderFooter.Get(wpIsFooter, wpraNamed, 'TWO').RtfText.AsString :=
    'Dies ist der Footer TWO';
  WPRichText1.HeaderFooter.Get(wpIsFooter, wpraNamed, 'THREE').RtfText.AsString :=
    'Dies ist der Footer THREE';


In the event WPRichText1GetSpecialText you can activate one of the above texts using this code:

Code:
 if WPFindTxtOnPage(WPRichText1,par,lin,'ONE',true) then
  begin
     SpecialText := WPRichText1.HeaderFooter.Get(Kind, wpraNamed, 'ONE');
  end
  else if WPFindTxtOnPage(WPRichText1,par,lin,'TWO',true) then
  begin
     SpecialText := WPRichText1.HeaderFooter.Get(Kind, wpraNamed, 'TWO');
  end ..


The code above uses an utility function which checks if a certain text exists within one line on a certain page. If 'scan=true' it finds the text anywher in the line, otherwise only at the start.

Code:
function WPFindTxtOnPage(wp: TWPCustomRichText; apar: PTParagraph; alin: PTLine; Text: string; Scan: Boolean): Boolean;
var
  par: PTparagraph;
  lin: PTLine;
  len: INteger;
  pageno: Integer;
  i: Integer;
  pc: PChar;
begin
  if alin = nil then raise Exception.Create('Wrong param lin');
  pageno := alin^.pagenum;
  par := wp.FirstPar;
  len := Length(Text);
  Result := FALSE;
  while par <> nil do
  begin
    lin := par^.line;
    while lin <> nil do
    begin
      if lin^.pagenum = pageno then
      begin
         // Find the text anywhere in the line
        if Scan then
        begin
          pc := lin^.pc;
          for i := 0 to lin^.plen - len + 1 do
            if StrLComp(pc, PChar(text), len) = 0 then
            begin
              Result := TRUE;
              break;
            end else inc(pc);
        end
        else // Only expect text at start of line
          if StrLComp(lin^.pc, PChar(text), len) = 0 then Result := TRUE;   
        if Result then break;
      end;
      // Next
      lin := lin^.next;
    end;
    par := par^.next;
  end;
end;


NOTE: This unit will be in V4.2a and higher (unit WPRich.PAS)
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Leo W. Beckham



Joined: 26 Feb 2004
Posts: 1

PostPosted: Fri Feb 27, 2004 5:28 pm    Post subject: HEADERS FOOTERS BY PAGE KEYWORD DO NOT DISPLAY IN THE EDITOR Reply with quote

The code provided was implemented to get special text and four keywords were used to search for the header footers. Each keyword was found on the page and during print preview the headers and footers could be viewed but not in the open body of the editor.

When placing a keyword such as "ONE" on a page and backspacing out letters it could be seen that a print change was occuring in the header, and a small blur appeared as if the system was trying show the header. The blur would disappear when the full word was typed, for example as ONE; once the last letter was typed, the header cleared indicating that the read of the keyword was successful.

How can I get the headers and footers using code as provided in the solution to show in the body of the editor?
Back to top
View user's profile Send private message Send e-mail
vendre



Joined: 13 Sep 2006
Posts: 1

PostPosted: Wed Sep 13, 2006 6:27 pm    Post subject: Reply with quote

it has these functionalities in version 3?
Back to top
View user's profile Send private message
wpsupport
Site Admin


Joined: 24 Oct 2003
Posts: 5658

PostPosted: Fri Sep 15, 2006 2:37 am    Post subject: Reply with quote

Hi,

no in V3 you cannot do it. The best is V5 anyways since there the header and footer are editable WYSIWYG in page layout mode.

Julian
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    wpcubed.com Forum Index -> FAQ WPTools 3+4 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group