[api-dev] Inserting GraphicObjects in tablecells in oWriter

2009-07-01 Thread Steffen Boersig

Hi,

i'm currently trying to solve my problem with tablecells.
I managed to get my GraphicObjects into my oWriter files with help of 
snippets, mainly with


http://codesnippets.services.openoffice.org/Writer/Writer.EmbedAGraphicIntoATextdocument.snip

To determine the position where to anchor the image, I'm using 
placeholders as normal strings within my oWriter file.

A XTextCursor is placed onto that placeholder and ist used for

text.insertTextContent(cursor, xTextContent, true);

Runs smoothly except for the fact, that if my placeholder is within a 
table I'm getting a RuntimeException with no further details.
After some research online I've found several approaches to that 
problem. One which suggests using the method


getCellParagraph($cell)

to get an anchor to that specific cell. Problem is, there is no 
getCellParagraph() method in the API of OOo.

Maybe it was an older approach.
The second approach I found suggests using Shapes to add them to 
DrawPages. I couldn't figure out to make that one work, maybe because it 
was suggested for oCalc instead of oWriter. But I don't know if it 
should work in oWriter the same way and I'm just too dumb to use it.

That one was discussed here:

http://api.openoffice.org/servlets/ReadMsg?listName=devmsgNo=2618

So my questions are:
(1) Is it possible to use insertTextContent with images in tablecells 
when I'm in oWriter? And what do I have to change to make it work? When 
not, why isn't it possible?
(2) Is using Shapes also the way to go for oWriter if I'm trying to get 
images into tablecells?
(3) What mehtod is used if I manually insert images into cells with the 
oWriter GUI?


Thanks in advance.

Steffen Boersig


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



Re: [api-dev] Inserting GraphicObjects in tablecells in oWriter

2009-07-01 Thread Fernand Vanrie

Steffen,

please find the basic code who inserts graphics in Tablecells using the 
cell dimensions to dimensioning the grapgics.
Finding the dimensions off a cell can be tricky when cells are merged 
ect.. therefore i use the dificult to read :-)firts part of the code


hope it helps

Fernand

   oText = oDocument.text
  RasterofCursor = True
   oViewCursor = oDocument.getCurrentController().getViewCursor()
'xray oviewcursor
   If Not isEmpty(oViewCursor.TextTable) then  ' Cursor is in een Tabel
'   sFrameofTabel = TABEL
 '  inFRameofTabel = true
 '  RasterofCursor = False
   Twidth = oViewCursor.TextTable.width
   TTotalpercent = oViewCursor.TextTable.TableColumnRelativeSum
   startcell = oViewCursor.cell.cellname
   Kindex = asc(left(oViewCursor.cell.cellname,1))-65
   Rindex = int(mid(oViewCursor.cell.cellname,2,2))-1
   CurRow = oViewCursor.texttable.rows.getbyindex(Rindex)
   if CurRow.IsAutoHeight = True then
   msgbox De ROWhooghte moet FIXED zijn !  chr(13)  Eerst 
aanpassen, dan pas kan je verder

   exit sub
   end if
if 
oViewCursor.cell.compareRegionStarts(oViewCursor.cell.getstart,oViewCursor.cell.getend) 
 0 or oViewCursor.cell.string  then
   msgbox  er mag in de cell enkel één  chr(13)  RETURN staan  
chr(13)  Eerst aanpassen, dan pas kan je verder

  exit sub
   endif
   if oViewCursor.paraStylename  Standard then
   msgbox de ParaGraphStyle in de Tabelcell staat niet op default  
chr(13)  wordt nu automatisch aangepast !!

   oViewCursor.ParaStyleName = Standard
   end if
   if oViewCursor.CharStylenamethen
   msgbox de CharacterStyle in de Tabelcell staat niet op default  
chr(13)  wordt nu automatisch aangepast !!

oViewCursor.setPropertyToDefault(CharStyleName)
   end if

   if oViewCursor.texttable.Horiorient = 6 then
   msgbox  De Table mag niet AUTOMATISCH gealigneerd zijn  chr(13)  
wordt nu automatisch aangepast naar center !!

oViewCursor.texttable.Horiorient = 2
   end if

   
  ' welke cell ??
   startcellname = oViewCursor.cell.cellname  
   startrow = int(mid(startcellname,2,2))

   if  oViewCursor.cell.VertOrient  2 then
   msgbox Cursor staat niet in de HOOGTE gecentreerd  chr(13)  
wordt nu automatisch aangepast !!

   oViewCursor.cell.VertOrient = 2
   end if
  if  oViewCursor.cell.createEnumeration.nextelement.paraAdjust  3 then
   msgbox Tabelcell-Cursor is Niet in de BREEDTE gecentreerd  
chr(13)  wordt nu automatisch aangepast !!

oViewCursor.cell.createEnumeration.nextelement.paraAdjust = 3
end if
   
 oViewcursor.goDOWN(1,false) ' de tabel MOET in een FRame 
zitten anders problemen bij de onderste rij !

 if isEmpty(oViewCursor.TextTable) then

 startcellpos = ONDER
 oViewcursor.goUP(1,false)

end if

   
if startcellpos = ONDER then

'eerst terug naar startcell
otext = oviewcursor.texttable.getcellbyname(startcellname,true).text
  
otabelCursor = oText.createTextCursor()
   
oViewcursor.gotorange(otabelCursor,false)

'  xray oViewcursor
 If otext.supportsService(com.sun.star.text.Paragraph) then
  print is paragraaf
  exit sub
  end if

laatsterow = oViewCursor.TextTable.rows.count
if laatsterow = int(mid(oViewCursor.cell.cellname,2,2)) then ' cell 
is één row hoog

iFotH = oViewCursor.texttable.rows.getbyindex(Rindex).height
else
   for i= 0 to laatsterow - int(mid(oViewCursor.cell.cellname,2,2))
iFotH = iFotH + oViewCursor.texttable.rows.getbyindex(Rindex+ i 
).height

next i
end if
  
  
else 'cell boven of midden

' eerst terug naar de startcell
otext =  oviewcursor.texttable.getcellbyname(startcellname,true).text
   
   
otabelCursor = oText.createTextCursor()

oViewcursor.gotorange(otabelCursor,false)
startrow = int(mid(oViewCursor.cell.cellname,2,2))
oViewcursor.goDOWN(1,false)
   volgenderow = int(mid(oViewCursor.cell.cellname,2,2))
   
 if isEmpty(oViewCursor.TextTable) then 'terug naar binnen de tabel

oViewcursor.goUP(1,false)
end if
 ' terug naar de startcell
otext = oviewcursor.texttable.getcellbyname(startcellname,true).text
otabelCursor = oText.createTextCursor()
oViewcursor.gotorange(otabelCursor,false)
for i= 1 to volgenderow - startrow
iFotH = iFotH + oViewCursor.texttable.rows.getbyindex(Rindex + i-1 
).height


next i
  
endif


  ' iFotH = CurRow.height
  


   tabstops = CurRow.TableColumnSeparators()
   
  if uBound(tabstops) 0 then

   iFotW = tWidth
   else
 
   if kindex = 0 then

   iFotW = (twidth * tabstops(Kindex).position/TTotalpercent)
   elseif kindex -1 = ubound(tabstops) then
   iFotW = twidth - (twidth * 
tabstops(Kindex-1).position/TTotalpercent)
   else  
   iFotW = (twidth * tabstops(Kindex).position/TTotalpercent) - 
(twidth * tabstops(Kindex-1).position/TTotalpercent)

   endif
   end if
 
  
   otext = oViewCursor.text


[api-dev] Focus window to the view cursor

2009-07-01 Thread Andrew Douglas Pitonyak


I move the view cursor in a Write document and then the cursor is no 
longer visible. What is the trick to move the view so that I can see the 
view cursor.  If I manually press a key to move the cursor, then the 
view changes so that I can see the cursor. I just cannot remember how to 
do this from StarBasic.


--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html


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