Issue 100662 - Writer: Incorrect number of pages and hidden property
Summary: Writer: Incorrect number of pages and hidden property
Status: UNCONFIRMED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC Windows XP
: P3 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-30 08:06 UTC by backfin
Modified: 2017-05-20 11:28 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description backfin 2009-03-30 08:06:51 UTC
I'm using following code (C#) to determine the number of pages in doc and docx 
files: 

Code: 
public static short GetPageCount(string path) 
      { 
         if (_componentLoader == null) 
            Initialize(); 

         XComponent xComponent = null; 
         int counter = 0; 

         while (xComponent == null) 
         { 
            try 
            { 
               string url = _urlConverter.getFileURLFromSystemPath
(Path.GetPathRoot(path), path); 
               xComponent = _componentLoader.loadComponentFromURL
(url, "_blank", 0, new PropertyValue[] { MakePropertyValue("Hidden", new uno.Any
(true)) }); 
            } 
            catch (DisposedException) 
            { 
               if (counter >= _maxRetries) 
                  throw; 

               Thread.Sleep(200 * counter); 
               Initialize(); 
            } 
            finally 
            { 
               counter++; 
            } 
         } 

         XTextDocument doc = (XTextDocument)xComponent; 
         XController controller = doc.getCurrentController(); 
         XPageCursor cursor = (XPageCursor)((XTextViewCursorSupplier)
controller).getViewCursor(); 

         cursor.jumpToLastPage(); 
         short result = cursor.getPage(); 

         return result; 
      } 

The purpose of Initialize and MakePropertyValue methods is evident.

Result is sometimes different then the actual number of pages (as rendered by 
swriter). The only workaround I've found is not specifying Hidden property when 
loading xComponent. It's not acceptable for many reasons.
Comment 1 jsc 2009-03-30 09:07:01 UTC
jsc -> od: after discussion with mba to you
Comment 2 backfin 2009-03-31 11:58:55 UTC
Looks like commenting 'MakePropertyValue("Hidden", new uno.Any
(true))' out doesn't resolve docx issue completely, but only reduces number of 
documents it's reproducible on
Comment 3 Marcus 2017-05-20 11:28:04 UTC
Reset assigne to the default "issues@openoffice.apache.org".