[Solved Elsewhere] Is there any API opposite of EOF?

Creating a macro - Writing a Script - Using the API

[Solved Elsewhere] Is there any API opposite of EOF?

Postby rajibando » Mon Jul 31, 2017 2:10 pm

Please peruse this API on EOF.
Is there any API opposite of EOF? Like the Boolean testing of the Beginning Of File? And Going to the BOF? It is very much required! Because I want a second search from the beginning of the file after the first ends at the EOF.
Last edited by rajibando on Mon Aug 28, 2017 4:56 am, edited 2 times in total.
LibreOffice 4.0.3.3 (Build ID: 400m0(Build:3)) in Knoppix 7.2.0
rajibando
 
Posts: 52
Joined: Sat Jul 29, 2017 4:59 am

Re: Is there any API opposite of EOF?

Postby JeJe » Mon Jul 31, 2017 3:25 pm

Openoffice 4.1.2
Windows 8
JeJe
 
Posts: 122
Joined: Wed Mar 09, 2016 2:40 pm

Re: Is there any API opposite of EOF?

Postby rajibando » Mon Jul 31, 2017 3:57 pm

Searched for examples, and read and found these codes here:
Code: Select all   Expand viewCollapse view
uno::Any aRet = cppu::queryInterface( rType,
                                          (static_cast< io::XInputStream* >(this)),
                                          (static_cast< io::XSeekable* >(this)) );
The user mohitchugh never visited the forum again, so the case of PMing him or Helmar, who visited only twice, to learn doesn't arise.

How to use them here to bring the pointer/cursor to the beginning of the file before running the following function? :
Code: Select all   Expand viewCollapse view
    REM Reiteration to remove empty paras after above action
        Function Writer_ReplaceAll_Blank_Paras() As Long
        Dim bReplace as Object
        bReplace = ThisComponent.createReplaceDescriptor()
        bReplace.setSearchString( chr(10) + "^$" )
        bReplace.setReplaceString( chr(10)  )
        bReplace.SearchRegularExpression = True
        Writer_ReplaceAll_Blank_Paras = ThisComponent.replaceAll( bReplace )
       End Function
Last edited by rajibando on Mon Jul 31, 2017 6:32 pm, edited 1 time in total.
LibreOffice 4.0.3.3 (Build ID: 400m0(Build:3)) in Knoppix 7.2.0
rajibando
 
Posts: 52
Joined: Sat Jul 29, 2017 4:59 am

Re: Is there any API opposite of EOF?

Postby FJCC » Mon Jul 31, 2017 5:10 pm

Input streams are not related to the find and replace functions in macros. The replaceAll() function will, as I understand it, search the entire document without any need to tell it where to start. I do see a problem with your SearchString. I don't see how chr(10) + "^$" can find anything. It represents a linefeed followed by an empty paragraph but a linefeed does not end a paragraph, so what is between the linefeed and the empty paragraph? Do you want to search for a linefeed at the end of a paragraph? That would be "\n$".
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 6168
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Is there any API opposite of EOF?

Postby rajibando » Mon Jul 31, 2017 6:13 pm

FJCC wrote: The replaceAll() function will ... search the entire document without any need to tell it where to start

Okay, that is great! So I will not have to work on that code that much! Thanks!
I just wanted to incorporate that pattern, I did not want to involve you as Zizi is handling that post.
The post is here: A Specific Macro with Find-Replace?
...
FJCC wrote:... I don't see how chr(10) + "^$" can find anything...

Okay, please look at the attached file:
WhatIwant.odt
What I need is to remove the empty ¶ mark just after the ↲
(11.31 KiB) Downloaded 16 times
, you shalll see the need for that particular string "↲¶", where ¶ is the empty paragraph "^$" in my text to be removed.
LibreOffice 4.0.3.3 (Build ID: 400m0(Build:3)) in Knoppix 7.2.0
rajibando
 
Posts: 52
Joined: Sat Jul 29, 2017 4:59 am

Re: Is there any API opposite of EOF?

Postby FJCC » Mon Jul 31, 2017 9:11 pm

Perhaps we are using different terminology but I don't see any empty paragraphs in your document. When I view it with non-printing characters visible, I see a mixture of line feeds (↲) and paragraph marks (¶) and in no case does a line feed come immediately before a paragraph mark.

ParaMarks.JPG

Do you want to replace all ¶ with ↲? That will convert your document to a single paragraph, which can cause problems because there is a limit to size of a paragraph. Searching for "$" and replacing with CHR(10) will do that.
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 6168
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Is there any API opposite of EOF?

Postby rajibando » Tue Aug 01, 2017 3:58 am

That one was the perfect file, manually edited.
The two are the initial 'Test' file, and the result of the macro application to output 'Tested' file.
You didn't look at the indicated thread, which Zizi is handling?
This macro is as follows:
Code: Select all   Expand viewCollapse view
rem *****************************************
Function Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds() As Long
REM Replaces all Paragraph breaks with a Linefeed character within the current Writer document.
REM Returns: the number of found/replaced occurrences.
    Dim oReplace as Object
    oReplace = ThisComponent.createReplaceDescriptor()
    oReplace.setSearchString( "[a-z,A-Z,0-9]$" )
    oReplace.setReplaceString( "&" + chr(10) )
    oReplace.SearchRegularExpression = True
    Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds = ThisComponent.replaceAll( oReplace )
    End Function

change_from_this to_this.jpeg
Change from 'this' to 'this', from file 'tested.odt' to 'whatIwant.odt'

test.odt
The initial file where ¶ are to be replaced by ↲
(11.27 KiB) Downloaded 22 times

tested.odt
The file after the present macro is run, replacing ¶ with ¶ ↲
(11.3 KiB) Downloaded 21 times

and after application of the macro
LibreOffice 4.0.3.3 (Build ID: 400m0(Build:3)) in Knoppix 7.2.0
rajibando
 
Posts: 52
Joined: Sat Jul 29, 2017 4:59 am


Return to Macros and UNO API

Who is online

Users browsing this forum: Google [Bot] and 11 guests