예제 #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Parses the picture location range string.
        /// </summary>
        /// <param name="s">The string representation of the picture location range.</param>
        /// <param name="anchorLocation">The anchor location.</param>
        /// <param name="locType">The type of the location range. The incoming value tells us
        /// the assumed type for parsing. The out value can be set to a different type if we
        /// discover that the actual value is another type.</param>
        /// <param name="locationMin">The location min.</param>
        /// <param name="locationMax">The location max.</param>
        /// ------------------------------------------------------------------------------------
        public void ParsePictureLoc(string s, int anchorLocation,
                                    ref PictureLocationRangeType locType, out int locationMin, out int locationMax)
        {
            locationMin = locationMax = 0;
            switch (locType)
            {
            case PictureLocationRangeType.AfterAnchor:
                return;

            case PictureLocationRangeType.ReferenceRange:
                throw new NotSupportedException("CmPicture cannot parse Scripture references. Use another implementation of IPictureLocationParser.");

            case PictureLocationRangeType.ParagraphRange:
                if (String.IsNullOrEmpty(s))
                {
                    locType = PictureLocationRangeType.AfterAnchor;
                    return;
                }
                string[] pieces = s.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
                if (pieces.Length == 2)
                {
                    if (Int32.TryParse(pieces[0], out locationMin))
                    {
                        if (Int32.TryParse(pieces[1], out locationMax))
                        {
                            return;
                        }
                    }
                }
                locType = PictureLocationRangeType.AfterAnchor;
                return;
            }
        }
예제 #2
0
 /// ------------------------------------------------------------------------------------
 /// <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="layoutPos">Indication of where in the column/page the picture is to be
 /// laid out.</param>
 /// <param name="scaleFactor">Integral percentage by which picture is grown or shrunk.</param>
 /// <param name="locationRangeType">Indicates the type of data contained in LocationMin
 /// and LocationMax.</param>
 /// <param name="locationMin">The minimum Scripture reference at which this picture can
 /// be laid out.</param>
 /// <param name="locationMax">The maximum Scripture reference at which this picture can
 /// be laid out.</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 void InitializeNewPicture(string srcFilename, ITsString captionTss,
                                   string description, PictureLayoutPosition layoutPos, int scaleFactor,
                                   PictureLocationRangeType locationRangeType, int locationMin, int locationMax,
                                   string copyright, string sFolder)
 {
     InitializeNewPicture(srcFilename, captionTss, description, layoutPos, scaleFactor,
                          locationRangeType, locationMin, locationMax, copyright, sFolder,
                          m_cache.DefaultVernWs);
 }
예제 #3
0
 /// ------------------------------------------------------------------------------------
 /// <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);
 }
예제 #4
0
        /// ------------------------------------------------------------------------------------
        /// <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);
        }
예제 #5
0
 /// ------------------------------------------------------------------------------------
 /// <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);
         }
     }
 }
예제 #6
0
        /// ------------------------------------------------------------------------------------
        /// <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);
        }
예제 #7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initialize a new CmPicture by creating a copy of the file in the given folder and
        /// hooking everything up.
        /// </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 given Writing System)</param>
        /// <param name="description">Illustration description in English. This is not
        /// published.</param>
        /// <param name="layoutPos">Indication of where in the column/page the picture is to be
        /// laid out.</param>
        /// <param name="scaleFactor">Integral percentage by which picture is grown or shrunk.</param>
        /// <param name="locationRangeType">Indicates the type of data contained in LocationMin
        /// and LocationMax.</param>
        /// <param name="locationMin">The minimum Scripture reference at which this picture can
        /// be laid out.</param>
        /// <param name="locationMax">The maximum Scripture reference at which this picture can
        /// be laid out.</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>
        /// <param name="ws">The WS of the caption and copyright</param>
        /// ------------------------------------------------------------------------------------
        public void InitializeNewPicture(string srcFilename, ITsString captionTss,
                                         string description, PictureLayoutPosition layoutPos, int scaleFactor,
                                         PictureLocationRangeType locationRangeType, int locationMin, int locationMax,
                                         string copyright, string sFolder, int ws)
        {
            // Set the caption first since creating the CmFile will throw if srcFilename is empty.
            if (captionTss != null)
            {
                Caption.SetAlternative(captionTss, ws);
            }
            // Locate CmFolder with given name or create it, if neccessary
            ICmFolder folder = CmFolder.FindOrCreateFolder(m_cache, (int)LangProject.LangProjectTags.kflidPictures, sFolder);

            PictureFileRA = CmFile.FindOrCreateFile(folder, srcFilename);
            int wsEn = Cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr("en");

            if (!String.IsNullOrEmpty(description) && wsEn > 0)
            {
                Description.SetAlternative(description, wsEn);
            }
            LayoutPos         = layoutPos;
            ScaleFactor       = scaleFactor;
            LocationRangeType = locationRangeType;
            LocationMin       = locationMin;
            LocationMax       = locationMax;
            if (!string.IsNullOrEmpty(copyright))
            {
                string sExistingCopyright = PictureFileRA.Copyright.GetAlternative(ws).Text;
                if (sExistingCopyright != null && sExistingCopyright != copyright)
                {
                    Logger.WriteEvent("Could not update copyright for picture " +
                                      PictureFileRA.AbsoluteInternalPath + " to '" + copyright + "'");
                    return;
                }
                PictureFileRA.Copyright.SetAlternative(copyright, ws);
            }
        }
예제 #8
0
        /// ------------------------------------------------------------------------------------
        /// <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);
        }
예제 #9
0
		/// ------------------------------------------------------------------------------------
		/// <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);
			}
		}
예제 #10
0
		/// ------------------------------------------------------------------------------------
		/// <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);
		}
예제 #11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Parses the picture location range string.
		/// </summary>
		/// <param name="s">The string representation of the picture location range.</param>
		/// <param name="locType">The type of the location range. The incoming value tells us
		/// the assumed type for parsing. The out value can be set to a different type if we
		/// discover that the actual value is another type.</param>
		/// <param name="locationMin">The location min.</param>
		/// <param name="locationMax">The location max.</param>
		/// ------------------------------------------------------------------------------------
		private static void ParsePictureLoc(string s, ref PictureLocationRangeType locType,
			out int locationMin, out int locationMax)
		{
			locationMin = locationMax = 0;
			switch (locType)
			{
				case PictureLocationRangeType.AfterAnchor:
					return;
				case PictureLocationRangeType.ReferenceRange:
					// Range is generated internally in the form BCCCVVV-BCCCVVV
					int index = s.IndexOf('-');
					if (s.Length <= 15 && index > 0 &&
						Int32.TryParse(s.Substring(0, index), out locationMin) &&
						Int32.TryParse(s.Substring(index + 1), out locationMax))
					{
						// sucessful parse!
						return;
					}
					locationMin = locationMax = 0;
					locType = PictureLocationRangeType.AfterAnchor;
					return;
				case PictureLocationRangeType.ParagraphRange:
					if (String.IsNullOrEmpty(s))
					{
						locType = PictureLocationRangeType.AfterAnchor;
						return;
					}
					string[] pieces = s.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
					if (pieces.Length == 2)
					{
						if (Int32.TryParse(pieces[0], out locationMin))
							if (Int32.TryParse(pieces[1], out locationMax))
								return;
					}
					locType = PictureLocationRangeType.AfterAnchor;
					return;
			}
		}
예제 #12
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initialize a new CmPicture by creating a copy of the file in the given folder and
		/// hooking everything up.
		/// </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 given Writing System)</param>
		/// <param name="description">Illustration description in English. This is not
		/// published.</param>
		/// <param name="layoutPos">Indication of where in the column/page the picture is to be
		/// laid out.</param>
		/// <param name="scaleFactor">Integral percentage by which picture is grown or shrunk.</param>
		/// <param name="locationRangeType">Indicates the type of data contained in LocationMin
		/// and LocationMax.</param>
		/// <param name="locationMin">The minimum Scripture reference at which this picture can
		/// be laid out.</param>
		/// <param name="locationMax">The maximum Scripture reference at which this picture can
		/// be laid out.</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>
		/// <param name="ws">The WS of the caption and copyright</param>
		/// ------------------------------------------------------------------------------------
		private ICmPicture Create(string srcFilename, ITsString captionTss, string description,
			PictureLayoutPosition layoutPos, int scaleFactor,
			PictureLocationRangeType locationRangeType, int locationMin, int locationMax,
			string copyright, string sFolder, int ws)
		{
			ICmPicture pic = Create();
			pic.UpdatePicture(srcFilename, captionTss, sFolder, ws);
			int wsEn = m_cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr("en");
			if (!String.IsNullOrEmpty(description) && wsEn > 0)
				pic.Description.set_String(wsEn, description);
			pic.LayoutPos = layoutPos;
			pic.ScaleFactor = scaleFactor;
			pic.LocationRangeType = locationRangeType;
			pic.LocationMin = locationMin;
			pic.LocationMax = locationMax;
			if (!string.IsNullOrEmpty(copyright))
				pic.PictureFileRA.Copyright.set_String(ws, copyright);
			return pic;
		}
예제 #13
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Parses the picture location range string.
		/// </summary>
		/// <param name="s">The string representation of the picture location range.</param>
		/// <param name="anchorLocation">The anchor location.</param>
		/// <param name="locType">The type of the location range. The incoming value tells us
		/// the assumed type for parsing. The out value can be set to a different type if we
		/// discover that the actual value is another type.</param>
		/// <param name="locationMin">The location min.</param>
		/// <param name="locationMax">The location max.</param>
		/// ------------------------------------------------------------------------------------
		public void ParsePictureLoc(string s, int anchorLocation,
			ref PictureLocationRangeType locType, out int locationMin, out int locationMax)
		{
			locationMin = locationMax = 0;
			switch (locType)
			{
				case PictureLocationRangeType.AfterAnchor:
					return;
				case PictureLocationRangeType.ReferenceRange:
					throw new NotSupportedException("CmPicture cannot parse Scripture references. Use another implementation of IPictureLocationParser.");
				case PictureLocationRangeType.ParagraphRange:
					if (String.IsNullOrEmpty(s))
					{
						locType = PictureLocationRangeType.AfterAnchor;
						return;
					}
					string[] pieces = s.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
					if (pieces.Length == 2)
					{
						if (Int32.TryParse(pieces[0], out locationMin))
							if (Int32.TryParse(pieces[1], out locationMax))
								return;
					}
					locType = PictureLocationRangeType.AfterAnchor;
					return;
			}
		}
예제 #14
0
		/// ------------------------------------------------------------------------------------
		/// <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="layoutPos">Indication of where in the column/page the picture is to be
		/// laid out.</param>
		/// <param name="scaleFactor">Integral percentage by which picture is grown or shrunk.</param>
		/// <param name="locationRangeType">Indicates the type of data contained in LocationMin
		/// and LocationMax.</param>
		/// <param name="locationMin">The minimum Scripture reference at which this picture can
		/// be laid out.</param>
		/// <param name="locationMax">The maximum Scripture reference at which this picture can
		/// be laid out.</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 void InitializeNewPicture(string srcFilename, ITsString captionTss,
			string description, PictureLayoutPosition layoutPos, int scaleFactor,
			PictureLocationRangeType locationRangeType, int locationMin, int locationMax,
			string copyright, string sFolder)
		{
			InitializeNewPicture(srcFilename, captionTss, description, layoutPos, scaleFactor,
				locationRangeType, locationMin, locationMax, copyright, sFolder,
				m_cache.DefaultVernWs);
		}
예제 #15
0
		/// ------------------------------------------------------------------------------------
		/// <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);
		}
예제 #16
0
		/// ------------------------------------------------------------------------------------
		/// <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);
		}
예제 #17
0
		/// ------------------------------------------------------------------------------------
		/// <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;
		}
예제 #18
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initialize a new CmPicture by creating a copy of the file in the given folder and
		/// hooking everything up.
		/// </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 given Writing System)</param>
		/// <param name="description">Illustration description in English. This is not
		/// published.</param>
		/// <param name="layoutPos">Indication of where in the column/page the picture is to be
		/// laid out.</param>
		/// <param name="scaleFactor">Integral percentage by which picture is grown or shrunk.</param>
		/// <param name="locationRangeType">Indicates the type of data contained in LocationMin
		/// and LocationMax.</param>
		/// <param name="locationMin">The minimum Scripture reference at which this picture can
		/// be laid out.</param>
		/// <param name="locationMax">The maximum Scripture reference at which this picture can
		/// be laid out.</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>
		/// <param name="ws">The WS of the caption and copyright</param>
		/// ------------------------------------------------------------------------------------
		public void InitializeNewPicture(string srcFilename, ITsString captionTss,
			string description, PictureLayoutPosition layoutPos, int scaleFactor,
			PictureLocationRangeType locationRangeType, int locationMin, int locationMax,
			string copyright, string sFolder, int ws)
		{
			// Set the caption first since creating the CmFile will throw if srcFilename is empty.
			if (captionTss != null)
				Caption.SetAlternative(captionTss, ws);
			// Locate CmFolder with given name or create it, if neccessary
			ICmFolder folder = CmFolder.FindOrCreateFolder(m_cache, (int)LangProject.LangProjectTags.kflidPictures, sFolder);
			PictureFileRA = CmFile.FindOrCreateFile(folder, srcFilename);
			int wsEn = Cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr("en");
			if (!String.IsNullOrEmpty(description) && wsEn > 0)
				Description.SetAlternative(description, wsEn);
			LayoutPos = layoutPos;
			ScaleFactor = scaleFactor;
			LocationRangeType = locationRangeType;
			LocationMin = locationMin;
			LocationMax = locationMax;
			if (!string.IsNullOrEmpty(copyright))
			{
				string sExistingCopyright = PictureFileRA.Copyright.GetAlternative(ws).Text;
				if (sExistingCopyright != null && sExistingCopyright != copyright)
				{
					Logger.WriteEvent("Could not update copyright for picture " +
						PictureFileRA.AbsoluteInternalPath + " to '" + copyright + "'");
					return;
				}
				PictureFileRA.Copyright.SetAlternative(copyright, ws);
			}
		}
예제 #19
0
		/// ------------------------------------------------------------------------------------
		/// <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);
		}
예제 #20
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Parses a picture location range string.
		/// </summary>
		/// <param name="s">The string representation of a picture location range.</param>
		/// <param name="anchorLocation">The anchor location.</param>
		/// <param name="locType">The type of the location range. The incoming value tells us
		/// the assumed type for parsing. The out value can be set to a different type if we
		/// discover that the actual value is another type.</param>
		/// <param name="locationMin">The location min.</param>
		/// <param name="locationMax">The location max.</param>
		/// <remarks>This is implemented on Scripture because CmPicture's implementation does
		/// not handle Scripture reference ranges.</remarks>
		/// ------------------------------------------------------------------------------------
		public void ParsePictureLoc(string s, int anchorLocation,
			ref PictureLocationRangeType locType, out int locationMin, out int locationMax)
		{
			locationMin = locationMax = 0;
			if (BCVRef.GetChapterFromBcv(anchorLocation) == 1 &&
				BCVRef.GetVerseFromBcv(anchorLocation) == 0)
			{
				string[] pieces = s.Split(new char[] { '-' }, 2,
					StringSplitOptions.RemoveEmptyEntries);

				if (pieces.Length == 2 &&
					Int32.TryParse(pieces[0], out locationMin) &&
					Int32.TryParse(pieces[1], out locationMax))
				{
					locType = PictureLocationRangeType.ParagraphRange;
					return;
				}
				locType = PictureLocationRangeType.AfterAnchor;
				return;
			}
			BCVRef startRef = new BCVRef(anchorLocation);
			BCVRef endRef = new BCVRef(anchorLocation);
			if (ScrReference.ParseRefRange(s, ref startRef, ref endRef, Versification) &&
				startRef <= anchorLocation && endRef >= anchorLocation)
			{
				locationMin = startRef.BBCCCVVV;
				locationMax = endRef.BBCCCVVV;
				locType = PictureLocationRangeType.ReferenceRange;
			}
			else
				locType = PictureLocationRangeType.AfterAnchor;
		}
예제 #21
0
		/// ------------------------------------------------------------------------------------
		/// <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);
		}