Beispiel #1
0
        internal void ArrangeBoxes(FwTextAlign align, int gapLeft, int gapRight, int firstLineIndent, int availWidth, int topDepth)
        {
            int position = 0;

            switch (align)
            {
            case FwTextAlign.ktalJustify:                             // Todo: implement justification; for now, just treat as left aligned.
            case FwTextAlign.ktalLeft:
                position = gapLeft + firstLineIndent;
                break;

            case FwTextAlign.ktalRight:
                // Enhance: adjust by firstLineIndent if direction is RTL.
                position = availWidth - gapRight - WidthOfAllBoxes;
                if (topDepth == 1)
                {
                    position -= firstLineIndent;
                }
                break;

            case FwTextAlign.ktalCenter:
                position = gapLeft + firstLineIndent + (availWidth - gapRight - gapLeft - firstLineIndent - WidthOfAllBoxes) / 2;
                break;
            }
            Height = 0;
            foreach (var box in OrderedBoxes(topDepth))
            {
                box.Top   = Top;               // todo: align baselines
                box.Left  = position;
                position += box.Width;
                Height    = Math.Max(box.Top + box.Height - Top, Height);
            }
            Width = LastBox.Left + LastBox.Width - gapLeft;
        }
Beispiel #2
0
		internal void ArrangeBoxes(FwTextAlign align, int gapLeft, int gapRight, int firstLineIndent, int availWidth, int topDepth)
		{
			int position = 0;
			switch (align)
			{
					case FwTextAlign.ktalJustify: // Todo: implement justification; for now, just treat as left aligned.
				case FwTextAlign.ktalLeft:
					position = gapLeft + firstLineIndent;
					break;
				case FwTextAlign.ktalRight:
					// Enhance: adjust by firstLineIndent if direction is RTL.
					position = availWidth - gapRight - WidthOfAllBoxes;
					if (topDepth == 1)
						position -= firstLineIndent;
					break;
				case FwTextAlign.ktalCenter:
					position = gapLeft + firstLineIndent + (availWidth - gapRight - gapLeft - firstLineIndent - WidthOfAllBoxes)/2;
					break;
			}
			Height = 0;
			foreach (var box in OrderedBoxes(topDepth))
			{
				box.Top = Top; // todo: align baselines
				box.Left = position;
				position += box.Width;
				Height = Math.Max(box.Top + box.Height - Top, Height);
			}
			Width = LastBox.Left + LastBox.Width - gapLeft;
		}
Beispiel #3
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Add a column to the header/footer
 /// </summary>
 /// <param name="vwenv"></param>
 /// <param name="align"></param>
 /// <param name="flid"></param>
 /// ------------------------------------------------------------------------------------
 private void AddColumn(IVwEnv vwenv, FwTextAlign align, PubHeader.PubHeaderTags flid)
 {
     vwenv.OpenTableCell(1, 1);
     if (HeaderFooterParaStyle != null && HeaderFooterParaStyle != string.Empty)
     {
         vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle,
                                  HeaderFooterParaStyle);
     }
     vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
                           (int)FwTextPropVar.ktpvEnum, (int)align);
     vwenv.OpenMappedPara();
     vwenv.AddStringProp((int)flid, this);
     vwenv.CloseParagraph();
     vwenv.CloseTableCell();
 }
Beispiel #4
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Construct a dummy RTF style with everything fully specified.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public DummyRtfStyle(string styleName,
                      StyleType styleType,
                      bool bold,
                      bool italic,
                      FwSuperscriptVal superSub,
                      FwTextAlign paraAlign,
                      int lineSpacing,
                      bool fLineSpacingRelative,
                      int spaceBefore,
                      int spaceAfter,
                      int firstLineIndent,
                      int leadingIndent,
                      int trailingIndent,
                      string fontName, // Pass null to leave as inherited
                      int fontSize,
                      Color fontColor, // Pass Color.Empty to leave as inherited
                      int borderTop,
                      int borderBottom,
                      int borderLeading,
                      int borderTrailing,
                      Color borderColor, // Pass Color.Empty to leave as inherited
                      string basedOnStyleName,
                      string nextStyleName) :
     this(styleName, styleType, spaceBefore, spaceAfter, firstLineIndent, leadingIndent,
          trailingIndent, basedOnStyleName, nextStyleName)
 {
     m_defaultFontInfo.m_bold.ExplicitValue = bold;
     if (fontName != null)
     {
         m_defaultFontInfo.m_fontName.ExplicitValue = fontName;
     }
     if (fontColor != Color.Empty)
     {
         m_defaultFontInfo.m_fontColor.ExplicitValue = fontColor;
     }
     m_defaultFontInfo.m_fontSize.ExplicitValue = fontSize;
     m_defaultFontInfo.m_italic.ExplicitValue   = italic;
     m_defaultFontInfo.m_superSub.ExplicitValue = superSub;
     // TODO(TE-4649): Implement unlerline property for RTF export
     m_defaultFontInfo.m_underline = new InheritableStyleProp <FwUnderlineType>(FwUnderlineType.kuntNone);
     m_alignment.ExplicitValue     = paraAlign;
     m_lineSpacing.ExplicitValue   = new LineHeightInfo(lineSpacing, fLineSpacingRelative);
     m_border.ExplicitValue        = new BorderThicknesses(borderLeading, borderTrailing, borderTop, borderBottom);
     if (borderColor != Color.Empty)
     {
         m_borderColor.ExplicitValue = borderColor;
     }
 }
Beispiel #5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Construct a dummy RTF style with everything fully specified.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public DummyRtfStyle(string styleName,
			StyleType styleType,
			bool bold,
			bool italic,
			FwSuperscriptVal superSub,
			FwTextAlign paraAlign,
			int lineSpacing,
			bool fLineSpacingRelative,
			int spaceBefore,
			int spaceAfter,
			int firstLineIndent,
			int leadingIndent,
			int trailingIndent,
			string fontName, // Pass null to leave as inherited
			int fontSize,
			Color fontColor, // Pass Color.Empty to leave as inherited
			int borderTop,
			int borderBottom,
			int borderLeading,
			int borderTrailing,
			Color borderColor, // Pass Color.Empty to leave as inherited
			string basedOnStyleName,
			string nextStyleName) :
			this(styleName, styleType, spaceBefore, spaceAfter, firstLineIndent, leadingIndent,
				trailingIndent, basedOnStyleName, nextStyleName)
		{
			m_defaultFontInfo.m_bold.ExplicitValue = bold;
			if (fontName != null)
				m_defaultFontInfo.m_fontName.ExplicitValue = fontName;
			if (fontColor != Color.Empty)
				m_defaultFontInfo.m_fontColor.ExplicitValue = fontColor;
			m_defaultFontInfo.m_fontSize.ExplicitValue = fontSize;
			m_defaultFontInfo.m_italic.ExplicitValue = italic;
			m_defaultFontInfo.m_superSub.ExplicitValue = superSub;
			// TODO(TE-4649): Implement unlerline property for RTF export
			m_defaultFontInfo.m_underline = new InheritableStyleProp<FwUnderlineType>(FwUnderlineType.kuntNone);
			m_alignment.ExplicitValue = paraAlign;
			m_lineSpacing.ExplicitValue = new LineHeightInfo(lineSpacing, fLineSpacingRelative);
			m_border.ExplicitValue = new BorderThicknesses(borderLeading, borderTrailing, borderTop, borderBottom);
			if (borderColor != Color.Empty)
				m_borderColor.ExplicitValue = borderColor;
		}
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Saves the paragraph information to the styleInfo
        /// </summary>
        /// <param name="styleInfo">The style info.</param>
        /// ------------------------------------------------------------------------------------
        public void SaveToInfo(StyleInfo styleInfo)
        {
            CheckDisposed();

            if (styleInfo.IsCharacterStyle)
            {
                Debug.Assert(false, "Somehow, the Paragraph tab has been asked to write its data to a character-based style [" + styleInfo.Name + "].");
                return;
            }

            // direction
            bool newInherit = IsInherited(m_cboDirection);

            if (styleInfo.IRightToLeftStyle.Save(newInherit, (TriStateBool)m_cboDirection.SelectedIndex))
            {
                styleInfo.Dirty = true;
            }

            // alignment
            newInherit = m_cboAlignment.IsInherited;
            FwTextAlign newAlignment = FwTextAlign.ktalLeading;

            switch (m_cboAlignment.AdjustedSelectedIndex)
            {
            case 1: newAlignment = FwTextAlign.ktalLeading; break;

            case 2: newAlignment = FwTextAlign.ktalLeft; break;

            case 3: newAlignment = FwTextAlign.ktalCenter; break;

            case 4: newAlignment = FwTextAlign.ktalRight; break;

            case 5: newAlignment = FwTextAlign.ktalTrailing; break;

            case 6: newAlignment = FwTextAlign.ktalJustify; break;
            }
            if (styleInfo.IAlignment.Save(newInherit, newAlignment))
            {
                styleInfo.Dirty = true;
            }

            // background color - only save it if the control is visible
            if (m_cboBackground.Visible)
            {
                newInherit = IsInherited(m_cboBackground);
                FontInfo fontInfo = styleInfo.FontInfoForWs(-1);                 // get default FontInfo
                if (fontInfo.m_backColor.Save(newInherit, m_cboBackground.ColorValue))
                {
                    styleInfo.Dirty = true;
                }
            }

            // left indent
            newInherit = IsInherited(m_nudLeftIndentation);
            if (styleInfo.ILeadingIndent.Save(newInherit, m_nudLeftIndentation.MeasureValue))
            {
                styleInfo.Dirty = true;
            }

            // right indent
            newInherit = IsInherited(m_nudRightIndentation);
            if (styleInfo.ITrailingIndent.Save(newInherit, m_nudRightIndentation.MeasureValue))
            {
                styleInfo.Dirty = true;
            }

            // special indent
            newInherit = m_cboSpecialIndentation.IsInherited;
            int newValue = 0;

            switch (m_cboSpecialIndentation.AdjustedSelectedIndex)
            {
            case 2: newValue = m_nudIndentBy.MeasureValue; break;

            case 3: newValue = -m_nudIndentBy.MeasureValue; break;
            }
            if (styleInfo.IFirstLineIndent.Save(newInherit, newValue))
            {
                styleInfo.Dirty = true;
            }

            // spacing before
            newInherit = IsInherited(m_nudBefore);
            if (styleInfo.ISpaceBefore.Save(newInherit, m_nudBefore.MeasureValue))
            {
                styleInfo.Dirty = true;
            }

            // spacing after
            newInherit = IsInherited(m_nudAfter);
            if (styleInfo.ISpaceAfter.Save(newInherit, m_nudAfter.MeasureValue))
            {
                styleInfo.Dirty = true;
            }

            // line spacing
            int index = m_cboLineSpacing.AdjustedSelectedIndex;

            newInherit = m_cboLineSpacing.IsInherited;
            LineHeightInfo newLineHeight = new LineHeightInfo();

            newLineHeight.m_relative = (index <= 3);
            switch (index)
            {
            case 1:                      // single spacing
                newLineHeight.m_lineHeight = 10000; break;

            case 2:                     // 1.5 spacing
                newLineHeight.m_lineHeight = 15000; break;

            case 3:                     // double spacing
                newLineHeight.m_lineHeight = 20000; break;

            case kAtLeastIndex:                     // at least
                newLineHeight.m_lineHeight = m_nudSpacingAt.MeasureValue; break;

            case kExactlyIndex:                     // exactly
                newLineHeight.m_lineHeight = -m_nudSpacingAt.MeasureValue; break;
            }
            if (styleInfo.ILineSpacing.Save(newInherit, newLineHeight))
            {
                styleInfo.Dirty = true;
            }
        }
Beispiel #7
0
		/// <summary>
		/// Intended for use only by AssembledStylesCache to make derived styles.
		/// If inheritedOnly is true, only those properties are copied which should be inherited by
		/// nested boxes.
		/// </summary>
		internal AssembledStyles(AssembledStyles basedOn, bool inheritedOnly)
		{
			m_styleCache = basedOn.m_styleCache; // all derived styles share it
			m_chrp = basedOn.m_chrp;
			m_lineHeight = basedOn.m_lineHeight;
			m_firstLineIndent = basedOn.m_firstLineIndent;
			m_styleName = basedOn.m_styleName;
			RightToLeft = basedOn.RightToLeft;
			if (inheritedOnly)
			{
				SetNonInheritedDefaults();
			}
			else
			{
				// copy everything else, too.
				m_paraAlignment = basedOn.m_paraAlignment;
				m_borderColor = basedOn.m_borderColor;
				m_borders = basedOn.m_borders;
				m_margins = basedOn.m_margins;
				m_pads = basedOn.m_pads;
				m_weight = basedOn.m_weight;
			}
		}
Beispiel #8
0
		public AssembledStyles WithParaAlignment(FwTextAlign alignment)
		{
			return m_styleCache.GetDerivedStyle(this, (int)FwTextPropType.ktptAlign, alignment, (newStyles, w) => newStyles.m_paraAlignment = alignment);
		}
Beispiel #9
0
		private void ApplyParagraphStyleInfo(IParaStyleInfo paraInfo)
		{
			if(paraInfo == null)
				return;

			if(paraInfo.Alignment != null && paraInfo.Alignment.ValueIsSet)
				m_paraAlignment = paraInfo.Alignment.Value;
			if (paraInfo.LineHeight != null && paraInfo.LineHeight.ValueIsSet)
				m_lineHeight = paraInfo.LineHeight.Value.m_lineHeight;
			if (paraInfo.FirstLineIndent != null && paraInfo.FirstLineIndent.ValueIsSet)
				m_firstLineIndent = paraInfo.FirstLineIndent.Value;

			int borderLeading = 0;
			int borderTop = 0;
			int borderTrailing = 0;
			int borderBottom = 0;
			if(paraInfo.BorderColor != null && paraInfo.BorderColor.ValueIsSet)
				m_borderColor = paraInfo.BorderColor.Value;
			if (paraInfo.BorderLeading != null && paraInfo.BorderLeading.ValueIsSet)
				borderLeading = paraInfo.BorderLeading.Value;
			if (paraInfo.BorderTop != null && paraInfo.BorderTop.ValueIsSet)
				borderTop = paraInfo.BorderTop.Value;
			if (paraInfo.BorderTrailing != null && paraInfo.BorderTrailing.ValueIsSet)
				borderTrailing = paraInfo.BorderTrailing.Value;
			if (paraInfo.BorderBottom != null && paraInfo.BorderBottom.ValueIsSet)
				borderBottom = paraInfo.BorderBottom.Value;
			m_borders = new Thickness(borderLeading, borderTop, borderTrailing, borderBottom);

			int marginLeading = 0;
			int marginTop = 0;
			int marginTrailing = 0;
			int marginBottom = 0;
			if (paraInfo.MarginLeading != null && paraInfo.MarginLeading.ValueIsSet)
				marginLeading = paraInfo.MarginLeading.Value;
			if (paraInfo.MarginTop != null && paraInfo.MarginTop.ValueIsSet)
				marginTop = paraInfo.MarginTop.Value;
			if (paraInfo.MarginTrailing != null && paraInfo.MarginTrailing.ValueIsSet)
				marginTrailing = paraInfo.MarginTrailing.Value;
			if (paraInfo.MarginBottom != null && paraInfo.MarginBottom.ValueIsSet)
				marginBottom = paraInfo.MarginBottom.Value;
			m_margins = new Thickness(marginLeading, marginTop, marginTrailing, marginBottom);

			int padLeading = 0;
			int padTop = 0;
			int padTrailing = 0;
			int padBottom = 0;
			if (paraInfo.PadLeading != null && paraInfo.PadLeading.ValueIsSet)
				padLeading = paraInfo.PadLeading.Value;
			if (paraInfo.PadTop != null && paraInfo.PadTop.ValueIsSet)
				padTop = paraInfo.PadTop.Value;
			if (paraInfo.PadTrailing != null && paraInfo.PadTrailing.ValueIsSet)
				padTrailing = paraInfo.PadTrailing.Value;
			if (paraInfo.PadBottom != null && paraInfo.PadBottom.ValueIsSet)
				padBottom = paraInfo.PadBottom.Value;
			m_pads = new Thickness(padLeading, padTop, padTrailing, padBottom);
		}
Beispiel #10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Add a column to the header/footer
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="align"></param>
		/// <param name="flid"></param>
		/// ------------------------------------------------------------------------------------
		private void AddColumn(IVwEnv vwenv, FwTextAlign align, PubHeader.PubHeaderTags flid)
		{
			vwenv.OpenTableCell(1, 1);
			if (HeaderFooterParaStyle != null && HeaderFooterParaStyle != string.Empty)
			{
				vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle,
					HeaderFooterParaStyle);
			}
			vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
				(int)FwTextPropVar.ktpvEnum, (int)align);
			vwenv.OpenMappedPara();
			vwenv.AddStringProp((int)flid, this);
			vwenv.CloseParagraph();
			vwenv.CloseTableCell();
		}