Exemplo n.º 1
0
 public Hyperlink(Accessible accessible, string path)
 {
     application = accessible.application;
     ObjectPath op = new ObjectPath (path);
     proxy = Registry.Bus.GetObject<IHyperlink> (application.name, op);
     properties = Registry.Bus.GetObject<Properties> (application.name, op);
 }
Exemplo n.º 2
0
        public void TestWithTwoHyperlinks()
        {
            HSSFWorkbook wb = OpenSample("WithTwoHyperLinks.xls");

            NPOI.SS.UserModel.ISheet sheet = wb.GetSheetAt(0);

            ICell      cell1 = sheet.GetRow(4).GetCell(0);
            IHyperlink link1 = cell1.Hyperlink;

            Assert.IsNotNull(link1);
            Assert.AreEqual("Foo", link1.Label);
            Assert.AreEqual("http://poi.apache.org/", link1.Address);
            Assert.AreEqual(4, link1.FirstRow);
            Assert.AreEqual(0, link1.FirstColumn);

            ICell      cell2 = sheet.GetRow(8).GetCell(1);
            IHyperlink link2 = cell2.Hyperlink;

            Assert.IsNotNull(link2);
            Assert.AreEqual("Bar", link2.Label);
            Assert.AreEqual("http://poi.apache.org/hssf/", link2.Address);
            Assert.AreEqual(8, link2.FirstRow);
            Assert.AreEqual(1, link2.FirstColumn);

            wb.Close();
        }
Exemplo n.º 3
0
        public HGCommunicationsGridMode(
            NetworkServersInfo serversInfo,
            SceneManager sman, LibraryRootFolder libraryRootFolder)
            : base(serversInfo, libraryRootFolder)
        {
            // From constructor at CommunicationsOGS1
            HGGridServices gridInterComms = new HGGridServicesGridMode(serversInfo, sman, m_userProfileCacheService);
            m_gridService = gridInterComms;
            m_osw = gridInterComms;

            // The HG InventoryService always uses secure handlers
            HGInventoryServiceClient invService = new HGInventoryServiceClient(serversInfo.InventoryURL, this.m_userProfileCacheService, true);
            invService.UserProfileCache = m_userProfileCacheService; 
            AddSecureInventoryService(invService);
            m_defaultInventoryHost = invService.Host;
            if (SecureInventoryService != null)
                m_log.Info("[HG]: SecureInventoryService.");
            else
                m_log.Info("[HG]: Non-secureInventoryService.");

            HGUserServices userServices = new HGUserServices(this);
            // This plugin arrangement could eventually be configurable rather than hardcoded here.
            userServices.AddPlugin(new TemporaryUserProfilePlugin());
            userServices.AddPlugin(new OGS1UserDataPlugin(this));            
            
            m_userService = userServices;
            m_messageService = userServices;
            m_avatarService = userServices;           
        }
Exemplo n.º 4
0
        bool HasAnyUrl(object[] objects, out string urls)
        {
            urls = null;

            foreach (object obj in objects)
            {
                if (obj is IHyperlink)
                {
                    IHyperlink link = (IHyperlink)obj;
                    if (!string.IsNullOrEmpty(link.Hyperlink))
                    {
                        if (urls == null)
                        {
                            urls = link.Hyperlink;
                        }
                        else
                        {
                            urls += "\n" + link.Hyperlink;
                        }
                    }
                }
            }

            return(urls != null);
        }
Exemplo n.º 5
0
        private void CreateHyperlink(ICreationHelper helper, ICell cell, HyperlinkType linkType, String ref1)
        {
            cell.SetCellValue(ref1);
            IHyperlink link = helper.CreateHyperlink(linkType);

            link.Address   = (ref1);
            cell.Hyperlink = (link);
        }
Exemplo n.º 6
0
        private void VerifyHyperlink(ICell cell, HyperlinkType linkType, String ref1)
        {
            Assert.IsTrue(CellHasHyperlink(cell));
            IHyperlink link = cell.Hyperlink;

            Assert.AreEqual(linkType, link.Type);
            Assert.AreEqual(ref1, link.Address);
        }
Exemplo n.º 7
0
        public void TestCopyCellFrom_CellCopyPolicy_mergeHyperlink()
        {
            //setUp_testCopyCellFrom_CellCopyPolicy();
            IWorkbook       wb           = srcCell.Sheet.Workbook;
            ICreationHelper createHelper = wb.GetCreationHelper();

            srcCell.SetCellValue("URL LINK");
            IHyperlink link = createHelper.CreateHyperlink(HyperlinkType.Url);

            link.Address       = ("http://poi.apache.org/");
            destCell.Hyperlink = (link);
            // Set link cell style (optional)
            ICellStyle hlinkStyle = wb.CreateCellStyle();
            IFont      hlinkFont  = wb.CreateFont();

            hlinkFont.Underline = FontUnderlineType.Single;
            hlinkFont.Color     = (IndexedColors.Blue.Index);
            hlinkStyle.SetFont(hlinkFont);
            destCell.CellStyle = (hlinkStyle);

            // Pre-condition assumptions. This test is broken if either of these Assert.Fail.
            Assert.AreSame(srcCell.Sheet, destCell.Sheet,
                           "unit test assumes srcCell and destCell are on the same sheet");
            Assert.IsNull(srcCell.Hyperlink);
            // Merge hyperlink - since srcCell doesn't have a hyperlink, destCell's hyperlink is not overwritten (cleared).
            CellCopyPolicy policy = new CellCopyPolicy.Builder().MergeHyperlink(true).CopyHyperlink(false).Build();

            destCell.CopyCellFrom(srcCell, policy);
            Assert.IsNull(srcCell.Hyperlink);
            Assert.IsNotNull(destCell.Hyperlink);
            Assert.AreSame(link, destCell.Hyperlink);
            List <IHyperlink> links;

            links = srcCell.Sheet.GetHyperlinkList();
            Assert.AreEqual(1, links.Count, "number of hyperlinks on sheet");
            Assert.AreEqual(new CellReference(destCell).FormatAsString(), (links[(0)] as XSSFHyperlink).CellRef,
                            "source hyperlink");

            // Merge destCell's hyperlink to srcCell. Since destCell does have a hyperlink, this should copy destCell's hyperlink to srcCell.
            srcCell.CopyCellFrom(destCell, policy);
            Assert.IsNotNull(srcCell.Hyperlink);
            Assert.IsNotNull(destCell.Hyperlink);

            links = srcCell.Sheet.GetHyperlinkList();
            Assert.AreEqual(2, links.Count, "number of hyperlinks on sheet");
            Assert.AreEqual(new CellReference(destCell).FormatAsString(), (links[(0)] as XSSFHyperlink).CellRef,
                            "dest hyperlink");
            Assert.AreEqual(new CellReference(srcCell).FormatAsString(), (links[(1)] as XSSFHyperlink).CellRef,
                            "source hyperlink");

            wb.Close();
        }
Exemplo n.º 8
0
        /// <inheritdoc />
        public bool Equals([CanBeNull] IHyperlink other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            if (ReferenceEquals(other, null))
            {
                return(false);
            }

            return(StringComparer.OrdinalIgnoreCase.Equals(Location, other.Location));
        }
Exemplo n.º 9
0
        protected virtual void InitialiseHGStandaloneServices(LibraryRootFolder libraryRootFolder)
        {
            HGGridServicesStandalone gridService = new HGGridServicesStandalone(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_openSim.SceneManager);

            m_commsManager
                = new HGCommunicationsStandalone(
                      m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache,
                      gridService,
                      libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile);

            HGServices = gridService;

            CreateGridInfoService();
        }
Exemplo n.º 10
0
        protected virtual void InitialiseHGGridServices(LibraryRootFolder libraryRootFolder)
        {
            m_commsManager = new HGCommunicationsGridMode(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_openSim.SceneManager, libraryRootFolder);

            HGServices = ((HGCommunicationsGridMode)m_commsManager).HGServices;

            m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler());
            m_httpServer.AddStreamHandler(new OpenSim.XSimStatusHandler(m_openSim));

            if (m_openSim.userStatsURI != String.Empty)
            {
                m_httpServer.AddStreamHandler(new OpenSim.UXSimStatusHandler(m_openSim));
            }
        }
Exemplo n.º 11
0
        public void TestWithHyperlink()
        {
            HSSFWorkbook wb = OpenSample("WithHyperlink.xls");

            NPOI.SS.UserModel.ISheet sheet = wb.GetSheetAt(0);
            ICell      cell = sheet.GetRow(4).GetCell(0);
            IHyperlink link = cell.Hyperlink;

            Assert.IsNotNull(link);

            Assert.AreEqual("Foo", link.Label);
            Assert.AreEqual(link.Address, "http://poi.apache.org/");
            Assert.AreEqual(4, link.FirstRow);
            Assert.AreEqual(0, link.FirstColumn);
        }
        public static IHyperlink CreateHyperlink(this ISheet sheet, Int32 x, Int32 y)
        {
            IHyperlink link = null;

            if (sheet is XSSFSheet)
            {
                link = new XSSFHyperlink(HyperlinkType.Document);
            }
            else
            {
                link = new HSSFHyperlink(HyperlinkType.Document);
            }
            String address = $"!R{x.ToString()}C{y.ToString()}";

            link.Address = $"'{ sheet.SheetName}'" + address;
            return(link);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 添加超链接
        /// </summary>
        /// <param name="exCell">单元格</param>
        /// <param name="field">字段规则</param>
        /// <param name="addr">地址</param>
        public static void AddHyperLink(ICell exCell, HyperlinkType linkType, string addr)
        {
            IWorkbook  book = exCell.Sheet.Workbook;
            IHyperlink link = book.GetCreationHelper().CreateHyperlink(linkType);

            link.Address     = addr;
            exCell.Hyperlink = link;

            IFont linkFont = book.CreateFont();

            linkFont.Underline = FontUnderlineType.Single;
            linkFont.Color     = IndexedColors.Blue.Index;
            ICellStyle linkStyle = exCell.CellStyle ?? book.CreateCellStyle();

            linkStyle.SetFont(linkFont);
            exCell.CellStyle = linkStyle;
        }
Exemplo n.º 14
0
        public void TestShiftRows()
        {
            HSSFWorkbook wb = HSSFTestDataSamples.OpenSampleWorkbook("46445.xls");


            NPOI.SS.UserModel.ISheet sheet = wb.GetSheetAt(0);

            //verify existing hyperlink in A3
            ICell      cell1 = sheet.GetRow(2).GetCell(0);
            IHyperlink link1 = cell1.Hyperlink;

            Assert.IsNotNull(link1);
            Assert.AreEqual(2, link1.FirstRow);
            Assert.AreEqual(2, link1.LastRow);

            //assign a hyperlink to A4
            HSSFHyperlink link2 = new HSSFHyperlink(HyperlinkType.Document);

            link2.Address = ("Sheet2!A2");
            ICell cell2 = sheet.GetRow(3).GetCell(0);

            cell2.Hyperlink = (link2);
            Assert.AreEqual(3, link2.FirstRow);
            Assert.AreEqual(3, link2.LastRow);

            //move the 3rd row two rows down
            sheet.ShiftRows(sheet.FirstRowNum, sheet.LastRowNum, 2);

            //cells A3 and A4 don't contain hyperlinks anymore
            Assert.IsNull(sheet.GetRow(2).GetCell(0).Hyperlink);
            Assert.IsNull(sheet.GetRow(3).GetCell(0).Hyperlink);

            //the first hypelink now belongs to A5
            IHyperlink link1_shifted = sheet.GetRow(2 + 2).GetCell(0).Hyperlink;

            Assert.IsNotNull(link1_shifted);
            Assert.AreEqual(4, link1_shifted.FirstRow);
            Assert.AreEqual(4, link1_shifted.LastRow);

            //the second hypelink now belongs to A6
            IHyperlink link2_shifted = sheet.GetRow(3 + 2).GetCell(0).Hyperlink;

            Assert.IsNotNull(link2_shifted);
            Assert.AreEqual(5, link2_shifted.FirstRow);
            Assert.AreEqual(5, link2_shifted.LastRow);
        }
Exemplo n.º 15
0
 public HSSFHyperlink(IHyperlink other)
 {
     if (other is HSSFHyperlink)
     {
         HSSFHyperlink hlink = (HSSFHyperlink)other;
         record    = hlink.record.Clone() as HyperlinkRecord;
         link_type = getType(record);
     }
     else
     {
         link_type   = other.Type;
         record      = new HyperlinkRecord();
         FirstRow    = (other.FirstRow);
         FirstColumn = (other.FirstColumn);
         LastRow     = (other.LastRow);
         LastColumn  = (other.LastColumn);
     }
 }
Exemplo n.º 16
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            IHyperlink link = value as IHyperlink;

            if (link.IsLinkOnly)
            {
                //if the resource is just a link, do not serialize any properties other than Href
                writer.WriteStartObject();

                writer.WritePropertyName(HrefElementName);
                serializer.Serialize(writer, link.Href);

                writer.WriteEndObject();
            }
            else
            {
                JObject.FromObject(link.ObjectValue, DefaultSerializer).WriteTo(writer);
            }
        }
Exemplo n.º 17
0
 /**
  * Create a new XSSFHyperlink. This method is for Internal use only.
  * XSSFHyperlinks can be created by XSSFCreationHelper.
  *
  * @param type - the type of hyperlink to create, see {@link Hyperlink}
  */
 //FIXME: change to protected if/when SXSSFHyperlink class is created
 public XSSFHyperlink(IHyperlink other)
 {
     if (other is XSSFHyperlink)
     {
         XSSFHyperlink xlink = (XSSFHyperlink)other;
         _type        = xlink.Type;
         _location    = xlink._location;
         _externalRel = xlink._externalRel;
         _ctHyperlink = xlink._ctHyperlink.Copy();
     }
     else
     {
         _type        = other.Type;
         _location    = other.Address;
         _externalRel = null;
         _ctHyperlink = new CT_Hyperlink();
         SetCellReference(new CellReference(other.FirstRow, other.FirstColumn));
     }
 }
Exemplo n.º 18
0
        public void Render(ICell cell)
        {
            //NPOIExcelUtil.AddHyperLink(cell, GetLinkType(LinkType), Address);
            HyperlinkType linkType = GetLinkType(LinkType);
            IWorkbook     book     = cell.Sheet.Workbook;
            IHyperlink    link     = book.GetCreationHelper().CreateHyperlink(linkType);

            link.Address   = Address;
            cell.Hyperlink = link;

            IFont linkFont = book.CreateFont();

            linkFont.Underline = FontUnderlineType.Single;
            linkFont.Color     = IndexedColors.Blue.Index;
            ICellStyle linkStyle = cell.CellStyle ?? book.CreateCellStyle();

            linkStyle.SetFont(linkFont);
            cell.CellStyle = linkStyle;
        }
        public HGCommunicationsGridMode(
            NetworkServersInfo serversInfo,
            SceneManager sman, LibraryRootFolder libraryRootFolder)
            : base(serversInfo, libraryRootFolder)
        {
            // From constructor at CommunicationsOGS1
            HGGridServices gridInterComms = new HGGridServicesGridMode(serversInfo, sman, m_userProfileCacheService);
            m_gridService = gridInterComms;
            m_osw = gridInterComms;

            HGUserServices userServices = new HGUserServices(this);
            // This plugin arrangement could eventually be configurable rather than hardcoded here.
            userServices.AddPlugin(new TemporaryUserProfilePlugin());
            userServices.AddPlugin(new HGUserDataPlugin(this, userServices));            
            
            m_userService = userServices;
            m_messageService = userServices;
            m_avatarService = userServices;           
        }
        /// <summary>
        /// 创建与指定 工作表关联的超链接
        /// </summary>
        /// <param name="sheet">工作表</param>
        /// <param name="address">链接地址</param>
        /// <returns></returns>
        public static IHyperlink CreateHyperlink(this ISheet sheet, String address = null)
        {
            IHyperlink link = null;

            if (sheet is XSSFSheet)
            {
                link = new XSSFHyperlink(HyperlinkType.Document);
            }
            else
            {
                link = new HSSFHyperlink(HyperlinkType.Document);
            }
            //'Murray工作表_2'!A1
            if (address == null)
            {
                address = "!A1";
            }
            link.Address = $"'{ sheet.SheetName}'" + address;
            return(link);
        }
Exemplo n.º 21
0
        public void TestRemoveHyperlink()
        {
            IWorkbook       wb     = _testDataProvider.CreateWorkbook();
            ISheet          sh     = wb.CreateSheet("test");
            IRow            row    = sh.CreateRow(0);
            ICreationHelper helper = wb.GetCreationHelper();

            ICell      cell1 = row.CreateCell(1);
            IHyperlink link1 = helper.CreateHyperlink(HyperlinkType.Url);

            cell1.Hyperlink = (/*setter*/ link1);
            Assert.IsNotNull(cell1.Hyperlink);
            cell1.RemoveHyperlink();
            Assert.IsNull(cell1.Hyperlink);

            ICell      cell2 = row.CreateCell(0);
            IHyperlink link2 = helper.CreateHyperlink(HyperlinkType.Url);

            cell2.Hyperlink = (/*setter*/ link2);
            Assert.IsNotNull(cell2.Hyperlink);
            cell2.Hyperlink = (/*setter*/ null);
            Assert.IsNull(cell2.Hyperlink);

            ICell      cell3 = row.CreateCell(2);
            IHyperlink link3 = helper.CreateHyperlink(HyperlinkType.Url);

            link3.Address   = (/*setter*/ "http://poi.apache.org/");
            cell3.Hyperlink = (/*setter*/ link3);
            Assert.IsNotNull(cell3.Hyperlink);

            IWorkbook wbBack = _testDataProvider.WriteOutAndReadBack(wb);

            Assert.IsNotNull(wbBack);

            cell1 = wbBack.GetSheet("test").GetRow(0).GetCell(1);
            Assert.IsNull(cell1.Hyperlink);
            cell2 = wbBack.GetSheet("test").GetRow(0).GetCell(0);
            Assert.IsNull(cell2.Hyperlink);
            cell3 = wbBack.GetSheet("test").GetRow(0).GetCell(2);
            Assert.IsNotNull(cell3.Hyperlink);
        }
Exemplo n.º 22
0
        public HGCommunicationsGridMode(
            NetworkServersInfo serversInfo, BaseHttpServer httpServer,
            IAssetCache assetCache, SceneManager sman, LibraryRootFolder libraryRootFolder)
            : base(serversInfo, httpServer, assetCache, false, libraryRootFolder)
        {
            // From constructor at CommunicationsOGS1
            HGGridServices gridInterComms = new HGGridServicesGridMode(serversInfo, httpServer, assetCache, sman, m_userProfileCacheService);

            m_gridService = gridInterComms;
            m_osw         = gridInterComms;

            // The HG InventoryService always uses secure handlers
            HGInventoryServiceClient invService = new HGInventoryServiceClient(serversInfo.InventoryURL, this.m_userProfileCacheService, true);

            invService.UserProfileCache = m_userProfileCacheService;
            AddSecureInventoryService(invService);
            m_defaultInventoryHost = invService.Host;
            if (SecureInventoryService != null)
            {
                m_log.Info("[HG]: SecureInventoryService.");
            }
            else
            {
                m_log.Info("[HG]: Non-secureInventoryService.");
            }

            HGUserServices userServices = new HGUserServices(this);

            // This plugin arrangement could eventually be configurable rather than hardcoded here.
            userServices.AddPlugin(new TemporaryUserProfilePlugin());
            userServices.AddPlugin(new OGS1UserDataPlugin(this));

            m_userService    = userServices;
            m_messageService = userServices;
            m_avatarService  = userServices;
        }
Exemplo n.º 23
0
        public void TestCopyCellFrom_CellCopyPolicy_copyHyperlink()
        {
            //setUp_testCopyCellFrom_CellCopyPolicy();
            IWorkbook       wb           = srcCell.Sheet.Workbook;
            ICreationHelper createHelper = wb.GetCreationHelper();

            srcCell.SetCellValue("URL LINK");
            IHyperlink link = createHelper.CreateHyperlink(HyperlinkType.Url);

            link.Address      = ("http://poi.apache.org/");
            srcCell.Hyperlink = (link);
            // Set link cell style (optional)
            ICellStyle hlinkStyle = wb.CreateCellStyle();
            IFont      hlinkFont  = wb.CreateFont();

            hlinkFont.Underline = FontUnderlineType.Single;
            hlinkFont.Color     = (IndexedColors.Blue.Index);
            hlinkStyle.SetFont(hlinkFont);
            srcCell.CellStyle = (hlinkStyle);
            // Copy hyperlink
            CellCopyPolicy policy = new CellCopyPolicy.Builder().CopyHyperlink(true).MergeHyperlink(false).Build();

            destCell.CopyCellFrom(srcCell, policy);
            Assert.IsNotNull(destCell.Hyperlink);
            Assert.AreSame(srcCell.Sheet, destCell.Sheet,
                           "unit test assumes srcCell and destCell are on the same sheet");
            List <IHyperlink> links = srcCell.Sheet.GetHyperlinkList();

            Assert.AreEqual(2, links.Count, "number of hyperlinks on sheet");
            Assert.AreEqual(new CellReference(srcCell).FormatAsString(), (links[(0)] as XSSFHyperlink).CellRef,
                            "source hyperlink");
            Assert.AreEqual(new CellReference(destCell).FormatAsString(), (links[(1)] as XSSFHyperlink).CellRef,
                            "destination hyperlink");

            wb.Close();
        }
Exemplo n.º 24
0
 public HGSceneCommunicationService(CommunicationsManager commsMan, IHyperlink hg) : base(commsMan)
 {
     m_hg = hg;
 }
Exemplo n.º 25
0
 /// <summary>
 /// Writes the specified link.
 /// </summary>
 /// <param name="link">The link.</param>
 /// <returns>System.String.</returns>
 private static string Write(IHyperlink link)
 {
     return(String.Format("(Hyperlink) Location:{0}", link.Location));
 }
Exemplo n.º 26
0
        public void Export(IList <IExportTargeter> exportTargeters, IList <SchemaInfoTuple> schemas, ExportConfig config)
        {
            List <SchemaInfoTuple> schemaInfos = new List <SchemaInfoTuple>(schemas);

            Dictionary <String, SchemaInfoTuple> schemaTable = new Dictionary <string, SchemaInfoTuple>();

            schemaInfos.ForEach(t =>
            {
                schemaTable.Add(t.ObjectSchema.Name, t);
            });
            Int32             total        = schemaTable.Count;
            Int32             current      = 0;
            ExcelExportConfig exportConfig = config as ExcelExportConfig;

            //若有分组,首先写入分组中的结构信息
            //在目标表合并一行用于写入分组名称
            //后续写入属于此组的 TableSchema 信息
            //若需要建立合并分组信息,则以组名创建 Sheet ,属于此组的所有 Schem 信息,写入到此 Sheet 中
            //完成一个组的写入,并移除已写入的 Schema 信息

            //完成所有分组的写入后,将剩下零散的 Schema 信息单独创建 Sheet 写入信息

            var templatePath = Path.Combine(this.ExcelExportTemplateDirectory, exportConfig.ExcelTemplatePath);
            //Start
            var workbook = OfficeAssistor.OpenExcel(templatePath);
            //新建目录 Sheet

            EPoint catalogLocation = new EPoint(2, 2);

            var catalogTemplateSheet = workbook.GetSheet(ExcelTemplateFormat.CatalogSheetTemplateName);
            var tableTemplateSheet   = workbook.GetSheet(ExcelTemplateFormat.TableSheetTemplateName);
            var catalogSheet         = workbook.CreateSheet(ExcelTemplateFormat.CatalogSheetName);



            foreach (var pair in exportConfig.GroupInfos)
            {
                var    schemaNames   = pair.Value;
                var    groupName     = pair.Key;
                ISheet schemaSheet   = null;
                EPoint sheetLocation = new EPoint(2, 2);
                if (exportConfig.IsMergeGroupToSheet)
                {
                    schemaSheet = workbook.CreateSheet(groupName);
                }



                //复制目录头
                catalogTemplateSheet.CopyRow(ExcelTemplateFormat.CSTHeadRowNum, catalogSheet, catalogLocation.X, catalogLocation.Y);
                //向目录表中写入 组名
                catalogSheet.SetCellValue(catalogLocation.X, 0, groupName);
                catalogLocation.X += ExcelTemplateFormat.RowSpan;

                //复制目录列
                catalogTemplateSheet.CopyRow(ExcelTemplateFormat.CSTColumnHeaderRowNum, catalogSheet, catalogLocation.X, catalogLocation.Y);
                catalogLocation.X += ExcelTemplateFormat.RowSpan;



                //写入目录行
                Int32 internalnum = 1;

                foreach (String schemaName in schemaNames)
                {
                    IObjectSchema objectSchema = schemaTable[schemaName].ObjectSchema;
                    catalogTemplateSheet.CopyRow(ExcelTemplateFormat.CSTRowTemlateNum, catalogSheet, catalogLocation.X, catalogLocation.Y);

                    var schemaInfo = schemaTable[schemaName];
                    this.RaiseExportProgressChanged(total, ++current, schemaInfo);
                    this.WriteCatalogRow(catalogSheet, objectSchema, internalnum++, catalogLocation.X, 0);
                    //写入对应表的列信息

                    if (!exportConfig.IsMergeGroupToSheet)
                    {
                        schemaSheet = workbook.CreateSheet(schemaInfo.ObjectSchema.Name);
                    }
                    this.WriteSchemaInfo(tableTemplateSheet, schemaSheet, sheetLocation, schemaInfo);
                    schemaTable.Remove(schemaName);
                    if (exportConfig.IsMergeGroupToSheet)
                    {
                        sheetLocation.X += ExcelTemplateFormat.RowSpan;
                    }

                    //目录表获取表名单元格,并添加链接
                    ICell cell = catalogSheet.GetCell(catalogLocation.X, 0 + ExcelTemplateFormat.CatalogNumColLength);

                    //TODO: 连接R1C1样式单元格 ,暂时只连接到 Sheet
                    IHyperlink link = OfficeAssistor.CreateHyperlink(schemaSheet /*, sheetLocation.X, sheetLocation.Y*/);

                    cell.Hyperlink = link;

                    catalogLocation.X += ExcelTemplateFormat.RowSpan;
                    Thread.Sleep(10);
                }
                catalogLocation.X += ExcelTemplateFormat.RowSpan;
            }

            if (schemaTable.Count > 0)
            {
                if (!exportConfig.EnableExclude)
                {
                    catalogTemplateSheet.CopyRow(ExcelTemplateFormat.CSTHeadRowNum, catalogSheet, catalogLocation.X, catalogLocation.Y);

                    catalogSheet.SetCellValue(catalogLocation.X, 0, ExcelTemplateFormat.CatalogSheetName);
                    catalogLocation.X += ExcelTemplateFormat.RowSpan;

                    //复制目录列
                    catalogTemplateSheet.CopyRow(ExcelTemplateFormat.CSTColumnHeaderRowNum, catalogSheet, catalogLocation.X, catalogLocation.Y);
                    catalogLocation.X += ExcelTemplateFormat.RowSpan;

                    Int32 num = 1;
                    foreach (var pair in schemaTable)
                    {
                        String schemaName    = pair.Key;
                        var    schemaInfo    = schemaTable[schemaName];
                        ISheet schemaSheet   = null;
                        EPoint sheetLocation = new EPoint(2, 2);
                        schemaSheet = workbook.CreateSheet(schemaName);

                        IObjectSchema objectSchema = schemaTable[schemaName].ObjectSchema;
                        catalogTemplateSheet.CopyRow(ExcelTemplateFormat.CSTRowTemlateNum, catalogSheet, catalogLocation.X, catalogLocation.Y);
                        this.RaiseExportProgressChanged(total, ++current, schemaInfo);
                        this.WriteCatalogRow(catalogSheet, objectSchema, num++, catalogLocation.X, 0);

                        this.WriteSchemaInfo(tableTemplateSheet, schemaSheet, sheetLocation, schemaInfo);

                        //目录表获取表名单元格,并添加链接
                        ICell cell = catalogSheet.GetCell(catalogLocation.X, 0 + ExcelTemplateFormat.CatalogNumColLength);

                        //TODO: 连接R1C1样式单元格 ,暂时只连接到 Sheet
                        IHyperlink link = OfficeAssistor.CreateHyperlink(schemaSheet);

                        cell.Hyperlink = link;

                        catalogLocation.X += ExcelTemplateFormat.RowSpan;
                        Thread.Sleep(10);
                    }
                }
                else
                {
                    this.RaiseExportProgressChanged(total - schemaTable.Count, current, null);
                }
            }

            //删除模板 Sheet
            workbook.RemoveSheetByName(ExcelTemplateFormat.CatalogSheetTemplateName);
            workbook.RemoveSheetByName(ExcelTemplateFormat.TableSheetTemplateName);
            this.SaveExcel(workbook, exportTargeters);
        }
        protected virtual void InitialiseHGGridServices(LibraryRootFolder libraryRootFolder)
        {
            m_commsManager 
                = new HGCommunicationsGridMode(
                    m_openSim.NetServersInfo,
                    m_openSim.SceneManager, libraryRootFolder);

            HGServices = ((HGCommunicationsGridMode) m_commsManager).HGServices;

            m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler());
            m_httpServer.AddStreamHandler(new OpenSim.XSimStatusHandler(m_openSim));
            if (m_openSim.userStatsURI != String.Empty)
                m_httpServer.AddStreamHandler(new OpenSim.UXSimStatusHandler(m_openSim));
        }
Exemplo n.º 28
0
        /// <summary>
        /// Copy cell value, formula and style, from srcCell per cell copy policy
        ///  If srcCell is null, clears the cell value and cell style per cell copy policy
        ///
        /// This does not shift references in formulas. Use {@link XSSFRowShifter} to shift references in formulas.
        /// </summary>
        /// <param name="srcCell">The cell to take value, formula and style from</param>
        /// <param name="policy">The policy for copying the information, see {@link CellCopyPolicy}</param>
        /// <exception cref="ArgumentException">if copy cell style and srcCell is from a different workbook</exception>
        public void CopyCellFrom(ICell srcCell, CellCopyPolicy policy)
        {
            // Copy cell value (cell type is updated implicitly)
            if (policy.IsCopyCellValue)
            {
                if (srcCell != null)
                {
                    CellType copyCellType = srcCell.CellType;
                    if (copyCellType == CellType.Formula && !policy.IsCopyCellFormula)
                    {
                        // Copy formula result as value
                        // FIXME: Cached value may be stale
                        copyCellType = srcCell.CachedFormulaResultType;
                    }
                    switch (copyCellType)
                    {
                    case CellType.Boolean:
                        SetCellValue(srcCell.BooleanCellValue);
                        break;

                    case CellType.Error:
                        SetCellErrorValue(srcCell.ErrorCellValue);
                        break;

                    case CellType.Formula:
                        SetCellFormula(srcCell.CellFormula);
                        break;

                    case CellType.Numeric:
                        // DataFormat is not copied unless policy.isCopyCellStyle is true
                        if (DateUtil.IsCellDateFormatted(srcCell))
                        {
                            SetCellValue(srcCell.DateCellValue);
                        }
                        else
                        {
                            SetCellValue(srcCell.NumericCellValue);
                        }
                        break;

                    case CellType.String:
                        SetCellValue(srcCell.StringCellValue);
                        break;

                    case CellType.Blank:
                        SetBlank();
                        break;

                    default:
                        throw new ArgumentException("Invalid cell type " + srcCell.CellType);
                    }
                }
                else
                { //srcCell is null
                    SetBlank();
                }
            }

            // Copy CellStyle
            if (policy.IsCopyCellStyle)
            {
                if (srcCell != null)
                {
                    CellStyle = (srcCell.CellStyle);
                }
                else
                {
                    // clear cell style
                    CellStyle = (null);
                }
            }


            if (policy.IsMergeHyperlink)
            {
                // if srcCell doesn't have a hyperlink and destCell has a hyperlink, don't clear destCell's hyperlink
                IHyperlink srcHyperlink = srcCell.Hyperlink;
                if (srcHyperlink != null)
                {
                    Hyperlink = new XSSFHyperlink(srcHyperlink);
                }
            }
            else if (policy.IsCopyHyperlink)
            {
                // overwrite the hyperlink at dest cell with srcCell's hyperlink
                // if srcCell doesn't have a hyperlink, clear the hyperlink (if one exists) at destCell
                IHyperlink srcHyperlink = srcCell.Hyperlink;
                if (srcHyperlink == null)
                {
                    Hyperlink = (null);
                }
                else
                {
                    Hyperlink = new XSSFHyperlink(srcHyperlink);
                }
            }
        }
Exemplo n.º 29
0
 public override IHyperlink CopyHyperlink(IHyperlink link)
 {
     return(new HSSFHyperlink(link));
 }
Exemplo n.º 30
0
        /// <summary>
        /// 跨sheet复制行
        /// 注意:复制的行中存在夸行合并单元格时将会出错
        /// </summary>
        /// <param name="sourceSheet">源表</param>
        /// <param name="targetSheet">目标表</param>
        /// <param name="sourceRowNum">源复制行</param>
        /// <param name="targetRowNum">目标复制行</param>
        /// <param name="doMerged">是否复制合并单元格</param>
        ///<param name="cover">是否以覆盖原来内容,true为覆盖,false为插入</param>
        public static void CopyRowOverSheet(ISheet sourceSheet, ISheet targetSheet, int sourceRowNum, int targetRowNum, bool doMerged, bool cover)
        {
            IRow targetRow = targetSheet.GetRow(targetRowNum);
            IRow sourceRow = sourceSheet.GetRow(sourceRowNum);

            if (targetRow != null && !cover)
            {
                //如果插入的行已经有内容,则将该内容以及该行以下的全部内容都往下移一行
                targetSheet.ShiftRows(targetRowNum, targetSheet.LastRowNum, 1, true, false);
            }
            else
            {
                targetRow = targetSheet.CreateRow(targetRowNum);
            }
            short h = sourceRow.Height;

            targetRow.Height = h;

            for (int i = 0; i < sourceRow.LastCellNum; i++)
            {
                ICell oldCell = sourceRow.GetCell(i);
                ICell newCell = targetRow.CreateCell(i);
                if (oldCell == null)
                {
                    newCell = null;
                    continue;
                }
                if (oldCell.CellStyle != null)
                {
                    ICellStyle os = oldCell.CellStyle;
                    if (sourceSheet.Workbook == targetSheet.Workbook)
                    {
                        newCell.CellStyle = os;
                    }
                    else
                    {//跨workbook的情况
                        newCell.CellStyle = cloneCellstyle(sourceSheet.Workbook, targetSheet.Workbook, os);
                    }
                }
                // 复制批注
                if (oldCell.CellComment != null)
                {
                    IComment ic = oldCell.CellComment;
                    newCell.CellComment = ic;
                }
                // 复制超链
                if (oldCell.Hyperlink != null)
                {
                    IHyperlink hl = oldCell.Hyperlink;
                    newCell.Hyperlink = hl;
                }
                // 复制单元格类型
                CellType ct = oldCell.CellType;
                newCell.SetCellType(ct);
                // 设置单元格数据值
                switch (oldCell.CellType)
                {
                case CellType.Blank:    //空值
                    string s1 = oldCell.StringCellValue;
                    newCell.SetCellValue(s1);
                    break;

                case CellType.Boolean:
                    bool b1 = oldCell.BooleanCellValue;
                    newCell.SetCellValue(b1);
                    break;

                case CellType.Error:
                    byte err = oldCell.ErrorCellValue;
                    newCell.SetCellErrorValue(err);
                    break;

                case CellType.Formula:    //公式,重要更新公式可以外接处理程序
                    string f = oldCell.CellFormula;
                    if (CellFormulaChangeEvent != null)
                    {
                        Tuple <string, ICell, ICell> t = new Tuple <string, ICell, ICell>(f, oldCell, newCell);
                        f = CellFormulaChangeEvent(t);
                    }
                    newCell.SetCellFormula(f);
                    break;

                case CellType.Numeric:    //数值
                    double d = oldCell.NumericCellValue;
                    newCell.SetCellValue(d);
                    break;

                case CellType.String:    //字符串
                    IRichTextString ir = oldCell.RichStringCellValue;
                    newCell.SetCellValue(ir);
                    break;

                case CellType.Unknown:    //未知
                    string scv = oldCell.StringCellValue;
                    newCell.SetCellValue(scv);
                    break;
                }
            }

            // 合拼单元格操作
            if (doMerged)
            {
                for (int i = 0; i < sourceSheet.NumMergedRegions; i++)                               //NumMergedRegions:整个sheet的合拼单元格数量
                {
                    NPOI.SS.Util.CellRangeAddress cellRangeAddress = sourceSheet.GetMergedRegion(i); //获取合拼单元格的地址字符串
                    if (cellRangeAddress.FirstRow == sourceRow.RowNum)
                    {
                        NPOI.SS.Util.CellRangeAddress newCellRangeAddress = new NPOI.SS.Util.CellRangeAddress(targetRow.RowNum,
                                                                                                              (targetRow.RowNum +
                                                                                                               (cellRangeAddress.FirstRow -
                                                                                                                cellRangeAddress.LastRow)),
                                                                                                              cellRangeAddress.FirstColumn,
                                                                                                              cellRangeAddress.LastColumn);
                        targetSheet.AddMergedRegion(newCellRangeAddress);
                    }
                }
            }
        }
        protected virtual void InitialiseHGStandaloneServices(LibraryRootFolder libraryRootFolder)
        {    
            HGGridServicesStandalone gridService 
                = new HGGridServicesStandalone(
                    m_openSim.NetServersInfo, m_httpServer, m_openSim.SceneManager);                         

            m_commsManager 
                = new HGCommunicationsStandalone(
                    m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer, 
                    gridService, 
                    libraryRootFolder, false);                        
            
            HGServices = gridService;

            CreateGridInfoService();
        }
Exemplo n.º 32
0
 public HGSceneCommunicationService(CommunicationsManager commsMan, IHyperlink hg) : base(commsMan)
 {
     m_hg = hg;
 }
Exemplo n.º 33
0
 void IHyperlinkContainer.set_Hyperlink(int Index, IHyperlink Link)
 {
     ((IHyperlinkContainer)featureLayer).set_Hyperlink(Index, Link);
 }
Exemplo n.º 34
0
 void IHyperlinkContainer.AddHyperlink(IHyperlink Link)
 {
     ((IHyperlinkContainer)featureLayer).AddHyperlink(Link);
 }
Exemplo n.º 35
0
 /// <summary>
 ///     Adds the specified link.
 /// </summary>
 /// <param name="link">The link.</param>
 /// <returns>Int32.</returns>
 Int32 ILinkCollection.Add(IHyperlink link)
 {
     Add((LinkImpl)link);
     return(ItemList.IndexOf((LinkImpl)link));
 }
Exemplo n.º 36
0
 public HyperlinkController(IHyperlink control)  : base(control)
 {
 }
Exemplo n.º 37
0
        public void TestLoadSave()
        {
            XSSFWorkbook    workbook     = XSSFTestDataSamples.OpenSampleWorkbook("WithMoreVariousData.xlsx");
            ICreationHelper CreateHelper = workbook.GetCreationHelper();

            Assert.AreEqual(3, workbook.NumberOfSheets);
            XSSFSheet sheet = (XSSFSheet)workbook.GetSheetAt(0);

            // Check hyperlinks
            Assert.AreEqual(4, sheet.NumHyperlinks);
            doTestHyperlinkContents(sheet);


            // Write out, and check

            // Load up again, check all links still there
            XSSFWorkbook wb2 = (XSSFWorkbook)XSSFTestDataSamples.WriteOutAndReadBack(workbook);

            Assert.AreEqual(3, wb2.NumberOfSheets);
            Assert.IsNotNull(wb2.GetSheetAt(0));
            Assert.IsNotNull(wb2.GetSheetAt(1));
            Assert.IsNotNull(wb2.GetSheetAt(2));

            sheet = (XSSFSheet)wb2.GetSheetAt(0);


            // Check hyperlinks again
            Assert.AreEqual(4, sheet.NumHyperlinks);
            doTestHyperlinkContents(sheet);


            // Add one more, and re-check
            IRow  r17  = sheet.CreateRow(17);
            ICell r17c = r17.CreateCell(2);

            IHyperlink hyperlink = CreateHelper.CreateHyperlink(HyperlinkType.Url);

            hyperlink.Address = ("http://poi.apache.org/spreadsheet/");
            hyperlink.Label   = "POI SS Link";
            r17c.Hyperlink    = (hyperlink);

            Assert.AreEqual(5, sheet.NumHyperlinks);
            doTestHyperlinkContents(sheet);

            Assert.AreEqual(HyperlinkType.Url,
                            sheet.GetRow(17).GetCell(2).Hyperlink.Type);
            Assert.AreEqual("POI SS Link",
                            sheet.GetRow(17).GetCell(2).Hyperlink.Label);
            Assert.AreEqual("http://poi.apache.org/spreadsheet/",
                            sheet.GetRow(17).GetCell(2).Hyperlink.Address);


            // Save and re-load once more

            XSSFWorkbook wb3 = (XSSFWorkbook)XSSFTestDataSamples.WriteOutAndReadBack(wb2);

            Assert.AreEqual(3, wb3.NumberOfSheets);
            Assert.IsNotNull(wb3.GetSheetAt(0));
            Assert.IsNotNull(wb3.GetSheetAt(1));
            Assert.IsNotNull(wb3.GetSheetAt(2));

            sheet = (XSSFSheet)wb3.GetSheetAt(0);

            Assert.AreEqual(5, sheet.NumHyperlinks);
            doTestHyperlinkContents(sheet);

            Assert.AreEqual(HyperlinkType.Url,
                            sheet.GetRow(17).GetCell(2).Hyperlink.Type);
            Assert.AreEqual("POI SS Link",
                            sheet.GetRow(17).GetCell(2).Hyperlink.Label);
            Assert.AreEqual("http://poi.apache.org/spreadsheet/",
                            sheet.GetRow(17).GetCell(2).Hyperlink.Address);
        }
Exemplo n.º 38
0
 public abstract IHyperlink CopyHyperlink(IHyperlink link);