Hi Skyler,
if you want to access the page number at the currently selected position
in the document, you'll have to first get the current selection
(http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/Component/Controllers#XSelectionSupplier),
figure
if there's actually a *point* in the document selected (otherwise the
selection might span multiple pages), the create a
com.sun.star.text.TextLayoutCursor, which provides an XPageCursor
interface, which in turns provides a method to tell which page you're
currently on.
It might well be possible that the current page number is also exposed
as a property of an TextRange service that might be returned by
XSelectionSupplier.getSelection (if a textrange and not something else,
a frame object for example, is currently selected).
Getting this right for every possible type of selection aint trivial, by
the way.
Good luck,
Peter
The interesting thing's IMHO the
Am 28.03.11 05:33, schrieb Skyler Hawthorne:
Hello all,
I am working on the EasyHack "Print current page" (
http://wiki.documentfoundation.org/Easy_Hacks#Print_current_page ), and
I need a little help. I believe I've found out how to change the default
value:
In PrintDialog::setupOptionalUI, it appears the default text for the
page range edit box is set on line 1507 (
http://opengrok.libreoffice.org/xref/libs-gui/vcl/source/window/printdlg.cxx#1507
). As a test, I commented out line #1516, where it actually sets the
string value for the edit box, and added:
rtl::OUString curActivePageNum( RTL_CONSTASCII_USTRINGPARAM("2") );
pField->SetText( curActivePageNum );
maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
"PageRange" ) ), makeAny( curActivePageNum ) );
And that sets the PrinterController's PageRange property to 2, and sets
it as the default value for the edit box.
Now, I just need to be able to access the current document's page
number. However, I've been digging through this code all weekend, and I
cannot find anything that stores that value. Is it some other
PropertyValue stored in maPController? If so, what is the name? Is there
some static function that can access information about the current
document?
Any help is much appreciated.
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.