< prev index next >

src/java.desktop/share/classes/javax/swing/text/rtf/RTFReader.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1404         /* Other attributes are maintained directly in "attributes" */
1405 
1406         return attributes;
1407     }
1408 
1409     /**
1410      * Calculates the current paragraph attributes (with keys
1411      * as given in StyleConstants) from the current parser state.
1412      *
1413      * @return a newly created MutableAttributeSet.
1414      * @see StyleConstants
1415      */
1416     MutableAttributeSet currentParagraphAttributes()
1417     {
1418         /* NB if there were a mutableCopy() method we should use it */
1419         MutableAttributeSet bld = new SimpleAttributeSet(paragraphAttributes);
1420 
1421         Integer stateItem;
1422 
1423         /*** Tab stops ***/
1424         TabStop tabs[];
1425 
1426         tabs = (TabStop[])parserState.get("_tabs_immutable");
1427         if (tabs == null) {
1428             @SuppressWarnings("unchecked")
1429             Dictionary<Object, Object> workingTabs = (Dictionary)parserState.get("_tabs");
1430             if (workingTabs != null) {
1431                 int count = ((Integer)workingTabs.get("stop count")).intValue();
1432                 tabs = new TabStop[count];
1433                 for (int ix = 1; ix <= count; ix ++)
1434                     tabs[ix-1] = (TabStop)workingTabs.get(Integer.valueOf(ix));
1435                 parserState.put("_tabs_immutable", tabs);
1436             }
1437         }
1438         if (tabs != null)
1439             bld.addAttribute(Constants.Tabs, tabs);
1440 
1441         Style paragraphStyle = (Style)parserState.get("paragraphStyle");
1442         if (paragraphStyle != null)
1443             bld.setResolveParent(paragraphStyle);
1444 


   1 /*
   2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1404         /* Other attributes are maintained directly in "attributes" */
1405 
1406         return attributes;
1407     }
1408 
1409     /**
1410      * Calculates the current paragraph attributes (with keys
1411      * as given in StyleConstants) from the current parser state.
1412      *
1413      * @return a newly created MutableAttributeSet.
1414      * @see StyleConstants
1415      */
1416     MutableAttributeSet currentParagraphAttributes()
1417     {
1418         /* NB if there were a mutableCopy() method we should use it */
1419         MutableAttributeSet bld = new SimpleAttributeSet(paragraphAttributes);
1420 
1421         Integer stateItem;
1422 
1423         /*** Tab stops ***/
1424         TabStop[] tabs;
1425 
1426         tabs = (TabStop[])parserState.get("_tabs_immutable");
1427         if (tabs == null) {
1428             @SuppressWarnings("unchecked")
1429             Dictionary<Object, Object> workingTabs = (Dictionary)parserState.get("_tabs");
1430             if (workingTabs != null) {
1431                 int count = ((Integer)workingTabs.get("stop count")).intValue();
1432                 tabs = new TabStop[count];
1433                 for (int ix = 1; ix <= count; ix ++)
1434                     tabs[ix-1] = (TabStop)workingTabs.get(Integer.valueOf(ix));
1435                 parserState.put("_tabs_immutable", tabs);
1436             }
1437         }
1438         if (tabs != null)
1439             bld.addAttribute(Constants.Tabs, tabs);
1440 
1441         Style paragraphStyle = (Style)parserState.get("paragraphStyle");
1442         if (paragraphStyle != null)
1443             bld.setResolveParent(paragraphStyle);
1444 


< prev index next >