To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=100662
                 Issue #|100662
                 Summary|Writer: Incorrect number of pages when xComponent is l
                        |oaded with hidden property
               Component|api
                 Version|OOo 3.0.1
                Platform|PC
                     URL|
              OS/Version|Windows XP
                  Status|UNCONFIRMED
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|DEFECT
                Priority|P3
            Subcomponent|code
             Assigned to|jsc
             Reported by|backfin





------- Additional comments from back...@openoffice.org Mon Mar 30 07:06:51 
+0000 2009 -------
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.

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@api.openoffice.org
For additional commands, e-mail: issues-h...@api.openoffice.org


---------------------------------------------------------------------
To unsubscribe, e-mail: allbugs-unsubscr...@openoffice.org
For additional commands, e-mail: allbugs-h...@openoffice.org

Reply via email to