| View previous topic :: View next topic |
| Author |
Message |
tdiaz General User

Joined: 04 Jun 2005 Posts: 9
|
Posted: Mon Jul 04, 2005 10:29 am Post subject: how get the text of headers and footers in C++ ? |
|
|
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 |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8979 Location: Lexinton, Kentucky, USA
|
Posted: Tue Jul 05, 2005 8:06 am Post subject: |
|
|
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 |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
Posted: Tue Jul 05, 2005 9:01 am Post subject: |
|
|
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 ) _________________ 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 |
|
 |
tdiaz General User

Joined: 04 Jun 2005 Posts: 9
|
Posted: Tue Jul 05, 2005 11:27 pm Post subject: thankyou, I am trying all the possibilities explained |
|
|
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 |
|
 |
tdiaz General User

Joined: 04 Jun 2005 Posts: 9
|
Posted: Wed Jul 06, 2005 2:40 am Post subject: header and footers in c++ , copy it to code snippets please |
|
|
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
tony |
|
| Back to top |
|
 |
|