Issue 100662

Summary: Writer: Incorrect number of pages and hidden property
Product: App Dev Reporter: backfin <backfin>
Component: apiAssignee: AOO issues mailing list <issues>
Status: UNCONFIRMED --- QA Contact:
Severity: Trivial    
Priority: P3 CC: issues
Version: 3.3.0 or older (OOo)   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---

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".