1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 package com.sun.star.wizards.db; 28 29 import com.sun.star.wizards.common.JavaTools; 30 import com.sun.star.wizards.common.PropertyNames; 31 32 /** 33 * 34 * @author bc93774 35 */ 36 public class BlindtextCreator 37 { 38 39 public static final String BlindText = 40 "Ut wisi enim ad minim veniam, quis nostrud exerci tation " + "ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor " + "in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at " + "vero et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore " + "te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy " + "nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, " + "quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. " + "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum " + "dolore eu feugiat nulla facilisis at vero et accumsan et iusto odio dignissim qui blandit praesent " + "luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis " + "eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum."; 41 42 public static String adjustBlindTextlength(String FieldTitle, int FieldWidth, boolean bIsCurLandscape, boolean bIsGroupTable, String[] _RecordFieldNames) 43 { 44 String BlindTextString = PropertyNames.EMPTY_STRING; 45 if (bIsGroupTable) 46 { 47 return getBlindTextString(FieldTitle, FieldWidth, FieldWidth); 48 } 49 int MaxFieldCount = getMaxFieldCount(bIsCurLandscape); 50 if (_RecordFieldNames.length <= 2 * MaxFieldCount) 51 { 52 if (_RecordFieldNames.length <= MaxFieldCount) 53 { 54 BlindTextString = getBlindTextString(FieldTitle, FieldWidth, FieldWidth); 55 } 56 else 57 { 58 BlindTextString = getBlindTextString(FieldTitle, FieldWidth, (int) (0.5 * FieldWidth)); 59 } 60 } 61 else 62 { 63 BlindTextString = getBlindTextString(FieldTitle, FieldWidth, (int) 1.1 * FieldTitle.length()); 64 } 65 return BlindTextString; 66 } 67 68 public static String getBlindTextString(String FieldTitle, int FieldWidth, int MaxWidth) 69 { 70 String[] BlindTextArray = JavaTools.ArrayoutofString(BlindText, PropertyNames.SPACE); 71 String PartBlindText = BlindTextArray[0]; 72 String NewPartBlindText; 73 int MaxHeaderWidth; 74 int Titlelength = (int) 1.1 * FieldTitle.length(); // We assume that the TableHeading is bold 75 76 if (Titlelength > PartBlindText.length()) 77 { 78 MaxHeaderWidth = Titlelength; 79 } 80 else 81 { 82 MaxHeaderWidth = PartBlindText.length(); 83 } 84 if (MaxHeaderWidth > MaxWidth) 85 { 86 MaxWidth = MaxHeaderWidth; 87 } 88 int i = 1; 89 do 90 { 91 NewPartBlindText = PartBlindText + PropertyNames.SPACE + BlindTextArray[i]; 92 if (NewPartBlindText.length() < MaxWidth) 93 { 94 PartBlindText = NewPartBlindText; 95 i += 1; 96 } 97 } 98 while (NewPartBlindText.length() < MaxWidth); 99 return PartBlindText; 100 } 101 102 private static int getMaxFieldCount(boolean bIsCurLandscape) 103 { 104 if (bIsCurLandscape) 105 { 106 return 5; 107 } 108 else 109 { 110 return 3; 111 } 112 } 113 } 114