You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BasicLinkLayoutManager.java 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.layoutmgr;
  18. import org.apache.fop.fo.flow.BasicLink;
  19. import org.apache.fop.area.inline.InlineParent;
  20. import org.apache.fop.area.Trait;
  21. import org.apache.fop.area.LinkResolver;
  22. import org.apache.fop.area.PageViewport;
  23. /**
  24. * LayoutManager for the fo:basic-link formatting object
  25. */
  26. public class BasicLinkLayoutManager extends InlineStackingLayoutManager {
  27. private BasicLink fobj;
  28. /**
  29. * Create an fo:basic-link layout manager.
  30. *
  31. * @param node the formatting object that creates the area
  32. */
  33. public BasicLinkLayoutManager(BasicLink node) {
  34. super(node);
  35. fobj = node;
  36. }
  37. protected InlineParent createArea() {
  38. InlineParent area = super.createArea();
  39. setupBasicLinkArea(parentLM, area);
  40. return area;
  41. }
  42. private void setupBasicLinkArea(LayoutManager parentLM,
  43. InlineParent area) {
  44. if (fobj.getExternalDestination() != null) {
  45. area.addTrait(Trait.EXTERNAL_LINK, fobj.getExternalDestination());
  46. } else {
  47. String link = fobj.getInternalDestination();
  48. PageViewport page = parentLM.resolveRefID(link);
  49. if (page != null) {
  50. area.addTrait(Trait.INTERNAL_LINK, page.getKey());
  51. } else {
  52. LinkResolver res = new LinkResolver(link, area);
  53. parentLM.addUnresolvedArea(link, res);
  54. }
  55. }
  56. }
  57. }