OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

how get the text of headers and footers in C++ ?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer
View previous topic :: View next topic  
Author Message
tdiaz
General User
General User


Joined: 04 Jun 2005
Posts: 9

PostPosted: Mon Jul 04, 2005 10:29 am    Post subject: how get the text of headers and footers in C++ ? Reply with quote

Hello to all

I need to know if the user has the selection cursor (or whichever name you want
to give to the cursor that is visible and that selects text) in the header or in the
footer of the current page. How can I do that in C++ ?
If that can not be done, At least I need to access the text of the header and footer
of the current page.
I have been trying to get there but documentation about that is very sparse
and with no details in the SDK.

SDK docs explains about the properties:
Code:
 Header
 HeaderLeft
 HeaderRight
and similar ones for footers, but I dont know how to obtain those properties.

thanks in advance
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Tue Jul 05, 2005 4:50 am    Post subject: Reply with quote

a quick search effectively doesn't allow me to find the IDL corresponding file.
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Tue Jul 05, 2005 8:06 am    Post subject: Reply with quote

I can't help you with C++ but here is a way to determine if the cursor is in a normal header and then get the header text in Basic.
Code:
Sub Main
oDoc = thisComponent
oVC = oDoc.CurrentController.getViewCursor
If oVC.ParaStyleName = "Header" then
 oVC.gotoStart(false)
 Do
  oVC.gotoEndOfLine(true)
  Print oVC.String
  oVC.collapseToStart
 Loop While oVC.goDown(1,false)
EndIf 
End Sub

Hope this helps you in some way.

EDIT - I've been playing around and here is another way to get the header text.
Code:
Sub Main
oDoc = thisComponent
oVC = oDoc.CurrentController.getViewCursor
If oVC.ParaStyleName = "Header" then
 oPageStyles = oDoc.StyleFamilies.getByName("PageStyles")
 thisPage = oPageStyles.getByName(oVC.PageStyleName)
 HeaderText =  thisPage.HeaderText.String
 MsgBox HeaderText
EndIf 
End Sub
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Tue Jul 05, 2005 9:01 am    Post subject: Reply with quote

To complete JohnV answer here is ParagraphProperties.idl file :
Code:

module com {  module sun {  module star {  module style {
service ParagraphProperties
{
   [property] com::sun::star::style::ParagraphAdjust ParaAdjust;
   //-------------------------------------------------------------------------

   [optional, property] string ParaStyleName;
   
       //-------------------------------------------------------------------------

};
}; }; }; };

where you can see ParaStyleName property. If you know how to set/get properties in C++ I think it's easy to access header. (It's always easy without a try Laughing )
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
tdiaz
General User
General User


Joined: 04 Jun 2005
Posts: 9

PostPosted: Tue Jul 05, 2005 11:27 pm    Post subject: thankyou, I am trying all the possibilities explained Reply with quote

Hi, the subject says all.
I am an experienced developer in C++, but believe me that
the hardest part is just translating from StartBasic to C++,
as the StarBasic interpreter?, parser? makes a lot of
magic tricks to offer that great simplicity. The StarBasic code
should be supported by A LOT of code behind, or I am missing
something.
When I have the sollution I wil post it here.
thanks to all
tony
Back to top
View user's profile Send private message
tdiaz
General User
General User


Joined: 04 Jun 2005
Posts: 9

PostPosted: Wed Jul 06, 2005 2:40 am    Post subject: header and footers in c++ , copy it to code snippets please Reply with quote

Here is the way to get the name of the paragraph style used by a given text range:

Code:

 // range is the XTextRange we want to get its Paragraph Style
 Reference < XServiceInfo > siRange (range, UNO_QUERY);
 Reference < XPropertySet > psRange (range, UNO_QUERY);
 // ousParaStyleName will be the name of the Paragraph Style
 OUString ousParaStyleName;
 Reference < XPropertySetInfo > psiRange = psRange->getPropertySetInfo ();
 OUString ousParaStyle = OUString::createFromAscii ("ParaStyleName");
 Any anyParaStyleName = psRange->getPropertyValue (ousParaStyle);
 anyParaStyleName >>= ousParaStyleName;

Error handling omited for clarity.
Forgive any mistake in my texts as I am not native english speaker.
Now I am giving help back to those who may need it Very Happy
tony
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer All times are GMT - 8 Hours
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