/// ------------------------------------------------------------------------------------ /// <summary> /// Create a new picture, given string representations of most of the parameters. Used /// for creating a picture from a USFM-style Standard Format import. /// </summary> /// <param name="fcCache">FDO cache</param> /// <param name="sFolder">The name of the CmFolder where picture should be stored</param> /// <param name="anchorLoc">The anchor location that can be used to determine (may be 0).</param> /// <param name="locationParser">The location parser.</param> /// <param name="sDescription">Illustration description in English.</param> /// <param name="srcFilename">The picture filename.</param> /// <param name="sLayoutPos">The layout position (as a string).</param> /// <param name="sLocationRange">The location range (as a string).</param> /// <param name="sCopyright">The copyright.</param> /// <param name="sCaption">The caption, in the default vernacular writing system.</param> /// <param name="locRangeType">Assumed type of the location range.</param> /// <param name="sScaleFactor">The scale factor (as a string).</param> /// ------------------------------------------------------------------------------------ public CmPicture(FdoCache fcCache, string sFolder, int anchorLoc, IPictureLocationBridge locationParser, string sDescription, string srcFilename, string sLayoutPos, string sLocationRange, string sCopyright, string sCaption, PictureLocationRangeType locRangeType, string sScaleFactor) : base(fcCache, fcCache.CreateObject(CmPicture.kclsidCmPicture)) { InitializeNewPicture(sFolder, anchorLoc, locationParser, sDescription, srcFilename, sLayoutPos, sLocationRange, sCopyright, sCaption, locRangeType, sScaleFactor); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes the new picture. /// </summary> /// <param name="sFolder">The folder.</param> /// <param name="anchorLoc">The anchor location.</param> /// <param name="locationParser">The location parser (can be null).</param> /// <param name="sDescription">Illustration description in English.</param> /// <param name="srcFilename">The picture filename.</param> /// <param name="sLayoutPos">The layout position (as a string).</param> /// <param name="sLocationRange">The location range (as a string).</param> /// <param name="sCopyright">The copyright.</param> /// <param name="sCaption">The caption (in the default vernacular Writing System).</param> /// <param name="locRangeType">Type of the location range.</param> /// <param name="sScaleFactor">The scale factor (as a string).</param> /// ------------------------------------------------------------------------------------ private void InitializeNewPicture(string sFolder, int anchorLoc, IPictureLocationBridge locationParser, string sDescription, string srcFilename, string sLayoutPos, string sLocationRange, string sCopyright, string sCaption, PictureLocationRangeType locRangeType, string sScaleFactor) { ITsStrFactory factory = TsStrFactoryClass.Create(); InitializeNewPicture(sFolder, anchorLoc, locationParser, sDescription, srcFilename, sLayoutPos, sLocationRange, sCopyright, factory.MakeString(sCaption, m_cache.DefaultVernWs), locRangeType, sScaleFactor); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a new picture, given string representations of most of the parameters. Used /// for creating a picture from a Toolbox-style Standard Format import. /// </summary> /// <param name="fcCache">FDO cache</param> /// <param name="sFolder">The name of the CmFolder where picture should be stored</param> /// <param name="anchorLoc">The anchor location that the locationParser can use if /// necessary (can be 0).</param> /// <param name="locationParser">The location parser.</param> /// <param name="descriptions">The descriptions in 0 or more writing systems.</param> /// <param name="srcFilename">The picture filename.</param> /// <param name="sLayoutPos">The layout position (as a string).</param> /// <param name="sLocationRange">The location range (as a string).</param> /// <param name="sCopyright">The copyright.</param> /// <param name="tssCaption">The caption, in the default vernacular writing system.</param> /// <param name="locRangeType">Assumed type of the location range.</param> /// <param name="sScaleFactor">The scale factor (as a string).</param> /// ------------------------------------------------------------------------------------ public CmPicture(FdoCache fcCache, string sFolder, int anchorLoc, IPictureLocationBridge locationParser, Dictionary <int, string> descriptions, string srcFilename, string sLayoutPos, string sLocationRange, string sCopyright, ITsString tssCaption, PictureLocationRangeType locRangeType, string sScaleFactor) : base(fcCache, fcCache.CreateObject(CmPicture.kclsidCmPicture)) { InitializeNewPicture(sFolder, anchorLoc, locationParser, null, srcFilename, sLayoutPos, sLocationRange, sCopyright, tssCaption, locRangeType, sScaleFactor); if (descriptions != null) { foreach (int ws in descriptions.Keys) { Description.SetAlternative(descriptions[ws], ws); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets a string representation of the picture suitable for exporting or for building /// a clipboard representation of the object. /// </summary> /// <param name="fFileNameOnly">If set to <c>true</c> the picture filename does not /// contain the full path specification. Use <c>false</c> for the full path (e.g., for /// use on the clipboard). /// </param> /// <param name="sReference">A string containing the picture's reference (can be null or /// empty).</param> /// <param name="picLocBridge">A picture location bridge object (can be null).</param> /// <returns>String representation of the picture</returns> /// ------------------------------------------------------------------------------------ public string GetTextRepOfPicture(bool fFileNameOnly, string sReference, IPictureLocationBridge picLocBridge) { string sPicLoc = (picLocBridge == null) ? PictureLocAsString : picLocBridge.GetPictureLocAsString(this); string sResult = BuildTextRepParamString(EnglishDescriptionAsString, (fFileNameOnly ? Path.GetFileName(PictureFileRA.InternalPath) : PictureFileRA.AbsoluteInternalPath), LayoutPosAsString, sPicLoc, PictureFileRA.Copyright.VernacularDefaultWritingSystem.Text, Caption.VernacularDefaultWritingSystem.Text); if (sReference != null) { sResult = BuildTextRepParamString(sResult, sReference); } // TODO (TE-7759) Include LocationRangeType and ScaleFactor return(sResult); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes the new picture. /// </summary> /// <param name="sFolder">The folder.</param> /// <param name="anchorLoc">The anchor location that the locationParser can use if /// necessary (can be 0).</param> /// <param name="locationParser">The location parser (can be null).</param> /// <param name="sDescription">Illustration description in English.</param> /// <param name="srcFilename">The picture filename.</param> /// <param name="sLayoutPos">The layout position (as a string).</param> /// <param name="sLocationRange">The location range (as a string).</param> /// <param name="sCopyright">The copyright.</param> /// <param name="tssCaption">The caption (in the default vernacular Writing System).</param> /// <param name="locRangeType">Type of the location range.</param> /// <param name="sScaleFactor">The scale factor (as a string).</param> /// ------------------------------------------------------------------------------------ private void InitializeNewPicture(string sFolder, int anchorLoc, IPictureLocationBridge locationParser, string sDescription, string srcFilename, string sLayoutPos, string sLocationRange, string sCopyright, ITsString tssCaption, PictureLocationRangeType locRangeType, string sScaleFactor) { if (locationParser == null) { locationParser = this; } int locationMin, locationMax; locationParser.ParsePictureLoc(sLocationRange, anchorLoc, ref locRangeType, out locationMin, out locationMax); InitializeNewPicture(srcFilename, tssCaption, sDescription, ParseLayoutPosition(sLayoutPos), ParseScaleFactor(sScaleFactor), locRangeType, locationMin, locationMax, sCopyright, sFolder); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a new picture, given a text representation (e.g., from the clipboard). /// NOTE: The caption is put into the default vernacular writing system. /// </summary> /// <param name="fcCache">FDO cache</param> /// <param name="sTextRepOfPicture">Clipboard representation of a picture</param> /// <param name="sFolder">The name of the CmFolder where picture should be stored</param> /// <param name="anchorLoc">The anchor location that can be used to determine (may be 0).</param> /// <param name="locationParser">The picture location parser (can be null).</param> /// ------------------------------------------------------------------------------------ public CmPicture(FdoCache fcCache, string sTextRepOfPicture, string sFolder, int anchorLoc, IPictureLocationBridge locationParser) : base(fcCache, fcCache.CreateObject(CmPicture.kclsidCmPicture)) { string[] tokens = sTextRepOfPicture.Split(new char[] {'|'}); if (tokens.Length < 9 || tokens[0] != "CmPicture") throw new ArgumentException("The clipboard format for a Picture was invalid"); string sDescription = tokens[1]; string srcFilename = tokens[2]; string sLayoutPos = tokens[3]; string sLocationRange = tokens[4]; string sCopyright = tokens[5]; string sCaption = tokens[6]; string sLocationRangeType = tokens[7]; string sScaleFactor = tokens[8]; PictureLocationRangeType locRangeType = ParseLocationRangeType(sLocationRangeType); InitializeNewPicture(sFolder, anchorLoc, locationParser, sDescription, srcFilename, sLayoutPos, sLocationRange, sCopyright, sCaption, locRangeType, sScaleFactor); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a new picture, given a text representation (e.g., from the clipboard). /// NOTE: The caption is put into the default vernacular writing system. /// </summary> /// <param name="fcCache">FDO cache</param> /// <param name="sTextRepOfPicture">Clipboard representation of a picture</param> /// <param name="sFolder">The name of the CmFolder where picture should be stored</param> /// <param name="anchorLoc">The anchor location that can be used to determine (may be 0).</param> /// <param name="locationParser">The picture location parser (can be null).</param> /// ------------------------------------------------------------------------------------ public CmPicture(FdoCache fcCache, string sTextRepOfPicture, string sFolder, int anchorLoc, IPictureLocationBridge locationParser) : base(fcCache, fcCache.CreateObject(CmPicture.kclsidCmPicture)) { string[] tokens = sTextRepOfPicture.Split(new char[] { '|' }); if (tokens.Length < 9 || tokens[0] != "CmPicture") { throw new ArgumentException("The clipboard format for a Picture was invalid"); } string sDescription = tokens[1]; string srcFilename = tokens[2]; string sLayoutPos = tokens[3]; string sLocationRange = tokens[4]; string sCopyright = tokens[5]; string sCaption = tokens[6]; string sLocationRangeType = tokens[7]; string sScaleFactor = tokens[8]; PictureLocationRangeType locRangeType = ParseLocationRangeType(sLocationRangeType); InitializeNewPicture(sFolder, anchorLoc, locationParser, sDescription, srcFilename, sLayoutPos, sLocationRange, sCopyright, sCaption, locRangeType, sScaleFactor); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets a string representation of the picture suitable for exporting or for building /// a clipboard representation of the object. /// </summary> /// <param name="fFileNameOnly">If set to <c>true</c> the picture filename does not /// contain the full path specification. Use <c>false</c> for the full path (e.g., for /// use on the clipboard). /// </param> /// <param name="sReference">A string containing the picture's reference (can be null or /// empty).</param> /// <param name="picLocBridge">A picture location bridge object (can be null).</param> /// <returns>String representation of the picture</returns> /// ------------------------------------------------------------------------------------ public string GetTextRepOfPicture(bool fFileNameOnly, string sReference, IPictureLocationBridge picLocBridge) { if (picLocBridge == null) picLocBridge = this; string sResult = BuildTextRepParamString(EnglishDescriptionAsString, (fFileNameOnly ? Path.GetFileName(PictureFileRA.InternalPath) : PictureFileRA.AbsoluteInternalPath), LayoutPosAsString, picLocBridge.GetPictureLocAsString(this), PictureFileRA.Copyright.VernacularDefaultWritingSystem.Text, Caption.VernacularDefaultWritingSystem.Text); if (sReference != null) sResult = BuildTextRepParamString(sResult, sReference); // TODO (TE-7759) Include LocationRangeType and ScaleFactor return sResult; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes the new picture. /// </summary> /// <param name="sFolder">The folder.</param> /// <param name="anchorLoc">The anchor location that the locationParser can use if /// necessary (can be 0).</param> /// <param name="locationParser">The location parser (can be null).</param> /// <param name="sDescription">Illustration description in English.</param> /// <param name="srcFilename">The picture filename.</param> /// <param name="sLayoutPos">The layout position (as a string).</param> /// <param name="sLocationRange">The location range (as a string).</param> /// <param name="sCopyright">The copyright.</param> /// <param name="tssCaption">The caption (in the default vernacular Writing System).</param> /// <param name="locRangeType">Type of the location range.</param> /// <param name="sScaleFactor">The scale factor (as a string).</param> /// ------------------------------------------------------------------------------------ private void InitializeNewPicture(string sFolder, int anchorLoc, IPictureLocationBridge locationParser, string sDescription, string srcFilename, string sLayoutPos, string sLocationRange, string sCopyright, ITsString tssCaption, PictureLocationRangeType locRangeType, string sScaleFactor) { if (locationParser == null) locationParser = this; int locationMin, locationMax; locationParser.ParsePictureLoc(sLocationRange, anchorLoc, ref locRangeType, out locationMin, out locationMax); InitializeNewPicture(srcFilename, tssCaption, sDescription, ParseLayoutPosition(sLayoutPos), ParseScaleFactor(sScaleFactor), locRangeType, locationMin, locationMax, sCopyright, sFolder); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes the new picture. /// </summary> /// <param name="sFolder">The folder.</param> /// <param name="anchorLoc">The anchor location.</param> /// <param name="locationParser">The location parser (can be null).</param> /// <param name="sDescription">Illustration description in English.</param> /// <param name="srcFilename">The picture filename.</param> /// <param name="sLayoutPos">The layout position (as a string).</param> /// <param name="sLocationRange">The location range (as a string).</param> /// <param name="sCopyright">The copyright.</param> /// <param name="sCaption">The caption (in the default vernacular Writing System).</param> /// <param name="locRangeType">Type of the location range.</param> /// <param name="sScaleFactor">The scale factor (as a string).</param> /// ------------------------------------------------------------------------------------ private void InitializeNewPicture(string sFolder, int anchorLoc, IPictureLocationBridge locationParser, string sDescription, string srcFilename, string sLayoutPos, string sLocationRange, string sCopyright, string sCaption, PictureLocationRangeType locRangeType, string sScaleFactor) { ITsStrFactory factory = TsStrFactoryClass.Create(); InitializeNewPicture(sFolder, anchorLoc, locationParser, sDescription, srcFilename, sLayoutPos, sLocationRange, sCopyright, factory.MakeString(sCaption, m_cache.DefaultVernWs), locRangeType, sScaleFactor); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a new picture, given string representations of most of the parameters. Used /// for creating a picture from a Toolbox-style Standard Format import. /// </summary> /// <param name="fcCache">FDO cache</param> /// <param name="sFolder">The name of the CmFolder where picture should be stored</param> /// <param name="anchorLoc">The anchor location that the locationParser can use if /// necessary (can be 0).</param> /// <param name="locationParser">The location parser.</param> /// <param name="descriptions">The descriptions in 0 or more writing systems.</param> /// <param name="srcFilename">The picture filename.</param> /// <param name="sLayoutPos">The layout position (as a string).</param> /// <param name="sLocationRange">The location range (as a string).</param> /// <param name="sCopyright">The copyright.</param> /// <param name="tssCaption">The caption, in the default vernacular writing system.</param> /// <param name="locRangeType">Assumed type of the location range.</param> /// <param name="sScaleFactor">The scale factor (as a string).</param> /// ------------------------------------------------------------------------------------ public CmPicture(FdoCache fcCache, string sFolder, int anchorLoc, IPictureLocationBridge locationParser, Dictionary<int, string> descriptions, string srcFilename, string sLayoutPos, string sLocationRange, string sCopyright, ITsString tssCaption, PictureLocationRangeType locRangeType, string sScaleFactor) : base(fcCache, fcCache.CreateObject(CmPicture.kclsidCmPicture)) { InitializeNewPicture(sFolder, anchorLoc, locationParser, null, srcFilename, sLayoutPos, sLocationRange, sCopyright, tssCaption, locRangeType, sScaleFactor); if (descriptions != null) { foreach (int ws in descriptions.Keys) Description.SetAlternative(descriptions[ws], ws); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a new picture, given string representations of most of the parameters. Used /// for creating a picture from a USFM-style Standard Format import. /// </summary> /// <param name="fcCache">FDO cache</param> /// <param name="sFolder">The name of the CmFolder where picture should be stored</param> /// <param name="anchorLoc">The anchor location that can be used to determine (may be 0).</param> /// <param name="locationParser">The location parser.</param> /// <param name="sDescription">Illustration description in English.</param> /// <param name="srcFilename">The picture filename.</param> /// <param name="sLayoutPos">The layout position (as a string).</param> /// <param name="sLocationRange">The location range (as a string).</param> /// <param name="sCopyright">The copyright.</param> /// <param name="sCaption">The caption, in the default vernacular writing system.</param> /// <param name="locRangeType">Assumed type of the location range.</param> /// <param name="sScaleFactor">The scale factor (as a string).</param> /// ------------------------------------------------------------------------------------ public CmPicture(FdoCache fcCache, string sFolder, int anchorLoc, IPictureLocationBridge locationParser, string sDescription, string srcFilename, string sLayoutPos, string sLocationRange, string sCopyright, string sCaption, PictureLocationRangeType locRangeType, string sScaleFactor) : base(fcCache, fcCache.CreateObject(CmPicture.kclsidCmPicture)) { InitializeNewPicture(sFolder, anchorLoc, locationParser, sDescription, srcFilename, sLayoutPos, sLocationRange, sCopyright, sCaption, locRangeType, sScaleFactor); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initialize a new CmPicture by creating a copy of the file in the given folder and /// hooking everything up. Put the caption in the default vernacular writing system. /// </summary> /// <param name="srcFilename">The path to the original filename (an internal copy will /// be made in this method)</param> /// <param name="captionTss">The caption (in the default vernacular Writing System)</param> /// <param name="description">Illustration description in English. This is not published.</param> /// <param name="sLayoutPos">The layout position (as a string).</param> /// <param name="sScaleFactor">The scale factor (as a string).</param> /// <param name="locRangeType">Indicates the type of data contained in LocationMin /// and LocationMax.</param> /// <param name="anchorLoc">The anchor location that can be used to determine (may be 0).</param> /// <param name="locationParser">The location parser.</param> /// <param name="sLocationRange">The location range (as a string).</param> /// <param name="copyright">Publishable information about the copyright that should /// appear on the copyright page of the publication.</param> /// <param name="sFolder">The name of the CmFolder where picture should be stored</param> /// ------------------------------------------------------------------------------------ private ICmPicture Create(string srcFilename, ITsString captionTss, string description, string sLayoutPos, string sScaleFactor, PictureLocationRangeType locRangeType, int anchorLoc, IPictureLocationBridge locationParser, string sLocationRange, string copyright, string sFolder) { int locationMin, locationMax; if (locationParser != null) { locationParser.ParsePictureLoc(sLocationRange, anchorLoc, ref locRangeType, out locationMin, out locationMax); } else { ParsePictureLoc(sLocationRange, ref locRangeType, out locationMin, out locationMax); } return Create(srcFilename, captionTss, description, ParseLayoutPosition(sLayoutPos), ParseScaleFactor(sScaleFactor), locRangeType, locationMin, locationMax, copyright, sFolder, m_cache.DefaultVernWs); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a new picture, given string representations of most of the parameters. Used /// for creating a picture from a USFM-style Standard Format import. /// </summary> /// <param name="sFolder">The name of the CmFolder where picture should be stored</param> /// <param name="anchorLoc">The anchor location that can be used to determine (may be 0).</param> /// <param name="locationParser">The location parser.</param> /// <param name="sDescription">Illustration description in English.</param> /// <param name="srcFilename">The picture filename.</param> /// <param name="sLayoutPos">The layout position (as a string).</param> /// <param name="sLocationRange">The location range (as a string).</param> /// <param name="sCopyright">The copyright.</param> /// <param name="sCaption">The caption, in the default vernacular writing system.</param> /// <param name="locRangeType">Assumed type of the location range.</param> /// <param name="sScaleFactor">The scale factor (as a string).</param> /// ------------------------------------------------------------------------------------ public ICmPicture Create(string sFolder, int anchorLoc, IPictureLocationBridge locationParser, string sDescription, string srcFilename, string sLayoutPos, string sLocationRange, string sCopyright, string sCaption, PictureLocationRangeType locRangeType, string sScaleFactor) { return Create(srcFilename, m_cache.TsStrFactory.MakeString(sCaption, m_cache.DefaultVernWs), sDescription, sLayoutPos, sScaleFactor, locRangeType, anchorLoc, locationParser, sLocationRange, sCopyright, sFolder); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a new picture, given string representations of most of the parameters. Used /// for creating a picture from a Toolbox-style Standard Format import. /// </summary> /// <param name="sFolder">The name of the CmFolder where picture should be stored</param> /// <param name="anchorLoc">The anchor location that the locationParser can use if /// necessary (can be 0).</param> /// <param name="locationParser">The location parser.</param> /// <param name="descriptions">The descriptions in 0 or more writing systems.</param> /// <param name="srcFilename">The picture filename.</param> /// <param name="sLayoutPos">The layout position (as a string).</param> /// <param name="sLocationRange">The location range (as a string).</param> /// <param name="sCopyright">The copyright.</param> /// <param name="tssCaption">The caption, in the default vernacular writing system.</param> /// <param name="locRangeType">Assumed type of the location range.</param> /// <param name="sScaleFactor">The scale factor (as a string).</param> /// ------------------------------------------------------------------------------------ public ICmPicture Create(string sFolder, int anchorLoc, IPictureLocationBridge locationParser, Dictionary<int, string> descriptions, string srcFilename, string sLayoutPos, string sLocationRange, string sCopyright, ITsString tssCaption, PictureLocationRangeType locRangeType, string sScaleFactor) { ICmPicture pic = Create(srcFilename, tssCaption, null, sLayoutPos, sScaleFactor, locRangeType, anchorLoc, locationParser, sLocationRange, sCopyright, sFolder); if (descriptions != null) { foreach (int ws in descriptions.Keys) pic.Description.set_String(ws, descriptions[ws]); } return pic; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a new picture, given a text representation (e.g., from the clipboard). /// NOTE: The caption is put into the default vernacular writing system. /// </summary> /// <param name="sTextRepOfPicture">Clipboard representation of a picture</param> /// <param name="sFolder">The name of the CmFolder where picture should be stored</param> /// <param name="anchorLoc">The anchor location that can be used to determine (may be 0).</param> /// <param name="locationParser">The picture location parser (can be null).</param> /// ------------------------------------------------------------------------------------ public ICmPicture Create(string sTextRepOfPicture, string sFolder, int anchorLoc, IPictureLocationBridge locationParser) { string[] tokens = sTextRepOfPicture.Split('|'); if (!CmPictureServices.ValidTextRepOfPicture(tokens)) throw new ArgumentException("The clipboard format for a Picture was invalid"); string sDescription = tokens[1]; string srcFilename = tokens[2]; string sLayoutPos = tokens[3]; string sLocationRange = tokens[4]; string sCopyright = tokens[5]; string sCaption = tokens[6]; string sLocationRangeType = tokens[7]; string sScaleFactor = tokens[8]; PictureLocationRangeType locRangeType = ParseLocationRangeType(sLocationRangeType); return Create(sFolder, anchorLoc, locationParser, sDescription, srcFilename, sLayoutPos, sLocationRange, sCopyright, sCaption, locRangeType, sScaleFactor); }