Hi Bartolomeo,

Thanks for your help. I have another problem I implemented the method below,
but only the first paragraph of the document are changed with the
properties. I need to set all document paragraphs to the properties into the
loop. Why this happens. Could you help me?

  public void testar (XComponent xComponent)
  {

    try
    {
      XTextDocument xTextDocument = (XTextDocument)
      UnoRuntime.queryInterface(XTextDocument.class, xComponent);

      XText xText = xTextDocument.getText();
      XTextCursor curText = xText.createTextCursor();

        // get the XPropertySet interface of cursor.
      XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(
            XPropertySet.class, curText);

      /*while (eoParagraph.hasMoreElements()) 
      {     
      XPropertySet xCursorProps =
(XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,curText); 
     
xCursorProps.setPropertyValue("CharPosture",com.sun.star.awt.FontSlant.ITALIC); 
      xCursorProps.setPropertyValue("CharWeight",new
Float(com.sun.star.awt.FontWeight.BOLD) ); 
      xCursorProps.setPropertyValue("CharFontName","Arial" ); 
      xCursorProps.setPropertyValue("ParaAdjust",ParagraphAdjust.BLOCK); 
      curText.getEnd();
   
      }*/
      // get the XEnumerationAccess interface
      XEnumerationAccess enumText = (XEnumerationAccess)
        UnoRuntime.queryInterface(XEnumerationAccess.class, xText);

      // Call the method to get the XEnumeration service
      XEnumeration eoParagraph = enumText.createEnumeration();      
      
      // While there are paragraphs, do things to them
     while (eoParagraph.hasMoreElements()) 
      {
        XServiceInfo xInfo = (XServiceInfo) UnoRuntime.queryInterface(
                XServiceInfo.class, eoParagraph.nextElement());
        XPropertySet xSet = (XPropertySet)UnoRuntime.
         queryInterface(XPropertySet.class, xInfo);
    
        xSet.setPropertyValue("ParaLeftMargin", new Integer(200));
        xSet.setPropertyValue("ParaFirstLineIndent", new Integer(2500));
        LineSpacing linha = new LineSpacing();
        linha.Height = 150;
        linha.Mode = LineSpacingMode.PROP;
        xSet.setPropertyValue("ParaLineSpacing", linha);
        xSet.setPropertyValue("ParaAdjust", ParagraphAdjust.BLOCK);
        xSet.setPropertyValue("ParaRightMargin", new Integer(100));
       
     }

      
  } catch (UnknownPropertyException e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (PropertyVetoException e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IllegalArgumentException e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (WrappedTargetException e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (Exception e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
}



Bartolomeo Mastromarco wrote:
> 
> aloizio wrote:
>> I need to change via OO API the following parameters 
>>
>> LineSpacing
>>
>> ParaFirstLineIndent
>>
>> ParaVertAlignment
>>
>>
>>   
> hi,
> 
> this is the code for you:
> 
> XStyle xStyle = (XStyle)UnoRuntime.queryInterface (
>                         XStyle.class, 
> this.xMultiServiceFactory.createInstance(
>                         "com.sun.star.style.ParagraphStyle"));
> 
> XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface (
>                     XPropertySet.class, xStyle);
> 
> 
> //1)
> if(lineSpacing.equals("Single"))
>         {
>             
> xPropertySet.setPropertyValue("ParaLineNumberCount",Boolean.TRUE);
>            
>             LineSpacing linespacing = new LineSpacing();
>             linespacing.Mode = (short)Lines.Mode;
>             linespacing.Height = (short)Lines.Single;
>             xPropertySet.setPropertyValue("ParaLineSpacing",linespacing);
>         }
>         else if(lineSpacing.equals("1.5 lines"))
>         {
>             
> xPropertySet.setPropertyValue("ParaLineNumberCount",Boolean.TRUE);
>             LineSpacing linespacing = new LineSpacing();
>             linespacing.Mode = (short)Lines.Mode;
>             linespacing.Height = (short)Lines.halfLine;
>             xPropertySet.setPropertyValue("ParaLineSpacing",linespacing);
>         }
>         else if(lineSpacing.equals("Double"))
>         {
>             
> xPropertySet.setPropertyValue("ParaLineNumberCount",Boolean.TRUE);
>             LineSpacing linespacing = new LineSpacing();
>             linespacing.Mode = (short)Lines.Mode;
>             linespacing.Height = (short)Lines.Double;
>             xPropertySet.setPropertyValue("ParaLineSpacing",linespacing);
>         }
> 
> 
> //2)
> xPropertySet.setPropertyValue("ParaFirstLineIndent",new 
> Integer((int)(value*1000)));
> 
> //3)
> to you..............
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-apply-Paragraph-Style-to-XTextDocument--tf2597290.html#a7318396
Sent from the openoffice - api dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to